-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue handling bucketTake events #30
Conversation
@@ -313,9 +313,8 @@ export function handleBucketBankruptcy(event: BucketBankruptcyEvent): void { | |||
} | |||
|
|||
export function handleBucketTake(event: BucketTakeEvent): void { | |||
const bucketTake = new BucketTake( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to assume the next log index at all? Shouldn't the transaction hash and block number concat still work for the ID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how block number helps us. A transaction hash may contain multiple bucketTake
actions. As such, we need the log index. The LP award should always be followed by the bucket take event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, I had the issue backwards - this makes sense
src/utils/liquidation.ts
Outdated
} | ||
return bucketTake; | ||
}1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: trailing 1 and no extra line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 25b6954
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a chicken-and-egg problem handling
bucketTake
.BucketTakeLPAwardedEvent
is currently emitted beforeBucketTakeEvent
. As such, when the LP award looked up theBucketTake
entity, it was unexpectedly null.Because
BucketTakeLPAwardedEvent
does not have enough information to build theBucketTake
, we now create a placeholder which references the LP award event. When theBucketTakeEvent
occurs (on the very next log index), it looks up the LP award event and updates state of all related entities. We associate these events by assuming the take event will always be the subsequent log index, which a cursory review of the code reveals is the case. Reviewer should confirm.This should handle the case where multiple
bucketTake
s occur in a single transaction, but that remains untested.Tested on
parvati
, which is able to sync up to current block height on goerli (9336296).