tapimo 0.7.0 → 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 (689) 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 +151 -95
  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 +14377 -10165
  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 +1231 -324
  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.map +1 -1
  78. package/dist/apps/data/routes/fee-amm.js +59 -8
  79. package/dist/apps/data/routes/fee-amm.js.map +1 -1
  80. package/dist/apps/data/routes/funding.d.ts +4092 -387
  81. package/dist/apps/data/routes/funding.d.ts.map +1 -1
  82. package/dist/apps/data/routes/funding.js +1403 -256
  83. package/dist/apps/data/routes/funding.js.map +1 -1
  84. package/dist/apps/data/routes/indexer.d.ts +5 -5
  85. package/dist/apps/data/routes/indexer.d.ts.map +1 -1
  86. package/dist/apps/data/routes/indexer.js +19 -2
  87. package/dist/apps/data/routes/indexer.js.map +1 -1
  88. package/dist/apps/data/routes/receipts.d.ts +265 -265
  89. package/dist/apps/data/routes/receipts.d.ts.map +1 -1
  90. package/dist/apps/data/routes/receipts.js +11 -11
  91. package/dist/apps/data/routes/receipts.js.map +1 -1
  92. package/dist/apps/data/routes/rpc.d.ts +5 -5
  93. package/dist/apps/data/routes/rpc.d.ts.map +1 -1
  94. package/dist/apps/data/routes/rpc.js +211 -22
  95. package/dist/apps/data/routes/rpc.js.map +1 -1
  96. package/dist/apps/data/routes/tokenlist.d.ts +36 -36
  97. package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
  98. package/dist/apps/data/routes/tokenlist.js +49 -9
  99. package/dist/apps/data/routes/tokenlist.js.map +1 -1
  100. package/dist/apps/data/routes/tokens.d.ts +116 -88
  101. package/dist/apps/data/routes/tokens.d.ts.map +1 -1
  102. package/dist/apps/data/routes/tokens.js +198 -91
  103. package/dist/apps/data/routes/tokens.js.map +1 -1
  104. package/dist/apps/data/routes/transactions.d.ts +55 -55
  105. package/dist/apps/data/routes/transactions.d.ts.map +1 -1
  106. package/dist/apps/data/routes/transactions.js +78 -39
  107. package/dist/apps/data/routes/transactions.js.map +1 -1
  108. package/dist/apps/data/routes/transfers.d.ts +78 -29
  109. package/dist/apps/data/routes/transfers.d.ts.map +1 -1
  110. package/dist/apps/data/routes/transfers.js +165 -67
  111. package/dist/apps/data/routes/transfers.js.map +1 -1
  112. package/dist/apps/data/routes/valuation.d.ts +10 -10
  113. package/dist/apps/data/routes/valuation.js +2 -2
  114. package/dist/apps/data/routes/valuation.js.map +1 -1
  115. package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -1
  116. package/dist/apps/data/routes/verified-tokens.js +34 -9
  117. package/dist/apps/data/routes/verified-tokens.js.map +1 -1
  118. package/dist/apps/data/routes/webhooks.d.ts +5 -3
  119. package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
  120. package/dist/apps/data/routes/webhooks.js +175 -65
  121. package/dist/apps/data/routes/webhooks.js.map +1 -1
  122. package/dist/apps/data/routes/zones.d.ts +281 -0
  123. package/dist/apps/data/routes/zones.d.ts.map +1 -0
  124. package/dist/apps/data/routes/zones.js +252 -0
  125. package/dist/apps/data/routes/zones.js.map +1 -0
  126. package/dist/apps/docs/reference.js +6 -5
  127. package/dist/apps/docs/reference.js.map +1 -1
  128. package/dist/apps/index.d.ts +2 -1
  129. package/dist/apps/index.d.ts.map +1 -1
  130. package/dist/apps/index.js +2 -1
  131. package/dist/apps/index.js.map +1 -1
  132. package/dist/apps/management/App.d.ts +670 -670
  133. package/dist/apps/management/Billing.d.ts +8 -0
  134. package/dist/apps/management/Billing.d.ts.map +1 -1
  135. package/dist/apps/management/Billing.js +12 -0
  136. package/dist/apps/management/Billing.js.map +1 -1
  137. package/dist/apps/management/Error.d.ts +12 -0
  138. package/dist/apps/management/Error.d.ts.map +1 -0
  139. package/dist/apps/management/Error.js +10 -0
  140. package/dist/apps/management/Error.js.map +1 -0
  141. package/dist/apps/management/routes/api-keys.d.ts +5 -5
  142. package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
  143. package/dist/apps/management/routes/api-keys.js +2 -8
  144. package/dist/apps/management/routes/api-keys.js.map +1 -1
  145. package/dist/apps/management/routes/billing.d.ts +119 -119
  146. package/dist/apps/management/routes/faucet.d.ts +35 -35
  147. package/dist/apps/management/routes/invitations.d.ts +62 -62
  148. package/dist/apps/management/routes/invitations.d.ts.map +1 -1
  149. package/dist/apps/management/routes/invitations.js +4 -10
  150. package/dist/apps/management/routes/invitations.js.map +1 -1
  151. package/dist/apps/management/routes/invite-links.d.ts +30 -30
  152. package/dist/apps/management/routes/me.d.ts +6 -6
  153. package/dist/apps/management/routes/members.d.ts +78 -78
  154. package/dist/apps/management/routes/orgs.d.ts +48 -48
  155. package/dist/apps/management/routes/orgs.d.ts.map +1 -1
  156. package/dist/apps/management/routes/orgs.js +2 -8
  157. package/dist/apps/management/routes/orgs.js.map +1 -1
  158. package/dist/apps/management/routes/projects.d.ts +9 -9
  159. package/dist/apps/management/routes/scopes.js +2 -2
  160. package/dist/apps/management/routes/scopes.js.map +1 -1
  161. package/dist/apps/management/routes/usage.d.ts +80 -80
  162. package/dist/apps/management/routes/verified-token-requests.d.ts +36 -36
  163. package/dist/apps/management/routes/webhooks.d.ts +50 -50
  164. package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
  165. package/dist/apps/management/routes/webhooks.js +15 -3
  166. package/dist/apps/management/routes/webhooks.js.map +1 -1
  167. package/dist/apps/mpp/App.d.ts +55 -56
  168. package/dist/apps/mpp/App.d.ts.map +1 -1
  169. package/dist/apps/mpp/App.js +192 -27
  170. package/dist/apps/mpp/App.js.map +1 -1
  171. package/dist/apps/mpp/Mpp.d.ts +0 -20
  172. package/dist/apps/mpp/Mpp.d.ts.map +1 -1
  173. package/dist/apps/mpp/Mpp.js +0 -24
  174. package/dist/apps/mpp/Mpp.js.map +1 -1
  175. package/dist/apps/mpp/internal/Adapter.d.ts +40 -0
  176. package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -0
  177. package/dist/apps/mpp/internal/Adapter.js +66 -0
  178. package/dist/apps/mpp/internal/Adapter.js.map +1 -0
  179. package/dist/apps/mpp/internal/Error.d.ts +4 -0
  180. package/dist/apps/mpp/internal/Error.d.ts.map +1 -0
  181. package/dist/apps/mpp/internal/Error.js +41 -0
  182. package/dist/apps/mpp/internal/Error.js.map +1 -0
  183. package/dist/apps/mpp/internal/Idempotency.d.ts +33 -0
  184. package/dist/apps/mpp/internal/Idempotency.d.ts.map +1 -0
  185. package/dist/apps/mpp/internal/Idempotency.js +28 -0
  186. package/dist/apps/mpp/internal/Idempotency.js.map +1 -0
  187. package/dist/apps/mpp/internal/Policy.d.ts +46 -0
  188. package/dist/apps/mpp/internal/Policy.d.ts.map +1 -0
  189. package/dist/apps/mpp/internal/Policy.js +57 -0
  190. package/dist/apps/mpp/internal/Policy.js.map +1 -0
  191. package/dist/apps/mpp/internal/ScreenManager.d.ts +27 -0
  192. package/dist/apps/mpp/internal/ScreenManager.d.ts.map +1 -0
  193. package/dist/apps/mpp/internal/ScreenManager.js +18 -0
  194. package/dist/apps/mpp/internal/ScreenManager.js.map +1 -0
  195. package/dist/apps/mpp/internal/Screening.d.ts +35 -0
  196. package/dist/apps/mpp/internal/Screening.d.ts.map +1 -0
  197. package/dist/apps/mpp/internal/Screening.js +20 -0
  198. package/dist/apps/mpp/internal/Screening.js.map +1 -0
  199. package/dist/apps/mpp/internal/Sponsorship.d.ts +36 -0
  200. package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -0
  201. package/dist/apps/mpp/internal/Sponsorship.js +103 -0
  202. package/dist/apps/mpp/internal/Sponsorship.js.map +1 -0
  203. package/dist/apps/mpp/internal/Utils.d.ts +7 -0
  204. package/dist/apps/mpp/internal/Utils.d.ts.map +1 -0
  205. package/dist/apps/mpp/internal/Utils.js +24 -0
  206. package/dist/apps/mpp/internal/Utils.js.map +1 -0
  207. package/dist/apps/relay/App.js +184 -24
  208. package/dist/apps/relay/App.js.map +1 -1
  209. package/dist/apps/relay/Sponsorships.d.ts +4 -0
  210. package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
  211. package/dist/apps/relay/Sponsorships.js +16 -7
  212. package/dist/apps/relay/Sponsorships.js.map +1 -1
  213. package/dist/db/Db.d.ts +20 -0
  214. package/dist/db/Db.d.ts.map +1 -1
  215. package/dist/db/Db.js +342 -0
  216. package/dist/db/Db.js.map +1 -1
  217. package/dist/db/Schema.d.ts +921 -1
  218. package/dist/db/Schema.d.ts.map +1 -1
  219. package/dist/db/Schema.js +269 -1
  220. package/dist/db/Schema.js.map +1 -1
  221. package/dist/db/tables/earnVaults.d.ts +68 -0
  222. package/dist/db/tables/earnVaults.d.ts.map +1 -0
  223. package/dist/db/tables/earnVaults.js +72 -0
  224. package/dist/db/tables/earnVaults.js.map +1 -0
  225. package/dist/db/tables/fundingCatalog.d.ts +56 -0
  226. package/dist/db/tables/fundingCatalog.d.ts.map +1 -0
  227. package/dist/db/tables/fundingCatalog.js +85 -0
  228. package/dist/db/tables/fundingCatalog.js.map +1 -0
  229. package/dist/db/tables/fundingDepositAddresses.d.ts +159 -0
  230. package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -0
  231. package/dist/db/tables/fundingDepositAddresses.js +206 -0
  232. package/dist/db/tables/fundingDepositAddresses.js.map +1 -0
  233. package/dist/db/tables/fundingDeposits.d.ts +115 -0
  234. package/dist/db/tables/fundingDeposits.d.ts.map +1 -0
  235. package/dist/db/tables/fundingDeposits.js +100 -0
  236. package/dist/db/tables/fundingDeposits.js.map +1 -0
  237. package/dist/db/tables/fundingIdempotency.d.ts +91 -0
  238. package/dist/db/tables/fundingIdempotency.d.ts.map +1 -0
  239. package/dist/db/tables/fundingIdempotency.js +103 -0
  240. package/dist/db/tables/fundingIdempotency.js.map +1 -0
  241. package/dist/db/tables/fundingTransferEvents.d.ts +12 -0
  242. package/dist/db/tables/fundingTransferEvents.d.ts.map +1 -0
  243. package/dist/db/tables/fundingTransferEvents.js +18 -0
  244. package/dist/db/tables/fundingTransferEvents.js.map +1 -0
  245. package/dist/db/tables/fundingTransferTransactions.d.ts +15 -0
  246. package/dist/db/tables/fundingTransferTransactions.d.ts.map +1 -0
  247. package/dist/db/tables/fundingTransferTransactions.js +27 -0
  248. package/dist/db/tables/fundingTransferTransactions.js.map +1 -0
  249. package/dist/db/tables/fundingTransfers.d.ts +82 -0
  250. package/dist/db/tables/fundingTransfers.d.ts.map +1 -0
  251. package/dist/db/tables/fundingTransfers.js +89 -0
  252. package/dist/db/tables/fundingTransfers.js.map +1 -0
  253. package/dist/db/tables/organizations.d.ts +8 -0
  254. package/dist/db/tables/organizations.d.ts.map +1 -1
  255. package/dist/db/tables/organizations.js +35 -0
  256. package/dist/db/tables/organizations.js.map +1 -1
  257. package/dist/db/tables/projects.d.ts +8 -0
  258. package/dist/db/tables/projects.d.ts.map +1 -1
  259. package/dist/db/tables/projects.js +16 -0
  260. package/dist/db/tables/projects.js.map +1 -1
  261. package/dist/db/tables/requestUsage.d.ts +13 -0
  262. package/dist/db/tables/requestUsage.d.ts.map +1 -1
  263. package/dist/db/tables/requestUsage.js +16 -0
  264. package/dist/db/tables/requestUsage.js.map +1 -1
  265. package/dist/db/tables/sponsoredTransactions.d.ts +4 -2
  266. package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
  267. package/dist/db/tables/sponsoredTransactions.js +14 -4
  268. package/dist/db/tables/sponsoredTransactions.js.map +1 -1
  269. package/dist/db/tables/users.d.ts +8 -0
  270. package/dist/db/tables/users.d.ts.map +1 -1
  271. package/dist/db/tables/users.js +16 -0
  272. package/dist/db/tables/users.js.map +1 -1
  273. package/dist/db/tables/verifiedTokens.d.ts +14 -7
  274. package/dist/db/tables/verifiedTokens.d.ts.map +1 -1
  275. package/dist/db/tables/verifiedTokens.js +9 -7
  276. package/dist/db/tables/verifiedTokens.js.map +1 -1
  277. package/dist/db/tables/webhookSubscriptions.d.ts +31 -1
  278. package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
  279. package/dist/db/tables/webhookSubscriptions.js +24 -3
  280. package/dist/db/tables/webhookSubscriptions.js.map +1 -1
  281. package/dist/handlers/relay.js +108 -108
  282. package/dist/handlers/relay.js.map +1 -1
  283. package/dist/internal/Auth.d.ts +26 -0
  284. package/dist/internal/Auth.d.ts.map +1 -1
  285. package/dist/internal/Auth.js +35 -2
  286. package/dist/internal/Auth.js.map +1 -1
  287. package/dist/internal/Cache.d.ts.map +1 -1
  288. package/dist/internal/Cache.js +16 -10
  289. package/dist/internal/Cache.js.map +1 -1
  290. package/dist/internal/Cursor.js +1 -1
  291. package/dist/internal/Cursor.js.map +1 -1
  292. package/dist/internal/EarnRates.d.ts +89 -0
  293. package/dist/internal/EarnRates.d.ts.map +1 -0
  294. package/dist/internal/EarnRates.js +266 -0
  295. package/dist/internal/EarnRates.js.map +1 -0
  296. package/dist/internal/EarnVaults.d.ts +171 -0
  297. package/dist/internal/EarnVaults.d.ts.map +1 -0
  298. package/dist/internal/EarnVaults.js +547 -0
  299. package/dist/internal/EarnVaults.js.map +1 -0
  300. package/dist/internal/EdgeCache.d.ts +9 -2
  301. package/dist/internal/EdgeCache.d.ts.map +1 -1
  302. package/dist/internal/EdgeCache.js +36 -9
  303. package/dist/internal/EdgeCache.js.map +1 -1
  304. package/dist/internal/Id.d.ts +11 -0
  305. package/dist/internal/Id.d.ts.map +1 -1
  306. package/dist/internal/Id.js +13 -0
  307. package/dist/internal/Id.js.map +1 -1
  308. package/dist/internal/Idempotency.d.ts +83 -0
  309. package/dist/internal/Idempotency.d.ts.map +1 -0
  310. package/dist/internal/Idempotency.js +113 -0
  311. package/dist/internal/Idempotency.js.map +1 -0
  312. package/dist/internal/Log.d.ts +64 -9
  313. package/dist/internal/Log.d.ts.map +1 -1
  314. package/dist/internal/Log.js +29 -7
  315. package/dist/internal/Log.js.map +1 -1
  316. package/dist/internal/MetricSink.d.ts.map +1 -1
  317. package/dist/internal/MetricSink.js +47 -1
  318. package/dist/internal/MetricSink.js.map +1 -1
  319. package/dist/internal/OpenApi.d.ts +1 -1
  320. package/dist/internal/OpenApi.d.ts.map +1 -1
  321. package/dist/internal/OpenApi.js +3 -0
  322. package/dist/internal/OpenApi.js.map +1 -1
  323. package/dist/internal/Provider.d.ts +14 -0
  324. package/dist/internal/Provider.d.ts.map +1 -0
  325. package/dist/internal/Provider.js +5 -0
  326. package/dist/internal/Provider.js.map +1 -0
  327. package/dist/internal/Schema.d.ts +8 -3
  328. package/dist/internal/Schema.d.ts.map +1 -1
  329. package/dist/internal/Schema.js +24 -13
  330. package/dist/internal/Schema.js.map +1 -1
  331. package/dist/internal/Store.d.ts +6 -0
  332. package/dist/internal/Store.d.ts.map +1 -1
  333. package/dist/internal/Store.js +35 -0
  334. package/dist/internal/Store.js.map +1 -1
  335. package/dist/internal/Tidx.d.ts +43 -24
  336. package/dist/internal/Tidx.d.ts.map +1 -1
  337. package/dist/internal/Tidx.js +79 -11
  338. package/dist/internal/Tidx.js.map +1 -1
  339. package/dist/internal/Viem.d.ts +82 -65
  340. package/dist/internal/Viem.d.ts.map +1 -1
  341. package/dist/internal/Viem.js +83 -12
  342. package/dist/internal/Viem.js.map +1 -1
  343. package/dist/internal/WebhookDestination.d.ts.map +1 -1
  344. package/dist/internal/WebhookDestination.js +34 -28
  345. package/dist/internal/WebhookDestination.js.map +1 -1
  346. package/dist/internal/Webhooks.d.ts +9 -0
  347. package/dist/internal/Webhooks.d.ts.map +1 -1
  348. package/dist/internal/Webhooks.js +15 -10
  349. package/dist/internal/Webhooks.js.map +1 -1
  350. package/dist/internal/exchange/Provider.d.ts +219 -0
  351. package/dist/internal/exchange/Provider.d.ts.map +1 -0
  352. package/dist/internal/exchange/Provider.js +117 -0
  353. package/dist/internal/exchange/Provider.js.map +1 -0
  354. package/dist/internal/exchange/index.d.ts +2 -0
  355. package/dist/internal/exchange/index.d.ts.map +1 -0
  356. package/dist/internal/exchange/index.js +2 -0
  357. package/dist/internal/exchange/index.js.map +1 -0
  358. package/dist/internal/exchange/providers/uniswap.d.ts +57 -0
  359. package/dist/internal/exchange/providers/uniswap.d.ts.map +1 -0
  360. package/dist/internal/exchange/providers/uniswap.js +553 -0
  361. package/dist/internal/exchange/providers/uniswap.js.map +1 -0
  362. package/dist/internal/funding/Action.d.ts +55 -0
  363. package/dist/internal/funding/Action.d.ts.map +1 -0
  364. package/dist/internal/funding/Action.js +74 -0
  365. package/dist/internal/funding/Action.js.map +1 -0
  366. package/dist/internal/funding/Catalog.d.ts +107 -0
  367. package/dist/internal/funding/Catalog.d.ts.map +1 -0
  368. package/dist/internal/funding/Catalog.js +270 -0
  369. package/dist/internal/funding/Catalog.js.map +1 -0
  370. package/dist/internal/funding/Chain.d.ts +76 -0
  371. package/dist/internal/funding/Chain.d.ts.map +1 -0
  372. package/dist/internal/funding/Chain.js +38 -0
  373. package/dist/internal/funding/Chain.js.map +1 -0
  374. package/dist/internal/funding/Deposit.d.ts +366 -0
  375. package/dist/internal/funding/Deposit.d.ts.map +1 -0
  376. package/dist/internal/funding/Deposit.js +286 -0
  377. package/dist/internal/funding/Deposit.js.map +1 -0
  378. package/dist/internal/funding/DepositAddress.d.ts +345 -0
  379. package/dist/internal/funding/DepositAddress.d.ts.map +1 -0
  380. package/dist/internal/funding/DepositAddress.js +189 -0
  381. package/dist/internal/funding/DepositAddress.js.map +1 -0
  382. package/dist/internal/funding/Evidence.d.ts +52 -0
  383. package/dist/internal/funding/Evidence.d.ts.map +1 -0
  384. package/dist/internal/funding/Evidence.js +314 -0
  385. package/dist/internal/funding/Evidence.js.map +1 -0
  386. package/dist/internal/funding/Provider.d.ts +1186 -0
  387. package/dist/internal/funding/Provider.d.ts.map +1 -0
  388. package/dist/internal/funding/Provider.js +1081 -0
  389. package/dist/internal/funding/Provider.js.map +1 -0
  390. package/dist/internal/funding/Reconciliation.d.ts +113 -0
  391. package/dist/internal/funding/Reconciliation.d.ts.map +1 -0
  392. package/dist/internal/funding/Reconciliation.js +676 -0
  393. package/dist/internal/funding/Reconciliation.js.map +1 -0
  394. package/dist/internal/funding/Route.d.ts +21 -0
  395. package/dist/internal/funding/Route.d.ts.map +1 -0
  396. package/dist/internal/funding/Route.js +5 -0
  397. package/dist/internal/funding/Route.js.map +1 -0
  398. package/dist/internal/funding/Subsidy.d.ts +113 -0
  399. package/dist/internal/funding/Subsidy.d.ts.map +1 -0
  400. package/dist/internal/funding/Subsidy.js +138 -0
  401. package/dist/internal/funding/Subsidy.js.map +1 -0
  402. package/dist/internal/funding/Token.d.ts +41 -0
  403. package/dist/internal/funding/Token.d.ts.map +1 -0
  404. package/dist/internal/funding/Token.js +22 -0
  405. package/dist/internal/funding/Token.js.map +1 -0
  406. package/dist/internal/funding/Transfer.d.ts +643 -0
  407. package/dist/internal/funding/Transfer.d.ts.map +1 -0
  408. package/dist/internal/funding/Transfer.js +332 -0
  409. package/dist/internal/funding/Transfer.js.map +1 -0
  410. package/dist/internal/funding/index.d.ts +13 -0
  411. package/dist/internal/funding/index.d.ts.map +1 -0
  412. package/dist/internal/funding/index.js +13 -0
  413. package/dist/internal/funding/index.js.map +1 -0
  414. package/dist/internal/funding/providers/across.d.ts +21 -0
  415. package/dist/internal/funding/providers/across.d.ts.map +1 -0
  416. package/dist/internal/funding/providers/across.js +117 -0
  417. package/dist/internal/funding/providers/across.js.map +1 -0
  418. package/dist/internal/funding/providers/relay.d.ts +46 -0
  419. package/dist/internal/funding/providers/relay.d.ts.map +1 -0
  420. package/dist/internal/funding/providers/relay.js +464 -0
  421. package/dist/internal/funding/providers/relay.js.map +1 -0
  422. package/dist/internal/funding/providers/rhino.d.ts +15 -0
  423. package/dist/internal/funding/providers/rhino.d.ts.map +1 -0
  424. package/dist/internal/funding/providers/rhino.js +116 -0
  425. package/dist/internal/funding/providers/rhino.js.map +1 -0
  426. package/dist/internal/funding/providers/squid.d.ts +19 -0
  427. package/dist/internal/funding/providers/squid.d.ts.map +1 -0
  428. package/dist/internal/funding/providers/squid.js +120 -0
  429. package/dist/internal/funding/providers/squid.js.map +1 -0
  430. package/dist/internal/funding/providers/symbiosis.d.ts +20 -0
  431. package/dist/internal/funding/providers/symbiosis.d.ts.map +1 -0
  432. package/dist/internal/funding/providers/symbiosis.js +176 -0
  433. package/dist/internal/funding/providers/symbiosis.js.map +1 -0
  434. package/dist/internal/index.d.ts +5 -1
  435. package/dist/internal/index.d.ts.map +1 -1
  436. package/dist/internal/index.js +5 -1
  437. package/dist/internal/index.js.map +1 -1
  438. package/dist/internal/webhookDestinations/url.js +61 -57
  439. package/dist/internal/webhookDestinations/url.js.map +1 -1
  440. package/dist/providers/index.d.ts +43 -0
  441. package/dist/providers/index.d.ts.map +1 -0
  442. package/dist/providers/index.js +19 -0
  443. package/dist/providers/index.js.map +1 -0
  444. package/package.json +9 -4
  445. package/src/ApiKeys.test.ts +11 -7
  446. package/src/ApiKeys.ts +37 -9
  447. package/src/App.test.ts +85 -10
  448. package/src/App.ts +224 -137
  449. package/src/Assets.ts +29 -4
  450. package/src/Client.test-d.ts +650 -30
  451. package/src/Scope.test.ts +19 -0
  452. package/src/Scope.ts +28 -11
  453. package/src/Webhooks.test.ts +25 -0
  454. package/src/Webhooks.ts +1 -1
  455. package/src/admin/App.test.ts +9 -2
  456. package/src/admin/App.ts +32 -9
  457. package/src/admin/apps/api-keys.test.ts +167 -23
  458. package/src/admin/apps/api-keys.ts +166 -28
  459. package/src/admin/apps/earn-vaults.test.ts +338 -0
  460. package/src/admin/apps/earn-vaults.ts +572 -0
  461. package/src/admin/apps/scopes.test.ts +16 -1
  462. package/src/admin/ui/plugin.ts +2 -2
  463. package/src/admin/ui/src/components/EarnVaultForm.tsx +137 -0
  464. package/src/admin/ui/src/components/MobileProfile.tsx +2 -2
  465. package/src/admin/ui/src/components/Page.tsx +1 -1
  466. package/src/admin/ui/src/components/ThemeToggle.tsx +1 -1
  467. package/src/admin/ui/src/lib/api-keys.ts +37 -7
  468. package/src/admin/ui/src/lib/client.ts +1 -1
  469. package/src/admin/ui/src/lib/config.ts +1 -1
  470. package/src/admin/ui/src/lib/early-access.ts +8 -9
  471. package/src/admin/ui/src/lib/earn-vaults.ts +207 -0
  472. package/src/admin/ui/src/lib/format.ts +13 -0
  473. package/src/admin/ui/src/lib/organizations.test.ts +14 -4
  474. package/src/admin/ui/src/lib/organizations.ts +7 -1
  475. package/src/admin/ui/src/lib/response.ts +22 -0
  476. package/src/admin/ui/src/lib/scopes.test.ts +19 -11
  477. package/src/admin/ui/src/lib/scopes.ts +28 -7
  478. package/src/admin/ui/src/lib/verified-tokens.ts +10 -9
  479. package/src/admin/ui/src/routeTree.gen.ts +70 -7
  480. package/src/admin/ui/src/router.tsx +2 -2
  481. package/src/admin/ui/src/routes/__root.tsx +9 -8
  482. package/src/admin/ui/src/routes/api-keys.tsx +475 -64
  483. package/src/admin/ui/src/routes/early-access.tsx +5 -12
  484. package/src/admin/ui/src/routes/earn.vaults.tsx +348 -0
  485. package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +154 -0
  486. package/src/admin/ui/src/routes/earn.vaults_.new.tsx +190 -0
  487. package/src/admin/ui/src/routes/organizations.tsx +4 -7
  488. package/src/admin/ui/src/routes/organizations_.$orgId.tsx +56 -54
  489. package/src/admin/ui/src/routes/verified-tokens.tsx +4 -4
  490. package/src/admin/ui/vite.config.ts +4 -1
  491. package/src/admin/ui.generated.ts +189 -95
  492. package/src/analytics/Analytics.test.ts +69 -10
  493. package/src/analytics/Analytics.ts +20 -1
  494. package/src/analytics/tables/requestEvents.ts +79 -37
  495. package/src/apps/Zones.test.ts +33 -0
  496. package/src/apps/Zones.ts +40 -0
  497. package/src/apps/composition.test.ts +84 -1
  498. package/src/apps/data/App.test.ts +38 -9
  499. package/src/apps/data/App.ts +96 -33
  500. package/src/apps/data/FxOracle.ts +1 -1
  501. package/src/apps/data/index.ts +0 -1
  502. package/src/apps/data/routes/activities.test.ts +82 -6
  503. package/src/apps/data/routes/activities.ts +131 -71
  504. package/src/apps/data/routes/balances.test.ts +50 -37
  505. package/src/apps/data/routes/balances.ts +5 -5
  506. package/src/apps/data/routes/blocks.test.ts +2 -0
  507. package/src/apps/data/routes/coingecko.test.ts +22 -0
  508. package/src/apps/data/routes/coingecko.ts +84 -48
  509. package/src/apps/data/routes/earn.test.ts +1108 -0
  510. package/src/apps/data/routes/earn.ts +1391 -0
  511. package/src/apps/data/routes/exchanges.test.ts +82 -33
  512. package/src/apps/data/routes/exchanges.ts +842 -227
  513. package/src/apps/data/routes/fee-amm.test.ts +4 -6
  514. package/src/apps/data/routes/fee-amm.ts +69 -12
  515. package/src/apps/data/routes/funding.test.ts +2712 -221
  516. package/src/apps/data/routes/funding.ts +1604 -387
  517. package/src/apps/data/routes/indexer.test.ts +43 -34
  518. package/src/apps/data/routes/indexer.ts +19 -2
  519. package/src/apps/data/routes/receipts.test.ts +5 -3
  520. package/src/apps/data/routes/receipts.ts +13 -11
  521. package/src/apps/data/routes/rpc.test.ts +446 -28
  522. package/src/apps/data/routes/rpc.ts +243 -25
  523. package/src/apps/data/routes/tokenlist.test.ts +15 -0
  524. package/src/apps/data/routes/tokenlist.ts +88 -22
  525. package/src/apps/data/routes/tokens.ts +262 -86
  526. package/src/apps/data/routes/transactions.test.ts +2 -0
  527. package/src/apps/data/routes/transactions.ts +77 -42
  528. package/src/apps/data/routes/transfers.test.ts +166 -4
  529. package/src/apps/data/routes/transfers.ts +216 -78
  530. package/src/apps/data/routes/valuation.test.ts +62 -9
  531. package/src/apps/data/routes/valuation.ts +2 -2
  532. package/src/apps/data/routes/verified-tokens.test.ts +51 -0
  533. package/src/apps/data/routes/verified-tokens.ts +52 -15
  534. package/src/apps/data/routes/webhooks.test.ts +432 -33
  535. package/src/apps/data/routes/webhooks.ts +189 -79
  536. package/src/apps/data/routes/zones.test.ts +473 -0
  537. package/src/apps/data/routes/zones.ts +338 -0
  538. package/src/apps/docs/reference.ts +8 -6
  539. package/src/apps/index.ts +2 -1
  540. package/src/apps/management/Billing.test.ts +29 -0
  541. package/src/apps/management/Billing.ts +23 -0
  542. package/src/apps/management/Error.ts +12 -0
  543. package/src/apps/management/routes/api-keys.test.ts +5 -3
  544. package/src/apps/management/routes/api-keys.ts +2 -9
  545. package/src/apps/management/routes/invitations.ts +4 -11
  546. package/src/apps/management/routes/orgs.ts +2 -9
  547. package/src/apps/management/routes/scopes.test.ts +7 -2
  548. package/src/apps/management/routes/scopes.ts +2 -2
  549. package/src/apps/management/routes/webhooks.test.ts +6 -1
  550. package/src/apps/management/routes/webhooks.ts +15 -3
  551. package/src/apps/mpp/App.ts +276 -29
  552. package/src/apps/mpp/Mpp.test.ts +631 -26
  553. package/src/apps/mpp/Mpp.ts +0 -42
  554. package/src/apps/mpp/internal/Adapter.ts +108 -3
  555. package/src/apps/mpp/internal/Error.test.ts +33 -0
  556. package/src/apps/mpp/internal/Error.ts +44 -6
  557. package/src/apps/mpp/internal/Idempotency.test.ts +213 -0
  558. package/src/apps/mpp/internal/Idempotency.ts +59 -5
  559. package/src/apps/mpp/internal/Policy.test.ts +122 -0
  560. package/src/apps/mpp/internal/Policy.ts +98 -0
  561. package/src/apps/mpp/internal/ScreenManager.test.ts +68 -0
  562. package/src/apps/mpp/internal/ScreenManager.ts +41 -0
  563. package/src/apps/mpp/internal/Screening.ts +40 -3
  564. package/src/apps/mpp/internal/Sponsorship.ts +144 -0
  565. package/src/apps/mpp/internal/Utils.ts +30 -0
  566. package/src/apps/relay/App.test.ts +495 -64
  567. package/src/apps/relay/App.ts +234 -24
  568. package/src/apps/relay/Sponsorships.test.ts +51 -0
  569. package/src/apps/relay/Sponsorships.ts +19 -7
  570. package/src/db/Db.ts +439 -0
  571. package/src/db/Schema.ts +325 -2
  572. package/src/db/tables/earnVaults.test.ts +185 -0
  573. package/src/db/tables/earnVaults.ts +151 -0
  574. package/src/db/tables/fundingCatalog.test.ts +108 -0
  575. package/src/db/tables/fundingCatalog.ts +157 -0
  576. package/src/db/tables/fundingDepositAddresses.test.ts +580 -0
  577. package/src/db/tables/fundingDepositAddresses.ts +376 -0
  578. package/src/db/tables/fundingDeposits.test.ts +261 -0
  579. package/src/db/tables/fundingDeposits.ts +229 -0
  580. package/src/db/tables/fundingIdempotency.test.ts +182 -0
  581. package/src/db/tables/fundingIdempotency.ts +180 -0
  582. package/src/db/tables/fundingTransferEvents.ts +28 -0
  583. package/src/db/tables/fundingTransferTransactions.test.ts +69 -0
  584. package/src/db/tables/fundingTransferTransactions.ts +37 -0
  585. package/src/db/tables/fundingTransfers.test.ts +89 -0
  586. package/src/db/tables/fundingTransfers.ts +153 -0
  587. package/src/db/tables/organizations.test.ts +88 -0
  588. package/src/db/tables/organizations.ts +42 -1
  589. package/src/db/tables/projects.ts +16 -0
  590. package/src/db/tables/requestUsage.ts +23 -0
  591. package/src/db/tables/sponsoredTransactions.test.ts +52 -2
  592. package/src/db/tables/sponsoredTransactions.ts +18 -6
  593. package/src/db/tables/users.ts +16 -0
  594. package/src/db/tables/verifiedTokens.ts +19 -14
  595. package/src/db/tables/webhookSubscriptions.ts +58 -3
  596. package/src/handlers/relay.test.ts +2 -0
  597. package/src/handlers/relay.ts +95 -99
  598. package/src/internal/Auth.test.ts +48 -0
  599. package/src/internal/Auth.ts +61 -2
  600. package/src/internal/Cache.ts +13 -9
  601. package/src/internal/Cursor.test.ts +2 -2
  602. package/src/internal/Cursor.ts +1 -1
  603. package/src/internal/EarnRates.test.ts +125 -0
  604. package/src/internal/EarnRates.ts +409 -0
  605. package/src/internal/EarnVaults.test.ts +195 -0
  606. package/src/internal/EarnVaults.ts +876 -0
  607. package/src/internal/EdgeCache.test.ts +37 -5
  608. package/src/internal/EdgeCache.ts +39 -7
  609. package/src/internal/Id.ts +14 -0
  610. package/src/internal/Idempotency.test.ts +109 -0
  611. package/src/internal/Idempotency.ts +237 -0
  612. package/src/internal/Log.test-d.ts +41 -8
  613. package/src/internal/Log.test.ts +189 -8
  614. package/src/internal/Log.ts +124 -17
  615. package/src/internal/MetricSink.test.ts +244 -4
  616. package/src/internal/MetricSink.ts +51 -1
  617. package/src/internal/OpenApi.ts +3 -0
  618. package/src/internal/Provider.test.ts +17 -0
  619. package/src/internal/Provider.ts +17 -0
  620. package/src/internal/Schema.test.ts +13 -0
  621. package/src/internal/Schema.ts +41 -24
  622. package/src/internal/Store.test.ts +25 -0
  623. package/src/internal/Store.ts +46 -0
  624. package/src/internal/Tidx.local.test.ts +78 -3
  625. package/src/internal/Tidx.test.ts +212 -18
  626. package/src/internal/Tidx.ts +112 -32
  627. package/src/internal/VerifiedTokens.test.ts +15 -0
  628. package/src/internal/Viem.test.ts +170 -17
  629. package/src/internal/Viem.ts +111 -28
  630. package/src/internal/WebhookDestination.ts +25 -23
  631. package/src/internal/Webhooks.test.ts +59 -0
  632. package/src/internal/Webhooks.ts +34 -10
  633. package/src/internal/exchange/Provider.test.ts +216 -0
  634. package/src/internal/exchange/Provider.ts +326 -0
  635. package/src/internal/exchange/index.test.ts +6 -0
  636. package/src/internal/exchange/index.ts +1 -0
  637. package/src/internal/exchange/providers/uniswap.test.ts +122 -0
  638. package/src/internal/exchange/providers/uniswap.ts +682 -0
  639. package/src/internal/funding/Action.test.ts +138 -0
  640. package/src/internal/funding/Action.ts +117 -0
  641. package/src/internal/funding/Catalog.test.ts +311 -0
  642. package/src/internal/funding/Catalog.ts +347 -0
  643. package/src/internal/funding/Chain.test.ts +79 -0
  644. package/src/internal/funding/Chain.ts +120 -0
  645. package/src/internal/funding/Deposit.test.ts +26 -0
  646. package/src/internal/funding/Deposit.ts +453 -0
  647. package/src/internal/funding/DepositAddress.test.ts +18 -0
  648. package/src/internal/funding/DepositAddress.ts +312 -0
  649. package/src/internal/funding/Evidence.test.ts +297 -0
  650. package/src/internal/funding/Evidence.ts +430 -0
  651. package/src/internal/funding/Provider.test.ts +1328 -0
  652. package/src/internal/funding/Provider.ts +1796 -0
  653. package/src/internal/funding/Reconciliation.local.test.ts +504 -0
  654. package/src/internal/funding/Reconciliation.test.ts +2020 -0
  655. package/src/internal/funding/Reconciliation.ts +930 -0
  656. package/src/internal/funding/Route.test.ts +66 -0
  657. package/src/internal/funding/Route.ts +29 -0
  658. package/src/internal/funding/Subsidy.local.test.ts +152 -0
  659. package/src/internal/funding/Subsidy.test.ts +75 -0
  660. package/src/internal/funding/Subsidy.ts +260 -0
  661. package/src/internal/funding/Token.test.ts +47 -0
  662. package/src/internal/funding/Token.ts +59 -0
  663. package/src/internal/funding/Transfer.test.ts +369 -0
  664. package/src/internal/funding/Transfer.ts +522 -0
  665. package/src/internal/funding/index.test.ts +20 -0
  666. package/src/internal/funding/index.ts +12 -0
  667. package/src/internal/funding/providers/across.ts +149 -0
  668. package/src/{apps/data/FundingQuoteProviders.test.ts → internal/funding/providers/index.test.ts} +178 -157
  669. package/src/internal/funding/providers/relay.test.ts +474 -0
  670. package/src/internal/funding/providers/relay.ts +559 -0
  671. package/src/internal/funding/providers/rhino.ts +139 -0
  672. package/src/internal/funding/providers/squid.ts +151 -0
  673. package/src/internal/funding/providers/symbiosis.ts +221 -0
  674. package/src/internal/index.test.ts +5 -1
  675. package/src/internal/index.ts +5 -1
  676. package/src/internal/webhookDestinations/url.ts +49 -45
  677. package/src/providers/index.test.ts +14 -0
  678. package/src/providers/index.ts +54 -0
  679. package/dist/apps/data/FundingQuoteProviders.d.ts +0 -174
  680. package/dist/apps/data/FundingQuoteProviders.d.ts.map +0 -1
  681. package/dist/apps/data/FundingQuoteProviders.js +0 -775
  682. package/dist/apps/data/FundingQuoteProviders.js.map +0 -1
  683. package/dist/internal/FundingQuotes.d.ts +0 -864
  684. package/dist/internal/FundingQuotes.d.ts.map +0 -1
  685. package/dist/internal/FundingQuotes.js +0 -672
  686. package/dist/internal/FundingQuotes.js.map +0 -1
  687. package/src/apps/data/FundingQuoteProviders.ts +0 -1043
  688. package/src/internal/FundingQuotes.test.ts +0 -456
  689. package/src/internal/FundingQuotes.ts +0 -944
