tapimo 0.15.0 → 0.18.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 (734) hide show
  1. package/README.md +137 -0
  2. package/dist/ApiKey.d.ts +1 -0
  3. package/dist/ApiKey.d.ts.map +1 -1
  4. package/dist/ApiKey.js +4 -2
  5. package/dist/ApiKey.js.map +1 -1
  6. package/dist/ApiKeys.d.ts +37 -11
  7. package/dist/ApiKeys.d.ts.map +1 -1
  8. package/dist/ApiKeys.js +163 -10
  9. package/dist/ApiKeys.js.map +1 -1
  10. package/dist/App.d.ts +13085 -11974
  11. package/dist/App.d.ts.map +1 -1
  12. package/dist/App.js +46 -15
  13. package/dist/App.js.map +1 -1
  14. package/dist/Scope.d.ts +1 -1
  15. package/dist/Scope.d.ts.map +1 -1
  16. package/dist/Scope.js +1 -1
  17. package/dist/Scope.js.map +1 -1
  18. package/dist/admin/App.d.ts +896 -191
  19. package/dist/admin/App.d.ts.map +1 -1
  20. package/dist/admin/App.js +5 -1
  21. package/dist/admin/App.js.map +1 -1
  22. package/dist/admin/apps/api-keys.d.ts +33 -33
  23. package/dist/admin/apps/api-keys.d.ts.map +1 -1
  24. package/dist/admin/apps/api-keys.js +8 -3
  25. package/dist/admin/apps/api-keys.js.map +1 -1
  26. package/dist/admin/apps/earn-vaults.d.ts +66 -27
  27. package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
  28. package/dist/admin/apps/earn-vaults.js +36 -7
  29. package/dist/admin/apps/earn-vaults.js.map +1 -1
  30. package/dist/admin/apps/organizations.d.ts +25 -25
  31. package/dist/admin/apps/organizations.d.ts.map +1 -1
  32. package/dist/admin/apps/organizations.js +5 -4
  33. package/dist/admin/apps/organizations.js.map +1 -1
  34. package/dist/admin/apps/route-policies.d.ts +632 -0
  35. package/dist/admin/apps/route-policies.d.ts.map +1 -0
  36. package/dist/admin/apps/route-policies.js +257 -0
  37. package/dist/admin/apps/route-policies.js.map +1 -0
  38. package/dist/admin/apps/routes-support.js +39 -3
  39. package/dist/admin/apps/routes-support.js.map +1 -1
  40. package/dist/admin/apps/routes.d.ts +454 -1
  41. package/dist/admin/apps/routes.d.ts.map +1 -1
  42. package/dist/admin/apps/routes.js +82 -1
  43. package/dist/admin/apps/routes.js.map +1 -1
  44. package/dist/admin/apps/verified-tokens.d.ts +10 -4
  45. package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
  46. package/dist/admin/apps/verified-tokens.js +24 -4
  47. package/dist/admin/apps/verified-tokens.js.map +1 -1
  48. package/dist/admin/index.d.ts +0 -1
  49. package/dist/admin/index.d.ts.map +1 -1
  50. package/dist/admin/index.js +0 -1
  51. package/dist/admin/index.js.map +1 -1
  52. package/dist/admin/ui.generated.d.ts +1 -1
  53. package/dist/admin/ui.generated.d.ts.map +1 -1
  54. package/dist/admin/ui.generated.js +99 -103
  55. package/dist/admin/ui.generated.js.map +1 -1
  56. package/dist/analytics/Analytics.d.ts.map +1 -1
  57. package/dist/analytics/Analytics.js +65 -1
  58. package/dist/analytics/Analytics.js.map +1 -1
  59. package/dist/analytics/tables/requestEvents.d.ts +1 -1
  60. package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
  61. package/dist/analytics/tables/requestEvents.js +58 -59
  62. package/dist/analytics/tables/requestEvents.js.map +1 -1
  63. package/dist/apps/data/App.d.ts +2709 -2670
  64. package/dist/apps/data/App.d.ts.map +1 -1
  65. package/dist/apps/data/routes/activities.d.ts +5 -5
  66. package/dist/apps/data/routes/activities.d.ts.map +1 -1
  67. package/dist/apps/data/routes/activities.js +50 -0
  68. package/dist/apps/data/routes/activities.js.map +1 -1
  69. package/dist/apps/data/routes/addresses.d.ts +248 -248
  70. package/dist/apps/data/routes/balances.d.ts +22 -22
  71. package/dist/apps/data/routes/balances.d.ts.map +1 -1
  72. package/dist/apps/data/routes/balances.js +5 -7
  73. package/dist/apps/data/routes/balances.js.map +1 -1
  74. package/dist/apps/data/routes/coingecko.d.ts +54 -54
  75. package/dist/apps/data/routes/earn.d.ts +103 -12
  76. package/dist/apps/data/routes/earn.d.ts.map +1 -1
  77. package/dist/apps/data/routes/earn.js +456 -220
  78. package/dist/apps/data/routes/earn.js.map +1 -1
  79. package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
  80. package/dist/apps/data/routes/exchanges.js +267 -97
  81. package/dist/apps/data/routes/exchanges.js.map +1 -1
  82. package/dist/apps/data/routes/fee-amm.d.ts +1 -19
  83. package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
  84. package/dist/apps/data/routes/fee-amm.js +93 -56
  85. package/dist/apps/data/routes/fee-amm.js.map +1 -1
  86. package/dist/apps/data/routes/indexer.d.ts +10 -10
  87. package/dist/apps/data/routes/rpc.d.ts +30 -30
  88. package/dist/apps/data/routes/rpc.js +45 -11
  89. package/dist/apps/data/routes/rpc.js.map +1 -1
  90. package/dist/apps/data/routes/tokens.d.ts.map +1 -1
  91. package/dist/apps/data/routes/tokens.js +11 -6
  92. package/dist/apps/data/routes/tokens.js.map +1 -1
  93. package/dist/apps/data/routes/transactions.d.ts +2 -0
  94. package/dist/apps/data/routes/transactions.d.ts.map +1 -1
  95. package/dist/apps/data/routes/transactions.js +30 -22
  96. package/dist/apps/data/routes/transactions.js.map +1 -1
  97. package/dist/apps/data/routes/transfers.d.ts +12 -12
  98. package/dist/apps/data/routes/valuation.d.ts +30 -30
  99. package/dist/apps/data/routes/verified-tokens.d.ts +5 -5
  100. package/dist/apps/data/routes/webhooks.d.ts +1 -1
  101. package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
  102. package/dist/apps/data/routes/webhooks.js +18 -11
  103. package/dist/apps/data/routes/webhooks.js.map +1 -1
  104. package/dist/apps/data/routes/zones.d.ts +3 -3
  105. package/dist/apps/management/App.d.ts +3043 -2198
  106. package/dist/apps/management/App.d.ts.map +1 -1
  107. package/dist/apps/management/App.js +2 -0
  108. package/dist/apps/management/App.js.map +1 -1
  109. package/dist/apps/management/Billing.d.ts +2 -4
  110. package/dist/apps/management/Billing.d.ts.map +1 -1
  111. package/dist/apps/management/Billing.js +65 -26
  112. package/dist/apps/management/Billing.js.map +1 -1
  113. package/dist/apps/management/routes/api-keys.d.ts +16 -4
  114. package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
  115. package/dist/apps/management/routes/api-keys.js +70 -11
  116. package/dist/apps/management/routes/api-keys.js.map +1 -1
  117. package/dist/apps/management/routes/billing.d.ts +84 -84
  118. package/dist/apps/management/routes/cli.d.ts +912 -0
  119. package/dist/apps/management/routes/cli.d.ts.map +1 -0
  120. package/dist/apps/management/routes/cli.js +416 -0
  121. package/dist/apps/management/routes/cli.js.map +1 -0
  122. package/dist/apps/management/routes/faucet.d.ts +8 -8
  123. package/dist/apps/management/routes/invitations.d.ts +24 -24
  124. package/dist/apps/management/routes/invite-links.d.ts +66 -66
  125. package/dist/apps/management/routes/members.d.ts +16 -16
  126. package/dist/apps/management/routes/orgs.d.ts +20 -20
  127. package/dist/apps/management/routes/orgs.d.ts.map +1 -1
  128. package/dist/apps/management/routes/orgs.js +8 -2
  129. package/dist/apps/management/routes/orgs.js.map +1 -1
  130. package/dist/apps/management/routes/projects.d.ts +76 -76
  131. package/dist/apps/management/routes/usage.d.ts +8 -8
  132. package/dist/apps/management/routes/verified-token-requests.d.ts +42 -42
  133. package/dist/apps/management/routes/verified-token-requests.d.ts.map +1 -1
  134. package/dist/apps/management/routes/verified-token-requests.js +7 -9
  135. package/dist/apps/management/routes/verified-token-requests.js.map +1 -1
  136. package/dist/apps/management/routes/webhooks.d.ts +119 -119
  137. package/dist/apps/mcp.d.ts.map +1 -1
  138. package/dist/apps/mcp.js +16 -3
  139. package/dist/apps/mcp.js.map +1 -1
  140. package/dist/apps/mpp/internal/Policy.d.ts.map +1 -1
  141. package/dist/apps/mpp/internal/Policy.js +4 -2
  142. package/dist/apps/mpp/internal/Policy.js.map +1 -1
  143. package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -1
  144. package/dist/apps/mpp/internal/Sponsorship.js +6 -4
  145. package/dist/apps/mpp/internal/Sponsorship.js.map +1 -1
  146. package/dist/apps/relay/App.d.ts +8 -0
  147. package/dist/apps/relay/App.d.ts.map +1 -1
  148. package/dist/apps/relay/App.js +16 -4
  149. package/dist/apps/relay/App.js.map +1 -1
  150. package/dist/apps/relay/Sponsorships.d.ts +4 -6
  151. package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
  152. package/dist/apps/relay/Sponsorships.js +71 -60
  153. package/dist/apps/relay/Sponsorships.js.map +1 -1
  154. package/dist/apps/routes/Access.d.ts +53 -0
  155. package/dist/apps/routes/Access.d.ts.map +1 -1
  156. package/dist/apps/routes/Access.js +121 -0
  157. package/dist/apps/routes/Access.js.map +1 -1
  158. package/dist/apps/routes/App.d.ts +397 -158
  159. package/dist/apps/routes/App.d.ts.map +1 -1
  160. package/dist/apps/routes/App.js.map +1 -1
  161. package/dist/apps/routes/routes/deposit-addresses.d.ts +169 -61
  162. package/dist/apps/routes/routes/deposit-addresses.d.ts.map +1 -1
  163. package/dist/apps/routes/routes/deposit-addresses.js +217 -32
  164. package/dist/apps/routes/routes/deposit-addresses.js.map +1 -1
  165. package/dist/apps/routes/routes/quotes.d.ts +90 -0
  166. package/dist/apps/routes/routes/quotes.d.ts.map +1 -1
  167. package/dist/apps/routes/routes/quotes.js +101 -27
  168. package/dist/apps/routes/routes/quotes.js.map +1 -1
  169. package/dist/apps/routes/routes/transfers.d.ts +187 -135
  170. package/dist/apps/routes/routes/transfers.d.ts.map +1 -1
  171. package/dist/apps/routes/routes/transfers.js +182 -37
  172. package/dist/apps/routes/routes/transfers.js.map +1 -1
  173. package/dist/cli/ApiKeys.d.ts +120 -0
  174. package/dist/cli/ApiKeys.d.ts.map +1 -0
  175. package/dist/cli/ApiKeys.js +138 -0
  176. package/dist/cli/ApiKeys.js.map +1 -0
  177. package/dist/cli/Cli.d.ts +92 -34
  178. package/dist/cli/Cli.d.ts.map +1 -1
  179. package/dist/cli/Cli.js +188 -11
  180. package/dist/cli/Cli.js.map +1 -1
  181. package/dist/cli/Credentials.d.ts +95 -0
  182. package/dist/cli/Credentials.d.ts.map +1 -0
  183. package/dist/cli/Credentials.js +110 -0
  184. package/dist/cli/Credentials.js.map +1 -0
  185. package/dist/cli/Spec.d.ts +59 -0
  186. package/dist/cli/Spec.d.ts.map +1 -0
  187. package/dist/cli/Spec.js +77 -0
  188. package/dist/cli/Spec.js.map +1 -0
  189. package/dist/cli/bin.js +5 -1
  190. package/dist/cli/bin.js.map +1 -1
  191. package/dist/cli/commands/admin.d.ts +5 -5
  192. package/dist/cli/commands/admin.d.ts.map +1 -1
  193. package/dist/cli/commands/auth.d.ts +73 -0
  194. package/dist/cli/commands/auth.d.ts.map +1 -0
  195. package/dist/cli/commands/auth.js +204 -0
  196. package/dist/cli/commands/auth.js.map +1 -0
  197. package/dist/cli/commands/keys.d.ts +17 -0
  198. package/dist/cli/commands/keys.d.ts.map +1 -0
  199. package/dist/cli/commands/keys.js +109 -0
  200. package/dist/cli/commands/keys.js.map +1 -0
  201. package/dist/cloudflare.d.ts +27 -2
  202. package/dist/cloudflare.d.ts.map +1 -1
  203. package/dist/cloudflare.js +144 -17
  204. package/dist/cloudflare.js.map +1 -1
  205. package/dist/db/Db.d.ts +23 -0
  206. package/dist/db/Db.d.ts.map +1 -1
  207. package/dist/db/Db.js +418 -1
  208. package/dist/db/Db.js.map +1 -1
  209. package/dist/db/Schema.d.ts +44 -1
  210. package/dist/db/Schema.d.ts.map +1 -1
  211. package/dist/db/Schema.js +56 -3
  212. package/dist/db/Schema.js.map +1 -1
  213. package/dist/db/tables/apiKeyAdmissions.d.ts +28 -2
  214. package/dist/db/tables/apiKeyAdmissions.d.ts.map +1 -1
  215. package/dist/db/tables/apiKeyAdmissions.js +65 -9
  216. package/dist/db/tables/apiKeyAdmissions.js.map +1 -1
  217. package/dist/db/tables/apiKeyOwnerTombstones.d.ts +2 -0
  218. package/dist/db/tables/apiKeyOwnerTombstones.d.ts.map +1 -1
  219. package/dist/db/tables/apiKeyOwnerTombstones.js +2 -2
  220. package/dist/db/tables/apiKeyOwnerTombstones.js.map +1 -1
  221. package/dist/db/tables/authAccounts.d.ts.map +1 -1
  222. package/dist/db/tables/authAccounts.js +1 -0
  223. package/dist/db/tables/authAccounts.js.map +1 -1
  224. package/dist/db/tables/earnVaults.d.ts +5 -1
  225. package/dist/db/tables/earnVaults.d.ts.map +1 -1
  226. package/dist/db/tables/earnVaults.js +12 -1
  227. package/dist/db/tables/earnVaults.js.map +1 -1
  228. package/dist/db/tables/organizations.d.ts +4 -2
  229. package/dist/db/tables/organizations.d.ts.map +1 -1
  230. package/dist/db/tables/organizations.js +8 -34
  231. package/dist/db/tables/organizations.js.map +1 -1
  232. package/dist/db/tables/requestUsage.d.ts +5 -1
  233. package/dist/db/tables/requestUsage.d.ts.map +1 -1
  234. package/dist/db/tables/requestUsage.js +10 -2
  235. package/dist/db/tables/requestUsage.js.map +1 -1
  236. package/dist/db/tables/rewardEligibilityAssociations.d.ts +13 -0
  237. package/dist/db/tables/rewardEligibilityAssociations.d.ts.map +1 -1
  238. package/dist/db/tables/rewardEligibilityAssociations.js +11 -0
  239. package/dist/db/tables/rewardEligibilityAssociations.js.map +1 -1
  240. package/dist/db/tables/rewardRuns.d.ts.map +1 -1
  241. package/dist/db/tables/rewardRuns.js +4 -0
  242. package/dist/db/tables/rewardRuns.js.map +1 -1
  243. package/dist/db/tables/rewardTransactionAttempts.d.ts.map +1 -1
  244. package/dist/db/tables/rewardTransactionAttempts.js +2 -0
  245. package/dist/db/tables/rewardTransactionAttempts.js.map +1 -1
  246. package/dist/db/tables/routesDepositAddresses.d.ts +29 -0
  247. package/dist/db/tables/routesDepositAddresses.d.ts.map +1 -1
  248. package/dist/db/tables/routesDepositAddresses.js +84 -31
  249. package/dist/db/tables/routesDepositAddresses.js.map +1 -1
  250. package/dist/db/tables/routesDeposits.d.ts.map +1 -1
  251. package/dist/db/tables/routesDeposits.js +31 -21
  252. package/dist/db/tables/routesDeposits.js.map +1 -1
  253. package/dist/db/tables/routesIdempotency.d.ts.map +1 -1
  254. package/dist/db/tables/routesIdempotency.js +2 -0
  255. package/dist/db/tables/routesIdempotency.js.map +1 -1
  256. package/dist/db/tables/routesPolicies.d.ts +58 -0
  257. package/dist/db/tables/routesPolicies.d.ts.map +1 -0
  258. package/dist/db/tables/routesPolicies.js +198 -0
  259. package/dist/db/tables/routesPolicies.js.map +1 -0
  260. package/dist/db/tables/routesTransferSubsidies.d.ts +22 -0
  261. package/dist/db/tables/routesTransferSubsidies.d.ts.map +1 -1
  262. package/dist/db/tables/routesTransferSubsidies.js +41 -0
  263. package/dist/db/tables/routesTransferSubsidies.js.map +1 -1
  264. package/dist/db/tables/routesTransferSubsidyNonces.d.ts.map +1 -1
  265. package/dist/db/tables/routesTransferSubsidyNonces.js +12 -4
  266. package/dist/db/tables/routesTransferSubsidyNonces.js.map +1 -1
  267. package/dist/db/tables/routesTransfers.d.ts +26 -1
  268. package/dist/db/tables/routesTransfers.d.ts.map +1 -1
  269. package/dist/db/tables/routesTransfers.js +36 -6
  270. package/dist/db/tables/routesTransfers.js.map +1 -1
  271. package/dist/db/tables/sponsoredTransactions.d.ts +45 -13
  272. package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
  273. package/dist/db/tables/sponsoredTransactions.js +144 -33
  274. package/dist/db/tables/sponsoredTransactions.js.map +1 -1
  275. package/dist/db/tables/users.d.ts +2 -0
  276. package/dist/db/tables/users.d.ts.map +1 -1
  277. package/dist/db/tables/users.js +11 -0
  278. package/dist/db/tables/users.js.map +1 -1
  279. package/dist/db/tables/verifiedTokenRequests.d.ts +21 -4
  280. package/dist/db/tables/verifiedTokenRequests.d.ts.map +1 -1
  281. package/dist/db/tables/verifiedTokenRequests.js +65 -44
  282. package/dist/db/tables/verifiedTokenRequests.js.map +1 -1
  283. package/dist/handlers/internal/multisig.d.ts +1 -1
  284. package/dist/handlers/internal/multisig.d.ts.map +1 -1
  285. package/dist/handlers/internal/multisig.js +3 -2
  286. package/dist/handlers/internal/multisig.js.map +1 -1
  287. package/dist/handlers/relay.d.ts +2 -0
  288. package/dist/handlers/relay.d.ts.map +1 -1
  289. package/dist/handlers/relay.js +34 -15
  290. package/dist/handlers/relay.js.map +1 -1
  291. package/dist/internal/Auth.d.ts +73 -6
  292. package/dist/internal/Auth.d.ts.map +1 -1
  293. package/dist/internal/Auth.js +212 -85
  294. package/dist/internal/Auth.js.map +1 -1
  295. package/dist/internal/BetterAuth.d.ts +22 -0
  296. package/dist/internal/BetterAuth.d.ts.map +1 -1
  297. package/dist/internal/BetterAuth.js +17 -14
  298. package/dist/internal/BetterAuth.js.map +1 -1
  299. package/dist/internal/Cache.d.ts +5 -0
  300. package/dist/internal/Cache.d.ts.map +1 -1
  301. package/dist/internal/Cache.js +3 -1
  302. package/dist/internal/Cache.js.map +1 -1
  303. package/dist/internal/CliAuth.d.ts +243 -0
  304. package/dist/internal/CliAuth.d.ts.map +1 -0
  305. package/dist/internal/CliAuth.js +249 -0
  306. package/dist/internal/CliAuth.js.map +1 -0
  307. package/dist/internal/EarnSharePrices.d.ts +1 -1
  308. package/dist/internal/EarnSharePrices.d.ts.map +1 -1
  309. package/dist/internal/EarnSharePrices.js +7 -3
  310. package/dist/internal/EarnSharePrices.js.map +1 -1
  311. package/dist/internal/EarnVaults.d.ts +47 -0
  312. package/dist/internal/EarnVaults.d.ts.map +1 -1
  313. package/dist/internal/EarnVaults.js +188 -4
  314. package/dist/internal/EarnVaults.js.map +1 -1
  315. package/dist/internal/EarnWithdrawals.d.ts +73 -0
  316. package/dist/internal/EarnWithdrawals.d.ts.map +1 -0
  317. package/dist/internal/EarnWithdrawals.js +189 -0
  318. package/dist/internal/EarnWithdrawals.js.map +1 -0
  319. package/dist/internal/ExecutionContext.d.ts +21 -0
  320. package/dist/internal/ExecutionContext.d.ts.map +1 -0
  321. package/dist/internal/ExecutionContext.js +16 -0
  322. package/dist/internal/ExecutionContext.js.map +1 -0
  323. package/dist/internal/Log.d.ts +7 -3
  324. package/dist/internal/Log.d.ts.map +1 -1
  325. package/dist/internal/Log.js +163 -130
  326. package/dist/internal/Log.js.map +1 -1
  327. package/dist/internal/MetricSink.d.ts.map +1 -1
  328. package/dist/internal/MetricSink.js +26 -1
  329. package/dist/internal/MetricSink.js.map +1 -1
  330. package/dist/internal/RateLimit.d.ts +67 -0
  331. package/dist/internal/RateLimit.d.ts.map +1 -1
  332. package/dist/internal/RateLimit.js +174 -27
  333. package/dist/internal/RateLimit.js.map +1 -1
  334. package/dist/internal/Store.d.ts +6 -0
  335. package/dist/internal/Store.d.ts.map +1 -1
  336. package/dist/internal/Store.js +4 -5
  337. package/dist/internal/Store.js.map +1 -1
  338. package/dist/internal/Timing.d.ts +6 -0
  339. package/dist/internal/Timing.d.ts.map +1 -1
  340. package/dist/internal/Timing.js +21 -1
  341. package/dist/internal/Timing.js.map +1 -1
  342. package/dist/internal/Tron.d.ts +124 -0
  343. package/dist/internal/Tron.d.ts.map +1 -0
  344. package/dist/internal/Tron.js +202 -0
  345. package/dist/internal/Tron.js.map +1 -0
  346. package/dist/internal/Viem.d.ts +4 -0
  347. package/dist/internal/Viem.d.ts.map +1 -1
  348. package/dist/internal/Viem.js +25 -6
  349. package/dist/internal/Viem.js.map +1 -1
  350. package/dist/internal/rewards/Read.d.ts +2 -2
  351. package/dist/internal/rewards/Read.d.ts.map +1 -1
  352. package/dist/internal/rewards/Read.js +11 -2
  353. package/dist/internal/rewards/Read.js.map +1 -1
  354. package/dist/internal/routes/Action.d.ts +27 -0
  355. package/dist/internal/routes/Action.d.ts.map +1 -1
  356. package/dist/internal/routes/Action.js +49 -1
  357. package/dist/internal/routes/Action.js.map +1 -1
  358. package/dist/internal/routes/Chain.d.ts +2 -0
  359. package/dist/internal/routes/Chain.d.ts.map +1 -1
  360. package/dist/internal/routes/Chain.js +4 -0
  361. package/dist/internal/routes/Chain.js.map +1 -1
  362. package/dist/internal/routes/DepositAddress.d.ts.map +1 -1
  363. package/dist/internal/routes/DepositAddress.js +5 -0
  364. package/dist/internal/routes/DepositAddress.js.map +1 -1
  365. package/dist/internal/routes/Evidence.d.ts.map +1 -1
  366. package/dist/internal/routes/Evidence.js +6 -2
  367. package/dist/internal/routes/Evidence.js.map +1 -1
  368. package/dist/internal/routes/EvmTransferSettlement.d.ts +17 -0
  369. package/dist/internal/routes/EvmTransferSettlement.d.ts.map +1 -0
  370. package/dist/internal/routes/EvmTransferSettlement.js +196 -0
  371. package/dist/internal/routes/EvmTransferSettlement.js.map +1 -0
  372. package/dist/internal/routes/Policy.d.ts +161 -0
  373. package/dist/internal/routes/Policy.d.ts.map +1 -0
  374. package/dist/internal/routes/Policy.js +249 -0
  375. package/dist/internal/routes/Policy.js.map +1 -0
  376. package/dist/internal/routes/Provider.d.ts +66 -3
  377. package/dist/internal/routes/Provider.d.ts.map +1 -1
  378. package/dist/internal/routes/Provider.js +106 -27
  379. package/dist/internal/routes/Provider.js.map +1 -1
  380. package/dist/internal/routes/Quota.d.ts +57 -0
  381. package/dist/internal/routes/Quota.d.ts.map +1 -0
  382. package/dist/internal/routes/Quota.js +144 -0
  383. package/dist/internal/routes/Quota.js.map +1 -0
  384. package/dist/internal/routes/Reconciliation.d.ts.map +1 -1
  385. package/dist/internal/routes/Reconciliation.js +163 -47
  386. package/dist/internal/routes/Reconciliation.js.map +1 -1
  387. package/dist/internal/routes/SolanaTransferSettlement.d.ts +12 -0
  388. package/dist/internal/routes/SolanaTransferSettlement.d.ts.map +1 -0
  389. package/dist/internal/routes/SolanaTransferSettlement.js +220 -0
  390. package/dist/internal/routes/SolanaTransferSettlement.js.map +1 -0
  391. package/dist/internal/routes/SolanaTransferSubsidy.d.ts +172 -0
  392. package/dist/internal/routes/SolanaTransferSubsidy.d.ts.map +1 -0
  393. package/dist/internal/routes/SolanaTransferSubsidy.js +564 -0
  394. package/dist/internal/routes/SolanaTransferSubsidy.js.map +1 -0
  395. package/dist/internal/routes/Subsidy.d.ts +2 -2
  396. package/dist/internal/routes/Subsidy.d.ts.map +1 -1
  397. package/dist/internal/routes/Subsidy.js +2 -2
  398. package/dist/internal/routes/Subsidy.js.map +1 -1
  399. package/dist/internal/routes/Transfer.d.ts +229 -1
  400. package/dist/internal/routes/Transfer.d.ts.map +1 -1
  401. package/dist/internal/routes/Transfer.js +644 -7
  402. package/dist/internal/routes/Transfer.js.map +1 -1
  403. package/dist/internal/routes/TransferReconciliation.d.ts +6 -0
  404. package/dist/internal/routes/TransferReconciliation.d.ts.map +1 -1
  405. package/dist/internal/routes/TransferReconciliation.js +83 -159
  406. package/dist/internal/routes/TransferReconciliation.js.map +1 -1
  407. package/dist/internal/routes/TransferSettlement.d.ts +45 -0
  408. package/dist/internal/routes/TransferSettlement.d.ts.map +1 -0
  409. package/dist/internal/routes/TransferSettlement.js +2 -0
  410. package/dist/internal/routes/TransferSettlement.js.map +1 -0
  411. package/dist/internal/routes/TransferSubsidy.d.ts +23 -8
  412. package/dist/internal/routes/TransferSubsidy.d.ts.map +1 -1
  413. package/dist/internal/routes/TransferSubsidy.js +64 -5
  414. package/dist/internal/routes/TransferSubsidy.js.map +1 -1
  415. package/dist/internal/routes/TronTransferSettlement.d.ts +12 -0
  416. package/dist/internal/routes/TronTransferSettlement.d.ts.map +1 -0
  417. package/dist/internal/routes/TronTransferSettlement.js +201 -0
  418. package/dist/internal/routes/TronTransferSettlement.js.map +1 -0
  419. package/dist/internal/routes/TronTransferSubsidy.d.ts +174 -0
  420. package/dist/internal/routes/TronTransferSubsidy.d.ts.map +1 -0
  421. package/dist/internal/routes/TronTransferSubsidy.js +439 -0
  422. package/dist/internal/routes/TronTransferSubsidy.js.map +1 -0
  423. package/dist/internal/routes/index.d.ts +3 -0
  424. package/dist/internal/routes/index.d.ts.map +1 -1
  425. package/dist/internal/routes/index.js +3 -0
  426. package/dist/internal/routes/index.js.map +1 -1
  427. package/dist/internal/routes/providers/across.d.ts +3 -0
  428. package/dist/internal/routes/providers/across.d.ts.map +1 -1
  429. package/dist/internal/routes/providers/across.js +11 -0
  430. package/dist/internal/routes/providers/across.js.map +1 -1
  431. package/dist/internal/routes/providers/legacyMesh.d.ts +29 -0
  432. package/dist/internal/routes/providers/legacyMesh.d.ts.map +1 -0
  433. package/dist/internal/routes/providers/legacyMesh.js +474 -0
  434. package/dist/internal/routes/providers/legacyMesh.js.map +1 -0
  435. package/dist/internal/routes/providers/legacyMeshDelivery.d.ts +59 -0
  436. package/dist/internal/routes/providers/legacyMeshDelivery.d.ts.map +1 -0
  437. package/dist/internal/routes/providers/legacyMeshDelivery.js +229 -0
  438. package/dist/internal/routes/providers/legacyMeshDelivery.js.map +1 -0
  439. package/dist/internal/routes/providers/legacyMeshOutbound.d.ts +19 -0
  440. package/dist/internal/routes/providers/legacyMeshOutbound.d.ts.map +1 -0
  441. package/dist/internal/routes/providers/legacyMeshOutbound.js +457 -0
  442. package/dist/internal/routes/providers/legacyMeshOutbound.js.map +1 -0
  443. package/dist/internal/routes/providers/legacyMeshOutboundDelivery.d.ts +123 -0
  444. package/dist/internal/routes/providers/legacyMeshOutboundDelivery.d.ts.map +1 -0
  445. package/dist/internal/routes/providers/legacyMeshOutboundDelivery.js +333 -0
  446. package/dist/internal/routes/providers/legacyMeshOutboundDelivery.js.map +1 -0
  447. package/dist/internal/routes/providers/propAmm.d.ts +70 -0
  448. package/dist/internal/routes/providers/propAmm.d.ts.map +1 -0
  449. package/dist/internal/routes/providers/propAmm.js +524 -0
  450. package/dist/internal/routes/providers/propAmm.js.map +1 -0
  451. package/dist/internal/routes/providers/relay.d.ts +4 -1
  452. package/dist/internal/routes/providers/relay.d.ts.map +1 -1
  453. package/dist/internal/routes/providers/relay.js +353 -42
  454. package/dist/internal/routes/providers/relay.js.map +1 -1
  455. package/dist/internal/routes/providers/rhino.d.ts +3 -0
  456. package/dist/internal/routes/providers/rhino.d.ts.map +1 -1
  457. package/dist/internal/routes/providers/rhino.js +11 -0
  458. package/dist/internal/routes/providers/rhino.js.map +1 -1
  459. package/dist/internal/routes/providers/squid.d.ts +3 -0
  460. package/dist/internal/routes/providers/squid.d.ts.map +1 -1
  461. package/dist/internal/routes/providers/squid.js +19 -0
  462. package/dist/internal/routes/providers/squid.js.map +1 -1
  463. package/dist/internal/routes/providers/stargate.d.ts.map +1 -1
  464. package/dist/internal/routes/providers/stargate.js +22 -9
  465. package/dist/internal/routes/providers/stargate.js.map +1 -1
  466. package/dist/internal/routes/providers/symbiosis.d.ts.map +1 -1
  467. package/dist/internal/routes/providers/symbiosis.js +13 -17
  468. package/dist/internal/routes/providers/symbiosis.js.map +1 -1
  469. package/dist/providers/index.d.ts +14 -0
  470. package/dist/providers/index.d.ts.map +1 -1
  471. package/dist/providers/index.js +6 -0
  472. package/dist/providers/index.js.map +1 -1
  473. package/package.json +16 -6
  474. package/src/ApiKey.ts +7 -3
  475. package/src/ApiKeys.test.ts +652 -8
  476. package/src/ApiKeys.ts +191 -11
  477. package/src/App.test.ts +405 -18
  478. package/src/App.ts +51 -15
  479. package/src/Client.test-d.ts +157 -10
  480. package/src/Client.test.ts +4 -4
  481. package/src/Scope.ts +1 -2
  482. package/src/admin/App.ts +11 -5
  483. package/src/admin/apps/api-keys.test.ts +98 -2
  484. package/src/admin/apps/api-keys.ts +21 -12
  485. package/src/admin/apps/earn-vaults.test.ts +76 -7
  486. package/src/admin/apps/earn-vaults.ts +47 -8
  487. package/src/admin/apps/organizations.test.ts +147 -31
  488. package/src/admin/apps/organizations.ts +5 -4
  489. package/src/admin/apps/route-policies.test.ts +220 -0
  490. package/src/admin/apps/route-policies.ts +322 -0
  491. package/src/admin/apps/routes-support.test.ts +107 -2
  492. package/src/admin/apps/routes-support.ts +43 -3
  493. package/src/admin/apps/routes.test.ts +150 -0
  494. package/src/admin/apps/routes.ts +97 -1
  495. package/src/admin/apps/scopes.test.ts +1 -1
  496. package/src/admin/apps/verified-tokens.test.ts +32 -0
  497. package/src/admin/apps/verified-tokens.ts +30 -4
  498. package/src/admin/index.ts +0 -1
  499. package/src/admin/ui/plugin.ts +2 -1
  500. package/src/admin/ui/src/components/Dialog.tsx +1 -1
  501. package/src/admin/ui/src/components/EarnVaultForm.tsx +45 -0
  502. package/src/admin/ui/src/components/RoutePicker.tsx +79 -0
  503. package/src/admin/ui/src/lib/earn-vaults.ts +1 -1
  504. package/src/admin/ui/src/lib/route-policies.test.ts +452 -0
  505. package/src/admin/ui/src/lib/route-policies.ts +232 -0
  506. package/src/admin/ui/src/lib/routes.ts +34 -0
  507. package/src/admin/ui/src/lib/verified-tokens.ts +24 -9
  508. package/src/admin/ui/src/routeTree.gen.ts +21 -0
  509. package/src/admin/ui/src/routes/__root.tsx +1 -1
  510. package/src/admin/ui/src/routes/api-keys.tsx +21 -2
  511. package/src/admin/ui/src/routes/early-access.tsx +1 -0
  512. package/src/admin/ui/src/routes/earn.vaults.tsx +1 -0
  513. package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +22 -0
  514. package/src/admin/ui/src/routes/earn.vaults_.new.tsx +10 -0
  515. package/src/admin/ui/src/routes/organizations.tsx +35 -4
  516. package/src/admin/ui/src/routes/organizations_.$orgId.tsx +18 -3
  517. package/src/admin/ui/src/routes/route-policies.tsx +678 -0
  518. package/src/admin/ui/src/routes/routes.tsx +85 -2
  519. package/src/admin/ui/src/routes/routes_.support.tsx +6 -22
  520. package/src/admin/ui/src/routes/subsidies.tsx +1 -0
  521. package/src/admin/ui/src/routes/verified-tokens.tsx +65 -20
  522. package/src/admin/ui.generated.ts +99 -104
  523. package/src/analytics/Analytics.test.ts +4 -50
  524. package/src/analytics/Analytics.ts +65 -1
  525. package/src/analytics/tables/requestEvents.test.ts +402 -1
  526. package/src/analytics/tables/requestEvents.ts +62 -93
  527. package/src/apps/data/App.test.ts +26 -0
  528. package/src/apps/data/routes/activities.test.ts +315 -14
  529. package/src/apps/data/routes/activities.ts +60 -0
  530. package/src/apps/data/routes/balances.ts +5 -7
  531. package/src/apps/data/routes/earn.bench.ts +18 -0
  532. package/src/apps/data/routes/earn.local.test.ts +507 -0
  533. package/src/apps/data/routes/earn.test.ts +405 -127
  534. package/src/apps/data/routes/earn.ts +660 -270
  535. package/src/apps/data/routes/exchanges.bench.ts +3 -1
  536. package/src/apps/data/routes/exchanges.test.ts +166 -2
  537. package/src/apps/data/routes/exchanges.ts +308 -101
  538. package/src/apps/data/routes/fee-amm.test.ts +153 -2
  539. package/src/apps/data/routes/fee-amm.ts +132 -62
  540. package/src/apps/data/routes/receipts.test.ts +21 -18
  541. package/src/apps/data/routes/rpc.test.ts +34 -2
  542. package/src/apps/data/routes/rpc.ts +47 -10
  543. package/src/apps/data/routes/tokens.provenance.test.ts +157 -0
  544. package/src/apps/data/routes/tokens.test.ts +4 -4
  545. package/src/apps/data/routes/tokens.ts +11 -6
  546. package/src/apps/data/routes/transactions.test.ts +29 -0
  547. package/src/apps/data/routes/transactions.ts +33 -22
  548. package/src/apps/data/routes/webhooks.scan.test.ts +29 -0
  549. package/src/apps/data/routes/webhooks.test.ts +18 -3
  550. package/src/apps/data/routes/webhooks.ts +27 -13
  551. package/src/apps/management/App.ts +4 -0
  552. package/src/apps/management/Billing.test.ts +253 -27
  553. package/src/apps/management/Billing.ts +83 -29
  554. package/src/apps/management/routes/api-keys.test.ts +1 -1
  555. package/src/apps/management/routes/api-keys.ts +85 -11
  556. package/src/apps/management/routes/billing.test.ts +68 -4
  557. package/src/apps/management/routes/cli.test.ts +370 -0
  558. package/src/apps/management/routes/cli.ts +533 -0
  559. package/src/apps/management/routes/me.test.ts +14 -4
  560. package/src/apps/management/routes/orgs.test.ts +108 -4
  561. package/src/apps/management/routes/orgs.ts +7 -2
  562. package/src/apps/management/routes/usage.test.ts +2 -2
  563. package/src/apps/management/routes/verified-token-requests.test.ts +16 -2
  564. package/src/apps/management/routes/verified-token-requests.ts +7 -10
  565. package/src/apps/mcp.test.ts +108 -25
  566. package/src/apps/mcp.ts +15 -3
  567. package/src/apps/mpp/internal/Policy.test.ts +51 -4
  568. package/src/apps/mpp/internal/Policy.ts +6 -2
  569. package/src/apps/mpp/internal/Sponsorship.test.ts +29 -0
  570. package/src/apps/mpp/internal/Sponsorship.ts +6 -4
  571. package/src/apps/relay/App.test.ts +85 -1
  572. package/src/apps/relay/App.ts +28 -4
  573. package/src/apps/relay/Sponsorships.test.ts +97 -1
  574. package/src/apps/relay/Sponsorships.ts +77 -66
  575. package/src/apps/routes/Access.test.ts +319 -0
  576. package/src/apps/routes/Access.ts +147 -0
  577. package/src/apps/routes/App.ts +10 -0
  578. package/src/apps/routes/routes/chains.test.ts +3 -2
  579. package/src/apps/routes/routes/deposit-addresses.test.ts +978 -34
  580. package/src/apps/routes/routes/deposit-addresses.ts +243 -32
  581. package/src/apps/routes/routes/propAmm.local.test.ts +951 -0
  582. package/src/apps/routes/routes/quotes.test.ts +81 -8
  583. package/src/apps/routes/routes/quotes.ts +109 -27
  584. package/src/apps/routes/routes/transfers.test.ts +252 -15
  585. package/src/apps/routes/routes/transfers.ts +212 -33
  586. package/src/cli/ApiKeys.test.ts +265 -0
  587. package/src/cli/ApiKeys.ts +189 -0
  588. package/src/cli/Cli.test.ts +188 -0
  589. package/src/cli/Cli.ts +280 -12
  590. package/src/cli/Credentials.test.ts +122 -0
  591. package/src/cli/Credentials.ts +144 -0
  592. package/src/cli/Spec.test.ts +133 -0
  593. package/src/cli/Spec.ts +132 -0
  594. package/src/cli/bin.test.ts +49 -0
  595. package/src/cli/bin.ts +5 -1
  596. package/src/cli/commands/auth.test.ts +138 -0
  597. package/src/cli/commands/auth.ts +254 -0
  598. package/src/cli/commands/keys.test.ts +68 -0
  599. package/src/cli/commands/keys.ts +125 -0
  600. package/src/cloudflare.ts +184 -36
  601. package/src/db/Db.test.ts +877 -0
  602. package/src/db/Db.ts +507 -1
  603. package/src/db/Schema.ts +75 -4
  604. package/src/db/tables/apiKeyAdmissions.test.ts +57 -0
  605. package/src/db/tables/apiKeyAdmissions.ts +101 -11
  606. package/src/db/tables/apiKeyOwnerTombstones.ts +2 -2
  607. package/src/db/tables/authAccounts.test.ts +30 -0
  608. package/src/db/tables/authAccounts.ts +1 -0
  609. package/src/db/tables/earnVaults.test.ts +34 -0
  610. package/src/db/tables/earnVaults.ts +17 -2
  611. package/src/db/tables/organizations.test.ts +148 -84
  612. package/src/db/tables/organizations.ts +11 -43
  613. package/src/db/tables/requestUsage.ts +13 -2
  614. package/src/db/tables/rewardCampaigns.test.ts +163 -0
  615. package/src/db/tables/rewardEligibilityAssociations.test.ts +14 -0
  616. package/src/db/tables/rewardEligibilityAssociations.ts +24 -0
  617. package/src/db/tables/rewardRuns.ts +4 -0
  618. package/src/db/tables/rewardTransactionAttempts.ts +2 -0
  619. package/src/db/tables/routesDepositAddresses.test.ts +263 -0
  620. package/src/db/tables/routesDepositAddresses.ts +118 -34
  621. package/src/db/tables/routesDeposits.test.ts +133 -0
  622. package/src/db/tables/routesDeposits.ts +47 -26
  623. package/src/db/tables/routesIdempotency.test.ts +80 -0
  624. package/src/db/tables/routesIdempotency.ts +2 -0
  625. package/src/db/tables/routesPolicies.test.ts +143 -0
  626. package/src/db/tables/routesPolicies.ts +251 -0
  627. package/src/db/tables/routesTransferSubsidies.ts +64 -0
  628. package/src/db/tables/routesTransferSubsidyNonces.ts +16 -4
  629. package/src/db/tables/routesTransfers.test.ts +183 -2
  630. package/src/db/tables/routesTransfers.ts +65 -6
  631. package/src/db/tables/sponsoredTransactions.test.ts +351 -76
  632. package/src/db/tables/sponsoredTransactions.ts +182 -38
  633. package/src/db/tables/users.test.ts +51 -0
  634. package/src/db/tables/users.ts +12 -0
  635. package/src/db/tables/verifiedTokenRequests.test.ts +39 -20
  636. package/src/db/tables/verifiedTokenRequests.ts +80 -44
  637. package/src/handlers/internal/multisig.store.test.ts +120 -0
  638. package/src/handlers/internal/multisig.test.ts +389 -0
  639. package/src/handlers/internal/multisig.ts +13 -10
  640. package/src/handlers/relay.test.ts +259 -83
  641. package/src/handlers/relay.ts +36 -17
  642. package/src/internal/Auth.test.ts +383 -8
  643. package/src/internal/Auth.ts +272 -99
  644. package/src/internal/BetterAuth.test.ts +58 -22
  645. package/src/internal/BetterAuth.ts +23 -17
  646. package/src/internal/Cache.ts +3 -1
  647. package/src/internal/CliAuth.test.ts +279 -0
  648. package/src/internal/CliAuth.ts +319 -0
  649. package/src/internal/EarnSharePrices.test.ts +25 -0
  650. package/src/internal/EarnSharePrices.ts +9 -2
  651. package/src/internal/EarnVaults.test.ts +67 -0
  652. package/src/internal/EarnVaults.ts +299 -4
  653. package/src/internal/EarnWithdrawals.test.ts +315 -0
  654. package/src/internal/EarnWithdrawals.ts +266 -0
  655. package/src/internal/ExecutionContext.ts +31 -0
  656. package/src/internal/Log.test.ts +210 -0
  657. package/src/internal/Log.ts +180 -142
  658. package/src/internal/MetricSink.test.ts +190 -15
  659. package/src/internal/MetricSink.ts +27 -1
  660. package/src/internal/RateLimit.test.ts +144 -8
  661. package/src/internal/RateLimit.ts +254 -26
  662. package/src/internal/Store.ts +4 -5
  663. package/src/internal/Timing.test.ts +32 -0
  664. package/src/internal/Timing.ts +20 -1
  665. package/src/internal/Tron.test-d.ts +22 -0
  666. package/src/internal/Tron.test.ts +94 -0
  667. package/src/internal/Tron.ts +289 -0
  668. package/src/internal/Viem.rpc.test.ts +76 -0
  669. package/src/internal/Viem.ts +29 -6
  670. package/src/internal/rewards/Read.test.ts +109 -0
  671. package/src/internal/rewards/Read.ts +13 -4
  672. package/src/internal/routes/Action.test.ts +70 -0
  673. package/src/internal/routes/Action.ts +76 -1
  674. package/src/internal/routes/Chain.test.ts +18 -0
  675. package/src/internal/routes/Chain.ts +5 -0
  676. package/src/internal/routes/DepositAddress.ts +5 -0
  677. package/src/internal/routes/Evidence.test.ts +64 -0
  678. package/src/internal/routes/Evidence.ts +11 -3
  679. package/src/internal/routes/EvmTransferSettlement.ts +213 -0
  680. package/src/internal/routes/Policy.test.ts +316 -0
  681. package/src/internal/routes/Policy.ts +399 -0
  682. package/src/internal/routes/Provider.test.ts +103 -2
  683. package/src/internal/routes/Provider.ts +149 -27
  684. package/src/internal/routes/Quota.test.ts +149 -0
  685. package/src/internal/routes/Quota.ts +226 -0
  686. package/src/internal/routes/Reconciliation.local.test.ts +285 -0
  687. package/src/internal/routes/Reconciliation.test.ts +371 -13
  688. package/src/internal/routes/Reconciliation.ts +193 -42
  689. package/src/internal/routes/SolanaTransferSettlement.ts +232 -0
  690. package/src/internal/routes/SolanaTransferSubsidy.test.ts +471 -0
  691. package/src/internal/routes/SolanaTransferSubsidy.ts +760 -0
  692. package/src/internal/routes/SourceObservation.test.ts +221 -0
  693. package/src/internal/routes/Subsidy.local.test.ts +46 -0
  694. package/src/internal/routes/Subsidy.ts +4 -2
  695. package/src/internal/routes/Transfer.solana.test.ts +389 -0
  696. package/src/internal/routes/Transfer.test.ts +130 -1
  697. package/src/internal/routes/Transfer.tron.test.ts +172 -0
  698. package/src/internal/routes/Transfer.ts +866 -8
  699. package/src/internal/routes/TransferReconciliation.test.ts +26 -4
  700. package/src/internal/routes/TransferReconciliation.ts +91 -166
  701. package/src/internal/routes/TransferSettlement.ts +48 -0
  702. package/src/internal/routes/TransferSubsidy.local.test.ts +143 -0
  703. package/src/internal/routes/TransferSubsidy.test.ts +34 -4
  704. package/src/internal/routes/TransferSubsidy.ts +87 -12
  705. package/src/internal/routes/TronTransferSettlement.ts +212 -0
  706. package/src/internal/routes/TronTransferSubsidy.test.ts +109 -0
  707. package/src/internal/routes/TronTransferSubsidy.ts +619 -0
  708. package/src/internal/routes/index.test.ts +3 -0
  709. package/src/internal/routes/index.ts +3 -0
  710. package/src/internal/routes/providers/across.ts +13 -0
  711. package/src/internal/routes/providers/index.test.ts +141 -0
  712. package/src/internal/routes/providers/legacyMesh.test.ts +484 -0
  713. package/src/internal/routes/providers/legacyMesh.ts +633 -0
  714. package/src/internal/routes/providers/legacyMeshDelivery.test.ts +306 -0
  715. package/src/internal/routes/providers/legacyMeshDelivery.ts +320 -0
  716. package/src/internal/routes/providers/legacyMeshOutbound.test.ts +401 -0
  717. package/src/internal/routes/providers/legacyMeshOutbound.ts +566 -0
  718. package/src/internal/routes/providers/legacyMeshOutboundDelivery.ts +473 -0
  719. package/src/internal/routes/providers/propAmm.ts +640 -0
  720. package/src/internal/routes/providers/relay.test.ts +1299 -18
  721. package/src/internal/routes/providers/relay.ts +424 -39
  722. package/src/internal/routes/providers/rhino.ts +14 -1
  723. package/src/internal/routes/providers/squid.ts +21 -0
  724. package/src/internal/routes/providers/stargate.test.ts +105 -1
  725. package/src/internal/routes/providers/stargate.ts +22 -9
  726. package/src/internal/routes/providers/symbiosis.ts +13 -47
  727. package/src/providers/index.test.ts +2 -0
  728. package/src/providers/index.ts +18 -0
  729. package/dist/admin/Access.d.ts +0 -39
  730. package/dist/admin/Access.d.ts.map +0 -1
  731. package/dist/admin/Access.js +0 -73
  732. package/dist/admin/Access.js.map +0 -1
  733. package/src/admin/Access.test.ts +0 -130
  734. package/src/admin/Access.ts +0 -85
