@somnia-chain/markets-sdk / index / lendRayRateToApy
Function: lendRayRateToApy()
lendRayRateToApy(
rateRay):number
Defined in: packages/sdk/src/lend/math.ts:95
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).
Details
rateRay: Annual rate in ray (1e27) units, as returned in LendReserve.- Returns: The compounded annual yield as a plain fraction (
0.031⇒ 3.1% APY).
Gotchas
Display-only — the one place the lend surface hands back a number.
Example (Converting a ray rate)
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)}%`);
Parameters
rateRay
bigint
Returns
number