Calculate Position Fees
Prerequisites
Get Position Fees
// Fetch position with fee data
async function getPositionFees(
pair: LBPair,
positionId: string
) {
// Get reserves including fees
const reserves = await sdk.Pair.getPairReserves(pair);
const positionBins = await sdk.Position.getPositionBins(pair, positionId);
let totalFeesX = 0n;
let totalFeesY = 0n;
for (const posBin of positionBins) {
const binReserve = reserves.find(r => r.id === posBin.id);
if (!binReserve) continue;
// Calculate position's share of fees
const shareOfFees = await calculateBinFeeShare(
posBin.liquidity,
binReserve,
pair
);
totalFeesX += shareOfFees.feeX;
totalFeesY += shareOfFees.feeY;
}
return { totalFeesX, totalFeesY };
}Calculate Fee Share
Simplified Fee Tracking
Fee Performance Metrics
Track Fee Generation by Bin
Display Fee Summary
Important Notes
Related Topics
Last updated