@across-protocol/sdk 4.3.127 → 4.3.129
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/test/constants.d.ts +58 -8
- package/dist/cjs/test/constants.js +70 -13
- package/dist/cjs/test/constants.js.map +1 -1
- package/dist/cjs/test/fixtures/MerkleLib.Fixture.d.ts +4 -0
- package/dist/cjs/test/fixtures/MerkleLib.Fixture.js +22 -0
- package/dist/cjs/test/fixtures/MerkleLib.Fixture.js.map +1 -0
- package/dist/cjs/test/fixtures/SpokePool.Fixture.d.ts +91 -1
- package/dist/cjs/test/fixtures/SpokePool.Fixture.js +196 -1
- package/dist/cjs/test/fixtures/SpokePool.Fixture.js.map +1 -1
- package/dist/cjs/test/types/index.d.ts +10 -11
- package/dist/cjs/test/utils/MerkleLib.utils.d.ts +26 -1
- package/dist/cjs/test/utils/MerkleLib.utils.js +40 -0
- package/dist/cjs/test/utils/MerkleLib.utils.js.map +1 -1
- package/dist/cjs/test/utils/index.d.ts +0 -1
- package/dist/cjs/test/utils/index.js +1 -2
- package/dist/cjs/test/utils/index.js.map +1 -1
- package/dist/cjs/test/utils/utils.d.ts +44 -17
- package/dist/cjs/test/utils/utils.js +223 -37
- package/dist/cjs/test/utils/utils.js.map +1 -1
- package/dist/cjs/test-utils.d.ts +1 -1
- package/dist/cjs/test-utils.js +47 -12
- package/dist/cjs/test-utils.js.map +1 -1
- package/dist/cjs/typechain.d.ts +1 -0
- package/dist/cjs/typechain.js +5 -0
- package/dist/cjs/typechain.js.map +1 -0
- package/dist/esm/test/constants.d.ts +58 -8
- package/dist/esm/test/constants.js +87 -13
- package/dist/esm/test/constants.js.map +1 -1
- package/dist/esm/test/fixtures/MerkleLib.Fixture.d.ts +4 -0
- package/dist/esm/test/fixtures/MerkleLib.Fixture.js +19 -0
- package/dist/esm/test/fixtures/MerkleLib.Fixture.js.map +1 -0
- package/dist/esm/test/fixtures/SpokePool.Fixture.d.ts +92 -1
- package/dist/esm/test/fixtures/SpokePool.Fixture.js +201 -1
- package/dist/esm/test/fixtures/SpokePool.Fixture.js.map +1 -1
- package/dist/esm/test/types/index.d.ts +10 -11
- package/dist/esm/test/utils/MerkleLib.utils.d.ts +32 -1
- package/dist/esm/test/utils/MerkleLib.utils.js +44 -0
- package/dist/esm/test/utils/MerkleLib.utils.js.map +1 -1
- package/dist/esm/test/utils/index.d.ts +0 -1
- package/dist/esm/test/utils/index.js +0 -2
- package/dist/esm/test/utils/index.js.map +1 -1
- package/dist/esm/test/utils/utils.d.ts +44 -17
- package/dist/esm/test/utils/utils.js +205 -29
- package/dist/esm/test/utils/utils.js.map +1 -1
- package/dist/esm/test-utils.d.ts +1 -1
- package/dist/esm/test-utils.js +1 -1
- package/dist/esm/test-utils.js.map +1 -1
- package/dist/esm/typechain.d.ts +1 -0
- package/dist/esm/typechain.js +4 -0
- package/dist/esm/typechain.js.map +1 -0
- package/dist/types/test/constants.d.ts +58 -8
- package/dist/types/test/constants.d.ts.map +1 -1
- package/dist/types/test/fixtures/MerkleLib.Fixture.d.ts +5 -0
- package/dist/types/test/fixtures/MerkleLib.Fixture.d.ts.map +1 -0
- package/dist/types/test/fixtures/SpokePool.Fixture.d.ts +92 -1
- package/dist/types/test/fixtures/SpokePool.Fixture.d.ts.map +1 -1
- package/dist/types/test/types/index.d.ts +10 -11
- package/dist/types/test/types/index.d.ts.map +1 -1
- package/dist/types/test/utils/MerkleLib.utils.d.ts +32 -1
- package/dist/types/test/utils/MerkleLib.utils.d.ts.map +1 -1
- package/dist/types/test/utils/index.d.ts +0 -1
- package/dist/types/test/utils/index.d.ts.map +1 -1
- package/dist/types/test/utils/utils.d.ts +44 -17
- package/dist/types/test/utils/utils.d.ts.map +1 -1
- package/dist/types/test-utils.d.ts +1 -1
- package/dist/types/test-utils.d.ts.map +1 -1
- package/dist/types/typechain.d.ts +2 -0
- package/dist/types/typechain.d.ts.map +1 -0
- package/package.json +9 -2
- package/test-utils.ts +88 -0
- package/typechain.ts +3 -0
|
@@ -3,9 +3,209 @@ import "@nomiclabs/hardhat-ethers";
|
|
|
3
3
|
import "@openzeppelin/hardhat-upgrades";
|
|
4
4
|
import "hardhat-deploy";
|
|
5
5
|
import hre from "hardhat";
|
|
6
|
+
import { ethers as ethersLib } from "ethers";
|
|
6
7
|
import { getContractFactory } from "../utils/getContractFactory";
|
|
7
|
-
import { destinationChainId, TokenRolesEnum, zeroAddress } from "../constants";
|
|
8
|
+
import { amountToDeposit, depositRelayerFeePct, destinationChainId, maxUint256, realizedLpFeePct, repaymentChainId, TokenRolesEnum, zeroAddress, randomAddress, } from "../constants";
|
|
9
|
+
var _a = ethersLib.utils, defaultAbiCoder = _a.defaultAbiCoder, keccak256 = _a.keccak256;
|
|
8
10
|
export { zeroAddress };
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Relay hash helpers
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
export function getRelayHash(_depositor, _recipient, _depositId, _originChainId, _destinationChainId, _destinationToken, _amount, _realizedLpFeePct, _relayerFeePct, _message) {
|
|
15
|
+
var relayData = {
|
|
16
|
+
depositor: _depositor,
|
|
17
|
+
recipient: _recipient,
|
|
18
|
+
destinationToken: _destinationToken,
|
|
19
|
+
amount: _amount || amountToDeposit,
|
|
20
|
+
originChainId: _originChainId.toString(),
|
|
21
|
+
destinationChainId: _destinationChainId.toString(),
|
|
22
|
+
realizedLpFeePct: _realizedLpFeePct || realizedLpFeePct,
|
|
23
|
+
relayerFeePct: _relayerFeePct || depositRelayerFeePct,
|
|
24
|
+
depositId: _depositId.toString(),
|
|
25
|
+
message: _message || "0x",
|
|
26
|
+
};
|
|
27
|
+
var relayHash = keccak256(defaultAbiCoder.encode([
|
|
28
|
+
"tuple(address depositor, address recipient, address destinationToken, uint256 amount, uint256 originChainId, uint256 destinationChainId, int64 realizedLpFeePct, int64 relayerFeePct, uint32 depositId, bytes message)",
|
|
29
|
+
], [relayData]));
|
|
30
|
+
return { relayHash: relayHash, relayData: relayData };
|
|
31
|
+
}
|
|
32
|
+
export function getV3RelayHash(relayData, destChainId) {
|
|
33
|
+
return keccak256(defaultAbiCoder.encode([
|
|
34
|
+
"tuple(bytes32 depositor, bytes32 recipient, bytes32 exclusiveRelayer, bytes32 inputToken, bytes32 outputToken, uint256 inputAmount, uint256 outputAmount, uint256 originChainId, uint256 depositId, uint32 fillDeadline, uint32 exclusivityDeadline, bytes message)",
|
|
35
|
+
"uint256 destinationChainId",
|
|
36
|
+
], [relayData, destChainId]));
|
|
37
|
+
}
|
|
38
|
+
export function getLegacyV3RelayHash(relayData, destChainId) {
|
|
39
|
+
return keccak256(defaultAbiCoder.encode([
|
|
40
|
+
"tuple(address depositor, address recipient, address exclusiveRelayer, address inputToken, address outputToken, uint256 inputAmount, uint256 outputAmount, uint256 originChainId, uint32 depositId, uint32 fillDeadline, uint32 exclusivityDeadline, bytes message)",
|
|
41
|
+
"uint256 destinationChainId",
|
|
42
|
+
], [relayData, destChainId]));
|
|
43
|
+
}
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// Parameter builders
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
export function getDepositParams(args) {
|
|
48
|
+
var _a, _b, _c, _d;
|
|
49
|
+
return [
|
|
50
|
+
(_a = args.recipient) !== null && _a !== void 0 ? _a : randomAddress(),
|
|
51
|
+
args.originToken,
|
|
52
|
+
args.amount.toString(),
|
|
53
|
+
args.destinationChainId.toString(),
|
|
54
|
+
args.relayerFeePct.toString(),
|
|
55
|
+
args.quoteTimestamp.toString(),
|
|
56
|
+
(_b = args.message) !== null && _b !== void 0 ? _b : "0x",
|
|
57
|
+
(_d = (_c = args === null || args === void 0 ? void 0 : args.maxCount) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : maxUint256.toString(),
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
export function getFillRelayParams(_relayData, _maxTokensToSend, _repaymentChain, _maxCount) {
|
|
61
|
+
return [
|
|
62
|
+
_relayData.depositor,
|
|
63
|
+
_relayData.recipient,
|
|
64
|
+
_relayData.destinationToken,
|
|
65
|
+
_relayData.amount.toString(),
|
|
66
|
+
_maxTokensToSend.toString(),
|
|
67
|
+
_repaymentChain ? _repaymentChain.toString() : repaymentChainId.toString(),
|
|
68
|
+
_relayData.originChainId,
|
|
69
|
+
_relayData.realizedLpFeePct.toString(),
|
|
70
|
+
_relayData.relayerFeePct.toString(),
|
|
71
|
+
_relayData.depositId,
|
|
72
|
+
_relayData.message || "0x",
|
|
73
|
+
_maxCount ? _maxCount.toString() : maxUint256.toString(),
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
export function getFillRelayUpdatedFeeParams(_relayData, _maxTokensToSend, _updatedFee, _signature, _repaymentChain, _updatedRecipient, _updatedMessage, _maxCount) {
|
|
77
|
+
return [
|
|
78
|
+
_relayData.depositor,
|
|
79
|
+
_relayData.recipient,
|
|
80
|
+
_updatedRecipient || _relayData.recipient,
|
|
81
|
+
_relayData.destinationToken,
|
|
82
|
+
_relayData.amount.toString(),
|
|
83
|
+
_maxTokensToSend.toString(),
|
|
84
|
+
_repaymentChain ? _repaymentChain.toString() : repaymentChainId.toString(),
|
|
85
|
+
_relayData.originChainId,
|
|
86
|
+
_relayData.realizedLpFeePct.toString(),
|
|
87
|
+
_relayData.relayerFeePct.toString(),
|
|
88
|
+
_updatedFee.toString(),
|
|
89
|
+
_relayData.depositId,
|
|
90
|
+
_relayData.message,
|
|
91
|
+
_updatedMessage || _relayData.message,
|
|
92
|
+
_signature,
|
|
93
|
+
_maxCount ? _maxCount.toString() : maxUint256.toString(),
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
export function getExecuteSlowRelayParams(_depositor, _recipient, _destToken, _amount, _originChainId, _realizedLpFeePct, _relayerFeePct, _depositId, _relayerRefundId, _message, _payoutAdjustment, _proof) {
|
|
97
|
+
return [
|
|
98
|
+
_depositor,
|
|
99
|
+
_recipient,
|
|
100
|
+
_destToken,
|
|
101
|
+
_amount.toString(),
|
|
102
|
+
_originChainId.toString(),
|
|
103
|
+
_realizedLpFeePct.toString(),
|
|
104
|
+
_relayerFeePct.toString(),
|
|
105
|
+
_depositId.toString(),
|
|
106
|
+
_relayerRefundId.toString(),
|
|
107
|
+
_message,
|
|
108
|
+
_payoutAdjustment.toString(),
|
|
109
|
+
_proof,
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
// ---------------------------------------------------------------------------
|
|
113
|
+
// EIP-712 signature helpers
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
export function modifyRelayHelper(modifiedRelayerFeePct, depositId, originChainId, depositor, updatedRecipient, updatedMessage) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
+
var typedData, signature;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
typedData = {
|
|
122
|
+
types: {
|
|
123
|
+
UpdateDepositDetails: [
|
|
124
|
+
{ name: "depositId", type: "uint32" },
|
|
125
|
+
{ name: "originChainId", type: "uint256" },
|
|
126
|
+
{ name: "updatedRelayerFeePct", type: "int64" },
|
|
127
|
+
{ name: "updatedRecipient", type: "address" },
|
|
128
|
+
{ name: "updatedMessage", type: "bytes" },
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
domain: {
|
|
132
|
+
name: "ACROSS-V2",
|
|
133
|
+
version: "1.0.0",
|
|
134
|
+
chainId: Number(originChainId),
|
|
135
|
+
},
|
|
136
|
+
message: {
|
|
137
|
+
depositId: depositId,
|
|
138
|
+
originChainId: originChainId,
|
|
139
|
+
updatedRelayerFeePct: modifiedRelayerFeePct,
|
|
140
|
+
updatedRecipient: updatedRecipient,
|
|
141
|
+
updatedMessage: updatedMessage,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
return [4 /*yield*/, depositor._signTypedData(typedData.domain, typedData.types, typedData.message)];
|
|
145
|
+
case 1:
|
|
146
|
+
signature = _a.sent();
|
|
147
|
+
return [2 /*return*/, { signature: signature }];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export function getUpdatedV3DepositSignature(depositor, depositId, originChainId, updatedOutputAmount, updatedRecipient, updatedMessage) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
154
|
+
var typedData;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
typedData = {
|
|
159
|
+
types: {
|
|
160
|
+
UpdateDepositDetails: [
|
|
161
|
+
{ name: "depositId", type: "uint256" },
|
|
162
|
+
{ name: "originChainId", type: "uint256" },
|
|
163
|
+
{ name: "updatedOutputAmount", type: "uint256" },
|
|
164
|
+
{ name: "updatedRecipient", type: "bytes32" },
|
|
165
|
+
{ name: "updatedMessage", type: "bytes" },
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
domain: {
|
|
169
|
+
name: "ACROSS-V2",
|
|
170
|
+
version: "1.0.0",
|
|
171
|
+
chainId: originChainId,
|
|
172
|
+
},
|
|
173
|
+
message: {
|
|
174
|
+
depositId: depositId,
|
|
175
|
+
originChainId: originChainId,
|
|
176
|
+
updatedOutputAmount: updatedOutputAmount,
|
|
177
|
+
updatedRecipient: updatedRecipient,
|
|
178
|
+
updatedMessage: updatedMessage,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
return [4 /*yield*/, depositor._signTypedData(typedData.domain, typedData.types, typedData.message)];
|
|
182
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
// Mock deployers
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
export function deployMockSpokePoolCaller(spokePool, rootBundleId, leaf, proof) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
192
|
+
var _a, _b;
|
|
193
|
+
return __generator(this, function (_c) {
|
|
194
|
+
switch (_c.label) {
|
|
195
|
+
case 0:
|
|
196
|
+
_a = getContractFactory;
|
|
197
|
+
_b = ["MockCaller"];
|
|
198
|
+
return [4 /*yield*/, hre.ethers.getSigners()];
|
|
199
|
+
case 1: return [4 /*yield*/, _a.apply(void 0, _b.concat([(_c.sent())[0]]))];
|
|
200
|
+
case 2: return [4 /*yield*/, (_c.sent()).deploy(spokePool.address, rootBundleId, leaf, proof)];
|
|
201
|
+
case 3: return [2 /*return*/, _c.sent()];
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
// Deployment
|
|
208
|
+
// ---------------------------------------------------------------------------
|
|
9
209
|
/**
|
|
10
210
|
* Deploys a SpokePool with associated tokens for testing.
|
|
11
211
|
* This is a local implementation that uses our local getContractFactory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpokePool.Fixture.js","sourceRoot":"","sources":["../../../../test/fixtures/SpokePool.Fixture.ts"],"names":[],"mappings":";AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,gCAAgC,CAAC;AACxC,OAAO,gBAAgB,CAAC;AACxB,OAAO,GAAG,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SpokePool.Fixture.js","sourceRoot":"","sources":["../../../../test/fixtures/SpokePool.Fixture.ts"],"names":[],"mappings":";AAAA,OAAO,2BAA2B,CAAC;AACnC,OAAO,gCAAgC,CAAC;AACxC,OAAO,gBAAgB,CAAC;AACxB,OAAO,GAAG,MAAM,SAAS,CAAC;AAC1B,OAAO,EAAuB,MAAM,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,eAAe,EACf,oBAAoB,EACp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C,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HardhatEthersHelpers } from "@nomiclabs/hardhat-ethers/types";
|
|
2
|
-
import type { ethers } from "ethers";
|
|
2
|
+
import type { ethers, Contract, BigNumber } from "ethers";
|
|
3
3
|
import winston from "winston";
|
|
4
|
-
import * as utils from "@across-protocol/contracts/dist/test-utils";
|
|
5
4
|
import { sinon } from "../utils";
|
|
6
5
|
export type EthersTestLibrary = typeof ethers & HardhatEthersHelpers;
|
|
7
6
|
export type SpyLoggerResult = {
|
|
@@ -9,20 +8,20 @@ export type SpyLoggerResult = {
|
|
|
9
8
|
spyLogger: winston.Logger;
|
|
10
9
|
};
|
|
11
10
|
export type SpokePoolDeploymentResult = {
|
|
12
|
-
weth:
|
|
13
|
-
erc20:
|
|
14
|
-
spokePool:
|
|
15
|
-
unwhitelistedErc20:
|
|
16
|
-
destErc20:
|
|
11
|
+
weth: Contract;
|
|
12
|
+
erc20: Contract;
|
|
13
|
+
spokePool: Contract;
|
|
14
|
+
unwhitelistedErc20: Contract;
|
|
15
|
+
destErc20: Contract;
|
|
17
16
|
deploymentBlock: number;
|
|
18
17
|
};
|
|
19
18
|
export type ContractsV2SlowFillRelayData = {
|
|
20
19
|
depositor: string;
|
|
21
20
|
recipient: string;
|
|
22
21
|
destinationToken: string;
|
|
23
|
-
amount:
|
|
24
|
-
realizedLpFeePct:
|
|
25
|
-
relayerFeePct:
|
|
22
|
+
amount: BigNumber;
|
|
23
|
+
realizedLpFeePct: BigNumber;
|
|
24
|
+
relayerFeePct: BigNumber;
|
|
26
25
|
depositId: string;
|
|
27
26
|
originChainId: string;
|
|
28
27
|
destinationChainId: string;
|
|
@@ -30,5 +29,5 @@ export type ContractsV2SlowFillRelayData = {
|
|
|
30
29
|
};
|
|
31
30
|
export type ContractsV2SlowFill = {
|
|
32
31
|
relayData: ContractsV2SlowFillRelayData;
|
|
33
|
-
payoutAdjustmentPct:
|
|
32
|
+
payoutAdjustmentPct: BigNumber;
|
|
34
33
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* These are reimplementations of the utilities from @across-protocol/contracts
|
|
4
4
|
* to avoid dependency on their getContractFactory which looks for Hardhat artifacts.
|
|
5
5
|
*/
|
|
6
|
-
import { BigNumber, ethers } from "ethers";
|
|
6
|
+
import { BigNumber, Contract, ethers } from "ethers";
|
|
7
7
|
import { MerkleTree } from "@across-protocol/contracts/dist/utils/MerkleTree";
|
|
8
8
|
/**
|
|
9
9
|
* Get the parameter type for a contract function parameter.
|
|
@@ -64,3 +64,34 @@ export declare function buildSlowRelayTree(slowFills: unknown[]): Promise<Merkle
|
|
|
64
64
|
* Build a V3 slow relay Merkle tree.
|
|
65
65
|
*/
|
|
66
66
|
export declare function buildV3SlowRelayTree(slowFills: unknown[]): Promise<MerkleTree<unknown>>;
|
|
67
|
+
/**
|
|
68
|
+
* Construct a single-leaf relayer refund tree.
|
|
69
|
+
*/
|
|
70
|
+
export declare function constructSingleRelayerRefundTree(l2Token: Contract | string, destinationChainId: number, amount?: BigNumber): Promise<{
|
|
71
|
+
leaves: {
|
|
72
|
+
leafId: BigNumber;
|
|
73
|
+
chainId: BigNumber;
|
|
74
|
+
amountToReturn: BigNumber;
|
|
75
|
+
l2TokenAddress: string;
|
|
76
|
+
refundAddresses: string[];
|
|
77
|
+
refundAmounts: BigNumber[];
|
|
78
|
+
}[];
|
|
79
|
+
tree: MerkleTree<unknown>;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Construct a single-chain pool rebalance tree.
|
|
83
|
+
*/
|
|
84
|
+
export declare function constructSingleChainTree(token: string, scalingSize?: number, repaymentChain?: number, decimals?: number): Promise<{
|
|
85
|
+
tokensSendToL2: BigNumber;
|
|
86
|
+
realizedLpFees: BigNumber;
|
|
87
|
+
leaves: {
|
|
88
|
+
leafId: BigNumber;
|
|
89
|
+
chainId: BigNumber;
|
|
90
|
+
groupIndex: BigNumber;
|
|
91
|
+
bundleLpFees: BigNumber[];
|
|
92
|
+
netSendAmounts: BigNumber[];
|
|
93
|
+
runningBalances: BigNumber[];
|
|
94
|
+
l1Tokens: string[];
|
|
95
|
+
}[];
|
|
96
|
+
tree: MerkleTree<unknown>;
|
|
97
|
+
}>;
|
|
@@ -8,6 +8,7 @@ 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";
|
|
11
12
|
var _a = ethers.utils, keccak256 = _a.keccak256, defaultAbiCoder = _a.defaultAbiCoder;
|
|
12
13
|
/**
|
|
13
14
|
* Get the parameter type for a contract function parameter.
|
|
@@ -147,4 +148,47 @@ export function buildV3SlowRelayTree(slowFills) {
|
|
|
147
148
|
});
|
|
148
149
|
});
|
|
149
150
|
}
|
|
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
|
+
}
|
|
150
194
|
//# 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,EAAY,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE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/hardhat-ethers";
|
|
2
|
-
import * as contractsV2Utils_1 from "@across-protocol/contracts/dist/test-utils";
|
|
3
|
-
export { contractsV2Utils_1 as contractsV2Utils };
|
|
4
2
|
export { ethers } from "hardhat";
|
|
5
3
|
export { smock } from "@defi-wonderland/smock";
|
|
6
4
|
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;AACnC,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,47 +1,74 @@
|
|
|
1
1
|
import { AcrossConfigStore } from "@across-protocol/contracts";
|
|
2
|
-
import * as utils from "@across-protocol/contracts/dist/test-utils";
|
|
3
2
|
import chai, { expect } from "chai";
|
|
4
|
-
import { Contract, providers } from "ethers";
|
|
3
|
+
import { ethers, BaseContract, Contract, providers, Signer } from "ethers";
|
|
4
|
+
import { FakeContract } from "@defi-wonderland/smock";
|
|
5
5
|
import sinon from "sinon";
|
|
6
6
|
import winston from "winston";
|
|
7
|
+
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
|
|
7
8
|
import { AcrossConfigStoreClient as ConfigStoreClient } from "../../src/clients";
|
|
8
9
|
import { Deposit, DepositWithBlock, FillWithBlock, RelayData, SlowFillRequestWithBlock } from "../../src/interfaces";
|
|
9
10
|
import { Address, BigNumber, BigNumberish, toBN, toBNWei, toWei, utf8ToHex } from "../../src/utils";
|
|
11
|
+
import { randomAddress, zeroAddress } from "../constants";
|
|
10
12
|
import { SpokePoolDeploymentResult, SpyLoggerResult } from "../types";
|
|
11
13
|
declare const chaiAssert: Chai.AssertStatic;
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export {
|
|
14
|
+
export { ethers };
|
|
15
|
+
export type { SignerWithAddress };
|
|
16
|
+
export { getDepositParams, getUpdatedV3DepositSignature, modifyRelayHelper, getRelayHash, getV3RelayHash, getLegacyV3RelayHash, getFillRelayParams, getFillRelayUpdatedFeeParams, getExecuteSlowRelayParams, deployMockSpokePoolCaller, } from "../fixtures/SpokePool.Fixture";
|
|
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";
|
|
15
21
|
import { getContractFactory } from "./getContractFactory";
|
|
16
22
|
export { getContractFactory };
|
|
17
23
|
import { hubPoolFixture, deployHubPool } from "../fixtures/HubPool.Fixture";
|
|
18
24
|
import { spokePoolFixture, deploySpokePool } from "../fixtures/SpokePool.Fixture";
|
|
19
25
|
export { hubPoolFixture, deployHubPool, spokePoolFixture, deploySpokePool };
|
|
26
|
+
export { merkleLibFixture } from "../fixtures/MerkleLib.Fixture";
|
|
20
27
|
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;
|
|
21
48
|
export declare function deepEqualsWithBigNumber(x: unknown, y: unknown, omitKeys?: string[]): boolean;
|
|
22
49
|
export declare function assertPromiseError<T>(promise: Promise<T>, errMessage?: string): Promise<void>;
|
|
23
50
|
export declare function assertPromisePasses<T>(promise: Promise<T>): Promise<void>;
|
|
24
|
-
export declare function setupTokensForWallet(contractToApprove:
|
|
51
|
+
export declare function setupTokensForWallet(contractToApprove: Contract, wallet: SignerWithAddress, tokens: Contract[], weth?: Contract, seedMultiplier?: number): Promise<void>;
|
|
25
52
|
export declare function createSpyLogger(): SpyLoggerResult;
|
|
26
53
|
export declare function deploySpokePoolWithToken(fromChainId?: number): Promise<SpokePoolDeploymentResult>;
|
|
27
|
-
export declare function deployConfigStore(signer:
|
|
54
|
+
export declare function deployConfigStore(signer: SignerWithAddress, tokensToAdd: Contract[], maxL1TokensPerPoolRebalanceLeaf?: number, maxRefundPerRelayerRefundLeaf?: number, rateModel?: unknown, additionalChainIdIndices?: number[]): Promise<{
|
|
28
55
|
configStore: AcrossConfigStore;
|
|
29
56
|
deploymentBlock: number;
|
|
30
57
|
}>;
|
|
31
|
-
export declare function deployAndConfigureHubPool(signer:
|
|
58
|
+
export declare function deployAndConfigureHubPool(signer: SignerWithAddress, spokePools: {
|
|
32
59
|
l2ChainId: number;
|
|
33
|
-
spokePool:
|
|
60
|
+
spokePool: Contract;
|
|
34
61
|
}[], finderAddress?: string, timerAddress?: string): Promise<{
|
|
35
|
-
hubPool:
|
|
36
|
-
mockAdapter:
|
|
37
|
-
l1Token_1:
|
|
38
|
-
l1Token_2:
|
|
62
|
+
hubPool: Contract;
|
|
63
|
+
mockAdapter: Contract;
|
|
64
|
+
l1Token_1: Contract;
|
|
65
|
+
l1Token_2: Contract;
|
|
39
66
|
hubPoolDeploymentBlock: number;
|
|
40
67
|
}>;
|
|
41
|
-
export declare function enableRoutesOnHubPool(hubPool:
|
|
68
|
+
export declare function enableRoutesOnHubPool(hubPool: Contract, rebalanceRouteTokens: {
|
|
42
69
|
destinationChainId: number;
|
|
43
|
-
l1Token:
|
|
44
|
-
destinationToken:
|
|
70
|
+
l1Token: Contract;
|
|
71
|
+
destinationToken: Contract;
|
|
45
72
|
}[]): Promise<void>;
|
|
46
73
|
/**
|
|
47
74
|
* Takes as input a body and returns a new object with the body and a message property. Used to appease the typescript
|
|
@@ -53,7 +80,7 @@ export declare function appendMessageToResult<T>(body: T): T & {
|
|
|
53
80
|
message: string;
|
|
54
81
|
};
|
|
55
82
|
export declare function getLastBlockTime(provider: providers.Provider): Promise<number>;
|
|
56
|
-
export declare function addLiquidity(signer:
|
|
83
|
+
export declare function addLiquidity(signer: SignerWithAddress, hubPool: Contract, l1Token: Contract, amount: BigNumber): Promise<void>;
|
|
57
84
|
export declare function deposit(spokePool: Contract, destinationChainId: number, signer: SignerWithAddress, inputToken: Address, inputAmount: BigNumber, outputToken: Address, outputAmount: BigNumber, opts?: {
|
|
58
85
|
destinationChainId?: number;
|
|
59
86
|
recipient?: Address;
|