Skip to content

Commit

Permalink
Merge pull request #94 from cd-sigma/aaaveeeee
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
cd-sigma authored Dec 10, 2023
2 parents 63dd173 + 511fdf7 commit 392f0af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backend/api/resolvers/health.factor.resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ async function calculateHealthFactor(web3, supplied, borrowed) {
let borrowSum = 0

for (const supply of supplied) {
collateralSum = collateralSum + ((parseFloat(supply.balance) * parseFloat(supply.usdPrice) * parseFloat(supply.liqudationThreshold)) / supply.ethPrice)
const ethPrice = await priceLib.getTokenPriceFromChainlinkPriceOracle("eth", "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", web3)
collateralSum = collateralSum + ((parseFloat(supply.balance) * parseFloat(supply.usdPrice) * parseFloat(supply.liqudationThreshold)) / parseFloat(ethPrice.usdPrice))
}

for (const borrow of borrowed) {
borrowSum = borrowSum + ((parseFloat(borrow.balance) * parseFloat(borrow.usdPrice)) / borrow.ethPrice)
const ethPrice = await priceLib.getTokenPriceFromChainlinkPriceOracle("eth", "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", web3)
borrowSum = borrowSum + ((parseFloat(borrow.balance) * parseFloat(borrow.usdPrice)) / parseFloat(ethPrice.usdPrice))
}

return collateralSum / borrowSum
Expand Down

0 comments on commit 392f0af

Please sign in to comment.