@across-protocol/sdk 4.3.120-alpha.1 → 4.3.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/utils/NetworkUtils.js +2 -0
- package/dist/cjs/src/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/test/constants.d.ts +8 -58
- package/dist/cjs/test/constants.js +13 -70
- package/dist/cjs/test/constants.js.map +1 -1
- package/dist/cjs/test/fixtures/SpokePool.Fixture.d.ts +1 -91
- package/dist/cjs/test/fixtures/SpokePool.Fixture.js +1 -196
- package/dist/cjs/test/fixtures/SpokePool.Fixture.js.map +1 -1
- package/dist/cjs/test/types/index.d.ts +11 -10
- package/dist/cjs/test/utils/MerkleLib.utils.d.ts +1 -26
- package/dist/cjs/test/utils/MerkleLib.utils.js +0 -40
- package/dist/cjs/test/utils/MerkleLib.utils.js.map +1 -1
- package/dist/cjs/test/utils/index.d.ts +1 -0
- package/dist/cjs/test/utils/index.js +2 -1
- package/dist/cjs/test/utils/index.js.map +1 -1
- package/dist/cjs/test/utils/utils.d.ts +17 -44
- package/dist/cjs/test/utils/utils.js +37 -223
- package/dist/cjs/test/utils/utils.js.map +1 -1
- package/dist/esm/src/utils/NetworkUtils.js +2 -0
- package/dist/esm/src/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/test/constants.d.ts +8 -58
- package/dist/esm/test/constants.js +13 -87
- package/dist/esm/test/constants.js.map +1 -1
- package/dist/esm/test/fixtures/SpokePool.Fixture.d.ts +1 -92
- package/dist/esm/test/fixtures/SpokePool.Fixture.js +1 -201
- package/dist/esm/test/fixtures/SpokePool.Fixture.js.map +1 -1
- package/dist/esm/test/types/index.d.ts +11 -10
- package/dist/esm/test/utils/MerkleLib.utils.d.ts +1 -32
- package/dist/esm/test/utils/MerkleLib.utils.js +0 -44
- package/dist/esm/test/utils/MerkleLib.utils.js.map +1 -1
- package/dist/esm/test/utils/index.d.ts +1 -0
- package/dist/esm/test/utils/index.js +2 -0
- package/dist/esm/test/utils/index.js.map +1 -1
- package/dist/esm/test/utils/utils.d.ts +17 -44
- package/dist/esm/test/utils/utils.js +29 -205
- package/dist/esm/test/utils/utils.js.map +1 -1
- package/dist/types/src/utils/NetworkUtils.d.ts.map +1 -1
- package/dist/types/test/constants.d.ts +8 -58
- package/dist/types/test/constants.d.ts.map +1 -1
- package/dist/types/test/fixtures/SpokePool.Fixture.d.ts +1 -92
- package/dist/types/test/fixtures/SpokePool.Fixture.d.ts.map +1 -1
- package/dist/types/test/types/index.d.ts +11 -10
- package/dist/types/test/types/index.d.ts.map +1 -1
- package/dist/types/test/utils/MerkleLib.utils.d.ts +1 -32
- package/dist/types/test/utils/MerkleLib.utils.d.ts.map +1 -1
- package/dist/types/test/utils/index.d.ts +1 -0
- package/dist/types/test/utils/index.d.ts.map +1 -1
- package/dist/types/test/utils/utils.d.ts +17 -44
- package/dist/types/test/utils/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/utils/NetworkUtils.ts +2 -0
- package/dist/cjs/test/fixtures/MerkleLib.Fixture.d.ts +0 -4
- package/dist/cjs/test/fixtures/MerkleLib.Fixture.js +0 -22
- package/dist/cjs/test/fixtures/MerkleLib.Fixture.js.map +0 -1
- package/dist/esm/test/fixtures/MerkleLib.Fixture.d.ts +0 -4
- package/dist/esm/test/fixtures/MerkleLib.Fixture.js +0 -19
- package/dist/esm/test/fixtures/MerkleLib.Fixture.js.map +0 -1
- package/dist/types/test/fixtures/MerkleLib.Fixture.d.ts +0 -5
- package/dist/types/test/fixtures/MerkleLib.Fixture.d.ts.map +0 -1
|
@@ -8,7 +8,6 @@ import { BigNumber, ethers } from "ethers";
|
|
|
8
8
|
import { getContractFactory } from "./getContractFactory";
|
|
9
9
|
import { MerkleTree } from "@across-protocol/contracts/dist/utils/MerkleTree";
|
|
10
10
|
import { expect } from "chai";
|
|
11
|
-
import { amountToReturn, repaymentChainId } from "../constants";
|
|
12
11
|
var _a = ethers.utils, keccak256 = _a.keccak256, defaultAbiCoder = _a.defaultAbiCoder;
|
|
13
12
|
/**
|
|
14
13
|
* Get the parameter type for a contract function parameter.
|
|
@@ -148,47 +147,4 @@ export function buildV3SlowRelayTree(slowFills) {
|
|
|
148
147
|
});
|
|
149
148
|
});
|
|
150
149
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Construct a single-leaf relayer refund tree.
|
|
153
|
-
*/
|
|
154
|
-
export function constructSingleRelayerRefundTree(l2Token, destinationChainId, amount) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
-
var amountToUse, l2TokenAddress, leaves, tree;
|
|
157
|
-
return __generator(this, function (_a) {
|
|
158
|
-
switch (_a.label) {
|
|
159
|
-
case 0:
|
|
160
|
-
amountToUse = amount !== undefined ? amount : amountToReturn;
|
|
161
|
-
l2TokenAddress = typeof l2Token === "string" ? l2Token : l2Token.address;
|
|
162
|
-
leaves = buildRelayerRefundLeaves([destinationChainId], [amountToUse], [l2TokenAddress], [[]], [[]]);
|
|
163
|
-
return [4 /*yield*/, buildRelayerRefundTree(leaves)];
|
|
164
|
-
case 1:
|
|
165
|
-
tree = _a.sent();
|
|
166
|
-
return [2 /*return*/, { leaves: leaves, tree: tree }];
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Construct a single-chain pool rebalance tree.
|
|
173
|
-
*/
|
|
174
|
-
export function constructSingleChainTree(token_1) {
|
|
175
|
-
return __awaiter(this, arguments, void 0, function (token, scalingSize, repaymentChain, decimals) {
|
|
176
|
-
var tokensSendToL2, realizedLpFees, leaves, tree;
|
|
177
|
-
if (scalingSize === void 0) { scalingSize = 1; }
|
|
178
|
-
if (repaymentChain === void 0) { repaymentChain = repaymentChainId; }
|
|
179
|
-
if (decimals === void 0) { decimals = 18; }
|
|
180
|
-
return __generator(this, function (_a) {
|
|
181
|
-
switch (_a.label) {
|
|
182
|
-
case 0:
|
|
183
|
-
tokensSendToL2 = ethers.utils.parseUnits((100 * scalingSize).toString(), decimals);
|
|
184
|
-
realizedLpFees = ethers.utils.parseUnits((10 * scalingSize).toString(), decimals);
|
|
185
|
-
leaves = buildPoolRebalanceLeaves([repaymentChain], [[token]], [[realizedLpFees]], [[tokensSendToL2]], [[tokensSendToL2]], [0]);
|
|
186
|
-
return [4 /*yield*/, buildPoolRebalanceLeafTree(leaves)];
|
|
187
|
-
case 1:
|
|
188
|
-
tree = _a.sent();
|
|
189
|
-
return [2 /*return*/, { tokensSendToL2: tokensSendToL2, realizedLpFees: realizedLpFees, leaves: leaves, tree: tree }];
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
150
|
//# sourceMappingURL=MerkleLib.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MerkleLib.utils.js","sourceRoot":"","sources":["../../../../test/utils/MerkleLib.utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"MerkleLib.utils.js","sourceRoot":"","sources":["../../../../test/utils/MerkleLib.utils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAExB,IAAA,KAAiC,MAAM,CAAC,KAAK,EAA3C,SAAS,eAAA,EAAE,eAAe,qBAAiB,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAgB,YAAY,CAChC,YAAoB,EACpB,YAAoB,EACpB,SAAiB;;;;;wBAEO,qBAAM,kBAAkB,CAAC,YAAY,EAAE,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,C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KAAK,CAAC,CAAC,CAAC,EAAjF,CAAiF,CAAC;oBACrH,sBAAO,IAAI,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,EAAC;;;;CAC1C;AAED;;GAEG;AACH,MAAM,UAAgB,oBAAoB,CAAC,SAAoB;;;;;wBAC3C,qBAAM,YAAY,CAAC,eAAe,EAAE,8BAA8B,EAAE,UAAU,CAAC,EAAA;;oBAA3F,SAAS,GAAG,SAA+E;oBAC3F,MAAM,GAAG,UAAC,KAAc,IAAK,OAAA,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,SAAmC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAjF,CAAiF,CAAC;oBACrH,sBAAO,IAAI,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,EAAC;;;;CAC1C"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import "@nomiclabs/hardhat-ethers";
|
|
2
|
+
import * as contractsV2Utils_1 from "@across-protocol/contracts/dist/test-utils";
|
|
3
|
+
export { contractsV2Utils_1 as contractsV2Utils };
|
|
2
4
|
export { ethers } from "hardhat";
|
|
3
5
|
export { smock } from "@defi-wonderland/smock";
|
|
4
6
|
export * from "./utils";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../test/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../test/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;oCACD,4CAA4C;+BAAlE,gBAAgB;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
|
|
@@ -1,74 +1,47 @@
|
|
|
1
1
|
import { AcrossConfigStore } from "@across-protocol/contracts";
|
|
2
|
+
import * as utils from "@across-protocol/contracts/dist/test-utils";
|
|
2
3
|
import chai, { expect } from "chai";
|
|
3
|
-
import {
|
|
4
|
-
import { FakeContract } from "@defi-wonderland/smock";
|
|
4
|
+
import { Contract, providers } from "ethers";
|
|
5
5
|
import sinon from "sinon";
|
|
6
6
|
import winston from "winston";
|
|
7
|
-
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
8
7
|
import { AcrossConfigStoreClient as ConfigStoreClient } from "../../src/clients";
|
|
9
8
|
import { Deposit, DepositWithBlock, FillWithBlock, RelayData, SlowFillRequestWithBlock } from "../../src/interfaces";
|
|
10
9
|
import { Address, BigNumber, BigNumberish, toBN, toBNWei, toWei, utf8ToHex } from "../../src/utils";
|
|
11
|
-
import { randomAddress, zeroAddress } from "../constants";
|
|
12
10
|
import { SpokePoolDeploymentResult, SpyLoggerResult } from "../types";
|
|
13
11
|
declare const chaiAssert: Chai.AssertStatic;
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export {
|
|
17
|
-
export type { ContractRelayData, V3RelayData, V3RelayExecutionParams, SlowFill, V3SlowFill, UpdatedRelayerFeeData, } from "../fixtures/SpokePool.Fixture";
|
|
18
|
-
export { FillType, FillStatus } from "../fixtures/SpokePool.Fixture";
|
|
19
|
-
export { randomAddress, zeroAddress };
|
|
20
|
-
export { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves, buildRelayerRefundTree, buildRelayerRefundLeaves, buildSlowRelayTree, buildV3SlowRelayTree, getParamType, constructSingleRelayerRefundTree, constructSingleChainTree, } from "./MerkleLib.utils";
|
|
12
|
+
export type SignerWithAddress = utils.SignerWithAddress;
|
|
13
|
+
export declare const getDepositParams: typeof utils.getDepositParams, getUpdatedV3DepositSignature: typeof utils.getUpdatedV3DepositSignature, modifyRelayHelper: typeof utils.modifyRelayHelper, randomAddress: typeof utils.randomAddress, zeroAddress: string;
|
|
14
|
+
export { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves, buildRelayerRefundTree, buildRelayerRefundLeaves, buildSlowRelayTree, buildV3SlowRelayTree, getParamType, } from "./MerkleLib.utils";
|
|
21
15
|
import { getContractFactory } from "./getContractFactory";
|
|
22
16
|
export { getContractFactory };
|
|
23
17
|
import { hubPoolFixture, deployHubPool } from "../fixtures/HubPool.Fixture";
|
|
24
18
|
import { spokePoolFixture, deploySpokePool } from "../fixtures/SpokePool.Fixture";
|
|
25
19
|
export { hubPoolFixture, deployHubPool, spokePoolFixture, deploySpokePool };
|
|
26
|
-
export { merkleLibFixture } from "../fixtures/MerkleLib.Fixture";
|
|
27
20
|
export { BigNumber, Contract, chai, chaiAssert, expect, sinon, toBN, toBNWei, toWei, utf8ToHex, winston };
|
|
28
|
-
declare const defaultAbiCoder: ethers.utils.AbiCoder, keccak256: typeof ethers.utils.keccak256;
|
|
29
|
-
export { defaultAbiCoder, keccak256, Signer, FakeContract };
|
|
30
|
-
export declare const toWeiWithDecimals: (num: string | number | BigNumber, decimals: number) => BigNumber;
|
|
31
|
-
export declare const toBNWeiWithDecimals: (num: string | number | BigNumber, decimals: number) => BigNumber;
|
|
32
|
-
export declare const fromWei: (num: string | number | BigNumber) => string;
|
|
33
|
-
export declare const hexToUtf8: (input: string) => string;
|
|
34
|
-
export declare const hexZeroPad: (input: string, length: number) => string;
|
|
35
|
-
export declare const addressToBytes: (input: string) => string;
|
|
36
|
-
export declare const bytes32ToAddress: (input: string) => string;
|
|
37
|
-
export declare const isBytes32: (input: string) => boolean;
|
|
38
|
-
export declare function randomBigNumber(bytes?: number, signed?: boolean): BigNumber;
|
|
39
|
-
export declare function randomBytes32(): string;
|
|
40
|
-
export declare function seedWallet(walletToFund: Signer, tokens: Contract[], weth: Contract | undefined, amountToSeedWith: number | BigNumber): Promise<void>;
|
|
41
|
-
export declare function seedContract(contract: Contract, walletToFund: Signer, tokens: Contract[], weth: Contract | undefined, amountToSeedWith: number | BigNumber): Promise<void>;
|
|
42
|
-
export declare function createFake(contractName: string, targetAddress?: string): Promise<FakeContract<BaseContract>>;
|
|
43
|
-
export declare function createFakeFromABI(abi: unknown[], targetAddress?: string): Promise<FakeContract<BaseContract>>;
|
|
44
|
-
export declare function createTypedFakeFromABI<T extends BaseContract>(abi: unknown[], targetAddress?: string): Promise<FakeContract<T>>;
|
|
45
|
-
export declare function trimSolanaAddress(bytes32Address: string): string;
|
|
46
|
-
export declare function hashNonEmptyMessage(message: string): string;
|
|
47
|
-
export declare const createRandomBytes32: () => string;
|
|
48
21
|
export declare function deepEqualsWithBigNumber(x: unknown, y: unknown, omitKeys?: string[]): boolean;
|
|
49
22
|
export declare function assertPromiseError<T>(promise: Promise<T>, errMessage?: string): Promise<void>;
|
|
50
23
|
export declare function assertPromisePasses<T>(promise: Promise<T>): Promise<void>;
|
|
51
|
-
export declare function setupTokensForWallet(contractToApprove: Contract, wallet: SignerWithAddress, tokens: Contract[], weth?: Contract, seedMultiplier?: number): Promise<void>;
|
|
24
|
+
export declare function setupTokensForWallet(contractToApprove: utils.Contract, wallet: utils.SignerWithAddress, tokens: utils.Contract[], weth?: utils.Contract, seedMultiplier?: number): Promise<void>;
|
|
52
25
|
export declare function createSpyLogger(): SpyLoggerResult;
|
|
53
26
|
export declare function deploySpokePoolWithToken(fromChainId?: number): Promise<SpokePoolDeploymentResult>;
|
|
54
|
-
export declare function deployConfigStore(signer: SignerWithAddress, tokensToAdd: Contract[], maxL1TokensPerPoolRebalanceLeaf?: number, maxRefundPerRelayerRefundLeaf?: number, rateModel?: unknown, additionalChainIdIndices?: number[]): Promise<{
|
|
27
|
+
export declare function deployConfigStore(signer: utils.SignerWithAddress, tokensToAdd: utils.Contract[], maxL1TokensPerPoolRebalanceLeaf?: number, maxRefundPerRelayerRefundLeaf?: number, rateModel?: unknown, additionalChainIdIndices?: number[]): Promise<{
|
|
55
28
|
configStore: AcrossConfigStore;
|
|
56
29
|
deploymentBlock: number;
|
|
57
30
|
}>;
|
|
58
|
-
export declare function deployAndConfigureHubPool(signer: SignerWithAddress, spokePools: {
|
|
31
|
+
export declare function deployAndConfigureHubPool(signer: utils.SignerWithAddress, spokePools: {
|
|
59
32
|
l2ChainId: number;
|
|
60
|
-
spokePool: Contract;
|
|
33
|
+
spokePool: utils.Contract;
|
|
61
34
|
}[], finderAddress?: string, timerAddress?: string): Promise<{
|
|
62
|
-
hubPool: Contract;
|
|
63
|
-
mockAdapter: Contract;
|
|
64
|
-
l1Token_1: Contract;
|
|
65
|
-
l1Token_2: Contract;
|
|
35
|
+
hubPool: utils.Contract;
|
|
36
|
+
mockAdapter: utils.Contract;
|
|
37
|
+
l1Token_1: utils.Contract;
|
|
38
|
+
l1Token_2: utils.Contract;
|
|
66
39
|
hubPoolDeploymentBlock: number;
|
|
67
40
|
}>;
|
|
68
|
-
export declare function enableRoutesOnHubPool(hubPool: Contract, rebalanceRouteTokens: {
|
|
41
|
+
export declare function enableRoutesOnHubPool(hubPool: utils.Contract, rebalanceRouteTokens: {
|
|
69
42
|
destinationChainId: number;
|
|
70
|
-
l1Token: Contract;
|
|
71
|
-
destinationToken: Contract;
|
|
43
|
+
l1Token: utils.Contract;
|
|
44
|
+
destinationToken: utils.Contract;
|
|
72
45
|
}[]): Promise<void>;
|
|
73
46
|
/**
|
|
74
47
|
* Takes as input a body and returns a new object with the body and a message property. Used to appease the typescript
|
|
@@ -80,7 +53,7 @@ export declare function appendMessageToResult<T>(body: T): T & {
|
|
|
80
53
|
message: string;
|
|
81
54
|
};
|
|
82
55
|
export declare function getLastBlockTime(provider: providers.Provider): Promise<number>;
|
|
83
|
-
export declare function addLiquidity(signer: SignerWithAddress, hubPool: Contract, l1Token: Contract, amount: BigNumber): Promise<void>;
|
|
56
|
+
export declare function addLiquidity(signer: utils.SignerWithAddress, hubPool: utils.Contract, l1Token: utils.Contract, amount: utils.BigNumber): Promise<void>;
|
|
84
57
|
export declare function deposit(spokePool: Contract, destinationChainId: number, signer: SignerWithAddress, inputToken: Address, inputAmount: BigNumber, outputToken: Address, outputAmount: BigNumber, opts?: {
|
|
85
58
|
destinationChainId?: number;
|
|
86
59
|
recipient?: Address;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator, __spreadArray } from "tslib";
|
|
2
|
+
import * as utils from "@across-protocol/contracts/dist/test-utils";
|
|
2
3
|
import assert from "assert";
|
|
3
4
|
import chai, { expect } from "chai";
|
|
4
5
|
import chaiExclude from "chai-exclude";
|
|
5
|
-
import {
|
|
6
|
-
import { ethers as hreEthers } from "hardhat";
|
|
7
|
-
import { smock } from "@defi-wonderland/smock";
|
|
6
|
+
import { Contract } from "ethers";
|
|
8
7
|
import _ from "lodash";
|
|
9
8
|
import sinon from "sinon";
|
|
10
9
|
import winston from "winston";
|
|
11
10
|
import { GLOBAL_CONFIG_STORE_KEYS } from "../../src/clients";
|
|
12
11
|
import { EMPTY_MESSAGE, PROTOCOL_DEFAULT_CHAIN_ID_INDICES, ZERO_ADDRESS } from "../../src/constants";
|
|
13
12
|
import { BigNumber, bnOne, bnUint32Max, getCurrentTime, getMessageHash, isDefined, resolveContractFromSymbol, toAddressType, toBN, toBNWei, toBytes32, toEvmAddress, toWei, utf8ToHex, } from "../../src/utils";
|
|
14
|
-
import {
|
|
13
|
+
import { MAX_L1_TOKENS_PER_POOL_REBALANCE_LEAF, MAX_REFUNDS_PER_RELAYER_REFUND_LEAF, sampleRateModel, } from "../constants";
|
|
15
14
|
import { SpyTransport } from "./SpyTransport";
|
|
16
15
|
chai.use(chaiExclude);
|
|
17
16
|
var chaiAssert = chai.assert;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export { getDepositParams, getUpdatedV3DepositSignature, modifyRelayHelper, getRelayHash, getV3RelayHash, getLegacyV3RelayHash, getFillRelayParams, getFillRelayUpdatedFeeParams, getExecuteSlowRelayParams, deployMockSpokePoolCaller, } from "../fixtures/SpokePool.Fixture";
|
|
21
|
-
// Re-export constants
|
|
22
|
-
export { randomAddress, zeroAddress };
|
|
17
|
+
// Import fixtures that don't use getContractFactory from @across-protocol/contracts
|
|
18
|
+
export var getDepositParams = utils.getDepositParams, getUpdatedV3DepositSignature = utils.getUpdatedV3DepositSignature, modifyRelayHelper = utils.modifyRelayHelper, randomAddress = utils.randomAddress, zeroAddress = utils.zeroAddress;
|
|
23
19
|
// Import local Merkle utilities that use our local getContractFactory
|
|
24
|
-
export { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves, buildRelayerRefundTree, buildRelayerRefundLeaves, buildSlowRelayTree, buildV3SlowRelayTree, getParamType,
|
|
20
|
+
export { buildPoolRebalanceLeafTree, buildPoolRebalanceLeaves, buildRelayerRefundTree, buildRelayerRefundLeaves, buildSlowRelayTree, buildV3SlowRelayTree, getParamType, } from "./MerkleLib.utils";
|
|
25
21
|
// Import and export the local getContractFactory
|
|
26
22
|
import { getContractFactory } from "./getContractFactory";
|
|
27
23
|
export { getContractFactory };
|
|
@@ -29,184 +25,12 @@ export { getContractFactory };
|
|
|
29
25
|
import { hubPoolFixture, deployHubPool } from "../fixtures/HubPool.Fixture";
|
|
30
26
|
import { spokePoolFixture, deploySpokePool } from "../fixtures/SpokePool.Fixture";
|
|
31
27
|
export { hubPoolFixture, deployHubPool, spokePoolFixture, deploySpokePool };
|
|
32
|
-
// Import and export the merkle lib fixture
|
|
33
|
-
export { merkleLibFixture } from "../fixtures/MerkleLib.Fixture";
|
|
34
28
|
export { BigNumber, Contract, chai, chaiAssert, expect, sinon, toBN, toBNWei, toWei, utf8ToHex, winston };
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// Conversion / encoding helpers (mirroring contracts test-utils)
|
|
40
|
-
// ---------------------------------------------------------------------------
|
|
41
|
-
export var toWeiWithDecimals = function (num, decimals) {
|
|
42
|
-
return ethers.utils.parseUnits(num.toString(), decimals);
|
|
29
|
+
var TokenRolesEnum = {
|
|
30
|
+
OWNER: "0",
|
|
31
|
+
MINTER: "1",
|
|
32
|
+
BURNER: "3",
|
|
43
33
|
};
|
|
44
|
-
export var toBNWeiWithDecimals = function (num, decimals) {
|
|
45
|
-
return BigNumber.from(toWeiWithDecimals(num, decimals));
|
|
46
|
-
};
|
|
47
|
-
export var fromWei = function (num) { return ethers.utils.formatUnits(num.toString()); };
|
|
48
|
-
export var hexToUtf8 = function (input) { return ethers.utils.toUtf8String(input); };
|
|
49
|
-
export var hexZeroPad = function (input, length) { return ethers.utils.hexZeroPad(input, length); };
|
|
50
|
-
export var addressToBytes = function (input) { return hexZeroPad(input.toLowerCase(), 32); };
|
|
51
|
-
export var bytes32ToAddress = function (input) {
|
|
52
|
-
if (!/^0x[a-fA-F0-9]{64}$/.test(input)) {
|
|
53
|
-
throw new Error("Invalid bytes32 input");
|
|
54
|
-
}
|
|
55
|
-
return ethers.utils.getAddress("0x" + input.slice(26));
|
|
56
|
-
};
|
|
57
|
-
export var isBytes32 = function (input) { return /^0x[0-9a-fA-F]{64}$/.test(input); };
|
|
58
|
-
// ---------------------------------------------------------------------------
|
|
59
|
-
// Random data generators
|
|
60
|
-
// ---------------------------------------------------------------------------
|
|
61
|
-
export function randomBigNumber(bytes, signed) {
|
|
62
|
-
if (bytes === void 0) { bytes = 32; }
|
|
63
|
-
if (signed === void 0) { signed = false; }
|
|
64
|
-
var sign = signed && Math.random() < 0.5 ? "-" : "";
|
|
65
|
-
var byteString = "0x" + Buffer.from(ethers.utils.randomBytes(signed ? bytes - 1 : bytes)).toString("hex");
|
|
66
|
-
return ethers.BigNumber.from(sign + byteString);
|
|
67
|
-
}
|
|
68
|
-
export function randomBytes32() {
|
|
69
|
-
return ethers.utils.hexlify(ethers.utils.randomBytes(32));
|
|
70
|
-
}
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
// Wallet / contract seeding
|
|
73
|
-
// ---------------------------------------------------------------------------
|
|
74
|
-
export function seedWallet(walletToFund, tokens, weth, amountToSeedWith) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
-
var _i, tokens_1, token, _a, _b;
|
|
77
|
-
return __generator(this, function (_c) {
|
|
78
|
-
switch (_c.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
_i = 0, tokens_1 = tokens;
|
|
81
|
-
_c.label = 1;
|
|
82
|
-
case 1:
|
|
83
|
-
if (!(_i < tokens_1.length)) return [3 /*break*/, 5];
|
|
84
|
-
token = tokens_1[_i];
|
|
85
|
-
_b = (_a = token).mint;
|
|
86
|
-
return [4 /*yield*/, walletToFund.getAddress()];
|
|
87
|
-
case 2: return [4 /*yield*/, _b.apply(_a, [_c.sent(), amountToSeedWith])];
|
|
88
|
-
case 3:
|
|
89
|
-
_c.sent();
|
|
90
|
-
_c.label = 4;
|
|
91
|
-
case 4:
|
|
92
|
-
_i++;
|
|
93
|
-
return [3 /*break*/, 1];
|
|
94
|
-
case 5:
|
|
95
|
-
if (!weth) return [3 /*break*/, 7];
|
|
96
|
-
return [4 /*yield*/, weth.connect(walletToFund).deposit({ value: amountToSeedWith })];
|
|
97
|
-
case 6:
|
|
98
|
-
_c.sent();
|
|
99
|
-
_c.label = 7;
|
|
100
|
-
case 7: return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
export function seedContract(contract, walletToFund, tokens, weth, amountToSeedWith) {
|
|
106
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
-
var _i, tokens_2, token;
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0: return [4 /*yield*/, seedWallet(walletToFund, tokens, weth, amountToSeedWith)];
|
|
111
|
-
case 1:
|
|
112
|
-
_a.sent();
|
|
113
|
-
_i = 0, tokens_2 = tokens;
|
|
114
|
-
_a.label = 2;
|
|
115
|
-
case 2:
|
|
116
|
-
if (!(_i < tokens_2.length)) return [3 /*break*/, 5];
|
|
117
|
-
token = tokens_2[_i];
|
|
118
|
-
return [4 /*yield*/, token.connect(walletToFund).transfer(contract.address, amountToSeedWith)];
|
|
119
|
-
case 3:
|
|
120
|
-
_a.sent();
|
|
121
|
-
_a.label = 4;
|
|
122
|
-
case 4:
|
|
123
|
-
_i++;
|
|
124
|
-
return [3 /*break*/, 2];
|
|
125
|
-
case 5:
|
|
126
|
-
if (!weth) return [3 /*break*/, 7];
|
|
127
|
-
return [4 /*yield*/, weth.connect(walletToFund).transfer(contract.address, amountToSeedWith)];
|
|
128
|
-
case 6:
|
|
129
|
-
_a.sent();
|
|
130
|
-
_a.label = 7;
|
|
131
|
-
case 7: return [2 /*return*/];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
// ---------------------------------------------------------------------------
|
|
137
|
-
// Smock fakes
|
|
138
|
-
// ---------------------------------------------------------------------------
|
|
139
|
-
export function createFake(contractName_1) {
|
|
140
|
-
return __awaiter(this, arguments, void 0, function (contractName, targetAddress) {
|
|
141
|
-
var contractFactory;
|
|
142
|
-
if (targetAddress === void 0) { targetAddress = ""; }
|
|
143
|
-
return __generator(this, function (_a) {
|
|
144
|
-
switch (_a.label) {
|
|
145
|
-
case 0: return [4 /*yield*/, getContractFactory(contractName, new ethers.VoidSigner(ethers.constants.AddressZero))];
|
|
146
|
-
case 1:
|
|
147
|
-
contractFactory = _a.sent();
|
|
148
|
-
return [2 /*return*/, smock.fake(contractFactory.interface.fragments, {
|
|
149
|
-
address: targetAddress === "" ? undefined : targetAddress,
|
|
150
|
-
provider: contractFactory.signer.provider,
|
|
151
|
-
})];
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
export function createFakeFromABI(abi_1) {
|
|
157
|
-
return __awaiter(this, arguments, void 0, function (abi, targetAddress) {
|
|
158
|
-
if (targetAddress === void 0) { targetAddress = ""; }
|
|
159
|
-
return __generator(this, function (_a) {
|
|
160
|
-
switch (_a.label) {
|
|
161
|
-
case 0: return [4 /*yield*/, createTypedFakeFromABI(abi, targetAddress)];
|
|
162
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
export function createTypedFakeFromABI(abi_1) {
|
|
168
|
-
return __awaiter(this, arguments, void 0, function (abi, targetAddress) {
|
|
169
|
-
var signer;
|
|
170
|
-
if (targetAddress === void 0) { targetAddress = ""; }
|
|
171
|
-
return __generator(this, function (_a) {
|
|
172
|
-
switch (_a.label) {
|
|
173
|
-
case 0:
|
|
174
|
-
signer = new ethers.VoidSigner(ethers.constants.AddressZero);
|
|
175
|
-
return [4 /*yield*/, smock.fake(abi, {
|
|
176
|
-
address: !targetAddress ? undefined : targetAddress,
|
|
177
|
-
provider: signer.provider,
|
|
178
|
-
})];
|
|
179
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
// ---------------------------------------------------------------------------
|
|
185
|
-
// Solana / message helpers
|
|
186
|
-
// ---------------------------------------------------------------------------
|
|
187
|
-
export function trimSolanaAddress(bytes32Address) {
|
|
188
|
-
if (!ethers.utils.isHexString(bytes32Address, 32)) {
|
|
189
|
-
throw new Error("Invalid bytes32 address");
|
|
190
|
-
}
|
|
191
|
-
var uint160Address = ethers.BigNumber.from(bytes32Address).mask(160);
|
|
192
|
-
return ethers.utils.hexZeroPad(ethers.utils.hexlify(uint160Address), 20);
|
|
193
|
-
}
|
|
194
|
-
export function hashNonEmptyMessage(message) {
|
|
195
|
-
if (!ethers.utils.isHexString(message) || message.length % 2 !== 0)
|
|
196
|
-
throw new Error("Invalid hex message bytes");
|
|
197
|
-
// account for 0x prefix when checking length
|
|
198
|
-
if (message.length > 2) {
|
|
199
|
-
return ethers.utils.keccak256(message);
|
|
200
|
-
}
|
|
201
|
-
return ethers.utils.hexlify(new Uint8Array(32));
|
|
202
|
-
}
|
|
203
|
-
// ---------------------------------------------------------------------------
|
|
204
|
-
// createRandomBytes32 (kept for backward compatibility)
|
|
205
|
-
// ---------------------------------------------------------------------------
|
|
206
|
-
export var createRandomBytes32 = function () { return ethers.utils.hexlify(ethers.utils.randomBytes(32)); };
|
|
207
|
-
// ---------------------------------------------------------------------------
|
|
208
|
-
// Test helper functions
|
|
209
|
-
// ---------------------------------------------------------------------------
|
|
210
34
|
export function deepEqualsWithBigNumber(x, y, omitKeys) {
|
|
211
35
|
if (omitKeys === void 0) { omitKeys = []; }
|
|
212
36
|
if (x === undefined || y === undefined || x === null || y === null) {
|
|
@@ -272,7 +96,7 @@ export function assertPromisePasses(promise) {
|
|
|
272
96
|
});
|
|
273
97
|
});
|
|
274
98
|
}
|
|
275
|
-
export function setupTokensForWallet(contractToApprove_1, wallet_1,
|
|
99
|
+
export function setupTokensForWallet(contractToApprove_1, wallet_1, tokens_1, weth_1) {
|
|
276
100
|
return __awaiter(this, arguments, void 0, function (contractToApprove, wallet, tokens, weth, seedMultiplier) {
|
|
277
101
|
var approveToken;
|
|
278
102
|
var _this = this;
|
|
@@ -294,7 +118,7 @@ export function setupTokensForWallet(contractToApprove_1, wallet_1, tokens_3, we
|
|
|
294
118
|
}
|
|
295
119
|
});
|
|
296
120
|
}); };
|
|
297
|
-
return [4 /*yield*/, seedWallet(wallet, tokens, weth, amountToSeedWallets.mul(seedMultiplier))];
|
|
121
|
+
return [4 /*yield*/, utils.seedWallet(wallet, tokens, weth, utils.amountToSeedWallets.mul(seedMultiplier))];
|
|
298
122
|
case 1:
|
|
299
123
|
_a.sent();
|
|
300
124
|
return [4 /*yield*/, Promise.all(tokens.map(approveToken))];
|
|
@@ -328,13 +152,13 @@ export function deploySpokePoolWithToken() {
|
|
|
328
152
|
if (fromChainId === void 0) { fromChainId = 0; }
|
|
329
153
|
return __generator(this, function (_b) {
|
|
330
154
|
switch (_b.label) {
|
|
331
|
-
case 0: return [4 /*yield*/, deploySpokePool(
|
|
155
|
+
case 0: return [4 /*yield*/, deploySpokePool(utils.ethers)];
|
|
332
156
|
case 1:
|
|
333
157
|
_a = _b.sent(), weth = _a.weth, erc20 = _a.erc20, spokePool = _a.spokePool, unwhitelistedErc20 = _a.unwhitelistedErc20, destErc20 = _a.destErc20;
|
|
334
158
|
return [4 /*yield*/, spokePool.deployTransaction.wait()];
|
|
335
159
|
case 2:
|
|
336
160
|
receipt = _b.sent();
|
|
337
|
-
return [4 /*yield*/, spokePool.setChainId(fromChainId == 0 ? originChainId : fromChainId)];
|
|
161
|
+
return [4 /*yield*/, spokePool.setChainId(fromChainId == 0 ? utils.originChainId : fromChainId)];
|
|
338
162
|
case 3:
|
|
339
163
|
_b.sent();
|
|
340
164
|
return [2 /*return*/, { weth: weth, erc20: erc20, spokePool: spokePool, unwhitelistedErc20: unwhitelistedErc20, destErc20: destErc20, deploymentBlock: receipt.blockNumber }];
|
|
@@ -493,7 +317,7 @@ export function addLiquidity(signer, hubPool, l1Token, amount) {
|
|
|
493
317
|
return __awaiter(this, void 0, void 0, function () {
|
|
494
318
|
return __generator(this, function (_a) {
|
|
495
319
|
switch (_a.label) {
|
|
496
|
-
case 0: return [4 /*yield*/, seedWallet(signer, [l1Token], undefined, amount)];
|
|
320
|
+
case 0: return [4 /*yield*/, utils.seedWallet(signer, [l1Token], undefined, amount)];
|
|
497
321
|
case 1:
|
|
498
322
|
_a.sent();
|
|
499
323
|
return [4 /*yield*/, l1Token.connect(signer).approve(hubPool.address, amount)];
|
|
@@ -520,7 +344,7 @@ export function depositV3(spokePool, destinationChainId, signer, inputToken, inp
|
|
|
520
344
|
}
|
|
521
345
|
function _deposit(spokePool_1, destinationChainId_1, signer_1, inputToken_1, inputAmount_1, outputToken_1, outputAmount_1) {
|
|
522
346
|
return __awaiter(this, arguments, void 0, function (spokePool, destinationChainId, signer, inputToken, inputAmount, outputToken, outputAmount, opts) {
|
|
523
|
-
var depositor, _a, _b, recipient, _c, spokePoolTime, fillDeadlineBuffer, quoteTimestamp, message, fillDeadline, exclusivityDeadline, exclusiveRelayer, getChainId, _d, events,
|
|
347
|
+
var depositor, _a, _b, recipient, _c, spokePoolTime, fillDeadlineBuffer, quoteTimestamp, message, fillDeadline, exclusivityDeadline, exclusiveRelayer, getChainId, _d, events, originChainId, lastEvent, args, _e, blockNumber, transactionHash, transactionIndex, logIndex;
|
|
524
348
|
var _this = this;
|
|
525
349
|
var _f, _g, _h, _j, _k, _l;
|
|
526
350
|
if (opts === void 0) { opts = {}; }
|
|
@@ -560,7 +384,7 @@ function _deposit(spokePool_1, destinationChainId_1, signer_1, inputToken_1, inp
|
|
|
560
384
|
getChainId(),
|
|
561
385
|
])];
|
|
562
386
|
case 4:
|
|
563
|
-
_d = _m.sent(), events = _d[0],
|
|
387
|
+
_d = _m.sent(), events = _d[0], originChainId = _d[1];
|
|
564
388
|
lastEvent = events.at(-1);
|
|
565
389
|
args = lastEvent === null || lastEvent === void 0 ? void 0 : lastEvent.args;
|
|
566
390
|
chaiAssert.exists(args);
|
|
@@ -569,11 +393,11 @@ function _deposit(spokePool_1, destinationChainId_1, signer_1, inputToken_1, inp
|
|
|
569
393
|
assert(args.destinationChainId.toNumber() === destinationChainId);
|
|
570
394
|
return [2 /*return*/, {
|
|
571
395
|
depositId: toBN(args.depositId),
|
|
572
|
-
originChainId:
|
|
396
|
+
originChainId: originChainId,
|
|
573
397
|
destinationChainId: destinationChainId,
|
|
574
|
-
depositor: toAddressType(args.depositor,
|
|
398
|
+
depositor: toAddressType(args.depositor, originChainId),
|
|
575
399
|
recipient: toAddressType(args.recipient, destinationChainId),
|
|
576
|
-
inputToken: toAddressType(args.inputToken,
|
|
400
|
+
inputToken: toAddressType(args.inputToken, originChainId),
|
|
577
401
|
inputAmount: args.inputAmount,
|
|
578
402
|
outputToken: toAddressType(args.outputToken, destinationChainId),
|
|
579
403
|
outputAmount: args.outputAmount,
|
|
@@ -597,7 +421,7 @@ function _deposit(spokePool_1, destinationChainId_1, signer_1, inputToken_1, inp
|
|
|
597
421
|
}
|
|
598
422
|
export function requestV3SlowFill(spokePool, relayData, signer) {
|
|
599
423
|
return __awaiter(this, void 0, void 0, function () {
|
|
600
|
-
var destinationChainId, _a, events, lastEvent, _b, blockNumber, transactionHash, transactionIndex, logIndex, args,
|
|
424
|
+
var destinationChainId, _a, events, lastEvent, _b, blockNumber, transactionHash, transactionIndex, logIndex, args, originChainId;
|
|
601
425
|
return __generator(this, function (_c) {
|
|
602
426
|
switch (_c.label) {
|
|
603
427
|
case 0:
|
|
@@ -617,14 +441,14 @@ export function requestV3SlowFill(spokePool, relayData, signer) {
|
|
|
617
441
|
_b = lastEvent, blockNumber = _b.blockNumber, transactionHash = _b.transactionHash, transactionIndex = _b.transactionIndex, logIndex = _b.logIndex;
|
|
618
442
|
expect(lastEvent.args).to.exist;
|
|
619
443
|
args = lastEvent.args;
|
|
620
|
-
|
|
444
|
+
originChainId = Number(args.originChainId);
|
|
621
445
|
return [2 /*return*/, {
|
|
622
446
|
depositId: toBN(args.depositId),
|
|
623
|
-
originChainId:
|
|
447
|
+
originChainId: originChainId,
|
|
624
448
|
destinationChainId: destinationChainId,
|
|
625
|
-
depositor: toAddressType(args.depositor,
|
|
449
|
+
depositor: toAddressType(args.depositor, originChainId),
|
|
626
450
|
recipient: toAddressType(args.recipient, destinationChainId),
|
|
627
|
-
inputToken: toAddressType(args.inputToken,
|
|
451
|
+
inputToken: toAddressType(args.inputToken, originChainId),
|
|
628
452
|
inputAmount: args.inputAmount,
|
|
629
453
|
outputToken: toAddressType(args.outputToken, destinationChainId),
|
|
630
454
|
outputAmount: args.outputAmount,
|
|
@@ -643,7 +467,7 @@ export function requestV3SlowFill(spokePool, relayData, signer) {
|
|
|
643
467
|
}
|
|
644
468
|
export function fillRelay(spokePool, _deposit, signer, repayment) {
|
|
645
469
|
return __awaiter(this, void 0, void 0, function () {
|
|
646
|
-
var destinationChainId, _a,
|
|
470
|
+
var destinationChainId, _a, deposit, repaymentAddress, events, lastEvent, args, _b, blockNumber, transactionHash, transactionIndex, logIndex;
|
|
647
471
|
var _c, _d;
|
|
648
472
|
return __generator(this, function (_e) {
|
|
649
473
|
switch (_e.label) {
|
|
@@ -653,11 +477,11 @@ export function fillRelay(spokePool, _deposit, signer, repayment) {
|
|
|
653
477
|
case 1:
|
|
654
478
|
destinationChainId = _a.apply(void 0, [_e.sent()]);
|
|
655
479
|
chaiAssert.notEqual(_deposit.originChainId, destinationChainId);
|
|
656
|
-
|
|
480
|
+
deposit = __assign(__assign({}, _deposit), { depositor: _deposit.depositor.toBytes32(), recipient: _deposit.recipient.toBytes32(), exclusiveRelayer: _deposit.exclusiveRelayer.toBytes32(), inputToken: _deposit.inputToken.toBytes32(), outputToken: _deposit.outputToken.toBytes32() });
|
|
657
481
|
repaymentAddress = (_c = repayment === null || repayment === void 0 ? void 0 : repayment.repaymentAddress.toBytes32()) !== null && _c !== void 0 ? _c : toBytes32(signer.address);
|
|
658
482
|
return [4 /*yield*/, spokePool
|
|
659
483
|
.connect(signer)
|
|
660
|
-
.fillRelay(
|
|
484
|
+
.fillRelay(deposit, (_d = repayment === null || repayment === void 0 ? void 0 : repayment.repaymentChainId) !== null && _d !== void 0 ? _d : destinationChainId, repaymentAddress)];
|
|
661
485
|
case 2:
|
|
662
486
|
_e.sent();
|
|
663
487
|
return [4 /*yield*/, spokePool.queryFilter(spokePool.filters.FilledRelay())];
|
|
@@ -704,7 +528,7 @@ export function fillRelay(spokePool, _deposit, signer, repayment) {
|
|
|
704
528
|
* @returns The latest block number.
|
|
705
529
|
*/
|
|
706
530
|
export function getLastBlockNumber() {
|
|
707
|
-
return
|
|
531
|
+
return utils.ethers.provider.getBlockNumber();
|
|
708
532
|
}
|
|
709
533
|
export function convertMockedConfigClient(_client) {
|
|
710
534
|
return true;
|