Skip to content

Commit

Permalink
fix apr calculation (#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
syuhei176 authored Nov 6, 2023
1 parent aeb7969 commit 5e6e223
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/adaptors/predy-v5/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ const lendingApys = async () => {
function getApr(latest, start) {
const latestPrice = new BigNumber(latest.closePrice)
const startPrice = new BigNumber(start.closePrice)
const apr = latestPrice.times(1000000).div(startPrice).minus(1000000)
const apr = latestPrice.times(1000000).div(startPrice).toNumber() - 1000000
const span = Number(latest.closeTimestamp) - Number(start.closeTimestamp)

if (span === 0) {
return 0
}

return (apr.toNumber() / 10000) * (60 * 60 * 24 * 365) / span
return (apr / 10000) * (60 * 60 * 24 * 365) / span
}


Expand Down

0 comments on commit 5e6e223

Please sign in to comment.