@@ -5,6 +5,7 @@ import type * as Db from '../db/Db.js'
5
5
  import * as WebhookDeliveries from '../db/tables/webhookDeliveries.js'
6
6
  import * as WebhookSubscriptions from '../db/tables/webhookSubscriptions.js'
7
7
  import type * as Metrics from '../Metrics.js'
8
+ import * as Cursor from './Cursor.js'
8
9
  import * as Id from './Id.js'
9
10
  import * as MetricSink from './MetricSink.js'
10
11
  import * as WebhookDestination from './WebhookDestination.js'
@@ -170,9 +171,18 @@ export async function createSubscription(
170
171
  options: createSubscription.Options = {},
171
172
  ): Promise<Subscription> {
172
173
  WebhookDestination.assertDestination(input.destination)
174
+ if (
175
+ options.startBlockNumber !== undefined &&
176
+ (!Number.isSafeInteger(options.startBlockNumber) || options.startBlockNumber < 0)
177
+ )
178
+ throw new RangeError('startBlockNumber must be a non-negative safe integer.')
173
179
 
174
180
  const now = (options.now ?? (() => new Date()))()
175
181
  const iso = now.toISOString()
182
+ // A one-field checkpoint records the live creation head without claiming it
183
+ // was scanned. The poller expands it using its confirmation depth.
184
+ const pollerCursor =
185
+ options.startBlockNumber === undefined ? undefined : Cursor.encode([options.startBlockNumber])
176
186
 
177
187
  const subscription: Subscription = {
178
188
  chainId: input.chainId,
@@ -196,9 +206,15 @@ export async function createSubscription(
196
206
  const inserted = await WebhookSubscriptions.insertWithinLimit(db, subscription, {
197
207
  maxPerOwner: options.maxPerOwner,
198
208
  now: iso,
209
+ ...(pollerCursor === undefined ? {} : { pollerCursor }),
199
210
  })
200
211
  if (!inserted) throw new LimitExceededError(options.maxPerOwner)
201
- } else await WebhookSubscriptions.insert(db, subscription)
212
+ } else
213
+ await WebhookSubscriptions.insert(
214
+ db,
215
+ subscription,
216
+ pollerCursor === undefined ? {} : { pollerCursor },
217
+ )
202
218
  return subscription
203
219
  }
