- 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%
As of now on Compound on Rinkeby network, the divisor seems to be the sum of the assets you've supplied, i.e., their definition seems to be "Net APY compared to what you invested".
This gets the correct value for me:
Don't need the conditional check on if the sum is positive or negative.
Example from my rinkeby wallet (using DAI and USDC so no currency conversion step here):