Skip to content

Commit

Permalink
Merge pull request #95 from cd-sigma/main
Browse files Browse the repository at this point in the history
Build
  • Loading branch information
cd-simarpreet committed Dec 10, 2023
2 parents f604368 + 392f0af commit fca6284
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 fca6284

Please sign in to comment.