Get Pool Position Rewards
Check reward amounts for liquidity positions.
Quick Start
// Get rewards for single position
const pool = await sdk.Pool.getPool(poolId)
const rewards = await sdk.Rewarder.fetchPositionRewarders(pool, positionId)
rewards.forEach(reward => {
console.log({
token: reward.coin_address,
amount: reward.amount_owed.toString()
})
})
Check Pool Rewards
// Get position with full reward info
const position = await sdk.Position.getPositionById(positionId, true)
// Access reward amounts
if (position.rewards) {
position.rewards.forEach(reward => {
console.log({
token: reward.coin_type,
amount: reward.amount_owed
})
})
}
Batch Check Rewards
Check rewards for multiple positions:
const positionIds = ['0x1...', '0x2...', '0x3...']
// Batch fetch all rewards
const allRewards = await sdk.Rewarder.batchFetchPositionRewarders(positionIds)
// Display results
Object.entries(allRewards).forEach(([posId, rewards]) => {
console.log(`Position ${posId}:`)
rewards.forEach(reward => {
console.log(` ${reward.coin_address}: ${reward.amount_owed}`)
})
})
// Batch fetch fees
const allFees = await sdk.Position.batchFetchPositionFees(positionIds)
Pool Reward Info
Daily Emissions
// Check how much rewards pool distributes daily
const emissions = await sdk.Rewarder.emissionsEveryDay(poolId)
emissions?.forEach(emission => {
console.log({
token: emission.coin_address,
perDay: emission.emissions
})
})
Total User Rewards
// Get total rewards across all positions in pool
const totalRewards = await sdk.Rewarder.fetchPoolRewardersAmount(
userAddress,
poolId
)
totalRewards.forEach((amount, index) => {
if (amount.gt(new BN(0))) {
console.log(`Rewarder ${index}: ${amount.toString()}`)
}
})
Complete Example
// 1. Get user positions
const positions = await sdk.Position.getPositionList(userAddress)
// 2. Group by pool
const poolGroups = {}
positions.forEach(pos => {
if (!poolGroups[pos.pool]) poolGroups[pos.pool] = []
poolGroups[pos.pool].push(pos)
})
// 3. Check rewards for each pool
for (const [poolId, poolPositions] of Object.entries(poolGroups)) {
const pool = await sdk.Pool.getPool(poolId)
console.log(`\nPool: ${poolId}`)
console.log(`Rewarders: ${pool.rewarder_infos.length}`)
// Check emissions
const emissions = await sdk.Rewarder.emissionsEveryDay(poolId)
emissions?.forEach(e => {
console.log(` Daily ${e.coin_address}: ${e.emissions}`)
})
// Check each position
for (const pos of poolPositions) {
// Fees
const fees = await sdk.Position.calculateFee({
pool_id: pos.pool,
pos_id: pos.pos_object_id,
coinTypeA: pos.coin_type_a,
coinTypeB: pos.coin_type_b
})
// Rewards
const rewards = await sdk.Rewarder.fetchPositionRewarders(pool, pos.pos_object_id)
console.log(`\n Position ${pos.pos_object_id}:`)
console.log(` Fees: ${fees.feeOwedA} / ${fees.feeOwedB}`)
rewards.forEach(r => {
console.log(` ${r.coin_address}: ${r.amount_owed}`)
})
}
}
Response Types
interface RewarderAmountOwed {
amount_owed: BN
coin_address: string
}
interface CollectFeesQuote {
feeOwedA: BN
feeOwedB: BN
position_id: string
}
Important Notes
Rewards accumulate in real-time based on liquidity and time
Trading fees come from swaps in your price range
Pool rewards are additional incentives from protocol
Use
calculateRewards: true
when getting position to include rewardsBatch methods are more efficient for multiple positions
Last updated