@across-protocol/sdk 3.1.27 → 3.1.28
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/clients/BundleDataClient/BundleDataClient.d.ts +60 -0
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +929 -0
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -0
- package/dist/cjs/clients/BundleDataClient/index.d.ts +2 -0
- package/dist/cjs/clients/BundleDataClient/index.js +6 -0
- package/dist/cjs/clients/BundleDataClient/index.js.map +1 -0
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.d.ts +15 -0
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +131 -0
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -0
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +6 -0
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +19 -0
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -0
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts +3 -0
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +23 -0
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -0
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +24 -0
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +129 -0
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -0
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +302 -0
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +77 -0
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -0
- package/dist/cjs/clients/BundleDataClient/utils/index.d.ts +6 -0
- package/dist/cjs/clients/BundleDataClient/utils/index.js +10 -0
- package/dist/cjs/clients/BundleDataClient/utils/index.js.map +1 -0
- package/dist/cjs/clients/BundleDataClient/utils/shims.d.ts +8 -0
- package/dist/cjs/clients/BundleDataClient/utils/shims.js +3 -0
- package/dist/cjs/clients/BundleDataClient/utils/shims.js.map +1 -0
- package/dist/cjs/clients/index.d.ts +1 -0
- package/dist/cjs/clients/index.js +2 -1
- package/dist/cjs/clients/index.js.map +1 -1
- package/dist/cjs/interfaces/BundleData.d.ts +63 -0
- package/dist/cjs/interfaces/BundleData.js +3 -0
- package/dist/cjs/interfaces/BundleData.js.map +1 -0
- package/dist/cjs/interfaces/index.d.ts +1 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/interfaces/index.js.map +1 -1
- package/dist/cjs/providers/alchemy.js +5 -5
- package/dist/cjs/providers/alchemy.js.map +1 -1
- package/dist/cjs/providers/drpc.d.ts +2 -0
- package/dist/cjs/providers/drpc.js +21 -0
- package/dist/cjs/providers/drpc.js.map +1 -0
- package/dist/cjs/providers/infura.js +5 -5
- package/dist/cjs/providers/infura.js.map +1 -1
- package/dist/cjs/providers/types.d.ts +1 -1
- package/dist/cjs/providers/utils.js +3 -1
- package/dist/cjs/providers/utils.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +1 -0
- package/dist/cjs/utils/AddressUtils.js +15 -1
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/ContractUtils.d.ts +1 -0
- package/dist/cjs/utils/ContractUtils.js +12 -0
- package/dist/cjs/utils/ContractUtils.js.map +1 -0
- package/dist/cjs/utils/Multicall.d.ts +3 -2
- package/dist/cjs/utils/Multicall.js +40 -41
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/ObjectUtils.d.ts +18 -0
- package/dist/cjs/utils/ObjectUtils.js +27 -1
- package/dist/cjs/utils/ObjectUtils.js.map +1 -1
- package/dist/cjs/utils/abi/contracts/index.d.ts +1 -0
- package/dist/cjs/utils/abi/contracts/index.js +9 -0
- package/dist/cjs/utils/abi/contracts/index.js.map +1 -0
- package/dist/cjs/utils/abi/typechain/Multicall3.d.ts +289 -0
- package/dist/cjs/utils/abi/typechain/Multicall3.js +3 -0
- package/dist/cjs/utils/abi/typechain/Multicall3.js.map +1 -0
- package/dist/cjs/utils/abi/typechain/common.d.ts +21 -0
- package/dist/cjs/utils/abi/typechain/common.js +3 -0
- package/dist/cjs/utils/abi/typechain/common.js.map +1 -0
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.d.ts +339 -0
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js +458 -0
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -0
- package/dist/cjs/utils/abi/typechain/factories/index.d.ts +1 -0
- package/dist/cjs/utils/abi/typechain/factories/index.js +6 -0
- package/dist/cjs/utils/abi/typechain/factories/index.js.map +1 -0
- package/dist/cjs/utils/abi/typechain/index.d.ts +3 -0
- package/dist/cjs/utils/abi/typechain/index.js +8 -0
- package/dist/cjs/utils/abi/typechain/index.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +60 -0
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1097 -0
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/index.d.ts +2 -0
- package/dist/esm/clients/BundleDataClient/index.js +3 -0
- package/dist/esm/clients/BundleDataClient/index.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.d.ts +15 -0
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +182 -0
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +6 -0
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +20 -0
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts +3 -0
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +20 -0
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +24 -0
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +157 -0
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +302 -0
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +79 -0
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/utils/index.d.ts +6 -0
- package/dist/esm/clients/BundleDataClient/utils/index.js +7 -0
- package/dist/esm/clients/BundleDataClient/utils/index.js.map +1 -0
- package/dist/esm/clients/BundleDataClient/utils/shims.d.ts +8 -0
- package/dist/esm/clients/BundleDataClient/utils/shims.js +2 -0
- package/dist/esm/clients/BundleDataClient/utils/shims.js.map +1 -0
- package/dist/esm/clients/index.d.ts +1 -0
- package/dist/esm/clients/index.js +2 -0
- package/dist/esm/clients/index.js.map +1 -1
- package/dist/esm/interfaces/BundleData.d.ts +63 -0
- package/dist/esm/interfaces/BundleData.js +2 -0
- package/dist/esm/interfaces/BundleData.js.map +1 -0
- package/dist/esm/interfaces/index.d.ts +1 -0
- package/dist/esm/interfaces/index.js +1 -0
- package/dist/esm/interfaces/index.js.map +1 -1
- package/dist/esm/providers/alchemy.js +6 -6
- package/dist/esm/providers/alchemy.js.map +1 -1
- package/dist/esm/providers/drpc.d.ts +2 -0
- package/dist/esm/providers/drpc.js +18 -0
- package/dist/esm/providers/drpc.js.map +1 -0
- package/dist/esm/providers/infura.js +6 -6
- package/dist/esm/providers/infura.js.map +1 -1
- package/dist/esm/providers/types.d.ts +1 -1
- package/dist/esm/providers/utils.js +3 -1
- package/dist/esm/providers/utils.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +1 -0
- package/dist/esm/utils/AddressUtils.js +16 -1
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/ContractUtils.d.ts +1 -0
- package/dist/esm/utils/ContractUtils.js +8 -0
- package/dist/esm/utils/ContractUtils.js.map +1 -0
- package/dist/esm/utils/Multicall.d.ts +3 -2
- package/dist/esm/utils/Multicall.js +39 -42
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/ObjectUtils.d.ts +18 -0
- package/dist/esm/utils/ObjectUtils.js +24 -0
- package/dist/esm/utils/ObjectUtils.js.map +1 -1
- package/dist/esm/utils/abi/contracts/index.d.ts +1 -0
- package/dist/esm/utils/abi/contracts/index.js +2 -0
- package/dist/esm/utils/abi/contracts/index.js.map +1 -0
- package/dist/esm/utils/abi/typechain/Multicall3.d.ts +292 -0
- package/dist/esm/utils/abi/typechain/Multicall3.js +2 -0
- package/dist/esm/utils/abi/typechain/Multicall3.js.map +1 -0
- package/dist/esm/utils/abi/typechain/common.d.ts +21 -0
- package/dist/esm/utils/abi/typechain/common.js +2 -0
- package/dist/esm/utils/abi/typechain/common.js.map +1 -0
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.d.ts +339 -0
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js +458 -0
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -0
- package/dist/esm/utils/abi/typechain/factories/index.d.ts +1 -0
- package/dist/esm/utils/abi/typechain/factories/index.js +5 -0
- package/dist/esm/utils/abi/typechain/factories/index.js.map +1 -0
- package/dist/esm/utils/abi/typechain/index.d.ts +3 -0
- package/dist/esm/utils/abi/typechain/index.js +4 -0
- package/dist/esm/utils/abi/typechain/index.js.map +1 -0
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +61 -0
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -0
- package/dist/types/clients/BundleDataClient/index.d.ts +3 -0
- package/dist/types/clients/BundleDataClient/index.d.ts.map +1 -0
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts +16 -0
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -0
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +7 -0
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -0
- package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts +4 -0
- package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -0
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +25 -0
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -0
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +303 -0
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -0
- package/dist/types/clients/BundleDataClient/utils/index.d.ts +7 -0
- package/dist/types/clients/BundleDataClient/utils/index.d.ts.map +1 -0
- package/dist/types/clients/BundleDataClient/utils/shims.d.ts +9 -0
- package/dist/types/clients/BundleDataClient/utils/shims.d.ts.map +1 -0
- package/dist/types/clients/index.d.ts +1 -0
- package/dist/types/clients/index.d.ts.map +1 -1
- package/dist/types/interfaces/BundleData.d.ts +64 -0
- package/dist/types/interfaces/BundleData.d.ts.map +1 -0
- package/dist/types/interfaces/index.d.ts +1 -0
- package/dist/types/interfaces/index.d.ts.map +1 -1
- package/dist/types/providers/drpc.d.ts +3 -0
- package/dist/types/providers/drpc.d.ts.map +1 -0
- package/dist/types/providers/types.d.ts +1 -1
- package/dist/types/providers/types.d.ts.map +1 -1
- package/dist/types/providers/utils.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +1 -0
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/ContractUtils.d.ts +2 -0
- package/dist/types/utils/ContractUtils.d.ts.map +1 -0
- package/dist/types/utils/Multicall.d.ts +3 -2
- package/dist/types/utils/Multicall.d.ts.map +1 -1
- package/dist/types/utils/ObjectUtils.d.ts +18 -0
- package/dist/types/utils/ObjectUtils.d.ts.map +1 -1
- package/dist/types/utils/abi/contracts/index.d.ts +2 -0
- package/dist/types/utils/abi/contracts/index.d.ts.map +1 -0
- package/dist/types/utils/abi/typechain/Multicall3.d.ts +293 -0
- package/dist/types/utils/abi/typechain/Multicall3.d.ts.map +1 -0
- package/dist/types/utils/abi/typechain/common.d.ts +22 -0
- package/dist/types/utils/abi/typechain/common.d.ts.map +1 -0
- package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts +340 -0
- package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts.map +1 -0
- package/dist/types/utils/abi/typechain/factories/index.d.ts +2 -0
- package/dist/types/utils/abi/typechain/factories/index.d.ts.map +1 -0
- package/dist/types/utils/abi/typechain/index.d.ts +4 -0
- package/dist/types/utils/abi/typechain/index.d.ts.map +1 -0
- package/package.json +6 -8
- package/src/clients/BundleDataClient/BundleDataClient.ts +1311 -0
- package/src/clients/BundleDataClient/index.ts +2 -0
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +268 -0
- package/src/clients/BundleDataClient/utils/FillUtils.ts +46 -0
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +26 -0
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +238 -0
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +132 -0
- package/src/clients/BundleDataClient/utils/index.ts +6 -0
- package/src/clients/BundleDataClient/utils/shims.ts +10 -0
- package/src/clients/index.ts +1 -0
- package/src/interfaces/BundleData.ts +68 -0
- package/src/interfaces/index.ts +1 -0
- package/src/providers/alchemy.ts +6 -6
- package/src/providers/drpc.ts +19 -0
- package/src/providers/infura.ts +6 -6
- package/src/providers/types.ts +1 -1
- package/src/providers/utils.ts +3 -1
- package/src/utils/AddressUtils.ts +15 -1
- package/src/utils/ContractUtils.ts +8 -0
- package/src/utils/Multicall.ts +38 -30
- package/src/utils/ObjectUtils.ts +23 -0
- package/src/utils/abi/contracts/index.ts +1 -0
- package/src/utils/abi/typechain/Multicall3.ts +433 -0
- package/src/utils/abi/typechain/common.ts +30 -0
- package/src/utils/abi/typechain/factories/Multicall3__factory.ts +458 -0
- package/src/utils/abi/typechain/factories/index.ts +4 -0
- package/src/utils/abi/typechain/index.ts +6 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {
|
|
2
|
+
object,
|
|
3
|
+
number,
|
|
4
|
+
optional,
|
|
5
|
+
string,
|
|
6
|
+
array,
|
|
7
|
+
record,
|
|
8
|
+
coerce,
|
|
9
|
+
instance,
|
|
10
|
+
pattern,
|
|
11
|
+
boolean,
|
|
12
|
+
defaulted,
|
|
13
|
+
} from "superstruct";
|
|
14
|
+
import { BigNumber } from "ethers";
|
|
15
|
+
|
|
16
|
+
const PositiveIntegerStringSS = pattern(string(), /\d+/);
|
|
17
|
+
const Web3AddressSS = pattern(string(), /^0x[a-fA-F0-9]{40}$/);
|
|
18
|
+
|
|
19
|
+
const BigNumberType = coerce(instance(BigNumber), string(), (value) => {
|
|
20
|
+
try {
|
|
21
|
+
// Attempt to convert the string to a BigNumber
|
|
22
|
+
return BigNumber.from(value);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
// In case of any error during conversion, return the original value
|
|
25
|
+
// This will lead to a validation error, as the resulting value won't match the expected BigNumber type
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const FillTypeSS = number();
|
|
31
|
+
|
|
32
|
+
const V3RelayDataSS = {
|
|
33
|
+
inputToken: string(),
|
|
34
|
+
inputAmount: BigNumberType,
|
|
35
|
+
outputToken: string(),
|
|
36
|
+
outputAmount: BigNumberType,
|
|
37
|
+
fillDeadline: number(),
|
|
38
|
+
exclusiveRelayer: string(),
|
|
39
|
+
exclusivityDeadline: number(),
|
|
40
|
+
originChainId: number(),
|
|
41
|
+
depositor: string(),
|
|
42
|
+
recipient: string(),
|
|
43
|
+
depositId: number(),
|
|
44
|
+
message: string(),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const SortableEventSS = {
|
|
48
|
+
blockNumber: number(),
|
|
49
|
+
transactionIndex: number(),
|
|
50
|
+
logIndex: number(),
|
|
51
|
+
transactionHash: string(),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const V3DepositSS = {
|
|
55
|
+
fromLiteChain: defaulted(boolean(), false),
|
|
56
|
+
toLiteChain: defaulted(boolean(), false),
|
|
57
|
+
destinationChainId: number(),
|
|
58
|
+
quoteTimestamp: number(),
|
|
59
|
+
relayerFeePct: optional(BigNumberType),
|
|
60
|
+
speedUpSignature: optional(string()),
|
|
61
|
+
updatedRecipient: optional(string()),
|
|
62
|
+
updatedOutputAmount: optional(BigNumberType),
|
|
63
|
+
updatedMessage: optional(string()),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const _V3DepositWithBlockSS = {
|
|
67
|
+
quoteBlockNumber: number(),
|
|
68
|
+
...V3DepositSS,
|
|
69
|
+
...SortableEventSS,
|
|
70
|
+
...V3RelayDataSS,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const V3DepositWithBlockSS = object(_V3DepositWithBlockSS);
|
|
74
|
+
const V3DepositWithBlockLpFeeSS = object({
|
|
75
|
+
..._V3DepositWithBlockSS,
|
|
76
|
+
lpFeePct: BigNumberType,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const V3RelayExecutionEventInfoSS = object({
|
|
80
|
+
updatedOutputAmount: BigNumberType,
|
|
81
|
+
fillType: FillTypeSS,
|
|
82
|
+
updatedRecipient: string(),
|
|
83
|
+
updatedMessage: string(),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const V3FillSS = {
|
|
87
|
+
...V3RelayDataSS,
|
|
88
|
+
destinationChainId: number(),
|
|
89
|
+
relayer: string(),
|
|
90
|
+
repaymentChainId: number(),
|
|
91
|
+
relayExecutionInfo: V3RelayExecutionEventInfoSS,
|
|
92
|
+
quoteTimestamp: number(),
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const V3FillWithBlockSS = {
|
|
96
|
+
...SortableEventSS,
|
|
97
|
+
...V3FillSS,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const BundleFillV3SS = object({
|
|
101
|
+
...V3FillWithBlockSS,
|
|
102
|
+
lpFeePct: BigNumberType,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const nestedV3DepositRecordSS = record(PositiveIntegerStringSS, record(Web3AddressSS, array(V3DepositWithBlockSS)));
|
|
106
|
+
const nestedV3DepositRecordWithLpFeePctSS = record(
|
|
107
|
+
PositiveIntegerStringSS,
|
|
108
|
+
record(Web3AddressSS, array(V3DepositWithBlockLpFeeSS))
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const nestedV3BundleFillsSS = record(
|
|
112
|
+
// Must be a chainId
|
|
113
|
+
PositiveIntegerStringSS,
|
|
114
|
+
record(
|
|
115
|
+
Web3AddressSS,
|
|
116
|
+
object({
|
|
117
|
+
fills: array(BundleFillV3SS),
|
|
118
|
+
refunds: record(string(), BigNumberType),
|
|
119
|
+
totalRefundAmount: BigNumberType,
|
|
120
|
+
realizedLpFees: BigNumberType,
|
|
121
|
+
})
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
export const BundleDataSS = object({
|
|
126
|
+
bundleBlockRanges: array(array(number())),
|
|
127
|
+
bundleDepositsV3: nestedV3DepositRecordSS,
|
|
128
|
+
expiredDepositsToRefundV3: nestedV3DepositRecordSS,
|
|
129
|
+
unexecutableSlowFills: nestedV3DepositRecordWithLpFeePctSS,
|
|
130
|
+
bundleSlowFillsV3: nestedV3DepositRecordWithLpFeePctSS,
|
|
131
|
+
bundleFillsV3: nestedV3BundleFillsSS,
|
|
132
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RelayData, Deposit, DepositWithBlock, SpeedUp, Fill, FillWithBlock, SlowFillLeaf } from "../../../interfaces";
|
|
2
|
+
|
|
3
|
+
// V3 shims (to be removed later)
|
|
4
|
+
export type V3RelayData = RelayData;
|
|
5
|
+
export type V3Deposit = Deposit;
|
|
6
|
+
export type V3DepositWithBlock = DepositWithBlock;
|
|
7
|
+
export type V3SpeedUp = SpeedUp;
|
|
8
|
+
export type V3Fill = Fill;
|
|
9
|
+
export type V3FillWithBlock = FillWithBlock;
|
|
10
|
+
export type V3SlowFillLeaf = SlowFillLeaf;
|
package/src/clients/index.ts
CHANGED
|
@@ -6,4 +6,5 @@ export {
|
|
|
6
6
|
} from "./AcrossConfigStoreClient";
|
|
7
7
|
export { HubPoolClient, LpFeeRequest } from "./HubPoolClient";
|
|
8
8
|
export { SpokePoolClient, SpokePoolUpdate } from "./SpokePoolClient";
|
|
9
|
+
export * as BundleDataClient from "./BundleDataClient";
|
|
9
10
|
export * as mocks from "./mocks";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { BigNumber, Signer } from "ethers";
|
|
2
|
+
import { DepositWithBlock, FillWithBlock, Refund } from "./SpokePool";
|
|
3
|
+
import { HubPoolClient } from "../clients/HubPoolClient";
|
|
4
|
+
import { AcrossConfigStoreClient } from "../clients";
|
|
5
|
+
import { ArweaveClient } from "../caching";
|
|
6
|
+
|
|
7
|
+
export type ExpiredDepositsToRefundV3 = {
|
|
8
|
+
[originChainId: number]: {
|
|
9
|
+
[originToken: string]: DepositWithBlock[];
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type BundleDepositsV3 = {
|
|
14
|
+
[originChainId: number]: {
|
|
15
|
+
[originToken: string]: DepositWithBlock[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface BundleFillV3 extends FillWithBlock {
|
|
20
|
+
lpFeePct: BigNumber;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type BundleFillsV3 = {
|
|
24
|
+
[repaymentChainId: number]: {
|
|
25
|
+
[repaymentToken: string]: {
|
|
26
|
+
fills: BundleFillV3[];
|
|
27
|
+
refunds: Refund;
|
|
28
|
+
totalRefundAmount: BigNumber;
|
|
29
|
+
realizedLpFees: BigNumber;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type BundleExcessSlowFills = {
|
|
35
|
+
[destinationChainId: number]: {
|
|
36
|
+
[destinationToken: string]: (DepositWithBlock & { lpFeePct: BigNumber })[];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export type BundleSlowFills = {
|
|
40
|
+
[destinationChainId: number]: {
|
|
41
|
+
[destinationToken: string]: (DepositWithBlock & { lpFeePct: BigNumber })[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type LoadDataReturnValue = {
|
|
46
|
+
bundleDepositsV3: BundleDepositsV3;
|
|
47
|
+
expiredDepositsToRefundV3: ExpiredDepositsToRefundV3;
|
|
48
|
+
bundleFillsV3: BundleFillsV3;
|
|
49
|
+
unexecutableSlowFills: BundleExcessSlowFills;
|
|
50
|
+
bundleSlowFillsV3: BundleSlowFills;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type BundleData = LoadDataReturnValue & {
|
|
54
|
+
bundleBlockRanges: number[][];
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export interface Clients {
|
|
58
|
+
hubPoolClient: HubPoolClient;
|
|
59
|
+
configStoreClient: AcrossConfigStoreClient;
|
|
60
|
+
hubSigner?: Signer;
|
|
61
|
+
arweaveClient: ArweaveClient;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type CombinedRefunds = {
|
|
65
|
+
[repaymentChainId: number]: {
|
|
66
|
+
[repaymentToken: string]: Refund;
|
|
67
|
+
};
|
|
68
|
+
};
|
package/src/interfaces/index.ts
CHANGED
package/src/providers/alchemy.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { RPCTransport } from "./types";
|
|
|
3
3
|
|
|
4
4
|
const MAINNET_CHAIN_IDs = Object.values(_MAINNET_CHAIN_IDs);
|
|
5
5
|
|
|
6
|
-
// Chain-specific overrides for when the
|
|
6
|
+
// Chain-specific overrides for when the endpoint name does not match the canonical chain name.
|
|
7
7
|
const endpoints: { [chainId: string]: string } = {
|
|
8
8
|
[CHAIN_IDs.ARBITRUM]: "arb",
|
|
9
9
|
[CHAIN_IDs.ARBITRUM_SEPOLIA]: "arb-sepolia",
|
|
@@ -14,15 +14,15 @@ const endpoints: { [chainId: string]: string } = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export function getURL(chainId: number, apiKey: string, transport: RPCTransport): string {
|
|
17
|
-
let
|
|
18
|
-
if (!
|
|
17
|
+
let chain = endpoints[chainId] ?? PUBLIC_NETWORKS[chainId]?.name;
|
|
18
|
+
if (!chain) {
|
|
19
19
|
throw new Error(`No known Alchemy provider for chainId ${chainId}`);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (MAINNET_CHAIN_IDs.includes(chainId)) {
|
|
23
|
-
|
|
23
|
+
chain = `${chain}-mainnet`;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
chain = chain.toLowerCase().replace(" ", "-");
|
|
26
26
|
|
|
27
|
-
return `${transport}://${
|
|
27
|
+
return `${transport}://${chain}.g.alchemy.com/v2/${apiKey}`;
|
|
28
28
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CHAIN_IDs, PUBLIC_NETWORKS } from "../constants";
|
|
2
|
+
import { RPCTransport } from "./types";
|
|
3
|
+
|
|
4
|
+
// Chain-specific overrides for when the endpoint name does not match the canonical chain name.
|
|
5
|
+
const endpoints: { [chainId: string]: string } = {
|
|
6
|
+
[CHAIN_IDs.ARBITRUM]: "arbitrum",
|
|
7
|
+
[CHAIN_IDs.MAINNET]: "ethereum",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function getURL(chainId: number, apiKey: string, transport: RPCTransport): string {
|
|
11
|
+
let chain = endpoints[chainId] ?? PUBLIC_NETWORKS[chainId]?.name;
|
|
12
|
+
if (!chain) {
|
|
13
|
+
throw new Error(`No known DRPC provider for chainId ${chainId}`);
|
|
14
|
+
}
|
|
15
|
+
chain = chain.toLowerCase().replace(" ", "-");
|
|
16
|
+
const rpcType = transport === "https" ? "rpc" : "ws";
|
|
17
|
+
|
|
18
|
+
return `${transport}://lb.drpc.org/og${rpcType}?network=${chain}&dkey=${apiKey}`;
|
|
19
|
+
}
|
package/src/providers/infura.ts
CHANGED
|
@@ -3,21 +3,21 @@ import { RPCTransport } from "./types";
|
|
|
3
3
|
|
|
4
4
|
const MAINNET_CHAIN_IDs = Object.values(_MAINNET_CHAIN_IDs);
|
|
5
5
|
|
|
6
|
-
// Chain-specific overrides for when the
|
|
6
|
+
// Chain-specific overrides for when the endpoint name does not match the canonical chain name.
|
|
7
7
|
const endpoints: { [chainId: string]: string } = {
|
|
8
8
|
[CHAIN_IDs.ARBITRUM]: "arbitrum",
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export function getURL(chainId: number, apiKey: string, transport: RPCTransport): string {
|
|
12
|
-
let
|
|
13
|
-
if (!
|
|
12
|
+
let chain = endpoints[chainId] ?? PUBLIC_NETWORKS[chainId]?.name;
|
|
13
|
+
if (!chain) {
|
|
14
14
|
throw new Error(`No known Infura provider for chainId ${chainId}`);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
if (chainId !== CHAIN_IDs.MAINNET && MAINNET_CHAIN_IDs.includes(chainId)) {
|
|
18
|
-
|
|
18
|
+
chain = `${chain}-mainnet`;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
chain = chain.toLowerCase().replace(" ", "-");
|
|
21
21
|
|
|
22
|
-
return transport === "https" ? `https://${
|
|
22
|
+
return transport === "https" ? `https://${chain}.infura.io/v3/${apiKey}` : `wss://${chain}.infura.io/ws/v3/${apiKey}`;
|
|
23
23
|
}
|
package/src/providers/types.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type RPCProvider = "INFURA" | "
|
|
1
|
+
export type RPCProvider = "ALCHEMY" | "DRPC" | "INFURA" | "INFURA_DIN";
|
|
2
2
|
export type RPCTransport = "https" | "wss";
|
package/src/providers/utils.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { isDefined } from "../utils";
|
|
|
6
6
|
import { RPCProvider, RPCTransport } from "./types";
|
|
7
7
|
import * as alchemy from "./alchemy";
|
|
8
8
|
import * as infura from "./infura";
|
|
9
|
+
import * as drpc from "./drpc";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Infura DIN is identified separately to allow it to be configured explicitly.
|
|
@@ -14,6 +15,7 @@ const PROVIDERS = {
|
|
|
14
15
|
ALCHEMY: alchemy.getURL,
|
|
15
16
|
INFURA: infura.getURL,
|
|
16
17
|
INFURA_DIN: infura.getURL,
|
|
18
|
+
DRPC: drpc.getURL,
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -22,7 +24,7 @@ const PROVIDERS = {
|
|
|
22
24
|
* @returns True if the provider string is a supported provider.
|
|
23
25
|
*/
|
|
24
26
|
export function isSupportedProvider(provider: string): provider is RPCProvider {
|
|
25
|
-
return ["ALCHEMY", "INFURA", "INFURA_DIN"].includes(provider);
|
|
27
|
+
return ["ALCHEMY", "INFURA", "INFURA_DIN", "DRPC"].includes(provider);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { providers, utils } from "ethers";
|
|
1
|
+
import { BigNumber, providers, utils } from "ethers";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Checks if a contract is deployed at the given address
|
|
@@ -17,6 +17,20 @@ export async function isContractDeployedToAddress(address: string, provider: pro
|
|
|
17
17
|
return code !== "0x";
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export function compareAddresses(addressA: string, addressB: string): 1 | -1 | 0 {
|
|
21
|
+
// Convert address strings to BigNumbers and then sort numerical value of the BigNumber, which sorts the addresses
|
|
22
|
+
// effectively by their hex value.
|
|
23
|
+
const bnAddressA = BigNumber.from(addressA);
|
|
24
|
+
const bnAddressB = BigNumber.from(addressB);
|
|
25
|
+
if (bnAddressA.gt(bnAddressB)) {
|
|
26
|
+
return 1;
|
|
27
|
+
} else if (bnAddressA.lt(bnAddressB)) {
|
|
28
|
+
return -1;
|
|
29
|
+
} else {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
20
34
|
export function compareAddressesSimple(addressA?: string, addressB?: string): boolean {
|
|
21
35
|
if (addressA === undefined || addressB === undefined) {
|
|
22
36
|
return false;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as typechain from "@across-protocol/contracts/dist/typechain"; // Import the typechain module
|
|
2
|
+
|
|
3
|
+
export function getParamType(contractName: string, functionName: string, paramName: string): string {
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
+
const artifact = (typechain as any)[`${[contractName]}__factory`];
|
|
6
|
+
const fragment = artifact.abi.find((fragment: { name: string }) => fragment.name === functionName);
|
|
7
|
+
return fragment?.inputs.find((input: { name: string }) => input.name === paramName) || "";
|
|
8
|
+
}
|
package/src/utils/Multicall.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BigNumber, Contract, providers, Signer, utils as ethersUtils } from "ethers";
|
|
2
|
-
import {
|
|
2
|
+
import { CHAIN_IDs } from "@across-protocol/constants";
|
|
3
|
+
import { Multicall3, Multicall3__factory } from "./abi/typechain";
|
|
3
4
|
|
|
4
5
|
type Provider = providers.Provider;
|
|
5
6
|
type BlockTag = providers.BlockTag;
|
|
@@ -12,41 +13,48 @@ export type Call3 = {
|
|
|
12
13
|
args?: any[];
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
137: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
20
|
-
324: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
|
|
21
|
-
8453: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
22
|
-
34443: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
23
|
-
42161: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
24
|
-
59144: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
25
|
-
534352: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
26
|
-
// Testnets
|
|
27
|
-
5: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
28
|
-
300: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
|
|
29
|
-
59140: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
30
|
-
59141: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
31
|
-
80002: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
32
|
-
84531: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
33
|
-
84532: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
34
|
-
421613: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
35
|
-
534351: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
36
|
-
11155111: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
37
|
-
11155420: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
16
|
+
const DETERMINISTIC_MULTICALL_ADDRESS = "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
17
|
+
|
|
18
|
+
const NON_DETERMINISTIC_MULTICALL_ADDRESSES = {
|
|
19
|
+
[CHAIN_IDs.ZK_SYNC]: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
|
|
38
20
|
};
|
|
39
21
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
const DETERMINISTIC_MULTICALL_CHAINS = [
|
|
23
|
+
CHAIN_IDs.ARBITRUM,
|
|
24
|
+
CHAIN_IDs.BASE,
|
|
25
|
+
CHAIN_IDs.BLAST,
|
|
26
|
+
CHAIN_IDs.BOBA,
|
|
27
|
+
CHAIN_IDs.LINEA,
|
|
28
|
+
CHAIN_IDs.LISK,
|
|
29
|
+
CHAIN_IDs.MAINNET,
|
|
30
|
+
CHAIN_IDs.MODE,
|
|
31
|
+
CHAIN_IDs.OPTIMISM,
|
|
32
|
+
CHAIN_IDs.POLYGON,
|
|
33
|
+
CHAIN_IDs.REDSTONE,
|
|
34
|
+
CHAIN_IDs.SCROLL,
|
|
35
|
+
CHAIN_IDs.ZORA,
|
|
36
|
+
// Testnet:
|
|
37
|
+
CHAIN_IDs.BASE_SEPOLIA,
|
|
38
|
+
CHAIN_IDs.BLAST_SEPOLIA,
|
|
39
|
+
CHAIN_IDs.POLYGON_AMOY,
|
|
40
|
+
CHAIN_IDs.SCROLL_SEPOLIA,
|
|
41
|
+
CHAIN_IDs.SEPOLIA,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export function getMulticallAddress(chainId: number): string | undefined {
|
|
45
|
+
if (DETERMINISTIC_MULTICALL_CHAINS.includes(chainId)) {
|
|
46
|
+
return DETERMINISTIC_MULTICALL_ADDRESS;
|
|
47
|
+
}
|
|
48
|
+
return NON_DETERMINISTIC_MULTICALL_ADDRESSES[chainId];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getMulticall3(chainId: number, signerOrProvider: Signer | Provider): Multicall3 | undefined {
|
|
52
|
+
const address = getMulticallAddress(chainId);
|
|
45
53
|
if (!address) {
|
|
46
54
|
return undefined;
|
|
47
55
|
}
|
|
48
56
|
|
|
49
|
-
return
|
|
57
|
+
return Multicall3__factory.connect(address, signerOrProvider);
|
|
50
58
|
}
|
|
51
59
|
|
|
52
60
|
export async function aggregate(multicall3: Contract, calls: Call3[], blockTag?: BlockTag): Promise<Result[]> {
|
package/src/utils/ObjectUtils.ts
CHANGED
|
@@ -76,3 +76,26 @@ export function groupObjectCountsByProp(objects: any[], getProp: (obj: any) => s
|
|
|
76
76
|
export function filterFalsyKeys(obj: Record<string | number, unknown>): Record<string | number, unknown> {
|
|
77
77
|
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v));
|
|
78
78
|
}
|
|
79
|
+
|
|
80
|
+
export function count2DDictionaryValues(dictionary: { [key: string]: { [key2: string]: any[] } }): {
|
|
81
|
+
[key: string]: { [key2: string]: number };
|
|
82
|
+
} {
|
|
83
|
+
return Object.entries(dictionary).reduce((output, [key, innerDict]) => {
|
|
84
|
+
const innerDictOutput = Object.entries(innerDict).reduce((innerOutput, [key2, vals]) => {
|
|
85
|
+
return { ...innerOutput, [key2]: vals.length };
|
|
86
|
+
}, {});
|
|
87
|
+
return { ...output, [key]: innerDictOutput };
|
|
88
|
+
}, {});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function count3DDictionaryValues(
|
|
92
|
+
dictionary: { [key: string]: { [key2: string]: any } },
|
|
93
|
+
innerPropName: string
|
|
94
|
+
): { [key: string]: { [key2: string]: number } } {
|
|
95
|
+
return Object.entries(dictionary).reduce((output, [key, innerDict]) => {
|
|
96
|
+
const innerDictOutput = Object.entries(innerDict).reduce((innerOutput, [key2, vals]) => {
|
|
97
|
+
return { ...innerOutput, [key2]: vals[innerPropName].length };
|
|
98
|
+
}, {});
|
|
99
|
+
return { ...output, [key]: innerDictOutput };
|
|
100
|
+
}, {});
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Multicall3Abi } from "./Multicall3.json";
|