tapimo 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (786) hide show
  1. package/README.md +10 -7
  2. package/dist/ApiKey.d.ts +3 -0
  3. package/dist/ApiKey.d.ts.map +1 -1
  4. package/dist/ApiKey.js +10 -0
  5. package/dist/ApiKey.js.map +1 -1
  6. package/dist/ApiKeys.d.ts +29 -8
  7. package/dist/ApiKeys.d.ts.map +1 -1
  8. package/dist/ApiKeys.js +24 -5
  9. package/dist/ApiKeys.js.map +1 -1
  10. package/dist/App.d.ts +20680 -15487
  11. package/dist/App.d.ts.map +1 -1
  12. package/dist/App.js +250 -129
  13. package/dist/App.js.map +1 -1
  14. package/dist/Assets.d.ts +10 -0
  15. package/dist/Assets.d.ts.map +1 -1
  16. package/dist/Assets.js +17 -4
  17. package/dist/Assets.js.map +1 -1
  18. package/dist/Scope.d.ts +19 -8
  19. package/dist/Scope.d.ts.map +1 -1
  20. package/dist/Scope.js +25 -9
  21. package/dist/Scope.js.map +1 -1
  22. package/dist/Webhooks.d.ts +1 -1
  23. package/dist/admin/App.d.ts +667 -76
  24. package/dist/admin/App.d.ts.map +1 -1
  25. package/dist/admin/App.js +12 -2
  26. package/dist/admin/App.js.map +1 -1
  27. package/dist/admin/apps/api-keys.d.ts +107 -11
  28. package/dist/admin/apps/api-keys.d.ts.map +1 -1
  29. package/dist/admin/apps/api-keys.js +145 -32
  30. package/dist/admin/apps/api-keys.js.map +1 -1
  31. package/dist/admin/apps/earn-vaults.d.ts +1069 -0
  32. package/dist/admin/apps/earn-vaults.d.ts.map +1 -0
  33. package/dist/admin/apps/earn-vaults.js +409 -0
  34. package/dist/admin/apps/earn-vaults.js.map +1 -0
  35. package/dist/admin/apps/organizations.d.ts +2 -0
  36. package/dist/admin/apps/organizations.d.ts.map +1 -1
  37. package/dist/admin/apps/verified-tokens.d.ts +74 -74
  38. package/dist/admin/ui.generated.d.ts +1 -1
  39. package/dist/admin/ui.generated.d.ts.map +1 -1
  40. package/dist/admin/ui.generated.js +99 -43
  41. package/dist/admin/ui.generated.js.map +1 -1
  42. package/dist/analytics/Analytics.d.ts +4 -0
  43. package/dist/analytics/Analytics.d.ts.map +1 -1
  44. package/dist/analytics/Analytics.js +21 -2
  45. package/dist/analytics/Analytics.js.map +1 -1
  46. package/dist/analytics/tables/requestEvents.d.ts +22 -1
  47. package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
  48. package/dist/analytics/tables/requestEvents.js +59 -39
  49. package/dist/analytics/tables/requestEvents.js.map +1 -1
  50. package/dist/apps/Zones.d.ts +8335 -0
  51. package/dist/apps/Zones.d.ts.map +1 -0
  52. package/dist/apps/Zones.js +38 -0
  53. package/dist/apps/Zones.js.map +1 -0
  54. package/dist/apps/data/App.d.ts +5666 -3934
  55. package/dist/apps/data/App.d.ts.map +1 -1
  56. package/dist/apps/data/App.js +90 -22
  57. package/dist/apps/data/App.js.map +1 -1
  58. package/dist/apps/data/FxOracle.d.ts +1 -1
  59. package/dist/apps/data/FxOracle.d.ts.map +1 -1
  60. package/dist/apps/data/index.d.ts +0 -1
  61. package/dist/apps/data/index.d.ts.map +1 -1
  62. package/dist/apps/data/index.js +0 -1
  63. package/dist/apps/data/index.js.map +1 -1
  64. package/dist/apps/data/routes/activities.d.ts +56 -56
  65. package/dist/apps/data/routes/activities.d.ts.map +1 -1
  66. package/dist/apps/data/routes/activities.js +130 -65
  67. package/dist/apps/data/routes/activities.js.map +1 -1
  68. package/dist/apps/data/routes/addresses.d.ts +65 -65
  69. package/dist/apps/data/routes/balances.d.ts +14 -14
  70. package/dist/apps/data/routes/balances.js +5 -5
  71. package/dist/apps/data/routes/balances.js.map +1 -1
  72. package/dist/apps/data/routes/blocks.d.ts +39 -39
  73. package/dist/apps/data/routes/coingecko.d.ts +54 -54
  74. package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
  75. package/dist/apps/data/routes/coingecko.js +62 -35
  76. package/dist/apps/data/routes/coingecko.js.map +1 -1
  77. package/dist/apps/data/routes/earn.d.ts +2574 -0
  78. package/dist/apps/data/routes/earn.d.ts.map +1 -0
  79. package/dist/apps/data/routes/earn.js +1574 -0
  80. package/dist/apps/data/routes/earn.js.map +1 -0
  81. package/dist/apps/data/routes/exchanges.d.ts +1626 -719
  82. package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
  83. package/dist/apps/data/routes/exchanges.js +656 -193
  84. package/dist/apps/data/routes/exchanges.js.map +1 -1
  85. package/dist/apps/data/routes/fee-amm.d.ts +108 -108
  86. package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
  87. package/dist/apps/data/routes/fee-amm.js +59 -8
  88. package/dist/apps/data/routes/fee-amm.js.map +1 -1
  89. package/dist/apps/data/routes/indexer.d.ts +35 -35
  90. package/dist/apps/data/routes/indexer.d.ts.map +1 -1
  91. package/dist/apps/data/routes/indexer.js +23 -3
  92. package/dist/apps/data/routes/indexer.js.map +1 -1
  93. package/dist/apps/data/routes/receipts.d.ts +33 -33
  94. package/dist/apps/data/routes/receipts.d.ts.map +1 -1
  95. package/dist/apps/data/routes/receipts.js +11 -11
  96. package/dist/apps/data/routes/receipts.js.map +1 -1
  97. package/dist/apps/data/routes/rpc.d.ts +6 -6
  98. package/dist/apps/data/routes/rpc.d.ts.map +1 -1
  99. package/dist/apps/data/routes/rpc.js +214 -22
  100. package/dist/apps/data/routes/rpc.js.map +1 -1
  101. package/dist/apps/data/routes/tokenlist.d.ts +1 -1
  102. package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
  103. package/dist/apps/data/routes/tokenlist.js +39 -8
  104. package/dist/apps/data/routes/tokenlist.js.map +1 -1
  105. package/dist/apps/data/routes/tokens.d.ts +115 -87
  106. package/dist/apps/data/routes/tokens.d.ts.map +1 -1
  107. package/dist/apps/data/routes/tokens.js +194 -91
  108. package/dist/apps/data/routes/tokens.js.map +1 -1
  109. package/dist/apps/data/routes/transactions.d.ts +54 -54
  110. package/dist/apps/data/routes/transactions.d.ts.map +1 -1
  111. package/dist/apps/data/routes/transactions.js +78 -39
  112. package/dist/apps/data/routes/transactions.js.map +1 -1
  113. package/dist/apps/data/routes/transfers.d.ts +76 -27
  114. package/dist/apps/data/routes/transfers.d.ts.map +1 -1
  115. package/dist/apps/data/routes/transfers.js +165 -67
  116. package/dist/apps/data/routes/transfers.js.map +1 -1
  117. package/dist/apps/data/routes/valuation.d.ts +42 -42
  118. package/dist/apps/data/routes/valuation.js +2 -2
  119. package/dist/apps/data/routes/valuation.js.map +1 -1
  120. package/dist/apps/data/routes/verified-tokens.d.ts +36 -36
  121. package/dist/apps/data/routes/webhooks.d.ts +370 -368
  122. package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
  123. package/dist/apps/data/routes/webhooks.js +161 -59
  124. package/dist/apps/data/routes/webhooks.js.map +1 -1
  125. package/dist/apps/data/routes/zones.d.ts +281 -0
  126. package/dist/apps/data/routes/zones.d.ts.map +1 -0
  127. package/dist/apps/data/routes/zones.js +252 -0
  128. package/dist/apps/data/routes/zones.js.map +1 -0
  129. package/dist/apps/docs/reference.js +6 -5
  130. package/dist/apps/docs/reference.js.map +1 -1
  131. package/dist/apps/funding/Access.d.ts +16 -0
  132. package/dist/apps/funding/Access.d.ts.map +1 -0
  133. package/dist/apps/funding/Access.js +22 -0
  134. package/dist/apps/funding/Access.js.map +1 -0
  135. package/dist/apps/funding/App.d.ts +3183 -0
  136. package/dist/apps/funding/App.d.ts.map +1 -0
  137. package/dist/apps/funding/App.js +46 -0
  138. package/dist/apps/funding/App.js.map +1 -0
  139. package/dist/apps/funding/Inventory.d.ts +5 -0
  140. package/dist/apps/funding/Inventory.d.ts.map +1 -0
  141. package/dist/apps/funding/Inventory.js +25 -0
  142. package/dist/apps/funding/Inventory.js.map +1 -0
  143. package/dist/apps/funding/ProviderAttempts.d.ts +5 -0
  144. package/dist/apps/funding/ProviderAttempts.d.ts.map +1 -0
  145. package/dist/apps/funding/ProviderAttempts.js +24 -0
  146. package/dist/apps/funding/ProviderAttempts.js.map +1 -0
  147. package/dist/apps/funding/index.d.ts +2 -0
  148. package/dist/apps/funding/index.d.ts.map +1 -0
  149. package/dist/apps/funding/index.js +2 -0
  150. package/dist/apps/funding/index.js.map +1 -0
  151. package/dist/apps/funding/routes/chains.d.ts +169 -0
  152. package/dist/apps/funding/routes/chains.d.ts.map +1 -0
  153. package/dist/apps/funding/routes/chains.js +80 -0
  154. package/dist/apps/funding/routes/chains.js.map +1 -0
  155. package/dist/apps/funding/routes/deposit-addresses.d.ts +2388 -0
  156. package/dist/apps/funding/routes/deposit-addresses.d.ts.map +1 -0
  157. package/dist/apps/funding/routes/deposit-addresses.js +860 -0
  158. package/dist/apps/funding/routes/deposit-addresses.js.map +1 -0
  159. package/dist/apps/funding/routes/providers.d.ts +91 -0
  160. package/dist/apps/funding/routes/providers.d.ts.map +1 -0
  161. package/dist/apps/funding/routes/providers.js +56 -0
  162. package/dist/apps/funding/routes/providers.js.map +1 -0
  163. package/dist/apps/{data/routes/funding.d.ts → funding/routes/quotes.d.ts} +26 -396
  164. package/dist/apps/funding/routes/quotes.d.ts.map +1 -0
  165. package/dist/apps/funding/routes/quotes.js +188 -0
  166. package/dist/apps/funding/routes/quotes.js.map +1 -0
  167. package/dist/apps/funding/routes/transfers.d.ts +1999 -0
  168. package/dist/apps/funding/routes/transfers.d.ts.map +1 -0
  169. package/dist/apps/funding/routes/transfers.js +614 -0
  170. package/dist/apps/funding/routes/transfers.js.map +1 -0
  171. package/dist/apps/index.d.ts +3 -1
  172. package/dist/apps/index.d.ts.map +1 -1
  173. package/dist/apps/index.js +3 -1
  174. package/dist/apps/index.js.map +1 -1
  175. package/dist/apps/management/App.d.ts +839 -574
  176. package/dist/apps/management/App.d.ts.map +1 -1
  177. package/dist/apps/management/Billing.d.ts +8 -0
  178. package/dist/apps/management/Billing.d.ts.map +1 -1
  179. package/dist/apps/management/Billing.js +12 -0
  180. package/dist/apps/management/Billing.js.map +1 -1
  181. package/dist/apps/management/Error.d.ts +12 -0
  182. package/dist/apps/management/Error.d.ts.map +1 -0
  183. package/dist/apps/management/Error.js +10 -0
  184. package/dist/apps/management/Error.js.map +1 -0
  185. package/dist/apps/management/routes/api-keys.d.ts +296 -19
  186. package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
  187. package/dist/apps/management/routes/api-keys.js +77 -9
  188. package/dist/apps/management/routes/api-keys.js.map +1 -1
  189. package/dist/apps/management/routes/billing.d.ts +119 -119
  190. package/dist/apps/management/routes/faucet.d.ts +35 -35
  191. package/dist/apps/management/routes/invitations.d.ts +17 -17
  192. package/dist/apps/management/routes/invitations.d.ts.map +1 -1
  193. package/dist/apps/management/routes/invitations.js +4 -10
  194. package/dist/apps/management/routes/invitations.js.map +1 -1
  195. package/dist/apps/management/routes/invite-links.d.ts +38 -38
  196. package/dist/apps/management/routes/me.d.ts +6 -6
  197. package/dist/apps/management/routes/members.d.ts +69 -69
  198. package/dist/apps/management/routes/orgs.d.ts +16 -16
  199. package/dist/apps/management/routes/orgs.d.ts.map +1 -1
  200. package/dist/apps/management/routes/orgs.js +2 -8
  201. package/dist/apps/management/routes/orgs.js.map +1 -1
  202. package/dist/apps/management/routes/projects.d.ts +19 -19
  203. package/dist/apps/management/routes/scopes.d.ts +1 -1
  204. package/dist/apps/management/routes/scopes.js +2 -2
  205. package/dist/apps/management/routes/scopes.js.map +1 -1
  206. package/dist/apps/management/routes/usage.d.ts +72 -72
  207. package/dist/apps/management/routes/verified-token-requests.d.ts +18 -18
  208. package/dist/apps/management/routes/webhooks.d.ts +122 -122
  209. package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
  210. package/dist/apps/management/routes/webhooks.js +15 -3
  211. package/dist/apps/management/routes/webhooks.js.map +1 -1
  212. package/dist/apps/mcp.d.ts +2 -3
  213. package/dist/apps/mcp.d.ts.map +1 -1
  214. package/dist/apps/mcp.js +16 -14
  215. package/dist/apps/mcp.js.map +1 -1
  216. package/dist/apps/metadata.d.ts +4 -0
  217. package/dist/apps/metadata.d.ts.map +1 -1
  218. package/dist/apps/metadata.js +10 -0
  219. package/dist/apps/metadata.js.map +1 -1
  220. package/dist/apps/mpp/App.d.ts +57 -58
  221. package/dist/apps/mpp/App.d.ts.map +1 -1
  222. package/dist/apps/mpp/App.js +192 -27
  223. package/dist/apps/mpp/App.js.map +1 -1
  224. package/dist/apps/mpp/Mpp.d.ts +0 -20
  225. package/dist/apps/mpp/Mpp.d.ts.map +1 -1
  226. package/dist/apps/mpp/Mpp.js +0 -24
  227. package/dist/apps/mpp/Mpp.js.map +1 -1
  228. package/dist/apps/mpp/internal/Adapter.d.ts +40 -0
  229. package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -0
  230. package/dist/apps/mpp/internal/Adapter.js +66 -0
  231. package/dist/apps/mpp/internal/Adapter.js.map +1 -0
  232. package/dist/apps/mpp/internal/Error.d.ts +4 -0
  233. package/dist/apps/mpp/internal/Error.d.ts.map +1 -0
  234. package/dist/apps/mpp/internal/Error.js +41 -0
  235. package/dist/apps/mpp/internal/Error.js.map +1 -0
  236. package/dist/apps/mpp/internal/Idempotency.d.ts +33 -0
  237. package/dist/apps/mpp/internal/Idempotency.d.ts.map +1 -0
  238. package/dist/apps/mpp/internal/Idempotency.js +28 -0
  239. package/dist/apps/mpp/internal/Idempotency.js.map +1 -0
  240. package/dist/apps/mpp/internal/Policy.d.ts +46 -0
  241. package/dist/apps/mpp/internal/Policy.d.ts.map +1 -0
  242. package/dist/apps/mpp/internal/Policy.js +57 -0
  243. package/dist/apps/mpp/internal/Policy.js.map +1 -0
  244. package/dist/apps/mpp/internal/ScreenManager.d.ts +27 -0
  245. package/dist/apps/mpp/internal/ScreenManager.d.ts.map +1 -0
  246. package/dist/apps/mpp/internal/ScreenManager.js +18 -0
  247. package/dist/apps/mpp/internal/ScreenManager.js.map +1 -0
  248. package/dist/apps/mpp/internal/Screening.d.ts +35 -0
  249. package/dist/apps/mpp/internal/Screening.d.ts.map +1 -0
  250. package/dist/apps/mpp/internal/Screening.js +20 -0
  251. package/dist/apps/mpp/internal/Screening.js.map +1 -0
  252. package/dist/apps/mpp/internal/Sponsorship.d.ts +36 -0
  253. package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -0
  254. package/dist/apps/mpp/internal/Sponsorship.js +103 -0
  255. package/dist/apps/mpp/internal/Sponsorship.js.map +1 -0
  256. package/dist/apps/mpp/internal/Utils.d.ts +7 -0
  257. package/dist/apps/mpp/internal/Utils.d.ts.map +1 -0
  258. package/dist/apps/mpp/internal/Utils.js +24 -0
  259. package/dist/apps/mpp/internal/Utils.js.map +1 -0
  260. package/dist/apps/relay/App.js +183 -23
  261. package/dist/apps/relay/App.js.map +1 -1
  262. package/dist/apps/relay/Sponsorships.d.ts +4 -0
  263. package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
  264. package/dist/apps/relay/Sponsorships.js +15 -6
  265. package/dist/apps/relay/Sponsorships.js.map +1 -1
  266. package/dist/cloudflare.d.ts +50 -0
  267. package/dist/cloudflare.d.ts.map +1 -1
  268. package/dist/cloudflare.js +178 -0
  269. package/dist/cloudflare.js.map +1 -1
  270. package/dist/db/Db.d.ts +22 -0
  271. package/dist/db/Db.d.ts.map +1 -1
  272. package/dist/db/Db.js +379 -0
  273. package/dist/db/Db.js.map +1 -1
  274. package/dist/db/Schema.d.ts +933 -1
  275. package/dist/db/Schema.d.ts.map +1 -1
  276. package/dist/db/Schema.js +289 -1
  277. package/dist/db/Schema.js.map +1 -1
  278. package/dist/db/tables/earnVaults.d.ts +68 -0
  279. package/dist/db/tables/earnVaults.d.ts.map +1 -0
  280. package/dist/db/tables/earnVaults.js +72 -0
  281. package/dist/db/tables/earnVaults.js.map +1 -0
  282. package/dist/db/tables/fundingCatalog.d.ts +56 -0
  283. package/dist/db/tables/fundingCatalog.d.ts.map +1 -0
  284. package/dist/db/tables/fundingCatalog.js +85 -0
  285. package/dist/db/tables/fundingCatalog.js.map +1 -0
  286. package/dist/db/tables/fundingDepositAddresses.d.ts +172 -0
  287. package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -0
  288. package/dist/db/tables/fundingDepositAddresses.js +218 -0
  289. package/dist/db/tables/fundingDepositAddresses.js.map +1 -0
  290. package/dist/db/tables/fundingDepositRequestObservations.d.ts +45 -0
  291. package/dist/db/tables/fundingDepositRequestObservations.d.ts.map +1 -0
  292. package/dist/db/tables/fundingDepositRequestObservations.js +46 -0
  293. package/dist/db/tables/fundingDepositRequestObservations.js.map +1 -0
  294. package/dist/db/tables/fundingDeposits.d.ts +171 -0
  295. package/dist/db/tables/fundingDeposits.d.ts.map +1 -0
  296. package/dist/db/tables/fundingDeposits.js +182 -0
  297. package/dist/db/tables/fundingDeposits.js.map +1 -0
  298. package/dist/db/tables/fundingIdempotency.d.ts +91 -0
  299. package/dist/db/tables/fundingIdempotency.d.ts.map +1 -0
  300. package/dist/db/tables/fundingIdempotency.js +103 -0
  301. package/dist/db/tables/fundingIdempotency.js.map +1 -0
  302. package/dist/db/tables/fundingTransferEvents.d.ts +12 -0
  303. package/dist/db/tables/fundingTransferEvents.d.ts.map +1 -0
  304. package/dist/db/tables/fundingTransferEvents.js +18 -0
  305. package/dist/db/tables/fundingTransferEvents.js.map +1 -0
  306. package/dist/db/tables/fundingTransferTransactions.d.ts +15 -0
  307. package/dist/db/tables/fundingTransferTransactions.d.ts.map +1 -0
  308. package/dist/db/tables/fundingTransferTransactions.js +27 -0
  309. package/dist/db/tables/fundingTransferTransactions.js.map +1 -0
  310. package/dist/db/tables/fundingTransfers.d.ts +82 -0
  311. package/dist/db/tables/fundingTransfers.d.ts.map +1 -0
  312. package/dist/db/tables/fundingTransfers.js +89 -0
  313. package/dist/db/tables/fundingTransfers.js.map +1 -0
  314. package/dist/db/tables/organizations.d.ts +8 -0
  315. package/dist/db/tables/organizations.d.ts.map +1 -1
  316. package/dist/db/tables/organizations.js +16 -0
  317. package/dist/db/tables/organizations.js.map +1 -1
  318. package/dist/db/tables/projects.d.ts +8 -0
  319. package/dist/db/tables/projects.d.ts.map +1 -1
  320. package/dist/db/tables/projects.js +16 -0
  321. package/dist/db/tables/projects.js.map +1 -1
  322. package/dist/db/tables/requestUsage.d.ts +13 -0
  323. package/dist/db/tables/requestUsage.d.ts.map +1 -1
  324. package/dist/db/tables/requestUsage.js +16 -0
  325. package/dist/db/tables/requestUsage.js.map +1 -1
  326. package/dist/db/tables/sponsoredTransactions.d.ts +2 -2
  327. package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
  328. package/dist/db/tables/sponsoredTransactions.js +1 -1
  329. package/dist/db/tables/sponsoredTransactions.js.map +1 -1
  330. package/dist/db/tables/users.d.ts +8 -0
  331. package/dist/db/tables/users.d.ts.map +1 -1
  332. package/dist/db/tables/users.js +16 -0
  333. package/dist/db/tables/users.js.map +1 -1
  334. package/dist/db/tables/verifiedTokens.d.ts +14 -7
  335. package/dist/db/tables/verifiedTokens.d.ts.map +1 -1
  336. package/dist/db/tables/verifiedTokens.js +9 -7
  337. package/dist/db/tables/verifiedTokens.js.map +1 -1
  338. package/dist/db/tables/webhookSubscriptions.d.ts +31 -1
  339. package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
  340. package/dist/db/tables/webhookSubscriptions.js +24 -3
  341. package/dist/db/tables/webhookSubscriptions.js.map +1 -1
  342. package/dist/handlers/relay.js +108 -108
  343. package/dist/handlers/relay.js.map +1 -1
  344. package/dist/internal/Auth.d.ts +37 -11
  345. package/dist/internal/Auth.d.ts.map +1 -1
  346. package/dist/internal/Auth.js +75 -16
  347. package/dist/internal/Auth.js.map +1 -1
  348. package/dist/internal/Cache.d.ts.map +1 -1
  349. package/dist/internal/Cache.js +17 -11
  350. package/dist/internal/Cache.js.map +1 -1
  351. package/dist/internal/Cursor.js +1 -1
  352. package/dist/internal/Cursor.js.map +1 -1
  353. package/dist/internal/EarnRates.d.ts +89 -0
  354. package/dist/internal/EarnRates.d.ts.map +1 -0
  355. package/dist/internal/EarnRates.js +266 -0
  356. package/dist/internal/EarnRates.js.map +1 -0
  357. package/dist/internal/EarnVaults.d.ts +171 -0
  358. package/dist/internal/EarnVaults.d.ts.map +1 -0
  359. package/dist/internal/EarnVaults.js +547 -0
  360. package/dist/internal/EarnVaults.js.map +1 -0
  361. package/dist/internal/EdgeCache.d.ts +10 -3
  362. package/dist/internal/EdgeCache.d.ts.map +1 -1
  363. package/dist/internal/EdgeCache.js +43 -11
  364. package/dist/internal/EdgeCache.js.map +1 -1
  365. package/dist/internal/Id.d.ts +11 -0
  366. package/dist/internal/Id.d.ts.map +1 -1
  367. package/dist/internal/Id.js +13 -0
  368. package/dist/internal/Id.js.map +1 -1
  369. package/dist/internal/Idempotency.d.ts +83 -0
  370. package/dist/internal/Idempotency.d.ts.map +1 -0
  371. package/dist/internal/Idempotency.js +113 -0
  372. package/dist/internal/Idempotency.js.map +1 -0
  373. package/dist/internal/IpAllowlist.d.ts +15 -0
  374. package/dist/internal/IpAllowlist.d.ts.map +1 -0
  375. package/dist/internal/IpAllowlist.js +27 -0
  376. package/dist/internal/IpAllowlist.js.map +1 -0
  377. package/dist/internal/Log.d.ts +64 -9
  378. package/dist/internal/Log.d.ts.map +1 -1
  379. package/dist/internal/Log.js +29 -7
  380. package/dist/internal/Log.js.map +1 -1
  381. package/dist/internal/MetricSink.d.ts.map +1 -1
  382. package/dist/internal/MetricSink.js +47 -1
  383. package/dist/internal/MetricSink.js.map +1 -1
  384. package/dist/internal/OpenApi.d.ts +2 -2
  385. package/dist/internal/OpenApi.d.ts.map +1 -1
  386. package/dist/internal/OpenApi.js +4 -1
  387. package/dist/internal/OpenApi.js.map +1 -1
  388. package/dist/internal/Provider.d.ts +14 -0
  389. package/dist/internal/Provider.d.ts.map +1 -0
  390. package/dist/internal/Provider.js +5 -0
  391. package/dist/internal/Provider.js.map +1 -0
  392. package/dist/internal/Schema.d.ts +6 -1
  393. package/dist/internal/Schema.d.ts.map +1 -1
  394. package/dist/internal/Schema.js +20 -11
  395. package/dist/internal/Schema.js.map +1 -1
  396. package/dist/internal/Store.d.ts +6 -0
  397. package/dist/internal/Store.d.ts.map +1 -1
  398. package/dist/internal/Store.js +35 -0
  399. package/dist/internal/Store.js.map +1 -1
  400. package/dist/internal/Tidx.d.ts +49 -24
  401. package/dist/internal/Tidx.d.ts.map +1 -1
  402. package/dist/internal/Tidx.js +90 -12
  403. package/dist/internal/Tidx.js.map +1 -1
  404. package/dist/internal/Viem.d.ts +90 -65
  405. package/dist/internal/Viem.d.ts.map +1 -1
  406. package/dist/internal/Viem.js +90 -12
  407. package/dist/internal/Viem.js.map +1 -1
  408. package/dist/internal/WebhookDestination.d.ts.map +1 -1
  409. package/dist/internal/WebhookDestination.js +34 -28
  410. package/dist/internal/WebhookDestination.js.map +1 -1
  411. package/dist/internal/Webhooks.d.ts +9 -0
  412. package/dist/internal/Webhooks.d.ts.map +1 -1
  413. package/dist/internal/Webhooks.js +15 -10
  414. package/dist/internal/Webhooks.js.map +1 -1
  415. package/dist/internal/exchange/Provider.d.ts +219 -0
  416. package/dist/internal/exchange/Provider.d.ts.map +1 -0
  417. package/dist/internal/exchange/Provider.js +117 -0
  418. package/dist/internal/exchange/Provider.js.map +1 -0
  419. package/dist/internal/exchange/index.d.ts +2 -0
  420. package/dist/internal/exchange/index.d.ts.map +1 -0
  421. package/dist/internal/exchange/index.js +2 -0
  422. package/dist/internal/exchange/index.js.map +1 -0
  423. package/dist/internal/exchange/providers/uniswap.d.ts +57 -0
  424. package/dist/internal/exchange/providers/uniswap.d.ts.map +1 -0
  425. package/dist/internal/exchange/providers/uniswap.js +553 -0
  426. package/dist/internal/exchange/providers/uniswap.js.map +1 -0
  427. package/dist/internal/funding/Action.d.ts +55 -0
  428. package/dist/internal/funding/Action.d.ts.map +1 -0
  429. package/dist/internal/funding/Action.js +74 -0
  430. package/dist/internal/funding/Action.js.map +1 -0
  431. package/dist/internal/funding/Catalog.d.ts +107 -0
  432. package/dist/internal/funding/Catalog.d.ts.map +1 -0
  433. package/dist/internal/funding/Catalog.js +270 -0
  434. package/dist/internal/funding/Catalog.js.map +1 -0
  435. package/dist/internal/funding/Chain.d.ts +76 -0
  436. package/dist/internal/funding/Chain.d.ts.map +1 -0
  437. package/dist/internal/funding/Chain.js +38 -0
  438. package/dist/internal/funding/Chain.js.map +1 -0
  439. package/dist/internal/funding/Deposit.d.ts +408 -0
  440. package/dist/internal/funding/Deposit.d.ts.map +1 -0
  441. package/dist/internal/funding/Deposit.js +318 -0
  442. package/dist/internal/funding/Deposit.js.map +1 -0
  443. package/dist/internal/funding/DepositAddress.d.ts +345 -0
  444. package/dist/internal/funding/DepositAddress.d.ts.map +1 -0
  445. package/dist/internal/funding/DepositAddress.js +189 -0
  446. package/dist/internal/funding/DepositAddress.js.map +1 -0
  447. package/dist/internal/funding/Evidence.d.ts +48 -0
  448. package/dist/internal/funding/Evidence.d.ts.map +1 -0
  449. package/dist/internal/funding/Evidence.js +315 -0
  450. package/dist/internal/funding/Evidence.js.map +1 -0
  451. package/dist/internal/funding/Provider.d.ts +1288 -0
  452. package/dist/internal/funding/Provider.d.ts.map +1 -0
  453. package/dist/internal/funding/Provider.js +1086 -0
  454. package/dist/internal/funding/Provider.js.map +1 -0
  455. package/dist/internal/funding/Reconciliation.d.ts +127 -0
  456. package/dist/internal/funding/Reconciliation.d.ts.map +1 -0
  457. package/dist/internal/funding/Reconciliation.js +885 -0
  458. package/dist/internal/funding/Reconciliation.js.map +1 -0
  459. package/dist/internal/funding/Route.d.ts +21 -0
  460. package/dist/internal/funding/Route.d.ts.map +1 -0
  461. package/dist/internal/funding/Route.js +5 -0
  462. package/dist/internal/funding/Route.js.map +1 -0
  463. package/dist/internal/funding/SourceObservation.d.ts +108 -0
  464. package/dist/internal/funding/SourceObservation.d.ts.map +1 -0
  465. package/dist/internal/funding/SourceObservation.js +143 -0
  466. package/dist/internal/funding/SourceObservation.js.map +1 -0
  467. package/dist/internal/funding/Subsidy.d.ts +113 -0
  468. package/dist/internal/funding/Subsidy.d.ts.map +1 -0
  469. package/dist/internal/funding/Subsidy.js +138 -0
  470. package/dist/internal/funding/Subsidy.js.map +1 -0
  471. package/dist/internal/funding/Token.d.ts +41 -0
  472. package/dist/internal/funding/Token.d.ts.map +1 -0
  473. package/dist/internal/funding/Token.js +22 -0
  474. package/dist/internal/funding/Token.js.map +1 -0
  475. package/dist/internal/funding/Transfer.d.ts +643 -0
  476. package/dist/internal/funding/Transfer.d.ts.map +1 -0
  477. package/dist/internal/funding/Transfer.js +332 -0
  478. package/dist/internal/funding/Transfer.js.map +1 -0
  479. package/dist/internal/funding/index.d.ts +14 -0
  480. package/dist/internal/funding/index.d.ts.map +1 -0
  481. package/dist/internal/funding/index.js +14 -0
  482. package/dist/internal/funding/index.js.map +1 -0
  483. package/dist/internal/funding/providers/across.d.ts +21 -0
  484. package/dist/internal/funding/providers/across.d.ts.map +1 -0
  485. package/dist/internal/funding/providers/across.js +117 -0
  486. package/dist/internal/funding/providers/across.js.map +1 -0
  487. package/dist/internal/funding/providers/relay.d.ts +88 -0
  488. package/dist/internal/funding/providers/relay.d.ts.map +1 -0
  489. package/dist/internal/funding/providers/relay.js +871 -0
  490. package/dist/internal/funding/providers/relay.js.map +1 -0
  491. package/dist/internal/funding/providers/rhino.d.ts +15 -0
  492. package/dist/internal/funding/providers/rhino.d.ts.map +1 -0
  493. package/dist/internal/funding/providers/rhino.js +116 -0
  494. package/dist/internal/funding/providers/rhino.js.map +1 -0
  495. package/dist/internal/funding/providers/squid.d.ts +19 -0
  496. package/dist/internal/funding/providers/squid.d.ts.map +1 -0
  497. package/dist/internal/funding/providers/squid.js +120 -0
  498. package/dist/internal/funding/providers/squid.js.map +1 -0
  499. package/dist/internal/funding/providers/symbiosis.d.ts +20 -0
  500. package/dist/internal/funding/providers/symbiosis.d.ts.map +1 -0
  501. package/dist/internal/funding/providers/symbiosis.js +176 -0
  502. package/dist/internal/funding/providers/symbiosis.js.map +1 -0
  503. package/dist/internal/index.d.ts +5 -1
  504. package/dist/internal/index.d.ts.map +1 -1
  505. package/dist/internal/index.js +5 -1
  506. package/dist/internal/index.js.map +1 -1
  507. package/dist/internal/webhookDestinations/url.js +61 -57
  508. package/dist/internal/webhookDestinations/url.js.map +1 -1
  509. package/dist/providers/index.d.ts +43 -0
  510. package/dist/providers/index.d.ts.map +1 -0
  511. package/dist/providers/index.js +19 -0
  512. package/dist/providers/index.js.map +1 -0
  513. package/package.json +10 -5
  514. package/src/ApiKey.test.ts +35 -0
  515. package/src/ApiKey.ts +27 -0
  516. package/src/ApiKeys.test.ts +40 -7
  517. package/src/ApiKeys.ts +46 -10
  518. package/src/App.test.ts +108 -15
  519. package/src/App.ts +296 -138
  520. package/src/Assets.ts +29 -4
  521. package/src/Client.test-d.ts +809 -37
  522. package/src/Scope.test.ts +19 -0
  523. package/src/Scope.ts +28 -11
  524. package/src/Webhooks.test.ts +25 -0
  525. package/src/Webhooks.ts +1 -1
  526. package/src/admin/App.test.ts +9 -2
  527. package/src/admin/App.ts +32 -9
  528. package/src/admin/apps/api-keys.test.ts +190 -22
  529. package/src/admin/apps/api-keys.ts +170 -28
  530. package/src/admin/apps/earn-vaults.test.ts +338 -0
  531. package/src/admin/apps/earn-vaults.ts +572 -0
  532. package/src/admin/apps/scopes.test.ts +16 -1
  533. package/src/admin/ui/plugin.ts +2 -2
  534. package/src/admin/ui/src/components/EarnVaultForm.tsx +137 -0
  535. package/src/admin/ui/src/components/MobileProfile.tsx +2 -2
  536. package/src/admin/ui/src/components/Page.tsx +1 -1
  537. package/src/admin/ui/src/components/ThemeToggle.tsx +1 -1
  538. package/src/admin/ui/src/lib/api-keys.ts +37 -7
  539. package/src/admin/ui/src/lib/client.ts +1 -1
  540. package/src/admin/ui/src/lib/config.ts +1 -1
  541. package/src/admin/ui/src/lib/early-access.ts +8 -9
  542. package/src/admin/ui/src/lib/earn-vaults.ts +207 -0
  543. package/src/admin/ui/src/lib/format.ts +13 -0
  544. package/src/admin/ui/src/lib/organizations.test.ts +14 -4
  545. package/src/admin/ui/src/lib/organizations.ts +7 -1
  546. package/src/admin/ui/src/lib/response.ts +22 -0
  547. package/src/admin/ui/src/lib/scopes.test.ts +19 -11
  548. package/src/admin/ui/src/lib/scopes.ts +28 -7
  549. package/src/admin/ui/src/lib/verified-tokens.ts +10 -9
  550. package/src/admin/ui/src/routeTree.gen.ts +70 -7
  551. package/src/admin/ui/src/router.tsx +2 -2
  552. package/src/admin/ui/src/routes/__root.tsx +9 -8
  553. package/src/admin/ui/src/routes/api-keys.tsx +475 -64
  554. package/src/admin/ui/src/routes/early-access.tsx +5 -12
  555. package/src/admin/ui/src/routes/earn.vaults.tsx +348 -0
  556. package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +154 -0
  557. package/src/admin/ui/src/routes/earn.vaults_.new.tsx +190 -0
  558. package/src/admin/ui/src/routes/organizations.tsx +4 -7
  559. package/src/admin/ui/src/routes/organizations_.$orgId.tsx +56 -54
  560. package/src/admin/ui/src/routes/verified-tokens.tsx +4 -4
  561. package/src/admin/ui/vite.config.ts +4 -1
  562. package/src/admin/ui.generated.ts +113 -43
  563. package/src/analytics/Analytics.test.ts +69 -10
  564. package/src/analytics/Analytics.ts +24 -1
  565. package/src/analytics/tables/requestEvents.ts +79 -37
  566. package/src/apps/Zones.test.ts +33 -0
  567. package/src/apps/Zones.ts +40 -0
  568. package/src/apps/composition.test.ts +184 -3
  569. package/src/apps/data/App.test.ts +28 -23
  570. package/src/apps/data/App.ts +95 -36
  571. package/src/apps/data/FxOracle.ts +1 -1
  572. package/src/apps/data/index.ts +0 -1
  573. package/src/apps/data/routes/activities.test.ts +82 -6
  574. package/src/apps/data/routes/activities.ts +131 -71
  575. package/src/apps/data/routes/balances.test.ts +50 -37
  576. package/src/apps/data/routes/balances.ts +5 -5
  577. package/src/apps/data/routes/blocks.test.ts +2 -0
  578. package/src/apps/data/routes/coingecko.test.ts +22 -0
  579. package/src/apps/data/routes/coingecko.ts +84 -48
  580. package/src/apps/data/routes/earn.test.ts +1391 -0
  581. package/src/apps/data/routes/earn.ts +2188 -0
  582. package/src/apps/data/routes/exchanges.test.ts +82 -33
  583. package/src/apps/data/routes/exchanges.ts +842 -227
  584. package/src/apps/data/routes/fee-amm.test.ts +4 -6
  585. package/src/apps/data/routes/fee-amm.ts +69 -12
  586. package/src/apps/data/routes/indexer.test.ts +43 -34
  587. package/src/apps/data/routes/indexer.ts +21 -3
  588. package/src/apps/data/routes/receipts.test.ts +5 -3
  589. package/src/apps/data/routes/receipts.ts +13 -11
  590. package/src/apps/data/routes/rpc.test.ts +446 -28
  591. package/src/apps/data/routes/rpc.ts +245 -25
  592. package/src/apps/data/routes/tokenlist.ts +72 -19
  593. package/src/apps/data/routes/tokens.test.ts +6 -8
  594. package/src/apps/data/routes/tokens.ts +258 -86
  595. package/src/apps/data/routes/transactions.test.ts +2 -0
  596. package/src/apps/data/routes/transactions.ts +77 -42
  597. package/src/apps/data/routes/transfers.test.ts +166 -4
  598. package/src/apps/data/routes/transfers.ts +216 -78
  599. package/src/apps/data/routes/valuation.test.ts +62 -9
  600. package/src/apps/data/routes/valuation.ts +2 -2
  601. package/src/apps/data/routes/webhooks.test.ts +386 -43
  602. package/src/apps/data/routes/webhooks.ts +172 -71
  603. package/src/apps/data/routes/zones.test.ts +473 -0
  604. package/src/apps/data/routes/zones.ts +338 -0
  605. package/src/apps/docs/reference.ts +8 -6
  606. package/src/apps/funding/Access.ts +26 -0
  607. package/src/apps/funding/App.test.ts +78 -0
  608. package/src/apps/funding/App.ts +63 -0
  609. package/src/apps/funding/Inventory.ts +30 -0
  610. package/src/apps/funding/ProviderAttempts.ts +26 -0
  611. package/src/apps/funding/index.ts +1 -0
  612. package/src/apps/funding/routes/chains.test.ts +78 -0
  613. package/src/apps/funding/routes/chains.ts +101 -0
  614. package/src/apps/funding/routes/deposit-addresses.test.ts +1628 -0
  615. package/src/apps/funding/routes/deposit-addresses.ts +1015 -0
  616. package/src/apps/funding/routes/providers.test.ts +165 -0
  617. package/src/apps/funding/routes/providers.ts +73 -0
  618. package/src/apps/funding/routes/quotes.test.ts +511 -0
  619. package/src/apps/funding/routes/quotes.ts +205 -0
  620. package/src/apps/funding/routes/transfers.test.ts +1255 -0
  621. package/src/apps/funding/routes/transfers.ts +704 -0
  622. package/src/apps/index.ts +3 -1
  623. package/src/apps/management/Billing.test.ts +29 -0
  624. package/src/apps/management/Billing.ts +23 -0
  625. package/src/apps/management/Error.ts +12 -0
  626. package/src/apps/management/routes/api-keys.test.ts +103 -3
  627. package/src/apps/management/routes/api-keys.ts +98 -10
  628. package/src/apps/management/routes/invitations.ts +4 -11
  629. package/src/apps/management/routes/orgs.ts +2 -9
  630. package/src/apps/management/routes/scopes.test.ts +7 -2
  631. package/src/apps/management/routes/scopes.ts +2 -2
  632. package/src/apps/management/routes/webhooks.test.ts +6 -1
  633. package/src/apps/management/routes/webhooks.ts +15 -3
  634. package/src/apps/mcp.test.ts +17 -2
  635. package/src/apps/mcp.ts +18 -13
  636. package/src/apps/metadata.ts +12 -0
  637. package/src/apps/mpp/App.ts +276 -29
  638. package/src/apps/mpp/Mpp.test.ts +631 -26
  639. package/src/apps/mpp/Mpp.ts +0 -42
  640. package/src/apps/mpp/internal/Adapter.ts +108 -3
  641. package/src/apps/mpp/internal/Error.test.ts +33 -0
  642. package/src/apps/mpp/internal/Error.ts +44 -6
  643. package/src/apps/mpp/internal/Idempotency.test.ts +213 -0
  644. package/src/apps/mpp/internal/Idempotency.ts +59 -5
  645. package/src/apps/mpp/internal/Policy.test.ts +128 -0
  646. package/src/apps/mpp/internal/Policy.ts +98 -0
  647. package/src/apps/mpp/internal/ScreenManager.test.ts +68 -0
  648. package/src/apps/mpp/internal/ScreenManager.ts +41 -0
  649. package/src/apps/mpp/internal/Screening.ts +40 -3
  650. package/src/apps/mpp/internal/Sponsorship.ts +144 -0
  651. package/src/apps/mpp/internal/Utils.ts +30 -0
  652. package/src/apps/relay/App.test.ts +493 -62
  653. package/src/apps/relay/App.ts +233 -23
  654. package/src/apps/relay/Sponsorships.test.ts +49 -0
  655. package/src/apps/relay/Sponsorships.ts +18 -6
  656. package/src/cloudflare.ts +279 -0
  657. package/src/db/Db.ts +501 -0
  658. package/src/db/Schema.ts +349 -2
  659. package/src/db/tables/earnVaults.test.ts +185 -0
  660. package/src/db/tables/earnVaults.ts +151 -0
  661. package/src/db/tables/fundingCatalog.test.ts +108 -0
  662. package/src/db/tables/fundingCatalog.ts +157 -0
  663. package/src/db/tables/fundingDepositAddresses.test.ts +580 -0
  664. package/src/db/tables/fundingDepositAddresses.ts +404 -0
  665. package/src/db/tables/fundingDepositRequestObservations.test.ts +106 -0
  666. package/src/db/tables/fundingDepositRequestObservations.ts +99 -0
  667. package/src/db/tables/fundingDeposits.test.ts +399 -0
  668. package/src/db/tables/fundingDeposits.ts +373 -0
  669. package/src/db/tables/fundingIdempotency.test.ts +182 -0
  670. package/src/db/tables/fundingIdempotency.ts +180 -0
  671. package/src/db/tables/fundingTransferEvents.ts +28 -0
  672. package/src/db/tables/fundingTransferTransactions.test.ts +69 -0
  673. package/src/db/tables/fundingTransferTransactions.ts +37 -0
  674. package/src/db/tables/fundingTransfers.test.ts +89 -0
  675. package/src/db/tables/fundingTransfers.ts +153 -0
  676. package/src/db/tables/organizations.ts +16 -0
  677. package/src/db/tables/projects.ts +16 -0
  678. package/src/db/tables/requestUsage.ts +23 -0
  679. package/src/db/tables/sponsoredTransactions.test.ts +11 -0
  680. package/src/db/tables/sponsoredTransactions.ts +3 -3
  681. package/src/db/tables/users.ts +16 -0
  682. package/src/db/tables/verifiedTokens.ts +19 -14
  683. package/src/db/tables/webhookSubscriptions.ts +58 -3
  684. package/src/handlers/relay.test.ts +2 -0
  685. package/src/handlers/relay.ts +95 -99
  686. package/src/internal/Auth.test.ts +225 -5
  687. package/src/internal/Auth.ts +109 -20
  688. package/src/internal/Cache.test.ts +37 -3
  689. package/src/internal/Cache.ts +14 -10
  690. package/src/internal/Cursor.test.ts +2 -2
  691. package/src/internal/Cursor.ts +1 -1
  692. package/src/internal/EarnRates.test.ts +125 -0
  693. package/src/internal/EarnRates.ts +409 -0
  694. package/src/internal/EarnVaults.test.ts +195 -0
  695. package/src/internal/EarnVaults.ts +876 -0
  696. package/src/internal/EdgeCache.test.ts +26 -7
  697. package/src/internal/EdgeCache.ts +48 -9
  698. package/src/internal/Id.ts +14 -0
  699. package/src/internal/Idempotency.test.ts +109 -0
  700. package/src/internal/Idempotency.ts +237 -0
  701. package/src/internal/IpAllowlist.test.ts +52 -0
  702. package/src/internal/IpAllowlist.ts +39 -0
  703. package/src/internal/Log.test-d.ts +41 -8
  704. package/src/internal/Log.test.ts +196 -9
  705. package/src/internal/Log.ts +124 -17
  706. package/src/internal/MetricSink.test.ts +244 -4
  707. package/src/internal/MetricSink.ts +51 -1
  708. package/src/internal/OpenApi.ts +4 -1
  709. package/src/internal/Provider.test.ts +17 -0
  710. package/src/internal/Provider.ts +17 -0
  711. package/src/internal/Schema.ts +27 -17
  712. package/src/internal/Store.test.ts +25 -0
  713. package/src/internal/Store.ts +46 -0
  714. package/src/internal/Tidx.local.test.ts +78 -3
  715. package/src/internal/Tidx.test.ts +240 -18
  716. package/src/internal/Tidx.ts +129 -33
  717. package/src/internal/VerifiedTokens.test.ts +15 -0
  718. package/src/internal/Viem.test.ts +198 -17
  719. package/src/internal/Viem.ts +127 -28
  720. package/src/internal/WebhookDestination.ts +25 -23
  721. package/src/internal/Webhooks.test.ts +59 -0
  722. package/src/internal/Webhooks.ts +34 -10
  723. package/src/internal/exchange/Provider.test.ts +216 -0
  724. package/src/internal/exchange/Provider.ts +326 -0
  725. package/src/internal/exchange/index.test.ts +6 -0
  726. package/src/internal/exchange/index.ts +1 -0
  727. package/src/internal/exchange/providers/uniswap.test.ts +122 -0
  728. package/src/internal/exchange/providers/uniswap.ts +682 -0
  729. package/src/internal/funding/Action.test.ts +138 -0
  730. package/src/internal/funding/Action.ts +117 -0
  731. package/src/internal/funding/Catalog.test.ts +311 -0
  732. package/src/internal/funding/Catalog.ts +347 -0
  733. package/src/internal/funding/Chain.test.ts +79 -0
  734. package/src/internal/funding/Chain.ts +120 -0
  735. package/src/internal/funding/Deposit.test.ts +26 -0
  736. package/src/internal/funding/Deposit.ts +522 -0
  737. package/src/internal/funding/DepositAddress.test.ts +18 -0
  738. package/src/internal/funding/DepositAddress.ts +312 -0
  739. package/src/internal/funding/Evidence.test.ts +297 -0
  740. package/src/internal/funding/Evidence.ts +425 -0
  741. package/src/internal/funding/Provider.test.ts +1328 -0
  742. package/src/internal/funding/Provider.ts +1911 -0
  743. package/src/internal/funding/Reconciliation.local.test.ts +511 -0
  744. package/src/internal/funding/Reconciliation.test.ts +3037 -0
  745. package/src/internal/funding/Reconciliation.ts +1202 -0
  746. package/src/internal/funding/Route.test.ts +66 -0
  747. package/src/internal/funding/Route.ts +29 -0
  748. package/src/internal/funding/SourceObservation.test.ts +301 -0
  749. package/src/internal/funding/SourceObservation.ts +267 -0
  750. package/src/internal/funding/Subsidy.local.test.ts +152 -0
  751. package/src/internal/funding/Subsidy.test.ts +75 -0
  752. package/src/internal/funding/Subsidy.ts +260 -0
  753. package/src/internal/funding/Token.test.ts +47 -0
  754. package/src/internal/funding/Token.ts +59 -0
  755. package/src/internal/funding/Transfer.test.ts +369 -0
  756. package/src/internal/funding/Transfer.ts +522 -0
  757. package/src/internal/funding/index.test.ts +21 -0
  758. package/src/internal/funding/index.ts +13 -0
  759. package/src/internal/funding/providers/across.ts +149 -0
  760. package/src/{apps/data/FundingQuoteProviders.test.ts → internal/funding/providers/index.test.ts} +178 -157
  761. package/src/internal/funding/providers/relay.test.ts +564 -0
  762. package/src/internal/funding/providers/relay.ts +1060 -0
  763. package/src/internal/funding/providers/rhino.ts +139 -0
  764. package/src/internal/funding/providers/squid.ts +151 -0
  765. package/src/internal/funding/providers/symbiosis.ts +221 -0
  766. package/src/internal/index.test.ts +5 -1
  767. package/src/internal/index.ts +5 -1
  768. package/src/internal/webhookDestinations/url.ts +49 -45
  769. package/src/providers/index.test.ts +14 -0
  770. package/src/providers/index.ts +54 -0
  771. package/dist/apps/data/FundingQuoteProviders.d.ts +0 -174
  772. package/dist/apps/data/FundingQuoteProviders.d.ts.map +0 -1
  773. package/dist/apps/data/FundingQuoteProviders.js +0 -775
  774. package/dist/apps/data/FundingQuoteProviders.js.map +0 -1
  775. package/dist/apps/data/routes/funding.d.ts.map +0 -1
  776. package/dist/apps/data/routes/funding.js +0 -410
  777. package/dist/apps/data/routes/funding.js.map +0 -1
  778. package/dist/internal/FundingQuotes.d.ts +0 -864
  779. package/dist/internal/FundingQuotes.d.ts.map +0 -1
  780. package/dist/internal/FundingQuotes.js +0 -672
  781. package/dist/internal/FundingQuotes.js.map +0 -1
  782. package/src/apps/data/FundingQuoteProviders.ts +0 -1043
  783. package/src/apps/data/routes/funding.test.ts +0 -503
  784. package/src/apps/data/routes/funding.ts +0 -604
  785. package/src/internal/FundingQuotes.test.ts +0 -456
  786. package/src/internal/FundingQuotes.ts +0 -944
