collect Fees
Adding liquidity within a valid price range allows for the distribution of transaction fees based on each position's proportional share of effective liquidity in that range. To harvest transaction fees separately, please follow the method outlined below.
Signature
async collectFee(options: Pool.CollectFeeOptions): Promise
Params
export interface CollectFeeOptions extends Pick<Pool.MintParams, 'pool' | 'txb' | 'address' | 'deadline'> {
/**
* Position NFT ID
*/
nft: string;
collectAmountA: string | number;
collectAmountB: string | number;
}
collectAmountA & collectAmountB
The maximum value of u64 can be passed in, so the contract will automatically handle extracting all fees.
Examples
Get unclaimed fee amounts
const turbosSdk = new TurbosSdk(Network.testnet, {
url: 'https://fullnode.testnet.sui.io',
});
//const signer = turbosSdk.account.getKeypairFromMnemonics("your mnemonic");
const signer = services.turbosBaseService.signer;
const poolId = '0xb32fb8ec0b447a833066496bd7251d3a2ee57a0a97c54bf4cc945a986235582a';
const positionId =
'0xb7efa54832e000dcb8879e586f74cec55623105920c96f5f1ebe78a60f9cbd3b';
const txb = await turbosSdk.pool.collectFee({
pool: poolId,
nft: positionId,
collectAmountA: MAX_UINT_64.toString(),
collectAmountB: MAX_UINT_64.toString(),
address: signer.toSuiAddress(),
});
const result = await turbosSdk.provider.devInspectTransactionBlock({
transactionBlock: txb,
sender: signer.toSuiAddress(),
});
const collectEvent = result.events.filter((event) =>
event.type.endsWith('::pool::CollectEvent'),
);
const amountA = collectEvent[0]!.parsedJson!.amount_a!;
const amountB = collectEvent[0]!.parsedJson!.amount_b!;
console.log(amountA, amountB);
Collect fees
const turbosSdk = new TurbosSdk(Network.testnet, {
url: 'https://fullnode.testnet.sui.io',
});
//const signer = turbosSdk.account.getKeypairFromMnemonics("your mnemonic");
const signer = services.turbosBaseService.signer;
const poolId = '0xb32fb8ec0b447a833066496bd7251d3a2ee57a0a97c54bf4cc945a986235582a';
const positionId = '0xb7efa54832e000dcb8879e586f74cec55623105920c96f5f1ebe78a60f9cbd3b';
const txb = await turbosSdk.pool.collectFee({
pool: poolId,
nft: positionId,
collectAmountA: MAX_UINT_64.toString(),
collectAmountB: MAX_UINT_64.toString(),
address: signer.toSuiAddress(),
});
const result = await turbosSdk.provider.signAndExecuteTransaction({
transaction: txb,
signer,
});
console.log(result);
Last updated