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

LIQUIDITY_ZERO #59

Open
edsonPrimo opened this issue Jul 4, 2024 · 0 comments
Open

LIQUIDITY_ZERO #59

edsonPrimo opened this issue Jul 4, 2024 · 0 comments

Comments

@edsonPrimo
Copy link

onstructing a position that is out of range returns it as zero liquidity. Then, when I try to use the position instance to increase this position's liquidity, I receive the ZERO_LIQUIDITY error

const token0 = CurrencyAmount.fromRawAmount(
      positionData.amount0.currency,
      BigNumber(positionData.amount0.quotient.toString()).multipliedBy(fractionToAdd).toFixed(0),
    );
    const token1 = CurrencyAmount.fromRawAmount(
      positionData.amount1.currency,
      BigNumber(positionData.amount1.quotient.toString()).multipliedBy(fractionToAdd).toFixed(0),
    );

const configuredPool = new Pool(
      token0.currency,
      token1.currency,
      poolFee,
      sqrtPriceX96.toFixed(),
      liquidity.toFixed(),
      tick,
    );

    const position =  Position.fromAmounts({
      pool: configuredPool,
      tickLower: nearestUsableTick(tick, tickSpacing) - tickSpacing * 2,
      tickUpper: nearestUsableTick(tick, tickSpacing) + tickSpacing * 2,
      amount0: token0.quotient,
      amount1: token1.quotient,
      useFullPrecision: true,
    });

const addLiquidityOptions: IncreaseOptions = {
      deadline: Math.floor(Date.now() / 1000) + 60 * 20,
      slippageTolerance: new Percent(50, 10_000),
      tokenId: positionData.positionId,
    };

    const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, addLiquidityOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant