Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

[Liquidity swaps] Ensuring enough funds on pool before swap #16

Open
souradeep-das opened this issue May 26, 2021 · 1 comment
Open

Comments

@souradeep-das
Copy link

Issue

https://github.com/enyalabs/OMGX_wallet/issues/22
Someone willing to swap on/off needs to ensure there is enough in the pool on the other side, otherwise they end up losing funds to the LP. This process has to be manual. There should be an external service which confirms this fact before someone can use the contracts.

Possible solutions

Some solutions to remove the external service and make it trustless could be-

Reserve tx - A ticket/reserve mechanism can be used where a tx is first sent to the LP on the withdrawal chain, this is to reserve the amount from the pool for a certain period of time, so that someone else couldn’t race out and clear funds from the pool before it can be withdrawn

A circular cross-domain tx - After supplying to L2 pool, a cross-domain tx is sent to withdraw from the L1 pool. An unsuccessful transfer on L1 ( i.e. if the L1 pool doesn’t have enough funds) could trigger another cross-domain tx back to the L2 pool, and allowing to take back the funds for a failed swap. There could be a chance to break this up into two separate tx considering the gas. Note, this could be a process to save funds for a rare case, and higher gas should be okay

@souradeep-das
Copy link
Author

souradeep-das commented Jun 22, 2021

#37 adds protection on the swap-off side, protection wasn't added on the swap-on side, since traffic is expected towards swap-offs

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant