-
Notifications
You must be signed in to change notification settings - Fork 193
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
feat(perp): Gracefully handle errors in MsgLiquidate #844
Labels
Comments
Let's keep this without merging, there are some comments from @godismercilex about it. |
I think for the sake of simplicity, I would add a new Msg called message MsgMultiLiquidate {
repeated msgs_liquidate MsgLiquidate = 1;
}
message MsgMultiLiquidateResponse {
message LiquidationResponse {
// reports the index of a successful liquidation
uint64 index = 1;
MsgLiquidateResponse resp = 2;
}
repeated LiquidationResponse = 1;
} At golang level: func (k Keeper) MultiLiquidate(ctx sdk.Context, m MsgMultiLiquidate) MsgMultiLiquidateResponse {
var responses []LiquidationResponse
for index, liquidation := range m.MsgsLiquidate {
cacheCtx, commit := ctx.CacheContext()
liquidationResp, err := k.Liquidate(cacheCtx, liquidation)
if err != nil {
continue
// or maybe here we wanna add extra failure events ???
}
commit()
responses = append(responses, LiquidationResponse { Index: index, MsgLiquidateResponse: liquidationResp }
}
} |
If we add the error in the liquidation response proto that would be nice |
All in then with the MultiLiquidate message. |
Need to think about limiting the number of liquidations per block. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Makes the validation checks skip the part of execution that closes a position and sends funds if there's:
Desired use case: If two
MsgLiquidate
messages are included in the same transaction and one raises an error, the transaction should still succeed (and only liquidate based on the valid message).The text was updated successfully, but these errors were encountered: