Skip to content

Commit

Permalink
feat: added vaultManagerGovernance added to liquidated vaults
Browse files Browse the repository at this point in the history
  • Loading branch information
frazarshad committed May 14, 2024
1 parent c09906b commit 8dcbfba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ type Vault @entity {
wallet: Wallet!
}

type VaultManagerGovernanceJson @jsonField {
liquidationMarginDenominator: BigInt
liquidationMarginNumerator: BigInt
}

type VaultLiquidation @entity {
id: ID!
blockHeight: BigInt!
Expand All @@ -152,6 +157,7 @@ type VaultLiquidation @entity {
wallet: Wallet!
currentState: Vault!
liquidatingState: VaultLiquidation!
vaultManagerGovernance: VaultManagerGovernanceJson
}

type VaultManagerMetrics @entity {
Expand Down
10 changes: 10 additions & 0 deletions src/mappings/events/vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ export const vaultsEventKit = (block: any, data: any, module: string, path: stri
);
}

const vaultGovernanceId = id.split('.').slice(0, 4).join('.') + '.governance';
const vaultManagerGovernance = await VaultManagerGovernance.get(vaultGovernanceId);

if (vaultManagerGovernance && payload?.vaultState === 'liquidated' && vault.vaultManagerGovernance === undefined) {
vault.vaultManagerGovernance = {
liquidationMarginNumerator: vaultManagerGovernance?.liquidationMarginNumerator,
liquidationMarginDenominator: vaultManagerGovernance?.liquidationMarginDenominator,
};
}

vault.coin = payload?.locked?.__brand;
vault.denom = payload?.locked?.__brand;
vault.debt = payload?.debtSnapshot?.debt?.__value;
Expand Down

0 comments on commit 8dcbfba

Please sign in to comment.