@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.
Files changed (229) hide show
  1. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +60 -0
  2. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +929 -0
  3. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -0
  4. package/dist/cjs/clients/BundleDataClient/index.d.ts +2 -0
  5. package/dist/cjs/clients/BundleDataClient/index.js +6 -0
  6. package/dist/cjs/clients/BundleDataClient/index.js.map +1 -0
  7. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.d.ts +15 -0
  8. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +131 -0
  9. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -0
  10. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +6 -0
  11. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +19 -0
  12. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -0
  13. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts +3 -0
  14. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +23 -0
  15. package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -0
  16. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +24 -0
  17. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +129 -0
  18. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -0
  19. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +302 -0
  20. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +77 -0
  21. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -0
  22. package/dist/cjs/clients/BundleDataClient/utils/index.d.ts +6 -0
  23. package/dist/cjs/clients/BundleDataClient/utils/index.js +10 -0
  24. package/dist/cjs/clients/BundleDataClient/utils/index.js.map +1 -0
  25. package/dist/cjs/clients/BundleDataClient/utils/shims.d.ts +8 -0
  26. package/dist/cjs/clients/BundleDataClient/utils/shims.js +3 -0
  27. package/dist/cjs/clients/BundleDataClient/utils/shims.js.map +1 -0
  28. package/dist/cjs/clients/index.d.ts +1 -0
  29. package/dist/cjs/clients/index.js +2 -1
  30. package/dist/cjs/clients/index.js.map +1 -1
  31. package/dist/cjs/interfaces/BundleData.d.ts +63 -0
  32. package/dist/cjs/interfaces/BundleData.js +3 -0
  33. package/dist/cjs/interfaces/BundleData.js.map +1 -0
  34. package/dist/cjs/interfaces/index.d.ts +1 -0
  35. package/dist/cjs/interfaces/index.js +1 -0
  36. package/dist/cjs/interfaces/index.js.map +1 -1
  37. package/dist/cjs/providers/alchemy.js +5 -5
  38. package/dist/cjs/providers/alchemy.js.map +1 -1
  39. package/dist/cjs/providers/drpc.d.ts +2 -0
  40. package/dist/cjs/providers/drpc.js +21 -0
  41. package/dist/cjs/providers/drpc.js.map +1 -0
  42. package/dist/cjs/providers/infura.js +5 -5
  43. package/dist/cjs/providers/infura.js.map +1 -1
  44. package/dist/cjs/providers/types.d.ts +1 -1
  45. package/dist/cjs/providers/utils.js +3 -1
  46. package/dist/cjs/providers/utils.js.map +1 -1
  47. package/dist/cjs/utils/AddressUtils.d.ts +1 -0
  48. package/dist/cjs/utils/AddressUtils.js +15 -1
  49. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  50. package/dist/cjs/utils/ContractUtils.d.ts +1 -0
  51. package/dist/cjs/utils/ContractUtils.js +12 -0
  52. package/dist/cjs/utils/ContractUtils.js.map +1 -0
  53. package/dist/cjs/utils/Multicall.d.ts +3 -2
  54. package/dist/cjs/utils/Multicall.js +40 -41
  55. package/dist/cjs/utils/Multicall.js.map +1 -1
  56. package/dist/cjs/utils/ObjectUtils.d.ts +18 -0
  57. package/dist/cjs/utils/ObjectUtils.js +27 -1
  58. package/dist/cjs/utils/ObjectUtils.js.map +1 -1
  59. package/dist/cjs/utils/abi/contracts/index.d.ts +1 -0
  60. package/dist/cjs/utils/abi/contracts/index.js +9 -0
  61. package/dist/cjs/utils/abi/contracts/index.js.map +1 -0
  62. package/dist/cjs/utils/abi/typechain/Multicall3.d.ts +289 -0
  63. package/dist/cjs/utils/abi/typechain/Multicall3.js +3 -0
  64. package/dist/cjs/utils/abi/typechain/Multicall3.js.map +1 -0
  65. package/dist/cjs/utils/abi/typechain/common.d.ts +21 -0
  66. package/dist/cjs/utils/abi/typechain/common.js +3 -0
  67. package/dist/cjs/utils/abi/typechain/common.js.map +1 -0
  68. package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.d.ts +339 -0
  69. package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js +458 -0
  70. package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -0
  71. package/dist/cjs/utils/abi/typechain/factories/index.d.ts +1 -0
  72. package/dist/cjs/utils/abi/typechain/factories/index.js +6 -0
  73. package/dist/cjs/utils/abi/typechain/factories/index.js.map +1 -0
  74. package/dist/cjs/utils/abi/typechain/index.d.ts +3 -0
  75. package/dist/cjs/utils/abi/typechain/index.js +8 -0
  76. package/dist/cjs/utils/abi/typechain/index.js.map +1 -0
  77. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +60 -0
  78. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1097 -0
  79. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -0
  80. package/dist/esm/clients/BundleDataClient/index.d.ts +2 -0
  81. package/dist/esm/clients/BundleDataClient/index.js +3 -0
  82. package/dist/esm/clients/BundleDataClient/index.js.map +1 -0
  83. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.d.ts +15 -0
  84. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +182 -0
  85. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -0
  86. package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +6 -0
  87. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +20 -0
  88. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -0
  89. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts +3 -0
  90. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +20 -0
  91. package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -0
  92. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +24 -0
  93. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +157 -0
  94. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -0
  95. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +302 -0
  96. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +79 -0
  97. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -0
  98. package/dist/esm/clients/BundleDataClient/utils/index.d.ts +6 -0
  99. package/dist/esm/clients/BundleDataClient/utils/index.js +7 -0
  100. package/dist/esm/clients/BundleDataClient/utils/index.js.map +1 -0
  101. package/dist/esm/clients/BundleDataClient/utils/shims.d.ts +8 -0
  102. package/dist/esm/clients/BundleDataClient/utils/shims.js +2 -0
  103. package/dist/esm/clients/BundleDataClient/utils/shims.js.map +1 -0
  104. package/dist/esm/clients/index.d.ts +1 -0
  105. package/dist/esm/clients/index.js +2 -0
  106. package/dist/esm/clients/index.js.map +1 -1
  107. package/dist/esm/interfaces/BundleData.d.ts +63 -0
  108. package/dist/esm/interfaces/BundleData.js +2 -0
  109. package/dist/esm/interfaces/BundleData.js.map +1 -0
  110. package/dist/esm/interfaces/index.d.ts +1 -0
  111. package/dist/esm/interfaces/index.js +1 -0
  112. package/dist/esm/interfaces/index.js.map +1 -1
  113. package/dist/esm/providers/alchemy.js +6 -6
  114. package/dist/esm/providers/alchemy.js.map +1 -1
  115. package/dist/esm/providers/drpc.d.ts +2 -0
  116. package/dist/esm/providers/drpc.js +18 -0
  117. package/dist/esm/providers/drpc.js.map +1 -0
  118. package/dist/esm/providers/infura.js +6 -6
  119. package/dist/esm/providers/infura.js.map +1 -1
  120. package/dist/esm/providers/types.d.ts +1 -1
  121. package/dist/esm/providers/utils.js +3 -1
  122. package/dist/esm/providers/utils.js.map +1 -1
  123. package/dist/esm/utils/AddressUtils.d.ts +1 -0
  124. package/dist/esm/utils/AddressUtils.js +16 -1
  125. package/dist/esm/utils/AddressUtils.js.map +1 -1
  126. package/dist/esm/utils/ContractUtils.d.ts +1 -0
  127. package/dist/esm/utils/ContractUtils.js +8 -0
  128. package/dist/esm/utils/ContractUtils.js.map +1 -0
  129. package/dist/esm/utils/Multicall.d.ts +3 -2
  130. package/dist/esm/utils/Multicall.js +39 -42
  131. package/dist/esm/utils/Multicall.js.map +1 -1
  132. package/dist/esm/utils/ObjectUtils.d.ts +18 -0
  133. package/dist/esm/utils/ObjectUtils.js +24 -0
  134. package/dist/esm/utils/ObjectUtils.js.map +1 -1
  135. package/dist/esm/utils/abi/contracts/index.d.ts +1 -0
  136. package/dist/esm/utils/abi/contracts/index.js +2 -0
  137. package/dist/esm/utils/abi/contracts/index.js.map +1 -0
  138. package/dist/esm/utils/abi/typechain/Multicall3.d.ts +292 -0
  139. package/dist/esm/utils/abi/typechain/Multicall3.js +2 -0
  140. package/dist/esm/utils/abi/typechain/Multicall3.js.map +1 -0
  141. package/dist/esm/utils/abi/typechain/common.d.ts +21 -0
  142. package/dist/esm/utils/abi/typechain/common.js +2 -0
  143. package/dist/esm/utils/abi/typechain/common.js.map +1 -0
  144. package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.d.ts +339 -0
  145. package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js +458 -0
  146. package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -0
  147. package/dist/esm/utils/abi/typechain/factories/index.d.ts +1 -0
  148. package/dist/esm/utils/abi/typechain/factories/index.js +5 -0
  149. package/dist/esm/utils/abi/typechain/factories/index.js.map +1 -0
  150. package/dist/esm/utils/abi/typechain/index.d.ts +3 -0
  151. package/dist/esm/utils/abi/typechain/index.js +4 -0
  152. package/dist/esm/utils/abi/typechain/index.js.map +1 -0
  153. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +61 -0
  154. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -0
  155. package/dist/types/clients/BundleDataClient/index.d.ts +3 -0
  156. package/dist/types/clients/BundleDataClient/index.d.ts.map +1 -0
  157. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts +16 -0
  158. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -0
  159. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +7 -0
  160. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -0
  161. package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts +4 -0
  162. package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -0
  163. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +25 -0
  164. package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -0
  165. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +303 -0
  166. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -0
  167. package/dist/types/clients/BundleDataClient/utils/index.d.ts +7 -0
  168. package/dist/types/clients/BundleDataClient/utils/index.d.ts.map +1 -0
  169. package/dist/types/clients/BundleDataClient/utils/shims.d.ts +9 -0
  170. package/dist/types/clients/BundleDataClient/utils/shims.d.ts.map +1 -0
  171. package/dist/types/clients/index.d.ts +1 -0
  172. package/dist/types/clients/index.d.ts.map +1 -1
  173. package/dist/types/interfaces/BundleData.d.ts +64 -0
  174. package/dist/types/interfaces/BundleData.d.ts.map +1 -0
  175. package/dist/types/interfaces/index.d.ts +1 -0
  176. package/dist/types/interfaces/index.d.ts.map +1 -1
  177. package/dist/types/providers/drpc.d.ts +3 -0
  178. package/dist/types/providers/drpc.d.ts.map +1 -0
  179. package/dist/types/providers/types.d.ts +1 -1
  180. package/dist/types/providers/types.d.ts.map +1 -1
  181. package/dist/types/providers/utils.d.ts.map +1 -1
  182. package/dist/types/utils/AddressUtils.d.ts +1 -0
  183. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  184. package/dist/types/utils/ContractUtils.d.ts +2 -0
  185. package/dist/types/utils/ContractUtils.d.ts.map +1 -0
  186. package/dist/types/utils/Multicall.d.ts +3 -2
  187. package/dist/types/utils/Multicall.d.ts.map +1 -1
  188. package/dist/types/utils/ObjectUtils.d.ts +18 -0
  189. package/dist/types/utils/ObjectUtils.d.ts.map +1 -1
  190. package/dist/types/utils/abi/contracts/index.d.ts +2 -0
  191. package/dist/types/utils/abi/contracts/index.d.ts.map +1 -0
  192. package/dist/types/utils/abi/typechain/Multicall3.d.ts +293 -0
  193. package/dist/types/utils/abi/typechain/Multicall3.d.ts.map +1 -0
  194. package/dist/types/utils/abi/typechain/common.d.ts +22 -0
  195. package/dist/types/utils/abi/typechain/common.d.ts.map +1 -0
  196. package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts +340 -0
  197. package/dist/types/utils/abi/typechain/factories/Multicall3__factory.d.ts.map +1 -0
  198. package/dist/types/utils/abi/typechain/factories/index.d.ts +2 -0
  199. package/dist/types/utils/abi/typechain/factories/index.d.ts.map +1 -0
  200. package/dist/types/utils/abi/typechain/index.d.ts +4 -0
  201. package/dist/types/utils/abi/typechain/index.d.ts.map +1 -0
  202. package/package.json +6 -8
  203. package/src/clients/BundleDataClient/BundleDataClient.ts +1311 -0
  204. package/src/clients/BundleDataClient/index.ts +2 -0
  205. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +268 -0
  206. package/src/clients/BundleDataClient/utils/FillUtils.ts +46 -0
  207. package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +26 -0
  208. package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +238 -0
  209. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +132 -0
  210. package/src/clients/BundleDataClient/utils/index.ts +6 -0
  211. package/src/clients/BundleDataClient/utils/shims.ts +10 -0
  212. package/src/clients/index.ts +1 -0
  213. package/src/interfaces/BundleData.ts +68 -0
  214. package/src/interfaces/index.ts +1 -0
  215. package/src/providers/alchemy.ts +6 -6
  216. package/src/providers/drpc.ts +19 -0
  217. package/src/providers/infura.ts +6 -6
  218. package/src/providers/types.ts +1 -1
  219. package/src/providers/utils.ts +3 -1
  220. package/src/utils/AddressUtils.ts +15 -1
  221. package/src/utils/ContractUtils.ts +8 -0
  222. package/src/utils/Multicall.ts +38 -30
  223. package/src/utils/ObjectUtils.ts +23 -0
  224. package/src/utils/abi/contracts/index.ts +1 -0
  225. package/src/utils/abi/typechain/Multicall3.ts +433 -0
  226. package/src/utils/abi/typechain/common.ts +30 -0
  227. package/src/utils/abi/typechain/factories/Multicall3__factory.ts +458 -0
  228. package/src/utils/abi/typechain/factories/index.ts +4 -0
  229. 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,6 @@
