diff --git a/src/containers/NewPositionWrapper/NewPositionWrapper.tsx b/src/containers/NewPositionWrapper/NewPositionWrapper.tsx index 7024b7703..8f398f2bc 100644 --- a/src/containers/NewPositionWrapper/NewPositionWrapper.tsx +++ b/src/containers/NewPositionWrapper/NewPositionWrapper.tsx @@ -23,12 +23,7 @@ import { getLiquidityByX, getLiquidityByY } from '@invariant-labs/sdk/src/math' import { Decimal } from '@invariant-labs/sdk/lib/market' import { initPosition, plotTicks } from '@selectors/positions' import { BN } from '@project-serum/anchor' -import { - ALL_FEE_TIERS_DATA, - bestTiers, - commonTokensForNetworks, - getNewPositionUIFeeTiers -} from '@consts/static' +import { ALL_FEE_TIERS_DATA, bestTiers, commonTokensForNetworks } from '@consts/static' import { Status } from '@reducers/solanaWallet' import { ProgressState } from '@components/AnimatedButton/AnimatedButton' import { TickPlotPositionData } from '@components/PriceRangePlot/PriceRangePlot' @@ -128,21 +123,8 @@ export const NewPositionWrapper = () => { return 0 }, [tokenAIndex, tokenBIndex]) - const currentUiTiers = useMemo( - () => - getNewPositionUIFeeTiers( - tokenAIndex === null ? null : tokens[tokenAIndex].assetAddress, - tokenBIndex === null ? null : tokens[tokenBIndex].assetAddress - ), - [tokenAIndex, tokenBIndex] - ) - const [feeIndex, setFeeIndex] = useState(0) - const currentUiFeeIndex = useMemo(() => { - const index = currentUiTiers.findIndex(t => t.primaryIndex === feeIndex) - return index === -1 ? 0 : index - }, [currentUiTiers, feeIndex]) const fee = useMemo(() => ALL_FEE_TIERS_DATA[feeIndex].tier.fee, [feeIndex]) const tickSpacing = useMemo( () => @@ -382,16 +364,6 @@ export const NewPositionWrapper = () => { { - let newTierIndex: number - - if (typeof currentUiTiers?.[feeTierIndex] === 'undefined') { - const indexForFee = ALL_FEE_TIERS_DATA.findIndex(tier => fee.eq(tier.tier.fee)) - - newTierIndex = indexForFee === -1 ? 0 : indexForFee - } else { - newTierIndex = currentUiTiers[feeTierIndex].primaryIndex - } - if ( tokenA !== null && tokenB !== null && @@ -399,12 +371,12 @@ export const NewPositionWrapper = () => { !( tokenAIndex === tokenA && tokenBIndex === tokenB && - fee.eq(ALL_FEE_TIERS_DATA[newTierIndex].tier.fee) + fee.eq(ALL_FEE_TIERS_DATA[feeTierIndex].tier.fee) ) ) { const index = allPools.findIndex( pool => - pool.fee.v.eq(ALL_FEE_TIERS_DATA[newTierIndex].tier.fee) && + pool.fee.v.eq(ALL_FEE_TIERS_DATA[feeTierIndex].tier.fee) && ((pool.tokenX.equals(tokens[tokenA].assetAddress) && pool.tokenY.equals(tokens[tokenB].assetAddress)) || (pool.tokenX.equals(tokens[tokenB].assetAddress) && @@ -416,7 +388,7 @@ export const NewPositionWrapper = () => { !( tokenAIndex === tokenB && tokenBIndex === tokenA && - fee.eq(ALL_FEE_TIERS_DATA[newTierIndex].tier.fee) + fee.eq(ALL_FEE_TIERS_DATA[feeTierIndex].tier.fee) ) ) { setPoolIndex(index !== -1 ? index : null) @@ -424,7 +396,7 @@ export const NewPositionWrapper = () => { } else if ( tokenAIndex === tokenB && tokenBIndex === tokenA && - fee.eq(ALL_FEE_TIERS_DATA[newTierIndex].tier.fee) + fee.eq(ALL_FEE_TIERS_DATA[feeTierIndex].tier.fee) ) { setCurrentPairReversed(currentPairReversed === null ? true : !currentPairReversed) } @@ -440,13 +412,13 @@ export const NewPositionWrapper = () => { !( tokenAIndex === tokenB && tokenBIndex === tokenA && - fee.eq(ALL_FEE_TIERS_DATA[newTierIndex].tier.fee) + fee.eq(ALL_FEE_TIERS_DATA[feeTierIndex].tier.fee) ) ) { dispatch( poolsActions.getPoolData( new Pair(tokens[tokenA].assetAddress, tokens[tokenB].assetAddress, { - fee: ALL_FEE_TIERS_DATA[newTierIndex].tier.fee + fee: ALL_FEE_TIERS_DATA[feeTierIndex].tier.fee }) ) ) @@ -455,9 +427,9 @@ export const NewPositionWrapper = () => { setTokenAIndex(tokenA) setTokenBIndex(tokenB) - setFeeIndex(newTierIndex) + setFeeIndex(feeTierIndex) }} - feeTiers={currentUiTiers.map(tier => ({ + feeTiers={ALL_FEE_TIERS_DATA.map(tier => ({ feeValue: +printBN(tier.tier.fee, DECIMAL - 2), maxSafeConcentration: tier.maxSafeConcentration, minimumRange: tier.minimumRange @@ -595,7 +567,7 @@ export const NewPositionWrapper = () => { } }} plotVolumeRange={currentVolumeRange} - currentFeeIndex={currentUiFeeIndex} + currentFeeIndex={feeIndex} onSlippageChange={onSlippageChange} initialSlippage={initialSlippage} /> diff --git a/src/store/consts/static.ts b/src/store/consts/static.ts index ce00ec100..11cfb6fe7 100644 --- a/src/store/consts/static.ts +++ b/src/store/consts/static.ts @@ -230,7 +230,7 @@ const mainnetBestTiersCreator = () => { bestTiers.push({ tokenX, tokenY, - bestTierIndex: 2 + bestTierIndex: 4 }) } } @@ -244,7 +244,7 @@ const mainnetBestTiersCreator = () => { bestTiers.push({ tokenX, tokenY, - bestTierIndex: 3 + bestTierIndex: 4 }) } } @@ -262,22 +262,22 @@ export const bestTiers: Record = { { tokenX: USDC_DEV.address, tokenY: WSOL_DEV.address, - bestTierIndex: 3 + bestTierIndex: 4 }, { tokenX: USDC_DEV.address, tokenY: BTC_DEV.address, - bestTierIndex: 3 + bestTierIndex: 4 }, { tokenX: RENDOGE_DEV.address, tokenY: BTC_DEV.address, - bestTierIndex: 5 + bestTierIndex: 6 }, { tokenX: USDC_DEV.address, tokenY: RENDOGE_DEV.address, - bestTierIndex: 5 + bestTierIndex: 6 } ], Testnet: [], @@ -365,23 +365,4 @@ export const ALL_FEE_TIERS_DATA = FEE_TIERS.map((tier, index) => ({ primaryIndex: index })) -export const getNewPositionUIFeeTiers = ( - tokenAAddress: PublicKey | null, - tokenBAddress: PublicKey | null -) => { - const USDC = new PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v') - const USDT = new PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') - - if ( - tokenAAddress !== null && - tokenBAddress !== null && - ((tokenAAddress.equals(USDC) && tokenBAddress.equals(USDT)) || - (tokenAAddress.equals(USDT) && tokenBAddress.equals(USDC))) - ) { - return ALL_FEE_TIERS_DATA - } - - return ALL_FEE_TIERS_DATA.slice(1) -} - export { SolanaNetworks, DEFAULT_PUBLICKEY, MAX_U64, NetworkType }