204
220
 
@@ -209,6 +225,8 @@ export declare namespace createSubscription {
209
225
  maxPerOwner?: number | undefined
210
226
  /** Clock used for timestamps (injectable for tests). */
211
227
  now?: (() => Date) | undefined
228
+ /** Chain head observed immediately before the subscription becomes visible. */
229
+ startBlockNumber?: number | undefined
212
230
  }
213
231
  }
214
232
 
@@ -316,6 +334,19 @@ export async function getCursor(db: Db.Db, subscriptionId: string): Promise<stri
316
334
  return WebhookSubscriptions.getCursor(db, subscriptionId)
317
335
  }
318
336
 
337
+ /** Writes a cursor only when its stored value matches the expected cursor. */
338
+ export async function compareAndSetCursor(
339
+ db: Db.Db,
340
+ options: compareAndSetCursor.Options,
341
+ ): Promise<boolean> {
342
+ return WebhookSubscriptions.compareAndSetCursor(db, options)
343
+ }
344
+
345
+ export declare namespace compareAndSetCursor {
346
+ /** Options for {@link compareAndSetCursor}. */
347
+ type Options = WebhookSubscriptions.compareAndSetCursor.Options
348
+ }
349
+
319
350
  /** Writes a subscription's keyset cursor. */
320
351
  export async function setCursor(db: Db.Db, subscriptionId: string, cursor: string): Promise<void> {
321
352
  await WebhookSubscriptions.setCursor(db, subscriptionId, cursor)
@@ -790,18 +821,11 @@ export declare namespace ping {
790
821
  }
791
822
 
792
823
  function generateId(now: Date): string {
793
- // Zero-pad the epoch-ms so ids sort chronologically by string comparison
794
- // (mirroring delivery ids), letting listSubscriptions page newest-first; 15
795
- // digits leaves headroom well past the year 5138.
796
- const timestamp = now.getTime().toString().padStart(15, '0')
797
- return `wh_${timestamp}_${Id.random()}`
824
+ return Id.generateSortable('wh', now)
798
825
  }
799
826
 
800
827
  function generateDeliveryId(now: Date): string {
801
- // Zero-pad the epoch-ms so ids sort chronologically by string comparison; 15
802
- // digits leaves headroom well past the year 5138.
803
- const timestamp = now.getTime().toString().padStart(15, '0')
804
- return `whd_${timestamp}_${Id.random()}`
828
+ return Id.generateSortable('whd', now)
805
829
  }
806
830
 
807
831
  function generateSecret(): string {
@@ -0,0 +1,216 @@
1
+ import * as core_Provider from '../Provider.js'
2
+ import * as Provider from './Provider.js'
3
+
4
+ describe('from', () => {
5
+ test('preserves provider identity and adds the exchange category', () => {
6
+ const provider = Provider.from({
7
+ id: 'example',
8
+ name: 'Example',
9
+ async quote() {
10
+ throw new Provider.RouteUnavailableError()
11
+ },
12
+ })
13
+
14
+ expect(provider).toMatchObject({
15
+ id: 'example',
16
+ name: 'Example',
17
+ type: 'exchange',
18
+ })
19
+ })
20
+
21
+ test('rejects provider ids that are not normalized', () => {
22
+ expect(() =>
23
+ Provider.from({
24
+ id: ' Example ',
25
+ name: 'Example',
26
+ async quote() {
27
+ throw new Provider.RouteUnavailableError()
28
+ },
29
+ }),
30
+ ).toThrowErrorMatchingInlineSnapshot(
31
+ `[ExchangeProvider.ProviderConfigurationError: Provider ids must be lowercase and trimmed.]`,
32
+ )
33
+ })
34
+ })
35
+
36
+ describe('is', () => {
37
+ test('accepts only exchange providers with quote capability', () => {
38
+ const exchange = Provider.from({
39
+ id: 'exchange',
40
+ name: 'Exchange',
41
+ async quote() {
42
+ throw new Provider.RouteUnavailableError()
43
+ },
44
+ })
45
+ const incomplete = core_Provider.from({
46
+ id: 'incomplete',
47
+ name: 'Incomplete',
48
+ type: 'exchange',
49
+ })
50
+ const funding = core_Provider.from({ id: 'funding', name: 'Funding', type: 'funding' })
51
+
52
+ expect([exchange, incomplete, funding].map(Provider.is)).toEqual([true, false, false])
53
+ })
54
+ })
55
+
56
+ describe('failure', () => {
57
+ const provider = Provider.from({
58
+ id: 'example',
59
+ name: 'Example',
60
+ async quote() {
61
+ throw new Provider.RouteUnavailableError()
62
+ },
63
+ })
64
+
65
+ test('reports the upstream operation and status', () => {
66
+ expect(
67
+ Provider.failure(
68
+ new Provider.ProviderResponseError({ operation: 'check_approval', status: 429 }),
69
+ { chainId: 4217, operation: 'quote', provider },
70
+ ),
71
+ ).toMatchInlineSnapshot(`
72
+ {
73
+ "chainId": 4217,
74
+ "failure": "rate_limit",
75
+ "id": "example",
76
+ "operation": "check_approval",
77
+ "status": 429,
78
+ }
79
+ `)
80
+ })
81
+
82
+ test('reports payload failures at the enclosing operation', () => {
83
+ expect(
84
+ Provider.failure(new Provider.ProviderPayloadError(), {
85
+ chainId: 4217,
86
+ operation: 'finalize',
87
+ provider,
88
+ }),
89
+ ).toMatchInlineSnapshot(`
90
+ {
91
+ "chainId": 4217,
92
+ "failure": "payload",
93
+ "id": "example",
94
+ "operation": "finalize",
95
+ }
96
+ `)
97
+ })
98
+
99
+ test('reports bounded payload validation codes', () => {
100
+ expect(
101
+ Provider.failure(new Provider.ProviderPayloadError({ code: 'quote.response.permitData' }), {
102
+ chainId: 4217,
103
+ operation: 'quote',
104
+ provider,
105
+ }),
106
+ ).toMatchInlineSnapshot(`
107
+ {
108
+ "chainId": 4217,
109
+ "code": "quote.response.permitData",
110
+ "failure": "payload",
111
+ "id": "example",
112
+ "operation": "quote",
113
+ }
114
+ `)
115
+ })
116
+
117
+ test('reports the upstream operation for network failures', () => {
118
+ expect(
119
+ Provider.failure(
120
+ new Provider.ProviderNetworkError({
121
+ cause: new TypeError('secret network detail'),
122
+ operation: 'check_approval',
123
+ }),
124
+ { chainId: 4217, operation: 'quote', provider },
125
+ ),
126
+ ).toMatchInlineSnapshot(`
127
+ {
128
+ "chainId": 4217,
129
+ "failure": "network",
130
+ "id": "example",
131
+ "operation": "check_approval",
132
+ }
133
+ `)
134
+ })
135
+
136
+ test('ignores failures outside the provider boundary', () => {
137
+ expect(
138
+ Provider.failure(new Error('metadata lookup failed'), {
139
+ chainId: 4217,
140
+ operation: 'quote',
141
+ provider,
142
+ }),
143
+ ).toBeUndefined()
144
+ })
145
+ })
146
+
147
+ describe('validateExecution', () => {
148
+ const account = '0x1111111111111111111111111111111111111111'
149
+ const destinationToken = '0x20c0000000000000000000000000000000000002'
150
+ const sourceToken = '0x20c0000000000000000000000000000000000001'
151
+ const router = '0x2222222222222222222222222222222222222222'
152
+
153
+ test('accepts transfers within exact-source bounds', () => {
154
+ expect(() =>
155
+ Provider.validateExecution({
156
+ account,
157
+ execution: {
158
+ destinationAmount: '100',
159
+ destinationToken,
160
+ gasUnits: '1',
161
+ minimumDestinationAmount: '99',
162
+ mode: 'exactSource',
163
+ sourceAmount: '50',
164
+ sourceToken,
165
+ },
166
+ transfers: [
167
+ { amount: 50n, from: account, to: router, token: sourceToken },
168
+ { amount: 99n, from: router, to: account, token: destinationToken },
169
+ ],
170
+ }),
171
+ ).not.toThrow()
172
+ })
173
+
174
+ test('rejects a different outgoing token', () => {
175
+ expect(() =>
176
+ Provider.validateExecution({
177
+ account,
178
+ execution: {
179
+ destinationAmount: '100',
180
+ destinationToken,
181
+ gasUnits: '1',
182
+ minimumDestinationAmount: '99',
183
+ mode: 'exactSource',
184
+ sourceAmount: '50',
185
+ sourceToken,
186
+ },
187
+ transfers: [
188
+ { amount: 1n, from: account, to: router, token: destinationToken },
189
+ { amount: 50n, from: account, to: router, token: sourceToken },
190
+ { amount: 100n, from: router, to: account, token: destinationToken },
191
+ ],
192
+ }),
193
+ ).toThrow(Provider.ProviderPayloadError)
194
+ })
195
+
196
+ test('rejects execution outside exact-destination bounds', () => {
197
+ expect(() =>
198
+ Provider.validateExecution({
199
+ account,
200
+ execution: {
201
+ destinationAmount: '100',
202
+ destinationToken,
203
+ gasUnits: '1',
204
+ maximumSourceAmount: '50',
205
+ mode: 'exactDestination',
206
+ sourceAmount: '49',
207
+ sourceToken,
208
+ },
209
+ transfers: [
210
+ { amount: 51n, from: account, to: router, token: sourceToken },
211
+ { amount: 100n, from: router, to: account, token: destinationToken },
212
+ ],
213
+ }),
214
+ ).toThrow(Provider.ProviderPayloadError)
215
+ })
216
+ })
@@ -0,0 +1,326 @@
1
+ import type { Hex } from 'ox'
2
+
3
+ import * as core_Provider from '../Provider.js'
4
+ import type * as Log from '../Log.js'
5
+
6
+ /** Exchange quote provider called after the native DEX cannot route a swap. */
7
+ export type Provider<id extends string = string> = core_Provider.Provider<id, 'exchange'> & {
8
+ /** Converts a signed continuation into final executable calls. */
9
+ finalizeQuote?(
10
+ this: void,
11
+ input: FinalizeQuoteInput,
12
+ signal: AbortSignal,
13
+ ): Promise<FinalizeQuoteResult>
14
+ /** Returns the approvals, signature, or executable calls needed to continue. */
15
+ quote(this: void, input: QuoteInput, signal: AbortSignal): Promise<QuoteResult>
16
+ }
17
+
18
+ /** Provider-neutral unsigned transaction call. */
19
+ export type Call = {
20
+ /** ABI-encoded call data. */
21
+ data: Hex.Hex
22
+ /** Contract receiving the call. */
23
+ to: `0x${string}`
24
+ /** Native token value as a JSON-RPC quantity. */
25
+ value: Hex.Hex
26
+ }
27
+
28
+ /** Input used to finish a provider quote after signing. */
29
+ export type FinalizeQuoteInput = {
30
+ /** Wallet signing and executing the swap. */
31
+ account: `0x${string}`
32
+ /** Tempo chain id. */
33
+ chainId: number
34
+ /** Opaque provider state returned by `quote`. */
35
+ continuation: string
36
+ /** EIP-712 signature requested by the quote result. */
37
+ signature: Hex.Hex
38
+ }
39
+
40
+ /** Final executable calls returned after a signature. */
41
+ export type FinalizeQuoteResult = {
42
+ /** Calls to execute in order. */
43
+ calls: readonly Call[]
44
+ /** Quote constraints that the final calls must satisfy. */
45
+ execution: Execution
46
+ }
47
+
48
+ /** Constraints used to validate executable provider calls. */
49
+ export type Execution = QuoteAmounts & {
50
+ /** Token received by the swap. */
51
+ destinationToken: `0x${string}`
52
+ /** Side whose requested amount remains exact. */
53
+ mode: 'exactDestination' | 'exactSource'
54
+ /** Token spent by the swap. */
55
+ sourceToken: `0x${string}`
56
+ }
57
+
58
+ /** Token movement observed while simulating provider calls. */
59
+ export type Transfer = {
60
+ /** Amount moved in base units. */
61
+ amount: bigint
62
+ /** Account sending the tokens. */
63
+ from: `0x${string}`
64
+ /** Account receiving the tokens. */
65
+ to: `0x${string}`
66
+ /** Token contract that emitted the transfer. */
67
+ token: `0x${string}`
68
+ }
69
+
70
+ /** Provider-neutral quote input. */
71
+ export type QuoteInput = {
72
+ /** Wallet receiving and executing the swap. */
73
+ account: `0x${string}`
74
+ /** Exact source or destination amount in base units. */
75
+ amount: string
76
+ /** Tempo chain id. */
77
+ chainId: number
78
+ /** Token received by the swap. */
79
+ destinationToken: `0x${string}`
80
+ /** Side whose requested amount remains exact. */
81
+ mode: 'exactDestination' | 'exactSource'
82
+ /** Maximum execution slippage in basis points. */
83
+ slippageBps: number
84
+ /** Token spent by the swap. */
85
+ sourceToken: `0x${string}`
86
+ }
87
+
88
+ /** Quote with the approvals, signature, or transaction needed for its next step. */
89
+ export type QuoteResult =
90
+ | (QuoteAmounts & {
91
+ /** Calls that must confirm before requesting a fresh quote. */
92
+ approval: { calls: readonly Call[] }
93
+ /** Onchain approval is required before this swap can be quoted for execution. */
94
+ status: 'approvalRequired'
95
+ })
96
+ | (QuoteAmounts & {
97
+ /** Quote is ready for execution. */
98
+ status: 'ready'
99
+ /** Ordered calls required to execute the quote. */
100
+ transaction: { calls: readonly Call[] }
101
+ })
102
+ | (QuoteAmounts & {
103
+ /** Opaque provider state passed to `finalizeQuote`. */
104
+ continuation: string
105
+ /** Quote needs a wallet signature before final calldata can be built. */
106
+ status: 'signatureRequired'
107
+ /** EIP-712 payload the wallet must sign. */
108
+ typedData: TypedData
109
+ })
110
+
111
+ /** Defines an exchange provider while preserving its concrete identity. */
112
+ export function from<const id extends string>(options: from.Options<id>): Provider<id> {
113
+ if (options.id !== options.id.trim().toLowerCase() || options.id.length === 0)
114
+ throw new ProviderConfigurationError('Provider ids must be lowercase and trimmed.')
115
+ return core_Provider.from({ ...options, type: 'exchange' })
116
+ }
117
+
118
+ export declare namespace from {
119
+ /** Exchange provider definition. */
120
+ type Options<id extends string> = Omit<Provider<id>, 'type'>
121
+ }
122
+
123
+ /** Returns whether a registered provider implements exchange quotes. */
124
+ export function is(provider: core_Provider.Provider): provider is Provider {
125
+ return provider.type === 'exchange' && 'quote' in provider && typeof provider.quote === 'function'
126
+ }
127
+
128
+ /** Returns bounded exchange-provider failure details for structured request logs. */
129
+ export function failure(cause: unknown, options: failure.Options): Log.ProviderFailure | undefined {
130
+ const { chainId, operation, provider } = options
131
+ if (cause instanceof ProviderResponseError)
132
+ return {
133
+ chainId,
134
+ failure: cause.status === 429 ? 'rate_limit' : 'http',
135
+ id: provider.id,
136
+ operation: cause.operation,
137
+ status: cause.status,
138
+ }
139
+ if (cause instanceof ProviderNetworkError)
140
+ return { chainId, failure: 'network', id: provider.id, operation: cause.operation }
141
+ if (cause instanceof ProviderPayloadError)
142
+ return {
143
+ chainId,
144
+ ...(cause.code ? { code: cause.code } : {}),
145
+ failure: 'payload',
146
+ id: provider.id,
147
+ operation,
148
+ }
149
+ return undefined
150
+ }
151
+
152
+ export declare namespace failure {
153
+ /** Exchange-provider context retained when a quote operation fails. */
154
+ type Options = {
155
+ /** Chain selected by the quote request. */
156
+ chainId: number
157
+ /** Provider operation used when the error has no narrower operation. */
158
+ operation: string
159
+ /** Exchange provider that handled the request. */
160
+ provider: Provider
161
+ }
162
+ }
163
+
164
+ /** Validates simulated token movements against an executable quote. */
165
+ export function validateExecution(options: validateExecution.Options): void {
166
+ const account = options.account.toLowerCase()
167
+ const destinationToken = options.execution.destinationToken.toLowerCase()
168
+ const sourceToken = options.execution.sourceToken.toLowerCase()
169
+ let destinationReceived = 0n
170
+ let sourceIncoming = 0n
171
+ let sourceOutgoing = 0n
172
+
173
+ for (const transfer of options.transfers) {
174
+ const token = transfer.token.toLowerCase()
175
+ if (transfer.from.toLowerCase() === account) {
176
+ if (token !== sourceToken) throw new ProviderPayloadError()
177
+ sourceOutgoing += transfer.amount
178
+ }
179
+ if (transfer.to.toLowerCase() !== account) continue
180
+ if (token === sourceToken) sourceIncoming += transfer.amount
181
+ if (token === destinationToken) destinationReceived += transfer.amount
182
+ }
183
+
184
+ const sourceSpent = sourceOutgoing - sourceIncoming
185
+ if (sourceSpent <= 0n) throw new ProviderPayloadError()
186
+ if (options.execution.mode === 'exactSource') {
187
+ if (
188
+ sourceSpent !== BigInt(options.execution.sourceAmount) ||
189
+ options.execution.minimumDestinationAmount === undefined ||
190
+ destinationReceived < BigInt(options.execution.minimumDestinationAmount)
191
+ )
192
+ throw new ProviderPayloadError()
193
+ return
194
+ }
195
+
196
+ if (
197
+ options.execution.maximumSourceAmount === undefined ||
198
+ sourceSpent > BigInt(options.execution.maximumSourceAmount) ||
199
+ destinationReceived < BigInt(options.execution.destinationAmount)
200
+ )
201
+ throw new ProviderPayloadError()
202
+ }
203
+
204
+ export declare namespace validateExecution {
205
+ /** Simulated transfers and quote constraints to validate. */
206
+ type Options = {
207
+ /** Wallet executing the provider calls. */
208
+ account: `0x${string}`
209
+ /** Quote constraints bound to the executable calls. */
210
+ execution: Execution
211
+ /** Token transfers emitted by the simulated calls. */
212
+ transfers: readonly Transfer[]
213
+ }
214
+ }
215
+
216
+ /** Amount bounds returned by an exchange provider. */
217
+ export type QuoteAmounts = {
218
+ /** Expected destination amount in base units. */
219
+ destinationAmount: string
220
+ /** Estimated execution gas units. */
221
+ gasUnits: string
222
+ /** Maximum source amount for an exact-destination quote. */
223
+ maximumSourceAmount?: string | undefined
224
+ /** Minimum destination amount for an exact-source quote. */
225
+ minimumDestinationAmount?: string | undefined
226
+ /** Expected source amount in base units. */
227
+ sourceAmount: string
228
+ }
229
+
230
+ /** Provider-neutral EIP-712 payload accepted by Privy and common wallet clients. */
231
+ export type TypedData = {
232
+ /** EIP-712 signing domain. */
233
+ domain: Record<string, unknown>
234
+ /** EIP-712 message values. */
235
+ message: Record<string, unknown>
236
+ /** Root EIP-712 type. */
237
+ primaryType: string
238
+ /** EIP-712 type definitions. */
239
+ types: Record<string, readonly { name: string; type: string }[]>
240
+ }
241
+
242
+ /** Raised when a provider has no executable route for the requested swap. */
243
+ export class RouteUnavailableError extends Error {
244
+ override name = 'ExchangeProvider.RouteUnavailableError'
245
+ }
246
+
247
+ /** Raised when a continuation cannot be decoded or validated. */
248
+ export class ProviderContinuationError extends Error {
249
+ override name = 'ExchangeProvider.ProviderContinuationError'
250
+ }
251
+
252
+ /** Raised when required provider configuration is invalid. */
253
+ export class ProviderConfigurationError extends Error {
254
+ override name = 'ExchangeProvider.ProviderConfigurationError'
255
+ }
256
+
257
+ /** Raised when an upstream provider request fails before receiving a response. */
258
+ export class ProviderNetworkError extends Error {
259
+ override name = 'ExchangeProvider.ProviderNetworkError'
260
+
261
+ /** Upstream operation that failed. */
262
+ operation: string
263
+
264
+ constructor(options: ProviderNetworkError.Options) {
265
+ super(`Provider ${options.operation} request failed`, { cause: options.cause })
266
+ this.operation = options.operation
267
+ }
268
+ }
269
+
270
+ export declare namespace ProviderNetworkError {
271
+ /** Safe request details retained for operational reporting. */
272
+ type Options = {
273
+ /** Original network error. */
274
+ cause: TypeError
275
+ /** Stable upstream operation identifier. */
276
+ operation: string
277
+ }
278
+ }
279
+
280
+ /** Raised when an upstream provider returns an invalid payload. */
281
+ export class ProviderPayloadError extends Error {
282
+ override name = 'ExchangeProvider.ProviderPayloadError'
283
+
284
+ /** Stable validation code safe for operational reporting. */
285
+ code?: string | undefined
286
+
287
+ constructor(options: ProviderPayloadError.Options = {}) {
288
+ super(options.code ? `Provider payload failed ${options.code}` : undefined)
289
+ this.code = options.code
290
+ }
291
+ }
292
+
293
+ export declare namespace ProviderPayloadError {
294
+ /** Bounded invalid-payload details. */
295
+ type Options = {
296
+ /** Stable validation code safe for operational reporting. */
297
+ code?: string | undefined
298
+ }
299
+ }
300
+
301
+ /** Raised when an upstream provider request fails. */
302
+ export class ProviderResponseError extends Error {
303
+ override name = 'ExchangeProvider.ProviderResponseError'
304
+
305
+ /** Upstream operation that returned the response. */
306
+ operation: string
307
+
308
+ /** Upstream HTTP status. */
309
+ status: number
310
+
311
+ constructor(options: ProviderResponseError.Options) {
312
+ super(`Provider ${options.operation} request failed with status ${options.status}`)
313
+ this.operation = options.operation
314
+ this.status = options.status
315
+ }
316
+ }
317
+
318
+ export declare namespace ProviderResponseError {
319
+ /** Safe upstream response details retained for operational reporting. */
320
+ type Options = {
321
+ /** Stable upstream operation identifier. */
322
+ operation: string
323
+ /** Upstream HTTP status. */
324
+ status: number
325
+ }
326
+ }
@@ -0,0 +1,6 @@
1
+ import * as Exchange from './index.js'
2
+
3
+ test('exports the exchange provider contract', () => {
4
+ expect(Exchange.Provider.from).toBeTypeOf('function')
5
+ expect(Exchange.Provider.is).toBeTypeOf('function')
6
+ })
@@ -0,0 +1 @@
1
+ export * as Provider from './Provider.js'