@@ -3,9 +3,16 @@ import { Address, Hash, Hex } from 'ox'
3
3
  import * as TestApp from '../../../../test/App.js'
4
4
  import * as TestRelay from '../../../../test/Relay.js'
5
5
  import * as TestRoutes from '../../../../test/Routes.js'
6
+ import * as RoutesCatalog from '../../../db/tables/routesCatalog.js'
7
+ import * as Organizations from '../../../db/tables/organizations.js'
6
8
  import * as RoutesDepositRequestObservations from '../../../db/tables/routesDepositRequestObservations.js'
9
+ import * as RoutesPolicies from '../../../db/tables/routesPolicies.js'
10
+ import type * as Log from '../../Log.js'
11
+ import * as Store from '../../Store.js'
7
12
  import * as DepositAddress from '../DepositAddress.js'
13
+ import * as Chain from '../Chain.js'
8
14
  import * as RoutesProvider from '../Provider.js'
15
+ import * as Across from './across.js'
9
16
  import * as Relay from './relay.js'
10
17
 
11
18
  const apiKey = process.env.RELAY_API_KEY
@@ -185,6 +192,8 @@ describe.skipIf(!apiKey)('relay.createDepositAddress (live)', () => {
185
192
  "amount": "100000000",
186
193
  "destinationChainId": 4217,
187
194
  "destinationCurrency": "0x20c00000000000000000000014f22ca97301eb73",
195
+ "fixedRate": "1:1",
196
+ "maxSubsidizationAmount": "100000000",
188
197
  "originChainId": 728126428,
189
198
  "originCurrency": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
190
199
  "recipient": "0x2222222222222222222222222222222222222222",
@@ -215,6 +224,7 @@ describe.skipIf(!apiKey)('relay.createDepositAddress (live)', () => {
215
224
  "address": Any<String>,
216
225
  "correlation": {
217
226
  "checkEndpoint": Any<String>,
227
+ "fixedRate": "1:1",
218
228
  "requestId": Any<String>,
219
229
  },
220
230
  "destinationAmount": Any<String>,
@@ -395,29 +405,48 @@ describe('parseDepositAddressRequests', () => {
395
405
  })
396
406
 
397
407
  describe('relay.listDepositAddressRequests', () => {
398
- test('returns the actual provider subsidy amount and token', async () => {
408
+ test('enforces the account-specific requests-v3 quota', async () => {
409
+ const now = new Date('2026-09-24T12:00:00.000Z')
410
+ const rateLimitStore = Store.memory()
411
+ await rateLimitStore.put(
412
+ 'routes:relay:requests-v3',
413
+ JSON.stringify({ bucket: Math.floor(now.getTime() / 1_000), count: 20, tenants: [] }),
414
+ )
415
+ let requested = false
416
+ const provider = Relay.relay({
417
+ fetch: async () => {
418
+ requested = true
419
+ throw new Error('unexpected request')
420
+ },
421
+ now: () => now,
422
+ rateLimitStore,
423
+ })
424
+
425
+ await expect(
426
+ provider.listDepositAddressRequests!(
427
+ { address: `0x${'11'.repeat(20)}` },
428
+ new AbortController().signal,
429
+ ),
430
+ ).rejects.toBeInstanceOf(RoutesProvider.ProviderRateLimitError)
431
+ expect(requested).toBe(false)
432
+ })
433
+
434
+ test('preserves completed deposit evidence when fee sponsorship is null', async () => {
399
435
  const server = await TestRelay.createServer((_request, response) => {
400
436
  response.writeHead(200, { 'content-type': 'application/json' })
401
437
  response.end(
402
438
  JSON.stringify({
403
439
  requests: [
404
440
  {
405
- createdAt: '2026-09-02T00:00:00.000Z',
441
+ createdAt: '2026-09-14T19:20:46.206Z',
406
442
  data: {
407
- feeSponsorship: {
408
- actual: {
409
- sponsorPayment: {
410
- address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
411
- amount: '23838',
412
- chainId: 8453,
413
- },
414
- },
415
- },
416
- outTxs: [],
443
+ feeSponsorship: null,
444
+ outTxs: [{ txHash: `0x${'bb'.repeat(32)}` }],
417
445
  },
418
- id: 'relay-sponsored-request',
446
+ depositAddress: { depositTxHash: `0x${'aa'.repeat(32)}` },
447
+ id: 'relay-unsponsored-request',
419
448
  status: 'success',
420
- updatedAt: '2026-09-02T00:00:10.000Z',
449
+ updatedAt: '2026-09-14T19:21:18.075Z',
421
450
  },
422
451
  ],
423
452
  }),
@@ -438,6 +467,75 @@ describe('relay.listDepositAddressRequests', () => {
438
467
  new AbortController().signal,
439
468
  ),
440
469
  ).resolves.toMatchInlineSnapshot(`
470
+ {
471
+ "requests": [
472
+ {
473
+ "createdAt": "2026-09-14T19:20:46.206Z",
474
+ "destinationTransactionHashes": [
475
+ "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
476
+ ],
477
+ "id": "relay-unsponsored-request",
478
+ "refundTransactionHashes": [],
479
+ "sourceTransactionHashes": [
480
+ "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
481
+ ],
482
+ "status": "success",
483
+ "updatedAt": "2026-09-14T19:21:18.075Z",
484
+ },
485
+ ],
486
+ }
487
+ `)
488
+ } finally {
489
+ await server.closeAsync()
490
+ }
491
+ })
492
+
493
+ test.each(['base', 'tron'] as const)(
494
+ 'returns actual sponsor payments for %s deposits',
495
+ async (source) => {
496
+ const server = await TestRelay.createServer((_request, response) => {
497
+ response.writeHead(200, { 'content-type': 'application/json' })
498
+ response.end(
499
+ JSON.stringify({
500
+ requests: [
501
+ {
502
+ createdAt: '2026-09-02T00:00:00.000Z',
503
+ data: {
504
+ feeSponsorship: {
505
+ actual: {
506
+ sponsorPayment: {
507
+ address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
508
+ amount: '23838',
509
+ chainId: 8453,
510
+ },
511
+ },
512
+ },
513
+ outTxs: [],
514
+ },
515
+ id: 'relay-sponsored-request',
516
+ status: 'success',
517
+ updatedAt: '2026-09-02T00:00:10.000Z',
518
+ },
519
+ ],
520
+ }),
521
+ )
522
+ })
523
+
524
+ try {
525
+ const provider = Relay.relay({ apiKey: 'relay-api-key', baseUrl: server.url })
526
+ const candidate =
527
+ source === 'base' ? candidateFor(provider) : depositAddressInput(provider).candidate
528
+
529
+ await expect(
530
+ provider.listDepositAddressRequests!(
531
+ {
532
+ address: `0x${'11'.repeat(20)}`,
533
+ destinationToken: candidate.destinationToken,
534
+ sourceToken: candidate.sourceToken,
535
+ },
536
+ new AbortController().signal,
537
+ ),
538
+ ).resolves.toMatchInlineSnapshot(`
441
539
  {
442
540
  "requests": [
443
541
  {
@@ -471,10 +569,11 @@ describe('relay.listDepositAddressRequests', () => {
471
569
  ],
472
570
  }
473
571
  `)
474
- } finally {
475
- await server.closeAsync()
476
- }
477
- })
572
+ } finally {
573
+ await server.closeAsync()
574
+ }
575
+ },
576
+ )
478
577
 
479
578
  test('omits unfinished output transaction hashes', async () => {
480
579
  const server = await TestRelay.createServer((_request, response) => {
@@ -528,6 +627,140 @@ describe('relay.listDepositAddressRequests', () => {
528
627
  })
529
628
 
530
629
  describe('relay.createDepositAddress', () => {
630
+ test('reserves the last two quote slots for executable operations', async () => {
631
+ const now = new Date('2026-09-24T12:00:00.000Z')
632
+ const rateLimitStore = Store.memory()
633
+ const key = 'routes:relay:quote-v2'
634
+ const quota = (count: number) =>
635
+ JSON.stringify({ bucket: Math.floor(now.getTime() / 1_000), count, tenants: [] })
636
+ const upstream = new Error('upstream reached')
637
+ const provider = Relay.relay({
638
+ fetch: async () => {
639
+ throw upstream
640
+ },
641
+ now: () => now,
642
+ rateLimitStore,
643
+ })
644
+
645
+ await rateLimitStore.put(key, quota(8))
646
+ await expect(
647
+ provider.createDepositAddress!(depositAddressInput(provider), new AbortController().signal),
648
+ ).rejects.toBe(upstream)
649
+ expect(JSON.parse((await rateLimitStore.get(key))!).count).toBe(9)
650
+
651
+ await rateLimitStore.put(key, quota(10))
652
+ await expect(
653
+ provider.createDepositAddress!(depositAddressInput(provider), new AbortController().signal),
654
+ ).rejects.toBeInstanceOf(RoutesProvider.ProviderRateLimitError)
655
+ expect(await rateLimitStore.get(key)).toBe(quota(10))
656
+ })
657
+
658
+ test.each([
659
+ { amount: '100000000', decimals: 6, isFixedRate: false, subsidize: false },
660
+ { amount: '100000000', decimals: 6, isFixedRate: false, subsidize: true },
661
+ { amount: '100000000', decimals: 6, isFixedRate: undefined, subsidize: true },
662
+ { amount: '100000000', decimals: 6, isFixedRate: true, subsidize: true },
663
+ { amount: '100000000', decimals: 6, fallback: true, isFixedRate: true, subsidize: true },
664
+ { amount: '100000000000000000000', decimals: 18, isFixedRate: true, subsidize: true },
665
+ ])('accepts 1:1 output with slippage minima: %j', async (scenario) => {
666
+ let body: Record<string, unknown> | undefined
667
+ const server = await TestRelay.createServer(async (request, response) => {
668
+ request.setEncoding('utf8')
669
+ let payload = ''
670
+ for await (const chunk of request) payload += chunk
671
+ body = JSON.parse(payload)
672
+ response.writeHead(200, { 'content-type': 'application/json' })
673
+ response.end(
674
+ JSON.stringify({
675
+ details: {
676
+ currencyIn: { amount: scenario.amount },
677
+ currencyOut: { amount: '100000000', minimumAmount: '98000000' },
678
+ isFixedRate: scenario.isFixedRate,
679
+ },
680
+ steps: [
681
+ {
682
+ depositAddress: 'TJRabPrwbZy45sbavfcjinPJC18kjpRTv8',
683
+ requestId: 'relay-fixed-rate',
684
+ },
685
+ ],
686
+ }),
687
+ )
688
+ })
689
+ try {
690
+ const provider = Relay.relay({ baseUrl: server.url, subsidies: { maxAmount: '100' } })
691
+ const input = depositAddressInput(provider)
692
+ const result = await provider.createDepositAddress!(
693
+ {
694
+ ...input,
695
+ amount: scenario.amount,
696
+ candidate: {
697
+ ...input.candidate,
698
+ sourceToken: { ...input.candidate.sourceToken, decimals: scenario.decimals },
699
+ },
700
+ subsidize: scenario.subsidize,
701
+ subsidyMaxAmount: 'fallback' in scenario ? undefined : '0.05',
702
+ },
703
+ new AbortController().signal,
704
+ )
705
+ expect(body).toMatchObject({
706
+ amount: scenario.amount,
707
+ subsidizeFees: scenario.subsidize,
708
+ tradeType: 'EXACT_INPUT',
709
+ useDepositAddress: true,
710
+ })
711
+ if (scenario.subsidize) {
712
+ expect(body).toMatchObject({
713
+ fixedRate: '1:1',
714
+ maxSubsidizationAmount: 'fallback' in scenario ? '100000000' : '50000',
715
+ })
716
+ expect(result.correlation.fixedRate).toBe('1:1')
717
+ } else {
718
+ expect(body).not.toHaveProperty('fixedRate')
719
+ expect(body).not.toHaveProperty('maxSubsidizationAmount')
720
+ expect(result.correlation).not.toHaveProperty('fixedRate')
721
+ }
722
+ expect(result.destinationAmount).toBe('100000000')
723
+ expect(result.destinationAmountMin).toBe('98000000')
724
+ } finally {
725
+ await server.closeAsync()
726
+ }
727
+ })
728
+
729
+ test.each([
730
+ { amount: '99000000', isFixedRate: true, minimumAmount: '99000000' },
731
+ { amount: '100000001', isFixedRate: true, minimumAmount: '98000000' },
732
+ ])('rejects sponsored quotes without exact 1:1 output: %j', async (scenario) => {
733
+ const server = await TestRelay.createServer((_request, response) => {
734
+ response.writeHead(200, { 'content-type': 'application/json' })
735
+ response.end(
736
+ JSON.stringify({
737
+ details: {
738
+ currencyIn: { amount: '100000000' },
739
+ currencyOut: { amount: scenario.amount, minimumAmount: scenario.minimumAmount },
740
+ isFixedRate: scenario.isFixedRate,
741
+ },
742
+ steps: [
743
+ { depositAddress: 'TJRabPrwbZy45sbavfcjinPJC18kjpRTv8', requestId: 'relay-fixed-rate' },
744
+ ],
745
+ }),
746
+ )
747
+ })
748
+ try {
749
+ const provider = Relay.relay({ baseUrl: server.url, subsidies: { maxAmount: '100' } })
750
+ await expect(
751
+ provider.createDepositAddress!(
752
+ {
753
+ ...depositAddressInput(provider),
754
+ subsidize: true,
755
+ },
756
+ new AbortController().signal,
757
+ ),
758
+ ).rejects.toThrow(RoutesProvider.ProviderPayloadError)
759
+ } finally {
760
+ await server.closeAsync()
761
+ }
762
+ })
763
+
531
764
  test('rejects subsidized provisioning outside the configured limit', async () => {
532
765
  const provider = Relay.relay({ subsidies: { maxAmount: '1' } })
533
766
 
@@ -541,6 +774,84 @@ describe('relay.createDepositAddress', () => {
541
774
  })
542
775
 
543
776
  describe('relay.prepareTransfer', () => {
777
+ test('prepares the curated Tempo USDC.e to Solana USDC route', async () => {
778
+ let requestBody: Record<string, unknown> | undefined
779
+ const server = await TestRelay.createServer(async (request, response) => {
780
+ let payload = ''
781
+ for await (const chunk of request) payload += chunk
782
+ requestBody = JSON.parse(payload)
783
+ response.writeHead(200, { 'content-type': 'application/json' })
784
+ response.end(
785
+ JSON.stringify({
786
+ details: {
787
+ currencyIn: { amount: '5000000' },
788
+ currencyOut: { amount: '4970000', minimumAmount: '4960000' },
789
+ },
790
+ steps: [
791
+ {
792
+ id: 'deposit',
793
+ items: [
794
+ {
795
+ data: {
796
+ chainId: 4217,
797
+ data: '0x1234',
798
+ from: sender,
799
+ to: '0x3333333333333333333333333333333333333333',
800
+ value: '0',
801
+ },
802
+ },
803
+ ],
804
+ kind: 'transaction',
805
+ requestId: 'relay-tempo-solana',
806
+ },
807
+ ],
808
+ }),
809
+ )
810
+ })
811
+ try {
812
+ const provider = Relay.relay({ baseUrl: server.url })
813
+ const candidate = RoutesProvider.getQuoteCandidates({
814
+ catalog: TestRoutes.snapshot,
815
+ destinationChain: 'solana',
816
+ destinationToken: 'USDC',
817
+ providers: [provider],
818
+ sourceAmount: '5000000',
819
+ sourceAmountUnits: 'baseUnits',
820
+ sourceChain: 'tempo',
821
+ sourceToken: 'USDC.e',
822
+ }).find((entry) => entry.id === 'tempo-usdce-solana-usdc-relay')
823
+ if (!candidate) throw new Error('Expected the Relay Tempo to Solana candidate.')
824
+ const solanaRecipient = '7ZwiMrYFNCzZ4TcPkeMx7BTZSZ9jDgGR8H8Nkazhr6L1'
825
+ const result = await provider.prepareTransfer!(
826
+ {
827
+ candidate,
828
+ method: 'transaction',
829
+ mode: 'exactSource',
830
+ recipient: solanaRecipient,
831
+ sender,
832
+ },
833
+ new AbortController().signal,
834
+ )
835
+ expect(requestBody).toMatchObject({
836
+ amount: '5000000',
837
+ destinationChainId: 792703809,
838
+ destinationCurrency: candidate.destinationToken.address,
839
+ originChainId: 4217,
840
+ originCurrency: candidate.sourceToken.address,
841
+ recipient: solanaRecipient,
842
+ user: sender,
843
+ })
844
+ expect(result).toMatchObject({
845
+ action: { type: 'evm:calls' },
846
+ correlation: { requestId: 'relay-tempo-solana' },
847
+ destinationAmount: '4970000',
848
+ destinationAmountMin: '4960000',
849
+ })
850
+ } finally {
851
+ await server.closeAsync()
852
+ }
853
+ })
854
+
544
855
  test('refuses methods and modes it cannot prepare', async () => {
545
856
  const provider = Relay.relay()
546
857
  await expect(
@@ -552,6 +863,570 @@ describe('relay.prepareTransfer', () => {
552
863
  })
553
864
  })
554
865
 
866
+ describe('relay.verifySourceTransaction', () => {
867
+ test('bounds the Relay chain lookup', async () => {
868
+ const snapshot = TestRoutes.transferSnapshot()
869
+ const transactionHash = `0x${'aa'.repeat(32)}`
870
+ const server = await TestRelay.createServer((request, response) => {
871
+ request.resume()
872
+ if (!request.url?.startsWith('/requests/v3')) return
873
+ response.writeHead(200, { 'content-type': 'application/json' })
874
+ response.end(
875
+ JSON.stringify({
876
+ requests: [
877
+ {
878
+ data: { inTxs: [{ chainId: 8453, status: 'success', txHash: transactionHash }] },
879
+ id: 'base-to-tempo',
880
+ recipient: snapshot.recipient,
881
+ sender: snapshot.sender,
882
+ status: 'pending',
883
+ },
884
+ ],
885
+ }),
886
+ )
887
+ })
888
+ try {
889
+ const provider = Relay.relay({
890
+ apiKey: 'relay-api-key',
891
+ baseUrl: server.url,
892
+ observation: { db },
893
+ })
894
+ const options = {
895
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id)!,
896
+ providerState: { requestId: 'base-to-tempo' },
897
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
898
+ transactionHash,
899
+ transfer: snapshot,
900
+ }
901
+ await expect(
902
+ provider.verifySourceTransaction!(options, new AbortController().signal),
903
+ ).rejects.toBeInstanceOf(RoutesProvider.ProviderTimeoutError)
904
+ } finally {
905
+ server.closeAllConnections()
906
+ await server.closeAsync()
907
+ }
908
+ }, 15_000)
909
+
910
+ test.each([
911
+ { sourceStatus: 'pending', type: 'pending' },
912
+ { sourceStatus: 'submitted', type: 'pending' },
913
+ { sourceStatus: 'failure', type: 'invalid' },
914
+ ])(
915
+ 'accepts the Base to Tempo route and treats $sourceStatus as $type',
916
+ async ({ sourceStatus, type }) => {
917
+ const transactionHash = `0x${'aa'.repeat(32)}`
918
+ const snapshot = TestRoutes.transferSnapshot({
919
+ destinationToken: {
920
+ ...TestRoutes.transferSnapshot().destinationToken,
921
+ address: '0x20c0000000000000000000000000000000000000',
922
+ name: 'pathUSD',
923
+ symbol: 'pathUSD',
924
+ },
925
+ })
926
+ const server = await TestRelay.createServer((_request, response) => {
927
+ response.writeHead(200, { 'content-type': 'application/json' })
928
+ response.end(
929
+ JSON.stringify({
930
+ requests: [
931
+ {
932
+ data: {
933
+ inTxs: [
934
+ { chainId: 8453, status: 'pending', txHash: null },
935
+ { chainId: 8453, status: sourceStatus, txHash: transactionHash },
936
+ ],
937
+ },
938
+ id: 'base-to-tempo',
939
+ recipient: snapshot.recipient,
940
+ sender: snapshot.sender,
941
+ status: 'pending',
942
+ },
943
+ ],
944
+ }),
945
+ )
946
+ })
947
+ try {
948
+ const provider = Relay.relay({
949
+ apiKey: 'relay-api-key',
950
+ baseUrl: server.url,
951
+ observation: { db },
952
+ })
953
+ const options = {
954
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id)!,
955
+ providerState: { requestId: 'base-to-tempo' },
956
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
957
+ transactionHash,
958
+ transfer: snapshot,
959
+ }
960
+ await expect(
961
+ provider.verifySourceTransaction!(options, new AbortController().signal),
962
+ ).resolves.toEqual({ type })
963
+ } finally {
964
+ await server.closeAsync()
965
+ }
966
+ },
967
+ )
968
+
969
+ test('keeps unfinished Tempo delivery pending', async () => {
970
+ const snapshot = TestRoutes.transferSnapshot({
971
+ destinationToken: {
972
+ ...TestRoutes.transferSnapshot().destinationToken,
973
+ address: '0x20c0000000000000000000000000000000000000',
974
+ name: 'pathUSD',
975
+ symbol: 'pathUSD',
976
+ },
977
+ })
978
+ const server = await TestRelay.createServer((_request, response) => {
979
+ response.writeHead(200, { 'content-type': 'application/json' })
980
+ response.end(
981
+ JSON.stringify({
982
+ requests: [
983
+ {
984
+ id: 'base-to-tempo',
985
+ recipient: snapshot.recipient,
986
+ sender: snapshot.sender,
987
+ status: 'pending',
988
+ },
989
+ ],
990
+ }),
991
+ )
992
+ })
993
+ try {
994
+ const provider = Relay.relay({
995
+ apiKey: 'relay-api-key',
996
+ baseUrl: server.url,
997
+ observation: { db },
998
+ })
999
+ await expect(
1000
+ provider.verifyDestinationDelivery!(
1001
+ {
1002
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id)!,
1003
+ providerState: { requestId: 'base-to-tempo' },
1004
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
1005
+ transfer: snapshot,
1006
+ },
1007
+ new AbortController().signal,
1008
+ ),
1009
+ ).resolves.toEqual({ type: 'pending' })
1010
+ } finally {
1011
+ await server.closeAsync()
1012
+ }
1013
+ })
1014
+ })
1015
+
1016
+ describe('relay.verifyDestinationDelivery', () => {
1017
+ test('keeps successful Relay outputs pending until their hash is assigned', async () => {
1018
+ const snapshot = TestRoutes.transferSnapshot()
1019
+ const server = await TestRelay.createServer((_request, response) => {
1020
+ response.writeHead(200, { 'content-type': 'application/json' })
1021
+ response.end(
1022
+ JSON.stringify({
1023
+ requests: [
1024
+ {
1025
+ data: {
1026
+ outTxs: [{ chainId: 4217, status: 'success', txHash: null }],
1027
+ route: {
1028
+ actual: {
1029
+ destination: {
1030
+ outputCurrency: {
1031
+ amount: '979295',
1032
+ currency: { address: snapshot.destinationToken.address, chainId: 4217 },
1033
+ },
1034
+ },
1035
+ },
1036
+ },
1037
+ },
1038
+ id: 'base-to-tempo',
1039
+ recipient: snapshot.recipient,
1040
+ sender: snapshot.sender,
1041
+ status: 'success',
1042
+ },
1043
+ ],
1044
+ }),
1045
+ )
1046
+ })
1047
+ try {
1048
+ const provider = Relay.relay({
1049
+ apiKey: 'relay-api-key',
1050
+ baseUrl: server.url,
1051
+ observation: { db },
1052
+ })
1053
+ await expect(
1054
+ provider.verifyDestinationDelivery!(
1055
+ {
1056
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id)!,
1057
+ providerState: { requestId: 'base-to-tempo' },
1058
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
1059
+ transfer: snapshot,
1060
+ },
1061
+ new AbortController().signal,
1062
+ ),
1063
+ ).resolves.toEqual({ type: 'pending' })
1064
+ } finally {
1065
+ await server.closeAsync()
1066
+ }
1067
+ })
1068
+
1069
+ test.each([
1070
+ { recipient: '0xAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa', type: 'pending' },
1071
+ { recipient: 'not-an-address', type: 'invalid' },
1072
+ ])('compares EVM recipients by address value: $recipient', async ({ recipient, type }) => {
1073
+ const snapshot = TestRoutes.transferSnapshot({
1074
+ recipient: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
1075
+ })
1076
+ const server = await TestRelay.createServer((_request, response) => {
1077
+ response.writeHead(200, { 'content-type': 'application/json' })
1078
+ response.end(
1079
+ JSON.stringify({
1080
+ requests: [
1081
+ { id: 'base-to-tempo', recipient, sender: snapshot.sender, status: 'pending' },
1082
+ ],
1083
+ }),
1084
+ )
1085
+ })
1086
+ try {
1087
+ const provider = Relay.relay({
1088
+ apiKey: 'relay-api-key',
1089
+ baseUrl: server.url,
1090
+ observation: { db },
1091
+ })
1092
+ await expect(
1093
+ provider.verifyDestinationDelivery!(
1094
+ {
1095
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id)!,
1096
+ providerState: { requestId: 'base-to-tempo' },
1097
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
1098
+ transfer: snapshot,
1099
+ },
1100
+ new AbortController().signal,
1101
+ ),
1102
+ ).resolves.toEqual({ type })
1103
+ } finally {
1104
+ await server.closeAsync()
1105
+ }
1106
+ })
1107
+
1108
+ test.each([
1109
+ { address: '0x20C000000000000000000000B9537D11C60E8B50', type: 'pending' },
1110
+ { address: 'not-an-address', type: 'invalid' },
1111
+ ])('compares EVM destination tokens by address value: $address', async ({ address, type }) => {
1112
+ const snapshot = TestRoutes.transferSnapshot()
1113
+ const server = await TestRelay.createServer((_request, response) => {
1114
+ response.writeHead(200, { 'content-type': 'application/json' })
1115
+ response.end(
1116
+ JSON.stringify({
1117
+ requests: [
1118
+ {
1119
+ data: {
1120
+ route: {
1121
+ actual: {
1122
+ destination: {
1123
+ outputCurrency: { amount: '979295', currency: { address, chainId: 4217 } },
1124
+ },
1125
+ },
1126
+ },
1127
+ },
1128
+ id: 'base-to-tempo',
1129
+ recipient: snapshot.recipient,
1130
+ sender: snapshot.sender,
1131
+ status: 'pending',
1132
+ },
1133
+ ],
1134
+ }),
1135
+ )
1136
+ })
1137
+ try {
1138
+ const provider = Relay.relay({
1139
+ apiKey: 'relay-api-key',
1140
+ baseUrl: server.url,
1141
+ observation: { db },
1142
+ })
1143
+ await expect(
1144
+ provider.verifyDestinationDelivery!(
1145
+ {
1146
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id)!,
1147
+ providerState: { requestId: 'base-to-tempo' },
1148
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
1149
+ transfer: snapshot,
1150
+ },
1151
+ new AbortController().signal,
1152
+ ),
1153
+ ).resolves.toEqual({ type })
1154
+ } finally {
1155
+ await server.closeAsync()
1156
+ }
1157
+ })
1158
+
1159
+ test('requires exact Solana recipient and token addresses', async () => {
1160
+ const snapshot = TestRoutes.transferSnapshot({
1161
+ destinationChain: {
1162
+ addressFormat: 'base58',
1163
+ id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
1164
+ kind: 'solana',
1165
+ name: 'Solana',
1166
+ },
1167
+ destinationToken: {
1168
+ ...TestRoutes.transferSnapshot().destinationToken,
1169
+ address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
1170
+ },
1171
+ recipient: '7ZwiMrYFNCzZ4TcPkeMx7BTZSZ9jDgGR8H8Nkazhr6L1',
1172
+ })
1173
+ const server = await TestRelay.createServer((_request, response) => {
1174
+ response.writeHead(200, { 'content-type': 'application/json' })
1175
+ response.end(
1176
+ JSON.stringify({
1177
+ requests: [
1178
+ {
1179
+ data: {
1180
+ route: {
1181
+ actual: {
1182
+ destination: {
1183
+ outputCurrency: {
1184
+ amount: '979295',
1185
+ currency: {
1186
+ address: snapshot.destinationToken.address.toLowerCase(),
1187
+ chainId: 792703809,
1188
+ },
1189
+ },
1190
+ },
1191
+ },
1192
+ },
1193
+ },
1194
+ id: 'base-to-solana',
1195
+ recipient: snapshot.recipient,
1196
+ sender: snapshot.sender,
1197
+ status: 'pending',
1198
+ },
1199
+ ],
1200
+ }),
1201
+ )
1202
+ })
1203
+ try {
1204
+ const provider = Relay.relay({
1205
+ apiKey: 'relay-api-key',
1206
+ baseUrl: server.url,
1207
+ observation: { db },
1208
+ })
1209
+ await expect(
1210
+ provider.verifyDestinationDelivery!(
1211
+ {
1212
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id) ??
1213
+ Chain.from({ id: snapshot.destinationChain.id as Chain.Id, name: 'Solana', rpcUrls: [server.url], slug: 'solana' }), // prettier-ignore
1214
+ providerState: { requestId: 'base-to-solana' },
1215
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
1216
+ transfer: snapshot,
1217
+ },
1218
+ new AbortController().signal,
1219
+ ),
1220
+ ).resolves.toEqual({ type: 'invalid' })
1221
+ } finally {
1222
+ await server.closeAsync()
1223
+ }
1224
+ })
1225
+
1226
+ test('moves Relay fallback to manual recovery', async () => {
1227
+ const snapshot = TestRoutes.transferSnapshot()
1228
+ const server = await TestRelay.createServer((_request, response) => {
1229
+ response.writeHead(200, { 'content-type': 'application/json' })
1230
+ response.end(JSON.stringify({ requests: [{ id: 'base-to-tempo', recipient: snapshot.recipient, sender: snapshot.sender, status: 'fallback' }] })) // prettier-ignore
1231
+ })
1232
+ try {
1233
+ const provider = Relay.relay({
1234
+ apiKey: 'relay-api-key',
1235
+ baseUrl: server.url,
1236
+ observation: { db },
1237
+ })
1238
+ await expect(
1239
+ provider.verifyDestinationDelivery!(
1240
+ {
1241
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id)!,
1242
+ providerState: { requestId: 'base-to-tempo' },
1243
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
1244
+ transfer: snapshot,
1245
+ },
1246
+ new AbortController().signal,
1247
+ ),
1248
+ ).resolves.toEqual({
1249
+ statusReason: {
1250
+ code: 'manual_recovery_required',
1251
+ message: 'Relay could not complete the destination transfer.',
1252
+ },
1253
+ type: 'action-required',
1254
+ })
1255
+ } finally {
1256
+ await server.closeAsync()
1257
+ }
1258
+ })
1259
+
1260
+ test('bounds Relay request polling and preserves caller cancellation', async () => {
1261
+ const snapshot = TestRoutes.transferSnapshot()
1262
+ const server = await TestRelay.createServer((request) => request.resume())
1263
+ try {
1264
+ const provider = Relay.relay({
1265
+ apiKey: 'relay-api-key',
1266
+ baseUrl: server.url,
1267
+ observation: { db },
1268
+ })
1269
+ const options = {
1270
+ destinationChain: TestRoutes.snapshot.chainsByKey.get(snapshot.destinationChain.id)!,
1271
+ providerState: { requestId: 'base-to-tempo' },
1272
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
1273
+ transfer: snapshot,
1274
+ }
1275
+ await expect(
1276
+ provider.verifyDestinationDelivery!(options, new AbortController().signal),
1277
+ ).rejects.toBeInstanceOf(RoutesProvider.ProviderTimeoutError)
1278
+ const controller = new AbortController()
1279
+ const request = provider.verifyDestinationDelivery!(options, controller.signal)
1280
+ controller.abort()
1281
+ await expect(request).rejects.toMatchObject({ name: 'AbortError' })
1282
+ } finally {
1283
+ server.closeAllConnections()
1284
+ await server.closeAsync()
1285
+ }
1286
+ }, 15_000)
1287
+
1288
+ test.each([
1289
+ {
1290
+ amount: '939241',
1291
+ expected: {
1292
+ statusReason: {
1293
+ code: 'manual_recovery_required',
1294
+ message: 'Relay delivered less than the quoted minimum destination amount.',
1295
+ },
1296
+ type: 'action-required',
1297
+ },
1298
+ },
1299
+ {
1300
+ amount: '939242',
1301
+ expected: { destinationAmount: '939242', transactionHash: '5wHu1qwD7iCD6aZLQ3xLyRsfNySXgJ7rPcT2fbeK4cjQ', type: 'verified' }, // prettier-ignore
1302
+ },
1303
+ ])('enforces the quoted minimum when Relay reports $amount', async ({ amount, expected }) => {
1304
+ const recipient = '7ZwiMrYFNCzZ4TcPkeMx7BTZSZ9jDgGR8H8Nkazhr6L1'
1305
+ const token = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
1306
+ const transactionHash = '5wHu1qwD7iCD6aZLQ3xLyRsfNySXgJ7rPcT2fbeK4cjQ'
1307
+ const snapshot = TestRoutes.transferSnapshot({
1308
+ destinationChain: {
1309
+ addressFormat: 'base58',
1310
+ id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
1311
+ kind: 'solana',
1312
+ name: 'Solana',
1313
+ },
1314
+ destinationToken: {
1315
+ address: token,
1316
+ currency: 'USD',
1317
+ decimals: 6,
1318
+ name: 'USD Coin',
1319
+ standard: 'SPL',
1320
+ symbol: 'USDC',
1321
+ tokenKey: `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:${token}`,
1322
+ verified: true,
1323
+ },
1324
+ recipient,
1325
+ })
1326
+ const server = await TestRelay.createServer((request, response) => {
1327
+ request.resume()
1328
+ response.writeHead(200, { 'content-type': 'application/json' })
1329
+ if (request.url?.startsWith('/requests/v3')) {
1330
+ response.end(
1331
+ JSON.stringify({
1332
+ requests: [
1333
+ {
1334
+ data: {
1335
+ outTxs: [{ chainId: 792703809, status: 'success', txHash: transactionHash }],
1336
+ route: {
1337
+ actual: {
1338
+ destination: {
1339
+ outputCurrency: {
1340
+ amount,
1341
+ currency: { address: token, chainId: 792703809 },
1342
+ },
1343
+ },
1344
+ },
1345
+ },
1346
+ },
1347
+ id: 'base-to-solana',
1348
+ recipient,
1349
+ sender: snapshot.sender,
1350
+ status: 'success',
1351
+ },
1352
+ ],
1353
+ }),
1354
+ )
1355
+ return
1356
+ }
1357
+ response.end(
1358
+ JSON.stringify({
1359
+ id: 1,
1360
+ jsonrpc: '2.0',
1361
+ result: {
1362
+ meta: {
1363
+ err: null,
1364
+ postTokenBalances: [{ accountIndex: 1, mint: token, owner: recipient }],
1365
+ },
1366
+ transaction: {
1367
+ message: {
1368
+ accountKeys: ['Sender1111111111111111111111111111111111', 'RecipientTokenAccount'],
1369
+ instructions: [
1370
+ {
1371
+ parsed: {
1372
+ info: {
1373
+ destination: 'RecipientTokenAccount',
1374
+ mint: token,
1375
+ tokenAmount: { amount },
1376
+ },
1377
+ type: 'transferChecked',
1378
+ },
1379
+ program: 'spl-token',
1380
+ },
1381
+ ],
1382
+ },
1383
+ },
1384
+ },
1385
+ }),
1386
+ )
1387
+ })
1388
+ try {
1389
+ await RoutesCatalog.publish(db, {
1390
+ chainTokens: [],
1391
+ chains: [
1392
+ {
1393
+ aliases: [],
1394
+ id: snapshot.destinationChain.id as Chain.Id,
1395
+ name: 'Solana',
1396
+ parentChainId: null,
1397
+ rpcUrls: [server.url],
1398
+ slug: 'solana',
1399
+ },
1400
+ ],
1401
+ routes: [],
1402
+ tokens: [],
1403
+ })
1404
+ const provider = Relay.relay({
1405
+ apiKey: 'relay-api-key',
1406
+ baseUrl: server.url,
1407
+ observation: { db },
1408
+ })
1409
+ const result = await provider.verifyDestinationDelivery!(
1410
+ {
1411
+ destinationChain: Chain.from({
1412
+ id: snapshot.destinationChain.id as Chain.Id,
1413
+ name: 'Solana',
1414
+ rpcUrls: [server.url],
1415
+ slug: 'solana',
1416
+ }),
1417
+ providerState: { requestId: 'base-to-solana' },
1418
+ sourceChain: TestRoutes.snapshot.chainsByKey.get(snapshot.sourceChain.id)!,
1419
+ transfer: snapshot,
1420
+ },
1421
+ new AbortController().signal,
1422
+ )
1423
+ expect(result).toEqual(expected)
1424
+ } finally {
1425
+ await server.closeAsync()
1426
+ }
1427
+ })
1428
+ })
1429
+
555
1430
  describe('verifyWebhook', () => {
556
1431
  beforeEach(() => vi.useFakeTimers({ now: webhookNow }))
557
1432
  afterEach(() => vi.useRealTimers())
@@ -688,3 +1563,409 @@ describe('receiveWebhook', () => {
688
1563
  `)
689
1564
  })
690
1565
  })
1566
+
1567
+ describe('quote errors', () => {
1568
+ const sourceToken = '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'
1569
+ const destinationToken = '0x20c000000000000000000000b9537d11c60e8b50'
1570
+ const pathUsd = '0x20c0000000000000000000000000000000000000'
1571
+ const rejection = {
1572
+ errorCode: 'AMOUNT_TOO_LOW',
1573
+ message: 'Swap output amount is too small to cover fees required to execute swap',
1574
+ requestId: '0x1789498645e745767fefcb596a776acd85361596dde3b91908a4a4268235da01',
1575
+ }
1576
+ const request = {
1577
+ destinationToken,
1578
+ sourceAmount: '200000',
1579
+ sourceAmountUnits: 'baseUnits',
1580
+ sourceChain: 'base',
1581
+ sourceToken,
1582
+ } as const
1583
+ const key = {
1584
+ id: 'key_relay_quote_errors',
1585
+ orgId: 'org_relay_quote_errors',
1586
+ scopes: ['data:read', 'routes:read', 'routes:write'],
1587
+ token: 'secret_relay_quote_errors',
1588
+ } satisfies TestApp.kvStore.Key
1589
+
1590
+ beforeAll(async () => {
1591
+ await TestRoutes.publish(db)
1592
+ await Organizations.upsert(db, { id: key.orgId, name: 'Relay quote errors' })
1593
+ await RoutesPolicies.save(db, {
1594
+ policy: { access: null },
1595
+ scope: { environment: 'production', orgId: key.orgId },
1596
+ version: 0,
1597
+ })
1598
+ })
1599
+
1600
+ describe.each(['getQuote', 'prepareTransfer', 'createDepositAddress'] as const)(
1601
+ '%s',
1602
+ (operation) => {
1603
+ test('classifies AMOUNT_TOO_LOW and retains the provider reason', async () => {
1604
+ const server = await quoteServer(400, rejection)
1605
+ try {
1606
+ const provider = Relay.relay({
1607
+ baseUrl: server.url,
1608
+ userAddresses: TestRoutes.relayQuoteUsers,
1609
+ })
1610
+ if (operation === 'getQuote')
1611
+ await expect(invoke(provider, operation)).resolves.toMatchObject({
1612
+ quality: { sourceDetail: 'relay:quote-v2:AMOUNT_TOO_LOW', tier: 'unavailable' },
1613
+ status: 'unavailable',
1614
+ })
1615
+ else
1616
+ await expect(invoke(provider, operation)).rejects.toMatchObject({
1617
+ cause: { body: rejection, status: 400 },
1618
+ message: 'AMOUNT_TOO_LOW',
1619
+ name:
1620
+ operation === 'createDepositAddress'
1621
+ ? 'RoutesProvider.AmountTooLowError'
1622
+ : 'RoutesProvider.ProviderUnavailableError',
1623
+ })
1624
+ expect(server.requests).toEqual([
1625
+ expect.objectContaining({
1626
+ amount: '200000',
1627
+ destinationChainId: 4217,
1628
+ destinationCurrency: operation === 'prepareTransfer' ? pathUsd : destinationToken,
1629
+ originChainId: 8453,
1630
+ originCurrency: sourceToken,
1631
+ tradeType: 'EXACT_INPUT',
1632
+ ...(operation === 'createDepositAddress'
1633
+ ? { subsidizeFees: false, useDepositAddress: true }
1634
+ : {}),
1635
+ }),
1636
+ ])
1637
+ } finally {
1638
+ await server.closeAsync()
1639
+ }
1640
+ })
1641
+
1642
+ test.each([
1643
+ { body: { errorCode: 'UNKNOWN_ERROR' }, status: 400 },
1644
+ { body: rejection, status: 500 },
1645
+ { body: { message: rejection.message }, status: 400 },
1646
+ ])('preserves unexpected upstream response $status: $body', async ({ body, status }) => {
1647
+ const server = await quoteServer(status, body)
1648
+ try {
1649
+ const provider = Relay.relay({
1650
+ baseUrl: server.url,
1651
+ userAddresses: TestRoutes.relayQuoteUsers,
1652
+ })
1653
+ await expect(invoke(provider, operation)).rejects.toMatchObject({
1654
+ body,
1655
+ name: 'RoutesProvider.ProviderResponseError',
1656
+ status,
1657
+ })
1658
+ } finally {
1659
+ await server.closeAsync()
1660
+ }
1661
+ })
1662
+
1663
+ test.each(['AMOUNT_TOO_LOW', 'NO_ROUTE'])(
1664
+ 'uses the composed API contract for %s',
1665
+ async (errorCode) => {
1666
+ const server = await quoteServer(400, { ...rejection, errorCode })
1667
+ const entries: Log.Entry[] = []
1668
+ try {
1669
+ const app = create(server.url, entries)
1670
+ const response = await apiRequest(app, operation)
1671
+ const body = await response.json()
1672
+ const code = (() => {
1673
+ if (operation === 'getQuote') return 'route_unavailable'
1674
+ if (operation === 'createDepositAddress' && errorCode === 'AMOUNT_TOO_LOW')
1675
+ return 'amount_too_low'
1676
+ return 'quote_not_available'
1677
+ })()
1678
+ expect({ error: { code: body.error.code }, status: response.status }).toEqual({
1679
+ error: { code },
1680
+ status: operation === 'getQuote' || code === 'amount_too_low' ? 400 : 404,
1681
+ })
1682
+ if (code === 'amount_too_low')
1683
+ expect(body.error.message).toMatchInlineSnapshot(
1684
+ `"This amount cannot cover the route fees. Increase the amount or enable subsidies if available."`,
1685
+ )
1686
+ expect(entries.at(-1)?.routesProviderAttempts).toEqual([
1687
+ {
1688
+ durationMs: expect.any(Number),
1689
+ id: 'relay',
1690
+ operation,
1691
+ outcome: 'unavailable',
1692
+ },
1693
+ ])
1694
+ expect(entries.at(-1)?.provider).toBeUndefined()
1695
+ expect(server.requests).toHaveLength(1)
1696
+ } finally {
1697
+ await server.closeAsync()
1698
+ }
1699
+ },
1700
+ )
1701
+
1702
+ test.each([400, 503])('keeps unexpected HTTP %s failures as API 502', async (status) => {
1703
+ const server = await quoteServer(status, { errorCode: 'UNKNOWN_ERROR' })
1704
+ const entries: Log.Entry[] = []
1705
+ try {
1706
+ const response = await apiRequest(create(server.url, entries), operation)
1707
+ expect(response.status).toBe(502)
1708
+ expect((await response.json()).error.code).toBe('upstream_error')
1709
+ expect(entries.at(-1)?.provider).toEqual({
1710
+ code: 'UNKNOWN_ERROR',
1711
+ failure: 'http',
1712
+ id: 'relay',
1713
+ operation,
1714
+ status,
1715
+ })
1716
+ } finally {
1717
+ await server.closeAsync()
1718
+ }
1719
+ })
1720
+ },
1721
+ )
1722
+
1723
+ describe('getQuotes', () => {
1724
+ test('honors Relay Retry-After cooldowns after an upstream 429', async () => {
1725
+ const relay = await quoteServer(429, { errorCode: 'RATE_LIMITED' }, { 'retry-after': '2' })
1726
+ const rateLimitStore = Store.memory()
1727
+ let time = new Date('2026-09-24T12:00:00.000Z')
1728
+ const provider = Relay.relay({
1729
+ baseUrl: relay.url,
1730
+ now: () => time,
1731
+ rateLimitStore,
1732
+ userAddresses: TestRoutes.relayQuoteUsers,
1733
+ })
1734
+
1735
+ try {
1736
+ await expect(invoke(provider, 'getQuote')).rejects.toMatchObject({
1737
+ retryAfterMs: 2_000,
1738
+ status: 429,
1739
+ })
1740
+ time = new Date(time.getTime() + 1_001)
1741
+ await expect(invoke(provider, 'getQuote')).rejects.toBeInstanceOf(
1742
+ RoutesProvider.ProviderRateLimitError,
1743
+ )
1744
+ expect(relay.requests).toHaveLength(1)
1745
+
1746
+ time = new Date(time.getTime() + 1_000)
1747
+ await expect(invoke(provider, 'getQuote')).rejects.toMatchObject({ status: 429 })
1748
+ expect(relay.requests).toHaveLength(2)
1749
+ } finally {
1750
+ await relay.closeAsync()
1751
+ }
1752
+ })
1753
+
1754
+ test('skips Relay when its read quota is exhausted and returns an alternative quote', async () => {
1755
+ const now = new Date('2026-09-24T12:00:00.000Z')
1756
+ const rateLimitStore = Store.memory()
1757
+ await rateLimitStore.put(
1758
+ 'routes:relay:quote-v2',
1759
+ JSON.stringify({
1760
+ bucket: Math.floor(now.getTime() / 1_000),
1761
+ count: 8,
1762
+ tenants: [],
1763
+ }),
1764
+ )
1765
+ const relay = await quoteServer(500, { errorCode: 'SHOULD_NOT_BE_CALLED' })
1766
+ const across = await TestRelay.createServer((_request, response) => {
1767
+ response.writeHead(200, { 'content-type': 'application/json' })
1768
+ response.end(
1769
+ JSON.stringify({
1770
+ amountType: 'exactInput',
1771
+ expectedFillTime: 5,
1772
+ expectedOutputAmount: '180000',
1773
+ inputAmount: '200000',
1774
+ inputToken: { address: sourceToken, chainId: 8453, decimals: 6 },
1775
+ minOutputAmount: '175000',
1776
+ outputToken: { address: destinationToken, chainId: 4217, decimals: 6 },
1777
+ quoteExpiryTimestamp: Math.floor(Date.now() / 1_000) + 60,
1778
+ }),
1779
+ )
1780
+ })
1781
+ const entries: Log.Entry[] = []
1782
+ try {
1783
+ const response = await apiRequest(
1784
+ create(
1785
+ relay.url,
1786
+ entries,
1787
+ [
1788
+ Across.across({
1789
+ apiKey: 'local-across',
1790
+ baseUrl: across.url,
1791
+ integratorId: '0xdead',
1792
+ userAddress: sender,
1793
+ }),
1794
+ ],
1795
+ { now: () => now, rateLimitStore },
1796
+ ),
1797
+ 'getQuote',
1798
+ )
1799
+ expect(response.status).toBe(200)
1800
+ expect((await response.json()).data).toMatchObject([{ provider: { id: 'across' } }])
1801
+ expect(relay.requests).toHaveLength(0)
1802
+ expect(entries.at(-1)?.routesProviderAttempts).toContainEqual({
1803
+ durationMs: expect.any(Number),
1804
+ failure: 'rate_limit',
1805
+ id: 'relay',
1806
+ operation: 'getQuote',
1807
+ outcome: 'failed',
1808
+ rateLimitSource: 'local',
1809
+ })
1810
+ } finally {
1811
+ await Promise.all([relay.closeAsync(), across.closeAsync()])
1812
+ }
1813
+ })
1814
+
1815
+ test.each([rejection, { errorCode: 'UNKNOWN_ERROR' }])(
1816
+ 'returns a valid alternative quote when Relay rejects with $errorCode',
1817
+ async (body) => {
1818
+ const relay = await quoteServer(400, body)
1819
+ const across = await TestRelay.createServer((_request, response) => {
1820
+ response.writeHead(200, { 'content-type': 'application/json' })
1821
+ response.end(
1822
+ JSON.stringify({
1823
+ amountType: 'exactInput',
1824
+ expectedFillTime: 5,
1825
+ expectedOutputAmount: '180000',
1826
+ inputAmount: '200000',
1827
+ inputToken: { address: sourceToken, chainId: 8453, decimals: 6 },
1828
+ minOutputAmount: '175000',
1829
+ outputToken: { address: destinationToken, chainId: 4217, decimals: 6 },
1830
+ quoteExpiryTimestamp: Math.floor(Date.now() / 1000) + 60,
1831
+ }),
1832
+ )
1833
+ })
1834
+ try {
1835
+ const app = create(
1836
+ relay.url,
1837
+ [],
1838
+ [
1839
+ Across.across({
1840
+ apiKey: 'local-across',
1841
+ baseUrl: across.url,
1842
+ integratorId: '0xdead',
1843
+ userAddress: sender,
1844
+ }),
1845
+ ],
1846
+ )
1847
+ const response = await apiRequest(app, 'getQuote')
1848
+ expect(response.status).toBe(200)
1849
+ expect((await response.json()).data).toMatchObject([
1850
+ {
1851
+ destinationAmount: { baseUnits: '180000' },
1852
+ destinationAmountMin: { baseUnits: '175000' },
1853
+ provider: { id: 'across' },
1854
+ },
1855
+ ])
1856
+ } finally {
1857
+ await Promise.all([relay.closeAsync(), across.closeAsync()])
1858
+ }
1859
+ },
1860
+ )
1861
+ })
1862
+
1863
+ function create(
1864
+ url: string,
1865
+ entries: Log.Entry[],
1866
+ alternatives: readonly RoutesProvider.Provider[] = [],
1867
+ relayOptions: Pick<Relay.relay.Options, 'now' | 'rateLimitStore'> = {},
1868
+ ) {
1869
+ return TestApp.create({
1870
+ auth: { keys: [key] },
1871
+ db,
1872
+ defaultChainId: 4217,
1873
+ logger: (entry) => void entries.push(entry),
1874
+ providers: [
1875
+ Relay.relay({
1876
+ baseUrl: url,
1877
+ userAddresses: TestRoutes.relayQuoteUsers,
1878
+ ...relayOptions,
1879
+ }),
1880
+ ...alternatives,
1881
+ ],
1882
+ })
1883
+ }
1884
+
1885
+ function apiRequest(
1886
+ app: ReturnType<typeof create>,
1887
+ operation: 'getQuote' | 'prepareTransfer' | 'createDepositAddress',
1888
+ ) {
1889
+ const headers = { 'tempo-api-key': key.token }
1890
+ if (operation === 'getQuote')
1891
+ return app.request(`/v1/routes/quotes?${new URLSearchParams(request)}`, { headers })
1892
+ return app.request(
1893
+ `/v1/routes/${operation === 'prepareTransfer' ? 'transfers' : 'deposit-addresses'}`,
1894
+ {
1895
+ body: JSON.stringify({
1896
+ amount: '200000',
1897
+ // Relay's published transfer route targets pathUSD, not USDC.e.
1898
+ destinationToken: operation === 'prepareTransfer' ? pathUsd : destinationToken,
1899
+ recipient,
1900
+ sourceChain: 'base',
1901
+ sourceToken,
1902
+ subsidize: false,
1903
+ ...(operation === 'prepareTransfer'
1904
+ ? { mode: 'exactSource', sender }
1905
+ : { refundAddress: sender }),
1906
+ }),
1907
+ headers: {
1908
+ ...headers,
1909
+ 'content-type': 'application/json',
1910
+ 'idempotency-key': crypto.randomUUID(),
1911
+ },
1912
+ method: 'POST',
1913
+ },
1914
+ )
1915
+ }
1916
+
1917
+ function invoke(
1918
+ provider: RoutesProvider.Provider,
1919
+ operation: 'getQuote' | 'prepareTransfer' | 'createDepositAddress',
1920
+ ) {
1921
+ const candidate = RoutesProvider.getQuoteCandidates({
1922
+ catalog: TestRoutes.snapshot,
1923
+ providers: [provider],
1924
+ ...request,
1925
+ destinationToken: operation === 'prepareTransfer' ? pathUsd : destinationToken,
1926
+ })[0]!
1927
+ const signal = new AbortController().signal
1928
+ if (operation === 'getQuote')
1929
+ return provider.getQuote(
1930
+ {
1931
+ ...candidate,
1932
+ cache: { bypass: true },
1933
+ candidate,
1934
+ quotaKey: 'local',
1935
+ request,
1936
+ },
1937
+ signal,
1938
+ )
1939
+ if (operation === 'prepareTransfer')
1940
+ return provider.prepareTransfer!(
1941
+ { candidate, method: 'transaction', mode: 'exactSource', recipient, sender },
1942
+ signal,
1943
+ )
1944
+ return provider.createDepositAddress!(
1945
+ {
1946
+ amount: '200000',
1947
+ candidate,
1948
+ recipient,
1949
+ refundAddress: sender,
1950
+ subsidize: false,
1951
+ },
1952
+ signal,
1953
+ )
1954
+ }
1955
+ })
1956
+
1957
+ async function quoteServer(status: number, body: unknown, headers: Record<string, string> = {}) {
1958
+ const requests: unknown[] = []
1959
+ const server = await TestRelay.createServer(async (request, response) => {
1960
+ if (request.method !== 'POST' || request.url !== '/quote/v2') {
1961
+ response.writeHead(404).end()
1962
+ return
1963
+ }
1964
+ const chunks: Buffer[] = []
1965
+ for await (const chunk of request) chunks.push(Buffer.from(chunk))
1966
+ requests.push(JSON.parse(Buffer.concat(chunks).toString()))
1967
+ response.writeHead(status, { 'content-type': 'application/json', ...headers })
1968
+ response.end(JSON.stringify(body))
1969
+ })
1970
+ return Object.assign(server, { requests })
1971
+ }