getUserPoolStake
Get detailed information about a user's stake in a specific pool, including staked amount, claimed rewards, fees paid, and reward debt.
Usage
example.ts
import { mintclub } from 'mint.club-v2-sdk'
const userStake = await mintclub.network('base').stake.getUserPoolStake({
user: '0x1234567890123456789012345678901234567890',
poolId: 0,
})
console.log('User stake info:', userStake)Return Value
Promise<UserPoolStakeInfo>
Returns a promise that resolves to a UserPoolStakeInfo object containing:
type UserPoolStakeInfo = {
stakedAmount: bigint // Amount of tokens staked
claimedTotal: bigint // Total rewards claimed so far
feeTotal: bigint // Total fees paid on claims
rewardDebt: bigint // Internal accounting for rewards
}Parameters
user
- Type:
'0x${string}'
The address of the user to get staking information for.
const userStake = await mintclub.network('base').stake.getUserPoolStake({
user: '0x1234567890123456789012345678901234567890',
poolId: 0,
})poolId
- Type:
number
The ID of the staking pool to check.
const userStake = await mintclub.network('base').stake.getUserPoolStake({
user: '0x1234567890123456789012345678901234567890',
poolId: 0,
})Example
example.ts
import { mintclub } from 'mint.club-v2-sdk'
import { formatUnits } from 'viem'
const userAddress = '0x1234567890123456789012345678901234567890'
const poolId = 0
// Get user's stake info
const userStake = await mintclub.network('base').stake.getUserPoolStake({
user: userAddress,
poolId,
})
// Get pool info for context
const poolInfo = await mintclub.network('base').stake.getPool({ poolId })
const { stakingToken, rewardToken } = poolInfo
// Access properties directly from the object
const { stakedAmount, claimedTotal, feeTotal, rewardDebt } = userStake
// Format amounts
const stakedAmountFormatted = formatUnits(stakedAmount, stakingToken.decimals)
const claimedTotalFormatted = formatUnits(claimedTotal, rewardToken.decimals)
const feeTotalFormatted = formatUnits(feeTotal, rewardToken.decimals)
console.log(`User Stake Information for Pool ${poolId}:`)
console.log(`Staked: ${stakedAmountFormatted} ${stakingToken.symbol}`)
console.log(`Claimed: ${claimedTotalFormatted} ${rewardToken.symbol}`)
console.log(`Fees Paid: ${feeTotalFormatted} ${rewardToken.symbol}`)
console.log(`Reward Debt: ${rewardDebt}`)
// Check if user has any stake
if (stakedAmount > 0n) {
console.log('User has an active stake in this pool')
// Get current claimable rewards
const claimable = await mintclub.network('base').stake.getClaimableReward({
poolId,
staker: userAddress,
})
const [rewardClaimable] = claimable
const pendingRewards = formatUnits(rewardClaimable, rewardToken.decimals)
console.log(`Pending Rewards: ${pendingRewards} ${rewardToken.symbol}`)
} else {
console.log('User has no stake in this pool')
}