tapimo 0.7.1 → 0.7.2

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 (681) hide show
  1. package/dist/ApiKeys.d.ts +24 -7
  2. package/dist/ApiKeys.d.ts.map +1 -1
  3. package/dist/ApiKeys.js +17 -5
  4. package/dist/ApiKeys.js.map +1 -1
  5. package/dist/App.d.ts +12104 -7861
  6. package/dist/App.d.ts.map +1 -1
  7. package/dist/App.js +191 -128
  8. package/dist/App.js.map +1 -1
  9. package/dist/Assets.d.ts +10 -0
  10. package/dist/Assets.d.ts.map +1 -1
  11. package/dist/Assets.js +17 -4
  12. package/dist/Assets.js.map +1 -1
  13. package/dist/Scope.d.ts +19 -8
  14. package/dist/Scope.d.ts.map +1 -1
  15. package/dist/Scope.js +25 -9
  16. package/dist/Scope.js.map +1 -1
  17. package/dist/Webhooks.d.ts +1 -1
  18. package/dist/admin/App.d.ts +601 -20
  19. package/dist/admin/App.d.ts.map +1 -1
  20. package/dist/admin/App.js +12 -2
  21. package/dist/admin/App.js.map +1 -1
  22. package/dist/admin/apps/api-keys.d.ts +94 -11
  23. package/dist/admin/apps/api-keys.d.ts.map +1 -1
  24. package/dist/admin/apps/api-keys.js +141 -32
  25. package/dist/admin/apps/api-keys.js.map +1 -1
  26. package/dist/admin/apps/earn-vaults.d.ts +1069 -0
  27. package/dist/admin/apps/earn-vaults.d.ts.map +1 -0
  28. package/dist/admin/apps/earn-vaults.js +409 -0
  29. package/dist/admin/apps/earn-vaults.js.map +1 -0
  30. package/dist/admin/apps/verified-tokens.d.ts +166 -166
  31. package/dist/admin/ui.generated.d.ts +1 -1
  32. package/dist/admin/ui.generated.d.ts.map +1 -1
  33. package/dist/admin/ui.generated.js +99 -43
  34. package/dist/admin/ui.generated.js.map +1 -1
  35. package/dist/analytics/Analytics.d.ts +2 -0
  36. package/dist/analytics/Analytics.d.ts.map +1 -1
  37. package/dist/analytics/Analytics.js +18 -2
  38. package/dist/analytics/Analytics.js.map +1 -1
  39. package/dist/analytics/tables/requestEvents.d.ts +22 -1
  40. package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
  41. package/dist/analytics/tables/requestEvents.js +59 -39
  42. package/dist/analytics/tables/requestEvents.js.map +1 -1
  43. package/dist/apps/Zones.d.ts +8335 -0
  44. package/dist/apps/Zones.d.ts.map +1 -0
  45. package/dist/apps/Zones.js +38 -0
  46. package/dist/apps/Zones.js.map +1 -0
  47. package/dist/apps/data/App.d.ts +12125 -7913
  48. package/dist/apps/data/App.d.ts.map +1 -1
  49. package/dist/apps/data/App.js +91 -19
  50. package/dist/apps/data/App.js.map +1 -1
  51. package/dist/apps/data/FxOracle.d.ts +1 -1
  52. package/dist/apps/data/FxOracle.d.ts.map +1 -1
  53. package/dist/apps/data/index.d.ts +0 -1
  54. package/dist/apps/data/index.d.ts.map +1 -1
  55. package/dist/apps/data/index.js +0 -1
  56. package/dist/apps/data/index.js.map +1 -1
  57. package/dist/apps/data/routes/activities.d.ts +32 -32
  58. package/dist/apps/data/routes/activities.d.ts.map +1 -1
  59. package/dist/apps/data/routes/activities.js +130 -65
  60. package/dist/apps/data/routes/activities.js.map +1 -1
  61. package/dist/apps/data/routes/addresses.d.ts +312 -312
  62. package/dist/apps/data/routes/balances.d.ts +18 -18
  63. package/dist/apps/data/routes/balances.js +5 -5
  64. package/dist/apps/data/routes/balances.js.map +1 -1
  65. package/dist/apps/data/routes/coingecko.d.ts +176 -176
  66. package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
  67. package/dist/apps/data/routes/coingecko.js +62 -35
  68. package/dist/apps/data/routes/coingecko.js.map +1 -1
  69. package/dist/apps/data/routes/earn.d.ts +2144 -0
  70. package/dist/apps/data/routes/earn.d.ts.map +1 -0
  71. package/dist/apps/data/routes/earn.js +947 -0
  72. package/dist/apps/data/routes/earn.js.map +1 -0
  73. package/dist/apps/data/routes/exchanges.d.ts +1625 -718
  74. package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
  75. package/dist/apps/data/routes/exchanges.js +656 -193
  76. package/dist/apps/data/routes/exchanges.js.map +1 -1
  77. package/dist/apps/data/routes/fee-amm.d.ts +108 -108
  78. package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
  79. package/dist/apps/data/routes/fee-amm.js +59 -8
  80. package/dist/apps/data/routes/fee-amm.js.map +1 -1
  81. package/dist/apps/data/routes/funding.d.ts +4092 -387
  82. package/dist/apps/data/routes/funding.d.ts.map +1 -1
  83. package/dist/apps/data/routes/funding.js +1403 -256
  84. package/dist/apps/data/routes/funding.js.map +1 -1
  85. package/dist/apps/data/routes/indexer.d.ts +30 -30
  86. package/dist/apps/data/routes/indexer.d.ts.map +1 -1
  87. package/dist/apps/data/routes/indexer.js +19 -2
  88. package/dist/apps/data/routes/indexer.js.map +1 -1
  89. package/dist/apps/data/routes/receipts.d.ts +263 -263
  90. package/dist/apps/data/routes/receipts.d.ts.map +1 -1
  91. package/dist/apps/data/routes/receipts.js +11 -11
  92. package/dist/apps/data/routes/receipts.js.map +1 -1
  93. package/dist/apps/data/routes/rpc.d.ts +5 -5
  94. package/dist/apps/data/routes/rpc.d.ts.map +1 -1
  95. package/dist/apps/data/routes/rpc.js +211 -22
  96. package/dist/apps/data/routes/rpc.js.map +1 -1
  97. package/dist/apps/data/routes/tokenlist.d.ts +36 -36
  98. package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
  99. package/dist/apps/data/routes/tokenlist.js +39 -8
  100. package/dist/apps/data/routes/tokenlist.js.map +1 -1
  101. package/dist/apps/data/routes/tokens.d.ts +114 -86
  102. package/dist/apps/data/routes/tokens.d.ts.map +1 -1
  103. package/dist/apps/data/routes/tokens.js +194 -91
  104. package/dist/apps/data/routes/tokens.js.map +1 -1
  105. package/dist/apps/data/routes/transactions.d.ts +53 -53
  106. package/dist/apps/data/routes/transactions.d.ts.map +1 -1
  107. package/dist/apps/data/routes/transactions.js +78 -39
  108. package/dist/apps/data/routes/transactions.js.map +1 -1
  109. package/dist/apps/data/routes/transfers.d.ts +76 -27
  110. package/dist/apps/data/routes/transfers.d.ts.map +1 -1
  111. package/dist/apps/data/routes/transfers.js +165 -67
  112. package/dist/apps/data/routes/transfers.js.map +1 -1
  113. package/dist/apps/data/routes/valuation.d.ts +42 -42
  114. package/dist/apps/data/routes/valuation.js +2 -2
  115. package/dist/apps/data/routes/valuation.js.map +1 -1
  116. package/dist/apps/data/routes/webhooks.d.ts +369 -367
  117. package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
  118. package/dist/apps/data/routes/webhooks.js +161 -59
  119. package/dist/apps/data/routes/webhooks.js.map +1 -1
  120. package/dist/apps/data/routes/zones.d.ts +281 -0
  121. package/dist/apps/data/routes/zones.d.ts.map +1 -0
  122. package/dist/apps/data/routes/zones.js +252 -0
  123. package/dist/apps/data/routes/zones.js.map +1 -0
  124. package/dist/apps/docs/reference.js +6 -5
  125. package/dist/apps/docs/reference.js.map +1 -1
  126. package/dist/apps/index.d.ts +2 -1
  127. package/dist/apps/index.d.ts.map +1 -1
  128. package/dist/apps/index.js +2 -1
  129. package/dist/apps/index.js.map +1 -1
  130. package/dist/apps/management/App.d.ts +670 -670
  131. package/dist/apps/management/Billing.d.ts +8 -0
  132. package/dist/apps/management/Billing.d.ts.map +1 -1
  133. package/dist/apps/management/Billing.js +12 -0
  134. package/dist/apps/management/Billing.js.map +1 -1
  135. package/dist/apps/management/Error.d.ts +12 -0
  136. package/dist/apps/management/Error.d.ts.map +1 -0
  137. package/dist/apps/management/Error.js +10 -0
  138. package/dist/apps/management/Error.js.map +1 -0
  139. package/dist/apps/management/routes/api-keys.d.ts +5 -5
  140. package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
  141. package/dist/apps/management/routes/api-keys.js +2 -8
  142. package/dist/apps/management/routes/api-keys.js.map +1 -1
  143. package/dist/apps/management/routes/billing.d.ts +119 -119
  144. package/dist/apps/management/routes/faucet.d.ts +2 -2
  145. package/dist/apps/management/routes/invitations.d.ts +62 -62
  146. package/dist/apps/management/routes/invitations.d.ts.map +1 -1
  147. package/dist/apps/management/routes/invitations.js +4 -10
  148. package/dist/apps/management/routes/invitations.js.map +1 -1
  149. package/dist/apps/management/routes/invite-links.d.ts +30 -30
  150. package/dist/apps/management/routes/me.d.ts +6 -6
  151. package/dist/apps/management/routes/members.d.ts +2 -2
  152. package/dist/apps/management/routes/orgs.d.ts +48 -48
  153. package/dist/apps/management/routes/orgs.d.ts.map +1 -1
  154. package/dist/apps/management/routes/orgs.js +2 -8
  155. package/dist/apps/management/routes/orgs.js.map +1 -1
  156. package/dist/apps/management/routes/projects.d.ts +9 -9
  157. package/dist/apps/management/routes/scopes.js +2 -2
  158. package/dist/apps/management/routes/scopes.js.map +1 -1
  159. package/dist/apps/management/routes/verified-token-requests.d.ts +36 -36
  160. package/dist/apps/management/routes/webhooks.d.ts +50 -50
  161. package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
  162. package/dist/apps/management/routes/webhooks.js +15 -3
  163. package/dist/apps/management/routes/webhooks.js.map +1 -1
  164. package/dist/apps/mpp/App.d.ts +55 -56
  165. package/dist/apps/mpp/App.d.ts.map +1 -1
  166. package/dist/apps/mpp/App.js +192 -27
  167. package/dist/apps/mpp/App.js.map +1 -1
  168. package/dist/apps/mpp/Mpp.d.ts +0 -20
  169. package/dist/apps/mpp/Mpp.d.ts.map +1 -1
  170. package/dist/apps/mpp/Mpp.js +0 -24
  171. package/dist/apps/mpp/Mpp.js.map +1 -1
  172. package/dist/apps/mpp/internal/Adapter.d.ts +40 -0
  173. package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -0
  174. package/dist/apps/mpp/internal/Adapter.js +66 -0
  175. package/dist/apps/mpp/internal/Adapter.js.map +1 -0
  176. package/dist/apps/mpp/internal/Error.d.ts +4 -0
  177. package/dist/apps/mpp/internal/Error.d.ts.map +1 -0
  178. package/dist/apps/mpp/internal/Error.js +41 -0
  179. package/dist/apps/mpp/internal/Error.js.map +1 -0
  180. package/dist/apps/mpp/internal/Idempotency.d.ts +33 -0
  181. package/dist/apps/mpp/internal/Idempotency.d.ts.map +1 -0
  182. package/dist/apps/mpp/internal/Idempotency.js +28 -0
  183. package/dist/apps/mpp/internal/Idempotency.js.map +1 -0
  184. package/dist/apps/mpp/internal/Policy.d.ts +46 -0
  185. package/dist/apps/mpp/internal/Policy.d.ts.map +1 -0
  186. package/dist/apps/mpp/internal/Policy.js +57 -0
  187. package/dist/apps/mpp/internal/Policy.js.map +1 -0
  188. package/dist/apps/mpp/internal/ScreenManager.d.ts +27 -0
  189. package/dist/apps/mpp/internal/ScreenManager.d.ts.map +1 -0
  190. package/dist/apps/mpp/internal/ScreenManager.js +18 -0
  191. package/dist/apps/mpp/internal/ScreenManager.js.map +1 -0
  192. package/dist/apps/mpp/internal/Screening.d.ts +35 -0
  193. package/dist/apps/mpp/internal/Screening.d.ts.map +1 -0
  194. package/dist/apps/mpp/internal/Screening.js +20 -0
  195. package/dist/apps/mpp/internal/Screening.js.map +1 -0
  196. package/dist/apps/mpp/internal/Sponsorship.d.ts +36 -0
  197. package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -0
  198. package/dist/apps/mpp/internal/Sponsorship.js +103 -0
  199. package/dist/apps/mpp/internal/Sponsorship.js.map +1 -0
  200. package/dist/apps/mpp/internal/Utils.d.ts +7 -0
  201. package/dist/apps/mpp/internal/Utils.d.ts.map +1 -0
  202. package/dist/apps/mpp/internal/Utils.js +24 -0
  203. package/dist/apps/mpp/internal/Utils.js.map +1 -0
  204. package/dist/apps/relay/App.js +183 -23
  205. package/dist/apps/relay/App.js.map +1 -1
  206. package/dist/apps/relay/Sponsorships.d.ts +4 -0
  207. package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
  208. package/dist/apps/relay/Sponsorships.js +15 -6
  209. package/dist/apps/relay/Sponsorships.js.map +1 -1
  210. package/dist/db/Db.d.ts +20 -0
  211. package/dist/db/Db.d.ts.map +1 -1
  212. package/dist/db/Db.js +342 -0
  213. package/dist/db/Db.js.map +1 -1
  214. package/dist/db/Schema.d.ts +921 -1
  215. package/dist/db/Schema.d.ts.map +1 -1
  216. package/dist/db/Schema.js +269 -1
  217. package/dist/db/Schema.js.map +1 -1
  218. package/dist/db/tables/earnVaults.d.ts +68 -0
  219. package/dist/db/tables/earnVaults.d.ts.map +1 -0
  220. package/dist/db/tables/earnVaults.js +72 -0
  221. package/dist/db/tables/earnVaults.js.map +1 -0
  222. package/dist/db/tables/fundingCatalog.d.ts +56 -0
  223. package/dist/db/tables/fundingCatalog.d.ts.map +1 -0
  224. package/dist/db/tables/fundingCatalog.js +85 -0
  225. package/dist/db/tables/fundingCatalog.js.map +1 -0
  226. package/dist/db/tables/fundingDepositAddresses.d.ts +159 -0
  227. package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -0
  228. package/dist/db/tables/fundingDepositAddresses.js +206 -0
  229. package/dist/db/tables/fundingDepositAddresses.js.map +1 -0
  230. package/dist/db/tables/fundingDeposits.d.ts +115 -0
  231. package/dist/db/tables/fundingDeposits.d.ts.map +1 -0
  232. package/dist/db/tables/fundingDeposits.js +100 -0
  233. package/dist/db/tables/fundingDeposits.js.map +1 -0
  234. package/dist/db/tables/fundingIdempotency.d.ts +91 -0
  235. package/dist/db/tables/fundingIdempotency.d.ts.map +1 -0
  236. package/dist/db/tables/fundingIdempotency.js +103 -0
  237. package/dist/db/tables/fundingIdempotency.js.map +1 -0
  238. package/dist/db/tables/fundingTransferEvents.d.ts +12 -0
  239. package/dist/db/tables/fundingTransferEvents.d.ts.map +1 -0
  240. package/dist/db/tables/fundingTransferEvents.js +18 -0
  241. package/dist/db/tables/fundingTransferEvents.js.map +1 -0
  242. package/dist/db/tables/fundingTransferTransactions.d.ts +15 -0
  243. package/dist/db/tables/fundingTransferTransactions.d.ts.map +1 -0
  244. package/dist/db/tables/fundingTransferTransactions.js +27 -0
  245. package/dist/db/tables/fundingTransferTransactions.js.map +1 -0
  246. package/dist/db/tables/fundingTransfers.d.ts +82 -0
  247. package/dist/db/tables/fundingTransfers.d.ts.map +1 -0
  248. package/dist/db/tables/fundingTransfers.js +89 -0
  249. package/dist/db/tables/fundingTransfers.js.map +1 -0
  250. package/dist/db/tables/organizations.d.ts +8 -0
  251. package/dist/db/tables/organizations.d.ts.map +1 -1
  252. package/dist/db/tables/organizations.js +16 -0
  253. package/dist/db/tables/organizations.js.map +1 -1
  254. package/dist/db/tables/projects.d.ts +8 -0
  255. package/dist/db/tables/projects.d.ts.map +1 -1
  256. package/dist/db/tables/projects.js +16 -0
  257. package/dist/db/tables/projects.js.map +1 -1
  258. package/dist/db/tables/requestUsage.d.ts +13 -0
  259. package/dist/db/tables/requestUsage.d.ts.map +1 -1
  260. package/dist/db/tables/requestUsage.js +16 -0
  261. package/dist/db/tables/requestUsage.js.map +1 -1
  262. package/dist/db/tables/sponsoredTransactions.d.ts +2 -2
  263. package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
  264. package/dist/db/tables/sponsoredTransactions.js +1 -1
  265. package/dist/db/tables/sponsoredTransactions.js.map +1 -1
  266. package/dist/db/tables/users.d.ts +8 -0
  267. package/dist/db/tables/users.d.ts.map +1 -1
  268. package/dist/db/tables/users.js +16 -0
  269. package/dist/db/tables/users.js.map +1 -1
  270. package/dist/db/tables/verifiedTokens.d.ts +14 -7
  271. package/dist/db/tables/verifiedTokens.d.ts.map +1 -1
  272. package/dist/db/tables/verifiedTokens.js +9 -7
  273. package/dist/db/tables/verifiedTokens.js.map +1 -1
  274. package/dist/db/tables/webhookSubscriptions.d.ts +31 -1
  275. package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
  276. package/dist/db/tables/webhookSubscriptions.js +24 -3
  277. package/dist/db/tables/webhookSubscriptions.js.map +1 -1
  278. package/dist/handlers/relay.js +108 -108
  279. package/dist/handlers/relay.js.map +1 -1
  280. package/dist/internal/Auth.d.ts +26 -0
  281. package/dist/internal/Auth.d.ts.map +1 -1
  282. package/dist/internal/Auth.js +35 -2
  283. package/dist/internal/Auth.js.map +1 -1
  284. package/dist/internal/Cache.d.ts.map +1 -1
  285. package/dist/internal/Cache.js +16 -10
  286. package/dist/internal/Cache.js.map +1 -1
  287. package/dist/internal/Cursor.js +1 -1
  288. package/dist/internal/Cursor.js.map +1 -1
  289. package/dist/internal/EarnRates.d.ts +89 -0
  290. package/dist/internal/EarnRates.d.ts.map +1 -0
  291. package/dist/internal/EarnRates.js +266 -0
  292. package/dist/internal/EarnRates.js.map +1 -0
  293. package/dist/internal/EarnVaults.d.ts +171 -0
  294. package/dist/internal/EarnVaults.d.ts.map +1 -0
  295. package/dist/internal/EarnVaults.js +547 -0
  296. package/dist/internal/EarnVaults.js.map +1 -0
  297. package/dist/internal/EdgeCache.d.ts +8 -1
  298. package/dist/internal/EdgeCache.d.ts.map +1 -1
  299. package/dist/internal/EdgeCache.js +33 -7
  300. package/dist/internal/EdgeCache.js.map +1 -1
  301. package/dist/internal/Id.d.ts +11 -0
  302. package/dist/internal/Id.d.ts.map +1 -1
  303. package/dist/internal/Id.js +13 -0
  304. package/dist/internal/Id.js.map +1 -1
  305. package/dist/internal/Idempotency.d.ts +83 -0
  306. package/dist/internal/Idempotency.d.ts.map +1 -0
  307. package/dist/internal/Idempotency.js +113 -0
  308. package/dist/internal/Idempotency.js.map +1 -0
  309. package/dist/internal/Log.d.ts +64 -9
  310. package/dist/internal/Log.d.ts.map +1 -1
  311. package/dist/internal/Log.js +29 -7
  312. package/dist/internal/Log.js.map +1 -1
  313. package/dist/internal/MetricSink.d.ts.map +1 -1
  314. package/dist/internal/MetricSink.js +47 -1
  315. package/dist/internal/MetricSink.js.map +1 -1
  316. package/dist/internal/OpenApi.d.ts +1 -1
  317. package/dist/internal/OpenApi.d.ts.map +1 -1
  318. package/dist/internal/OpenApi.js +3 -0
  319. package/dist/internal/OpenApi.js.map +1 -1
  320. package/dist/internal/Provider.d.ts +14 -0
  321. package/dist/internal/Provider.d.ts.map +1 -0
  322. package/dist/internal/Provider.js +5 -0
  323. package/dist/internal/Provider.js.map +1 -0
  324. package/dist/internal/Schema.d.ts +6 -1
  325. package/dist/internal/Schema.d.ts.map +1 -1
  326. package/dist/internal/Schema.js +20 -11
  327. package/dist/internal/Schema.js.map +1 -1
  328. package/dist/internal/Store.d.ts +6 -0
  329. package/dist/internal/Store.d.ts.map +1 -1
  330. package/dist/internal/Store.js +35 -0
  331. package/dist/internal/Store.js.map +1 -1
  332. package/dist/internal/Tidx.d.ts +43 -24
  333. package/dist/internal/Tidx.d.ts.map +1 -1
  334. package/dist/internal/Tidx.js +79 -11
  335. package/dist/internal/Tidx.js.map +1 -1
  336. package/dist/internal/Viem.d.ts +82 -65
  337. package/dist/internal/Viem.d.ts.map +1 -1
  338. package/dist/internal/Viem.js +83 -12
  339. package/dist/internal/Viem.js.map +1 -1
  340. package/dist/internal/WebhookDestination.d.ts.map +1 -1
  341. package/dist/internal/WebhookDestination.js +34 -28
  342. package/dist/internal/WebhookDestination.js.map +1 -1
  343. package/dist/internal/Webhooks.d.ts +9 -0
  344. package/dist/internal/Webhooks.d.ts.map +1 -1
  345. package/dist/internal/Webhooks.js +15 -10
  346. package/dist/internal/Webhooks.js.map +1 -1
  347. package/dist/internal/exchange/Provider.d.ts +219 -0
  348. package/dist/internal/exchange/Provider.d.ts.map +1 -0
  349. package/dist/internal/exchange/Provider.js +117 -0
  350. package/dist/internal/exchange/Provider.js.map +1 -0
  351. package/dist/internal/exchange/index.d.ts +2 -0
  352. package/dist/internal/exchange/index.d.ts.map +1 -0
  353. package/dist/internal/exchange/index.js +2 -0
  354. package/dist/internal/exchange/index.js.map +1 -0
  355. package/dist/internal/exchange/providers/uniswap.d.ts +57 -0
  356. package/dist/internal/exchange/providers/uniswap.d.ts.map +1 -0
  357. package/dist/internal/exchange/providers/uniswap.js +553 -0
  358. package/dist/internal/exchange/providers/uniswap.js.map +1 -0
  359. package/dist/internal/funding/Action.d.ts +55 -0
  360. package/dist/internal/funding/Action.d.ts.map +1 -0
  361. package/dist/internal/funding/Action.js +74 -0
  362. package/dist/internal/funding/Action.js.map +1 -0
  363. package/dist/internal/funding/Catalog.d.ts +107 -0
  364. package/dist/internal/funding/Catalog.d.ts.map +1 -0
  365. package/dist/internal/funding/Catalog.js +270 -0
  366. package/dist/internal/funding/Catalog.js.map +1 -0
  367. package/dist/internal/funding/Chain.d.ts +76 -0
  368. package/dist/internal/funding/Chain.d.ts.map +1 -0
  369. package/dist/internal/funding/Chain.js +38 -0
  370. package/dist/internal/funding/Chain.js.map +1 -0
  371. package/dist/internal/funding/Deposit.d.ts +366 -0
  372. package/dist/internal/funding/Deposit.d.ts.map +1 -0
  373. package/dist/internal/funding/Deposit.js +286 -0
  374. package/dist/internal/funding/Deposit.js.map +1 -0
  375. package/dist/internal/funding/DepositAddress.d.ts +345 -0
  376. package/dist/internal/funding/DepositAddress.d.ts.map +1 -0
  377. package/dist/internal/funding/DepositAddress.js +189 -0
  378. package/dist/internal/funding/DepositAddress.js.map +1 -0
  379. package/dist/internal/funding/Evidence.d.ts +52 -0
  380. package/dist/internal/funding/Evidence.d.ts.map +1 -0
  381. package/dist/internal/funding/Evidence.js +314 -0
  382. package/dist/internal/funding/Evidence.js.map +1 -0
  383. package/dist/internal/funding/Provider.d.ts +1186 -0
  384. package/dist/internal/funding/Provider.d.ts.map +1 -0
  385. package/dist/internal/funding/Provider.js +1081 -0
  386. package/dist/internal/funding/Provider.js.map +1 -0
  387. package/dist/internal/funding/Reconciliation.d.ts +113 -0
  388. package/dist/internal/funding/Reconciliation.d.ts.map +1 -0
  389. package/dist/internal/funding/Reconciliation.js +676 -0
  390. package/dist/internal/funding/Reconciliation.js.map +1 -0
  391. package/dist/internal/funding/Route.d.ts +21 -0
  392. package/dist/internal/funding/Route.d.ts.map +1 -0
  393. package/dist/internal/funding/Route.js +5 -0
  394. package/dist/internal/funding/Route.js.map +1 -0
  395. package/dist/internal/funding/Subsidy.d.ts +113 -0
  396. package/dist/internal/funding/Subsidy.d.ts.map +1 -0
  397. package/dist/internal/funding/Subsidy.js +138 -0
  398. package/dist/internal/funding/Subsidy.js.map +1 -0
  399. package/dist/internal/funding/Token.d.ts +41 -0
  400. package/dist/internal/funding/Token.d.ts.map +1 -0
  401. package/dist/internal/funding/Token.js +22 -0
  402. package/dist/internal/funding/Token.js.map +1 -0
  403. package/dist/internal/funding/Transfer.d.ts +643 -0
  404. package/dist/internal/funding/Transfer.d.ts.map +1 -0
  405. package/dist/internal/funding/Transfer.js +332 -0
  406. package/dist/internal/funding/Transfer.js.map +1 -0
  407. package/dist/internal/funding/index.d.ts +13 -0
  408. package/dist/internal/funding/index.d.ts.map +1 -0
  409. package/dist/internal/funding/index.js +13 -0
  410. package/dist/internal/funding/index.js.map +1 -0
  411. package/dist/internal/funding/providers/across.d.ts +21 -0
  412. package/dist/internal/funding/providers/across.d.ts.map +1 -0
  413. package/dist/internal/funding/providers/across.js +117 -0
  414. package/dist/internal/funding/providers/across.js.map +1 -0
  415. package/dist/internal/funding/providers/relay.d.ts +46 -0
  416. package/dist/internal/funding/providers/relay.d.ts.map +1 -0
  417. package/dist/internal/funding/providers/relay.js +464 -0
  418. package/dist/internal/funding/providers/relay.js.map +1 -0
  419. package/dist/internal/funding/providers/rhino.d.ts +15 -0
  420. package/dist/internal/funding/providers/rhino.d.ts.map +1 -0
  421. package/dist/internal/funding/providers/rhino.js +116 -0
  422. package/dist/internal/funding/providers/rhino.js.map +1 -0
  423. package/dist/internal/funding/providers/squid.d.ts +19 -0
  424. package/dist/internal/funding/providers/squid.d.ts.map +1 -0
  425. package/dist/internal/funding/providers/squid.js +120 -0
  426. package/dist/internal/funding/providers/squid.js.map +1 -0
  427. package/dist/internal/funding/providers/symbiosis.d.ts +20 -0
  428. package/dist/internal/funding/providers/symbiosis.d.ts.map +1 -0
  429. package/dist/internal/funding/providers/symbiosis.js +176 -0
  430. package/dist/internal/funding/providers/symbiosis.js.map +1 -0
  431. package/dist/internal/index.d.ts +5 -1
  432. package/dist/internal/index.d.ts.map +1 -1
  433. package/dist/internal/index.js +5 -1
  434. package/dist/internal/index.js.map +1 -1
  435. package/dist/internal/webhookDestinations/url.js +61 -57
  436. package/dist/internal/webhookDestinations/url.js.map +1 -1
  437. package/dist/providers/index.d.ts +43 -0
  438. package/dist/providers/index.d.ts.map +1 -0
  439. package/dist/providers/index.js +19 -0
  440. package/dist/providers/index.js.map +1 -0
  441. package/package.json +9 -4
  442. package/src/ApiKeys.test.ts +11 -7
  443. package/src/ApiKeys.ts +37 -9
  444. package/src/App.test.ts +85 -10
  445. package/src/App.ts +224 -137
  446. package/src/Assets.ts +29 -4
  447. package/src/Client.test-d.ts +650 -30
  448. package/src/Scope.test.ts +19 -0
  449. package/src/Scope.ts +28 -11
  450. package/src/Webhooks.test.ts +25 -0
  451. package/src/Webhooks.ts +1 -1
  452. package/src/admin/App.test.ts +9 -2
  453. package/src/admin/App.ts +32 -9
  454. package/src/admin/apps/api-keys.test.ts +167 -23
  455. package/src/admin/apps/api-keys.ts +166 -28
  456. package/src/admin/apps/earn-vaults.test.ts +338 -0
  457. package/src/admin/apps/earn-vaults.ts +572 -0
  458. package/src/admin/apps/scopes.test.ts +16 -1
  459. package/src/admin/ui/plugin.ts +2 -2
  460. package/src/admin/ui/src/components/EarnVaultForm.tsx +137 -0
  461. package/src/admin/ui/src/components/MobileProfile.tsx +2 -2
  462. package/src/admin/ui/src/components/Page.tsx +1 -1
  463. package/src/admin/ui/src/components/ThemeToggle.tsx +1 -1
  464. package/src/admin/ui/src/lib/api-keys.ts +37 -7
  465. package/src/admin/ui/src/lib/client.ts +1 -1
  466. package/src/admin/ui/src/lib/config.ts +1 -1
  467. package/src/admin/ui/src/lib/early-access.ts +8 -9
  468. package/src/admin/ui/src/lib/earn-vaults.ts +207 -0
  469. package/src/admin/ui/src/lib/format.ts +13 -0
  470. package/src/admin/ui/src/lib/organizations.test.ts +14 -4
  471. package/src/admin/ui/src/lib/organizations.ts +7 -1
  472. package/src/admin/ui/src/lib/response.ts +22 -0
  473. package/src/admin/ui/src/lib/scopes.test.ts +19 -11
  474. package/src/admin/ui/src/lib/scopes.ts +28 -7
  475. package/src/admin/ui/src/lib/verified-tokens.ts +10 -9
  476. package/src/admin/ui/src/routeTree.gen.ts +70 -7
  477. package/src/admin/ui/src/router.tsx +2 -2
  478. package/src/admin/ui/src/routes/__root.tsx +9 -8
  479. package/src/admin/ui/src/routes/api-keys.tsx +475 -64
  480. package/src/admin/ui/src/routes/early-access.tsx +5 -12
  481. package/src/admin/ui/src/routes/earn.vaults.tsx +348 -0
  482. package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +154 -0
  483. package/src/admin/ui/src/routes/earn.vaults_.new.tsx +190 -0
  484. package/src/admin/ui/src/routes/organizations.tsx +4 -7
  485. package/src/admin/ui/src/routes/organizations_.$orgId.tsx +56 -54
  486. package/src/admin/ui/src/routes/verified-tokens.tsx +4 -4
  487. package/src/admin/ui/vite.config.ts +4 -1
  488. package/src/admin/ui.generated.ts +113 -43
  489. package/src/analytics/Analytics.test.ts +69 -10
  490. package/src/analytics/Analytics.ts +20 -1
  491. package/src/analytics/tables/requestEvents.ts +79 -37
  492. package/src/apps/Zones.test.ts +33 -0
  493. package/src/apps/Zones.ts +40 -0
  494. package/src/apps/composition.test.ts +84 -1
  495. package/src/apps/data/App.test.ts +28 -11
  496. package/src/apps/data/App.ts +96 -33
  497. package/src/apps/data/FxOracle.ts +1 -1
  498. package/src/apps/data/index.ts +0 -1
  499. package/src/apps/data/routes/activities.test.ts +82 -6
  500. package/src/apps/data/routes/activities.ts +131 -71
  501. package/src/apps/data/routes/balances.test.ts +50 -37
  502. package/src/apps/data/routes/balances.ts +5 -5
  503. package/src/apps/data/routes/blocks.test.ts +2 -0
  504. package/src/apps/data/routes/coingecko.test.ts +22 -0
  505. package/src/apps/data/routes/coingecko.ts +84 -48
  506. package/src/apps/data/routes/earn.test.ts +1108 -0
  507. package/src/apps/data/routes/earn.ts +1391 -0
  508. package/src/apps/data/routes/exchanges.test.ts +82 -33
  509. package/src/apps/data/routes/exchanges.ts +842 -227
  510. package/src/apps/data/routes/fee-amm.test.ts +4 -6
  511. package/src/apps/data/routes/fee-amm.ts +69 -12
  512. package/src/apps/data/routes/funding.test.ts +2712 -221
  513. package/src/apps/data/routes/funding.ts +1604 -387
  514. package/src/apps/data/routes/indexer.test.ts +43 -34
  515. package/src/apps/data/routes/indexer.ts +19 -2
  516. package/src/apps/data/routes/receipts.test.ts +5 -3
  517. package/src/apps/data/routes/receipts.ts +13 -11
  518. package/src/apps/data/routes/rpc.test.ts +446 -28
  519. package/src/apps/data/routes/rpc.ts +243 -25
  520. package/src/apps/data/routes/tokenlist.ts +72 -19
  521. package/src/apps/data/routes/tokens.ts +258 -86
  522. package/src/apps/data/routes/transactions.test.ts +2 -0
  523. package/src/apps/data/routes/transactions.ts +77 -42
  524. package/src/apps/data/routes/transfers.test.ts +166 -4
  525. package/src/apps/data/routes/transfers.ts +216 -78
  526. package/src/apps/data/routes/valuation.test.ts +62 -9
  527. package/src/apps/data/routes/valuation.ts +2 -2
  528. package/src/apps/data/routes/webhooks.test.ts +386 -43
  529. package/src/apps/data/routes/webhooks.ts +172 -71
  530. package/src/apps/data/routes/zones.test.ts +473 -0
  531. package/src/apps/data/routes/zones.ts +338 -0
  532. package/src/apps/docs/reference.ts +8 -6
  533. package/src/apps/index.ts +2 -1
  534. package/src/apps/management/Billing.test.ts +29 -0
  535. package/src/apps/management/Billing.ts +23 -0
  536. package/src/apps/management/Error.ts +12 -0
  537. package/src/apps/management/routes/api-keys.test.ts +5 -3
  538. package/src/apps/management/routes/api-keys.ts +2 -9
  539. package/src/apps/management/routes/invitations.ts +4 -11
  540. package/src/apps/management/routes/orgs.ts +2 -9
  541. package/src/apps/management/routes/scopes.test.ts +7 -2
  542. package/src/apps/management/routes/scopes.ts +2 -2
  543. package/src/apps/management/routes/webhooks.test.ts +6 -1
  544. package/src/apps/management/routes/webhooks.ts +15 -3
  545. package/src/apps/mpp/App.ts +276 -29
  546. package/src/apps/mpp/Mpp.test.ts +631 -26
  547. package/src/apps/mpp/Mpp.ts +0 -42
  548. package/src/apps/mpp/internal/Adapter.ts +108 -3
  549. package/src/apps/mpp/internal/Error.test.ts +33 -0
  550. package/src/apps/mpp/internal/Error.ts +44 -6
  551. package/src/apps/mpp/internal/Idempotency.test.ts +213 -0
  552. package/src/apps/mpp/internal/Idempotency.ts +59 -5
  553. package/src/apps/mpp/internal/Policy.test.ts +122 -0
  554. package/src/apps/mpp/internal/Policy.ts +98 -0
  555. package/src/apps/mpp/internal/ScreenManager.test.ts +68 -0
  556. package/src/apps/mpp/internal/ScreenManager.ts +41 -0
  557. package/src/apps/mpp/internal/Screening.ts +40 -3
  558. package/src/apps/mpp/internal/Sponsorship.ts +144 -0
  559. package/src/apps/mpp/internal/Utils.ts +30 -0
  560. package/src/apps/relay/App.test.ts +493 -62
  561. package/src/apps/relay/App.ts +233 -23
  562. package/src/apps/relay/Sponsorships.test.ts +49 -0
  563. package/src/apps/relay/Sponsorships.ts +18 -6
  564. package/src/db/Db.ts +439 -0
  565. package/src/db/Schema.ts +325 -2
  566. package/src/db/tables/earnVaults.test.ts +185 -0
  567. package/src/db/tables/earnVaults.ts +151 -0
  568. package/src/db/tables/fundingCatalog.test.ts +108 -0
  569. package/src/db/tables/fundingCatalog.ts +157 -0
  570. package/src/db/tables/fundingDepositAddresses.test.ts +580 -0
  571. package/src/db/tables/fundingDepositAddresses.ts +376 -0
  572. package/src/db/tables/fundingDeposits.test.ts +261 -0
  573. package/src/db/tables/fundingDeposits.ts +229 -0
  574. package/src/db/tables/fundingIdempotency.test.ts +182 -0
  575. package/src/db/tables/fundingIdempotency.ts +180 -0
  576. package/src/db/tables/fundingTransferEvents.ts +28 -0
  577. package/src/db/tables/fundingTransferTransactions.test.ts +69 -0
  578. package/src/db/tables/fundingTransferTransactions.ts +37 -0
  579. package/src/db/tables/fundingTransfers.test.ts +89 -0
  580. package/src/db/tables/fundingTransfers.ts +153 -0
  581. package/src/db/tables/organizations.ts +16 -0
  582. package/src/db/tables/projects.ts +16 -0
  583. package/src/db/tables/requestUsage.ts +23 -0
  584. package/src/db/tables/sponsoredTransactions.test.ts +11 -0
  585. package/src/db/tables/sponsoredTransactions.ts +3 -3
  586. package/src/db/tables/users.ts +16 -0
  587. package/src/db/tables/verifiedTokens.ts +19 -14
  588. package/src/db/tables/webhookSubscriptions.ts +58 -3
  589. package/src/handlers/relay.test.ts +2 -0
  590. package/src/handlers/relay.ts +95 -99
  591. package/src/internal/Auth.test.ts +48 -0
  592. package/src/internal/Auth.ts +61 -2
  593. package/src/internal/Cache.ts +13 -9
  594. package/src/internal/Cursor.test.ts +2 -2
  595. package/src/internal/Cursor.ts +1 -1
  596. package/src/internal/EarnRates.test.ts +125 -0
  597. package/src/internal/EarnRates.ts +409 -0
  598. package/src/internal/EarnVaults.test.ts +195 -0
  599. package/src/internal/EarnVaults.ts +876 -0
  600. package/src/internal/EdgeCache.test.ts +19 -0
  601. package/src/internal/EdgeCache.ts +35 -5
  602. package/src/internal/Id.ts +14 -0
  603. package/src/internal/Idempotency.test.ts +109 -0
  604. package/src/internal/Idempotency.ts +237 -0
  605. package/src/internal/Log.test-d.ts +41 -8
  606. package/src/internal/Log.test.ts +189 -8
  607. package/src/internal/Log.ts +124 -17
  608. package/src/internal/MetricSink.test.ts +244 -4
  609. package/src/internal/MetricSink.ts +51 -1
  610. package/src/internal/OpenApi.ts +3 -0
  611. package/src/internal/Provider.test.ts +17 -0
  612. package/src/internal/Provider.ts +17 -0
  613. package/src/internal/Schema.ts +27 -17
  614. package/src/internal/Store.test.ts +25 -0
  615. package/src/internal/Store.ts +46 -0
  616. package/src/internal/Tidx.local.test.ts +78 -3
  617. package/src/internal/Tidx.test.ts +212 -18
  618. package/src/internal/Tidx.ts +112 -32
  619. package/src/internal/VerifiedTokens.test.ts +15 -0
  620. package/src/internal/Viem.test.ts +170 -17
  621. package/src/internal/Viem.ts +111 -28
  622. package/src/internal/WebhookDestination.ts +25 -23
  623. package/src/internal/Webhooks.test.ts +59 -0
  624. package/src/internal/Webhooks.ts +34 -10
  625. package/src/internal/exchange/Provider.test.ts +216 -0
  626. package/src/internal/exchange/Provider.ts +326 -0
  627. package/src/internal/exchange/index.test.ts +6 -0
  628. package/src/internal/exchange/index.ts +1 -0
  629. package/src/internal/exchange/providers/uniswap.test.ts +122 -0
  630. package/src/internal/exchange/providers/uniswap.ts +682 -0
  631. package/src/internal/funding/Action.test.ts +138 -0
  632. package/src/internal/funding/Action.ts +117 -0
  633. package/src/internal/funding/Catalog.test.ts +311 -0
  634. package/src/internal/funding/Catalog.ts +347 -0
  635. package/src/internal/funding/Chain.test.ts +79 -0
  636. package/src/internal/funding/Chain.ts +120 -0
  637. package/src/internal/funding/Deposit.test.ts +26 -0
  638. package/src/internal/funding/Deposit.ts +453 -0
  639. package/src/internal/funding/DepositAddress.test.ts +18 -0
  640. package/src/internal/funding/DepositAddress.ts +312 -0
  641. package/src/internal/funding/Evidence.test.ts +297 -0
  642. package/src/internal/funding/Evidence.ts +430 -0
  643. package/src/internal/funding/Provider.test.ts +1328 -0
  644. package/src/internal/funding/Provider.ts +1796 -0
  645. package/src/internal/funding/Reconciliation.local.test.ts +504 -0
  646. package/src/internal/funding/Reconciliation.test.ts +2020 -0
  647. package/src/internal/funding/Reconciliation.ts +930 -0
  648. package/src/internal/funding/Route.test.ts +66 -0
  649. package/src/internal/funding/Route.ts +29 -0
  650. package/src/internal/funding/Subsidy.local.test.ts +152 -0
  651. package/src/internal/funding/Subsidy.test.ts +75 -0
  652. package/src/internal/funding/Subsidy.ts +260 -0
  653. package/src/internal/funding/Token.test.ts +47 -0
  654. package/src/internal/funding/Token.ts +59 -0
  655. package/src/internal/funding/Transfer.test.ts +369 -0
  656. package/src/internal/funding/Transfer.ts +522 -0
  657. package/src/internal/funding/index.test.ts +20 -0
  658. package/src/internal/funding/index.ts +12 -0
  659. package/src/internal/funding/providers/across.ts +149 -0
  660. package/src/{apps/data/FundingQuoteProviders.test.ts → internal/funding/providers/index.test.ts} +178 -157
  661. package/src/internal/funding/providers/relay.test.ts +474 -0
  662. package/src/internal/funding/providers/relay.ts +559 -0
  663. package/src/internal/funding/providers/rhino.ts +139 -0
  664. package/src/internal/funding/providers/squid.ts +151 -0
  665. package/src/internal/funding/providers/symbiosis.ts +221 -0
  666. package/src/internal/index.test.ts +5 -1
  667. package/src/internal/index.ts +5 -1
  668. package/src/internal/webhookDestinations/url.ts +49 -45
  669. package/src/providers/index.test.ts +14 -0
  670. package/src/providers/index.ts +54 -0
  671. package/dist/apps/data/FundingQuoteProviders.d.ts +0 -174
  672. package/dist/apps/data/FundingQuoteProviders.d.ts.map +0 -1
  673. package/dist/apps/data/FundingQuoteProviders.js +0 -775
  674. package/dist/apps/data/FundingQuoteProviders.js.map +0 -1
  675. package/dist/internal/FundingQuotes.d.ts +0 -864
  676. package/dist/internal/FundingQuotes.d.ts.map +0 -1
  677. package/dist/internal/FundingQuotes.js +0 -672
  678. package/dist/internal/FundingQuotes.js.map +0 -1
  679. package/src/apps/data/FundingQuoteProviders.ts +0 -1043
  680. package/src/internal/FundingQuotes.test.ts +0 -456
  681. package/src/internal/FundingQuotes.ts +0 -944
