tapimo 0.14.0 → 0.15.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 +7 -4
- package/dist/ApiKey.js +1 -1
- package/dist/ApiKey.js.map +1 -1
- package/dist/ApiKeys.d.ts +95 -14
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +360 -49
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +12466 -10374
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +300 -22
- package/dist/App.js.map +1 -1
- package/dist/Assets.d.ts.map +1 -1
- package/dist/Assets.js +2 -1
- package/dist/Assets.js.map +1 -1
- package/dist/Handler.d.ts +0 -1
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js +0 -1
- package/dist/Handler.js.map +1 -1
- package/dist/Scope.d.ts +13 -5
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +16 -5
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.js +1 -1
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/App.d.ts +3057 -546
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +26 -5
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +179 -27
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +95 -43
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +1398 -0
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
- package/dist/admin/apps/earn-vaults.js +463 -7
- package/dist/admin/apps/earn-vaults.js.map +1 -1
- package/dist/admin/apps/organizations.d.ts +267 -15
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +241 -25
- package/dist/admin/apps/organizations.js.map +1 -1
- package/dist/admin/apps/routes-support.d.ts +95 -0
- package/dist/admin/apps/routes-support.d.ts.map +1 -0
- package/dist/admin/apps/routes-support.js +151 -0
- package/dist/admin/apps/routes-support.js.map +1 -0
- package/dist/admin/apps/routes.d.ts +2764 -0
- package/dist/admin/apps/routes.d.ts.map +1 -0
- package/dist/admin/apps/routes.js +728 -0
- package/dist/admin/apps/routes.js.map +1 -0
- package/dist/admin/apps/subsidies.d.ts +501 -0
- package/dist/admin/apps/subsidies.d.ts.map +1 -0
- package/dist/admin/apps/subsidies.js +384 -0
- package/dist/admin/apps/subsidies.js.map +1 -0
- package/dist/admin/apps/verified-tokens.d.ts +166 -160
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +27 -7
- package/dist/admin/apps/verified-tokens.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 +201 -149
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +5 -2
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +31 -1
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +2 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +10 -1
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts +72 -0
- package/dist/analytics/tables/routesLifecycleIntervals.d.ts.map +1 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js +56 -0
- package/dist/analytics/tables/routesLifecycleIntervals.js.map +1 -0
- package/dist/apps/Zones.d.ts +21 -12526
- package/dist/apps/Zones.d.ts.map +1 -1
- package/dist/apps/Zones.js +37 -5
- package/dist/apps/Zones.js.map +1 -1
- package/dist/apps/data/App.d.ts +3971 -2595
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +76 -21
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +629 -299
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +495 -190
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +72 -0
- package/dist/apps/data/routes/addresses.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +116 -116
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +47 -21
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/earn.d.ts +1450 -337
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +1226 -144
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +113 -108
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +41 -21
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +142 -17
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +83 -27
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +235 -235
- package/dist/apps/data/routes/rpc.d.ts +507 -33
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +309 -165
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +47 -15
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +68 -11
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +2 -0
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +26 -14
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +93 -77
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +9 -7
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/valuation.d.ts +32 -32
- package/dist/apps/data/routes/verified-tokens.d.ts +88 -88
- package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/verified-tokens.js +64 -20
- package/dist/apps/data/routes/verified-tokens.js.map +1 -1
- package/dist/apps/data/routes/webhooks.d.ts +614 -177
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +308 -205
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +31 -31
- package/dist/apps/data/routes/zones.d.ts.map +1 -1
- package/dist/apps/data/routes/zones.js +20 -12
- package/dist/apps/data/routes/zones.js.map +1 -1
- package/dist/apps/docs/reference.js +2 -2
- package/dist/apps/docs/reference.js.map +1 -1
- package/dist/apps/index.d.ts +1 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +3780 -3402
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/App.js +5 -14
- package/dist/apps/management/App.js.map +1 -1
- package/dist/apps/management/Billing.d.ts +48 -7
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +204 -25
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +317 -215
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +43 -15
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +290 -4
- package/dist/apps/management/routes/billing.d.ts.map +1 -1
- package/dist/apps/management/routes/billing.js +274 -49
- package/dist/apps/management/routes/billing.js.map +1 -1
- package/dist/apps/management/routes/faucet.d.ts +6 -6
- package/dist/apps/management/routes/faucet.js +1 -1
- package/dist/apps/management/routes/faucet.js.map +1 -1
- package/dist/apps/management/routes/invitations.d.ts +213 -138
- package/dist/apps/management/routes/invitations.d.ts.map +1 -1
- package/dist/apps/management/routes/invitations.js +117 -13
- package/dist/apps/management/routes/invitations.js.map +1 -1
- package/dist/apps/management/routes/invite-links.d.ts +166 -166
- package/dist/apps/management/routes/me.d.ts.map +1 -1
- package/dist/apps/management/routes/me.js +6 -2
- package/dist/apps/management/routes/me.js.map +1 -1
- package/dist/apps/management/routes/members.d.ts +30 -30
- package/dist/apps/management/routes/orgs.d.ts +103 -87
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +52 -12
- 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/projects.d.ts.map +1 -1
- package/dist/apps/management/routes/projects.js +6 -1
- package/dist/apps/management/routes/projects.js.map +1 -1
- package/dist/apps/management/routes/scopes.d.ts.map +1 -1
- package/dist/apps/management/routes/scopes.js +4 -1
- package/dist/apps/management/routes/scopes.js.map +1 -1
- package/dist/apps/management/routes/usage.d.ts +24 -24
- package/dist/apps/management/routes/usage.js +21 -4
- package/dist/apps/management/routes/usage.js.map +1 -1
- package/dist/apps/management/routes/verified-token-requests.d.ts +95 -95
- package/dist/apps/management/routes/verified-token-requests.d.ts.map +1 -1
- package/dist/apps/management/routes/verified-token-requests.js +7 -9
- package/dist/apps/management/routes/verified-token-requests.js.map +1 -1
- package/dist/apps/management/routes/webhooks.d.ts +682 -616
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +58 -12
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/mcp.d.ts +1 -1
- package/dist/apps/mcp.d.ts.map +1 -1
- package/dist/apps/mcp.js +23 -10
- package/dist/apps/mcp.js.map +1 -1
- package/dist/apps/mpp/App.d.ts +44 -44
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/App.js +35 -7
- package/dist/apps/mpp/App.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts +2 -0
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Adapter.js +30 -1
- package/dist/apps/mpp/internal/Adapter.js.map +1 -1
- package/dist/apps/mpp/internal/Policy.d.ts +22 -4
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Policy.js +24 -6
- package/dist/apps/mpp/internal/Policy.js.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.d.ts +3 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -1
- package/dist/apps/mpp/internal/Sponsorship.js +6 -3
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -1
- package/dist/apps/relay/App.d.ts +2 -0
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +134 -75
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts +5 -3
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +209 -28
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/apps/{funding → routes}/Access.d.ts +4 -4
- package/dist/apps/routes/Access.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/Access.js +4 -4
- package/dist/apps/routes/Access.js.map +1 -0
- package/dist/apps/{funding → routes}/App.d.ts +418 -124
- package/dist/apps/{funding → routes}/App.d.ts.map +1 -1
- package/dist/apps/{funding → routes}/App.js +16 -16
- package/dist/apps/routes/App.js.map +1 -0
- package/dist/apps/routes/Inventory.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/Inventory.js +2 -2
- package/dist/apps/routes/Inventory.js.map +1 -0
- package/dist/apps/routes/index.d.ts +2 -0
- package/dist/apps/routes/index.d.ts.map +1 -0
- package/dist/apps/routes/index.js +2 -0
- package/dist/apps/routes/index.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.d.ts +32 -32
- package/dist/apps/routes/routes/chains.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/chains.js +25 -25
- package/dist/apps/routes/routes/chains.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.d.ts +107 -43
- package/dist/apps/routes/routes/deposit-addresses.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/deposit-addresses.js +497 -222
- package/dist/apps/routes/routes/deposit-addresses.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/providers.d.ts +8 -8
- package/dist/apps/routes/routes/providers.d.ts.map +1 -0
- package/dist/apps/routes/routes/providers.js +57 -0
- package/dist/apps/routes/routes/providers.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.d.ts +106 -103
- package/dist/apps/routes/routes/quotes.d.ts.map +1 -0
- package/dist/apps/{funding → routes}/routes/quotes.js +55 -38
- package/dist/apps/routes/routes/quotes.js.map +1 -0
- package/dist/apps/{funding → routes}/routes/transfers.d.ts +733 -428
- package/dist/apps/routes/routes/transfers.d.ts.map +1 -0
- package/dist/apps/routes/routes/transfers.js +1140 -0
- package/dist/apps/routes/routes/transfers.js.map +1 -0
- package/dist/cli/Cli.d.ts +30 -0
- package/dist/cli/Cli.d.ts.map +1 -1
- package/dist/cli/commands/admin.d.ts +36 -0
- package/dist/cli/commands/admin.d.ts.map +1 -1
- package/dist/cli/commands/admin.js +273 -0
- package/dist/cli/commands/admin.js.map +1 -1
- package/dist/cloudflare.d.ts +16 -14
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +26 -21
- package/dist/cloudflare.js.map +1 -1
- package/dist/db/Db.d.ts +63 -21
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +1035 -15
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +780 -133
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +575 -162
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/apiKeyAdmissionBootstraps.d.ts +4 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.d.ts.map +1 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.js +2 -0
- package/dist/db/tables/apiKeyAdmissionBootstraps.js.map +1 -0
- package/dist/db/tables/apiKeyAdmissions.d.ts +73 -0
- package/dist/db/tables/apiKeyAdmissions.d.ts.map +1 -0
- package/dist/db/tables/apiKeyAdmissions.js +142 -0
- package/dist/db/tables/apiKeyAdmissions.js.map +1 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.d.ts +4 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.d.ts.map +1 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.js +2 -0
- package/dist/db/tables/apiKeyOwnerAdmissions.js.map +1 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts +20 -0
- package/dist/db/tables/apiKeyOwnerTombstones.d.ts.map +1 -0
- package/dist/db/tables/apiKeyOwnerTombstones.js +57 -0
- package/dist/db/tables/apiKeyOwnerTombstones.js.map +1 -0
- package/dist/db/tables/apiKeyRevocations.d.ts +21 -0
- package/dist/db/tables/apiKeyRevocations.d.ts.map +1 -0
- package/dist/db/tables/apiKeyRevocations.js +98 -0
- package/dist/db/tables/apiKeyRevocations.js.map +1 -0
- package/dist/db/tables/authAccounts.d.ts +47 -0
- package/dist/db/tables/authAccounts.d.ts.map +1 -0
- package/dist/db/tables/authAccounts.js +72 -0
- package/dist/db/tables/authAccounts.js.map +1 -0
- package/dist/db/tables/authSessions.d.ts +12 -0
- package/dist/db/tables/authSessions.d.ts.map +1 -0
- package/dist/db/tables/authSessions.js +2 -0
- package/dist/db/tables/authSessions.js.map +1 -0
- package/dist/db/tables/authVerifications.d.ts +12 -0
- package/dist/db/tables/authVerifications.d.ts.map +1 -0
- package/dist/db/tables/authVerifications.js +2 -0
- package/dist/db/tables/authVerifications.js.map +1 -0
- package/dist/db/tables/invitations.d.ts +17 -1
- package/dist/db/tables/invitations.d.ts.map +1 -1
- package/dist/db/tables/invitations.js +123 -43
- package/dist/db/tables/invitations.js.map +1 -1
- package/dist/db/tables/memberships.d.ts +8 -0
- package/dist/db/tables/memberships.d.ts.map +1 -1
- package/dist/db/tables/memberships.js +51 -2
- package/dist/db/tables/memberships.js.map +1 -1
- package/dist/db/tables/organizations.d.ts +32 -10
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +110 -49
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +2 -0
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +12 -3
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/requestUsage.d.ts.map +1 -1
- package/dist/db/tables/requestUsage.js.map +1 -1
- package/dist/db/tables/rewardAccounts.d.ts +86 -0
- package/dist/db/tables/rewardAccounts.d.ts.map +1 -0
- package/dist/db/tables/rewardAccounts.js +88 -0
- package/dist/db/tables/rewardAccounts.js.map +1 -0
- package/dist/db/tables/rewardCampaignDistributors.d.ts +36 -0
- package/dist/db/tables/rewardCampaignDistributors.d.ts.map +1 -0
- package/dist/db/tables/rewardCampaignDistributors.js +30 -0
- package/dist/db/tables/rewardCampaignDistributors.js.map +1 -0
- package/dist/db/tables/rewardCampaigns.d.ts +171 -0
- package/dist/db/tables/rewardCampaigns.d.ts.map +1 -0
- package/dist/db/tables/rewardCampaigns.js +392 -0
- package/dist/db/tables/rewardCampaigns.js.map +1 -0
- package/dist/db/tables/rewardCredits.d.ts +53 -0
- package/dist/db/tables/rewardCredits.d.ts.map +1 -0
- package/dist/db/tables/rewardCredits.js +63 -0
- package/dist/db/tables/rewardCredits.js.map +1 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts +61 -0
- package/dist/db/tables/rewardEligibilityAssociations.d.ts.map +1 -0
- package/dist/db/tables/rewardEligibilityAssociations.js +103 -0
- package/dist/db/tables/rewardEligibilityAssociations.js.map +1 -0
- package/dist/db/tables/rewardRuns.d.ts +188 -0
- package/dist/db/tables/rewardRuns.d.ts.map +1 -0
- package/dist/db/tables/rewardRuns.js +278 -0
- package/dist/db/tables/rewardRuns.js.map +1 -0
- package/dist/db/tables/rewardTransactionAttempts.d.ts +100 -0
- package/dist/db/tables/rewardTransactionAttempts.d.ts.map +1 -0
- package/dist/db/tables/rewardTransactionAttempts.js +163 -0
- package/dist/db/tables/rewardTransactionAttempts.js.map +1 -0
- package/dist/db/tables/routesCatalog.d.ts +58 -0
- package/dist/db/tables/routesCatalog.d.ts.map +1 -0
- package/dist/db/tables/{fundingCatalog.js → routesCatalog.js} +19 -19
- package/dist/db/tables/routesCatalog.js.map +1 -0
- package/dist/db/tables/routesDepositAddresses.d.ts +476 -0
- package/dist/db/tables/routesDepositAddresses.d.ts.map +1 -0
- package/dist/db/tables/routesDepositAddresses.js +587 -0
- package/dist/db/tables/routesDepositAddresses.js.map +1 -0
- package/dist/db/tables/{fundingDepositRequestObservations.d.ts → routesDepositRequestObservations.d.ts} +6 -6
- package/dist/db/tables/routesDepositRequestObservations.d.ts.map +1 -0
- package/dist/db/tables/{fundingDepositRequestObservations.js → routesDepositRequestObservations.js} +6 -6
- package/dist/db/tables/routesDepositRequestObservations.js.map +1 -0
- package/dist/db/tables/{fundingDeposits.d.ts → routesDeposits.d.ts} +210 -22
- package/dist/db/tables/routesDeposits.d.ts.map +1 -0
- package/dist/db/tables/routesDeposits.js +576 -0
- package/dist/db/tables/routesDeposits.js.map +1 -0
- package/dist/db/tables/routesIdempotency.d.ts +166 -0
- package/dist/db/tables/routesIdempotency.d.ts.map +1 -0
- package/dist/db/tables/routesIdempotency.js +330 -0
- package/dist/db/tables/routesIdempotency.js.map +1 -0
- package/dist/db/tables/routesSubsidies.d.ts +27 -0
- package/dist/db/tables/routesSubsidies.d.ts.map +1 -0
- package/dist/db/tables/routesSubsidies.js +45 -0
- package/dist/db/tables/routesSubsidies.js.map +1 -0
- package/dist/db/tables/{fundingTransferEvents.d.ts → routesTransferEvents.d.ts} +3 -3
- package/dist/db/tables/routesTransferEvents.d.ts.map +1 -0
- package/dist/db/tables/{fundingTransferEvents.js → routesTransferEvents.js} +3 -3
- package/dist/db/tables/routesTransferEvents.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts +19 -0
- package/dist/db/tables/routesTransferSubsidies.d.ts.map +1 -0
- package/dist/db/tables/routesTransferSubsidies.js +17 -0
- package/dist/db/tables/routesTransferSubsidies.js.map +1 -0
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts +51 -0
- package/dist/db/tables/routesTransferSubsidyNonces.d.ts.map +1 -0
- package/dist/db/tables/routesTransferSubsidyNonces.js +82 -0
- package/dist/db/tables/routesTransferSubsidyNonces.js.map +1 -0
- package/dist/db/tables/routesTransferTransactions.d.ts +77 -0
- package/dist/db/tables/routesTransferTransactions.d.ts.map +1 -0
- package/dist/db/tables/{fundingTransferTransactions.js → routesTransferTransactions.js} +31 -13
- package/dist/db/tables/routesTransferTransactions.js.map +1 -0
- package/dist/db/tables/routesTransfers.d.ts +319 -0
- package/dist/db/tables/routesTransfers.d.ts.map +1 -0
- package/dist/db/tables/routesTransfers.js +372 -0
- package/dist/db/tables/routesTransfers.js.map +1 -0
- package/dist/db/tables/sponsoredTransactions.d.ts +75 -20
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +124 -54
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/sponsorshipAttributions.d.ts +69 -0
- package/dist/db/tables/sponsorshipAttributions.d.ts.map +1 -0
- package/dist/db/tables/sponsorshipAttributions.js +77 -0
- package/dist/db/tables/sponsorshipAttributions.js.map +1 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.d.ts +22 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.d.ts.map +1 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.js +45 -0
- package/dist/db/tables/sponsorshipReconciliationCursors.js.map +1 -0
- package/dist/db/tables/stripeCustomers.d.ts +11 -0
- package/dist/db/tables/stripeCustomers.d.ts.map +1 -1
- package/dist/db/tables/stripeCustomers.js +13 -0
- package/dist/db/tables/stripeCustomers.js.map +1 -1
- package/dist/db/tables/users.d.ts +17 -1
- package/dist/db/tables/users.d.ts.map +1 -1
- package/dist/db/tables/users.js +47 -2
- package/dist/db/tables/users.js.map +1 -1
- package/dist/db/tables/verifiedTokenRequests.d.ts +21 -4
- package/dist/db/tables/verifiedTokenRequests.d.ts.map +1 -1
- package/dist/db/tables/verifiedTokenRequests.js +65 -44
- package/dist/db/tables/verifiedTokenRequests.js.map +1 -1
- package/dist/db/tables/webhookQueueEvents.d.ts.map +1 -1
- package/dist/db/tables/webhookQueueEvents.js +5 -1
- package/dist/db/tables/webhookQueueEvents.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +19 -11
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +45 -13
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/internal/executionError.d.ts +2 -2
- package/dist/handlers/internal/executionError.d.ts.map +1 -1
- package/dist/handlers/internal/executionError.js +1 -2
- package/dist/handlers/internal/executionError.js.map +1 -1
- package/dist/handlers/internal/multisig.d.ts +4 -232
- package/dist/handlers/internal/multisig.d.ts.map +1 -1
- package/dist/handlers/internal/multisig.js +11 -537
- package/dist/handlers/internal/multisig.js.map +1 -1
- package/dist/handlers/internal/sponsorship.d.ts +19 -8
- package/dist/handlers/internal/sponsorship.d.ts.map +1 -1
- package/dist/handlers/internal/sponsorship.js +13 -9
- package/dist/handlers/internal/sponsorship.js.map +1 -1
- package/dist/handlers/relay.d.ts +9 -12
- package/dist/handlers/relay.d.ts.map +1 -1
- package/dist/handlers/relay.js +81 -85
- package/dist/handlers/relay.js.map +1 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +1 -1
- package/dist/internal/AssetResponse.d.ts +12 -0
- package/dist/internal/AssetResponse.d.ts.map +1 -0
- package/dist/internal/AssetResponse.js +21 -0
- package/dist/internal/AssetResponse.js.map +1 -0
- package/dist/internal/Auth.d.ts +64 -12
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +631 -180
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/BetterAuth.d.ts +1488 -0
- package/dist/internal/BetterAuth.d.ts.map +1 -0
- package/dist/internal/BetterAuth.js +253 -0
- package/dist/internal/BetterAuth.js.map +1 -0
- package/dist/internal/Cache.d.ts +2 -0
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +2 -0
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/EarnRates.d.ts +26 -3
- package/dist/internal/EarnRates.d.ts.map +1 -1
- package/dist/internal/EarnRates.js +84 -19
- package/dist/internal/EarnRates.js.map +1 -1
- package/dist/internal/EarnSharePrices.d.ts +120 -0
- package/dist/internal/EarnSharePrices.d.ts.map +1 -0
- package/dist/internal/EarnSharePrices.js +179 -0
- package/dist/internal/EarnSharePrices.js.map +1 -0
- package/dist/internal/EarnVaults.d.ts +4 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -1
- package/dist/internal/EarnVaults.js +27 -10
- package/dist/internal/EarnVaults.js.map +1 -1
- package/dist/internal/Email.d.ts +37 -0
- package/dist/internal/Email.d.ts.map +1 -0
- package/dist/internal/Email.js +16 -0
- package/dist/internal/Email.js.map +1 -0
- package/dist/internal/Log.d.ts +32 -28
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +18 -11
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts +3 -0
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +67 -8
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/Mpp.d.ts.map +1 -1
- package/dist/internal/Mpp.js +20 -25
- package/dist/internal/Mpp.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +26 -3
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +25 -10
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Provider.d.ts +1 -1
- package/dist/internal/Provider.d.ts.map +1 -1
- package/dist/internal/RateLimit.d.ts.map +1 -1
- package/dist/internal/RateLimit.js +13 -1
- package/dist/internal/RateLimit.js.map +1 -1
- package/dist/internal/Store.d.ts +16 -0
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +59 -8
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts +9 -2
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +78 -11
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Timing.d.ts +26 -0
- package/dist/internal/Timing.d.ts.map +1 -1
- package/dist/internal/Timing.js +63 -5
- package/dist/internal/Timing.js.map +1 -1
- package/dist/internal/VercelOidc.d.ts +94 -0
- package/dist/internal/VercelOidc.d.ts.map +1 -0
- package/dist/internal/VercelOidc.js +128 -0
- package/dist/internal/VercelOidc.js.map +1 -0
- package/dist/internal/VerifiedTokens.d.ts +2 -8
- package/dist/internal/VerifiedTokens.d.ts.map +1 -1
- package/dist/internal/VerifiedTokens.js +24 -24
- package/dist/internal/VerifiedTokens.js.map +1 -1
- package/dist/internal/Viem.d.ts +30 -2067
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +167 -17
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/Webhooks.d.ts +12 -4
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +9 -3
- package/dist/internal/Webhooks.js.map +1 -1
- package/dist/internal/ZoneRpc.d.ts +7 -0
- package/dist/internal/ZoneRpc.d.ts.map +1 -0
- package/dist/internal/ZoneRpc.js +49 -0
- package/dist/internal/ZoneRpc.js.map +1 -0
- package/dist/internal/index.d.ts +3 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +3 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/rewards/Audit.d.ts +88 -0
- package/dist/internal/rewards/Audit.d.ts.map +1 -0
- package/dist/internal/rewards/Audit.js +134 -0
- package/dist/internal/rewards/Audit.js.map +1 -0
- package/dist/internal/rewards/Campaigns.d.ts +572 -0
- package/dist/internal/rewards/Campaigns.d.ts.map +1 -0
- package/dist/internal/rewards/Campaigns.js +531 -0
- package/dist/internal/rewards/Campaigns.js.map +1 -0
- package/dist/internal/rewards/Credits.d.ts +76 -0
- package/dist/internal/rewards/Credits.d.ts.map +1 -0
- package/dist/internal/rewards/Credits.js +95 -0
- package/dist/internal/rewards/Credits.js.map +1 -0
- package/dist/internal/rewards/Events.d.ts +100 -0
- package/dist/internal/rewards/Events.d.ts.map +1 -0
- package/dist/internal/rewards/Events.js +340 -0
- package/dist/internal/rewards/Events.js.map +1 -0
- package/dist/internal/rewards/Projection.d.ts +237 -0
- package/dist/internal/rewards/Projection.d.ts.map +1 -0
- package/dist/internal/rewards/Projection.js +616 -0
- package/dist/internal/rewards/Projection.js.map +1 -0
- package/dist/internal/rewards/Rates.d.ts +44 -0
- package/dist/internal/rewards/Rates.d.ts.map +1 -0
- package/dist/internal/rewards/Rates.js +60 -0
- package/dist/internal/rewards/Rates.js.map +1 -0
- package/dist/internal/rewards/Read.d.ts +158 -0
- package/dist/internal/rewards/Read.d.ts.map +1 -0
- package/dist/internal/rewards/Read.js +292 -0
- package/dist/internal/rewards/Read.js.map +1 -0
- package/dist/internal/rewards/Runner.d.ts +164 -0
- package/dist/internal/rewards/Runner.d.ts.map +1 -0
- package/dist/internal/rewards/Runner.js +1778 -0
- package/dist/internal/rewards/Runner.js.map +1 -0
- package/dist/internal/rewards/Signer.d.ts +224 -0
- package/dist/internal/rewards/Signer.d.ts.map +1 -0
- package/dist/internal/rewards/Signer.js +135 -0
- package/dist/internal/rewards/Signer.js.map +1 -0
- package/dist/internal/rewards/index.d.ts +15 -0
- package/dist/internal/rewards/index.d.ts.map +1 -0
- package/dist/internal/rewards/index.js +15 -0
- package/dist/internal/rewards/index.js.map +1 -0
- package/dist/internal/{funding → routes}/Action.d.ts +12 -1
- package/dist/internal/routes/Action.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Action.js +17 -9
- package/dist/internal/routes/Action.js.map +1 -0
- package/dist/internal/{funding → routes}/Catalog.d.ts +20 -20
- package/dist/internal/routes/Catalog.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Catalog.js +29 -29
- package/dist/internal/routes/Catalog.js.map +1 -0
- package/dist/internal/{funding → routes}/Chain.d.ts +10 -10
- package/dist/internal/routes/Chain.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Chain.js +3 -3
- package/dist/internal/routes/Chain.js.map +1 -0
- package/dist/internal/{funding → routes}/Deposit.d.ts +45 -23
- package/dist/internal/routes/Deposit.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Deposit.js +60 -27
- package/dist/internal/routes/Deposit.js.map +1 -0
- package/dist/internal/{funding → routes}/DepositAddress.d.ts +56 -27
- package/dist/internal/routes/DepositAddress.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/DepositAddress.js +95 -33
- package/dist/internal/routes/DepositAddress.js.map +1 -0
- package/dist/internal/{funding → routes}/DepositWebhook.d.ts +4 -4
- package/dist/internal/routes/DepositWebhook.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/DepositWebhook.js +4 -4
- package/dist/internal/routes/DepositWebhook.js.map +1 -0
- package/dist/internal/routes/Economics.d.ts +25 -0
- package/dist/internal/routes/Economics.d.ts.map +1 -0
- package/dist/internal/routes/Economics.js +28 -0
- package/dist/internal/routes/Economics.js.map +1 -0
- package/dist/internal/{funding → routes}/Evidence.d.ts +3 -3
- package/dist/internal/routes/Evidence.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Evidence.js +7 -7
- package/dist/internal/routes/Evidence.js.map +1 -0
- package/dist/internal/routes/Observability.d.ts +154 -0
- package/dist/internal/routes/Observability.d.ts.map +1 -0
- package/dist/internal/routes/Observability.js +389 -0
- package/dist/internal/routes/Observability.js.map +1 -0
- package/dist/internal/{funding → routes}/Provider.d.ts +311 -105
- package/dist/internal/routes/Provider.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Provider.js +229 -98
- package/dist/internal/routes/Provider.js.map +1 -0
- package/dist/internal/{funding → routes}/Reconciliation.d.ts +11 -6
- package/dist/internal/routes/Reconciliation.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Reconciliation.js +408 -158
- package/dist/internal/routes/Reconciliation.js.map +1 -0
- package/dist/internal/routes/Route.d.ts +21 -0
- package/dist/internal/routes/Route.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Route.js +1 -1
- package/dist/internal/routes/Route.js.map +1 -0
- package/dist/internal/{funding → routes}/SourceObservation.d.ts +6 -6
- package/dist/internal/routes/SourceObservation.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/SourceObservation.js +8 -8
- package/dist/internal/routes/SourceObservation.js.map +1 -0
- package/dist/internal/{funding → routes}/Subsidy.d.ts +48 -3
- package/dist/internal/routes/Subsidy.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Subsidy.js +43 -3
- package/dist/internal/routes/Subsidy.js.map +1 -0
- package/dist/internal/{funding → routes}/Token.d.ts +4 -4
- package/dist/internal/routes/Token.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/Token.js +3 -3
- package/dist/internal/routes/Token.js.map +1 -0
- package/dist/internal/{funding → routes}/Transfer.d.ts +241 -46
- package/dist/internal/routes/Transfer.d.ts.map +1 -0
- package/dist/internal/routes/Transfer.js +728 -0
- package/dist/internal/routes/Transfer.js.map +1 -0
- package/dist/internal/{funding → routes}/TransferReconciliation.d.ts +13 -10
- package/dist/internal/routes/TransferReconciliation.d.ts.map +1 -0
- package/dist/internal/routes/TransferReconciliation.js +422 -0
- package/dist/internal/routes/TransferReconciliation.js.map +1 -0
- package/dist/internal/routes/TransferSubsidy.d.ts +201 -0
- package/dist/internal/routes/TransferSubsidy.d.ts.map +1 -0
- package/dist/internal/routes/TransferSubsidy.js +256 -0
- package/dist/internal/routes/TransferSubsidy.js.map +1 -0
- package/dist/internal/{funding → routes}/TransferWebhook.d.ts +5 -5
- package/dist/internal/routes/TransferWebhook.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/TransferWebhook.js +3 -3
- package/dist/internal/routes/TransferWebhook.js.map +1 -0
- package/dist/internal/{funding → routes}/index.d.ts +2 -0
- package/dist/internal/routes/index.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/index.js +2 -0
- package/dist/internal/routes/index.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/across.d.ts +4 -4
- package/dist/internal/routes/providers/across.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/across.js +13 -13
- package/dist/internal/routes/providers/across.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/relay.d.ts +21 -12
- package/dist/internal/routes/providers/relay.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/relay.js +194 -110
- package/dist/internal/routes/providers/relay.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/rhino.d.ts +4 -4
- package/dist/internal/routes/providers/rhino.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/rhino.js +10 -10
- package/dist/internal/routes/providers/rhino.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/squid.d.ts +4 -4
- package/dist/internal/routes/providers/squid.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/squid.js +14 -14
- package/dist/internal/routes/providers/squid.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/stargate.d.ts +46 -18
- package/dist/internal/routes/providers/stargate.d.ts.map +1 -0
- package/dist/internal/routes/providers/stargate.js +898 -0
- package/dist/internal/routes/providers/stargate.js.map +1 -0
- package/dist/internal/{funding → routes}/providers/symbiosis.d.ts +4 -4
- package/dist/internal/routes/providers/symbiosis.d.ts.map +1 -0
- package/dist/internal/{funding → routes}/providers/symbiosis.js +30 -20
- package/dist/internal/routes/providers/symbiosis.js.map +1 -0
- package/dist/internal/webhookDestinations/slack.js +12 -12
- package/dist/internal/webhookDestinations/slack.js.map +1 -1
- package/dist/providers/index.d.ts +12 -12
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +12 -12
- package/dist/providers/index.js.map +1 -1
- package/dist/server.d.ts +19 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +19 -0
- package/dist/server.js.map +1 -0
- package/package.json +15 -4
- package/src/ApiKey.ts +1 -1
- package/src/ApiKeys.test.ts +1033 -3
- package/src/ApiKeys.ts +489 -48
- package/src/App.test-d.ts +1 -1
- package/src/App.test.ts +216 -25
- package/src/App.ts +334 -31
- package/src/Assets.test.ts +2 -2
- package/src/Assets.ts +3 -1
- package/src/Auth.test-d.ts +1 -1
- package/src/Client.test-d.ts +539 -110
- package/src/Handler.ts +0 -1
- package/src/OpenApi.contract.test.ts +195 -0
- package/src/Scope.ts +17 -5
- package/src/Webhooks.ts +1 -1
- package/src/admin/App.test.ts +30 -2
- package/src/admin/App.ts +42 -6
- package/src/admin/apps/api-keys.test.ts +267 -5
- package/src/admin/apps/api-keys.ts +100 -50
- package/src/admin/apps/earn-vaults.test.ts +158 -0
- package/src/admin/apps/earn-vaults.ts +679 -6
- package/src/admin/apps/organizations.test.ts +306 -17
- package/src/admin/apps/organizations.ts +299 -24
- package/src/admin/apps/routes-support.test.ts +200 -0
- package/src/admin/apps/routes-support.ts +201 -0
- package/src/admin/apps/routes.test.ts +450 -0
- package/src/admin/apps/routes.ts +896 -0
- package/src/admin/apps/scopes.test.ts +15 -5
- package/src/admin/apps/subsidies.test.ts +306 -0
- package/src/admin/apps/subsidies.ts +457 -0
- package/src/admin/apps/verified-tokens.test.ts +40 -3
- package/src/admin/apps/verified-tokens.ts +33 -7
- package/src/admin/ui/plugin.ts +1 -2
- package/src/admin/ui/src/components/RewardCampaignForm.tsx +1009 -0
- package/src/admin/ui/src/lib/config.ts +11 -2
- package/src/admin/ui/src/lib/earn-vaults.ts +2 -2
- package/src/admin/ui/src/lib/organizations.test.ts +83 -50
- package/src/admin/ui/src/lib/organizations.ts +106 -25
- package/src/admin/ui/src/lib/query-client.ts +1 -1
- package/src/admin/ui/src/lib/reward-campaigns.ts +136 -0
- package/src/admin/ui/src/lib/routes.test.ts +88 -0
- package/src/admin/ui/src/lib/routes.ts +304 -0
- package/src/admin/ui/src/lib/subsidies.ts +75 -0
- package/src/admin/ui/src/lib/verified-tokens.ts +24 -9
- package/src/admin/ui/src/routeTree.gen.ts +63 -0
- package/src/admin/ui/src/routes/__root.tsx +13 -2
- package/src/admin/ui/src/routes/api-keys.tsx +196 -84
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +105 -70
- package/src/admin/ui/src/routes/organizations.tsx +34 -4
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +239 -23
- package/src/admin/ui/src/routes/routes.tsx +1615 -0
- package/src/admin/ui/src/routes/routes_.support.tsx +248 -0
- package/src/admin/ui/src/routes/subsidies.tsx +799 -0
- package/src/admin/ui/src/routes/verified-tokens.tsx +64 -20
- package/src/admin/ui.generated.ts +202 -188
- package/src/analytics/Analytics.test.ts +108 -18
- package/src/analytics/Analytics.ts +38 -6
- package/src/analytics/tables/requestEvents.test.ts +100 -0
- package/src/analytics/tables/requestEvents.ts +10 -1
- package/src/analytics/tables/routesLifecycleIntervals.ts +140 -0
- package/src/apps/Zones.test.ts +15 -0
- package/src/apps/Zones.ts +52 -5
- package/src/apps/composition.test.ts +68 -60
- package/src/apps/data/App.test.ts +180 -2
- package/src/apps/data/App.ts +88 -28
- package/src/apps/data/routes/activities.test.ts +419 -7
- package/src/apps/data/routes/activities.ts +683 -216
- package/src/apps/data/routes/balances.test.ts +2 -2
- package/src/apps/data/routes/blocks.test.ts +46 -1
- package/src/apps/data/routes/coingecko.test.ts +419 -1
- package/src/apps/data/routes/coingecko.ts +309 -253
- package/src/apps/data/routes/earn.discovery.test.ts +274 -0
- package/src/apps/data/routes/earn.test.ts +1294 -17
- package/src/apps/data/routes/earn.ts +1838 -321
- package/src/apps/data/routes/exchanges.test.ts +12 -15
- package/src/apps/data/routes/fee-amm.test.ts +243 -0
- package/src/apps/data/routes/fee-amm.ts +201 -162
- package/src/apps/data/routes/indexer.test.ts +389 -0
- package/src/apps/data/routes/indexer.ts +165 -69
- package/src/apps/data/routes/receipts.test.ts +1 -1
- package/src/apps/data/routes/rpc.test.ts +384 -8
- package/src/apps/data/routes/rpc.ts +452 -227
- package/src/apps/data/routes/rpc.zone.test.ts +340 -0
- package/src/apps/data/routes/tokenlist.test.ts +285 -0
- package/src/apps/data/routes/tokenlist.ts +173 -88
- package/src/apps/data/routes/tokens.test.ts +93 -3
- package/src/apps/data/routes/tokens.ts +39 -23
- package/src/apps/data/routes/transactions.test.ts +1 -1
- package/src/apps/data/routes/transfers.test.ts +56 -24
- package/src/apps/data/routes/transfers.ts +19 -8
- package/src/apps/data/routes/valuation.test.ts +1 -1
- package/src/apps/data/routes/verified-tokens.test.ts +345 -0
- package/src/apps/data/routes/verified-tokens.ts +99 -29
- package/src/apps/data/routes/webhooks.scan.test.ts +29 -0
- package/src/apps/data/routes/webhooks.test.ts +651 -83
- package/src/apps/data/routes/webhooks.ts +1113 -868
- package/src/apps/data/routes/zones.test.ts +148 -71
- package/src/apps/data/routes/zones.ts +71 -55
- package/src/apps/docs/reference.ts +2 -2
- package/src/apps/index.ts +1 -1
- package/src/apps/management/App.ts +9 -51
- package/src/apps/management/Billing.test.ts +375 -14
- package/src/apps/management/Billing.ts +265 -29
- package/src/apps/management/routes/api-keys.test.ts +269 -7
- package/src/apps/management/routes/api-keys.ts +61 -20
- package/src/apps/management/routes/billing.test.ts +477 -15
- package/src/apps/management/routes/billing.ts +377 -50
- package/src/apps/management/routes/faucet.test.ts +1 -1
- package/src/apps/management/routes/faucet.ts +1 -1
- package/src/apps/management/routes/invitations.test.ts +270 -3
- package/src/apps/management/routes/invitations.ts +185 -15
- package/src/apps/management/routes/invoicePreview.test.ts +549 -0
- package/src/apps/management/routes/me.test.ts +246 -5
- package/src/apps/management/routes/me.ts +7 -2
- package/src/apps/management/routes/members.test.ts +108 -0
- package/src/apps/management/routes/orgs.test.ts +191 -3
- package/src/apps/management/routes/orgs.ts +58 -11
- package/src/apps/management/routes/projects.test.ts +33 -3
- package/src/apps/management/routes/projects.ts +6 -1
- package/src/apps/management/routes/scopes.test.ts +30 -2
- package/src/apps/management/routes/scopes.ts +4 -1
- package/src/apps/management/routes/usage.test.ts +32 -0
- package/src/apps/management/routes/usage.ts +22 -4
- package/src/apps/management/routes/verified-token-requests.test.ts +16 -2
- package/src/apps/management/routes/verified-token-requests.ts +7 -10
- package/src/apps/management/routes/webhooks.test.ts +49 -26
- package/src/apps/management/routes/webhooks.ts +78 -22
- package/src/apps/mcp.test.ts +113 -30
- package/src/apps/mcp.ts +22 -10
- package/src/apps/mpp/App.ts +37 -7
- package/src/apps/mpp/Mpp.test.ts +49 -8
- package/src/apps/mpp/Mpp.zone.test.ts +219 -0
- package/src/apps/mpp/internal/Adapter.ts +34 -0
- package/src/apps/mpp/internal/Policy.test.ts +86 -31
- package/src/apps/mpp/internal/Policy.ts +49 -7
- package/src/apps/mpp/internal/Sponsorship.test.ts +207 -0
- package/src/apps/mpp/internal/Sponsorship.ts +9 -3
- package/src/apps/relay/App.test.ts +839 -64
- package/src/apps/relay/App.ts +148 -81
- package/src/apps/relay/App.zone-billing.test.ts +257 -0
- package/src/apps/relay/Sponsorships.test.ts +67 -4
- package/src/apps/relay/Sponsorships.ts +233 -32
- package/src/apps/relay/Sponsorships.zone.test.ts +102 -0
- package/src/apps/{funding → routes}/Access.ts +6 -6
- package/src/apps/routes/App.test.ts +165 -0
- package/src/apps/routes/App.ts +96 -0
- package/src/apps/{funding → routes}/Inventory.ts +2 -2
- package/src/apps/routes/index.ts +1 -0
- package/src/apps/{funding → routes}/routes/chains.test.ts +66 -66
- package/src/apps/{funding → routes}/routes/chains.ts +23 -23
- package/src/apps/{funding → routes}/routes/deposit-addresses.test.ts +1358 -458
- package/src/apps/{funding → routes}/routes/deposit-addresses.ts +566 -246
- package/src/apps/{funding → routes}/routes/providers.test.ts +27 -33
- package/src/apps/{funding → routes}/routes/providers.ts +23 -23
- package/src/apps/{funding → routes}/routes/quotes.test.ts +298 -41
- package/src/apps/{funding → routes}/routes/quotes.ts +57 -40
- package/src/apps/{funding → routes}/routes/transfers.test.ts +1100 -353
- package/src/apps/routes/routes/transfers.ts +1332 -0
- package/src/cli/Cli.test.ts +1 -1
- package/src/cli/commands/admin.test.ts +748 -1
- package/src/cli/commands/admin.ts +278 -0
- package/src/cloudflare.ts +52 -47
- package/src/db/Db.test.ts +245 -2
- package/src/db/Db.ts +1485 -34
- package/src/db/Schema.ts +729 -228
- package/src/db/tables/apiKeyAdmissionBootstraps.ts +4 -0
- package/src/db/tables/apiKeyAdmissions.ts +218 -0
- package/src/db/tables/apiKeyOwnerAdmissions.ts +4 -0
- package/src/db/tables/apiKeyOwnerTombstones.ts +81 -0
- package/src/db/tables/apiKeyRevocations.test.ts +74 -0
- package/src/db/tables/apiKeyRevocations.ts +121 -0
- package/src/db/tables/authAccounts.ts +105 -0
- package/src/db/tables/authSessions.ts +13 -0
- package/src/db/tables/authVerifications.ts +13 -0
- package/src/db/tables/invitations.ts +142 -45
- package/src/db/tables/memberships.ts +79 -3
- package/src/db/tables/organizations.test.ts +690 -13
- package/src/db/tables/organizations.ts +139 -55
- package/src/db/tables/projects.test.ts +16 -0
- package/src/db/tables/projects.ts +13 -3
- package/src/db/tables/requestUsage.ts +4 -1
- package/src/db/tables/rewardAccounts.ts +178 -0
- package/src/db/tables/rewardCampaignDistributors.ts +68 -0
- package/src/db/tables/rewardCampaigns.test.ts +1388 -0
- package/src/db/tables/rewardCampaigns.ts +647 -0
- package/src/db/tables/rewardCredits.ts +110 -0
- package/src/db/tables/rewardEligibilityAssociations.test.ts +271 -0
- package/src/db/tables/rewardEligibilityAssociations.ts +184 -0
- package/src/db/tables/rewardRuns.ts +514 -0
- package/src/db/tables/rewardTransactionAttempts.ts +272 -0
- package/src/db/tables/routesCatalog.test.ts +185 -0
- package/src/db/tables/routesCatalog.ts +163 -0
- package/src/db/tables/routesDepositAddresses.test.ts +1048 -0
- package/src/db/tables/routesDepositAddresses.ts +1008 -0
- package/src/db/tables/{fundingDepositRequestObservations.test.ts → routesDepositRequestObservations.test.ts} +13 -14
- package/src/db/tables/{fundingDepositRequestObservations.ts → routesDepositRequestObservations.ts} +10 -10
- package/src/db/tables/{fundingDeposits.test.ts → routesDeposits.test.ts} +388 -46
- package/src/db/tables/routesDeposits.ts +1062 -0
- package/src/db/tables/routesIdempotency.test.ts +796 -0
- package/src/db/tables/routesIdempotency.ts +496 -0
- package/src/db/tables/routesSubsidies.test.ts +120 -0
- package/src/db/tables/routesSubsidies.ts +71 -0
- package/src/db/tables/{fundingTransferEvents.ts → routesTransferEvents.ts} +4 -4
- package/src/db/tables/routesTransferSubsidies.ts +38 -0
- package/src/db/tables/routesTransferSubsidyNonces.ts +124 -0
- package/src/db/tables/routesTransferTransactions.test.ts +195 -0
- package/src/db/tables/{fundingTransferTransactions.ts → routesTransferTransactions.ts} +63 -18
- package/src/db/tables/routesTransfers.test.ts +338 -0
- package/src/db/tables/routesTransfers.ts +662 -0
- package/src/db/tables/sponsoredTransactions.test.ts +269 -45
- package/src/db/tables/sponsoredTransactions.ts +225 -65
- package/src/db/tables/sponsorshipAttributions.test.ts +160 -0
- package/src/db/tables/sponsorshipAttributions.ts +168 -0
- package/src/db/tables/sponsorshipReconciliationCursors.test.ts +115 -0
- package/src/db/tables/sponsorshipReconciliationCursors.ts +67 -0
- package/src/db/tables/stripeCustomers.test.ts +85 -0
- package/src/db/tables/stripeCustomers.ts +24 -0
- package/src/db/tables/users.test.ts +129 -0
- package/src/db/tables/users.ts +49 -3
- package/src/db/tables/verifiedTokenRequests.test.ts +39 -20
- package/src/db/tables/verifiedTokenRequests.ts +80 -44
- package/src/db/tables/webhookQueueEvents.ts +8 -1
- package/src/db/tables/webhookSubscriptions.ts +95 -20
- package/src/handlers/internal/executionError.ts +3 -4
- package/src/handlers/internal/multisig.ts +13 -816
- package/src/handlers/internal/sponsorship.ts +26 -10
- package/src/handlers/relay.test-d.ts +9 -1
- package/src/handlers/relay.test.ts +823 -3
- package/src/handlers/relay.ts +127 -107
- package/src/index.test-d.ts +7 -0
- package/src/index.ts +0 -17
- package/src/internal/AssetResponse.ts +26 -0
- package/src/internal/Auth.test.ts +1656 -9
- package/src/internal/Auth.ts +880 -244
- package/src/internal/BetterAuth.test.ts +242 -0
- package/src/internal/BetterAuth.ts +349 -0
- package/src/internal/Cache.ts +2 -0
- package/src/internal/EarnRates.test.ts +17 -0
- package/src/internal/EarnRates.ts +124 -31
- package/src/internal/EarnSharePrices.test.ts +182 -0
- package/src/internal/EarnSharePrices.ts +313 -0
- package/src/internal/EarnVaults.test.ts +21 -0
- package/src/internal/EarnVaults.ts +33 -11
- package/src/internal/Email.ts +54 -0
- package/src/internal/Idempotency.test.ts +2 -2
- package/src/internal/Log.test-d.ts +8 -7
- package/src/internal/Log.test.ts +114 -16
- package/src/internal/Log.ts +53 -40
- package/src/internal/MetricSink.test.ts +313 -26
- package/src/internal/MetricSink.ts +73 -8
- package/src/internal/Mpp.test.ts +31 -0
- package/src/internal/Mpp.ts +21 -24
- package/src/internal/OpenApi.ts +45 -12
- package/src/internal/Provider.test.ts +1 -1
- package/src/internal/Provider.ts +1 -1
- package/src/internal/RateLimit.test.ts +21 -3
- package/src/internal/RateLimit.ts +12 -1
- package/src/internal/Store.test-d.ts +1 -1
- package/src/internal/Store.test.ts +151 -8
- package/src/internal/Store.ts +76 -9
- package/src/internal/Tidx.test.ts +59 -8
- package/src/internal/Tidx.ts +86 -14
- package/src/internal/Timing.test.ts +77 -0
- package/src/internal/Timing.ts +83 -6
- package/src/internal/VercelOidc.test.ts +188 -0
- package/src/internal/VercelOidc.ts +193 -0
- package/src/internal/VerifiedTokens.test.ts +60 -6
- package/src/internal/VerifiedTokens.ts +21 -24
- package/src/internal/Viem.batch.test.ts +80 -0
- package/src/internal/Viem.test.ts +201 -2
- package/src/internal/Viem.ts +221 -25
- package/src/internal/Webhooks.test.ts +85 -6
- package/src/internal/Webhooks.ts +22 -4
- package/src/internal/ZoneRpc.ts +50 -0
- package/src/internal/exchange/Provider.test.ts +2 -2
- package/src/internal/index.test.ts +3 -1
- package/src/internal/index.ts +3 -1
- package/src/internal/rewards/Audit.ts +231 -0
- package/src/internal/rewards/Campaigns.test.ts +1234 -0
- package/src/internal/rewards/Campaigns.ts +1205 -0
- package/src/internal/rewards/Credits.ts +165 -0
- package/src/internal/rewards/Events.local.test.ts +113 -0
- package/src/internal/rewards/Events.test.ts +152 -0
- package/src/internal/rewards/Events.ts +468 -0
- package/src/internal/rewards/Projection.test.ts +681 -0
- package/src/internal/rewards/Projection.ts +987 -0
- package/src/internal/rewards/Rates.test.ts +171 -0
- package/src/internal/rewards/Rates.ts +110 -0
- package/src/internal/rewards/Read.test.ts +501 -0
- package/src/internal/rewards/Read.ts +476 -0
- package/src/internal/rewards/Runner.checkpoint.test.ts +80 -0
- package/src/internal/rewards/Runner.states.test.ts +188 -0
- package/src/internal/rewards/Runner.test.ts +90 -0
- package/src/internal/rewards/Runner.ts +2229 -0
- package/src/internal/rewards/Signer.test.ts +79 -0
- package/src/internal/rewards/Signer.ts +180 -0
- package/src/internal/rewards/index.ts +14 -0
- package/src/internal/{funding → routes}/Action.test.ts +63 -14
- package/src/internal/{funding → routes}/Action.ts +35 -8
- package/src/internal/{funding → routes}/Catalog.test.ts +3 -3
- package/src/internal/{funding → routes}/Catalog.ts +39 -39
- package/src/internal/{funding → routes}/Chain.test.ts +1 -1
- package/src/internal/{funding → routes}/Chain.ts +11 -11
- package/src/internal/{funding → routes}/Deposit.test.ts +1 -1
- package/src/internal/{funding → routes}/Deposit.ts +93 -45
- package/src/internal/{funding → routes}/DepositAddress.test.ts +11 -3
- package/src/internal/{funding → routes}/DepositAddress.ts +132 -53
- package/src/internal/{funding → routes}/DepositWebhook.test.ts +61 -18
- package/src/internal/{funding → routes}/DepositWebhook.ts +9 -9
- package/src/internal/routes/Economics.test.ts +42 -0
- package/src/internal/routes/Economics.ts +47 -0
- package/src/internal/{funding → routes}/Evidence.test.ts +6 -6
- package/src/internal/{funding → routes}/Evidence.ts +9 -9
- package/src/internal/routes/Observability.test.ts +636 -0
- package/src/internal/routes/Observability.ts +668 -0
- package/src/internal/{funding → routes}/Provider.test.ts +489 -153
- package/src/internal/{funding → routes}/Provider.ts +489 -186
- package/src/internal/{funding → routes}/Reconciliation.local.test.ts +84 -12
- package/src/internal/{funding → routes}/Reconciliation.test.ts +1213 -279
- package/src/internal/{funding → routes}/Reconciliation.ts +501 -203
- package/src/internal/routes/Reconciliation.unattributed.test.ts +250 -0
- package/src/internal/{funding → routes}/Route.ts +7 -7
- package/src/internal/{funding → routes}/SourceObservation.test.ts +13 -14
- package/src/internal/{funding → routes}/SourceObservation.ts +13 -13
- package/src/internal/{funding → routes}/Subsidy.local.test.ts +7 -7
- package/src/internal/routes/Subsidy.test.ts +169 -0
- package/src/internal/{funding → routes}/Subsidy.ts +86 -6
- package/src/internal/{funding → routes}/Token.test.ts +1 -1
- package/src/internal/{funding → routes}/Token.ts +5 -5
- package/src/internal/routes/Transfer.test.ts +1199 -0
- package/src/internal/routes/Transfer.ts +1206 -0
- package/src/internal/routes/TransferReconciliation.test.ts +731 -0
- package/src/internal/routes/TransferReconciliation.ts +527 -0
- package/src/internal/routes/TransferSubsidy.test.ts +172 -0
- package/src/internal/routes/TransferSubsidy.ts +447 -0
- package/src/internal/{funding → routes}/TransferWebhook.test.ts +13 -13
- package/src/internal/{funding → routes}/TransferWebhook.ts +7 -7
- package/src/internal/{funding → routes}/index.test.ts +5 -3
- package/src/internal/{funding → routes}/index.ts +2 -0
- package/src/internal/{funding → routes}/providers/across.ts +16 -16
- package/src/internal/{funding → routes}/providers/index.test.ts +157 -44
- package/src/internal/{funding → routes}/providers/relay.test.ts +224 -32
- package/src/internal/{funding → routes}/providers/relay.ts +228 -121
- package/src/internal/{funding → routes}/providers/rhino.ts +16 -16
- package/src/internal/{funding → routes}/providers/squid.ts +17 -17
- package/src/internal/routes/providers/stargate.test.ts +728 -0
- package/src/internal/routes/providers/stargate.ts +1276 -0
- package/src/internal/{funding → routes}/providers/symbiosis.ts +64 -24
- package/src/internal/webhookDestinations/slack.ts +10 -10
- package/src/providers/index.ts +13 -13
- package/src/server.ts +18 -0
- package/dist/apps/funding/Access.d.ts.map +0 -1
- package/dist/apps/funding/Access.js.map +0 -1
- package/dist/apps/funding/App.js.map +0 -1
- package/dist/apps/funding/Inventory.d.ts.map +0 -1
- package/dist/apps/funding/Inventory.js.map +0 -1
- package/dist/apps/funding/ProviderAttempts.d.ts +0 -5
- package/dist/apps/funding/ProviderAttempts.d.ts.map +0 -1
- package/dist/apps/funding/ProviderAttempts.js +0 -24
- package/dist/apps/funding/ProviderAttempts.js.map +0 -1
- package/dist/apps/funding/index.d.ts +0 -2
- package/dist/apps/funding/index.d.ts.map +0 -1
- package/dist/apps/funding/index.js +0 -2
- package/dist/apps/funding/index.js.map +0 -1
- package/dist/apps/funding/routes/chains.d.ts.map +0 -1
- package/dist/apps/funding/routes/chains.js.map +0 -1
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +0 -1
- package/dist/apps/funding/routes/deposit-addresses.js.map +0 -1
- package/dist/apps/funding/routes/providers.d.ts.map +0 -1
- package/dist/apps/funding/routes/providers.js +0 -57
- package/dist/apps/funding/routes/providers.js.map +0 -1
- package/dist/apps/funding/routes/quotes.d.ts.map +0 -1
- package/dist/apps/funding/routes/quotes.js.map +0 -1
- package/dist/apps/funding/routes/transfers.d.ts.map +0 -1
- package/dist/apps/funding/routes/transfers.js +0 -828
- package/dist/apps/funding/routes/transfers.js.map +0 -1
- package/dist/db/tables/fundingCatalog.d.ts +0 -58
- package/dist/db/tables/fundingCatalog.d.ts.map +0 -1
- package/dist/db/tables/fundingCatalog.js.map +0 -1
- package/dist/db/tables/fundingDepositAddresses.d.ts +0 -192
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +0 -1
- package/dist/db/tables/fundingDepositAddresses.js +0 -235
- package/dist/db/tables/fundingDepositAddresses.js.map +0 -1
- package/dist/db/tables/fundingDepositRequestObservations.d.ts.map +0 -1
- package/dist/db/tables/fundingDepositRequestObservations.js.map +0 -1
- package/dist/db/tables/fundingDeposits.d.ts.map +0 -1
- package/dist/db/tables/fundingDeposits.js +0 -295
- package/dist/db/tables/fundingDeposits.js.map +0 -1
- package/dist/db/tables/fundingIdempotency.d.ts +0 -91
- package/dist/db/tables/fundingIdempotency.d.ts.map +0 -1
- package/dist/db/tables/fundingIdempotency.js +0 -103
- package/dist/db/tables/fundingIdempotency.js.map +0 -1
- package/dist/db/tables/fundingTransferEvents.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferEvents.js.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.d.ts +0 -53
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +0 -1
- package/dist/db/tables/fundingTransferTransactions.js.map +0 -1
- package/dist/db/tables/fundingTransfers.d.ts +0 -99
- package/dist/db/tables/fundingTransfers.d.ts.map +0 -1
- package/dist/db/tables/fundingTransfers.js +0 -110
- package/dist/db/tables/fundingTransfers.js.map +0 -1
- package/dist/internal/funding/Action.d.ts.map +0 -1
- package/dist/internal/funding/Action.js.map +0 -1
- package/dist/internal/funding/Catalog.d.ts.map +0 -1
- package/dist/internal/funding/Catalog.js.map +0 -1
- package/dist/internal/funding/Chain.d.ts.map +0 -1
- package/dist/internal/funding/Chain.js.map +0 -1
- package/dist/internal/funding/Deposit.d.ts.map +0 -1
- package/dist/internal/funding/Deposit.js.map +0 -1
- package/dist/internal/funding/DepositAddress.d.ts.map +0 -1
- package/dist/internal/funding/DepositAddress.js.map +0 -1
- package/dist/internal/funding/DepositWebhook.d.ts.map +0 -1
- package/dist/internal/funding/DepositWebhook.js.map +0 -1
- package/dist/internal/funding/Evidence.d.ts.map +0 -1
- package/dist/internal/funding/Evidence.js.map +0 -1
- package/dist/internal/funding/Provider.d.ts.map +0 -1
- package/dist/internal/funding/Provider.js.map +0 -1
- package/dist/internal/funding/Reconciliation.d.ts.map +0 -1
- package/dist/internal/funding/Reconciliation.js.map +0 -1
- package/dist/internal/funding/Route.d.ts +0 -21
- package/dist/internal/funding/Route.d.ts.map +0 -1
- package/dist/internal/funding/Route.js.map +0 -1
- package/dist/internal/funding/SourceObservation.d.ts.map +0 -1
- package/dist/internal/funding/SourceObservation.js.map +0 -1
- package/dist/internal/funding/Subsidy.d.ts.map +0 -1
- package/dist/internal/funding/Subsidy.js.map +0 -1
- package/dist/internal/funding/Token.d.ts.map +0 -1
- package/dist/internal/funding/Token.js.map +0 -1
- package/dist/internal/funding/Transfer.d.ts.map +0 -1
- package/dist/internal/funding/Transfer.js +0 -462
- package/dist/internal/funding/Transfer.js.map +0 -1
- package/dist/internal/funding/TransferReconciliation.d.ts.map +0 -1
- package/dist/internal/funding/TransferReconciliation.js +0 -192
- package/dist/internal/funding/TransferReconciliation.js.map +0 -1
- package/dist/internal/funding/TransferWebhook.d.ts.map +0 -1
- package/dist/internal/funding/TransferWebhook.js.map +0 -1
- package/dist/internal/funding/index.d.ts.map +0 -1
- package/dist/internal/funding/index.js.map +0 -1
- package/dist/internal/funding/providers/across.d.ts.map +0 -1
- package/dist/internal/funding/providers/across.js.map +0 -1
- package/dist/internal/funding/providers/relay.d.ts.map +0 -1
- package/dist/internal/funding/providers/relay.js.map +0 -1
- package/dist/internal/funding/providers/rhino.d.ts.map +0 -1
- package/dist/internal/funding/providers/rhino.js.map +0 -1
- package/dist/internal/funding/providers/squid.d.ts.map +0 -1
- package/dist/internal/funding/providers/squid.js.map +0 -1
- package/dist/internal/funding/providers/stargate.d.ts.map +0 -1
- package/dist/internal/funding/providers/stargate.js +0 -579
- package/dist/internal/funding/providers/stargate.js.map +0 -1
- package/dist/internal/funding/providers/symbiosis.d.ts.map +0 -1
- package/dist/internal/funding/providers/symbiosis.js.map +0 -1
- package/src/apps/funding/App.test.ts +0 -78
- package/src/apps/funding/App.ts +0 -88
- package/src/apps/funding/ProviderAttempts.ts +0 -26
- package/src/apps/funding/index.ts +0 -1
- package/src/apps/funding/routes/transfers.ts +0 -987
- package/src/db/tables/fundingCatalog.test.ts +0 -122
- package/src/db/tables/fundingCatalog.ts +0 -163
- package/src/db/tables/fundingDepositAddresses.test.ts +0 -608
- package/src/db/tables/fundingDepositAddresses.ts +0 -443
- package/src/db/tables/fundingDeposits.ts +0 -572
- package/src/db/tables/fundingIdempotency.test.ts +0 -182
- package/src/db/tables/fundingIdempotency.ts +0 -180
- package/src/db/tables/fundingTransferTransactions.test.ts +0 -112
- package/src/db/tables/fundingTransfers.test.ts +0 -115
- package/src/db/tables/fundingTransfers.ts +0 -189
- package/src/handlers/internal/multisig.test.ts +0 -818
- package/src/internal/funding/Subsidy.test.ts +0 -75
- package/src/internal/funding/Transfer.test.ts +0 -524
- package/src/internal/funding/Transfer.ts +0 -762
- package/src/internal/funding/TransferReconciliation.test.ts +0 -147
- package/src/internal/funding/TransferReconciliation.ts +0 -264
- package/src/internal/funding/providers/stargate.test.ts +0 -328
- package/src/internal/funding/providers/stargate.ts +0 -856
- /package/dist/apps/{funding → routes}/Inventory.d.ts +0 -0
- /package/src/internal/{funding → routes}/Route.test.ts +0 -0
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import { Hex } from 'ox'
|
|
2
|
+
import * as z from 'zod/mini'
|
|
2
3
|
|
|
3
4
|
import * as Db from '../../db/Db.js'
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as
|
|
5
|
+
import * as RoutesDepositAddresses from '../../db/tables/routesDepositAddresses.js'
|
|
6
|
+
import * as RoutesDepositRequestObservations from '../../db/tables/routesDepositRequestObservations.js'
|
|
7
|
+
import * as RoutesDeposits from '../../db/tables/routesDeposits.js'
|
|
7
8
|
import type * as Metrics from '../../Metrics.js'
|
|
9
|
+
import * as MetricSink from '../MetricSink.js'
|
|
8
10
|
import * as Value from '../Value.js'
|
|
9
11
|
import type * as Webhooks from '../Webhooks.js'
|
|
10
12
|
import * as Deposit from './Deposit.js'
|
|
11
13
|
import * as DepositWebhook from './DepositWebhook.js'
|
|
14
|
+
import * as Observability from './Observability.js'
|
|
12
15
|
import * as Provider from './Provider.js'
|
|
13
16
|
import * as Subsidy from './Subsidy.js'
|
|
14
17
|
|
|
15
18
|
const defaultBatchSize = 25
|
|
16
19
|
const defaultLeaseMs = 2 * 60_000
|
|
17
20
|
const defaultPollIntervalMs = 60_000
|
|
18
|
-
const
|
|
19
|
-
const
|
|
21
|
+
const chainCatchUpFollowUpDelaySeconds = 1
|
|
22
|
+
const chainCatchUpMaximumFollowUpAttempts = 30
|
|
20
23
|
const followUpDelaySeconds = { delivery: 1, provider: 5, settlement: 2 } as const satisfies Record<
|
|
21
24
|
Provider.Webhook.receive.FollowUp['kind'],
|
|
22
25
|
number
|
|
23
26
|
>
|
|
24
27
|
const maximumPages = 100
|
|
25
28
|
const maximumFollowUpAttempts = 6
|
|
29
|
+
const providerMaximumFollowUpAttempts = 24
|
|
26
30
|
const providerFailureStatuses = ['failure'] as const
|
|
27
31
|
const providerRefundStatuses = ['refund', 'refunded'] as const
|
|
32
|
+
const unattributedBatchSize = 25
|
|
28
33
|
|
|
29
34
|
/** Verified token transfer returned by an authoritative chain reader. */
|
|
30
35
|
export type TransferEvidence = {
|
|
@@ -63,9 +68,10 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
63
68
|
const batchSize = options.batchSize ?? defaultBatchSize
|
|
64
69
|
const leaseMs = options.leaseMs ?? defaultLeaseMs
|
|
65
70
|
const pollIntervalMs = options.pollIntervalMs ?? defaultPollIntervalMs
|
|
71
|
+
const recordProviderOperation = MetricSink.routesProviderOperations(options.metrics)
|
|
66
72
|
|
|
67
73
|
const record = (outcome: string, providerId: string, trigger: Deposit.DetectionTrigger) => {
|
|
68
|
-
options.metrics?.count('
|
|
74
|
+
options.metrics?.count('routes_deposit_reconciliation_count', 1, {
|
|
69
75
|
outcome,
|
|
70
76
|
provider: providerId,
|
|
71
77
|
trigger,
|
|
@@ -100,11 +106,20 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
100
106
|
await heartbeat.ready()
|
|
101
107
|
const requests = await listRequests(provider, {
|
|
102
108
|
address: claimed,
|
|
109
|
+
onAttempt: recordProviderOperation,
|
|
103
110
|
requestId: message.requestId,
|
|
104
111
|
signal: options.signal,
|
|
112
|
+
}).catch(async () => {
|
|
113
|
+
// The durable poll owns provider retries; queue redelivery must not advance its backoff again.
|
|
114
|
+
const leaseFailure = await heartbeat.stop()
|
|
115
|
+
if (leaseFailure !== undefined) throw leaseFailure
|
|
116
|
+
await fail(database, claimed, now(), pollIntervalMs)
|
|
117
|
+
record('provider_unavailable', claimed.providerId, trigger)
|
|
118
|
+
return undefined
|
|
105
119
|
})
|
|
120
|
+
if (!requests) return { type: 'provider_unavailable' }
|
|
106
121
|
if (trigger === 'poll')
|
|
107
|
-
await
|
|
122
|
+
await RoutesDepositRequestObservations.observePoll(database, {
|
|
108
123
|
depositAddressId: claimed.id,
|
|
109
124
|
observedAt: now().toISOString(),
|
|
110
125
|
providerRequestIds: requests.requests.map((request) => request.id),
|
|
@@ -137,6 +152,7 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
137
152
|
...requests.pendingRequestIds,
|
|
138
153
|
...(message.requestId ? [message.requestId] : []),
|
|
139
154
|
])
|
|
155
|
+
const sourceRoutesIntervals: Observability.LifecycleInterval[] = []
|
|
140
156
|
let followUpKind: Provider.Webhook.receive.FollowUp['kind'] | undefined
|
|
141
157
|
for (const request of requests.requests) {
|
|
142
158
|
const result = await reconcileRequest(database, {
|
|
@@ -144,6 +160,13 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
144
160
|
metrics: options.metrics,
|
|
145
161
|
onDeposit,
|
|
146
162
|
provider,
|
|
163
|
+
...(options.recordLifecycleInterval
|
|
164
|
+
? {
|
|
165
|
+
recordLifecycleInterval: async (interval) => {
|
|
166
|
+
sourceRoutesIntervals.push(interval)
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
: {}),
|
|
147
170
|
request,
|
|
148
171
|
signal: options.signal,
|
|
149
172
|
subsidies: options.subsidies,
|
|
@@ -159,8 +182,15 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
159
182
|
followUpKind = result.followUp ?? followUpKind ?? 'provider'
|
|
160
183
|
}
|
|
161
184
|
}
|
|
185
|
+
const sourceRoutes = sourceRoutesIntervals.toSorted((left, right) =>
|
|
186
|
+
left.endedAt.localeCompare(right.endedAt),
|
|
187
|
+
)[0]
|
|
188
|
+
if (sourceRoutes) await options.recordLifecycleInterval?.(sourceRoutes)
|
|
189
|
+
const page = await checkpointUnattributed(database, { address: claimed, now: startedAt })
|
|
190
|
+
heartbeat.assert()
|
|
162
191
|
const unattributed = await reconcileUnattributed(database, {
|
|
163
192
|
address: claimed,
|
|
193
|
+
deposits: page.deposits,
|
|
164
194
|
metrics: options.metrics,
|
|
165
195
|
onDeposit,
|
|
166
196
|
provider,
|
|
@@ -172,11 +202,11 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
172
202
|
updated += unattributed.updatedIds.size
|
|
173
203
|
if (!unattributed.terminal)
|
|
174
204
|
followUpKind = unattributed.followUp ?? followUpKind ?? 'provider'
|
|
175
|
-
const awaitsProvider = await
|
|
205
|
+
const awaitsProvider = await RoutesDeposits.hasUnattributed(database, claimed.id)
|
|
176
206
|
if (message.requestId && message.webhookTiming && !webhookUpdateObserved)
|
|
177
207
|
pendingRequestIds.add(message.requestId)
|
|
178
208
|
if (created > 0)
|
|
179
|
-
options.metrics?.count('
|
|
209
|
+
options.metrics?.count('routes_deposit_detection_count', created, {
|
|
180
210
|
provider: claimed.providerId,
|
|
181
211
|
trigger,
|
|
182
212
|
})
|
|
@@ -185,12 +215,12 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
185
215
|
const references = [...depositWebhookReferences.values()]
|
|
186
216
|
await options.dispatchDepositUpdates(references).then(
|
|
187
217
|
(count) =>
|
|
188
|
-
options.metrics?.count('
|
|
218
|
+
options.metrics?.count('routes_deposit_webhook_enqueue_count', count, {
|
|
189
219
|
outcome: 'succeeded',
|
|
190
220
|
provider: claimed.providerId,
|
|
191
221
|
}),
|
|
192
222
|
(cause) => {
|
|
193
|
-
options.metrics?.count('
|
|
223
|
+
options.metrics?.count('routes_deposit_webhook_enqueue_count', references.length, {
|
|
194
224
|
outcome: 'failed',
|
|
195
225
|
provider: claimed.providerId,
|
|
196
226
|
})
|
|
@@ -199,16 +229,21 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
199
229
|
)
|
|
200
230
|
}
|
|
201
231
|
|
|
232
|
+
if (unattributed.errors.length > 0)
|
|
233
|
+
throw new AggregateError(
|
|
234
|
+
unattributed.errors,
|
|
235
|
+
'Unattributed deposit reconciliation failed.',
|
|
236
|
+
)
|
|
202
237
|
const leaseFailure = await heartbeat.stop()
|
|
203
238
|
if (leaseFailure !== undefined) throw leaseFailure
|
|
204
239
|
const completedAt = now()
|
|
205
|
-
const stored = await
|
|
240
|
+
const stored = await RoutesDepositAddresses.completePoll(database, {
|
|
206
241
|
id: claimed.id,
|
|
207
242
|
lastPolledAt: completedAt.toISOString(),
|
|
208
243
|
nextPollAt: new Date(completedAt.getTime() + pollIntervalMs).toISOString(),
|
|
209
244
|
pollLeaseVersion: claimed.pollLeaseVersion,
|
|
210
245
|
providerRequestIds: claimed.providerRequestIds,
|
|
211
|
-
providerState: reconciliationState(
|
|
246
|
+
providerState: reconciliationState(page.address.providerState, {
|
|
212
247
|
pendingRequestIds: [...pendingRequestIds],
|
|
213
248
|
requests,
|
|
214
249
|
...(message.webhookTiming && message.requestId && webhookUpdateObserved
|
|
@@ -233,7 +268,7 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
233
268
|
followUp: followUp.state,
|
|
234
269
|
...(message.requestId ? { requestId: message.requestId } : {}),
|
|
235
270
|
trigger,
|
|
236
|
-
type: '
|
|
271
|
+
type: 'routes:deposit-address:reconcile',
|
|
237
272
|
...(message.webhookTiming && !webhookUpdateObserved
|
|
238
273
|
? { webhookTiming: message.webhookTiming }
|
|
239
274
|
: {}),
|
|
@@ -258,7 +293,7 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
258
293
|
})
|
|
259
294
|
record('completed', claimed.providerId, trigger)
|
|
260
295
|
options.metrics?.histogram(
|
|
261
|
-
'
|
|
296
|
+
'routes_deposit_reconciliation_duration_ms',
|
|
262
297
|
completedAt.getTime() - startedAt.getTime(),
|
|
263
298
|
{ provider: claimed.providerId, trigger },
|
|
264
299
|
)
|
|
@@ -281,7 +316,7 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
281
316
|
let failed = 0
|
|
282
317
|
for (const provider of options.providers) {
|
|
283
318
|
if (!Provider.canListDepositAddressRequests(provider)) continue
|
|
284
|
-
const records = await
|
|
319
|
+
const records = await RoutesDepositAddresses.claimDue(database, {
|
|
285
320
|
leaseUntil,
|
|
286
321
|
limit: Math.max(0, batchSize - claimed),
|
|
287
322
|
now: startedAt.toISOString(),
|
|
@@ -290,7 +325,7 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
290
325
|
for (const address of records) {
|
|
291
326
|
claimed += 1
|
|
292
327
|
options.metrics?.histogram(
|
|
293
|
-
'
|
|
328
|
+
'routes_deposit_poll_lag_ms',
|
|
294
329
|
Math.max(0, startedAt.getTime() - new Date(address.nextPollAt).getTime()),
|
|
295
330
|
{ provider: provider.id },
|
|
296
331
|
)
|
|
@@ -299,7 +334,7 @@ export function createTracker(options: createTracker.Options): createTracker.Tra
|
|
|
299
334
|
addressId: address.id,
|
|
300
335
|
pollLeaseVersion: address.pollLeaseVersion,
|
|
301
336
|
trigger: 'poll',
|
|
302
|
-
type: '
|
|
337
|
+
type: 'routes:deposit-address:reconcile',
|
|
303
338
|
})
|
|
304
339
|
record('enqueued', provider.id, 'poll')
|
|
305
340
|
} catch {
|
|
@@ -328,7 +363,7 @@ export declare namespace createTracker {
|
|
|
328
363
|
message: Provider.Webhook.receive.Dispatchable,
|
|
329
364
|
options?: createTracker.DispatchOptions,
|
|
330
365
|
) => Promise<void>
|
|
331
|
-
/** Stages and dispatches committed
|
|
366
|
+
/** Stages and dispatches committed route deposit webhook updates. */
|
|
332
367
|
dispatchDepositUpdates?:
|
|
333
368
|
| ((references: readonly Webhooks.QueueReference[]) => Promise<number>)
|
|
334
369
|
| undefined
|
|
@@ -340,8 +375,12 @@ export declare namespace createTracker {
|
|
|
340
375
|
now?: (() => Date) | undefined
|
|
341
376
|
/** Delay before a successfully reconciled address is polled again. */
|
|
342
377
|
pollIntervalMs?: number | undefined
|
|
343
|
-
/** Configured
|
|
378
|
+
/** Configured route provider integrations. */
|
|
344
379
|
providers: readonly Provider.Provider[]
|
|
380
|
+
/** Records completed route lifecycle intervals. */
|
|
381
|
+
recordLifecycleInterval?:
|
|
382
|
+
| ((interval: Observability.LifecycleInterval) => Promise<void>)
|
|
383
|
+
| undefined
|
|
345
384
|
/** Optional cancellation signal for provider reads. */
|
|
346
385
|
signal?: AbortSignal | undefined
|
|
347
386
|
/** Optional pathUSD-funded subsidy settler. */
|
|
@@ -377,12 +416,12 @@ type ClaimOptions = {
|
|
|
377
416
|
|
|
378
417
|
async function claim(db: Db.Db, message: Provider.Webhook.receive.Queued, options: ClaimOptions) {
|
|
379
418
|
if (message.pollLeaseVersion === undefined)
|
|
380
|
-
return
|
|
419
|
+
return RoutesDepositAddresses.claim(db, {
|
|
381
420
|
id: message.addressId,
|
|
382
421
|
leaseUntil: options.leaseUntil,
|
|
383
422
|
now: options.now,
|
|
384
423
|
})
|
|
385
|
-
const current = await
|
|
424
|
+
const current = await RoutesDepositAddresses.get(db, message.addressId)
|
|
386
425
|
if (
|
|
387
426
|
!current?.pollLeaseUntil ||
|
|
388
427
|
current.pollLeaseUntil <= options.now ||
|
|
@@ -394,12 +433,12 @@ async function claim(db: Db.Db, message: Provider.Webhook.receive.Queued, option
|
|
|
394
433
|
|
|
395
434
|
async function fail(
|
|
396
435
|
db: Db.Db,
|
|
397
|
-
address:
|
|
436
|
+
address: RoutesDepositAddresses.Record,
|
|
398
437
|
now: Date,
|
|
399
438
|
pollIntervalMs: number,
|
|
400
439
|
) {
|
|
401
440
|
const delay = Math.min(pollIntervalMs * 2 ** address.pollFailureCount, 15 * 60_000)
|
|
402
|
-
return
|
|
441
|
+
return RoutesDepositAddresses.failPoll(db, {
|
|
403
442
|
id: address.id,
|
|
404
443
|
nextPollAt: new Date(now.getTime() + delay).toISOString(),
|
|
405
444
|
pollLeaseVersion: address.pollLeaseVersion,
|
|
@@ -413,14 +452,14 @@ type MaintainLeaseOptions = {
|
|
|
413
452
|
|
|
414
453
|
function maintainLease(
|
|
415
454
|
db: Db.Db,
|
|
416
|
-
address:
|
|
455
|
+
address: RoutesDepositAddresses.Record,
|
|
417
456
|
options: MaintainLeaseOptions,
|
|
418
457
|
) {
|
|
419
458
|
let failure: unknown
|
|
420
459
|
let stopped = false
|
|
421
460
|
const extend = async () => {
|
|
422
461
|
if (stopped || failure !== undefined) return
|
|
423
|
-
const renewed = await
|
|
462
|
+
const renewed = await RoutesDepositAddresses.renewPoll(db, {
|
|
424
463
|
id: address.id,
|
|
425
464
|
leaseUntil: new Date(options.now().getTime() + options.leaseMs).toISOString(),
|
|
426
465
|
pollLeaseVersion: address.pollLeaseVersion,
|
|
@@ -465,7 +504,8 @@ type Requests = {
|
|
|
465
504
|
}
|
|
466
505
|
|
|
467
506
|
type ListRequestsOptions = {
|
|
468
|
-
address:
|
|
507
|
+
address: RoutesDepositAddresses.Record
|
|
508
|
+
onAttempt: (result: Provider.ProviderAttemptResult) => void
|
|
469
509
|
requestId?: string | undefined
|
|
470
510
|
signal?: AbortSignal | undefined
|
|
471
511
|
}
|
|
@@ -482,9 +522,19 @@ async function listRequests(
|
|
|
482
522
|
const requests: Provider.listDepositAddressRequests.ReturnType['requests'][number][] = []
|
|
483
523
|
let continuation: string | undefined
|
|
484
524
|
for (let page = 0; page < maximumPages; page++) {
|
|
485
|
-
const result = await
|
|
486
|
-
|
|
487
|
-
|
|
525
|
+
const result = await Provider.observe(
|
|
526
|
+
provider,
|
|
527
|
+
() =>
|
|
528
|
+
provider.listDepositAddressRequests(
|
|
529
|
+
{
|
|
530
|
+
address: options.address.address,
|
|
531
|
+
...(continuation ? { continuation } : {}),
|
|
532
|
+
destinationToken: options.address.snapshot.destinationToken,
|
|
533
|
+
sourceToken: options.address.snapshot.sourceToken,
|
|
534
|
+
},
|
|
535
|
+
options.signal ?? new AbortController().signal,
|
|
536
|
+
),
|
|
537
|
+
{ onAttempt: options.onAttempt, operation: 'listDepositAddressRequests' },
|
|
488
538
|
)
|
|
489
539
|
requests.push(
|
|
490
540
|
...result.requests.filter(
|
|
@@ -509,9 +559,19 @@ async function listRequests(
|
|
|
509
559
|
...(options.requestId ? [options.requestId] : []),
|
|
510
560
|
])) {
|
|
511
561
|
if (observed.has(requestId)) continue
|
|
512
|
-
const result = await
|
|
513
|
-
|
|
514
|
-
|
|
562
|
+
const result = await Provider.observe(
|
|
563
|
+
provider,
|
|
564
|
+
() =>
|
|
565
|
+
provider.listDepositAddressRequests(
|
|
566
|
+
{
|
|
567
|
+
address: options.address.address,
|
|
568
|
+
destinationToken: options.address.snapshot.destinationToken,
|
|
569
|
+
requestId,
|
|
570
|
+
sourceToken: options.address.snapshot.sourceToken,
|
|
571
|
+
},
|
|
572
|
+
options.signal ?? new AbortController().signal,
|
|
573
|
+
),
|
|
574
|
+
{ onAttempt: options.onAttempt, operation: 'listDepositAddressRequests' },
|
|
515
575
|
)
|
|
516
576
|
requests.push(...result.requests)
|
|
517
577
|
}
|
|
@@ -544,7 +604,7 @@ type HighWater = {
|
|
|
544
604
|
updatedAt?: string | undefined
|
|
545
605
|
}
|
|
546
606
|
|
|
547
|
-
function readHighWater(state:
|
|
607
|
+
function readHighWater(state: RoutesDepositAddresses.Record['providerState']): HighWater {
|
|
548
608
|
if (!state || typeof state !== 'object') return { pendingRequestIds: [], requestIds: [] }
|
|
549
609
|
const reconciliation = state['reconciliation']
|
|
550
610
|
if (!reconciliation || typeof reconciliation !== 'object')
|
|
@@ -587,7 +647,7 @@ type ReconciliationStateOptions = {
|
|
|
587
647
|
}
|
|
588
648
|
|
|
589
649
|
function reconciliationState(
|
|
590
|
-
state:
|
|
650
|
+
state: RoutesDepositAddresses.Record['providerState'],
|
|
591
651
|
options: ReconciliationStateOptions,
|
|
592
652
|
) {
|
|
593
653
|
const current = state && typeof state === 'object' ? state : {}
|
|
@@ -611,20 +671,20 @@ function reconciliationState(
|
|
|
611
671
|
}
|
|
612
672
|
|
|
613
673
|
type ObservedSourceTransaction = {
|
|
614
|
-
deposits:
|
|
674
|
+
deposits: RoutesDeposits.Record[]
|
|
615
675
|
transactionHash: string
|
|
616
676
|
transfers: readonly TransferEvidence[]
|
|
617
677
|
}
|
|
618
678
|
|
|
619
679
|
type VerifiedDeposit = {
|
|
620
|
-
deposit:
|
|
680
|
+
deposit: RoutesDeposits.Record
|
|
621
681
|
required: bigint
|
|
622
682
|
source: TransferEvidence
|
|
623
683
|
sourceAmount: bigint
|
|
624
684
|
}
|
|
625
685
|
|
|
626
686
|
type ReconcileDeliveryOptions = {
|
|
627
|
-
address:
|
|
687
|
+
address: RoutesDepositAddresses.Record
|
|
628
688
|
metrics?: Metrics.Metrics | undefined
|
|
629
689
|
onDeposit?: reconcileRequest.Options['onDeposit'] | undefined
|
|
630
690
|
provider?: Provider.Provider | undefined
|
|
@@ -651,53 +711,102 @@ async function observeProviderDelivery(options: ReconcileDeliveryOptions) {
|
|
|
651
711
|
)
|
|
652
712
|
return undefined
|
|
653
713
|
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
714
|
+
const provider = options.provider
|
|
715
|
+
const recordProviderOperation = MetricSink.routesProviderOperations(options.metrics)
|
|
716
|
+
const result = await Provider.observe(
|
|
717
|
+
provider,
|
|
718
|
+
() =>
|
|
719
|
+
provider.observeDepositAddressRequest(
|
|
720
|
+
{
|
|
721
|
+
address: options.address.address,
|
|
722
|
+
destinationChain: options.address.snapshot.destinationChain,
|
|
723
|
+
destinationToken: options.address.providerOutputToken,
|
|
724
|
+
providerState: entry.deposit.providerState ?? undefined,
|
|
725
|
+
recipient: options.address.recipient,
|
|
726
|
+
refundAddress: options.address.refundAddress,
|
|
727
|
+
...(options.request ? { request: options.request } : {}),
|
|
728
|
+
source: entry.source,
|
|
729
|
+
sourceChain: options.address.snapshot.sourceChain,
|
|
730
|
+
sourceToken: options.address.snapshot.sourceToken,
|
|
731
|
+
},
|
|
732
|
+
options.signal ?? new AbortController().signal,
|
|
733
|
+
),
|
|
734
|
+
{ onAttempt: recordProviderOperation, operation: 'observeDepositAddressRequest' },
|
|
735
|
+
).catch((cause) => {
|
|
736
|
+
if (options.signal?.aborted) throw cause
|
|
737
|
+
return undefined
|
|
738
|
+
})
|
|
739
|
+
options.metrics?.count('routes_deposit_delivery_observation_count', 1, {
|
|
675
740
|
outcome: result?.type ?? 'failed',
|
|
676
741
|
provider: options.address.providerId,
|
|
677
742
|
})
|
|
678
743
|
return result
|
|
679
744
|
}
|
|
680
745
|
|
|
746
|
+
async function checkpointUnattributed(db: Db.Db, options: checkpointUnattributed.Options) {
|
|
747
|
+
const parsed = z.safeParse(
|
|
748
|
+
z.object({
|
|
749
|
+
before: z.iso.datetime(),
|
|
750
|
+
cursor: z.object({ createdAt: z.iso.datetime(), id: z.string() }),
|
|
751
|
+
}),
|
|
752
|
+
options.address.providerState?.['unattributed'],
|
|
753
|
+
)
|
|
754
|
+
const before = parsed.success ? parsed.data.before : options.now.toISOString()
|
|
755
|
+
const deposits = await RoutesDeposits.listUnattributed(db, {
|
|
756
|
+
before,
|
|
757
|
+
cursor: parsed.success ? parsed.data.cursor : undefined,
|
|
758
|
+
depositAddressId: options.address.id,
|
|
759
|
+
limit: unattributedBatchSize,
|
|
760
|
+
})
|
|
761
|
+
if (!parsed.success && deposits.length < unattributedBatchSize)
|
|
762
|
+
return { address: options.address, deposits }
|
|
763
|
+
const last = deposits.at(-1)
|
|
764
|
+
// Checkpoint attempts before RPC work so failures cannot pin a page. A fixed boundary lets old rows recur despite new arrivals.
|
|
765
|
+
const address = await RoutesDepositAddresses.checkpointPoll(db, {
|
|
766
|
+
id: options.address.id,
|
|
767
|
+
pollLeaseVersion: options.address.pollLeaseVersion,
|
|
768
|
+
providerState: {
|
|
769
|
+
...options.address.providerState,
|
|
770
|
+
unattributed:
|
|
771
|
+
deposits.length === unattributedBatchSize && last
|
|
772
|
+
? { before, cursor: { createdAt: last.createdAt, id: last.id } }
|
|
773
|
+
: undefined,
|
|
774
|
+
},
|
|
775
|
+
})
|
|
776
|
+
if (!address) throw new StaleLeaseError()
|
|
777
|
+
return { address, deposits }
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
declare namespace checkpointUnattributed {
|
|
781
|
+
type Options = {
|
|
782
|
+
address: RoutesDepositAddresses.Record
|
|
783
|
+
now: Date
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
681
787
|
async function reconcileUnattributed(db: Db.Db, options: reconcileUnattributed.Options) {
|
|
682
|
-
const deposits =
|
|
683
|
-
if (deposits.length === 0) return { terminal: true, updatedIds: new Set<string>() }
|
|
684
|
-
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
788
|
+
const { deposits } = options
|
|
789
|
+
if (deposits.length === 0) return { errors: [], terminal: true, updatedIds: new Set<string>() }
|
|
790
|
+
|
|
791
|
+
const sources = await Promise.allSettled(
|
|
792
|
+
unique(deposits.map((deposit) => deposit.sourceTransactionHash)).map(
|
|
793
|
+
async (transactionHash) =>
|
|
794
|
+
[
|
|
795
|
+
transactionHash,
|
|
796
|
+
await options.verifyTransfers({
|
|
797
|
+
chain: options.address.snapshot.sourceChain,
|
|
798
|
+
recipient: options.address.address,
|
|
799
|
+
token: options.address.snapshot.sourceToken,
|
|
690
800
|
transactionHash,
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
recipient: options.address.address,
|
|
694
|
-
token: options.address.snapshot.sourceToken,
|
|
695
|
-
transactionHash,
|
|
696
|
-
}),
|
|
697
|
-
] as const,
|
|
698
|
-
),
|
|
801
|
+
}),
|
|
802
|
+
] as const,
|
|
699
803
|
),
|
|
700
804
|
)
|
|
805
|
+
const errors: unknown[] = []
|
|
806
|
+
const transfersByTransaction = new Map<string, readonly TransferEvidence[]>()
|
|
807
|
+
for (const result of sources)
|
|
808
|
+
if (result.status === 'fulfilled') transfersByTransaction.set(...result.value)
|
|
809
|
+
else errors.push(result.reason)
|
|
701
810
|
let followUp: reconcileRequest.ReturnType['followUp']
|
|
702
811
|
let terminal = true
|
|
703
812
|
const updatedIds = new Set<string>()
|
|
@@ -723,20 +832,30 @@ async function reconcileUnattributed(db: Db.Db, options: reconcileUnattributed.O
|
|
|
723
832
|
sourceAmount: BigInt(source.amount),
|
|
724
833
|
},
|
|
725
834
|
],
|
|
835
|
+
}).catch((cause: unknown) => {
|
|
836
|
+
errors.push(cause)
|
|
837
|
+
return undefined
|
|
726
838
|
})
|
|
839
|
+
if (!delivery) {
|
|
840
|
+
terminal = false
|
|
841
|
+
continue
|
|
842
|
+
}
|
|
727
843
|
if (delivery.followUp === 'delivery' || !followUp) followUp = delivery.followUp
|
|
728
844
|
if (!delivery.terminal) terminal = false
|
|
729
845
|
for (const id of delivery.updatedIds) updatedIds.add(id)
|
|
730
846
|
}
|
|
731
847
|
return {
|
|
732
848
|
...(followUp ? { followUp } : {}),
|
|
849
|
+
errors,
|
|
733
850
|
terminal,
|
|
734
851
|
updatedIds,
|
|
735
852
|
}
|
|
736
853
|
}
|
|
737
854
|
|
|
738
855
|
declare namespace reconcileUnattributed {
|
|
739
|
-
type Options = Omit<ReconcileDeliveryOptions, 'request' | 'verified'>
|
|
856
|
+
type Options = Omit<ReconcileDeliveryOptions, 'request' | 'verified'> & {
|
|
857
|
+
deposits: readonly RoutesDeposits.Record[]
|
|
858
|
+
}
|
|
740
859
|
}
|
|
741
860
|
|
|
742
861
|
/** Reconciles one provider request against verified chain evidence. */
|
|
@@ -745,12 +864,12 @@ export async function reconcileRequest(
|
|
|
745
864
|
options: reconcileRequest.Options,
|
|
746
865
|
): Promise<reconcileRequest.ReturnType> {
|
|
747
866
|
const trigger = options.trigger ?? 'poll'
|
|
748
|
-
const observation = await
|
|
867
|
+
const observation = await RoutesDepositRequestObservations.get(db, {
|
|
749
868
|
depositAddressId: options.address.id,
|
|
750
869
|
providerRequestId: options.request.id,
|
|
751
870
|
})
|
|
752
871
|
if (observation)
|
|
753
|
-
await
|
|
872
|
+
await RoutesDeposits.recordRequestObservation(db, {
|
|
754
873
|
depositAddressId: observation.depositAddressId,
|
|
755
874
|
...(observation.pollObservedAt ? { pollObservedAt: observation.pollObservedAt } : {}),
|
|
756
875
|
providerRequestId: observation.providerRequestId,
|
|
@@ -762,16 +881,17 @@ export async function reconcileRequest(
|
|
|
762
881
|
const observed: ObservedSourceTransaction[] = []
|
|
763
882
|
// Persist provider observations first so transient chain failures do not hide acknowledged deposits.
|
|
764
883
|
for (const transactionHash of unique(options.request.sourceTransactionHashes)) {
|
|
765
|
-
const
|
|
884
|
+
const createdBefore = created
|
|
885
|
+
const deposits = await RoutesDeposits.withSourceTransaction(db, {
|
|
766
886
|
depositAddressId: options.address.id,
|
|
767
|
-
fn: async (tx): Promise<
|
|
768
|
-
let records = await
|
|
887
|
+
fn: async (tx): Promise<RoutesDeposits.Record[]> => {
|
|
888
|
+
let records = await RoutesDeposits.listByProviderObservation(tx, {
|
|
769
889
|
depositAddressId: options.address.id,
|
|
770
890
|
providerRequestId: options.request.id,
|
|
771
891
|
sourceTransactionHash: transactionHash,
|
|
772
892
|
})
|
|
773
893
|
if (records.length === 0)
|
|
774
|
-
records = await
|
|
894
|
+
records = await RoutesDeposits.listBySourceTransaction(tx, {
|
|
775
895
|
depositAddressId: options.address.id,
|
|
776
896
|
sourceTransactionHash: transactionHash,
|
|
777
897
|
})
|
|
@@ -803,6 +923,8 @@ export async function reconcileRequest(
|
|
|
803
923
|
},
|
|
804
924
|
sourceTransactionHash: transactionHash,
|
|
805
925
|
})
|
|
926
|
+
if (created > createdBefore)
|
|
927
|
+
Observability.recordDeposit(options.metrics, { record: deposits[0]! })
|
|
806
928
|
observed.push({ deposits, transactionHash, transfers: [] })
|
|
807
929
|
}
|
|
808
930
|
|
|
@@ -877,6 +999,7 @@ export async function reconcileRequest(
|
|
|
877
999
|
? { webhookReceivedAt: observation.webhookReceivedAt }
|
|
878
1000
|
: {}),
|
|
879
1001
|
})
|
|
1002
|
+
Observability.recordDeposit(options.metrics, { record: deposit })
|
|
880
1003
|
source.deposits.push(deposit)
|
|
881
1004
|
created += 1
|
|
882
1005
|
}
|
|
@@ -885,9 +1008,11 @@ export async function reconcileRequest(
|
|
|
885
1008
|
deposit.providerRequestId === null ||
|
|
886
1009
|
!deposit.providerRequestIds.includes(options.request.id)
|
|
887
1010
|
) {
|
|
888
|
-
const result = await transitionDeposit(
|
|
889
|
-
|
|
890
|
-
|
|
1011
|
+
const result = await transitionDeposit(db, {
|
|
1012
|
+
current: deposit,
|
|
1013
|
+
metrics: options.metrics,
|
|
1014
|
+
onDeposit: options.onDeposit,
|
|
1015
|
+
transition: {
|
|
891
1016
|
expectedVersion: deposit.version,
|
|
892
1017
|
id: deposit.id,
|
|
893
1018
|
providerRequestId: options.request.id,
|
|
@@ -902,8 +1027,7 @@ export async function reconcileRequest(
|
|
|
902
1027
|
sourceTransferIndex: transfer.transferIndex,
|
|
903
1028
|
status: deposit.status === 'detected' ? 'bridging' : deposit.status,
|
|
904
1029
|
},
|
|
905
|
-
|
|
906
|
-
)
|
|
1030
|
+
})
|
|
907
1031
|
if (result.type === 'applied') {
|
|
908
1032
|
deposit = result.record
|
|
909
1033
|
updatedIds.add(deposit.id)
|
|
@@ -916,6 +1040,18 @@ export async function reconcileRequest(
|
|
|
916
1040
|
if (!sourceEvidenceComplete) {
|
|
917
1041
|
return { created, terminal: false, updated: updatedIds.size }
|
|
918
1042
|
}
|
|
1043
|
+
if (options.recordLifecycleInterval) {
|
|
1044
|
+
const first = await RoutesDeposits.getFirstByAddress(db, options.address.id)
|
|
1045
|
+
if (
|
|
1046
|
+
first &&
|
|
1047
|
+
first.providerRequestId === options.request.id &&
|
|
1048
|
+
updatedIds.has(first.id) &&
|
|
1049
|
+
verified.some(({ deposit }) => deposit.id === first.id)
|
|
1050
|
+
)
|
|
1051
|
+
await options.recordLifecycleInterval(
|
|
1052
|
+
Observability.depositAddressSourceRoutesInterval(options),
|
|
1053
|
+
)
|
|
1054
|
+
}
|
|
919
1055
|
const recovery = await reconcileProviderRecovery(db, { ...options, verified })
|
|
920
1056
|
if (recovery) {
|
|
921
1057
|
for (const id of recovery.updatedIds) updatedIds.add(id)
|
|
@@ -940,15 +1076,19 @@ export declare namespace reconcileRequest {
|
|
|
940
1076
|
/** Provider request, address, and settlement dependencies. */
|
|
941
1077
|
type Options = {
|
|
942
1078
|
/** Reusable deposit address attributed by the provider. */
|
|
943
|
-
address:
|
|
1079
|
+
address: RoutesDepositAddresses.Record
|
|
944
1080
|
/** Optional bounded operational metrics sink. */
|
|
945
1081
|
metrics?: Metrics.Metrics | undefined
|
|
946
1082
|
/** Observes the latest committed form of each verified deposit. */
|
|
947
1083
|
onDeposit?:
|
|
948
|
-
| ((deposit:
|
|
1084
|
+
| ((deposit: RoutesDeposits.Record, references: readonly Webhooks.QueueReference[]) => void)
|
|
949
1085
|
| undefined
|
|
950
1086
|
/** Provider integration that discovered the request. */
|
|
951
1087
|
provider?: Provider.Provider | undefined
|
|
1088
|
+
/** Records completed route lifecycle intervals. */
|
|
1089
|
+
recordLifecycleInterval?:
|
|
1090
|
+
| ((interval: Observability.LifecycleInterval) => Promise<void>)
|
|
1091
|
+
| undefined
|
|
952
1092
|
/** Provider request containing discovered chain transactions. */
|
|
953
1093
|
request: Provider.listDepositAddressRequests.ReturnType['requests'][number]
|
|
954
1094
|
/** Abort signal forwarded to provider delivery observation. */
|
|
@@ -976,15 +1116,33 @@ export declare namespace reconcileRequest {
|
|
|
976
1116
|
|
|
977
1117
|
async function transitionDeposit(
|
|
978
1118
|
db: Db.Db,
|
|
979
|
-
options:
|
|
980
|
-
onDeposit: reconcileRequest.Options['onDeposit'],
|
|
1119
|
+
options: transitionDeposit.Options,
|
|
981
1120
|
): Promise<Deposit.transition.Result> {
|
|
982
|
-
const committed = await DepositWebhook.transition(db,
|
|
983
|
-
|
|
984
|
-
|
|
1121
|
+
const committed = await DepositWebhook.transition(db, {
|
|
1122
|
+
...options.transition,
|
|
1123
|
+
...(options.providerEvidenceComplete ? { providerDeliveredAt: new Date().toISOString() } : {}),
|
|
1124
|
+
})
|
|
1125
|
+
if (committed.result.type === 'applied') {
|
|
1126
|
+
Observability.recordDeposit(options.metrics, {
|
|
1127
|
+
previous: options.current,
|
|
1128
|
+
...(options.providerEvidenceComplete ? { providerEvidenceComplete: true } : {}),
|
|
1129
|
+
record: committed.result.record,
|
|
1130
|
+
})
|
|
1131
|
+
options.onDeposit?.(committed.result.record, committed.references)
|
|
1132
|
+
}
|
|
985
1133
|
return committed.result
|
|
986
1134
|
}
|
|
987
1135
|
|
|
1136
|
+
declare namespace transitionDeposit {
|
|
1137
|
+
type Options = {
|
|
1138
|
+
current: RoutesDeposits.Record
|
|
1139
|
+
metrics?: Metrics.Metrics | undefined
|
|
1140
|
+
onDeposit: reconcileRequest.Options['onDeposit']
|
|
1141
|
+
providerEvidenceComplete?: boolean | undefined
|
|
1142
|
+
transition: Deposit.transition.Options
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
|
|
988
1146
|
async function reconcileProviderRecovery(db: Db.Db, options: ReconcileDeliveryOptions) {
|
|
989
1147
|
const failed = (providerFailureStatuses as readonly string[]).includes(
|
|
990
1148
|
options.request?.status ?? '',
|
|
@@ -1054,9 +1212,11 @@ async function reconcileProviderRecovery(db: Db.Db, options: ReconcileDeliveryOp
|
|
|
1054
1212
|
if (Deposit.isTerminal(entry.deposit.status)) continue
|
|
1055
1213
|
let deposit = entry.deposit
|
|
1056
1214
|
if (deposit.status !== 'refunding') {
|
|
1057
|
-
const result = await transitionDeposit(
|
|
1058
|
-
|
|
1059
|
-
|
|
1215
|
+
const result = await transitionDeposit(db, {
|
|
1216
|
+
current: deposit,
|
|
1217
|
+
metrics: options.metrics,
|
|
1218
|
+
onDeposit: options.onDeposit,
|
|
1219
|
+
transition: {
|
|
1060
1220
|
expectedVersion: deposit.version,
|
|
1061
1221
|
id: deposit.id,
|
|
1062
1222
|
providerTransactionHashes: unique([
|
|
@@ -1065,8 +1225,7 @@ async function reconcileProviderRecovery(db: Db.Db, options: ReconcileDeliveryOp
|
|
|
1065
1225
|
]),
|
|
1066
1226
|
status: 'refunding',
|
|
1067
1227
|
},
|
|
1068
|
-
|
|
1069
|
-
)
|
|
1228
|
+
})
|
|
1070
1229
|
if (result.type === 'applied') {
|
|
1071
1230
|
deposit = result.record
|
|
1072
1231
|
updatedIds.add(deposit.id)
|
|
@@ -1078,9 +1237,11 @@ async function reconcileProviderRecovery(db: Db.Db, options: ReconcileDeliveryOp
|
|
|
1078
1237
|
terminal = false
|
|
1079
1238
|
continue
|
|
1080
1239
|
}
|
|
1081
|
-
const result = await transitionDeposit(
|
|
1082
|
-
|
|
1083
|
-
|
|
1240
|
+
const result = await transitionDeposit(db, {
|
|
1241
|
+
current: deposit,
|
|
1242
|
+
metrics: options.metrics,
|
|
1243
|
+
onDeposit: options.onDeposit,
|
|
1244
|
+
transition: {
|
|
1084
1245
|
expectedVersion: deposit.version,
|
|
1085
1246
|
id: deposit.id,
|
|
1086
1247
|
snapshot: {
|
|
@@ -1094,8 +1255,7 @@ async function reconcileProviderRecovery(db: Db.Db, options: ReconcileDeliveryOp
|
|
|
1094
1255
|
},
|
|
1095
1256
|
status: 'refunded',
|
|
1096
1257
|
},
|
|
1097
|
-
|
|
1098
|
-
)
|
|
1258
|
+
})
|
|
1099
1259
|
if (result.type === 'applied') updatedIds.add(deposit.id)
|
|
1100
1260
|
else if (result.type !== 'stale' || !Deposit.isTerminal(result.current.status)) terminal = false
|
|
1101
1261
|
}
|
|
@@ -1106,7 +1266,7 @@ async function reconcileProviderRecovery(db: Db.Db, options: ReconcileDeliveryOp
|
|
|
1106
1266
|
if (failed) return 'provider_failed'
|
|
1107
1267
|
return 'pending'
|
|
1108
1268
|
})()
|
|
1109
|
-
options.metrics?.count('
|
|
1269
|
+
options.metrics?.count('routes_deposit_refund_count', 1, {
|
|
1110
1270
|
outcome,
|
|
1111
1271
|
provider: options.address.providerId,
|
|
1112
1272
|
})
|
|
@@ -1121,7 +1281,14 @@ async function reconcileDelivery(db: Db.Db, options: ReconcileDeliveryOptions) {
|
|
|
1121
1281
|
let followUp: reconcileRequest.ReturnType['followUp']
|
|
1122
1282
|
let terminal = true
|
|
1123
1283
|
const updatedIds = new Set<string>()
|
|
1124
|
-
|
|
1284
|
+
const allTerminal = options.verified.every((entry) => Deposit.isTerminal(entry.deposit.status))
|
|
1285
|
+
// Providers can publish sponsorship after destination finality, so terminal rows
|
|
1286
|
+
// remain eligible for a bounded metadata follow-up.
|
|
1287
|
+
if (
|
|
1288
|
+
allTerminal &&
|
|
1289
|
+
(!options.address.snapshot.subsidize ||
|
|
1290
|
+
options.verified.some((entry) => entry.deposit.providerSubsidy))
|
|
1291
|
+
)
|
|
1125
1292
|
return { terminal, updatedIds }
|
|
1126
1293
|
const deliveryObservation = await observeProviderDelivery(options)
|
|
1127
1294
|
if (deliveryObservation?.type === 'pending') followUp = 'delivery'
|
|
@@ -1152,6 +1319,36 @@ async function reconcileDelivery(db: Db.Db, options: ReconcileDeliveryOptions) {
|
|
|
1152
1319
|
0n,
|
|
1153
1320
|
)
|
|
1154
1321
|
const totalRequired = options.verified.reduce((total, entry) => total + entry.required, 0n)
|
|
1322
|
+
const providerSubsidy =
|
|
1323
|
+
options.request?.subsidy ??
|
|
1324
|
+
(providerEvidenceComplete && deliveryObservation?.type === 'verified'
|
|
1325
|
+
? deliveryObservation.subsidy
|
|
1326
|
+
: undefined)
|
|
1327
|
+
// Providers report one subsidy per request, so attribute it to the first verified transfer.
|
|
1328
|
+
const providerSubsidyDepositId = providerSubsidy ? options.verified[0]?.deposit.id : undefined
|
|
1329
|
+
if (allTerminal) {
|
|
1330
|
+
if (!providerEvidenceComplete || !providerSubsidy)
|
|
1331
|
+
return { ...(followUp ? { followUp } : {}), terminal: false, updatedIds }
|
|
1332
|
+
const deposit = options.verified.find(
|
|
1333
|
+
(entry) => entry.deposit.id === providerSubsidyDepositId,
|
|
1334
|
+
)?.deposit
|
|
1335
|
+
if (!deposit || deposit.providerSubsidy) return { terminal, updatedIds }
|
|
1336
|
+
const result = await transitionDeposit(db, {
|
|
1337
|
+
current: deposit,
|
|
1338
|
+
metrics: options.metrics,
|
|
1339
|
+
onDeposit: options.onDeposit,
|
|
1340
|
+
transition: {
|
|
1341
|
+
expectedVersion: deposit.version,
|
|
1342
|
+
id: deposit.id,
|
|
1343
|
+
providerSubsidy,
|
|
1344
|
+
},
|
|
1345
|
+
})
|
|
1346
|
+
if (result.type === 'applied') updatedIds.add(deposit.id)
|
|
1347
|
+
return {
|
|
1348
|
+
terminal: result.type !== 'stale' || Boolean(result.current.providerSubsidy),
|
|
1349
|
+
updatedIds,
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1155
1352
|
let allocated = 0n
|
|
1156
1353
|
let cumulativeRequired = 0n
|
|
1157
1354
|
|
|
@@ -1165,94 +1362,144 @@ async function reconcileDelivery(db: Db.Db, options: ReconcileDeliveryOptions) {
|
|
|
1165
1362
|
const { deposit } = entry
|
|
1166
1363
|
if (Deposit.isTerminal(deposit.status)) continue
|
|
1167
1364
|
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1365
|
+
const prepare = async (database: Db.Db) => {
|
|
1366
|
+
const settlement = await reconcileSubsidy(database, {
|
|
1367
|
+
address: options.address,
|
|
1368
|
+
delivered,
|
|
1369
|
+
deposit,
|
|
1370
|
+
providerEvidenceComplete,
|
|
1371
|
+
required,
|
|
1372
|
+
sourceAmount,
|
|
1373
|
+
subsidies: options.subsidies,
|
|
1374
|
+
verifyTransfers: options.verifyTransfers,
|
|
1375
|
+
})
|
|
1376
|
+
const destinationAmount = Value.tokenAmount({
|
|
1377
|
+
baseUnits: delivered + settlement.delivered,
|
|
1378
|
+
currency: options.address.snapshot.destinationToken.currency,
|
|
1379
|
+
decimals: options.address.snapshot.destinationToken.decimals,
|
|
1380
|
+
})
|
|
1381
|
+
const destinationAmountRequired = (() => {
|
|
1382
|
+
if (options.address.snapshot.subsidize)
|
|
1383
|
+
return Value.tokenAmount({
|
|
1384
|
+
baseUnits: required,
|
|
1385
|
+
currency: options.address.snapshot.destinationToken.currency,
|
|
1386
|
+
decimals: options.address.snapshot.destinationToken.decimals,
|
|
1387
|
+
})
|
|
1388
|
+
if (settlement.status === 'completed') return destinationAmount
|
|
1389
|
+
return undefined
|
|
1390
|
+
})()
|
|
1391
|
+
return {
|
|
1392
|
+
settlement,
|
|
1393
|
+
transition: {
|
|
1394
|
+
expectedVersion: deposit.version,
|
|
1395
|
+
id: deposit.id,
|
|
1396
|
+
...(delivered > 0n
|
|
1397
|
+
? {
|
|
1398
|
+
providerOutputAmount: Value.tokenAmount({
|
|
1399
|
+
baseUnits: delivered,
|
|
1400
|
+
currency: options.address.providerOutputToken.currency,
|
|
1401
|
+
decimals: options.address.providerOutputToken.decimals,
|
|
1402
|
+
}),
|
|
1403
|
+
}
|
|
1404
|
+
: {}),
|
|
1405
|
+
...(providerEvidenceComplete ? { providerDeliveredAt: new Date().toISOString() } : {}),
|
|
1406
|
+
...(providerSubsidy && deposit.id === providerSubsidyDepositId
|
|
1407
|
+
? { providerSubsidy }
|
|
1408
|
+
: {}),
|
|
1409
|
+
providerRequestIds: options.request
|
|
1410
|
+
? unique([...deposit.providerRequestIds, options.request.id])
|
|
1411
|
+
: deposit.providerRequestIds,
|
|
1412
|
+
...(deliveryObservation?.providerState
|
|
1413
|
+
? {
|
|
1414
|
+
providerState: {
|
|
1415
|
+
...deposit.providerState,
|
|
1416
|
+
...deliveryObservation.providerState,
|
|
1417
|
+
},
|
|
1418
|
+
}
|
|
1419
|
+
: {}),
|
|
1420
|
+
providerTransactionHashes: unique([
|
|
1421
|
+
...deposit.providerTransactionHashes,
|
|
1422
|
+
...providerTransactionHashes,
|
|
1423
|
+
...(deliveryObservation?.providerTransactionHashes ?? []),
|
|
1424
|
+
]),
|
|
1425
|
+
...(settlement.settlementTransaction
|
|
1426
|
+
? { settlementTransaction: settlement.settlementTransaction }
|
|
1427
|
+
: {}),
|
|
1428
|
+
...(settlement.settlementTransactionHash
|
|
1429
|
+
? { settlementTransactionHash: settlement.settlementTransactionHash }
|
|
1430
|
+
: {}),
|
|
1431
|
+
snapshot: {
|
|
1432
|
+
...deposit.snapshot,
|
|
1433
|
+
...(delivered + settlement.delivered > 0n ? { destinationAmount } : {}),
|
|
1434
|
+
...(destinationAmountRequired ? { destinationAmountRequired } : {}),
|
|
1435
|
+
destinationTransactionHashes: unique([
|
|
1436
|
+
...(deposit.snapshot.destinationTransactionHashes ?? []),
|
|
1437
|
+
...destinationTransfers.map((evidence) => evidence.transactionHash),
|
|
1438
|
+
...settlement.destinationTransactionHashes,
|
|
1439
|
+
]),
|
|
1440
|
+
},
|
|
1441
|
+
status: settlement.status,
|
|
1442
|
+
...(settlement.statusReason ? { statusReason: settlement.statusReason } : {}),
|
|
1443
|
+
...(settlement.subsidyAmount ? { subsidyAmount: settlement.subsidyAmount } : {}),
|
|
1444
|
+
...(settlement.tempoGasPaid ? { tempoGasPaid: settlement.tempoGasPaid } : {}),
|
|
1445
|
+
},
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
const { committed, settlement } = await (async () => {
|
|
1449
|
+
if (!options.address.snapshot.subsidize) {
|
|
1450
|
+
const prepared = await prepare(db)
|
|
1451
|
+
return {
|
|
1452
|
+
committed: await DepositWebhook.transition(db, prepared.transition),
|
|
1453
|
+
settlement: prepared.settlement,
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
return RoutesDeposits.withSubsidySettlement(db, {
|
|
1457
|
+
fn: async (tx) => {
|
|
1458
|
+
const prepared = await prepare(tx)
|
|
1459
|
+
const result = await Deposit.transition(tx, prepared.transition)
|
|
1460
|
+
const staged =
|
|
1461
|
+
result.type === 'applied'
|
|
1462
|
+
? await DepositWebhook.stage(tx, { records: [result.record] })
|
|
1463
|
+
: undefined
|
|
1464
|
+
return {
|
|
1465
|
+
committed: { references: staged?.references ?? [], result },
|
|
1466
|
+
settlement: prepared.settlement,
|
|
1467
|
+
}
|
|
1468
|
+
},
|
|
1469
|
+
orgId: options.address.orgId,
|
|
1470
|
+
})
|
|
1471
|
+
})()
|
|
1178
1472
|
if (settlement.outcome)
|
|
1179
|
-
options.metrics?.count('
|
|
1473
|
+
options.metrics?.count('routes_deposit_subsidy_count', 1, {
|
|
1180
1474
|
outcome: settlement.outcome,
|
|
1181
1475
|
provider: options.address.providerId,
|
|
1182
1476
|
})
|
|
1183
|
-
|
|
1477
|
+
const policyPending =
|
|
1478
|
+
settlement.outcome === 'routes_subsidy_limit_exceeded' ||
|
|
1479
|
+
(settlement.outcome !== undefined && settlement.outcome in Subsidy.denialMessages)
|
|
1480
|
+
if (settlement.status === 'bridging' || settlement.status === 'settling' || policyPending)
|
|
1481
|
+
terminal = false
|
|
1184
1482
|
if (settlement.status === 'settling') followUp = 'settlement'
|
|
1185
|
-
const
|
|
1186
|
-
baseUnits: delivered + settlement.delivered,
|
|
1187
|
-
currency: options.address.snapshot.destinationToken.currency,
|
|
1188
|
-
decimals: options.address.snapshot.destinationToken.decimals,
|
|
1189
|
-
})
|
|
1190
|
-
const result = await transitionDeposit(
|
|
1191
|
-
db,
|
|
1192
|
-
{
|
|
1193
|
-
expectedVersion: deposit.version,
|
|
1194
|
-
id: deposit.id,
|
|
1195
|
-
...(delivered > 0n
|
|
1196
|
-
? {
|
|
1197
|
-
providerOutputAmount: Value.tokenAmount({
|
|
1198
|
-
baseUnits: delivered,
|
|
1199
|
-
currency: options.address.providerOutputToken.currency,
|
|
1200
|
-
decimals: options.address.providerOutputToken.decimals,
|
|
1201
|
-
}),
|
|
1202
|
-
}
|
|
1203
|
-
: {}),
|
|
1204
|
-
providerRequestIds: options.request
|
|
1205
|
-
? unique([...deposit.providerRequestIds, options.request.id])
|
|
1206
|
-
: deposit.providerRequestIds,
|
|
1207
|
-
...(deliveryObservation?.providerState
|
|
1208
|
-
? {
|
|
1209
|
-
providerState: {
|
|
1210
|
-
...deposit.providerState,
|
|
1211
|
-
...deliveryObservation.providerState,
|
|
1212
|
-
},
|
|
1213
|
-
}
|
|
1214
|
-
: {}),
|
|
1215
|
-
providerTransactionHashes: unique([
|
|
1216
|
-
...deposit.providerTransactionHashes,
|
|
1217
|
-
...providerTransactionHashes,
|
|
1218
|
-
...(deliveryObservation?.providerTransactionHashes ?? []),
|
|
1219
|
-
]),
|
|
1220
|
-
...(settlement.settlementTransaction
|
|
1221
|
-
? { settlementTransaction: settlement.settlementTransaction }
|
|
1222
|
-
: {}),
|
|
1223
|
-
...(settlement.settlementTransactionHash
|
|
1224
|
-
? { settlementTransactionHash: settlement.settlementTransactionHash }
|
|
1225
|
-
: {}),
|
|
1226
|
-
snapshot: {
|
|
1227
|
-
...deposit.snapshot,
|
|
1228
|
-
...(delivered + settlement.delivered > 0n ? { destinationAmount } : {}),
|
|
1229
|
-
...(settlement.status === 'completed' && !options.address.snapshot.subsidize
|
|
1230
|
-
? { destinationAmountRequired: destinationAmount }
|
|
1231
|
-
: {}),
|
|
1232
|
-
destinationTransactionHashes: unique([
|
|
1233
|
-
...(deposit.snapshot.destinationTransactionHashes ?? []),
|
|
1234
|
-
...destinationTransfers.map((evidence) => evidence.transactionHash),
|
|
1235
|
-
...settlement.destinationTransactionHashes,
|
|
1236
|
-
]),
|
|
1237
|
-
},
|
|
1238
|
-
status: settlement.status,
|
|
1239
|
-
...(settlement.statusReason ? { statusReason: settlement.statusReason } : {}),
|
|
1240
|
-
...(settlement.subsidyAmount ? { subsidyAmount: settlement.subsidyAmount } : {}),
|
|
1241
|
-
...(settlement.tempoGasPaid ? { tempoGasPaid: settlement.tempoGasPaid } : {}),
|
|
1242
|
-
},
|
|
1243
|
-
options.onDeposit,
|
|
1244
|
-
)
|
|
1483
|
+
const { result } = committed
|
|
1245
1484
|
if (result.type === 'applied') {
|
|
1485
|
+
Observability.recordDeposit(options.metrics, {
|
|
1486
|
+
previous: deposit,
|
|
1487
|
+
...(providerEvidenceComplete ? { providerEvidenceComplete: true } : {}),
|
|
1488
|
+
record: result.record,
|
|
1489
|
+
})
|
|
1490
|
+
options.onDeposit?.(result.record, committed.references)
|
|
1246
1491
|
updatedIds.add(deposit.id)
|
|
1492
|
+
}
|
|
1493
|
+
if (result.type === 'applied' || result.type === 'unchanged') {
|
|
1247
1494
|
if (settlement.broadcast && options.subsidies) {
|
|
1248
1495
|
await options.subsidies.broadcast(settlement.broadcast).catch((cause) => {
|
|
1249
|
-
options.metrics?.count('
|
|
1496
|
+
options.metrics?.count('routes_deposit_subsidy_count', 1, {
|
|
1250
1497
|
outcome: 'broadcast_failed',
|
|
1251
1498
|
provider: options.address.providerId,
|
|
1252
1499
|
})
|
|
1253
1500
|
throw cause
|
|
1254
1501
|
})
|
|
1255
|
-
options.metrics?.count('
|
|
1502
|
+
options.metrics?.count('routes_deposit_subsidy_count', 1, {
|
|
1256
1503
|
outcome: 'broadcast',
|
|
1257
1504
|
provider: options.address.providerId,
|
|
1258
1505
|
})
|
|
@@ -1263,9 +1510,9 @@ async function reconcileDelivery(db: Db.Db, options: ReconcileDeliveryOptions) {
|
|
|
1263
1510
|
}
|
|
1264
1511
|
|
|
1265
1512
|
type ReconcileSubsidyOptions = {
|
|
1266
|
-
address:
|
|
1513
|
+
address: RoutesDepositAddresses.Record
|
|
1267
1514
|
delivered: bigint
|
|
1268
|
-
deposit:
|
|
1515
|
+
deposit: RoutesDeposits.Record
|
|
1269
1516
|
providerEvidenceComplete: boolean
|
|
1270
1517
|
required: bigint
|
|
1271
1518
|
sourceAmount: bigint
|
|
@@ -1277,7 +1524,19 @@ type ReconcileSubsidyResult = {
|
|
|
1277
1524
|
broadcast?: Subsidy.Settler.broadcast.Parameters | undefined
|
|
1278
1525
|
delivered: bigint
|
|
1279
1526
|
destinationTransactionHashes: readonly string[]
|
|
1280
|
-
outcome?:
|
|
1527
|
+
outcome?:
|
|
1528
|
+
| 'balance_unavailable'
|
|
1529
|
+
| 'completed'
|
|
1530
|
+
| 'liquidity_unavailable'
|
|
1531
|
+
| 'pending'
|
|
1532
|
+
| 'prepared'
|
|
1533
|
+
| 'reverted'
|
|
1534
|
+
| 'routes_subsidy_limit_exceeded'
|
|
1535
|
+
| 'underfilled'
|
|
1536
|
+
| 'unavailable'
|
|
1537
|
+
| 'unsupported'
|
|
1538
|
+
| Subsidy.DenialReason
|
|
1539
|
+
| undefined
|
|
1281
1540
|
settlementTransaction?: string | undefined
|
|
1282
1541
|
settlementTransactionHash?: string | undefined
|
|
1283
1542
|
status: Deposit.Status
|
|
@@ -1286,7 +1545,10 @@ type ReconcileSubsidyResult = {
|
|
|
1286
1545
|
tempoGasPaid?: string | undefined
|
|
1287
1546
|
}
|
|
1288
1547
|
|
|
1289
|
-
async function reconcileSubsidy(
|
|
1548
|
+
async function reconcileSubsidy(
|
|
1549
|
+
db: Db.Db,
|
|
1550
|
+
options: ReconcileSubsidyOptions,
|
|
1551
|
+
): Promise<ReconcileSubsidyResult> {
|
|
1290
1552
|
const empty = { delivered: 0n, destinationTransactionHashes: [] } as const
|
|
1291
1553
|
if (options.required === 0n)
|
|
1292
1554
|
return {
|
|
@@ -1328,7 +1590,11 @@ async function reconcileSubsidy(options: ReconcileSubsidyOptions): Promise<Recon
|
|
|
1328
1590
|
code: 'subsidy_failed',
|
|
1329
1591
|
message: 'Tempo could not deliver the required subsidy.',
|
|
1330
1592
|
},
|
|
1331
|
-
subsidyAmount
|
|
1593
|
+
subsidyAmount: Value.tokenAmount({
|
|
1594
|
+
baseUnits: 0n,
|
|
1595
|
+
currency: options.address.snapshot.destinationToken.currency,
|
|
1596
|
+
decimals: options.address.snapshot.destinationToken.decimals,
|
|
1597
|
+
}),
|
|
1332
1598
|
tempoGasPaid: status.tempoGasPaid,
|
|
1333
1599
|
}
|
|
1334
1600
|
if (status.type === 'pending')
|
|
@@ -1355,7 +1621,11 @@ async function reconcileSubsidy(options: ReconcileSubsidyOptions): Promise<Recon
|
|
|
1355
1621
|
destinationTransactionHashes: transfers.map((transfer) => transfer.transactionHash),
|
|
1356
1622
|
outcome: options.delivered + delivered >= options.required ? 'completed' : 'underfilled',
|
|
1357
1623
|
status: options.delivered + delivered >= options.required ? 'completed' : 'settling',
|
|
1358
|
-
subsidyAmount
|
|
1624
|
+
subsidyAmount: Value.tokenAmount({
|
|
1625
|
+
baseUnits: delivered,
|
|
1626
|
+
currency: options.address.snapshot.destinationToken.currency,
|
|
1627
|
+
decimals: options.address.snapshot.destinationToken.decimals,
|
|
1628
|
+
}),
|
|
1359
1629
|
tempoGasPaid: status.tempoGasPaid,
|
|
1360
1630
|
}
|
|
1361
1631
|
}
|
|
@@ -1374,6 +1644,35 @@ async function reconcileSubsidy(options: ReconcileSubsidyOptions): Promise<Recon
|
|
|
1374
1644
|
}
|
|
1375
1645
|
}
|
|
1376
1646
|
if (!options.providerEvidenceComplete) return { ...empty, status: 'bridging' }
|
|
1647
|
+
const policy = await Subsidy.check(db, {
|
|
1648
|
+
environment: options.address.environment,
|
|
1649
|
+
orgId: options.address.orgId,
|
|
1650
|
+
})
|
|
1651
|
+
if (policy.type === 'denied')
|
|
1652
|
+
return {
|
|
1653
|
+
...empty,
|
|
1654
|
+
outcome: policy.reason,
|
|
1655
|
+
status: 'action-required',
|
|
1656
|
+
statusReason: {
|
|
1657
|
+
code: policy.reason,
|
|
1658
|
+
message: Subsidy.denialMessages[policy.reason],
|
|
1659
|
+
},
|
|
1660
|
+
}
|
|
1661
|
+
if (
|
|
1662
|
+
!Subsidy.supportsGap(policy, {
|
|
1663
|
+
amount: deficit,
|
|
1664
|
+
destinationToken: options.address.snapshot.destinationToken,
|
|
1665
|
+
})
|
|
1666
|
+
)
|
|
1667
|
+
return {
|
|
1668
|
+
...empty,
|
|
1669
|
+
outcome: 'routes_subsidy_limit_exceeded',
|
|
1670
|
+
status: 'action-required',
|
|
1671
|
+
statusReason: {
|
|
1672
|
+
code: 'routes_subsidy_limit_exceeded',
|
|
1673
|
+
message: 'The required subsidy exceeds the per-transaction limit.',
|
|
1674
|
+
},
|
|
1675
|
+
}
|
|
1377
1676
|
if (!options.subsidies)
|
|
1378
1677
|
return {
|
|
1379
1678
|
...empty,
|
|
@@ -1460,13 +1759,16 @@ function nextFollowUp(
|
|
|
1460
1759
|
kind: Provider.Webhook.receive.FollowUp['kind'],
|
|
1461
1760
|
) {
|
|
1462
1761
|
const attempt = message.followUp?.kind === kind ? message.followUp.attempt + 1 : 0
|
|
1463
|
-
|
|
1464
|
-
const
|
|
1465
|
-
|
|
1466
|
-
|
|
1762
|
+
// Provider fee metadata can arrive after delivery, so its slower retry window outlives chain catch-up.
|
|
1763
|
+
const chainCatchUp = kind === 'delivery' && message.trigger === 'chain'
|
|
1764
|
+
const maximumAttempts = (() => {
|
|
1765
|
+
if (chainCatchUp) return chainCatchUpMaximumFollowUpAttempts
|
|
1766
|
+
if (kind === 'provider') return providerMaximumFollowUpAttempts
|
|
1767
|
+
return maximumFollowUpAttempts
|
|
1768
|
+
})()
|
|
1467
1769
|
if (attempt >= maximumAttempts) return undefined
|
|
1468
1770
|
return {
|
|
1469
|
-
delaySeconds:
|
|
1771
|
+
delaySeconds: chainCatchUp ? chainCatchUpFollowUpDelaySeconds : followUpDelaySeconds[kind],
|
|
1470
1772
|
state: { attempt, kind },
|
|
1471
1773
|
}
|
|
1472
1774
|
}
|
|
@@ -1474,7 +1776,7 @@ function nextFollowUp(
|
|
|
1474
1776
|
type RecordWebhookLatencyOptions = {
|
|
1475
1777
|
/** When Tempo completed the webhook-triggered reconciliation. */
|
|
1476
1778
|
completedAt: Date
|
|
1477
|
-
/**
|
|
1779
|
+
/** Route provider that sent the webhook. */
|
|
1478
1780
|
providerId: string
|
|
1479
1781
|
/** Authenticated timestamps carried from webhook receipt. */
|
|
1480
1782
|
timing: Provider.Webhook.receive.WebhookTiming
|
|
@@ -1498,23 +1800,19 @@ function recordWebhookLatency(
|
|
|
1498
1800
|
{ from: providerUpdatedAt, segment: 'provider_to_reconciled', to: completedAt },
|
|
1499
1801
|
] as const
|
|
1500
1802
|
for (const segment of segments)
|
|
1501
|
-
metrics.histogram(
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
segment: segment.segment,
|
|
1507
|
-
status: options.timing.providerStatus,
|
|
1508
|
-
},
|
|
1509
|
-
)
|
|
1803
|
+
metrics.histogram('routes_deposit_webhook_latency_ms', Math.max(0, segment.to - segment.from), {
|
|
1804
|
+
provider: options.providerId,
|
|
1805
|
+
segment: segment.segment,
|
|
1806
|
+
status: options.timing.providerStatus,
|
|
1807
|
+
})
|
|
1510
1808
|
}
|
|
1511
1809
|
|
|
1512
1810
|
/** Provider pagination exceeded the bounded reconciliation limit. */
|
|
1513
1811
|
export class PaginationLimitError extends Error {
|
|
1514
|
-
override name = '
|
|
1812
|
+
override name = 'Routes.Reconciliation.PaginationLimitError'
|
|
1515
1813
|
}
|
|
1516
1814
|
|
|
1517
1815
|
/** The reconciliation lease was claimed by another worker. */
|
|
1518
1816
|
export class StaleLeaseError extends Error {
|
|
1519
|
-
override name = '
|
|
1817
|
+
override name = 'Routes.Reconciliation.StaleLeaseError'
|
|
1520
1818
|
}
|