@across-protocol/sdk 4.2.16 → 4.3.1
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 +8 -3
- package/dist/cjs/arch/evm/SpokeUtils.js +26 -11
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +8 -2
- package/dist/cjs/arch/svm/SpokeUtils.js +41 -50
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +4 -2
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +3 -3
- package/dist/cjs/arch/svm/utils.js +16 -14
- 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 +4 -4
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +59 -59
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +16 -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/MerkleTreeUtils.js +5 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.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 +71 -71
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +13 -8
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
- package/dist/cjs/clients/HubPoolClient.js +85 -58
- 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/SVMSpokePoolClient.js +1 -3
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +66 -46
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/cjs/clients/SpokePoolClient/index.js +3 -1
- package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/clients/index.d.ts +1 -1
- package/dist/cjs/clients/index.js +2 -1
- package/dist/cjs/clients/index.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 +5 -3
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +6 -4
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.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 +19 -14
- package/dist/cjs/interfaces/SpokePool.d.ts +18 -19
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +17 -9
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +24 -15
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +13 -5
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +61 -58
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +15 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +13 -13
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +12 -8
- package/dist/cjs/utils/AddressUtils.js +33 -36
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +2 -2
- package/dist/cjs/utils/DepositUtils.js +1 -1
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +1 -3
- package/dist/cjs/utils/SpokeUtils.js +3 -25
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +5 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/esm/arch/evm/SpokeUtils.js +29 -14
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -3
- package/dist/esm/arch/svm/SpokeUtils.js +42 -55
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +5 -3
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +3 -3
- package/dist/esm/arch/svm/utils.js +17 -15
- 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 +4 -4
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +60 -60
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +18 -15
- 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 +7 -7
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.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 +71 -71
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +20 -10
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -22
- package/dist/esm/clients/HubPoolClient.js +93 -66
- 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/SVMSpokePoolClient.js +2 -4
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +69 -48
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/esm/clients/SpokePoolClient/index.js +1 -0
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/clients/index.d.ts +1 -1
- package/dist/esm/clients/index.js +1 -1
- package/dist/esm/clients/index.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 +5 -3
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +7 -5
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.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 +19 -14
- package/dist/esm/interfaces/SpokePool.d.ts +18 -19
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +28 -19
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +9 -6
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +67 -63
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +12 -12
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +12 -8
- package/dist/esm/utils/AddressUtils.js +36 -38
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +2 -2
- package/dist/esm/utils/DepositUtils.js +2 -2
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +1 -8
- package/dist/esm/utils/SpokeUtils.js +3 -29
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +6 -18
- package/dist/esm/utils/TokenUtils.js +6 -4
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +9 -3
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/eventsClient.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +3 -3
- 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 +4 -4
- 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/MerkleTreeUtils.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 +71 -71
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +22 -22
- 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/SVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/index.d.ts +1 -0
- package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
- package/dist/types/clients/index.d.ts +1 -1
- package/dist/types/clients/index.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 +5 -3
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.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 +19 -14
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +18 -19
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +20 -12
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +15 -7
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +25 -8
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +12 -8
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +2 -2
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +1 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +6 -18
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/arch/evm/SpokeUtils.ts +72 -22
- package/src/arch/svm/SpokeUtils.ts +67 -53
- package/src/arch/svm/eventsClient.ts +40 -8
- package/src/arch/svm/utils.ts +6 -6
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +56 -56
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +32 -15
- package/src/clients/BundleDataClient/utils/FillUtils.ts +12 -8
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +22 -10
- package/src/clients/HubPoolClient.ts +125 -86
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -2
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +1 -4
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +122 -37
- package/src/clients/SpokePoolClient/index.ts +1 -0
- package/src/clients/index.ts +1 -0
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +8 -5
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +20 -14
- package/src/interfaces/SpokePool.ts +19 -19
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +39 -21
- package/src/relayFeeCalculator/chain-queries/factory.ts +8 -5
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +73 -58
- package/src/relayFeeCalculator/relayFeeCalculator.ts +23 -21
- package/src/utils/AddressUtils.ts +39 -51
- package/src/utils/DepositUtils.ts +4 -4
- package/src/utils/SpokeUtils.ts +8 -36
- package/src/utils/TokenUtils.ts +10 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Create a combined `refunds` object containing refunds for V2 + V3 fills
|
|
2
|
-
|
|
2
|
+
import assert from "assert";
|
|
3
3
|
import {
|
|
4
4
|
BundleDepositsV3,
|
|
5
5
|
BundleExcessSlowFills,
|
|
@@ -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,25 @@ 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, repaymentChainId),
|
|
159
|
+
repaymentChainId,
|
|
160
|
+
mainnetBundleEndBlock
|
|
161
|
+
)
|
|
157
162
|
) {
|
|
158
163
|
chainWithRefundsOnly.add(repaymentChainId);
|
|
159
164
|
return;
|
|
160
165
|
}
|
|
161
|
-
const
|
|
162
|
-
l2TokenAddress,
|
|
166
|
+
const l1Token = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
167
|
+
toAddressType(l2TokenAddress, repaymentChainId),
|
|
163
168
|
repaymentChainId,
|
|
164
169
|
mainnetBundleEndBlock
|
|
165
170
|
);
|
|
171
|
+
const l1TokenAddr = l1Token.toNative();
|
|
172
|
+
assert(l1Token.isEVM(), `Expected an EVM address: ${l1TokenAddr}`);
|
|
166
173
|
|
|
167
|
-
updateRunningBalance(runningBalances, repaymentChainId,
|
|
168
|
-
updateRunningBalance(realizedLpFees, repaymentChainId,
|
|
174
|
+
updateRunningBalance(runningBalances, repaymentChainId, l1TokenAddr, totalRefundAmount);
|
|
175
|
+
updateRunningBalance(realizedLpFees, repaymentChainId, l1TokenAddr, totalRealizedLpFee);
|
|
169
176
|
}
|
|
170
177
|
);
|
|
171
178
|
});
|
|
@@ -182,12 +189,17 @@ export function _buildPoolRebalanceRoot(
|
|
|
182
189
|
Object.entries(depositsForChain).forEach(([outputToken, deposits]) => {
|
|
183
190
|
deposits.forEach((deposit) => {
|
|
184
191
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
185
|
-
outputToken,
|
|
192
|
+
toAddressType(outputToken, destinationChainId),
|
|
186
193
|
destinationChainId,
|
|
187
194
|
mainnetBundleEndBlock
|
|
188
195
|
);
|
|
189
196
|
const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
|
|
190
|
-
updateRunningBalance(
|
|
197
|
+
updateRunningBalance(
|
|
198
|
+
runningBalances,
|
|
199
|
+
destinationChainId,
|
|
200
|
+
l1TokenCounterpart.toEvmAddress(),
|
|
201
|
+
deposit.inputAmount.sub(lpFee)
|
|
202
|
+
);
|
|
191
203
|
// Slow fill LP fees are accounted for when the slow fill executes and a V3FilledRelay is emitted. i.e. when
|
|
192
204
|
// the slow fill execution is included in bundleFillsV3.
|
|
193
205
|
});
|
|
@@ -206,12 +218,17 @@ export function _buildPoolRebalanceRoot(
|
|
|
206
218
|
Object.entries(slowFilledDepositsForChain).forEach(([outputToken, slowFilledDeposits]) => {
|
|
207
219
|
slowFilledDeposits.forEach((deposit) => {
|
|
208
220
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
209
|
-
outputToken,
|
|
221
|
+
toAddressType(outputToken, destinationChainId),
|
|
210
222
|
destinationChainId,
|
|
211
223
|
mainnetBundleEndBlock
|
|
212
224
|
);
|
|
213
225
|
const lpFee = deposit.lpFeePct.mul(deposit.inputAmount).div(fixedPointAdjustment);
|
|
214
|
-
updateRunningBalance(
|
|
226
|
+
updateRunningBalance(
|
|
227
|
+
runningBalances,
|
|
228
|
+
destinationChainId,
|
|
229
|
+
l1TokenCounterpart.toEvmAddress(),
|
|
230
|
+
lpFee.sub(deposit.inputAmount)
|
|
231
|
+
);
|
|
215
232
|
// Slow fills don't add to lpFees, only when the slow fill is executed and a V3FilledRelay is emitted, so
|
|
216
233
|
// we don't need to subtract it here. Moreover, the HubPoole expects bundleLpFees to be > 0.
|
|
217
234
|
});
|
|
@@ -271,11 +288,11 @@ export function _buildPoolRebalanceRoot(
|
|
|
271
288
|
return;
|
|
272
289
|
}
|
|
273
290
|
const l1TokenCounterpart = clients.hubPoolClient.getL1TokenForL2TokenAtBlock(
|
|
274
|
-
inputToken,
|
|
291
|
+
toAddressType(inputToken, originChainId),
|
|
275
292
|
originChainId,
|
|
276
293
|
mainnetBundleEndBlock
|
|
277
294
|
);
|
|
278
|
-
updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart, deposit.inputAmount);
|
|
295
|
+
updateRunningBalance(runningBalances, originChainId, l1TokenCounterpart.toEvmAddress(), deposit.inputAmount);
|
|
279
296
|
});
|
|
280
297
|
});
|
|
281
298
|
});
|
|
@@ -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,11 @@ export async function verifyFillRepayment(
|
|
|
125
126
|
return undefined;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
fill.relayer = destinationRelayer;
|
|
129
|
+
fill.relayer = toAddressType(destinationRelayer, fill.destinationChainId);
|
|
130
|
+
assert(
|
|
131
|
+
fill.relayer.isValidOn(fill.destinationChainId),
|
|
132
|
+
`Cannot re-assign fill to msg.sender: ${destinationRelayer}`
|
|
133
|
+
);
|
|
129
134
|
} else {
|
|
130
135
|
return undefined;
|
|
131
136
|
}
|
|
@@ -196,9 +201,8 @@ function _repaymentAddressNeedsToBeOverwritten(fill: Fill): boolean {
|
|
|
196
201
|
return false;
|
|
197
202
|
}
|
|
198
203
|
|
|
199
|
-
// @
|
|
200
|
-
//
|
|
201
|
-
//
|
|
202
|
-
|
|
203
|
-
return !isValidEvmAddress(fill.relayer);
|
|
204
|
+
// @dev If the repayment chain is EVM, the repayment address is valid if the address is 20 bytes.
|
|
205
|
+
// If the repayment chain is SVM, the repayment address is valid if the address is strictly greater than
|
|
206
|
+
// 20 bytes.
|
|
207
|
+
return !fill.relayer.isValidOn(fill.repaymentChainId);
|
|
204
208
|
}
|
|
@@ -21,6 +21,12 @@ export function buildPoolRebalanceLeafTree(poolRebalanceLeaves: PoolRebalanceLea
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const paramType = getParamType("MerkleLibTest", "verifyPoolRebalance", "rebalance");
|
|
24
|
-
const hashFn = (input: PoolRebalanceLeaf) =>
|
|
24
|
+
const hashFn = (input: PoolRebalanceLeaf) => {
|
|
25
|
+
const ethersLeaf = {
|
|
26
|
+
...input,
|
|
27
|
+
l1Tokens: input.l1Tokens.map((l1Token) => l1Token.toEvmAddress()),
|
|
28
|
+
};
|
|
29
|
+
return utils.keccak256(utils.defaultAbiCoder.encode([paramType], [ethersLeaf]));
|
|
30
|
+
};
|
|
25
31
|
return new MerkleTree<PoolRebalanceLeaf>(poolRebalanceLeaves, hashFn);
|
|
26
32
|
}
|
|
@@ -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
|
});
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
union,
|
|
15
15
|
type,
|
|
16
16
|
} from "superstruct";
|
|
17
|
-
import { UNDEFINED_MESSAGE_HASH } from "../../../constants";
|
|
18
|
-
import { BigNumber } from "../../../utils";
|
|
17
|
+
import { CHAIN_IDs, UNDEFINED_MESSAGE_HASH } from "../../../constants";
|
|
18
|
+
import { BigNumber, EvmAddress, RawAddress, SvmAddress, toAddressType } 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,31 @@ const BigNumberType = coerce(instance(BigNumber), union([string(), number()]), (
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
// Accept any concrete implementation of `Address` (Evm, Svm, or Raw) but avoid using the
|
|
35
|
+
// abstract `Address` class directly to keep TypeScript happy.
|
|
36
|
+
const AddressInstanceSS = union([instance(EvmAddress), instance(SvmAddress), instance(RawAddress)]);
|
|
37
|
+
|
|
38
|
+
const AddressType = coerce(AddressInstanceSS, string(), (value) => {
|
|
39
|
+
// Addresses are posted to arweave in their native format (base16 for EVM, base58 for SVM). The chainId for
|
|
40
|
+
// for the event data is not directly available, so infer it based on the shape of the address. RawAddress
|
|
41
|
+
// will be instantiated if the address format does not match the expected family.
|
|
42
|
+
const chainId = value.startsWith("0x") ? CHAIN_IDs.MAINNET : CHAIN_IDs.SOLANA;
|
|
43
|
+
return toAddressType(value, chainId);
|
|
44
|
+
});
|
|
45
|
+
|
|
34
46
|
const FillTypeSS = number();
|
|
35
47
|
|
|
36
48
|
const V3RelayDataSS = {
|
|
37
|
-
inputToken:
|
|
49
|
+
inputToken: AddressType,
|
|
38
50
|
inputAmount: BigNumberType,
|
|
39
|
-
outputToken:
|
|
51
|
+
outputToken: AddressType,
|
|
40
52
|
outputAmount: BigNumberType,
|
|
41
53
|
fillDeadline: number(),
|
|
42
|
-
exclusiveRelayer:
|
|
54
|
+
exclusiveRelayer: AddressType,
|
|
43
55
|
exclusivityDeadline: number(),
|
|
44
56
|
originChainId: number(),
|
|
45
|
-
depositor:
|
|
46
|
-
recipient:
|
|
57
|
+
depositor: AddressType,
|
|
58
|
+
recipient: AddressType,
|
|
47
59
|
depositId: BigNumberType,
|
|
48
60
|
message: string(),
|
|
49
61
|
};
|
|
@@ -67,7 +79,7 @@ const V3DepositSS = {
|
|
|
67
79
|
quoteTimestamp: number(),
|
|
68
80
|
relayerFeePct: optional(BigNumberType),
|
|
69
81
|
speedUpSignature: optional(string()),
|
|
70
|
-
updatedRecipient: optional(
|
|
82
|
+
updatedRecipient: optional(AddressType),
|
|
71
83
|
updatedOutputAmount: optional(BigNumberType),
|
|
72
84
|
updatedMessage: optional(string()),
|
|
73
85
|
};
|
|
@@ -88,7 +100,7 @@ const V3DepositWithBlockLpFeeSS = object({
|
|
|
88
100
|
const V3RelayExecutionEventInfoSS = object({
|
|
89
101
|
updatedOutputAmount: BigNumberType,
|
|
90
102
|
fillType: FillTypeSS,
|
|
91
|
-
updatedRecipient:
|
|
103
|
+
updatedRecipient: AddressType,
|
|
92
104
|
updatedMessage: optional(string()),
|
|
93
105
|
updatedMessageHash: defaulted(string(), UNDEFINED_MESSAGE_HASH),
|
|
94
106
|
});
|
|
@@ -98,7 +110,7 @@ const V3FillSS = {
|
|
|
98
110
|
message: optional(string()),
|
|
99
111
|
messageHash: defaulted(string(), UNDEFINED_MESSAGE_HASH),
|
|
100
112
|
destinationChainId: number(),
|
|
101
|
-
relayer:
|
|
113
|
+
relayer: AddressType,
|
|
102
114
|
repaymentChainId: number(),
|
|
103
115
|
relayExecutionInfo: V3RelayExecutionEventInfoSS,
|
|
104
116
|
quoteTimestamp: number(),
|