tapimo 0.15.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/dist/ApiKey.d.ts +1 -0
- package/dist/ApiKey.d.ts.map +1 -1
- package/dist/ApiKey.js +4 -2
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +37 -11
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +163 -10
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +13085 -11974
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +46 -15
- package/dist/App.js.map +1 -1
- package/dist/Scope.d.ts +1 -1
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +1 -1
- package/dist/Scope.js.map +1 -1
- package/dist/admin/App.d.ts +893 -191
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +5 -1
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +70 -70
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +8 -3
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +66 -27
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
- package/dist/admin/apps/earn-vaults.js +36 -7
- package/dist/admin/apps/earn-vaults.js.map +1 -1
- package/dist/admin/apps/organizations.d.ts +25 -25
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +5 -4
- package/dist/admin/apps/organizations.js.map +1 -1
- package/dist/admin/apps/route-policies.d.ts +632 -0
- package/dist/admin/apps/route-policies.d.ts.map +1 -0
- package/dist/admin/apps/route-policies.js +257 -0
- package/dist/admin/apps/route-policies.js.map +1 -0
- package/dist/admin/apps/routes-support.js +39 -3
- package/dist/admin/apps/routes-support.js.map +1 -1
- package/dist/admin/apps/routes.d.ts +529 -76
- package/dist/admin/apps/routes.d.ts.map +1 -1
- package/dist/admin/apps/routes.js +82 -1
- package/dist/admin/apps/routes.js.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +157 -157
- package/dist/admin/index.d.ts +0 -1
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +0 -1
- package/dist/admin/index.js.map +1 -1
- 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 +205 -201
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +65 -1
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +1 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +58 -59
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/apps/data/App.d.ts +2709 -2670
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +357 -357
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +50 -0
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +248 -248
- package/dist/apps/data/routes/balances.d.ts +22 -22
- package/dist/apps/data/routes/balances.d.ts.map +1 -1
- package/dist/apps/data/routes/balances.js +5 -7
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +125 -125
- package/dist/apps/data/routes/coingecko.d.ts +54 -54
- package/dist/apps/data/routes/earn.d.ts +103 -12
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +456 -220
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +267 -97
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +109 -127
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +83 -54
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +43 -43
- package/dist/apps/data/routes/receipts.d.ts +235 -235
- package/dist/apps/data/routes/rpc.d.ts +30 -30
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +11 -6
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +2 -0
- package/dist/apps/data/routes/transactions.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.js +30 -22
- package/dist/apps/data/routes/transactions.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +77 -77
- package/dist/apps/data/routes/valuation.d.ts +32 -32
- package/dist/apps/data/routes/verified-tokens.d.ts +86 -86
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +1 -1
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +31 -31
- package/dist/apps/management/App.d.ts +2909 -2064
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/App.js +2 -0
- package/dist/apps/management/App.js.map +1 -1
- package/dist/apps/management/Billing.d.ts +2 -4
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +65 -26
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +257 -245
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +70 -11
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +84 -84
- package/dist/apps/management/routes/cli.d.ts +912 -0
- package/dist/apps/management/routes/cli.d.ts.map +1 -0
- package/dist/apps/management/routes/cli.js +416 -0
- package/dist/apps/management/routes/cli.js.map +1 -0
- package/dist/apps/management/routes/faucet.d.ts +8 -8
- package/dist/apps/management/routes/invitations.d.ts +138 -138
- package/dist/apps/management/routes/invite-links.d.ts +172 -172
- package/dist/apps/management/routes/members.d.ts +16 -16
- package/dist/apps/management/routes/orgs.d.ts +104 -104
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +8 -2
- package/dist/apps/management/routes/orgs.js.map +1 -1
- package/dist/apps/management/routes/projects.d.ts +125 -125
- package/dist/apps/management/routes/usage.d.ts +8 -8
- package/dist/apps/management/routes/verified-token-requests.d.ts +86 -86
- package/dist/apps/management/routes/webhooks.d.ts +485 -485
- package/dist/apps/mpp/App.d.ts +44 -44
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Policy.js +4 -2
- package/dist/apps/mpp/internal/Policy.js.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.js +6 -4
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -1
- package/dist/apps/relay/App.d.ts +8 -0
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +16 -4
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts +4 -6
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +71 -60
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/apps/routes/Access.d.ts +53 -0
- package/dist/apps/routes/Access.d.ts.map +1 -1
- package/dist/apps/routes/Access.js +121 -0
- package/dist/apps/routes/Access.js.map +1 -1
- package/dist/apps/routes/App.d.ts +397 -158
- package/dist/apps/routes/App.d.ts.map +1 -1
- package/dist/apps/routes/App.js.map +1 -1
- package/dist/apps/routes/routes/chains.d.ts +25 -25
- package/dist/apps/routes/routes/deposit-addresses.d.ts +169 -61
- package/dist/apps/routes/routes/deposit-addresses.d.ts.map +1 -1
- package/dist/apps/routes/routes/deposit-addresses.js +217 -32
- package/dist/apps/routes/routes/deposit-addresses.js.map +1 -1
- package/dist/apps/routes/routes/quotes.d.ts +171 -81
- package/dist/apps/routes/routes/quotes.d.ts.map +1 -1
- package/dist/apps/routes/routes/quotes.js +101 -27
- package/dist/apps/routes/routes/quotes.js.map +1 -1
- package/dist/apps/routes/routes/transfers.d.ts +532 -480
- package/dist/apps/routes/routes/transfers.d.ts.map +1 -1
- package/dist/apps/routes/routes/transfers.js +182 -37
- package/dist/apps/routes/routes/transfers.js.map +1 -1
- package/dist/cli/ApiKeys.d.ts +120 -0
- package/dist/cli/ApiKeys.d.ts.map +1 -0
- package/dist/cli/ApiKeys.js +138 -0
- package/dist/cli/ApiKeys.js.map +1 -0
- package/dist/cli/Cli.d.ts +92 -34
- package/dist/cli/Cli.d.ts.map +1 -1
- package/dist/cli/Cli.js +188 -11
- package/dist/cli/Cli.js.map +1 -1
- package/dist/cli/Credentials.d.ts +95 -0
- package/dist/cli/Credentials.d.ts.map +1 -0
- package/dist/cli/Credentials.js +110 -0
- package/dist/cli/Credentials.js.map +1 -0
- package/dist/cli/Spec.d.ts +59 -0
- package/dist/cli/Spec.d.ts.map +1 -0
- package/dist/cli/Spec.js +77 -0
- package/dist/cli/Spec.js.map +1 -0
- package/dist/cli/bin.js +5 -1
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/commands/admin.d.ts +5 -5
- package/dist/cli/commands/admin.d.ts.map +1 -1
- package/dist/cli/commands/auth.d.ts +73 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +204 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/keys.d.ts +17 -0
- package/dist/cli/commands/keys.d.ts.map +1 -0
- package/dist/cli/commands/keys.js +109 -0
- package/dist/cli/commands/keys.js.map +1 -0
- package/dist/cloudflare.d.ts +27 -2
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +144 -17
- package/dist/cloudflare.js.map +1 -1
- package/dist/db/Db.d.ts +23 -0
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +413 -1
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +44 -1
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +56 -3
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/apiKeyAdmissions.d.ts +28 -2
- package/dist/db/tables/apiKeyAdmissions.d.ts.map +1 -1
- package/dist/db/tables/apiKeyAdmissions.js +65 -9
- package/dist/db/tables/apiKeyAdmissions.js.map +1 -1
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts +2 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts.map +1 -1
- package/dist/db/tables/apiKeyOwnerTombstones.js +2 -2
- package/dist/db/tables/apiKeyOwnerTombstones.js.map +1 -1
- package/dist/db/tables/authAccounts.d.ts.map +1 -1
- package/dist/db/tables/authAccounts.js +1 -0
- package/dist/db/tables/authAccounts.js.map +1 -1
- package/dist/db/tables/earnVaults.d.ts +5 -1
- package/dist/db/tables/earnVaults.d.ts.map +1 -1
- package/dist/db/tables/earnVaults.js +12 -1
- package/dist/db/tables/earnVaults.js.map +1 -1
- package/dist/db/tables/organizations.d.ts +4 -2
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +8 -34
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/requestUsage.d.ts +5 -1
- package/dist/db/tables/requestUsage.d.ts.map +1 -1
- package/dist/db/tables/requestUsage.js +10 -2
- package/dist/db/tables/requestUsage.js.map +1 -1
- package/dist/db/tables/rewardEligibilityAssociations.d.ts +13 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts.map +1 -1
- package/dist/db/tables/rewardEligibilityAssociations.js +11 -0
- package/dist/db/tables/rewardEligibilityAssociations.js.map +1 -1
- package/dist/db/tables/rewardRuns.d.ts.map +1 -1
- package/dist/db/tables/rewardRuns.js +4 -0
- package/dist/db/tables/rewardRuns.js.map +1 -1
- package/dist/db/tables/rewardTransactionAttempts.d.ts.map +1 -1
- package/dist/db/tables/rewardTransactionAttempts.js +2 -0
- package/dist/db/tables/rewardTransactionAttempts.js.map +1 -1
- package/dist/db/tables/routesDepositAddresses.d.ts +29 -0
- package/dist/db/tables/routesDepositAddresses.d.ts.map +1 -1
- package/dist/db/tables/routesDepositAddresses.js +84 -31
- package/dist/db/tables/routesDepositAddresses.js.map +1 -1
- package/dist/db/tables/routesDeposits.d.ts.map +1 -1
- package/dist/db/tables/routesDeposits.js +31 -21
- package/dist/db/tables/routesDeposits.js.map +1 -1
- package/dist/db/tables/routesIdempotency.d.ts.map +1 -1
- package/dist/db/tables/routesIdempotency.js +2 -0
- package/dist/db/tables/routesIdempotency.js.map +1 -1
- package/dist/db/tables/routesPolicies.d.ts +58 -0
- package/dist/db/tables/routesPolicies.d.ts.map +1 -0
- package/dist/db/tables/routesPolicies.js +198 -0
- package/dist/db/tables/routesPolicies.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts +22 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts.map +1 -1
- package/dist/db/tables/routesTransferSubsidies.js +41 -0
- package/dist/db/tables/routesTransferSubsidies.js.map +1 -1
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts.map +1 -1
- package/dist/db/tables/routesTransferSubsidyNonces.js +12 -4
- package/dist/db/tables/routesTransferSubsidyNonces.js.map +1 -1
- package/dist/db/tables/routesTransfers.d.ts +26 -1
- package/dist/db/tables/routesTransfers.d.ts.map +1 -1
- package/dist/db/tables/routesTransfers.js +36 -6
- package/dist/db/tables/routesTransfers.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts +45 -13
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +144 -33
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/users.d.ts +2 -0
- package/dist/db/tables/users.d.ts.map +1 -1
- package/dist/db/tables/users.js +11 -0
- package/dist/db/tables/users.js.map +1 -1
- package/dist/handlers/internal/multisig.d.ts +1 -1
- package/dist/handlers/internal/multisig.d.ts.map +1 -1
- package/dist/handlers/internal/multisig.js +3 -2
- package/dist/handlers/internal/multisig.js.map +1 -1
- package/dist/handlers/relay.d.ts +2 -0
- package/dist/handlers/relay.d.ts.map +1 -1
- package/dist/handlers/relay.js +34 -15
- package/dist/handlers/relay.js.map +1 -1
- package/dist/internal/Auth.d.ts +57 -6
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +182 -78
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/BetterAuth.d.ts +22 -0
- package/dist/internal/BetterAuth.d.ts.map +1 -1
- package/dist/internal/BetterAuth.js +17 -14
- package/dist/internal/BetterAuth.js.map +1 -1
- package/dist/internal/Cache.d.ts +5 -0
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +3 -1
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/CliAuth.d.ts +243 -0
- package/dist/internal/CliAuth.d.ts.map +1 -0
- package/dist/internal/CliAuth.js +249 -0
- package/dist/internal/CliAuth.js.map +1 -0
- package/dist/internal/EarnSharePrices.d.ts +1 -1
- package/dist/internal/EarnSharePrices.d.ts.map +1 -1
- package/dist/internal/EarnSharePrices.js +7 -3
- package/dist/internal/EarnSharePrices.js.map +1 -1
- package/dist/internal/EarnVaults.d.ts +47 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -1
- package/dist/internal/EarnVaults.js +188 -4
- package/dist/internal/EarnVaults.js.map +1 -1
- package/dist/internal/EarnWithdrawals.d.ts +73 -0
- package/dist/internal/EarnWithdrawals.d.ts.map +1 -0
- package/dist/internal/EarnWithdrawals.js +189 -0
- package/dist/internal/EarnWithdrawals.js.map +1 -0
- package/dist/internal/ExecutionContext.d.ts +21 -0
- package/dist/internal/ExecutionContext.d.ts.map +1 -0
- package/dist/internal/ExecutionContext.js +16 -0
- package/dist/internal/ExecutionContext.js.map +1 -0
- package/dist/internal/Log.d.ts +7 -3
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +163 -130
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +26 -1
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/RateLimit.d.ts +67 -0
- package/dist/internal/RateLimit.d.ts.map +1 -1
- package/dist/internal/RateLimit.js +174 -27
- package/dist/internal/RateLimit.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 +4 -5
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Timing.d.ts +6 -0
- package/dist/internal/Timing.d.ts.map +1 -1
- package/dist/internal/Timing.js +21 -1
- package/dist/internal/Timing.js.map +1 -1
- package/dist/internal/Tron.d.ts +124 -0
- package/dist/internal/Tron.d.ts.map +1 -0
- package/dist/internal/Tron.js +202 -0
- package/dist/internal/Tron.js.map +1 -0
- package/dist/internal/Viem.d.ts +4 -0
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +25 -6
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/rewards/Read.d.ts +2 -2
- package/dist/internal/rewards/Read.d.ts.map +1 -1
- package/dist/internal/rewards/Read.js +11 -2
- package/dist/internal/rewards/Read.js.map +1 -1
- package/dist/internal/routes/Action.d.ts +27 -0
- package/dist/internal/routes/Action.d.ts.map +1 -1
- package/dist/internal/routes/Action.js +49 -1
- package/dist/internal/routes/Action.js.map +1 -1
- package/dist/internal/routes/Chain.d.ts +2 -0
- package/dist/internal/routes/Chain.d.ts.map +1 -1
- package/dist/internal/routes/Chain.js +4 -0
- package/dist/internal/routes/Chain.js.map +1 -1
- package/dist/internal/routes/DepositAddress.d.ts.map +1 -1
- package/dist/internal/routes/DepositAddress.js +5 -0
- package/dist/internal/routes/DepositAddress.js.map +1 -1
- package/dist/internal/routes/Evidence.d.ts.map +1 -1
- package/dist/internal/routes/Evidence.js +6 -2
- package/dist/internal/routes/Evidence.js.map +1 -1
- package/dist/internal/routes/EvmTransferSettlement.d.ts +17 -0
- package/dist/internal/routes/EvmTransferSettlement.d.ts.map +1 -0
- package/dist/internal/routes/EvmTransferSettlement.js +196 -0
- package/dist/internal/routes/EvmTransferSettlement.js.map +1 -0
- package/dist/internal/routes/Policy.d.ts +161 -0
- package/dist/internal/routes/Policy.d.ts.map +1 -0
- package/dist/internal/routes/Policy.js +249 -0
- package/dist/internal/routes/Policy.js.map +1 -0
- package/dist/internal/routes/Provider.d.ts +66 -3
- package/dist/internal/routes/Provider.d.ts.map +1 -1
- package/dist/internal/routes/Provider.js +106 -27
- package/dist/internal/routes/Provider.js.map +1 -1
- package/dist/internal/routes/Quota.d.ts +57 -0
- package/dist/internal/routes/Quota.d.ts.map +1 -0
- package/dist/internal/routes/Quota.js +144 -0
- package/dist/internal/routes/Quota.js.map +1 -0
- package/dist/internal/routes/Reconciliation.d.ts.map +1 -1
- package/dist/internal/routes/Reconciliation.js +163 -47
- package/dist/internal/routes/Reconciliation.js.map +1 -1
- package/dist/internal/routes/SolanaTransferSettlement.d.ts +12 -0
- package/dist/internal/routes/SolanaTransferSettlement.d.ts.map +1 -0
- package/dist/internal/routes/SolanaTransferSettlement.js +220 -0
- package/dist/internal/routes/SolanaTransferSettlement.js.map +1 -0
- package/dist/internal/routes/SolanaTransferSubsidy.d.ts +172 -0
- package/dist/internal/routes/SolanaTransferSubsidy.d.ts.map +1 -0
- package/dist/internal/routes/SolanaTransferSubsidy.js +564 -0
- package/dist/internal/routes/SolanaTransferSubsidy.js.map +1 -0
- package/dist/internal/routes/Subsidy.d.ts +2 -2
- package/dist/internal/routes/Subsidy.d.ts.map +1 -1
- package/dist/internal/routes/Subsidy.js +2 -2
- package/dist/internal/routes/Subsidy.js.map +1 -1
- package/dist/internal/routes/Transfer.d.ts +229 -1
- package/dist/internal/routes/Transfer.d.ts.map +1 -1
- package/dist/internal/routes/Transfer.js +644 -7
- package/dist/internal/routes/Transfer.js.map +1 -1
- package/dist/internal/routes/TransferReconciliation.d.ts +6 -0
- package/dist/internal/routes/TransferReconciliation.d.ts.map +1 -1
- package/dist/internal/routes/TransferReconciliation.js +83 -159
- package/dist/internal/routes/TransferReconciliation.js.map +1 -1
- package/dist/internal/routes/TransferSettlement.d.ts +45 -0
- package/dist/internal/routes/TransferSettlement.d.ts.map +1 -0
- package/dist/internal/routes/TransferSettlement.js +2 -0
- package/dist/internal/routes/TransferSettlement.js.map +1 -0
- package/dist/internal/routes/TransferSubsidy.d.ts +23 -8
- package/dist/internal/routes/TransferSubsidy.d.ts.map +1 -1
- package/dist/internal/routes/TransferSubsidy.js +64 -5
- package/dist/internal/routes/TransferSubsidy.js.map +1 -1
- package/dist/internal/routes/TronTransferSettlement.d.ts +12 -0
- package/dist/internal/routes/TronTransferSettlement.d.ts.map +1 -0
- package/dist/internal/routes/TronTransferSettlement.js +201 -0
- package/dist/internal/routes/TronTransferSettlement.js.map +1 -0
- package/dist/internal/routes/TronTransferSubsidy.d.ts +174 -0
- package/dist/internal/routes/TronTransferSubsidy.d.ts.map +1 -0
- package/dist/internal/routes/TronTransferSubsidy.js +439 -0
- package/dist/internal/routes/TronTransferSubsidy.js.map +1 -0
- package/dist/internal/routes/index.d.ts +3 -0
- package/dist/internal/routes/index.d.ts.map +1 -1
- package/dist/internal/routes/index.js +3 -0
- package/dist/internal/routes/index.js.map +1 -1
- package/dist/internal/routes/providers/across.d.ts +3 -0
- package/dist/internal/routes/providers/across.d.ts.map +1 -1
- package/dist/internal/routes/providers/across.js +11 -0
- package/dist/internal/routes/providers/across.js.map +1 -1
- package/dist/internal/routes/providers/legacyMesh.d.ts +29 -0
- package/dist/internal/routes/providers/legacyMesh.d.ts.map +1 -0
- package/dist/internal/routes/providers/legacyMesh.js +474 -0
- package/dist/internal/routes/providers/legacyMesh.js.map +1 -0
- package/dist/internal/routes/providers/legacyMeshDelivery.d.ts +59 -0
- package/dist/internal/routes/providers/legacyMeshDelivery.d.ts.map +1 -0
- package/dist/internal/routes/providers/legacyMeshDelivery.js +229 -0
- package/dist/internal/routes/providers/legacyMeshDelivery.js.map +1 -0
- package/dist/internal/routes/providers/legacyMeshOutbound.d.ts +19 -0
- package/dist/internal/routes/providers/legacyMeshOutbound.d.ts.map +1 -0
- package/dist/internal/routes/providers/legacyMeshOutbound.js +457 -0
- package/dist/internal/routes/providers/legacyMeshOutbound.js.map +1 -0
- package/dist/internal/routes/providers/legacyMeshOutboundDelivery.d.ts +123 -0
- package/dist/internal/routes/providers/legacyMeshOutboundDelivery.d.ts.map +1 -0
- package/dist/internal/routes/providers/legacyMeshOutboundDelivery.js +333 -0
- package/dist/internal/routes/providers/legacyMeshOutboundDelivery.js.map +1 -0
- package/dist/internal/routes/providers/propAmm.d.ts +70 -0
- package/dist/internal/routes/providers/propAmm.d.ts.map +1 -0
- package/dist/internal/routes/providers/propAmm.js +524 -0
- package/dist/internal/routes/providers/propAmm.js.map +1 -0
- package/dist/internal/routes/providers/relay.d.ts +3 -0
- package/dist/internal/routes/providers/relay.d.ts.map +1 -1
- package/dist/internal/routes/providers/relay.js +352 -41
- package/dist/internal/routes/providers/relay.js.map +1 -1
- package/dist/internal/routes/providers/rhino.d.ts +3 -0
- package/dist/internal/routes/providers/rhino.d.ts.map +1 -1
- package/dist/internal/routes/providers/rhino.js +11 -0
- package/dist/internal/routes/providers/rhino.js.map +1 -1
- package/dist/internal/routes/providers/squid.d.ts +3 -0
- package/dist/internal/routes/providers/squid.d.ts.map +1 -1
- package/dist/internal/routes/providers/squid.js +19 -0
- package/dist/internal/routes/providers/squid.js.map +1 -1
- package/dist/internal/routes/providers/stargate.d.ts.map +1 -1
- package/dist/internal/routes/providers/stargate.js +22 -9
- package/dist/internal/routes/providers/stargate.js.map +1 -1
- package/dist/internal/routes/providers/symbiosis.d.ts.map +1 -1
- package/dist/internal/routes/providers/symbiosis.js +13 -17
- package/dist/internal/routes/providers/symbiosis.js.map +1 -1
- package/dist/providers/index.d.ts +14 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +6 -0
- package/dist/providers/index.js.map +1 -1
- package/package.json +16 -6
- package/src/ApiKey.ts +7 -3
- package/src/ApiKeys.test.ts +652 -8
- package/src/ApiKeys.ts +191 -11
- package/src/App.test.ts +405 -18
- package/src/App.ts +51 -15
- package/src/Client.test-d.ts +157 -10
- package/src/Client.test.ts +4 -4
- package/src/Scope.ts +1 -2
- package/src/admin/App.ts +11 -5
- package/src/admin/apps/api-keys.test.ts +98 -2
- package/src/admin/apps/api-keys.ts +21 -12
- package/src/admin/apps/earn-vaults.test.ts +76 -7
- package/src/admin/apps/earn-vaults.ts +47 -8
- package/src/admin/apps/organizations.test.ts +147 -31
- package/src/admin/apps/organizations.ts +5 -4
- package/src/admin/apps/route-policies.test.ts +220 -0
- package/src/admin/apps/route-policies.ts +322 -0
- package/src/admin/apps/routes-support.test.ts +107 -2
- package/src/admin/apps/routes-support.ts +43 -3
- package/src/admin/apps/routes.test.ts +150 -0
- package/src/admin/apps/routes.ts +97 -1
- package/src/admin/apps/scopes.test.ts +1 -1
- package/src/admin/index.ts +0 -1
- package/src/admin/ui/plugin.ts +2 -1
- package/src/admin/ui/src/components/Dialog.tsx +1 -1
- package/src/admin/ui/src/components/EarnVaultForm.tsx +45 -0
- package/src/admin/ui/src/components/RoutePicker.tsx +79 -0
- package/src/admin/ui/src/lib/earn-vaults.ts +1 -1
- package/src/admin/ui/src/lib/route-policies.test.ts +452 -0
- package/src/admin/ui/src/lib/route-policies.ts +232 -0
- package/src/admin/ui/src/lib/routes.ts +34 -0
- package/src/admin/ui/src/routeTree.gen.ts +21 -0
- package/src/admin/ui/src/routes/api-keys.tsx +21 -2
- package/src/admin/ui/src/routes/early-access.tsx +1 -0
- package/src/admin/ui/src/routes/earn.vaults.tsx +1 -0
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +22 -0
- package/src/admin/ui/src/routes/earn.vaults_.new.tsx +10 -0
- package/src/admin/ui/src/routes/organizations.tsx +1 -0
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +18 -3
- package/src/admin/ui/src/routes/route-policies.tsx +678 -0
- package/src/admin/ui/src/routes/routes.tsx +85 -2
- package/src/admin/ui/src/routes/routes_.support.tsx +6 -22
- package/src/admin/ui/src/routes/subsidies.tsx +1 -0
- package/src/admin/ui/src/routes/verified-tokens.tsx +1 -0
- package/src/admin/ui.generated.ts +258 -202
- package/src/analytics/Analytics.test.ts +4 -50
- package/src/analytics/Analytics.ts +65 -1
- package/src/analytics/tables/requestEvents.test.ts +402 -1
- package/src/analytics/tables/requestEvents.ts +62 -93
- package/src/apps/data/routes/activities.test.ts +315 -14
- package/src/apps/data/routes/activities.ts +60 -0
- package/src/apps/data/routes/balances.ts +5 -7
- package/src/apps/data/routes/earn.bench.ts +18 -0
- package/src/apps/data/routes/earn.local.test.ts +507 -0
- package/src/apps/data/routes/earn.test.ts +405 -127
- package/src/apps/data/routes/earn.ts +660 -270
- package/src/apps/data/routes/exchanges.bench.ts +3 -1
- package/src/apps/data/routes/exchanges.test.ts +166 -2
- package/src/apps/data/routes/exchanges.ts +308 -101
- package/src/apps/data/routes/fee-amm.test.ts +134 -2
- package/src/apps/data/routes/fee-amm.ts +122 -60
- package/src/apps/data/routes/receipts.test.ts +21 -18
- package/src/apps/data/routes/rpc.test.ts +2 -2
- package/src/apps/data/routes/tokens.provenance.test.ts +157 -0
- package/src/apps/data/routes/tokens.test.ts +4 -4
- package/src/apps/data/routes/tokens.ts +11 -6
- package/src/apps/data/routes/transactions.test.ts +29 -0
- package/src/apps/data/routes/transactions.ts +33 -22
- package/src/apps/data/routes/webhooks.test.ts +12 -3
- package/src/apps/data/routes/webhooks.ts +2 -1
- package/src/apps/management/App.ts +4 -0
- package/src/apps/management/Billing.test.ts +253 -27
- package/src/apps/management/Billing.ts +83 -29
- package/src/apps/management/routes/api-keys.test.ts +1 -1
- package/src/apps/management/routes/api-keys.ts +85 -11
- package/src/apps/management/routes/billing.test.ts +68 -4
- package/src/apps/management/routes/cli.test.ts +370 -0
- package/src/apps/management/routes/cli.ts +533 -0
- package/src/apps/management/routes/me.test.ts +14 -4
- package/src/apps/management/routes/orgs.test.ts +108 -4
- package/src/apps/management/routes/orgs.ts +7 -2
- package/src/apps/management/routes/usage.test.ts +2 -2
- package/src/apps/mpp/internal/Policy.test.ts +51 -4
- package/src/apps/mpp/internal/Policy.ts +6 -2
- package/src/apps/mpp/internal/Sponsorship.test.ts +29 -0
- package/src/apps/mpp/internal/Sponsorship.ts +6 -4
- package/src/apps/relay/App.test.ts +85 -1
- package/src/apps/relay/App.ts +28 -4
- package/src/apps/relay/Sponsorships.test.ts +97 -1
- package/src/apps/relay/Sponsorships.ts +77 -66
- package/src/apps/routes/Access.test.ts +319 -0
- package/src/apps/routes/Access.ts +147 -0
- package/src/apps/routes/App.ts +10 -0
- package/src/apps/routes/routes/chains.test.ts +3 -2
- package/src/apps/routes/routes/deposit-addresses.test.ts +978 -34
- package/src/apps/routes/routes/deposit-addresses.ts +243 -32
- package/src/apps/routes/routes/propAmm.local.test.ts +951 -0
- package/src/apps/routes/routes/quotes.test.ts +81 -8
- package/src/apps/routes/routes/quotes.ts +109 -27
- package/src/apps/routes/routes/transfers.test.ts +252 -15
- package/src/apps/routes/routes/transfers.ts +212 -33
- package/src/cli/ApiKeys.test.ts +265 -0
- package/src/cli/ApiKeys.ts +189 -0
- package/src/cli/Cli.test.ts +188 -0
- package/src/cli/Cli.ts +280 -12
- package/src/cli/Credentials.test.ts +122 -0
- package/src/cli/Credentials.ts +144 -0
- package/src/cli/Spec.test.ts +133 -0
- package/src/cli/Spec.ts +132 -0
- package/src/cli/bin.test.ts +49 -0
- package/src/cli/bin.ts +5 -1
- package/src/cli/commands/auth.test.ts +138 -0
- package/src/cli/commands/auth.ts +254 -0
- package/src/cli/commands/keys.test.ts +68 -0
- package/src/cli/commands/keys.ts +125 -0
- package/src/cloudflare.ts +184 -36
- package/src/db/Db.test.ts +877 -0
- package/src/db/Db.ts +498 -1
- package/src/db/Schema.ts +75 -4
- package/src/db/tables/apiKeyAdmissions.test.ts +57 -0
- package/src/db/tables/apiKeyAdmissions.ts +101 -11
- package/src/db/tables/apiKeyOwnerTombstones.ts +2 -2
- package/src/db/tables/authAccounts.test.ts +30 -0
- package/src/db/tables/authAccounts.ts +1 -0
- package/src/db/tables/earnVaults.test.ts +34 -0
- package/src/db/tables/earnVaults.ts +17 -2
- package/src/db/tables/organizations.test.ts +148 -84
- package/src/db/tables/organizations.ts +11 -43
- package/src/db/tables/requestUsage.ts +13 -2
- package/src/db/tables/rewardCampaigns.test.ts +163 -0
- package/src/db/tables/rewardEligibilityAssociations.test.ts +14 -0
- package/src/db/tables/rewardEligibilityAssociations.ts +24 -0
- package/src/db/tables/rewardRuns.ts +4 -0
- package/src/db/tables/rewardTransactionAttempts.ts +2 -0
- package/src/db/tables/routesDepositAddresses.test.ts +263 -0
- package/src/db/tables/routesDepositAddresses.ts +118 -34
- package/src/db/tables/routesDeposits.test.ts +66 -5
- package/src/db/tables/routesDeposits.ts +47 -26
- package/src/db/tables/routesIdempotency.test.ts +80 -0
- package/src/db/tables/routesIdempotency.ts +2 -0
- package/src/db/tables/routesPolicies.test.ts +143 -0
- package/src/db/tables/routesPolicies.ts +251 -0
- package/src/db/tables/routesTransferSubsidies.ts +64 -0
- package/src/db/tables/routesTransferSubsidyNonces.ts +16 -4
- package/src/db/tables/routesTransfers.test.ts +183 -2
- package/src/db/tables/routesTransfers.ts +65 -6
- package/src/db/tables/sponsoredTransactions.test.ts +351 -76
- package/src/db/tables/sponsoredTransactions.ts +182 -38
- package/src/db/tables/users.test.ts +51 -0
- package/src/db/tables/users.ts +12 -0
- package/src/handlers/internal/multisig.store.test.ts +120 -0
- package/src/handlers/internal/multisig.test.ts +389 -0
- package/src/handlers/internal/multisig.ts +13 -10
- package/src/handlers/relay.test.ts +259 -83
- package/src/handlers/relay.ts +36 -17
- package/src/internal/Auth.test.ts +291 -8
- package/src/internal/Auth.ts +227 -96
- package/src/internal/BetterAuth.test.ts +58 -22
- package/src/internal/BetterAuth.ts +23 -17
- package/src/internal/Cache.ts +3 -1
- package/src/internal/CliAuth.test.ts +279 -0
- package/src/internal/CliAuth.ts +319 -0
- package/src/internal/EarnSharePrices.test.ts +25 -0
- package/src/internal/EarnSharePrices.ts +9 -2
- package/src/internal/EarnVaults.test.ts +67 -0
- package/src/internal/EarnVaults.ts +299 -4
- package/src/internal/EarnWithdrawals.test.ts +315 -0
- package/src/internal/EarnWithdrawals.ts +266 -0
- package/src/internal/ExecutionContext.ts +31 -0
- package/src/internal/Log.test.ts +210 -0
- package/src/internal/Log.ts +180 -142
- package/src/internal/MetricSink.test.ts +190 -15
- package/src/internal/MetricSink.ts +27 -1
- package/src/internal/RateLimit.test.ts +144 -8
- package/src/internal/RateLimit.ts +254 -26
- package/src/internal/Store.ts +4 -5
- package/src/internal/Timing.test.ts +32 -0
- package/src/internal/Timing.ts +20 -1
- package/src/internal/Tron.test-d.ts +22 -0
- package/src/internal/Tron.test.ts +94 -0
- package/src/internal/Tron.ts +289 -0
- package/src/internal/Viem.rpc.test.ts +76 -0
- package/src/internal/Viem.ts +29 -6
- package/src/internal/rewards/Read.test.ts +109 -0
- package/src/internal/rewards/Read.ts +13 -4
- package/src/internal/routes/Action.test.ts +70 -0
- package/src/internal/routes/Action.ts +76 -1
- package/src/internal/routes/Chain.test.ts +18 -0
- package/src/internal/routes/Chain.ts +5 -0
- package/src/internal/routes/DepositAddress.ts +5 -0
- package/src/internal/routes/Evidence.test.ts +64 -0
- package/src/internal/routes/Evidence.ts +11 -3
- package/src/internal/routes/EvmTransferSettlement.ts +213 -0
- package/src/internal/routes/Policy.test.ts +316 -0
- package/src/internal/routes/Policy.ts +399 -0
- package/src/internal/routes/Provider.test.ts +103 -2
- package/src/internal/routes/Provider.ts +149 -27
- package/src/internal/routes/Quota.test.ts +149 -0
- package/src/internal/routes/Quota.ts +226 -0
- package/src/internal/routes/Reconciliation.local.test.ts +285 -0
- package/src/internal/routes/Reconciliation.test.ts +371 -13
- package/src/internal/routes/Reconciliation.ts +193 -42
- package/src/internal/routes/SolanaTransferSettlement.ts +232 -0
- package/src/internal/routes/SolanaTransferSubsidy.test.ts +471 -0
- package/src/internal/routes/SolanaTransferSubsidy.ts +760 -0
- package/src/internal/routes/SourceObservation.test.ts +221 -0
- package/src/internal/routes/Subsidy.local.test.ts +46 -0
- package/src/internal/routes/Subsidy.ts +4 -2
- package/src/internal/routes/Transfer.solana.test.ts +389 -0
- package/src/internal/routes/Transfer.test.ts +130 -1
- package/src/internal/routes/Transfer.tron.test.ts +172 -0
- package/src/internal/routes/Transfer.ts +866 -8
- package/src/internal/routes/TransferReconciliation.test.ts +26 -4
- package/src/internal/routes/TransferReconciliation.ts +91 -166
- package/src/internal/routes/TransferSettlement.ts +48 -0
- package/src/internal/routes/TransferSubsidy.local.test.ts +143 -0
- package/src/internal/routes/TransferSubsidy.test.ts +34 -4
- package/src/internal/routes/TransferSubsidy.ts +87 -12
- package/src/internal/routes/TronTransferSettlement.ts +212 -0
- package/src/internal/routes/TronTransferSubsidy.test.ts +109 -0
- package/src/internal/routes/TronTransferSubsidy.ts +619 -0
- package/src/internal/routes/index.test.ts +3 -0
- package/src/internal/routes/index.ts +3 -0
- package/src/internal/routes/providers/across.ts +13 -0
- package/src/internal/routes/providers/index.test.ts +141 -0
- package/src/internal/routes/providers/legacyMesh.test.ts +484 -0
- package/src/internal/routes/providers/legacyMesh.ts +633 -0
- package/src/internal/routes/providers/legacyMeshDelivery.test.ts +306 -0
- package/src/internal/routes/providers/legacyMeshDelivery.ts +320 -0
- package/src/internal/routes/providers/legacyMeshOutbound.test.ts +401 -0
- package/src/internal/routes/providers/legacyMeshOutbound.ts +566 -0
- package/src/internal/routes/providers/legacyMeshOutboundDelivery.ts +473 -0
- package/src/internal/routes/providers/propAmm.ts +640 -0
- package/src/internal/routes/providers/relay.test.ts +1263 -41
- package/src/internal/routes/providers/relay.ts +423 -38
- package/src/internal/routes/providers/rhino.ts +14 -1
- package/src/internal/routes/providers/squid.ts +21 -0
- package/src/internal/routes/providers/stargate.test.ts +105 -1
- package/src/internal/routes/providers/stargate.ts +22 -9
- package/src/internal/routes/providers/symbiosis.ts +13 -47
- package/src/providers/index.test.ts +2 -0
- package/src/providers/index.ts +18 -0
- package/dist/admin/Access.d.ts +0 -39
- package/dist/admin/Access.d.ts.map +0 -1
- package/dist/admin/Access.js +0 -73
- package/dist/admin/Access.js.map +0 -1
- package/src/admin/Access.test.ts +0 -130
- package/src/admin/Access.ts +0 -85
|
@@ -1,22 +1,49 @@
|
|
|
1
|
-
import { AbiEvent, AbiFunction, Address, Base58, Bytes, Hash, Hex } from 'ox';
|
|
1
|
+
import { AbiEvent, AbiFunction, Address, Base58, Bytes, Hash, Hex, Value as core_Value } from 'ox';
|
|
2
2
|
import { getBlockNumber, getLogs, getTransaction, getTransactionReceipt } from 'viem/actions';
|
|
3
3
|
import * as z from 'zod/mini';
|
|
4
4
|
import * as Db from '../../../db/Db.js';
|
|
5
5
|
import * as RoutesDepositAddresses from '../../../db/tables/routesDepositAddresses.js';
|
|
6
6
|
import * as RoutesDepositRequestObservations from '../../../db/tables/routesDepositRequestObservations.js';
|
|
7
|
+
import * as Store from '../../Store.js';
|
|
7
8
|
import * as Value from '../../Value.js';
|
|
8
9
|
import * as Viem from '../../Viem.js';
|
|
9
10
|
import * as RoutesCatalog from '../Catalog.js';
|
|
10
11
|
import * as RoutesChain from '../Chain.js';
|
|
11
12
|
import * as Evidence from '../Evidence.js';
|
|
12
13
|
import * as RoutesProvider from '../Provider.js';
|
|
14
|
+
import * as ProviderQuota from '../Quota.js';
|
|
13
15
|
import * as Subsidy from '../Subsidy.js';
|
|
14
16
|
const defaultBaseUrl = 'https://api.relay.link';
|
|
15
17
|
const defaultFetch = (input, init) => globalThis.fetch(input, init);
|
|
16
18
|
const deliveryBackfillBlocks = 256n;
|
|
19
|
+
// Quote-time fee insufficiency is an expected rejection, not a provider outage.
|
|
20
|
+
const quoteUnavailableCodes = ['AMOUNT_TOO_LOW', 'NO_QUOTES', 'NO_ROUTE', 'UNSUPPORTED_ROUTE'];
|
|
21
|
+
// Recheck the Relay key dashboard before changing account-specific quotas.
|
|
22
|
+
// Treat /quote/v2 as generic /quote until Relay confirms its bridge classification.
|
|
23
|
+
const quoteRateLimit = 10;
|
|
24
|
+
// Reserve two requests for operations that must turn an accepted quote into work.
|
|
25
|
+
const quoteReadRateLimit = 8;
|
|
26
|
+
const quoteRateLimitWindowMs = 1_000;
|
|
27
|
+
const quoteQuotaStoreKey = 'routes:relay:quote-v2';
|
|
17
28
|
const relayChainsCacheTtlMs = 60_000;
|
|
18
29
|
const relayRefundStatuses = ['refund', 'refunded'];
|
|
19
30
|
const relayRequestPageLimit = 100;
|
|
31
|
+
const requestsRateLimit = 20;
|
|
32
|
+
const requestsRateLimitWindowMs = 1_000;
|
|
33
|
+
const requestsQuotaStoreKey = 'routes:relay:requests-v3';
|
|
34
|
+
const chainsTimeoutMs = 10_000;
|
|
35
|
+
const requestsTimeoutMs = 10_000;
|
|
36
|
+
// Relay app-balance sponsorship can settle in Base USDC even when neither route leg uses it.
|
|
37
|
+
const sponsorToken = {
|
|
38
|
+
address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
39
|
+
currency: 'USD',
|
|
40
|
+
decimals: 6,
|
|
41
|
+
name: 'USD Coin',
|
|
42
|
+
standard: 'ERC-20',
|
|
43
|
+
symbol: 'USDC',
|
|
44
|
+
tokenKey: 'eip155:8453/erc20:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
45
|
+
verified: true,
|
|
46
|
+
};
|
|
20
47
|
const sourceSweepForwardBlocks = 256n;
|
|
21
48
|
const depositErc20FullAllowance = AbiFunction.from('function depositErc20(address depositor,address token,bytes32 id)');
|
|
22
49
|
const depositErc20WithAmount = AbiFunction.from('function depositErc20(address depositor,address token,uint256 amount,bytes32 id)');
|
|
@@ -92,7 +119,9 @@ var schema;
|
|
|
92
119
|
steps: z.array(Step),
|
|
93
120
|
});
|
|
94
121
|
schema.DepositAddress = z.object({
|
|
95
|
-
details: schema.PreparedQuote.shape.details,
|
|
122
|
+
details: z.extend(schema.PreparedQuote.shape.details, {
|
|
123
|
+
isFixedRate: z.optional(z.boolean()),
|
|
124
|
+
}),
|
|
96
125
|
fees: schema.PreparedQuote.shape.fees,
|
|
97
126
|
steps: z.array(z.object({
|
|
98
127
|
depositAddress: z.optional(z.string()),
|
|
@@ -172,6 +201,46 @@ var schema;
|
|
|
172
201
|
updatedAt: z.iso.datetime(),
|
|
173
202
|
})),
|
|
174
203
|
});
|
|
204
|
+
const TransferCurrency = z.object({
|
|
205
|
+
amount: Decimal,
|
|
206
|
+
currency: z.object({
|
|
207
|
+
address: z.string(),
|
|
208
|
+
chainId: Integer,
|
|
209
|
+
}),
|
|
210
|
+
});
|
|
211
|
+
const TransferTransaction = z.object({
|
|
212
|
+
chainId: Integer,
|
|
213
|
+
status: z.string(),
|
|
214
|
+
txHash: z.nullish(z.string()),
|
|
215
|
+
});
|
|
216
|
+
schema.TransferRequests = z.object({
|
|
217
|
+
requests: z.array(z.object({
|
|
218
|
+
data: z.optional(z.object({
|
|
219
|
+
inTxs: z.optional(z.array(TransferTransaction)),
|
|
220
|
+
outTxs: z.optional(z.array(TransferTransaction)),
|
|
221
|
+
route: z.optional(z.object({
|
|
222
|
+
actual: z.optional(z.object({
|
|
223
|
+
destination: z.optional(z.object({ outputCurrency: TransferCurrency })),
|
|
224
|
+
origin: z.optional(z.object({ inputCurrency: TransferCurrency })),
|
|
225
|
+
})),
|
|
226
|
+
})),
|
|
227
|
+
})),
|
|
228
|
+
id: z.string().check(z.minLength(1)),
|
|
229
|
+
protocol: z.nullish(z.object({
|
|
230
|
+
deposit: z.optional(z.object({
|
|
231
|
+
origin: z.optional(z.object({
|
|
232
|
+
depository: z.optional(z.string()),
|
|
233
|
+
})),
|
|
234
|
+
})),
|
|
235
|
+
})),
|
|
236
|
+
recipient: z.optional(z.string()),
|
|
237
|
+
sender: z.optional(z.string()),
|
|
238
|
+
status: z.string().check(z.minLength(1)),
|
|
239
|
+
})),
|
|
240
|
+
});
|
|
241
|
+
schema.TransferCorrelation = z.object({
|
|
242
|
+
requestId: z.string().check(z.minLength(1)),
|
|
243
|
+
});
|
|
175
244
|
schema.WebhookPayload = z.object({
|
|
176
245
|
data: z.object({
|
|
177
246
|
depositAddress: z.nullable(z.object({ address: z.string().check(z.minLength(1)) })),
|
|
@@ -197,6 +266,80 @@ export function relay(options = {}) {
|
|
|
197
266
|
const endpoint = quoteEndpoint(options);
|
|
198
267
|
const fetch = options.fetch ?? defaultFetch;
|
|
199
268
|
const now = options.now ?? (() => new Date());
|
|
269
|
+
const rateLimitStore = options.rateLimitStore ?? Store.memory();
|
|
270
|
+
const verifyTransfers = options.observation
|
|
271
|
+
? Evidence.createVerifier({
|
|
272
|
+
...options.observation,
|
|
273
|
+
fetch,
|
|
274
|
+
})
|
|
275
|
+
: undefined;
|
|
276
|
+
let transferChainsExpiresAt = 0;
|
|
277
|
+
let transferChainsPromise;
|
|
278
|
+
const getTransferChains = (signal) => {
|
|
279
|
+
if (transferChainsPromise && now().getTime() < transferChainsExpiresAt)
|
|
280
|
+
return transferChainsPromise;
|
|
281
|
+
transferChainsExpiresAt = now().getTime() + relayChainsCacheTtlMs;
|
|
282
|
+
transferChainsPromise = RoutesProvider.requestJson(chainsEndpoint(options), {
|
|
283
|
+
fetch,
|
|
284
|
+
headers: options.apiKey ? { 'x-api-key': options.apiKey } : undefined,
|
|
285
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(chainsTimeoutMs)]),
|
|
286
|
+
})
|
|
287
|
+
.then((value) => schema.Chains.parse(value).chains)
|
|
288
|
+
.catch((cause) => {
|
|
289
|
+
transferChainsExpiresAt = 0;
|
|
290
|
+
transferChainsPromise = undefined;
|
|
291
|
+
if (cause instanceof DOMException && cause.name === 'TimeoutError')
|
|
292
|
+
throw new RoutesProvider.ProviderTimeoutError();
|
|
293
|
+
throw cause;
|
|
294
|
+
});
|
|
295
|
+
return transferChainsPromise;
|
|
296
|
+
};
|
|
297
|
+
const consumeQuoteQuota = (limit) => ProviderQuota.consume(rateLimitStore, {
|
|
298
|
+
key: quoteQuotaStoreKey,
|
|
299
|
+
limit,
|
|
300
|
+
now: now(),
|
|
301
|
+
windowMs: quoteRateLimitWindowMs,
|
|
302
|
+
});
|
|
303
|
+
const consumeRequestsQuota = () => ProviderQuota.consume(rateLimitStore, {
|
|
304
|
+
key: requestsQuotaStoreKey,
|
|
305
|
+
limit: requestsRateLimit,
|
|
306
|
+
now: now(),
|
|
307
|
+
windowMs: requestsRateLimitWindowMs,
|
|
308
|
+
});
|
|
309
|
+
const blockQuoteOnRateLimit = (cause) => ProviderQuota.blockOnRateLimit(rateLimitStore, cause, {
|
|
310
|
+
key: quoteQuotaStoreKey,
|
|
311
|
+
now: now(),
|
|
312
|
+
windowMs: quoteRateLimitWindowMs,
|
|
313
|
+
});
|
|
314
|
+
const blockRequestsOnRateLimit = (cause) => ProviderQuota.blockOnRateLimit(rateLimitStore, cause, {
|
|
315
|
+
key: requestsQuotaStoreKey,
|
|
316
|
+
now: now(),
|
|
317
|
+
windowMs: requestsRateLimitWindowMs,
|
|
318
|
+
});
|
|
319
|
+
const getTransferRequest = async (requestId, signal) => {
|
|
320
|
+
const url = requestsEndpoint(options);
|
|
321
|
+
url.searchParams.set('id', requestId);
|
|
322
|
+
await consumeRequestsQuota();
|
|
323
|
+
const response = await RoutesProvider.requestJson(url, {
|
|
324
|
+
fetch,
|
|
325
|
+
headers: { 'x-api-key': options.apiKey },
|
|
326
|
+
method: 'GET',
|
|
327
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(requestsTimeoutMs)]),
|
|
328
|
+
}).catch(async (cause) => {
|
|
329
|
+
await blockRequestsOnRateLimit(cause);
|
|
330
|
+
if (cause instanceof DOMException && cause.name === 'TimeoutError')
|
|
331
|
+
throw new RoutesProvider.ProviderTimeoutError();
|
|
332
|
+
throw cause;
|
|
333
|
+
});
|
|
334
|
+
const requests = schema.TransferRequests.safeParse(response);
|
|
335
|
+
if (!requests.success)
|
|
336
|
+
throw new RoutesProvider.ProviderPayloadError();
|
|
337
|
+
if (requests.data.requests.some((request) => request.id !== requestId))
|
|
338
|
+
throw new RoutesProvider.ProviderPayloadError();
|
|
339
|
+
if (requests.data.requests.length > 1)
|
|
340
|
+
throw new RoutesProvider.ProviderPayloadError();
|
|
341
|
+
return requests.data.requests[0];
|
|
342
|
+
};
|
|
200
343
|
async function listDepositAddressRequests(parameters, signal) {
|
|
201
344
|
const requestUrl = requestsEndpoint(options);
|
|
202
345
|
if (parameters.requestId)
|
|
@@ -209,12 +352,23 @@ export function relay(options = {}) {
|
|
|
209
352
|
requestUrl.searchParams.set('sortDirection', 'desc');
|
|
210
353
|
if (parameters.continuation)
|
|
211
354
|
requestUrl.searchParams.set('continuation', parameters.continuation);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
355
|
+
await consumeRequestsQuota();
|
|
356
|
+
const response = await (async () => {
|
|
357
|
+
try {
|
|
358
|
+
return await RoutesProvider.requestJson(requestUrl, {
|
|
359
|
+
fetch,
|
|
360
|
+
headers: options.apiKey ? { 'x-api-key': options.apiKey } : undefined,
|
|
361
|
+
method: 'GET',
|
|
362
|
+
signal: AbortSignal.any([signal, AbortSignal.timeout(requestsTimeoutMs)]),
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
catch (cause) {
|
|
366
|
+
await blockRequestsOnRateLimit(cause);
|
|
367
|
+
if (cause instanceof DOMException && cause.name === 'TimeoutError')
|
|
368
|
+
throw new RoutesProvider.ProviderTimeoutError();
|
|
369
|
+
throw cause;
|
|
370
|
+
}
|
|
371
|
+
})();
|
|
218
372
|
const parsed = parseDepositAddressRequests(response);
|
|
219
373
|
return {
|
|
220
374
|
...(parsed.continuation ? { continuation: parsed.continuation } : {}),
|
|
@@ -225,7 +379,7 @@ export function relay(options = {}) {
|
|
|
225
379
|
if (!payment || BigInt(payment.amount) === 0n)
|
|
226
380
|
return undefined;
|
|
227
381
|
const chainId = `eip155:${payment.chainId}/`;
|
|
228
|
-
const token = [parameters.destinationToken, parameters.sourceToken].find((token) => token?.tokenKey.startsWith(chainId) &&
|
|
382
|
+
const token = [parameters.destinationToken, parameters.sourceToken, sponsorToken].find((token) => token?.tokenKey.startsWith(chainId) &&
|
|
229
383
|
token.address.toLowerCase() === payment.address.toLowerCase());
|
|
230
384
|
if (!token)
|
|
231
385
|
throw new RoutesProvider.ProviderPayloadError();
|
|
@@ -362,8 +516,14 @@ export function relay(options = {}) {
|
|
|
362
516
|
id: 'relay',
|
|
363
517
|
name: 'Relay',
|
|
364
518
|
...(webhook ? { webhook } : {}),
|
|
365
|
-
async createDepositAddress({ amount, candidate, recipient, refundAddress, subsidize }, signal) {
|
|
519
|
+
async createDepositAddress({ amount, candidate, recipient, refundAddress, subsidize, subsidyMaxAmount }, signal) {
|
|
520
|
+
if (subsidize &&
|
|
521
|
+
subsidyMaxAmount !== undefined &&
|
|
522
|
+
(candidate.sourceToken.currency !== 'USD' ||
|
|
523
|
+
!Subsidy.supportsGap({ maxAmount: subsidyMaxAmount }, { amount: 0n, destinationToken: candidate.destinationToken })))
|
|
524
|
+
throw new RoutesProvider.ProviderUnavailableError();
|
|
366
525
|
if (subsidize &&
|
|
526
|
+
subsidyMaxAmount === undefined &&
|
|
367
527
|
(!options.subsidies ||
|
|
368
528
|
!Subsidy.supports(options.subsidies, {
|
|
369
529
|
amount,
|
|
@@ -373,11 +533,17 @@ export function relay(options = {}) {
|
|
|
373
533
|
throw new RoutesProvider.ProviderUnavailableError();
|
|
374
534
|
const quote = await (async () => {
|
|
375
535
|
try {
|
|
536
|
+
await consumeQuoteQuota(quoteRateLimit);
|
|
537
|
+
const maximum = subsidyMaxAmount ?? options.subsidies?.maxAmount;
|
|
376
538
|
return await RoutesProvider.requestJson(endpoint, {
|
|
377
539
|
body: {
|
|
378
540
|
amount,
|
|
379
541
|
destinationChainId: relayChainId(candidate.route.destination.chain),
|
|
380
542
|
destinationCurrency: candidate.destinationToken.address,
|
|
543
|
+
...(subsidize ? { fixedRate: '1:1' } : {}),
|
|
544
|
+
...(subsidize && maximum !== undefined
|
|
545
|
+
? { maxSubsidizationAmount: core_Value.from(maximum, 6).toString() }
|
|
546
|
+
: {}),
|
|
381
547
|
originChainId: relayChainId(candidate.route.source.chain),
|
|
382
548
|
originCurrency: candidate.sourceToken.address,
|
|
383
549
|
recipient,
|
|
@@ -394,8 +560,12 @@ export function relay(options = {}) {
|
|
|
394
560
|
});
|
|
395
561
|
}
|
|
396
562
|
catch (cause) {
|
|
397
|
-
|
|
398
|
-
|
|
563
|
+
await blockQuoteOnRateLimit(cause);
|
|
564
|
+
const unavailable = RoutesProvider.unavailable(cause, quoteUnavailableCodes);
|
|
565
|
+
if (unavailable === 'AMOUNT_TOO_LOW')
|
|
566
|
+
throw new RoutesProvider.AmountTooLowError(unavailable, { cause });
|
|
567
|
+
if (unavailable)
|
|
568
|
+
throw new RoutesProvider.ProviderUnavailableError(unavailable, { cause });
|
|
399
569
|
throw cause;
|
|
400
570
|
}
|
|
401
571
|
})();
|
|
@@ -404,6 +574,18 @@ export function relay(options = {}) {
|
|
|
404
574
|
throw new RoutesProvider.ProviderPayloadError();
|
|
405
575
|
if (parsed.data.details.currencyIn.amount !== amount)
|
|
406
576
|
throw new RoutesProvider.ProviderPayloadError();
|
|
577
|
+
if (subsidize) {
|
|
578
|
+
const expected = (BigInt(amount) * 10n ** BigInt(candidate.destinationToken.decimals)) /
|
|
579
|
+
10n ** BigInt(candidate.sourceToken.decimals);
|
|
580
|
+
// Relay can quote 1:1 with isFixedRate=false and a slippage-adjusted minimum; validate the quoted output.
|
|
581
|
+
if (BigInt(parsed.data.details.currencyOut.amount) !== expected)
|
|
582
|
+
// Relay may have issued an address already; retain the irrevocable claim on invalid terms.
|
|
583
|
+
throw new RoutesProvider.ProviderPayloadError(`FIXED_RATE_MISMATCH: ${JSON.stringify({
|
|
584
|
+
amount: parsed.data.details.currencyOut.amount,
|
|
585
|
+
expected: expected.toString(),
|
|
586
|
+
isFixedRate: parsed.data.details.isFixedRate ?? null,
|
|
587
|
+
})}`);
|
|
588
|
+
}
|
|
407
589
|
const step = parsed.data.steps.find((candidate) => candidate.depositAddress && candidate.requestId);
|
|
408
590
|
if (!step?.depositAddress || !step.requestId)
|
|
409
591
|
throw new RoutesProvider.ProviderPayloadError();
|
|
@@ -413,6 +595,7 @@ export function relay(options = {}) {
|
|
|
413
595
|
address: step.depositAddress,
|
|
414
596
|
correlation: {
|
|
415
597
|
...(checkEndpoint ? { checkEndpoint } : {}),
|
|
598
|
+
...(subsidize ? { fixedRate: '1:1' } : {}),
|
|
416
599
|
requestId: step.requestId,
|
|
417
600
|
},
|
|
418
601
|
destinationAmount: parsed.data.details.currencyOut.amount,
|
|
@@ -441,6 +624,7 @@ export function relay(options = {}) {
|
|
|
441
624
|
const destinationChainId = relayChainId(route.destination.chain);
|
|
442
625
|
const sourceChainId = relayChainId(route.source.chain);
|
|
443
626
|
try {
|
|
627
|
+
await consumeQuoteQuota(quoteReadRateLimit);
|
|
444
628
|
const quote = await RoutesProvider.requestJson(endpoint, {
|
|
445
629
|
body: {
|
|
446
630
|
amount: candidate.sourceAmount.amount,
|
|
@@ -478,11 +662,8 @@ export function relay(options = {}) {
|
|
|
478
662
|
};
|
|
479
663
|
}
|
|
480
664
|
catch (cause) {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
'NO_ROUTE',
|
|
484
|
-
'UNSUPPORTED_ROUTE',
|
|
485
|
-
]);
|
|
665
|
+
await blockQuoteOnRateLimit(cause);
|
|
666
|
+
const unavailable = RoutesProvider.unavailable(cause, quoteUnavailableCodes);
|
|
486
667
|
if (!unavailable)
|
|
487
668
|
throw cause;
|
|
488
669
|
return RoutesProvider.unavailableResult({
|
|
@@ -502,12 +683,13 @@ export function relay(options = {}) {
|
|
|
502
683
|
throw new RoutesProvider.ProviderConfigurationError();
|
|
503
684
|
const quote = await (async () => {
|
|
504
685
|
try {
|
|
686
|
+
await consumeQuoteQuota(quoteRateLimit);
|
|
505
687
|
return await RoutesProvider.requestJson(endpoint, {
|
|
506
688
|
body: {
|
|
507
689
|
amount: candidate.sourceAmount.amount,
|
|
508
|
-
destinationChainId:
|
|
690
|
+
destinationChainId: relayChainId(candidate.route.destination.chain),
|
|
509
691
|
destinationCurrency: candidate.destinationToken.address,
|
|
510
|
-
originChainId:
|
|
692
|
+
originChainId: relayChainId(candidate.route.source.chain),
|
|
511
693
|
originCurrency: candidate.sourceToken.address,
|
|
512
694
|
recipient,
|
|
513
695
|
...(slippageBps !== undefined ? { slippageTolerance: String(slippageBps) } : {}),
|
|
@@ -521,8 +703,10 @@ export function relay(options = {}) {
|
|
|
521
703
|
});
|
|
522
704
|
}
|
|
523
705
|
catch (cause) {
|
|
524
|
-
|
|
525
|
-
|
|
706
|
+
await blockQuoteOnRateLimit(cause);
|
|
707
|
+
const unavailable = RoutesProvider.unavailable(cause, quoteUnavailableCodes);
|
|
708
|
+
if (unavailable)
|
|
709
|
+
throw new RoutesProvider.ProviderUnavailableError(unavailable, { cause });
|
|
526
710
|
throw cause;
|
|
527
711
|
}
|
|
528
712
|
})();
|
|
@@ -540,7 +724,7 @@ export function relay(options = {}) {
|
|
|
540
724
|
const requestId = steps.find((step) => step.requestId)?.requestId;
|
|
541
725
|
if (items.length === 0 || !requestId)
|
|
542
726
|
throw new RoutesProvider.ProviderPayloadError();
|
|
543
|
-
const sourceChainId =
|
|
727
|
+
const sourceChainId = relayChainId(candidate.route.source.chain);
|
|
544
728
|
for (const item of items)
|
|
545
729
|
if (item.data.chainId !== sourceChainId ||
|
|
546
730
|
item.data.from.toLowerCase() !== sender.toLowerCase())
|
|
@@ -571,6 +755,118 @@ export function relay(options = {}) {
|
|
|
571
755
|
sampledAt: now().toISOString(),
|
|
572
756
|
};
|
|
573
757
|
},
|
|
758
|
+
...(verifyTransfers && options.apiKey
|
|
759
|
+
? {
|
|
760
|
+
async verifySourceTransaction({ destinationChain, providerState, sourceChain, transactionHash, transfer }, signal) {
|
|
761
|
+
const correlation = schema.TransferCorrelation.safeParse(providerState);
|
|
762
|
+
if (!correlation.success ||
|
|
763
|
+
sourceChain.kind !== 'evm' ||
|
|
764
|
+
(destinationChain.kind !== 'evm' && destinationChain.kind !== 'solana') ||
|
|
765
|
+
!transfer.sender ||
|
|
766
|
+
transfer.method !== 'transaction' ||
|
|
767
|
+
transfer.mode !== 'exactSource')
|
|
768
|
+
return { type: 'invalid' };
|
|
769
|
+
const request = await getTransferRequest(correlation.data.requestId, signal);
|
|
770
|
+
if (!request)
|
|
771
|
+
return { type: 'pending' };
|
|
772
|
+
if (!transferRequestMatches(request, { destinationChain, sourceChain, transfer }))
|
|
773
|
+
return { type: 'invalid' };
|
|
774
|
+
const source = request.data?.inTxs?.find((entry) => entry.chainId === relayChainId(sourceChain) &&
|
|
775
|
+
entry.txHash?.toLowerCase() === transactionHash.toLowerCase());
|
|
776
|
+
if (!source)
|
|
777
|
+
return { type: 'pending' };
|
|
778
|
+
if (source.status === 'failure' ||
|
|
779
|
+
source.status === 'failed' ||
|
|
780
|
+
source.status === 'cancelled' ||
|
|
781
|
+
source.status === 'canceled')
|
|
782
|
+
return { type: 'invalid' };
|
|
783
|
+
if (source.status !== 'success')
|
|
784
|
+
return { type: 'pending' };
|
|
785
|
+
const chains = await getTransferChains(signal);
|
|
786
|
+
const depository = relayEvmChain(chains, sourceChain)?.protocol?.v2?.depository;
|
|
787
|
+
if (!depository || !Address.validate(depository, { strict: false }))
|
|
788
|
+
throw new RoutesProvider.ProviderConfigurationError();
|
|
789
|
+
const reportedDepository = request.protocol?.deposit?.origin?.depository;
|
|
790
|
+
if (reportedDepository &&
|
|
791
|
+
(!Address.validate(reportedDepository, { strict: false }) ||
|
|
792
|
+
!Address.isEqual(reportedDepository, depository)))
|
|
793
|
+
return { type: 'invalid' };
|
|
794
|
+
const evidence = await verifyTransfers({
|
|
795
|
+
chain: sourceChain,
|
|
796
|
+
recipient: depository,
|
|
797
|
+
token: transfer.sourceToken,
|
|
798
|
+
transactionHash,
|
|
799
|
+
});
|
|
800
|
+
const amount = evidence
|
|
801
|
+
.filter((entry) => entry.sender?.toLowerCase() === transfer.sender.toLowerCase())
|
|
802
|
+
.reduce((total, entry) => total + BigInt(entry.amount), 0n);
|
|
803
|
+
if (amount === 0n)
|
|
804
|
+
return { type: 'pending' };
|
|
805
|
+
if (amount !== BigInt(transfer.sourceAmount.baseUnits))
|
|
806
|
+
return { type: 'invalid' };
|
|
807
|
+
return { type: 'verified' };
|
|
808
|
+
},
|
|
809
|
+
async verifyDestinationDelivery({ destinationChain, providerState, sourceChain, transfer }, signal) {
|
|
810
|
+
const correlation = schema.TransferCorrelation.safeParse(providerState);
|
|
811
|
+
if (!correlation.success ||
|
|
812
|
+
sourceChain.kind !== 'evm' ||
|
|
813
|
+
(destinationChain.kind !== 'evm' && destinationChain.kind !== 'solana'))
|
|
814
|
+
return { type: 'invalid' };
|
|
815
|
+
const request = await getTransferRequest(correlation.data.requestId, signal);
|
|
816
|
+
if (!request)
|
|
817
|
+
return { type: 'pending' };
|
|
818
|
+
if (!transferRequestMatches(request, { destinationChain, sourceChain, transfer }))
|
|
819
|
+
return { type: 'invalid' };
|
|
820
|
+
if (request.status === 'failure' ||
|
|
821
|
+
request.status === 'fallback' ||
|
|
822
|
+
request.status === 'refund' ||
|
|
823
|
+
request.status === 'refunded')
|
|
824
|
+
return {
|
|
825
|
+
statusReason: {
|
|
826
|
+
code: 'manual_recovery_required',
|
|
827
|
+
message: 'Relay could not complete the destination transfer.',
|
|
828
|
+
},
|
|
829
|
+
type: 'action-required',
|
|
830
|
+
};
|
|
831
|
+
if (request.status !== 'success')
|
|
832
|
+
return { type: 'pending' };
|
|
833
|
+
const destination = request.data?.route?.actual?.destination?.outputCurrency;
|
|
834
|
+
const outputs = request.data?.outTxs?.filter((entry) => entry.chainId === relayChainId(destinationChain));
|
|
835
|
+
if (!destination ||
|
|
836
|
+
!outputs ||
|
|
837
|
+
outputs.length !== 1 ||
|
|
838
|
+
outputs[0]?.status !== 'success' ||
|
|
839
|
+
!outputs[0].txHash)
|
|
840
|
+
return { type: 'pending' };
|
|
841
|
+
const transactionHash = outputs[0].txHash;
|
|
842
|
+
const evidence = await verifyTransfers({
|
|
843
|
+
chain: destinationChain,
|
|
844
|
+
recipient: transfer.recipient,
|
|
845
|
+
token: transfer.destinationToken,
|
|
846
|
+
transactionHash,
|
|
847
|
+
});
|
|
848
|
+
const amount = evidence.reduce((total, entry) => total + BigInt(entry.amount), 0n);
|
|
849
|
+
if (amount === 0n)
|
|
850
|
+
return { type: 'pending' };
|
|
851
|
+
if (amount !== BigInt(destination.amount))
|
|
852
|
+
return { type: 'invalid' };
|
|
853
|
+
if (transfer.destinationAmountMin &&
|
|
854
|
+
amount < BigInt(transfer.destinationAmountMin.baseUnits))
|
|
855
|
+
return {
|
|
856
|
+
statusReason: {
|
|
857
|
+
code: 'manual_recovery_required',
|
|
858
|
+
message: 'Relay delivered less than the quoted minimum destination amount.',
|
|
859
|
+
},
|
|
860
|
+
type: 'action-required',
|
|
861
|
+
};
|
|
862
|
+
return {
|
|
863
|
+
destinationAmount: amount.toString(),
|
|
864
|
+
transactionHash,
|
|
865
|
+
type: 'verified',
|
|
866
|
+
};
|
|
867
|
+
},
|
|
868
|
+
}
|
|
869
|
+
: {}),
|
|
574
870
|
});
|
|
575
871
|
}
|
|
576
872
|
function parseUserAddresses(value) {
|
|
@@ -804,11 +1100,8 @@ function createDepositAddressObserver(options) {
|
|
|
804
1100
|
});
|
|
805
1101
|
const solverAddresses = (correlation?.solver ? [correlation.solver] : solvers).map((address) => address);
|
|
806
1102
|
const correlatedTransactionHashes = [];
|
|
807
|
-
const uncorrelatedTransactionHashes = [];
|
|
808
1103
|
for (const log of destinationLogs) {
|
|
809
|
-
if (!log.transactionHash ||
|
|
810
|
-
correlatedTransactionHashes.includes(log.transactionHash) ||
|
|
811
|
-
uncorrelatedTransactionHashes.includes(log.transactionHash))
|
|
1104
|
+
if (!log.transactionHash || correlatedTransactionHashes.includes(log.transactionHash))
|
|
812
1105
|
continue;
|
|
813
1106
|
const event = decodeEvent(transferEvent, log);
|
|
814
1107
|
if (!event ||
|
|
@@ -825,23 +1118,12 @@ function createDepositAddressObserver(options) {
|
|
|
825
1118
|
!Address.isEqual(transaction.to, parameters.destinationToken.address) ||
|
|
826
1119
|
!Address.isEqual(call.recipient, event.to) ||
|
|
827
1120
|
call.amount !== event.value ||
|
|
828
|
-
|
|
1121
|
+
!call.orderId ||
|
|
1122
|
+
!Hex.isEqual(call.orderId, sourceObservation.orderId))
|
|
829
1123
|
continue;
|
|
830
|
-
|
|
831
|
-
correlatedTransactionHashes.push(log.transactionHash);
|
|
832
|
-
else
|
|
833
|
-
uncorrelatedTransactionHashes.push(log.transactionHash);
|
|
1124
|
+
correlatedTransactionHashes.push(log.transactionHash);
|
|
834
1125
|
}
|
|
835
|
-
const destinationTransactionHashes =
|
|
836
|
-
if (correlatedTransactionHashes.length > 0)
|
|
837
|
-
return correlatedTransactionHashes;
|
|
838
|
-
// Provider-independent completion requires the Relay order id to bind both chain legs.
|
|
839
|
-
if (!parameters.request)
|
|
840
|
-
return [];
|
|
841
|
-
if (uncorrelatedTransactionHashes.length === 1)
|
|
842
|
-
return uncorrelatedTransactionHashes;
|
|
843
|
-
return [];
|
|
844
|
-
})();
|
|
1126
|
+
const destinationTransactionHashes = correlatedTransactionHashes;
|
|
845
1127
|
const providerState = { relay: sourceObservation };
|
|
846
1128
|
if (destinationTransactionHashes.length === 0)
|
|
847
1129
|
return {
|
|
@@ -1001,6 +1283,35 @@ function relayChainId(chain) {
|
|
|
1001
1283
|
return Number(chain.id.slice('tron:'.length));
|
|
1002
1284
|
throw new RoutesProvider.ProviderConfigurationError();
|
|
1003
1285
|
}
|
|
1286
|
+
function transferRequestMatches(request, options) {
|
|
1287
|
+
const { destinationChain, sourceChain, transfer } = options;
|
|
1288
|
+
const actual = request.data?.route?.actual;
|
|
1289
|
+
if (!transfer.sender ||
|
|
1290
|
+
!request.sender ||
|
|
1291
|
+
!request.recipient ||
|
|
1292
|
+
!Address.validate(request.sender, { strict: false }) ||
|
|
1293
|
+
!Address.isEqual(request.sender, transfer.sender) ||
|
|
1294
|
+
(destinationChain.kind === 'evm'
|
|
1295
|
+
? !Address.validate(request.recipient, { strict: false }) ||
|
|
1296
|
+
!Address.isEqual(request.recipient, transfer.recipient)
|
|
1297
|
+
: request.recipient !== transfer.recipient))
|
|
1298
|
+
return false;
|
|
1299
|
+
if (!actual)
|
|
1300
|
+
return true;
|
|
1301
|
+
const source = actual.origin?.inputCurrency;
|
|
1302
|
+
const destination = actual.destination?.outputCurrency;
|
|
1303
|
+
return ((!source ||
|
|
1304
|
+
(source.currency.chainId === relayChainId(sourceChain) &&
|
|
1305
|
+
Address.validate(source.currency.address, { strict: false }) &&
|
|
1306
|
+
Address.isEqual(source.currency.address, transfer.sourceToken.address) &&
|
|
1307
|
+
source.amount === transfer.sourceAmount.baseUnits)) &&
|
|
1308
|
+
(!destination ||
|
|
1309
|
+
(destination.currency.chainId === relayChainId(destinationChain) &&
|
|
1310
|
+
(destinationChain.kind === 'evm'
|
|
1311
|
+
? Address.validate(destination.currency.address, { strict: false }) &&
|
|
1312
|
+
Address.isEqual(destination.currency.address, transfer.destinationToken.address)
|
|
1313
|
+
: destination.currency.address === transfer.destinationToken.address))));
|
|
1314
|
+
}
|
|
1004
1315
|
/** Relay webhook signature is missing, stale, or invalid. */
|
|
1005
1316
|
export class WebhookSignatureError extends RoutesProvider.WebhookAuthenticationError {
|
|
1006
1317
|
name = 'Routes.Provider.Relay.WebhookSignatureError';
|