Skip to content

Commit

Permalink
fix: use aggregate of item.liquidated
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Jun 7, 2024
1 parent ba14563 commit 2b3ceec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/pages/Liquidated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export function Liquidated() {
const graphDataList = populateMissingDays(graphDataMap, GRAPH_DAYS);

const summedGraphDataList = graphDataList.map((item) => {
const totalActive = item.active ? sum(Object.values(item.active)) : NaN;
const totalLiquidated = item.liquidated ? sum(Object.values(item.liquidated)) : NaN;
const totalActive = item.active ? sum(Object.values(item.active)) : 0;
const totalLiquidated = item.liquidated ? sum(Object.values(item.liquidated)) : 0;

return {
...item,
Expand All @@ -82,7 +82,7 @@ export function Liquidated() {
<ValueCardGrid>
<LiquidatedVaultCountCard data={response?.vaultManagerMetrics?.nodes} isLoading={isLoading} />
</ValueCardGrid>
<VaultStatesChart data={summedGraphDataList} isLoading={graphDataIsLoading} />
{/* <VaultStatesChart data={summedGraphDataList} isLoading={graphDataIsLoading} /> */}
<hr className="my-5" />
<LiquidatedVaults data={liquidationDashboardData} boardAuxes={boardAuxes} isLoading={isLoading} />
</PageContent>
Expand Down
7 changes: 2 additions & 5 deletions src/widgets/LiquidatedVaults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ export function LiquidatedVaults({ title = 'Liquidated Vaults', data, boardAuxes

const vaultStateSuffix = vaultData?.currentState?.state === VAULT_STATES.CLOSED ? ' (Closed)' : '';
const vaultState = vaultData.state[0].toUpperCase() + vaultData.state.slice(1) + vaultStateSuffix;
console.log("YYYYYYYYYYYY", vaultData)
const liquidationRatio =
parseBigInt(vaultData.vaultManagerGovernance?.liquidationMarginNumerator || '') /
parseBigInt(vaultData.vaultManagerGovernance?.liquidationMarginDenominator || '');
parseBigInt(vaultData.vaultManagerGovernance?.liquidationMarginNumerator) /
parseBigInt(vaultData.vaultManagerGovernance?.liquidationMarginDenominator);

const istDivisor = getTokenDivisor(boardAuxes, 'IST');
const tokenDivisor = getTokenDivisor(boardAuxes, vaultData.denom);
Expand All @@ -53,8 +52,6 @@ export function LiquidatedVaults({ title = 'Liquidated Vaults', data, boardAuxes
const collateralAmount = vaultData.liquidatingState.balance / tokenDivisor;
const liquidationPrice = (istDebtAmount * liquidationRatio) / collateralAmount;
const collateralAmountReturned = (vaultData.liquidatingState.balance - vaultData.balance) / tokenDivisor;
console.log("YYYYYYYYYYYY 5555")

const oraclePriceRatio =
parseBigInt(vaultData.oraclePrice?.typeOutAmount) / parseBigInt(vaultData.oraclePrice?.typeInAmount);
const collateralAmountReturnedUsd = collateralAmountReturned * oraclePriceRatio;
Expand Down

0 comments on commit 2b3ceec

Please sign in to comment.