@across-protocol/sdk 4.1.63 → 4.2.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.
Files changed (536) hide show
  1. package/dist/cjs/arch/evm/BlockUtils.d.ts +15 -0
  2. package/dist/cjs/arch/evm/BlockUtils.js +218 -0
  3. package/dist/cjs/arch/evm/BlockUtils.js.map +1 -0
  4. package/dist/cjs/arch/evm/SpokeUtils.d.ts +1 -1
  5. package/dist/cjs/arch/evm/SpokeUtils.js +6 -5
  6. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
  7. package/dist/cjs/arch/evm/index.d.ts +1 -0
  8. package/dist/cjs/arch/evm/index.js +1 -0
  9. package/dist/cjs/arch/evm/index.js.map +1 -1
  10. package/dist/cjs/arch/svm/SpokeUtils.d.ts +20 -0
  11. package/dist/cjs/arch/svm/SpokeUtils.js +449 -0
  12. package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -0
  13. package/dist/cjs/arch/svm/constants.d.ts +2 -0
  14. package/dist/cjs/arch/svm/constants.js +7 -0
  15. package/dist/cjs/arch/svm/constants.js.map +1 -0
  16. package/dist/cjs/arch/svm/eventsClient.d.ts +26 -0
  17. package/dist/cjs/arch/svm/eventsClient.js +253 -0
  18. package/dist/cjs/arch/svm/eventsClient.js.map +1 -0
  19. package/dist/cjs/arch/svm/index.d.ts +5 -1
  20. package/dist/cjs/arch/svm/index.js +6 -2
  21. package/dist/cjs/arch/svm/index.js.map +1 -1
  22. package/dist/cjs/{svm → arch/svm}/types.d.ts +9 -4
  23. package/dist/cjs/arch/svm/types.js.map +1 -0
  24. package/dist/cjs/arch/svm/utils.d.ts +18 -0
  25. package/dist/cjs/arch/svm/utils.js +212 -0
  26. package/dist/cjs/arch/svm/utils.js.map +1 -0
  27. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
  28. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +7 -7
  29. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  30. package/dist/cjs/clients/BaseAbstractClient.d.ts +6 -5
  31. package/dist/cjs/clients/BaseAbstractClient.js +30 -19
  32. package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
  33. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +15 -11
  34. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  35. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +1 -1
  36. package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  37. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +114 -114
  38. package/dist/cjs/clients/HubPoolClient.d.ts +4 -3
  39. package/dist/cjs/clients/HubPoolClient.js +18 -17
  40. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  41. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
  42. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +23 -20
  43. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  44. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +23 -0
  45. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +172 -0
  46. package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -0
  47. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -5
  48. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +54 -57
  49. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  50. package/dist/cjs/clients/SpokePoolClient/index.d.ts +3 -0
  51. package/dist/cjs/clients/SpokePoolClient/index.js +8 -1
  52. package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
  53. package/dist/cjs/clients/index.d.ts +1 -1
  54. package/dist/cjs/clients/index.js +2 -1
  55. package/dist/cjs/clients/index.js.map +1 -1
  56. package/dist/cjs/clients/mocks/MockConfigStoreClient.d.ts +1 -1
  57. package/dist/cjs/clients/mocks/MockConfigStoreClient.js +2 -2
  58. package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
  59. package/dist/cjs/clients/mocks/MockHubPoolClient.js +2 -2
  60. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  61. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +7 -4
  62. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  63. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +33 -0
  64. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +184 -0
  65. package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -0
  66. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +30 -0
  67. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +90 -0
  68. package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -0
  69. package/dist/cjs/clients/mocks/index.d.ts +2 -0
  70. package/dist/cjs/clients/mocks/index.js +2 -0
  71. package/dist/cjs/clients/mocks/index.js.map +1 -1
  72. package/dist/cjs/coingecko/Coingecko.d.ts +3 -2
  73. package/dist/cjs/coingecko/Coingecko.js +11 -3
  74. package/dist/cjs/coingecko/Coingecko.js.map +1 -1
  75. package/dist/cjs/constants.d.ts +1 -0
  76. package/dist/cjs/constants.js +2 -1
  77. package/dist/cjs/constants.js.map +1 -1
  78. package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
  79. package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  80. package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +4 -4
  81. package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
  82. package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +3 -2
  83. package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
  84. package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +3 -3
  85. package/dist/cjs/gasPriceOracle/adapters/solana.d.ts +4 -0
  86. package/dist/cjs/gasPriceOracle/adapters/solana.js +43 -0
  87. package/dist/cjs/gasPriceOracle/adapters/solana.js.map +1 -0
  88. package/dist/cjs/gasPriceOracle/index.d.ts +1 -1
  89. package/dist/cjs/gasPriceOracle/oracle.d.ts +4 -3
  90. package/dist/cjs/gasPriceOracle/oracle.js +16 -9
  91. package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
  92. package/dist/cjs/gasPriceOracle/types.d.ts +6 -1
  93. package/dist/cjs/index.d.ts +0 -1
  94. package/dist/cjs/index.js +1 -2
  95. package/dist/cjs/index.js.map +1 -1
  96. package/dist/cjs/interfaces/SpokePool.d.ts +13 -0
  97. package/dist/cjs/interfaces/SpokePool.js.map +1 -1
  98. package/dist/cjs/providers/index.d.ts +1 -1
  99. package/dist/cjs/providers/index.js +1 -2
  100. package/dist/cjs/providers/index.js.map +1 -1
  101. package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.d.ts +5 -0
  102. package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js +21 -0
  103. package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -0
  104. package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +5 -0
  105. package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js +20 -0
  106. package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -0
  107. package/dist/cjs/providers/mocks/MockSolanaRpcFactory.d.ts +13 -0
  108. package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js +76 -0
  109. package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js.map +1 -0
  110. package/dist/cjs/providers/mocks/index.d.ts +4 -0
  111. package/dist/cjs/providers/mocks/index.js +8 -0
  112. package/dist/cjs/providers/mocks/index.js.map +1 -0
  113. package/dist/cjs/providers/{mockProvider.js → mocks/mockEthersProvider.js} +2 -2
  114. package/dist/cjs/providers/mocks/mockEthersProvider.js.map +1 -0
  115. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
  116. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +10 -8
  117. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  118. package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
  119. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +8 -2
  120. package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  121. package/dist/cjs/relayFeeCalculator/chain-queries/index.d.ts +1 -0
  122. package/dist/cjs/relayFeeCalculator/chain-queries/index.js +1 -0
  123. package/dist/cjs/relayFeeCalculator/chain-queries/index.js.map +1 -1
  124. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +37 -0
  125. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +171 -0
  126. package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -0
  127. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +2 -0
  128. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +9 -3
  129. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  130. package/dist/cjs/utils/AddressUtils.d.ts +9 -3
  131. package/dist/cjs/utils/AddressUtils.js +36 -6
  132. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  133. package/dist/cjs/utils/ArrayUtils.d.ts +1 -0
  134. package/dist/cjs/utils/ArrayUtils.js +6 -1
  135. package/dist/cjs/utils/ArrayUtils.js.map +1 -1
  136. package/dist/cjs/utils/BlockFinder.d.ts +22 -0
  137. package/dist/cjs/utils/BlockFinder.js +10 -0
  138. package/dist/cjs/utils/BlockFinder.js.map +1 -0
  139. package/dist/cjs/utils/BlockUtils.d.ts +2 -27
  140. package/dist/cjs/utils/BlockUtils.js +2 -208
  141. package/dist/cjs/utils/BlockUtils.js.map +1 -1
  142. package/dist/cjs/utils/EventUtils.d.ts +4 -4
  143. package/dist/cjs/utils/EventUtils.js +7 -4
  144. package/dist/cjs/utils/EventUtils.js.map +1 -1
  145. package/dist/cjs/utils/JSONUtils.js +3 -0
  146. package/dist/cjs/utils/JSONUtils.js.map +1 -1
  147. package/dist/cjs/utils/NumberUtils.d.ts +1 -0
  148. package/dist/cjs/utils/NumberUtils.js +7 -1
  149. package/dist/cjs/utils/NumberUtils.js.map +1 -1
  150. package/dist/cjs/utils/SpokeUtils.js +5 -0
  151. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  152. package/dist/cjs/utils/TokenUtils.js +4 -1
  153. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  154. package/dist/cjs/utils/index.d.ts +1 -0
  155. package/dist/cjs/utils/index.js +1 -0
  156. package/dist/cjs/utils/index.js.map +1 -1
  157. package/dist/esm/arch/evm/BlockUtils.d.ts +24 -0
  158. package/dist/esm/arch/evm/BlockUtils.js +250 -0
  159. package/dist/esm/arch/evm/BlockUtils.js.map +1 -0
  160. package/dist/esm/arch/evm/SpokeUtils.d.ts +1 -1
  161. package/dist/esm/arch/evm/SpokeUtils.js +6 -5
  162. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
  163. package/dist/esm/arch/evm/index.d.ts +1 -0
  164. package/dist/esm/arch/evm/index.js +1 -0
  165. package/dist/esm/arch/evm/index.js.map +1 -1
  166. package/dist/esm/arch/svm/SpokeUtils.d.ts +122 -0
  167. package/dist/esm/arch/svm/SpokeUtils.js +566 -0
  168. package/dist/esm/arch/svm/SpokeUtils.js.map +1 -0
  169. package/dist/esm/arch/svm/constants.d.ts +2 -0
  170. package/dist/esm/arch/svm/constants.js +3 -0
  171. package/dist/esm/arch/svm/constants.js.map +1 -0
  172. package/dist/esm/arch/svm/eventsClient.d.ts +87 -0
  173. package/dist/esm/arch/svm/eventsClient.js +316 -0
  174. package/dist/esm/arch/svm/eventsClient.js.map +1 -0
  175. package/dist/esm/arch/svm/index.d.ts +5 -1
  176. package/dist/esm/arch/svm/index.js +5 -1
  177. package/dist/esm/arch/svm/index.js.map +1 -1
  178. package/dist/esm/{svm → arch/svm}/types.d.ts +9 -4
  179. package/dist/esm/arch/svm/types.js.map +1 -0
  180. package/dist/esm/arch/svm/utils.d.ts +63 -0
  181. package/dist/esm/arch/svm/utils.js +258 -0
  182. package/dist/esm/arch/svm/utils.js.map +1 -0
  183. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
  184. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +7 -7
  185. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  186. package/dist/esm/clients/BaseAbstractClient.d.ts +6 -5
  187. package/dist/esm/clients/BaseAbstractClient.js +30 -19
  188. package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
  189. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +17 -14
  190. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  191. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +1 -1
  192. package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
  193. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +114 -114
  194. package/dist/esm/clients/HubPoolClient.d.ts +4 -3
  195. package/dist/esm/clients/HubPoolClient.js +19 -18
  196. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  197. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
  198. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +23 -20
  199. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  200. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +66 -0
  201. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +225 -0
  202. package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -0
  203. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +7 -7
  204. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +57 -59
  205. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  206. package/dist/esm/clients/SpokePoolClient/index.d.ts +8 -0
  207. package/dist/esm/clients/SpokePoolClient/index.js +10 -0
  208. package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
  209. package/dist/esm/clients/index.d.ts +1 -1
  210. package/dist/esm/clients/index.js +1 -1
  211. package/dist/esm/clients/index.js.map +1 -1
  212. package/dist/esm/clients/mocks/MockConfigStoreClient.d.ts +1 -1
  213. package/dist/esm/clients/mocks/MockConfigStoreClient.js +2 -2
  214. package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
  215. package/dist/esm/clients/mocks/MockHubPoolClient.js +2 -2
  216. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  217. package/dist/esm/clients/mocks/MockSpokePoolClient.js +8 -5
  218. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  219. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +33 -0
  220. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +183 -0
  221. package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -0
  222. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +30 -0
  223. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +89 -0
  224. package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -0
  225. package/dist/esm/clients/mocks/index.d.ts +2 -0
  226. package/dist/esm/clients/mocks/index.js +2 -0
  227. package/dist/esm/clients/mocks/index.js.map +1 -1
  228. package/dist/esm/coingecko/Coingecko.d.ts +3 -2
  229. package/dist/esm/coingecko/Coingecko.js +12 -3
  230. package/dist/esm/coingecko/Coingecko.js.map +1 -1
  231. package/dist/esm/constants.d.ts +1 -0
  232. package/dist/esm/constants.js +1 -0
  233. package/dist/esm/constants.js.map +1 -1
  234. package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
  235. package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
  236. package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +4 -4
  237. package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
  238. package/dist/esm/gasPriceOracle/adapters/linea-viem.js +3 -2
  239. package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
  240. package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +4 -4
  241. package/dist/esm/gasPriceOracle/adapters/polygon.js +1 -1
  242. package/dist/esm/gasPriceOracle/adapters/solana.d.ts +8 -0
  243. package/dist/esm/gasPriceOracle/adapters/solana.js +43 -0
  244. package/dist/esm/gasPriceOracle/adapters/solana.js.map +1 -0
  245. package/dist/esm/gasPriceOracle/index.d.ts +1 -1
  246. package/dist/esm/gasPriceOracle/oracle.d.ts +4 -3
  247. package/dist/esm/gasPriceOracle/oracle.js +18 -9
  248. package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
  249. package/dist/esm/gasPriceOracle/types.d.ts +6 -1
  250. package/dist/esm/index.d.ts +0 -1
  251. package/dist/esm/index.js +0 -2
  252. package/dist/esm/index.js.map +1 -1
  253. package/dist/esm/interfaces/SpokePool.d.ts +13 -0
  254. package/dist/esm/interfaces/SpokePool.js.map +1 -1
  255. package/dist/esm/providers/index.d.ts +1 -1
  256. package/dist/esm/providers/index.js +1 -2
  257. package/dist/esm/providers/index.js.map +1 -1
  258. package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.d.ts +5 -0
  259. package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js +19 -0
  260. package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -0
  261. package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +5 -0
  262. package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js +18 -0
  263. package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -0
  264. package/dist/esm/providers/mocks/MockSolanaRpcFactory.d.ts +13 -0
  265. package/dist/esm/providers/mocks/MockSolanaRpcFactory.js +74 -0
  266. package/dist/esm/providers/mocks/MockSolanaRpcFactory.js.map +1 -0
  267. package/dist/esm/providers/mocks/index.d.ts +4 -0
  268. package/dist/esm/providers/mocks/index.js +5 -0
  269. package/dist/esm/providers/mocks/index.js.map +1 -0
  270. package/dist/esm/providers/{mockProvider.js → mocks/mockEthersProvider.js} +2 -2
  271. package/dist/esm/providers/mocks/mockEthersProvider.js.map +1 -0
  272. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
  273. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +10 -8
  274. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  275. package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
  276. package/dist/esm/relayFeeCalculator/chain-queries/factory.js +11 -5
  277. package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
  278. package/dist/esm/relayFeeCalculator/chain-queries/index.d.ts +1 -0
  279. package/dist/esm/relayFeeCalculator/chain-queries/index.js +1 -0
  280. package/dist/esm/relayFeeCalculator/chain-queries/index.js.map +1 -1
  281. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +84 -0
  282. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +216 -0
  283. package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -0
  284. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +12 -1
  285. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +9 -4
  286. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  287. package/dist/esm/utils/AddressUtils.d.ts +9 -3
  288. package/dist/esm/utils/AddressUtils.js +41 -6
  289. package/dist/esm/utils/AddressUtils.js.map +1 -1
  290. package/dist/esm/utils/ArrayUtils.d.ts +6 -0
  291. package/dist/esm/utils/ArrayUtils.js +9 -0
  292. package/dist/esm/utils/ArrayUtils.js.map +1 -1
  293. package/dist/esm/utils/BlockFinder.d.ts +22 -0
  294. package/dist/esm/utils/BlockFinder.js +7 -0
  295. package/dist/esm/utils/BlockFinder.js.map +1 -0
  296. package/dist/esm/utils/BlockUtils.d.ts +2 -36
  297. package/dist/esm/utils/BlockUtils.js +2 -243
  298. package/dist/esm/utils/BlockUtils.js.map +1 -1
  299. package/dist/esm/utils/EventUtils.d.ts +4 -4
  300. package/dist/esm/utils/EventUtils.js +7 -4
  301. package/dist/esm/utils/EventUtils.js.map +1 -1
  302. package/dist/esm/utils/JSONUtils.js +3 -0
  303. package/dist/esm/utils/JSONUtils.js.map +1 -1
  304. package/dist/esm/utils/NumberUtils.d.ts +7 -0
  305. package/dist/esm/utils/NumberUtils.js +11 -0
  306. package/dist/esm/utils/NumberUtils.js.map +1 -1
  307. package/dist/esm/utils/SpokeUtils.js +5 -0
  308. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  309. package/dist/esm/utils/TokenUtils.d.ts +12 -0
  310. package/dist/esm/utils/TokenUtils.js +6 -3
  311. package/dist/esm/utils/TokenUtils.js.map +1 -1
  312. package/dist/esm/utils/index.d.ts +1 -0
  313. package/dist/esm/utils/index.js +1 -0
  314. package/dist/esm/utils/index.js.map +1 -1
  315. package/dist/types/arch/evm/BlockUtils.d.ts +25 -0
  316. package/dist/types/arch/evm/BlockUtils.d.ts.map +1 -0
  317. package/dist/types/arch/evm/SpokeUtils.d.ts +1 -1
  318. package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
  319. package/dist/types/arch/evm/index.d.ts +1 -0
  320. package/dist/types/arch/evm/index.d.ts.map +1 -1
  321. package/dist/types/arch/svm/SpokeUtils.d.ts +123 -0
  322. package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -0
  323. package/dist/types/arch/svm/constants.d.ts +3 -0
  324. package/dist/types/arch/svm/constants.d.ts.map +1 -0
  325. package/dist/types/arch/svm/eventsClient.d.ts +88 -0
  326. package/dist/types/arch/svm/eventsClient.d.ts.map +1 -0
  327. package/dist/types/arch/svm/index.d.ts +5 -1
  328. package/dist/types/arch/svm/index.d.ts.map +1 -1
  329. package/dist/types/{svm → arch/svm}/types.d.ts +9 -4
  330. package/dist/types/arch/svm/types.d.ts.map +1 -0
  331. package/dist/types/arch/svm/utils.d.ts +64 -0
  332. package/dist/types/arch/svm/utils.d.ts.map +1 -0
  333. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
  334. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  335. package/dist/types/clients/BaseAbstractClient.d.ts +6 -5
  336. package/dist/types/clients/BaseAbstractClient.d.ts.map +1 -1
  337. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  338. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +114 -114
  339. package/dist/types/clients/HubPoolClient.d.ts +4 -3
  340. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  341. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
  342. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  343. package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +67 -0
  344. package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -0
  345. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +7 -7
  346. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  347. package/dist/types/clients/SpokePoolClient/index.d.ts +8 -0
  348. package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
  349. package/dist/types/clients/index.d.ts +1 -1
  350. package/dist/types/clients/index.d.ts.map +1 -1
  351. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts +1 -1
  352. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
  353. package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
  354. package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +34 -0
  355. package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -0
  356. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +31 -0
  357. package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -0
  358. package/dist/types/clients/mocks/index.d.ts +2 -0
  359. package/dist/types/clients/mocks/index.d.ts.map +1 -1
  360. package/dist/types/coingecko/Coingecko.d.ts +3 -2
  361. package/dist/types/coingecko/Coingecko.d.ts.map +1 -1
  362. package/dist/types/constants.d.ts +1 -0
  363. package/dist/types/constants.d.ts.map +1 -1
  364. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
  365. package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
  366. package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +4 -4
  367. package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
  368. package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts.map +1 -1
  369. package/dist/types/gasPriceOracle/adapters/polygon.d.ts +4 -4
  370. package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
  371. package/dist/types/gasPriceOracle/adapters/solana.d.ts +9 -0
  372. package/dist/types/gasPriceOracle/adapters/solana.d.ts.map +1 -0
  373. package/dist/types/gasPriceOracle/index.d.ts +1 -1
  374. package/dist/types/gasPriceOracle/index.d.ts.map +1 -1
  375. package/dist/types/gasPriceOracle/oracle.d.ts +4 -3
  376. package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
  377. package/dist/types/gasPriceOracle/types.d.ts +6 -1
  378. package/dist/types/gasPriceOracle/types.d.ts.map +1 -1
  379. package/dist/types/index.d.ts +0 -1
  380. package/dist/types/index.d.ts.map +1 -1
  381. package/dist/types/interfaces/SpokePool.d.ts +13 -0
  382. package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
  383. package/dist/types/providers/index.d.ts +1 -1
  384. package/dist/types/providers/index.d.ts.map +1 -1
  385. package/dist/types/providers/mocks/MockCachedSolanaRpcFactory.d.ts +6 -0
  386. package/dist/types/providers/mocks/MockCachedSolanaRpcFactory.d.ts.map +1 -0
  387. package/dist/types/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +6 -0
  388. package/dist/types/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts.map +1 -0
  389. package/dist/types/providers/mocks/MockSolanaRpcFactory.d.ts +14 -0
  390. package/dist/types/providers/mocks/MockSolanaRpcFactory.d.ts.map +1 -0
  391. package/dist/types/providers/mocks/index.d.ts +5 -0
  392. package/dist/types/providers/mocks/index.d.ts.map +1 -0
  393. package/dist/types/providers/{mockProvider.d.ts → mocks/mockEthersProvider.d.ts} +1 -1
  394. package/dist/types/providers/mocks/mockEthersProvider.d.ts.map +1 -0
  395. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
  396. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  397. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
  398. package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
  399. package/dist/types/relayFeeCalculator/chain-queries/index.d.ts +1 -0
  400. package/dist/types/relayFeeCalculator/chain-queries/index.d.ts.map +1 -1
  401. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +85 -0
  402. package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -0
  403. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +12 -1
  404. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  405. package/dist/types/utils/AddressUtils.d.ts +9 -3
  406. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  407. package/dist/types/utils/ArrayUtils.d.ts +6 -0
  408. package/dist/types/utils/ArrayUtils.d.ts.map +1 -1
  409. package/dist/types/utils/BlockFinder.d.ts +23 -0
  410. package/dist/types/utils/BlockFinder.d.ts.map +1 -0
  411. package/dist/types/utils/BlockUtils.d.ts +2 -36
  412. package/dist/types/utils/BlockUtils.d.ts.map +1 -1
  413. package/dist/types/utils/EventUtils.d.ts +4 -4
  414. package/dist/types/utils/EventUtils.d.ts.map +1 -1
  415. package/dist/types/utils/JSONUtils.d.ts.map +1 -1
  416. package/dist/types/utils/NumberUtils.d.ts +7 -0
  417. package/dist/types/utils/NumberUtils.d.ts.map +1 -1
  418. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  419. package/dist/types/utils/TokenUtils.d.ts +12 -0
  420. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  421. package/dist/types/utils/index.d.ts +1 -0
  422. package/dist/types/utils/index.d.ts.map +1 -1
  423. package/package.json +3 -1
  424. package/src/arch/evm/BlockUtils.ts +209 -0
  425. package/src/arch/evm/SpokeUtils.ts +5 -5
  426. package/src/arch/evm/index.ts +1 -0
  427. package/src/arch/svm/SpokeUtils.ts +581 -0
  428. package/src/arch/svm/constants.ts +2 -0
  429. package/src/arch/svm/eventsClient.ts +342 -0
  430. package/src/arch/svm/index.ts +5 -1
  431. package/src/{svm → arch/svm}/types.ts +21 -4
  432. package/src/arch/svm/utils.ts +233 -0
  433. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -7
  434. package/src/clients/BaseAbstractClient.ts +20 -13
  435. package/src/clients/BundleDataClient/BundleDataClient.ts +28 -19
  436. package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +1 -1
  437. package/src/clients/HubPoolClient.ts +19 -19
  438. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +23 -21
  439. package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +268 -0
  440. package/src/clients/SpokePoolClient/SpokePoolClient.ts +50 -59
  441. package/src/clients/SpokePoolClient/index.ts +11 -0
  442. package/src/clients/index.ts +1 -1
  443. package/src/clients/mocks/MockConfigStoreClient.ts +2 -2
  444. package/src/clients/mocks/MockHubPoolClient.ts +2 -2
  445. package/src/clients/mocks/MockSpokePoolClient.ts +9 -4
  446. package/src/clients/mocks/MockSvmCpiEventsClient.ts +226 -0
  447. package/src/clients/mocks/MockSvmSpokePoolClient.ts +119 -0
  448. package/src/clients/mocks/index.ts +2 -0
  449. package/src/coingecko/Coingecko.ts +12 -3
  450. package/src/constants.ts +1 -0
  451. package/src/gasPriceOracle/adapters/arbitrum.ts +5 -2
  452. package/src/gasPriceOracle/adapters/ethereum.ts +7 -4
  453. package/src/gasPriceOracle/adapters/linea-viem.ts +3 -1
  454. package/src/gasPriceOracle/adapters/polygon.ts +6 -6
  455. package/src/gasPriceOracle/adapters/solana.ts +47 -0
  456. package/src/gasPriceOracle/index.ts +1 -1
  457. package/src/gasPriceOracle/oracle.ts +20 -4
  458. package/src/gasPriceOracle/types.ts +7 -1
  459. package/src/index.ts +0 -1
  460. package/src/interfaces/SpokePool.ts +14 -0
  461. package/src/providers/index.ts +1 -1
  462. package/src/providers/mocks/MockCachedSolanaRpcFactory.ts +15 -0
  463. package/src/providers/mocks/MockRateLimitedSolanaRpcFactory.ts +14 -0
  464. package/src/providers/mocks/MockSolanaRpcFactory.ts +55 -0
  465. package/src/providers/mocks/index.ts +4 -0
  466. package/src/providers/{mockProvider.ts → mocks/mockEthersProvider.ts} +1 -1
  467. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +11 -9
  468. package/src/relayFeeCalculator/chain-queries/factory.ts +24 -8
  469. package/src/relayFeeCalculator/chain-queries/index.ts +1 -0
  470. package/src/relayFeeCalculator/chain-queries/svmQuery.ts +225 -0
  471. package/src/relayFeeCalculator/relayFeeCalculator.ts +15 -3
  472. package/src/utils/AddressUtils.ts +49 -6
  473. package/src/utils/ArrayUtils.ts +12 -0
  474. package/src/utils/BlockFinder.ts +26 -0
  475. package/src/utils/BlockUtils.ts +5 -215
  476. package/src/utils/EventUtils.ts +11 -11
  477. package/src/utils/JSONUtils.ts +2 -0
  478. package/src/utils/NumberUtils.ts +10 -0
  479. package/src/utils/SpokeUtils.ts +7 -3
  480. package/src/utils/TokenUtils.ts +6 -3
  481. package/src/utils/index.ts +1 -0
  482. package/dist/cjs/providers/mockProvider.js.map +0 -1
  483. package/dist/cjs/svm/eventsClient.d.ts +0 -15
  484. package/dist/cjs/svm/eventsClient.js +0 -157
  485. package/dist/cjs/svm/eventsClient.js.map +0 -1
  486. package/dist/cjs/svm/index.d.ts +0 -3
  487. package/dist/cjs/svm/index.js +0 -8
  488. package/dist/cjs/svm/index.js.map +0 -1
  489. package/dist/cjs/svm/types.js.map +0 -1
  490. package/dist/cjs/svm/utils/events.d.ts +0 -8
  491. package/dist/cjs/svm/utils/events.js +0 -47
  492. package/dist/cjs/svm/utils/events.js.map +0 -1
  493. package/dist/cjs/svm/utils/helpers.d.ts +0 -2
  494. package/dist/cjs/svm/utils/helpers.js +0 -19
  495. package/dist/cjs/svm/utils/helpers.js.map +0 -1
  496. package/dist/cjs/svm/utils/index.d.ts +0 -1
  497. package/dist/cjs/svm/utils/index.js +0 -5
  498. package/dist/cjs/svm/utils/index.js.map +0 -1
  499. package/dist/esm/providers/mockProvider.js.map +0 -1
  500. package/dist/esm/svm/eventsClient.d.ts +0 -51
  501. package/dist/esm/svm/eventsClient.js +0 -195
  502. package/dist/esm/svm/eventsClient.js.map +0 -1
  503. package/dist/esm/svm/index.d.ts +0 -3
  504. package/dist/esm/svm/index.js +0 -5
  505. package/dist/esm/svm/index.js.map +0 -1
  506. package/dist/esm/svm/types.js.map +0 -1
  507. package/dist/esm/svm/utils/events.d.ts +0 -17
  508. package/dist/esm/svm/utils/events.js +0 -55
  509. package/dist/esm/svm/utils/events.js.map +0 -1
  510. package/dist/esm/svm/utils/helpers.d.ts +0 -5
  511. package/dist/esm/svm/utils/helpers.js +0 -18
  512. package/dist/esm/svm/utils/helpers.js.map +0 -1
  513. package/dist/esm/svm/utils/index.d.ts +0 -1
  514. package/dist/esm/svm/utils/index.js +0 -2
  515. package/dist/esm/svm/utils/index.js.map +0 -1
  516. package/dist/types/providers/mockProvider.d.ts.map +0 -1
  517. package/dist/types/svm/eventsClient.d.ts +0 -52
  518. package/dist/types/svm/eventsClient.d.ts.map +0 -1
  519. package/dist/types/svm/index.d.ts +0 -4
  520. package/dist/types/svm/index.d.ts.map +0 -1
  521. package/dist/types/svm/types.d.ts.map +0 -1
  522. package/dist/types/svm/utils/events.d.ts +0 -18
  523. package/dist/types/svm/utils/events.d.ts.map +0 -1
  524. package/dist/types/svm/utils/helpers.d.ts +0 -6
  525. package/dist/types/svm/utils/helpers.d.ts.map +0 -1
  526. package/dist/types/svm/utils/index.d.ts +0 -2
  527. package/dist/types/svm/utils/index.d.ts.map +0 -1
  528. package/src/svm/eventsClient.ts +0 -199
  529. package/src/svm/index.ts +0 -3
  530. package/src/svm/utils/events.ts +0 -58
  531. package/src/svm/utils/helpers.ts +0 -9
  532. package/src/svm/utils/index.ts +0 -1
  533. /package/dist/cjs/{svm → arch/svm}/types.js +0 -0
  534. /package/dist/cjs/providers/{mockProvider.d.ts → mocks/mockEthersProvider.d.ts} +0 -0
  535. /package/dist/esm/{svm → arch/svm}/types.js +0 -0
  536. /package/dist/esm/providers/{mockProvider.d.ts → mocks/mockEthersProvider.d.ts} +0 -0
