tapimo 0.4.4 → 0.5.1
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.
- package/dist/App.d.ts +4701 -3416
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +24 -2
- package/dist/App.js.map +1 -1
- package/dist/Assets.js +3 -3
- package/dist/Assets.js.map +1 -1
- package/dist/Scope.d.ts +18 -1
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +23 -3
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.d.ts +1 -1
- package/dist/Webhooks.d.ts.map +1 -1
- package/dist/Webhooks.js +5 -10
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/App.d.ts +6 -34
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +3 -3
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +4 -1
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/scopes.d.ts +6 -34
- package/dist/admin/apps/scopes.d.ts.map +1 -1
- package/dist/admin/apps/scopes.js +2 -2
- package/dist/admin/apps/scopes.js.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +57 -57
- package/dist/admin/ui.generated.d.ts +1 -1
- package/dist/admin/ui.generated.js +33 -33
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/apps/data/App.d.ts +4574 -4277
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +155 -77
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/FundingQuoteProviders.d.ts +109 -0
- package/dist/apps/data/FundingQuoteProviders.d.ts.map +1 -0
- package/dist/apps/data/FundingQuoteProviders.js +464 -0
- package/dist/apps/data/FundingQuoteProviders.js.map +1 -0
- package/dist/apps/data/index.d.ts +1 -1
- package/dist/apps/data/index.js +1 -1
- package/dist/apps/data/routes/activities.d.ts +26 -26
- package/dist/apps/data/routes/addresses.d.ts +38 -38
- package/dist/apps/data/routes/balances.d.ts +45 -45
- package/dist/apps/data/routes/balances.d.ts.map +1 -1
- package/dist/apps/data/routes/balances.js +67 -149
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +2 -3
- package/dist/apps/data/routes/blocks.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.js +3 -5
- package/dist/apps/data/routes/blocks.js.map +1 -1
- package/dist/apps/data/routes/coingecko.d.ts +177 -176
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +3 -8
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/funding.d.ts +131 -228
- package/dist/apps/data/routes/funding.d.ts.map +1 -1
- package/dist/apps/data/routes/funding.js +152 -219
- package/dist/apps/data/routes/funding.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +34 -34
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +9 -2
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +228 -228
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +86 -16
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +12 -12
- package/dist/apps/data/routes/verified-tokens.d.ts +5 -5
- package/dist/apps/data/routes/webhooks.d.ts +340 -0
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +13 -1
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/index.d.ts +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/apps/management/App.d.ts +1833 -851
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/App.js +4 -0
- package/dist/apps/management/App.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +41 -41
- package/dist/apps/management/routes/api-keys.js +2 -2
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +48 -48
- package/dist/apps/management/routes/invitations.d.ts +132 -132
- package/dist/apps/management/routes/invite-links.d.ts +1100 -0
- package/dist/apps/management/routes/invite-links.d.ts.map +1 -0
- package/dist/apps/management/routes/invite-links.js +411 -0
- package/dist/apps/management/routes/invite-links.js.map +1 -0
- package/dist/apps/management/routes/members.d.ts +41 -41
- package/dist/apps/management/routes/orgs.d.ts +92 -92
- package/dist/apps/management/routes/projects.d.ts +9 -9
- package/dist/apps/management/routes/scopes.d.ts.map +1 -1
- package/dist/apps/management/routes/scopes.js +2 -2
- package/dist/apps/management/routes/scopes.js.map +1 -1
- package/dist/apps/management/routes/usage.d.ts +24 -24
- package/dist/apps/mcp.js +2 -2
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/relay/App.d.ts +2 -2
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +44 -6
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/db/Db.d.ts +3 -0
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +57 -0
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +31 -0
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +31 -0
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/inviteLinks.d.ts +42 -0
- package/dist/db/tables/inviteLinks.d.ts.map +1 -0
- package/dist/db/tables/inviteLinks.js +148 -0
- package/dist/db/tables/inviteLinks.js.map +1 -0
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +2 -0
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +6 -2
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/handlers/relay.d.ts.map +1 -1
- package/dist/handlers/relay.js +13 -3
- package/dist/handlers/relay.js.map +1 -1
- package/dist/internal/Auth.d.ts +9 -1
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +138 -10
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/EdgeCache.d.ts +3 -1
- package/dist/internal/EdgeCache.d.ts.map +1 -1
- package/dist/internal/EdgeCache.js +17 -2
- package/dist/internal/EdgeCache.js.map +1 -1
- package/dist/internal/{FundingRoutes.d.ts → FundingQuotes.d.ts} +240 -369
- package/dist/internal/FundingQuotes.d.ts.map +1 -0
- package/dist/internal/{FundingRoutes.js → FundingQuotes.js} +144 -183
- package/dist/internal/FundingQuotes.js.map +1 -0
- package/dist/internal/Log.d.ts +18 -12
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +2 -0
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/Tidx.d.ts +9 -3
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +13 -7
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Viem.d.ts +17 -2
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +30 -3
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +1 -1
- package/package.json +2 -2
- package/src/ApiKeys.test.ts +25 -0
- package/src/App.test-d.ts +2 -0
- package/src/App.test.ts +13 -2
- package/src/App.ts +37 -5
- package/src/Assets.ts +3 -3
- package/src/Client.test-d.ts +21 -11
- package/src/Scope.test.ts +1 -0
- package/src/Scope.ts +32 -4
- package/src/Webhooks.ts +5 -10
- package/src/admin/apps/api-keys.test.ts +27 -0
- package/src/admin/apps/api-keys.ts +8 -1
- package/src/admin/apps/scopes.test.ts +7 -2
- package/src/admin/apps/scopes.ts +2 -2
- package/src/admin/ui/src/components/Dialog.tsx +8 -2
- package/src/admin/ui/src/lib/scopes.test.ts +19 -0
- package/src/admin/ui/src/lib/scopes.ts +12 -0
- package/src/admin/ui/src/routes/api-keys.tsx +128 -27
- package/src/admin/ui.generated.ts +33 -33
- package/src/apps/composition.test.ts +77 -0
- package/src/apps/data/App.test.ts +354 -0
- package/src/apps/data/App.ts +178 -91
- package/src/apps/data/FundingQuoteProviders.test.ts +577 -0
- package/src/apps/data/FundingQuoteProviders.ts +633 -0
- package/src/apps/data/index.ts +1 -1
- package/src/apps/data/routes/balances.test.ts +64 -18
- package/src/apps/data/routes/balances.ts +76 -177
- package/src/apps/data/routes/blocks.ts +3 -5
- package/src/apps/data/routes/coingecko.ts +3 -8
- package/src/apps/data/routes/funding.test.ts +304 -192
- package/src/apps/data/routes/funding.ts +166 -286
- package/src/apps/data/routes/indexer.test.ts +173 -15
- package/src/apps/data/routes/indexer.ts +8 -2
- package/src/apps/data/routes/rpc.test.ts +219 -0
- package/src/apps/data/routes/rpc.ts +92 -17
- package/src/apps/data/routes/webhooks.test.ts +21 -0
- package/src/apps/data/routes/webhooks.ts +13 -1
- package/src/apps/index.ts +1 -1
- package/src/apps/management/App.ts +4 -0
- package/src/apps/management/Billing.test.ts +2 -2
- package/src/apps/management/routes/api-keys.test.ts +47 -3
- package/src/apps/management/routes/api-keys.ts +2 -2
- package/src/apps/management/routes/invite-links.test.ts +385 -0
- package/src/apps/management/routes/invite-links.ts +570 -0
- package/src/apps/management/routes/scopes.test.ts +3 -2
- package/src/apps/management/routes/scopes.ts +4 -2
- package/src/apps/mcp.test.ts +18 -0
- package/src/apps/mcp.ts +2 -2
- package/src/apps/relay/App.test.ts +328 -7
- package/src/apps/relay/App.ts +42 -6
- package/src/apps/relay/Sponsorships.test.ts +2 -2
- package/src/db/Db.test.ts +5 -5
- package/src/db/Db.ts +65 -0
- package/src/db/Schema.ts +39 -0
- package/src/db/tables/billingSettings.test.ts +2 -2
- package/src/db/tables/inviteLinks.ts +187 -0
- package/src/db/tables/organizations.test.ts +2 -2
- package/src/db/tables/organizations.ts +2 -0
- package/src/db/tables/sponsoredTransactions.test.ts +19 -2
- package/src/db/tables/sponsoredTransactions.ts +21 -14
- package/src/db/tables/stripeCustomers.test.ts +2 -2
- package/src/handlers/relay.ts +16 -4
- package/src/internal/Auth.test.ts +132 -22
- package/src/internal/Auth.ts +181 -14
- package/src/internal/EdgeCache.test.ts +24 -3
- package/src/internal/EdgeCache.ts +18 -2
- package/src/internal/FundingQuotes.test.ts +268 -0
- package/src/internal/{FundingRoutes.ts → FundingQuotes.ts} +216 -277
- package/src/internal/Log.ts +21 -14
- package/src/internal/Tidx.test.ts +48 -0
- package/src/internal/Tidx.ts +21 -7
- package/src/internal/Viem.test.ts +46 -0
- package/src/internal/Viem.ts +48 -6
- package/src/internal/index.test.ts +1 -1
- package/src/internal/index.ts +1 -1
- package/dist/apps/data/FundingRouteProviders.d.ts +0 -36
- package/dist/apps/data/FundingRouteProviders.d.ts.map +0 -1
- package/dist/apps/data/FundingRouteProviders.js +0 -245
- package/dist/apps/data/FundingRouteProviders.js.map +0 -1
- package/dist/internal/FundingRoutes.d.ts.map +0 -1
- package/dist/internal/FundingRoutes.js.map +0 -1
- package/src/apps/data/FundingRouteProviders.test.ts +0 -225
- package/src/apps/data/FundingRouteProviders.ts +0 -312
- package/src/internal/FundingRoutes.test.ts +0 -213
|
@@ -9,7 +9,7 @@ const destinationChain = {
|
|
|
9
9
|
/** Tempo token used when the caller omits `destinationToken`. */
|
|
10
10
|
const defaultDestinationToken = 'usdce'
|
|
11
11
|
|
|
12
|
-
/** Source chains
|
|
12
|
+
/** Source chains considered by funding quote providers. */
|
|
13
13
|
const sourceChains = [
|
|
14
14
|
{
|
|
15
15
|
addressFormat: 'evm',
|
|
@@ -18,9 +18,7 @@ const sourceChains = [
|
|
|
18
18
|
kind: 'evm',
|
|
19
19
|
name: 'Ethereum',
|
|
20
20
|
providerIds: {
|
|
21
|
-
|
|
22
|
-
bungee: '1',
|
|
23
|
-
lifi: '1',
|
|
21
|
+
across: '1',
|
|
24
22
|
relay: '1',
|
|
25
23
|
},
|
|
26
24
|
slug: 'ethereum',
|
|
@@ -74,10 +72,9 @@ const sourceChains = [
|
|
|
74
72
|
kind: 'evm',
|
|
75
73
|
name: 'Base',
|
|
76
74
|
providerIds: {
|
|
77
|
-
|
|
78
|
-
bungee: '8453',
|
|
79
|
-
lifi: '8453',
|
|
75
|
+
across: '8453',
|
|
80
76
|
relay: '8453',
|
|
77
|
+
rhino: 'BASE',
|
|
81
78
|
},
|
|
82
79
|
slug: 'base',
|
|
83
80
|
tokens: [
|
|
@@ -114,8 +111,7 @@ const sourceChains = [
|
|
|
114
111
|
kind: 'evm',
|
|
115
112
|
name: 'BNB Smart Chain',
|
|
116
113
|
providerIds: {
|
|
117
|
-
|
|
118
|
-
lifi: '56',
|
|
114
|
+
across: '56',
|
|
119
115
|
relay: '56',
|
|
120
116
|
},
|
|
121
117
|
slug: 'bnb',
|
|
@@ -139,14 +135,13 @@ const sourceChains = [
|
|
|
139
135
|
],
|
|
140
136
|
},
|
|
141
137
|
{
|
|
142
|
-
addressFormat: '
|
|
143
|
-
aliases: ['solana', 'solana:
|
|
144
|
-
id: 'solana:
|
|
138
|
+
addressFormat: 'base58',
|
|
139
|
+
aliases: ['solana', 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'],
|
|
140
|
+
id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
145
141
|
kind: 'solana',
|
|
146
142
|
name: 'Solana',
|
|
147
143
|
providerIds: {
|
|
148
|
-
|
|
149
|
-
relay: 'solana',
|
|
144
|
+
rhino: 'SOLANA',
|
|
150
145
|
},
|
|
151
146
|
slug: 'solana',
|
|
152
147
|
tokens: [
|
|
@@ -158,25 +153,16 @@ const sourceChains = [
|
|
|
158
153
|
standard: 'SPL',
|
|
159
154
|
symbol: 'USDC',
|
|
160
155
|
},
|
|
161
|
-
{
|
|
162
|
-
address: 'Es9vMFrzaCERmJfrF4H2FYD4KCo3LwC1uix9YEaQ8t1v',
|
|
163
|
-
coingeckoId: 'tether',
|
|
164
|
-
decimals: 6,
|
|
165
|
-
name: 'Tether USD',
|
|
166
|
-
standard: 'SPL',
|
|
167
|
-
symbol: 'USDT',
|
|
168
|
-
},
|
|
169
156
|
],
|
|
170
157
|
},
|
|
171
158
|
{
|
|
172
|
-
addressFormat: '
|
|
173
|
-
aliases: ['tron', 'tron:
|
|
174
|
-
id: 'tron:
|
|
159
|
+
addressFormat: 'base58check',
|
|
160
|
+
aliases: ['tron', 'tron:0x2b6653dc'],
|
|
161
|
+
id: 'tron:0x2b6653dc',
|
|
175
162
|
kind: 'tron',
|
|
176
163
|
name: 'Tron',
|
|
177
164
|
providerIds: {
|
|
178
|
-
|
|
179
|
-
relay: 'tron',
|
|
165
|
+
rhino: 'TRON',
|
|
180
166
|
},
|
|
181
167
|
slug: 'tron',
|
|
182
168
|
tokens: [
|
|
@@ -192,7 +178,7 @@ const sourceChains = [
|
|
|
192
178
|
},
|
|
193
179
|
] as const
|
|
194
180
|
|
|
195
|
-
/** Tempo destination tokens supported by
|
|
181
|
+
/** Tempo destination tokens supported by funding quote providers. */
|
|
196
182
|
const destinationTokens = [
|
|
197
183
|
{
|
|
198
184
|
address: '0x20c0000000000000000000000000000000000000',
|
|
@@ -236,39 +222,28 @@ const destinationTokens = [
|
|
|
236
222
|
},
|
|
237
223
|
] as const
|
|
238
224
|
|
|
239
|
-
/** Providers
|
|
225
|
+
/** Providers supported by live funding quotes. */
|
|
240
226
|
const providers = [
|
|
241
227
|
{
|
|
242
|
-
|
|
228
|
+
id: 'across',
|
|
229
|
+
kind: 'intentBridge',
|
|
230
|
+
name: 'Across',
|
|
231
|
+
requiresApiKey: true,
|
|
232
|
+
status: 'unconfigured',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
243
235
|
id: 'relay',
|
|
244
236
|
kind: 'solverNetwork',
|
|
245
237
|
name: 'Relay',
|
|
246
238
|
requiresApiKey: false,
|
|
247
|
-
status: '
|
|
239
|
+
status: 'unconfigured',
|
|
248
240
|
},
|
|
249
241
|
{
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
name: 'Bridge.xyz',
|
|
254
|
-
requiresApiKey: true,
|
|
255
|
-
status: 'inventoryOnly',
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
capabilities: ['fundingRoutes'],
|
|
259
|
-
id: 'bungee',
|
|
260
|
-
kind: 'aggregator',
|
|
261
|
-
name: 'Bungee',
|
|
242
|
+
id: 'rhino',
|
|
243
|
+
kind: 'bridge',
|
|
244
|
+
name: 'Rhino',
|
|
262
245
|
requiresApiKey: false,
|
|
263
|
-
status: '
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
capabilities: ['fundingRoutes'],
|
|
267
|
-
id: 'lifi',
|
|
268
|
-
kind: 'aggregator',
|
|
269
|
-
name: 'LI.FI',
|
|
270
|
-
requiresApiKey: true,
|
|
271
|
-
status: 'planned',
|
|
246
|
+
status: 'unconfigured',
|
|
272
247
|
},
|
|
273
248
|
] as const
|
|
274
249
|
|
|
@@ -277,17 +252,14 @@ type DestinationTokenInput = (typeof destinationTokens)[number]
|
|
|
277
252
|
type ProviderInput = (typeof providers)[number]
|
|
278
253
|
type SourceChainInput = (typeof sourceChains)[number]
|
|
279
254
|
|
|
280
|
-
/** Provider ids accepted by
|
|
255
|
+
/** Provider ids accepted by funding quote requests. */
|
|
281
256
|
export type ProviderId = ProviderInput['id']
|
|
282
257
|
|
|
283
|
-
/** Provider-specific
|
|
284
|
-
export type
|
|
285
|
-
|
|
286
|
-
/** Machine-readable route quality tier. */
|
|
287
|
-
export type QualityTier = 'liquid' | 'thin' | 'unknown' | 'unavailable' | 'error'
|
|
258
|
+
/** Provider-specific quote status for the requested amount. */
|
|
259
|
+
export type QuoteStatus = 'available' | 'thin' | 'unknown' | 'unavailable'
|
|
288
260
|
|
|
289
|
-
/**
|
|
290
|
-
export type
|
|
261
|
+
/** Machine-readable quote quality tier. */
|
|
262
|
+
export type QualityTier = 'liquid' | 'thin' | 'unknown' | 'unavailable'
|
|
291
263
|
|
|
292
264
|
/** Normalized chain reference passed to provider adapters. */
|
|
293
265
|
export type ChainRef = ReturnType<typeof formatChain> | typeof destinationChain
|
|
@@ -300,10 +272,13 @@ export type TokenRef =
|
|
|
300
272
|
| ReturnType<typeof formatDestinationToken>
|
|
301
273
|
| ReturnType<typeof formatSourceToken>
|
|
302
274
|
|
|
303
|
-
/** A normalized
|
|
304
|
-
export type
|
|
275
|
+
/** A normalized internal candidate passed to funding quote providers. */
|
|
276
|
+
export type QuoteCandidate = ReturnType<typeof formatQuoteCandidate>
|
|
305
277
|
|
|
306
|
-
/**
|
|
278
|
+
/** A successful normalized funding quote returned to callers. */
|
|
279
|
+
export type FundingQuote = ReturnType<typeof formatFundingQuote>
|
|
280
|
+
|
|
281
|
+
/** Cache policy for a single funding quote request. */
|
|
307
282
|
export type CachePolicy = {
|
|
308
283
|
/** Whether provider adapters should bypass their own quote or inventory caches. */
|
|
309
284
|
bypass: boolean
|
|
@@ -313,10 +288,6 @@ export type CachePolicy = {
|
|
|
313
288
|
export type QuoteRequest = {
|
|
314
289
|
/** Optional Tempo destination token symbol, address, or token key. */
|
|
315
290
|
destinationToken?: string | undefined
|
|
316
|
-
/** Response expansions requested by the caller. */
|
|
317
|
-
include: readonly Include[]
|
|
318
|
-
/** Maximum number of route candidates requested by the caller. */
|
|
319
|
-
limit: number
|
|
320
291
|
/** Optional provider id filter. */
|
|
321
292
|
provider?: string | undefined
|
|
322
293
|
/** Source amount as supplied by the caller. */
|
|
@@ -329,20 +300,18 @@ export type QuoteRequest = {
|
|
|
329
300
|
sourceToken: string
|
|
330
301
|
}
|
|
331
302
|
|
|
332
|
-
/** Input passed to a provider adapter for one
|
|
303
|
+
/** Input passed to a provider adapter for one curated quote candidate. */
|
|
333
304
|
export type QuoteProbeInput = {
|
|
334
|
-
/** Cache policy for provider-side
|
|
305
|
+
/** Cache policy for provider-side discovery and quote lookups. */
|
|
335
306
|
cache: CachePolicy
|
|
336
307
|
/** Destination chain, always Tempo mainnet in V1. */
|
|
337
308
|
destinationChain: ChainRef
|
|
338
|
-
/** Tempo token expected from this
|
|
309
|
+
/** Tempo token expected from this quote. */
|
|
339
310
|
destinationToken: TokenRef
|
|
340
|
-
/**
|
|
341
|
-
include: readonly Include[]
|
|
342
|
-
/** Normalized caller request that produced this route candidate. */
|
|
311
|
+
/** Normalized caller request that produced this quote candidate. */
|
|
343
312
|
request: QuoteRequest
|
|
344
|
-
/**
|
|
345
|
-
|
|
313
|
+
/** Curated candidate selected for live provider quoting. */
|
|
314
|
+
candidate: QuoteCandidate
|
|
346
315
|
/** Source amount in base units and display form. */
|
|
347
316
|
sourceAmount: TokenAmount
|
|
348
317
|
/** Chain where the caller currently holds funds. */
|
|
@@ -351,72 +320,56 @@ export type QuoteProbeInput = {
|
|
|
351
320
|
sourceToken: TokenRef
|
|
352
321
|
}
|
|
353
322
|
|
|
354
|
-
/** Provider-specific source amount limits, expressed in source base units. */
|
|
355
|
-
export type QuoteProbeLimits = {
|
|
356
|
-
/** Provider-reported instant source amount capacity. */
|
|
357
|
-
instantSourceAmount?: string | null | undefined
|
|
358
|
-
/** Provider-reported maximum source amount. */
|
|
359
|
-
maxSourceAmount?: string | null | undefined
|
|
360
|
-
/** Provider-reported minimum source amount. */
|
|
361
|
-
minSourceAmount?: string | null | undefined
|
|
362
|
-
}
|
|
363
|
-
|
|
364
323
|
/** Quote probe data returned by a provider adapter. */
|
|
365
324
|
export type QuoteProbeResult = {
|
|
366
|
-
/**
|
|
367
|
-
|
|
368
|
-
/** Provider quote expiry timestamp. */
|
|
369
|
-
expiresAt?: string | null | undefined
|
|
370
|
-
/** Provider-reported source amount limits. */
|
|
371
|
-
limits?: QuoteProbeLimits | null | undefined
|
|
325
|
+
/** Timestamp after which the provider quote is no longer valid. */
|
|
326
|
+
expiresAt?: string | undefined
|
|
372
327
|
/** Slippage-adjusted minimum destination amount in base units. */
|
|
373
|
-
minimumOutputAmount?: string |
|
|
328
|
+
minimumOutputAmount?: string | undefined
|
|
374
329
|
/** Expected destination amount in base units. */
|
|
375
|
-
outputAmount?: string |
|
|
330
|
+
outputAmount?: string | undefined
|
|
376
331
|
/** Expected destination amount rendered with destination token decimals. */
|
|
377
|
-
outputAmountFormatted?: string |
|
|
378
|
-
/** Timestamp for the live quote
|
|
332
|
+
outputAmountFormatted?: string | undefined
|
|
333
|
+
/** Timestamp for the live quote probe. */
|
|
379
334
|
sampledAt: string
|
|
380
|
-
/** Provider-specific
|
|
381
|
-
status:
|
|
382
|
-
/** Provider-backed
|
|
335
|
+
/** Provider-specific quote status for the requested amount. */
|
|
336
|
+
status: QuoteStatus
|
|
337
|
+
/** Provider-backed quote quality metadata. */
|
|
383
338
|
quality?: {
|
|
384
|
-
/** Available USD capacity, when available. */
|
|
385
|
-
availableVolumeUsd?: string | null | undefined
|
|
386
339
|
/** Estimated settlement time in seconds, when known. */
|
|
387
|
-
estimatedSeconds?: number |
|
|
388
|
-
/** Estimated fee in basis points, when known. */
|
|
389
|
-
feeBps?: number | null | undefined
|
|
390
|
-
/** 24h routed volume in USD, when available. */
|
|
391
|
-
historicalVolumeUsd24h?: string | null | undefined
|
|
392
|
-
/** Instant USD capacity, when available. */
|
|
393
|
-
instantVolumeUsd?: string | null | undefined
|
|
340
|
+
estimatedSeconds?: number | undefined
|
|
394
341
|
/** Where the live liquidity or support signal came from. */
|
|
395
342
|
liquiditySource: string
|
|
396
|
-
/** Explainable route score from 0 to 100, when enough signals are available. */
|
|
397
|
-
score?: number | null | undefined
|
|
398
343
|
/** Provider-specific quote source or endpoint detail. */
|
|
399
|
-
sourceDetail?: string |
|
|
400
|
-
/** Machine-readable
|
|
344
|
+
sourceDetail?: string | undefined
|
|
345
|
+
/** Machine-readable quote quality tier. */
|
|
401
346
|
tier?: QualityTier | undefined
|
|
402
347
|
}
|
|
403
348
|
}
|
|
404
349
|
|
|
405
|
-
/** Adapter used to
|
|
350
|
+
/** Adapter used to request a live provider quote. */
|
|
406
351
|
export type ProviderAdapter = {
|
|
407
352
|
/** Probes provider-backed quote information for one static candidate. */
|
|
408
353
|
probeQuote(input: QuoteProbeInput, signal: AbortSignal): Promise<QuoteProbeResult>
|
|
409
354
|
}
|
|
410
355
|
|
|
411
|
-
/** Provider adapter registry, keyed by provider id.
|
|
356
|
+
/** Provider adapter registry, keyed by provider id. */
|
|
412
357
|
export type ProviderAdapters = Partial<Record<ProviderId, ProviderAdapter>>
|
|
413
358
|
|
|
414
|
-
/**
|
|
359
|
+
/** A provider adapter failure retained for bounded request diagnostics. */
|
|
360
|
+
export type ProviderFailure = {
|
|
361
|
+
/** Error thrown by the provider boundary. */
|
|
362
|
+
cause: unknown
|
|
363
|
+
/** Provider that failed. */
|
|
364
|
+
provider: ProviderId
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** Curated provider support rows used to select live quote probes. */
|
|
415
368
|
const inventory: readonly InventoryEntry[] = [
|
|
369
|
+
{ destinationToken: 'usdce', provider: 'across', sourceChains: ['ethereum', 'base', 'bnb'], sourceTokens: ['USDC'] }, // prettier-ignore
|
|
416
370
|
{ destinationToken: 'usdce', provider: 'relay', sourceChains: ['ethereum', 'base', 'bnb'], sourceTokens: ['USDC', 'USDT'] }, // prettier-ignore
|
|
417
|
-
{ destinationToken: 'usdce', provider: '
|
|
418
|
-
{ destinationToken: '
|
|
419
|
-
{ destinationToken: 'usdce', provider: 'bungee', sourceChains: ['ethereum', 'base', 'bnb'], sourceTokens: ['USDC'] }, // prettier-ignore
|
|
371
|
+
{ destinationToken: 'usdce', provider: 'rhino', sourceChains: ['base', 'solana'], sourceTokens: ['USDC'] }, // prettier-ignore
|
|
372
|
+
{ destinationToken: 'usdt0', provider: 'rhino', sourceChains: ['tron'], sourceTokens: ['USDT'] }, // prettier-ignore
|
|
420
373
|
]
|
|
421
374
|
|
|
422
375
|
type InventoryEntry = {
|
|
@@ -426,27 +379,34 @@ type InventoryEntry = {
|
|
|
426
379
|
sourceTokens: readonly string[]
|
|
427
380
|
}
|
|
428
381
|
|
|
429
|
-
const defaultAdapterTimeoutMs =
|
|
430
|
-
const includes = ['quotes'] as const
|
|
382
|
+
const defaultAdapterTimeoutMs = 2_000
|
|
431
383
|
|
|
432
|
-
/** Lists normalized chains and source tokens
|
|
384
|
+
/** Lists normalized chains and source tokens supported by quote providers. */
|
|
433
385
|
export function listChains() {
|
|
434
|
-
return sourceChains.
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
386
|
+
return sourceChains.flatMap((chain) => {
|
|
387
|
+
const symbols = new Set(
|
|
388
|
+
inventory
|
|
389
|
+
.filter((entry) => entry.sourceChains.includes(chain.slug))
|
|
390
|
+
.flatMap((entry) => entry.sourceTokens),
|
|
391
|
+
)
|
|
392
|
+
if (symbols.size === 0) return []
|
|
393
|
+
return [
|
|
394
|
+
{
|
|
395
|
+
...formatChain(chain),
|
|
396
|
+
tokens: chain.tokens
|
|
397
|
+
.filter((token) => symbols.has(token.symbol))
|
|
398
|
+
.map((token) => formatSourceToken(chain, token)),
|
|
399
|
+
},
|
|
400
|
+
]
|
|
401
|
+
})
|
|
438
402
|
}
|
|
439
403
|
|
|
440
|
-
/** Lists
|
|
404
|
+
/** Lists funding quote providers and their deployment status. */
|
|
441
405
|
export function listProviders(options: listProviders.Options = {}) {
|
|
442
|
-
return providers
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
.map((provider) => ({
|
|
447
|
-
...formatProvider(provider),
|
|
448
|
-
status: options.adapters?.[provider.id] ? ('configured' as const) : provider.status,
|
|
449
|
-
}))
|
|
406
|
+
return providers.map((provider) => ({
|
|
407
|
+
...formatProvider(provider),
|
|
408
|
+
status: options.adapters?.[provider.id] ? ('configured' as const) : provider.status,
|
|
409
|
+
}))
|
|
450
410
|
}
|
|
451
411
|
|
|
452
412
|
export declare namespace listProviders {
|
|
@@ -454,39 +414,19 @@ export declare namespace listProviders {
|
|
|
454
414
|
type Options = {
|
|
455
415
|
/** Provider adapters configured for this deployment. */
|
|
456
416
|
adapters?: ProviderAdapters | undefined
|
|
457
|
-
/** Provider capability to require. */
|
|
458
|
-
capability?: Capability | undefined
|
|
459
417
|
}
|
|
460
418
|
}
|
|
461
419
|
|
|
462
|
-
/**
|
|
463
|
-
export function
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
.
|
|
467
|
-
|
|
468
|
-
.filter(Boolean)
|
|
469
|
-
for (const include of parsed)
|
|
470
|
-
if (!(includes as readonly string[]).includes(include)) throw new UnsupportedIncludeError()
|
|
471
|
-
return [...new Set(parsed)] as readonly Include[]
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/** Lists funding route candidates, enriching static inventory when adapters are configured. */
|
|
475
|
-
export async function listRoutes(options: listRoutes.Options) {
|
|
476
|
-
const routes = listStaticRoutes(options)
|
|
477
|
-
const adapterEntries = Object.entries(options.adapters ?? {})
|
|
478
|
-
if (adapterEntries.length === 0) return routes
|
|
479
|
-
|
|
480
|
-
return Promise.all(
|
|
481
|
-
routes.map((route) =>
|
|
482
|
-
enrichRoute(route, {
|
|
420
|
+
/** Returns successful live funding quotes from configured providers. */
|
|
421
|
+
export async function listQuotes(options: listQuotes.Options) {
|
|
422
|
+
const candidates = listQuoteCandidates(options)
|
|
423
|
+
const results = await Promise.allSettled(
|
|
424
|
+
candidates.map((candidate) =>
|
|
425
|
+
quoteCandidate(candidate, {
|
|
483
426
|
adapters: options.adapters ?? {},
|
|
484
427
|
cache: options.cache ?? { bypass: false },
|
|
485
|
-
include: options.include ?? [],
|
|
486
428
|
request: {
|
|
487
429
|
destinationToken: options.destinationToken,
|
|
488
|
-
include: options.include ?? [],
|
|
489
|
-
limit: options.limit,
|
|
490
430
|
provider: options.provider,
|
|
491
431
|
sourceAmount: options.sourceAmount,
|
|
492
432
|
sourceAmountUnits: options.sourceAmountUnits,
|
|
@@ -497,10 +437,20 @@ export async function listRoutes(options: listRoutes.Options) {
|
|
|
497
437
|
}),
|
|
498
438
|
),
|
|
499
439
|
)
|
|
440
|
+
const quotes = results.flatMap((result) =>
|
|
441
|
+
result.status === 'fulfilled' && result.value ? [result.value] : [],
|
|
442
|
+
)
|
|
443
|
+
const failures = results.flatMap((result, index) =>
|
|
444
|
+
result.status === 'rejected'
|
|
445
|
+
? [{ cause: result.reason, provider: candidates[index]!.provider.id }]
|
|
446
|
+
: [],
|
|
447
|
+
)
|
|
448
|
+
if (quotes.length === 0 && failures.length > 0) throw new ProviderQuoteError(failures)
|
|
449
|
+
return quotes
|
|
500
450
|
}
|
|
501
451
|
|
|
502
|
-
/** Lists
|
|
503
|
-
export function
|
|
452
|
+
/** Lists internal quote candidates for a normalized caller request. */
|
|
453
|
+
export function listQuoteCandidates(options: listQuoteCandidates.Options) {
|
|
504
454
|
const sourceChain = resolveSourceChain(options.sourceChain)
|
|
505
455
|
const sourceToken = resolveSourceToken(sourceChain, options.sourceToken)
|
|
506
456
|
const destinationToken = resolveDestinationToken(options.destinationToken)
|
|
@@ -522,9 +472,8 @@ export function listStaticRoutes(options: listStaticRoutes.Options) {
|
|
|
522
472
|
.filter((entry) => entry.sourceTokens.includes(sourceToken.symbol))
|
|
523
473
|
.filter((entry) => entry.destinationToken === destinationToken.slug)
|
|
524
474
|
.filter((entry) => provider === undefined || entry.provider === provider.id)
|
|
525
|
-
.slice(0, options.limit)
|
|
526
475
|
.map((entry) =>
|
|
527
|
-
|
|
476
|
+
formatQuoteCandidate({
|
|
528
477
|
destinationToken,
|
|
529
478
|
provider: providers.find((candidate) => candidate.id === entry.provider)!,
|
|
530
479
|
sourceAmount,
|
|
@@ -534,13 +483,11 @@ export function listStaticRoutes(options: listStaticRoutes.Options) {
|
|
|
534
483
|
)
|
|
535
484
|
}
|
|
536
485
|
|
|
537
|
-
export declare namespace
|
|
538
|
-
/** Options for
|
|
486
|
+
export declare namespace listQuoteCandidates {
|
|
487
|
+
/** Options for selecting funding quote candidates. */
|
|
539
488
|
type Options = {
|
|
540
489
|
/** Optional Tempo destination token symbol, address, or token key. */
|
|
541
490
|
destinationToken?: string | undefined
|
|
542
|
-
/** Maximum number of route candidates to return. */
|
|
543
|
-
limit: number
|
|
544
491
|
/** Optional provider id filter. */
|
|
545
492
|
provider?: string | undefined
|
|
546
493
|
/** Source amount as supplied by the caller. */
|
|
@@ -554,30 +501,28 @@ export declare namespace listStaticRoutes {
|
|
|
554
501
|
}
|
|
555
502
|
}
|
|
556
503
|
|
|
557
|
-
export declare namespace
|
|
558
|
-
/** Options for
|
|
559
|
-
type Options =
|
|
560
|
-
/** Provider adapters used to
|
|
504
|
+
export declare namespace listQuotes {
|
|
505
|
+
/** Options for requesting live funding quotes. */
|
|
506
|
+
type Options = listQuoteCandidates.Options & {
|
|
507
|
+
/** Provider adapters used to request live quotes. */
|
|
561
508
|
adapters?: ProviderAdapters | undefined
|
|
562
509
|
/** Per-provider quote timeout in milliseconds. */
|
|
563
510
|
adapterTimeoutMs?: number | undefined
|
|
564
|
-
/** Cache policy for provider-side
|
|
511
|
+
/** Cache policy for provider-side discovery and quote lookups. */
|
|
565
512
|
cache?: CachePolicy | undefined
|
|
566
|
-
/** Response expansions requested by the caller. */
|
|
567
|
-
include?: readonly Include[] | undefined
|
|
568
513
|
}
|
|
569
514
|
}
|
|
570
515
|
|
|
571
|
-
/**
|
|
572
|
-
export type Capability = 'fundingRoutes'
|
|
573
|
-
|
|
574
|
-
/** Source amount unit accepted by the funding route request. */
|
|
516
|
+
/** Source amount unit accepted by the funding quote request. */
|
|
575
517
|
export type SourceAmountUnits = 'baseUnits' | 'decimal'
|
|
576
518
|
|
|
577
|
-
function tokenKey(chain: { id: string }, token: TokenInput | DestinationTokenInput) {
|
|
578
|
-
const
|
|
579
|
-
|
|
580
|
-
|
|
519
|
+
function tokenKey(chain: { id: string; kind: string }, token: TokenInput | DestinationTokenInput) {
|
|
520
|
+
const namespace = (() => {
|
|
521
|
+
if (chain.kind === 'solana') return 'token'
|
|
522
|
+
if (chain.kind === 'tron') return 'trc20'
|
|
523
|
+
return 'erc20'
|
|
524
|
+
})()
|
|
525
|
+
return `${chain.id}/${namespace}:${token.address}`
|
|
581
526
|
}
|
|
582
527
|
|
|
583
528
|
function decimalFromBaseUnits(baseUnits: string, decimals: number) {
|
|
@@ -587,52 +532,47 @@ function decimalFromBaseUnits(baseUnits: string, decimals: number) {
|
|
|
587
532
|
return fraction ? `${whole}.${fraction}` : whole
|
|
588
533
|
}
|
|
589
534
|
|
|
590
|
-
async function
|
|
591
|
-
|
|
535
|
+
async function quoteCandidate(
|
|
536
|
+
candidate: QuoteCandidate,
|
|
592
537
|
options: {
|
|
593
538
|
adapters: ProviderAdapters
|
|
594
539
|
cache: CachePolicy
|
|
595
|
-
include: readonly Include[]
|
|
596
540
|
request: QuoteRequest
|
|
597
541
|
timeoutMs: number
|
|
598
542
|
},
|
|
599
543
|
) {
|
|
600
|
-
const adapter = options.adapters[
|
|
601
|
-
if (!adapter) return
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
}
|
|
633
|
-
} catch (cause) {
|
|
634
|
-
return markRouteError(route, cause instanceof ProviderAdapterTimeoutError ? 'provider_timeout' : 'provider_error') // prettier-ignore
|
|
635
|
-
}
|
|
544
|
+
const adapter = options.adapters[candidate.provider.id as ProviderId]
|
|
545
|
+
if (!adapter) return undefined
|
|
546
|
+
|
|
547
|
+
const quote = await runWithTimeout(
|
|
548
|
+
(signal) =>
|
|
549
|
+
adapter.probeQuote(
|
|
550
|
+
{
|
|
551
|
+
cache: options.cache,
|
|
552
|
+
destinationChain: candidate.destinationChain,
|
|
553
|
+
destinationToken: candidate.destinationToken,
|
|
554
|
+
request: options.request,
|
|
555
|
+
candidate,
|
|
556
|
+
sourceAmount: candidate.sourceAmount,
|
|
557
|
+
sourceChain: candidate.sourceChain,
|
|
558
|
+
sourceToken: candidate.sourceToken,
|
|
559
|
+
},
|
|
560
|
+
signal,
|
|
561
|
+
),
|
|
562
|
+
options.timeoutMs,
|
|
563
|
+
)
|
|
564
|
+
if (quote.status === 'unavailable') return undefined
|
|
565
|
+
if (
|
|
566
|
+
(quote.status !== 'available' && quote.status !== 'thin') ||
|
|
567
|
+
quote.outputAmount === undefined ||
|
|
568
|
+
quote.outputAmount === null
|
|
569
|
+
)
|
|
570
|
+
throw new InvalidProviderQuoteError()
|
|
571
|
+
return formatFundingQuote(candidate, {
|
|
572
|
+
...quote,
|
|
573
|
+
outputAmount: quote.outputAmount,
|
|
574
|
+
status: quote.status,
|
|
575
|
+
})
|
|
636
576
|
}
|
|
637
577
|
|
|
638
578
|
function formatChain(chain: SourceChainInput) {
|
|
@@ -655,7 +595,7 @@ function formatDestinationToken(token: DestinationTokenInput) {
|
|
|
655
595
|
|
|
656
596
|
function formatProvider(provider: ProviderInput) {
|
|
657
597
|
const { id, kind, name, requiresApiKey, status } = provider
|
|
658
|
-
return {
|
|
598
|
+
return { id, kind, name, requiresApiKey, status }
|
|
659
599
|
}
|
|
660
600
|
|
|
661
601
|
function formatProviderRef(provider: ProviderInput) {
|
|
@@ -663,7 +603,7 @@ function formatProviderRef(provider: ProviderInput) {
|
|
|
663
603
|
return { id, kind, name, requiresApiKey }
|
|
664
604
|
}
|
|
665
605
|
|
|
666
|
-
function
|
|
606
|
+
function formatQuoteCandidate(options: {
|
|
667
607
|
destinationToken: DestinationTokenInput
|
|
668
608
|
provider: ProviderInput
|
|
669
609
|
sourceAmount: ReturnType<typeof resolveSourceAmount>
|
|
@@ -673,7 +613,6 @@ function formatRouteCandidate(options: {
|
|
|
673
613
|
return {
|
|
674
614
|
destinationChain,
|
|
675
615
|
destinationToken: formatDestinationToken(options.destinationToken),
|
|
676
|
-
errorCode: null,
|
|
677
616
|
id: [
|
|
678
617
|
options.sourceChain.slug,
|
|
679
618
|
options.sourceToken.symbol.toLowerCase(),
|
|
@@ -682,22 +621,9 @@ function formatRouteCandidate(options: {
|
|
|
682
621
|
options.provider.id,
|
|
683
622
|
].join('-'),
|
|
684
623
|
provider: formatProviderRef(options.provider),
|
|
685
|
-
quality: {
|
|
686
|
-
availableVolumeUsd: null,
|
|
687
|
-
estimatedSeconds: null,
|
|
688
|
-
feeBps: null,
|
|
689
|
-
historicalVolumeUsd24h: null,
|
|
690
|
-
instantVolumeUsd: null,
|
|
691
|
-
liquiditySource: 'staticInventory',
|
|
692
|
-
score: null,
|
|
693
|
-
sourceDetail: null,
|
|
694
|
-
tier: 'unknown',
|
|
695
|
-
},
|
|
696
|
-
quote: null,
|
|
697
624
|
sourceAmount: options.sourceAmount,
|
|
698
625
|
sourceChain: formatChain(options.sourceChain),
|
|
699
626
|
sourceToken: formatSourceToken(options.sourceChain, options.sourceToken),
|
|
700
|
-
status: 'unknown',
|
|
701
627
|
} as const
|
|
702
628
|
}
|
|
703
629
|
|
|
@@ -732,38 +658,37 @@ function parseDecimalUnits(value: string, decimals: number) {
|
|
|
732
658
|
return baseUnits.toString()
|
|
733
659
|
}
|
|
734
660
|
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
inputAmount: route.sourceAmount.amount,
|
|
739
|
-
limits: quote.limits
|
|
740
|
-
? {
|
|
741
|
-
instantSourceAmount: quote.limits.instantSourceAmount ?? null,
|
|
742
|
-
maxSourceAmount: quote.limits.maxSourceAmount ?? null,
|
|
743
|
-
minSourceAmount: quote.limits.minSourceAmount ?? null,
|
|
744
|
-
}
|
|
745
|
-
: null,
|
|
746
|
-
minimumOutputAmount: quote.minimumOutputAmount ?? null,
|
|
747
|
-
outputAmount: quote.outputAmount ?? null,
|
|
748
|
-
outputAmountFormatted: quote.outputAmountFormatted ?? null,
|
|
749
|
-
sampledAt: quote.sampledAt,
|
|
750
|
-
} as const
|
|
661
|
+
type SuccessfulQuoteProbe = QuoteProbeResult & {
|
|
662
|
+
outputAmount: string
|
|
663
|
+
status: 'available' | 'thin'
|
|
751
664
|
}
|
|
752
665
|
|
|
753
|
-
function
|
|
666
|
+
function formatFundingQuote(candidate: QuoteCandidate, quote: SuccessfulQuoteProbe) {
|
|
754
667
|
return {
|
|
755
|
-
...
|
|
756
|
-
errorCode,
|
|
668
|
+
...candidate,
|
|
757
669
|
quality: {
|
|
758
|
-
...
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
670
|
+
...(quote.quality?.estimatedSeconds !== undefined
|
|
671
|
+
? { estimatedSeconds: quote.quality.estimatedSeconds }
|
|
672
|
+
: {}),
|
|
673
|
+
liquiditySource: quote.quality?.liquiditySource ?? 'providerQuote',
|
|
674
|
+
...(quote.quality?.sourceDetail !== undefined
|
|
675
|
+
? { sourceDetail: quote.quality.sourceDetail }
|
|
676
|
+
: {}),
|
|
677
|
+
tier: quote.status === 'thin' ? ('thin' as const) : ('liquid' as const),
|
|
763
678
|
},
|
|
764
|
-
quote:
|
|
765
|
-
|
|
766
|
-
|
|
679
|
+
quote: {
|
|
680
|
+
...(quote.expiresAt !== undefined ? { expiresAt: quote.expiresAt } : {}),
|
|
681
|
+
inputAmount: candidate.sourceAmount.amount,
|
|
682
|
+
...(quote.minimumOutputAmount !== undefined
|
|
683
|
+
? { minimumOutputAmount: quote.minimumOutputAmount }
|
|
684
|
+
: {}),
|
|
685
|
+
outputAmount: quote.outputAmount,
|
|
686
|
+
outputAmountFormatted:
|
|
687
|
+
quote.outputAmountFormatted ??
|
|
688
|
+
decimalFromBaseUnits(quote.outputAmount, candidate.destinationToken.decimals),
|
|
689
|
+
sampledAt: quote.sampledAt,
|
|
690
|
+
},
|
|
691
|
+
} as const
|
|
767
692
|
}
|
|
768
693
|
|
|
769
694
|
function runWithTimeout<result>(fn: (signal: AbortSignal) => Promise<result>, timeoutMs: number) {
|
|
@@ -811,7 +736,6 @@ function resolveSourceAmount(options: resolveSourceAmount.Options) {
|
|
|
811
736
|
return {
|
|
812
737
|
amount,
|
|
813
738
|
formatted: decimalFromBaseUnits(amount, options.token.decimals),
|
|
814
|
-
usd: null,
|
|
815
739
|
}
|
|
816
740
|
}
|
|
817
741
|
|
|
@@ -844,10 +768,13 @@ function matchesTokenIdentifier(
|
|
|
844
768
|
}
|
|
845
769
|
|
|
846
770
|
function resolveSourceChain(input: string) {
|
|
771
|
+
const trimmed = input.trim()
|
|
847
772
|
const normalized = normalizeInput(input)
|
|
848
773
|
const chain = sourceChains.find(
|
|
849
774
|
(candidate) =>
|
|
850
|
-
candidate.id ===
|
|
775
|
+
candidate.id === trimmed ||
|
|
776
|
+
candidate.slug === normalized ||
|
|
777
|
+
(candidate.kind === 'evm' && (candidate.aliases as readonly string[]).includes(normalized)),
|
|
851
778
|
)
|
|
852
779
|
if (!chain) throw new UnsupportedSourceChainError()
|
|
853
780
|
return chain
|
|
@@ -865,30 +792,42 @@ function validateSourceAmountSyntax(value: string, units: SourceAmountUnits) {
|
|
|
865
792
|
|
|
866
793
|
/** Error thrown when the caller supplies an unsupported destination token. */
|
|
867
794
|
export class UnsupportedDestinationTokenError extends Error {
|
|
868
|
-
override name = '
|
|
795
|
+
override name = 'FundingQuotes.UnsupportedDestinationTokenError'
|
|
869
796
|
}
|
|
870
797
|
|
|
871
798
|
/** Error thrown when the caller supplies an invalid source amount. */
|
|
872
799
|
export class InvalidAmountError extends Error {
|
|
873
|
-
override name = '
|
|
800
|
+
override name = 'FundingQuotes.InvalidAmountError'
|
|
874
801
|
}
|
|
875
802
|
|
|
876
|
-
/** Error thrown internally when a provider adapter exceeds its
|
|
803
|
+
/** Error thrown internally when a provider adapter exceeds its quote timeout. */
|
|
877
804
|
export class ProviderAdapterTimeoutError extends Error {
|
|
878
|
-
override name = '
|
|
805
|
+
override name = 'FundingQuotes.ProviderAdapterTimeoutError'
|
|
879
806
|
}
|
|
880
807
|
|
|
881
|
-
/** Error thrown when
|
|
882
|
-
export class
|
|
883
|
-
override name = '
|
|
808
|
+
/** Error thrown when every matching provider fails to produce a quote. */
|
|
809
|
+
export class ProviderQuoteError extends Error {
|
|
810
|
+
override name = 'FundingQuotes.ProviderQuoteError'
|
|
811
|
+
|
|
812
|
+
/** Provider failures that prevented a successful quote. */
|
|
813
|
+
failures: readonly ProviderFailure[]
|
|
814
|
+
|
|
815
|
+
constructor(failures: readonly ProviderFailure[]) {
|
|
816
|
+
super()
|
|
817
|
+
this.failures = failures
|
|
818
|
+
}
|
|
884
819
|
}
|
|
885
820
|
|
|
886
|
-
/** Error thrown when the caller
|
|
887
|
-
export class
|
|
888
|
-
override name = '
|
|
821
|
+
/** Error thrown when the caller filters to an unknown provider. */
|
|
822
|
+
export class UnsupportedProviderError extends Error {
|
|
823
|
+
override name = 'FundingQuotes.UnsupportedProviderError'
|
|
889
824
|
}
|
|
890
825
|
|
|
891
826
|
/** Error thrown when the caller supplies an unsupported source chain. */
|
|
892
827
|
export class UnsupportedSourceChainError extends Error {
|
|
893
|
-
override name = '
|
|
828
|
+
override name = 'FundingQuotes.UnsupportedSourceChainError'
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
class InvalidProviderQuoteError extends Error {
|
|
832
|
+
override name = 'FundingQuotes.InvalidProviderQuoteError'
|
|
894
833
|
}
|