Skip to content

Commit

Permalink
mv commpon part to functions
Browse files Browse the repository at this point in the history
  • Loading branch information
elshan-eth committed Jun 27, 2024
1 parent 456c700 commit f40578a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
177.1k
177.0k
Original file line number Diff line number Diff line change
@@ -1 +1 @@
160.6k
160.5k
Original file line number Diff line number Diff line change
@@ -1 +1 @@
176.8k
176.7k
43 changes: 21 additions & 22 deletions pvt/benchmarks/src/PoolBenchmark.behavior.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down

0 comments on commit f40578a

Please sign in to comment.