Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update old test cases #323

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tasks/deploy_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface MockAddresses extends Addresses {
mockWbnb: string;
mockUsdc: string;
mockBusd: string;
mockStEth: string;
mockWstEth: string;
mockUniswapV2Pair: string;
}

Expand Down Expand Up @@ -109,6 +111,23 @@ task("deploy_mock", "Deploy mock contracts")
mockWethAddress = mockWeth.address;
}

let mockStEthAddress = "";
let mockWstEthAddress = "";
if (args.silent || keyInYNStrict("Deploy MockStEth and MockWstEth?", { guide: true })) {
const MockToken = await ethers.getContractFactory("MockToken");
const mockStEth = await MockToken.deploy("Mock stETH", "stETH", 18);
console.log(`MockStEth: ${mockStEth.address}`);
const MockWstETH = await ethers.getContractFactory("MockWstETH");
const mockWstEth = await MockWstETH.deploy(mockStEth.address);
await mockWstEth.update(parseEther("1"));
console.log(`MockWstEth: ${mockWstEth.address}`);
mockStEthAddress = mockStEth.address;
mockWstEthAddress = mockWstEth.address;
await mockStEth.mint(deployer.address, parseEther("2000000"));
await mockStEth.approve(mockWstEth.address, parseEther("1000000"));
await mockWstEth.wrap(parseEther("1000000"));
}

let mockUniswapV2PairAddress = "";
if (args.silent || keyInYNStrict("Deploy MockUniswapV2Pair?", { guide: true })) {
const MockUniswapV2Pair = await ethers.getContractAt(
Expand Down Expand Up @@ -136,6 +155,8 @@ task("deploy_mock", "Deploy mock contracts")
mockWbnb: mockWbnbAddress,
mockUsdc: mockUsdcAddress,
mockBusd: mockBusdAddress,
mockStEth: mockStEthAddress,
mockWstEth: mockWstEthAddress,
mockUniswapV2Pair: mockUniswapV2PairAddress,
};
saveAddressFile(hre, "mock", addresses);
Expand Down
5 changes: 4 additions & 1 deletion tasks/deploy_swap_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface SwapRouterAddresses extends Addresses {
}

task("deploy_swap_router", "Deploy swap routers contracts")
.addParam("wsteth", "wstETH address")
.addParam("queenSwaps", "Comma-separated fund underlying symbols for QueenStableSwaps")
.addParam("bishopSwaps", "Comma-separated fund underlying symbols for BishopStableSwaps")
.setAction(async function (args, hre) {
Expand All @@ -25,6 +26,8 @@ task("deploy_swap_router", "Deploy swap routers contracts")
for (const bishopSwap of bishopSwaps) {
assert.match(bishopSwap, /^[a-zA-Z]+$/, "Invalid symbol");
}
const wstETH = await ethers.getContractAt("ERC20", args.wsteth);
assert.strictEqual(await wstETH.symbol(), "wstETH");

const governanceAddresses = loadAddressFile<GovernanceAddresses>(hre, "governance");

Expand All @@ -45,7 +48,7 @@ task("deploy_swap_router", "Deploy swap routers contracts")
}

const SwapRouter = await ethers.getContractFactory("SwapRouter");
const swapRouter = await SwapRouter.deploy();
const swapRouter = await SwapRouter.deploy(wstETH.address);
console.log(`SwapRouter: ${swapRouter.address}`);

for (const swapAddresses of swapAddressesList) {
Expand Down
1 change: 1 addition & 0 deletions tasks/test_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ task("test_deploy", "Run all deployment scripts on a temp Hardhat node", async (
console.log();
console.log("[+] Deploying swap router");
await hre.run("deploy_swap_router", {
wsteth: mockAddresses.mockWstEth,
queenSwaps: "WBNB",
bishopSwaps: "BTC,ETH,WBNB",
});
Expand Down
4 changes: 3 additions & 1 deletion test/bishopStableSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ describe("BishopStableSwap", function () {
await usdc.mint(stableSwap.address, INIT_USDC);
await stableSwap.addLiquidity(0, user1.address);

const wstETH = await deployMockForName(owner, "IWstETH");
await wstETH.mock.stETH.returns(ethers.constants.AddressZero);
const SwapRouter = await ethers.getContractFactory("SwapRouter");
const swapRouter = await SwapRouter.connect(owner).deploy();
const swapRouter = await SwapRouter.connect(owner).deploy(wstETH.address);
await swapRouter.addSwap(tokenB.address, usdc.address, stableSwap.address);

return {
Expand Down
4 changes: 3 additions & 1 deletion test/bishopStableSwapV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ describe("BishopStableSwapV2", function () {
await usdc.mint(stableSwap.address, INIT_USDC);
await stableSwap.addLiquidity(0, user1.address);

const wstETH = await deployMockForName(owner, "IWstETH");
await wstETH.mock.stETH.returns(ethers.constants.AddressZero);
const SwapRouter = await ethers.getContractFactory("SwapRouter");
const swapRouter = await SwapRouter.connect(owner).deploy();
const swapRouter = await SwapRouter.connect(owner).deploy(wstETH.address);
await swapRouter.addSwap(tokenB.address, usdc.address, stableSwap.address);

return {
Expand Down
4 changes: 3 additions & 1 deletion test/flashSwapRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ describe("FlashSwapRouter", function () {
0
);

const wstETH = await deployMockForName(owner, "IWstETH");
await wstETH.mock.stETH.returns(ethers.constants.AddressZero);
const SwapRouter = await ethers.getContractFactory("SwapRouter");
const swapRouter = await SwapRouter.connect(owner).deploy();
const swapRouter = await SwapRouter.connect(owner).deploy(wstETH.address);
await swapRouter.addSwap(shareB.address, usdc.address, stableSwap.address);
const MockExternalRouter = await ethers.getContractFactory("MockExternalRouter");
const externalRouter = await MockExternalRouter.connect(owner).deploy();
Expand Down
4 changes: 3 additions & 1 deletion test/queenStableSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ describe("QueenStableSwap", function () {
await btc.mint(stableSwap.address, INIT_BTC);
await stableSwap.addLiquidity(0, user1.address);

const wstETH = await deployMockForName(owner, "IWstETH");
await wstETH.mock.stETH.returns(ethers.constants.AddressZero);
const SwapRouter = await ethers.getContractFactory("SwapRouter");
const swapRouter = await SwapRouter.connect(owner).deploy();
const swapRouter = await SwapRouter.connect(owner).deploy(wstETH.address);
await swapRouter.addSwap(tokenQ.address, btc.address, stableSwap.address);

return {
Expand Down
Loading