@somnia-chain/markets-sdk / index / lendRayRateToApy
Function: lendRayRateToApy()
lendRayRateToApy(
rateRay):number
Defined in: packages/sdk/src/lend/math.ts:78
Convert a ray annual rate (a reserve's liquidityRateRay / variableBorrowRateRay)
to the per-second-compounded APY fraction Aave UIs display (0.05 = 5%).
When to use
Use to display a rate — this exists so apps don't each re-derive
(1 + r/s)^s - 1 from the ray rate. Position math stays in bigint ray space
(rayMul, accrueCompounded).
Gotchas
Display-only — the one place the lend surface hands back a number.
Parameters
rateRay
bigint
Annual rate in ray (1e27) units, as returned in LendReserve.
Returns
number
The compounded annual yield as a plain fraction (0.031 ⇒ 3.1% APY).
Example
ts
const reserves = await lend.listReserves();
const usdso = reserves.find((r) => r.symbol === "USDso");
if (usdso) console.log(`supply APY ${(lendRayRateToApy(usdso.liquidityRateRay) * 100).toFixed(2)}%`);