Skip to content
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

Handle Swap Orders in On-Ramp Experience #7

Open
zugdev opened this issue Oct 13, 2024 · 10 comments
Open

Handle Swap Orders in On-Ramp Experience #7

zugdev opened this issue Oct 13, 2024 · 10 comments

Comments

@zugdev
Copy link

zugdev commented Oct 13, 2024

In developing the UUSD on-ramp experience to Gnosis we must handle swapping from any available token in CoW Swap to LUSD and UBQ. The suggested approach in #4 is just bundling swap, mint and bridge into a multicall. However that's not viable since CoW Swap operates in an asynchronous way, you don't get your tokens as soon as you send a swap transaction, a relayer has to send your order to solvers and then it settles which can take up to minutes. This also means that we must track potentially multiple orders at the same time in our backend without mixing, which needs extra care. Another super delicate case is order expiration: what if CoW Swap fails to resolve the swap in sufficient time? The solution should return funds in that case and should warn possible failure based on pool liquidity even before the user submits a transaction.

@0x4007
Copy link
Member

0x4007 commented Oct 13, 2024

Then we make an escrow contract and pay for failures. I expect them to be rare.

@rndquu rfc

@zugdev
Copy link
Author

zugdev commented Oct 13, 2024

Then we make an escrow contract and pay for failures. I expect them to be rare.

@rndquu rfc

It depends on input asset's liquidity.

@0x4007
Copy link
Member

0x4007 commented Oct 13, 2024

Then we make an escrow contract and pay for failures. I expect them to be rare.
@rndquu rfc

It depends on input asset's liquidity.

We can whitelist mainstream assets if its a problem

@zugdev
Copy link
Author

zugdev commented Oct 13, 2024

I don't think it will be, I can work around it with their API. And also part of what I was saying in main issue is that this other "parts" should be built to never fail. I hope there isn't a need for a escrow contract but at the end of the day it's a private key doing those tasks at the back, we can just hop in and manually compensate in the extremely unlucky scenario of a fail.

@0x4007
Copy link
Member

0x4007 commented Oct 14, 2024

Can't the transaction be made to be atomic? It seems conceptually possible. If it fails just revert everything.

We might even be able to make use of permits for redeeming from escrow.

Basically if our system detects a failure we can send a permit for the user to withdraw and try again.

We just need to make sure that the escrow is regularly cleared out because it seems like a shaky part of the system regarding attack vectors.

@zugdev
Copy link
Author

zugdev commented Oct 14, 2024

Can't the transaction be made to be atomic? It seems conceptually possible. If it fails just revert everything.

Problem is we are on mainnet, gas is expensive, we will just lose a lot of funds. I think retrying the swaps in the unlikely scenario a quote is not met is the best approach.

We might even be able to make use of permits for redeeming from escrow.

This is a good idea. I also think that if we have a very precise fees and quoting mechanism we can allow users to receive from some UUSD already in Gnosis and then use their submited funds to cover it. Then we could have a instantaneous UUSD feature for an extra fee.

@0x4007
Copy link
Member

0x4007 commented Oct 14, 2024

This is a good idea. I also think that if we have a very precise fees and quoting mechanism we can allow users to receive from some UUSD already in Gnosis and then use their submited funds to cover it. Then we could have a instantaneous UUSD feature for an extra fee.

I like the idea of better UX but this also means that we are assuming risk. Anyways, if we are getting paid for it then I think its worth a shot. We might just need to set limits for safety reasons i.e. instant transfer up to 10k UUSD a day etc.

@zugdev
Copy link
Author

zugdev commented Oct 14, 2024

Yes that makes sense, I think we can try it out post MVP.

@rndquu
Copy link
Member

rndquu commented Jan 22, 2025

li.fi has a widget SDK (demo) which supports bridging via https://bridge.gnosischain.com.

@zugdev
Copy link
Author

zugdev commented Jan 23, 2025

Super cool, thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

3 participants