- Convert all supplied and borrowed asset amounts to a single asset (like USD or ETH).
- Calculate the sum of (suppliedAmount * supplyApyAsDecimal - borrowedAmount * borrowApyAsDecimal) for all underlying assets.
- If the calculated sum from the previous step is >0 then Net APY = 100 * (sum / totalSuppliedValue). If the calculation from the previous step is <0 then Net APY = 100 * (sum / totalBorrowedValue). If the calculation from the previous step is 0 then Net APY = 0.
Net APY:
- -7.29%
Supplied Assets:
- 0.6 ETH ($260.20) @ 1.11% APY
Borrowed Assets:
- 75 BAT ($26.56) @ 5.57% APY
- 100.02 USDT ($100.02) @ 10.64 APY%
Calculation:
(260.20 * 0.0111 - 0 * 0) + (0 * 0 - 26.56 * 0.0557) + (0 * 0 - 100.02 * 0.1064) = -9.2333
100 * (-9.2333 / (26.56 + 100.02)) = -7.294438299889398
-7.29%
If the account transfers out cTokens, then their net APY reduces, because their account is entitled to fewer underlying tokens. So using the cToken balance is valid.