Add Liquidity
Last updated
const currencyAAmount = Math.pow(10, 8);
// currencyA's decimals is 8
// currencyB's decimals is 6
const decimalsRatio = Math.pow(10, 8 - 6);
const feeTierIndex = FeeTierIndex["PER_0.05_SPACING_5"]
const currentPriceTick = priceToTick({
price: 995,
feeTierIndex,
decimalsRatio,
})
const tickLower = priceToTick({
price: 992,
feeTierIndex,
decimalsRatio,
})
const tickUpper = priceToTick({
price: 1336,
feeTierIndex,
decimalsRatio,
})
const [_, currencyBAmount] = await sdk.Pool.estCurrencyBAmountFromA({
// address here mus be fa type
currencyA: "0xa",
currencyB:
"0xc5bcdea4d8a9f5809c5c945a3ff5698a347afb982c7389a335100e1b0043d115",
currencyAAmount,
feeTierIndex,
tickLower,
tickUpper,
currentPriceTick,
});
const params = {
positionId: '',
currencyA: "0x1::aptos_coin::AptosCoin",
currencyB:
"0x6926bff1eab5554fa72ae167ed736acf623ab17fe81ebf2ea0d2138f8c533f77::type::T",
currencyAAmount,
currencyBAmount,
slippage: 0.1,
feeTierIndex,
}
const payload = await sdk.Position.addLiquidityTransactionPayload(params)