Calculate Position Fees
Track accumulated trading fees across all bins in your position. Monitor fee generation and calculate your earnings from providing liquidity.
Prerequisites
Position ID with active liquidity
Understanding of fee structure
Pair reserves data access
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
Fees accumulate in bins, not positions
Calculation requires bin reserves data
Fees auto-compound into liquidity
Active bins typically generate most fees
Related Topics
Fee Structure - How fees work
Collect Fees - Claim your fees
Position Value - Total worth including fees
Calculate APR - Annualized returns
Last updated