-
Notifications
You must be signed in to change notification settings - Fork 2
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 batch withdrawal to work with auto-closing positions #241
Comments
Note: a position can be closed by the DEX engine for arbitrary reasons (from the pov of the explorer). The explorer needs to support those cases. The core logic is the same: if we are trying to withdraw a position that is closed, then we just add Specifically, we shouldn't assume that the closed-withdraw mismatch happens exclusively for positions that are |
For now we can assume that the user has all their LPs in the main account, since we do not support subaccount filtering of positions. When penumbra-zone/penumbra#4985 gets merged we will be able to make it work for that case as well. |
Context
On the Penumbra DEX, liquidity position can be set to
close_on_fill
(aka. "auto-closing") which means that they will be automatically closed by the DEX engine after being filled.Since those positions close without any user actions, this means that token balance state of that user can lag behind the actual state of the position: the user will own an
lpnft_opened
to a position that is closed.Bug
The DEX interface has "batch close" and "batch withdraw" features, which are currently broken when the position gets filled. This means that a user exercising limit orders will most likely lock themselves out of being able to do batch withdraws. We should fix this.
Bug mechanics
The DEX interface fetches the latest for each liquidity position that it is displaying. If it detects a position as
Closed
it will try to include it as part of a batch withdraw action. If the user does not possess an equivalentlpnft_closed
the transcation will fail to plan with the following error ("Insufficient balance"):Solution
Since the DEX engine has all the context it needs to detect those discrepancies (local state: opened, remote state: closed), it can remediate the insufficient funds issue by adding
PositionClose
to the transaction planner request.This is possible for two reasons:
PositionWithdraw
actionPositionWithdraw
action with the output of thePositionClose
action (-opened + closed - closed + withdraw
)Alternative solution
Exclude those mismatch-y positions from the batch withdraw. We should not do that. It's simpler to let the planner handle all of this for us.
The text was updated successfully, but these errors were encountered: