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

fix(maker): Update vault debt balances to account for the ilk rate #3163

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading