Skip to content

Instantly share code, notes, and snippets.

@sparrowDom
Created April 9, 2025 19:00
Show Gist options
  • Save sparrowDom/5c1cc3c08cee94ca76d9271911acb72c to your computer and use it in GitHub Desktop.
Save sparrowDom/5c1cc3c08cee94ca76d9271911acb72c to your computer and use it in GitHub Desktop.
int32[] memory ticks = new int32[](1);
uint128[] memory relativeLiquidityAmounts = new uint128[](1);
ticks[0] = -1;
// all liquidity into one tick
relativeLiquidityAmounts[0] = 1e18;
uint256 maxAmountA = 1e18;
// see documentation: https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/interfaces/imaverickv2poollens#addparamsspecification
IMaverickV2PoolLens.AddParamsSpecification memory addSpec = IMaverickV2PoolLens.AddParamsSpecification({
slippageFactorD18: 0.01e18,
numberOfPriceBreaksPerSide: 0,
targetAmount: maxAmountA,
targetIsA: false
});
int32 activeTick = mPool.getState().activeTick;
console.log("activeTick");
console.log(activeTick == -1); // true
// see documentation: https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/maverickv2poollens#getaddliquidityparams
(bytes memory packedSqrtPriceBreaks, bytes[] memory packedArgs, , , ) = poolLens.getAddLiquidityParams(IMaverickV2PoolLens.AddParamsViewInputs({
pool: mPool,
kind: 0, // static kind
ticks: ticks,
relativeLiquidityAmounts: relativeLiquidityAmounts,
addSpec: addSpec
}));
console.log("getAddLiquidityParams called");
(uint256 amountA, uint256 amountB, , uint256 _tokenId) = liquidityManager.mintPositionNftToSender(mPool, packedSqrtPriceBreaks, packedArgs);
// Store the tokenId
tokenId = _tokenId;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment