MoonSwap: A platform for token swaps between DAOs

Moonshot Collective Anon
Moonshot Collective
4 min readDec 20, 2021

What is MoonSwap?

MoonSwap is a tool that enables DAOs to swap, borrow, lend, and stream tokens from their treasuries, in order to empower shared interests and foster long-term partnerships between DAOs.

How it was built

MoonSwap was developed by a collaborative effort between farque65, qedk, dhaiwat10, miral, nazeeh21. This app is built on the top of scaffold-eth which allows you to quickly experiment with solidity using a front end that adapts to your Smart Contract. It provides extensive documentation on tools that you can use to develop an app using Solidity for Smart Contracts, Hardhat (which provides an ethereum development environment), React for frontend, Ethers.js to interact with the deployed Smart Contract, and Ant for the user interface.

Here’s how MoonSwap works:

  1. Create Swap: 1st party creates a swap by adding the number of tokens they want to swap and their token address. 1st party also needs to enter the address of the 2nd party they’re sending to. 1st party can predefine the number of tokens they should get in return from the 2nd party.
  2. Sharing the swap: After successfully creating their swap, a shareable URL will be generated. The 1st party shares the URL with the 2nd party, and thus the 2nd party can choose to commit to the swap from that link.
  3. Commit Swap: The URL will open a page with the token details already pre-filled. The 2nd party can simply click on the Commit Swap button and the swap will commence. How easy is that?

Check out a detailed walkthrough below!

Here we’ll go through each process of swapping the tokens.

  1. Go to the MoonSwap Landing Page. Feel free to watch the video explaining how MoonSwap works!

2. Next, click on “Start Swap”. You should see a dashboard like this.

3. In the In party address field, enter the address of the 1st party. In the token hash field, insert the token hash of the token you want to swap.

For example: the token hash of dGTC is 0xE0F028C08852D70243BD7c6EF030bCf6049e6d98.

In the Token amount field, insert the number of tokens you want to swap.

4. In the Out party address field, enter the address of the 2nd party. In the token hash field insert the token hash of the token with which you want to swap the 1st token for.

For example: token hash of dETH is 0x1d269Cf95A2732ce98fAaF909642D756b59Af0aF.

In the Token Amount field, insert the number of tokens you want in return from the 2nd party.

5. After entering all the details, click on Create Swap, and MoonSwap will try to access the token from your wallet in order to swap it. Thus, your wallet will check if you have permitted MoonSwap to access the required amount of tokens. This is known as the Allowance. If your allowance for the token to be swapped is low, then a metamask pop-up will appear seeking your permission to increase the allowance. If this is necessary, select allow, and the app will increase the allowance and a swap will be created.

6. After successfully creating your swap, a link with a unique swap id will be generated, which you need to share with the 2nd party.

7. The 2nd party selects the link, connects their ethereum wallet, and the Commit To Swap dashboard will open. This dashboard will display all the swap details like swap id, 1st party, 2nd party, in token, and out token.

8. To complete the swap successfully, the 2nd party needs to click on the Commit Swap button. If you are the 2nd party, before committing the swap make sure that you are connected to the MoonSwap app using the same address in the 2nd party field.

9. Once the swap is successful, you will see a “Swap complete” message. Congrats! You have successfully swapped tokens in just a few clicks.

In conclusion

MoonSwap is a great tool for DAOs who wish to exchange tokens between them. For more information, check out the app here, or the documentation on Github here. Are you a dev Interested in working on cutting-edge DAO tech? Join us in Moonshot Collective, by reaching out through Twitter, Discord, or Telegram. You can find our links in this Linktree.

--

--