Add `saversAPR` to `/pools` endpoint
add saversAPR based on formula below:
if the period is longer than when savers initiated, Midgard will show 0
(24hrs as period param)
unitsBefore = saver's units 24hrs bucket before than current time (it might be different than `unitsNow` due to stake, and withdraws)
unitsNow = saver's units now
depthBefore = saver's depth 24hrs bucket before now
depthNow = saver's depth now
beforeGrowthIndex = depthBefore / unitsBefore
nowGrowthIndex = depthNow / unitsNow
----
saversAPR = (nowGrowthIndex - beforeGrowthIndex) * blocksPerYear/24hrsBlockCount
{
"annualPercentageRate": "0.07447201962776606",
"asset": "BTC.BTC",
"assetDepth": "118241681",
"assetPrice": "14608.295471340602",
"assetPriceUSD": "17660.720513651784",
"liquidityUnits": "1223159714705",
"nativeDecimal": "8",
"poolAPY": "0.07447201962776606",
"runeDepth": "1727309413076",
"saversDepth": "100901",
"saversUnits": "100853",
"status": "available",
"synthSupply": "17592752",
"synthUnits": "98308216680",
"units": "1321467931385",
"volume24h": "0"
}
{
"annualPercentageRate": "0.0532067787486169",
"asset": "BTC.BTC",
"assetDepth": "118246541",
"assetPrice": "14544.627383104593",
"assetPriceUSD": "17660.720513651784",
"liquidityUnits": "1223159714705",
"nativeDecimal": "8",
"poolAPY": "0.0532067787486169",
"runeDepth": "1719851878186",
"saversAPR": "0.3219128408886943", // adds savers APR based on the period param (default 30d)
"saversDepth": "100901",
"saversUnits": "100853",
"status": "available",
"synthSupply": "17592752",
"synthUnits": "98303851424",
"units": "1321463566129",
"volume24h": "176960415464"
}
Edited by Hoori Rn