@@ -0,0 +1,3037 @@
1
+ import * as NodeBuffer from 'node:buffer'
2
+
3
+ import { AbiEvent, AbiFunction, AbiParameters, Address, Hex } from 'ox'
4
+
5
+ import * as Metrics from '../../Metrics.js'
6
+ import * as FundingCatalog from '../../db/tables/fundingCatalog.js'
7
+ import * as FundingDepositAddresses from '../../db/tables/fundingDepositAddresses.js'
8
+ import * as FundingDepositRequestObservations from '../../db/tables/fundingDepositRequestObservations.js'
9
+ import * as FundingDeposits from '../../db/tables/fundingDeposits.js'
10
+ import * as TestApp from '../../../test/App.js'
11
+ import * as TestFunding from '../../../test/Funding.js'
12
+ import * as TestRelay from '../../../test/Relay.js'
13
+ import * as Chain from './Chain.js'
14
+ import * as Deposit from './Deposit.js'
15
+ import * as DepositAddress from './DepositAddress.js'
16
+ import * as Evidence from './Evidence.js'
17
+ import * as Provider from './Provider.js'
18
+ import * as Reconciliation from './Reconciliation.js'
19
+ import * as Relay from './providers/relay.js'
20
+
21
+ const db = TestApp.database()
22
+ const transferTopic = AbiEvent.getSelector('event Transfer(address,address,uint256)')
23
+
24
+ describe('createTracker', () => {
25
+ test('keeps Relay success pending without destination evidence', async () => {
26
+ const route = TestFunding.transferSnapshot()
27
+ const depositAddress = `0x${'44'.repeat(20)}`
28
+ const sourceTransactionHash = `0x${'aa'.repeat(32)}`
29
+ const providerTransactionHash = `0x${'cc'.repeat(32)}`
30
+ const address = await DepositAddress.create(db, {
31
+ apiKeyId: 'key_reconciliation',
32
+ deliveryStrategy: 'provider',
33
+ environment: 'production',
34
+ now: new Date('2026-01-01T00:00:00.000Z'),
35
+ orgId: 'org_reconciliation',
36
+ providerOutputToken: route.destinationToken,
37
+ snapshot: {
38
+ address: depositAddress,
39
+ destinationChain: route.destinationChain,
40
+ destinationToken: route.destinationToken,
41
+ provider: { id: 'relay', name: 'Relay' },
42
+ recipient: route.recipient,
43
+ refundAddress: `0x${'55'.repeat(20)}`,
44
+ sourceChain: route.sourceChain,
45
+ sourceToken: route.sourceToken,
46
+ subsidize: false,
47
+ },
48
+ })
49
+ const counts: Parameters<Metrics.Metrics['count']>[] = []
50
+ const metrics = Metrics.from({
51
+ count(...parameters) {
52
+ counts.push(parameters)
53
+ },
54
+ flush() {},
55
+ gauge() {},
56
+ histogram() {},
57
+ })
58
+ const server = await TestRelay.createServer(async (request, response) => {
59
+ if (request.method === 'GET') {
60
+ response.writeHead(200, { 'content-type': 'application/json' })
61
+ response.end(
62
+ JSON.stringify({
63
+ requests: [
64
+ {
65
+ createdAt: '2026-01-01T00:01:00.000Z',
66
+ data: {
67
+ inTxs: [{ txHash: providerTransactionHash }],
68
+ outTxs: [],
69
+ },
70
+ depositAddress: { depositTxHash: sourceTransactionHash },
71
+ id: 'relay-child-request',
72
+ status: 'success',
73
+ updatedAt: '2026-01-01T00:02:00.000Z',
74
+ },
75
+ ],
76
+ }),
77
+ )
78
+ return
79
+ }
80
+
81
+ const chunks: Uint8Array[] = []
82
+ for await (const chunk of request) chunks.push(chunk)
83
+ const body = JSON.parse(NodeBuffer.Buffer.concat(chunks).toString()) as {
84
+ id: number
85
+ method: string
86
+ params?: readonly string[] | undefined
87
+ }
88
+ const hash = body.params?.[0]
89
+ const result =
90
+ body.method === 'eth_blockNumber'
91
+ ? '0x100'
92
+ : {
93
+ blockNumber: '0x80',
94
+ logs: [
95
+ hash === sourceTransactionHash
96
+ ? transferLog({
97
+ amount: 1_000_000n,
98
+ recipient: depositAddress,
99
+ sender: `0x${'66'.repeat(20)}`,
100
+ token: route.sourceToken.address,
101
+ })
102
+ : transferLog({
103
+ amount: 950_000n,
104
+ recipient: route.recipient,
105
+ sender: `0x${'77'.repeat(20)}`,
106
+ token: route.destinationToken.address,
107
+ }),
108
+ ],
109
+ status: '0x1',
110
+ }
111
+ response.writeHead(200, { 'content-type': 'application/json' })
112
+ response.end(JSON.stringify({ id: body.id, jsonrpc: '2.0', result }))
113
+ })
114
+
115
+ try {
116
+ await FundingCatalog.publish(db, {
117
+ chainTokens: [],
118
+ chains: [
119
+ {
120
+ aliases: [],
121
+ id: route.destinationChain.id as Chain.Id,
122
+ name: route.destinationChain.name,
123
+ parentChainId: null,
124
+ rpcUrls: [server.url],
125
+ slug: 'destination',
126
+ },
127
+ {
128
+ aliases: [],
129
+ id: route.sourceChain.id as Chain.Id,
130
+ name: route.sourceChain.name,
131
+ parentChainId: null,
132
+ rpcUrls: [server.url],
133
+ slug: 'source',
134
+ },
135
+ ],
136
+ routes: [],
137
+ tokens: [],
138
+ })
139
+ const messages: Provider.Webhook.receive.Dispatchable[] = []
140
+ const provider = Relay.relay({ apiKey: 'relay-api-key', baseUrl: server.url })
141
+ const tracker = Reconciliation.createTracker({
142
+ db,
143
+ dispatch: async (message) => {
144
+ messages.push(message)
145
+ },
146
+ metrics,
147
+ now: () => new Date('2027-01-01T00:00:00.000Z'),
148
+ providers: [provider],
149
+ verifyTransfers: Evidence.createVerifier({
150
+ db,
151
+ }),
152
+ })
153
+
154
+ const tick = await tracker.tick()
155
+ const message = messages[0]
156
+ if (!message) throw new Error('Expected a reconciliation message.')
157
+ const queuedBeforeAttribution: Provider.Webhook.receive.Queued = {
158
+ addressId: message.addressId,
159
+ pollLeaseVersion: message.pollLeaseVersion,
160
+ type: message.type,
161
+ }
162
+ const reconciliation = await tracker.reconcile(queuedBeforeAttribution)
163
+ const duplicate = await tracker.reconcile(queuedBeforeAttribution)
164
+ const [record] = await FundingDeposits.listBySourceTransaction(db, {
165
+ depositAddressId: address.id,
166
+ sourceTransactionHash,
167
+ })
168
+ const observation = await FundingDepositRequestObservations.get(db, {
169
+ depositAddressId: address.id,
170
+ providerRequestId: 'relay-child-request',
171
+ })
172
+ const storedAddress = await FundingDepositAddresses.get(db, address.id)
173
+
174
+ expect({
175
+ counts,
176
+ duplicate,
177
+ observation,
178
+ reconciliation,
179
+ record,
180
+ storedAddress,
181
+ tick,
182
+ }).toMatchInlineSnapshot(
183
+ {
184
+ record: {
185
+ createdAt: expect.any(String),
186
+ depositAddressId: expect.any(String),
187
+ id: expect.any(String),
188
+ snapshot: { depositAddressId: expect.any(String) },
189
+ updatedAt: expect.any(String),
190
+ },
191
+ observation: { depositAddressId: expect.any(String) },
192
+ storedAddress: {
193
+ id: expect.any(String),
194
+ providerOutputToken: expect.any(Object),
195
+ snapshot: expect.any(Object),
196
+ },
197
+ },
198
+ `
199
+ {
200
+ "counts": [
201
+ [
202
+ "funding_deposit_reconciliation_count",
203
+ 1,
204
+ {
205
+ "outcome": "enqueued",
206
+ "provider": "relay",
207
+ "trigger": "poll",
208
+ },
209
+ ],
210
+ [
211
+ "funding_deposit_detection_count",
212
+ 1,
213
+ {
214
+ "provider": "relay",
215
+ "trigger": "poll",
216
+ },
217
+ ],
218
+ [
219
+ "funding_deposit_reconciliation_count",
220
+ 1,
221
+ {
222
+ "outcome": "follow_up_enqueued",
223
+ "provider": "relay",
224
+ "trigger": "poll",
225
+ },
226
+ ],
227
+ [
228
+ "funding_deposit_reconciliation_count",
229
+ 1,
230
+ {
231
+ "outcome": "completed",
232
+ "provider": "relay",
233
+ "trigger": "poll",
234
+ },
235
+ ],
236
+ ],
237
+ "duplicate": {
238
+ "type": "busy",
239
+ },
240
+ "observation": {
241
+ "depositAddressId": Any<String>,
242
+ "pollObservedAt": "2027-01-01T00:00:00.000Z",
243
+ "providerRequestId": "relay-child-request",
244
+ "webhookReceivedAt": null,
245
+ },
246
+ "reconciliation": {
247
+ "created": 1,
248
+ "type": "completed",
249
+ "updated": 1,
250
+ },
251
+ "record": {
252
+ "createdAt": Any<String>,
253
+ "depositAddressId": Any<String>,
254
+ "detectionTrigger": "poll",
255
+ "environment": "production",
256
+ "id": Any<String>,
257
+ "orgId": "org_reconciliation",
258
+ "pollObservedAt": "2027-01-01T00:00:00.000Z",
259
+ "projectId": null,
260
+ "providerOutputAmount": null,
261
+ "providerOutputToken": {
262
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
263
+ "currency": "USD",
264
+ "decimals": 6,
265
+ "name": "Bridged USDC (Stargate)",
266
+ "standard": "TIP-20",
267
+ "symbol": "USDC.e",
268
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
269
+ "verified": true,
270
+ },
271
+ "providerRequestId": "relay-child-request",
272
+ "providerRequestIds": [
273
+ "relay-child-request",
274
+ ],
275
+ "providerState": null,
276
+ "providerTransactionHashes": [],
277
+ "providerTransferIndex": 0,
278
+ "retryState": null,
279
+ "settlementTransaction": null,
280
+ "settlementTransactionHash": null,
281
+ "snapshot": {
282
+ "depositAddressId": Any<String>,
283
+ "destinationChain": {
284
+ "addressFormat": "hex",
285
+ "id": "eip155:4217",
286
+ "kind": "evm",
287
+ "name": "Tempo",
288
+ },
289
+ "destinationToken": {
290
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
291
+ "currency": "USD",
292
+ "decimals": 6,
293
+ "name": "Bridged USDC (Stargate)",
294
+ "standard": "TIP-20",
295
+ "symbol": "USDC.e",
296
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
297
+ "verified": true,
298
+ },
299
+ "destinationTransactionHashes": [],
300
+ "provider": {
301
+ "id": "relay",
302
+ "name": "Relay",
303
+ },
304
+ "recipient": "0x1111111111111111111111111111111111111111",
305
+ "refundAddress": "0x5555555555555555555555555555555555555555",
306
+ "sender": "0x6666666666666666666666666666666666666666",
307
+ "sourceAmount": {
308
+ "baseUnits": "1000000",
309
+ "currency": "USD",
310
+ "decimals": 6,
311
+ "formatted": "1",
312
+ },
313
+ "sourceChain": {
314
+ "addressFormat": "hex",
315
+ "id": "eip155:8453",
316
+ "kind": "evm",
317
+ "name": "Base",
318
+ },
319
+ "sourceToken": {
320
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
321
+ "currency": "USD",
322
+ "decimals": 6,
323
+ "name": "USD Coin",
324
+ "standard": "ERC-20",
325
+ "symbol": "USDC",
326
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
327
+ "verified": true,
328
+ },
329
+ "sourceTransactionHashes": [
330
+ "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
331
+ ],
332
+ },
333
+ "sourceChainId": "eip155:8453",
334
+ "sourceTransactionHash": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
335
+ "sourceTransferIndex": 0,
336
+ "status": "bridging",
337
+ "statusReason": null,
338
+ "subsidyAmount": null,
339
+ "tempoGasPaid": null,
340
+ "updatedAt": Any<String>,
341
+ "version": 3,
342
+ "webhookReceivedAt": null,
343
+ },
344
+ "storedAddress": {
345
+ "address": "0x4444444444444444444444444444444444444444",
346
+ "apiKeyId": "key_reconciliation",
347
+ "createdAt": "2026-01-01T00:00:00.000Z",
348
+ "deliveryStrategy": "provider",
349
+ "destinationTokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
350
+ "environment": "production",
351
+ "id": Any<String>,
352
+ "lastPolledAt": "2027-01-01T00:00:00.000Z",
353
+ "nextPollAt": "2027-01-01T00:01:00.000Z",
354
+ "orgId": "org_reconciliation",
355
+ "pollFailureCount": 0,
356
+ "pollLeaseUntil": null,
357
+ "pollLeaseVersion": 1,
358
+ "projectId": null,
359
+ "providerId": "relay",
360
+ "providerOutputToken": Any<Object>,
361
+ "providerRequestIds": [],
362
+ "providerState": {
363
+ "reconciliation": {
364
+ "pendingRequestIds": [
365
+ "relay-child-request",
366
+ ],
367
+ "requestIds": [
368
+ "relay-child-request",
369
+ ],
370
+ "updatedAt": "2026-01-01T00:02:00.000Z",
371
+ },
372
+ },
373
+ "recipient": "0x1111111111111111111111111111111111111111",
374
+ "refundAddress": "0x5555555555555555555555555555555555555555",
375
+ "snapshot": Any<Object>,
376
+ "sourceChainId": "eip155:8453",
377
+ "sourceTokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
378
+ "status": "active",
379
+ "subsidize": false,
380
+ "updatedAt": "2026-01-01T00:00:00.000Z",
381
+ "version": 1,
382
+ },
383
+ "tick": {
384
+ "claimed": 1,
385
+ "failed": 0,
386
+ },
387
+ }
388
+ `,
389
+ )
390
+ } finally {
391
+ await server.closeAsync()
392
+ }
393
+ })
394
+
395
+ test('completes an unsubsidized deposit at its verified provider output', async () => {
396
+ const route = TestFunding.transferSnapshot()
397
+ const depositAddress = `0x${'45'.repeat(20)}`
398
+ const destinationTransactionHash = `0x${'cd'.repeat(32)}`
399
+ const sourceTransactionHash = `0x${'ab'.repeat(32)}`
400
+ const address = await DepositAddress.create(db, {
401
+ apiKeyId: 'key_unsubsidized_reconciliation',
402
+ deliveryStrategy: 'provider',
403
+ environment: 'production',
404
+ now: new Date('2026-01-06T00:00:00.000Z'),
405
+ orgId: 'org_unsubsidized_reconciliation',
406
+ providerOutputToken: route.destinationToken,
407
+ snapshot: {
408
+ address: depositAddress,
409
+ destinationChain: route.destinationChain,
410
+ destinationToken: route.destinationToken,
411
+ provider: { id: 'local', name: 'Local' },
412
+ recipient: route.recipient,
413
+ refundAddress: `0x${'46'.repeat(20)}`,
414
+ sourceChain: route.sourceChain,
415
+ sourceToken: route.sourceToken,
416
+ subsidize: false,
417
+ },
418
+ })
419
+ const server = await TestRelay.createServer(async (request, response) => {
420
+ const chunks: Uint8Array[] = []
421
+ for await (const chunk of request) chunks.push(chunk)
422
+ const body = JSON.parse(NodeBuffer.Buffer.concat(chunks).toString()) as {
423
+ id: number
424
+ method: string
425
+ params?: readonly string[] | undefined
426
+ }
427
+ const source = body.params?.[0] === sourceTransactionHash
428
+ const result =
429
+ body.method === 'eth_blockNumber'
430
+ ? '0x100'
431
+ : {
432
+ blockNumber: '0x80',
433
+ logs: [
434
+ transferLog({
435
+ amount: source ? 1_000_000n : 950_000n,
436
+ recipient: source ? depositAddress : route.recipient,
437
+ sender: `0x${'47'.repeat(20)}`,
438
+ token: source ? route.sourceToken.address : route.destinationToken.address,
439
+ }),
440
+ ],
441
+ status: '0x1',
442
+ }
443
+ response.writeHead(200, { 'content-type': 'application/json' })
444
+ response.end(JSON.stringify({ id: body.id, jsonrpc: '2.0', result }))
445
+ })
446
+
447
+ try {
448
+ await FundingCatalog.publish(db, {
449
+ chainTokens: [],
450
+ chains: [
451
+ {
452
+ aliases: [],
453
+ id: route.destinationChain.id as Chain.Id,
454
+ name: route.destinationChain.name,
455
+ parentChainId: null,
456
+ rpcUrls: [server.url],
457
+ slug: 'destination-unsubsidized',
458
+ },
459
+ {
460
+ aliases: [],
461
+ id: route.sourceChain.id as Chain.Id,
462
+ name: route.sourceChain.name,
463
+ parentChainId: null,
464
+ rpcUrls: [server.url],
465
+ slug: 'source-unsubsidized',
466
+ },
467
+ ],
468
+ routes: [],
469
+ tokens: [],
470
+ })
471
+ const result = await Reconciliation.reconcileRequest(db, {
472
+ address,
473
+ request: {
474
+ createdAt: '2026-01-06T00:01:00.000Z',
475
+ destinationTransactionHashes: [destinationTransactionHash],
476
+ id: 'unsubsidized-request',
477
+ sourceTransactionHashes: [sourceTransactionHash],
478
+ status: 'success',
479
+ updatedAt: '2026-01-06T00:02:00.000Z',
480
+ },
481
+ trigger: 'manual',
482
+ verifyTransfers: Evidence.createVerifier({ db }),
483
+ })
484
+ const [record] = await FundingDeposits.listBySourceTransaction(db, {
485
+ depositAddressId: address.id,
486
+ sourceTransactionHash,
487
+ })
488
+
489
+ expect({ record, result }).toMatchInlineSnapshot(
490
+ {
491
+ record: {
492
+ createdAt: expect.any(String),
493
+ depositAddressId: expect.any(String),
494
+ id: expect.any(String),
495
+ snapshot: { depositAddressId: expect.any(String) },
496
+ updatedAt: expect.any(String),
497
+ },
498
+ },
499
+ `
500
+ {
501
+ "record": {
502
+ "createdAt": Any<String>,
503
+ "depositAddressId": Any<String>,
504
+ "detectionTrigger": "manual",
505
+ "environment": "production",
506
+ "id": Any<String>,
507
+ "orgId": "org_unsubsidized_reconciliation",
508
+ "pollObservedAt": null,
509
+ "projectId": null,
510
+ "providerOutputAmount": {
511
+ "baseUnits": "950000",
512
+ "currency": "USD",
513
+ "decimals": 6,
514
+ "formatted": "0.95",
515
+ },
516
+ "providerOutputToken": {
517
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
518
+ "currency": "USD",
519
+ "decimals": 6,
520
+ "name": "Bridged USDC (Stargate)",
521
+ "standard": "TIP-20",
522
+ "symbol": "USDC.e",
523
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
524
+ "verified": true,
525
+ },
526
+ "providerRequestId": "unsubsidized-request",
527
+ "providerRequestIds": [
528
+ "unsubsidized-request",
529
+ ],
530
+ "providerState": null,
531
+ "providerTransactionHashes": [
532
+ "0xcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
533
+ ],
534
+ "providerTransferIndex": 0,
535
+ "retryState": null,
536
+ "settlementTransaction": null,
537
+ "settlementTransactionHash": null,
538
+ "snapshot": {
539
+ "depositAddressId": Any<String>,
540
+ "destinationAmount": {
541
+ "baseUnits": "950000",
542
+ "currency": "USD",
543
+ "decimals": 6,
544
+ "formatted": "0.95",
545
+ },
546
+ "destinationAmountRequired": {
547
+ "baseUnits": "950000",
548
+ "currency": "USD",
549
+ "decimals": 6,
550
+ "formatted": "0.95",
551
+ },
552
+ "destinationChain": {
553
+ "addressFormat": "hex",
554
+ "id": "eip155:4217",
555
+ "kind": "evm",
556
+ "name": "Tempo",
557
+ },
558
+ "destinationToken": {
559
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
560
+ "currency": "USD",
561
+ "decimals": 6,
562
+ "name": "Bridged USDC (Stargate)",
563
+ "standard": "TIP-20",
564
+ "symbol": "USDC.e",
565
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
566
+ "verified": true,
567
+ },
568
+ "destinationTransactionHashes": [
569
+ "0xcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
570
+ ],
571
+ "provider": {
572
+ "id": "local",
573
+ "name": "Local",
574
+ },
575
+ "recipient": "0x1111111111111111111111111111111111111111",
576
+ "refundAddress": "0x4646464646464646464646464646464646464646",
577
+ "sender": "0x4747474747474747474747474747474747474747",
578
+ "sourceAmount": {
579
+ "baseUnits": "1000000",
580
+ "currency": "USD",
581
+ "decimals": 6,
582
+ "formatted": "1",
583
+ },
584
+ "sourceChain": {
585
+ "addressFormat": "hex",
586
+ "id": "eip155:8453",
587
+ "kind": "evm",
588
+ "name": "Base",
589
+ },
590
+ "sourceToken": {
591
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
592
+ "currency": "USD",
593
+ "decimals": 6,
594
+ "name": "USD Coin",
595
+ "standard": "ERC-20",
596
+ "symbol": "USDC",
597
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
598
+ "verified": true,
599
+ },
600
+ "sourceTransactionHashes": [
601
+ "0xabababababababababababababababababababababababababababababababab",
602
+ ],
603
+ },
604
+ "sourceChainId": "eip155:8453",
605
+ "sourceTransactionHash": "0xabababababababababababababababababababababababababababababababab",
606
+ "sourceTransferIndex": 0,
607
+ "status": "completed",
608
+ "statusReason": null,
609
+ "subsidyAmount": null,
610
+ "tempoGasPaid": null,
611
+ "updatedAt": Any<String>,
612
+ "version": 3,
613
+ "webhookReceivedAt": null,
614
+ },
615
+ "result": {
616
+ "created": 1,
617
+ "terminal": true,
618
+ "updated": 1,
619
+ },
620
+ }
621
+ `,
622
+ )
623
+ } finally {
624
+ await server.closeAsync()
625
+ }
626
+ })
627
+
628
+ test('persists a detected deposit before source verification succeeds', async () => {
629
+ const route = TestFunding.transferSnapshot()
630
+ const depositAddress = `0x${'20'.repeat(20)}`
631
+ const sourceTransactionHash = `0x${'21'.repeat(32)}`
632
+ const address = await DepositAddress.create(db, {
633
+ apiKeyId: 'key_observed_reconciliation',
634
+ deliveryStrategy: 'provider',
635
+ environment: 'production',
636
+ now: new Date('2026-01-04T00:00:00.000Z'),
637
+ orgId: 'org_observed_reconciliation',
638
+ providerOutputToken: route.destinationToken,
639
+ snapshot: {
640
+ address: depositAddress,
641
+ destinationChain: route.destinationChain,
642
+ destinationToken: route.destinationToken,
643
+ provider: { id: 'relay', name: 'Relay' },
644
+ recipient: route.recipient,
645
+ refundAddress: `0x${'22'.repeat(20)}`,
646
+ sourceChain: route.sourceChain,
647
+ sourceToken: route.sourceToken,
648
+ subsidize: false,
649
+ },
650
+ })
651
+ const server = await TestRelay.createServer(async (request, response) => {
652
+ response.writeHead(200, { 'content-type': 'application/json' })
653
+ if (request.method === 'GET') {
654
+ response.end(
655
+ JSON.stringify({
656
+ requests: [
657
+ {
658
+ createdAt: '2026-01-04T00:01:00.000Z',
659
+ data: { inTxs: [{ txHash: sourceTransactionHash }], outTxs: [] },
660
+ depositAddress: { depositTxHash: sourceTransactionHash },
661
+ id: 'relay-observed-request',
662
+ status: 'pending',
663
+ updatedAt: '2026-01-04T00:02:00.000Z',
664
+ },
665
+ ],
666
+ }),
667
+ )
668
+ return
669
+ }
670
+
671
+ const chunks: Uint8Array[] = []
672
+ for await (const chunk of request) chunks.push(chunk)
673
+ const body = JSON.parse(NodeBuffer.Buffer.concat(chunks).toString()) as { id: number }
674
+ response.end(
675
+ JSON.stringify({
676
+ error: { code: -32_000, message: 'Source RPC unavailable.' },
677
+ id: body.id,
678
+ jsonrpc: '2.0',
679
+ }),
680
+ )
681
+ })
682
+
683
+ try {
684
+ await FundingCatalog.publish(db, {
685
+ chainTokens: [],
686
+ chains: [
687
+ {
688
+ aliases: [],
689
+ id: route.destinationChain.id as Chain.Id,
690
+ name: route.destinationChain.name,
691
+ parentChainId: null,
692
+ rpcUrls: [server.url],
693
+ slug: 'destination',
694
+ },
695
+ {
696
+ aliases: [],
697
+ id: route.sourceChain.id as Chain.Id,
698
+ name: route.sourceChain.name,
699
+ parentChainId: null,
700
+ rpcUrls: [server.url],
701
+ slug: 'source',
702
+ },
703
+ ],
704
+ routes: [],
705
+ tokens: [],
706
+ })
707
+ const tracker = Reconciliation.createTracker({
708
+ db,
709
+ dispatch: async () => undefined,
710
+ providers: [Relay.relay({ apiKey: 'relay-api-key', baseUrl: server.url })],
711
+ verifyTransfers: Evidence.createVerifier({ db }),
712
+ })
713
+ const failures: boolean[] = []
714
+ for (let attempt = 0; attempt < 2; attempt++)
715
+ failures.push(
716
+ await tracker
717
+ .reconcile({
718
+ addressId: address.id,
719
+ type: 'funding:deposit-address:reconcile',
720
+ })
721
+ .then(
722
+ () => false,
723
+ () => true,
724
+ ),
725
+ )
726
+ const records = await FundingDeposits.listByAddress(
727
+ db,
728
+ { environment: 'production', orgId: 'org_observed_reconciliation' },
729
+ address.id,
730
+ { limit: 10 },
731
+ )
732
+
733
+ expect({ failures, records: records.map(Deposit.toPublic) }).toMatchInlineSnapshot(
734
+ {
735
+ records: [
736
+ {
737
+ createdAt: expect.any(String),
738
+ depositAddressId: expect.any(String),
739
+ id: expect.any(String),
740
+ updatedAt: expect.any(String),
741
+ },
742
+ ],
743
+ },
744
+ `
745
+ {
746
+ "failures": [
747
+ true,
748
+ true,
749
+ ],
750
+ "records": [
751
+ {
752
+ "createdAt": Any<String>,
753
+ "depositAddressId": Any<String>,
754
+ "destinationChain": {
755
+ "addressFormat": "hex",
756
+ "id": "eip155:4217",
757
+ "kind": "evm",
758
+ "name": "Tempo",
759
+ },
760
+ "destinationToken": {
761
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
762
+ "currency": "USD",
763
+ "decimals": 6,
764
+ "name": "Bridged USDC (Stargate)",
765
+ "standard": "TIP-20",
766
+ "symbol": "USDC.e",
767
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
768
+ "verified": true,
769
+ },
770
+ "detectionTrigger": "webhook",
771
+ "id": Any<String>,
772
+ "provider": {
773
+ "id": "relay",
774
+ "name": "Relay",
775
+ },
776
+ "recipient": "0x1111111111111111111111111111111111111111",
777
+ "refundAddress": "0x2222222222222222222222222222222222222222",
778
+ "sourceChain": {
779
+ "addressFormat": "hex",
780
+ "id": "eip155:8453",
781
+ "kind": "evm",
782
+ "name": "Base",
783
+ },
784
+ "sourceToken": {
785
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
786
+ "currency": "USD",
787
+ "decimals": 6,
788
+ "name": "USD Coin",
789
+ "standard": "ERC-20",
790
+ "symbol": "USDC",
791
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
792
+ "verified": true,
793
+ },
794
+ "sourceTransactionHashes": [
795
+ "0x2121212121212121212121212121212121212121212121212121212121212121",
796
+ ],
797
+ "status": "detected",
798
+ "updatedAt": Any<String>,
799
+ },
800
+ ],
801
+ }
802
+ `,
803
+ )
804
+ } finally {
805
+ await server.closeAsync()
806
+ }
807
+ })
808
+
809
+ test('rechecks pending Relay requests by id until delivery is verified', async () => {
810
+ const route = TestFunding.transferSnapshot()
811
+ const depositAddress = `0x${'88'.repeat(20)}`
812
+ const sourceTransactionHash = `0x${'cc'.repeat(32)}`
813
+ const destinationTransactionHash = `0x${'dd'.repeat(32)}`
814
+ const address = await DepositAddress.create(db, {
815
+ apiKeyId: 'key_pending_reconciliation',
816
+ deliveryStrategy: 'provider',
817
+ environment: 'production',
818
+ now: new Date('2026-01-02T00:00:00.000Z'),
819
+ orgId: 'org_pending_reconciliation',
820
+ providerOutputToken: route.destinationToken,
821
+ snapshot: {
822
+ address: depositAddress,
823
+ destinationChain: route.destinationChain,
824
+ destinationToken: route.destinationToken,
825
+ provider: { id: 'relay', name: 'Relay' },
826
+ recipient: route.recipient,
827
+ refundAddress: `0x${'99'.repeat(20)}`,
828
+ sourceChain: route.sourceChain,
829
+ sourceToken: route.sourceToken,
830
+ subsidize: false,
831
+ },
832
+ })
833
+ const counts: Parameters<Metrics.Metrics['count']>[] = []
834
+ const dispatches: Parameters<Reconciliation.createTracker.Options['dispatch']>[] = []
835
+ const histograms: Parameters<Metrics.Metrics['histogram']>[] = []
836
+ const metrics = Metrics.from({
837
+ count(...parameters) {
838
+ counts.push(parameters)
839
+ },
840
+ flush() {},
841
+ gauge() {},
842
+ histogram(...parameters) {
843
+ histograms.push(parameters)
844
+ },
845
+ })
846
+ const requestTargets: string[] = []
847
+ let delivered = false
848
+ let dispatchFailure = true
849
+ let includeAddressRequest = true
850
+ let indexed = false
851
+ let providerUpdateVisible = false
852
+ let returnOlderDirect = false
853
+ const server = await TestRelay.createServer(async (request, response) => {
854
+ if (request.method === 'GET') {
855
+ const url = new URL(request.url ?? '/', server.url)
856
+ requestTargets.push(`${url.pathname}${url.search}`)
857
+ const direct = url.searchParams.get('id') === 'relay-pending-request'
858
+ response.writeHead(200, { 'content-type': 'application/json' })
859
+ response.end(
860
+ JSON.stringify({
861
+ requests:
862
+ indexed && (includeAddressRequest || direct)
863
+ ? [
864
+ {
865
+ createdAt: '2026-01-02T00:01:00.000Z',
866
+ data: {
867
+ inTxs: [{ txHash: sourceTransactionHash }],
868
+ outTxs: delivered ? [{ txHash: destinationTransactionHash }] : [],
869
+ },
870
+ depositAddress: { depositTxHash: sourceTransactionHash },
871
+ id: 'relay-pending-request',
872
+ status: delivered ? 'success' : 'pending',
873
+ updatedAt: (() => {
874
+ if (direct && returnOlderDirect) return '2026-01-01T00:00:00.000Z'
875
+ if (!providerUpdateVisible) return '2026-01-02T00:02:00.000Z'
876
+ if (delivered) return '2026-01-02T00:03:00.500Z'
877
+ return '2026-01-02T00:03:00Z'
878
+ })(),
879
+ },
880
+ ]
881
+ : [],
882
+ }),
883
+ )
884
+ return
885
+ }
886
+
887
+ const chunks: Uint8Array[] = []
888
+ for await (const chunk of request) chunks.push(chunk)
889
+ const body = JSON.parse(NodeBuffer.Buffer.concat(chunks).toString()) as {
890
+ id: number
891
+ method: string
892
+ params?: readonly string[] | undefined
893
+ }
894
+ const hash = body.params?.[0]
895
+ const result =
896
+ body.method === 'eth_blockNumber'
897
+ ? '0x100'
898
+ : {
899
+ blockNumber: '0x80',
900
+ logs: [
901
+ hash === sourceTransactionHash
902
+ ? transferLog({
903
+ amount: 1_000_000n,
904
+ recipient: depositAddress,
905
+ sender: `0x${'aa'.repeat(20)}`,
906
+ token: route.sourceToken.address,
907
+ })
908
+ : transferLog({
909
+ amount: 1_000_000n,
910
+ recipient: route.recipient,
911
+ sender: `0x${'bb'.repeat(20)}`,
912
+ token: route.destinationToken.address,
913
+ }),
914
+ ],
915
+ status: '0x1',
916
+ }
917
+ response.writeHead(200, { 'content-type': 'application/json' })
918
+ response.end(JSON.stringify({ id: body.id, jsonrpc: '2.0', result }))
919
+ })
920
+
921
+ try {
922
+ await FundingCatalog.publish(db, {
923
+ chainTokens: [],
924
+ chains: [
925
+ {
926
+ aliases: [],
927
+ id: route.destinationChain.id as Chain.Id,
928
+ name: route.destinationChain.name,
929
+ parentChainId: null,
930
+ rpcUrls: [server.url],
931
+ slug: 'destination',
932
+ },
933
+ {
934
+ aliases: [],
935
+ id: route.sourceChain.id as Chain.Id,
936
+ name: route.sourceChain.name,
937
+ parentChainId: null,
938
+ rpcUrls: [server.url],
939
+ slug: 'source',
940
+ },
941
+ ],
942
+ routes: [],
943
+ tokens: [],
944
+ })
945
+ const provider = Relay.relay({ apiKey: 'relay-api-key', baseUrl: server.url })
946
+ let trackerNow = new Date('2026-01-02T00:03:10.000Z')
947
+ const tracker = Reconciliation.createTracker({
948
+ db,
949
+ dispatch: async (...parameters) => {
950
+ if (dispatchFailure) {
951
+ dispatchFailure = false
952
+ throw new Error('Reconciliation queue unavailable.')
953
+ }
954
+ dispatches.push(parameters)
955
+ },
956
+ metrics,
957
+ now: () => trackerNow,
958
+ providers: [provider],
959
+ verifyTransfers: Evidence.createVerifier({ db }),
960
+ })
961
+
962
+ const message = {
963
+ addressId: address.id,
964
+ requestId: 'relay-pending-request',
965
+ trigger: 'webhook',
966
+ type: 'funding:deposit-address:reconcile',
967
+ webhookTiming: {
968
+ enqueuedAt: '2026-01-02T00:03:07.000Z',
969
+ providerStatus: 'pending',
970
+ providerUpdatedAt: '2026-01-02T00:03:00.000Z',
971
+ receivedAt: '2026-01-02T00:03:06.000Z',
972
+ sentAt: '2026-01-02T00:03:05.000Z',
973
+ },
974
+ } satisfies Provider.Webhook.receive.Dispatchable
975
+ await expect(tracker.reconcile(message)).rejects.toThrowErrorMatchingInlineSnapshot(
976
+ `[Error: Reconciliation queue unavailable.]`,
977
+ )
978
+ const pending = await tracker.reconcile(message)
979
+ const [firstFollowUp] = dispatches
980
+ if (!firstFollowUp) throw new Error('Expected a provider follow-up message.')
981
+ indexed = true
982
+ const pendingFollowUp = await tracker.reconcile(firstFollowUp[0])
983
+ const exhausted = await tracker.reconcile({
984
+ ...firstFollowUp[0],
985
+ followUp: { attempt: 5, kind: 'provider' },
986
+ })
987
+ const [, secondFollowUp] = dispatches
988
+ if (!secondFollowUp) throw new Error('Expected a second provider follow-up message.')
989
+ delivered = true
990
+ includeAddressRequest = false
991
+ providerUpdateVisible = true
992
+ trackerNow = new Date('2026-01-02T00:03:15.000Z')
993
+ const completed = await tracker.reconcile(secondFollowUp[0])
994
+ includeAddressRequest = true
995
+ const replay = await tracker.reconcile({
996
+ addressId: address.id,
997
+ trigger: 'webhook',
998
+ type: 'funding:deposit-address:reconcile',
999
+ })
1000
+ includeAddressRequest = false
1001
+ returnOlderDirect = true
1002
+ const webhook = await tracker.reconcile({
1003
+ addressId: address.id,
1004
+ requestId: 'relay-pending-request',
1005
+ trigger: 'webhook',
1006
+ type: 'funding:deposit-address:reconcile',
1007
+ })
1008
+ const [record] = await FundingDeposits.listBySourceTransaction(db, {
1009
+ depositAddressId: address.id,
1010
+ sourceTransactionHash,
1011
+ })
1012
+ const storedAddress = await FundingDepositAddresses.get(db, address.id)
1013
+
1014
+ expect({
1015
+ completed,
1016
+ counts,
1017
+ dispatches,
1018
+ exhausted,
1019
+ histograms,
1020
+ pending,
1021
+ pendingFollowUp,
1022
+ record,
1023
+ replay,
1024
+ requestTargets,
1025
+ storedAddress,
1026
+ webhook,
1027
+ }).toMatchInlineSnapshot(
1028
+ {
1029
+ dispatches: [
1030
+ [{ addressId: expect.any(String) }, { delaySeconds: 5 }],
1031
+ [{ addressId: expect.any(String) }, { delaySeconds: 5 }],
1032
+ ],
1033
+ record: {
1034
+ createdAt: expect.any(String),
1035
+ depositAddressId: expect.any(String),
1036
+ id: expect.any(String),
1037
+ snapshot: { depositAddressId: expect.any(String) },
1038
+ updatedAt: expect.any(String),
1039
+ },
1040
+ storedAddress: {
1041
+ id: expect.any(String),
1042
+ providerOutputToken: expect.any(Object),
1043
+ snapshot: expect.any(Object),
1044
+ },
1045
+ },
1046
+ `
1047
+ {
1048
+ "completed": {
1049
+ "created": 0,
1050
+ "type": "completed",
1051
+ "updated": 1,
1052
+ },
1053
+ "counts": [
1054
+ [
1055
+ "funding_deposit_reconciliation_count",
1056
+ 1,
1057
+ {
1058
+ "outcome": "follow_up_enqueue_failed",
1059
+ "provider": "relay",
1060
+ "trigger": "webhook",
1061
+ },
1062
+ ],
1063
+ [
1064
+ "funding_deposit_reconciliation_count",
1065
+ 1,
1066
+ {
1067
+ "outcome": "failed",
1068
+ "provider": "relay",
1069
+ "trigger": "webhook",
1070
+ },
1071
+ ],
1072
+ [
1073
+ "funding_deposit_reconciliation_count",
1074
+ 1,
1075
+ {
1076
+ "outcome": "follow_up_enqueued",
1077
+ "provider": "relay",
1078
+ "trigger": "webhook",
1079
+ },
1080
+ ],
1081
+ [
1082
+ "funding_deposit_reconciliation_count",
1083
+ 1,
1084
+ {
1085
+ "outcome": "completed",
1086
+ "provider": "relay",
1087
+ "trigger": "webhook",
1088
+ },
1089
+ ],
1090
+ [
1091
+ "funding_deposit_detection_count",
1092
+ 1,
1093
+ {
1094
+ "provider": "relay",
1095
+ "trigger": "webhook",
1096
+ },
1097
+ ],
1098
+ [
1099
+ "funding_deposit_reconciliation_count",
1100
+ 1,
1101
+ {
1102
+ "outcome": "follow_up_enqueued",
1103
+ "provider": "relay",
1104
+ "trigger": "webhook",
1105
+ },
1106
+ ],
1107
+ [
1108
+ "funding_deposit_reconciliation_count",
1109
+ 1,
1110
+ {
1111
+ "outcome": "completed",
1112
+ "provider": "relay",
1113
+ "trigger": "webhook",
1114
+ },
1115
+ ],
1116
+ [
1117
+ "funding_deposit_reconciliation_count",
1118
+ 1,
1119
+ {
1120
+ "outcome": "follow_up_exhausted",
1121
+ "provider": "relay",
1122
+ "trigger": "webhook",
1123
+ },
1124
+ ],
1125
+ [
1126
+ "funding_deposit_reconciliation_count",
1127
+ 1,
1128
+ {
1129
+ "outcome": "completed",
1130
+ "provider": "relay",
1131
+ "trigger": "webhook",
1132
+ },
1133
+ ],
1134
+ [
1135
+ "funding_deposit_reconciliation_count",
1136
+ 1,
1137
+ {
1138
+ "outcome": "completed",
1139
+ "provider": "relay",
1140
+ "trigger": "webhook",
1141
+ },
1142
+ ],
1143
+ [
1144
+ "funding_deposit_reconciliation_count",
1145
+ 1,
1146
+ {
1147
+ "outcome": "completed",
1148
+ "provider": "relay",
1149
+ "trigger": "webhook",
1150
+ },
1151
+ ],
1152
+ [
1153
+ "funding_deposit_reconciliation_count",
1154
+ 1,
1155
+ {
1156
+ "outcome": "completed",
1157
+ "provider": "relay",
1158
+ "trigger": "webhook",
1159
+ },
1160
+ ],
1161
+ ],
1162
+ "dispatches": [
1163
+ [
1164
+ {
1165
+ "addressId": Any<String>,
1166
+ "followUp": {
1167
+ "attempt": 0,
1168
+ "kind": "provider",
1169
+ },
1170
+ "requestId": "relay-pending-request",
1171
+ "trigger": "webhook",
1172
+ "type": "funding:deposit-address:reconcile",
1173
+ "webhookTiming": {
1174
+ "enqueuedAt": "2026-01-02T00:03:07.000Z",
1175
+ "providerStatus": "pending",
1176
+ "providerUpdatedAt": "2026-01-02T00:03:00.000Z",
1177
+ "receivedAt": "2026-01-02T00:03:06.000Z",
1178
+ "sentAt": "2026-01-02T00:03:05.000Z",
1179
+ },
1180
+ },
1181
+ {
1182
+ "delaySeconds": 5,
1183
+ },
1184
+ ],
1185
+ [
1186
+ {
1187
+ "addressId": Any<String>,
1188
+ "followUp": {
1189
+ "attempt": 1,
1190
+ "kind": "provider",
1191
+ },
1192
+ "requestId": "relay-pending-request",
1193
+ "trigger": "webhook",
1194
+ "type": "funding:deposit-address:reconcile",
1195
+ "webhookTiming": {
1196
+ "enqueuedAt": "2026-01-02T00:03:07.000Z",
1197
+ "providerStatus": "pending",
1198
+ "providerUpdatedAt": "2026-01-02T00:03:00.000Z",
1199
+ "receivedAt": "2026-01-02T00:03:06.000Z",
1200
+ "sentAt": "2026-01-02T00:03:05.000Z",
1201
+ },
1202
+ },
1203
+ {
1204
+ "delaySeconds": 5,
1205
+ },
1206
+ ],
1207
+ ],
1208
+ "exhausted": {
1209
+ "created": 0,
1210
+ "type": "completed",
1211
+ "updated": 1,
1212
+ },
1213
+ "histograms": [
1214
+ [
1215
+ "funding_deposit_reconciliation_duration_ms",
1216
+ 0,
1217
+ {
1218
+ "provider": "relay",
1219
+ "trigger": "webhook",
1220
+ },
1221
+ ],
1222
+ [
1223
+ "funding_deposit_reconciliation_duration_ms",
1224
+ 0,
1225
+ {
1226
+ "provider": "relay",
1227
+ "trigger": "webhook",
1228
+ },
1229
+ ],
1230
+ [
1231
+ "funding_deposit_reconciliation_duration_ms",
1232
+ 0,
1233
+ {
1234
+ "provider": "relay",
1235
+ "trigger": "webhook",
1236
+ },
1237
+ ],
1238
+ [
1239
+ "funding_deposit_webhook_latency_ms",
1240
+ 5000,
1241
+ {
1242
+ "provider": "relay",
1243
+ "segment": "provider_to_sent",
1244
+ "status": "pending",
1245
+ },
1246
+ ],
1247
+ [
1248
+ "funding_deposit_webhook_latency_ms",
1249
+ 1000,
1250
+ {
1251
+ "provider": "relay",
1252
+ "segment": "sent_to_received",
1253
+ "status": "pending",
1254
+ },
1255
+ ],
1256
+ [
1257
+ "funding_deposit_webhook_latency_ms",
1258
+ 1000,
1259
+ {
1260
+ "provider": "relay",
1261
+ "segment": "received_to_enqueued",
1262
+ "status": "pending",
1263
+ },
1264
+ ],
1265
+ [
1266
+ "funding_deposit_webhook_latency_ms",
1267
+ 8000,
1268
+ {
1269
+ "provider": "relay",
1270
+ "segment": "enqueued_to_reconciled",
1271
+ "status": "pending",
1272
+ },
1273
+ ],
1274
+ [
1275
+ "funding_deposit_webhook_latency_ms",
1276
+ 15000,
1277
+ {
1278
+ "provider": "relay",
1279
+ "segment": "provider_to_reconciled",
1280
+ "status": "pending",
1281
+ },
1282
+ ],
1283
+ [
1284
+ "funding_deposit_reconciliation_duration_ms",
1285
+ 0,
1286
+ {
1287
+ "provider": "relay",
1288
+ "trigger": "webhook",
1289
+ },
1290
+ ],
1291
+ [
1292
+ "funding_deposit_reconciliation_duration_ms",
1293
+ 0,
1294
+ {
1295
+ "provider": "relay",
1296
+ "trigger": "webhook",
1297
+ },
1298
+ ],
1299
+ [
1300
+ "funding_deposit_reconciliation_duration_ms",
1301
+ 0,
1302
+ {
1303
+ "provider": "relay",
1304
+ "trigger": "webhook",
1305
+ },
1306
+ ],
1307
+ ],
1308
+ "pending": {
1309
+ "created": 0,
1310
+ "type": "completed",
1311
+ "updated": 0,
1312
+ },
1313
+ "pendingFollowUp": {
1314
+ "created": 1,
1315
+ "type": "completed",
1316
+ "updated": 1,
1317
+ },
1318
+ "record": {
1319
+ "createdAt": Any<String>,
1320
+ "depositAddressId": Any<String>,
1321
+ "detectionTrigger": "webhook",
1322
+ "environment": "production",
1323
+ "id": Any<String>,
1324
+ "orgId": "org_pending_reconciliation",
1325
+ "pollObservedAt": null,
1326
+ "projectId": null,
1327
+ "providerOutputAmount": {
1328
+ "baseUnits": "1000000",
1329
+ "currency": "USD",
1330
+ "decimals": 6,
1331
+ "formatted": "1",
1332
+ },
1333
+ "providerOutputToken": {
1334
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
1335
+ "currency": "USD",
1336
+ "decimals": 6,
1337
+ "name": "Bridged USDC (Stargate)",
1338
+ "standard": "TIP-20",
1339
+ "symbol": "USDC.e",
1340
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
1341
+ "verified": true,
1342
+ },
1343
+ "providerRequestId": "relay-pending-request",
1344
+ "providerRequestIds": [
1345
+ "relay-pending-request",
1346
+ ],
1347
+ "providerState": null,
1348
+ "providerTransactionHashes": [
1349
+ "0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
1350
+ ],
1351
+ "providerTransferIndex": 0,
1352
+ "retryState": null,
1353
+ "settlementTransaction": null,
1354
+ "settlementTransactionHash": null,
1355
+ "snapshot": {
1356
+ "depositAddressId": Any<String>,
1357
+ "destinationAmount": {
1358
+ "baseUnits": "1000000",
1359
+ "currency": "USD",
1360
+ "decimals": 6,
1361
+ "formatted": "1",
1362
+ },
1363
+ "destinationAmountRequired": {
1364
+ "baseUnits": "1000000",
1365
+ "currency": "USD",
1366
+ "decimals": 6,
1367
+ "formatted": "1",
1368
+ },
1369
+ "destinationChain": {
1370
+ "addressFormat": "hex",
1371
+ "id": "eip155:4217",
1372
+ "kind": "evm",
1373
+ "name": "Tempo",
1374
+ },
1375
+ "destinationToken": {
1376
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
1377
+ "currency": "USD",
1378
+ "decimals": 6,
1379
+ "name": "Bridged USDC (Stargate)",
1380
+ "standard": "TIP-20",
1381
+ "symbol": "USDC.e",
1382
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
1383
+ "verified": true,
1384
+ },
1385
+ "destinationTransactionHashes": [
1386
+ "0xdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
1387
+ ],
1388
+ "provider": {
1389
+ "id": "relay",
1390
+ "name": "Relay",
1391
+ },
1392
+ "recipient": "0x1111111111111111111111111111111111111111",
1393
+ "refundAddress": "0x9999999999999999999999999999999999999999",
1394
+ "sender": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
1395
+ "sourceAmount": {
1396
+ "baseUnits": "1000000",
1397
+ "currency": "USD",
1398
+ "decimals": 6,
1399
+ "formatted": "1",
1400
+ },
1401
+ "sourceChain": {
1402
+ "addressFormat": "hex",
1403
+ "id": "eip155:8453",
1404
+ "kind": "evm",
1405
+ "name": "Base",
1406
+ },
1407
+ "sourceToken": {
1408
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
1409
+ "currency": "USD",
1410
+ "decimals": 6,
1411
+ "name": "USD Coin",
1412
+ "standard": "ERC-20",
1413
+ "symbol": "USDC",
1414
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
1415
+ "verified": true,
1416
+ },
1417
+ "sourceTransactionHashes": [
1418
+ "0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
1419
+ ],
1420
+ },
1421
+ "sourceChainId": "eip155:8453",
1422
+ "sourceTransactionHash": "0xcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
1423
+ "sourceTransferIndex": 0,
1424
+ "status": "completed",
1425
+ "statusReason": null,
1426
+ "subsidyAmount": null,
1427
+ "tempoGasPaid": null,
1428
+ "updatedAt": Any<String>,
1429
+ "version": 7,
1430
+ "webhookReceivedAt": null,
1431
+ },
1432
+ "replay": {
1433
+ "created": 0,
1434
+ "type": "completed",
1435
+ "updated": 0,
1436
+ },
1437
+ "requestTargets": [
1438
+ "/requests/v3?depositAddress=0x8888888888888888888888888888888888888888&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1439
+ "/requests/v3?id=relay-pending-request&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1440
+ "/requests/v3?depositAddress=0x8888888888888888888888888888888888888888&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1441
+ "/requests/v3?id=relay-pending-request&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1442
+ "/requests/v3?depositAddress=0x8888888888888888888888888888888888888888&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1443
+ "/requests/v3?depositAddress=0x8888888888888888888888888888888888888888&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1444
+ "/requests/v3?depositAddress=0x8888888888888888888888888888888888888888&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1445
+ "/requests/v3?id=relay-pending-request&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1446
+ "/requests/v3?depositAddress=0x8888888888888888888888888888888888888888&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1447
+ "/requests/v3?depositAddress=0x8888888888888888888888888888888888888888&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1448
+ "/requests/v3?id=relay-pending-request&includeChildRequests=true&limit=50&sortBy=updatedAt&sortDirection=desc",
1449
+ ],
1450
+ "storedAddress": {
1451
+ "address": "0x8888888888888888888888888888888888888888",
1452
+ "apiKeyId": "key_pending_reconciliation",
1453
+ "createdAt": "2026-01-02T00:00:00.000Z",
1454
+ "deliveryStrategy": "provider",
1455
+ "destinationTokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
1456
+ "environment": "production",
1457
+ "id": Any<String>,
1458
+ "lastPolledAt": "2026-01-02T00:03:15.000Z",
1459
+ "nextPollAt": "2026-01-02T00:04:15.000Z",
1460
+ "orgId": "org_pending_reconciliation",
1461
+ "pollFailureCount": 0,
1462
+ "pollLeaseUntil": null,
1463
+ "pollLeaseVersion": 7,
1464
+ "projectId": null,
1465
+ "providerId": "relay",
1466
+ "providerOutputToken": Any<Object>,
1467
+ "providerRequestIds": [],
1468
+ "providerState": {
1469
+ "reconciliation": {
1470
+ "pendingRequestIds": [],
1471
+ "requestIds": [
1472
+ "relay-pending-request",
1473
+ ],
1474
+ "updatedAt": "2026-01-02T00:03:00.500Z",
1475
+ "webhookTiming": {
1476
+ "enqueuedAt": "2026-01-02T00:03:07.000Z",
1477
+ "providerStatus": "pending",
1478
+ "providerUpdatedAt": "2026-01-02T00:03:00.000Z",
1479
+ "receivedAt": "2026-01-02T00:03:06.000Z",
1480
+ "reconciliationCompletedAt": "2026-01-02T00:03:15.000Z",
1481
+ "requestId": "relay-pending-request",
1482
+ "sentAt": "2026-01-02T00:03:05.000Z",
1483
+ },
1484
+ },
1485
+ },
1486
+ "recipient": "0x1111111111111111111111111111111111111111",
1487
+ "refundAddress": "0x9999999999999999999999999999999999999999",
1488
+ "snapshot": Any<Object>,
1489
+ "sourceChainId": "eip155:8453",
1490
+ "sourceTokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
1491
+ "status": "active",
1492
+ "subsidize": false,
1493
+ "updatedAt": "2026-01-02T00:00:00.000Z",
1494
+ "version": 1,
1495
+ },
1496
+ "webhook": {
1497
+ "created": 0,
1498
+ "type": "completed",
1499
+ "updated": 0,
1500
+ },
1501
+ }
1502
+ `,
1503
+ )
1504
+ } finally {
1505
+ await server.closeAsync()
1506
+ }
1507
+ })
1508
+
1509
+ test('completes subsidized Relay delivery from authenticated chain evidence', async () => {
1510
+ const route = TestFunding.transferSnapshot()
1511
+ const ambiguousOrderId = `0x${'3d'.repeat(32)}`
1512
+ const ambiguousSweepTransactionHash = `0x${'3e'.repeat(32)}`
1513
+ const depositAddress = `0x${'31'.repeat(20)}`
1514
+ const depository = `0x${'32'.repeat(20)}`
1515
+ const destinationTransactionHash = `0x${'33'.repeat(32)}`
1516
+ const orderId = `0x${'34'.repeat(32)}`
1517
+ const refundAddress = `0x${'38'.repeat(20)}`
1518
+ const solver = `0x${'35'.repeat(20)}`
1519
+ const sourceSweepTransactionHash = `0x${'36'.repeat(32)}`
1520
+ const sourceTransactionHash = `0x${'37'.repeat(32)}`
1521
+ const address = await DepositAddress.create(db, {
1522
+ apiKeyId: 'key_delivery_observation',
1523
+ deliveryStrategy: 'provider',
1524
+ environment: 'production',
1525
+ now: new Date('2026-01-04T00:00:00.000Z'),
1526
+ orgId: 'org_delivery_observation',
1527
+ providerOutputToken: route.destinationToken,
1528
+ snapshot: {
1529
+ address: depositAddress,
1530
+ destinationChain: route.destinationChain,
1531
+ destinationToken: route.destinationToken,
1532
+ provider: { id: 'relay', name: 'Relay' },
1533
+ recipient: route.recipient,
1534
+ refundAddress,
1535
+ sourceChain: route.sourceChain,
1536
+ sourceToken: route.sourceToken,
1537
+ subsidize: true,
1538
+ },
1539
+ })
1540
+ const counts: Parameters<Metrics.Metrics['count']>[] = []
1541
+ const dispatches: Parameters<Reconciliation.createTracker.Options['dispatch']>[] = []
1542
+ const metrics = Metrics.from({
1543
+ count(...parameters) {
1544
+ counts.push(parameters)
1545
+ },
1546
+ flush() {},
1547
+ gauge() {},
1548
+ histogram() {},
1549
+ })
1550
+ const rpcMethods: string[] = []
1551
+ let correlated = false
1552
+ let delivered = false
1553
+ const server = await TestRelay.createServer(async (request, response) => {
1554
+ if (request.method === 'GET') {
1555
+ const url = new URL(request.url ?? '/', server.url)
1556
+ response.writeHead(200, { 'content-type': 'application/json' })
1557
+ response.end(
1558
+ JSON.stringify(
1559
+ url.pathname === '/chains'
1560
+ ? {
1561
+ chains: [
1562
+ {
1563
+ id: Number(route.sourceChain.id.slice('eip155:'.length)),
1564
+ protocol: { v2: { depository } },
1565
+ solverAddresses: [],
1566
+ },
1567
+ {
1568
+ id: Number(route.destinationChain.id.slice('eip155:'.length)),
1569
+ solverAddresses: [solver],
1570
+ },
1571
+ ],
1572
+ }
1573
+ : {
1574
+ requests: [
1575
+ {
1576
+ createdAt: '2026-01-04T00:01:00.000Z',
1577
+ data: { outTxs: [] },
1578
+ depositAddress: { depositTxHash: sourceTransactionHash },
1579
+ id: 'relay-observed-request',
1580
+ ...(() => {
1581
+ if (!correlated) return {}
1582
+ return {
1583
+ protocol: {
1584
+ deposit: { origin: { depositor: refundAddress, depository } },
1585
+ orderId,
1586
+ solver: { address: solver },
1587
+ },
1588
+ }
1589
+ })(),
1590
+ status: 'pending',
1591
+ updatedAt: '2026-01-04T00:02:00.000Z',
1592
+ },
1593
+ ],
1594
+ },
1595
+ ),
1596
+ )
1597
+ return
1598
+ }
1599
+
1600
+ const chunks: Uint8Array[] = []
1601
+ for await (const chunk of request) chunks.push(chunk)
1602
+ const body = JSON.parse(NodeBuffer.Buffer.concat(chunks).toString()) as {
1603
+ id: number
1604
+ method: string
1605
+ params?: readonly unknown[] | undefined
1606
+ }
1607
+ rpcMethods.push(body.method)
1608
+ const parameter = body.params?.[0]
1609
+ const result = (() => {
1610
+ if (body.method === 'eth_blockNumber') return '0x100'
1611
+ if (body.method === 'eth_getTransactionByHash')
1612
+ return parameter === destinationTransactionHash
1613
+ ? rpcTransaction({
1614
+ blockNumber: 0xf0,
1615
+ from: solver,
1616
+ hash: destinationTransactionHash,
1617
+ input: AbiFunction.encodeData(
1618
+ AbiFunction.from('function transfer(address recipient,uint256 amount)'),
1619
+ [route.recipient as Address.Address, 1_000_000n],
1620
+ ),
1621
+ to: route.destinationToken.address,
1622
+ })
1623
+ : rpcTransaction({
1624
+ blockNumber: 0x82,
1625
+ from: depositAddress,
1626
+ hash:
1627
+ parameter === sourceSweepTransactionHash
1628
+ ? sourceSweepTransactionHash
1629
+ : ambiguousSweepTransactionHash,
1630
+ input: (() => {
1631
+ if (parameter === sourceSweepTransactionHash)
1632
+ return AbiFunction.encodeData(
1633
+ AbiFunction.from(
1634
+ 'function depositErc20(address depositor,address token,bytes32 id)',
1635
+ ),
1636
+ [
1637
+ refundAddress as Address.Address,
1638
+ route.sourceToken.address as Address.Address,
1639
+ orderId as Hex.Hex,
1640
+ ],
1641
+ )
1642
+ return AbiFunction.encodeData(
1643
+ AbiFunction.from(
1644
+ 'function depositErc20(address depositor,address token,uint256 amount,bytes32 id)',
1645
+ ),
1646
+ [
1647
+ refundAddress as Address.Address,
1648
+ route.sourceToken.address as Address.Address,
1649
+ 1_000_000n,
1650
+ ambiguousOrderId as Hex.Hex,
1651
+ ],
1652
+ )
1653
+ })(),
1654
+ to: depository,
1655
+ })
1656
+ if (body.method === 'eth_getLogs') {
1657
+ const filter = parameter as { address?: string | undefined }
1658
+ if (filter.address?.toLowerCase() === depository.toLowerCase())
1659
+ return [
1660
+ relayDepositLog({
1661
+ amount: 1_000_000n,
1662
+ blockNumber: 0x81,
1663
+ depository,
1664
+ from: refundAddress,
1665
+ orderId: ambiguousOrderId,
1666
+ token: route.sourceToken.address,
1667
+ transactionHash: ambiguousSweepTransactionHash,
1668
+ }),
1669
+ relayDepositLog({
1670
+ amount: 1_000_000n,
1671
+ blockNumber: 0x82,
1672
+ depository,
1673
+ from: refundAddress,
1674
+ orderId,
1675
+ token: route.sourceToken.address,
1676
+ transactionHash: sourceSweepTransactionHash,
1677
+ }),
1678
+ ]
1679
+ if (delivered)
1680
+ return [
1681
+ transferLog({
1682
+ amount: 1_000_000n,
1683
+ blockNumber: 0xf0,
1684
+ recipient: route.recipient,
1685
+ sender: solver,
1686
+ token: route.destinationToken.address,
1687
+ transactionHash: destinationTransactionHash,
1688
+ }),
1689
+ ]
1690
+ return []
1691
+ }
1692
+ if (body.method === 'eth_getTransactionReceipt') {
1693
+ const hash = parameter
1694
+ return {
1695
+ blockNumber: hash === sourceTransactionHash ? '0x80' : '0xf0',
1696
+ logs: [
1697
+ hash === sourceTransactionHash
1698
+ ? transferLog({
1699
+ amount: 1_000_000n,
1700
+ recipient: depositAddress,
1701
+ sender: `0x${'3c'.repeat(20)}`,
1702
+ token: route.sourceToken.address,
1703
+ })
1704
+ : transferLog({
1705
+ amount: 1_000_000n,
1706
+ recipient: route.recipient,
1707
+ sender: solver,
1708
+ token: route.destinationToken.address,
1709
+ }),
1710
+ ],
1711
+ status: '0x1',
1712
+ }
1713
+ }
1714
+ throw new Error(`Unexpected RPC method: ${body.method}`)
1715
+ })()
1716
+ response.writeHead(200, { 'content-type': 'application/json' })
1717
+ response.end(JSON.stringify({ id: body.id, jsonrpc: '2.0', result }))
1718
+ })
1719
+
1720
+ try {
1721
+ await FundingCatalog.publish(db, {
1722
+ chainTokens: [],
1723
+ chains: [
1724
+ {
1725
+ aliases: [],
1726
+ id: route.destinationChain.id as Chain.Id,
1727
+ name: route.destinationChain.name,
1728
+ parentChainId: null,
1729
+ rpcUrls: [server.url],
1730
+ slug: 'destination',
1731
+ },
1732
+ {
1733
+ aliases: [],
1734
+ id: route.sourceChain.id as Chain.Id,
1735
+ name: route.sourceChain.name,
1736
+ parentChainId: null,
1737
+ rpcUrls: [server.url],
1738
+ slug: 'source',
1739
+ },
1740
+ ],
1741
+ routes: [],
1742
+ tokens: [],
1743
+ })
1744
+ const provider = Relay.relay({
1745
+ apiKey: 'relay-api-key',
1746
+ baseUrl: server.url,
1747
+ now: () => new Date('2026-01-04T00:03:00.000Z'),
1748
+ observation: { db },
1749
+ })
1750
+ const tracker = Reconciliation.createTracker({
1751
+ db,
1752
+ dispatch: async (...parameters) => {
1753
+ dispatches.push(parameters)
1754
+ },
1755
+ metrics,
1756
+ now: () => new Date('2026-01-04T00:03:00.000Z'),
1757
+ providers: [provider],
1758
+ verifyTransfers: Evidence.createVerifier({ db }),
1759
+ })
1760
+ const message = {
1761
+ addressId: address.id,
1762
+ requestId: 'relay-observed-request',
1763
+ trigger: 'webhook',
1764
+ type: 'funding:deposit-address:reconcile',
1765
+ } satisfies Provider.Webhook.receive.Dispatchable
1766
+ const pending = await tracker.reconcile(message)
1767
+ const [followUp] = dispatches
1768
+ if (!followUp) throw new Error('Expected a delivery follow-up message.')
1769
+ correlated = true
1770
+ delivered = true
1771
+ const completed = await tracker.reconcile(followUp[0])
1772
+ const [record] = await FundingDeposits.listBySourceTransaction(db, {
1773
+ depositAddressId: address.id,
1774
+ sourceTransactionHash,
1775
+ })
1776
+
1777
+ expect({
1778
+ completed,
1779
+ counts,
1780
+ dispatches: dispatches.map(([message, dispatchOptions]) => [
1781
+ { ...message, addressId: '<address-id>' },
1782
+ dispatchOptions,
1783
+ ]),
1784
+ pending,
1785
+ record,
1786
+ rpcMethods,
1787
+ }).toMatchInlineSnapshot(
1788
+ {
1789
+ record: {
1790
+ createdAt: expect.any(String),
1791
+ depositAddressId: expect.any(String),
1792
+ id: expect.any(String),
1793
+ snapshot: { depositAddressId: expect.any(String) },
1794
+ updatedAt: expect.any(String),
1795
+ },
1796
+ },
1797
+ `
1798
+ {
1799
+ "completed": {
1800
+ "created": 0,
1801
+ "type": "completed",
1802
+ "updated": 1,
1803
+ },
1804
+ "counts": [
1805
+ [
1806
+ "funding_deposit_delivery_observation_count",
1807
+ 1,
1808
+ {
1809
+ "outcome": "pending",
1810
+ "provider": "relay",
1811
+ },
1812
+ ],
1813
+ [
1814
+ "funding_deposit_detection_count",
1815
+ 1,
1816
+ {
1817
+ "provider": "relay",
1818
+ "trigger": "webhook",
1819
+ },
1820
+ ],
1821
+ [
1822
+ "funding_deposit_reconciliation_count",
1823
+ 1,
1824
+ {
1825
+ "outcome": "follow_up_enqueued",
1826
+ "provider": "relay",
1827
+ "trigger": "webhook",
1828
+ },
1829
+ ],
1830
+ [
1831
+ "funding_deposit_reconciliation_count",
1832
+ 1,
1833
+ {
1834
+ "outcome": "completed",
1835
+ "provider": "relay",
1836
+ "trigger": "webhook",
1837
+ },
1838
+ ],
1839
+ [
1840
+ "funding_deposit_delivery_observation_count",
1841
+ 1,
1842
+ {
1843
+ "outcome": "verified",
1844
+ "provider": "relay",
1845
+ },
1846
+ ],
1847
+ [
1848
+ "funding_deposit_reconciliation_count",
1849
+ 1,
1850
+ {
1851
+ "outcome": "completed",
1852
+ "provider": "relay",
1853
+ "trigger": "webhook",
1854
+ },
1855
+ ],
1856
+ ],
1857
+ "dispatches": [
1858
+ [
1859
+ {
1860
+ "addressId": "<address-id>",
1861
+ "followUp": {
1862
+ "attempt": 0,
1863
+ "kind": "delivery",
1864
+ },
1865
+ "requestId": "relay-observed-request",
1866
+ "trigger": "webhook",
1867
+ "type": "funding:deposit-address:reconcile",
1868
+ },
1869
+ {
1870
+ "delaySeconds": 1,
1871
+ },
1872
+ ],
1873
+ ],
1874
+ "pending": {
1875
+ "created": 1,
1876
+ "type": "completed",
1877
+ "updated": 1,
1878
+ },
1879
+ "record": {
1880
+ "createdAt": Any<String>,
1881
+ "depositAddressId": Any<String>,
1882
+ "detectionTrigger": "webhook",
1883
+ "environment": "production",
1884
+ "id": Any<String>,
1885
+ "orgId": "org_delivery_observation",
1886
+ "pollObservedAt": null,
1887
+ "projectId": null,
1888
+ "providerOutputAmount": {
1889
+ "baseUnits": "1000000",
1890
+ "currency": "USD",
1891
+ "decimals": 6,
1892
+ "formatted": "1",
1893
+ },
1894
+ "providerOutputToken": {
1895
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
1896
+ "currency": "USD",
1897
+ "decimals": 6,
1898
+ "name": "Bridged USDC (Stargate)",
1899
+ "standard": "TIP-20",
1900
+ "symbol": "USDC.e",
1901
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
1902
+ "verified": true,
1903
+ },
1904
+ "providerRequestId": "relay-observed-request",
1905
+ "providerRequestIds": [
1906
+ "relay-observed-request",
1907
+ ],
1908
+ "providerState": {
1909
+ "relay": {
1910
+ "destinationObservedAt": "2026-01-04T00:03:00.000Z",
1911
+ "orderId": "0x3434343434343434343434343434343434343434343434343434343434343434",
1912
+ "sourceDepository": "0x3232323232323232323232323232323232323232",
1913
+ "sourceObservedAt": "2026-01-04T00:03:00.000Z",
1914
+ "sourceSweepTransactionHash": "0x3636363636363636363636363636363636363636363636363636363636363636",
1915
+ },
1916
+ },
1917
+ "providerTransactionHashes": [
1918
+ "0x3636363636363636363636363636363636363636363636363636363636363636",
1919
+ "0x3333333333333333333333333333333333333333333333333333333333333333",
1920
+ ],
1921
+ "providerTransferIndex": 0,
1922
+ "retryState": null,
1923
+ "settlementTransaction": null,
1924
+ "settlementTransactionHash": null,
1925
+ "snapshot": {
1926
+ "depositAddressId": Any<String>,
1927
+ "destinationAmount": {
1928
+ "baseUnits": "1000000",
1929
+ "currency": "USD",
1930
+ "decimals": 6,
1931
+ "formatted": "1",
1932
+ },
1933
+ "destinationAmountRequired": {
1934
+ "baseUnits": "1000000",
1935
+ "currency": "USD",
1936
+ "decimals": 6,
1937
+ "formatted": "1",
1938
+ },
1939
+ "destinationChain": {
1940
+ "addressFormat": "hex",
1941
+ "id": "eip155:4217",
1942
+ "kind": "evm",
1943
+ "name": "Tempo",
1944
+ },
1945
+ "destinationToken": {
1946
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
1947
+ "currency": "USD",
1948
+ "decimals": 6,
1949
+ "name": "Bridged USDC (Stargate)",
1950
+ "standard": "TIP-20",
1951
+ "symbol": "USDC.e",
1952
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
1953
+ "verified": true,
1954
+ },
1955
+ "destinationTransactionHashes": [
1956
+ "0x3333333333333333333333333333333333333333333333333333333333333333",
1957
+ ],
1958
+ "provider": {
1959
+ "id": "relay",
1960
+ "name": "Relay",
1961
+ },
1962
+ "recipient": "0x1111111111111111111111111111111111111111",
1963
+ "refundAddress": "0x3838383838383838383838383838383838383838",
1964
+ "sender": "0x3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c",
1965
+ "sourceAmount": {
1966
+ "baseUnits": "1000000",
1967
+ "currency": "USD",
1968
+ "decimals": 6,
1969
+ "formatted": "1",
1970
+ },
1971
+ "sourceChain": {
1972
+ "addressFormat": "hex",
1973
+ "id": "eip155:8453",
1974
+ "kind": "evm",
1975
+ "name": "Base",
1976
+ },
1977
+ "sourceToken": {
1978
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
1979
+ "currency": "USD",
1980
+ "decimals": 6,
1981
+ "name": "USD Coin",
1982
+ "standard": "ERC-20",
1983
+ "symbol": "USDC",
1984
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
1985
+ "verified": true,
1986
+ },
1987
+ "sourceTransactionHashes": [
1988
+ "0x3737373737373737373737373737373737373737373737373737373737373737",
1989
+ ],
1990
+ },
1991
+ "sourceChainId": "eip155:8453",
1992
+ "sourceTransactionHash": "0x3737373737373737373737373737373737373737373737373737373737373737",
1993
+ "sourceTransferIndex": 0,
1994
+ "status": "completed",
1995
+ "statusReason": null,
1996
+ "subsidyAmount": null,
1997
+ "tempoGasPaid": null,
1998
+ "updatedAt": Any<String>,
1999
+ "version": 5,
2000
+ "webhookReceivedAt": null,
2001
+ },
2002
+ "rpcMethods": [
2003
+ "eth_getTransactionReceipt",
2004
+ "eth_blockNumber",
2005
+ "eth_getTransactionReceipt",
2006
+ "eth_blockNumber",
2007
+ "eth_getLogs",
2008
+ "eth_getTransactionByHash",
2009
+ "eth_getTransactionByHash",
2010
+ "eth_getTransactionReceipt",
2011
+ "eth_blockNumber",
2012
+ "eth_getTransactionReceipt",
2013
+ "eth_blockNumber",
2014
+ "eth_getLogs",
2015
+ "eth_getTransactionByHash",
2016
+ "eth_blockNumber",
2017
+ "eth_getLogs",
2018
+ "eth_getTransactionByHash",
2019
+ "eth_getTransactionReceipt",
2020
+ "eth_blockNumber",
2021
+ ],
2022
+ }
2023
+ `,
2024
+ )
2025
+ } finally {
2026
+ await server.closeAsync()
2027
+ }
2028
+ })
2029
+
2030
+ test('renews the address lease during a slow provider read', async () => {
2031
+ const route = TestFunding.transferSnapshot()
2032
+ const depositAddress = `0x${'16'.repeat(20)}`
2033
+ const address = await DepositAddress.create(db, {
2034
+ apiKeyId: 'key_lease_reconciliation',
2035
+ deliveryStrategy: 'provider',
2036
+ environment: 'production',
2037
+ now: new Date('2026-01-04T00:00:00.000Z'),
2038
+ orgId: 'org_lease_reconciliation',
2039
+ providerOutputToken: route.destinationToken,
2040
+ snapshot: {
2041
+ address: depositAddress,
2042
+ destinationChain: route.destinationChain,
2043
+ destinationToken: route.destinationToken,
2044
+ provider: { id: 'relay', name: 'Relay' },
2045
+ recipient: route.recipient,
2046
+ refundAddress: `0x${'17'.repeat(20)}`,
2047
+ sourceChain: route.sourceChain,
2048
+ sourceToken: route.sourceToken,
2049
+ subsidize: false,
2050
+ },
2051
+ })
2052
+ const providerReleased = Promise.withResolvers<void>()
2053
+ const providerStarted = Promise.withResolvers<void>()
2054
+ const server = await TestRelay.createServer(async (request, response) => {
2055
+ if (request.method !== 'GET') throw new Error('Expected a Relay request read.')
2056
+ providerStarted.resolve()
2057
+ await providerReleased.promise
2058
+ response.writeHead(200, { 'content-type': 'application/json' })
2059
+ response.end(JSON.stringify({ requests: [] }))
2060
+ })
2061
+
2062
+ try {
2063
+ vi.useFakeTimers({ now: new Date('2027-01-04T00:00:00.000Z') })
2064
+ const tracker = Reconciliation.createTracker({
2065
+ db,
2066
+ dispatch: async () => undefined,
2067
+ leaseMs: 100,
2068
+ now: () => new Date(),
2069
+ providers: [Relay.relay({ apiKey: 'relay-api-key', baseUrl: server.url })],
2070
+ verifyTransfers: Evidence.createVerifier({ db }),
2071
+ })
2072
+
2073
+ const reconciliation = tracker.reconcile({
2074
+ addressId: address.id,
2075
+ trigger: 'webhook',
2076
+ type: 'funding:deposit-address:reconcile',
2077
+ })
2078
+ await providerStarted.promise
2079
+ await vi.advanceTimersByTimeAsync(60)
2080
+ const renewed = await FundingDepositAddresses.get(db, address.id)
2081
+ providerReleased.resolve()
2082
+ const result = await reconciliation
2083
+ const completed = await FundingDepositAddresses.get(db, address.id)
2084
+
2085
+ expect({ completed, renewed, result }).toMatchInlineSnapshot(
2086
+ {
2087
+ completed: {
2088
+ id: expect.any(String),
2089
+ providerOutputToken: expect.any(Object),
2090
+ snapshot: expect.any(Object),
2091
+ },
2092
+ renewed: {
2093
+ id: expect.any(String),
2094
+ providerOutputToken: expect.any(Object),
2095
+ snapshot: expect.any(Object),
2096
+ },
2097
+ },
2098
+ `
2099
+ {
2100
+ "completed": {
2101
+ "address": "0x1616161616161616161616161616161616161616",
2102
+ "apiKeyId": "key_lease_reconciliation",
2103
+ "createdAt": "2026-01-04T00:00:00.000Z",
2104
+ "deliveryStrategy": "provider",
2105
+ "destinationTokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2106
+ "environment": "production",
2107
+ "id": Any<String>,
2108
+ "lastPolledAt": "2027-01-04T00:00:00.060Z",
2109
+ "nextPollAt": "2027-01-04T00:01:00.060Z",
2110
+ "orgId": "org_lease_reconciliation",
2111
+ "pollFailureCount": 0,
2112
+ "pollLeaseUntil": null,
2113
+ "pollLeaseVersion": 1,
2114
+ "projectId": null,
2115
+ "providerId": "relay",
2116
+ "providerOutputToken": Any<Object>,
2117
+ "providerRequestIds": [],
2118
+ "providerState": {
2119
+ "reconciliation": {
2120
+ "pendingRequestIds": [],
2121
+ "requestIds": [],
2122
+ },
2123
+ },
2124
+ "recipient": "0x1111111111111111111111111111111111111111",
2125
+ "refundAddress": "0x1717171717171717171717171717171717171717",
2126
+ "snapshot": Any<Object>,
2127
+ "sourceChainId": "eip155:8453",
2128
+ "sourceTokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2129
+ "status": "active",
2130
+ "subsidize": false,
2131
+ "updatedAt": "2026-01-04T00:00:00.000Z",
2132
+ "version": 1,
2133
+ },
2134
+ "renewed": {
2135
+ "address": "0x1616161616161616161616161616161616161616",
2136
+ "apiKeyId": "key_lease_reconciliation",
2137
+ "createdAt": "2026-01-04T00:00:00.000Z",
2138
+ "deliveryStrategy": "provider",
2139
+ "destinationTokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2140
+ "environment": "production",
2141
+ "id": Any<String>,
2142
+ "lastPolledAt": null,
2143
+ "nextPollAt": "2026-01-04T00:00:00.000Z",
2144
+ "orgId": "org_lease_reconciliation",
2145
+ "pollFailureCount": 0,
2146
+ "pollLeaseUntil": "2027-01-04T00:00:00.150Z",
2147
+ "pollLeaseVersion": 1,
2148
+ "projectId": null,
2149
+ "providerId": "relay",
2150
+ "providerOutputToken": Any<Object>,
2151
+ "providerRequestIds": [],
2152
+ "providerState": null,
2153
+ "recipient": "0x1111111111111111111111111111111111111111",
2154
+ "refundAddress": "0x1717171717171717171717171717171717171717",
2155
+ "snapshot": Any<Object>,
2156
+ "sourceChainId": "eip155:8453",
2157
+ "sourceTokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2158
+ "status": "active",
2159
+ "subsidize": false,
2160
+ "updatedAt": "2026-01-04T00:00:00.000Z",
2161
+ "version": 1,
2162
+ },
2163
+ "result": {
2164
+ "created": 0,
2165
+ "type": "completed",
2166
+ "updated": 0,
2167
+ },
2168
+ }
2169
+ `,
2170
+ )
2171
+ } finally {
2172
+ providerReleased.resolve()
2173
+ vi.useRealTimers()
2174
+ await server.closeAsync()
2175
+ }
2176
+ })
2177
+
2178
+ test('waits for every source transaction before allocating provider output', async () => {
2179
+ const route = TestFunding.transferSnapshot()
2180
+ const depositAddress = `0x${'21'.repeat(20)}`
2181
+ const firstSourceTransactionHash = `0x${'31'.repeat(32)}`
2182
+ const secondSourceTransactionHash = `0x${'32'.repeat(32)}`
2183
+ const destinationTransactionHash = `0x${'33'.repeat(32)}`
2184
+ const address = await DepositAddress.create(db, {
2185
+ apiKeyId: 'key_source_evidence_reconciliation',
2186
+ deliveryStrategy: 'provider',
2187
+ environment: 'production',
2188
+ now: new Date('2026-01-05T00:00:00.000Z'),
2189
+ orgId: 'org_source_evidence_reconciliation',
2190
+ providerOutputToken: route.destinationToken,
2191
+ snapshot: {
2192
+ address: depositAddress,
2193
+ destinationChain: route.destinationChain,
2194
+ destinationToken: route.destinationToken,
2195
+ provider: { id: 'local', name: 'Local' },
2196
+ recipient: route.recipient,
2197
+ refundAddress: `0x${'22'.repeat(20)}`,
2198
+ sourceChain: route.sourceChain,
2199
+ sourceToken: route.sourceToken,
2200
+ subsidize: false,
2201
+ },
2202
+ })
2203
+ let destinationReceiptReads = 0
2204
+ const server = await TestRelay.createServer(async (request, response) => {
2205
+ const chunks: Uint8Array[] = []
2206
+ for await (const chunk of request) chunks.push(chunk)
2207
+ const body = JSON.parse(NodeBuffer.Buffer.concat(chunks).toString()) as {
2208
+ id: number
2209
+ method: string
2210
+ params?: readonly string[] | undefined
2211
+ }
2212
+ const hash = body.params?.[0]
2213
+ const result = (() => {
2214
+ if (body.method === 'eth_blockNumber') return '0x100'
2215
+ if (hash === secondSourceTransactionHash) return null
2216
+ const source = hash === firstSourceTransactionHash
2217
+ if (!source) destinationReceiptReads += 1
2218
+ return {
2219
+ blockNumber: '0x80',
2220
+ logs: [
2221
+ transferLog({
2222
+ amount: source ? 1_000_000n : 3_000_000n,
2223
+ recipient: source ? depositAddress : route.recipient,
2224
+ sender: `0x${'23'.repeat(20)}`,
2225
+ token: source ? route.sourceToken.address : route.destinationToken.address,
2226
+ }),
2227
+ ],
2228
+ status: '0x1',
2229
+ }
2230
+ })()
2231
+ response.writeHead(200, { 'content-type': 'application/json' })
2232
+ response.end(JSON.stringify({ id: body.id, jsonrpc: '2.0', result }))
2233
+ })
2234
+
2235
+ try {
2236
+ await FundingCatalog.publish(db, {
2237
+ chainTokens: [],
2238
+ chains: [
2239
+ {
2240
+ aliases: [],
2241
+ id: route.destinationChain.id as Chain.Id,
2242
+ name: route.destinationChain.name,
2243
+ parentChainId: null,
2244
+ rpcUrls: [server.url],
2245
+ slug: 'destination-source-evidence',
2246
+ },
2247
+ {
2248
+ aliases: [],
2249
+ id: route.sourceChain.id as Chain.Id,
2250
+ name: route.sourceChain.name,
2251
+ parentChainId: null,
2252
+ rpcUrls: [server.url],
2253
+ slug: 'source-source-evidence',
2254
+ },
2255
+ ],
2256
+ routes: [],
2257
+ tokens: [],
2258
+ })
2259
+ const result = await Reconciliation.reconcileRequest(db, {
2260
+ address,
2261
+ request: {
2262
+ createdAt: '2026-01-05T00:01:00.000Z',
2263
+ destinationTransactionHashes: [destinationTransactionHash],
2264
+ id: 'source-evidence-request',
2265
+ sourceTransactionHashes: [firstSourceTransactionHash, secondSourceTransactionHash],
2266
+ status: 'success',
2267
+ updatedAt: '2026-01-05T00:02:00.000Z',
2268
+ },
2269
+ verifyTransfers: Evidence.createVerifier({ db }),
2270
+ })
2271
+ const records = (
2272
+ await FundingDeposits.listByAddress(
2273
+ db,
2274
+ { environment: 'production', orgId: 'org_source_evidence_reconciliation' },
2275
+ address.id,
2276
+ { limit: 10 },
2277
+ )
2278
+ ).toSorted((left, right) =>
2279
+ left.sourceTransactionHash.localeCompare(right.sourceTransactionHash),
2280
+ )
2281
+
2282
+ expect({ destinationReceiptReads, records, result }).toMatchInlineSnapshot(
2283
+ {
2284
+ records: [
2285
+ {
2286
+ createdAt: expect.any(String),
2287
+ depositAddressId: expect.any(String),
2288
+ id: expect.any(String),
2289
+ snapshot: { depositAddressId: expect.any(String) },
2290
+ updatedAt: expect.any(String),
2291
+ },
2292
+ {
2293
+ createdAt: expect.any(String),
2294
+ depositAddressId: expect.any(String),
2295
+ id: expect.any(String),
2296
+ snapshot: { depositAddressId: expect.any(String) },
2297
+ updatedAt: expect.any(String),
2298
+ },
2299
+ ],
2300
+ },
2301
+ `
2302
+ {
2303
+ "destinationReceiptReads": 0,
2304
+ "records": [
2305
+ {
2306
+ "createdAt": Any<String>,
2307
+ "depositAddressId": Any<String>,
2308
+ "detectionTrigger": "poll",
2309
+ "environment": "production",
2310
+ "id": Any<String>,
2311
+ "orgId": "org_source_evidence_reconciliation",
2312
+ "pollObservedAt": null,
2313
+ "projectId": null,
2314
+ "providerOutputAmount": null,
2315
+ "providerOutputToken": {
2316
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
2317
+ "currency": "USD",
2318
+ "decimals": 6,
2319
+ "name": "Bridged USDC (Stargate)",
2320
+ "standard": "TIP-20",
2321
+ "symbol": "USDC.e",
2322
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2323
+ "verified": true,
2324
+ },
2325
+ "providerRequestId": "source-evidence-request",
2326
+ "providerRequestIds": [
2327
+ "source-evidence-request",
2328
+ ],
2329
+ "providerState": null,
2330
+ "providerTransactionHashes": [],
2331
+ "providerTransferIndex": 0,
2332
+ "retryState": null,
2333
+ "settlementTransaction": null,
2334
+ "settlementTransactionHash": null,
2335
+ "snapshot": {
2336
+ "depositAddressId": Any<String>,
2337
+ "destinationChain": {
2338
+ "addressFormat": "hex",
2339
+ "id": "eip155:4217",
2340
+ "kind": "evm",
2341
+ "name": "Tempo",
2342
+ },
2343
+ "destinationToken": {
2344
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
2345
+ "currency": "USD",
2346
+ "decimals": 6,
2347
+ "name": "Bridged USDC (Stargate)",
2348
+ "standard": "TIP-20",
2349
+ "symbol": "USDC.e",
2350
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2351
+ "verified": true,
2352
+ },
2353
+ "provider": {
2354
+ "id": "local",
2355
+ "name": "Local",
2356
+ },
2357
+ "recipient": "0x1111111111111111111111111111111111111111",
2358
+ "refundAddress": "0x2222222222222222222222222222222222222222",
2359
+ "sender": "0x2323232323232323232323232323232323232323",
2360
+ "sourceAmount": {
2361
+ "baseUnits": "1000000",
2362
+ "currency": "USD",
2363
+ "decimals": 6,
2364
+ "formatted": "1",
2365
+ },
2366
+ "sourceChain": {
2367
+ "addressFormat": "hex",
2368
+ "id": "eip155:8453",
2369
+ "kind": "evm",
2370
+ "name": "Base",
2371
+ },
2372
+ "sourceToken": {
2373
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2374
+ "currency": "USD",
2375
+ "decimals": 6,
2376
+ "name": "USD Coin",
2377
+ "standard": "ERC-20",
2378
+ "symbol": "USDC",
2379
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2380
+ "verified": true,
2381
+ },
2382
+ "sourceTransactionHashes": [
2383
+ "0x3131313131313131313131313131313131313131313131313131313131313131",
2384
+ ],
2385
+ },
2386
+ "sourceChainId": "eip155:8453",
2387
+ "sourceTransactionHash": "0x3131313131313131313131313131313131313131313131313131313131313131",
2388
+ "sourceTransferIndex": 0,
2389
+ "status": "bridging",
2390
+ "statusReason": null,
2391
+ "subsidyAmount": null,
2392
+ "tempoGasPaid": null,
2393
+ "updatedAt": Any<String>,
2394
+ "version": 2,
2395
+ "webhookReceivedAt": null,
2396
+ },
2397
+ {
2398
+ "createdAt": Any<String>,
2399
+ "depositAddressId": Any<String>,
2400
+ "detectionTrigger": "poll",
2401
+ "environment": "production",
2402
+ "id": Any<String>,
2403
+ "orgId": "org_source_evidence_reconciliation",
2404
+ "pollObservedAt": null,
2405
+ "projectId": null,
2406
+ "providerOutputAmount": null,
2407
+ "providerOutputToken": {
2408
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
2409
+ "currency": "USD",
2410
+ "decimals": 6,
2411
+ "name": "Bridged USDC (Stargate)",
2412
+ "standard": "TIP-20",
2413
+ "symbol": "USDC.e",
2414
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2415
+ "verified": true,
2416
+ },
2417
+ "providerRequestId": "source-evidence-request",
2418
+ "providerRequestIds": [
2419
+ "source-evidence-request",
2420
+ ],
2421
+ "providerState": null,
2422
+ "providerTransactionHashes": [],
2423
+ "providerTransferIndex": 0,
2424
+ "retryState": null,
2425
+ "settlementTransaction": null,
2426
+ "settlementTransactionHash": null,
2427
+ "snapshot": {
2428
+ "depositAddressId": Any<String>,
2429
+ "destinationChain": {
2430
+ "addressFormat": "hex",
2431
+ "id": "eip155:4217",
2432
+ "kind": "evm",
2433
+ "name": "Tempo",
2434
+ },
2435
+ "destinationToken": {
2436
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
2437
+ "currency": "USD",
2438
+ "decimals": 6,
2439
+ "name": "Bridged USDC (Stargate)",
2440
+ "standard": "TIP-20",
2441
+ "symbol": "USDC.e",
2442
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2443
+ "verified": true,
2444
+ },
2445
+ "provider": {
2446
+ "id": "local",
2447
+ "name": "Local",
2448
+ },
2449
+ "recipient": "0x1111111111111111111111111111111111111111",
2450
+ "refundAddress": "0x2222222222222222222222222222222222222222",
2451
+ "sourceChain": {
2452
+ "addressFormat": "hex",
2453
+ "id": "eip155:8453",
2454
+ "kind": "evm",
2455
+ "name": "Base",
2456
+ },
2457
+ "sourceToken": {
2458
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2459
+ "currency": "USD",
2460
+ "decimals": 6,
2461
+ "name": "USD Coin",
2462
+ "standard": "ERC-20",
2463
+ "symbol": "USDC",
2464
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2465
+ "verified": true,
2466
+ },
2467
+ "sourceTransactionHashes": [
2468
+ "0x3232323232323232323232323232323232323232323232323232323232323232",
2469
+ ],
2470
+ },
2471
+ "sourceChainId": "eip155:8453",
2472
+ "sourceTransactionHash": "0x3232323232323232323232323232323232323232323232323232323232323232",
2473
+ "sourceTransferIndex": null,
2474
+ "status": "detected",
2475
+ "statusReason": null,
2476
+ "subsidyAmount": null,
2477
+ "tempoGasPaid": null,
2478
+ "updatedAt": Any<String>,
2479
+ "version": 1,
2480
+ "webhookReceivedAt": null,
2481
+ },
2482
+ ],
2483
+ "result": {
2484
+ "created": 2,
2485
+ "terminal": false,
2486
+ "updated": 1,
2487
+ },
2488
+ }
2489
+ `,
2490
+ )
2491
+ } finally {
2492
+ await server.closeAsync()
2493
+ }
2494
+ })
2495
+
2496
+ test('records multiple source transfers with finer precision independently', async () => {
2497
+ const route = TestFunding.transferSnapshot()
2498
+ const sourceToken = { ...route.sourceToken, decimals: 18 }
2499
+ const depositAddress = `0x${'12'.repeat(20)}`
2500
+ const sourceTransactionHash = `0x${'ee'.repeat(32)}`
2501
+ const destinationTransactionHash = `0x${'ff'.repeat(32)}`
2502
+ const address = await DepositAddress.create(db, {
2503
+ apiKeyId: 'key_precision_reconciliation',
2504
+ deliveryStrategy: 'provider',
2505
+ environment: 'production',
2506
+ now: new Date('2026-01-03T00:00:00.000Z'),
2507
+ orgId: 'org_precision_reconciliation',
2508
+ providerOutputToken: route.destinationToken,
2509
+ providerRequestIds: ['relay-address-request'],
2510
+ snapshot: {
2511
+ address: depositAddress,
2512
+ destinationChain: route.destinationChain,
2513
+ destinationToken: route.destinationToken,
2514
+ provider: { id: 'relay', name: 'Relay' },
2515
+ recipient: route.recipient,
2516
+ refundAddress: `0x${'13'.repeat(20)}`,
2517
+ sourceChain: route.sourceChain,
2518
+ sourceToken,
2519
+ subsidize: false,
2520
+ },
2521
+ })
2522
+ const server = await TestRelay.createServer(async (request, response) => {
2523
+ if (request.method === 'GET') {
2524
+ response.writeHead(200, { 'content-type': 'application/json' })
2525
+ response.end(
2526
+ JSON.stringify({
2527
+ requests: [
2528
+ {
2529
+ createdAt: '2026-01-03T00:01:00.000Z',
2530
+ data: {
2531
+ inTxs: [{ txHash: sourceTransactionHash }],
2532
+ outTxs: [{ txHash: destinationTransactionHash }],
2533
+ },
2534
+ depositAddress: { depositTxHash: sourceTransactionHash },
2535
+ id: 'relay-multiple-transfer-request',
2536
+ status: 'success',
2537
+ updatedAt: '2026-01-03T00:02:00.000Z',
2538
+ },
2539
+ ],
2540
+ }),
2541
+ )
2542
+ return
2543
+ }
2544
+
2545
+ const chunks: Uint8Array[] = []
2546
+ for await (const chunk of request) chunks.push(chunk)
2547
+ const body = JSON.parse(NodeBuffer.Buffer.concat(chunks).toString()) as {
2548
+ id: number
2549
+ method: string
2550
+ params?: readonly string[] | undefined
2551
+ }
2552
+ const hash = body.params?.[0]
2553
+ const result =
2554
+ body.method === 'eth_blockNumber'
2555
+ ? '0x100'
2556
+ : {
2557
+ blockNumber: '0x80',
2558
+ logs:
2559
+ hash === sourceTransactionHash
2560
+ ? [
2561
+ transferLog({
2562
+ amount: 1_000_000_000_000_000_001n,
2563
+ logIndex: 0,
2564
+ recipient: depositAddress,
2565
+ sender: `0x${'14'.repeat(20)}`,
2566
+ token: sourceToken.address,
2567
+ }),
2568
+ transferLog({
2569
+ amount: 2_000_000_000_000_000_001n,
2570
+ logIndex: 1,
2571
+ recipient: depositAddress,
2572
+ sender: `0x${'14'.repeat(20)}`,
2573
+ token: sourceToken.address,
2574
+ }),
2575
+ ]
2576
+ : [
2577
+ transferLog({
2578
+ amount: 3_000_000n,
2579
+ logIndex: 0,
2580
+ recipient: route.recipient,
2581
+ sender: `0x${'15'.repeat(20)}`,
2582
+ token: route.destinationToken.address,
2583
+ }),
2584
+ ],
2585
+ status: '0x1',
2586
+ }
2587
+ response.writeHead(200, { 'content-type': 'application/json' })
2588
+ response.end(JSON.stringify({ id: body.id, jsonrpc: '2.0', result }))
2589
+ })
2590
+
2591
+ try {
2592
+ await FundingCatalog.publish(db, {
2593
+ chainTokens: [],
2594
+ chains: [
2595
+ {
2596
+ aliases: [],
2597
+ id: route.destinationChain.id as Chain.Id,
2598
+ name: route.destinationChain.name,
2599
+ parentChainId: null,
2600
+ rpcUrls: [server.url],
2601
+ slug: 'destination',
2602
+ },
2603
+ {
2604
+ aliases: [],
2605
+ id: route.sourceChain.id as Chain.Id,
2606
+ name: route.sourceChain.name,
2607
+ parentChainId: null,
2608
+ rpcUrls: [server.url],
2609
+ slug: 'source',
2610
+ },
2611
+ ],
2612
+ routes: [],
2613
+ tokens: [],
2614
+ })
2615
+ const tracker = Reconciliation.createTracker({
2616
+ db,
2617
+ dispatch: async () => undefined,
2618
+ now: () => new Date('2027-01-03T00:00:00.000Z'),
2619
+ providers: [Relay.relay({ apiKey: 'relay-api-key', baseUrl: server.url })],
2620
+ verifyTransfers: Evidence.createVerifier({ db }),
2621
+ })
2622
+
2623
+ const result = await tracker.reconcile({
2624
+ addressId: address.id,
2625
+ trigger: 'webhook',
2626
+ type: 'funding:deposit-address:reconcile',
2627
+ })
2628
+ const records = (
2629
+ await FundingDeposits.listByAddress(
2630
+ db,
2631
+ { environment: 'production', orgId: 'org_precision_reconciliation' },
2632
+ address.id,
2633
+ { limit: 10 },
2634
+ )
2635
+ ).toSorted(
2636
+ (left, right) => (right.sourceTransferIndex ?? -1) - (left.sourceTransferIndex ?? -1),
2637
+ )
2638
+ const storedAddress = await FundingDepositAddresses.get(db, address.id)
2639
+
2640
+ expect({ records, result, storedAddress }).toMatchInlineSnapshot(
2641
+ {
2642
+ records: [
2643
+ {
2644
+ createdAt: expect.any(String),
2645
+ depositAddressId: expect.any(String),
2646
+ id: expect.any(String),
2647
+ snapshot: { depositAddressId: expect.any(String) },
2648
+ updatedAt: expect.any(String),
2649
+ },
2650
+ {
2651
+ createdAt: expect.any(String),
2652
+ depositAddressId: expect.any(String),
2653
+ id: expect.any(String),
2654
+ snapshot: { depositAddressId: expect.any(String) },
2655
+ updatedAt: expect.any(String),
2656
+ },
2657
+ ],
2658
+ storedAddress: {
2659
+ id: expect.any(String),
2660
+ providerOutputToken: expect.any(Object),
2661
+ snapshot: expect.any(Object),
2662
+ },
2663
+ },
2664
+ `
2665
+ {
2666
+ "records": [
2667
+ {
2668
+ "createdAt": Any<String>,
2669
+ "depositAddressId": Any<String>,
2670
+ "detectionTrigger": "webhook",
2671
+ "environment": "production",
2672
+ "id": Any<String>,
2673
+ "orgId": "org_precision_reconciliation",
2674
+ "pollObservedAt": null,
2675
+ "projectId": null,
2676
+ "providerOutputAmount": {
2677
+ "baseUnits": "2000000",
2678
+ "currency": "USD",
2679
+ "decimals": 6,
2680
+ "formatted": "2",
2681
+ },
2682
+ "providerOutputToken": {
2683
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
2684
+ "currency": "USD",
2685
+ "decimals": 6,
2686
+ "name": "Bridged USDC (Stargate)",
2687
+ "standard": "TIP-20",
2688
+ "symbol": "USDC.e",
2689
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2690
+ "verified": true,
2691
+ },
2692
+ "providerRequestId": "relay-multiple-transfer-request",
2693
+ "providerRequestIds": [
2694
+ "relay-multiple-transfer-request",
2695
+ ],
2696
+ "providerState": null,
2697
+ "providerTransactionHashes": [
2698
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
2699
+ ],
2700
+ "providerTransferIndex": 1,
2701
+ "retryState": null,
2702
+ "settlementTransaction": null,
2703
+ "settlementTransactionHash": null,
2704
+ "snapshot": {
2705
+ "depositAddressId": Any<String>,
2706
+ "destinationAmount": {
2707
+ "baseUnits": "2000000",
2708
+ "currency": "USD",
2709
+ "decimals": 6,
2710
+ "formatted": "2",
2711
+ },
2712
+ "destinationAmountRequired": {
2713
+ "baseUnits": "2000000",
2714
+ "currency": "USD",
2715
+ "decimals": 6,
2716
+ "formatted": "2",
2717
+ },
2718
+ "destinationChain": {
2719
+ "addressFormat": "hex",
2720
+ "id": "eip155:4217",
2721
+ "kind": "evm",
2722
+ "name": "Tempo",
2723
+ },
2724
+ "destinationToken": {
2725
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
2726
+ "currency": "USD",
2727
+ "decimals": 6,
2728
+ "name": "Bridged USDC (Stargate)",
2729
+ "standard": "TIP-20",
2730
+ "symbol": "USDC.e",
2731
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2732
+ "verified": true,
2733
+ },
2734
+ "destinationTransactionHashes": [
2735
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
2736
+ ],
2737
+ "provider": {
2738
+ "id": "relay",
2739
+ "name": "Relay",
2740
+ },
2741
+ "recipient": "0x1111111111111111111111111111111111111111",
2742
+ "refundAddress": "0x1313131313131313131313131313131313131313",
2743
+ "sender": "0x1414141414141414141414141414141414141414",
2744
+ "sourceAmount": {
2745
+ "baseUnits": "2000000000000000001",
2746
+ "currency": "USD",
2747
+ "decimals": 18,
2748
+ "formatted": "2.000000000000000001",
2749
+ },
2750
+ "sourceChain": {
2751
+ "addressFormat": "hex",
2752
+ "id": "eip155:8453",
2753
+ "kind": "evm",
2754
+ "name": "Base",
2755
+ },
2756
+ "sourceToken": {
2757
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2758
+ "currency": "USD",
2759
+ "decimals": 18,
2760
+ "name": "USD Coin",
2761
+ "standard": "ERC-20",
2762
+ "symbol": "USDC",
2763
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2764
+ "verified": true,
2765
+ },
2766
+ "sourceTransactionHashes": [
2767
+ "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
2768
+ ],
2769
+ },
2770
+ "sourceChainId": "eip155:8453",
2771
+ "sourceTransactionHash": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
2772
+ "sourceTransferIndex": 1,
2773
+ "status": "completed",
2774
+ "statusReason": null,
2775
+ "subsidyAmount": null,
2776
+ "tempoGasPaid": null,
2777
+ "updatedAt": Any<String>,
2778
+ "version": 3,
2779
+ "webhookReceivedAt": null,
2780
+ },
2781
+ {
2782
+ "createdAt": Any<String>,
2783
+ "depositAddressId": Any<String>,
2784
+ "detectionTrigger": "webhook",
2785
+ "environment": "production",
2786
+ "id": Any<String>,
2787
+ "orgId": "org_precision_reconciliation",
2788
+ "pollObservedAt": null,
2789
+ "projectId": null,
2790
+ "providerOutputAmount": {
2791
+ "baseUnits": "1000000",
2792
+ "currency": "USD",
2793
+ "decimals": 6,
2794
+ "formatted": "1",
2795
+ },
2796
+ "providerOutputToken": {
2797
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
2798
+ "currency": "USD",
2799
+ "decimals": 6,
2800
+ "name": "Bridged USDC (Stargate)",
2801
+ "standard": "TIP-20",
2802
+ "symbol": "USDC.e",
2803
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2804
+ "verified": true,
2805
+ },
2806
+ "providerRequestId": "relay-multiple-transfer-request",
2807
+ "providerRequestIds": [
2808
+ "relay-multiple-transfer-request",
2809
+ ],
2810
+ "providerState": null,
2811
+ "providerTransactionHashes": [
2812
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
2813
+ ],
2814
+ "providerTransferIndex": 0,
2815
+ "retryState": null,
2816
+ "settlementTransaction": null,
2817
+ "settlementTransactionHash": null,
2818
+ "snapshot": {
2819
+ "depositAddressId": Any<String>,
2820
+ "destinationAmount": {
2821
+ "baseUnits": "1000000",
2822
+ "currency": "USD",
2823
+ "decimals": 6,
2824
+ "formatted": "1",
2825
+ },
2826
+ "destinationAmountRequired": {
2827
+ "baseUnits": "1000000",
2828
+ "currency": "USD",
2829
+ "decimals": 6,
2830
+ "formatted": "1",
2831
+ },
2832
+ "destinationChain": {
2833
+ "addressFormat": "hex",
2834
+ "id": "eip155:4217",
2835
+ "kind": "evm",
2836
+ "name": "Tempo",
2837
+ },
2838
+ "destinationToken": {
2839
+ "address": "0x20c000000000000000000000b9537d11c60e8b50",
2840
+ "currency": "USD",
2841
+ "decimals": 6,
2842
+ "name": "Bridged USDC (Stargate)",
2843
+ "standard": "TIP-20",
2844
+ "symbol": "USDC.e",
2845
+ "tokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2846
+ "verified": true,
2847
+ },
2848
+ "destinationTransactionHashes": [
2849
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
2850
+ ],
2851
+ "provider": {
2852
+ "id": "relay",
2853
+ "name": "Relay",
2854
+ },
2855
+ "recipient": "0x1111111111111111111111111111111111111111",
2856
+ "refundAddress": "0x1313131313131313131313131313131313131313",
2857
+ "sender": "0x1414141414141414141414141414141414141414",
2858
+ "sourceAmount": {
2859
+ "baseUnits": "1000000000000000001",
2860
+ "currency": "USD",
2861
+ "decimals": 18,
2862
+ "formatted": "1.000000000000000001",
2863
+ },
2864
+ "sourceChain": {
2865
+ "addressFormat": "hex",
2866
+ "id": "eip155:8453",
2867
+ "kind": "evm",
2868
+ "name": "Base",
2869
+ },
2870
+ "sourceToken": {
2871
+ "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2872
+ "currency": "USD",
2873
+ "decimals": 18,
2874
+ "name": "USD Coin",
2875
+ "standard": "ERC-20",
2876
+ "symbol": "USDC",
2877
+ "tokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2878
+ "verified": true,
2879
+ },
2880
+ "sourceTransactionHashes": [
2881
+ "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
2882
+ ],
2883
+ },
2884
+ "sourceChainId": "eip155:8453",
2885
+ "sourceTransactionHash": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
2886
+ "sourceTransferIndex": 0,
2887
+ "status": "completed",
2888
+ "statusReason": null,
2889
+ "subsidyAmount": null,
2890
+ "tempoGasPaid": null,
2891
+ "updatedAt": Any<String>,
2892
+ "version": 3,
2893
+ "webhookReceivedAt": null,
2894
+ },
2895
+ ],
2896
+ "result": {
2897
+ "created": 2,
2898
+ "type": "completed",
2899
+ "updated": 2,
2900
+ },
2901
+ "storedAddress": {
2902
+ "address": "0x1212121212121212121212121212121212121212",
2903
+ "apiKeyId": "key_precision_reconciliation",
2904
+ "createdAt": "2026-01-03T00:00:00.000Z",
2905
+ "deliveryStrategy": "provider",
2906
+ "destinationTokenKey": "eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50",
2907
+ "environment": "production",
2908
+ "id": Any<String>,
2909
+ "lastPolledAt": "2027-01-03T00:00:00.000Z",
2910
+ "nextPollAt": "2027-01-03T00:01:00.000Z",
2911
+ "orgId": "org_precision_reconciliation",
2912
+ "pollFailureCount": 0,
2913
+ "pollLeaseUntil": null,
2914
+ "pollLeaseVersion": 1,
2915
+ "projectId": null,
2916
+ "providerId": "relay",
2917
+ "providerOutputToken": Any<Object>,
2918
+ "providerRequestIds": [
2919
+ "relay-address-request",
2920
+ ],
2921
+ "providerState": {
2922
+ "reconciliation": {
2923
+ "pendingRequestIds": [],
2924
+ "requestIds": [
2925
+ "relay-multiple-transfer-request",
2926
+ ],
2927
+ "updatedAt": "2026-01-03T00:02:00.000Z",
2928
+ },
2929
+ },
2930
+ "recipient": "0x1111111111111111111111111111111111111111",
2931
+ "refundAddress": "0x1313131313131313131313131313131313131313",
2932
+ "snapshot": Any<Object>,
2933
+ "sourceChainId": "eip155:8453",
2934
+ "sourceTokenKey": "eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
2935
+ "status": "active",
2936
+ "subsidize": false,
2937
+ "updatedAt": "2026-01-03T00:00:00.000Z",
2938
+ "version": 1,
2939
+ },
2940
+ }
2941
+ `,
2942
+ )
2943
+ } finally {
2944
+ await server.closeAsync()
2945
+ }
2946
+ })
2947
+ })
2948
+
2949
+ function transferLog(options: transferLog.Options) {
2950
+ return {
2951
+ address: options.token,
2952
+ ...(options.blockNumber !== undefined
2953
+ ? { blockNumber: `0x${options.blockNumber.toString(16)}` }
2954
+ : {}),
2955
+ data: `0x${options.amount.toString(16).padStart(64, '0')}`,
2956
+ logIndex: `0x${(options.logIndex ?? 0).toString(16)}`,
2957
+ topics: [transferTopic, topicAddress(options.sender), topicAddress(options.recipient)],
2958
+ ...(options.transactionHash ? { transactionHash: options.transactionHash } : {}),
2959
+ }
2960
+ }
2961
+
2962
+ declare namespace transferLog {
2963
+ type Options = {
2964
+ amount: bigint
2965
+ blockNumber?: number | undefined
2966
+ logIndex?: number | undefined
2967
+ recipient: string
2968
+ sender: string
2969
+ token: string
2970
+ transactionHash?: string | undefined
2971
+ }
2972
+ }
2973
+
2974
+ function relayDepositLog(options: relayDepositLog.Options) {
2975
+ const event = AbiEvent.from(
2976
+ 'event RelayErc20Deposit(address from, address token, uint256 amount, bytes32 id)',
2977
+ )
2978
+ return {
2979
+ address: options.depository,
2980
+ blockNumber: `0x${options.blockNumber.toString(16)}`,
2981
+ data: AbiParameters.encode(event.inputs, [
2982
+ options.from as Address.Address,
2983
+ options.token as Address.Address,
2984
+ options.amount,
2985
+ options.orderId as Hex.Hex,
2986
+ ]),
2987
+ logIndex: '0x0',
2988
+ topics: [AbiEvent.getSelector(event)],
2989
+ transactionHash: options.transactionHash,
2990
+ }
2991
+ }
2992
+
2993
+ declare namespace relayDepositLog {
2994
+ type Options = {
2995
+ amount: bigint
2996
+ blockNumber: number
2997
+ depository: string
2998
+ from: string
2999
+ orderId: string
3000
+ token: string
3001
+ transactionHash: string
3002
+ }
3003
+ }
3004
+
3005
+ function rpcTransaction(options: rpcTransaction.Options) {
3006
+ return {
3007
+ blockHash: `0x${'39'.repeat(32)}`,
3008
+ blockNumber: `0x${options.blockNumber.toString(16)}`,
3009
+ from: options.from,
3010
+ gas: '0x5208',
3011
+ gasPrice: '0x1',
3012
+ hash: options.hash,
3013
+ input: options.input,
3014
+ nonce: '0x1',
3015
+ r: `0x${'3a'.repeat(32)}`,
3016
+ s: `0x${'3b'.repeat(32)}`,
3017
+ to: options.to,
3018
+ transactionIndex: '0x0',
3019
+ type: '0x0',
3020
+ v: '0x1b',
3021
+ value: '0x0',
3022
+ }
3023
+ }
3024
+
3025
+ declare namespace rpcTransaction {
3026
+ type Options = {
3027
+ blockNumber: number
3028
+ from: string
3029
+ hash: string
3030
+ input: string
3031
+ to: string
3032
+ }
3033
+ }
3034
+
3035
+ function topicAddress(address: string) {
3036
+ return `0x${address.slice(2).padStart(64, '0')}`
3037
+ }