Skip to content

Commit

Permalink
rename signer
Browse files Browse the repository at this point in the history
  • Loading branch information
andresaiello committed Oct 5, 2023
1 parent fcafd22 commit 9c54418
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,66 @@ const tokenAddress2 = "0x0278d356b23366037F8D3C34e3B387c971197EA2";
const uniswapRouterAddress = "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe";

const stressSwap = async () => {
const [deployer] = await ethers.getSigners();
const [signer] = await ethers.getSigners();

const MockToken1 = await MockZETA__factory.connect(tokenAddress1, deployer);
const MockToken2 = await MockZETA__factory.connect(tokenAddress2, deployer);
const MockToken1 = await MockZETA__factory.connect(tokenAddress1, signer);
const MockToken2 = await MockZETA__factory.connect(tokenAddress2, signer);

await MockToken1.mint(deployer.address, TOKEN_TO_MINT);
await MockToken1.mint(signer.address, TOKEN_TO_MINT);

const uniswapRouter = await UniswapV2Router02__factory.connect(uniswapRouterAddress, deployer);
const uniswapRouter = await UniswapV2Router02__factory.connect(uniswapRouterAddress, signer);

const tokenContract1 = ERC20__factory.connect(tokenAddress1, deployer);
const tokenContract1 = ERC20__factory.connect(tokenAddress1, signer);

const tokenContract2 = ERC20__factory.connect(tokenAddress2, deployer);
const tokenContract2 = ERC20__factory.connect(tokenAddress2, signer);

const tx1 = await tokenContract1.approve(uniswapRouter.address, MaxUint256);
await tx1.wait();

const tx2 = await tokenContract2.approve(uniswapRouter.address, MaxUint256);
await tx2.wait();

const initialBalance1 = await tokenContract1.balanceOf(deployer.address);
const initialBalance2 = await tokenContract2.balanceOf(deployer.address);
const initialBalance1 = await tokenContract1.balanceOf(signer.address);
const initialBalance2 = await tokenContract2.balanceOf(signer.address);
console.log(`initialBalance1: ${initialBalance1.toString()}`);
console.log(`initialBalance2: ${initialBalance2.toString()}`);

const tx3 = await uniswapRouter.swapExactTokensForTokens(
TOKEN_TO_MINT,
0,
[tokenAddress1, tokenAddress2],
deployer.address,
signer.address,
(await getNow()) + 360,
{ gasLimit: 10_000_000 }
);
await tx3.wait();

const balanceAfterSwap1 = await tokenContract1.balanceOf(deployer.address);
const balanceAfterSwap2 = await tokenContract2.balanceOf(deployer.address);
const balanceAfterSwap1 = await tokenContract1.balanceOf(signer.address);
const balanceAfterSwap2 = await tokenContract2.balanceOf(signer.address);
console.log(`balanceAfterSwap1: ${balanceAfterSwap1.toString()}`);
console.log(`balanceAfterSwap2: ${balanceAfterSwap2.toString()}`);

const tx4 = await uniswapRouter.swapExactTokensForTokens(
balanceAfterSwap2.sub(initialBalance2),
0,
[tokenAddress2, tokenAddress1],
deployer.address,
signer.address,
(await getNow()) + 360,
{ gasLimit: 10_000_000 }
);

await tx4.wait();

const balanceAfterSecondSwap1 = await tokenContract1.balanceOf(deployer.address);
const balanceAfterSecondSwap2 = await tokenContract2.balanceOf(deployer.address);
const balanceAfterSecondSwap1 = await tokenContract1.balanceOf(signer.address);
const balanceAfterSecondSwap2 = await tokenContract2.balanceOf(signer.address);
console.log(`balanceAfterSecondSwap1: ${balanceAfterSecondSwap1.toString()}`);
console.log(`balanceAfterSecondSwap2: ${balanceAfterSecondSwap2.toString()}`);

await MockToken1.burn(deployer.address, balanceAfterSecondSwap1);
await MockToken2.burn(deployer.address, balanceAfterSecondSwap2);
await MockToken1.burn(signer.address, balanceAfterSecondSwap1);
await MockToken2.burn(signer.address, balanceAfterSecondSwap2);

const endBalance1 = await tokenContract1.balanceOf(deployer.address);
const endBalance2 = await tokenContract2.balanceOf(deployer.address);
const endBalance1 = await tokenContract1.balanceOf(signer.address);
const endBalance2 = await tokenContract2.balanceOf(signer.address);
console.log(`endBalance1: ${endBalance1.toString()}`);
console.log(`endBalance2: ${endBalance2.toString()}`);
};
Expand Down

0 comments on commit 9c54418

Please sign in to comment.