Skip to main content
The MarketThree.calculateClaimableFees() static method calculates the claimable fees for a liquidity position based on fee growth indices and position parameters.

Usage

import { MarketThree } from "@exponent-labs/exponent-sdk";

// Calculate claimable fees for a position
const feeData = MarketThree.calculateClaimableFees({
  lpBalance: position.lpBalance,
  feeInsideLastSy: position.feeGrowthInsideLastSy,
  feeInsideLastPt: position.feeGrowthInsideLastPt,
  currentInsideSy: currentFeeGrowthSy,
  currentInsidePt: currentFeeGrowthPt,
  tokensOwedSy: position.tokensOwedSy,
  tokensOwedPt: position.tokensOwedPt,
});

console.log("Claimable SY fees:", feeData.claimableSy);
console.log("Claimable PT fees:", feeData.claimablePt);
console.log("Total SY fees:", feeData.totalSy);
console.log("Total PT fees:", feeData.totalPt);

Parameters

ParameterTypeRequiredDescription
lpBalancebigintYesThe liquidity balance of the position
feeInsideLastSybigintYesLast recorded SY fee growth inside the position range
feeInsideLastPtbigintYesLast recorded PT fee growth inside the position range
currentInsideSybigintYesCurrent SY fee growth inside the position range
currentInsidePtbigintYesCurrent PT fee growth inside the position range
tokensOwedSybigintYesPreviously owed SY fees not yet claimed
tokensOwedPtbigintYesPreviously owed PT fees not yet claimed

Returns

Returns an object with:
{
  claimableSy: bigint;
  claimablePt: bigint;
  tokensOwedSy: bigint;
  tokensOwedPt: bigint;
  totalSy: bigint;
  totalPt: bigint;
}
PropertyTypeDescription
claimableSybigintNewly accrued SY fees that can be claimed
claimablePtbigintNewly accrued PT fees that can be claimed
tokensOwedSybigintUpdated total SY fees owed (includes previously owed)
tokensOwedPtbigintUpdated total PT fees owed (includes previously owed)
totalSybigintTotal SY fees (claimable + previously owed)
totalPtbigintTotal PT fees (claimable + previously owed)

Calculation Details

The method uses Q64.64 fixed-point math to calculate fees:
fees = floor((lpBalance * feeGrowthDelta) >> 64)
Where feeGrowthDelta is the difference between current and last recorded fee growth inside the position range.