Skip to main content

calculateAllocatorPosition

Description:

Calculates the user's APY and total staked assets in a vault from the result of getPositionData and optional deltas. Zero deltas return the current position.

A negative boostedSharesDelta is ignored: unboosted shares stay in the position while they are exiting.

Arguments:

NameTypeRequiredDescription
dataPositionDataYesResult of getPositionData
stakedAssetsDeltabigintNoChange in staked assets (e.g. +assets to stake, -assets to unstake). Defaults to 0n
mintedSharesDeltabigintNoChange in minted osToken shares (+shares to mint, -shares to burn). Defaults to 0n
boostedSharesDeltabigintNoChange in boosted osToken shares (+shares to boost). Defaults to 0n

Returns:

type Output = {
apy: number
totalAssets: bigint
}

Example:

const data = await sdk.vault.getPositionData({
userAddress: '0x...',
vaultAddress: '0x...',
})

const { apy, totalAssets } = sdk.vault.helpers.calculateAllocatorPosition({
data,
stakedAssetsDelta: parseEther('1'),
})