Skip to content

Commit

Permalink
feat: Update to >= [email protected] (#1188)
Browse files Browse the repository at this point in the history
* feat: Update to >= [email protected]

* update version

* version

---------

Co-authored-by: Paul <[email protected]>
  • Loading branch information
nicholaspai and pxrl authored Feb 12, 2024
1 parent 37dce49 commit e747979
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 84 deletions.
3 changes: 2 additions & 1 deletion contracts/MockSpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ import "@across-protocol/contracts-v2/contracts/test/MockSpokePool.sol";
* this contract is explicitly defined here.
*/
contract _MockSpokePool is MockSpokePool {

/// @custom:oz-upgrades-unsafe-allow constructor
constructor(address _wrappedNativeTokenAddress) MockSpokePool(_wrappedNativeTokenAddress) {} // solhint-disable-line no-empty-blocks
}
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import "@openzeppelin/hardhat-upgrades";

dotenv.config();

const solcVersion = "0.8.18";
const solcVersion = "0.8.23";
const mnemonic = getMnemonic();

const config: HardhatUserConfig = {
solidity: {
compilers: [{ version: solcVersion, settings: { optimizer: { enabled: true, runs: 1000000 }, viaIR: true } }],
compilers: [{ version: solcVersion, settings: { optimizer: { enabled: true, runs: 1 }, viaIR: true } }],
},
networks: {
hardhat: { accounts: { accountsBalance: "1000000000000000000000000" } },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@across-protocol/constants-v2": "1.0.8",
"@across-protocol/contracts-v2": "2.4.7",
"@across-protocol/contracts-v2": "2.5.0-beta.5",
"@across-protocol/sdk-v2": "0.20.5",
"@arbitrum/sdk": "^3.1.3",
"@defi-wonderland/smock": "^2.3.5",
Expand Down
16 changes: 8 additions & 8 deletions test/Relayer.BasicFill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
deployAndConfigureHubPool,
deployConfigStore,
deploySpokePoolWithToken,
deposit,
depositV2,
destinationChainId,
enableRoutesOnHubPool,
ethers,
Expand Down Expand Up @@ -162,7 +162,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
});

it("Correctly fetches single unfilled deposit and fills it", async function () {
const deposit1 = await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
const deposit1 = await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);

await updateAllClients();
await relayerInstance.checkForUnfilledDepositsAndFill();
Expand Down Expand Up @@ -198,7 +198,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
it("Correctly validates self-relays", async function () {
const relayerFeePct = bnZero;
for (const testDepositor of [depositor, relayer]) {
await deposit(spokePool_1, erc20_1, relayer, testDepositor, destinationChainId, amountToDeposit, relayerFeePct);
await depositV2(spokePool_1, erc20_1, relayer, testDepositor, destinationChainId, amountToDeposit, relayerFeePct);

await updateAllClients();
await relayerInstance.checkForUnfilledDepositsAndFill();
Expand All @@ -208,7 +208,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
});

it("Ignores deposits older than min deposit confirmation threshold", async function () {
await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);

// Set MDC such that the deposit is is ignored. The profit client will return a fill USD amount of $0,
// so we need to set the MDC for the `0` threshold to be large enough such that the deposit would be ignored.
Expand Down Expand Up @@ -240,7 +240,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
});

it("Ignores deposits with quote times in future", async function () {
const { quoteTimestamp } = await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
const { quoteTimestamp } = await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);

// Override hub pool client timestamp to make deposit look like its in the future
await updateAllClients();
Expand Down Expand Up @@ -290,7 +290,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
it("Ignores deposit from preconfigured addresses", async function () {
relayerInstance.config.ignoredAddresses = [depositor.address];

await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await updateAllClients();
await relayerInstance.checkForUnfilledDepositsAndFill();

Expand Down Expand Up @@ -488,7 +488,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
});

it("Shouldn't double fill a deposit", async function () {
await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);

await updateAllClients();
await relayerInstance.checkForUnfilledDepositsAndFill();
Expand Down Expand Up @@ -533,7 +533,7 @@ describe("Relayer: Check for Unfilled Deposits and Fill", async function () {
routes.forEach(({ from, to, enabled }) => expect(relayerInstance.routeEnabled(from, to)).to.equal(enabled));

// Deposit on originChainId, destined for destinationChainId => expect ignored.
await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await updateAllClients();
await relayerInstance.checkForUnfilledDepositsAndFill();
expect(
Expand Down
6 changes: 3 additions & 3 deletions test/Relayer.SlowFill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
deployAndConfigureHubPool,
deployConfigStore,
deploySpokePoolWithToken,
deposit,
depositV2,
destinationChainId,
enableRoutesOnHubPool,
ethers,
Expand Down Expand Up @@ -164,7 +164,7 @@ describe("Relayer: Zero sized fill for slow relay", async function () {
await erc20_2.connect(relayer).transfer(owner.address, balance.sub(amountToDeposit));
// The relayer wallet was seeded with 5x the deposit amount. Make the deposit 6x this size.
await spokePool_1.setCurrentTime(await getLastBlockTime(spokePool_1.provider));
const deposit1 = await deposit(
const deposit1 = await depositV2(
spokePool_1,
erc20_1,
depositor,
Expand Down Expand Up @@ -211,7 +211,7 @@ describe("Relayer: Zero sized fill for slow relay", async function () {
await erc20_2.connect(relayer).transfer(owner.address, balance.sub(amountToDeposit));
// The relayer wallet was seeded with 5x the deposit amount. Make the deposit 6x this size.
await spokePool_1.setCurrentTime(await getLastBlockTime(spokePool_1.provider));
deposit1 = await deposit(
deposit1 = await depositV2(
spokePool_1,
erc20_1,
depositor,
Expand Down
12 changes: 6 additions & 6 deletions test/Relayer.TokenShortfall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
deployAndConfigureHubPool,
deployConfigStore,
deploySpokePoolWithToken,
deposit,
depositV2,
destinationChainId,
enableRoutesOnHubPool,
ethers,
Expand Down Expand Up @@ -154,8 +154,8 @@ describe("Relayer: Token balance shortfall", async function () {
it("Produces expected logs based on insufficient single token balance", async function () {
await spokePool_1.setCurrentTime(await getLastBlockTime(spokePool_1.provider));
// Deposit 100 tokens to be relayed, two times.
await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);

// Seed the relayer with 50 tokens. This is insufficient to fill the relay and should produce the expected log.
await erc20_2.mint(relayer.address, toBNWei(50));
Expand All @@ -169,7 +169,7 @@ describe("Relayer: Token balance shortfall", async function () {
expect(lastSpyLogIncludes(spy, "blocking deposits: 1,0")).to.be.true;

// Submitting another relay should increment the shortfall and log accordingly. Total shortfall of 250 now.
await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await updateAllClients();
await relayerInstance.checkForUnfilledDepositsAndFill();
expect(lastSpyLogIncludes(spy, `${await l1Token.symbol()} cumulative shortfall of 250.00`)).to.be.true;
Expand All @@ -191,8 +191,8 @@ describe("Relayer: Token balance shortfall", async function () {
await spokePool_1.setCurrentTime(await getLastBlockTime(spokePool_1.provider));
await spokePool_2.setCurrentTime(await getLastBlockTime(spokePool_1.provider));
// Deposit 100 tokens to be relayed of each token type.
await deposit(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await deposit(spokePool_2, erc20_2, depositor, depositor, originChainId);
await depositV2(spokePool_1, erc20_1, depositor, depositor, destinationChainId);
await depositV2(spokePool_2, erc20_2, depositor, depositor, originChainId);

await updateAllClients();

Expand Down
19 changes: 1 addition & 18 deletions test/utils/SpokePoolUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DepositWithBlock, Fill, FillWithBlock, RefundRequest } from "../../src/interfaces";
import { DepositWithBlock, Fill } from "../../src/interfaces";
import { toBN } from "../../src/utils";

export function fillFromDeposit(deposit: DepositWithBlock, relayer: string): Fill {
Expand Down Expand Up @@ -33,20 +33,3 @@ export function fillFromDeposit(deposit: DepositWithBlock, relayer: string): Fil

return fill;
}

export function refundRequestFromFill(fill: FillWithBlock, refundToken: string): RefundRequest {
const refundRequest: RefundRequest = {
amount: fill.amount,
depositId: fill.depositId,
originChainId: fill.originChainId,
destinationChainId: fill.destinationChainId,
repaymentChainId: fill.repaymentChainId,
realizedLpFeePct: fill.realizedLpFeePct,
fillBlock: toBN(fill.blockNumber),
relayer: fill.relayer,
refundToken,
previousIdenticalRequests: toBN(0),
};

return refundRequest;
}
48 changes: 5 additions & 43 deletions test/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as utils from "@across-protocol/contracts-v2/dist/test-utils";
import { TokenRolesEnum } from "@uma/common";
import { SpyTransport, bigNumberFormatter } from "@uma/financial-templates-lib";
import { constants as ethersConstants, providers } from "ethers";
import { providers } from "ethers";
import { ConfigStoreClient, GLOBAL_CONFIG_STORE_KEYS, HubPoolClient } from "../../src/clients";
import { Deposit, Fill, FillWithBlock, RelayerRefundLeaf, RunningBalances } from "../../src/interfaces";
import { TransactionResponse, buildRelayerRefundTree, toBN, toBNWei, utf8ToHex } from "../../src/utils";
import { Deposit, Fill, RelayerRefundLeaf, RunningBalances } from "../../src/interfaces";
import { buildRelayerRefundTree, toBN, toBNWei, utf8ToHex } from "../../src/utils";
import {
DEFAULT_BLOCK_RANGE_FOR_CHAIN,
MAX_L1_TOKENS_PER_POOL_REBALANCE_LEAF,
Expand Down Expand Up @@ -261,7 +261,7 @@ export async function simpleDeposit(
amountToDeposit: utils.BigNumber = utils.amountToDeposit,
depositRelayerFeePct: utils.BigNumber = utils.depositRelayerFeePct
): Promise<Deposit> {
const depositObject = await utils.deposit(
const depositObject = await utils.depositV2(
spokePool,
token,
recipient,
Expand Down Expand Up @@ -328,7 +328,7 @@ export async function buildDeposit(
quoteTimestamp?: number,
message?: string
): Promise<Deposit> {
const _deposit = await utils.deposit(
const _deposit = await utils.depositV2(
spokePool,
tokenToDeposit,
recipientAndDepositor,
Expand Down Expand Up @@ -542,44 +542,6 @@ export async function buildFillForRepaymentChain(
}
}

export async function buildRefundRequest(
spokePool: Contract,
relayer: SignerWithAddress,
fill: FillWithBlock,
refundToken: string,
maxCount?: BigNumber
): Promise<TransactionResponse> {
// @note: These chainIds should align, but don't! @todo: Fix!
// const chainId = (await spokePool.provider.getNetwork()).chainId;
// assert.isTrue(fill.repaymentChainId === chainId);

const {
originChainId,
depositId,
destinationChainId,
fillAmount: amount,
realizedLpFeePct,
blockNumber: fillBlock,
} = fill;

maxCount ??= ethersConstants.MaxUint256;

const refundRequest = await spokePool
.connect(relayer)
.requestRefund(
refundToken,
amount,
originChainId,
destinationChainId,
realizedLpFeePct,
depositId,
fillBlock,
maxCount
);

return refundRequest;
}

// Returns expected leaves ordered by origin chain ID and then deposit ID(ascending). Ordering is implemented
// same way that dataworker orders them.
export function buildSlowRelayLeaves(
Expand Down
38 changes: 36 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,27 @@
resolved "https://registry.yarnpkg.com/@across-protocol/constants-v2/-/constants-v2-1.0.8.tgz#0f4dc9fbcf7b99dd895a06bb6070b5d3c8e1188d"
integrity sha512-7rygtlYseWNI/5ocIT9SXYu6L86oQbKTtFNAOw5MqD53bbsREzRy5dU0wkUHJzvHiNIQ+iawKnzprqshHHeRKw==

"@across-protocol/[email protected]", "@across-protocol/contracts-v2@^2.4.7":
"@across-protocol/[email protected]":
version "2.5.0-beta.5"
resolved "https://registry.yarnpkg.com/@across-protocol/contracts-v2/-/contracts-v2-2.5.0-beta.5.tgz#d053facf0408047da4a25b25a54143f2944cda0f"
integrity sha512-bInPHvrN2cBJwokcHLNdzsE6E901Y0e67fpY4ihnx3Zf8VjBBI25YhCOWNkv/t7wOQj3+lJ6OZ9m4hNcJDLhgw==
dependencies:
"@across-protocol/constants-v2" "^1.0.4"
"@defi-wonderland/smock" "^2.3.4"
"@eth-optimism/contracts" "^0.5.40"
"@ethersproject/abstract-provider" "5.7.0"
"@ethersproject/abstract-signer" "5.7.0"
"@ethersproject/bignumber" "5.7.0"
"@openzeppelin/contracts" "4.9.3"
"@openzeppelin/contracts-upgradeable" "4.9.3"
"@scroll-tech/contracts" "^0.1.0"
"@uma/common" "^2.34.0"
"@uma/contracts-node" "^0.4.17"
"@uma/core" "^2.56.0"
axios "^1.6.2"
zksync-web3 "^0.14.3"

"@across-protocol/contracts-v2@^2.4.7":
version "2.4.7"
resolved "https://registry.yarnpkg.com/@across-protocol/contracts-v2/-/contracts-v2-2.4.7.tgz#1f3be7410cd77a11c17d6f86758ad3290d886740"
integrity sha512-Ao7B2Sp9MUCVB77bJLLemZThpHU+0/BLbQdI0/vn2AQWtwTQfFqlF3q+qfbEvFI4arNsivHcM5rsfwyWrz4onw==
Expand Down Expand Up @@ -2315,6 +2335,11 @@
resolved "https://registry.yarnpkg.com/@sapphire/snowflake/-/snowflake-3.5.1.tgz#254521c188b49e8b2d4cc048b475fb2b38737fec"
integrity sha512-BxcYGzgEsdlG0dKAyOm0ehLGm2CafIrfQTZGWgkfKYbj+pNNsorZ7EotuZukc2MT70E0UbppVbtpBrqpzVzjNA==

"@scroll-tech/contracts@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@scroll-tech/contracts/-/contracts-0.1.0.tgz#ccea8db1b3df7d740e4b7843ac01b5bd25b4438b"
integrity sha512-aBbDOc3WB/WveZdpJYcrfvMYMz7ZTEiW8M9XMJLba8p9FAR5KGYB/cV+8+EUsq3MKt7C1BfR+WnXoTVdvwIY6w==

"@scure/base@~1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.0.0.tgz#109fb595021de285f05a7db6806f2f48296fcee7"
Expand Down Expand Up @@ -3940,6 +3965,15 @@ axios@^1.6.0:
form-data "^4.0.0"
proxy-from-env "^1.1.0"

axios@^1.6.2:
version "1.6.7"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.7.tgz#7b48c2e27c96f9c68a2f8f31e2ab19f59b06b0a7"
integrity sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==
dependencies:
follow-redirects "^1.15.4"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

babel-plugin-polyfill-corejs2@^0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz#440f1b70ccfaabc6b676d196239b138f8a2cfba5"
Expand Down Expand Up @@ -6987,7 +7021,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc"
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==

follow-redirects@^1.12.1, follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.14.9, follow-redirects@^1.15.0:
follow-redirects@^1.12.1, follow-redirects@^1.14.0, follow-redirects@^1.14.4, follow-redirects@^1.14.9, follow-redirects@^1.15.0, follow-redirects@^1.15.4:
version "1.15.5"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==
Expand Down

0 comments on commit e747979

Please sign in to comment.