1
+ export * from "./shims";
2
+ export * from "./FillUtils";
3
+ export * from "./DataworkerUtils";
4
+ export * from "./PoolRebalanceUtils";
5
+ export * from "./SuperstructUtils";
6
+ export * from "./MerkleTreeUtils";
@@ -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;
@@ -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
+ };
@@ -6,3 +6,4 @@ export * from "./Bridge";
6
6
  export * from "./Error";
7
7
  export * from "./TypedData";
8
8
  export * from "./CachingMechanism";
9
+ export * from "./BundleData";
@@ -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 Alchemy endpoint does not match the canonical chain name.
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 host = endpoints[chainId] ?? PUBLIC_NETWORKS[chainId]?.name;
18
- if (!host) {
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
- host = `${host}-mainnet`;
23
+ chain = `${chain}-mainnet`;
24
24
  }
25
- host = host.toLowerCase().replace(" ", "-");
25
+ chain = chain.toLowerCase().replace(" ", "-");
26
26
 
27
- return `${transport}://${host}.g.alchemy.com/v2/${apiKey}`;
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
+ }
@@ -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 Infura endpoint does not match the canonical chain name.
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 host = endpoints[chainId] ?? PUBLIC_NETWORKS[chainId]?.name;
13
- if (!host) {
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
- host = `${host}-mainnet`;
18
+ chain = `${chain}-mainnet`;
19
19
  }
