getYieldPerformance
Gets a wallet’s earnings in a single Earn vault: how much the position has earned (netEarningsAssets) and its return on capital (returnOnCapital).
The values are indexed by Morpho rather than read on-chain, so they trail the chain head by a short delay. getYieldPosition stays the source of truth for what a position is worth right now; use this function for earnings and PNL.
returnOnCapital is a time-weighted, non-annualized decimal (for example 0.00413 means a 0.41% return). It comes back null when Morpho has too little history on the position to compute one.
netEarningsAssets comes back as a raw string (e.g. "854395278"), not a human-readable number, so values above 2^53 stay exact. Divide by the vault’s assetDecimals, from getYieldDetails, before displaying it, the same way you’d format a position’s assets. See the example below.Usage
Parameters
Returns
Promise<YieldVaultPositionPerformance> - The position’s net earnings and return on capital.
Examples
Format earnings for display
React
useGetYieldPerformance is a query hook that stays disabled until walletAccount is defined, safe to render before a wallet is connected.
Related
getYieldPosition- The wallet’s current balance in the vaultgetYieldEarnings- The wallet’s earnings across all vaults on a chaingetYieldDetails- Vault details, includingassetDecimals