@@ -0,0 +1,1081 @@
1
+ import { Address, Base58, Bytes, Hash, Value as core_Value } from 'ox';
2
+ import * as z from 'zod/mini';
3
+ import * as core_Provider from '../Provider.js';
4
+ import * as Schema from '../Schema.js';
5
+ import * as Value from '../Value.js';
6
+ import * as Action from './Action.js';
7
+ /** Tempo token used when the caller omits `destinationToken`. */
8
+ const defaultDestinationToken = 'usdce';
9
+ /** Funding provider schemas. */
10
+ export var schema;
11
+ (function (schema) {
12
+ /** Bounded upstream error code safe for structured logs. */
13
+ schema.ErrorCode = z.string().check(z.regex(/^[A-Za-z0-9_.:-]{1,64}$/));
14
+ /** Nested upstream error fields used to extract a stable code. */
15
+ schema.Error = z.object({
16
+ code: z.optional(z.string()),
17
+ type: z.optional(z.string()),
18
+ });
19
+ /** Common upstream error body fields used to extract a stable code. */
20
+ schema.ErrorBody = z.object({
21
+ _tag: z.optional(z.string()),
22
+ code: z.optional(z.string()),
23
+ error: z.optional(schema.Error),
24
+ errorCode: z.optional(z.string()),
25
+ errorType: z.optional(z.string()),
26
+ type: z.optional(z.string()),
27
+ });
28
+ /** Positive decimal amount accepted by funding quote requests. */
29
+ schema.PositiveDecimal = z.string().check(z.regex(/^(?=.*[1-9])\d+(\.\d+)?$/));
30
+ /** Positive base-unit amount accepted by funding quote requests. */
31
+ schema.PositiveInteger = z.string().check(z.regex(/^(?=.*[1-9])\d+$/));
32
+ /** Normalized chain reference passed to funding providers. */
33
+ schema.ChainRef = Schema.describe(z.object({
34
+ addressFormat: z
35
+ .enum(['base58', 'base58check', 'hex'])
36
+ .check(z.describe('Address encoding used by accounts and token identifiers on this chain.'), z.meta({ examples: ['hex'] })),
37
+ id: z.string().check(z.describe('CAIP-2 chain id.'), z.meta({ examples: ['eip155:8453'] })),
38
+ kind: z
39
+ .enum(['evm', 'solana', 'tron'])
40
+ .check(z.describe('Chain execution family used for provider routing.'), z.meta({ examples: ['evm'] })),
41
+ name: z
42
+ .string()
43
+ .check(z.describe('Human-readable chain name.'), z.meta({ examples: ['Base'] })),
44
+ }), 'A normalized chain reference for funding quotes.');
45
+ /** Normalized token reference passed to funding providers. */
46
+ schema.TokenRef = Schema.describe(z.object({
47
+ address: z
48
+ .string()
49
+ .check(z.describe('Contract address, mint, or issuer address on the token chain.'), z.meta({ examples: ['0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'] })),
50
+ currency: z
51
+ .string()
52
+ .check(z.describe('Monetary denomination represented by this token.'), z.meta({ examples: ['USD'] })),
53
+ decimals: z
54
+ .number()
55
+ .check(z.int(), z.gte(0), z.describe('Number of decimal places this token uses.'), z.meta({ examples: [6] })),
56
+ name: z
57
+ .string()
58
+ .check(z.describe('Human-readable token name.'), z.meta({ examples: ['USD Coin'] })),
59
+ standard: z
60
+ .string()
61
+ .check(z.describe('Token standard on the token chain.'), z.meta({ examples: ['ERC-20'] })),
62
+ symbol: z
63
+ .string()
64
+ .check(z.describe('Short token ticker symbol.'), z.meta({ examples: ['USDC'] })),
65
+ tokenKey: z.string().check(z.describe('Stable Tempo token key scoped to the token chain.'), z.meta({
66
+ examples: ['eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'],
67
+ })),
68
+ verified: z
69
+ .boolean()
70
+ .check(z.describe('Whether Tempo recognizes this token in its funding quote inventory.'), z.meta({ examples: [true] })),
71
+ }), 'A normalized token reference for funding quotes.');
72
+ /** Provider identity embedded in funding resources. */
73
+ schema.ProviderRef = Schema.describe(z.object({
74
+ id: z.string().check(z.describe('Stable provider id.'), z.meta({ examples: ['relay'] })),
75
+ name: z
76
+ .string()
77
+ .check(z.describe('Human-readable provider name.'), z.meta({ examples: ['Relay'] })),
78
+ }), 'Provider metadata embedded in a funding quote.');
79
+ /** Source amount unit accepted by a funding quote request. */
80
+ schema.SourceAmountUnits = z
81
+ ._default(z.enum(['baseUnits', 'decimal']), 'baseUnits')
82
+ .check(z.describe('Whether `sourceAmount` is base units or a human-readable decimal.'), z.meta({ examples: ['baseUnits', 'decimal'] }));
83
+ /** Normalized caller request passed to funding providers. */
84
+ schema.QuoteRequest = z
85
+ .strictObject({
86
+ destinationToken: z
87
+ .optional(z.string())
88
+ .check(z.describe('Tempo destination token symbol, address, or token key. Defaults to USDC.e.'), z.meta({ examples: ['usdc.e'] })),
89
+ provider: z
90
+ .optional(z.string().check(z.minLength(1)))
91
+ .check(z.describe('Only request a quote from this provider. Use an id returned by the funding providers endpoint, or omit it to query every available provider.'), z.meta({ examples: ['relay'] })),
92
+ sourceAmount: schema.PositiveDecimal.check(z.describe('Positive source token amount. Base units by default, so 1 USDC is `1000000`.'), z.meta({ examples: ['1000000'] })),
93
+ sourceAmountUnits: schema.SourceAmountUnits,
94
+ sourceChain: z
95
+ .string()
96
+ .check(z.minLength(1), z.describe('Source chain alias or stable id, such as `base`, `solana`, or `eip155:8453`.'), z.meta({ examples: ['base', 'eip155:8453'] })),
97
+ sourceToken: z
98
+ .string()
99
+ .check(z.minLength(1), z.describe('Source token symbol, contract address, or Tempo token key. Lookup is scoped to `sourceChain`; non-EVM addresses are case-sensitive. An unknown token returns an empty list.'), z.meta({ examples: ['usdc', '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'] })),
100
+ })
101
+ .check(z.describe('Query parameters for live funding quotes into Tempo.'));
102
+ /** Provider-specific quote status for the requested amount. */
103
+ schema.QuoteStatus = z.enum(['available', 'thin', 'unknown', 'unavailable']);
104
+ /** Machine-readable provider quote quality tier. */
105
+ schema.QualityTier = z.enum(['liquid', 'thin', 'unknown', 'unavailable']);
106
+ /** Quote data returned by a funding provider. */
107
+ schema.GetQuoteResult = Schema.describe(z.object({
108
+ expiresAt: z.optional(z.iso.datetime()),
109
+ destinationAmountMin: z.optional(Schema.DecimalString),
110
+ destinationAmount: z.optional(Schema.DecimalString),
111
+ quality: z.optional(z.object({
112
+ estimatedSeconds: z.optional(z.number().check(z.int(), z.nonnegative())),
113
+ liquiditySource: z.string(),
114
+ sourceDetail: z.optional(z.string()),
115
+ tier: z.optional(schema.QualityTier),
116
+ })),
117
+ sampledAt: z.iso.datetime(),
118
+ status: schema.QuoteStatus,
119
+ }), 'Quote data returned by a funding provider.');
120
+ /** Executable preparation returned by a funding provider. */
121
+ schema.PrepareResult = z.object({
122
+ action: Action.schema.Action,
123
+ correlation: z.object({
124
+ checkEndpoint: z.optional(z.string()),
125
+ requestId: z.string().check(z.minLength(1)),
126
+ }),
127
+ destinationAmount: schema.PositiveInteger,
128
+ destinationAmountMin: schema.PositiveInteger,
129
+ expiresAt: z.optional(z.iso.datetime()),
130
+ fees: z.array(z.object({
131
+ amount: Schema.DecimalString,
132
+ side: z.enum(['destination', 'source']),
133
+ })),
134
+ quality: schema.GetQuoteResult.shape.quality,
135
+ sampledAt: z.iso.datetime(),
136
+ });
137
+ /** Reusable deposit address provisioned by a funding provider. */
138
+ schema.DepositAddressResult = z
139
+ .object({
140
+ address: z
141
+ .string()
142
+ .check(z.minLength(1), z.describe('Reusable source-chain deposit address.')),
143
+ correlation: z
144
+ .object({
145
+ checkEndpoint: z
146
+ .optional(z.string())
147
+ .check(z.describe('Provider status endpoint for the original address request.')),
148
+ requestId: z
149
+ .string()
150
+ .check(z.minLength(1), z.describe('Provider-issued address request identifier.')),
151
+ })
152
+ .check(z.describe('Private provider correlation retained for reconciliation.')),
153
+ destinationAmount: schema.PositiveInteger,
154
+ destinationAmountMin: schema.PositiveInteger,
155
+ expiresAt: z.optional(z.iso.datetime()),
156
+ fees: schema.PrepareResult.shape.fees,
157
+ sampledAt: z.iso.datetime(),
158
+ })
159
+ .check(z.describe('Reusable deposit address and quoted delivery terms returned by a provider.'));
160
+ /** One provider request discovered for a reusable deposit address. */
161
+ schema.DepositAddressRequest = z.object({
162
+ createdAt: z.iso.datetime(),
163
+ destinationTransactionHashes: z.array(z.string()),
164
+ id: z.string().check(z.minLength(1)),
165
+ sourceTransactionHashes: z.array(z.string()),
166
+ status: z.string().check(z.minLength(1)),
167
+ updatedAt: z.iso.datetime(),
168
+ });
169
+ /** One page of provider requests discovered for a reusable address. */
170
+ schema.DepositAddressRequestsResult = z.object({
171
+ continuation: z.optional(z.string().check(z.minLength(1))),
172
+ requests: z.array(schema.DepositAddressRequest),
173
+ });
174
+ /** Quote quality signals exposed to funding API callers. */
175
+ schema.FundingQuoteQuality = Schema.describe(z.object({
176
+ estimatedSeconds: z
177
+ .optional(z.number().check(z.int(), z.nonnegative()))
178
+ .check(z.describe('Estimated settlement time in seconds, when known.'), z.meta({ examples: [2] })),
179
+ liquiditySource: z
180
+ .string()
181
+ .check(z.describe('Provider source for the live quote quality signal.'), z.meta({ examples: ['providerQuote'] })),
182
+ sourceDetail: z
183
+ .optional(z.string())
184
+ .check(z.describe('Provider-specific source or endpoint detail for the quality signal.'), z.meta({ examples: ['providerEndpoint'] })),
185
+ tier: z
186
+ .enum(['liquid', 'thin'])
187
+ .check(z.describe('Machine-readable quote quality tier for a successful quote.'), z.meta({ examples: ['liquid'] })),
188
+ }), 'Machine-readable liquidity, fee, and source signals for a successful quote.');
189
+ /** Provider quote freshness data exposed to funding API callers. */
190
+ schema.QuoteDetails = Schema.describe(z.object({
191
+ expiresAt: z
192
+ .optional(z.iso.datetime())
193
+ .check(z.describe('Timestamp after which the provider quote is no longer valid.'), z.meta({ examples: ['2026-01-01T00:01:00Z'] })),
194
+ sampledAt: z.iso
195
+ .datetime()
196
+ .check(z.describe('Timestamp for the live quote request.'), z.meta({ examples: ['2026-01-01T00:00:00Z'] })),
197
+ }), 'Freshness data for a provider funding quote.');
198
+ /** Successful normalized funding quote returned to callers. */
199
+ schema.FundingQuote = Schema.describe(z.object({
200
+ destinationAmount: Schema.TokenAmount.check(z.describe('Expected destination amount.')),
201
+ destinationAmountMin: z
202
+ .optional(Schema.TokenAmount)
203
+ .check(z.describe('Provider-derived minimum destination amount. Symbiosis and Squid quotes use a fixed 1% slippage tolerance.')),
204
+ destinationChain: schema.ChainRef.check(z.describe('Destination chain, always Tempo mainnet in V1.')),
205
+ destinationToken: schema.TokenRef.check(z.describe('Tempo token expected from this quote.')),
206
+ id: z
207
+ .string()
208
+ .check(z.describe('Stable deterministic funding quote id.'), z.meta({ examples: ['base-usdc-tempo-usdce-relay'] })),
209
+ provider: schema.ProviderRef,
210
+ quality: schema.FundingQuoteQuality,
211
+ quote: schema.QuoteDetails,
212
+ sourceAmount: Schema.TokenAmount,
213
+ sourceChain: schema.ChainRef.check(z.describe('Chain where the caller currently holds funds.')),
214
+ sourceToken: schema.TokenRef.check(z.describe('Token the caller currently holds.')),
215
+ }), 'One successful provider-specific funding quote.');
216
+ })(schema || (schema = {}));
217
+ /** Defines a funding provider from its identity and quote implementation. */
218
+ export function from(options) {
219
+ if (options.id !== normalizeInput(options.id) || options.id.length === 0)
220
+ throw new ProviderConfigurationError('Provider ids must be lowercase and trimmed.');
221
+ return core_Provider.from({ ...options, type: 'funding' });
222
+ }
223
+ /** Narrows a registered provider to a funding provider. */
224
+ export function is(provider) {
225
+ return (provider.type === 'funding' && 'getQuote' in provider && typeof provider.getQuote === 'function');
226
+ }
227
+ /** Narrows a funding provider to one that prepares executable transfers. */
228
+ export function canPrepareTransfer(provider) {
229
+ return typeof provider.prepareTransfer === 'function';
230
+ }
231
+ /** Narrows a funding provider to one that provisions reusable deposit addresses. */
232
+ export function canCreateDepositAddress(provider) {
233
+ return typeof provider.createDepositAddress === 'function';
234
+ }
235
+ /** Narrows a funding provider to one that tracks reusable deposit addresses. */
236
+ export function canListDepositAddressRequests(provider) {
237
+ return typeof provider.listDepositAddressRequests === 'function';
238
+ }
239
+ /** Narrows a funding provider to one with authenticated webhook receipt. */
240
+ export function canReceiveWebhook(provider) {
241
+ return provider.webhook !== undefined;
242
+ }
243
+ const defaultTimeoutMs = 2_000;
244
+ /** Returns normalized chains and source tokens supported by quote providers. */
245
+ export function getChains(options) {
246
+ const routes = getRoutes(options.catalog, options.providers);
247
+ const chains = uniqueBy(routes.map((entry) => entry.route.source.chain), (chain) => chain.id);
248
+ return chains.flatMap((chain) => {
249
+ const tokens = routes
250
+ .filter((entry) => entry.route.source.chain.id === chain.id)
251
+ .map((entry) => entry.route.source);
252
+ if (tokens.length === 0)
253
+ return [];
254
+ return [
255
+ {
256
+ ...chainRef(chain),
257
+ tokens: uniqueBy(tokens, (token) => token.address).map(tokenRef),
258
+ },
259
+ ];
260
+ });
261
+ }
262
+ /** Returns the supplied funding quote providers. */
263
+ export function getProviders(options) {
264
+ return options.providers
265
+ .filter((provider) => (options.catalog.routesByProvider.get(provider.id)?.length ?? 0) > 0)
266
+ .map((provider) => schema.ProviderRef.parse(provider));
267
+ }
268
+ /** Returns successful live funding quotes from the supplied providers. */
269
+ export async function getQuotes(options) {
270
+ const providers = options.providers ?? [];
271
+ const operation = 'getQuote';
272
+ const candidates = getQuoteCandidates(options).flatMap((candidate) => {
273
+ const provider = providers.find((entry) => entry.id === candidate.provider.id);
274
+ return provider ? [{ candidate, provider }] : [];
275
+ });
276
+ const attempts = new Map();
277
+ const results = await Promise.allSettled(candidates.map(async ({ candidate, provider }, index) => {
278
+ const start = performance.now();
279
+ try {
280
+ const result = await quoteCandidate(candidate, {
281
+ cache: options.cache ?? { bypass: false },
282
+ provider,
283
+ request: {
284
+ destinationToken: options.destinationToken,
285
+ provider: options.provider,
286
+ sourceAmount: options.sourceAmount,
287
+ sourceAmountUnits: options.sourceAmountUnits,
288
+ sourceChain: options.sourceChain,
289
+ sourceToken: options.sourceToken,
290
+ },
291
+ timeoutMs: options.providerTimeoutMs ?? defaultTimeoutMs,
292
+ });
293
+ attempts.set(index, {
294
+ durationMs: performance.now() - start,
295
+ operation,
296
+ outcome: result.outcome,
297
+ provider,
298
+ });
299
+ return 'quote' in result ? result.quote : undefined;
300
+ }
301
+ catch (cause) {
302
+ attempts.set(index, {
303
+ cause,
304
+ durationMs: performance.now() - start,
305
+ operation,
306
+ outcome: 'failed',
307
+ provider,
308
+ });
309
+ throw cause;
310
+ }
311
+ }));
312
+ const values = [...candidates.keys()].flatMap((index) => {
313
+ const attempt = attempts.get(index);
314
+ return attempt ? [attempt] : [];
315
+ });
316
+ for (const attempt of values) {
317
+ try {
318
+ options.onAttempt?.(attempt);
319
+ }
320
+ catch {
321
+ // Observability hooks never alter funding quote behavior.
322
+ }
323
+ }
324
+ const quotes = results.flatMap((result) => result.status === 'fulfilled' && result.value ? [result.value] : []);
325
+ const failures = results.flatMap((result, index) => result.status === 'rejected'
326
+ ? [
327
+ {
328
+ cause: result.reason,
329
+ operation,
330
+ provider: candidates[index].provider,
331
+ },
332
+ ]
333
+ : []);
334
+ if (quotes.length === 0 && failures.length > 0)
335
+ throw new ProviderQuoteError(failures, values);
336
+ return quotes;
337
+ }
338
+ /** Returns internal quote candidates for a normalized caller request. */
339
+ export function getQuoteCandidates(options) {
340
+ const { catalog, providers } = options;
341
+ const amount = (options.sourceAmountUnits === 'baseUnits' ? schema.PositiveInteger : schema.PositiveDecimal).safeParse(options.sourceAmount);
342
+ if (!amount.success)
343
+ throw new InvalidAmountError();
344
+ const sourceChain = resolveSourceChain(options.sourceChain, catalog);
345
+ const sourceToken = resolveSourceToken(sourceChain, options.sourceToken, catalog);
346
+ const destination = resolveDestinationToken(options.destinationToken, catalog);
347
+ const provider = options.provider ? resolveProvider(options.provider, providers) : undefined;
348
+ if (providers.length === 0)
349
+ return [];
350
+ if (!sourceToken)
351
+ return [];
352
+ const sourceAmount = resolveSourceAmount({
353
+ amount: options.sourceAmount,
354
+ token: sourceToken,
355
+ units: options.sourceAmountUnits,
356
+ });
357
+ return getRoutes(catalog, providers)
358
+ .filter((entry) => entry.route.source.chain.id === sourceChain.id)
359
+ .filter((entry) => entry.route.source.address === sourceToken.address)
360
+ .filter((entry) => entry.route.destination.chain.id === destination.chain.id)
361
+ .filter((entry) => entry.route.destination.address === destination.address)
362
+ .filter((entry) => provider === undefined || entry.provider.id === provider.id)
363
+ .map((entry) => createQuoteCandidate({
364
+ destinationToken: entry.route.destination,
365
+ provider: entry.provider,
366
+ route: entry.route,
367
+ sourceAmount,
368
+ sourceToken: entry.route.source,
369
+ }));
370
+ }
371
+ const defaultPrepareTimeoutMs = 10_000;
372
+ // Providers that return no quote validity window get a conservative default:
373
+ // the caller must sign and submit promptly, mirroring wallet quote UX.
374
+ const defaultQuoteTtlMs = 60_000;
375
+ /**
376
+ * Provisions one reusable deposit address through the first deterministic
377
+ * capability-enabled provider. Returns `undefined` when no route is enabled.
378
+ */
379
+ export async function createDepositAddress(options) {
380
+ const operation = 'createDepositAddress';
381
+ if (!schema.PositiveInteger.safeParse(options.amount).success)
382
+ throw new InvalidAmountError();
383
+ const candidates = getDepositAddressCandidates(options).sort((a, b) => a.provider.id.localeCompare(b.provider.id));
384
+ const selected = candidates[0];
385
+ if (!selected)
386
+ return undefined;
387
+ const recipient = normalizeAccountAddress(options.recipient, selected.candidate.destinationChain);
388
+ const refundAddress = normalizeAccountAddress(options.refundAddress, selected.candidate.sourceChain);
389
+ if (!recipient)
390
+ throw new ProviderPayloadError();
391
+ if (!refundAddress)
392
+ throw new InvalidRefundAddressError();
393
+ const start = performance.now();
394
+ try {
395
+ const parsed = schema.DepositAddressResult.safeParse(await withTimeout((signal) => selected.provider.createDepositAddress({
396
+ amount: options.amount,
397
+ candidate: selected.candidate,
398
+ recipient,
399
+ refundAddress,
400
+ subsidize: options.subsidize,
401
+ }, signal), options.providerTimeoutMs ?? defaultPrepareTimeoutMs));
402
+ if (!parsed.success)
403
+ throw new ProviderPayloadError();
404
+ const result = parsed.data;
405
+ if (!normalizeAccountAddress(result.address, selected.candidate.sourceChain))
406
+ throw new ProviderPayloadError();
407
+ if (BigInt(result.destinationAmountMin) > BigInt(result.destinationAmount))
408
+ throw new ProviderPayloadError();
409
+ if (result.expiresAt !== undefined && Date.parse(result.expiresAt) <= Date.now())
410
+ throw new ProviderPayloadError();
411
+ const attempt = {
412
+ durationMs: performance.now() - start,
413
+ operation,
414
+ outcome: 'available',
415
+ provider: selected.provider,
416
+ };
417
+ try {
418
+ options.onAttempt?.(attempt);
419
+ }
420
+ catch {
421
+ // Observability hooks never alter provisioning behavior.
422
+ }
423
+ return { ...selected, recipient, refundAddress, result };
424
+ }
425
+ catch (cause) {
426
+ const attempt = cause instanceof ProviderUnavailableError
427
+ ? {
428
+ durationMs: performance.now() - start,
429
+ operation,
430
+ outcome: 'unavailable',
431
+ provider: selected.provider,
432
+ }
433
+ : {
434
+ cause,
435
+ durationMs: performance.now() - start,
436
+ operation,
437
+ outcome: 'failed',
438
+ provider: selected.provider,
439
+ };
440
+ try {
441
+ options.onAttempt?.(attempt);
442
+ }
443
+ catch {
444
+ // Observability hooks never alter provisioning behavior.
445
+ }
446
+ if (cause instanceof ProviderUnavailableError)
447
+ return undefined;
448
+ throw new ProviderQuoteError([{ cause, operation, provider: selected.provider }], [attempt]);
449
+ }
450
+ }
451
+ /**
452
+ * Prepares one executable transfer across capability-enabled candidates,
453
+ * selecting the best successful preparation. Returns `undefined` when no
454
+ * enabled corridor matches; throws {@link ProviderQuoteError} when every
455
+ * matching provider failed unexpectedly.
456
+ */
457
+ export async function prepareTransfer(options) {
458
+ const operation = 'prepareTransfer';
459
+ const candidates = getPrepareCandidates(options);
460
+ if (candidates.length === 0)
461
+ return undefined;
462
+ const attempts = [];
463
+ const results = await Promise.allSettled(candidates.map(async ({ candidate, provider }) => {
464
+ const start = performance.now();
465
+ try {
466
+ const parsed = schema.PrepareResult.safeParse(await withTimeout((signal) => provider.prepareTransfer({
467
+ candidate,
468
+ method: options.method,
469
+ mode: options.mode,
470
+ recipient: options.recipient,
471
+ sender: options.sender,
472
+ slippageBps: options.slippageBps,
473
+ }, signal), options.providerTimeoutMs ?? defaultPrepareTimeoutMs));
474
+ if (!parsed.success)
475
+ throw new ProviderPayloadError();
476
+ const result = parsed.data;
477
+ const expiresAt = result.expiresAt ??
478
+ new Date(Date.parse(result.sampledAt) + defaultQuoteTtlMs).toISOString();
479
+ if (Date.parse(expiresAt) <= Date.now())
480
+ throw new ProviderPayloadError();
481
+ if (BigInt(result.destinationAmountMin) > BigInt(result.destinationAmount))
482
+ throw new ProviderPayloadError();
483
+ // A provider that ignores the caller's slippage bound is unusable for
484
+ // this request; enforce the bound against the quoted minimum.
485
+ if (options.slippageBps !== undefined) {
486
+ const basisPointScale = 10000n;
487
+ const numerator = BigInt(result.destinationAmount) * BigInt(10_000 - options.slippageBps);
488
+ const floor = (numerator + basisPointScale - 1n) / basisPointScale;
489
+ if (BigInt(result.destinationAmountMin) < floor)
490
+ throw new ProviderPayloadError();
491
+ }
492
+ if (result.action.type === 'evm:calls')
493
+ try {
494
+ Action.validateEvmCalls({
495
+ action: result.action,
496
+ sourceAmount: candidate.sourceAmount.amount,
497
+ sourceTokenAddress: candidate.sourceToken.address,
498
+ });
499
+ }
500
+ catch (cause) {
501
+ if (cause instanceof Action.InvalidActionError)
502
+ throw new ProviderPayloadError();
503
+ throw cause;
504
+ }
505
+ attempts.push({
506
+ durationMs: performance.now() - start,
507
+ operation,
508
+ outcome: 'available',
509
+ provider,
510
+ });
511
+ return { candidate, provider, result: { ...result, expiresAt } };
512
+ }
513
+ catch (cause) {
514
+ if (cause instanceof ProviderUnavailableError) {
515
+ attempts.push({
516
+ durationMs: performance.now() - start,
517
+ operation,
518
+ outcome: 'unavailable',
519
+ provider,
520
+ });
521
+ return undefined;
522
+ }
523
+ attempts.push({
524
+ cause,
525
+ durationMs: performance.now() - start,
526
+ operation,
527
+ outcome: 'failed',
528
+ provider,
529
+ });
530
+ throw cause;
531
+ }
532
+ }));
533
+ for (const attempt of attempts) {
534
+ try {
535
+ options.onAttempt?.(attempt);
536
+ }
537
+ catch {
538
+ // Observability hooks never alter preparation behavior.
539
+ }
540
+ }
541
+ const prepared = results.flatMap((result) => result.status === 'fulfilled' && result.value ? [result.value] : []);
542
+ if (prepared.length === 0) {
543
+ const failures = results.flatMap((result, index) => result.status === 'rejected'
544
+ ? [
545
+ {
546
+ cause: result.reason,
547
+ operation,
548
+ provider: candidates[index].provider,
549
+ },
550
+ ]
551
+ : []);
552
+ if (failures.length === 0)
553
+ return undefined;
554
+ throw new ProviderQuoteError(failures, attempts);
555
+ }
556
+ // Deterministic selection: highest guaranteed minimum, then provider id.
557
+ prepared.sort((a, b) => {
558
+ const delta = BigInt(b.result.destinationAmountMin) - BigInt(a.result.destinationAmountMin);
559
+ if (delta !== 0n)
560
+ return delta > 0n ? 1 : -1;
561
+ return a.provider.id < b.provider.id ? -1 : 1;
562
+ });
563
+ return prepared[0];
564
+ }
565
+ /**
566
+ * Returns capability-enabled reusable-address candidates for a route. Tokens
567
+ * resolve within their chains and only provider delivery qualifies.
568
+ */
569
+ export function getDepositAddressCandidates(options) {
570
+ const sourceChain = resolveSourceChain(options.sourceChain, options.catalog);
571
+ const destinationChainId = `eip155:${options.destinationChainId}`;
572
+ return options.catalog.routes.flatMap((entry) => {
573
+ if (entry.route.source.chain.id !== sourceChain.id)
574
+ return [];
575
+ if (entry.route.destination.chain.id !== destinationChainId)
576
+ return [];
577
+ if (!matchesToken(entry.route.source, options.sourceToken))
578
+ return [];
579
+ if (!matchesToken(entry.route.destination, options.destinationToken))
580
+ return [];
581
+ if (!entry.capabilities?.depositAddress)
582
+ return [];
583
+ const provider = options.providers.find((candidate) => candidate.id === entry.providerId);
584
+ if (!provider || !canCreateDepositAddress(provider))
585
+ return [];
586
+ return [
587
+ { candidate: createDepositAddressCandidate({ provider, route: entry.route }), provider },
588
+ ];
589
+ });
590
+ }
591
+ /**
592
+ * Returns capability-enabled preparation candidates for a creation request.
593
+ * Tokens resolve within their chains. A route must enable the requested mode,
594
+ * and its provider must implement `prepareTransfer`.
595
+ */
596
+ export function getPrepareCandidates(options) {
597
+ const amount = schema.PositiveInteger.safeParse(options.sourceAmount);
598
+ if (!amount.success)
599
+ throw new InvalidAmountError();
600
+ const sourceChain = resolveSourceChain(options.sourceChain, options.catalog);
601
+ const destinationChainId = `eip155:${options.destinationChainId}`;
602
+ return options.catalog.routes.flatMap((entry) => {
603
+ if (entry.route.source.chain.id !== sourceChain.id)
604
+ return [];
605
+ if (entry.route.destination.chain.id !== destinationChainId)
606
+ return [];
607
+ if (!matchesToken(entry.route.source, options.sourceToken))
608
+ return [];
609
+ if (!matchesToken(entry.route.destination, options.destinationToken))
610
+ return [];
611
+ if (!entry.capabilities?.transfer?.modes.includes(options.mode))
612
+ return [];
613
+ const provider = options.providers.find((candidate) => candidate.id === entry.providerId);
614
+ if (!provider || !canPrepareTransfer(provider))
615
+ return [];
616
+ return [
617
+ {
618
+ candidate: createQuoteCandidate({
619
+ destinationToken: entry.route.destination,
620
+ provider,
621
+ route: entry.route,
622
+ sourceAmount: resolveSourceAmount({
623
+ amount: options.sourceAmount,
624
+ token: entry.route.source,
625
+ units: 'baseUnits',
626
+ }),
627
+ sourceToken: entry.route.source,
628
+ }),
629
+ provider,
630
+ },
631
+ ];
632
+ });
633
+ }
634
+ /** Returns bounded provider failure details suitable for structured request logs. */
635
+ export function failure(options) {
636
+ const { cause, operation, provider } = options;
637
+ if (cause instanceof ProviderTimeoutError ||
638
+ (cause instanceof DOMException && cause.name === 'AbortError'))
639
+ return { failure: 'timeout', id: provider.id, operation };
640
+ if (cause instanceof ProviderResponseError) {
641
+ const code = errorCode(cause.body);
642
+ return {
643
+ ...(code === undefined ? {} : { code }),
644
+ failure: 'http',
645
+ id: provider.id,
646
+ operation,
647
+ status: cause.status,
648
+ };
649
+ }
650
+ if (cause instanceof ProviderPayloadError)
651
+ return { failure: 'payload', id: provider.id, operation };
652
+ if (cause instanceof ProviderRateLimitError)
653
+ return { failure: 'rate_limit', id: provider.id, operation };
654
+ if (cause instanceof TypeError)
655
+ return { failure: 'network', id: provider.id, operation };
656
+ return { failure: 'unknown', id: provider.id, operation };
657
+ }
658
+ /** Returns a supported expected-unavailable code from a provider response. */
659
+ export function unavailable(cause, codes) {
660
+ if (!(cause instanceof ProviderResponseError) || cause.status < 400 || cause.status >= 500)
661
+ return undefined;
662
+ const code = errorCode(cause.body);
663
+ if (code && codes.includes(code))
664
+ return code;
665
+ return undefined;
666
+ }
667
+ /** Requests and parses a JSON provider response. */
668
+ export async function requestJson(url, options) {
669
+ const headers = { accept: 'application/json', ...options.headers };
670
+ const init = {
671
+ headers: options.body === undefined ? headers : { ...headers, 'content-type': 'application/json' },
672
+ method: options.method ?? 'GET',
673
+ signal: options.signal,
674
+ };
675
+ if (options.body !== undefined)
676
+ init.body = JSON.stringify(options.body);
677
+ const response = await options.fetch(url, init);
678
+ const text = await response.text();
679
+ const body = (() => {
680
+ if (!text)
681
+ return null;
682
+ try {
683
+ return JSON.parse(text);
684
+ }
685
+ catch {
686
+ return text;
687
+ }
688
+ })();
689
+ if (!response.ok)
690
+ throw new ProviderResponseError(response.status, body);
691
+ return body;
692
+ }
693
+ /** Creates a normalized expected-unavailable quote result. */
694
+ export function unavailableResult(options) {
695
+ return {
696
+ quality: {
697
+ liquiditySource: options.source,
698
+ sourceDetail: `${options.detail}:${options.message}`,
699
+ tier: 'unavailable',
700
+ },
701
+ sampledAt: options.now.toISOString(),
702
+ status: 'unavailable',
703
+ };
704
+ }
705
+ function tokenKey(token) {
706
+ const namespace = (() => {
707
+ if (token.chain.kind === 'solana')
708
+ return 'token';
709
+ if (token.chain.kind === 'tron')
710
+ return 'trc20';
711
+ return 'erc20';
712
+ })();
713
+ return `${token.chain.id}/${namespace}:${token.address}`;
714
+ }
715
+ async function quoteCandidate(candidate, options) {
716
+ const result = schema.GetQuoteResult.safeParse(await withTimeout((signal) => options.provider.getQuote({
717
+ candidate,
718
+ cache: options.cache,
719
+ destinationChain: candidate.destinationChain,
720
+ destinationToken: candidate.destinationToken,
721
+ request: options.request,
722
+ route: candidate.route,
723
+ sourceAmount: candidate.sourceAmount,
724
+ sourceChain: candidate.sourceChain,
725
+ sourceToken: candidate.sourceToken,
726
+ }, signal), options.timeoutMs));
727
+ if (!result.success)
728
+ throw new ProviderPayloadError();
729
+ const quote = result.data;
730
+ if (quote.status === 'unavailable')
731
+ return { outcome: quote.status };
732
+ if ((quote.status !== 'available' && quote.status !== 'thin') ||
733
+ quote.destinationAmount === undefined ||
734
+ quote.destinationAmount === null)
735
+ throw new ProviderPayloadError();
736
+ const destinationAmount = BigInt(quote.destinationAmount);
737
+ const destinationAmountMin = quote.destinationAmountMin === undefined ? undefined : BigInt(quote.destinationAmountMin);
738
+ if (destinationAmount === 0n ||
739
+ destinationAmountMin === 0n ||
740
+ (destinationAmountMin !== undefined && destinationAmountMin > destinationAmount))
741
+ throw new ProviderPayloadError();
742
+ return {
743
+ outcome: quote.status,
744
+ quote: createQuote(candidate, {
745
+ ...quote,
746
+ destinationAmount: quote.destinationAmount,
747
+ status: quote.status,
748
+ }),
749
+ };
750
+ }
751
+ function tokenRef(token) {
752
+ return schema.TokenRef.parse({
753
+ address: token.address,
754
+ currency: token.currency,
755
+ decimals: token.decimals,
756
+ name: token.name,
757
+ standard: token.standard,
758
+ symbol: token.symbol,
759
+ tokenKey: tokenKey(token),
760
+ verified: true,
761
+ });
762
+ }
763
+ function chainRef(chain) {
764
+ return schema.ChainRef.parse({
765
+ addressFormat: chain.addressFormat,
766
+ id: chain.id,
767
+ kind: chain.kind,
768
+ name: chain.name,
769
+ });
770
+ }
771
+ function createDepositAddressCandidate(options) {
772
+ return {
773
+ destinationChain: chainRef(options.route.destination.chain),
774
+ destinationToken: tokenRef(options.route.destination),
775
+ provider: schema.ProviderRef.parse(options.provider),
776
+ route: options.route,
777
+ sourceChain: chainRef(options.route.source.chain),
778
+ sourceToken: tokenRef(options.route.source),
779
+ };
780
+ }
781
+ function createQuoteCandidate(options) {
782
+ return {
783
+ destinationChain: chainRef(options.destinationToken.chain),
784
+ destinationToken: tokenRef(options.destinationToken),
785
+ id: [
786
+ options.sourceToken.chain.slug,
787
+ options.sourceToken.slug,
788
+ options.destinationToken.chain.slug,
789
+ options.destinationToken.slug,
790
+ options.provider.id,
791
+ ].join('-'),
792
+ provider: schema.ProviderRef.parse(options.provider),
793
+ route: options.route,
794
+ sourceAmount: options.sourceAmount,
795
+ sourceChain: chainRef(options.sourceToken.chain),
796
+ sourceToken: tokenRef(options.sourceToken),
797
+ };
798
+ }
799
+ function normalizeInput(value) {
800
+ return value.trim().toLowerCase();
801
+ }
802
+ function parseBaseUnits(value) {
803
+ return BigInt(value).toString();
804
+ }
805
+ function parseDecimalUnits(value, decimals) {
806
+ const fraction = value.split('.')[1]?.replace(/0+$/, '') ?? '';
807
+ if (fraction.length > decimals)
808
+ throw new InvalidAmountError();
809
+ try {
810
+ const amount = core_Value.from(value, decimals);
811
+ if (amount <= 0n)
812
+ throw new InvalidAmountError();
813
+ return amount.toString();
814
+ }
815
+ catch (cause) {
816
+ if (cause instanceof InvalidAmountError)
817
+ throw cause;
818
+ throw new InvalidAmountError();
819
+ }
820
+ }
821
+ function createQuote(candidate, quote) {
822
+ return schema.FundingQuote.parse({
823
+ destinationAmount: Value.tokenAmount({
824
+ baseUnits: quote.destinationAmount,
825
+ currency: candidate.destinationToken.currency,
826
+ decimals: candidate.destinationToken.decimals,
827
+ }),
828
+ ...(quote.destinationAmountMin !== undefined
829
+ ? {
830
+ destinationAmountMin: Value.tokenAmount({
831
+ baseUnits: quote.destinationAmountMin,
832
+ currency: candidate.destinationToken.currency,
833
+ decimals: candidate.destinationToken.decimals,
834
+ }),
835
+ }
836
+ : {}),
837
+ destinationChain: candidate.destinationChain,
838
+ destinationToken: candidate.destinationToken,
839
+ id: candidate.id,
840
+ provider: candidate.provider,
841
+ quality: {
842
+ ...(quote.quality?.estimatedSeconds !== undefined
843
+ ? { estimatedSeconds: quote.quality.estimatedSeconds }
844
+ : {}),
845
+ liquiditySource: quote.quality?.liquiditySource ?? 'providerQuote',
846
+ ...(quote.quality?.sourceDetail !== undefined
847
+ ? { sourceDetail: quote.quality.sourceDetail }
848
+ : {}),
849
+ tier: quote.status === 'thin' ? 'thin' : 'liquid',
850
+ },
851
+ quote: {
852
+ ...(quote.expiresAt !== undefined ? { expiresAt: quote.expiresAt } : {}),
853
+ sampledAt: quote.sampledAt,
854
+ },
855
+ sourceAmount: Value.tokenAmount({
856
+ baseUnits: candidate.sourceAmount.amount,
857
+ currency: candidate.sourceToken.currency,
858
+ decimals: candidate.sourceToken.decimals,
859
+ }),
860
+ sourceChain: candidate.sourceChain,
861
+ sourceToken: candidate.sourceToken,
862
+ });
863
+ }
864
+ function withTimeout(fn, timeoutMs) {
865
+ const controller = new AbortController();
866
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
867
+ // Some provider implementations may not honor the signal, so the boundary also races them.
868
+ return Promise.race([
869
+ fn(controller.signal),
870
+ new Promise((_, reject) => {
871
+ if (controller.signal.aborted) {
872
+ reject(new ProviderTimeoutError());
873
+ return;
874
+ }
875
+ controller.signal.addEventListener('abort', () => reject(new ProviderTimeoutError()), {
876
+ once: true,
877
+ });
878
+ }),
879
+ ]).finally(() => clearTimeout(timeout));
880
+ }
881
+ function errorCode(input) {
882
+ const result = schema.ErrorBody.safeParse(input);
883
+ if (!result.success)
884
+ return undefined;
885
+ const body = result.data;
886
+ const code = body._tag ??
887
+ body.code ??
888
+ body.errorCode ??
889
+ body.errorType ??
890
+ body.type ??
891
+ body.error?.code ??
892
+ body.error?.type;
893
+ const parsed = schema.ErrorCode.safeParse(code);
894
+ return parsed.success ? parsed.data : undefined;
895
+ }
896
+ function attemptResult(attempt) {
897
+ return {
898
+ durationMs: attempt.durationMs,
899
+ ...(attempt.outcome === 'failed'
900
+ ? {
901
+ failure: failure({
902
+ cause: attempt.cause,
903
+ operation: attempt.operation,
904
+ provider: attempt.provider,
905
+ }).failure,
906
+ }
907
+ : {}),
908
+ id: attempt.provider.id,
909
+ operation: attempt.operation,
910
+ outcome: attempt.outcome,
911
+ };
912
+ }
913
+ function resolveDestinationToken(input, catalog) {
914
+ const destinations = uniqueBy(catalog.routes.map((entry) => entry.route.destination), (token) => `${token.chain.id}:${token.address}`);
915
+ if (input === undefined) {
916
+ const destination = destinations.find((candidate) => candidate.slug === defaultDestinationToken);
917
+ if (!destination)
918
+ throw new UnsupportedDestinationTokenError();
919
+ return destination;
920
+ }
921
+ const destination = destinations.find((candidate) => matchesToken(candidate, input));
922
+ if (!destination)
923
+ throw new UnsupportedDestinationTokenError();
924
+ return destination;
925
+ }
926
+ function resolveProvider(input, providers) {
927
+ const provider = providers.find((candidate) => candidate.id === normalizeInput(input));
928
+ if (!provider)
929
+ throw new UnsupportedProviderError();
930
+ return provider;
931
+ }
932
+ function resolveSourceAmount(options) {
933
+ const amount = options.units === 'baseUnits'
934
+ ? parseBaseUnits(options.amount)
935
+ : parseDecimalUnits(options.amount, options.token.decimals);
936
+ return {
937
+ amount,
938
+ formatted: core_Value.format(BigInt(amount), options.token.decimals),
939
+ };
940
+ }
941
+ function resolveSourceToken(chain, input, catalog) {
942
+ const tokens = catalog.routes
943
+ .filter((entry) => entry.route.source.chain.id === chain.id)
944
+ .map((entry) => entry.route.source);
945
+ return tokens.find((token) => matchesToken(token, input));
946
+ }
947
+ function matchesToken(token, input) {
948
+ const trimmed = input.trim();
949
+ const normalized = normalizeInput(input);
950
+ return (token.slug === normalized ||
951
+ token.symbol.toLowerCase() === normalized ||
952
+ matchesTokenIdentifier(token.chain, token.address, trimmed, normalized) ||
953
+ matchesTokenIdentifier(token.chain, tokenKey(token), trimmed, normalized));
954
+ }
955
+ function matchesTokenIdentifier(chain, candidate, trimmed, normalized) {
956
+ return chain.kind === 'evm' ? candidate.toLowerCase() === normalized : candidate === trimmed;
957
+ }
958
+ function resolveSourceChain(input, catalog) {
959
+ const normalized = normalizeInput(input);
960
+ const chain = catalog.chainsByKey.get(normalized);
961
+ if (!chain || !catalog.routes.some((entry) => entry.route.source.chain.id === chain.id))
962
+ throw new UnsupportedSourceChainError();
963
+ return chain;
964
+ }
965
+ function getRoutes(catalog, providers) {
966
+ return providers.flatMap((provider) => (catalog.routesByProvider.get(provider.id) ?? []).map((route) => ({ provider, route })));
967
+ }
968
+ function uniqueBy(values, key) {
969
+ const seen = new Set();
970
+ return values.filter((value) => {
971
+ const id = key(value);
972
+ if (seen.has(id))
973
+ return false;
974
+ seen.add(id);
975
+ return true;
976
+ });
977
+ }
978
+ function normalizeAccountAddress(value, chain) {
979
+ if (chain.kind === 'evm')
980
+ return Address.validate(value, { strict: false }) ? Address.checksum(value) : undefined;
981
+ try {
982
+ const bytes = Base58.toBytes(value);
983
+ if (chain.kind === 'solana')
984
+ return bytes.length === 32 ? value : undefined;
985
+ if (bytes.length !== 25 || bytes[0] !== 0x41)
986
+ return undefined;
987
+ const payload = bytes.slice(0, 21);
988
+ const checksum = Hash.sha256(Hash.sha256(payload), { as: 'Bytes' }).slice(0, 4);
989
+ return Bytes.isEqual(bytes.slice(21), checksum) ? value : undefined;
990
+ }
991
+ catch {
992
+ return undefined;
993
+ }
994
+ }
995
+ /** Error thrown when the caller supplies an unsupported destination token. */
996
+ export class UnsupportedDestinationTokenError extends Error {
997
+ name = 'FundingProvider.UnsupportedDestinationTokenError';
998
+ }
999
+ /** Error thrown when a provider webhook cannot be authenticated. */
1000
+ export class WebhookAuthenticationError extends Error {
1001
+ name = 'FundingProvider.WebhookAuthenticationError';
1002
+ }
1003
+ /** Error thrown when an authenticated provider webhook has an invalid body. */
1004
+ export class WebhookPayloadError extends Error {
1005
+ name = 'FundingProvider.WebhookPayloadError';
1006
+ }
1007
+ /** Error thrown when the caller supplies an invalid source amount. */
1008
+ export class InvalidAmountError extends Error {
1009
+ name = 'FundingProvider.InvalidAmountError';
1010
+ }
1011
+ /** Error thrown when the caller supplies an invalid source-chain refund address. */
1012
+ export class InvalidRefundAddressError extends Error {
1013
+ name = 'FundingProvider.InvalidRefundAddressError';
1014
+ }
1015
+ /** Error thrown when provider deployment configuration is invalid. */
1016
+ export class ProviderConfigurationError extends Error {
1017
+ name = 'FundingProvider.ProviderConfigurationError';
1018
+ }
1019
+ /** Error thrown when a provider response does not match the requested quote. */
1020
+ export class ProviderPayloadError extends Error {
1021
+ name = 'FundingProvider.ProviderPayloadError';
1022
+ }
1023
+ /** Error thrown when a provider confirms that no executable route is available. */
1024
+ export class ProviderUnavailableError extends Error {
1025
+ name = 'FundingProvider.ProviderUnavailableError';
1026
+ }
1027
+ /** Error thrown internally when a provider exceeds its quote timeout. */
1028
+ export class ProviderTimeoutError extends Error {
1029
+ name = 'FundingProvider.ProviderTimeoutError';
1030
+ }
1031
+ /** Error thrown when an internal provider quota rejects a quote request. */
1032
+ export class ProviderRateLimitError extends Error {
1033
+ name = 'FundingProvider.ProviderRateLimitError';
1034
+ }
1035
+ /** Error thrown when a provider returns an unsuccessful HTTP response. */
1036
+ export class ProviderResponseError extends Error {
1037
+ status;
1038
+ body;
1039
+ name = 'FundingProvider.ProviderResponseError';
1040
+ constructor(
1041
+ /** Provider response status. */
1042
+ status,
1043
+ /** Parsed provider response body. */
1044
+ body) {
1045
+ super(`Provider request failed with status ${status}`);
1046
+ this.status = status;
1047
+ this.body = body;
1048
+ }
1049
+ }
1050
+ /** Error thrown when every matching provider fails to produce a quote. */
1051
+ export class ProviderQuoteError extends Error {
1052
+ name = 'FundingProvider.ProviderQuoteError';
1053
+ /** Provider failures that prevented a successful quote. */
1054
+ failures;
1055
+ /** Bounded provider attempts retained for request logs. */
1056
+ fundingProviderAttempts;
1057
+ /** First bounded provider failure retained for request logs. */
1058
+ providerFailure;
1059
+ /** Bounded provider failures retained when multiple providers failed. */
1060
+ providerFailures;
1061
+ constructor(failures, attempts = []) {
1062
+ super();
1063
+ this.failures = failures;
1064
+ this.fundingProviderAttempts = attempts.map(attemptResult);
1065
+ const values = failures.map(failure);
1066
+ const first = values[0];
1067
+ if (first)
1068
+ this.providerFailure = first;
1069
+ if (values.length > 1)
1070
+ this.providerFailures = values;
1071
+ }
1072
+ }
1073
+ /** Error thrown when the caller filters to an unknown provider. */
1074
+ export class UnsupportedProviderError extends Error {
1075
+ name = 'FundingProvider.UnsupportedProviderError';
1076
+ }
1077
+ /** Error thrown when the caller supplies an unsupported source chain. */
1078
+ export class UnsupportedSourceChainError extends Error {
1079
+ name = 'FundingProvider.UnsupportedSourceChainError';
1080
+ }
1081
+ //# sourceMappingURL=Provider.js.map