Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v1.724.0 #8406

Merged
merged 17 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.base
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ REACT_APP_FEATURE_FOX_PAGE_GOVERNANCE=true
REACT_APP_FEATURE_PHANTOM_WALLET=true
REACT_APP_FEATURE_THOR_FREE_FEES=true
REACT_APP_FEATURE_LIMIT_ORDERS=false
REACT_APP_FEATURE_NEW_TRADE_FLOW=false

# absolute URL prefix
REACT_APP_ABSOLUTE_URL_PREFIX=https://app.shapeshift.com
Expand Down
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ REACT_APP_FEATURE_SWAPPER_SOLANA=true
REACT_APP_FEATURE_CHAINFLIP_SWAP_DCA=true
REACT_APP_FEATURE_LIMIT_ORDERS=true
REACT_APP_FEATURE_JUPITER_SWAP=true
REACT_APP_FEATURE_NEW_TRADE_FLOW=true

# logging
REACT_APP_REDUX_WINDOW=false
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ASSET_NAMESPACE,
CHAIN_NAMESPACE,
CHAIN_REFERENCE,
fromAssetId,
solAssetId,
toAssetId,
wrappedSolAssetId,
Expand All @@ -12,6 +13,7 @@ import type { KnownChainIds } from '@shapeshiftoss/types'
import { bn, bnOrZero, convertDecimalPercentageToBasisPoints } from '@shapeshiftoss/utils'
import type { Result } from '@sniptt/monads'
import { Err, Ok } from '@sniptt/monads'
import { PublicKey } from '@solana/web3.js'
import { v4 as uuid } from 'uuid'

