You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create one contract that can handle and track many atomic swaps. Each swap has a unique ID and can store some tokens when it is created. Its balance cannot be adjusted after that fact, until it is either claimed or aborted (when the swap is closed and the funds go to a recipient).
For the first step, this should just handle native tokens that are sent along with the "create swap" message (see env.msg.sent_funds), and these can be distributed with BankMsg::Send.
You can start with with cosmwasm-template, but as the various contracts in this package are rather customized, it might make sense to copy eg. cw20-escrow as a start and then modify it heavily.
Please cover it with reasonable unit tests. You can look at this integration test to get an idea of a successful end-to-end flow. For this contract, it would be nice to break it up into smaller pieces. Note it should be able to create both sides of the swap on the same contract and resolve them.
The text was updated successfully, but these errors were encountered:
@maurolacy I was doing cleanup and stubled upon https://github.com/CosmWasm/cosmwasm-examples/pull/2 which is when I started an atomic swap contract in Jan/Feb. The code uses a much older version of CosmWasm, but the key logic is the same. Maybe you can copy some stuff from that (I'm closing that PR)
This should be a basic contract that implements one half of the IOV atomic swap spec. There is also a Solidity implementation of atomic swap as well as one that supports ERC20 tokens, so creating such a contract allows any CosmWasm-based chain to swap tokens with an Ethereum-based chain, possibly on some off-chain DEX or just "over the counter".
Create one contract that can handle and track many atomic swaps. Each swap has a unique ID and can store some tokens when it is created. Its balance cannot be adjusted after that fact, until it is either claimed or aborted (when the swap is closed and the funds go to a recipient).
For the first step, this should just handle native tokens that are sent along with the "create swap" message (see
env.msg.sent_funds
), and these can be distributed withBankMsg::Send
.You can start with with
cosmwasm-template
, but as the various contracts in this package are rather customized, it might make sense to copy eg.cw20-escrow
as a start and then modify it heavily.Please cover it with reasonable unit tests. You can look at this integration test to get an idea of a successful end-to-end flow. For this contract, it would be nice to break it up into smaller pieces. Note it should be able to create both sides of the swap on the same contract and resolve them.
The text was updated successfully, but these errors were encountered: