tapimo 0.7.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/README.md +10 -7
  2. package/dist/ApiKey.d.ts +3 -0
  3. package/dist/ApiKey.d.ts.map +1 -1
  4. package/dist/ApiKey.js +10 -0
  5. package/dist/ApiKey.js.map +1 -1
  6. package/dist/ApiKeys.d.ts +7 -3
  7. package/dist/ApiKeys.d.ts.map +1 -1
  8. package/dist/ApiKeys.js +9 -2
  9. package/dist/ApiKeys.js.map +1 -1
  10. package/dist/App.d.ts +20117 -19183
  11. package/dist/App.d.ts.map +1 -1
  12. package/dist/App.js +61 -4
  13. package/dist/App.js.map +1 -1
  14. package/dist/admin/App.d.ts +84 -74
  15. package/dist/admin/App.d.ts.map +1 -1
  16. package/dist/admin/apps/api-keys.d.ts +14 -1
  17. package/dist/admin/apps/api-keys.d.ts.map +1 -1
  18. package/dist/admin/apps/api-keys.js +6 -2
  19. package/dist/admin/apps/api-keys.js.map +1 -1
  20. package/dist/admin/apps/organizations.d.ts +2 -0
  21. package/dist/admin/apps/organizations.d.ts.map +1 -1
  22. package/dist/admin/apps/verified-tokens.d.ts +11 -11
  23. package/dist/admin/ui.generated.d.ts +1 -1
  24. package/dist/admin/ui.generated.js +67 -67
  25. package/dist/admin/ui.generated.js.map +1 -1
  26. package/dist/analytics/Analytics.d.ts +2 -0
  27. package/dist/analytics/Analytics.d.ts.map +1 -1
  28. package/dist/analytics/Analytics.js +3 -0
  29. package/dist/analytics/Analytics.js.map +1 -1
  30. package/dist/apps/data/App.d.ts +11696 -13937
  31. package/dist/apps/data/App.d.ts.map +1 -1
  32. package/dist/apps/data/App.js +4 -8
  33. package/dist/apps/data/App.js.map +1 -1
  34. package/dist/apps/data/routes/activities.d.ts +271 -271
  35. package/dist/apps/data/routes/addresses.d.ts +398 -167
  36. package/dist/apps/data/routes/addresses.d.ts.map +1 -1
  37. package/dist/apps/data/routes/balances.d.ts +278 -8
  38. package/dist/apps/data/routes/balances.d.ts.map +1 -1
  39. package/dist/apps/data/routes/balances.js +114 -2
  40. package/dist/apps/data/routes/balances.js.map +1 -1
  41. package/dist/apps/data/routes/blocks.d.ts +123 -123
  42. package/dist/apps/data/routes/coingecko.d.ts +170 -170
  43. package/dist/apps/data/routes/earn.d.ts +498 -6
  44. package/dist/apps/data/routes/earn.d.ts.map +1 -1
  45. package/dist/apps/data/routes/earn.js +876 -4
  46. package/dist/apps/data/routes/earn.js.map +1 -1
  47. package/dist/apps/data/routes/exchanges.d.ts +10 -10
  48. package/dist/apps/data/routes/fee-amm.d.ts +2 -2
  49. package/dist/apps/data/routes/indexer.d.ts +6 -6
  50. package/dist/apps/data/routes/indexer.js +4 -1
  51. package/dist/apps/data/routes/indexer.js.map +1 -1
  52. package/dist/apps/data/routes/receipts.d.ts +235 -235
  53. package/dist/apps/data/routes/rpc.d.ts +31 -31
  54. package/dist/apps/data/routes/rpc.js +4 -1
  55. package/dist/apps/data/routes/rpc.js.map +1 -1
  56. package/dist/apps/data/routes/tokenlist.d.ts +36 -36
  57. package/dist/apps/data/routes/tokens.d.ts +449 -449
  58. package/dist/apps/data/routes/transactions.d.ts +2 -2
  59. package/dist/apps/data/routes/transfers.d.ts +81 -81
  60. package/dist/apps/data/routes/valuation.d.ts +1 -1
  61. package/dist/apps/data/routes/verified-tokens.d.ts +36 -36
  62. package/dist/apps/data/routes/webhooks.d.ts +9 -9
  63. package/dist/apps/data/routes/zones.d.ts +14 -14
  64. package/dist/apps/funding/Access.d.ts +16 -0
  65. package/dist/apps/funding/Access.d.ts.map +1 -0
  66. package/dist/apps/funding/Access.js +22 -0
  67. package/dist/apps/funding/Access.js.map +1 -0
  68. package/dist/apps/{data/routes/funding.d.ts → funding/App.d.ts} +1640 -3217
  69. package/dist/apps/funding/App.d.ts.map +1 -0
  70. package/dist/apps/funding/App.js +61 -0
  71. package/dist/apps/funding/App.js.map +1 -0
  72. package/dist/apps/funding/Inventory.d.ts +5 -0
  73. package/dist/apps/funding/Inventory.d.ts.map +1 -0
  74. package/dist/apps/funding/Inventory.js +25 -0
  75. package/dist/apps/funding/Inventory.js.map +1 -0
  76. package/dist/apps/funding/ProviderAttempts.d.ts +5 -0
  77. package/dist/apps/funding/ProviderAttempts.d.ts.map +1 -0
  78. package/dist/apps/funding/ProviderAttempts.js +24 -0
  79. package/dist/apps/funding/ProviderAttempts.js.map +1 -0
  80. package/dist/apps/funding/index.d.ts +2 -0
  81. package/dist/apps/funding/index.d.ts.map +1 -0
  82. package/dist/apps/funding/index.js +2 -0
  83. package/dist/apps/funding/index.js.map +1 -0
  84. package/dist/apps/funding/routes/chains.d.ts +169 -0
  85. package/dist/apps/funding/routes/chains.d.ts.map +1 -0
  86. package/dist/apps/funding/routes/chains.js +80 -0
  87. package/dist/apps/funding/routes/chains.js.map +1 -0
  88. package/dist/apps/funding/routes/deposit-addresses.d.ts +1997 -0
  89. package/dist/apps/funding/routes/deposit-addresses.d.ts.map +1 -0
  90. package/dist/apps/funding/routes/deposit-addresses.js +778 -0
  91. package/dist/apps/funding/routes/deposit-addresses.js.map +1 -0
  92. package/dist/apps/funding/routes/providers.d.ts +91 -0
  93. package/dist/apps/funding/routes/providers.d.ts.map +1 -0
  94. package/dist/apps/funding/routes/providers.js +56 -0
  95. package/dist/apps/funding/routes/providers.js.map +1 -0
  96. package/dist/apps/funding/routes/quotes.d.ts +426 -0
  97. package/dist/apps/funding/routes/quotes.d.ts.map +1 -0
  98. package/dist/apps/funding/routes/quotes.js +188 -0
  99. package/dist/apps/funding/routes/quotes.js.map +1 -0
  100. package/dist/apps/funding/routes/transfers.d.ts +1999 -0
  101. package/dist/apps/funding/routes/transfers.d.ts.map +1 -0
  102. package/dist/apps/funding/routes/transfers.js +614 -0
  103. package/dist/apps/funding/routes/transfers.js.map +1 -0
  104. package/dist/apps/index.d.ts +1 -0
  105. package/dist/apps/index.d.ts.map +1 -1
  106. package/dist/apps/index.js +1 -0
  107. package/dist/apps/index.js.map +1 -1
  108. package/dist/apps/management/App.d.ts +430 -165
  109. package/dist/apps/management/App.d.ts.map +1 -1
  110. package/dist/apps/management/routes/api-keys.d.ts +298 -21
  111. package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
  112. package/dist/apps/management/routes/api-keys.js +75 -1
  113. package/dist/apps/management/routes/api-keys.js.map +1 -1
  114. package/dist/apps/management/routes/billing.d.ts +6 -6
  115. package/dist/apps/management/routes/faucet.d.ts +35 -35
  116. package/dist/apps/management/routes/invitations.d.ts +122 -122
  117. package/dist/apps/management/routes/invite-links.d.ts +38 -38
  118. package/dist/apps/management/routes/members.d.ts +69 -69
  119. package/dist/apps/management/routes/orgs.d.ts +99 -99
  120. package/dist/apps/management/routes/projects.d.ts +25 -25
  121. package/dist/apps/management/routes/scopes.d.ts +1 -1
  122. package/dist/apps/management/routes/usage.d.ts +72 -72
  123. package/dist/apps/management/routes/verified-token-requests.d.ts +77 -77
  124. package/dist/apps/management/routes/webhooks.d.ts +128 -128
  125. package/dist/apps/mcp.d.ts +2 -3
  126. package/dist/apps/mcp.d.ts.map +1 -1
  127. package/dist/apps/mcp.js +16 -14
  128. package/dist/apps/mcp.js.map +1 -1
  129. package/dist/apps/metadata.d.ts +4 -0
  130. package/dist/apps/metadata.d.ts.map +1 -1
  131. package/dist/apps/metadata.js +10 -0
  132. package/dist/apps/metadata.js.map +1 -1
  133. package/dist/apps/mpp/App.d.ts +44 -44
  134. package/dist/cloudflare.d.ts +50 -0
  135. package/dist/cloudflare.d.ts.map +1 -1
  136. package/dist/cloudflare.js +178 -0
  137. package/dist/cloudflare.js.map +1 -1
  138. package/dist/db/Db.d.ts +2 -0
  139. package/dist/db/Db.d.ts.map +1 -1
  140. package/dist/db/Db.js +45 -0
  141. package/dist/db/Db.js.map +1 -1
  142. package/dist/db/Schema.d.ts +12 -0
  143. package/dist/db/Schema.d.ts.map +1 -1
  144. package/dist/db/Schema.js +20 -0
  145. package/dist/db/Schema.js.map +1 -1
  146. package/dist/db/tables/fundingDepositAddresses.d.ts +13 -0
  147. package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -1
  148. package/dist/db/tables/fundingDepositAddresses.js +12 -0
  149. package/dist/db/tables/fundingDepositAddresses.js.map +1 -1
  150. package/dist/db/tables/fundingDepositRequestObservations.d.ts +45 -0
  151. package/dist/db/tables/fundingDepositRequestObservations.d.ts.map +1 -0
  152. package/dist/db/tables/fundingDepositRequestObservations.js +46 -0
  153. package/dist/db/tables/fundingDepositRequestObservations.js.map +1 -0
  154. package/dist/db/tables/fundingDeposits.d.ts +74 -1
  155. package/dist/db/tables/fundingDeposits.d.ts.map +1 -1
  156. package/dist/db/tables/fundingDeposits.js +126 -0
  157. package/dist/db/tables/fundingDeposits.js.map +1 -1
  158. package/dist/internal/Auth.d.ts +15 -11
  159. package/dist/internal/Auth.d.ts.map +1 -1
  160. package/dist/internal/Auth.js +52 -17
  161. package/dist/internal/Auth.js.map +1 -1
  162. package/dist/internal/Cache.js +1 -1
  163. package/dist/internal/Cache.js.map +1 -1
  164. package/dist/internal/EdgeCache.d.ts +2 -2
  165. package/dist/internal/EdgeCache.d.ts.map +1 -1
  166. package/dist/internal/EdgeCache.js +10 -4
  167. package/dist/internal/EdgeCache.js.map +1 -1
  168. package/dist/internal/IpAllowlist.d.ts +15 -0
  169. package/dist/internal/IpAllowlist.d.ts.map +1 -0
  170. package/dist/internal/IpAllowlist.js +27 -0
  171. package/dist/internal/IpAllowlist.js.map +1 -0
  172. package/dist/internal/OpenApi.d.ts +1 -1
  173. package/dist/internal/OpenApi.js +1 -1
  174. package/dist/internal/OpenApi.js.map +1 -1
  175. package/dist/internal/Tidx.d.ts +6 -0
  176. package/dist/internal/Tidx.d.ts.map +1 -1
  177. package/dist/internal/Tidx.js +13 -3
  178. package/dist/internal/Tidx.js.map +1 -1
  179. package/dist/internal/Viem.d.ts +8 -0
  180. package/dist/internal/Viem.d.ts.map +1 -1
  181. package/dist/internal/Viem.js +12 -5
  182. package/dist/internal/Viem.js.map +1 -1
  183. package/dist/internal/funding/Deposit.d.ts +42 -0
  184. package/dist/internal/funding/Deposit.d.ts.map +1 -1
  185. package/dist/internal/funding/Deposit.js +37 -5
  186. package/dist/internal/funding/Deposit.js.map +1 -1
  187. package/dist/internal/funding/Evidence.d.ts +1 -5
  188. package/dist/internal/funding/Evidence.d.ts.map +1 -1
  189. package/dist/internal/funding/Evidence.js +4 -3
  190. package/dist/internal/funding/Evidence.js.map +1 -1
  191. package/dist/internal/funding/Provider.d.ts +102 -0
  192. package/dist/internal/funding/Provider.d.ts.map +1 -1
  193. package/dist/internal/funding/Provider.js +5 -0
  194. package/dist/internal/funding/Provider.js.map +1 -1
  195. package/dist/internal/funding/Reconciliation.d.ts +16 -2
  196. package/dist/internal/funding/Reconciliation.d.ts.map +1 -1
  197. package/dist/internal/funding/Reconciliation.js +348 -54
  198. package/dist/internal/funding/Reconciliation.js.map +1 -1
  199. package/dist/internal/funding/SourceObservation.d.ts +108 -0
  200. package/dist/internal/funding/SourceObservation.d.ts.map +1 -0
  201. package/dist/internal/funding/SourceObservation.js +143 -0
  202. package/dist/internal/funding/SourceObservation.js.map +1 -0
  203. package/dist/internal/funding/Subsidy.d.ts +2 -2
  204. package/dist/internal/funding/Subsidy.d.ts.map +1 -1
  205. package/dist/internal/funding/Subsidy.js +1 -1
  206. package/dist/internal/funding/Subsidy.js.map +1 -1
  207. package/dist/internal/funding/index.d.ts +1 -0
  208. package/dist/internal/funding/index.d.ts.map +1 -1
  209. package/dist/internal/funding/index.js +1 -0
  210. package/dist/internal/funding/index.js.map +1 -1
  211. package/dist/internal/funding/providers/relay.d.ts +43 -1
  212. package/dist/internal/funding/providers/relay.d.ts.map +1 -1
  213. package/dist/internal/funding/providers/relay.js +438 -27
  214. package/dist/internal/funding/providers/relay.js.map +1 -1
  215. package/package.json +3 -3
  216. package/src/ApiKey.test.ts +35 -0
  217. package/src/ApiKey.ts +27 -0
  218. package/src/ApiKeys.test.ts +29 -0
  219. package/src/ApiKeys.ts +11 -3
  220. package/src/App.test.ts +55 -5
  221. package/src/App.ts +79 -5
  222. package/src/Client.test-d.ts +203 -28
  223. package/src/admin/apps/api-keys.test.ts +25 -1
  224. package/src/admin/apps/api-keys.ts +6 -2
  225. package/src/admin/ui.generated.ts +67 -67
  226. package/src/analytics/Analytics.ts +4 -0
  227. package/src/apps/composition.test.ts +130 -3
  228. package/src/apps/data/App.test.ts +0 -12
  229. package/src/apps/data/App.ts +4 -8
  230. package/src/apps/data/routes/balances.test.ts +42 -0
  231. package/src/apps/data/routes/balances.ts +218 -85
  232. package/src/apps/data/routes/earn.test.ts +363 -0
  233. package/src/apps/data/routes/earn.ts +1141 -3
  234. package/src/apps/data/routes/indexer.ts +2 -1
  235. package/src/apps/data/routes/rpc.ts +2 -0
  236. package/src/apps/data/routes/tokens.test.ts +6 -8
  237. package/src/apps/funding/Access.ts +26 -0
  238. package/src/apps/funding/App.test.ts +78 -0
  239. package/src/apps/funding/App.ts +78 -0
  240. package/src/apps/funding/Inventory.ts +30 -0
  241. package/src/apps/funding/ProviderAttempts.ts +26 -0
  242. package/src/apps/funding/index.ts +1 -0
  243. package/src/apps/funding/routes/chains.test.ts +78 -0
  244. package/src/apps/funding/routes/chains.ts +101 -0
  245. package/src/apps/funding/routes/deposit-addresses.test.ts +1649 -0
  246. package/src/apps/funding/routes/deposit-addresses.ts +932 -0
  247. package/src/apps/funding/routes/providers.test.ts +165 -0
  248. package/src/apps/funding/routes/providers.ts +73 -0
  249. package/src/apps/funding/routes/quotes.test.ts +511 -0
  250. package/src/apps/funding/routes/quotes.ts +205 -0
  251. package/src/apps/funding/routes/transfers.test.ts +1236 -0
  252. package/src/apps/funding/routes/transfers.ts +704 -0
  253. package/src/apps/index.ts +1 -0
  254. package/src/apps/management/routes/api-keys.test.ts +98 -0
  255. package/src/apps/management/routes/api-keys.ts +96 -1
  256. package/src/apps/mcp.test.ts +17 -2
  257. package/src/apps/mcp.ts +18 -13
  258. package/src/apps/metadata.ts +12 -0
  259. package/src/apps/mpp/internal/Policy.test.ts +7 -1
  260. package/src/cloudflare.ts +279 -0
  261. package/src/db/Db.ts +71 -0
  262. package/src/db/Schema.ts +24 -0
  263. package/src/db/tables/fundingDepositAddresses.ts +28 -0
  264. package/src/db/tables/fundingDepositRequestObservations.test.ts +106 -0
  265. package/src/db/tables/fundingDepositRequestObservations.ts +99 -0
  266. package/src/db/tables/fundingDeposits.test.ts +239 -0
  267. package/src/db/tables/fundingDeposits.ts +214 -1
  268. package/src/internal/Auth.test.ts +205 -5
  269. package/src/internal/Auth.ts +63 -19
  270. package/src/internal/Cache.test.ts +37 -3
  271. package/src/internal/Cache.ts +1 -1
  272. package/src/internal/EdgeCache.test.ts +7 -7
  273. package/src/internal/EdgeCache.ts +13 -4
  274. package/src/internal/IpAllowlist.test.ts +52 -0
  275. package/src/internal/IpAllowlist.ts +39 -0
  276. package/src/internal/Log.test.ts +7 -1
  277. package/src/internal/OpenApi.ts +1 -1
  278. package/src/internal/Tidx.test.ts +28 -0
  279. package/src/internal/Tidx.ts +19 -3
  280. package/src/internal/Viem.test.ts +28 -0
  281. package/src/internal/Viem.ts +21 -5
  282. package/src/internal/funding/Deposit.ts +74 -5
  283. package/src/internal/funding/Evidence.test.ts +2 -2
  284. package/src/internal/funding/Evidence.ts +4 -9
  285. package/src/internal/funding/Provider.ts +115 -0
  286. package/src/internal/funding/Reconciliation.local.test.ts +7 -0
  287. package/src/internal/funding/Reconciliation.test.ts +1364 -109
  288. package/src/internal/funding/Reconciliation.ts +467 -88
  289. package/src/internal/funding/SourceObservation.test.ts +301 -0
  290. package/src/internal/funding/SourceObservation.ts +267 -0
  291. package/src/internal/funding/Subsidy.ts +2 -2
  292. package/src/internal/funding/index.test.ts +1 -0
  293. package/src/internal/funding/index.ts +1 -0
  294. package/src/internal/funding/providers/relay.test.ts +94 -4
  295. package/src/internal/funding/providers/relay.ts +533 -27
  296. package/dist/apps/data/routes/funding.d.ts.map +0 -1
  297. package/dist/apps/data/routes/funding.js +0 -1557
  298. package/dist/apps/data/routes/funding.js.map +0 -1
  299. package/src/apps/data/routes/funding.test.ts +0 -2994
  300. package/src/apps/data/routes/funding.ts +0 -1821
@@ -0,0 +1,511 @@
1
+ import { Schema } from 'tapimo'
2
+
3
+ import * as FundingProvider from '../../../internal/funding/Provider.js'
4
+
5
+ import * as Across from '../../../internal/funding/providers/across.js'
6
+
7
+ import * as Relay from '../../../internal/funding/providers/relay.js'
8
+
9
+ import * as Rhino from '../../../internal/funding/providers/rhino.js'
10
+
11
+ import * as Squid from '../../../internal/funding/providers/squid.js'
12
+
13
+ import * as Symbiosis from '../../../internal/funding/providers/symbiosis.js'
14
+
15
+ import type * as Log from '../../../internal/Log.js'
16
+
17
+ import * as TestApp from '../../../../test/App.js'
18
+
19
+ import * as TestFunding from '../../../../test/Funding.js'
20
+
21
+ import * as Funding from './quotes.js'
22
+
23
+ const db = TestApp.database()
24
+
25
+ const providers = [
26
+ Across.across({
27
+ apiKey: 'across-api-key',
28
+ integratorId: '0xdead',
29
+ userAddress: '0x1111111111111111111111111111111111111111',
30
+ }),
31
+ Relay.relay({ userAddress: '0x1111111111111111111111111111111111111111' }),
32
+ Rhino.rhino(),
33
+ Squid.squid({
34
+ integratorId: 'squid-integrator-id',
35
+ userAddress: '0x1111111111111111111111111111111111111111',
36
+ }),
37
+ Symbiosis.symbiosis({ userAddress: '0x1111111111111111111111111111111111111111' }),
38
+ ] as const
39
+
40
+ beforeAll(() => TestFunding.publish(db))
41
+
42
+ function create(options: TestApp.create.Options = {}) {
43
+ return TestApp.create({ ...options, db })
44
+ }
45
+
46
+ describe('GET /funding/quotes', () => {
47
+ test('publishes alphabetically ordered quote example fields', async () => {
48
+ const app = create({ auth: false })
49
+ const spec = await (await app.request('/openapi.json')).json()
50
+ const operation = spec.paths['/v1/funding/quotes'].get
51
+ const response = operation.responses['200'].content['application/json']
52
+ const fields = Object.keys(response.example.data[0])
53
+
54
+ expect(fields).toEqual([...fields].sort())
55
+ })
56
+
57
+ test('returns successful live quotes with output amounts', async () => {
58
+ const app = create({ providers: [relayProvider()] })
59
+ const response = await app.request(quoteUrl(), { headers: TestApp.auth.headers })
60
+ expect(response.status).toBe(200)
61
+ expect(response.headers.get('cache-control')).toBe('no-store')
62
+ const body = await TestApp.json(response, Funding.schema.quoteFunding.Response)
63
+
64
+ expect(body.data).toHaveLength(1)
65
+ expect(body.data[0]).toMatchObject({
66
+ destinationAmount: {
67
+ baseUnits: '990000',
68
+ currency: 'USD',
69
+ decimals: 6,
70
+ formatted: '0.99',
71
+ },
72
+ destinationAmountMin: {
73
+ baseUnits: '980000',
74
+ currency: 'USD',
75
+ decimals: 6,
76
+ formatted: '0.98',
77
+ },
78
+ id: 'base-usdc-tempo-usdce-relay',
79
+ provider: { id: 'relay' },
80
+ quality: { liquiditySource: 'providerQuote', tier: 'liquid' },
81
+ quote: { sampledAt: '2026-01-01T00:00:00Z' },
82
+ sourceAmount: { baseUnits: '1000000', currency: 'USD', decimals: 6, formatted: '1' },
83
+ })
84
+ expect(body.data[0]?.sourceToken).not.toHaveProperty('amount')
85
+ expect(body.data[0]?.destinationToken).not.toHaveProperty('amount')
86
+ })
87
+
88
+ test('resolves token identifiers through the composed route', async () => {
89
+ const app = create({ providers: [relayProvider()] })
90
+ const identifiers = [
91
+ { destinationToken: 'usdc.e', name: 'symbol', sourceToken: 'USDC' },
92
+ { destinationToken: 'usdce', name: 'slug', sourceToken: 'usdc' },
93
+ {
94
+ destinationToken: '0x20c000000000000000000000b9537d11c60e8b50',
95
+ name: 'address',
96
+ sourceToken: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
97
+ },
98
+ {
99
+ destinationToken: 'eip155:4217/erc20:0x20c000000000000000000000b9537d11c60e8b50',
100
+ name: 'token key',
101
+ sourceToken: 'eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
102
+ },
103
+ ] as const
104
+ const results = []
105
+ for (const identifier of identifiers) {
106
+ const response = await app.request(
107
+ quoteUrl({
108
+ destinationToken: identifier.destinationToken,
109
+ sourceAmount: '1000000',
110
+ sourceChain: 'base',
111
+ sourceToken: identifier.sourceToken,
112
+ }),
113
+ { headers: TestApp.auth.headers },
114
+ )
115
+ const body = await TestApp.json(response, Funding.schema.quoteFunding.Response)
116
+ results.push({
117
+ destinationToken: body.data[0]?.destinationToken.symbol,
118
+ name: identifier.name,
119
+ sourceToken: body.data[0]?.sourceToken.symbol,
120
+ status: response.status,
121
+ })
122
+ }
123
+
124
+ expect(results).toMatchInlineSnapshot(`
125
+ [
126
+ {
127
+ "destinationToken": "USDC.e",
128
+ "name": "symbol",
129
+ "sourceToken": "USDC",
130
+ "status": 200,
131
+ },
132
+ {
133
+ "destinationToken": "USDC.e",
134
+ "name": "slug",
135
+ "sourceToken": "USDC",
136
+ "status": 200,
137
+ },
138
+ {
139
+ "destinationToken": "USDC.e",
140
+ "name": "address",
141
+ "sourceToken": "USDC",
142
+ "status": 200,
143
+ },
144
+ {
145
+ "destinationToken": "USDC.e",
146
+ "name": "token key",
147
+ "sourceToken": "USDC",
148
+ "status": 200,
149
+ },
150
+ ]
151
+ `)
152
+ })
153
+
154
+ test('queries only the requested provider', async () => {
155
+ let acrossCalls = 0
156
+ let relayCalls = 0
157
+ const app = create({
158
+ providers: [
159
+ acrossProvider(() => {
160
+ acrossCalls += 1
161
+ }),
162
+ relayProvider(() => {
163
+ relayCalls += 1
164
+ }),
165
+ ],
166
+ })
167
+ const response = await app.request(quoteUrl({ ...baseUsdcQuery, provider: 'across' }), {
168
+ headers: TestApp.auth.headers,
169
+ })
170
+
171
+ expect(response.status).toBe(200)
172
+ expect(acrossCalls).toBe(1)
173
+ expect(relayCalls).toBe(0)
174
+ const body = await TestApp.json(response, Funding.schema.quoteFunding.Response)
175
+ expect(body.data[0]?.quote.expiresAt).toBe('2026-01-01T00:01:00Z')
176
+ })
177
+
178
+ test('returns non-EVM Rhino quotes with stable chain and token ids', async () => {
179
+ const app = create({ providers: [rhinoProvider()] })
180
+ const response = await app.request(
181
+ quoteUrl({
182
+ destinationToken: 'USDC.e',
183
+ provider: 'rhino',
184
+ sourceAmount: '1000000',
185
+ sourceChain: 'solana',
186
+ sourceToken: 'USDC',
187
+ }),
188
+ { headers: TestApp.auth.headers },
189
+ )
190
+
191
+ expect(response.status).toBe(200)
192
+ const body = await TestApp.json(response, Funding.schema.quoteFunding.Response)
193
+ expect(body.data[0]).toMatchObject({
194
+ id: 'solana-usdc-tempo-usdce-rhino',
195
+ provider: { id: 'rhino' },
196
+ sourceChain: {
197
+ addressFormat: 'base58',
198
+ id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
199
+ kind: 'solana',
200
+ },
201
+ sourceToken: {
202
+ tokenKey:
203
+ 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
204
+ },
205
+ })
206
+ })
207
+
208
+ test('returns an empty list when no provider is available', async () => {
209
+ const response = await create().request(quoteUrl(), {
210
+ headers: TestApp.auth.headers,
211
+ })
212
+ expect(response.status).toBe(200)
213
+ const body = await TestApp.json(response, Funding.schema.quoteFunding.Response)
214
+ expect(body.data).toEqual([])
215
+ })
216
+
217
+ test('returns an empty list when the provider reports no quote', async () => {
218
+ const entries: Log.Entry[] = []
219
+ const app = create({
220
+ logger: (entry) => {
221
+ entries.push(entry)
222
+ },
223
+ providers: [
224
+ withGetQuote('relay', async () => ({
225
+ sampledAt: '2026-01-01T00:00:00Z',
226
+ status: 'unavailable',
227
+ })),
228
+ ],
229
+ })
230
+ const response = await app.request(quoteUrl(), { headers: TestApp.auth.headers })
231
+ expect(response.status).toBe(200)
232
+ const body = await TestApp.json(response, Funding.schema.quoteFunding.Response)
233
+ expect(body.data).toEqual([])
234
+ expect(entries[0]?.fundingProviderAttempts).toEqual([
235
+ {
236
+ durationMs: expect.any(Number),
237
+ id: 'relay',
238
+ operation: 'getQuote',
239
+ outcome: 'unavailable',
240
+ },
241
+ ])
242
+ })
243
+
244
+ test('returns 502 when every matching provider fails', async () => {
245
+ const app = create({
246
+ providers: [
247
+ withGetQuote('relay', async () => {
248
+ throw new Error('upstream unavailable')
249
+ }),
250
+ ],
251
+ })
252
+ const response = await app.request(quoteUrl(), { headers: TestApp.auth.headers })
253
+ expect(response.status).toBe(502)
254
+ const body = await TestApp.json(response, Schema.ErrorResponse)
255
+ expect(body.error.code).toBe('upstream_error')
256
+ })
257
+
258
+ test('logs provider quote deadlines as timeouts', async () => {
259
+ vi.useFakeTimers()
260
+ const entries: Log.Entry[] = []
261
+ const app = create({
262
+ logger: (entry) => {
263
+ entries.push(entry)
264
+ },
265
+ providers: [
266
+ withGetQuote('across', () => new Promise<FundingProvider.getQuote.ReturnType>(() => {})),
267
+ ],
268
+ })
269
+
270
+ try {
271
+ const response_promise = app.request(quoteUrl({ ...baseUsdcQuery, provider: 'across' }), {
272
+ headers: TestApp.auth.headers,
273
+ })
274
+ await vi.advanceTimersByTimeAsync(2_000)
275
+ const response = await response_promise
276
+
277
+ expect(response.status).toBe(502)
278
+ expect(entries[0]?.provider).toEqual({
279
+ failure: 'timeout',
280
+ id: 'across',
281
+ operation: 'getQuote',
282
+ })
283
+ expect(entries[0]?.fundingProviderAttempts).toEqual([
284
+ {
285
+ durationMs: expect.any(Number),
286
+ failure: 'timeout',
287
+ id: 'across',
288
+ operation: 'getQuote',
289
+ outcome: 'failed',
290
+ },
291
+ ])
292
+ } finally {
293
+ vi.useRealTimers()
294
+ }
295
+ })
296
+
297
+ test('logs every failure when multiple providers fail', async () => {
298
+ const entries: Log.Entry[] = []
299
+ const app = create({
300
+ logger: (entry) => {
301
+ entries.push(entry)
302
+ },
303
+ providers: [
304
+ withGetQuote('across', async () => {
305
+ throw new TypeError('Across network failure')
306
+ }),
307
+ withGetQuote('relay', async () => {
308
+ throw new Error('Relay failure')
309
+ }),
310
+ ],
311
+ })
312
+
313
+ const response = await app.request(quoteUrl(), { headers: TestApp.auth.headers })
314
+
315
+ expect(response.status).toBe(502)
316
+ expect(entries[0]?.provider).toEqual({
317
+ failure: 'network',
318
+ id: 'across',
319
+ operation: 'getQuote',
320
+ })
321
+ expect(entries[0]?.providerFailures).toEqual([
322
+ { failure: 'network', id: 'across', operation: 'getQuote' },
323
+ { failure: 'unknown', id: 'relay', operation: 'getQuote' },
324
+ ])
325
+ expect(entries[0]?.fundingProviderAttempts).toEqual([
326
+ {
327
+ durationMs: expect.any(Number),
328
+ failure: 'network',
329
+ id: 'across',
330
+ operation: 'getQuote',
331
+ outcome: 'failed',
332
+ },
333
+ {
334
+ durationMs: expect.any(Number),
335
+ failure: 'unknown',
336
+ id: 'relay',
337
+ operation: 'getQuote',
338
+ outcome: 'failed',
339
+ },
340
+ ])
341
+ })
342
+
343
+ test('logs failed providers when another provider returns a quote', async () => {
344
+ const entries: Log.Entry[] = []
345
+ const app = create({
346
+ logger: (entry) => {
347
+ entries.push(entry)
348
+ },
349
+ providers: [
350
+ withGetQuote('across', async () => {
351
+ throw new TypeError(`wallet ${'0xaa'.repeat(20)} could not reach secret-provider`)
352
+ }),
353
+ relayProvider(),
354
+ ],
355
+ })
356
+
357
+ const response = await app.request(quoteUrl(), { headers: TestApp.auth.headers })
358
+
359
+ expect(response.status).toBe(200)
360
+ expect(entries[0]?.fundingProviderAttempts).toEqual([
361
+ {
362
+ durationMs: expect.any(Number),
363
+ failure: 'network',
364
+ id: 'across',
365
+ operation: 'getQuote',
366
+ outcome: 'failed',
367
+ },
368
+ {
369
+ durationMs: expect.any(Number),
370
+ id: 'relay',
371
+ operation: 'getQuote',
372
+ outcome: 'available',
373
+ },
374
+ ])
375
+ expect(JSON.stringify(entries[0])).not.toContain('secret-provider')
376
+ expect(JSON.stringify(entries[0])).not.toContain('0xaa')
377
+ })
378
+
379
+ test('rejects successful provider results without output amounts', async () => {
380
+ const app = create({
381
+ providers: [
382
+ withGetQuote('relay', async () => ({
383
+ sampledAt: '2026-01-01T00:00:00Z',
384
+ status: 'available',
385
+ })),
386
+ ],
387
+ })
388
+ const response = await app.request(quoteUrl(), { headers: TestApp.auth.headers })
389
+ expect(response.status).toBe(502)
390
+ })
391
+
392
+ test('rejects invalid query parameters', async () => {
393
+ const response = await create().request(
394
+ quoteUrl({ sourceAmount: '1000000', sourceChain: 'base' }),
395
+ { headers: TestApp.auth.headers },
396
+ )
397
+ expect(response.status).toBe(400)
398
+ const body = await TestApp.json(response, Schema.ErrorResponse)
399
+ expect(body.error.code).toBe('query_invalid')
400
+ })
401
+
402
+ test('rejects unsupported providers', async () => {
403
+ const response = await create().request(quoteUrl({ ...baseUsdcQuery, provider: 'bridge' }), {
404
+ headers: TestApp.auth.headers,
405
+ })
406
+ expect(response.status).toBe(400)
407
+ const body = await TestApp.json(response, Schema.ErrorResponse)
408
+ expect(body.error.code).toBe('query_invalid')
409
+ })
410
+
411
+ test('rejects unsupported source chains', async () => {
412
+ const response = await create().request(
413
+ quoteUrl({ ...baseUsdcQuery, sourceChain: 'bitcoin' }),
414
+ {
415
+ headers: TestApp.auth.headers,
416
+ },
417
+ )
418
+ expect(response.status).toBe(400)
419
+ const body = await TestApp.json(response, Schema.ErrorResponse)
420
+ expect(body.error.code).toBe('query_invalid')
421
+ })
422
+
423
+ test('does not expose the removed routes endpoint', async () => {
424
+ const response = await create().request(
425
+ '/v1/funding/routes?sourceChain=base&sourceToken=USDC&sourceAmount=1000000',
426
+ { headers: TestApp.auth.headers },
427
+ )
428
+ expect(response.status).toBe(404)
429
+ })
430
+ })
431
+
432
+ const baseUsdcQuery = {
433
+ sourceAmount: '1000000',
434
+ sourceChain: 'base',
435
+ sourceToken: 'USDC',
436
+ } as const
437
+
438
+ type QuoteQuery = Record<string, string>
439
+
440
+ function quoteUrl(query: QuoteQuery = baseUsdcQuery) {
441
+ return `/v1/funding/quotes?${new URLSearchParams(
442
+ Object.entries(query).map(([key, value]) => [key, String(value)]),
443
+ )}`
444
+ }
445
+
446
+ function relayProvider(onGetQuote: () => void = () => {}) {
447
+ return withGetQuote('relay', async (input, signal) => {
448
+ onGetQuote()
449
+ expect(signal.aborted).toBe(false)
450
+ expect(input.candidate.id).toBe('base-usdc-tempo-usdce-relay')
451
+ return {
452
+ destinationAmountMin: '980000',
453
+ destinationAmount: '990000',
454
+ quality: {
455
+ estimatedSeconds: 4,
456
+ liquiditySource: 'providerQuote',
457
+ sourceDetail: 'relay:quote-v2',
458
+ tier: 'liquid',
459
+ },
460
+ sampledAt: '2026-01-01T00:00:00Z',
461
+ status: 'available',
462
+ }
463
+ })
464
+ }
465
+
466
+ function acrossProvider(onGetQuote: () => void = () => {}) {
467
+ return withGetQuote('across', async (input, signal) => {
468
+ onGetQuote()
469
+ expect(signal.aborted).toBe(false)
470
+ expect(input.candidate.id).toBe('base-usdc-tempo-usdce-across')
471
+ return {
472
+ expiresAt: '2026-01-01T00:01:00Z',
473
+ destinationAmountMin: '988000',
474
+ destinationAmount: '990000',
475
+ quality: {
476
+ estimatedSeconds: 2,
477
+ liquiditySource: 'providerQuote',
478
+ sourceDetail: 'across:swap-approval',
479
+ tier: 'liquid',
480
+ },
481
+ sampledAt: '2026-01-01T00:00:00Z',
482
+ status: 'available',
483
+ }
484
+ })
485
+ }
486
+
487
+ function rhinoProvider() {
488
+ return withGetQuote('rhino', async (input, signal) => {
489
+ expect(signal.aborted).toBe(false)
490
+ expect(input.candidate.id).toBe('solana-usdc-tempo-usdce-rhino')
491
+ return {
492
+ destinationAmount: '983000',
493
+ quality: {
494
+ liquiditySource: 'providerQuote',
495
+ sourceDetail: 'rhino:bridge-swap-public',
496
+ tier: 'liquid',
497
+ },
498
+ sampledAt: '2026-01-01T00:00:00Z',
499
+ status: 'available',
500
+ }
501
+ })
502
+ }
503
+
504
+ function withGetQuote(
505
+ id: FundingProvider.ProviderId,
506
+ getQuote: FundingProvider.Provider['getQuote'],
507
+ ) {
508
+ const provider = providers.find((entry) => entry.id === id)
509
+ if (!provider) throw new Error(`Missing ${id} provider`)
510
+ return FundingProvider.from({ ...provider, getQuote })
511
+ }