import type {
Expand All @@ -23,7 +25,7 @@ import type {
} from '../../../types'
import { SwapperName, TradeQuoteError } from '../../../types'
import { getInputOutputRate, makeSwapErrorRight } from '../../../utils'
import { JUPITER_COMPUTE_UNIT_MARGIN_MULTIPLIER } from '../utils/constants'
import { JUPITER_COMPUTE_UNIT_MARGIN_MULTIPLIER, TOKEN_2022_PROGRAM_ID } from '../utils/constants'
import {
calculateAccountCreationCosts,
createSwapInstructions,
Expand All @@ -38,7 +40,7 @@ export const getTradeQuote = async (
const {
sellAsset,
buyAsset,
affiliateBps,
affiliateBps: _affiliateBps,
receiveAddress,
accountNumber,
sendAddress,
Expand Down Expand Up @@ -99,10 +101,31 @@ export const getTradeQuote = async (
)
}

const adapter = deps.assertGetSolanaChainAdapter(sellAsset.chainId)

const buyAssetAddress =
buyAsset.assetId === solAssetId
? fromAssetId(wrappedSolAssetId).assetReference
: fromAssetId(buyAsset.assetId).assetReference

const sellAssetAddress =
sellAsset.assetId === solAssetId
? fromAssetId(wrappedSolAssetId).assetReference
: fromAssetId(sellAsset.assetId).assetReference

const sellTokenInfo = await adapter
.getConnection()
.getAccountInfo(new PublicKey(sellAssetAddress))
const buyTokenInfo = await adapter.getConnection().getAccountInfo(new PublicKey(buyAssetAddress))
const isSellTokenToken2022 = sellTokenInfo?.owner.toString() === TOKEN_2022_PROGRAM_ID.toString()
const isBuyTokenToken2022 = buyTokenInfo?.owner.toString() === TOKEN_2022_PROGRAM_ID.toString()

const affiliateBps = isSellTokenToken2022 && isBuyTokenToken2022 ? '0' : _affiliateBps

const maybePriceResponse = await getJupiterPrice({
apiUrl: jupiterUrl,
sourceAsset: sellAsset.assetId === solAssetId ? wrappedSolAssetId : sellAsset.assetId,
destinationAsset: buyAsset.assetId === solAssetId ? wrappedSolAssetId : buyAsset.assetId,
sourceAssetAddress: sellAssetAddress,
destinationAssetAddress: buyAssetAddress,
commissionBps: affiliateBps,
amount: sellAmount,
slippageBps: _slippageTolerancePercentageDecimal
Expand All @@ -126,8 +149,6 @@ export const getTradeQuote = async (
// e.g for 0.5% bps, Jupiter represents this as 50. 50/100 = 0.5, then we div by 100 again to honour our decimal format e.g 0.5/100 = 0.005
bn(priceResponse.slippageBps).div(100).div(100).toString()

const adapter = deps.assertGetSolanaChainAdapter(sellAsset.chainId)

const { instructions, addressLookupTableAddresses } = await createSwapInstructions({
priceResponse,
sendAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { KnownChainIds } from '@shapeshiftoss/types'
import { bn, bnOrZero, convertDecimalPercentageToBasisPoints } from '@shapeshiftoss/utils'
import type { Result } from '@sniptt/monads'
import { Err, Ok } from '@sniptt/monads'
import { PublicKey } from '@solana/web3.js'
import { v4 as uuid } from 'uuid'

import type {
Expand All @@ -24,7 +25,7 @@ import type {
} from '../../../types'
import { SwapperName, TradeQuoteError } from '../../../types'
import { getInputOutputRate, makeSwapErrorRight } from '../../../utils'
import { SOLANA_RANDOM_ADDRESS } from '../utils/constants'
import { SOLANA_RANDOM_ADDRESS, TOKEN_2022_PROGRAM_ID } from '../utils/constants'
import {
calculateAccountCreationCosts,
createSwapInstructions,
Expand All @@ -40,7 +41,7 @@ export const getTradeRate = async (
sellAsset,
buyAsset,
sellAmountIncludingProtocolFeesCryptoBaseUnit: sellAmount,
affiliateBps,
affiliateBps: _affiliateBps,
receiveAddress,
accountNumber,
slippageTolerancePercentageDecimal: _slippageTolerancePercentageDecimal,
Expand Down Expand Up @@ -90,10 +91,31 @@ export const getTradeRate = async (
)
}

const adapter = deps.assertGetSolanaChainAdapter(sellAsset.chainId)

const buyAssetAddress =
buyAsset.assetId === solAssetId
? fromAssetId(wrappedSolAssetId).assetReference
: fromAssetId(buyAsset.assetId).assetReference

const sellAssetAddress =
sellAsset.assetId === solAssetId
? fromAssetId(wrappedSolAssetId).assetReference
: fromAssetId(sellAsset.assetId).assetReference

const sellTokenInfo = await adapter
.getConnection()
.getAccountInfo(new PublicKey(sellAssetAddress))
const buyTokenInfo = await adapter.getConnection().getAccountInfo(new PublicKey(buyAssetAddress))
const isSellTokenToken2022 = sellTokenInfo?.owner.toString() === TOKEN_2022_PROGRAM_ID.toString()
const isBuyTokenToken2022 = buyTokenInfo?.owner.toString() === TOKEN_2022_PROGRAM_ID.toString()

const affiliateBps = isSellTokenToken2022 && isBuyTokenToken2022 ? '0' : _affiliateBps

const maybePriceResponse = await getJupiterPrice({
apiUrl: jupiterUrl,
sourceAsset: sellAsset.assetId === solAssetId ? wrappedSolAssetId : sellAsset.assetId,
destinationAsset: buyAsset.assetId === solAssetId ? wrappedSolAssetId : buyAsset.assetId,
sourceAssetAddress: sellAssetAddress,
destinationAssetAddress: buyAssetAddress,
commissionBps: affiliateBps,
amount: sellAmount,
slippageBps: _slippageTolerancePercentageDecimal
Expand Down Expand Up @@ -130,8 +152,6 @@ export const getTradeRate = async (
return { networkFeeCryptoBaseUnit: fast.txFee }
}

const adapter = deps.assertGetSolanaChainAdapter(sellAsset.chainId)

const protocolFees: Record<AssetId, ProtocolFee> = priceResponse.routePlan.reduce(
(acc, route) => {
const feeAssetId = toAssetId({
Expand Down
12 changes: 6 additions & 6 deletions packages/swapper/src/swappers/JupiterSwapper/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const JUPITER_TRANSACTION_MAX_ACCOUNTS = 54

type GetJupiterQuoteArgs = {
apiUrl: string
sourceAsset: string
destinationAsset: string
sourceAssetAddress: string
destinationAssetAddress: string
commissionBps: string
amount: string
slippageBps: string | undefined
Expand Down Expand Up @@ -60,16 +60,16 @@ type CreateInstructionsParams = {

export const getJupiterPrice = ({
apiUrl,
sourceAsset,
destinationAsset,
sourceAssetAddress,
destinationAssetAddress,
commissionBps,
amount,
slippageBps,
}: GetJupiterQuoteArgs): Promise<Result<AxiosResponse<QuoteResponse, any>, SwapErrorRight>> =>
jupiterService.get<QuoteResponse>(
`${apiUrl}/quote` +
`?inputMint=${fromAssetId(sourceAsset).assetReference}` +
`&outputMint=${fromAssetId(destinationAsset).assetReference}` +
`?inputMint=${sourceAssetAddress}` +
`&outputMint=${destinationAssetAddress}` +
`&amount=${amount}` +
(slippageBps ? `&slippageBps=${slippageBps}` : `&autoSlippage=true`) +
`&maxAccounts=${JUPITER_TRANSACTION_MAX_ACCOUNTS}` +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PERMIT2_CONTRACT } from '@shapeshiftoss/contracts'
import type { AssetsByIdPartial } from '@shapeshiftoss/types'
import type { Result } from '@sniptt/monads'
import { Err, Ok } from '@sniptt/monads'
Expand All @@ -11,6 +12,7 @@ import type {
TradeRate,
} from '../../../types'
import { SwapperName } from '../../../types'
import { isNativeEvmAsset } from '../../utils/helpers/helpers'
import { fetchZrxPrice } from '../utils/fetchFromZrx'
import {
assertValidTrade,
Expand Down Expand Up @@ -79,6 +81,7 @@ export async function getZrxTradeRate(
steps: [
{
estimatedExecutionTimeMs: undefined,
allowanceContract: isNativeEvmAsset(sellAsset.assetId) ? undefined : PERMIT2_CONTRACT,
buyAsset,
sellAsset,
accountNumber,
Expand Down
Loading
Loading