Skip to content

Commit

Permalink
Merge pull request #26 from Agoric/feat/liquidated-closed-state
Browse files Browse the repository at this point in the history
fix: mark liquidated => closed as liquidatedClosed
  • Loading branch information
frazarshad authored Jun 7, 2024
2 parents 5859ba2 + ec2e772 commit f4a7b8c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/mappings/events/vaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ export const vaultsEventKit = (block: any, data: any, module: string, path: stri
(vaultState as any)[oldProperty] -= BigInt(1);
}

if (newState && propertyMap[newState]) {
const newProperty = propertyMap[newState];
// handle liquidated -> closed = liquidatedClosed
const newStateModified =
oldState === VAULT_STATES.LIQUIDATED && newState === VAULT_STATES.CLOSED
? VAULT_STATES.LIQUIDATED_CLOSED
: newState;

if (newStateModified && propertyMap[newStateModified]) {
const newProperty = propertyMap[newStateModified];
(vaultState as any)[newProperty] += BigInt(1);
}

Expand Down Expand Up @@ -151,7 +157,7 @@ export const vaultsEventKit = (block: any, data: any, module: string, path: stri
);
}

const pathRegex = /^(published\.vaultFactory\.managers\.manager[0-9]+)\.vaults\.vault[0-9]+$/
const pathRegex = /^(published\.vaultFactory\.managers\.manager[0-9]+)\.vaults\.vault[0-9]+$/;
const pathRegexMatch = path.match(pathRegex);
if (!pathRegexMatch) {
throw new Error('path format is invalid');
Expand Down

0 comments on commit f4a7b8c

Please sign in to comment.