diff --git a/schema.graphql b/schema.graphql index ee51c0eb..d47d34fc 100644 --- a/schema.graphql +++ b/schema.graphql @@ -139,6 +139,11 @@ type Vault @entity { wallet: Wallet! } +type VaultManagerGovernanceJson @jsonField { + liquidationMarginDenominator: BigInt + liquidationMarginNumerator: BigInt +} + type VaultLiquidation @entity { id: ID! blockHeight: BigInt! @@ -152,6 +157,7 @@ type VaultLiquidation @entity { wallet: Wallet! currentState: Vault! liquidatingState: VaultLiquidation! + vaultManagerGovernance: VaultManagerGovernanceJson } type VaultManagerMetrics @entity { diff --git a/src/mappings/events/vaults.ts b/src/mappings/events/vaults.ts index 00535679..922f69a8 100644 --- a/src/mappings/events/vaults.ts +++ b/src/mappings/events/vaults.ts @@ -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;