Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
fix(maker): Update vault debt balances to account for the ilk rate (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Dec 21, 2023
1 parent cc3053f commit f56fa24
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/apps/maker/ethereum/maker.vault.contract-position-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ export class EthereumMakerVaultContractPositionFetcher extends CustomContractPos
positions.map(async position => {
const ilk = ethers.utils.formatBytes32String(position.dataProps.ilkName);
const [ink, art] = await multicall.wrap(vatContract).read.urns([ilk, urn.toLowerCase()]);
const ilks = await multicall.wrap(vatContract).read.ilks([ilk]);
const rate = new BigNumber(ilks[1].toString()).div(10 ** 27);

const collateralToken = position.tokens.find(isSupplied);
const debtToken = position.tokens.find(isBorrowed);
Expand All @@ -182,10 +184,10 @@ export class EthereumMakerVaultContractPositionFetcher extends CustomContractPos
.div(10 ** 18)
.times(10 ** collateralToken.decimals)
.toFixed(0);
const debtRaw = new BigNumber(art.toString())
.div(10 ** 18)
.times(10 ** debtToken.decimals)
.toFixed(0);
const artRaw = new BigNumber(art.toString()).div(10 ** 18).times(10 ** debtToken.decimals);

const debtRaw = artRaw.times(rate).toFixed(0);

const collateral = drillBalance(collateralToken, collateralRaw);
const debt = drillBalance(debtToken, debtRaw, { isDebt: true });
const tokens = [collateral, debt];
Expand Down

0 comments on commit f56fa24

Please sign in to comment.