getYieldPosition
Gets a wallet’s current balance in an Earn vault. Reads on-chain, so the result always reflects the vault’s current state — there’s no caching delay. The response has two numbers,shares and assets. Show assets, not shares, in your UI.
assetsis what the wallet’s position is worth right now, in the underlying token (e.g. USDC). This is the number that grows as yield accrues — it’s the balance and earnings your users care about.sharesis an internal accounting number the vault uses to track ownership. It’s set once at deposit time and doesn’t change after that, even while the position is earning yield. Showing it to a user just creates a second, unmoving “balance” that looks broken next to the real one.
Both
shares and assets come back as raw strings (e.g. "10500000"), not human-readable numbers. Divide by the vault’s assetDecimals — from getYieldDetails — before displaying either one. See the example below.Usage
Parameters
Returns
Promise<YieldVaultPosition> - The wallet’s balance in the vault.
Examples
Format a position for display
React
useGetYieldPosition is a query hook that stays disabled until walletAccount is defined — safe to render before a wallet is connected.
Related
getYieldDetails- Vault details, includingassetDecimalsgetYieldRewards- The wallet’s accrued rewards in this vaultwithdrawFromYieldVault- Withdraw from this vault