@@ -37,6 +37,10 @@ export interface DepositWithBlock extends Deposit, SortableEvent {
37
37
  quoteBlockNumber: number;
38
38
  }
39
39
 
40
+ export interface DepositWithTime extends Deposit, SortableEvent {
41
+ depositTimestamp: number;
42
+ }
43
+
40
44
  export enum FillStatus {
41
45
  Unfilled = 0,
42
46
  RequestedSlowFill,
@@ -66,7 +70,17 @@ export interface Fill extends Omit<RelayData, "message"> {
66
70
  }
67
71
 
68
72
  export interface FillWithBlock extends Fill, SortableEvent {}
73
+ export interface FillWithTime extends Fill, SortableEvent {
74
+ fillTimestamp: number;
75
+ }
76
+
77
+ export interface EnabledDepositRoute {
78
+ originToken: string;
79
+ destinationChainId: number;
80
+ enabled: boolean;
81
+ }
69
82
 
83
+ export interface EnabledDepositRouteWithBlock extends EnabledDepositRoute, SortableEvent {}
70
84
  export interface SpeedUp {
71
85
  depositor: string;
72
86
  depositorSignature: string;
@@ -5,5 +5,5 @@ export * from "./speedProvider";
5
5
  export * from "./constants";
6
6
  export * from "./types";
7
7
  export * from "./utils";
8
- export * as mocks from "./mockProvider";
8
+ export * from "./mocks";
9
9
  export * from "./solana";
@@ -0,0 +1,15 @@
1
+ import { CachedSolanaRpcFactory } from "..";
2
+ import { MockRateLimitedSolanaRpcFactory } from "./MockRateLimitedSolanaRpcFactory";
3
+
4
+ // Creates mocked cached Solana RPC factory by using the mocked Solana RPC factory.
5
+ export class MockCachedSolanaRpcFactory extends CachedSolanaRpcFactory {
6
+ constructor(
7
+ mockRateLimitedSolanaRpcFactory: MockRateLimitedSolanaRpcFactory,
8
+ ...cachedConstructorParams: ConstructorParameters<typeof CachedSolanaRpcFactory>
9
+ ) {
10
+ super(...cachedConstructorParams);
11
+
12
+ this.rateLimitedTransport = mockRateLimitedSolanaRpcFactory.createTransport();
13
+ this.rateLimitedRpcClient = mockRateLimitedSolanaRpcFactory.createRpcClient();
14
+ }
15
+ }
@@ -0,0 +1,14 @@
1
+ import { RateLimitedSolanaRpcFactory } from "..";
2
+ import { MockSolanaRpcFactory } from "./MockSolanaRpcFactory";
3
+
4
+ // Creates mocked rate limited Solana RPC factory by using the mocked Solana RPC factory.
5
+ export class MockRateLimitedSolanaRpcFactory extends RateLimitedSolanaRpcFactory {
6
+ constructor(
7
+ mockSolanaRpcFactory: MockSolanaRpcFactory,
8
+ ...rateLimitedConstructorParams: ConstructorParameters<typeof RateLimitedSolanaRpcFactory>
9
+ ) {
10
+ super(...rateLimitedConstructorParams);
11
+
12
+ this.defaultTransport = mockSolanaRpcFactory.createTransport();
13
+ }
14
+ }
@@ -0,0 +1,55 @@
1
+ import { RpcResponse, RpcTransport } from "@solana/kit";
2
+ import { SolanaClusterRpcFactory } from "../solana";
3
+
4
+ type CachedResponse = { result: unknown } | { error: unknown } | { throwError: string };
5
+
6
+ // Exposes mocked RPC transport for Solana in the SolanaClusterRpcFactory class.
7
+ export class MockSolanaRpcFactory extends SolanaClusterRpcFactory {
8
+ private responseTime: number = 10; // in milliseconds
9
+ private responses: Map<string, CachedResponse> = new Map();
10
+
11
+ constructor(...clusterConstructorParams: ConstructorParameters<typeof SolanaClusterRpcFactory>) {
12
+ super(...clusterConstructorParams);
13
+ }
14
+
15
+ public createTransport(): RpcTransport {
16
+ return <TResponse>(...args: Parameters<RpcTransport>): Promise<TResponse> => {
17
+ return this.createMockRpcTransport()<TResponse>(...args);
18
+ };
19
+ }
20
+
21
+ public setResult(method: string, params: unknown[], result: unknown) {
22
+ const requestKey = JSON.stringify({ method, params });
23
+ this.responses.set(requestKey, { result });
24
+ }
25
+
26
+ public setError(method: string, params: unknown[], error: unknown) {
27
+ const requestKey = JSON.stringify({ method, params });
28
+ this.responses.set(requestKey, { error });
29
+ }
30
+
31
+ public setThrow(method: string, params: unknown[], throwError: string) {
32
+ const requestKey = JSON.stringify({ method, params });
33
+ this.responses.set(requestKey, { throwError });
34
+ }
35
+
36
+ public setResponseTime(responseTime: number) {
37
+ this.responseTime = responseTime;
38
+ }
39
+
40
+ private createMockRpcTransport(): RpcTransport {
41
+ return async <TResponse>({ payload }: Parameters<RpcTransport>[0]): Promise<RpcResponse<TResponse>> => {
42
+ const { method, params } = payload as { method: string; params?: unknown[] };
43
+ const requestKey = JSON.stringify({ method, params });
44
+ let jsonRpcResponse = this.responses.get(requestKey);
45
+ if (jsonRpcResponse === undefined) {
46
+ const requestKeyWithoutParams = JSON.stringify({ method, params: [] });
47
+ jsonRpcResponse = this.responses.get(requestKeyWithoutParams);
48
+ if (jsonRpcResponse === undefined) jsonRpcResponse = { result: null };
49
+ }
50
+ await new Promise((resolve) => setTimeout(resolve, this.responseTime));
51
+ if ("throwError" in jsonRpcResponse) throw new Error(jsonRpcResponse.throwError);
52
+ return jsonRpcResponse as TResponse;
53
+ };
54
+ }
55
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./mockEthersProvider";
2
+ export * from "./MockCachedSolanaRpcFactory";
3
+ export * from "./MockRateLimitedSolanaRpcFactory";
4
+ export * from "./MockSolanaRpcFactory";
@@ -1,6 +1,6 @@
1
1
  import { BigNumber, providers } from "ethers";
2
2
  import { Block, BlockTag, FeeData, TransactionResponse } from "@ethersproject/abstract-provider";
3
- import { bnZero } from "../utils/BigNumberUtils";
3
+ import { bnZero } from "../../utils/BigNumberUtils";
4
4
 
5
5
  /**
6
6
  * @notice Class used to test GasPriceOracle which makes ethers provider calls to the following implemented
@@ -3,7 +3,7 @@ import { isL2Provider as isOptimismL2Provider } from "@eth-optimism/sdk/dist/l2-
3
3
 
4
4
  import { PopulatedTransaction, providers, VoidSigner } from "ethers";
5
5
  import { Coingecko } from "../../coingecko";
6
- import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS } from "../../constants";
6
+ import { CHAIN_IDs } from "../../constants";
7
7
  import { Deposit } from "../../interfaces";
8
8
  import { SpokePool, SpokePool__factory } from "../../typechain";
9
9
  import { populateV3Relay } from "../../arch/evm";
@@ -17,12 +17,12 @@ import {
17
17
  fixedPointAdjustment,
18
18
  } from "../../utils";
19
19
  import assert from "assert";
20
- import { Logger, QueryInterface } from "../relayFeeCalculator";
20
+ import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
21
21
  import { Transport } from "viem";
22
- import { getGasPriceEstimate } from "../../gasPriceOracle/oracle";
22
+ import { getGasPriceEstimate, EvmGasPriceEstimate } from "../../gasPriceOracle";
23
23
  type Provider = providers.Provider;
24
24
  type OptimismProvider = L2Provider<Provider>;
25
- type SymbolMappingType = Record<
25
+ export type SymbolMappingType = Record<
26
26
  string,
27
27
  {
28
28
  addresses: Record<number, string>;
@@ -72,7 +72,7 @@ export class QueryBase implements QueryInterface {
72
72
  */
73
73
  async getGasCosts(
74
74
  deposit: Omit<Deposit, "messageHash">,
75
- relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS,
75
+ relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
76
76
  options: Partial<{
77
77
  gasPrice: BigNumberish;
78
78
  gasUnits: BigNumberish;
@@ -122,7 +122,7 @@ export class QueryBase implements QueryInterface {
122
122
  */
123
123
  getUnsignedTxFromDeposit(
124
124
  deposit: Omit<Deposit, "messageHash">,
125
- relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS
125
+ relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
126
126
  ): Promise<PopulatedTransaction> {
127
127
  return populateV3Relay(this.spokePool, deposit, relayer);
128
128
  }
@@ -135,7 +135,7 @@ export class QueryBase implements QueryInterface {
135
135
  */
136
136
  async getNativeGasCost(
137
137
  deposit: Omit<Deposit, "messageHash">,
138
- relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS
138
+ relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
139
139
  ): Promise<BigNumber> {
140
140
  const unsignedTx = await this.getUnsignedTxFromDeposit(deposit, relayer);
141
141
  const voidSigner = new VoidSigner(relayer, this.provider);
@@ -152,7 +152,7 @@ export class QueryBase implements QueryInterface {
152
152
  */
153
153
  async getOpStackL1DataFee(
154
154
  unsignedTx: PopulatedTransaction,
155
- relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS,
155
+ relayer = getDefaultSimulatedRelayerAddress(unsignedTx.chainId),
156
156
  options: Partial<{
157
157
  opStackL2GasUnits: BigNumberish;
158
158
  opStackL1DataFeeMultiplier: BigNumber;
@@ -213,7 +213,9 @@ export class QueryBase implements QueryInterface {
213
213
  ? Promise.resolve({ maxFeePerGas: _gasPrice })
214
214
  : getGasPriceEstimate(provider, { chainId, baseFeeMultiplier, priorityFeeMultiplier, transport, unsignedTx }),
215
215
  ] as const;
216
- const [nativeGasCost, { maxFeePerGas: gasPrice }] = await Promise.all(queries);
216
+ const [nativeGasCost, _gasPriceEstimate] = await Promise.all(queries);
217
+ // It should be safe to cast to an EvmGasPriceEstimate here since QueryBase is only used for EVM chains.
218
+ const gasPrice = (_gasPriceEstimate as EvmGasPriceEstimate).maxFeePerGas;
217
219
  assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
218
220
  let tokenGasCost: BigNumber;
219
221
 
@@ -3,11 +3,13 @@ import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants";
3
3
  import { getDeployedAddress } from "@across-protocol/contracts";
4
4
  import { asL2Provider } from "@eth-optimism/sdk";
5
5
  import { providers } from "ethers";
6
- import { DEFAULT_SIMULATED_RELAYER_ADDRESS, CUSTOM_GAS_TOKENS } from "../../constants";
7
- import { chainIsOPStack, isDefined } from "../../utils";
6
+ import { CUSTOM_GAS_TOKENS } from "../../constants";
7
+ import { chainIsOPStack, isDefined, chainIsSvm, SvmAddress } from "../../utils";
8
8
  import { QueryBase } from "./baseQuery";
9
- import { DEFAULT_LOGGER, Logger } from "../relayFeeCalculator";
9
+ import { SVMProvider as svmProvider } from "../../arch/svm";
10
+ import { DEFAULT_LOGGER, getDefaultSimulatedRelayerAddress, Logger } from "../relayFeeCalculator";
10
11
  import { CustomGasTokenQueries } from "./customGasToken";
12
+ import { SvmQuery } from "./svmQuery";
11
13
 
12
14
  /**
13
15
  * Some chains have a fixed gas price that is applied to the gas estimates. We should override
@@ -20,21 +22,21 @@ const fixedGasPrice = {
20
22
  export class QueryBase__factory {
21
23
  static create(
22
24
  chainId: number,
23
- provider: providers.Provider,
25
+ provider: providers.Provider | svmProvider,
24
26
  symbolMapping = TOKEN_SYMBOLS_MAP,
25
27
  spokePoolAddress = getDeployedAddress("SpokePool", chainId),
26
- simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
28
+ simulatedRelayerAddress = getDefaultSimulatedRelayerAddress(chainId),
27
29
  coingeckoProApiKey?: string,
28
30
  logger: Logger = DEFAULT_LOGGER,
29
31
  coingeckoBaseCurrency = "eth"
30
- ): QueryBase {
32
+ ): QueryBase | SvmQuery {
31
33
  assert(isDefined(spokePoolAddress));
32
34
 
33
35
  const customGasTokenSymbol = CUSTOM_GAS_TOKENS[chainId];
34
36
  if (customGasTokenSymbol) {
35
37
  return new CustomGasTokenQueries({
36
38
  queryBaseArgs: [
37
- provider,
39
+ provider as providers.Provider,
38
40
  symbolMapping,
39
41
  spokePoolAddress,
40
42
  simulatedRelayerAddress,
@@ -46,9 +48,23 @@ export class QueryBase__factory {
46
48
  customGasTokenSymbol,
47
49
  });
48
50
  }
51
+ if (chainIsSvm(chainId)) {
52
+ return new SvmQuery(
53
+ provider as svmProvider,
54
+ symbolMapping,
55
+ SvmAddress.from(spokePoolAddress),
56
+ SvmAddress.from(simulatedRelayerAddress),
57
+ logger,
58
+ coingeckoProApiKey,
59
+ fixedGasPrice[chainId],
60
+ coingeckoBaseCurrency
61
+ );
62
+ }
49
63
 
50
64
  // For OPStack chains, we need to wrap the provider in an L2Provider
51
- provider = chainIsOPStack(chainId) ? asL2Provider(provider) : provider;
65
+ provider = chainIsOPStack(chainId)
66
+ ? asL2Provider(provider as providers.Provider)
67
+ : (provider as providers.Provider);
52
68
 
53
69
  return new QueryBase(
54
70
  provider,
@@ -1,3 +1,4 @@
1
1
  export * from "./baseQuery";
2
2
  export * from "./factory";
3
3
  export * from "./customGasToken";
4
+ export * from "./svmQuery";
@@ -0,0 +1,225 @@
1
+ import { pipe } from "@solana/functional";
2
+ import { Coingecko } from "../../coingecko";
3
+ import { SymbolMappingType } from "./";
4
+ import { CHAIN_IDs } from "../../constants";
5
+ import { Deposit } from "../../interfaces";
6
+ import { getGasPriceEstimate, SvmGasPriceEstimate } from "../../gasPriceOracle";
7
+ import {
8
+ BigNumberish,
9
+ TransactionCostEstimate,
10
+ BigNumber,
11
+ SvmAddress,
12
+ toBN,
13
+ isDefined,
14
+ toAddressType,
15
+ } from "../../utils";
16
+ import { getDefaultSimulatedRelayerAddress, Logger, QueryInterface } from "../relayFeeCalculator";
17
+ import {
18
+ fillRelayInstruction,
19
+ createApproveInstruction,
20
+ createTokenAccountsInstruction,
21
+ SVMProvider,
22
+ SolanaVoidSigner,
23
+ getAssociatedTokenAddress,
24
+ } from "../../arch/svm";
25
+ import {
26
+ createTransactionMessage,
27
+ setTransactionMessageFeePayer,
28
+ setTransactionMessageLifetimeUsingBlockhash,
29
+ appendTransactionMessageInstructions,
30
+ getComputeUnitEstimateForTransactionMessageFactory,
31
+ fetchEncodedAccount,
32
+ IInstruction,
33
+ } from "@solana/kit";
34
+ import { TOKEN_PROGRAM_ADDRESS, getMintSize, getInitializeMintInstruction, fetchMint } from "@solana-program/token";
35
+ import { getCreateAccountInstruction } from "@solana-program/system";
36
+
37
+ /**
38
+ * A special QueryBase implementation for SVM used for querying gas costs, token prices, and decimals of various tokens
39
+ * on Solana.
40
+ */
41
+ export class SvmQuery implements QueryInterface {
42
+ protected computeUnitEstimator;
43
+
44
+ /**
45
+ * Instantiates a SvmQuery instance
46
+ * @param provider A valid solana/kit rpc client.
47
+ * @param symbolMapping A mapping to valid ERC20 tokens and their respective characteristics
48
+ * @param spokePoolAddress The valid address of the Spoke Pool deployment
49
+ * @param simulatedRelayerAddress The address that these queries will reference as the sender. Note: This address must be approved for USDC
50
+ * @param logger A logging utility to report logs
51
+ * @param coingeckoProApiKey An optional CoinGecko API key that links to a PRO account
52
+ * @param fixedGasPrice Overrides the gas price with a fixed value. Note: primarily used for the Boba blockchain
53
+ * @param coingeckoBaseCurrency The basis currency that CoinGecko will use to resolve pricing
54
+ */
55
+ constructor(
56
+ readonly provider: SVMProvider,
57
+ readonly symbolMapping: SymbolMappingType,
58
+ readonly spokePoolAddress: SvmAddress,
59
+ readonly simulatedRelayerAddress: SvmAddress,
60
+ readonly logger: Logger,
61
+ readonly coingeckoProApiKey?: string,
62
+ readonly fixedGasPrice?: BigNumberish,
63
+ readonly coingeckoBaseCurrency: string = "eth"
64
+ ) {
65
+ this.computeUnitEstimator = getComputeUnitEstimateForTransactionMessageFactory({
66
+ rpc: provider,
67
+ });
68
+ }
69
+
70
+ /**
71
+ * Retrieves the current gas costs of performing a fillRelay contract at the referenced SpokePool.
72
+ * @param deposit V3 deposit instance.
73
+ * @param relayerAddress Relayer address to simulate with.
74
+ * @param options
75
+ * @param options.gasPrice Optional gas price to use for the simulation.
76
+ * @param options.gasUnits Optional gas units to use for the simulation.
77
+ * @param options.transport Optional transport object for custom gas price retrieval.
78
+ * @returns The gas estimate for this function call (multiplied with the optional buffer).
79
+ */
80
+ async getGasCosts(
81
+ deposit: Omit<Deposit, "messageHash">,
82
+ _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
83
+ options: Partial<{
84
+ gasPrice: BigNumberish;
85
+ gasUnits: BigNumberish;
86
+ baseFeeMultiplier: BigNumber;
87
+ priorityFeeMultiplier: BigNumber;
88
+ }> = {}
89
+ ): Promise<TransactionCostEstimate> {
90
+ const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
91
+
92
+ const fillRelayTx = await this.getFillRelayTx(deposit, relayer.toBase58());
93
+
94
+ const [computeUnitsConsumed, _gasPriceEstimate] = await Promise.all([
95
+ toBN(await this.computeUnitEstimator(fillRelayTx)),
96
+ getGasPriceEstimate(this.provider, {
97
+ unsignedTx: fillRelayTx,
98
+ baseFeeMultiplier: options.baseFeeMultiplier,
99
+ priorityFeeMultiplier: options.priorityFeeMultiplier,
100
+ }),
101
+ ]);
102
+
103
+ // We can cast the gas price estimate to an SvmGasPriceEstimate here since the oracle should always
104
+ // query the Solana adapter.
105
+ const gasPriceEstimate = _gasPriceEstimate as SvmGasPriceEstimate;
106
+ const gasPrice = gasPriceEstimate.baseFee.add(
107
+ gasPriceEstimate.microLamportsPerComputeUnit.mul(computeUnitsConsumed).div(toBN(1_000_000)) // 1_000_000 microLamports/lamport.
108
+ );
109
+
110
+ return {
111
+ nativeGasCost: computeUnitsConsumed,
112
+ tokenGasCost: gasPrice,
113
+ gasPrice,
114
+ };
115
+ }
116
+
117
+ /**
118
+ * @notice Return the gas cost of a simulated transaction
119
+ * @param fillRelayTx FillRelay transaction
120
+ * @param relayer SVM address of the relayer
121
+ * @returns Estimated gas cost in compute units
122
+ */
123
+ async getNativeGasCost(
124
+ deposit: Omit<Deposit, "messageHash">,
125
+ _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
126
+ ): Promise<BigNumber> {
127
+ const fillRelayTx = await this.getFillRelayTx(deposit, _relayer);
128
+ const computeUnitsConsumed = toBN(await this.computeUnitEstimator(fillRelayTx));
129
+ return computeUnitsConsumed;
130
+ }
131
+
132
+ /**
133
+ * @notice Return the fillRelay transaction for a given deposit
134
+ * @param deposit
135
+ * @param relayer SVM address of the relayer
136
+ * @returns FillRelay transaction
137
+ */
138
+ async getFillRelayTx(
139
+ deposit: Omit<Deposit, "messageHash">,
140
+ _relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
141
+ ) {
142
+ const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
143
+ // If the user did not have a token account created on destination, then we need to include this as a gas cost.
144
+ const mint = toAddressType(deposit.outputToken).forceSvmAddress();
145
+ const owner = toAddressType(deposit.recipient).forceSvmAddress();
146
+ const associatedToken = await getAssociatedTokenAddress(owner, mint);
147
+ const simulatedSigner = SolanaVoidSigner(relayer.toBase58());
148
+
149
+ // If the recipient has an associated token account on destination, then skip generating the instruction for creating a new token account.
150
+ let recipientCreateTokenAccountInstructions: IInstruction[] | undefined = undefined;
151
+ const [associatedTokenAccountExists, mintInfo] = await Promise.all([
152
+ (await fetchEncodedAccount(this.provider, associatedToken)).exists,
153
+ fetchMint(this.provider, mint.toV2Address()),
154
+ ]);
155
+ if (!associatedTokenAccountExists) {
156
+ const space = BigInt(getMintSize());
157
+ const rent = await this.provider.getMinimumBalanceForRentExemption(space).send();
158
+ const createAccountIx = getCreateAccountInstruction({
159
+ payer: simulatedSigner,
160
+ newAccount: SolanaVoidSigner(mint.toBase58()),
161
+ lamports: rent,
162
+ space,
163
+ programAddress: TOKEN_PROGRAM_ADDRESS,
164
+ });
165
+
166
+ const initializeMintIx = getInitializeMintInstruction({
167
+ mint: mint.toV2Address(),
168
+ decimals: mintInfo.data.decimals,
169
+ mintAuthority: owner.toV2Address(),
170
+ });
171
+ recipientCreateTokenAccountInstructions = [createAccountIx, initializeMintIx];
172
+ }
173
+
174
+ const [createTokenAccountsIx, approveIx, fillIx] = await Promise.all([
175
+ createTokenAccountsInstruction(mint, simulatedSigner),
176
+ createApproveInstruction(
177
+ mint,
178
+ deposit.outputAmount,
179
+ this.simulatedRelayerAddress,
180
+ this.spokePoolAddress,
181
+ mintInfo.data.decimals
182
+ ),
183
+ fillRelayInstruction(this.spokePoolAddress, deposit, simulatedSigner, associatedToken),
184
+ ]);
185
+
186
+ // Get the most recent confirmed blockhash.
187
+ const recentBlockhash = await this.provider.getLatestBlockhash().send();
188
+ const fillRelayTx = pipe(
189
+ createTransactionMessage({ version: 0 }),
190
+ (tx) => setTransactionMessageFeePayer(relayer.toV2Address(), tx),
191
+ (tx) => setTransactionMessageLifetimeUsingBlockhash(recentBlockhash.value, tx),
192
+ (tx) =>
193
+ isDefined(recipientCreateTokenAccountInstructions)
194
+ ? appendTransactionMessageInstructions(recipientCreateTokenAccountInstructions, tx)
195
+ : tx,
196
+ (tx) => appendTransactionMessageInstructions([createTokenAccountsIx, approveIx, fillIx], tx)
197
+ );
198
+ return fillRelayTx;
199
+ }
200
+
201
+ /**
202
+ * Retrieves the current price of a token
203
+ * @param tokenSymbol A valid [CoinGecko-ID](https://api.coingecko.com/api/v3/coins/list)
204
+ * @returns The resolved token price within the specified coingeckoBaseCurrency
205
+ */
206
+ async getTokenPrice(tokenSymbol: string): Promise<number> {
207
+ if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
208
+ const coingeckoInstance = Coingecko.get(this.logger, this.coingeckoProApiKey);
209
+ const [, price] = await coingeckoInstance.getCurrentPriceByContract(
210
+ this.symbolMapping[tokenSymbol].addresses[CHAIN_IDs.MAINNET],
211
+ this.coingeckoBaseCurrency
212
+ );
213
+ return price;
214
+ }
215
+
216
+ /**
217
+ * Resolves the number of decimal places a token can have
218
+ * @param tokenSymbol A valid Across-Enabled Token ID
219
+ * @returns The number of decimals of precision for the corresponding tokenSymbol
220
+ */
221
+ getTokenDecimals(tokenSymbol: string): number {
222
+ if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
223
+ return this.symbolMapping[tokenSymbol].decimals;
224
+ }
225
+ }
@@ -1,5 +1,9 @@
1
1
  import assert from "assert";
2
- import { DEFAULT_SIMULATED_RELAYER_ADDRESS, TOKEN_SYMBOLS_MAP } from "../constants";
2
+ import {
3
+ DEFAULT_SIMULATED_RELAYER_ADDRESS,
4
+ DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM,
5
+ TOKEN_SYMBOLS_MAP,
6
+ } from "../constants";
3
7
  import { Deposit } from "../interfaces";
4
8
  import {
5
9
  BigNumber,
@@ -18,6 +22,7 @@ import {
18
22
  toBNWei,
19
23
  isZeroAddress,
20
24
  compareAddressesSimple,
25
+ chainIsSvm,
21
26
  } from "../utils";
22
27
  import { Transport } from "viem";
23
28
 
@@ -36,6 +41,7 @@ export interface QueryInterface {
36
41
  }>
37
42
  ) => Promise<TransactionCostEstimate>;
38
43
  getTokenPrice: (tokenSymbol: string) => Promise<number>;
44
+ getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: string) => Promise<BigNumber>;
39
45
  }
40
46
 
41
47
  export const expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
@@ -105,6 +111,12 @@ export const DEFAULT_LOGGER: Logger = {
105
111
  error: (...args) => console.error(args),
106
112
  };
107
113
 
114
+ export function getDefaultSimulatedRelayerAddress(chainId?: number) {
115
+ return isDefined(chainId) && chainIsSvm(chainId)
116
+ ? DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM
117
+ : DEFAULT_SIMULATED_RELAYER_ADDRESS;
118
+ }
119
+
108
120
  // Small amount to simulate filling with. Should be low enough to guarantee a successful fill.
109
121
  const safeOutputAmount = toBN(100);
110
122
 
@@ -241,7 +253,7 @@ export class RelayFeeCalculator {
241
253
  deposit: Deposit,
242
254
  amountToRelay: BigNumberish,
243
255
  simulateZeroFill = false,
244
- relayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
256
+ relayerAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
245
257
  _tokenPrice?: number,
246
258
  tokenMapping = TOKEN_SYMBOLS_MAP,
247
259
  gasPrice?: BigNumberish,
@@ -480,7 +492,7 @@ export class RelayFeeCalculator {
480
492
  deposit: Deposit,
481
493
  amountToRelay?: BigNumberish,
482
494
  simulateZeroFill = false,
483
- relayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
495
+ relayerAddress = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
484
496
  _tokenPrice?: number,
485
497
  gasPrice?: BigNumberish,
486
498
  gasUnits?: BigNumberish,
@@ -1,5 +1,6 @@
1
1
  import { providers, utils } from "ethers";
2
2
  import bs58 from "bs58";
3
+ import { Address as V2Address } from "@solana/kit";
3
4
  import { BigNumber, chainIsEvm } from "./";
4
5
 
5
6
  /**
@@ -77,9 +78,9 @@ export function isValidEvmAddress(address: string): boolean {
77
78
  * @returns a child `Address` type most fitting for the chain ID.
78
79
  * @todo: Change this to `toAddress` once we remove the other `toAddress` function.
79
80
  */
80
- export function toAddressType(address: string, chainId: number): Address | EvmAddress | SvmAddress {
81
+ export function toAddressType(address: string): Address | EvmAddress | SvmAddress {
81
82
  try {
82
- if (chainIsEvm(chainId)) {
83
+ if (utils.isHexString(address)) {
83
84
  return EvmAddress.from(address);
84
85
  }
85
86
  return SvmAddress.from(address);
@@ -146,6 +147,11 @@ export class Address {
146
147
  return this.toBytes32();
147
148
  }
148
149
 
150
+ // Converts the address to a Buffer type.
151
+ toBuffer(): Buffer {
152
+ return Buffer.from(this.rawAddress);
153
+ }
154
+
149
155
  // Implements `Hexable` for `Address`. Needed for encoding purposes. This class is treated by default as a bytes32 primitive type, but can change for subclasses.
150
156
  toHexString(): string {
151
157
  return this.toBytes32();
@@ -185,6 +191,16 @@ export class Address {
185
191
  return utils.stripZeros(this.rawAddress).length === 0;
186
192
  }
187
193
 
194
+ // Forces `rawAddress` to become an SvmAddress type. This will only throw if `rawAddress.length > 32`.
195
+ forceSvmAddress(): SvmAddress {
196
+ return SvmAddress.from(this.toBase58());
197
+ }
198
+
199
+ // Forces `rawAddress` to become an EvmAddress type. This will throw if `rawAddress.length > 20`.
200
+ forceEvmAddress(): EvmAddress {
201
+ return EvmAddress.from(this.toEvmAddress());
202
+ }
203
+
188
204
  // Checks if the other address is equivalent to this address.
189
205
  eq(other: Address): boolean {
190
206
  return this.toString() === other.toString();
@@ -223,8 +239,20 @@ export class EvmAddress extends Address {
223
239
  }
224
240
 
225
241
  // Constructs a new EvmAddress type.
226
- static from(hexString: string): EvmAddress {
227
- return new this(utils.arrayify(hexString));
242
+ static from(address: string, encoding: "base16" | "base58" = "base16"): EvmAddress {
243
+ if (encoding === "base16") {
244
+ return new this(utils.arrayify(address));
245
+ }
246
+
247
+ const decodedAddress = bs58.decode(address);
248
+ const padding = decodedAddress.subarray(0, 12);
249
+ const evmAddress = decodedAddress.subarray(12);
250
+
251
+ if (padding.length !== 12 || utils.stripZeros(padding).length !== 0 || evmAddress.length !== 20) {
252
+ throw new Error(`Not a valid base58-encoded EVM address: ${address}`);
253
+ }
254
+
255
+ return new this(evmAddress);
228
256
  }
229
257
  }
230
258
 
@@ -241,12 +269,27 @@ export class SvmAddress extends Address {
241
269
  return this.toBase58();
242
270
  }
243
271
 
272
+ // Small utility to convert an SvmAddress to a Solana Kit branded type.
273
+ toV2Address(): V2Address<string> {
274
+ return this.toBase58() as V2Address<string>;
275
+ }
276
+
277
+ // Forces an SvmAddress to an EVM address string by truncating the leading 12 bytes.
244
278
  override toEvmAddress(): string {
245
279
  return toAddress(`0x${this.toBytes32().slice(-40)}`);
246
280
  }
247
281
 
248
282
  // Constructs a new SvmAddress type.
249
- static from(bs58Address: string): SvmAddress {
250
- return new this(bs58.decode(bs58Address));
283
+ static from(address: string, encoding: "base58" | "base16" = "base58"): SvmAddress {
284
+ if (encoding === "base58") {
285
+ return new this(bs58.decode(address));
286
+ }
287
+
288
+ const decodedAddress = utils.arrayify(address);
289
+ if (decodedAddress.length !== 32) {
290
+ throw new Error(`Not a valid base16-encoded SVM address: ${address}`);
291
+ }
292
+
293
+ return new this(decodedAddress);
251
294
  }
252
295
  }