Skip to content
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
11 changes: 3 additions & 8 deletions test/HubPool.Admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import { Contract, ethers, randomAddress, utf8ToHex } from "./utils";
import { originChainId, destinationChainId, bondAmount, zeroAddress, mockTreeRoot } from "./constants";
import { mockSlowRelayRoot, finalFeeUsdc, finalFee, totalBond } from "./constants";
import { hubPoolFixture } from "./fixtures/HubPool.Fixture";
import { ZERO_ADDRESS } from "@uma/common";

let hubPool: Contract,
weth: Contract,
usdc: Contract,
mockSpoke: Contract,
mockAdapter: Contract,
identifierWhitelist: Contract;
let hubPool: Contract, weth: Contract, usdc: Contract;
let mockSpoke: Contract, mockAdapter: Contract, identifierWhitelist: Contract;
let owner: SignerWithAddress, other: SignerWithAddress;

describe("HubPool Admin functions", function () {
Expand Down Expand Up @@ -66,7 +61,7 @@ describe("HubPool Admin functions", function () {
await expect(hubPool.connect(other).relaySpokePoolAdminFunction(destinationChainId, functionData)).to.be.reverted;

// Cannot relay admin function if spoke pool is set to zero address or adapter is set to non contract..
await hubPool.setCrossChainContracts(destinationChainId, mockAdapter.address, ZERO_ADDRESS);
await hubPool.setCrossChainContracts(destinationChainId, mockAdapter.address, zeroAddress);
await expect(hubPool.relaySpokePoolAdminFunction(destinationChainId, functionData)).to.be.revertedWith(
"SpokePool not initialized"
);
Expand Down
5 changes: 2 additions & 3 deletions test/HubPool.ExecuteRootBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { toBNWei, SignerWithAddress, seedWallet, expect, Contract, ethers, rando
import * as consts from "./constants";
import { hubPoolFixture, enableTokensForLP } from "./fixtures/HubPool.Fixture";
import { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves } from "./MerkleLib.utils";
import { ZERO_ADDRESS } from "@uma/common";

let hubPool: Contract, mockAdapter: Contract, weth: Contract, dai: Contract, mockSpoke: Contract, timer: Contract;
let owner: SignerWithAddress, dataWorker: SignerWithAddress, liquidityProvider: SignerWithAddress;
Expand Down Expand Up @@ -156,7 +155,7 @@ describe("HubPool Root Bundle Execution", function () {
.proposeRootBundle([3117, 3118], 2, tree.getHexRoot(), consts.mockRelayerRefundRoot, consts.mockSlowRelayRoot);

// Set spoke pool to address 0x0
await hubPool.setCrossChainContracts(consts.repaymentChainId, mockAdapter.address, ZERO_ADDRESS);
await hubPool.setCrossChainContracts(consts.repaymentChainId, mockAdapter.address, consts.zeroAddress);

// Advance time so the request can be executed and check that executing the request reverts.
await timer.setCurrentTime(Number(await timer.getCurrentTime()) + consts.refundProposalLiveness + 1);
Expand Down Expand Up @@ -194,7 +193,7 @@ describe("HubPool Root Bundle Execution", function () {
);

// Let's set weth pool rebalance route to zero address.
await hubPool.setPoolRebalanceRoute(consts.repaymentChainId, weth.address, ZERO_ADDRESS);
await hubPool.setPoolRebalanceRoute(consts.repaymentChainId, weth.address, consts.zeroAddress);

// Advance time so the request can be executed and check that executing the request reverts.
await timer.setCurrentTime(Number(await timer.getCurrentTime()) + consts.refundProposalLiveness + 1);
Expand Down
5 changes: 2 additions & 3 deletions test/HubPool.ProtocolFees.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { toWei, toBNWei, SignerWithAddress, seedWallet, expect, Contract, ethers } from "./utils";
import { mockTreeRoot, finalFee, bondAmount, amountToLp, refundProposalLiveness } from "./constants";
import { mockTreeRoot, finalFee, bondAmount, amountToLp, refundProposalLiveness, zeroAddress } from "./constants";
import { hubPoolFixture, enableTokensForLP } from "./fixtures/HubPool.Fixture";
import { constructSingleChainTree } from "./MerkleLib.utils";
import { ZERO_ADDRESS } from "@uma/common";

let hubPool: Contract, weth: Contract, timer: Contract;
let owner: SignerWithAddress, dataWorker: SignerWithAddress, liquidityProvider: SignerWithAddress;
Expand Down Expand Up @@ -34,7 +33,7 @@ describe("HubPool Protocol fees", function () {
const newPct = toWei("0.1");

// Can't set to 0 address
await expect(hubPool.connect(owner).setProtocolFeeCapture(ZERO_ADDRESS, newPct)).to.be.reverted;
await expect(hubPool.connect(owner).setProtocolFeeCapture(zeroAddress, newPct)).to.be.reverted;

await hubPool.connect(owner).setProtocolFeeCapture(liquidityProvider.address, newPct);
expect(await hubPool.callStatic.protocolFeeCaptureAddress()).to.equal(liquidityProvider.address);
Expand Down
5 changes: 2 additions & 3 deletions test/chain-specific-spokepools/Arbitrum_SpokePool.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants";
import { mockTreeRoot, amountToReturn, amountHeldByPool, zeroAddress } from "../constants";
import { ethers, expect, Contract, FakeContract, SignerWithAddress, createFake, toWei } from "../utils";
import { getContractFactory, seedContract, avmL1ToL2Alias, hre, toBN, toBNWei } from "../utils";
import { hubPoolFixture } from "../fixtures/HubPool.Fixture";
import { constructSingleRelayerRefundTree } from "../MerkleLib.utils";
import { ZERO_ADDRESS } from "@uma/common";

let hubPool: Contract, arbitrumSpokePool: Contract, timer: Contract, dai: Contract, weth: Contract;
let l2Weth: string, l2Dai: string, crossDomainAliasAddress;
Expand Down Expand Up @@ -91,7 +90,7 @@ describe("Arbitrum Spoke Pool", function () {
await arbitrumSpokePool.connect(crossDomainAlias).relayRootBundle(tree.getHexRoot(), mockTreeRoot);

// Reverts if route from arbitrum to mainnet for l2Dai isn't whitelisted.
await arbitrumSpokePool.connect(crossDomainAlias).whitelistToken(l2Dai, ZERO_ADDRESS);
await arbitrumSpokePool.connect(crossDomainAlias).whitelistToken(l2Dai, zeroAddress);
await expect(
arbitrumSpokePool.executeRelayerRefundLeaf(0, leaves[0], tree.getHexProof(leaves[0]))
).to.be.revertedWith("Uninitialized mainnet token");
Expand Down
20 changes: 4 additions & 16 deletions test/chain-specific-spokepools/Polygon_SpokePool.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
import { TokenRolesEnum, ZERO_ADDRESS } from "@uma/common";
import { mockTreeRoot, amountToReturn, amountHeldByPool } from "../constants";
import {
ethers,
expect,
Contract,
SignerWithAddress,
getContractFactory,
seedContract,
toWei,
randomBigNumber,
seedWallet,
FakeContract,
createFake,
} from "../utils";
import { mockTreeRoot, amountToReturn, amountHeldByPool, zeroAddress, TokenRolesEnum } from "../constants";
import { ethers, expect, Contract, SignerWithAddress, getContractFactory, createFake } from "../utils";
import { seedContract, toWei, randomBigNumber, seedWallet, FakeContract } from "../utils";
import { hubPoolFixture } from "../fixtures/HubPool.Fixture";
import { constructSingleRelayerRefundTree } from "../MerkleLib.utils";
import { randomBytes } from "crypto";
Expand Down Expand Up @@ -223,7 +211,7 @@ describe("Polygon Spoke Pool", function () {
// Checks that there's a burn event from the bridger.
await expect(polygonSpokePool.connect(relayer).executeRelayerRefundLeaf(0, leaves[0], tree.getHexProof(leaves[0])))
.to.emit(dai, "Transfer")
.withArgs(bridger, ZERO_ADDRESS, amountToReturn);
.withArgs(bridger, zeroAddress, amountToReturn);
});

it("PolygonTokenBridger retrieves and unwraps tokens correctly", async function () {
Expand Down
2 changes: 2 additions & 0 deletions test/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { toWei, utf8ToHex, toBN, createRandomBytes32, ethers, hre } from "./utils";

export { TokenRolesEnum } from "@uma/common";

export const maxUint256 = ethers.constants.MaxInt256;

export const amountToSeedWallets = toWei("1500");
Expand Down
5 changes: 1 addition & 4 deletions test/fixtures/HubPool.Fixture.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { TokenRolesEnum } from "@uma/common";
import { getContractFactory, randomAddress, hre, Contract, Signer } from "../utils";

import { originChainId, bondAmount, refundProposalLiveness, finalFee } from "../constants";
import { repaymentChainId, finalFeeUsdc } from "../constants";

import { repaymentChainId, finalFeeUsdc, TokenRolesEnum } from "../constants";
import { umaEcosystemFixture } from "./UmaEcosystem.Fixture";

export const hubPoolFixture = hre.deployments.createFixture(async ({ ethers }) => {
Expand Down
10 changes: 4 additions & 6 deletions test/fixtures/SpokePool.Fixture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { TokenRolesEnum } from "@uma/common";
import { getContractFactory, SignerWithAddress, Contract, hre } from "../utils";
import { ethers, BigNumber, defaultAbiCoder, toBN } from "../utils";
import { getContractFactory, SignerWithAddress, Contract, hre, ethers, BigNumber, defaultAbiCoder } from "../utils";
import * as consts from "../constants";

export const spokePoolFixture = hre.deployments.createFixture(async ({ ethers }) => {
Expand All @@ -24,15 +22,15 @@ export async function deploySpokePool(ethers: any): Promise<{
// Create tokens:
const weth = await (await getContractFactory("WETH9", deployerWallet)).deploy();
const erc20 = await (await getContractFactory("ExpandedERC20", deployerWallet)).deploy("USD Coin", "USDC", 18);
await erc20.addMember(TokenRolesEnum.MINTER, deployerWallet.address);
await erc20.addMember(consts.TokenRolesEnum.MINTER, deployerWallet.address);
const unwhitelistedErc20 = await (
await getContractFactory("ExpandedERC20", deployerWallet)
).deploy("Unwhitelisted", "UNWHITELISTED", 18);
await unwhitelistedErc20.addMember(TokenRolesEnum.MINTER, deployerWallet.address);
await unwhitelistedErc20.addMember(consts.TokenRolesEnum.MINTER, deployerWallet.address);
const destErc20 = await (
await getContractFactory("ExpandedERC20", deployerWallet)
).deploy("L2 USD Coin", "L2 USDC", 18);
await destErc20.addMember(TokenRolesEnum.MINTER, deployerWallet.address);
await destErc20.addMember(consts.TokenRolesEnum.MINTER, deployerWallet.address);

// Deploy the pool
const spokePool = await (
Expand Down
5 changes: 2 additions & 3 deletions test/gas-analytics/HubPool.RootExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { toBNWei, toBN, SignerWithAddress, seedWallet, Contract, ethers, hre, ex
import { getContractFactory, BigNumber, randomAddress, createRandomBytes32 } from "../utils";
import { deployErc20 } from "./utils";
import * as consts from "../constants";
import { ZERO_ADDRESS } from "@uma/common";
import { hubPoolFixture, enableTokensForLP } from "../fixtures/HubPool.Fixture";
import { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves, PoolRebalanceLeaf } from "../MerkleLib.utils";
import { MerkleTree } from "../../utils/MerkleTree";
Expand Down Expand Up @@ -96,14 +95,14 @@ describe("Gas Analytics: HubPool Root Bundle Execution", function () {
const adapter = await (await getContractFactory("Mock_Adapter", owner)).deploy();
const spoke = await (
await getContractFactory("MockSpokePool", owner)
).deploy(randomAddress(), hubPool.address, randomAddress(), ZERO_ADDRESS);
).deploy(randomAddress(), hubPool.address, randomAddress(), consts.zeroAddress);
await hubPool.setCrossChainContracts(hubPoolChainId, adapter.address, spoke.address);

for (let i = 0; i < REFUND_CHAIN_COUNT; i++) {
const adapter = await (await getContractFactory("Mock_Adapter", owner)).deploy();
const spoke = await (
await getContractFactory("MockSpokePool", owner)
).deploy(randomAddress(), hubPool.address, randomAddress(), ZERO_ADDRESS);
).deploy(randomAddress(), hubPool.address, randomAddress(), consts.zeroAddress);
await hubPool.setCrossChainContracts(i, adapter.address, spoke.address);
await Promise.all(
l1Tokens.map(async (token) => {
Expand Down
2 changes: 1 addition & 1 deletion test/gas-analytics/SpokePool.Deposit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { toBNWei, SignerWithAddress, Contract, ethers, seedWallet, toBN } from "../utils";
import { constructDepositParams, sendDeposit, warmSpokePool } from "./utils";
import * as constants from "../constants";
import { spokePoolFixture, enableRoutes } from "../fixtures/SpokePool.Fixture";
import { spokePoolFixture } from "../fixtures/SpokePool.Fixture";

require("dotenv").config();

Expand Down
13 changes: 2 additions & 11 deletions test/gas-analytics/SpokePool.RelayerRefundLeafExecution.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
import {
toBNWei,
SignerWithAddress,
Contract,
ethers,
BigNumber,
expect,
seedContract,
toBN,
seedWallet,
} from "../utils";
import { toBNWei, SignerWithAddress, Contract, ethers, BigNumber, expect } from "../utils";
import { seedContract, toBN, seedWallet } from "../utils";
import { deployErc20, warmSpokePool } from "./utils";
import * as consts from "../constants";
import { spokePoolFixture } from "../fixtures/SpokePool.Fixture";
Expand Down
3 changes: 1 addition & 2 deletions test/gas-analytics/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { SignerWithAddress, getContractFactory, BigNumber, toBN, Contract } from "../utils";
import { TokenRolesEnum } from "@uma/common";
import * as consts from "../constants";
import { getDepositParams, getRelayHash, getFillRelayParams, enableRoutes } from "../fixtures/SpokePool.Fixture";

export async function deployErc20(signer: SignerWithAddress, tokenName: string, tokenSymbol: string) {
const erc20 = await (await getContractFactory("ExpandedERC20", signer)).deploy(tokenName, tokenSymbol, 18);
await erc20.addMember(TokenRolesEnum.MINTER, signer.address);
await erc20.addMember(consts.TokenRolesEnum.MINTER, signer.address);
return erc20;
}

Expand Down