2-Step Guide to Swap your DAI for CNV

Official Apr 1, 2022

In this article, we will show you how to swap your DAI for CNV by interacting with the contract directly.

TL;DR version:

Step 1: Approve DAI to Router

Go to https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f#writeContract

and submit “approve” transaction with inputs:

Usr”: 0x0A3e1c20B5384eB97D2CCfF9a96bc91f0c77e7dB

Wad” <amount of DAI you wish to trade including 18 decimals>

Step 2: Swap DAI for CNV

Go to https://etherscan.io/address/0x0A3e1c20B5384eB97D2CCfF9a96bc91f0c77e7dB#writeContract and submit “swapExactTokensForTokens” transaction with inputs:

amountIn: <the amount of DAI you wish to trade (including 18 decimals)>

amountOutMin: <the amount of CNV you wish to receive (including 18 decimals)>

path: [0x6B175474E89094C44Da98b954EedeAC495271d0F,0x000000007a58f5f58E697e51Ab0357BC9e260A04]

To: <your address>

Deadline: 1449936454444555599999

Note: Important! If on step 2 the gas is very high, it means the “amountOutMin” is too high, try inputting a smaller amount.

Detailed version:

Make sure you have DAI in your wallet.

Step 1: Approve DAI to the router contract by following the steps below.

Head to DAI token contract on Etherscan: https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f

Click on 'Contract' and click on 'Write Contract'.

Click on 'Connect to Web3'. This will prompt you to connect to your MetaMask wallet. Once MetaMask is connected, the button will turn from 'Red' to 'Green'.

Here we will approve the AMM router contract to take our DAI for the swap.

Click on 'Approve' as shown below. This should toggle down two inputs:
- one for input address: the 'usr' field
- the other for the amount: the 'wad' field

In the 'usr' field, enter the Router address:
0x0A3e1c20B5384eB97D2CCfF9a96bc91f0c77e7dB

In the 'wad' field, enter the amount of DAI you want to trade (remember the 18 decimals!)

For example, the below is for USD 1,000.

Click on 'Write' which will prompt MetaMask and approve the transaction.

Now you have completed the approval of DAI and can now proceed to the router where we can perform the swap.

Step 2: Make the Swap

Proceed to the Router contract on Etherscan:
https://etherscan.io/address/0x0A3e1c20B5384eB97D2CCfF9a96bc91f0c77e7dB#writeContract

Again, click on 'Contract' and 'Write Contract', then proceed to 'Connect to Web3'.

Scroll down the list and click on 'swapExactTokensForTokens', and click on it so that it toggles the input fields.

Input the following:

amountIn:
<the amount of DAI you wish to trade (including 18 decimals)>

amountOutMin:
<the amount of CNV you wish to receive (including 18 decimals)>

path: [0x6B175474E89094C44Da98b954EedeAC495271d0F,0x000000007a58f5f58E697e51Ab0357BC9e260A04]

To:
<your address>

Deadline:
1449936454444555599999

Note: Make sure the “path” input and the “deadline” input are as above, and replace “amountIn”, “amountOutMin”, and “to”.


Click on 'Write' which will prompt your MetaMask to pop up where you confirm the transaction.

NOTE: IF GAS PRICE IS VERY HIGH - DO NOT CONFIRM! IT MEANS THE “amountOutMin” is too high, try changing it to a lower number.

How much to put in 'amountOutMin'?

Let's say you want to trade 1000 DAI, thus 'amountIn' will be 1000000000000000000000.

Referring to (https://www.dextools.io/app/ether/pair-explorer/0x84d53cba013d0163bb07d65d5123d1634bc2a575), the CNV price is $200, thus for 1000 DAI you should get 5 CNV, so on 'amountOutMin' you should input 5000000000000000000.

That's it, hope you enjoy our step-by-step guide on 'How to Swap your DAI to CNV'.


Tags