@@ -329,7 +329,7 @@ describe('SwapRouter gas tests', function () {
329
329
await snapshotGasCost ( router . connect ( trader ) . multicall ( data ) )
330
330
} )
331
331
332
- it ( '2 trades (directly to sender)' , async ( ) => {
332
+ it ( '3 trades (directly to sender)' , async ( ) => {
333
333
await weth9 . connect ( trader ) . deposit ( { value : 3 } )
334
334
await weth9 . connect ( trader ) . approve ( router . address , constants . MaxUint256 )
335
335
const swap0 = {
@@ -341,7 +341,15 @@ describe('SwapRouter gas tests', function () {
341
341
}
342
342
343
343
const swap1 = {
344
- path : encodePath ( [ tokens [ 1 ] . address , tokens [ 0 ] . address ] , [ FeeAmount . MEDIUM ] ) ,
344
+ path : encodePath ( [ tokens [ 0 ] . address , tokens [ 1 ] . address ] , [ FeeAmount . MEDIUM ] ) ,
345
+ recipient : trader . address ,
346
+ deadline : 1 ,
347
+ amountIn : 3 ,
348
+ amountOutMinimum : 1 ,
349
+ }
350
+
351
+ const swap2 = {
352
+ path : encodePath ( [ tokens [ 1 ] . address , tokens [ 2 ] . address ] , [ FeeAmount . MEDIUM ] ) ,
345
353
recipient : trader . address ,
346
354
deadline : 1 ,
347
355
amountIn : 3 ,
@@ -351,12 +359,40 @@ describe('SwapRouter gas tests', function () {
351
359
const data = [
352
360
router . interface . encodeFunctionData ( 'exactInput' , [ swap0 ] ) ,
353
361
router . interface . encodeFunctionData ( 'exactInput' , [ swap1 ] ) ,
362
+ router . interface . encodeFunctionData ( 'exactInput' , [ swap2 ] ) ,
354
363
]
355
364
356
365
await snapshotGasCost ( router . connect ( trader ) . multicall ( data ) )
357
366
} )
358
367
} )
359
368
369
+ it ( '3 trades (directly to sender)' , async ( ) => {
370
+ await weth9 . connect ( trader ) . deposit ( { value : 3 } )
371
+ await weth9 . connect ( trader ) . approve ( router . address , constants . MaxUint256 )
372
+ const swap0 = {
373
+ path : encodePath ( [ weth9 . address , tokens [ 0 ] . address ] , [ FeeAmount . MEDIUM ] ) ,
374
+ recipient : trader . address ,
375
+ deadline : 1 ,
376
+ amountIn : 3 ,
377
+ amountOutMinimum : 1 ,
378
+ }
379
+
380
+ const swap1 = {
381
+ path : encodePath ( [ tokens [ 1 ] . address , tokens [ 0 ] . address ] , [ FeeAmount . MEDIUM ] ) ,
382
+ recipient : trader . address ,
383
+ deadline : 1 ,
384
+ amountIn : 3 ,
385
+ amountOutMinimum : 1 ,
386
+ }
387
+
388
+ const data = [
389
+ router . interface . encodeFunctionData ( 'exactInput' , [ swap0 ] ) ,
390
+ router . interface . encodeFunctionData ( 'exactInput' , [ swap1 ] ) ,
391
+ ]
392
+
393
+ await snapshotGasCost ( router . connect ( trader ) . multicall ( data ) )
394
+ } )
395
+
360
396
describe ( '#exactInputSingle' , ( ) => {
361
397
it ( '0 -> 1' , async ( ) => {
362
398
await snapshotGasCost ( exactInputSingle ( tokens [ 0 ] . address , tokens [ 1 ] . address ) )
0 commit comments