tapimo 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/dist/ApiKey.d.ts +3 -0
- package/dist/ApiKey.d.ts.map +1 -1
- package/dist/ApiKey.js +10 -0
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +29 -8
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +24 -5
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +20680 -15487
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +250 -129
- 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 +667 -76
- 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 +107 -11
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +145 -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/organizations.d.ts +2 -0
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +74 -74
- 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 +99 -43
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +4 -0
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +21 -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 +5666 -3934
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +90 -22
- 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 +56 -56
- 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 +65 -65
- package/dist/apps/data/routes/balances.d.ts +14 -14
- package/dist/apps/data/routes/balances.js +5 -5
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +39 -39
- package/dist/apps/data/routes/coingecko.d.ts +54 -54
- 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 +2574 -0
- package/dist/apps/data/routes/earn.d.ts.map +1 -0
- package/dist/apps/data/routes/earn.js +1574 -0
- package/dist/apps/data/routes/earn.js.map +1 -0
- package/dist/apps/data/routes/exchanges.d.ts +1626 -719
- 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 +108 -108
- 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/indexer.d.ts +35 -35
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +23 -3
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +33 -33
- 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 +6 -6
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +214 -22
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +39 -8
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +115 -87
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +194 -91
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +54 -54
- 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 +76 -27
- 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 +42 -42
- 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 +36 -36
- package/dist/apps/data/routes/webhooks.d.ts +370 -368
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +161 -59
- 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/funding/Access.d.ts +16 -0
- package/dist/apps/funding/Access.d.ts.map +1 -0
- package/dist/apps/funding/Access.js +22 -0
- package/dist/apps/funding/Access.js.map +1 -0
- package/dist/apps/funding/App.d.ts +3183 -0
- package/dist/apps/funding/App.d.ts.map +1 -0
- package/dist/apps/funding/App.js +46 -0
- package/dist/apps/funding/App.js.map +1 -0
- package/dist/apps/funding/Inventory.d.ts +5 -0
- package/dist/apps/funding/Inventory.d.ts.map +1 -0
- package/dist/apps/funding/Inventory.js +25 -0
- package/dist/apps/funding/Inventory.js.map +1 -0
- package/dist/apps/funding/ProviderAttempts.d.ts +5 -0
- package/dist/apps/funding/ProviderAttempts.d.ts.map +1 -0
- package/dist/apps/funding/ProviderAttempts.js +24 -0
- package/dist/apps/funding/ProviderAttempts.js.map +1 -0
- package/dist/apps/funding/index.d.ts +2 -0
- package/dist/apps/funding/index.d.ts.map +1 -0
- package/dist/apps/funding/index.js +2 -0
- package/dist/apps/funding/index.js.map +1 -0
- package/dist/apps/funding/routes/chains.d.ts +169 -0
- package/dist/apps/funding/routes/chains.d.ts.map +1 -0
- package/dist/apps/funding/routes/chains.js +80 -0
- package/dist/apps/funding/routes/chains.js.map +1 -0
- package/dist/apps/funding/routes/deposit-addresses.d.ts +2388 -0
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +1 -0
- package/dist/apps/funding/routes/deposit-addresses.js +860 -0
- package/dist/apps/funding/routes/deposit-addresses.js.map +1 -0
- package/dist/apps/funding/routes/providers.d.ts +91 -0
- package/dist/apps/funding/routes/providers.d.ts.map +1 -0
- package/dist/apps/funding/routes/providers.js +56 -0
- package/dist/apps/funding/routes/providers.js.map +1 -0
- package/dist/apps/{data/routes/funding.d.ts → funding/routes/quotes.d.ts} +26 -396
- package/dist/apps/funding/routes/quotes.d.ts.map +1 -0
- package/dist/apps/funding/routes/quotes.js +188 -0
- package/dist/apps/funding/routes/quotes.js.map +1 -0
- package/dist/apps/funding/routes/transfers.d.ts +1999 -0
- package/dist/apps/funding/routes/transfers.d.ts.map +1 -0
- package/dist/apps/funding/routes/transfers.js +614 -0
- package/dist/apps/funding/routes/transfers.js.map +1 -0
- package/dist/apps/index.d.ts +3 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +3 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +839 -574
- package/dist/apps/management/App.d.ts.map +1 -1
- 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 +296 -19
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +77 -9
- 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 +17 -17
- 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 +38 -38
- package/dist/apps/management/routes/me.d.ts +6 -6
- package/dist/apps/management/routes/members.d.ts +69 -69
- package/dist/apps/management/routes/orgs.d.ts +16 -16
- 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 +19 -19
- package/dist/apps/management/routes/scopes.d.ts +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 +72 -72
- package/dist/apps/management/routes/verified-token-requests.d.ts +18 -18
- package/dist/apps/management/routes/webhooks.d.ts +122 -122
- 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/mcp.d.ts +2 -3
- package/dist/apps/mcp.d.ts.map +1 -1
- package/dist/apps/mcp.js +16 -14
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/metadata.d.ts +4 -0
- package/dist/apps/metadata.d.ts.map +1 -1
- package/dist/apps/metadata.js +10 -0
- package/dist/apps/metadata.js.map +1 -1
- package/dist/apps/mpp/App.d.ts +57 -58
- 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 +183 -23
- 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 +15 -6
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/cloudflare.d.ts +50 -0
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +178 -0
- package/dist/cloudflare.js.map +1 -1
- package/dist/db/Db.d.ts +22 -0
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +379 -0
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +933 -1
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +289 -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 +172 -0
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -0
- package/dist/db/tables/fundingDepositAddresses.js +218 -0
- package/dist/db/tables/fundingDepositAddresses.js.map +1 -0
- package/dist/db/tables/fundingDepositRequestObservations.d.ts +45 -0
- package/dist/db/tables/fundingDepositRequestObservations.d.ts.map +1 -0
- package/dist/db/tables/fundingDepositRequestObservations.js +46 -0
- package/dist/db/tables/fundingDepositRequestObservations.js.map +1 -0
- package/dist/db/tables/fundingDeposits.d.ts +171 -0
- package/dist/db/tables/fundingDeposits.d.ts.map +1 -0
- package/dist/db/tables/fundingDeposits.js +182 -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 +16 -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 +2 -2
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +1 -1
- 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 +37 -11
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +75 -16
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +17 -11
- 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 +10 -3
- package/dist/internal/EdgeCache.d.ts.map +1 -1
- package/dist/internal/EdgeCache.js +43 -11
- 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/IpAllowlist.d.ts +15 -0
- package/dist/internal/IpAllowlist.d.ts.map +1 -0
- package/dist/internal/IpAllowlist.js +27 -0
- package/dist/internal/IpAllowlist.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 +2 -2
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +4 -1
- 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 +6 -1
- package/dist/internal/Schema.d.ts.map +1 -1
- package/dist/internal/Schema.js +20 -11
- 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 +49 -24
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +90 -12
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Viem.d.ts +90 -65
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +90 -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 +408 -0
- package/dist/internal/funding/Deposit.d.ts.map +1 -0
- package/dist/internal/funding/Deposit.js +318 -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 +48 -0
- package/dist/internal/funding/Evidence.d.ts.map +1 -0
- package/dist/internal/funding/Evidence.js +315 -0
- package/dist/internal/funding/Evidence.js.map +1 -0
- package/dist/internal/funding/Provider.d.ts +1288 -0
- package/dist/internal/funding/Provider.d.ts.map +1 -0
- package/dist/internal/funding/Provider.js +1086 -0
- package/dist/internal/funding/Provider.js.map +1 -0
- package/dist/internal/funding/Reconciliation.d.ts +127 -0
- package/dist/internal/funding/Reconciliation.d.ts.map +1 -0
- package/dist/internal/funding/Reconciliation.js +885 -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/SourceObservation.d.ts +108 -0
- package/dist/internal/funding/SourceObservation.d.ts.map +1 -0
- package/dist/internal/funding/SourceObservation.js +143 -0
- package/dist/internal/funding/SourceObservation.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 +14 -0
- package/dist/internal/funding/index.d.ts.map +1 -0
- package/dist/internal/funding/index.js +14 -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 +88 -0
- package/dist/internal/funding/providers/relay.d.ts.map +1 -0
- package/dist/internal/funding/providers/relay.js +871 -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 +10 -5
- package/src/ApiKey.test.ts +35 -0
- package/src/ApiKey.ts +27 -0
- package/src/ApiKeys.test.ts +40 -7
- package/src/ApiKeys.ts +46 -10
- package/src/App.test.ts +108 -15
- package/src/App.ts +296 -138
- package/src/Assets.ts +29 -4
- package/src/Client.test-d.ts +809 -37
- 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 +190 -22
- package/src/admin/apps/api-keys.ts +170 -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 +113 -43
- package/src/analytics/Analytics.test.ts +69 -10
- package/src/analytics/Analytics.ts +24 -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 +184 -3
- package/src/apps/data/App.test.ts +28 -23
- package/src/apps/data/App.ts +95 -36
- 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 +1391 -0
- package/src/apps/data/routes/earn.ts +2188 -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/indexer.test.ts +43 -34
- package/src/apps/data/routes/indexer.ts +21 -3
- 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 +245 -25
- package/src/apps/data/routes/tokenlist.ts +72 -19
- package/src/apps/data/routes/tokens.test.ts +6 -8
- package/src/apps/data/routes/tokens.ts +258 -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/webhooks.test.ts +386 -43
- package/src/apps/data/routes/webhooks.ts +172 -71
- 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/funding/Access.ts +26 -0
- package/src/apps/funding/App.test.ts +78 -0
- package/src/apps/funding/App.ts +63 -0
- package/src/apps/funding/Inventory.ts +30 -0
- package/src/apps/funding/ProviderAttempts.ts +26 -0
- package/src/apps/funding/index.ts +1 -0
- package/src/apps/funding/routes/chains.test.ts +78 -0
- package/src/apps/funding/routes/chains.ts +101 -0
- package/src/apps/funding/routes/deposit-addresses.test.ts +1628 -0
- package/src/apps/funding/routes/deposit-addresses.ts +1015 -0
- package/src/apps/funding/routes/providers.test.ts +165 -0
- package/src/apps/funding/routes/providers.ts +73 -0
- package/src/apps/funding/routes/quotes.test.ts +511 -0
- package/src/apps/funding/routes/quotes.ts +205 -0
- package/src/apps/funding/routes/transfers.test.ts +1255 -0
- package/src/apps/funding/routes/transfers.ts +704 -0
- package/src/apps/index.ts +3 -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 +103 -3
- package/src/apps/management/routes/api-keys.ts +98 -10
- 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/mcp.test.ts +17 -2
- package/src/apps/mcp.ts +18 -13
- package/src/apps/metadata.ts +12 -0
- 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 +128 -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 +493 -62
- package/src/apps/relay/App.ts +233 -23
- package/src/apps/relay/Sponsorships.test.ts +49 -0
- package/src/apps/relay/Sponsorships.ts +18 -6
- package/src/cloudflare.ts +279 -0
- package/src/db/Db.ts +501 -0
- package/src/db/Schema.ts +349 -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 +404 -0
- package/src/db/tables/fundingDepositRequestObservations.test.ts +106 -0
- package/src/db/tables/fundingDepositRequestObservations.ts +99 -0
- package/src/db/tables/fundingDeposits.test.ts +399 -0
- package/src/db/tables/fundingDeposits.ts +373 -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.ts +16 -0
- package/src/db/tables/projects.ts +16 -0
- package/src/db/tables/requestUsage.ts +23 -0
- package/src/db/tables/sponsoredTransactions.test.ts +11 -0
- package/src/db/tables/sponsoredTransactions.ts +3 -3
- 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 +225 -5
- package/src/internal/Auth.ts +109 -20
- package/src/internal/Cache.test.ts +37 -3
- package/src/internal/Cache.ts +14 -10
- 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 +26 -7
- package/src/internal/EdgeCache.ts +48 -9
- 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/IpAllowlist.test.ts +52 -0
- package/src/internal/IpAllowlist.ts +39 -0
- package/src/internal/Log.test-d.ts +41 -8
- package/src/internal/Log.test.ts +196 -9
- 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 +4 -1
- package/src/internal/Provider.test.ts +17 -0
- package/src/internal/Provider.ts +17 -0
- package/src/internal/Schema.ts +27 -17
- 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 +240 -18
- package/src/internal/Tidx.ts +129 -33
- package/src/internal/VerifiedTokens.test.ts +15 -0
- package/src/internal/Viem.test.ts +198 -17
- package/src/internal/Viem.ts +127 -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 +522 -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 +425 -0
- package/src/internal/funding/Provider.test.ts +1328 -0
- package/src/internal/funding/Provider.ts +1911 -0
- package/src/internal/funding/Reconciliation.local.test.ts +511 -0
- package/src/internal/funding/Reconciliation.test.ts +3037 -0
- package/src/internal/funding/Reconciliation.ts +1202 -0
- package/src/internal/funding/Route.test.ts +66 -0
- package/src/internal/funding/Route.ts +29 -0
- package/src/internal/funding/SourceObservation.test.ts +301 -0
- package/src/internal/funding/SourceObservation.ts +267 -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 +21 -0
- package/src/internal/funding/index.ts +13 -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 +564 -0
- package/src/internal/funding/providers/relay.ts +1060 -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/apps/data/routes/funding.d.ts.map +0 -1
- package/dist/apps/data/routes/funding.js +0 -410
- package/dist/apps/data/routes/funding.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/apps/data/routes/funding.test.ts +0 -503
- package/src/apps/data/routes/funding.ts +0 -604
- package/src/internal/FundingQuotes.test.ts +0 -456
- package/src/internal/FundingQuotes.ts +0 -944
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import * as core_Provider from '../Provider.js'
|
|
2
|
+
import * as Provider from './Provider.js'
|
|
3
|
+
|
|
4
|
+
describe('from', () => {
|
|
5
|
+
test('preserves provider identity and adds the exchange category', () => {
|
|
6
|
+
const provider = Provider.from({
|
|
7
|
+
id: 'example',
|
|
8
|
+
name: 'Example',
|
|
9
|
+
async quote() {
|
|
10
|
+
throw new Provider.RouteUnavailableError()
|
|
11
|
+
},
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
expect(provider).toMatchObject({
|
|
15
|
+
id: 'example',
|
|
16
|
+
name: 'Example',
|
|
17
|
+
type: 'exchange',
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('rejects provider ids that are not normalized', () => {
|
|
22
|
+
expect(() =>
|
|
23
|
+
Provider.from({
|
|
24
|
+
id: ' Example ',
|
|
25
|
+
name: 'Example',
|
|
26
|
+
async quote() {
|
|
27
|
+
throw new Provider.RouteUnavailableError()
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
).toThrowErrorMatchingInlineSnapshot(
|
|
31
|
+
`[ExchangeProvider.ProviderConfigurationError: Provider ids must be lowercase and trimmed.]`,
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
describe('is', () => {
|
|
37
|
+
test('accepts only exchange providers with quote capability', () => {
|
|
38
|
+
const exchange = Provider.from({
|
|
39
|
+
id: 'exchange',
|
|
40
|
+
name: 'Exchange',
|
|
41
|
+
async quote() {
|
|
42
|
+
throw new Provider.RouteUnavailableError()
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
const incomplete = core_Provider.from({
|
|
46
|
+
id: 'incomplete',
|
|
47
|
+
name: 'Incomplete',
|
|
48
|
+
type: 'exchange',
|
|
49
|
+
})
|
|
50
|
+
const funding = core_Provider.from({ id: 'funding', name: 'Funding', type: 'funding' })
|
|
51
|
+
|
|
52
|
+
expect([exchange, incomplete, funding].map(Provider.is)).toEqual([true, false, false])
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe('failure', () => {
|
|
57
|
+
const provider = Provider.from({
|
|
58
|
+
id: 'example',
|
|
59
|
+
name: 'Example',
|
|
60
|
+
async quote() {
|
|
61
|
+
throw new Provider.RouteUnavailableError()
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('reports the upstream operation and status', () => {
|
|
66
|
+
expect(
|
|
67
|
+
Provider.failure(
|
|
68
|
+
new Provider.ProviderResponseError({ operation: 'check_approval', status: 429 }),
|
|
69
|
+
{ chainId: 4217, operation: 'quote', provider },
|
|
70
|
+
),
|
|
71
|
+
).toMatchInlineSnapshot(`
|
|
72
|
+
{
|
|
73
|
+
"chainId": 4217,
|
|
74
|
+
"failure": "rate_limit",
|
|
75
|
+
"id": "example",
|
|
76
|
+
"operation": "check_approval",
|
|
77
|
+
"status": 429,
|
|
78
|
+
}
|
|
79
|
+
`)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('reports payload failures at the enclosing operation', () => {
|
|
83
|
+
expect(
|
|
84
|
+
Provider.failure(new Provider.ProviderPayloadError(), {
|
|
85
|
+
chainId: 4217,
|
|
86
|
+
operation: 'finalize',
|
|
87
|
+
provider,
|
|
88
|
+
}),
|
|
89
|
+
).toMatchInlineSnapshot(`
|
|
90
|
+
{
|
|
91
|
+
"chainId": 4217,
|
|
92
|
+
"failure": "payload",
|
|
93
|
+
"id": "example",
|
|
94
|
+
"operation": "finalize",
|
|
95
|
+
}
|
|
96
|
+
`)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
test('reports bounded payload validation codes', () => {
|
|
100
|
+
expect(
|
|
101
|
+
Provider.failure(new Provider.ProviderPayloadError({ code: 'quote.response.permitData' }), {
|
|
102
|
+
chainId: 4217,
|
|
103
|
+
operation: 'quote',
|
|
104
|
+
provider,
|
|
105
|
+
}),
|
|
106
|
+
).toMatchInlineSnapshot(`
|
|
107
|
+
{
|
|
108
|
+
"chainId": 4217,
|
|
109
|
+
"code": "quote.response.permitData",
|
|
110
|
+
"failure": "payload",
|
|
111
|
+
"id": "example",
|
|
112
|
+
"operation": "quote",
|
|
113
|
+
}
|
|
114
|
+
`)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test('reports the upstream operation for network failures', () => {
|
|
118
|
+
expect(
|
|
119
|
+
Provider.failure(
|
|
120
|
+
new Provider.ProviderNetworkError({
|
|
121
|
+
cause: new TypeError('secret network detail'),
|
|
122
|
+
operation: 'check_approval',
|
|
123
|
+
}),
|
|
124
|
+
{ chainId: 4217, operation: 'quote', provider },
|
|
125
|
+
),
|
|
126
|
+
).toMatchInlineSnapshot(`
|
|
127
|
+
{
|
|
128
|
+
"chainId": 4217,
|
|
129
|
+
"failure": "network",
|
|
130
|
+
"id": "example",
|
|
131
|
+
"operation": "check_approval",
|
|
132
|
+
}
|
|
133
|
+
`)
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
test('ignores failures outside the provider boundary', () => {
|
|
137
|
+
expect(
|
|
138
|
+
Provider.failure(new Error('metadata lookup failed'), {
|
|
139
|
+
chainId: 4217,
|
|
140
|
+
operation: 'quote',
|
|
141
|
+
provider,
|
|
142
|
+
}),
|
|
143
|
+
).toBeUndefined()
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
describe('validateExecution', () => {
|
|
148
|
+
const account = '0x1111111111111111111111111111111111111111'
|
|
149
|
+
const destinationToken = '0x20c0000000000000000000000000000000000002'
|
|
150
|
+
const sourceToken = '0x20c0000000000000000000000000000000000001'
|
|
151
|
+
const router = '0x2222222222222222222222222222222222222222'
|
|
152
|
+
|
|
153
|
+
test('accepts transfers within exact-source bounds', () => {
|
|
154
|
+
expect(() =>
|
|
155
|
+
Provider.validateExecution({
|
|
156
|
+
account,
|
|
157
|
+
execution: {
|
|
158
|
+
destinationAmount: '100',
|
|
159
|
+
destinationToken,
|
|
160
|
+
gasUnits: '1',
|
|
161
|
+
minimumDestinationAmount: '99',
|
|
162
|
+
mode: 'exactSource',
|
|
163
|
+
sourceAmount: '50',
|
|
164
|
+
sourceToken,
|
|
165
|
+
},
|
|
166
|
+
transfers: [
|
|
167
|
+
{ amount: 50n, from: account, to: router, token: sourceToken },
|
|
168
|
+
{ amount: 99n, from: router, to: account, token: destinationToken },
|
|
169
|
+
],
|
|
170
|
+
}),
|
|
171
|
+
).not.toThrow()
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
test('rejects a different outgoing token', () => {
|
|
175
|
+
expect(() =>
|
|
176
|
+
Provider.validateExecution({
|
|
177
|
+
account,
|
|
178
|
+
execution: {
|
|
179
|
+
destinationAmount: '100',
|
|
180
|
+
destinationToken,
|
|
181
|
+
gasUnits: '1',
|
|
182
|
+
minimumDestinationAmount: '99',
|
|
183
|
+
mode: 'exactSource',
|
|
184
|
+
sourceAmount: '50',
|
|
185
|
+
sourceToken,
|
|
186
|
+
},
|
|
187
|
+
transfers: [
|
|
188
|
+
{ amount: 1n, from: account, to: router, token: destinationToken },
|
|
189
|
+
{ amount: 50n, from: account, to: router, token: sourceToken },
|
|
190
|
+
{ amount: 100n, from: router, to: account, token: destinationToken },
|
|
191
|
+
],
|
|
192
|
+
}),
|
|
193
|
+
).toThrow(Provider.ProviderPayloadError)
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
test('rejects execution outside exact-destination bounds', () => {
|
|
197
|
+
expect(() =>
|
|
198
|
+
Provider.validateExecution({
|
|
199
|
+
account,
|
|
200
|
+
execution: {
|
|
201
|
+
destinationAmount: '100',
|
|
202
|
+
destinationToken,
|
|
203
|
+
gasUnits: '1',
|
|
204
|
+
maximumSourceAmount: '50',
|
|
205
|
+
mode: 'exactDestination',
|
|
206
|
+
sourceAmount: '49',
|
|
207
|
+
sourceToken,
|
|
208
|
+
},
|
|
209
|
+
transfers: [
|
|
210
|
+
{ amount: 51n, from: account, to: router, token: sourceToken },
|
|
211
|
+
{ amount: 100n, from: router, to: account, token: destinationToken },
|
|
212
|
+
],
|
|
213
|
+
}),
|
|
214
|
+
).toThrow(Provider.ProviderPayloadError)
|
|
215
|
+
})
|
|
216
|
+
})
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import type { Hex } from 'ox'
|
|
2
|
+
|
|
3
|
+
import * as core_Provider from '../Provider.js'
|
|
4
|
+
import type * as Log from '../Log.js'
|
|
5
|
+
|
|
6
|
+
/** Exchange quote provider called after the native DEX cannot route a swap. */
|
|
7
|
+
export type Provider<id extends string = string> = core_Provider.Provider<id, 'exchange'> & {
|
|
8
|
+
/** Converts a signed continuation into final executable calls. */
|
|
9
|
+
finalizeQuote?(
|
|
10
|
+
this: void,
|
|
11
|
+
input: FinalizeQuoteInput,
|
|
12
|
+
signal: AbortSignal,
|
|
13
|
+
): Promise<FinalizeQuoteResult>
|
|
14
|
+
/** Returns the approvals, signature, or executable calls needed to continue. */
|
|
15
|
+
quote(this: void, input: QuoteInput, signal: AbortSignal): Promise<QuoteResult>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Provider-neutral unsigned transaction call. */
|
|
19
|
+
export type Call = {
|
|
20
|
+
/** ABI-encoded call data. */
|
|
21
|
+
data: Hex.Hex
|
|
22
|
+
/** Contract receiving the call. */
|
|
23
|
+
to: `0x${string}`
|
|
24
|
+
/** Native token value as a JSON-RPC quantity. */
|
|
25
|
+
value: Hex.Hex
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Input used to finish a provider quote after signing. */
|
|
29
|
+
export type FinalizeQuoteInput = {
|
|
30
|
+
/** Wallet signing and executing the swap. */
|
|
31
|
+
account: `0x${string}`
|
|
32
|
+
/** Tempo chain id. */
|
|
33
|
+
chainId: number
|
|
34
|
+
/** Opaque provider state returned by `quote`. */
|
|
35
|
+
continuation: string
|
|
36
|
+
/** EIP-712 signature requested by the quote result. */
|
|
37
|
+
signature: Hex.Hex
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Final executable calls returned after a signature. */
|
|
41
|
+
export type FinalizeQuoteResult = {
|
|
42
|
+
/** Calls to execute in order. */
|
|
43
|
+
calls: readonly Call[]
|
|
44
|
+
/** Quote constraints that the final calls must satisfy. */
|
|
45
|
+
execution: Execution
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Constraints used to validate executable provider calls. */
|
|
49
|
+
export type Execution = QuoteAmounts & {
|
|
50
|
+
/** Token received by the swap. */
|
|
51
|
+
destinationToken: `0x${string}`
|
|
52
|
+
/** Side whose requested amount remains exact. */
|
|
53
|
+
mode: 'exactDestination' | 'exactSource'
|
|
54
|
+
/** Token spent by the swap. */
|
|
55
|
+
sourceToken: `0x${string}`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Token movement observed while simulating provider calls. */
|
|
59
|
+
export type Transfer = {
|
|
60
|
+
/** Amount moved in base units. */
|
|
61
|
+
amount: bigint
|
|
62
|
+
/** Account sending the tokens. */
|
|
63
|
+
from: `0x${string}`
|
|
64
|
+
/** Account receiving the tokens. */
|
|
65
|
+
to: `0x${string}`
|
|
66
|
+
/** Token contract that emitted the transfer. */
|
|
67
|
+
token: `0x${string}`
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Provider-neutral quote input. */
|
|
71
|
+
export type QuoteInput = {
|
|
72
|
+
/** Wallet receiving and executing the swap. */
|
|
73
|
+
account: `0x${string}`
|
|
74
|
+
/** Exact source or destination amount in base units. */
|
|
75
|
+
amount: string
|
|
76
|
+
/** Tempo chain id. */
|
|
77
|
+
chainId: number
|
|
78
|
+
/** Token received by the swap. */
|
|
79
|
+
destinationToken: `0x${string}`
|
|
80
|
+
/** Side whose requested amount remains exact. */
|
|
81
|
+
mode: 'exactDestination' | 'exactSource'
|
|
82
|
+
/** Maximum execution slippage in basis points. */
|
|
83
|
+
slippageBps: number
|
|
84
|
+
/** Token spent by the swap. */
|
|
85
|
+
sourceToken: `0x${string}`
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Quote with the approvals, signature, or transaction needed for its next step. */
|
|
89
|
+
export type QuoteResult =
|
|
90
|
+
| (QuoteAmounts & {
|
|
91
|
+
/** Calls that must confirm before requesting a fresh quote. */
|
|
92
|
+
approval: { calls: readonly Call[] }
|
|
93
|
+
/** Onchain approval is required before this swap can be quoted for execution. */
|
|
94
|
+
status: 'approvalRequired'
|
|
95
|
+
})
|
|
96
|
+
| (QuoteAmounts & {
|
|
97
|
+
/** Quote is ready for execution. */
|
|
98
|
+
status: 'ready'
|
|
99
|
+
/** Ordered calls required to execute the quote. */
|
|
100
|
+
transaction: { calls: readonly Call[] }
|
|
101
|
+
})
|
|
102
|
+
| (QuoteAmounts & {
|
|
103
|
+
/** Opaque provider state passed to `finalizeQuote`. */
|
|
104
|
+
continuation: string
|
|
105
|
+
/** Quote needs a wallet signature before final calldata can be built. */
|
|
106
|
+
status: 'signatureRequired'
|
|
107
|
+
/** EIP-712 payload the wallet must sign. */
|
|
108
|
+
typedData: TypedData
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
/** Defines an exchange provider while preserving its concrete identity. */
|
|
112
|
+
export function from<const id extends string>(options: from.Options<id>): Provider<id> {
|
|
113
|
+
if (options.id !== options.id.trim().toLowerCase() || options.id.length === 0)
|
|
114
|
+
throw new ProviderConfigurationError('Provider ids must be lowercase and trimmed.')
|
|
115
|
+
return core_Provider.from({ ...options, type: 'exchange' })
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export declare namespace from {
|
|
119
|
+
/** Exchange provider definition. */
|
|
120
|
+
type Options<id extends string> = Omit<Provider<id>, 'type'>
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Returns whether a registered provider implements exchange quotes. */
|
|
124
|
+
export function is(provider: core_Provider.Provider): provider is Provider {
|
|
125
|
+
return provider.type === 'exchange' && 'quote' in provider && typeof provider.quote === 'function'
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Returns bounded exchange-provider failure details for structured request logs. */
|
|
129
|
+
export function failure(cause: unknown, options: failure.Options): Log.ProviderFailure | undefined {
|
|
130
|
+
const { chainId, operation, provider } = options
|
|
131
|
+
if (cause instanceof ProviderResponseError)
|
|
132
|
+
return {
|
|
133
|
+
chainId,
|
|
134
|
+
failure: cause.status === 429 ? 'rate_limit' : 'http',
|
|
135
|
+
id: provider.id,
|
|
136
|
+
operation: cause.operation,
|
|
137
|
+
status: cause.status,
|
|
138
|
+
}
|
|
139
|
+
if (cause instanceof ProviderNetworkError)
|
|
140
|
+
return { chainId, failure: 'network', id: provider.id, operation: cause.operation }
|
|
141
|
+
if (cause instanceof ProviderPayloadError)
|
|
142
|
+
return {
|
|
143
|
+
chainId,
|
|
144
|
+
...(cause.code ? { code: cause.code } : {}),
|
|
145
|
+
failure: 'payload',
|
|
146
|
+
id: provider.id,
|
|
147
|
+
operation,
|
|
148
|
+
}
|
|
149
|
+
return undefined
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export declare namespace failure {
|
|
153
|
+
/** Exchange-provider context retained when a quote operation fails. */
|
|
154
|
+
type Options = {
|
|
155
|
+
/** Chain selected by the quote request. */
|
|
156
|
+
chainId: number
|
|
157
|
+
/** Provider operation used when the error has no narrower operation. */
|
|
158
|
+
operation: string
|
|
159
|
+
/** Exchange provider that handled the request. */
|
|
160
|
+
provider: Provider
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Validates simulated token movements against an executable quote. */
|
|
165
|
+
export function validateExecution(options: validateExecution.Options): void {
|
|
166
|
+
const account = options.account.toLowerCase()
|
|
167
|
+
const destinationToken = options.execution.destinationToken.toLowerCase()
|
|
168
|
+
const sourceToken = options.execution.sourceToken.toLowerCase()
|
|
169
|
+
let destinationReceived = 0n
|
|
170
|
+
let sourceIncoming = 0n
|
|
171
|
+
let sourceOutgoing = 0n
|
|
172
|
+
|
|
173
|
+
for (const transfer of options.transfers) {
|
|
174
|
+
const token = transfer.token.toLowerCase()
|
|
175
|
+
if (transfer.from.toLowerCase() === account) {
|
|
176
|
+
if (token !== sourceToken) throw new ProviderPayloadError()
|
|
177
|
+
sourceOutgoing += transfer.amount
|
|
178
|
+
}
|
|
179
|
+
if (transfer.to.toLowerCase() !== account) continue
|
|
180
|
+
if (token === sourceToken) sourceIncoming += transfer.amount
|
|
181
|
+
if (token === destinationToken) destinationReceived += transfer.amount
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const sourceSpent = sourceOutgoing - sourceIncoming
|
|
185
|
+
if (sourceSpent <= 0n) throw new ProviderPayloadError()
|
|
186
|
+
if (options.execution.mode === 'exactSource') {
|
|
187
|
+
if (
|
|
188
|
+
sourceSpent !== BigInt(options.execution.sourceAmount) ||
|
|
189
|
+
options.execution.minimumDestinationAmount === undefined ||
|
|
190
|
+
destinationReceived < BigInt(options.execution.minimumDestinationAmount)
|
|
191
|
+
)
|
|
192
|
+
throw new ProviderPayloadError()
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (
|
|
197
|
+
options.execution.maximumSourceAmount === undefined ||
|
|
198
|
+
sourceSpent > BigInt(options.execution.maximumSourceAmount) ||
|
|
199
|
+
destinationReceived < BigInt(options.execution.destinationAmount)
|
|
200
|
+
)
|
|
201
|
+
throw new ProviderPayloadError()
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export declare namespace validateExecution {
|
|
205
|
+
/** Simulated transfers and quote constraints to validate. */
|
|
206
|
+
type Options = {
|
|
207
|
+
/** Wallet executing the provider calls. */
|
|
208
|
+
account: `0x${string}`
|
|
209
|
+
/** Quote constraints bound to the executable calls. */
|
|
210
|
+
execution: Execution
|
|
211
|
+
/** Token transfers emitted by the simulated calls. */
|
|
212
|
+
transfers: readonly Transfer[]
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Amount bounds returned by an exchange provider. */
|
|
217
|
+
export type QuoteAmounts = {
|
|
218
|
+
/** Expected destination amount in base units. */
|
|
219
|
+
destinationAmount: string
|
|
220
|
+
/** Estimated execution gas units. */
|
|
221
|
+
gasUnits: string
|
|
222
|
+
/** Maximum source amount for an exact-destination quote. */
|
|
223
|
+
maximumSourceAmount?: string | undefined
|
|
224
|
+
/** Minimum destination amount for an exact-source quote. */
|
|
225
|
+
minimumDestinationAmount?: string | undefined
|
|
226
|
+
/** Expected source amount in base units. */
|
|
227
|
+
sourceAmount: string
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Provider-neutral EIP-712 payload accepted by Privy and common wallet clients. */
|
|
231
|
+
export type TypedData = {
|
|
232
|
+
/** EIP-712 signing domain. */
|
|
233
|
+
domain: Record<string, unknown>
|
|
234
|
+
/** EIP-712 message values. */
|
|
235
|
+
message: Record<string, unknown>
|
|
236
|
+
/** Root EIP-712 type. */
|
|
237
|
+
primaryType: string
|
|
238
|
+
/** EIP-712 type definitions. */
|
|
239
|
+
types: Record<string, readonly { name: string; type: string }[]>
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Raised when a provider has no executable route for the requested swap. */
|
|
243
|
+
export class RouteUnavailableError extends Error {
|
|
244
|
+
override name = 'ExchangeProvider.RouteUnavailableError'
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Raised when a continuation cannot be decoded or validated. */
|
|
248
|
+
export class ProviderContinuationError extends Error {
|
|
249
|
+
override name = 'ExchangeProvider.ProviderContinuationError'
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Raised when required provider configuration is invalid. */
|
|
253
|
+
export class ProviderConfigurationError extends Error {
|
|
254
|
+
override name = 'ExchangeProvider.ProviderConfigurationError'
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** Raised when an upstream provider request fails before receiving a response. */
|
|
258
|
+
export class ProviderNetworkError extends Error {
|
|
259
|
+
override name = 'ExchangeProvider.ProviderNetworkError'
|
|
260
|
+
|
|
261
|
+
/** Upstream operation that failed. */
|
|
262
|
+
operation: string
|
|
263
|
+
|
|
264
|
+
constructor(options: ProviderNetworkError.Options) {
|
|
265
|
+
super(`Provider ${options.operation} request failed`, { cause: options.cause })
|
|
266
|
+
this.operation = options.operation
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export declare namespace ProviderNetworkError {
|
|
271
|
+
/** Safe request details retained for operational reporting. */
|
|
272
|
+
type Options = {
|
|
273
|
+
/** Original network error. */
|
|
274
|
+
cause: TypeError
|
|
275
|
+
/** Stable upstream operation identifier. */
|
|
276
|
+
operation: string
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Raised when an upstream provider returns an invalid payload. */
|
|
281
|
+
export class ProviderPayloadError extends Error {
|
|
282
|
+
override name = 'ExchangeProvider.ProviderPayloadError'
|
|
283
|
+
|
|
284
|
+
/** Stable validation code safe for operational reporting. */
|
|
285
|
+
code?: string | undefined
|
|
286
|
+
|
|
287
|
+
constructor(options: ProviderPayloadError.Options = {}) {
|
|
288
|
+
super(options.code ? `Provider payload failed ${options.code}` : undefined)
|
|
289
|
+
this.code = options.code
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export declare namespace ProviderPayloadError {
|
|
294
|
+
/** Bounded invalid-payload details. */
|
|
295
|
+
type Options = {
|
|
296
|
+
/** Stable validation code safe for operational reporting. */
|
|
297
|
+
code?: string | undefined
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Raised when an upstream provider request fails. */
|
|
302
|
+
export class ProviderResponseError extends Error {
|
|
303
|
+
override name = 'ExchangeProvider.ProviderResponseError'
|
|
304
|
+
|
|
305
|
+
/** Upstream operation that returned the response. */
|
|
306
|
+
operation: string
|
|
307
|
+
|
|
308
|
+
/** Upstream HTTP status. */
|
|
309
|
+
status: number
|
|
310
|
+
|
|
311
|
+
constructor(options: ProviderResponseError.Options) {
|
|
312
|
+
super(`Provider ${options.operation} request failed with status ${options.status}`)
|
|
313
|
+
this.operation = options.operation
|
|
314
|
+
this.status = options.status
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export declare namespace ProviderResponseError {
|
|
319
|
+
/** Safe upstream response details retained for operational reporting. */
|
|
320
|
+
type Options = {
|
|
321
|
+
/** Stable upstream operation identifier. */
|
|
322
|
+
operation: string
|
|
323
|
+
/** Upstream HTTP status. */
|
|
324
|
+
status: number
|
|
325
|
+
}
|
|
326
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Provider from './Provider.js'
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Hex } from 'ox'
|
|
2
|
+
import { encodeAbiParameters, encodeFunctionData, parseAbi, parseAbiParameters } from 'viem'
|
|
3
|
+
|
|
4
|
+
import * as Provider from '../Provider.js'
|
|
5
|
+
import {
|
|
6
|
+
uniswap,
|
|
7
|
+
validateApprovalResponse,
|
|
8
|
+
validateExactSourceMaximum,
|
|
9
|
+
validateExactSourceMinimum,
|
|
10
|
+
validateRouterCalldata,
|
|
11
|
+
} from './uniswap.js'
|
|
12
|
+
|
|
13
|
+
const routerAbi = parseAbi([
|
|
14
|
+
'function execute(bytes commands, bytes[] inputs)',
|
|
15
|
+
'function execute(bytes commands, bytes[] inputs, uint256 deadline)',
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
const execute = (commands: `0x${string}`, inputs: readonly `0x${string}`[]) =>
|
|
19
|
+
encodeFunctionData({
|
|
20
|
+
abi: routerAbi,
|
|
21
|
+
args: [commands, inputs],
|
|
22
|
+
functionName: 'execute',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
describe('uniswap', () => {
|
|
26
|
+
test('creates an exchange provider', () => {
|
|
27
|
+
expect(uniswap({ apiKey: 'uniswap-key' })).toMatchObject({
|
|
28
|
+
id: 'uniswap',
|
|
29
|
+
name: 'Uniswap',
|
|
30
|
+
type: 'exchange',
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('rejects a blank API key', () => {
|
|
35
|
+
expect(() => uniswap({ apiKey: ' ' })).toThrow(Provider.ProviderConfigurationError)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
describe('validateApprovalResponse', () => {
|
|
40
|
+
test('accepts hex transaction values', () => {
|
|
41
|
+
expect(
|
|
42
|
+
validateApprovalResponse({
|
|
43
|
+
approval: {
|
|
44
|
+
chainId: 4217,
|
|
45
|
+
data: '0x1234',
|
|
46
|
+
from: `0x${'11'.repeat(20)}`,
|
|
47
|
+
to: `0x${'22'.repeat(20)}`,
|
|
48
|
+
value: '0x0',
|
|
49
|
+
},
|
|
50
|
+
cancel: null,
|
|
51
|
+
}),
|
|
52
|
+
).toMatchInlineSnapshot(`
|
|
53
|
+
{
|
|
54
|
+
"approval": {
|
|
55
|
+
"chainId": 4217,
|
|
56
|
+
"data": "0x1234",
|
|
57
|
+
"from": "0x1111111111111111111111111111111111111111",
|
|
58
|
+
"to": "0x2222222222222222222222222222222222222222",
|
|
59
|
+
"value": "0x0",
|
|
60
|
+
},
|
|
61
|
+
"cancel": null,
|
|
62
|
+
}
|
|
63
|
+
`)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe('validateRouterCalldata', () => {
|
|
68
|
+
test('accepts swap commands and nested plans', () => {
|
|
69
|
+
const nested = encodeAbiParameters(parseAbiParameters('bytes, bytes[]'), ['0x00', ['0x']])
|
|
70
|
+
expect(() => validateRouterCalldata(execute('0x0021', ['0x', nested]))).not.toThrow()
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('accepts supported V4 swap actions', () => {
|
|
74
|
+
const plan = encodeAbiParameters(parseAbiParameters('bytes, bytes[]'), ['0x060e', ['0x', '0x']])
|
|
75
|
+
expect(() => validateRouterCalldata(execute('0x10', [plan]))).not.toThrow()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('rejects unsupported commands and mismatched inputs', () => {
|
|
79
|
+
expect(() => validateRouterCalldata(execute('0x11', ['0x']))).toThrow(
|
|
80
|
+
Provider.ProviderPayloadError,
|
|
81
|
+
)
|
|
82
|
+
expect(() =>
|
|
83
|
+
validateRouterCalldata(execute(Hex.fromBytes(new Uint8Array([0x00])), [])),
|
|
84
|
+
).toThrow(Provider.ProviderPayloadError)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe('validateExactSourceMaximum', () => {
|
|
89
|
+
test('accepts an absent or equal maximum', () => {
|
|
90
|
+
expect(() => validateExactSourceMaximum({ amount: '100' })).not.toThrow()
|
|
91
|
+
expect(() => validateExactSourceMaximum({ amount: '100', maximumAmount: '100' })).not.toThrow()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('rejects a larger or smaller maximum', () => {
|
|
95
|
+
expect(() => validateExactSourceMaximum({ amount: '100', maximumAmount: '101' })).toThrow(
|
|
96
|
+
Provider.ProviderPayloadError,
|
|
97
|
+
)
|
|
98
|
+
expect(() => validateExactSourceMaximum({ amount: '100', maximumAmount: '99' })).toThrow(
|
|
99
|
+
Provider.ProviderPayloadError,
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
describe('validateExactSourceMinimum', () => {
|
|
105
|
+
test('accepts the integer slippage floor', () => {
|
|
106
|
+
expect(() =>
|
|
107
|
+
validateExactSourceMinimum({ amount: '101', minimumAmount: '100', slippageBps: 50 }),
|
|
108
|
+
).not.toThrow()
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
test('rejects missing, excessive, or insufficient minimums', () => {
|
|
112
|
+
expect(() => validateExactSourceMinimum({ amount: '101', slippageBps: 50 })).toThrow(
|
|
113
|
+
Provider.ProviderPayloadError,
|
|
114
|
+
)
|
|
115
|
+
expect(() =>
|
|
116
|
+
validateExactSourceMinimum({ amount: '101', minimumAmount: '99', slippageBps: 50 }),
|
|
117
|
+
).toThrow(Provider.ProviderPayloadError)
|
|
118
|
+
expect(() =>
|
|
119
|
+
validateExactSourceMinimum({ amount: '101', minimumAmount: '102', slippageBps: 50 }),
|
|
120
|
+
).toThrow(Provider.ProviderPayloadError)
|
|
121
|
+
})
|
|
122
|
+
})
|