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.
- package/dist/ApiKeys.d.ts +24 -7
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +17 -5
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +12104 -7861
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +191 -128
- package/dist/App.js.map +1 -1
- package/dist/Assets.d.ts +10 -0
- package/dist/Assets.d.ts.map +1 -1
- package/dist/Assets.js +17 -4
- package/dist/Assets.js.map +1 -1
- package/dist/Scope.d.ts +19 -8
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +25 -9
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.d.ts +1 -1
- package/dist/admin/App.d.ts +601 -20
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +12 -2
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +94 -11
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +141 -32
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +1069 -0
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -0
- package/dist/admin/apps/earn-vaults.js +409 -0
- package/dist/admin/apps/earn-vaults.js.map +1 -0
- package/dist/admin/apps/verified-tokens.d.ts +166 -166
- package/dist/admin/ui.generated.d.ts +1 -1
- package/dist/admin/ui.generated.d.ts.map +1 -1
- package/dist/admin/ui.generated.js +151 -95
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +2 -0
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +18 -2
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +22 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +59 -39
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/apps/Zones.d.ts +8335 -0
- package/dist/apps/Zones.d.ts.map +1 -0
- package/dist/apps/Zones.js +38 -0
- package/dist/apps/Zones.js.map +1 -0
- package/dist/apps/data/App.d.ts +14377 -10165
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +91 -19
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/FxOracle.d.ts +1 -1
- package/dist/apps/data/FxOracle.d.ts.map +1 -1
- package/dist/apps/data/index.d.ts +0 -1
- package/dist/apps/data/index.d.ts.map +1 -1
- package/dist/apps/data/index.js +0 -1
- package/dist/apps/data/index.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +32 -32
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +130 -65
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +312 -312
- package/dist/apps/data/routes/balances.d.ts +18 -18
- package/dist/apps/data/routes/balances.js +5 -5
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/coingecko.d.ts +176 -176
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +62 -35
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/earn.d.ts +2144 -0
- package/dist/apps/data/routes/earn.d.ts.map +1 -0
- package/dist/apps/data/routes/earn.js +947 -0
- package/dist/apps/data/routes/earn.js.map +1 -0
- package/dist/apps/data/routes/exchanges.d.ts +1231 -324
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +656 -193
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +59 -8
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/funding.d.ts +4092 -387
- package/dist/apps/data/routes/funding.d.ts.map +1 -1
- package/dist/apps/data/routes/funding.js +1403 -256
- package/dist/apps/data/routes/funding.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +5 -5
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +19 -2
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +265 -265
- package/dist/apps/data/routes/receipts.d.ts.map +1 -1
- package/dist/apps/data/routes/receipts.js +11 -11
- package/dist/apps/data/routes/receipts.js.map +1 -1
- package/dist/apps/data/routes/rpc.d.ts +5 -5
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +211 -22
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +36 -36
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +49 -9
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +116 -88
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +198 -91
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +55 -55
- package/dist/apps/data/routes/transactions.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.js +78 -39
- package/dist/apps/data/routes/transactions.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +78 -29
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +165 -67
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/valuation.d.ts +10 -10
- package/dist/apps/data/routes/valuation.js +2 -2
- package/dist/apps/data/routes/valuation.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/verified-tokens.js +34 -9
- package/dist/apps/data/routes/verified-tokens.js.map +1 -1
- package/dist/apps/data/routes/webhooks.d.ts +5 -3
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +175 -65
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +281 -0
- package/dist/apps/data/routes/zones.d.ts.map +1 -0
- package/dist/apps/data/routes/zones.js +252 -0
- package/dist/apps/data/routes/zones.js.map +1 -0
- package/dist/apps/docs/reference.js +6 -5
- package/dist/apps/docs/reference.js.map +1 -1
- package/dist/apps/index.d.ts +2 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +2 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +670 -670
- package/dist/apps/management/Billing.d.ts +8 -0
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +12 -0
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/Error.d.ts +12 -0
- package/dist/apps/management/Error.d.ts.map +1 -0
- package/dist/apps/management/Error.js +10 -0
- package/dist/apps/management/Error.js.map +1 -0
- package/dist/apps/management/routes/api-keys.d.ts +5 -5
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +2 -8
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +119 -119
- package/dist/apps/management/routes/faucet.d.ts +35 -35
- package/dist/apps/management/routes/invitations.d.ts +62 -62
- package/dist/apps/management/routes/invitations.d.ts.map +1 -1
- package/dist/apps/management/routes/invitations.js +4 -10
- package/dist/apps/management/routes/invitations.js.map +1 -1
- package/dist/apps/management/routes/invite-links.d.ts +30 -30
- package/dist/apps/management/routes/me.d.ts +6 -6
- package/dist/apps/management/routes/members.d.ts +78 -78
- package/dist/apps/management/routes/orgs.d.ts +48 -48
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +2 -8
- package/dist/apps/management/routes/orgs.js.map +1 -1
- package/dist/apps/management/routes/projects.d.ts +9 -9
- 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 +80 -80
- package/dist/apps/management/routes/verified-token-requests.d.ts +36 -36
- package/dist/apps/management/routes/webhooks.d.ts +50 -50
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +15 -3
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/mpp/App.d.ts +55 -56
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/App.js +192 -27
- package/dist/apps/mpp/App.js.map +1 -1
- package/dist/apps/mpp/Mpp.d.ts +0 -20
- package/dist/apps/mpp/Mpp.d.ts.map +1 -1
- package/dist/apps/mpp/Mpp.js +0 -24
- package/dist/apps/mpp/Mpp.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts +40 -0
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Adapter.js +66 -0
- package/dist/apps/mpp/internal/Adapter.js.map +1 -0
- package/dist/apps/mpp/internal/Error.d.ts +4 -0
- package/dist/apps/mpp/internal/Error.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Error.js +41 -0
- package/dist/apps/mpp/internal/Error.js.map +1 -0
- package/dist/apps/mpp/internal/Idempotency.d.ts +33 -0
- package/dist/apps/mpp/internal/Idempotency.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Idempotency.js +28 -0
- package/dist/apps/mpp/internal/Idempotency.js.map +1 -0
- package/dist/apps/mpp/internal/Policy.d.ts +46 -0
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Policy.js +57 -0
- package/dist/apps/mpp/internal/Policy.js.map +1 -0
- package/dist/apps/mpp/internal/ScreenManager.d.ts +27 -0
- package/dist/apps/mpp/internal/ScreenManager.d.ts.map +1 -0
- package/dist/apps/mpp/internal/ScreenManager.js +18 -0
- package/dist/apps/mpp/internal/ScreenManager.js.map +1 -0
- package/dist/apps/mpp/internal/Screening.d.ts +35 -0
- package/dist/apps/mpp/internal/Screening.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Screening.js +20 -0
- package/dist/apps/mpp/internal/Screening.js.map +1 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts +36 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Sponsorship.js +103 -0
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -0
- package/dist/apps/mpp/internal/Utils.d.ts +7 -0
- package/dist/apps/mpp/internal/Utils.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Utils.js +24 -0
- package/dist/apps/mpp/internal/Utils.js.map +1 -0
- package/dist/apps/relay/App.js +184 -24
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts +4 -0
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +16 -7
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/db/Db.d.ts +20 -0
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +342 -0
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +921 -1
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +269 -1
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/earnVaults.d.ts +68 -0
- package/dist/db/tables/earnVaults.d.ts.map +1 -0
- package/dist/db/tables/earnVaults.js +72 -0
- package/dist/db/tables/earnVaults.js.map +1 -0
- package/dist/db/tables/fundingCatalog.d.ts +56 -0
- package/dist/db/tables/fundingCatalog.d.ts.map +1 -0
- package/dist/db/tables/fundingCatalog.js +85 -0
- package/dist/db/tables/fundingCatalog.js.map +1 -0
- package/dist/db/tables/fundingDepositAddresses.d.ts +159 -0
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -0
- package/dist/db/tables/fundingDepositAddresses.js +206 -0
- package/dist/db/tables/fundingDepositAddresses.js.map +1 -0
- package/dist/db/tables/fundingDeposits.d.ts +115 -0
- package/dist/db/tables/fundingDeposits.d.ts.map +1 -0
- package/dist/db/tables/fundingDeposits.js +100 -0
- package/dist/db/tables/fundingDeposits.js.map +1 -0
- package/dist/db/tables/fundingIdempotency.d.ts +91 -0
- package/dist/db/tables/fundingIdempotency.d.ts.map +1 -0
- package/dist/db/tables/fundingIdempotency.js +103 -0
- package/dist/db/tables/fundingIdempotency.js.map +1 -0
- package/dist/db/tables/fundingTransferEvents.d.ts +12 -0
- package/dist/db/tables/fundingTransferEvents.d.ts.map +1 -0
- package/dist/db/tables/fundingTransferEvents.js +18 -0
- package/dist/db/tables/fundingTransferEvents.js.map +1 -0
- package/dist/db/tables/fundingTransferTransactions.d.ts +15 -0
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +1 -0
- package/dist/db/tables/fundingTransferTransactions.js +27 -0
- package/dist/db/tables/fundingTransferTransactions.js.map +1 -0
- package/dist/db/tables/fundingTransfers.d.ts +82 -0
- package/dist/db/tables/fundingTransfers.d.ts.map +1 -0
- package/dist/db/tables/fundingTransfers.js +89 -0
- package/dist/db/tables/fundingTransfers.js.map +1 -0
- package/dist/db/tables/organizations.d.ts +8 -0
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +35 -0
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +8 -0
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +16 -0
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/requestUsage.d.ts +13 -0
- package/dist/db/tables/requestUsage.d.ts.map +1 -1
- package/dist/db/tables/requestUsage.js +16 -0
- package/dist/db/tables/requestUsage.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts +4 -2
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +14 -4
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/users.d.ts +8 -0
- package/dist/db/tables/users.d.ts.map +1 -1
- package/dist/db/tables/users.js +16 -0
- package/dist/db/tables/users.js.map +1 -1
- package/dist/db/tables/verifiedTokens.d.ts +14 -7
- package/dist/db/tables/verifiedTokens.d.ts.map +1 -1
- package/dist/db/tables/verifiedTokens.js +9 -7
- package/dist/db/tables/verifiedTokens.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +31 -1
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +24 -3
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/relay.js +108 -108
- package/dist/handlers/relay.js.map +1 -1
- package/dist/internal/Auth.d.ts +26 -0
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +35 -2
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +16 -10
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/Cursor.js +1 -1
- package/dist/internal/Cursor.js.map +1 -1
- package/dist/internal/EarnRates.d.ts +89 -0
- package/dist/internal/EarnRates.d.ts.map +1 -0
- package/dist/internal/EarnRates.js +266 -0
- package/dist/internal/EarnRates.js.map +1 -0
- package/dist/internal/EarnVaults.d.ts +171 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -0
- package/dist/internal/EarnVaults.js +547 -0
- package/dist/internal/EarnVaults.js.map +1 -0
- package/dist/internal/EdgeCache.d.ts +9 -2
- package/dist/internal/EdgeCache.d.ts.map +1 -1
- package/dist/internal/EdgeCache.js +36 -9
- package/dist/internal/EdgeCache.js.map +1 -1
- package/dist/internal/Id.d.ts +11 -0
- package/dist/internal/Id.d.ts.map +1 -1
- package/dist/internal/Id.js +13 -0
- package/dist/internal/Id.js.map +1 -1
- package/dist/internal/Idempotency.d.ts +83 -0
- package/dist/internal/Idempotency.d.ts.map +1 -0
- package/dist/internal/Idempotency.js +113 -0
- package/dist/internal/Idempotency.js.map +1 -0
- package/dist/internal/Log.d.ts +64 -9
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +29 -7
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +47 -1
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +1 -1
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +3 -0
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Provider.d.ts +14 -0
- package/dist/internal/Provider.d.ts.map +1 -0
- package/dist/internal/Provider.js +5 -0
- package/dist/internal/Provider.js.map +1 -0
- package/dist/internal/Schema.d.ts +8 -3
- package/dist/internal/Schema.d.ts.map +1 -1
- package/dist/internal/Schema.js +24 -13
- package/dist/internal/Schema.js.map +1 -1
- package/dist/internal/Store.d.ts +6 -0
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +35 -0
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts +43 -24
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +79 -11
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Viem.d.ts +82 -65
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +83 -12
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/WebhookDestination.d.ts.map +1 -1
- package/dist/internal/WebhookDestination.js +34 -28
- package/dist/internal/WebhookDestination.js.map +1 -1
- package/dist/internal/Webhooks.d.ts +9 -0
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +15 -10
- package/dist/internal/Webhooks.js.map +1 -1
- package/dist/internal/exchange/Provider.d.ts +219 -0
- package/dist/internal/exchange/Provider.d.ts.map +1 -0
- package/dist/internal/exchange/Provider.js +117 -0
- package/dist/internal/exchange/Provider.js.map +1 -0
- package/dist/internal/exchange/index.d.ts +2 -0
- package/dist/internal/exchange/index.d.ts.map +1 -0
- package/dist/internal/exchange/index.js +2 -0
- package/dist/internal/exchange/index.js.map +1 -0
- package/dist/internal/exchange/providers/uniswap.d.ts +57 -0
- package/dist/internal/exchange/providers/uniswap.d.ts.map +1 -0
- package/dist/internal/exchange/providers/uniswap.js +553 -0
- package/dist/internal/exchange/providers/uniswap.js.map +1 -0
- package/dist/internal/funding/Action.d.ts +55 -0
- package/dist/internal/funding/Action.d.ts.map +1 -0
- package/dist/internal/funding/Action.js +74 -0
- package/dist/internal/funding/Action.js.map +1 -0
- package/dist/internal/funding/Catalog.d.ts +107 -0
- package/dist/internal/funding/Catalog.d.ts.map +1 -0
- package/dist/internal/funding/Catalog.js +270 -0
- package/dist/internal/funding/Catalog.js.map +1 -0
- package/dist/internal/funding/Chain.d.ts +76 -0
- package/dist/internal/funding/Chain.d.ts.map +1 -0
- package/dist/internal/funding/Chain.js +38 -0
- package/dist/internal/funding/Chain.js.map +1 -0
- package/dist/internal/funding/Deposit.d.ts +366 -0
- package/dist/internal/funding/Deposit.d.ts.map +1 -0
- package/dist/internal/funding/Deposit.js +286 -0
- package/dist/internal/funding/Deposit.js.map +1 -0
- package/dist/internal/funding/DepositAddress.d.ts +345 -0
- package/dist/internal/funding/DepositAddress.d.ts.map +1 -0
- package/dist/internal/funding/DepositAddress.js +189 -0
- package/dist/internal/funding/DepositAddress.js.map +1 -0
- package/dist/internal/funding/Evidence.d.ts +52 -0
- package/dist/internal/funding/Evidence.d.ts.map +1 -0
- package/dist/internal/funding/Evidence.js +314 -0
- package/dist/internal/funding/Evidence.js.map +1 -0
- package/dist/internal/funding/Provider.d.ts +1186 -0
- package/dist/internal/funding/Provider.d.ts.map +1 -0
- package/dist/internal/funding/Provider.js +1081 -0
- package/dist/internal/funding/Provider.js.map +1 -0
- package/dist/internal/funding/Reconciliation.d.ts +113 -0
- package/dist/internal/funding/Reconciliation.d.ts.map +1 -0
- package/dist/internal/funding/Reconciliation.js +676 -0
- package/dist/internal/funding/Reconciliation.js.map +1 -0
- package/dist/internal/funding/Route.d.ts +21 -0
- package/dist/internal/funding/Route.d.ts.map +1 -0
- package/dist/internal/funding/Route.js +5 -0
- package/dist/internal/funding/Route.js.map +1 -0
- package/dist/internal/funding/Subsidy.d.ts +113 -0
- package/dist/internal/funding/Subsidy.d.ts.map +1 -0
- package/dist/internal/funding/Subsidy.js +138 -0
- package/dist/internal/funding/Subsidy.js.map +1 -0
- package/dist/internal/funding/Token.d.ts +41 -0
- package/dist/internal/funding/Token.d.ts.map +1 -0
- package/dist/internal/funding/Token.js +22 -0
- package/dist/internal/funding/Token.js.map +1 -0
- package/dist/internal/funding/Transfer.d.ts +643 -0
- package/dist/internal/funding/Transfer.d.ts.map +1 -0
- package/dist/internal/funding/Transfer.js +332 -0
- package/dist/internal/funding/Transfer.js.map +1 -0
- package/dist/internal/funding/index.d.ts +13 -0
- package/dist/internal/funding/index.d.ts.map +1 -0
- package/dist/internal/funding/index.js +13 -0
- package/dist/internal/funding/index.js.map +1 -0
- package/dist/internal/funding/providers/across.d.ts +21 -0
- package/dist/internal/funding/providers/across.d.ts.map +1 -0
- package/dist/internal/funding/providers/across.js +117 -0
- package/dist/internal/funding/providers/across.js.map +1 -0
- package/dist/internal/funding/providers/relay.d.ts +46 -0
- package/dist/internal/funding/providers/relay.d.ts.map +1 -0
- package/dist/internal/funding/providers/relay.js +464 -0
- package/dist/internal/funding/providers/relay.js.map +1 -0
- package/dist/internal/funding/providers/rhino.d.ts +15 -0
- package/dist/internal/funding/providers/rhino.d.ts.map +1 -0
- package/dist/internal/funding/providers/rhino.js +116 -0
- package/dist/internal/funding/providers/rhino.js.map +1 -0
- package/dist/internal/funding/providers/squid.d.ts +19 -0
- package/dist/internal/funding/providers/squid.d.ts.map +1 -0
- package/dist/internal/funding/providers/squid.js +120 -0
- package/dist/internal/funding/providers/squid.js.map +1 -0
- package/dist/internal/funding/providers/symbiosis.d.ts +20 -0
- package/dist/internal/funding/providers/symbiosis.d.ts.map +1 -0
- package/dist/internal/funding/providers/symbiosis.js +176 -0
- package/dist/internal/funding/providers/symbiosis.js.map +1 -0
- package/dist/internal/index.d.ts +5 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +5 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/webhookDestinations/url.js +61 -57
- package/dist/internal/webhookDestinations/url.js.map +1 -1
- package/dist/providers/index.d.ts +43 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +19 -0
- package/dist/providers/index.js.map +1 -0
- package/package.json +9 -4
- package/src/ApiKeys.test.ts +11 -7
- package/src/ApiKeys.ts +37 -9
- package/src/App.test.ts +85 -10
- package/src/App.ts +224 -137
- package/src/Assets.ts +29 -4
- package/src/Client.test-d.ts +650 -30
- package/src/Scope.test.ts +19 -0
- package/src/Scope.ts +28 -11
- package/src/Webhooks.test.ts +25 -0
- package/src/Webhooks.ts +1 -1
- package/src/admin/App.test.ts +9 -2
- package/src/admin/App.ts +32 -9
- package/src/admin/apps/api-keys.test.ts +167 -23
- package/src/admin/apps/api-keys.ts +166 -28
- package/src/admin/apps/earn-vaults.test.ts +338 -0
- package/src/admin/apps/earn-vaults.ts +572 -0
- package/src/admin/apps/scopes.test.ts +16 -1
- package/src/admin/ui/plugin.ts +2 -2
- package/src/admin/ui/src/components/EarnVaultForm.tsx +137 -0
- package/src/admin/ui/src/components/MobileProfile.tsx +2 -2
- package/src/admin/ui/src/components/Page.tsx +1 -1
- package/src/admin/ui/src/components/ThemeToggle.tsx +1 -1
- package/src/admin/ui/src/lib/api-keys.ts +37 -7
- package/src/admin/ui/src/lib/client.ts +1 -1
- package/src/admin/ui/src/lib/config.ts +1 -1
- package/src/admin/ui/src/lib/early-access.ts +8 -9
- package/src/admin/ui/src/lib/earn-vaults.ts +207 -0
- package/src/admin/ui/src/lib/format.ts +13 -0
- package/src/admin/ui/src/lib/organizations.test.ts +14 -4
- package/src/admin/ui/src/lib/organizations.ts +7 -1
- package/src/admin/ui/src/lib/response.ts +22 -0
- package/src/admin/ui/src/lib/scopes.test.ts +19 -11
- package/src/admin/ui/src/lib/scopes.ts +28 -7
- package/src/admin/ui/src/lib/verified-tokens.ts +10 -9
- package/src/admin/ui/src/routeTree.gen.ts +70 -7
- package/src/admin/ui/src/router.tsx +2 -2
- package/src/admin/ui/src/routes/__root.tsx +9 -8
- package/src/admin/ui/src/routes/api-keys.tsx +475 -64
- package/src/admin/ui/src/routes/early-access.tsx +5 -12
- package/src/admin/ui/src/routes/earn.vaults.tsx +348 -0
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +154 -0
- package/src/admin/ui/src/routes/earn.vaults_.new.tsx +190 -0
- package/src/admin/ui/src/routes/organizations.tsx +4 -7
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +56 -54
- package/src/admin/ui/src/routes/verified-tokens.tsx +4 -4
- package/src/admin/ui/vite.config.ts +4 -1
- package/src/admin/ui.generated.ts +189 -95
- package/src/analytics/Analytics.test.ts +69 -10
- package/src/analytics/Analytics.ts +20 -1
- package/src/analytics/tables/requestEvents.ts +79 -37
- package/src/apps/Zones.test.ts +33 -0
- package/src/apps/Zones.ts +40 -0
- package/src/apps/composition.test.ts +84 -1
- package/src/apps/data/App.test.ts +38 -9
- package/src/apps/data/App.ts +96 -33
- package/src/apps/data/FxOracle.ts +1 -1
- package/src/apps/data/index.ts +0 -1
- package/src/apps/data/routes/activities.test.ts +82 -6
- package/src/apps/data/routes/activities.ts +131 -71
- package/src/apps/data/routes/balances.test.ts +50 -37
- package/src/apps/data/routes/balances.ts +5 -5
- package/src/apps/data/routes/blocks.test.ts +2 -0
- package/src/apps/data/routes/coingecko.test.ts +22 -0
- package/src/apps/data/routes/coingecko.ts +84 -48
- package/src/apps/data/routes/earn.test.ts +1108 -0
- package/src/apps/data/routes/earn.ts +1391 -0
- package/src/apps/data/routes/exchanges.test.ts +82 -33
- package/src/apps/data/routes/exchanges.ts +842 -227
- package/src/apps/data/routes/fee-amm.test.ts +4 -6
- package/src/apps/data/routes/fee-amm.ts +69 -12
- package/src/apps/data/routes/funding.test.ts +2712 -221
- package/src/apps/data/routes/funding.ts +1604 -387
- package/src/apps/data/routes/indexer.test.ts +43 -34
- package/src/apps/data/routes/indexer.ts +19 -2
- package/src/apps/data/routes/receipts.test.ts +5 -3
- package/src/apps/data/routes/receipts.ts +13 -11
- package/src/apps/data/routes/rpc.test.ts +446 -28
- package/src/apps/data/routes/rpc.ts +243 -25
- package/src/apps/data/routes/tokenlist.test.ts +15 -0
- package/src/apps/data/routes/tokenlist.ts +88 -22
- package/src/apps/data/routes/tokens.ts +262 -86
- package/src/apps/data/routes/transactions.test.ts +2 -0
- package/src/apps/data/routes/transactions.ts +77 -42
- package/src/apps/data/routes/transfers.test.ts +166 -4
- package/src/apps/data/routes/transfers.ts +216 -78
- package/src/apps/data/routes/valuation.test.ts +62 -9
- package/src/apps/data/routes/valuation.ts +2 -2
- package/src/apps/data/routes/verified-tokens.test.ts +51 -0
- package/src/apps/data/routes/verified-tokens.ts +52 -15
- package/src/apps/data/routes/webhooks.test.ts +432 -33
- package/src/apps/data/routes/webhooks.ts +189 -79
- package/src/apps/data/routes/zones.test.ts +473 -0
- package/src/apps/data/routes/zones.ts +338 -0
- package/src/apps/docs/reference.ts +8 -6
- package/src/apps/index.ts +2 -1
- package/src/apps/management/Billing.test.ts +29 -0
- package/src/apps/management/Billing.ts +23 -0
- package/src/apps/management/Error.ts +12 -0
- package/src/apps/management/routes/api-keys.test.ts +5 -3
- package/src/apps/management/routes/api-keys.ts +2 -9
- package/src/apps/management/routes/invitations.ts +4 -11
- package/src/apps/management/routes/orgs.ts +2 -9
- package/src/apps/management/routes/scopes.test.ts +7 -2
- package/src/apps/management/routes/scopes.ts +2 -2
- package/src/apps/management/routes/webhooks.test.ts +6 -1
- package/src/apps/management/routes/webhooks.ts +15 -3
- package/src/apps/mpp/App.ts +276 -29
- package/src/apps/mpp/Mpp.test.ts +631 -26
- package/src/apps/mpp/Mpp.ts +0 -42
- package/src/apps/mpp/internal/Adapter.ts +108 -3
- package/src/apps/mpp/internal/Error.test.ts +33 -0
- package/src/apps/mpp/internal/Error.ts +44 -6
- package/src/apps/mpp/internal/Idempotency.test.ts +213 -0
- package/src/apps/mpp/internal/Idempotency.ts +59 -5
- package/src/apps/mpp/internal/Policy.test.ts +122 -0
- package/src/apps/mpp/internal/Policy.ts +98 -0
- package/src/apps/mpp/internal/ScreenManager.test.ts +68 -0
- package/src/apps/mpp/internal/ScreenManager.ts +41 -0
- package/src/apps/mpp/internal/Screening.ts +40 -3
- package/src/apps/mpp/internal/Sponsorship.ts +144 -0
- package/src/apps/mpp/internal/Utils.ts +30 -0
- package/src/apps/relay/App.test.ts +495 -64
- package/src/apps/relay/App.ts +234 -24
- package/src/apps/relay/Sponsorships.test.ts +51 -0
- package/src/apps/relay/Sponsorships.ts +19 -7
- package/src/db/Db.ts +439 -0
- package/src/db/Schema.ts +325 -2
- package/src/db/tables/earnVaults.test.ts +185 -0
- package/src/db/tables/earnVaults.ts +151 -0
- package/src/db/tables/fundingCatalog.test.ts +108 -0
- package/src/db/tables/fundingCatalog.ts +157 -0
- package/src/db/tables/fundingDepositAddresses.test.ts +580 -0
- package/src/db/tables/fundingDepositAddresses.ts +376 -0
- package/src/db/tables/fundingDeposits.test.ts +261 -0
- package/src/db/tables/fundingDeposits.ts +229 -0
- package/src/db/tables/fundingIdempotency.test.ts +182 -0
- package/src/db/tables/fundingIdempotency.ts +180 -0
- package/src/db/tables/fundingTransferEvents.ts +28 -0
- package/src/db/tables/fundingTransferTransactions.test.ts +69 -0
- package/src/db/tables/fundingTransferTransactions.ts +37 -0
- package/src/db/tables/fundingTransfers.test.ts +89 -0
- package/src/db/tables/fundingTransfers.ts +153 -0
- package/src/db/tables/organizations.test.ts +88 -0
- package/src/db/tables/organizations.ts +42 -1
- package/src/db/tables/projects.ts +16 -0
- package/src/db/tables/requestUsage.ts +23 -0
- package/src/db/tables/sponsoredTransactions.test.ts +52 -2
- package/src/db/tables/sponsoredTransactions.ts +18 -6
- package/src/db/tables/users.ts +16 -0
- package/src/db/tables/verifiedTokens.ts +19 -14
- package/src/db/tables/webhookSubscriptions.ts +58 -3
- package/src/handlers/relay.test.ts +2 -0
- package/src/handlers/relay.ts +95 -99
- package/src/internal/Auth.test.ts +48 -0
- package/src/internal/Auth.ts +61 -2
- package/src/internal/Cache.ts +13 -9
- package/src/internal/Cursor.test.ts +2 -2
- package/src/internal/Cursor.ts +1 -1
- package/src/internal/EarnRates.test.ts +125 -0
- package/src/internal/EarnRates.ts +409 -0
- package/src/internal/EarnVaults.test.ts +195 -0
- package/src/internal/EarnVaults.ts +876 -0
- package/src/internal/EdgeCache.test.ts +37 -5
- package/src/internal/EdgeCache.ts +39 -7
- package/src/internal/Id.ts +14 -0
- package/src/internal/Idempotency.test.ts +109 -0
- package/src/internal/Idempotency.ts +237 -0
- package/src/internal/Log.test-d.ts +41 -8
- package/src/internal/Log.test.ts +189 -8
- package/src/internal/Log.ts +124 -17
- package/src/internal/MetricSink.test.ts +244 -4
- package/src/internal/MetricSink.ts +51 -1
- package/src/internal/OpenApi.ts +3 -0
- package/src/internal/Provider.test.ts +17 -0
- package/src/internal/Provider.ts +17 -0
- package/src/internal/Schema.test.ts +13 -0
- package/src/internal/Schema.ts +41 -24
- package/src/internal/Store.test.ts +25 -0
- package/src/internal/Store.ts +46 -0
- package/src/internal/Tidx.local.test.ts +78 -3
- package/src/internal/Tidx.test.ts +212 -18
- package/src/internal/Tidx.ts +112 -32
- package/src/internal/VerifiedTokens.test.ts +15 -0
- package/src/internal/Viem.test.ts +170 -17
- package/src/internal/Viem.ts +111 -28
- package/src/internal/WebhookDestination.ts +25 -23
- package/src/internal/Webhooks.test.ts +59 -0
- package/src/internal/Webhooks.ts +34 -10
- package/src/internal/exchange/Provider.test.ts +216 -0
- package/src/internal/exchange/Provider.ts +326 -0
- package/src/internal/exchange/index.test.ts +6 -0
- package/src/internal/exchange/index.ts +1 -0
- package/src/internal/exchange/providers/uniswap.test.ts +122 -0
- package/src/internal/exchange/providers/uniswap.ts +682 -0
- package/src/internal/funding/Action.test.ts +138 -0
- package/src/internal/funding/Action.ts +117 -0
- package/src/internal/funding/Catalog.test.ts +311 -0
- package/src/internal/funding/Catalog.ts +347 -0
- package/src/internal/funding/Chain.test.ts +79 -0
- package/src/internal/funding/Chain.ts +120 -0
- package/src/internal/funding/Deposit.test.ts +26 -0
- package/src/internal/funding/Deposit.ts +453 -0
- package/src/internal/funding/DepositAddress.test.ts +18 -0
- package/src/internal/funding/DepositAddress.ts +312 -0
- package/src/internal/funding/Evidence.test.ts +297 -0
- package/src/internal/funding/Evidence.ts +430 -0
- package/src/internal/funding/Provider.test.ts +1328 -0
- package/src/internal/funding/Provider.ts +1796 -0
- package/src/internal/funding/Reconciliation.local.test.ts +504 -0
- package/src/internal/funding/Reconciliation.test.ts +2020 -0
- package/src/internal/funding/Reconciliation.ts +930 -0
- package/src/internal/funding/Route.test.ts +66 -0
- package/src/internal/funding/Route.ts +29 -0
- package/src/internal/funding/Subsidy.local.test.ts +152 -0
- package/src/internal/funding/Subsidy.test.ts +75 -0
- package/src/internal/funding/Subsidy.ts +260 -0
- package/src/internal/funding/Token.test.ts +47 -0
- package/src/internal/funding/Token.ts +59 -0
- package/src/internal/funding/Transfer.test.ts +369 -0
- package/src/internal/funding/Transfer.ts +522 -0
- package/src/internal/funding/index.test.ts +20 -0
- package/src/internal/funding/index.ts +12 -0
- package/src/internal/funding/providers/across.ts +149 -0
- package/src/{apps/data/FundingQuoteProviders.test.ts → internal/funding/providers/index.test.ts} +178 -157
- package/src/internal/funding/providers/relay.test.ts +474 -0
- package/src/internal/funding/providers/relay.ts +559 -0
- package/src/internal/funding/providers/rhino.ts +139 -0
- package/src/internal/funding/providers/squid.ts +151 -0
- package/src/internal/funding/providers/symbiosis.ts +221 -0
- package/src/internal/index.test.ts +5 -1
- package/src/internal/index.ts +5 -1
- package/src/internal/webhookDestinations/url.ts +49 -45
- package/src/providers/index.test.ts +14 -0
- package/src/providers/index.ts +54 -0
- package/dist/apps/data/FundingQuoteProviders.d.ts +0 -174
- package/dist/apps/data/FundingQuoteProviders.d.ts.map +0 -1
- package/dist/apps/data/FundingQuoteProviders.js +0 -775
- package/dist/apps/data/FundingQuoteProviders.js.map +0 -1
- package/dist/internal/FundingQuotes.d.ts +0 -864
- package/dist/internal/FundingQuotes.d.ts.map +0 -1
- package/dist/internal/FundingQuotes.js +0 -672
- package/dist/internal/FundingQuotes.js.map +0 -1
- package/src/apps/data/FundingQuoteProviders.ts +0 -1043
- package/src/internal/FundingQuotes.test.ts +0 -456
- package/src/internal/FundingQuotes.ts +0 -944
|
@@ -1,775 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod/mini';
|
|
2
|
-
import * as FundingQuotes from '../../internal/FundingQuotes.js';
|
|
3
|
-
import * as Store from '../../internal/Store.js';
|
|
4
|
-
const defaultFetch = (input, init) => globalThis.fetch(input, init);
|
|
5
|
-
const defaultAcrossBaseUrl = 'https://app.across.to/api';
|
|
6
|
-
const defaultRelayBaseUrl = 'https://api.relay.link';
|
|
7
|
-
const defaultRhinoBaseUrl = 'https://api.rhino.fi/bridge';
|
|
8
|
-
const defaultSquidBaseUrl = 'https://v2.api.squidrouter.com/v2';
|
|
9
|
-
const defaultSymbiosisBaseUrl = 'https://api.symbiosis.finance/crosschain';
|
|
10
|
-
// Keep one upstream slot free for deployment smoke tests and operational probes.
|
|
11
|
-
const symbiosisRateLimit = 4;
|
|
12
|
-
const symbiosisRateLimitWindowMs = 1_000;
|
|
13
|
-
const providerOperations = {
|
|
14
|
-
across: 'swap/approval',
|
|
15
|
-
relay: 'quote/v2',
|
|
16
|
-
rhino: 'quote/bridge-swap/public',
|
|
17
|
-
squid: 'v2/route',
|
|
18
|
-
symbiosis: 'v2/quote',
|
|
19
|
-
};
|
|
20
|
-
/** Returns the stable upstream operation used by a funding quote provider. */
|
|
21
|
-
export function providerOperation(provider) {
|
|
22
|
-
return providerOperations[provider];
|
|
23
|
-
}
|
|
24
|
-
var schema;
|
|
25
|
-
(function (schema) {
|
|
26
|
-
const IntegerString = z.string().check(z.regex(/^\d+$/));
|
|
27
|
-
const AcrossToken = z.object({
|
|
28
|
-
address: z.string(),
|
|
29
|
-
chainId: z.number().check(z.int(), z.nonnegative()),
|
|
30
|
-
decimals: z.number().check(z.int(), z.nonnegative()),
|
|
31
|
-
});
|
|
32
|
-
schema.AcrossQuote = z.object({
|
|
33
|
-
amountType: z.literal('exactInput'),
|
|
34
|
-
expectedFillTime: z.number().check(z.int(), z.nonnegative()),
|
|
35
|
-
expectedOutputAmount: IntegerString,
|
|
36
|
-
inputAmount: IntegerString,
|
|
37
|
-
inputToken: AcrossToken,
|
|
38
|
-
minOutputAmount: IntegerString,
|
|
39
|
-
outputToken: AcrossToken,
|
|
40
|
-
quoteExpiryTimestamp: z.number().check(z.int(), z.nonnegative()),
|
|
41
|
-
});
|
|
42
|
-
schema.RhinoQuote = z.object({
|
|
43
|
-
_tag: z.literal('bridge'),
|
|
44
|
-
chainIn: z.string(),
|
|
45
|
-
chainOut: z.string(),
|
|
46
|
-
estimatedDuration: z.optional(z.nullable(z.number().check(z.nonnegative()))),
|
|
47
|
-
payAmount: z.string().check(z.regex(/^\d+(\.\d+)?$/)),
|
|
48
|
-
receiveAmount: z.string().check(z.regex(/^\d+(\.\d+)?$/)),
|
|
49
|
-
token: z.string(),
|
|
50
|
-
});
|
|
51
|
-
const SquidToken = z.object({
|
|
52
|
-
address: z.string(),
|
|
53
|
-
chainId: z.union([z.string(), z.number().check(z.int(), z.nonnegative())]),
|
|
54
|
-
decimals: z.number().check(z.int(), z.nonnegative()),
|
|
55
|
-
});
|
|
56
|
-
schema.SquidQuote = z.object({
|
|
57
|
-
route: z.object({
|
|
58
|
-
estimate: z.object({
|
|
59
|
-
estimatedRouteDuration: z.number().check(z.nonnegative()),
|
|
60
|
-
fromAmount: IntegerString,
|
|
61
|
-
fromToken: SquidToken,
|
|
62
|
-
toAmount: IntegerString,
|
|
63
|
-
toAmountMin: IntegerString,
|
|
64
|
-
toToken: SquidToken,
|
|
65
|
-
}),
|
|
66
|
-
}),
|
|
67
|
-
});
|
|
68
|
-
schema.SymbiosisToken = z.object({
|
|
69
|
-
address: z.string(),
|
|
70
|
-
chainId: z.number().check(z.int(), z.nonnegative()),
|
|
71
|
-
decimals: z.number().check(z.int(), z.nonnegative()),
|
|
72
|
-
});
|
|
73
|
-
const SymbiosisTokenAmount = z.extend(schema.SymbiosisToken, { amount: IntegerString });
|
|
74
|
-
schema.SymbiosisQuote = z.object({
|
|
75
|
-
estimatedTime: z.optional(z.number().check(z.nonnegative())),
|
|
76
|
-
kind: z.union([z.literal('bridge'), z.literal('crosschain-swap'), z.literal('intent-swap')]),
|
|
77
|
-
routes: z
|
|
78
|
-
.array(z.object({
|
|
79
|
-
tokens: z.array(schema.SymbiosisToken).check(z.minLength(1)),
|
|
80
|
-
}))
|
|
81
|
-
.check(z.minLength(1)),
|
|
82
|
-
tokenAmountOut: SymbiosisTokenAmount,
|
|
83
|
-
tokenAmountOutMin: SymbiosisTokenAmount,
|
|
84
|
-
tx: z.object({ chainId: z.number().check(z.int(), z.nonnegative()) }),
|
|
85
|
-
type: z.union([z.literal('evm'), z.literal('tron')]),
|
|
86
|
-
});
|
|
87
|
-
})(schema || (schema = {}));
|
|
88
|
-
/** Creates the live funding quote adapters configured for this deployment. */
|
|
89
|
-
export function createAdapters(options = {}) {
|
|
90
|
-
return {
|
|
91
|
-
...(options.across ? { across: across(options.across) } : {}),
|
|
92
|
-
...(options.relay ? { relay: relay(options.relay) } : {}),
|
|
93
|
-
...(options.rhino ? { rhino: rhino(options.rhino) } : {}),
|
|
94
|
-
...(options.squid ? { squid: squid(options.squid) } : {}),
|
|
95
|
-
...(options.symbiosis ? { symbiosis: symbiosis(options.symbiosis) } : {}),
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
/** Resolves all-or-none Across deployment configuration. */
|
|
99
|
-
export function configureAcross(options = {}) {
|
|
100
|
-
const configured = [options.apiKey, options.integratorId, options.userAddress].filter(Boolean);
|
|
101
|
-
if (configured.length === 0)
|
|
102
|
-
return undefined;
|
|
103
|
-
if (!options.apiKey || !options.integratorId || !options.userAddress)
|
|
104
|
-
throw new ProviderConfigurationError();
|
|
105
|
-
return {
|
|
106
|
-
apiKey: options.apiKey,
|
|
107
|
-
integratorId: options.integratorId,
|
|
108
|
-
userAddress: options.userAddress,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
/** Resolves all-or-none Squid deployment configuration. */
|
|
112
|
-
export function configureSquid(options = {}) {
|
|
113
|
-
const configured = [options.integratorId, options.userAddress].filter(Boolean);
|
|
114
|
-
if (configured.length === 0)
|
|
115
|
-
return undefined;
|
|
116
|
-
if (!options.integratorId || !options.userAddress)
|
|
117
|
-
throw new ProviderConfigurationError();
|
|
118
|
-
return {
|
|
119
|
-
integratorId: options.integratorId,
|
|
120
|
-
userAddress: options.userAddress,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
/** Resolves Symbiosis deployment configuration. */
|
|
124
|
-
export function configureSymbiosis(options = {}) {
|
|
125
|
-
if (!options.userAddress)
|
|
126
|
-
return undefined;
|
|
127
|
-
return { userAddress: options.userAddress };
|
|
128
|
-
}
|
|
129
|
-
/** Creates an Across quote adapter backed by `/swap/approval`. */
|
|
130
|
-
export function across(options) {
|
|
131
|
-
assertAcrossConfiguration(options);
|
|
132
|
-
const baseUrl = normalizeBaseUrl(options.baseUrl ?? defaultAcrossBaseUrl);
|
|
133
|
-
const fetcher = options.fetch ?? defaultFetch;
|
|
134
|
-
const now = options.now ?? (() => new Date());
|
|
135
|
-
return {
|
|
136
|
-
async probeQuote({ candidate }, signal) {
|
|
137
|
-
const destinationChainId = eip155ChainId(candidate.destinationChain);
|
|
138
|
-
const originChainId = providerChainId(candidate.sourceChain, 'across');
|
|
139
|
-
const url = new URL(`${baseUrl}/swap/approval`);
|
|
140
|
-
url.search = new URLSearchParams({
|
|
141
|
-
amount: candidate.sourceAmount.amount,
|
|
142
|
-
depositor: options.userAddress,
|
|
143
|
-
destinationChainId,
|
|
144
|
-
inputToken: candidate.sourceToken.address,
|
|
145
|
-
integratorId: options.integratorId,
|
|
146
|
-
originChainId,
|
|
147
|
-
outputToken: candidate.destinationToken.address,
|
|
148
|
-
recipient: options.userAddress,
|
|
149
|
-
skipOriginTxEstimation: 'true',
|
|
150
|
-
strictTradeType: 'true',
|
|
151
|
-
tradeType: 'exactInput',
|
|
152
|
-
}).toString();
|
|
153
|
-
try {
|
|
154
|
-
const quote = await requestJson(url, {
|
|
155
|
-
fetcher,
|
|
156
|
-
headers: { Authorization: `Bearer ${options.apiKey}` },
|
|
157
|
-
signal,
|
|
158
|
-
});
|
|
159
|
-
return formatAcrossResult(candidate, quote, now());
|
|
160
|
-
}
|
|
161
|
-
catch (cause) {
|
|
162
|
-
const unavailable = providerUnavailable(cause, [
|
|
163
|
-
'AMOUNT_TOO_HIGH',
|
|
164
|
-
'AMOUNT_TOO_LOW',
|
|
165
|
-
'INSUFFICIENT_LIQUIDITY',
|
|
166
|
-
'NO_QUOTES',
|
|
167
|
-
'NO_ROUTE',
|
|
168
|
-
'UNSUPPORTED_ROUTE',
|
|
169
|
-
]);
|
|
170
|
-
if (!unavailable)
|
|
171
|
-
throw cause;
|
|
172
|
-
return unavailableResult({
|
|
173
|
-
detail: 'across:swap-approval',
|
|
174
|
-
message: unavailable,
|
|
175
|
-
now: now(),
|
|
176
|
-
source: 'providerQuote',
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
/** Creates a Relay quote adapter backed by `/quote/v2`. */
|
|
183
|
-
export function relay(options) {
|
|
184
|
-
const baseUrl = normalizeBaseUrl(options.baseUrl ?? defaultRelayBaseUrl);
|
|
185
|
-
const fetcher = options.fetch ?? defaultFetch;
|
|
186
|
-
const now = options.now ?? (() => new Date());
|
|
187
|
-
return {
|
|
188
|
-
async probeQuote({ candidate }, signal) {
|
|
189
|
-
const originChainId = providerChainId(candidate.sourceChain, 'relay');
|
|
190
|
-
const destinationChainId = eip155ChainId(candidate.destinationChain);
|
|
191
|
-
const headers = relayHeaders(options.apiKey);
|
|
192
|
-
try {
|
|
193
|
-
const quote = await requestJson(new URL(`${baseUrl}/quote/v2`), {
|
|
194
|
-
body: {
|
|
195
|
-
amount: candidate.sourceAmount.amount,
|
|
196
|
-
destinationChainId: Number(destinationChainId),
|
|
197
|
-
destinationCurrency: candidate.destinationToken.address,
|
|
198
|
-
originChainId: Number(originChainId),
|
|
199
|
-
originCurrency: candidate.sourceToken.address,
|
|
200
|
-
recipient: options.recipientAddress ?? options.userAddress,
|
|
201
|
-
tradeType: 'EXACT_INPUT',
|
|
202
|
-
user: options.userAddress,
|
|
203
|
-
},
|
|
204
|
-
fetcher,
|
|
205
|
-
headers,
|
|
206
|
-
method: 'POST',
|
|
207
|
-
signal,
|
|
208
|
-
});
|
|
209
|
-
return formatRelayResult(quote, now());
|
|
210
|
-
}
|
|
211
|
-
catch (cause) {
|
|
212
|
-
const unavailable = providerUnavailable(cause, [
|
|
213
|
-
'NO_QUOTES',
|
|
214
|
-
'NO_ROUTE',
|
|
215
|
-
'UNSUPPORTED_ROUTE',
|
|
216
|
-
]);
|
|
217
|
-
if (!unavailable)
|
|
218
|
-
throw cause;
|
|
219
|
-
return unavailableResult({
|
|
220
|
-
detail: 'relay:quote-v2',
|
|
221
|
-
message: unavailable,
|
|
222
|
-
now: now(),
|
|
223
|
-
source: 'providerQuote',
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
/** Creates a Rhino quote adapter backed by the public bridge-and-swap quote endpoint. */
|
|
230
|
-
export function rhino(options = {}) {
|
|
231
|
-
const baseUrl = normalizeBaseUrl(options.baseUrl ?? defaultRhinoBaseUrl);
|
|
232
|
-
const fetcher = options.fetch ?? defaultFetch;
|
|
233
|
-
const now = options.now ?? (() => new Date());
|
|
234
|
-
return {
|
|
235
|
-
async probeQuote({ cache, candidate }, signal) {
|
|
236
|
-
const chainIn = providerChainReference(candidate.sourceChain, 'rhino');
|
|
237
|
-
const tokenOut = rhinoToken(candidate.destinationToken);
|
|
238
|
-
const url = new URL(`${baseUrl}/quote/bridge-swap/public`);
|
|
239
|
-
url.search = new URLSearchParams({
|
|
240
|
-
amount: candidate.sourceAmount.formatted,
|
|
241
|
-
amountNative: '0',
|
|
242
|
-
chainIn,
|
|
243
|
-
chainOut: 'TEMPO',
|
|
244
|
-
mode: 'pay',
|
|
245
|
-
tokenIn: candidate.sourceToken.symbol,
|
|
246
|
-
tokenOut,
|
|
247
|
-
}).toString();
|
|
248
|
-
try {
|
|
249
|
-
const quote = await requestJson(url, {
|
|
250
|
-
fetcher,
|
|
251
|
-
headers: cache.bypass ? { 'cache-control': 'no-cache' } : undefined,
|
|
252
|
-
signal,
|
|
253
|
-
});
|
|
254
|
-
return formatRhinoResult(candidate, quote, { chainIn, now: now(), tokenOut });
|
|
255
|
-
}
|
|
256
|
-
catch (cause) {
|
|
257
|
-
const unavailable = providerUnavailable(cause, ['NoRouteFoundError']);
|
|
258
|
-
if (!unavailable)
|
|
259
|
-
throw cause;
|
|
260
|
-
return unavailableResult({
|
|
261
|
-
detail: 'rhino:bridge-swap-public',
|
|
262
|
-
message: unavailable,
|
|
263
|
-
now: now(),
|
|
264
|
-
source: 'providerQuote',
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
},
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
/** Creates a Squid quote adapter backed by `/v2/route`. */
|
|
271
|
-
export function squid(options) {
|
|
272
|
-
assertSquidConfiguration(options);
|
|
273
|
-
const baseUrl = normalizeBaseUrl(options.baseUrl ?? defaultSquidBaseUrl);
|
|
274
|
-
const fetcher = options.fetch ?? defaultFetch;
|
|
275
|
-
const now = options.now ?? (() => new Date());
|
|
276
|
-
return {
|
|
277
|
-
async probeQuote({ candidate }, signal) {
|
|
278
|
-
const fromChain = eip155ChainId(candidate.sourceChain);
|
|
279
|
-
const toChain = eip155ChainId(candidate.destinationChain);
|
|
280
|
-
try {
|
|
281
|
-
const quote = await requestJson(new URL(`${baseUrl}/route`), {
|
|
282
|
-
body: {
|
|
283
|
-
fromAddress: options.userAddress,
|
|
284
|
-
fromAmount: candidate.sourceAmount.amount,
|
|
285
|
-
fromChain,
|
|
286
|
-
fromToken: candidate.sourceToken.address,
|
|
287
|
-
quoteOnly: true,
|
|
288
|
-
// V1 quotes use a fixed 1% tolerance; callers cannot customize execution policy.
|
|
289
|
-
slippage: 1,
|
|
290
|
-
toAddress: options.userAddress,
|
|
291
|
-
toChain,
|
|
292
|
-
toToken: candidate.destinationToken.address,
|
|
293
|
-
},
|
|
294
|
-
fetcher,
|
|
295
|
-
headers: { 'x-integrator-id': options.integratorId },
|
|
296
|
-
method: 'POST',
|
|
297
|
-
signal,
|
|
298
|
-
});
|
|
299
|
-
return formatSquidResult(candidate, quote, now());
|
|
300
|
-
}
|
|
301
|
-
catch (cause) {
|
|
302
|
-
const unavailable = providerUnavailable(cause, [
|
|
303
|
-
'NO_ROUTE',
|
|
304
|
-
'NO_ROUTE_FOUND',
|
|
305
|
-
'ROUTE_NOT_FOUND',
|
|
306
|
-
'UNSUPPORTED_ROUTE',
|
|
307
|
-
]) ?? squidUnavailable(cause);
|
|
308
|
-
if (!unavailable)
|
|
309
|
-
throw cause;
|
|
310
|
-
return unavailableResult({
|
|
311
|
-
detail: 'squid:route-v2',
|
|
312
|
-
message: unavailable,
|
|
313
|
-
now: now(),
|
|
314
|
-
source: 'providerQuote',
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
/** Creates a Symbiosis quote adapter backed by `/v2/quote`. */
|
|
321
|
-
export function symbiosis(options) {
|
|
322
|
-
assertUserAddress(options.userAddress);
|
|
323
|
-
const baseUrl = normalizeBaseUrl(options.baseUrl ?? defaultSymbiosisBaseUrl);
|
|
324
|
-
const fetcher = options.fetch ?? defaultFetch;
|
|
325
|
-
const now = options.now ?? (() => new Date());
|
|
326
|
-
const rateLimitStore = options.rateLimitStore ?? Store.memory();
|
|
327
|
-
return {
|
|
328
|
-
async probeQuote({ candidate }, signal) {
|
|
329
|
-
const fromChainId = Number(providerChainId(candidate.sourceChain, 'symbiosis'));
|
|
330
|
-
const fromToken = symbiosisSourceToken(candidate.sourceChain, candidate.sourceToken);
|
|
331
|
-
const toChainId = Number(eip155ChainId(candidate.destinationChain));
|
|
332
|
-
try {
|
|
333
|
-
await consumeSymbiosisQuota(rateLimitStore, now());
|
|
334
|
-
const quote = await requestJson(new URL(`${baseUrl}/v2/quote`), {
|
|
335
|
-
body: {
|
|
336
|
-
from: options.userAddress,
|
|
337
|
-
slippage: 100,
|
|
338
|
-
to: options.userAddress,
|
|
339
|
-
tokenAmountIn: {
|
|
340
|
-
address: fromToken,
|
|
341
|
-
amount: candidate.sourceAmount.amount,
|
|
342
|
-
chainId: fromChainId,
|
|
343
|
-
decimals: candidate.sourceToken.decimals,
|
|
344
|
-
symbol: candidate.sourceToken.symbol,
|
|
345
|
-
},
|
|
346
|
-
tokenOut: {
|
|
347
|
-
address: candidate.destinationToken.address,
|
|
348
|
-
chainId: toChainId,
|
|
349
|
-
decimals: candidate.destinationToken.decimals,
|
|
350
|
-
symbol: candidate.destinationToken.symbol,
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
fetcher,
|
|
354
|
-
headers: { 'x-partner-id': 'tempo' },
|
|
355
|
-
method: 'POST',
|
|
356
|
-
signal,
|
|
357
|
-
});
|
|
358
|
-
return formatSymbiosisResult(candidate, quote, now());
|
|
359
|
-
}
|
|
360
|
-
catch (cause) {
|
|
361
|
-
const unavailable = providerUnavailable(cause, [
|
|
362
|
-
'AMOUNT_TOO_LOW',
|
|
363
|
-
'NO_ROUTE',
|
|
364
|
-
'NO_ROUTE_FOUND',
|
|
365
|
-
'ROUTE_NOT_FOUND',
|
|
366
|
-
'UNSUPPORTED_ROUTE',
|
|
367
|
-
]) ?? symbiosisUnavailable(cause);
|
|
368
|
-
if (!unavailable)
|
|
369
|
-
throw cause;
|
|
370
|
-
return unavailableResult({
|
|
371
|
-
detail: 'symbiosis:quote-v2',
|
|
372
|
-
message: unavailable,
|
|
373
|
-
now: now(),
|
|
374
|
-
source: 'providerQuote',
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
},
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
/** Returns bounded provider failure details suitable for structured request logs. */
|
|
381
|
-
export function providerFailure(options) {
|
|
382
|
-
const operation = providerOperation(options.provider);
|
|
383
|
-
if (options.cause instanceof FundingQuotes.ProviderAdapterTimeoutError ||
|
|
384
|
-
(options.cause instanceof DOMException && options.cause.name === 'AbortError'))
|
|
385
|
-
return { failure: 'timeout', id: options.provider, operation };
|
|
386
|
-
if (options.cause instanceof ProviderResponseError) {
|
|
387
|
-
const code = providerErrorCode(options.cause.body);
|
|
388
|
-
return {
|
|
389
|
-
...(code === undefined ? {} : { code }),
|
|
390
|
-
failure: 'http',
|
|
391
|
-
id: options.provider,
|
|
392
|
-
operation,
|
|
393
|
-
status: options.cause.status,
|
|
394
|
-
};
|
|
395
|
-
}
|
|
396
|
-
if (options.cause instanceof ProviderPayloadError)
|
|
397
|
-
return { failure: 'payload', id: options.provider, operation };
|
|
398
|
-
if (options.cause instanceof ProviderRateLimitError)
|
|
399
|
-
return { failure: 'rate_limit', id: options.provider, operation };
|
|
400
|
-
if (options.cause instanceof TypeError)
|
|
401
|
-
return { failure: 'network', id: options.provider, operation };
|
|
402
|
-
return { failure: 'unknown', id: options.provider, operation };
|
|
403
|
-
}
|
|
404
|
-
function formatAcrossResult(candidate, quote, now) {
|
|
405
|
-
const parsed = schema.AcrossQuote.safeParse(quote);
|
|
406
|
-
if (!parsed.success)
|
|
407
|
-
throw new ProviderPayloadError();
|
|
408
|
-
const response = parsed.data;
|
|
409
|
-
const expiresAt = new Date(response.quoteExpiryTimestamp * 1_000);
|
|
410
|
-
if (response.inputAmount !== candidate.sourceAmount.amount ||
|
|
411
|
-
!matchesToken(response.inputToken, candidate.sourceChain, candidate.sourceToken) ||
|
|
412
|
-
!matchesToken(response.outputToken, candidate.destinationChain, candidate.destinationToken) ||
|
|
413
|
-
BigInt(response.expectedOutputAmount) <= 0n ||
|
|
414
|
-
BigInt(response.minOutputAmount) <= 0n ||
|
|
415
|
-
BigInt(response.minOutputAmount) > BigInt(response.expectedOutputAmount) ||
|
|
416
|
-
Number.isNaN(expiresAt.getTime()) ||
|
|
417
|
-
response.quoteExpiryTimestamp * 1_000 <= now.getTime())
|
|
418
|
-
throw new ProviderPayloadError();
|
|
419
|
-
return {
|
|
420
|
-
expiresAt: expiresAt.toISOString(),
|
|
421
|
-
minimumOutputAmount: response.minOutputAmount,
|
|
422
|
-
outputAmount: response.expectedOutputAmount,
|
|
423
|
-
quality: {
|
|
424
|
-
estimatedSeconds: response.expectedFillTime,
|
|
425
|
-
liquiditySource: 'providerQuote',
|
|
426
|
-
sourceDetail: 'across:swap-approval',
|
|
427
|
-
tier: 'liquid',
|
|
428
|
-
},
|
|
429
|
-
sampledAt: now.toISOString(),
|
|
430
|
-
status: 'available',
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
function formatRelayResult(quote, now) {
|
|
434
|
-
const details = record(record(quote)['details']);
|
|
435
|
-
const currencyOut = record(details['currencyOut']);
|
|
436
|
-
const outputAmount = decimalString(currencyOut['amount']);
|
|
437
|
-
const status = outputAmount
|
|
438
|
-
? { status: 'available', tier: 'liquid' }
|
|
439
|
-
: { status: 'unknown', tier: 'unknown' };
|
|
440
|
-
return {
|
|
441
|
-
minimumOutputAmount: decimalString(currencyOut['minimumAmount']),
|
|
442
|
-
outputAmount,
|
|
443
|
-
quality: {
|
|
444
|
-
estimatedSeconds: nonnegativeInteger(details['timeEstimate']),
|
|
445
|
-
liquiditySource: 'providerQuote',
|
|
446
|
-
sourceDetail: 'relay:quote-v2',
|
|
447
|
-
tier: status.tier,
|
|
448
|
-
},
|
|
449
|
-
sampledAt: now.toISOString(),
|
|
450
|
-
status: status.status,
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
function formatRhinoResult(candidate, quote, options) {
|
|
454
|
-
const parsed = schema.RhinoQuote.safeParse(quote);
|
|
455
|
-
if (!parsed.success)
|
|
456
|
-
throw new ProviderPayloadError();
|
|
457
|
-
const response = parsed.data;
|
|
458
|
-
const inputAmount = baseUnitsFromDecimal(response.payAmount, candidate.sourceToken.decimals);
|
|
459
|
-
const outputAmount = baseUnitsFromDecimal(response.receiveAmount, candidate.destinationToken.decimals);
|
|
460
|
-
if (response.chainIn !== options.chainIn ||
|
|
461
|
-
response.chainOut !== 'TEMPO' ||
|
|
462
|
-
response.token !== options.tokenOut ||
|
|
463
|
-
inputAmount !== candidate.sourceAmount.amount ||
|
|
464
|
-
outputAmount === undefined ||
|
|
465
|
-
BigInt(outputAmount) <= 0n)
|
|
466
|
-
throw new ProviderPayloadError();
|
|
467
|
-
return {
|
|
468
|
-
outputAmount,
|
|
469
|
-
quality: {
|
|
470
|
-
...(response.estimatedDuration === undefined || response.estimatedDuration === null
|
|
471
|
-
? {}
|
|
472
|
-
: { estimatedSeconds: Math.ceil(response.estimatedDuration / 1_000) }),
|
|
473
|
-
liquiditySource: 'providerQuote',
|
|
474
|
-
sourceDetail: 'rhino:bridge-swap-public',
|
|
475
|
-
tier: 'liquid',
|
|
476
|
-
},
|
|
477
|
-
sampledAt: options.now.toISOString(),
|
|
478
|
-
status: 'available',
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
function formatSquidResult(candidate, quote, now) {
|
|
482
|
-
const parsed = schema.SquidQuote.safeParse(quote);
|
|
483
|
-
if (!parsed.success)
|
|
484
|
-
throw new ProviderPayloadError();
|
|
485
|
-
const response = parsed.data.route.estimate;
|
|
486
|
-
if (response.fromAmount !== candidate.sourceAmount.amount ||
|
|
487
|
-
!matchesSquidToken(response.fromToken, candidate.sourceChain, candidate.sourceToken) ||
|
|
488
|
-
!matchesSquidToken(response.toToken, candidate.destinationChain, candidate.destinationToken) ||
|
|
489
|
-
BigInt(response.toAmount) <= 0n ||
|
|
490
|
-
BigInt(response.toAmountMin) <= 0n ||
|
|
491
|
-
BigInt(response.toAmountMin) > BigInt(response.toAmount))
|
|
492
|
-
throw new ProviderPayloadError();
|
|
493
|
-
return {
|
|
494
|
-
minimumOutputAmount: response.toAmountMin,
|
|
495
|
-
outputAmount: response.toAmount,
|
|
496
|
-
quality: {
|
|
497
|
-
estimatedSeconds: Math.ceil(response.estimatedRouteDuration),
|
|
498
|
-
liquiditySource: 'providerQuote',
|
|
499
|
-
sourceDetail: 'squid:route-v2',
|
|
500
|
-
tier: 'liquid',
|
|
501
|
-
},
|
|
502
|
-
sampledAt: now.toISOString(),
|
|
503
|
-
status: 'available',
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
|
-
function formatSymbiosisResult(candidate, quote, now) {
|
|
507
|
-
const parsed = schema.SymbiosisQuote.safeParse(quote);
|
|
508
|
-
if (!parsed.success)
|
|
509
|
-
throw new ProviderPayloadError();
|
|
510
|
-
const response = parsed.data;
|
|
511
|
-
const sourceChainId = Number(providerChainId(candidate.sourceChain, 'symbiosis'));
|
|
512
|
-
const sourceToken = symbiosisSourceToken(candidate.sourceChain, candidate.sourceToken);
|
|
513
|
-
const firstToken = response.routes[0].tokens[0];
|
|
514
|
-
const lastRoute = response.routes[response.routes.length - 1];
|
|
515
|
-
const lastToken = lastRoute.tokens[lastRoute.tokens.length - 1];
|
|
516
|
-
if (response.tx.chainId !== sourceChainId ||
|
|
517
|
-
response.type !== candidate.sourceChain.kind ||
|
|
518
|
-
!matchesSymbiosisToken(firstToken, {
|
|
519
|
-
address: sourceToken,
|
|
520
|
-
chainId: sourceChainId,
|
|
521
|
-
decimals: candidate.sourceToken.decimals,
|
|
522
|
-
}) ||
|
|
523
|
-
!matchesSymbiosisToken(lastToken, {
|
|
524
|
-
address: candidate.destinationToken.address,
|
|
525
|
-
chainId: Number(eip155ChainId(candidate.destinationChain)),
|
|
526
|
-
decimals: candidate.destinationToken.decimals,
|
|
527
|
-
}) ||
|
|
528
|
-
!matchesSymbiosisToken(response.tokenAmountOut, {
|
|
529
|
-
address: candidate.destinationToken.address,
|
|
530
|
-
chainId: Number(eip155ChainId(candidate.destinationChain)),
|
|
531
|
-
decimals: candidate.destinationToken.decimals,
|
|
532
|
-
}) ||
|
|
533
|
-
!matchesSymbiosisToken(response.tokenAmountOutMin, {
|
|
534
|
-
address: candidate.destinationToken.address,
|
|
535
|
-
chainId: Number(eip155ChainId(candidate.destinationChain)),
|
|
536
|
-
decimals: candidate.destinationToken.decimals,
|
|
537
|
-
}) ||
|
|
538
|
-
BigInt(response.tokenAmountOut.amount) <= 0n ||
|
|
539
|
-
BigInt(response.tokenAmountOutMin.amount) <= 0n ||
|
|
540
|
-
BigInt(response.tokenAmountOutMin.amount) > BigInt(response.tokenAmountOut.amount))
|
|
541
|
-
throw new ProviderPayloadError();
|
|
542
|
-
return {
|
|
543
|
-
minimumOutputAmount: response.tokenAmountOutMin.amount,
|
|
544
|
-
outputAmount: response.tokenAmountOut.amount,
|
|
545
|
-
quality: {
|
|
546
|
-
...(response.estimatedTime === undefined
|
|
547
|
-
? {}
|
|
548
|
-
: { estimatedSeconds: Math.ceil(response.estimatedTime) }),
|
|
549
|
-
liquiditySource: 'providerQuote',
|
|
550
|
-
sourceDetail: 'symbiosis:quote-v2',
|
|
551
|
-
tier: 'liquid',
|
|
552
|
-
},
|
|
553
|
-
sampledAt: now.toISOString(),
|
|
554
|
-
status: 'available',
|
|
555
|
-
};
|
|
556
|
-
}
|
|
557
|
-
function unavailableResult(options) {
|
|
558
|
-
return {
|
|
559
|
-
quality: {
|
|
560
|
-
liquiditySource: options.source,
|
|
561
|
-
sourceDetail: `${options.detail}:${options.message}`,
|
|
562
|
-
tier: 'unavailable',
|
|
563
|
-
},
|
|
564
|
-
sampledAt: options.now.toISOString(),
|
|
565
|
-
status: 'unavailable',
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
async function requestJson(url, options) {
|
|
569
|
-
const headers = { accept: 'application/json', ...options.headers };
|
|
570
|
-
const init = {
|
|
571
|
-
headers: options.body === undefined ? headers : { ...headers, 'content-type': 'application/json' },
|
|
572
|
-
method: options.method ?? 'GET',
|
|
573
|
-
signal: options.signal,
|
|
574
|
-
};
|
|
575
|
-
if (options.body !== undefined)
|
|
576
|
-
init.body = JSON.stringify(options.body);
|
|
577
|
-
const response = await options.fetcher(url, init);
|
|
578
|
-
const text = await response.text();
|
|
579
|
-
const body = parseJson(text);
|
|
580
|
-
if (!response.ok)
|
|
581
|
-
throw new ProviderResponseError(response.status, body);
|
|
582
|
-
return body;
|
|
583
|
-
}
|
|
584
|
-
function relayHeaders(apiKey) {
|
|
585
|
-
return apiKey ? { 'x-api-key': apiKey } : undefined;
|
|
586
|
-
}
|
|
587
|
-
function providerUnavailable(cause, codes) {
|
|
588
|
-
if (!(cause instanceof ProviderResponseError) || cause.status < 400 || cause.status >= 500)
|
|
589
|
-
return undefined;
|
|
590
|
-
const code = providerErrorCode(cause.body);
|
|
591
|
-
if (code && codes.includes(code))
|
|
592
|
-
return code;
|
|
593
|
-
return undefined;
|
|
594
|
-
}
|
|
595
|
-
function providerErrorCode(input) {
|
|
596
|
-
const body = record(input);
|
|
597
|
-
const error = record(body['error']);
|
|
598
|
-
const code = stringValue(body['_tag']) ??
|
|
599
|
-
stringValue(body['code']) ??
|
|
600
|
-
stringValue(body['errorCode']) ??
|
|
601
|
-
stringValue(body['errorType']) ??
|
|
602
|
-
stringValue(body['type']) ??
|
|
603
|
-
stringValue(error['code']) ??
|
|
604
|
-
stringValue(error['type']);
|
|
605
|
-
return code && /^[A-Za-z0-9_.:-]{1,64}$/.test(code) ? code : undefined;
|
|
606
|
-
}
|
|
607
|
-
function squidUnavailable(cause) {
|
|
608
|
-
if (!(cause instanceof ProviderResponseError) || cause.status !== 400)
|
|
609
|
-
return undefined;
|
|
610
|
-
const body = record(cause.body);
|
|
611
|
-
if (body['type'] === 'BAD_REQUEST' &&
|
|
612
|
-
body['message'] === 'Please increase the swap amount and try again.')
|
|
613
|
-
return 'AMOUNT_TOO_LOW';
|
|
614
|
-
return undefined;
|
|
615
|
-
}
|
|
616
|
-
function symbiosisUnavailable(cause) {
|
|
617
|
-
if (!(cause instanceof ProviderResponseError) || cause.status !== 400)
|
|
618
|
-
return undefined;
|
|
619
|
-
const body = record(cause.body);
|
|
620
|
-
if (body['message'] === 'Amount is too low to cover fees')
|
|
621
|
-
return 'AMOUNT_TOO_LOW';
|
|
622
|
-
return undefined;
|
|
623
|
-
}
|
|
624
|
-
async function consumeSymbiosisQuota(store, now) {
|
|
625
|
-
const time = now.getTime();
|
|
626
|
-
const bucket = Math.floor(time / symbiosisRateLimitWindowMs);
|
|
627
|
-
const count = await Store.increment(store, `funding:symbiosis:quote:${bucket}`, {
|
|
628
|
-
ttl: symbiosisRateLimitWindowMs * 2,
|
|
629
|
-
});
|
|
630
|
-
if (count > symbiosisRateLimit)
|
|
631
|
-
throw new ProviderRateLimitError();
|
|
632
|
-
}
|
|
633
|
-
function providerChainId(quoteChain, provider) {
|
|
634
|
-
const providerIds = quoteChain.providerIds;
|
|
635
|
-
const id = providerIds?.[provider];
|
|
636
|
-
if (id && /^\d+$/.test(id))
|
|
637
|
-
return id;
|
|
638
|
-
return eip155ChainId(quoteChain);
|
|
639
|
-
}
|
|
640
|
-
function providerChainReference(quoteChain, provider) {
|
|
641
|
-
const providerIds = quoteChain.providerIds;
|
|
642
|
-
const id = providerIds?.[provider];
|
|
643
|
-
if (!id)
|
|
644
|
-
throw new UnsupportedProviderChainError();
|
|
645
|
-
return id;
|
|
646
|
-
}
|
|
647
|
-
function rhinoToken(token) {
|
|
648
|
-
const tokens = {
|
|
649
|
-
'0x20c00000000000000000000014f22ca97301eb73': 'USDT',
|
|
650
|
-
'0x20c000000000000000000000b9537d11c60e8b50': 'USDC',
|
|
651
|
-
};
|
|
652
|
-
const id = tokens[token.address.toLowerCase()];
|
|
653
|
-
if (!id)
|
|
654
|
-
throw new UnsupportedProviderTokenError();
|
|
655
|
-
return id;
|
|
656
|
-
}
|
|
657
|
-
function symbiosisSourceToken(chain, token) {
|
|
658
|
-
if (chain.kind !== 'tron')
|
|
659
|
-
return token.address;
|
|
660
|
-
const tokens = {
|
|
661
|
-
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t: '0xa614f803b6fd780986a42c78ec9c7f77e6ded13c',
|
|
662
|
-
};
|
|
663
|
-
const id = tokens[token.address];
|
|
664
|
-
if (!id)
|
|
665
|
-
throw new UnsupportedProviderTokenError();
|
|
666
|
-
return id;
|
|
667
|
-
}
|
|
668
|
-
function matchesToken(token, chain, expected) {
|
|
669
|
-
return (token.address.toLowerCase() === expected.address.toLowerCase() &&
|
|
670
|
-
token.chainId === Number(eip155ChainId(chain)) &&
|
|
671
|
-
token.decimals === expected.decimals);
|
|
672
|
-
}
|
|
673
|
-
function matchesSquidToken(token, chain, expected) {
|
|
674
|
-
return (token.address.toLowerCase() === expected.address.toLowerCase() &&
|
|
675
|
-
String(token.chainId) === eip155ChainId(chain) &&
|
|
676
|
-
token.decimals === expected.decimals);
|
|
677
|
-
}
|
|
678
|
-
function matchesSymbiosisToken(token, options) {
|
|
679
|
-
return (token.address.toLowerCase() === options.address.toLowerCase() &&
|
|
680
|
-
token.chainId === options.chainId &&
|
|
681
|
-
token.decimals === options.decimals);
|
|
682
|
-
}
|
|
683
|
-
function eip155ChainId(chain) {
|
|
684
|
-
if (chain.kind !== 'evm')
|
|
685
|
-
throw new UnsupportedProviderChainError();
|
|
686
|
-
const match = /^eip155:(\d+)$/.exec(chain.id);
|
|
687
|
-
if (!match?.[1])
|
|
688
|
-
throw new UnsupportedProviderChainError();
|
|
689
|
-
return match[1];
|
|
690
|
-
}
|
|
691
|
-
function normalizeBaseUrl(input) {
|
|
692
|
-
return input.replace(/\/+$/, '');
|
|
693
|
-
}
|
|
694
|
-
function parseJson(input) {
|
|
695
|
-
if (!input)
|
|
696
|
-
return null;
|
|
697
|
-
try {
|
|
698
|
-
return JSON.parse(input);
|
|
699
|
-
}
|
|
700
|
-
catch {
|
|
701
|
-
return input;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
function record(input) {
|
|
705
|
-
return input && typeof input === 'object' && !Array.isArray(input)
|
|
706
|
-
? input
|
|
707
|
-
: {};
|
|
708
|
-
}
|
|
709
|
-
function stringValue(input) {
|
|
710
|
-
return typeof input === 'string' && input.length > 0 ? input : undefined;
|
|
711
|
-
}
|
|
712
|
-
function decimalString(input) {
|
|
713
|
-
if (typeof input === 'string' && /^\d+(\.\d+)?$/.test(input))
|
|
714
|
-
return input;
|
|
715
|
-
if (typeof input === 'number' && Number.isFinite(input) && input >= 0)
|
|
716
|
-
return String(input);
|
|
717
|
-
return undefined;
|
|
718
|
-
}
|
|
719
|
-
function nonnegativeInteger(input) {
|
|
720
|
-
if (typeof input === 'number' && Number.isSafeInteger(input) && input >= 0)
|
|
721
|
-
return input;
|
|
722
|
-
if (typeof input === 'string' && /^\d+$/.test(input))
|
|
723
|
-
return Number(input);
|
|
724
|
-
return undefined;
|
|
725
|
-
}
|
|
726
|
-
function baseUnitsFromDecimal(value, decimals) {
|
|
727
|
-
if (!/^\d+(\.\d+)?$/.test(value))
|
|
728
|
-
return undefined;
|
|
729
|
-
const [whole, fraction = ''] = value.split('.');
|
|
730
|
-
const significantFraction = fraction.replace(/0+$/, '');
|
|
731
|
-
if (significantFraction.length > decimals)
|
|
732
|
-
return undefined;
|
|
733
|
-
return BigInt(`${whole}${significantFraction.padEnd(decimals, '0')}`).toString();
|
|
734
|
-
}
|
|
735
|
-
function assertAcrossConfiguration(options) {
|
|
736
|
-
if (options.apiKey.length === 0 ||
|
|
737
|
-
!/^0x[\da-fA-F]{4}$/.test(options.integratorId) ||
|
|
738
|
-
!/^0x[\da-fA-F]{40}$/.test(options.userAddress))
|
|
739
|
-
throw new ProviderConfigurationError();
|
|
740
|
-
}
|
|
741
|
-
function assertSquidConfiguration(options) {
|
|
742
|
-
if (options.integratorId.length === 0)
|
|
743
|
-
throw new ProviderConfigurationError();
|
|
744
|
-
assertUserAddress(options.userAddress);
|
|
745
|
-
}
|
|
746
|
-
function assertUserAddress(userAddress) {
|
|
747
|
-
if (!/^0x[\da-fA-F]{40}$/.test(userAddress))
|
|
748
|
-
throw new ProviderConfigurationError();
|
|
749
|
-
}
|
|
750
|
-
class ProviderConfigurationError extends Error {
|
|
751
|
-
name = 'FundingQuoteProviders.ProviderConfigurationError';
|
|
752
|
-
}
|
|
753
|
-
class ProviderPayloadError extends Error {
|
|
754
|
-
name = 'FundingQuoteProviders.ProviderPayloadError';
|
|
755
|
-
}
|
|
756
|
-
class ProviderRateLimitError extends Error {
|
|
757
|
-
name = 'FundingQuoteProviders.ProviderRateLimitError';
|
|
758
|
-
}
|
|
759
|
-
class ProviderResponseError extends Error {
|
|
760
|
-
status;
|
|
761
|
-
body;
|
|
762
|
-
name = 'FundingQuoteProviders.ProviderResponseError';
|
|
763
|
-
constructor(status, body) {
|
|
764
|
-
super(`Provider request failed with status ${status}`);
|
|
765
|
-
this.status = status;
|
|
766
|
-
this.body = body;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
class UnsupportedProviderChainError extends Error {
|
|
770
|
-
name = 'FundingQuoteProviders.UnsupportedProviderChainError';
|
|
771
|
-
}
|
|
772
|
-
class UnsupportedProviderTokenError extends Error {
|
|
773
|
-
name = 'FundingQuoteProviders.UnsupportedProviderTokenError';
|
|
774
|
-
}
|
|
775
|
-
//# sourceMappingURL=FundingQuoteProviders.js.map
|