@@ -566,11 +566,11 @@ export function getV3PriceRangeInfo({
566
566
const { protocolVersion, currencies } = derivedPositionInfo
567
567
const pool = derivedPositionInfo . pool
568
568
569
- const sortedTokens = getSortedCurrenciesTuple (
570
- getCurrencyWithWrap ( currencies [ 0 ] , protocolVersion ) ,
571
- getCurrencyWithWrap ( currencies [ 1 ] , protocolVersion ) ,
572
- )
569
+ const tokenA = getCurrencyWithWrap ( currencies [ 0 ] , protocolVersion )
570
+ const tokenB = getCurrencyWithWrap ( currencies [ 1 ] , protocolVersion )
571
+ const sortedTokens = getSortedCurrenciesTuple ( tokenA , tokenB )
573
572
const [ sortedToken0 , sortedToken1 ] = sortedTokens
573
+
574
574
const [ baseCurrency , quoteCurrency ] = getInvertedTuple ( currencies , state . priceInverted )
575
575
const [ baseToken , quoteToken ] = [
576
576
getCurrencyWithWrap ( baseCurrency , protocolVersion ) ,
@@ -656,21 +656,22 @@ export function getV3PriceRangeInfo({
656
656
! invalidRange && price && prices [ 0 ] && prices [ 1 ] && ( price . lessThan ( prices [ 0 ] ) || price . greaterThan ( prices [ 1 ] ) ) ,
657
657
)
658
658
659
+ // This is in terms of the sorted tokens
659
660
const deposit0Disabled = Boolean ( upperTick && poolForPosition && poolForPosition . tickCurrent >= upperTick )
660
661
const deposit1Disabled = Boolean ( lowerTick && poolForPosition && poolForPosition . tickCurrent <= lowerTick )
661
662
662
663
const depositADisabled =
663
664
invalidRange ||
664
665
Boolean (
665
- ( deposit0Disabled && poolForPosition && baseToken && poolForPosition . token0 . equals ( baseToken ) ) ||
666
- ( deposit1Disabled && poolForPosition && baseToken && poolForPosition . token1 . equals ( baseToken ) ) ,
666
+ ( deposit0Disabled && poolForPosition && tokenA && poolForPosition . token0 . equals ( tokenA ) ) ||
667
+ ( deposit1Disabled && poolForPosition && tokenA && poolForPosition . token1 . equals ( tokenA ) ) ,
667
668
)
668
669
669
670
const depositBDisabled =
670
671
invalidRange ||
671
672
Boolean (
672
- ( deposit0Disabled && poolForPosition && quoteToken && poolForPosition . token0 . equals ( quoteToken ) ) ||
673
- ( deposit1Disabled && poolForPosition && quoteToken && poolForPosition . token1 . equals ( quoteToken ) ) ,
673
+ ( deposit0Disabled && poolForPosition && tokenB && poolForPosition . token0 . equals ( tokenB ) ) ||
674
+ ( deposit1Disabled && poolForPosition && tokenB && poolForPosition . token1 . equals ( tokenB ) ) ,
674
675
)
675
676
676
677
return {
@@ -883,8 +884,8 @@ export function generateAddLiquidityApprovalParams({
883
884
walletAddress : account . address ,
884
885
chainId : currencyAmounts . TOKEN0 . currency . chainId ,
885
886
protocol : apiProtocolItems ,
886
- token0 : getCurrencyAddressForTradingApi ( currencies [ 0 ] ) ,
887
- token1 : getCurrencyAddressForTradingApi ( currencies [ 1 ] ) ,
887
+ token0 : getCurrencyAddressForTradingApi ( getCurrencyWithWrap ( currencies [ 0 ] , positionState . protocolVersion ) ) ,
888
+ token1 : getCurrencyAddressForTradingApi ( getCurrencyWithWrap ( currencies [ 1 ] , positionState . protocolVersion ) ) ,
888
889
amount0 : currencyAmounts ?. TOKEN0 ?. quotient . toString ( ) ,
889
890
amount1 : currencyAmounts ?. TOKEN1 ?. quotient . toString ( ) ,
890
891
} satisfies CheckApprovalLPRequest
0 commit comments