-
Notifications
You must be signed in to change notification settings - Fork 120
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 dex ed #1196
Fix dex ed #1196
Conversation
Signed-off-by: zqhxuyuan <zqhxuyuan@gmail.com>
|
|
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.
Could reaping the dex account cause any other problems? I'd have to dive deeper but I feel like then the state of the dex could not match the account balance of dex account.
Maybe we could just send ed of manta, or create allowlist for non-reapable accounts
How big would that list grow to be? 🤔 |
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.
Can we have a real description please what problem this is solving and how exactly.
what is the concrete scenario you're worried about ? |
Does zenlink team know this issue or have they fixed it already in later release? |
yes, I've told them this issue. We may consider add some integration test into our chain. As zenlink's testcase is using tokens module not pallet_assets. |
add more info in the description. |
Description
fix dex ed when last user remove liquidity failed.
DEX commit: Manta-Network/Zenlink@853f41c#diff-48b4d8abc9afad5d3c79f61c7ad9b831eb830423e5709aaff6b6fd67acc3be3cR105-R110
i.e. A pair of(KMA,KSM), when add liquidity, user's KMA and KSM transfer to pair acocunt. And the liquidity amount is record as total_supply on pair account. when user remove liquidity, KMA and KSM return back to user account.
https://github.com/Manta-Network/Zenlink/blob/c2acc36bea02e6c2aa38f3b290e255dfd5c164dd/zenlink-protocol/src/swap/mod.rs#L135-L143
amount = remove_liquidity * reserve / total_supply, Let's say there's only one user add liquidity, now when user remove liquidity, remove_liquidity=total_supply, so the amount=reserve. amount_0 = KMA_balance(lp_account).
deposit ED of KMA to pair account is not going to work, because amount = KMA balance of pair account, and all the KMA on pair account will be transfer to user.
https://github.com/Manta-Network/Zenlink/blob/c2acc36bea02e6c2aa38f3b290e255dfd5c164dd/zenlink-protocol/src/swap/mod.rs#L176
The
T::MultiAssetsHandler::transfer
on original zenlink when transfer native token is using KeepAlive:https://github.com/zenlinkpro/Zenlink-DEX-Module/blob/7662acbff71cea3b35db918ceb9370e8929be991/zenlink-protocol/src/multiassets.rs#L100-L106
This will failed, because pair account can't transfer all KMA while keep alive at the same time.
For non native token, we already set as AllowDeath:
Manta/runtime/manta/src/zenlink.rs
Lines 153 to 157 in 51038df
Before we can approve this PR for merge, please make sure that all the following items have been checked off:
L-
group to this PRA-
andC-
groups to this PRA-calamari
and/orA-manta
if your changes are meant for/impact either of these (CI depends on it)Files changed
in the Github PR explorer.Situational Notes:
BaseFilter
. Ensure every extrinsic works from front-end. If there's corresponding tool, ensure both work for each other.try-runtime
. This includes migrations inherited from upstream changes, and you can search the diffs for modifications of#[pallet::storage]
items to check for any.