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,17 +1,22 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
2
|
import { Value as core_Value } from 'ox';
|
|
3
3
|
import { Abis } from 'viem/tempo';
|
|
4
|
-
import { ContractFunctionExecutionError, ContractFunctionRevertedError, ContractFunctionZeroDataError, zeroAddress, } from 'viem';
|
|
4
|
+
import { ContractFunctionExecutionError, ContractFunctionRevertedError, ContractFunctionZeroDataError, isAddress, parseAbi, parseUnits, zeroAddress, } from 'viem';
|
|
5
5
|
import * as z from 'zod/mini';
|
|
6
6
|
import * as Scope from '../../../Scope.js';
|
|
7
7
|
import * as Db from '../../../db/Db.js';
|
|
8
8
|
import * as core_EarnVaults from '../../../db/tables/earnVaults.js';
|
|
9
|
+
import * as RewardCampaignDistributors from '../../../db/tables/rewardCampaignDistributors.js';
|
|
10
|
+
import * as RewardCampaigns from '../../../db/tables/rewardCampaigns.js';
|
|
11
|
+
import * as RewardEligibilityAssociations from '../../../db/tables/rewardEligibilityAssociations.js';
|
|
9
12
|
import * as Auth from '../../../internal/Auth.js';
|
|
10
13
|
import * as Cache from '../../../internal/Cache.js';
|
|
11
14
|
import * as Cursor from '../../../internal/Cursor.js';
|
|
12
15
|
import * as EarnRates from '../../../internal/EarnRates.js';
|
|
16
|
+
import * as EarnSharePrices from '../../../internal/EarnSharePrices.js';
|
|
13
17
|
import * as EarnVaults from '../../../internal/EarnVaults.js';
|
|
14
18
|
import * as OpenApi from '../../../internal/OpenApi.js';
|
|
19
|
+
import * as RewardRead from '../../../internal/rewards/Read.js';
|
|
15
20
|
import * as Response from '../../../internal/Response.js';
|
|
16
21
|
import * as Schema from '../../../internal/Schema.js';
|
|
17
22
|
import * as Store from '../../../internal/Store.js';
|
|
@@ -20,10 +25,31 @@ import * as Timing from '../../../internal/Timing.js';
|
|
|
20
25
|
import * as Ttl from '../../../internal/Ttl.js';
|
|
21
26
|
import * as Value from '../../../internal/Value.js';
|
|
22
27
|
import * as VerifiedTokens from '../../../internal/VerifiedTokens.js';
|
|
28
|
+
import * as Viem from '../../../internal/Viem.js';
|
|
23
29
|
import * as FxOracle from '../FxOracle.js';
|
|
24
30
|
import * as Tokens from './tokens.js';
|
|
25
31
|
import * as Valuation from './valuation.js';
|
|
26
32
|
const deployedSignature = 'event EarnStackDeployed(address indexed earnVault,address indexed earnShare,address indexed earnFees,address engine,address asset,address owner,bytes32 deploymentId,address emergencyGuardian,address asyncJanitor,uint8 migrationMode,bytes32 earnShareSalt,bytes32 controlConfigHash,bytes32 feeConfigHash,bytes32 earnFeesSalt)';
|
|
33
|
+
// Historical factories for this signature, verified against upstream deployments
|
|
34
|
+
// and compiled EarnFactory releases. See docs/earn-discovery.md before updating.
|
|
35
|
+
const deploymentFactories = {
|
|
36
|
+
4217: [
|
|
37
|
+
'0x5b972d2490d06e436982fab77612fd9987f097d0',
|
|
38
|
+
'0x75b20eafdbd3dd974d00b573fd72852ab0237afd',
|
|
39
|
+
],
|
|
40
|
+
42431: [
|
|
41
|
+
'0x0f9ccbc97563a179f5f0886f89ee51c9185f6ec4',
|
|
42
|
+
'0x2aa26b7e24e6f1fb2d539d527b8f1bb5cacfa288',
|
|
43
|
+
'0x4990c74ae874f2b0fd4938662e2cdb8ca4c27887',
|
|
44
|
+
'0x518d4fbd5334bb7ff67c6ebcb67a7d60e1ef8d5d',
|
|
45
|
+
'0x6742345070be5a20ce05f53b6d08d071162c0ef8',
|
|
46
|
+
'0x846b8479d64691ff61c05137dc580a1ecdc188c5',
|
|
47
|
+
'0xb4944264260a6412351d64653f65d2c27d9cb038',
|
|
48
|
+
'0xb4ecb65a57e3585c3699c1617c2abb5de35a697d',
|
|
49
|
+
'0xb5e53c6b17c6f3a380ad94f5417c5e541dfeefac',
|
|
50
|
+
'0xe8fd5b183021ba3f6d3197c5b4238c93561b1b7a',
|
|
51
|
+
],
|
|
52
|
+
};
|
|
27
53
|
const depositedSignature = 'event Deposited(address indexed caller,address indexed receiver,uint256 assets,uint256 earnShares)';
|
|
28
54
|
const redeemedSignature = 'event Redeemed(address indexed caller,address indexed receiver,uint256 earnShares,uint256 assets)';
|
|
29
55
|
const withdrewExactSignature = 'event WithdrewExact(address indexed caller,address indexed receiver,uint256 assets,uint256 earnSharesBurned)';
|
|
@@ -31,17 +57,28 @@ const redeemFinalizedSignature = 'event RedeemFinalized(bytes32 indexed requestI
|
|
|
31
57
|
const redeemCancelledSignature = 'event RedeemCancelled(bytes32 indexed requestId,address indexed receiver,uint256 earnShares)';
|
|
32
58
|
const redeemRequestedSignature = 'event RedeemRequested(bytes32 indexed requestId,address indexed requester,address indexed receiver,uint256 earnShares)';
|
|
33
59
|
const venueSharesDepositedSignature = 'event VenueSharesDeposited(address indexed caller,address indexed receiver,uint256 requestedVenueShares,uint256 receivedVenueShares,uint256 earnShares)';
|
|
60
|
+
const unspentReturnedSignature = 'event UnspentReturned(address indexed treasury,uint256 earnShares)';
|
|
34
61
|
const maxScannedDeployments = 250;
|
|
35
62
|
const scanLimit = 50;
|
|
36
63
|
// Concurrent metadata reads in one macrotask collapse into one deployless
|
|
37
64
|
// multicall; an await between small chunks keeps each call under the RPC limit.
|
|
38
65
|
const tokenReadChunkSize = 20;
|
|
66
|
+
const tempoStateAddress = '0x1c00000000000000000000000000000000000000';
|
|
67
|
+
const tempoStateAbi = parseAbi(['function tempoBlockNumber() view returns (uint64)']);
|
|
68
|
+
const zonePortalAbi = parseAbi(['function lastSyncedTempoBlockNumber() view returns (uint64)']);
|
|
69
|
+
const tokenPositionAbi = parseAbi(['function balanceOf(address account) view returns (uint256)']);
|
|
39
70
|
/** Block boundary that includes all indexed history. */
|
|
40
71
|
const beforeFirstBlockNumber = -1;
|
|
41
72
|
/** Vault TVL is reported in USD only; the API exposes no denomination parameter. */
|
|
42
73
|
const tvlDenomination = 'USD';
|
|
43
74
|
/** `Valuation.valuationFor` floors to 6 dp, so 6 is the precision a valued amount carries. */
|
|
44
75
|
const tvlDecimals = 6;
|
|
76
|
+
function toRewardEligibilityAssociation(record) {
|
|
77
|
+
return {
|
|
78
|
+
...record,
|
|
79
|
+
id: `${record.vaultAddress}-${record.walletAddress}`,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
45
82
|
/** Returns the smallest useful live-discovery batch. */
|
|
46
83
|
export function discoveryBatchLimit(options) {
|
|
47
84
|
const needed = options.limit + 1 - options.matches;
|
|
@@ -55,6 +92,78 @@ export function hasZoneAccess(options) {
|
|
|
55
92
|
/** Zod schemas owned by the public Earn-vault resource. */
|
|
56
93
|
export var schema;
|
|
57
94
|
(function (schema) {
|
|
95
|
+
/** Schemas for the registerRewardEligibility operation. */
|
|
96
|
+
let registerRewardEligibility;
|
|
97
|
+
(function (registerRewardEligibility) {
|
|
98
|
+
/** Wallet and vault association to register for reward eligibility. */
|
|
99
|
+
registerRewardEligibility.Body = z
|
|
100
|
+
.strictObject({
|
|
101
|
+
chainId: Schema.ChainId.check(z.describe('Chain containing the Earn vault.'), z.meta({ examples: [4217] })),
|
|
102
|
+
transactionHash: z.optional(Schema.hash(`0x${'33'.repeat(32)}`)),
|
|
103
|
+
vaultAddress: Schema.Address.check(z.describe('Earn vault contract address.'), z.meta({ examples: ['0x59d27987bc7cc1521bba5f688a170c65840cbf43'] })),
|
|
104
|
+
walletAddress: Schema.Address.check(z.describe('Wallet to register for rewards.'), z.meta({ examples: ['0x8117e0ba6239b9695f780deb010f72a2fa4bdfb6'] })),
|
|
105
|
+
})
|
|
106
|
+
.check(z.describe('Reward eligibility registration.'));
|
|
107
|
+
/** Persisted reward eligibility association. */
|
|
108
|
+
registerRewardEligibility.Association = z
|
|
109
|
+
.strictObject({
|
|
110
|
+
chainId: Schema.ChainId,
|
|
111
|
+
firstRegisteredAt: z.iso
|
|
112
|
+
.datetime()
|
|
113
|
+
.check(z.describe('When the association was first registered.'), z.meta({ examples: ['2026-08-25T20:00:00.000Z'] })),
|
|
114
|
+
id: z.string().check(z.describe('Stable reward eligibility association identifier.'), z.meta({
|
|
115
|
+
examples: [
|
|
116
|
+
'0x59d27987bc7cc1521bba5f688a170c65840cbf43-0x8117e0ba6239b9695f780deb010f72a2fa4bdfb6',
|
|
117
|
+
],
|
|
118
|
+
})),
|
|
119
|
+
latestRegisteredAt: z.iso
|
|
120
|
+
.datetime()
|
|
121
|
+
.check(z.describe('When the association was most recently registered.'), z.meta({ examples: ['2026-08-25T20:00:00.000Z'] })),
|
|
122
|
+
registrationOrder: z
|
|
123
|
+
.string()
|
|
124
|
+
.check(z.regex(/^\d+$/), z.describe('Monotonic registration order.'), z.meta({ examples: ['42'] })),
|
|
125
|
+
transactionHash: z.optional(Schema.hash(`0x${'33'.repeat(32)}`)),
|
|
126
|
+
vaultAddress: Schema.Address,
|
|
127
|
+
walletAddress: Schema.Address,
|
|
128
|
+
})
|
|
129
|
+
.check(z.describe('Persisted reward eligibility association.'));
|
|
130
|
+
/** Persisted reward eligibility registration result. */
|
|
131
|
+
registerRewardEligibility.Response = z
|
|
132
|
+
.strictObject({
|
|
133
|
+
association: registerRewardEligibility.Association,
|
|
134
|
+
created: z
|
|
135
|
+
.boolean()
|
|
136
|
+
.check(z.describe('Whether this request created the association.'), z.meta({ examples: [true] })),
|
|
137
|
+
})
|
|
138
|
+
.check(z.describe('Persisted reward eligibility registration result.'));
|
|
139
|
+
})(registerRewardEligibility = schema.registerRewardEligibility || (schema.registerRewardEligibility = {}));
|
|
140
|
+
/** Schemas for the getRewardEligibility operation. */
|
|
141
|
+
let getRewardEligibility;
|
|
142
|
+
(function (getRewardEligibility) {
|
|
143
|
+
const Limit = z
|
|
144
|
+
._default(z.pipe(z.coerce.number().check(z.int(), z.gte(Schema.minLimit)), z.transform((value) => Math.min(value, 100))), 10)
|
|
145
|
+
.check(z.describe('How many items to return per page (5 to 100, default 10). Use `nextCursor` to fetch more.'), z.meta({ examples: [10] }));
|
|
146
|
+
/** Selects one chain and vault eligibility snapshot page. */
|
|
147
|
+
getRewardEligibility.Query = z
|
|
148
|
+
.strictObject({
|
|
149
|
+
chainId: Schema.ChainId.check(z.describe('Chain containing the Earn vault.')),
|
|
150
|
+
cursor: Schema.Cursor,
|
|
151
|
+
limit: Limit,
|
|
152
|
+
vaultAddress: Schema.Address.check(z.describe('Earn vault contract address.')),
|
|
153
|
+
})
|
|
154
|
+
.check(z.describe('Reward eligibility page selector.'));
|
|
155
|
+
/** One page of eligible wallets at the cursor's fixed checkpoint. */
|
|
156
|
+
getRewardEligibility.Response = z
|
|
157
|
+
.strictObject({
|
|
158
|
+
chainId: Schema.ChainId,
|
|
159
|
+
data: z
|
|
160
|
+
.array(Schema.Address)
|
|
161
|
+
.check(z.describe('Eligible wallet addresses in registration order.')),
|
|
162
|
+
nextCursor: Schema.NextCursor,
|
|
163
|
+
vaultAddress: Schema.Address,
|
|
164
|
+
})
|
|
165
|
+
.check(z.describe('A fixed-snapshot page of eligible wallet addresses.'));
|
|
166
|
+
})(getRewardEligibility = schema.getRewardEligibility || (schema.getRewardEligibility = {}));
|
|
58
167
|
const capability = z
|
|
59
168
|
.enum([
|
|
60
169
|
'asyncRedeem',
|
|
@@ -70,7 +179,7 @@ export var schema;
|
|
|
70
179
|
const engineType = z
|
|
71
180
|
.enum(['erc4626', 'veda'])
|
|
72
181
|
.check(z.describe('Inferred vault engine type.'), z.meta({ examples: ['erc4626'] }));
|
|
73
|
-
const engine = Schema.describe(z.strictObject({
|
|
182
|
+
const engine = OpenApi.component(Schema.describe(z.strictObject({
|
|
74
183
|
address: Schema.Address.check(z.describe('Current vault engine contract address.'), z.meta({ examples: ['0x59d27987bc7cc1521bba5f688a170c65840cbf43'] })),
|
|
75
184
|
type: z
|
|
76
185
|
.nullable(engineType)
|
|
@@ -78,18 +187,58 @@ export var schema;
|
|
|
78
187
|
venue: z
|
|
79
188
|
.nullable(Schema.Address.check(z.describe('Yield venue contract bound to the engine.'), z.meta({ examples: ['0x9a044ae05e5e6290dcf56afd69548565e957a626'] })))
|
|
80
189
|
.check(z.describe('Yield venue, or null when the engine does not expose one.')),
|
|
81
|
-
}), 'Current vault engine.');
|
|
190
|
+
}), 'Current vault engine.'), 'EarnVaultEngine');
|
|
82
191
|
const include = z
|
|
83
192
|
.enum(['access', 'apy', 'capabilities', 'token.logoUri', 'tvl', 'zone', 'zones'])
|
|
84
193
|
.check(z.describe('Optional vault fields to embed via `include`.'));
|
|
85
194
|
const includeQuery = Schema.includeQuery(include, 'Comma-separated vault fields to include, such as `apy,tvl`.');
|
|
195
|
+
const aprRatio = z
|
|
196
|
+
.string()
|
|
197
|
+
.check(z.regex(/^\d+(\.\d+)?$/), z.describe('Annual percentage rate as a non-negative decimal ratio.'), z.meta({ examples: ['0.0195'] }));
|
|
198
|
+
const reward = z.strictObject({
|
|
199
|
+
apr: z
|
|
200
|
+
.nullable(aprRatio)
|
|
201
|
+
.check(z.describe('Current reward APR, or null before its first calculation.')),
|
|
202
|
+
asset: z
|
|
203
|
+
.strictObject({
|
|
204
|
+
address: Schema.Address,
|
|
205
|
+
chainId: Schema.ChainId,
|
|
206
|
+
decimals: z
|
|
207
|
+
.number()
|
|
208
|
+
.check(z.int(), z.nonnegative(), z.describe('Reward asset decimal places.'), z.meta({ examples: [18] })),
|
|
209
|
+
})
|
|
210
|
+
.check(z.describe('EarnShare token distributed by the reward campaign.')),
|
|
211
|
+
calculatedThrough: z
|
|
212
|
+
.optional(z.number().check(z.int(), z.nonnegative()))
|
|
213
|
+
.check(z.describe('Unix timestamp through which a calculated reward APR applies.'), z.meta({ examples: [1788134700] })),
|
|
214
|
+
campaignId: z
|
|
215
|
+
.string()
|
|
216
|
+
.check(z.describe('EarnVault address that identifies the reward campaign.'), z.meta({ examples: ['0x1000000000000000000000000000000000000001'] })),
|
|
217
|
+
endsAt: z
|
|
218
|
+
.number()
|
|
219
|
+
.check(z.int(), z.nonnegative(), z.describe('Exclusive campaign end as a Unix timestamp.'), z.meta({ examples: [1790812800] })),
|
|
220
|
+
startsAt: z
|
|
221
|
+
.number()
|
|
222
|
+
.check(z.int(), z.nonnegative(), z.describe('Inclusive campaign start as a Unix timestamp.'), z.meta({ examples: [1788134400] })),
|
|
223
|
+
targetTotalApr: aprRatio.check(z.describe('Configured target for combined observed vault yield and Merkle rewards.'), z.meta({ examples: ['0.0700'] })),
|
|
224
|
+
});
|
|
225
|
+
const apy = z.strictObject({
|
|
226
|
+
asOf: EarnRates.schema.Apy.shape.asOf,
|
|
227
|
+
methodology: EarnRates.schema.Apy.shape.methodology,
|
|
228
|
+
net: EarnRates.schema.Apy.shape.net.check(z.describe('Higher of observed vault APY and configured reward campaign targets.')),
|
|
229
|
+
rewards: z
|
|
230
|
+
.optional(z.array(reward))
|
|
231
|
+
.check(z.describe('Enabled, registered Merkle rewards. Omitted when reward enrichment is unavailable.')),
|
|
232
|
+
vault: EarnRates.schema.Apy.shape.net.check(z.describe('Observed fee-aware vault APY before reward APR.')),
|
|
233
|
+
window: EarnRates.schema.Apy.shape.window,
|
|
234
|
+
});
|
|
86
235
|
// `apy` and `tvl` need indexer and FX access, so surfaces lacking either
|
|
87
236
|
// select from this reduced set instead.
|
|
88
237
|
const baseInclude = z
|
|
89
238
|
.enum(['access', 'capabilities', 'token.logoUri', 'zone', 'zones'])
|
|
90
239
|
.check(z.describe('Optional vault fields to embed via `include`.'));
|
|
91
240
|
const baseIncludeQuery = Schema.includeQuery(baseInclude, 'Comma-separated vault fields to include, such as `access,zone`.');
|
|
92
|
-
const zone = z
|
|
241
|
+
const zone = OpenApi.component(z
|
|
93
242
|
.strictObject({
|
|
94
243
|
chainId: Schema.ChainId.check(z.describe('Private Zone chain id.'), z.meta({ examples: [421700001] })),
|
|
95
244
|
inputTokens: z
|
|
@@ -102,13 +251,13 @@ export var schema;
|
|
|
102
251
|
.array(Schema.Address)
|
|
103
252
|
.check(z.describe('Tokens supported by private redemptions.'), z.meta({ examples: [['0x20c0000000000000000000006fd9a167923ba194']] })),
|
|
104
253
|
})
|
|
105
|
-
.check(z.describe('Private Zone route configured for a verified vault.'));
|
|
106
|
-
const zoneRoute = z
|
|
254
|
+
.check(z.describe('Private Zone route configured for a verified vault.')), 'EarnVaultZone');
|
|
255
|
+
const zoneRoute = OpenApi.component(z
|
|
107
256
|
.strictObject({
|
|
108
257
|
chainId: Schema.ChainId.check(z.describe('Private Zone chain id.'), z.meta({ examples: [421700001] })),
|
|
109
258
|
deploymentBlock: z
|
|
110
259
|
.number()
|
|
111
|
-
.check(z.int(), z.nonnegative(), z.describe('Parent-chain block that deployed the Earn router.'), z.meta({ examples: [
|
|
260
|
+
.check(z.int(), z.nonnegative(), z.describe('Parent-chain block that deployed the Earn router.'), z.meta({ examples: [35822949] })),
|
|
112
261
|
earnRouter: Schema.Address.check(z.describe('Parent-chain router for this Zone and Earn vault.'), z.meta({ examples: ['0x8117e0ba6239b9695f780deb010f72a2fa4bdfb6'] })),
|
|
113
262
|
inputTokens: z
|
|
114
263
|
.array(Schema.Address)
|
|
@@ -120,7 +269,7 @@ export var schema;
|
|
|
120
269
|
.array(Schema.Address)
|
|
121
270
|
.check(z.describe('Tokens returned by private redemptions.'), z.meta({ examples: [['0x20c0000000000000000000006fd9a167923ba194']] })),
|
|
122
271
|
})
|
|
123
|
-
.check(z.describe('Verified Earn route through one private Zone.'));
|
|
272
|
+
.check(z.describe('Verified Earn route through one private Zone.')), 'EarnVaultZoneRoute');
|
|
124
273
|
const value = z.strictObject({
|
|
125
274
|
amount: Schema.DecimalString.check(z.describe('Value in base units at `decimals` precision.'), z.meta({ examples: ['125288750000'] })),
|
|
126
275
|
currency: z
|
|
@@ -138,8 +287,8 @@ export var schema;
|
|
|
138
287
|
.optional(EarnVaults.schema.Discovery.shape.access)
|
|
139
288
|
.check(z.describe('Vault share-token access, when requested.')),
|
|
140
289
|
apy: z
|
|
141
|
-
.optional(z.nullable(
|
|
142
|
-
.check(z.describe('Annualized
|
|
290
|
+
.optional(z.nullable(apy))
|
|
291
|
+
.check(z.describe('Annualized vault yield over the selected window, plus every available current Merkle reward APR. Null when no component is measurable.')),
|
|
143
292
|
assetToken: Tokens.schema.Token.check(z.describe('Asset accepted by the vault.'), z.meta({
|
|
144
293
|
examples: [
|
|
145
294
|
{
|
|
@@ -203,7 +352,7 @@ export var schema;
|
|
|
203
352
|
[
|
|
204
353
|
{
|
|
205
354
|
chainId: 421700001,
|
|
206
|
-
deploymentBlock:
|
|
355
|
+
deploymentBlock: 35822949,
|
|
207
356
|
earnRouter: '0x8117e0ba6239b9695f780deb010f72a2fa4bdfb6',
|
|
208
357
|
inputTokens: ['0x20c0000000000000000000006fd9a167923ba194'],
|
|
209
358
|
name: 'zone-mainnet-internal',
|
|
@@ -214,9 +363,9 @@ export var schema;
|
|
|
214
363
|
})),
|
|
215
364
|
});
|
|
216
365
|
/** One compatible Earn vault resolved from current chain state. */
|
|
217
|
-
schema.Vault = Schema.describe(vault, 'A compatible earn vault resolved from chain state.');
|
|
366
|
+
schema.Vault = OpenApi.component(Schema.describe(vault, 'A compatible earn vault resolved from chain state.'), 'EarnVault');
|
|
218
367
|
/** One registry-curated Earn vault. */
|
|
219
|
-
schema.VerifiedVault = Schema.describe(z.extend(vault, {
|
|
368
|
+
schema.VerifiedVault = OpenApi.component(Schema.describe(z.extend(vault, {
|
|
220
369
|
engine: z.extend(engine, { type: engineType }),
|
|
221
370
|
slug: z
|
|
222
371
|
.string()
|
|
@@ -224,18 +373,62 @@ export var schema;
|
|
|
224
373
|
verified: z
|
|
225
374
|
.literal(true)
|
|
226
375
|
.check(z.describe('This vault is in the curated earn registry.'), z.meta({ examples: [true] })),
|
|
227
|
-
}), 'A registry-curated earn vault resolved from chain state.');
|
|
376
|
+
}), 'A registry-curated earn vault resolved from chain state.'), 'VerifiedEarnVault');
|
|
228
377
|
const position = z.strictObject({
|
|
229
378
|
account: Schema.Address.check(z.describe('Account whose earn position was read.'), z.meta({ examples: ['0xbe058e1c4df8a4366a387bf595b284246a93039e'] })),
|
|
230
|
-
assetAllowance: Schema.DecimalString.check(z.describe('Assets the vault may spend from
|
|
379
|
+
assetAllowance: Schema.DecimalString.check(z.describe('Assets the vault may spend from a direct account, in asset base units. Always zero for Zone-routed positions, which use Zone withdrawals instead of approvals.'), z.meta({ examples: ['0'] })),
|
|
231
380
|
assetBalance: Schema.DecimalString.check(z.describe('Assets held by this account at the observation block, in asset base units.'), z.meta({ examples: ['250000000'] })),
|
|
232
|
-
assetToken: Schema.tokenAddress('0x20c000000000000000000000b9537d11c60e8b50').check(z.describe('TIP-20 asset token accepted by the vault.')),
|
|
381
|
+
assetToken: Schema.tokenAddress('0x20c000000000000000000000b9537d11c60e8b50').check(z.describe('TIP-20 asset token accepted by the vault or its selected Zone route.')),
|
|
382
|
+
chainId: Schema.ChainId.check(z.describe('Chain containing the account position.'), z.meta({ examples: [42431] })),
|
|
233
383
|
id: Schema.Address.check(z.describe('Stable resource ID for this vault position, equal to the account address.'), z.meta({ examples: ['0xbe058e1c4df8a4366a387bf595b284246a93039e'] })),
|
|
234
|
-
shareAllowance: Schema.DecimalString.check(z.describe('Earn shares the vault may spend from
|
|
384
|
+
shareAllowance: Schema.DecimalString.check(z.describe('Earn shares the vault may spend from a direct account, in share base units. Always zero for Zone-routed positions, which use Zone withdrawals instead of approvals.'), z.meta({ examples: ['0'] })),
|
|
235
385
|
shareBalance: Schema.DecimalString.check(z.describe('Earn shares held by this account at the observation block, in share base units.'), z.meta({ examples: ['99500000'] })),
|
|
236
386
|
shareToken: Schema.tokenAddress('0x20c000000000000000000000300e14ab91a10769').check(z.describe('TIP-20 token representing earn shares.')),
|
|
237
|
-
value: Schema.DecimalString.check(z.describe('Asset value of this account’s earn shares at the observation block, including fees, in
|
|
387
|
+
value: Schema.DecimalString.check(z.describe('Asset value of this account’s earn shares at the observation block, including fees, in `valueToken` base units.'), z.meta({ examples: ['100000000'] })),
|
|
388
|
+
valueToken: Schema.tokenAddress('0x20c000000000000000000000b9537d11c60e8b50').check(z.describe('TIP-20 asset denominating `value` on the vault’s parent chain.')),
|
|
238
389
|
});
|
|
390
|
+
const positionApy = z
|
|
391
|
+
.strictObject({
|
|
392
|
+
breakdown: z
|
|
393
|
+
.array(z
|
|
394
|
+
.strictObject({
|
|
395
|
+
assetAmount: z
|
|
396
|
+
.strictObject({
|
|
397
|
+
baseUnits: Schema.DecimalString.check(z.describe('Position amount in vault asset base units.'), z.meta({ examples: ['25000000000'] })),
|
|
398
|
+
decimals: z
|
|
399
|
+
.number()
|
|
400
|
+
.check(z.int(), z.nonnegative(), z.describe('Vault asset decimal places.'), z.meta({ examples: [6] })),
|
|
401
|
+
formatted: z
|
|
402
|
+
.string()
|
|
403
|
+
.check(z.regex(/^\d+(\.\d+)?$/), z.describe('Position amount rendered in whole vault asset units.'), z.meta({ examples: ['25000'] })),
|
|
404
|
+
})
|
|
405
|
+
.check(z.describe('Vault asset amount receiving this annual rate.'), z.meta({
|
|
406
|
+
examples: [{ baseUnits: '25000000000', decimals: 6, formatted: '25000' }],
|
|
407
|
+
})),
|
|
408
|
+
net: EarnRates.schema.Apy.shape.net.check(z.describe('Annual rate applied to this position amount.'), z.meta({ examples: ['0.07'] })),
|
|
409
|
+
type: z
|
|
410
|
+
.enum(['base', 'boost'])
|
|
411
|
+
.check(z.describe('Base vault yield or qualified depositor boost.'), z.meta({ examples: ['boost'] })),
|
|
412
|
+
})
|
|
413
|
+
.check(z.describe('Position component receiving one annual rate.')))
|
|
414
|
+
.check(z.describe('Position amounts grouped by the annual rate they receive.'), z.meta({
|
|
415
|
+
examples: [
|
|
416
|
+
[
|
|
417
|
+
{
|
|
418
|
+
assetAmount: {
|
|
419
|
+
baseUnits: '25000000000',
|
|
420
|
+
decimals: 6,
|
|
421
|
+
formatted: '25000',
|
|
422
|
+
},
|
|
423
|
+
net: '0.07',
|
|
424
|
+
type: 'boost',
|
|
425
|
+
},
|
|
426
|
+
],
|
|
427
|
+
],
|
|
428
|
+
})),
|
|
429
|
+
net: EarnRates.schema.Apy.shape.net.check(z.describe('Balance-weighted annual rate for this wallet position.'), z.meta({ examples: ['0.0616666666666667'] })),
|
|
430
|
+
})
|
|
431
|
+
.check(z.describe('Wallet-specific effective APY combining live position amounts with qualification from the latest delivered reward snapshot.'));
|
|
239
432
|
const lifetimeCashFlows = z.union([
|
|
240
433
|
z.strictObject({
|
|
241
434
|
status: z
|
|
@@ -250,9 +443,11 @@ export var schema;
|
|
|
250
443
|
.check(z.describe('Cash flows are omitted because asset deposit history is incomplete.'), z.meta({ examples: ['incomplete_history'] })),
|
|
251
444
|
}),
|
|
252
445
|
]);
|
|
253
|
-
const addressPosition =
|
|
254
|
-
|
|
446
|
+
const addressPosition = OpenApi.component(z
|
|
447
|
+
.strictObject({
|
|
448
|
+
assetAmount: value.check(z.describe('Current asset value of the held shares, including fees, in `valueToken` units.')),
|
|
255
449
|
assetToken: Tokens.schema.Token.check(z.describe('Asset accepted by the vault.')),
|
|
450
|
+
chainId: Schema.ChainId.check(z.describe('Chain containing the held shares.'), z.meta({ examples: [42431] })),
|
|
256
451
|
id: Schema.Address.check(z.describe('Stable resource ID for this position, equal to the vault address.'), z.meta({ examples: ['0x4f94590b636f5878bce585e82379de81e1ec174f'] })),
|
|
257
452
|
lifetimeCashFlows: z
|
|
258
453
|
.optional(lifetimeCashFlows)
|
|
@@ -263,11 +458,13 @@ export var schema;
|
|
|
263
458
|
.optional(z.nullable(Valuation.schema.Value))
|
|
264
459
|
.check(z.describe('The position’s nominal value when `valuation.currency` is requested, or `null` when ' +
|
|
265
460
|
'the asset token is unverified, its display currency has no rate, or rates were unavailable.')),
|
|
461
|
+
valueToken: Tokens.schema.Token.check(z.describe('Parent-chain asset denominating `assetAmount`.')),
|
|
266
462
|
vaultAddress: Schema.Address.check(z.describe('Earn vault contract address holding this position.'), z.meta({ examples: ['0x4f94590b636f5878bce585e82379de81e1ec174f'] })),
|
|
267
463
|
verified: z
|
|
268
464
|
.boolean()
|
|
269
465
|
.check(z.describe('Whether the vault is in the curated earn registry.'), z.meta({ examples: [true] })),
|
|
270
|
-
})
|
|
466
|
+
})
|
|
467
|
+
.check(z.describe('An account’s position in one earn vault.')), 'EarnAddressPosition');
|
|
271
468
|
const earningsBase = z.strictObject({
|
|
272
469
|
account: Schema.Address.check(z.describe('Account whose vault earnings were calculated.'), z.meta({ examples: ['0x68f94cfca22e5969c0553bbeab00a2acde88939b'] })),
|
|
273
470
|
assetToken: Schema.TokenAddress.check(z.describe('TIP-20 asset token accepted by the vault.'), z.meta({ examples: ['0x20c000000000000000000000ff04042ee92fd449'] })),
|
|
@@ -371,7 +568,7 @@ export var schema;
|
|
|
371
568
|
/** Query parameters for all compatible deployed Earn vaults. */
|
|
372
569
|
getEarnVaults.Query = collectionQuery;
|
|
373
570
|
/** Paginated list of compatible deployed Earn vaults. */
|
|
374
|
-
getEarnVaults.Response = z
|
|
571
|
+
getEarnVaults.Response = OpenApi.component(z
|
|
375
572
|
.strictObject({
|
|
376
573
|
data: z
|
|
377
574
|
.array(schema.Vault)
|
|
@@ -379,7 +576,7 @@ export var schema;
|
|
|
379
576
|
meta: z.optional(meta),
|
|
380
577
|
nextCursor: Schema.NextCursor,
|
|
381
578
|
})
|
|
382
|
-
.check(z.describe('A page of compatible deployed earn vaults.'));
|
|
579
|
+
.check(z.describe('A page of compatible deployed earn vaults.')), 'EarnVaultList');
|
|
383
580
|
})(getEarnVaults = schema.getEarnVaults || (schema.getEarnVaults = {}));
|
|
384
581
|
/** Schemas for the getVerifiedEarnVaults operation. */
|
|
385
582
|
let getVerifiedEarnVaults;
|
|
@@ -389,7 +586,7 @@ export var schema;
|
|
|
389
586
|
/** Query parameters for registry-curated Earn vaults. */
|
|
390
587
|
getVerifiedEarnVaults.Query = collectionQuery;
|
|
391
588
|
/** Paginated list of registry-curated Earn vaults. */
|
|
392
|
-
getVerifiedEarnVaults.Response = z
|
|
589
|
+
getVerifiedEarnVaults.Response = OpenApi.component(z
|
|
393
590
|
.strictObject({
|
|
394
591
|
data: z
|
|
395
592
|
.array(schema.VerifiedVault)
|
|
@@ -397,7 +594,7 @@ export var schema;
|
|
|
397
594
|
meta: z.optional(meta),
|
|
398
595
|
nextCursor: Schema.NextCursor,
|
|
399
596
|
})
|
|
400
|
-
.check(z.describe('A page of registry-curated earn vaults.'));
|
|
597
|
+
.check(z.describe('A page of registry-curated earn vaults.')), 'VerifiedEarnVaultList');
|
|
401
598
|
})(getVerifiedEarnVaults = schema.getVerifiedEarnVaults || (schema.getVerifiedEarnVaults = {}));
|
|
402
599
|
/** Schemas for the getEarnAddressPositions operation. */
|
|
403
600
|
let getEarnAddressPositions;
|
|
@@ -413,7 +610,7 @@ export var schema;
|
|
|
413
610
|
.strictObject({
|
|
414
611
|
chainId: Schema.ChainIdQuery,
|
|
415
612
|
cursor: Schema.Cursor,
|
|
416
|
-
include: Schema.includeQuery(z.enum(['earnings']), 'Comma-separated position fields to include, such as `earnings`.'),
|
|
613
|
+
include: Schema.includeQuery(z.enum(['earnings']), 'Comma-separated position fields to include, such as `earnings`. Earnings are unavailable when selecting a private Zone.'),
|
|
417
614
|
limit: Schema.Limit,
|
|
418
615
|
'valuation.currency': Schema.Denomination.check(z.describe('When present, include each position’s nominal value in this denomination. ' +
|
|
419
616
|
'Case-insensitive and must be priced by the configured FX oracle.')),
|
|
@@ -432,7 +629,7 @@ export var schema;
|
|
|
432
629
|
})
|
|
433
630
|
.check(z.describe('Page-level valuation rate provenance.'));
|
|
434
631
|
/** Paginated list of the account's earn vault positions. */
|
|
435
|
-
getEarnAddressPositions.Response = z
|
|
632
|
+
getEarnAddressPositions.Response = OpenApi.component(z
|
|
436
633
|
.strictObject({
|
|
437
634
|
data: z
|
|
438
635
|
.array(addressPosition)
|
|
@@ -440,7 +637,7 @@ export var schema;
|
|
|
440
637
|
meta: z.optional(getEarnAddressPositions.Meta),
|
|
441
638
|
nextCursor: Schema.NextCursor,
|
|
442
639
|
})
|
|
443
|
-
.check(z.describe('A page of the account’s earn vault positions.'));
|
|
640
|
+
.check(z.describe('A page of the account’s earn vault positions.')), 'EarnAddressPositionList');
|
|
444
641
|
})(getEarnAddressPositions = schema.getEarnAddressPositions || (schema.getEarnAddressPositions = {}));
|
|
445
642
|
/** Schemas for the getEarnVault operation. */
|
|
446
643
|
let getEarnVault;
|
|
@@ -458,8 +655,65 @@ export var schema;
|
|
|
458
655
|
.extend(vaultSelector, { 'apy.window': EarnRates.schema.Window })
|
|
459
656
|
.check(z.describe('Query parameters selecting one earn vault.'));
|
|
460
657
|
/** One compatible Earn vault resolved directly from current chain state. */
|
|
461
|
-
getEarnVault.Response = Schema.describe(z.extend(vault, { meta: z.optional(meta) }), 'A compatible earn vault resolved from chain state, with rate provenance for its valued fields.');
|
|
658
|
+
getEarnVault.Response = OpenApi.component(Schema.describe(z.extend(vault, { meta: z.optional(meta) }), 'A compatible earn vault resolved from chain state, with rate provenance for its valued fields.'), 'EarnVaultDetail');
|
|
462
659
|
})(getEarnVault = schema.getEarnVault || (schema.getEarnVault = {}));
|
|
660
|
+
/** Schemas for the getEarnVaultSharePrices operation. */
|
|
661
|
+
let getEarnVaultSharePrices;
|
|
662
|
+
(function (getEarnVaultSharePrices) {
|
|
663
|
+
const timestamp = z.iso.datetime({ offset: true });
|
|
664
|
+
/** Path parameters identifying one Earn vault. */
|
|
665
|
+
getEarnVaultSharePrices.Params = z
|
|
666
|
+
.strictObject({
|
|
667
|
+
vaultId: Schema.address('0xf4ae63687d6753a78e7f551d2eda1d0d31a5ea3a').check(z.describe('Earn vault contract address.')),
|
|
668
|
+
})
|
|
669
|
+
.check(z.describe('Path parameters identifying one Earn vault share-price series.'));
|
|
670
|
+
/** Query parameters selecting a daily historical share-price range. */
|
|
671
|
+
getEarnVaultSharePrices.Query = z
|
|
672
|
+
.strictObject({
|
|
673
|
+
chainId: Schema.ChainIdQuery,
|
|
674
|
+
from: timestamp.check(z.describe('First daily share-price observation, as an ISO 8601 timestamp.'), z.meta({ examples: ['2026-07-01T00:00:00.000Z'] })),
|
|
675
|
+
interval: z
|
|
676
|
+
._default(z.literal(EarnSharePrices.interval), EarnSharePrices.interval)
|
|
677
|
+
.check(z.describe('Time between share-price observations.'), z.meta({ examples: [EarnSharePrices.interval] })),
|
|
678
|
+
to: timestamp.check(z.describe('Last possible daily share-price observation, as an ISO 8601 timestamp.'), z.meta({ examples: ['2026-07-31T00:00:00.000Z'] })),
|
|
679
|
+
})
|
|
680
|
+
.check(z.refine((query) => Date.parse(query.from) <= Date.parse(query.to), {
|
|
681
|
+
error: '`from` must be before or equal to `to`.',
|
|
682
|
+
path: ['from'],
|
|
683
|
+
}), z.refine((query) => Math.floor((Date.parse(query.to) - Date.parse(query.from)) / Ttl.days(1)) + 1 <=
|
|
684
|
+
EarnSharePrices.maxPoints, {
|
|
685
|
+
error: `Share-price series are limited to ${EarnSharePrices.maxPoints} daily observations.`,
|
|
686
|
+
path: ['to'],
|
|
687
|
+
}), z.describe('Query parameters selecting an Earn vault share-price series.'));
|
|
688
|
+
const Point = z
|
|
689
|
+
.strictObject({
|
|
690
|
+
sharePrice: value.check(z.describe('Assets returned for one whole Earn share at the observation block.')),
|
|
691
|
+
timestamp: z.iso
|
|
692
|
+
.datetime()
|
|
693
|
+
.check(z.describe('Requested daily observation timestamp.'), z.meta({ examples: ['2026-07-01T00:00:00.000Z'] })),
|
|
694
|
+
})
|
|
695
|
+
.check(z.describe('One historical Earn vault share price.'));
|
|
696
|
+
/** Daily share prices for one Earn vault. */
|
|
697
|
+
getEarnVaultSharePrices.Response = OpenApi.component(z
|
|
698
|
+
.strictObject({
|
|
699
|
+
data: z.array(Point).check(z.describe('Daily Earn vault share prices.'), z.meta({
|
|
700
|
+
examples: [
|
|
701
|
+
[
|
|
702
|
+
{
|
|
703
|
+
sharePrice: {
|
|
704
|
+
amount: '1000000',
|
|
705
|
+
currency: 'USD',
|
|
706
|
+
decimals: 6,
|
|
707
|
+
formatted: '1',
|
|
708
|
+
},
|
|
709
|
+
timestamp: '2026-07-01T00:00:00.000Z',
|
|
710
|
+
},
|
|
711
|
+
],
|
|
712
|
+
],
|
|
713
|
+
})),
|
|
714
|
+
})
|
|
715
|
+
.check(z.describe('Daily historical share prices for one Earn vault.')), 'EarnVaultSharePriceList');
|
|
716
|
+
})(getEarnVaultSharePrices = schema.getEarnVaultSharePrices || (schema.getEarnVaultSharePrices = {}));
|
|
463
717
|
/** Schemas for the getEarnVaultPosition operation. */
|
|
464
718
|
let getEarnVaultPosition;
|
|
465
719
|
(function (getEarnVaultPosition) {
|
|
@@ -478,6 +732,7 @@ export var schema;
|
|
|
478
732
|
.optional(asOf)
|
|
479
733
|
.check(z.describe('ISO 8601 timestamp at which to read the position. Resolves the latest indexed block at or before this time.'), z.meta({ examples: ['2026-07-21T09:00:00.000Z'] })),
|
|
480
734
|
chainId: Schema.ChainIdQuery,
|
|
735
|
+
include: Schema.includeQuery(z.enum(['apy', 'rewards', 'rewards.proof']), 'Include wallet-specific APY or current reward state, optionally with the latest recovery proof.'),
|
|
481
736
|
})
|
|
482
737
|
.check(z.describe('Query parameters selecting an earn vault position.'));
|
|
483
738
|
const Block = z
|
|
@@ -491,14 +746,54 @@ export var schema;
|
|
|
491
746
|
})
|
|
492
747
|
.check(z.describe('Indexed block used for a historical Earn position observation.'));
|
|
493
748
|
/** Current or historical asset and Earn-share state for one account in one vault. */
|
|
494
|
-
|
|
749
|
+
const Rewards = z
|
|
750
|
+
.strictObject({
|
|
751
|
+
cumulativeEntitlement: Schema.DecimalString.check(z.describe('Cumulative EarnShare entitlement.')),
|
|
752
|
+
cumulativePaid: Schema.DecimalString.check(z.describe('Cumulative EarnShare paid.')),
|
|
753
|
+
deferral: z
|
|
754
|
+
.optional(z.string())
|
|
755
|
+
.check(z.describe('Current payout delivery exception.'), z.meta({ examples: ['transfer_unavailable'] })),
|
|
756
|
+
pending: Schema.DecimalString.check(z.describe('EarnShare still owed.')),
|
|
757
|
+
proof: z
|
|
758
|
+
.optional(z.strictObject({
|
|
759
|
+
cumulativeAmount: Schema.DecimalString,
|
|
760
|
+
distributorAddress: Schema.Address,
|
|
761
|
+
proof: z.array(Schema.Hash),
|
|
762
|
+
rootVersion: Schema.DecimalString,
|
|
763
|
+
statementHash: Schema.Hash,
|
|
764
|
+
}))
|
|
765
|
+
.check(z.describe('Permissionless recovery proof against the confirmed root.')),
|
|
766
|
+
})
|
|
767
|
+
.check(z.describe('Current Earn reward state.'));
|
|
768
|
+
getEarnVaultPosition.Response = OpenApi.component(Schema.describe(z.extend(position, {
|
|
769
|
+
apy: z.optional(z.nullable(positionApy)).check(z.describe('Wallet-specific effective APY when requested, or null when unavailable. Qualification comes from the latest delivered reward snapshot and may lag recent deposits or transfers.'), z.meta({
|
|
770
|
+
examples: [
|
|
771
|
+
{
|
|
772
|
+
breakdown: [
|
|
773
|
+
{
|
|
774
|
+
assetAmount: {
|
|
775
|
+
baseUnits: '25000000000',
|
|
776
|
+
decimals: 6,
|
|
777
|
+
formatted: '25000',
|
|
778
|
+
},
|
|
779
|
+
net: '0.07',
|
|
780
|
+
type: 'boost',
|
|
781
|
+
},
|
|
782
|
+
],
|
|
783
|
+
net: '0.07',
|
|
784
|
+
},
|
|
785
|
+
],
|
|
786
|
+
})),
|
|
495
787
|
asOf: z
|
|
496
788
|
.optional(asOf)
|
|
497
789
|
.check(z.describe('Requested historical observation time, when supplied.'), z.meta({ examples: ['2026-07-21T09:00:00.000Z'] })),
|
|
498
790
|
block: z
|
|
499
791
|
.optional(Block)
|
|
500
792
|
.check(z.describe('Indexed block used for a historical Earn position observation, when requested.')),
|
|
501
|
-
|
|
793
|
+
rewards: z
|
|
794
|
+
.optional(Rewards)
|
|
795
|
+
.check(z.describe('Current reward state when requested through `include`.')),
|
|
796
|
+
}), 'Current or historical asset and earn-share balances, allowances, and asset value for an account in one earn vault.'), 'EarnVaultPosition');
|
|
502
797
|
})(getEarnVaultPosition = schema.getEarnVaultPosition || (schema.getEarnVaultPosition = {}));
|
|
503
798
|
/** Schemas for the getEarnVaultEarnings operation. */
|
|
504
799
|
let getEarnVaultEarnings;
|
|
@@ -518,13 +813,98 @@ export var schema;
|
|
|
518
813
|
})
|
|
519
814
|
.check(z.describe('Query parameters selecting an earn vault account.'));
|
|
520
815
|
/** Earnings for one account and period in one Earn vault. */
|
|
521
|
-
getEarnVaultEarnings.Response = Schema.describe(earnings, 'Indexed asset value and cost-basis-aware earnings for an account in one earn vault.');
|
|
816
|
+
getEarnVaultEarnings.Response = OpenApi.component(Schema.describe(earnings, 'Indexed asset value and cost-basis-aware earnings for an account in one earn vault.'), 'EarnVaultEarnings');
|
|
522
817
|
})(getEarnVaultEarnings = schema.getEarnVaultEarnings || (schema.getEarnVaultEarnings = {}));
|
|
523
818
|
})(schema || (schema = {}));
|
|
524
819
|
/** Creates the public Earn-vault handlers. */
|
|
525
820
|
export function earn(options = {}) {
|
|
526
821
|
const oracle = options.fx?.oracle ?? FxOracle.ecb();
|
|
527
822
|
return new Hono()
|
|
823
|
+
.post('/v1/earn/rewards/eligibility', Auth.policy({ apiKey: { scopes: [Scope.wildcard] } }), OpenApi.validate('json', schema.registerRewardEligibility.Body, {
|
|
824
|
+
code: 'body_invalid',
|
|
825
|
+
message: 'Invalid reward eligibility registration',
|
|
826
|
+
}), OpenApi.describeRoute({
|
|
827
|
+
description: 'Registers a wallet and Earn vault association for reward eligibility.',
|
|
828
|
+
hide: true,
|
|
829
|
+
operationId: 'registerRewardEligibility',
|
|
830
|
+
responses: OpenApi.responses({
|
|
831
|
+
errors: {
|
|
832
|
+
400: { codes: ['body_invalid', 'chain_id_unsupported'] },
|
|
833
|
+
},
|
|
834
|
+
success: {
|
|
835
|
+
description: 'The persisted reward eligibility association.',
|
|
836
|
+
schema: schema.registerRewardEligibility.Response,
|
|
837
|
+
},
|
|
838
|
+
}),
|
|
839
|
+
summary: 'Register reward eligibility',
|
|
840
|
+
tags: ['Earn'],
|
|
841
|
+
}), async (c) => {
|
|
842
|
+
if (Auth.narrowAccess)
|
|
843
|
+
return Auth.accessError(c);
|
|
844
|
+
if (OpenApi.narrowValidation)
|
|
845
|
+
return OpenApi.validationError(c, {
|
|
846
|
+
code: 'body_invalid',
|
|
847
|
+
message: 'Invalid reward eligibility registration',
|
|
848
|
+
});
|
|
849
|
+
const body = c.req.valid('json');
|
|
850
|
+
if (!c.get('supportedChainIds').has(body.chainId))
|
|
851
|
+
return Response.unsupportedChainId(c, body.chainId, c.get('supportedChainIds'));
|
|
852
|
+
c.set('chainId', body.chainId);
|
|
853
|
+
c.header('Cache-Control', Cache.policies.noStore);
|
|
854
|
+
const result = await RewardEligibilityAssociations.upsert(Db.get(c.get('db')), {
|
|
855
|
+
...body,
|
|
856
|
+
});
|
|
857
|
+
return c.json(Response.validated(schema.registerRewardEligibility.Response, {
|
|
858
|
+
association: toRewardEligibilityAssociation(result.record),
|
|
859
|
+
created: result.created,
|
|
860
|
+
}), 200);
|
|
861
|
+
})
|
|
862
|
+
.get('/v1/earn/rewards/eligibility', Auth.policy({ apiKey: { scopes: ['rewards:read'] } }), OpenApi.validate('query', schema.getRewardEligibility.Query, {
|
|
863
|
+
code: 'query_invalid',
|
|
864
|
+
message: 'Invalid reward eligibility selector',
|
|
865
|
+
}), OpenApi.describeRoute({
|
|
866
|
+
description: 'Lists reward eligibility associations for one Earn vault at a fixed high-water checkpoint.',
|
|
867
|
+
hide: true,
|
|
868
|
+
operationId: 'getRewardEligibility',
|
|
869
|
+
responses: OpenApi.responses({
|
|
870
|
+
success: {
|
|
871
|
+
description: 'A checkpointed page of reward eligibility associations.',
|
|
872
|
+
schema: schema.getRewardEligibility.Response,
|
|
873
|
+
},
|
|
874
|
+
}),
|
|
875
|
+
summary: 'List reward eligibility',
|
|
876
|
+
tags: ['Earn'],
|
|
877
|
+
}), async (c) => {
|
|
878
|
+
if (Auth.narrowAccess)
|
|
879
|
+
return Auth.accessError(c);
|
|
880
|
+
if (OpenApi.narrowValidation)
|
|
881
|
+
return OpenApi.validationError(c, {
|
|
882
|
+
code: 'query_invalid',
|
|
883
|
+
message: 'Invalid reward eligibility selector',
|
|
884
|
+
});
|
|
885
|
+
const query = c.req.valid('query');
|
|
886
|
+
const zone = c.get('zones').get(query.chainId);
|
|
887
|
+
const sourceChainId = zone ? zone.sourceId : query.chainId;
|
|
888
|
+
const principal = Auth.getPrincipal(c);
|
|
889
|
+
if (principal?.type === 'api_key' &&
|
|
890
|
+
principal.environment === 'sandbox' &&
|
|
891
|
+
(sourceChainId === undefined || Viem.isMainnet(sourceChainId)))
|
|
892
|
+
return Response.error(c, {
|
|
893
|
+
code: 'api_key_forbidden',
|
|
894
|
+
message: 'Sandbox API keys only support testnet.',
|
|
895
|
+
status: 403,
|
|
896
|
+
});
|
|
897
|
+
c.header('Cache-Control', Cache.policies.noStore);
|
|
898
|
+
const page = await RewardEligibilityAssociations.list(Db.get(c.get('db')), {
|
|
899
|
+
...query,
|
|
900
|
+
});
|
|
901
|
+
return c.json(Response.validated(schema.getRewardEligibility.Response, {
|
|
902
|
+
chainId: query.chainId,
|
|
903
|
+
data: page.data.map((association) => association.walletAddress),
|
|
904
|
+
nextCursor: page.nextCursor,
|
|
905
|
+
vaultAddress: query.vaultAddress,
|
|
906
|
+
}), 200);
|
|
907
|
+
})
|
|
528
908
|
.get('/v1/earn/vaults', Auth.policy({ apiKey: { scopes: ['data:read'] }, mpp: true, public: true }), OpenApi.validate('query', schema.getEarnVaults.Query, {
|
|
529
909
|
code: 'query_invalid',
|
|
530
910
|
message: 'Invalid query parameters',
|
|
@@ -532,7 +912,12 @@ export function earn(options = {}) {
|
|
|
532
912
|
description: 'Lists compatible earn vaults discovered from deployment events and resolved from current chain state.',
|
|
533
913
|
operationId: 'getEarnVaults',
|
|
534
914
|
responses: OpenApi.responses({
|
|
535
|
-
errors: {
|
|
915
|
+
errors: {
|
|
916
|
+
400: {
|
|
917
|
+
codes: ['chain_id_invalid', 'chain_id_unsupported', 'query_invalid'],
|
|
918
|
+
},
|
|
919
|
+
502: 'Could not read earn deployment or vault data.',
|
|
920
|
+
},
|
|
536
921
|
success: {
|
|
537
922
|
description: 'A page of compatible deployed earn vaults.',
|
|
538
923
|
schema: schema.getEarnVaults.Response,
|
|
@@ -546,10 +931,22 @@ export function earn(options = {}) {
|
|
|
546
931
|
Cache.response({
|
|
547
932
|
cacheControl: Cache.policies.state,
|
|
548
933
|
key: (c) => vaultCacheKey(c, schema.getEarnVaults.Query),
|
|
549
|
-
name: 'tempo-api:earn-vaults:
|
|
934
|
+
name: 'tempo-api:earn-vaults:v5',
|
|
550
935
|
}), async (c) => {
|
|
551
936
|
if (Auth.narrowAccess)
|
|
552
937
|
return Auth.paidAccessError(c);
|
|
938
|
+
if (OpenApi.narrowValidation)
|
|
939
|
+
return Response.error(c, {
|
|
940
|
+
code: 'chain_id_invalid',
|
|
941
|
+
message: 'Invalid chain id',
|
|
942
|
+
status: 400,
|
|
943
|
+
});
|
|
944
|
+
if (OpenApi.narrowValidation)
|
|
945
|
+
return Response.error(c, {
|
|
946
|
+
code: 'chain_id_unsupported',
|
|
947
|
+
message: 'Unsupported chain id',
|
|
948
|
+
status: 400,
|
|
949
|
+
});
|
|
553
950
|
if (OpenApi.narrowValidation)
|
|
554
951
|
return OpenApi.validationError(c, {
|
|
555
952
|
code: 'query_invalid',
|
|
@@ -572,7 +969,12 @@ export function earn(options = {}) {
|
|
|
572
969
|
description: 'Lists registry-curated earn vaults after resolving their current onchain configuration.',
|
|
573
970
|
operationId: 'getVerifiedEarnVaults',
|
|
574
971
|
responses: OpenApi.responses({
|
|
575
|
-
errors: {
|
|
972
|
+
errors: {
|
|
973
|
+
400: {
|
|
974
|
+
codes: ['chain_id_invalid', 'chain_id_unsupported', 'query_invalid'],
|
|
975
|
+
},
|
|
976
|
+
502: 'Could not read curated earn registry or vault data.',
|
|
977
|
+
},
|
|
576
978
|
success: {
|
|
577
979
|
description: 'A page of registry-curated earn vaults.',
|
|
578
980
|
schema: schema.getVerifiedEarnVaults.Response,
|
|
@@ -587,6 +989,18 @@ export function earn(options = {}) {
|
|
|
587
989
|
}), async (c) => {
|
|
588
990
|
if (Auth.narrowAccess)
|
|
589
991
|
return Auth.paidAccessError(c);
|
|
992
|
+
if (OpenApi.narrowValidation)
|
|
993
|
+
return Response.error(c, {
|
|
994
|
+
code: 'chain_id_invalid',
|
|
995
|
+
message: 'Invalid chain id',
|
|
996
|
+
status: 400,
|
|
997
|
+
});
|
|
998
|
+
if (OpenApi.narrowValidation)
|
|
999
|
+
return Response.error(c, {
|
|
1000
|
+
code: 'chain_id_unsupported',
|
|
1001
|
+
message: 'Unsupported chain id',
|
|
1002
|
+
status: 400,
|
|
1003
|
+
});
|
|
590
1004
|
if (OpenApi.narrowValidation)
|
|
591
1005
|
return OpenApi.validationError(c, {
|
|
592
1006
|
code: 'query_invalid',
|
|
@@ -595,7 +1009,11 @@ export function earn(options = {}) {
|
|
|
595
1009
|
const query = c.req.valid('query');
|
|
596
1010
|
try {
|
|
597
1011
|
const chainId = query.chainId ?? c.get('chainId');
|
|
598
|
-
const data = await listVerifiedVaults(c, {
|
|
1012
|
+
const data = await listVerifiedVaults(c, {
|
|
1013
|
+
...query,
|
|
1014
|
+
chainId,
|
|
1015
|
+
oracle,
|
|
1016
|
+
});
|
|
599
1017
|
return c.json(Response.validated(schema.getVerifiedEarnVaults.Response, data), 200);
|
|
600
1018
|
}
|
|
601
1019
|
catch (cause) {
|
|
@@ -609,7 +1027,7 @@ export function earn(options = {}) {
|
|
|
609
1027
|
code: 'query_invalid',
|
|
610
1028
|
message: 'Invalid query parameters',
|
|
611
1029
|
}), OpenApi.describeRoute({
|
|
612
|
-
description: 'Lists every earn vault where an account currently holds shares
|
|
1030
|
+
description: 'Lists every earn vault where an account currently holds shares on the selected Tempo chain or private Zone. Lifetime cash flows are available on Tempo chains.',
|
|
613
1031
|
operationId: 'getEarnAddressPositions',
|
|
614
1032
|
responses: OpenApi.responses({
|
|
615
1033
|
errors: {
|
|
@@ -672,6 +1090,101 @@ export function earn(options = {}) {
|
|
|
672
1090
|
catch (cause) {
|
|
673
1091
|
if (cause instanceof Valuation.UnsupportedDenominationError)
|
|
674
1092
|
return Response.error(c, { code: 'query_invalid', message: cause.message, status: 400 });
|
|
1093
|
+
if (cause instanceof ZoneEarningsUnsupportedError)
|
|
1094
|
+
return Response.error(c, { code: 'query_invalid', message: cause.message, status: 400 });
|
|
1095
|
+
return Response.upstream(c, cause);
|
|
1096
|
+
}
|
|
1097
|
+
})
|
|
1098
|
+
.get('/v1/earn/vaults/:vaultId/share-prices', Auth.policy({ apiKey: { scopes: ['data:read'] }, mpp: true, public: true }), OpenApi.validate('param', schema.getEarnVaultSharePrices.Params, {
|
|
1099
|
+
code: 'vault_id_invalid',
|
|
1100
|
+
message: 'Invalid vault id',
|
|
1101
|
+
}), OpenApi.validate('query', schema.getEarnVaultSharePrices.Query, {
|
|
1102
|
+
code: 'query_invalid',
|
|
1103
|
+
message: 'Invalid query parameters',
|
|
1104
|
+
}), OpenApi.describeRoute({
|
|
1105
|
+
description: 'Lists daily historical share prices for one earn vault.',
|
|
1106
|
+
operationId: 'getEarnVaultSharePrices',
|
|
1107
|
+
responses: OpenApi.responses({
|
|
1108
|
+
errors: {
|
|
1109
|
+
400: {
|
|
1110
|
+
codes: [
|
|
1111
|
+
'chain_id_invalid',
|
|
1112
|
+
'chain_id_unsupported',
|
|
1113
|
+
'query_invalid',
|
|
1114
|
+
'vault_id_invalid',
|
|
1115
|
+
],
|
|
1116
|
+
},
|
|
1117
|
+
404: {
|
|
1118
|
+
codes: ['earn_vault_not_found'],
|
|
1119
|
+
description: 'No compatible earn vault was found at the supplied vault address.',
|
|
1120
|
+
},
|
|
1121
|
+
502: 'Could not read historical earn vault share prices.',
|
|
1122
|
+
},
|
|
1123
|
+
success: {
|
|
1124
|
+
description: 'Daily historical share prices for one earn vault.',
|
|
1125
|
+
schema: schema.getEarnVaultSharePrices.Response,
|
|
1126
|
+
},
|
|
1127
|
+
}),
|
|
1128
|
+
summary: 'List share prices',
|
|
1129
|
+
tags: ['Earn'],
|
|
1130
|
+
}), Cache.response({
|
|
1131
|
+
cacheControl: Cache.policies.state,
|
|
1132
|
+
key: (c) => Cache.urlKey(c, schema.getEarnVaultSharePrices.Query),
|
|
1133
|
+
name: 'tempo-api:earn-vault-share-prices:v1',
|
|
1134
|
+
}), async (c) => {
|
|
1135
|
+
if (Auth.narrowAccess)
|
|
1136
|
+
return Auth.paidAccessError(c);
|
|
1137
|
+
if (OpenApi.narrowValidation)
|
|
1138
|
+
return Response.error(c, {
|
|
1139
|
+
code: 'chain_id_invalid',
|
|
1140
|
+
message: 'Invalid chain id',
|
|
1141
|
+
status: 400,
|
|
1142
|
+
});
|
|
1143
|
+
if (OpenApi.narrowValidation)
|
|
1144
|
+
return Response.error(c, {
|
|
1145
|
+
code: 'chain_id_unsupported',
|
|
1146
|
+
message: 'Unsupported chain id',
|
|
1147
|
+
status: 400,
|
|
1148
|
+
});
|
|
1149
|
+
if (OpenApi.narrowValidation)
|
|
1150
|
+
return OpenApi.validationError(c, {
|
|
1151
|
+
code: 'vault_id_invalid',
|
|
1152
|
+
message: 'Invalid vault id',
|
|
1153
|
+
});
|
|
1154
|
+
if (OpenApi.narrowValidation)
|
|
1155
|
+
return OpenApi.validationError(c, {
|
|
1156
|
+
code: 'query_invalid',
|
|
1157
|
+
message: 'Invalid query parameters',
|
|
1158
|
+
});
|
|
1159
|
+
const { vaultId } = c.req.valid('param');
|
|
1160
|
+
const query = c.req.valid('query');
|
|
1161
|
+
const chainId = query.chainId ?? c.get('chainId');
|
|
1162
|
+
try {
|
|
1163
|
+
const discovery = await resolveSharePriceVaultDiscovery(c, {
|
|
1164
|
+
chainId,
|
|
1165
|
+
vaultAddress: vaultId,
|
|
1166
|
+
});
|
|
1167
|
+
if (!discovery)
|
|
1168
|
+
return Response.error(c, {
|
|
1169
|
+
code: 'earn_vault_not_found',
|
|
1170
|
+
message: 'Earn vault not found',
|
|
1171
|
+
status: 404,
|
|
1172
|
+
});
|
|
1173
|
+
const data = await getVaultSharePrices(c, {
|
|
1174
|
+
...query,
|
|
1175
|
+
chainId,
|
|
1176
|
+
discovery,
|
|
1177
|
+
vault: vaultId,
|
|
1178
|
+
});
|
|
1179
|
+
return c.json(Response.validated(schema.getEarnVaultSharePrices.Response, { data }), 200);
|
|
1180
|
+
}
|
|
1181
|
+
catch (cause) {
|
|
1182
|
+
if (cause instanceof EarnSharePrices.IndexedBlockNotFoundError ||
|
|
1183
|
+
cause instanceof EarnSharePrices.IndexedCoverageError)
|
|
1184
|
+
return Response.error(c, { code: 'query_invalid', message: cause.message, status: 400 });
|
|
1185
|
+
const failure = sharePriceProviderFailure({ cause, chainId });
|
|
1186
|
+
if (failure)
|
|
1187
|
+
c.set('providerFailure', failure);
|
|
675
1188
|
return Response.upstream(c, cause);
|
|
676
1189
|
}
|
|
677
1190
|
})
|
|
@@ -682,7 +1195,7 @@ export function earn(options = {}) {
|
|
|
682
1195
|
code: 'query_invalid',
|
|
683
1196
|
message: 'Invalid query parameters',
|
|
684
1197
|
}), OpenApi.describeRoute({
|
|
685
|
-
description: 'Gets an account’s
|
|
1198
|
+
description: 'Gets an account’s direct or Zone-routed balances and asset value for one earn vault, optionally at an ISO 8601 timestamp.',
|
|
686
1199
|
operationId: 'getEarnVaultPosition',
|
|
687
1200
|
responses: OpenApi.responses({
|
|
688
1201
|
errors: {
|
|
@@ -712,7 +1225,7 @@ export function earn(options = {}) {
|
|
|
712
1225
|
Cache.response({
|
|
713
1226
|
cacheControl: Cache.policies.noStore,
|
|
714
1227
|
key: (c) => Cache.urlKey(c, schema.getEarnVaultPosition.Query),
|
|
715
|
-
name: 'tempo-api:earn-vault-positions:
|
|
1228
|
+
name: 'tempo-api:earn-vault-positions:v3',
|
|
716
1229
|
}), async (c) => {
|
|
717
1230
|
if (Auth.narrowAccess)
|
|
718
1231
|
return Auth.paidAccessError(c);
|
|
@@ -741,85 +1254,133 @@ export function earn(options = {}) {
|
|
|
741
1254
|
const { address, vaultId } = c.req.valid('param');
|
|
742
1255
|
const query = c.req.valid('query');
|
|
743
1256
|
const chainId = query.chainId ?? c.get('chainId');
|
|
744
|
-
|
|
1257
|
+
if (query.asOf && query.include.length > 0)
|
|
1258
|
+
return Response.error(c, {
|
|
1259
|
+
code: 'query_invalid',
|
|
1260
|
+
message: 'Historical position enrichments are not available.',
|
|
1261
|
+
status: 400,
|
|
1262
|
+
});
|
|
1263
|
+
if (c.get('zones').has(chainId))
|
|
1264
|
+
Cache.setPolicy(c, Cache.policies.noStore);
|
|
745
1265
|
try {
|
|
746
|
-
const
|
|
747
|
-
|
|
748
|
-
:
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
1266
|
+
const position = await getVaultPosition(c, {
|
|
1267
|
+
account: address,
|
|
1268
|
+
asOf: query.asOf,
|
|
1269
|
+
chainId,
|
|
1270
|
+
vault: vaultId,
|
|
1271
|
+
});
|
|
1272
|
+
const apy = query.include.includes('apy')
|
|
1273
|
+
? await resolvePositionApy(c, {
|
|
1274
|
+
chainId,
|
|
1275
|
+
recipient: address,
|
|
1276
|
+
shareBalance: position.shareBalance,
|
|
1277
|
+
value: position.value,
|
|
753
1278
|
vault: vaultId,
|
|
754
|
-
})
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
}),
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
}),
|
|
781
|
-
client.readContract({
|
|
782
|
-
abi: Abis.earnVault,
|
|
783
|
-
address: vaultId,
|
|
784
|
-
blockNumber: BigInt(block.number),
|
|
785
|
-
functionName: 'earnShare',
|
|
786
|
-
}),
|
|
787
|
-
]);
|
|
788
|
-
if (asset === zeroAddress || shareToken === zeroAddress)
|
|
789
|
-
return Response.error(c, {
|
|
790
|
-
code: 'earn_vault_not_found',
|
|
791
|
-
message: 'Earn vault not found',
|
|
792
|
-
status: 404,
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
catch (identityCause) {
|
|
796
|
-
if (isIncompatible(identityCause))
|
|
797
|
-
return Response.error(c, {
|
|
798
|
-
code: 'earn_vault_not_found',
|
|
799
|
-
message: 'Earn vault not found',
|
|
800
|
-
status: 404,
|
|
801
|
-
});
|
|
802
|
-
return Response.upstream(c, identityCause);
|
|
1279
|
+
})
|
|
1280
|
+
: undefined;
|
|
1281
|
+
const rewards = query.include.some((value) => value.startsWith('rewards'))
|
|
1282
|
+
? await RewardRead.recipient({
|
|
1283
|
+
chainId,
|
|
1284
|
+
db: c.get('db'),
|
|
1285
|
+
getClient: c.get('getClient'),
|
|
1286
|
+
recipient: address,
|
|
1287
|
+
vaultAddress: vaultId,
|
|
1288
|
+
})
|
|
1289
|
+
: undefined;
|
|
1290
|
+
return c.json(Response.validated(schema.getEarnVaultPosition.Response, {
|
|
1291
|
+
account: address,
|
|
1292
|
+
...(query.include.includes('apy') ? { apy } : {}),
|
|
1293
|
+
assetAllowance: position.assetAllowance.toString(),
|
|
1294
|
+
assetBalance: position.assetBalance.toString(),
|
|
1295
|
+
assetToken: position.assetToken,
|
|
1296
|
+
chainId,
|
|
1297
|
+
asOf: query.asOf,
|
|
1298
|
+
block: position.block,
|
|
1299
|
+
id: address,
|
|
1300
|
+
...(rewards
|
|
1301
|
+
? {
|
|
1302
|
+
rewards: query.include.includes('rewards.proof')
|
|
1303
|
+
? rewards
|
|
1304
|
+
: { ...rewards, proof: undefined },
|
|
803
1305
|
}
|
|
804
|
-
|
|
805
|
-
|
|
1306
|
+
: {}),
|
|
1307
|
+
shareAllowance: position.shareAllowance.toString(),
|
|
1308
|
+
shareBalance: position.shareBalance.toString(),
|
|
1309
|
+
shareToken: position.shareToken,
|
|
1310
|
+
value: position.value.toString(),
|
|
1311
|
+
valueToken: position.valueToken,
|
|
1312
|
+
}), 200);
|
|
1313
|
+
}
|
|
1314
|
+
catch (cause) {
|
|
1315
|
+
if (cause instanceof IndexedBlockNotFoundError || cause instanceof IndexedCoverageError)
|
|
1316
|
+
return Response.error(c, { code: 'query_invalid', message: cause.message, status: 400 });
|
|
1317
|
+
if (cause instanceof ZoneHistoricalAlignmentError)
|
|
1318
|
+
return Response.error(c, { code: 'query_invalid', message: cause.message, status: 400 });
|
|
1319
|
+
if (cause instanceof EarnVaults.NotFoundError)
|
|
1320
|
+
return Response.error(c, {
|
|
1321
|
+
code: 'earn_vault_not_found',
|
|
1322
|
+
message: 'Earn vault not found',
|
|
1323
|
+
status: 404,
|
|
1324
|
+
});
|
|
1325
|
+
const zone = c.get('zones').get(chainId);
|
|
1326
|
+
if (query.asOf && !zone) {
|
|
806
1327
|
try {
|
|
807
|
-
await
|
|
1328
|
+
const block = await getIndexedBlockAtOrBefore(c.get('getTidx')(chainId), query.asOf);
|
|
1329
|
+
const client = c.get('getClient')(chainId);
|
|
1330
|
+
// These immutable bindings establish historical vault identity
|
|
1331
|
+
// without repeating fallible token or redemption subreads.
|
|
1332
|
+
const [asset, shareToken] = await Promise.all([
|
|
1333
|
+
client.readContract({
|
|
1334
|
+
abi: Abis.earnVault,
|
|
1335
|
+
address: vaultId,
|
|
1336
|
+
blockNumber: BigInt(block.number),
|
|
1337
|
+
functionName: 'asset',
|
|
1338
|
+
}),
|
|
1339
|
+
client.readContract({
|
|
1340
|
+
abi: Abis.earnVault,
|
|
1341
|
+
address: vaultId,
|
|
1342
|
+
blockNumber: BigInt(block.number),
|
|
1343
|
+
functionName: 'earnShare',
|
|
1344
|
+
}),
|
|
1345
|
+
]);
|
|
1346
|
+
if (asset === zeroAddress || shareToken === zeroAddress)
|
|
1347
|
+
return Response.error(c, {
|
|
1348
|
+
code: 'earn_vault_not_found',
|
|
1349
|
+
message: 'Earn vault not found',
|
|
1350
|
+
status: 404,
|
|
1351
|
+
});
|
|
808
1352
|
}
|
|
809
|
-
catch (
|
|
810
|
-
if (
|
|
1353
|
+
catch (identityCause) {
|
|
1354
|
+
if (identityCause instanceof IndexedBlockNotFoundError ||
|
|
1355
|
+
identityCause instanceof IndexedCoverageError)
|
|
1356
|
+
return Response.error(c, {
|
|
1357
|
+
code: 'query_invalid',
|
|
1358
|
+
message: identityCause.message,
|
|
1359
|
+
status: 400,
|
|
1360
|
+
});
|
|
1361
|
+
if (isIncompatible(identityCause))
|
|
811
1362
|
return Response.error(c, {
|
|
812
1363
|
code: 'earn_vault_not_found',
|
|
813
1364
|
message: 'Earn vault not found',
|
|
814
1365
|
status: 404,
|
|
815
1366
|
});
|
|
1367
|
+
return Response.upstream(c, identityCause);
|
|
816
1368
|
}
|
|
817
1369
|
return Response.upstream(c, cause);
|
|
818
1370
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
1371
|
+
if (zone)
|
|
1372
|
+
return Response.upstream(c, cause);
|
|
1373
|
+
try {
|
|
1374
|
+
await resolveVaultDiscovery(c, { chainId, include: [], vaultAddress: vaultId });
|
|
1375
|
+
}
|
|
1376
|
+
catch (vaultCause) {
|
|
1377
|
+
if (isIncompatible(vaultCause))
|
|
1378
|
+
return Response.error(c, {
|
|
1379
|
+
code: 'earn_vault_not_found',
|
|
1380
|
+
message: 'Earn vault not found',
|
|
1381
|
+
status: 404,
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
823
1384
|
return Response.upstream(c, cause);
|
|
824
1385
|
}
|
|
825
1386
|
})
|
|
@@ -922,6 +1483,14 @@ export function earn(options = {}) {
|
|
|
922
1483
|
operationId: 'getEarnVault',
|
|
923
1484
|
responses: OpenApi.responses({
|
|
924
1485
|
errors: {
|
|
1486
|
+
400: {
|
|
1487
|
+
codes: [
|
|
1488
|
+
'chain_id_invalid',
|
|
1489
|
+
'chain_id_unsupported',
|
|
1490
|
+
'query_invalid',
|
|
1491
|
+
'vault_id_invalid',
|
|
1492
|
+
],
|
|
1493
|
+
},
|
|
925
1494
|
404: {
|
|
926
1495
|
codes: ['earn_vault_not_found'],
|
|
927
1496
|
description: 'No compatible earn vault was found at this address.',
|
|
@@ -942,6 +1511,18 @@ export function earn(options = {}) {
|
|
|
942
1511
|
}), async (c) => {
|
|
943
1512
|
if (Auth.narrowAccess)
|
|
944
1513
|
return Auth.paidAccessError(c);
|
|
1514
|
+
if (OpenApi.narrowValidation)
|
|
1515
|
+
return Response.error(c, {
|
|
1516
|
+
code: 'chain_id_invalid',
|
|
1517
|
+
message: 'Invalid chain id',
|
|
1518
|
+
status: 400,
|
|
1519
|
+
});
|
|
1520
|
+
if (OpenApi.narrowValidation)
|
|
1521
|
+
return Response.error(c, {
|
|
1522
|
+
code: 'chain_id_unsupported',
|
|
1523
|
+
message: 'Unsupported chain id',
|
|
1524
|
+
status: 400,
|
|
1525
|
+
});
|
|
945
1526
|
if (OpenApi.narrowValidation)
|
|
946
1527
|
return OpenApi.validationError(c, {
|
|
947
1528
|
code: 'vault_id_invalid',
|
|
@@ -980,7 +1561,10 @@ export function earn(options = {}) {
|
|
|
980
1561
|
export async function getVaultEarnings(c, options) {
|
|
981
1562
|
const client = c.get('getClient')(options.chainId);
|
|
982
1563
|
const tidx = c.get('getTidx')(options.chainId);
|
|
983
|
-
const block = await
|
|
1564
|
+
const [block, rewardTransfer] = await Promise.all([
|
|
1565
|
+
getLatestIndexedBlock(tidx),
|
|
1566
|
+
getRewardTransferPredicate(c, options),
|
|
1567
|
+
]);
|
|
984
1568
|
const blockNumber = block.number;
|
|
985
1569
|
if (options.period === '30d')
|
|
986
1570
|
return getWindowVaultEarnings(c, {
|
|
@@ -988,6 +1572,7 @@ export async function getVaultEarnings(c, options) {
|
|
|
988
1572
|
blockNumber,
|
|
989
1573
|
chainId: options.chainId,
|
|
990
1574
|
period: options.period,
|
|
1575
|
+
rewardTransfer,
|
|
991
1576
|
timestamp: block.timestamp,
|
|
992
1577
|
vault: options.vault,
|
|
993
1578
|
});
|
|
@@ -1008,6 +1593,7 @@ export async function getVaultEarnings(c, options) {
|
|
|
1008
1593
|
const activeCostBasis = await getActiveCostBasis(tidx, {
|
|
1009
1594
|
account: options.account,
|
|
1010
1595
|
blockNumber,
|
|
1596
|
+
rewardTransfer,
|
|
1011
1597
|
shareBalance: current.shareBalance,
|
|
1012
1598
|
shareToken: current.shareToken,
|
|
1013
1599
|
vault: options.vault,
|
|
@@ -1032,6 +1618,7 @@ export async function getVaultEarnings(c, options) {
|
|
|
1032
1618
|
const externalShareTransfer = await hasExternalShareTransfer(tidx, {
|
|
1033
1619
|
account: options.account,
|
|
1034
1620
|
blockNumber,
|
|
1621
|
+
rewardTransfer,
|
|
1035
1622
|
shareToken: current.shareToken,
|
|
1036
1623
|
startBlockNumber: beforeFirstBlockNumber,
|
|
1037
1624
|
vault: options.vault,
|
|
@@ -1076,6 +1663,7 @@ async function getWindowVaultEarnings(c, options) {
|
|
|
1076
1663
|
hasExternalShareTransfer(tidx, {
|
|
1077
1664
|
account: options.account,
|
|
1078
1665
|
blockNumber: options.blockNumber,
|
|
1666
|
+
rewardTransfer: options.rewardTransfer,
|
|
1079
1667
|
shareToken: current.shareToken,
|
|
1080
1668
|
startBlockNumber,
|
|
1081
1669
|
vault: options.vault,
|
|
@@ -1413,6 +2001,36 @@ async function getWindowShareState(tidx, options) {
|
|
|
1413
2001
|
startShares: receivedStartValue - sentStartValue,
|
|
1414
2002
|
};
|
|
1415
2003
|
}
|
|
2004
|
+
/** Builds a share-transfer predicate for the vault's verified reward distributors. */
|
|
2005
|
+
async function getRewardTransferPredicate(c, options) {
|
|
2006
|
+
const db = Db.get(c.get('db'));
|
|
2007
|
+
const campaign = await RewardCampaigns.get(db, {
|
|
2008
|
+
chainId: options.chainId,
|
|
2009
|
+
vaultAddress: options.vault,
|
|
2010
|
+
});
|
|
2011
|
+
if (!campaign)
|
|
2012
|
+
return '0';
|
|
2013
|
+
const distributors = await RewardCampaignDistributors.list(db, {
|
|
2014
|
+
chainId: options.chainId,
|
|
2015
|
+
vaultAddress: options.vault,
|
|
2016
|
+
});
|
|
2017
|
+
if (distributors.length === 0)
|
|
2018
|
+
return '0';
|
|
2019
|
+
const addresses = distributors
|
|
2020
|
+
.map(({ distributorAddress }) => Schema.Address.parse(distributorAddress))
|
|
2021
|
+
.map((address) => `'${address}'`)
|
|
2022
|
+
.join(', ');
|
|
2023
|
+
const shareToken = Schema.Address.parse(campaign.earnShareAddress);
|
|
2024
|
+
// Batch rewards have no per-recipient event; exclude treasury returns instead. Qualify the filter so TIDX does not apply it to other event CTEs.
|
|
2025
|
+
return `
|
|
2026
|
+
token = '${shareToken}'
|
|
2027
|
+
AND "from" IN (${addresses})
|
|
2028
|
+
AND tx_hash NOT IN (
|
|
2029
|
+
SELECT returned.tx_hash FROM UnspentReturned AS returned
|
|
2030
|
+
WHERE returned.address IN (${addresses})
|
|
2031
|
+
)
|
|
2032
|
+
`;
|
|
2033
|
+
}
|
|
1416
2034
|
/** Returns whether an account sent or received Earn shares outside known vault flows. */
|
|
1417
2035
|
async function hasExternalShareTransfer(tidx, options) {
|
|
1418
2036
|
// Vault exits pull shares into the vault before burning. Reconcile counts by transaction and amount so unmatched direct sends remain external.
|
|
@@ -1424,6 +2042,7 @@ async function hasExternalShareTransfer(tidx, options) {
|
|
|
1424
2042
|
SELECT count()
|
|
1425
2043
|
FROM token_transfers
|
|
1426
2044
|
WHERE token = '${options.shareToken.toLowerCase()}'
|
|
2045
|
+
AND toUInt256(amount) > 0
|
|
1427
2046
|
AND block_num > ${options.startBlockNumber}
|
|
1428
2047
|
AND block_num <= ${options.blockNumber}
|
|
1429
2048
|
AND (
|
|
@@ -1432,6 +2051,7 @@ async function hasExternalShareTransfer(tidx, options) {
|
|
|
1432
2051
|
"to" = '${options.account}'
|
|
1433
2052
|
AND "from" != '${zeroAddress}'
|
|
1434
2053
|
AND "from" != '${options.vault}'
|
|
2054
|
+
AND NOT (${options.rewardTransfer})
|
|
1435
2055
|
)
|
|
1436
2056
|
)
|
|
1437
2057
|
) + (
|
|
@@ -1440,6 +2060,7 @@ async function hasExternalShareTransfer(tidx, options) {
|
|
|
1440
2060
|
SELECT tx_hash, toUInt256(amount) AS amount, count() AS transfer_count
|
|
1441
2061
|
FROM token_transfers
|
|
1442
2062
|
WHERE token = '${options.shareToken.toLowerCase()}'
|
|
2063
|
+
AND toUInt256(amount) > 0
|
|
1443
2064
|
AND "from" = '${options.account}'
|
|
1444
2065
|
AND "to" = '${options.vault}'
|
|
1445
2066
|
AND block_num > ${options.startBlockNumber}
|
|
@@ -1480,6 +2101,7 @@ async function hasExternalShareTransfer(tidx, options) {
|
|
|
1480
2101
|
SELECT tx_hash, toUInt256(amount) AS amount, count() AS transfer_count
|
|
1481
2102
|
FROM token_transfers
|
|
1482
2103
|
WHERE token = '${options.shareToken.toLowerCase()}'
|
|
2104
|
+
AND toUInt256(amount) > 0
|
|
1483
2105
|
AND "from" = '${options.vault}'
|
|
1484
2106
|
AND "to" = '${options.account}'
|
|
1485
2107
|
AND block_num > ${options.startBlockNumber}
|
|
@@ -1503,6 +2125,7 @@ async function hasExternalShareTransfer(tidx, options) {
|
|
|
1503
2125
|
redeemCancelledSignature,
|
|
1504
2126
|
redeemedSignature,
|
|
1505
2127
|
redeemRequestedSignature,
|
|
2128
|
+
unspentReturnedSignature,
|
|
1506
2129
|
withdrewExactSignature,
|
|
1507
2130
|
],
|
|
1508
2131
|
});
|
|
@@ -1532,6 +2155,8 @@ export function calculateActiveCostBasis(options) {
|
|
|
1532
2155
|
return { costBasis: removed };
|
|
1533
2156
|
};
|
|
1534
2157
|
for (const action of options.actions) {
|
|
2158
|
+
if (action.shares === 0n)
|
|
2159
|
+
continue;
|
|
1535
2160
|
if (action.kind === 'deposit') {
|
|
1536
2161
|
if (costBasis !== undefined)
|
|
1537
2162
|
costBasis += action.assets;
|
|
@@ -1648,7 +2273,7 @@ async function getActiveCostBasis(tidx, options) {
|
|
|
1648
2273
|
AND block_num <= ${options.blockNumber}
|
|
1649
2274
|
UNION ALL
|
|
1650
2275
|
SELECT
|
|
1651
|
-
'unknown' AS kind,
|
|
2276
|
+
if(${options.rewardTransfer}, 'deposit', 'unknown') AS kind,
|
|
1652
2277
|
block_num,
|
|
1653
2278
|
log_idx,
|
|
1654
2279
|
'' AS request_id,
|
|
@@ -1656,6 +2281,7 @@ async function getActiveCostBasis(tidx, options) {
|
|
|
1656
2281
|
'0' AS assets
|
|
1657
2282
|
FROM token_transfers
|
|
1658
2283
|
WHERE token = '${options.shareToken.toLowerCase()}'
|
|
2284
|
+
AND toUInt256(amount) > 0
|
|
1659
2285
|
AND "to" = '${options.account}'
|
|
1660
2286
|
AND "from" != '${zeroAddress}'
|
|
1661
2287
|
AND "from" != '${options.vault}'
|
|
@@ -1670,6 +2296,7 @@ async function getActiveCostBasis(tidx, options) {
|
|
|
1670
2296
|
'0' AS assets
|
|
1671
2297
|
FROM token_transfers
|
|
1672
2298
|
WHERE token = '${options.shareToken.toLowerCase()}'
|
|
2299
|
+
AND toUInt256(amount) > 0
|
|
1673
2300
|
AND "from" = '${options.account}'
|
|
1674
2301
|
AND "to" != '${options.vault}'
|
|
1675
2302
|
AND block_num <= ${options.blockNumber}
|
|
@@ -1681,6 +2308,7 @@ async function getActiveCostBasis(tidx, options) {
|
|
|
1681
2308
|
redeemCancelledSignature,
|
|
1682
2309
|
redeemRequestedSignature,
|
|
1683
2310
|
redeemedSignature,
|
|
2311
|
+
unspentReturnedSignature,
|
|
1684
2312
|
venueSharesDepositedSignature,
|
|
1685
2313
|
withdrewExactSignature,
|
|
1686
2314
|
],
|
|
@@ -1823,7 +2451,7 @@ export async function listVaults(c, options) {
|
|
|
1823
2451
|
const missingApyVaults = include.includes('apy')
|
|
1824
2452
|
? discoveries.flatMap(({ vaultAddress }) => apyByVault.has(vaultAddress.toLowerCase()) ? [] : [vaultAddress])
|
|
1825
2453
|
: [];
|
|
1826
|
-
const [missingApy, rates, tokens] = await Promise.all([
|
|
2454
|
+
const [missingApy, rates, rewards, tokens] = await Promise.all([
|
|
1827
2455
|
missingApyVaults.length > 0
|
|
1828
2456
|
? resolvePageApy(c, {
|
|
1829
2457
|
chainId: options.chainId,
|
|
@@ -1833,12 +2461,25 @@ export async function listVaults(c, options) {
|
|
|
1833
2461
|
})
|
|
1834
2462
|
: undefined,
|
|
1835
2463
|
resolvePageRates(c, { discoveries, include, oracle: options.oracle, snapshot }),
|
|
2464
|
+
resolvePageRewards(c, {
|
|
2465
|
+
chainId: options.chainId,
|
|
2466
|
+
include,
|
|
2467
|
+
vaults: discoveries.map(({ vaultAddress }) => vaultAddress),
|
|
2468
|
+
}),
|
|
1836
2469
|
resolvePageTokens(c, { chainId: options.chainId, discoveries, include, snapshot }),
|
|
1837
2470
|
]);
|
|
1838
2471
|
for (const [vault, apy] of missingApy ?? [])
|
|
1839
2472
|
apyByVault.set(vault, apy);
|
|
1840
2473
|
const apy = include.includes('apy') ? apyByVault : undefined;
|
|
1841
|
-
const data = await Promise.all(page.map((match) => resolveVault(c, {
|
|
2474
|
+
const data = await Promise.all(page.map((match) => resolveVault(c, {
|
|
2475
|
+
...match,
|
|
2476
|
+
apy,
|
|
2477
|
+
include,
|
|
2478
|
+
rates,
|
|
2479
|
+
rewards: rewards?.get(match.discovery.vaultAddress),
|
|
2480
|
+
snapshot,
|
|
2481
|
+
tokens,
|
|
2482
|
+
})));
|
|
1842
2483
|
const last = matches[options.limit - 1];
|
|
1843
2484
|
const nextPosition = matches.length > options.limit ? last?.position : hasMore ? position : undefined;
|
|
1844
2485
|
return {
|
|
@@ -1891,7 +2532,7 @@ export async function listVerifiedVaults(c, options) {
|
|
|
1891
2532
|
}
|
|
1892
2533
|
const page = matches.slice(0, options.limit);
|
|
1893
2534
|
const discoveries = page.map(({ discovery }) => discovery);
|
|
1894
|
-
const [apy, rates, tokens] = await Promise.all([
|
|
2535
|
+
const [apy, rates, rewards, tokens] = await Promise.all([
|
|
1895
2536
|
resolvePageApy(c, {
|
|
1896
2537
|
chainId: options.chainId,
|
|
1897
2538
|
include,
|
|
@@ -1899,9 +2540,22 @@ export async function listVerifiedVaults(c, options) {
|
|
|
1899
2540
|
window: options['apy.window'],
|
|
1900
2541
|
}),
|
|
1901
2542
|
resolvePageRates(c, { discoveries, include, oracle: options.oracle, snapshot }),
|
|
2543
|
+
resolvePageRewards(c, {
|
|
2544
|
+
chainId: options.chainId,
|
|
2545
|
+
include,
|
|
2546
|
+
vaults: discoveries.map(({ vaultAddress }) => vaultAddress),
|
|
2547
|
+
}),
|
|
1902
2548
|
resolvePageTokens(c, { chainId: options.chainId, discoveries, include, snapshot }),
|
|
1903
2549
|
]);
|
|
1904
|
-
const data = await Promise.all(page.map(async (match) => Response.validated(schema.VerifiedVault, await resolveVault(c, {
|
|
2550
|
+
const data = await Promise.all(page.map(async (match) => Response.validated(schema.VerifiedVault, await resolveVault(c, {
|
|
2551
|
+
...match,
|
|
2552
|
+
apy,
|
|
2553
|
+
include,
|
|
2554
|
+
rates,
|
|
2555
|
+
rewards: rewards?.get(match.discovery.vaultAddress),
|
|
2556
|
+
snapshot,
|
|
2557
|
+
tokens,
|
|
2558
|
+
}))));
|
|
1905
2559
|
const last = matches[options.limit - 1];
|
|
1906
2560
|
return {
|
|
1907
2561
|
data,
|
|
@@ -1909,13 +2563,239 @@ export async function listVerifiedVaults(c, options) {
|
|
|
1909
2563
|
nextCursor: matches.length > options.limit && last ? Cursor.encode([last.record.vaultAddress]) : null,
|
|
1910
2564
|
};
|
|
1911
2565
|
}
|
|
2566
|
+
/** Reads daily historical share prices for one Earn vault. */
|
|
2567
|
+
export async function getVaultSharePrices(c, options) {
|
|
2568
|
+
const prices = await Timing.time(c, 'earn_share_prices', () => EarnSharePrices.resolve({
|
|
2569
|
+
chainId: options.chainId,
|
|
2570
|
+
from: options.from,
|
|
2571
|
+
// This client is request-local so viem's stateful HTTP batch cannot cross Worker invocations.
|
|
2572
|
+
getClient: (chainId = options.chainId) => Viem.createBatchClient({
|
|
2573
|
+
chainId,
|
|
2574
|
+
principal: Auth.getPrincipal(c),
|
|
2575
|
+
rpc: c.get('rpc'),
|
|
2576
|
+
zone: c.get('zones').get(chainId),
|
|
2577
|
+
}),
|
|
2578
|
+
getTidx: c.get('getTidx'),
|
|
2579
|
+
shareDecimals: options.discovery.shareToken.decimals,
|
|
2580
|
+
to: options.to,
|
|
2581
|
+
vault: options.vault,
|
|
2582
|
+
}));
|
|
2583
|
+
return prices.map((price) => ({
|
|
2584
|
+
sharePrice: {
|
|
2585
|
+
amount: price.amount.toString(),
|
|
2586
|
+
currency: options.discovery.assetToken.currency,
|
|
2587
|
+
decimals: options.discovery.assetToken.decimals,
|
|
2588
|
+
formatted: core_Value.format(price.amount, options.discovery.assetToken.decimals),
|
|
2589
|
+
},
|
|
2590
|
+
timestamp: price.timestamp,
|
|
2591
|
+
}));
|
|
2592
|
+
}
|
|
2593
|
+
/** Classifies an Earn share-price dependency failure for request metrics. */
|
|
2594
|
+
export function sharePriceProviderFailure(options) {
|
|
2595
|
+
if (options.cause instanceof EarnSharePrices.MalformedResponseError)
|
|
2596
|
+
return {
|
|
2597
|
+
chainId: options.chainId,
|
|
2598
|
+
failure: 'payload',
|
|
2599
|
+
id: 'tidx',
|
|
2600
|
+
operation: 'query',
|
|
2601
|
+
};
|
|
2602
|
+
if (options.cause instanceof EarnSharePrices.TidxRequestError)
|
|
2603
|
+
return { ...Tidx.providerFailure(options.cause.cause), chainId: options.chainId };
|
|
2604
|
+
const failure = Viem.requestFailure(options.cause);
|
|
2605
|
+
if (failure)
|
|
2606
|
+
return { ...failure, chainId: options.chainId, id: 'rpc', operation: 'eth_call' };
|
|
2607
|
+
return undefined;
|
|
2608
|
+
}
|
|
2609
|
+
async function resolveSharePriceVaultDiscovery(c, options) {
|
|
2610
|
+
const result = await Store.memoize(async () => {
|
|
2611
|
+
try {
|
|
2612
|
+
return {
|
|
2613
|
+
discovery: await readVaultDiscovery(c, { ...options, include: [] }),
|
|
2614
|
+
status: 'found',
|
|
2615
|
+
};
|
|
2616
|
+
}
|
|
2617
|
+
catch (cause) {
|
|
2618
|
+
if (isIncompatible(cause))
|
|
2619
|
+
return { status: 'not_found' };
|
|
2620
|
+
throw cause;
|
|
2621
|
+
}
|
|
2622
|
+
}, {
|
|
2623
|
+
key: `earn-share-price-vault:v1:${options.chainId}:${options.vaultAddress.toLowerCase()}`,
|
|
2624
|
+
store: c.get('store'),
|
|
2625
|
+
ttl: Ttl.seconds(5),
|
|
2626
|
+
});
|
|
2627
|
+
return result.status === 'found' ? result.discovery : undefined;
|
|
2628
|
+
}
|
|
2629
|
+
/** Reads one direct or Zone-routed account position in a parent-chain Earn vault. */
|
|
2630
|
+
export async function getVaultPosition(c, options) {
|
|
2631
|
+
const zone = c.get('zones').get(options.chainId);
|
|
2632
|
+
if (!zone) {
|
|
2633
|
+
const block = options.asOf === undefined
|
|
2634
|
+
? undefined
|
|
2635
|
+
: await getIndexedBlockAtOrBefore(c.get('getTidx')(options.chainId), options.asOf);
|
|
2636
|
+
const position = await c
|
|
2637
|
+
.get('getClient')(options.chainId)
|
|
2638
|
+
.earn.getPosition({
|
|
2639
|
+
account: options.account,
|
|
2640
|
+
...(block ? { blockNumber: BigInt(block.number) } : {}),
|
|
2641
|
+
vault: options.vault,
|
|
2642
|
+
});
|
|
2643
|
+
return { ...position, block, valueToken: position.assetToken };
|
|
2644
|
+
}
|
|
2645
|
+
const route = await resolveZonePositionRoute(c, {
|
|
2646
|
+
chainId: options.chainId,
|
|
2647
|
+
vault: options.vault,
|
|
2648
|
+
});
|
|
2649
|
+
const block = options.asOf === undefined
|
|
2650
|
+
? undefined
|
|
2651
|
+
: await getIndexedBlockAtOrBefore(c.get('getTidx')(options.chainId), options.asOf);
|
|
2652
|
+
const zoneClient = c.get('getClient')(options.chainId);
|
|
2653
|
+
const blockNumber = block ? BigInt(block.number) : await zoneClient.getBlockNumber();
|
|
2654
|
+
const [assetBalance, shareBalance, importedParentBlockNumber] = await Promise.all([
|
|
2655
|
+
readZoneBalance(zoneClient, {
|
|
2656
|
+
account: options.account,
|
|
2657
|
+
blockNumber,
|
|
2658
|
+
token: route.privateAsset,
|
|
2659
|
+
}),
|
|
2660
|
+
readZoneBalance(zoneClient, {
|
|
2661
|
+
account: options.account,
|
|
2662
|
+
blockNumber,
|
|
2663
|
+
token: route.shareToken,
|
|
2664
|
+
}),
|
|
2665
|
+
readZoneSourceBlock(c, {
|
|
2666
|
+
blockNumber,
|
|
2667
|
+
historical: block !== undefined,
|
|
2668
|
+
portal: route.portal,
|
|
2669
|
+
sourceChainId: route.sourceChainId,
|
|
2670
|
+
zoneClient,
|
|
2671
|
+
}),
|
|
2672
|
+
]);
|
|
2673
|
+
const sourceBlock = Value.toNumber(importedParentBlockNumber);
|
|
2674
|
+
if (sourceBlock === undefined || sourceBlock < route.deploymentBlock)
|
|
2675
|
+
throw new EarnVaults.NotFoundError();
|
|
2676
|
+
const value = await c
|
|
2677
|
+
.get('getClient')(route.sourceChainId)
|
|
2678
|
+
.earn.getRedeemQuote({
|
|
2679
|
+
blockNumber: BigInt(sourceBlock),
|
|
2680
|
+
shareAmount: shareBalance,
|
|
2681
|
+
vault: options.vault,
|
|
2682
|
+
});
|
|
2683
|
+
return {
|
|
2684
|
+
assetAllowance: 0n,
|
|
2685
|
+
assetBalance,
|
|
2686
|
+
assetToken: route.privateAsset,
|
|
2687
|
+
block,
|
|
2688
|
+
shareAllowance: 0n,
|
|
2689
|
+
shareBalance,
|
|
2690
|
+
shareToken: route.shareToken,
|
|
2691
|
+
value,
|
|
2692
|
+
valueToken: route.vaultAsset,
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2695
|
+
/** Reads a private Zone token balance with the holder as the authorized RPC caller. */
|
|
2696
|
+
async function readZoneBalance(client, options) {
|
|
2697
|
+
return client.readContract({
|
|
2698
|
+
abi: tokenPositionAbi,
|
|
2699
|
+
account: options.account,
|
|
2700
|
+
address: options.token,
|
|
2701
|
+
args: [options.account],
|
|
2702
|
+
...(options.blockNumber === undefined ? {} : { blockNumber: options.blockNumber }),
|
|
2703
|
+
functionName: 'balanceOf',
|
|
2704
|
+
});
|
|
2705
|
+
}
|
|
2706
|
+
/** Reads the parent Tempo checkpoint imported by one Zone observation. */
|
|
2707
|
+
async function readZoneSourceBlock(c, options) {
|
|
2708
|
+
const verifiedPromise = c.get('getClient')(options.sourceChainId).readContract({
|
|
2709
|
+
abi: zonePortalAbi,
|
|
2710
|
+
address: options.portal,
|
|
2711
|
+
functionName: 'lastSyncedTempoBlockNumber',
|
|
2712
|
+
});
|
|
2713
|
+
// A historical Zone without TempoState rejects before awaiting the portal.
|
|
2714
|
+
void verifiedPromise.catch(() => undefined);
|
|
2715
|
+
const reported = await (async () => {
|
|
2716
|
+
try {
|
|
2717
|
+
return await options.zoneClient.readContract({
|
|
2718
|
+
abi: tempoStateAbi,
|
|
2719
|
+
address: tempoStateAddress,
|
|
2720
|
+
blockNumber: options.blockNumber,
|
|
2721
|
+
functionName: 'tempoBlockNumber',
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
catch (cause) {
|
|
2725
|
+
if (!(cause instanceof ContractFunctionExecutionError) ||
|
|
2726
|
+
!(cause.cause instanceof ContractFunctionZeroDataError))
|
|
2727
|
+
throw cause;
|
|
2728
|
+
if (options.historical)
|
|
2729
|
+
throw new ZoneHistoricalAlignmentError();
|
|
2730
|
+
return undefined;
|
|
2731
|
+
}
|
|
2732
|
+
})();
|
|
2733
|
+
const verified = await verifiedPromise;
|
|
2734
|
+
return alignZoneSourceBlock({ reported, verified });
|
|
2735
|
+
}
|
|
2736
|
+
/** Caps a Zone-reported parent checkpoint at the L1 portal's verified watermark. */
|
|
2737
|
+
export function alignZoneSourceBlock(options) {
|
|
2738
|
+
if (options.reported === undefined || options.verified < options.reported)
|
|
2739
|
+
return options.verified;
|
|
2740
|
+
return options.reported;
|
|
2741
|
+
}
|
|
2742
|
+
/** Resolves the verified parent vault and token pair for one Zone route. */
|
|
2743
|
+
async function resolveZonePositionRoute(c, options) {
|
|
2744
|
+
const zone = c.get('zones').get(options.chainId);
|
|
2745
|
+
if (!zone?.sourceId)
|
|
2746
|
+
throw new EarnVaults.NotFoundError();
|
|
2747
|
+
const db = Db.get(c.get('dbCached'));
|
|
2748
|
+
const record = await core_EarnVaults.get(db, {
|
|
2749
|
+
chainId: zone.sourceId,
|
|
2750
|
+
vaultAddress: options.vault,
|
|
2751
|
+
});
|
|
2752
|
+
const configured = record?.zones.find((route) => route.chainId === options.chainId);
|
|
2753
|
+
if (!record || !configured)
|
|
2754
|
+
throw new EarnVaults.NotFoundError();
|
|
2755
|
+
const discovery = await resolveVaultDiscovery(c, {
|
|
2756
|
+
chainId: zone.sourceId,
|
|
2757
|
+
include: [],
|
|
2758
|
+
vaultAddress: options.vault,
|
|
2759
|
+
});
|
|
2760
|
+
const [route] = await EarnVaults.resolveZoneRoutes({
|
|
2761
|
+
discovery,
|
|
2762
|
+
getClient: c.get('getClient'),
|
|
2763
|
+
routes: [configured],
|
|
2764
|
+
zones: [...c.get('zones').values()],
|
|
2765
|
+
});
|
|
2766
|
+
const privateAsset = route?.inputTokens[0];
|
|
2767
|
+
const portalContract = zone.contracts?.['portal'];
|
|
2768
|
+
const portal = Schema.Address.safeParse(portalContract && 'address' in portalContract
|
|
2769
|
+
? portalContract.address
|
|
2770
|
+
: portalContract?.[zone.sourceId]?.address);
|
|
2771
|
+
if (!route || !privateAsset || !portal.success)
|
|
2772
|
+
throw new EarnVaults.NotFoundError();
|
|
2773
|
+
return {
|
|
2774
|
+
deploymentBlock: route.deploymentBlock,
|
|
2775
|
+
portal: portal.data,
|
|
2776
|
+
privateAsset,
|
|
2777
|
+
shareToken: discovery.shareToken.address,
|
|
2778
|
+
sourceChainId: zone.sourceId,
|
|
2779
|
+
vaultAsset: discovery.assetToken.address,
|
|
2780
|
+
};
|
|
2781
|
+
}
|
|
1912
2782
|
/** Lists every vault where an account holds earn shares, ordered by vault address. */
|
|
1913
2783
|
export async function listPositions(c, options) {
|
|
1914
2784
|
const denomination = options['valuation.currency'];
|
|
2785
|
+
const zone = c.get('zones').get(options.chainId);
|
|
2786
|
+
if (zone && options.include.includes('earnings'))
|
|
2787
|
+
throw new ZoneEarningsUnsupportedError();
|
|
2788
|
+
const sourceChainId = zone ? zone.sourceId : options.chainId;
|
|
2789
|
+
if (sourceChainId === undefined)
|
|
2790
|
+
throw new EarnVaults.NotFoundError();
|
|
1915
2791
|
const db = Db.get(c.get('dbCached'));
|
|
1916
|
-
const recordsPromise = core_EarnVaults
|
|
2792
|
+
const recordsPromise = core_EarnVaults
|
|
2793
|
+
.list(db, { chainId: sourceChainId })
|
|
2794
|
+
.then((records) => zone
|
|
2795
|
+
? records.filter((record) => record.zones.some((route) => route.chainId === options.chainId))
|
|
2796
|
+
: records);
|
|
1917
2797
|
// The verified page needs no index: the registry is the candidate set.
|
|
1918
|
-
const heldPromise = options.verified
|
|
2798
|
+
const heldPromise = options.verified || zone
|
|
1919
2799
|
? undefined
|
|
1920
2800
|
: queryHeldVaults(c, { address: options.address, chainId: options.chainId });
|
|
1921
2801
|
// Observing these branches prevents unhandled rejections while the
|
|
@@ -1951,14 +2831,16 @@ export async function listPositions(c, options) {
|
|
|
1951
2831
|
const read = await Timing.time(c, 'earn_positions', () => Promise.all(batch.map(async (vault) => {
|
|
1952
2832
|
const record = registry.get(vault);
|
|
1953
2833
|
try {
|
|
1954
|
-
const position = await
|
|
1955
|
-
|
|
2834
|
+
const position = await getVaultPosition(c, {
|
|
2835
|
+
account: options.address,
|
|
1956
2836
|
chainId: options.chainId,
|
|
1957
|
-
|
|
2837
|
+
vault: Schema.Address.parse(vault),
|
|
1958
2838
|
});
|
|
1959
2839
|
return { position, record, vaultAddress: vault };
|
|
1960
2840
|
}
|
|
1961
2841
|
catch (cause) {
|
|
2842
|
+
if (cause instanceof EarnVaults.NotFoundError)
|
|
2843
|
+
return undefined;
|
|
1962
2844
|
if (!record && isIncompatible(cause))
|
|
1963
2845
|
return undefined;
|
|
1964
2846
|
throw cause;
|
|
@@ -1971,10 +2853,10 @@ export async function listPositions(c, options) {
|
|
|
1971
2853
|
}
|
|
1972
2854
|
}
|
|
1973
2855
|
const page = matches.slice(0, options.limit);
|
|
1974
|
-
const indexedBlock = page.length > 0 && options.include.includes('earnings')
|
|
2856
|
+
const indexedBlock = !zone && page.length > 0 && options.include.includes('earnings')
|
|
1975
2857
|
? await getLatestIndexedBlock(c.get('getTidx')(options.chainId))
|
|
1976
2858
|
: undefined;
|
|
1977
|
-
const [cashFlows, tokens, snapshot] = await Promise.all([
|
|
2859
|
+
const [cashFlows, tokens, valueTokens, snapshot] = await Promise.all([
|
|
1978
2860
|
indexedBlock
|
|
1979
2861
|
? getVaultLifetimeCashFlows(c.get('getTidx')(options.chainId), {
|
|
1980
2862
|
account: options.address,
|
|
@@ -1995,12 +2877,19 @@ export async function listPositions(c, options) {
|
|
|
1995
2877
|
}));
|
|
1996
2878
|
return new Map(groups.flatMap((group) => [...group]));
|
|
1997
2879
|
})(),
|
|
1998
|
-
|
|
2880
|
+
zone
|
|
2881
|
+
? Tokens.resolveTokens(c, {
|
|
2882
|
+
addresses: [...new Set(page.map(({ position }) => position.valueToken))],
|
|
2883
|
+
chainId: sourceChainId,
|
|
2884
|
+
include: ['token.verified'],
|
|
2885
|
+
})
|
|
2886
|
+
: undefined,
|
|
2887
|
+
denomination ? VerifiedTokens.snapshot(c, sourceChainId) : undefined,
|
|
1999
2888
|
]);
|
|
2000
2889
|
const rates = denomination && snapshot
|
|
2001
2890
|
? await Valuation.ratesFor(c, {
|
|
2002
2891
|
currencies: page.flatMap(({ position }) => {
|
|
2003
|
-
const currency = snapshot.byAddress.get(position.
|
|
2892
|
+
const currency = snapshot.byAddress.get(position.valueToken.toLowerCase())?.currency;
|
|
2004
2893
|
return currency === undefined ? [] : [currency];
|
|
2005
2894
|
}),
|
|
2006
2895
|
denomination,
|
|
@@ -2018,11 +2907,13 @@ export async function listPositions(c, options) {
|
|
|
2018
2907
|
return {
|
|
2019
2908
|
data: page.map((match) => serializePosition({
|
|
2020
2909
|
cashFlows: cashFlows?.get(match.vaultAddress),
|
|
2910
|
+
chainId: options.chainId,
|
|
2021
2911
|
denomination,
|
|
2022
2912
|
position: match.position,
|
|
2023
2913
|
rates,
|
|
2024
2914
|
snapshot,
|
|
2025
2915
|
tokens,
|
|
2916
|
+
valueTokens,
|
|
2026
2917
|
vaultAddress: match.vaultAddress,
|
|
2027
2918
|
verified: match.record !== undefined,
|
|
2028
2919
|
})),
|
|
@@ -2032,12 +2923,12 @@ export async function listPositions(c, options) {
|
|
|
2032
2923
|
}
|
|
2033
2924
|
/** Finds vaults whose earn share token the account has ever held, by vault address. */
|
|
2034
2925
|
async function queryHeldVaults(c, options) {
|
|
2926
|
+
const factories = deploymentFactories[options.chainId] ?? [];
|
|
2927
|
+
if (factories.length === 0)
|
|
2928
|
+
return [];
|
|
2035
2929
|
const tidx = c.get('getTidx')(options.chainId);
|
|
2036
|
-
//
|
|
2037
|
-
//
|
|
2038
|
-
// candidates in one round trip, with no literal list to overflow the request.
|
|
2039
|
-
// Earn shares are factory-minted TIP-20s, so the `0x20c0` prefix bounds the
|
|
2040
|
-
// subquery. Stale delta rows are fine: the live read drops them.
|
|
2930
|
+
// Filter emitters before ranking so forged events cannot replace share bindings.
|
|
2931
|
+
// TIP-20 prefixes bound holder scans; live reads discard exited positions.
|
|
2041
2932
|
const result = await Timing.time(c, 'earn_positions_discovery', () => tidx.fetch({
|
|
2042
2933
|
chainId: options.chainId,
|
|
2043
2934
|
engine: 'clickhouse',
|
|
@@ -2052,6 +2943,7 @@ async function queryHeldVaults(c, options) {
|
|
|
2052
2943
|
ORDER BY block_num DESC, log_idx DESC
|
|
2053
2944
|
) AS deployment_rank
|
|
2054
2945
|
FROM EarnStackDeployed
|
|
2946
|
+
WHERE address IN (${factories.map((address) => `'${address}'`).join(', ')})
|
|
2055
2947
|
)
|
|
2056
2948
|
WHERE deployment_rank = 1 AND lower("earnShare") IN (
|
|
2057
2949
|
SELECT DISTINCT lower(token)
|
|
@@ -2068,21 +2960,17 @@ async function queryHeldVaults(c, options) {
|
|
|
2068
2960
|
return vault.success ? [vault.data.toLowerCase()] : [];
|
|
2069
2961
|
});
|
|
2070
2962
|
}
|
|
2071
|
-
/** Reads one account's live position in one vault. */
|
|
2072
|
-
function readPosition(c, options) {
|
|
2073
|
-
return c
|
|
2074
|
-
.get('getClient')(options.chainId)
|
|
2075
|
-
.earn.getPosition({ account: options.address, vault: options.vaultAddress });
|
|
2076
|
-
}
|
|
2077
2963
|
/** Serializes one live position into the address-scoped row contract. */
|
|
2078
2964
|
function serializePosition(options) {
|
|
2079
2965
|
const { position, tokens } = options;
|
|
2080
2966
|
const assetToken = getToken(tokens, position.assetToken);
|
|
2081
2967
|
const shareToken = getToken(tokens, position.shareToken);
|
|
2968
|
+
const valueToken = getToken(options.valueTokens ?? tokens, position.valueToken);
|
|
2082
2969
|
const vaultAddress = Schema.Address.parse(options.vaultAddress.toLowerCase());
|
|
2083
2970
|
return {
|
|
2084
|
-
assetAmount: valueFor(position.value,
|
|
2971
|
+
assetAmount: valueFor(position.value, valueToken),
|
|
2085
2972
|
assetToken,
|
|
2973
|
+
chainId: options.chainId,
|
|
2086
2974
|
id: vaultAddress,
|
|
2087
2975
|
...(options.cashFlows ? { lifetimeCashFlows: options.cashFlows } : {}),
|
|
2088
2976
|
shareAmount: valueFor(position.shareBalance, shareToken),
|
|
@@ -2093,10 +2981,11 @@ function serializePosition(options) {
|
|
|
2093
2981
|
amount: position.value,
|
|
2094
2982
|
denomination: options.denomination,
|
|
2095
2983
|
rates: options.rates,
|
|
2096
|
-
token: options.snapshot?.byAddress.get(
|
|
2984
|
+
token: options.snapshot?.byAddress.get(valueToken.address),
|
|
2097
2985
|
}),
|
|
2098
2986
|
}
|
|
2099
2987
|
: {}),
|
|
2988
|
+
valueToken,
|
|
2100
2989
|
vaultAddress,
|
|
2101
2990
|
verified: options.verified,
|
|
2102
2991
|
};
|
|
@@ -2257,7 +3146,7 @@ export async function getVault(c, options) {
|
|
|
2257
3146
|
record,
|
|
2258
3147
|
});
|
|
2259
3148
|
const discoveries = [discovery];
|
|
2260
|
-
const [apy, rates, tokens] = await Promise.all([
|
|
3149
|
+
const [apy, rates, rewards, tokens] = await Promise.all([
|
|
2261
3150
|
resolvePageApy(c, {
|
|
2262
3151
|
chainId: options.chainId,
|
|
2263
3152
|
include,
|
|
@@ -2265,6 +3154,11 @@ export async function getVault(c, options) {
|
|
|
2265
3154
|
window: options['apy.window'],
|
|
2266
3155
|
}),
|
|
2267
3156
|
resolvePageRates(c, { discoveries, include, oracle: options.oracle, snapshot }),
|
|
3157
|
+
resolveVaultRewards(c, {
|
|
3158
|
+
chainId: options.chainId,
|
|
3159
|
+
include,
|
|
3160
|
+
vault: discovery.vaultAddress,
|
|
3161
|
+
}),
|
|
2268
3162
|
resolvePageTokens(c, { chainId: options.chainId, discoveries, include, snapshot }),
|
|
2269
3163
|
]);
|
|
2270
3164
|
return {
|
|
@@ -2274,6 +3168,7 @@ export async function getVault(c, options) {
|
|
|
2274
3168
|
include,
|
|
2275
3169
|
rates,
|
|
2276
3170
|
record,
|
|
3171
|
+
rewards,
|
|
2277
3172
|
snapshot,
|
|
2278
3173
|
tokens,
|
|
2279
3174
|
zoneRoutes,
|
|
@@ -2320,7 +3215,16 @@ function discoveryInclude(options) {
|
|
|
2320
3215
|
];
|
|
2321
3216
|
}
|
|
2322
3217
|
async function resolveVaultDiscovery(c, options) {
|
|
2323
|
-
return Store.memoize(() =>
|
|
3218
|
+
return Store.memoize(() => readVaultDiscovery(c, options), {
|
|
3219
|
+
key: `earn-vault:v3:${options.chainId}:${options.vaultAddress.toLowerCase()}:include:${options.include.join(',') || 'base'}`,
|
|
3220
|
+
store: c.get('store'),
|
|
3221
|
+
// Matches the routes' `state` policy `max-age` so the two cache layers do
|
|
3222
|
+
// not compound staleness on live vault state.
|
|
3223
|
+
ttl: Ttl.seconds(30),
|
|
3224
|
+
});
|
|
3225
|
+
}
|
|
3226
|
+
async function readVaultDiscovery(c, options) {
|
|
3227
|
+
return Timing.time(c, 'earn_vault_discovery', () => EarnVaults.resolve({
|
|
2324
3228
|
getClient: c.get('getClient'),
|
|
2325
3229
|
include: options.include,
|
|
2326
3230
|
input: {
|
|
@@ -2328,13 +3232,7 @@ async function resolveVaultDiscovery(c, options) {
|
|
|
2328
3232
|
vaultAddress: options.vaultAddress,
|
|
2329
3233
|
},
|
|
2330
3234
|
zones: [...c.get('zones').values()],
|
|
2331
|
-
}))
|
|
2332
|
-
key: `earn-vault:v3:${options.chainId}:${options.vaultAddress.toLowerCase()}:include:${options.include.join(',') || 'base'}`,
|
|
2333
|
-
store: c.get('store'),
|
|
2334
|
-
// Matches the routes' `state` policy `max-age` so the two cache layers do
|
|
2335
|
-
// not compound staleness on live vault state.
|
|
2336
|
-
ttl: Ttl.seconds(30),
|
|
2337
|
-
});
|
|
3235
|
+
}));
|
|
2338
3236
|
}
|
|
2339
3237
|
async function resolveVaultRoutes(c, options) {
|
|
2340
3238
|
const { discovery, record } = options;
|
|
@@ -2369,6 +3267,106 @@ async function resolveVaultRoutes(c, options) {
|
|
|
2369
3267
|
: [],
|
|
2370
3268
|
};
|
|
2371
3269
|
}
|
|
3270
|
+
async function resolvePositionApy(c, options) {
|
|
3271
|
+
const sourceChainId = c.get('zones').get(options.chainId)?.sourceId ?? options.chainId;
|
|
3272
|
+
const recordFailure = (failure) => {
|
|
3273
|
+
Cache.setPolicy(c, Cache.policies.noStore);
|
|
3274
|
+
c.set('providerFailures', [...(c.get('providerFailures') ?? []), failure]);
|
|
3275
|
+
};
|
|
3276
|
+
const rateFailures = [];
|
|
3277
|
+
const [rates, discovery] = await Promise.all([
|
|
3278
|
+
Timing.time(c, 'earn_apy', () => EarnRates.resolve({
|
|
3279
|
+
chainId: sourceChainId,
|
|
3280
|
+
getClient: c.get('getClient'),
|
|
3281
|
+
getTidx: c.get('getTidx'),
|
|
3282
|
+
onFailure: (failure) => {
|
|
3283
|
+
rateFailures.push({ ...failure, chainId: sourceChainId });
|
|
3284
|
+
},
|
|
3285
|
+
store: c.get('store'),
|
|
3286
|
+
vaults: [options.vault],
|
|
3287
|
+
})).catch(() => {
|
|
3288
|
+
rateFailures.push({
|
|
3289
|
+
chainId: sourceChainId,
|
|
3290
|
+
failure: 'unknown',
|
|
3291
|
+
id: 'earn-apy',
|
|
3292
|
+
operation: 'resolve',
|
|
3293
|
+
});
|
|
3294
|
+
return undefined;
|
|
3295
|
+
}),
|
|
3296
|
+
resolveVaultDiscovery(c, {
|
|
3297
|
+
chainId: sourceChainId,
|
|
3298
|
+
include: [],
|
|
3299
|
+
vaultAddress: options.vault,
|
|
3300
|
+
}).catch((cause) => {
|
|
3301
|
+
const failure = Viem.requestFailure(cause);
|
|
3302
|
+
recordFailure(failure
|
|
3303
|
+
? { ...failure, chainId: sourceChainId, id: 'rpc', operation: 'eth_call' }
|
|
3304
|
+
: {
|
|
3305
|
+
chainId: sourceChainId,
|
|
3306
|
+
failure: 'unknown',
|
|
3307
|
+
id: 'earn-vaults',
|
|
3308
|
+
operation: 'getVault',
|
|
3309
|
+
});
|
|
3310
|
+
return undefined;
|
|
3311
|
+
}),
|
|
3312
|
+
]);
|
|
3313
|
+
const base = rates?.get(options.vault.toLowerCase());
|
|
3314
|
+
const rateFailure = rateFailures[0];
|
|
3315
|
+
if (rateFailure)
|
|
3316
|
+
recordFailure(rateFailure);
|
|
3317
|
+
if (!base || !discovery)
|
|
3318
|
+
return null;
|
|
3319
|
+
return await Timing.time(c, 'earn_rewards_apy', async () => {
|
|
3320
|
+
const [earnFees, record] = await Promise.all([
|
|
3321
|
+
c.get('getClient')(sourceChainId).readContract({
|
|
3322
|
+
abi: Abis.earnVault,
|
|
3323
|
+
address: options.vault,
|
|
3324
|
+
functionName: 'earnFees',
|
|
3325
|
+
}),
|
|
3326
|
+
core_EarnVaults.get(Db.get(c.get('db')), {
|
|
3327
|
+
chainId: options.chainId,
|
|
3328
|
+
vaultAddress: options.vault,
|
|
3329
|
+
}),
|
|
3330
|
+
]);
|
|
3331
|
+
// Accounting retains qualified shares for excluded infrastructure, so apply its current exclusions here too.
|
|
3332
|
+
const zoneContracts = [...c.get('zones').values()]
|
|
3333
|
+
.filter((zone) => zone.sourceId === options.chainId)
|
|
3334
|
+
.flatMap((zone) => positionApyContractAddresses(zone.contracts));
|
|
3335
|
+
return RewardRead.positionApy({
|
|
3336
|
+
assetDecimals: discovery.assetToken.decimals,
|
|
3337
|
+
baseNet: base.net,
|
|
3338
|
+
chainId: options.chainId,
|
|
3339
|
+
db: c.get('db'),
|
|
3340
|
+
excludedAddresses: [
|
|
3341
|
+
discovery.engine.address,
|
|
3342
|
+
earnFees,
|
|
3343
|
+
...(record?.zones.map((zone) => zone.earnRouter) ?? []),
|
|
3344
|
+
...zoneContracts,
|
|
3345
|
+
],
|
|
3346
|
+
recipient: options.recipient,
|
|
3347
|
+
shareBalance: options.shareBalance.toString(),
|
|
3348
|
+
value: options.value.toString(),
|
|
3349
|
+
vaultAddress: options.vault,
|
|
3350
|
+
});
|
|
3351
|
+
}).catch((cause) => {
|
|
3352
|
+
recordFailure(sharePriceProviderFailure({ cause, chainId: sourceChainId }) ?? {
|
|
3353
|
+
chainId: options.chainId,
|
|
3354
|
+
failure: 'unknown',
|
|
3355
|
+
id: 'earn-rewards',
|
|
3356
|
+
operation: 'getPositionApy',
|
|
3357
|
+
});
|
|
3358
|
+
return null;
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
function positionApyContractAddresses(contract) {
|
|
3362
|
+
if (!contract || typeof contract !== 'object')
|
|
3363
|
+
return [];
|
|
3364
|
+
const value = contract;
|
|
3365
|
+
const address = value['address'];
|
|
3366
|
+
if (typeof address === 'string' && isAddress(address))
|
|
3367
|
+
return [address];
|
|
3368
|
+
return Object.values(value).flatMap(positionApyContractAddresses);
|
|
3369
|
+
}
|
|
2372
3370
|
// Measuring a rate costs indexer boundary queries plus historical quotes against
|
|
2373
3371
|
// an archive node, so an unrequested rate reaches neither.
|
|
2374
3372
|
function resolvePageApy(c, options) {
|
|
@@ -2383,6 +3381,44 @@ function resolvePageApy(c, options) {
|
|
|
2383
3381
|
window: options.window,
|
|
2384
3382
|
}));
|
|
2385
3383
|
}
|
|
3384
|
+
function resolvePageRewards(c, options) {
|
|
3385
|
+
if (!options.include.includes('apy'))
|
|
3386
|
+
return undefined;
|
|
3387
|
+
return Timing.time(c, 'earn_rewards_apy', () => RewardRead.resolveCollection({
|
|
3388
|
+
chainId: options.chainId,
|
|
3389
|
+
db: c.get('dbCached'),
|
|
3390
|
+
vaults: options.vaults,
|
|
3391
|
+
}).catch(() => {
|
|
3392
|
+
Cache.setPolicy(c, Cache.policies.noStore);
|
|
3393
|
+
const failure = {
|
|
3394
|
+
chainId: options.chainId,
|
|
3395
|
+
failure: 'unknown',
|
|
3396
|
+
id: 'earn-rewards',
|
|
3397
|
+
operation: 'listVaultRewards',
|
|
3398
|
+
};
|
|
3399
|
+
c.set('providerFailures', [...(c.get('providerFailures') ?? []), failure]);
|
|
3400
|
+
return new Map();
|
|
3401
|
+
}));
|
|
3402
|
+
}
|
|
3403
|
+
function resolveVaultRewards(c, options) {
|
|
3404
|
+
if (!options.include.includes('apy'))
|
|
3405
|
+
return undefined;
|
|
3406
|
+
return Timing.time(c, 'earn_rewards_apy', () => RewardRead.get({
|
|
3407
|
+
chainId: options.chainId,
|
|
3408
|
+
db: c.get('dbCached'),
|
|
3409
|
+
vaultAddress: options.vault,
|
|
3410
|
+
}).catch(() => {
|
|
3411
|
+
Cache.setPolicy(c, Cache.policies.noStore);
|
|
3412
|
+
const failure = {
|
|
3413
|
+
chainId: options.chainId,
|
|
3414
|
+
failure: 'unknown',
|
|
3415
|
+
id: 'earn-rewards',
|
|
3416
|
+
operation: 'getVaultRewards',
|
|
3417
|
+
};
|
|
3418
|
+
c.set('providerFailures', [...(c.get('providerFailures') ?? []), failure]);
|
|
3419
|
+
return undefined;
|
|
3420
|
+
}));
|
|
3421
|
+
}
|
|
2386
3422
|
// The TVL denomination is a fixed constant, not caller input, so a rate set
|
|
2387
3423
|
// lacking it leaves `tvl` unpriced instead of failing the whole vault read.
|
|
2388
3424
|
function resolvePageRates(c, options) {
|
|
@@ -2453,6 +3489,7 @@ async function resolveVault(c, options) {
|
|
|
2453
3489
|
}
|
|
2454
3490
|
: null,
|
|
2455
3491
|
record,
|
|
3492
|
+
rewards: options.rewards,
|
|
2456
3493
|
shareToken: getToken(options.tokens, discovery.shareToken.address),
|
|
2457
3494
|
tvl: valued
|
|
2458
3495
|
? {
|
|
@@ -2474,9 +3511,37 @@ export function serializeVault(options) {
|
|
|
2474
3511
|
if (options.include.includes('capabilities') && !discovery.capabilities)
|
|
2475
3512
|
throw new Error('Earn vault capabilities were not resolved.');
|
|
2476
3513
|
const vaultAddress = Schema.Address.parse(discovery.vaultAddress.toLowerCase());
|
|
3514
|
+
const rewards = options.rewards?.map((reward) => ({
|
|
3515
|
+
apr: reward.currentRewardsAprBps === null ? null : RewardRead.ratio(reward.currentRewardsAprBps),
|
|
3516
|
+
asset: reward.asset,
|
|
3517
|
+
...(reward.calculatedThrough !== undefined
|
|
3518
|
+
? { calculatedThrough: reward.calculatedThrough }
|
|
3519
|
+
: {}),
|
|
3520
|
+
campaignId: reward.campaignId,
|
|
3521
|
+
endsAt: reward.endsAt,
|
|
3522
|
+
startsAt: reward.startsAt,
|
|
3523
|
+
targetTotalApr: RewardRead.ratio(reward.targetTotalAprBps),
|
|
3524
|
+
}));
|
|
3525
|
+
const startedRewards = options.rewards?.filter((reward) => reward.startsAt <= Math.floor(Date.now() / 1_000));
|
|
3526
|
+
const targetTotalAprBps = startedRewards?.reduce((target, reward) => Math.max(target, reward.targetTotalAprBps), 0);
|
|
3527
|
+
const apy = options.apy
|
|
3528
|
+
? {
|
|
3529
|
+
...options.apy,
|
|
3530
|
+
net: (() => {
|
|
3531
|
+
if (!startedRewards || startedRewards.length === 0)
|
|
3532
|
+
return options.apy.net;
|
|
3533
|
+
const target = targetTotalAprBps ?? 0;
|
|
3534
|
+
if (parseUnits(options.apy.net, 6) >= BigInt(target) * 100n)
|
|
3535
|
+
return options.apy.net;
|
|
3536
|
+
return RewardRead.ratio(target);
|
|
3537
|
+
})(),
|
|
3538
|
+
...(rewards ? { rewards } : {}),
|
|
3539
|
+
vault: options.apy.net,
|
|
3540
|
+
}
|
|
3541
|
+
: null;
|
|
2477
3542
|
return Response.validated(schema.Vault, {
|
|
2478
3543
|
...(options.include.includes('access') ? { access: discovery.access } : {}),
|
|
2479
|
-
...(options.include.includes('apy') ? { apy
|
|
3544
|
+
...(options.include.includes('apy') ? { apy } : {}),
|
|
2480
3545
|
assetToken: options.assetToken,
|
|
2481
3546
|
...(options.include.includes('capabilities') ? { capabilities: discovery.capabilities } : {}),
|
|
2482
3547
|
description: record?.description ?? null,
|
|
@@ -2560,6 +3625,9 @@ function getToken(tokens, address) {
|
|
|
2560
3625
|
return Response.validated(Tokens.schema.Token, token);
|
|
2561
3626
|
}
|
|
2562
3627
|
async function queryDeployments(c, options) {
|
|
3628
|
+
const factories = deploymentFactories[options.chainId] ?? [];
|
|
3629
|
+
if (factories.length === 0)
|
|
3630
|
+
return { hasMore: false, items: [] };
|
|
2563
3631
|
const filters = [];
|
|
2564
3632
|
if (options.asset)
|
|
2565
3633
|
filters.push(`lower(asset) = '${options.asset.toLowerCase()}'`);
|
|
@@ -2576,7 +3644,8 @@ async function queryDeployments(c, options) {
|
|
|
2576
3644
|
order: 'desc',
|
|
2577
3645
|
},
|
|
2578
3646
|
]));
|
|
2579
|
-
//
|
|
3647
|
+
// Authenticate emitters before deduplication so a forged newer event cannot
|
|
3648
|
+
// replace a factory deployment or suppress it through outer filters.
|
|
2580
3649
|
const result = await c
|
|
2581
3650
|
.get('getTidx')(options.chainId)
|
|
2582
3651
|
.fetch({
|
|
@@ -2591,6 +3660,7 @@ async function queryDeployments(c, options) {
|
|
|
2591
3660
|
block_num,
|
|
2592
3661
|
log_idx
|
|
2593
3662
|
FROM EarnStackDeployed
|
|
3663
|
+
WHERE address IN (${factories.map((address) => `'${address}'`).join(', ')})
|
|
2594
3664
|
ORDER BY block_num DESC, log_idx DESC
|
|
2595
3665
|
LIMIT 1 BY lower("earnVault")
|
|
2596
3666
|
)
|
|
@@ -2660,4 +3730,16 @@ class IndexedCoverageError extends Error {
|
|
|
2660
3730
|
super(`Indexed history does not yet cover ${asOf}.`);
|
|
2661
3731
|
}
|
|
2662
3732
|
}
|
|
3733
|
+
class ZoneHistoricalAlignmentError extends Error {
|
|
3734
|
+
name = 'Earn.ZoneHistoricalAlignmentError';
|
|
3735
|
+
constructor() {
|
|
3736
|
+
super('This Zone does not expose historical parent-chain synchronization checkpoints.');
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
class ZoneEarningsUnsupportedError extends Error {
|
|
3740
|
+
name = 'Earn.ZoneEarningsUnsupportedError';
|
|
3741
|
+
constructor() {
|
|
3742
|
+
super('Zone positions do not support the earnings include.');
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
2663
3745
|
//# sourceMappingURL=earn.js.map
|