@@ -37,7 +37,7 @@ describe("do some tests", () => {
3737 const daiContract = new ethers . Contract (
3838 erc20 . dai . address ,
3939 erc20 . dai . abi ,
40- wallet
40+ wallet ,
4141 )
4242 const daiBalanceWei = await daiContract . balanceOf ( wallet . address )
4343 const daiBalance = ethers . utils . formatUnits ( daiBalanceWei , 18 )
@@ -49,41 +49,41 @@ describe("do some tests", () => {
4949 const ethBalance = ethers . utils . formatEther ( ethBalanceWei )
5050 expect ( parseFloat ( ethBalance ) ) . toBe ( 1000 )
5151 } )
52-
52+
5353 test ( "buy DAI from Uniswap" , async ( ) => {
5454 // 1. instantiate contracts
5555 const daiContract = new ethers . Contract (
5656 erc20 . dai . address ,
5757 erc20 . dai . abi ,
58- wallet
58+ wallet ,
5959 )
6060 const uniswapFactoryContract = new ethers . Contract (
6161 uniswap . factory . address ,
6262 uniswap . factory . abi ,
63- wallet
63+ wallet ,
6464 )
6565 const daiExchangeAddress = await uniswapFactoryContract . getExchange (
66- erc20 . dai . address
66+ erc20 . dai . address ,
6767 )
6868 const daiExchangeContract = new ethers . Contract (
6969 daiExchangeAddress ,
7070 uniswap . exchange . abi ,
71- wallet
71+ wallet ,
7272 )
73-
73+
7474 // 2. do the actual swapping
7575 await daiExchangeContract . ethToTokenSwapInput (
7676 1 , // min amount of token retrieved
7777 2525644800 , // random timestamp in the future (year 2050)
7878 {
7979 gasLimit : 4000000 ,
8080 value : ethers . utils . parseEther ( "5" ) ,
81- }
81+ } ,
8282 )
83-
83+
8484 // util function
85- const fromWei = x => ethers . utils . formatUnits ( x , 18 )
86-
85+ const fromWei = ( x ) => ethers . utils . formatUnits ( x , 18 )
86+
8787 // 3. check DAI balance
8888 const daiBalanceWei = await daiContract . balanceOf ( wallet . address )
8989 const daiBalance = parseFloat ( fromWei ( daiBalanceWei ) )
0 commit comments