@across-protocol/sdk 4.2.7 → 4.2.9-alpha.0
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/arch/evm/SpokeUtils.d.ts +2 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +18 -3
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +7 -7
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +1 -1
- package/dist/cjs/arch/svm/utils.js +15 -13
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +2 -2
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +57 -53
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +11 -8
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +20 -20
- package/dist/cjs/clients/HubPoolClient.js +78 -57
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +35 -29
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +9 -13
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -56
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/interfaces/HubPool.d.ts +18 -13
- package/dist/cjs/interfaces/SpokePool.d.ts +14 -16
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +7 -7
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +10 -10
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +7 -4
- package/dist/cjs/utils/AddressUtils.js +21 -8
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
- package/dist/cjs/utils/SpokeUtils.js +4 -22
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +3 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +2 -2
- package/dist/esm/arch/evm/SpokeUtils.js +19 -4
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +8 -8
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +1 -1
- package/dist/esm/arch/svm/utils.js +15 -13
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +2 -2
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +58 -54
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +4 -3
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +12 -9
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -21
- package/dist/esm/clients/HubPoolClient.js +91 -61
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +37 -30
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +9 -13
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +44 -60
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/interfaces/HubPool.d.ts +18 -13
- package/dist/esm/interfaces/SpokePool.d.ts +14 -16
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +8 -8
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +10 -10
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +7 -4
- package/dist/esm/utils/AddressUtils.js +25 -10
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +3 -8
- package/dist/esm/utils/SpokeUtils.js +4 -26
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +4 -16
- package/dist/esm/utils/TokenUtils.js +3 -3
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +2 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +1 -1
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +2 -2
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +63 -63
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +22 -21
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +9 -13
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +18 -13
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +14 -16
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +3 -3
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +7 -4
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +3 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +4 -16
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/arch/evm/SpokeUtils.ts +22 -8
- package/src/arch/svm/SpokeUtils.ts +7 -8
- package/src/arch/svm/utils.ts +3 -3
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +49 -47
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +6 -4
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +13 -9
- package/src/clients/HubPoolClient.ts +113 -79
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -1
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +104 -37
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +53 -74
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +22 -13
- package/src/interfaces/SpokePool.ts +14 -17
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +10 -8
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +10 -10
- package/src/relayFeeCalculator/relayFeeCalculator.ts +11 -9
- package/src/utils/AddressUtils.ts +32 -14
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +7 -7
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
fixedPointAdjustment,
|
|
18
18
|
count2DDictionaryValues,
|
|
19
19
|
count3DDictionaryValues,
|
|
20
|
+
toAddressType,
|
|
20
21
|
} from "../../../utils";
|
|
21
22
|
import {
|
|
22
23
|
addLastRunningBalance,
|
|
@@ -65,10 +66,10 @@ export function getRefundsFromBundle(
|
|
|
65
66
|
Object.entries(depositsForChain).forEach(([l2TokenAddress, deposits]) => {
|
|
66
67
|
deposits.forEach((deposit) => {
|
|
67
68
|
if (combinedRefunds[originChainId][l2TokenAddress] === undefined) {
|
|
68
|
-
combinedRefunds[originChainId][l2TokenAddress] = { [deposit.depositor]: deposit.inputAmount };
|
|
69
|
+
combinedRefunds[originChainId][l2TokenAddress] = { [deposit.depositor.toBytes32()]: deposit.inputAmount };
|
|
69
70
|
} else {
|
|
70
|
-
const existingRefundAmount = combinedRefunds[originChainId][l2TokenAddress][deposit.depositor];
|
|
71
|
-
combinedRefunds[originChainId][l2TokenAddress][deposit.depositor] = deposit.inputAmount.add(
|
|
71
|
+
const existingRefundAmount = combinedRefunds[originChainId][l2TokenAddress][deposit.depositor.toBytes32()];
|
|
72
|
+
combinedRefunds[originChainId][l2TokenAddress][deposit.depositor.toBytes32()] = deposit.inputAmount.add(
|
|
72
73
|
existingRefundAmount ?? bnZero
|
|
73
74
|
);
|
|
74
75
|
}
|
|
@@ -153,19 +154,23 @@ export function _buildPoolRebalanceRoot(
|
|
|
153
154
|
// If the repayment token and repayment chain ID do not map to a PoolRebalanceRoute graph, then
|
|
154
155
|
// there are no relevant L1 running balances.
|
|
155
156
|
if (
|
|
156
|
-
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(
|
|
157
|
+
!clients.hubPoolClient.l2TokenHasPoolRebalanceRoute(
|
|
158
|
+
toAddressType(l2TokenAddress),
|
|
159
|
+
repaymentChainId,
|
|
160
|
+
mainnetBundleEndBlock
|
|
161
|
+
)
|
|
157
162
|
) {
|
|
158
163
|
chainWithRefundsOnly.add(repaymentChainId);
|
|
159
164
|
return;
|
|
160
165
|
}
|
|
161
166
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
162
|
-
l2TokenAddress,
|
|
167
|
+
toAddressType(l2TokenAddress),
|
|
163
168
|
repaymentChainId,
|
|
164
169
|
mainnetBundleEndBlock
|
|
165
170
|
);
|
|
166
171
|
|
|
167
|
-
updateRunningBalance(runningBalances, repaymentChainId, l1TokenCounterpart, totalRefundAmount);
|
|
168
|
-
updateRunningBalance(realizedLpFees, repaymentChainId, l1TokenCounterpart, totalRealizedLpFee);
|
|
172
|
+
updateRunningBalance(runningBalances, repaymentChainId, l1TokenCounterpart.toEvmAddress(), totalRefundAmount);
|
|
173
|
+
updateRunningBalance(realizedLpFees, repaymentChainId, l1TokenCounterpart.toEvmAddress(), totalRealizedLpFee);
|
|
169
174
|
}
|
|
170
175
|
);
|
|
171
176
|
});
|
|
@@ -182,12 +187,17 @@ export function _buildPoolRebalanceRoot(
|
|
|
182
187
|
Object.entries(depositsForChain).forEach(([outputToken, deposits]) => {
|
|
183
188
|
deposits.forEach((deposit) => {
|
|
184
189
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
185
|
-
outputToken,
|
|
190
|
+
toAddressType(outputToken),
|
|
186
191
|
destinationChainId,
|
|
187
192
|
mainnetBundleEndBlock
|
|
188
193
|
);
|
|
189
194
|
const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
|
|
190
|
-
updateRunningBalance(
|
|
195
|
+
updateRunningBalance(
|
|
196
|
+
runningBalances,
|
|
197
|
+
destinationChainId,
|
|
198
|
+
l1TokenCounterpart.toEvmAddress(),
|
|
199
|
+
deposit.inputAmount.sub(lpFee)
|
|
200
|
+
);
|
|
191
201
|
// Slow fill LP fees are accounted for when the slow fill executes and a V3FilledRelay is emitted. i.e. when
|
|
192
202
|
// the slow fill execution is included in bundleFillsV3.
|
|
193
203
|
});
|
|
@@ -206,12 +216,17 @@ export function _buildPoolRebalanceRoot(
|
|
|
206
216
|
Object.entries(slowFilledDepositsForChain).forEach(([outputToken, slowFilledDeposits]) => {
|
|
207
217
|
slowFilledDeposits.forEach((deposit) => {
|
|
208
218
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
209
|
-
outputToken,
|
|
219
|
+
toAddressType(outputToken),
|
|
210
220
|
destinationChainId,
|
|
211
221
|
mainnetBundleEndBlock
|
|
212
222
|
);
|
|
213
223
|
const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
|
|
214
|
-
updateRunningBalance(
|
|
224
|
+
updateRunningBalance(
|
|
225
|
+
runningBalances,
|
|
226
|
+
destinationChainId,
|
|
227
|
+
l1TokenCounterpart.toEvmAddress(),
|
|
228
|
+
lpFee.sub(deposit.inputAmount)
|
|
229
|
+
);
|
|
215
230
|
// Slow fills don't add to lpFees, only when the slow fill is executed and a V3FilledRelay is emitted, so
|
|
216
231
|
// we don't need to subtract it here. Moreover, the HubPoole expects bundleLpFees to be > 0.
|
|
217
232
|
});
|
|
@@ -271,11 +286,11 @@ export function _buildPoolRebalanceRoot(
|
|
|
271
286
|
return;
|
|
272
287
|
}
|
|
273
288
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
274
|
-
inputToken,
|
|
289
|
+
toAddressType(inputToken),
|
|
275
290
|
originChainId,
|
|
276
291
|
mainnetBundleEndBlock
|
|
277
292
|
);
|
|
278
|
-
updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart, deposit.inputAmount);
|
|
293
|
+
updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart.toEvmAddress(), deposit.inputAmount);
|
|
279
294
|
});
|
|
280
295
|
});
|
|
281
296
|
});
|
|
@@ -2,7 +2,7 @@ import _ from "lodash";
|
|
|
2
2
|
import assert from "assert";
|
|
3
3
|
import { providers } from "ethers";
|
|
4
4
|
import { DepositWithBlock, Fill, FillWithBlock } from "../../../interfaces";
|
|
5
|
-
import { isSlowFill, isValidEvmAddress, isDefined, chainIsEvm } from "../../../utils";
|
|
5
|
+
import { isSlowFill, isValidEvmAddress, isDefined, chainIsEvm, Address, toAddressType } from "../../../utils";
|
|
6
6
|
import { HubPoolClient } from "../../HubPoolClient";
|
|
7
7
|
import { SVMProvider } from "../../../arch/svm";
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@ export function getRefundInformationFromFill(
|
|
|
25
25
|
bundleEndBlockForMainnet: number
|
|
26
26
|
): {
|
|
27
27
|
chainToSendRefundTo: number;
|
|
28
|
-
repaymentToken:
|
|
28
|
+
repaymentToken: Address;
|
|
29
29
|
} {
|
|
30
30
|
const chainToSendRefundTo = _getRepaymentChainId(relayData, hubPoolClient, bundleEndBlockForMainnet);
|
|
31
31
|
if (chainToSendRefundTo === relayData.originChainId) {
|
|
@@ -49,6 +49,7 @@ export function getRefundInformationFromFill(
|
|
|
49
49
|
chainToSendRefundTo,
|
|
50
50
|
bundleEndBlockForMainnet
|
|
51
51
|
);
|
|
52
|
+
|
|
52
53
|
return {
|
|
53
54
|
chainToSendRefundTo,
|
|
54
55
|
repaymentToken,
|
|
@@ -125,7 +126,8 @@ export async function verifyFillRepayment(
|
|
|
125
126
|
return undefined;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
fill.relayer = destinationRelayer;
|
|
129
|
+
fill.relayer = toAddressType(destinationRelayer);
|
|
130
|
+
assert(fill.relayer.isValidEvmAddress(), `Cannot re-assign fill to msg.sender: ${destinationRelayer}`);
|
|
129
131
|
} else {
|
|
130
132
|
return undefined;
|
|
131
133
|
}
|
|
@@ -200,5 +202,5 @@ function _repaymentAddressNeedsToBeOverwritten(fill: Fill): boolean {
|
|
|
200
202
|
// - i.e. If chainIsSvm && !isValidSvmAddress(fill.relayer) then return false
|
|
201
203
|
// If chainIsEvm && !isValidEvmAddress(fill.relayer) then return false
|
|
202
204
|
// If chainIsEvm && isValidEvmAddress(fill.relayer) then return true
|
|
203
|
-
return
|
|
205
|
+
return chainIsEvm(fill.repaymentChainId) && !fill.relayer.isValidEvmAddress();
|
|
204
206
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MerkleTree } from "@across-protocol/contracts/dist/utils/MerkleTree";
|
|
2
2
|
import { RunningBalances, PoolRebalanceLeaf, Clients, SpokePoolTargetBalance } from "../../../interfaces";
|
|
3
3
|
import { SpokePoolClient } from "../../SpokePoolClient";
|
|
4
|
-
import { BigNumber, bnZero, compareAddresses } from "../../../utils";
|
|
4
|
+
import { BigNumber, bnZero, compareAddresses, EvmAddress } from "../../../utils";
|
|
5
5
|
import { HubPoolClient } from "../../HubPoolClient";
|
|
6
6
|
import { V3DepositWithBlock } from "./shims";
|
|
7
7
|
import { AcrossConfigStoreClient } from "../../AcrossConfigStoreClient";
|
|
@@ -151,7 +151,7 @@ export function addLastRunningBalance(
|
|
|
151
151
|
const { runningBalance } = hubPoolClient.getRunningBalanceBeforeBlockForChain(
|
|
152
152
|
latestMainnetBlock,
|
|
153
153
|
Number(repaymentChainId),
|
|
154
|
-
l1TokenAddress
|
|
154
|
+
EvmAddress.from(l1TokenAddress)
|
|
155
155
|
);
|
|
156
156
|
if (!runningBalance.eq(bnZero)) {
|
|
157
157
|
updateRunningBalance(runningBalances, Number(repaymentChainId), l1TokenAddress, runningBalance);
|
|
@@ -172,7 +172,7 @@ export function updateRunningBalanceForDeposit(
|
|
|
172
172
|
deposit.originChainId,
|
|
173
173
|
mainnetBundleEndBlock
|
|
174
174
|
);
|
|
175
|
-
updateRunningBalance(runningBalances, deposit.originChainId, l1TokenCounterpart, updateAmount);
|
|
175
|
+
updateRunningBalance(runningBalances, deposit.originChainId, l1TokenCounterpart.toEvmAddress(), updateAmount);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
export function constructPoolRebalanceLeaves(
|
|
@@ -253,7 +253,7 @@ export function constructPoolRebalanceLeaves(
|
|
|
253
253
|
runningBalances: leafRunningBalances,
|
|
254
254
|
groupIndex: groupIndexForChainId++,
|
|
255
255
|
leafId: leaves.length,
|
|
256
|
-
l1Tokens: l1TokensToIncludeInThisLeaf,
|
|
256
|
+
l1Tokens: l1TokensToIncludeInThisLeaf.map((l1TokenAddr: string) => EvmAddress.from(l1TokenAddr)),
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
});
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
type,
|
|
16
16
|
} from "superstruct";
|
|
17
17
|
import { UNDEFINED_MESSAGE_HASH } from "../../../constants";
|
|
18
|
-
import { BigNumber } from "../../../utils";
|
|
18
|
+
import { BigNumber, toAddressType, Address } from "../../../utils";
|
|
19
19
|
|
|
20
20
|
const PositiveIntegerStringSS = pattern(string(), /\d+/);
|
|
21
21
|
const Web3AddressSS = pattern(string(), /^0x[a-fA-F0-9]{40}$/);
|
|
@@ -31,19 +31,23 @@ const BigNumberType = coerce(instance(BigNumber), union([string(), number()]), (
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
const AddressType = coerce(instance(Address), string(), (value) => {
|
|
35
|
+
return toAddressType(value);
|
|
36
|
+
});
|
|
37
|
+
|
|
34
38
|
const FillTypeSS = number();
|
|
35
39
|
|
|
36
40
|
const V3RelayDataSS = {
|
|
37
|
-
inputToken:
|
|
41
|
+
inputToken: AddressType,
|
|
38
42
|
inputAmount: BigNumberType,
|
|
39
|
-
outputToken:
|
|
43
|
+
outputToken: AddressType,
|
|
40
44
|
outputAmount: BigNumberType,
|
|
41
45
|
fillDeadline: number(),
|
|
42
|
-
exclusiveRelayer:
|
|
46
|
+
exclusiveRelayer: AddressType,
|
|
43
47
|
exclusivityDeadline: number(),
|
|
44
48
|
originChainId: number(),
|
|
45
|
-
depositor:
|
|
46
|
-
recipient:
|
|
49
|
+
depositor: AddressType,
|
|
50
|
+
recipient: AddressType,
|
|
47
51
|
depositId: BigNumberType,
|
|
48
52
|
message: string(),
|
|
49
53
|
};
|
|
@@ -67,7 +71,7 @@ const V3DepositSS = {
|
|
|
67
71
|
quoteTimestamp: number(),
|
|
68
72
|
relayerFeePct: optional(BigNumberType),
|
|
69
73
|
speedUpSignature: optional(string()),
|
|
70
|
-
updatedRecipient: optional(
|
|
74
|
+
updatedRecipient: optional(AddressType),
|
|
71
75
|
updatedOutputAmount: optional(BigNumberType),
|
|
72
76
|
updatedMessage: optional(string()),
|
|
73
77
|
};
|
|
@@ -88,7 +92,7 @@ const V3DepositWithBlockLpFeeSS = object({
|
|
|
88
92
|
const V3RelayExecutionEventInfoSS = object({
|
|
89
93
|
updatedOutputAmount: BigNumberType,
|
|
90
94
|
fillType: FillTypeSS,
|
|
91
|
-
updatedRecipient:
|
|
95
|
+
updatedRecipient: AddressType,
|
|
92
96
|
updatedMessage: optional(string()),
|
|
93
97
|
updatedMessageHash: defaulted(string(), UNDEFINED_MESSAGE_HASH),
|
|
94
98
|
});
|
|
@@ -98,7 +102,7 @@ const V3FillSS = {
|
|
|
98
102
|
message: optional(string()),
|
|
99
103
|
messageHash: defaulted(string(), UNDEFINED_MESSAGE_HASH),
|
|
100
104
|
destinationChainId: number(),
|
|
101
|
-
relayer:
|
|
105
|
+
relayer: AddressType,
|
|
102
106
|
repaymentChainId: number(),
|
|
103
107
|
relayExecutionInfo: V3RelayExecutionEventInfoSS,
|
|
104
108
|
quoteTimestamp: number(),
|