@@ -143,7 +143,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
143143
144144 const userDaiStableDebtAmountBefore = await daiStableDebtContract . balanceOf ( userAddress ) ;
145145
146- await mockAugustus . expectSwap ( weth . address , dai . address , amountWETHtoSwap , amountWETHtoSwap , expectedDaiAmount ) ;
146+ await mockAugustus . expectBuy ( weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount , expectedDaiAmount ) ;
147147 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
148148 'buy' ,
149149 [ weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount ]
@@ -233,7 +233,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
233233
234234 const userDaiStableDebtAmountBefore = await daiStableDebtContract . balanceOf ( userAddress ) ;
235235
236- await mockAugustus . expectSwap ( weth . address , dai . address , amountWETHtoSwap , amountWETHtoSwap , expectedDaiAmount ) ;
236+ await mockAugustus . expectBuy ( weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount , expectedDaiAmount ) ;
237237 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
238238 'buy' ,
239239 [ weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount ]
@@ -326,7 +326,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
326326 // Open user Debt
327327 await pool . connect ( user ) . borrow ( dai . address , expectedDaiAmount , 1 , 0 , userAddress ) ;
328328
329- await mockAugustus . expectSwap ( weth . address , dai . address , amountWETHtoSwap , amountWETHtoSwap , expectedDaiAmount ) ;
329+ await mockAugustus . expectBuy ( weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount , expectedDaiAmount ) ;
330330 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
331331 'buy' ,
332332 [ weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount ]
@@ -382,7 +382,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
382382 // Open user Debt
383383 await pool . connect ( user ) . borrow ( dai . address , expectedDaiAmount , 2 , 0 , userAddress ) ;
384384
385- await mockAugustus . expectSwap ( weth . address , dai . address , amountWETHtoSwap , amountWETHtoSwap , expectedDaiAmount ) ;
385+ await mockAugustus . expectBuy ( weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount , expectedDaiAmount ) ;
386386 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
387387 'buy' ,
388388 [ weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount ]
@@ -438,7 +438,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
438438 new BigNumber ( amountWETHtoSwap . toString ( ) ) . div ( daiPrice . toString ( ) ) . toFixed ( 0 )
439439 ) ;
440440
441- await mockAugustus . expectSwap ( weth . address , dai . address , amountWETHtoSwap , amountWETHtoSwap , expectedDaiAmount ) ;
441+ await mockAugustus . expectBuy ( weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount , expectedDaiAmount ) ;
442442 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
443443 'buy' ,
444444 [ weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount ]
@@ -495,7 +495,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
495495 await pool . connect ( user ) . borrow ( dai . address , expectedDaiAmount , 1 , 0 , userAddress ) ;
496496
497497 const bigMaxAmountToSwap = amountWETHtoSwap . mul ( 2 ) ;
498- await mockAugustus . expectSwap ( weth . address , dai . address , bigMaxAmountToSwap , bigMaxAmountToSwap , expectedDaiAmount ) ;
498+ await mockAugustus . expectBuy ( weth . address , dai . address , bigMaxAmountToSwap , expectedDaiAmount , expectedDaiAmount ) ;
499499 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
500500 'buy' ,
501501 [ weth . address , dai . address , bigMaxAmountToSwap , expectedDaiAmount ]
@@ -572,7 +572,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
572572
573573 const userDaiStableDebtAmountBefore = await daiStableDebtContract . balanceOf ( userAddress ) ;
574574
575- await mockAugustus . expectSwap ( weth . address , dai . address , amountWETHtoSwap , amountWETHtoSwap , expectedDaiAmount ) ;
575+ await mockAugustus . expectBuy ( weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount , expectedDaiAmount ) ;
576576 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
577577 'buy' ,
578578 [ weth . address , dai . address , amountWETHtoSwap , expectedDaiAmount ]
@@ -666,19 +666,21 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
666666 const userDaiStableDebtAmountBefore = await daiStableDebtContract . balanceOf ( userAddress ) ;
667667
668668 // Add a % to repay on top of the debt
669- const liquidityToSwap = await convertToCurrencyDecimals ( weth . address , '11' ) ;
669+ const flashLoanAmount = await convertToCurrencyDecimals ( weth . address , '11' ) ;
670670 const amountToRepay = new BigNumber ( expectedDaiAmount . toString ( ) )
671671 . multipliedBy ( 1.1 )
672672 . toFixed ( 0 ) ;
673673
674- await mockAugustus . expectSwap ( weth . address , dai . address , liquidityToSwap , liquidityToSwap , amountToRepay ) ;
674+ await mockAugustus . expectBuy ( weth . address , dai . address , flashLoanAmount , expectedDaiAmount , amountToRepay ) ;
675+ const liquidityToSwap = await convertToCurrencyDecimals ( weth . address , '10.8' ) ;
676+
675677 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
676678 'buy' ,
677679 [ weth . address , dai . address , liquidityToSwap , expectedDaiAmount ]
678680 ) ;
679681
680- const flashloanPremium = liquidityToSwap . mul ( 9 ) . div ( 10000 ) ;
681- const flashloanTotal = liquidityToSwap . add ( flashloanPremium ) ;
682+ const flashloanPremium = flashLoanAmount . mul ( 9 ) . div ( 10000 ) ;
683+ const flashloanTotal = flashLoanAmount . add ( flashloanPremium ) ;
682684 await aWETH . connect ( user ) . approve ( paraswapRepayAdapter . address , flashloanTotal ) ;
683685 const userAEthBalanceBefore = await aWETH . balanceOf ( userAddress ) ;
684686
@@ -704,7 +706,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
704706 . flashLoan (
705707 paraswapRepayAdapter . address ,
706708 [ weth . address ] ,
707- [ liquidityToSwap . toString ( ) ] ,
709+ [ flashLoanAmount . toString ( ) ] ,
708710 [ 0 ] ,
709711 userAddress ,
710712 params ,
@@ -764,19 +766,20 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
764766 userAddress
765767 ) ;
766768
767- const liquidityToSwap = await convertToCurrencyDecimals ( weth . address , '11' ) ;
769+ const flashLoanAmount = await convertToCurrencyDecimals ( weth . address , '11' ) ;
770+ const liquidityToSwap = await convertToCurrencyDecimals ( weth . address , '10.8' ) ;
768771 const amountToRepay = new BigNumber ( expectedDaiAmount . toString ( ) )
769772 . multipliedBy ( 1.1 )
770773 . toFixed ( 0 ) ;
771774
772- await mockAugustus . expectSwap ( weth . address , dai . address , liquidityToSwap , liquidityToSwap , amountToRepay ) ;
775+ await mockAugustus . expectBuy ( weth . address , dai . address , flashLoanAmount , expectedDaiAmount , amountToRepay ) ;
773776 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
774777 'buy' ,
775778 [ weth . address , dai . address , liquidityToSwap , expectedDaiAmount ]
776779 ) ;
777780
778- const flashloanPremium = liquidityToSwap . mul ( 9 ) . div ( 10000 ) ;
779- const flashloanTotal = liquidityToSwap . add ( flashloanPremium ) ;
781+ const flashloanPremium = flashLoanAmount . mul ( 9 ) . div ( 10000 ) ;
782+ const flashloanTotal = flashLoanAmount . add ( flashloanPremium ) ;
780783 await aWETH . connect ( user ) . approve ( paraswapRepayAdapter . address , flashloanTotal ) ;
781784 const userAEthBalanceBefore = await aWETH . balanceOf ( userAddress ) ;
782785
@@ -800,7 +803,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
800803 . flashLoan (
801804 paraswapRepayAdapter . address ,
802805 [ weth . address ] ,
803- [ liquidityToSwap . toString ( ) ] ,
806+ [ flashLoanAmount . toString ( ) ] ,
804807 [ 0 ] ,
805808 userAddress ,
806809 params ,
@@ -863,7 +866,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
863866 const liquidityToSwap = amountWETHtoSwap ;
864867 const userAEthBalanceBefore = await aWETH . balanceOf ( userAddress ) ;
865868
866- await mockAugustus . expectSwap ( weth . address , dai . address , liquidityToSwap , liquidityToSwap , expectedDaiAmount ) ;
869+ await mockAugustus . expectBuy ( weth . address , dai . address , liquidityToSwap , expectedDaiAmount , expectedDaiAmount ) ;
867870 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
868871 'buy' ,
869872 [ weth . address , dai . address , liquidityToSwap , expectedDaiAmount ]
@@ -940,7 +943,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
940943 const liquidityToSwap = amountWETHtoSwap ;
941944 const userAEthBalanceBefore = await aWETH . balanceOf ( userAddress ) ;
942945
943- await mockAugustus . expectSwap ( weth . address , dai . address , liquidityToSwap , liquidityToSwap , expectedDaiAmount ) ;
946+ await mockAugustus . expectBuy ( weth . address , dai . address , liquidityToSwap , expectedDaiAmount , expectedDaiAmount ) ;
944947 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
945948 'buy' ,
946949 [ weth . address , dai . address , liquidityToSwap , expectedDaiAmount ]
@@ -1014,7 +1017,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
10141017
10151018 const liquidityToSwap = amountWETHtoSwap ;
10161019
1017- await mockAugustus . expectSwap ( weth . address , dai . address , liquidityToSwap , liquidityToSwap , expectedDaiAmount ) ;
1020+ await mockAugustus . expectBuy ( weth . address , dai . address , liquidityToSwap , expectedDaiAmount , expectedDaiAmount ) ;
10181021 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
10191022 'buy' ,
10201023 [ weth . address , dai . address , liquidityToSwap , expectedDaiAmount ]
@@ -1062,7 +1065,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
10621065 const bigMaxAmountToSwap = amountWETHtoSwap . mul ( 2 ) ;
10631066 await aWETH . connect ( user ) . approve ( paraswapRepayAdapter . address , bigMaxAmountToSwap ) ;
10641067
1065- await mockAugustus . expectSwap ( weth . address , dai . address , bigMaxAmountToSwap , bigMaxAmountToSwap , expectedDaiAmount ) ;
1068+ await mockAugustus . expectBuy ( weth . address , dai . address , bigMaxAmountToSwap , expectedDaiAmount , expectedDaiAmount ) ;
10661069 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
10671070 'buy' ,
10681071 [ weth . address , dai . address , bigMaxAmountToSwap , expectedDaiAmount ]
@@ -1127,7 +1130,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
11271130
11281131 const liquidityToSwap = amountWETHtoSwap ;
11291132
1130- await mockAugustus . expectSwap ( weth . address , dai . address , liquidityToSwap , liquidityToSwap , expectedDaiAmount ) ;
1133+ await mockAugustus . expectBuy ( weth . address , dai . address , liquidityToSwap , expectedDaiAmount , expectedDaiAmount ) ;
11311134 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
11321135 'buy' ,
11331136 [ weth . address , dai . address , liquidityToSwap , expectedDaiAmount ]
@@ -1219,7 +1222,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
12191222 . toFixed ( 0 ) ;
12201223
12211224
1222- await mockAugustus . expectSwap ( weth . address , dai . address , liquidityToSwap , liquidityToSwap , amountToRepay ) ;
1225+ await mockAugustus . expectBuy ( weth . address , dai . address , liquidityToSwap , expectedDaiAmount , amountToRepay ) ;
12231226 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
12241227 'buy' ,
12251228 [ weth . address , dai . address , liquidityToSwap , expectedDaiAmount ]
@@ -1312,7 +1315,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => {
13121315 . toFixed ( 0 ) ;
13131316
13141317
1315- await mockAugustus . expectSwap ( weth . address , dai . address , liquidityToSwap , liquidityToSwap , amountToRepay ) ;
1318+ await mockAugustus . expectBuy ( weth . address , dai . address , liquidityToSwap , expectedDaiAmount , amountToRepay ) ;
13161319 const mockAugustusCalldata = mockAugustus . interface . encodeFunctionData (
13171320 'buy' ,
13181321 [ weth . address , dai . address , liquidityToSwap , expectedDaiAmount ]
0 commit comments