In this article, we will show you how to swap your DAI for CNV by interacting with the contract directly.
Step 1: Approve DAI to Router
and submit “approve” transaction with inputs:
“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)>
To: <your address>
Note: Important! If on step 2 the gas is very high, it means the “amountOutMin” is too high, try inputting a smaller amount.
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:
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:
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:
<the amount of DAI you wish to trade (including 18 decimals)>
<the amount of CNV you wish to receive (including 18 decimals)>
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'.