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

Add cw20 support to atomic swap contract #27

Closed
ethanfrey opened this issue Jul 28, 2020 · 6 comments
Closed

Add cw20 support to atomic swap contract #27

ethanfrey opened this issue Jul 28, 2020 · 6 comments
Assignees

Comments

@ethanfrey
Copy link
Member

Builds on #26

Just like cw20-escrow supports both native tokens and cw20 tokens (via Receive), the atomic swap contract should be extended with this. We do not want a TopUp like cw20-escrow, but the creation via direct function call or via the cw20::Receive entry point serve as a useful model on how to implement this.

To test it, try swaping a native token vs a cw20 token using the same CosmWasm contract for both sides.

Once completed we can swap any native or cw20 token against eth or any erc20 token. Well.. we would need a UI for that, but the contracts are ready.

@maurolacy
Copy link
Contributor

maurolacy commented Sep 2, 2020

Initial implementation is under the cw20-atomic-swaps branch. Unit tests to follow; PR to follow after it.

I implemented functionality for the two tokens (native vs. cw20) into the same functions, for simplicity and consistency. Can separate them into different functions for clarity if you think it's worth it.

@maurolacy
Copy link
Contributor

maurolacy commented Sep 2, 2020

There are some FIXME? in the code: basically, what if somebody sents a non-empty array of native coins, or a cw20 coin, but sets their amounts to zero? Do we need to check / reject those messages, or are they rejected by the SDK?

Another question: Is it worth it to improve the logs a little? Log the sender and amounts on creation, by example.

@maurolacy
Copy link
Contributor

PR: #72.

@ethanfrey
Copy link
Member Author

Counting zero amounts as missing is a good check. I would filter out zeros in the native coins, and then ensure it has length >0 and only save the filtered list.

For cw20 coins, yeah, rejecting 0 amounts sounds good. We should also reject such sends in cw20-base. Can you make an issue for that?

@maurolacy
Copy link
Contributor

Sure. #76 created.

@ethanfrey
Copy link
Member Author

Closed by #72

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

No branches or pull requests

2 participants