From f40578aa1ac4776f4e657111e275b422e0d01394 Mon Sep 17 00:00:00 2001 From: elshan_eth Date: Thu, 27 Jun 2024 19:39:50 +0200 Subject: [PATCH] mv commpon part to functions --- ...ngle token exact in with fees - cold slots | 2 +- ...ngle token exact in with fees - warm slots | 2 +- ...ngle token exact in with fees - warm slots | 2 +- pvt/benchmarks/src/PoolBenchmark.behavior.ts | 43 +++++++++---------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] swap single token exact in with fees - cold slots b/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] swap single token exact in with fees - cold slots index cccd62a5d..f946bdf47 100644 --- a/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] swap single token exact in with fees - cold slots +++ b/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] swap single token exact in with fees - cold slots @@ -1 +1 @@ -177.1k \ No newline at end of file +177.0k \ No newline at end of file diff --git a/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] swap single token exact in with fees - warm slots b/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] swap single token exact in with fees - warm slots index 906872330..2927f9eb7 100644 --- a/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] swap single token exact in with fees - warm slots +++ b/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - Standard] swap single token exact in with fees - warm slots @@ -1 +1 @@ -160.6k \ No newline at end of file +160.5k \ No newline at end of file diff --git a/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - With rate] swap single token exact in with fees - warm slots b/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - With rate] swap single token exact in with fees - warm slots index 514112d22..1ce178592 100644 --- a/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - With rate] swap single token exact in with fees - warm slots +++ b/pkg/pool-weighted/test/gas/.hardhat-snapshots/[WeightedPool - With rate] swap single token exact in with fees - warm slots @@ -1 +1 @@ -176.8k \ No newline at end of file +176.7k \ No newline at end of file diff --git a/pvt/benchmarks/src/PoolBenchmark.behavior.ts b/pvt/benchmarks/src/PoolBenchmark.behavior.ts index efab3c0a0..a33253bf2 100644 --- a/pvt/benchmarks/src/PoolBenchmark.behavior.ts +++ b/pvt/benchmarks/src/PoolBenchmark.behavior.ts @@ -67,6 +67,22 @@ export class Benchmark { let poolTokens: string[]; + const setStaticSwapFeePercentage = async () => { + const setPoolSwapFeeAction = await actionId(this.vault, 'setStaticSwapFeePercentage'); + + const authorizerAddress = await this.vault.getAuthorizer(); + const authorizer = await deployedAt('v3-solidity-utils/BasicAuthorizerMock', authorizerAddress); + + await authorizer.grantRole(setPoolSwapFeeAction, admin.address); + + await this.vault.connect(admin).setStaticSwapFeePercentage(this.pool, SWAP_FEE); + }; + + const initializePool = async () => { + initialBalances = Array(poolTokens.length).fill(TOKEN_AMOUNT); + await router.connect(alice).initialize(this.pool, poolTokens, initialBalances, FP_ZERO, false, '0x'); + }; + before('setup signers', async () => { [, alice, admin] = await ethers.getSigners(); }); @@ -145,19 +161,11 @@ export class Benchmark { }); sharedBeforeEach('set pool fee', async () => { - const setPoolSwapFeeAction = await actionId(this.vault, 'setStaticSwapFeePercentage'); - - const authorizerAddress = await this.vault.getAuthorizer(); - const authorizer = await deployedAt('v3-solidity-utils/BasicAuthorizerMock', authorizerAddress); - - await authorizer.grantRole(setPoolSwapFeeAction, admin.address); - - await this.vault.connect(admin).setStaticSwapFeePercentage(this.pool, SWAP_FEE); + await setStaticSwapFeePercentage(); }); sharedBeforeEach('initialize pool', async () => { - initialBalances = Array(poolTokens.length).fill(TOKEN_AMOUNT); - await router.connect(alice).initialize(this.pool, poolTokens, initialBalances, FP_ZERO, false, '0x'); + await initializePool(); await actionAfterInit(); }); @@ -213,8 +221,7 @@ export class Benchmark { }); sharedBeforeEach('initialize pool', async () => { - initialBalances = Array(poolTokens.length).fill(TOKEN_AMOUNT); - await router.connect(alice).initialize(this.pool, poolTokens, initialBalances, FP_ZERO, false, '0x'); + await initializePool(); }); it('pool preconditions', async () => { @@ -239,19 +246,11 @@ export class Benchmark { }); sharedBeforeEach('set pool fee', async () => { - const setPoolSwapFeeAction = await actionId(this.vault, 'setStaticSwapFeePercentage'); - - const authorizerAddress = await this.vault.getAuthorizer(); - const authorizer = await deployedAt('v3-solidity-utils/BasicAuthorizerMock', authorizerAddress); - - await authorizer.grantRole(setPoolSwapFeeAction, admin.address); - - await this.vault.connect(admin).setStaticSwapFeePercentage(this.pool, SWAP_FEE); + await setStaticSwapFeePercentage(); }); sharedBeforeEach('initialize pool', async () => { - initialBalances = Array(poolTokens.length).fill(TOKEN_AMOUNT); - await router.connect(alice).initialize(this.pool, poolTokens, initialBalances, FP_ZERO, false, '0x'); + await initializePool(); }); it('pool and protocol fee preconditions', async () => {