Skip to content

Commit

Permalink
fix: fixed issue with dailyVaultStates
Browse files Browse the repository at this point in the history
  • Loading branch information
frazarshad authored and toliaqat committed May 26, 2024
1 parent ec4f992 commit 49d5bd3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/mappings/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const VAULT_STATES = {
CLOSED: 'closed',
LIQUIDATING: 'liquidating',
LIQUIDATED: 'liquidated',
LIQUIDATED_CLOSED: 'liquidatedClosed',
};

export const VALUE_KEY = b64encode('value');
Expand Down
11 changes: 3 additions & 8 deletions src/mappings/events/vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ export const vaultsEventKit = (block: any, data: any, module: string, path: stri
[VAULT_STATES.LIQUIDATED]: 'liquidated',
[VAULT_STATES.LIQUIDATING]: 'liquidating',
[VAULT_STATES.CLOSED]: 'closed',
};

const closedPropertyMap = {
[VAULT_STATES.ACTIVE]: 'closed',
[VAULT_STATES.LIQUIDATED]: 'liquidatedClosed',
[VAULT_STATES.LIQUIDATED_CLOSED]: 'liquidatedClosed',
};

vaultState.blockHeightLast = BigInt(blockHeight);
Expand All @@ -117,9 +113,8 @@ export const vaultsEventKit = (block: any, data: any, module: string, path: stri
(vaultState as any)[oldProperty] -= BigInt(1);
}

if ((newState && propertyMap[newState]) || (oldState && closedPropertyMap[oldState])) {
const newProperty =
newState === VAULT_STATES.CLOSED && oldState ? closedPropertyMap[oldState] : propertyMap[newState];
if ((newState && propertyMap[newState])) {
const newProperty = propertyMap[newState];
(vaultState as any)[newProperty] += BigInt(1);
}

Expand Down

0 comments on commit 49d5bd3

Please sign in to comment.