20
- host = host.toLowerCase().replace(" ", "-");
20
+ chain = chain.toLowerCase().replace(" ", "-");
21
21
 
22
- return transport === "https" ? `https://${host}.infura.io/v3/${apiKey}` : `wss://${host}.infura.io/ws/v3/${apiKey}`;
22
+ return transport === "https" ? `https://${chain}.infura.io/v3/${apiKey}` : `wss://${chain}.infura.io/ws/v3/${apiKey}`;
23
23
  }
@@ -1,2 +1,2 @@
1
- export type RPCProvider = "INFURA" | "ALCHEMY";
1
+ export type RPCProvider = "ALCHEMY" | "DRPC" | "INFURA" | "INFURA_DIN";
2
2
  export type RPCTransport = "https" | "wss";
@@ -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
+ }
@@ -1,5 +1,6 @@
1
1
  import { BigNumber, Contract, providers, Signer, utils as ethersUtils } from "ethers";
2
- import { getABI } from "./abi";
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
- // Multicall3 Constants:
16
- export const multicall3Addresses: Record<number, string> = {
17
- 1: "0xcA11bde05977b3631167028862bE2a173976CA11",
18
- 10: "0xcA11bde05977b3631167028862bE2a173976CA11",
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
- export async function getMulticall3(
41
- chainId: number,
42
- signerOrProvider?: Signer | Provider
43
- ): Promise<Contract | undefined> {
44
- const address = multicall3Addresses[chainId];
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 new Contract(address, await getABI("Multicall3"), signerOrProvider);
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[]> {
@@ -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";