tapimo 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +12457 -10365
- 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 -549
- 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 +159 -7
- 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 +88 -88
- package/dist/admin/apps/verified-tokens.d.ts.map +1 -1
- package/dist/admin/apps/verified-tokens.js +3 -3
- 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 +129 -69
- 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 +364 -34
- 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 +37 -37
- 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 +5 -0
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +31 -19
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +125 -0
- 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/rpc.d.ts +507 -33
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +266 -156
- 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 +28 -12
- 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 +30 -30
- package/dist/apps/data/routes/verified-tokens.d.ts +9 -9
- 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 +613 -176
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +291 -195
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- 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 +3763 -3385
- 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 +106 -4
- 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 +77 -2
- 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 +4 -4
- 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 +18 -2
- 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 +4 -4
- 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 +2 -2
- package/dist/apps/management/routes/webhooks.d.ts +280 -214
- 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.js +7 -7
- package/dist/apps/mcp.js.map +1 -1
- 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 +7 -7
- 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 +19 -16
- 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 +379 -74
- 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 +1030 -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/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 +48 -12
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +603 -175
- 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 +8 -3
- package/src/admin/apps/verified-tokens.ts +3 -3
- 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/routeTree.gen.ts +63 -0
- package/src/admin/ui/src/routes/__root.tsx +12 -1
- 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_.$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.generated.ts +144 -69
- 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 +154 -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 +224 -0
- package/src/apps/data/routes/fee-amm.ts +191 -160
- 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 +352 -8
- package/src/apps/data/routes/rpc.ts +407 -219
- 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.test.ts +645 -83
- package/src/apps/data/routes/webhooks.ts +1089 -857
- 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/webhooks.test.ts +49 -26
- package/src/apps/management/routes/webhooks.ts +78 -22
- package/src/apps/mcp.test.ts +6 -6
- package/src/apps/mcp.ts +7 -7
- 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 +1476 -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} +316 -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/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 +1564 -9
- package/src/internal/Auth.ts +833 -239
- 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 +165 -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
|
@@ -0,0 +1,1205 @@
|
|
|
1
|
+
import {
|
|
2
|
+
concatHex,
|
|
3
|
+
encodeAbiParameters,
|
|
4
|
+
getAddress,
|
|
5
|
+
keccak256,
|
|
6
|
+
parseAbiParameters,
|
|
7
|
+
stringToBytes,
|
|
8
|
+
zeroAddress,
|
|
9
|
+
type Address,
|
|
10
|
+
type Hex,
|
|
11
|
+
} from 'viem'
|
|
12
|
+
import * as z from 'zod/mini'
|
|
13
|
+
|
|
14
|
+
import * as Schema from '../Schema.js'
|
|
15
|
+
|
|
16
|
+
const maximumUint256 = (1n << 256n) - 1n
|
|
17
|
+
// EarnVault permits at most one basis point of conversion-floor loss. Funding at least 10,001 raw
|
|
18
|
+
// EarnShare units makes the loss of less than one raw unit strictly smaller than that bound.
|
|
19
|
+
const minimumSettlementFundingEarnShares = 10_001n
|
|
20
|
+
// Keeps the exact provider batch comfortably inside the signer's 28M gas envelope.
|
|
21
|
+
const maximumFundingLegs = 8
|
|
22
|
+
const leafParameters = parseAbiParameters('uint256,address,bytes32,address,uint256')
|
|
23
|
+
const basisPoints = z
|
|
24
|
+
.number()
|
|
25
|
+
.check(
|
|
26
|
+
z.int(),
|
|
27
|
+
z.nonnegative(),
|
|
28
|
+
z.lte(10_000),
|
|
29
|
+
z.describe('Annual rate in basis points, where 10,000 is 100%.'),
|
|
30
|
+
z.meta({ examples: [700] }),
|
|
31
|
+
)
|
|
32
|
+
const positiveBasisPoints = basisPoints.check(
|
|
33
|
+
z.positive(),
|
|
34
|
+
z.describe('Positive annual rate in basis points, where 10,000 is 100%.'),
|
|
35
|
+
)
|
|
36
|
+
const uint256 = Schema.DecimalString.check(
|
|
37
|
+
z.refine((value) => BigInt(value) <= maximumUint256, { error: 'value exceeds uint256' }),
|
|
38
|
+
z.describe('Unsigned 256-bit integer encoded as a decimal string.'),
|
|
39
|
+
)
|
|
40
|
+
const nonzeroAddress = Schema.Address.check(
|
|
41
|
+
z.refine((address) => address !== zeroAddress, { error: 'address must be nonzero' }),
|
|
42
|
+
z.describe('Nonzero Tempo account or contract address.'),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
/** Zod schemas for Earn reward campaigns. */
|
|
46
|
+
export namespace schema {
|
|
47
|
+
const AnnualRate = z
|
|
48
|
+
.union([
|
|
49
|
+
z.strictObject({ bps: positiveBasisPoints }).check(z.describe('Fixed annual target rate.')),
|
|
50
|
+
z
|
|
51
|
+
.strictObject({
|
|
52
|
+
maxBps: basisPoints,
|
|
53
|
+
minBps: basisPoints,
|
|
54
|
+
morphoVault: nonzeroAddress,
|
|
55
|
+
staleAfterSeconds: z
|
|
56
|
+
.number()
|
|
57
|
+
.check(
|
|
58
|
+
z.int(),
|
|
59
|
+
z.positive(),
|
|
60
|
+
z.describe('Maximum age in seconds of a reusable Morpho rate observation.'),
|
|
61
|
+
z.meta({ examples: [3_600] }),
|
|
62
|
+
),
|
|
63
|
+
})
|
|
64
|
+
.check(
|
|
65
|
+
z.refine((rate) => rate.minBps <= rate.maxBps, {
|
|
66
|
+
error: 'Morpho minBps must not exceed maxBps',
|
|
67
|
+
}),
|
|
68
|
+
z.describe('Base Morpho vault rate source with configured safety bounds.'),
|
|
69
|
+
),
|
|
70
|
+
])
|
|
71
|
+
.check(
|
|
72
|
+
z.describe('Fixed annual rate or bounded Base Morpho vault rate source.'),
|
|
73
|
+
z.meta({ examples: [{ bps: 500 }] }),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
const FundingLeg = z
|
|
77
|
+
.union([
|
|
78
|
+
z
|
|
79
|
+
.strictObject({
|
|
80
|
+
upToAnnualRate: z
|
|
81
|
+
.strictObject({ bps: positiveBasisPoints })
|
|
82
|
+
.check(z.describe('Cumulative annual target funded through this leg.')),
|
|
83
|
+
wallet: nonzeroAddress,
|
|
84
|
+
})
|
|
85
|
+
.check(z.describe('Funding wallet responsible up to one cumulative annual rate.')),
|
|
86
|
+
z
|
|
87
|
+
.strictObject({
|
|
88
|
+
remainder: z
|
|
89
|
+
.literal(true)
|
|
90
|
+
.check(
|
|
91
|
+
z.describe('Marks the final wallet as responsible for the remaining target.'),
|
|
92
|
+
z.meta({ examples: [true] }),
|
|
93
|
+
),
|
|
94
|
+
wallet: nonzeroAddress,
|
|
95
|
+
})
|
|
96
|
+
.check(z.describe('Final funding wallet responsible for the remaining target yield.')),
|
|
97
|
+
])
|
|
98
|
+
.check(z.describe('One ordered target-yield funding-waterfall leg.'))
|
|
99
|
+
|
|
100
|
+
/** Target-yield configuration for one vault. */
|
|
101
|
+
export const TargetYield = z
|
|
102
|
+
.strictObject({
|
|
103
|
+
annualRate: AnnualRate,
|
|
104
|
+
endTimestamp: z
|
|
105
|
+
.number()
|
|
106
|
+
.check(
|
|
107
|
+
z.int(),
|
|
108
|
+
z.positive(),
|
|
109
|
+
z.describe('Exclusive Unix timestamp when target-yield funding ends.'),
|
|
110
|
+
z.meta({ examples: [1_788_195_600] }),
|
|
111
|
+
),
|
|
112
|
+
funding: z.array(FundingLeg).check(
|
|
113
|
+
z.minLength(1),
|
|
114
|
+
z.maxLength(maximumFundingLegs),
|
|
115
|
+
z.describe('Ordered funding waterfall ending in exactly one remainder wallet.'),
|
|
116
|
+
z.meta({
|
|
117
|
+
examples: [[{ remainder: true, wallet: '0x5000000000000000000000000000000000000005' }]],
|
|
118
|
+
}),
|
|
119
|
+
),
|
|
120
|
+
intervalSeconds: z
|
|
121
|
+
.number()
|
|
122
|
+
.check(
|
|
123
|
+
z.int(),
|
|
124
|
+
z.gte(60),
|
|
125
|
+
z.lte(300),
|
|
126
|
+
z.describe('Target-yield accounting interval in seconds.'),
|
|
127
|
+
z.meta({ examples: [300] }),
|
|
128
|
+
),
|
|
129
|
+
startTimestamp: z
|
|
130
|
+
.number()
|
|
131
|
+
.check(
|
|
132
|
+
z.int(),
|
|
133
|
+
z.nonnegative(),
|
|
134
|
+
z.describe('Inclusive Unix timestamp when target-yield funding starts.'),
|
|
135
|
+
z.meta({ examples: [1_788_192_000] }),
|
|
136
|
+
),
|
|
137
|
+
})
|
|
138
|
+
.check(z.describe('Target-yield configuration for one verified Earn vault.'))
|
|
139
|
+
|
|
140
|
+
/** Automatic cumulative-payout schedule for one boost campaign. */
|
|
141
|
+
const PayoutSchedule = z
|
|
142
|
+
.strictObject({
|
|
143
|
+
intervalSeconds: z
|
|
144
|
+
.number()
|
|
145
|
+
.check(
|
|
146
|
+
z.int(),
|
|
147
|
+
z.positive(),
|
|
148
|
+
z.describe('Interval between automatic boost payouts, in seconds.'),
|
|
149
|
+
z.meta({ examples: [86_400] }),
|
|
150
|
+
),
|
|
151
|
+
startTimestamp: z
|
|
152
|
+
.number()
|
|
153
|
+
.check(
|
|
154
|
+
z.int(),
|
|
155
|
+
z.nonnegative(),
|
|
156
|
+
z.describe('Unix timestamp after which the next settlement triggers the first payout.'),
|
|
157
|
+
z.meta({ examples: [1_788_220_800] }),
|
|
158
|
+
),
|
|
159
|
+
})
|
|
160
|
+
.check(z.describe('Automatic boost payout schedule.'))
|
|
161
|
+
|
|
162
|
+
/** Registered-depositor boost configuration for one vault. */
|
|
163
|
+
export const BoostRewards = z
|
|
164
|
+
.strictObject({
|
|
165
|
+
enabled: z
|
|
166
|
+
.optional(z.boolean())
|
|
167
|
+
.check(
|
|
168
|
+
z.describe('Whether new depositor boost rewards accrue during the configured schedule.'),
|
|
169
|
+
z.meta({ examples: [true] }),
|
|
170
|
+
),
|
|
171
|
+
endTimestamp: z
|
|
172
|
+
.number()
|
|
173
|
+
.check(
|
|
174
|
+
z.int(),
|
|
175
|
+
z.positive(),
|
|
176
|
+
z.describe('Exclusive Unix timestamp when boost rewards end.'),
|
|
177
|
+
z.meta({ examples: [1_788_195_600] }),
|
|
178
|
+
),
|
|
179
|
+
excludedAddresses: z
|
|
180
|
+
.array(nonzeroAddress)
|
|
181
|
+
.check(
|
|
182
|
+
z.describe('Additional public holders excluded from boost rewards.'),
|
|
183
|
+
z.meta({ examples: [[]] }),
|
|
184
|
+
),
|
|
185
|
+
funding: z.strictObject({ wallet: nonzeroAddress }).check(
|
|
186
|
+
z.describe('Wallet funding EarnShare boost settlements.'),
|
|
187
|
+
z.meta({
|
|
188
|
+
examples: [{ wallet: '0x5000000000000000000000000000000000000005' }],
|
|
189
|
+
}),
|
|
190
|
+
),
|
|
191
|
+
intervalSeconds: z
|
|
192
|
+
.number()
|
|
193
|
+
.check(
|
|
194
|
+
z.int(),
|
|
195
|
+
z.gte(60),
|
|
196
|
+
z.lte(300),
|
|
197
|
+
z.describe('Boost-reward accounting interval in seconds.'),
|
|
198
|
+
z.meta({ examples: [300] }),
|
|
199
|
+
),
|
|
200
|
+
payoutSchedule: z
|
|
201
|
+
.optional(PayoutSchedule)
|
|
202
|
+
.check(
|
|
203
|
+
z.describe('Optional schedule for automatically pushing accumulated boost rewards.'),
|
|
204
|
+
),
|
|
205
|
+
perUserPrincipalCapAssets: uint256.check(
|
|
206
|
+
z.describe('Maximum qualifying principal per registered wallet in base-asset units.'),
|
|
207
|
+
z.meta({ examples: ['25000000000'] }),
|
|
208
|
+
),
|
|
209
|
+
startTimestamp: z
|
|
210
|
+
.number()
|
|
211
|
+
.check(
|
|
212
|
+
z.int(),
|
|
213
|
+
z.nonnegative(),
|
|
214
|
+
z.describe('Inclusive Unix timestamp when boost rewards start.'),
|
|
215
|
+
z.meta({ examples: [1_788_192_000] }),
|
|
216
|
+
),
|
|
217
|
+
targetAnnualRateBps: positiveBasisPoints.check(
|
|
218
|
+
z.describe('Target total annual rate for qualified principal, in basis points.'),
|
|
219
|
+
),
|
|
220
|
+
totalPrincipalCapAssets: uint256.check(
|
|
221
|
+
z.describe('Campaign-wide qualifying principal cap in base-asset units.'),
|
|
222
|
+
z.meta({ examples: ['10000000000000'] }),
|
|
223
|
+
),
|
|
224
|
+
treasury: nonzeroAddress.check(
|
|
225
|
+
z.describe('Immutable recipient of unclaimed EarnShare returned by the distributor.'),
|
|
226
|
+
),
|
|
227
|
+
})
|
|
228
|
+
.check(z.describe('Registered-depositor EarnShare boost configuration for one vault.'))
|
|
229
|
+
|
|
230
|
+
/** Complete rewards configuration for one verified Earn vault. */
|
|
231
|
+
export const Config = z
|
|
232
|
+
.strictObject({
|
|
233
|
+
boostRewards: z
|
|
234
|
+
.optional(BoostRewards)
|
|
235
|
+
.check(z.describe('Optional registered-depositor EarnShare boost configuration.')),
|
|
236
|
+
targetYield: z
|
|
237
|
+
.optional(TargetYield)
|
|
238
|
+
.check(z.describe('Optional target-yield funding configuration.')),
|
|
239
|
+
})
|
|
240
|
+
.check(
|
|
241
|
+
z.refine((config) => Boolean(config.boostRewards || config.targetYield), {
|
|
242
|
+
error: 'targetYield or boostRewards is required',
|
|
243
|
+
}),
|
|
244
|
+
z.refine(
|
|
245
|
+
(config) =>
|
|
246
|
+
!config.targetYield ||
|
|
247
|
+
!config.boostRewards ||
|
|
248
|
+
config.targetYield.intervalSeconds === config.boostRewards.intervalSeconds,
|
|
249
|
+
{ error: 'targetYield and boostRewards must use one intervalSeconds value' },
|
|
250
|
+
),
|
|
251
|
+
z.refine(
|
|
252
|
+
(config) =>
|
|
253
|
+
!config.targetYield ||
|
|
254
|
+
!config.boostRewards ||
|
|
255
|
+
Math.abs(config.targetYield.startTimestamp - config.boostRewards.startTimestamp) %
|
|
256
|
+
config.targetYield.intervalSeconds ===
|
|
257
|
+
0,
|
|
258
|
+
{ error: 'targetYield and boostRewards schedules must share one interval grid' },
|
|
259
|
+
),
|
|
260
|
+
z.refine(
|
|
261
|
+
(config) =>
|
|
262
|
+
!config.targetYield ||
|
|
263
|
+
(config.targetYield.endTimestamp - config.targetYield.startTimestamp >=
|
|
264
|
+
config.targetYield.intervalSeconds &&
|
|
265
|
+
config.targetYield.funding.filter((leg) => 'remainder' in leg).length === 1 &&
|
|
266
|
+
config.targetYield.funding.every(
|
|
267
|
+
(leg, index) =>
|
|
268
|
+
!('remainder' in leg) || index === config.targetYield!.funding.length - 1,
|
|
269
|
+
) &&
|
|
270
|
+
config.targetYield.funding.every((leg, index, funding) => {
|
|
271
|
+
if ('remainder' in leg || index === 0) return true
|
|
272
|
+
const previous = funding[index - 1]!
|
|
273
|
+
return (
|
|
274
|
+
'upToAnnualRate' in previous && leg.upToAnnualRate.bps > previous.upToAnnualRate.bps
|
|
275
|
+
)
|
|
276
|
+
}) &&
|
|
277
|
+
new Set(config.targetYield.funding.map((leg) => leg.wallet)).size ===
|
|
278
|
+
config.targetYield.funding.length),
|
|
279
|
+
{ error: 'targetYield schedule or funding waterfall is invalid' },
|
|
280
|
+
),
|
|
281
|
+
z.refine(
|
|
282
|
+
(config) =>
|
|
283
|
+
!config.boostRewards ||
|
|
284
|
+
(config.boostRewards.endTimestamp - config.boostRewards.startTimestamp >=
|
|
285
|
+
config.boostRewards.intervalSeconds &&
|
|
286
|
+
BigInt(config.boostRewards.perUserPrincipalCapAssets) > 0n &&
|
|
287
|
+
BigInt(config.boostRewards.perUserPrincipalCapAssets) <=
|
|
288
|
+
BigInt(config.boostRewards.totalPrincipalCapAssets) &&
|
|
289
|
+
new Set(config.boostRewards.excludedAddresses).size ===
|
|
290
|
+
config.boostRewards.excludedAddresses.length),
|
|
291
|
+
{ error: 'boostRewards schedule or principal caps are invalid' },
|
|
292
|
+
),
|
|
293
|
+
z.refine(
|
|
294
|
+
(config) => {
|
|
295
|
+
const boost = config.boostRewards
|
|
296
|
+
const payout = boost?.payoutSchedule
|
|
297
|
+
return (
|
|
298
|
+
!boost ||
|
|
299
|
+
!payout ||
|
|
300
|
+
(payout.intervalSeconds > boost.intervalSeconds &&
|
|
301
|
+
payout.startTimestamp > boost.startTimestamp &&
|
|
302
|
+
payout.startTimestamp <= boost.endTimestamp)
|
|
303
|
+
)
|
|
304
|
+
},
|
|
305
|
+
{ error: 'boostRewards payoutSchedule must be slower than its accounting interval' },
|
|
306
|
+
),
|
|
307
|
+
z.describe('Complete reward configuration for one verified Earn vault.'),
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Returns the single accounting interval shared by the configured capabilities. */
|
|
312
|
+
export function intervalSeconds(config: Config): number {
|
|
313
|
+
return config.targetYield?.intervalSeconds ?? config.boostRewards!.intervalSeconds
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** Returns the final complete accounting boundary, excluding a trailing partial interval. */
|
|
317
|
+
export function finalBoundary(config: Config): number {
|
|
318
|
+
return Math.max(
|
|
319
|
+
...[config.targetYield, config.boostRewards]
|
|
320
|
+
.filter((schedule): schedule is NonNullable<typeof schedule> => schedule !== undefined)
|
|
321
|
+
.map(
|
|
322
|
+
(schedule) =>
|
|
323
|
+
schedule.startTimestamp +
|
|
324
|
+
Math.floor((schedule.endTimestamp - schedule.startTimestamp) / schedule.intervalSeconds) *
|
|
325
|
+
schedule.intervalSeconds,
|
|
326
|
+
),
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Returns whether a completed accounting range overlaps one schedule's complete intervals. */
|
|
331
|
+
export function overlapsCompleteIntervals(
|
|
332
|
+
schedule: NonNullable<Config['boostRewards'] | Config['targetYield']>,
|
|
333
|
+
options: overlapsCompleteIntervals.Options,
|
|
334
|
+
): boolean {
|
|
335
|
+
const final =
|
|
336
|
+
schedule.startTimestamp +
|
|
337
|
+
Math.floor((schedule.endTimestamp - schedule.startTimestamp) / schedule.intervalSeconds) *
|
|
338
|
+
schedule.intervalSeconds
|
|
339
|
+
return options.endsAt > schedule.startTimestamp && options.startsAfter < final
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export declare namespace overlapsCompleteIntervals {
|
|
343
|
+
/** Completed accounting range tested against one reward schedule. */
|
|
344
|
+
type Options = {
|
|
345
|
+
/** Inclusive closing accounting boundary. */
|
|
346
|
+
endsAt: number
|
|
347
|
+
/** Exclusive opening accounting boundary. */
|
|
348
|
+
startsAfter: number
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Returns whether one completed run should automatically push accumulated boost rewards. */
|
|
353
|
+
export function shouldPushPayout(
|
|
354
|
+
boost: NonNullable<Config['boostRewards']>,
|
|
355
|
+
options: shouldPushPayout.Options,
|
|
356
|
+
): boolean {
|
|
357
|
+
const payout = boost.payoutSchedule
|
|
358
|
+
if (!payout) return true
|
|
359
|
+
const final = finalBoundary({ boostRewards: boost })
|
|
360
|
+
if (options.startsAfter < final && options.endsAt >= final) return true
|
|
361
|
+
// Later campaign runs retry recipients whose forced final transfer was temporarily unavailable.
|
|
362
|
+
if (options.startsAfter >= final) return true
|
|
363
|
+
if (options.endsAt < payout.startTimestamp) return false
|
|
364
|
+
const previous =
|
|
365
|
+
options.startsAfter < payout.startTimestamp
|
|
366
|
+
? -1
|
|
367
|
+
: Math.floor((options.startsAfter - payout.startTimestamp) / payout.intervalSeconds)
|
|
368
|
+
const current = Math.floor((options.endsAt - payout.startTimestamp) / payout.intervalSeconds)
|
|
369
|
+
return current > previous
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export declare namespace shouldPushPayout {
|
|
373
|
+
/** Completed accounting range considered for an automatic payout. */
|
|
374
|
+
type Options = {
|
|
375
|
+
/** Inclusive closing accounting boundary. */
|
|
376
|
+
endsAt: number
|
|
377
|
+
/** Exclusive opening accounting boundary. */
|
|
378
|
+
startsAfter: number
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** Converts base assets into EarnShare at the fee-inclusive vault NAV, rounding down. */
|
|
383
|
+
export function assetsToEarnShares(options: {
|
|
384
|
+
assets: bigint
|
|
385
|
+
totalAssets: bigint
|
|
386
|
+
totalEarnShares: bigint
|
|
387
|
+
}): bigint {
|
|
388
|
+
if (options.assets < 0n) throw new Error('assets must be nonnegative')
|
|
389
|
+
requirePositiveVaultQuote(options)
|
|
390
|
+
return (options.assets * options.totalEarnShares) / options.totalAssets
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Converts EarnShare into the assets needed at the fee-inclusive vault NAV, rounding up. */
|
|
394
|
+
export function earnSharesToAssets(options: {
|
|
395
|
+
earnShares: bigint
|
|
396
|
+
totalAssets: bigint
|
|
397
|
+
totalEarnShares: bigint
|
|
398
|
+
}): bigint {
|
|
399
|
+
if (options.earnShares < 0n) throw new Error('EarnShare must be nonnegative')
|
|
400
|
+
requirePositiveVaultQuote(options)
|
|
401
|
+
if (options.earnShares === 0n) return 0n
|
|
402
|
+
return (
|
|
403
|
+
(options.earnShares * options.totalAssets + options.totalEarnShares - 1n) /
|
|
404
|
+
options.totalEarnShares
|
|
405
|
+
)
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** Returns the inventory mint needed to fund a missing liability without coarse conversion loss. */
|
|
409
|
+
export function settlementFundingEarnShares(missingEarnShares: bigint): bigint {
|
|
410
|
+
if (missingEarnShares < 0n) throw new Error('missing EarnShare must be nonnegative')
|
|
411
|
+
if (missingEarnShares === 0n) return 0n
|
|
412
|
+
return missingEarnShares < minimumSettlementFundingEarnShares
|
|
413
|
+
? minimumSettlementFundingEarnShares
|
|
414
|
+
: missingEarnShares
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function requirePositiveVaultQuote(options: { totalAssets: bigint; totalEarnShares: bigint }) {
|
|
418
|
+
if (options.totalAssets <= 0n || options.totalEarnShares <= 0n)
|
|
419
|
+
throw new Error('vault quote requires positive assets and fee-inclusive EarnShare supply')
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** Removes explicit contributions from one interval's measured exchange-rate growth. */
|
|
423
|
+
export function organicGrowth(options: organicGrowth.Options): bigint {
|
|
424
|
+
const change = organicChange(options)
|
|
425
|
+
return change > 0n ? change : 0n
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/** Removes explicit contributions from signed exchange-rate changes, retaining losses for interval aggregation. */
|
|
429
|
+
export function organicChange(options: organicChange.Options): bigint {
|
|
430
|
+
if (options.openingAssets === 0n && options.openingEarnShareSupply === 0n) return 0n
|
|
431
|
+
if (
|
|
432
|
+
options.openingAssets <= 0n ||
|
|
433
|
+
options.openingEarnShareSupply <= 0n ||
|
|
434
|
+
options.openingValuePerEarnShare <= 0n
|
|
435
|
+
)
|
|
436
|
+
throw new Error('opening target-yield state must be positive')
|
|
437
|
+
const gross =
|
|
438
|
+
(options.openingAssets *
|
|
439
|
+
(options.closingValuePerEarnShare - options.openingValuePerEarnShare)) /
|
|
440
|
+
options.openingValuePerEarnShare
|
|
441
|
+
const contributed = options.contributions.reduce((sum, contribution) => {
|
|
442
|
+
if (contribution.earnShareSupply <= 0n)
|
|
443
|
+
throw new Error('contribution EarnShare supply must be positive')
|
|
444
|
+
return (
|
|
445
|
+
sum + (contribution.assets * options.openingEarnShareSupply) / contribution.earnShareSupply
|
|
446
|
+
)
|
|
447
|
+
}, 0n)
|
|
448
|
+
return gross - contributed
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export declare namespace organicChange {
|
|
452
|
+
/** Exchange-rate values and contributions whose signed change is measured. */
|
|
453
|
+
type Options = organicGrowth.Options
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export declare namespace organicGrowth {
|
|
457
|
+
/** One contribution normalized against its post-contribution holder supply. */
|
|
458
|
+
type Contribution = {
|
|
459
|
+
/** Contributed base-asset units. */
|
|
460
|
+
assets: bigint
|
|
461
|
+
/** Fee-inclusive EarnShare supply after the contribution. */
|
|
462
|
+
earnShareSupply: bigint
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** Target-yield interval values. */
|
|
466
|
+
type Options = {
|
|
467
|
+
/** Closing base assets per fixed EarnShare quote. */
|
|
468
|
+
closingValuePerEarnShare: bigint
|
|
469
|
+
/** Explicit contributions included in the closing value. */
|
|
470
|
+
contributions: readonly Contribution[]
|
|
471
|
+
/** Opening active base assets. */
|
|
472
|
+
openingAssets: bigint
|
|
473
|
+
/** Fee-inclusive opening EarnShare supply used to normalize mid-interval contributions. */
|
|
474
|
+
openingEarnShareSupply: bigint
|
|
475
|
+
/** Opening base assets per fixed EarnShare quote. */
|
|
476
|
+
openingValuePerEarnShare: bigint
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** Allocates an interval's target shortfall using principal held between EarnShare supply changes. */
|
|
481
|
+
export function targetFunding(options: targetFunding.Options): targetFunding.Result {
|
|
482
|
+
// Boundary blocks can change NAV without adding elapsed principal exposure.
|
|
483
|
+
const change = options.periods.reduce((sum, period) => sum + organicChange(period), 0n)
|
|
484
|
+
const growthAssets = change > 0n ? change : 0n
|
|
485
|
+
const principalAssetSeconds = options.periods.reduce((sum, period) => {
|
|
486
|
+
if (!Number.isSafeInteger(period.elapsedSeconds) || period.elapsedSeconds < 0)
|
|
487
|
+
throw new Error('target-yield period duration must be a nonnegative integer')
|
|
488
|
+
return sum + period.openingAssets * BigInt(period.elapsedSeconds)
|
|
489
|
+
}, 0n)
|
|
490
|
+
let funded = 0n
|
|
491
|
+
const remainders: bigint[] = []
|
|
492
|
+
const assets = options.funding.map((leg, index) => {
|
|
493
|
+
const annualRateBps =
|
|
494
|
+
'remainder' in leg
|
|
495
|
+
? options.annualRateBps
|
|
496
|
+
: Math.min(options.annualRateBps, leg.upToAnnualRate.bps)
|
|
497
|
+
// Asset-seconds preserve sub-unit principal exposure without rounding an average balance.
|
|
498
|
+
const accrued = accrue({
|
|
499
|
+
annualRateBps,
|
|
500
|
+
elapsedSeconds: 1,
|
|
501
|
+
principalAssets: principalAssetSeconds,
|
|
502
|
+
remainder: options.remainders[index] ?? 0n,
|
|
503
|
+
})
|
|
504
|
+
remainders.push(accrued.remainder)
|
|
505
|
+
const amount =
|
|
506
|
+
accrued.amount > growthAssets + funded ? accrued.amount - growthAssets - funded : 0n
|
|
507
|
+
funded += amount
|
|
508
|
+
return amount
|
|
509
|
+
})
|
|
510
|
+
return { assets, remainders }
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export declare namespace targetFunding {
|
|
514
|
+
/** One period with unchanged EarnShare supply. */
|
|
515
|
+
type Period = organicGrowth.Options & {
|
|
516
|
+
/** Seconds for which the opening principal remained active. */
|
|
517
|
+
elapsedSeconds: number
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/** Target funding calculation for one complete accounting interval. */
|
|
521
|
+
type Options = {
|
|
522
|
+
/** Resolved target annual rate in basis points. */
|
|
523
|
+
annualRateBps: number
|
|
524
|
+
/** Ordered funding waterfall. */
|
|
525
|
+
funding: readonly NonNullable<Config['targetYield']>['funding'][number][]
|
|
526
|
+
/** Historical periods covering the complete interval. */
|
|
527
|
+
periods: readonly Period[]
|
|
528
|
+
/** Exact accrual remainders carried from the preceding interval. */
|
|
529
|
+
remainders: readonly bigint[]
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** Exact assets and accrual remainders for each funding leg. */
|
|
533
|
+
type Result = {
|
|
534
|
+
/** Assets requested from each funding wallet. */
|
|
535
|
+
assets: bigint[]
|
|
536
|
+
/** Accrual remainders retained for the next interval. */
|
|
537
|
+
remainders: bigint[]
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/** Annualizes contribution-adjusted asset growth as a simple ACT/365 rate. */
|
|
542
|
+
export function annualRateBps(options: annualRateBps.Options): number {
|
|
543
|
+
if (!Number.isSafeInteger(options.elapsedSeconds) || options.elapsedSeconds <= 0)
|
|
544
|
+
throw new Error('elapsed seconds must be positive')
|
|
545
|
+
if (options.growthAssets < 0n) throw new Error('growth assets must be nonnegative')
|
|
546
|
+
if (options.principalAssets < 0n) throw new Error('principal assets must be nonnegative')
|
|
547
|
+
if (options.principalAssets === 0n) return 0
|
|
548
|
+
const rate =
|
|
549
|
+
(options.growthAssets * 10_000n * 365n * 24n * 60n * 60n) /
|
|
550
|
+
(options.principalAssets * BigInt(options.elapsedSeconds))
|
|
551
|
+
if (rate > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error('annual rate exceeds safe range')
|
|
552
|
+
return Number(rate)
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export declare namespace annualRateBps {
|
|
556
|
+
/** Inputs for annualizing exact interval growth. */
|
|
557
|
+
type Options = {
|
|
558
|
+
/** Closed interval length in seconds. */
|
|
559
|
+
elapsedSeconds: number
|
|
560
|
+
/** Contribution-adjusted growth in base-asset units. */
|
|
561
|
+
growthAssets: bigint
|
|
562
|
+
/** Opening base-asset principal. */
|
|
563
|
+
principalAssets: bigint
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/** Resolves the effective base and incremental boost rates for one interval. */
|
|
568
|
+
export function rewardRates(options: rewardRates.Options): rewardRates.Result {
|
|
569
|
+
for (const rate of [
|
|
570
|
+
options.boostTargetRateBps,
|
|
571
|
+
options.organicRateBps,
|
|
572
|
+
options.targetRateBps ?? 0,
|
|
573
|
+
])
|
|
574
|
+
if (!Number.isSafeInteger(rate) || rate < 0) throw new Error('reward rate is invalid')
|
|
575
|
+
const baseRateBps = Math.max(options.organicRateBps, options.targetRateBps ?? 0)
|
|
576
|
+
return {
|
|
577
|
+
baseRateBps,
|
|
578
|
+
boostRateBps: Math.max(options.boostTargetRateBps - baseRateBps, 0),
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
export declare namespace rewardRates {
|
|
583
|
+
/** Rate targets and observed growth for one closed interval. */
|
|
584
|
+
type Options = {
|
|
585
|
+
/** Total annual rate targeted for qualified depositors. */
|
|
586
|
+
boostTargetRateBps: number
|
|
587
|
+
/** Contribution-adjusted annual rate observed during the interval. */
|
|
588
|
+
organicRateBps: number
|
|
589
|
+
/** Active target-yield floor. */
|
|
590
|
+
targetRateBps?: number | undefined
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** Effective base and incremental boost rates for one closed interval. */
|
|
594
|
+
type Result = {
|
|
595
|
+
/** Higher of organic growth and the active target-yield floor. */
|
|
596
|
+
baseRateBps: number
|
|
597
|
+
/** Incremental depositor rate needed to reach the total target. */
|
|
598
|
+
boostRateBps: number
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/** Complete rewards configuration for one verified Earn vault. */
|
|
603
|
+
export type Config = z.output<typeof schema.Config>
|
|
604
|
+
|
|
605
|
+
/** Ordered TIDX event cursor for one campaign projection. */
|
|
606
|
+
export type EventCursor = {
|
|
607
|
+
/** Tempo block number. */
|
|
608
|
+
blockNumber: number
|
|
609
|
+
/** Log index within the transaction receipt. */
|
|
610
|
+
logIndex: number
|
|
611
|
+
/** Transaction index within the block. */
|
|
612
|
+
transactionIndex: number
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/** One surviving public deposit lot used for boost qualification. */
|
|
616
|
+
export type DepositLot = {
|
|
617
|
+
/** Principal allocated against campaign caps. */
|
|
618
|
+
allocatedPrincipalAssets: string
|
|
619
|
+
/** Original deposited base assets. */
|
|
620
|
+
depositedAssets: string
|
|
621
|
+
/** EarnShare minted by the deposit. */
|
|
622
|
+
depositedEarnShares: string
|
|
623
|
+
/** Event order used for deterministic qualification. */
|
|
624
|
+
event: EventCursor
|
|
625
|
+
/** Qualified EarnShare not consumed by an outgoing transfer or burn. */
|
|
626
|
+
remainingEarnShares: string
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/** Calculation and delivery state retained while one run is active. */
|
|
630
|
+
export type RunEvidence = {
|
|
631
|
+
/** Target annual rate applied to this run's intervals. */
|
|
632
|
+
appliedTargetRateBps?: number | undefined
|
|
633
|
+
/** Incremental boost annual rate selected for the run. */
|
|
634
|
+
boostRateBps?: number | undefined
|
|
635
|
+
/** Complete closing recipient projection used to resume payout after a crash. */
|
|
636
|
+
closingAccounts: readonly AccountSnapshot[]
|
|
637
|
+
/** Newly credited recipients retaining an unpaid entitlement after delivery. */
|
|
638
|
+
deferredRecipients?: number | undefined
|
|
639
|
+
/** Stable registration high-water mark consumed by the run. */
|
|
640
|
+
eligibilityCheckpoint?: string | undefined
|
|
641
|
+
/** Exact eligibility snapshot identity used by resumable calculation. */
|
|
642
|
+
eligibilityVersion?: Hex | undefined
|
|
643
|
+
/** Exact effective exclusion set identity used by resumable calculation. */
|
|
644
|
+
exclusionVersion?: Hex | undefined
|
|
645
|
+
/** Final TIDX event applied to the closing projection. */
|
|
646
|
+
eventCursor?: EventCursor | undefined
|
|
647
|
+
/** Rate sources using a bounded prior observation. */
|
|
648
|
+
staleRates?: readonly ('organic' | 'target')[] | undefined
|
|
649
|
+
/** Contribution-adjusted annual rate observed in the run's latest boost interval. */
|
|
650
|
+
organicRateBps?: number | undefined
|
|
651
|
+
/** Closing boundary of the interval supplying the organic rate. */
|
|
652
|
+
organicRateObservedAt?: string | undefined
|
|
653
|
+
/** Newly credited recipients whose cumulative entitlement is fully paid after delivery. */
|
|
654
|
+
paidRecipients?: number | undefined
|
|
655
|
+
/** Recipients receiving an EarnShare transfer during this run. */
|
|
656
|
+
payoutPaidRecipients?: number | undefined
|
|
657
|
+
/** Frozen automatic-payout recipients reused across delivery retries. */
|
|
658
|
+
payoutRecipients?: readonly Address[] | undefined
|
|
659
|
+
/** Recipients retaining an unpaid cumulative entitlement after automatic delivery. */
|
|
660
|
+
pendingRecipients?: number | undefined
|
|
661
|
+
/** Latest target annual rate observation retained for source fallback. */
|
|
662
|
+
targetRateBps?: number | undefined
|
|
663
|
+
/** Exact per-funder target-yield assets committed before signing. */
|
|
664
|
+
targetFundingAssets?: readonly string[] | undefined
|
|
665
|
+
/** Per-waterfall-threshold division remainders carried into the next run. */
|
|
666
|
+
targetFundingRemainders?: readonly string[] | undefined
|
|
667
|
+
/** Principal accounting method used for the committed funding amounts. */
|
|
668
|
+
targetPrincipalMethod?: 'time-weighted:v1' | undefined
|
|
669
|
+
/** When the selected external target rate was observed. */
|
|
670
|
+
targetRateObservedAt?: string | undefined
|
|
671
|
+
/** Per-interval calculation records in chronological order. */
|
|
672
|
+
intervals: readonly {
|
|
673
|
+
/** Fee-inclusive opening assets per EarnShare, scaled by 1e18. */
|
|
674
|
+
assetPerEarnShareWad: string
|
|
675
|
+
/** Per-recipient base-asset rewards for this interval. */
|
|
676
|
+
assetRewards: Readonly<Record<string, string>>
|
|
677
|
+
/** Final TIDX block included in the interval. */
|
|
678
|
+
blockNumber: number
|
|
679
|
+
/** Incremental boost annual rate applied to this interval. */
|
|
680
|
+
boostRateBps?: number | undefined
|
|
681
|
+
/** Exclusive interval end timestamp. */
|
|
682
|
+
endsAt: number
|
|
683
|
+
/** Contribution-adjusted annual rate observed in this interval. */
|
|
684
|
+
organicRateBps?: number | undefined
|
|
685
|
+
/** Inclusive interval start timestamp. */
|
|
686
|
+
startsAt: number
|
|
687
|
+
}[]
|
|
688
|
+
/** Explicit completed-state discriminator; absent on legacy completed evidence. */
|
|
689
|
+
kind?: 'complete' | undefined
|
|
690
|
+
/** Whether this run prepared and confirmed a new cumulative root. */
|
|
691
|
+
publishedRoot?: boolean | undefined
|
|
692
|
+
/** Base-asset units converted into the newly published entitlement. */
|
|
693
|
+
settledRewardAssets?: string | undefined
|
|
694
|
+
/** Recipients receiving a positive allocation in the new root. */
|
|
695
|
+
settlementRecipientAddresses?: readonly Address[] | undefined
|
|
696
|
+
/** Recipients receiving a positive allocation in the new root. */
|
|
697
|
+
settlementRecipients?: number | undefined
|
|
698
|
+
/** Closing account-state checksum. */
|
|
699
|
+
stateChecksum: Hex
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** Returns a stable identity for the complete eligibility snapshot. */
|
|
703
|
+
export function eligibilityVersion(entries: readonly eligibilityVersion.Entry[]): Hex {
|
|
704
|
+
return keccak256(
|
|
705
|
+
stringToBytes(
|
|
706
|
+
JSON.stringify(
|
|
707
|
+
entries.map((entry) => [
|
|
708
|
+
entry.walletAddress.toLowerCase(),
|
|
709
|
+
entry.registrationOrder,
|
|
710
|
+
entry.latestRegisteredAt,
|
|
711
|
+
]),
|
|
712
|
+
),
|
|
713
|
+
),
|
|
714
|
+
)
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
export declare namespace eligibilityVersion {
|
|
718
|
+
/** Eligibility fields that can change projection membership or replay. */
|
|
719
|
+
type Entry = {
|
|
720
|
+
/** Latest registration timestamp. */
|
|
721
|
+
latestRegisteredAt: string
|
|
722
|
+
/** Stable registration order. */
|
|
723
|
+
registrationOrder: string
|
|
724
|
+
/** Registered reward recipient. */
|
|
725
|
+
walletAddress: Address
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/** Returns a stable identity for the effective reward exclusion set. */
|
|
730
|
+
export function exclusionVersion(addresses: readonly Address[]): Hex {
|
|
731
|
+
return keccak256(
|
|
732
|
+
stringToBytes(
|
|
733
|
+
JSON.stringify([...new Set(addresses.map((address) => address.toLowerCase()))].sort()),
|
|
734
|
+
),
|
|
735
|
+
)
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/** Durable pagewise calculation state retained until complete evidence replaces it. */
|
|
739
|
+
export type RunCheckpointEvidence = {
|
|
740
|
+
/** Final TIDX event included in this checkpoint. */
|
|
741
|
+
cursor?: EventCursor | undefined
|
|
742
|
+
/** Stored-evidence discriminator. */
|
|
743
|
+
kind: 'checkpoint'
|
|
744
|
+
/** Completed calculation progress needed to resume the run. */
|
|
745
|
+
progress: Partial<RunEvidence>
|
|
746
|
+
/** Serializable projection reducer state. */
|
|
747
|
+
projection: {
|
|
748
|
+
/** Recipient whose registration-ordered deposit page was last applied. */
|
|
749
|
+
allocationRecipient?: Address | undefined
|
|
750
|
+
/** Account projections after the checkpointed page. */
|
|
751
|
+
accounts: readonly AccountSnapshot[]
|
|
752
|
+
/** Last accrued timestamp keyed by normalized recipient. */
|
|
753
|
+
accruedThrough?: Readonly<Record<string, number>> | undefined
|
|
754
|
+
/** Remaining FIFO-consumed shares while allocating surviving deposits. */
|
|
755
|
+
consumedEarnShares?: Readonly<Record<string, string>> | undefined
|
|
756
|
+
/** Gross historical deposit shares keyed by normalized recipient. */
|
|
757
|
+
depositedEarnShares?: Readonly<Record<string, string>> | undefined
|
|
758
|
+
/** Historical reconciliation pass. */
|
|
759
|
+
pass?: 'allocation' | 'survival' | undefined
|
|
760
|
+
/** Final canonical event applied by the survival pass. */
|
|
761
|
+
replayedThrough?: EventCursor | undefined
|
|
762
|
+
/** Weighted EarnShare seconds keyed by normalized recipient. */
|
|
763
|
+
weightedEarnShareSeconds?: Readonly<Record<string, string>> | undefined
|
|
764
|
+
}
|
|
765
|
+
/** Calculation reducer that produced this checkpoint. */
|
|
766
|
+
stage: 'calculate' | 'reconcile'
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/** Completed or resumable evidence stored on a reward run. */
|
|
770
|
+
export type StoredRunEvidence = RunCheckpointEvidence | RunEvidence
|
|
771
|
+
|
|
772
|
+
/** Narrows stored run evidence to resumable calculation state. */
|
|
773
|
+
export function isRunCheckpointEvidence(
|
|
774
|
+
evidence: StoredRunEvidence | null | undefined,
|
|
775
|
+
): evidence is RunCheckpointEvidence {
|
|
776
|
+
return evidence?.kind === 'checkpoint'
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** Restores funding amounts only when their saved principal accounting is safe to submit. */
|
|
780
|
+
export function targetFundingAssets(evidence: RunEvidence): bigint[] {
|
|
781
|
+
const assets = (evidence.targetFundingAssets ?? []).map(BigInt)
|
|
782
|
+
// Legacy evidence can contain inflated spot-principal amounts, including on a signed retry.
|
|
783
|
+
if (assets.some((amount) => amount > 0n) && evidence.targetPrincipalMethod !== 'time-weighted:v1')
|
|
784
|
+
throw new Error('Stored target-yield funding requires principal accounting review.')
|
|
785
|
+
return assets
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/** Removes active recipient calculation and payout state after a run is durably delivered. */
|
|
789
|
+
export function compactEvidence(evidence: RunEvidence): RunEvidence {
|
|
790
|
+
const compacted: RunEvidence = {
|
|
791
|
+
...evidence,
|
|
792
|
+
closingAccounts: [],
|
|
793
|
+
intervals: evidence.intervals.map((interval) => ({ ...interval, assetRewards: {} })),
|
|
794
|
+
payoutRecipients: [],
|
|
795
|
+
settlementRecipientAddresses: [],
|
|
796
|
+
}
|
|
797
|
+
return compacted
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/** Serializable reward-account projection retained by an in-flight run. */
|
|
801
|
+
export type AccountSnapshot = {
|
|
802
|
+
/** Arithmetic remainder carried across intervals. */
|
|
803
|
+
accrualRemainder: string
|
|
804
|
+
/** Principal allocated against campaign caps. */
|
|
805
|
+
allocatedPrincipalAssets: string
|
|
806
|
+
/** Cumulative EarnShare entitlement. */
|
|
807
|
+
cumulativeEntitlement: string
|
|
808
|
+
/** Cumulative EarnShare already paid. */
|
|
809
|
+
cumulativePaid: string
|
|
810
|
+
/** Current transfer deferral. */
|
|
811
|
+
deferral: string | null
|
|
812
|
+
/** Eligibility registration version consumed by this projection. */
|
|
813
|
+
eligibilityRegisteredAt: string | null
|
|
814
|
+
/** Surviving qualified deposits. */
|
|
815
|
+
lots: readonly DepositLot[]
|
|
816
|
+
/** Base-asset reward awaiting settlement. */
|
|
817
|
+
pendingRewardAssets: string
|
|
818
|
+
/** Current attributable public EarnShare. */
|
|
819
|
+
publicEarnShares: string
|
|
820
|
+
/** Current qualified EarnShare. */
|
|
821
|
+
qualifiedEarnShares: string
|
|
822
|
+
/** Registered recipient. */
|
|
823
|
+
recipient: Address
|
|
824
|
+
/** Monotonic registration order. */
|
|
825
|
+
registrationOrder: string
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/** Typed signer intent persisted before transaction construction. */
|
|
829
|
+
export type TransactionIntent = {
|
|
830
|
+
/** Deterministic content-addressed intent id. */
|
|
831
|
+
id: Hex
|
|
832
|
+
/** Operation accepted by the reward signer. */
|
|
833
|
+
operation: 'deploy' | 'targetYield' | 'settle' | 'publish' | 'push'
|
|
834
|
+
/** Operation-specific data validated by the signer. */
|
|
835
|
+
payload: Readonly<Record<string, unknown>>
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
/** Canonical receipt evidence retained after confirmation. */
|
|
839
|
+
export type TransactionReceipt = {
|
|
840
|
+
/** Canonical receipt block hash. */
|
|
841
|
+
blockHash: Hex
|
|
842
|
+
/** Receipt block number. */
|
|
843
|
+
blockNumber: string
|
|
844
|
+
/** Gas consumed by the transaction. */
|
|
845
|
+
gasUsed: string
|
|
846
|
+
/** Receipt status. */
|
|
847
|
+
status: 'success' | 'reverted'
|
|
848
|
+
/** Transaction hash. */
|
|
849
|
+
transactionHash: Hex
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/** One cumulative recipient entitlement. */
|
|
853
|
+
export type Entitlement = {
|
|
854
|
+
/** EarnShare owed cumulatively. */
|
|
855
|
+
cumulativeAmount: string
|
|
856
|
+
/** Committed recipient. */
|
|
857
|
+
recipient: Address
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/** One proof-bearing statement entry. */
|
|
861
|
+
export type StatementEntry = Entitlement & {
|
|
862
|
+
/** Domain-separated leaf hash. */
|
|
863
|
+
leaf: Hex
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/** One cumulative v2 Merkle statement. */
|
|
867
|
+
export type Statement = {
|
|
868
|
+
/** Zero-padded EarnVault campaign id. */
|
|
869
|
+
campaignId: Hex
|
|
870
|
+
/** Tempo chain containing the distributor. */
|
|
871
|
+
chainId: number
|
|
872
|
+
/** EarnShare distributor address. */
|
|
873
|
+
distributor: Address
|
|
874
|
+
/** Sorted cumulative entries. */
|
|
875
|
+
entries: readonly StatementEntry[]
|
|
876
|
+
/** Merkle root. */
|
|
877
|
+
root: Hex
|
|
878
|
+
/** Statement schema version. */
|
|
879
|
+
schemaVersion: 2
|
|
880
|
+
/** Content hash of the statement payload. */
|
|
881
|
+
statementHash: Hex
|
|
882
|
+
/** Sum of all cumulative entitlements. */
|
|
883
|
+
totalEntitlement: string
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
/** One permissionless cumulative multiproof payout batch. */
|
|
887
|
+
export type PayoutBatch = {
|
|
888
|
+
/** Cumulative amounts matching `recipients`. */
|
|
889
|
+
cumulativeAmounts: readonly string[]
|
|
890
|
+
/** StandardMerkleTree multiproof. */
|
|
891
|
+
multiproof: readonly Hex[]
|
|
892
|
+
/** OpenZeppelin multiproof queue flags. */
|
|
893
|
+
proofFlags: readonly boolean[]
|
|
894
|
+
/** Committed recipients in multiproof leaf order. */
|
|
895
|
+
recipients: readonly Address[]
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** Returns the next interval boundary relative to a schedule origin. */
|
|
899
|
+
export function nextBoundary(options: nextBoundary.Options): number {
|
|
900
|
+
if (!Number.isSafeInteger(options.intervalSeconds) || options.intervalSeconds <= 0)
|
|
901
|
+
throw new Error('intervalSeconds is invalid')
|
|
902
|
+
if (!Number.isSafeInteger(options.origin) || options.origin < 0)
|
|
903
|
+
throw new Error('origin is invalid')
|
|
904
|
+
if (!Number.isSafeInteger(options.timestamp) || options.timestamp < options.origin)
|
|
905
|
+
throw new Error('timestamp is invalid')
|
|
906
|
+
return (
|
|
907
|
+
options.origin +
|
|
908
|
+
(Math.floor((options.timestamp - options.origin) / options.intervalSeconds) + 1) *
|
|
909
|
+
options.intervalSeconds
|
|
910
|
+
)
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
export declare namespace nextBoundary {
|
|
914
|
+
/** Inputs for locating a schedule-relative interval boundary. */
|
|
915
|
+
type Options = {
|
|
916
|
+
/** Accounting interval length in seconds. */
|
|
917
|
+
intervalSeconds: number
|
|
918
|
+
/** Unix timestamp anchoring the schedule's interval grid. */
|
|
919
|
+
origin: number
|
|
920
|
+
/** Unix timestamp after which the boundary must fall. */
|
|
921
|
+
timestamp: number
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/** Calculates simple ACT/365 reward assets and the carried division remainder. */
|
|
926
|
+
export function accrue(options: accrue.Options): accrue.Result {
|
|
927
|
+
const denominator = 10_000n * 365n * 24n * 60n * 60n
|
|
928
|
+
const numerator =
|
|
929
|
+
options.principalAssets * BigInt(options.annualRateBps) * BigInt(options.elapsedSeconds) +
|
|
930
|
+
options.remainder
|
|
931
|
+
return { amount: numerator / denominator, remainder: numerator % denominator }
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
export declare namespace accrue {
|
|
935
|
+
/** Inputs for one simple annual reward calculation. */
|
|
936
|
+
type Options = {
|
|
937
|
+
/** Annual reward rate in basis points. */
|
|
938
|
+
annualRateBps: number
|
|
939
|
+
/** Seconds covered by the calculation. */
|
|
940
|
+
elapsedSeconds: number
|
|
941
|
+
/** Base-asset principal earning rewards. */
|
|
942
|
+
principalAssets: bigint
|
|
943
|
+
/** Division remainder carried from earlier intervals. */
|
|
944
|
+
remainder: bigint
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
/** Exact integer result and its remainder. */
|
|
948
|
+
type Result = {
|
|
949
|
+
/** Whole base-asset units earned. */
|
|
950
|
+
amount: bigint
|
|
951
|
+
/** Numerator remainder carried into the next interval. */
|
|
952
|
+
remainder: bigint
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/** Allocates every minted EarnShare unit by deterministic largest remainder. */
|
|
957
|
+
export function allocate(options: allocate.Options): ReadonlyMap<Address, bigint> {
|
|
958
|
+
const rewards = [...options.rewards]
|
|
959
|
+
.filter((reward) => reward.assets > 0n)
|
|
960
|
+
.sort((left, right) =>
|
|
961
|
+
left.recipient.toLowerCase().localeCompare(right.recipient.toLowerCase()),
|
|
962
|
+
)
|
|
963
|
+
const total = rewards.reduce((sum, reward) => sum + reward.assets, 0n)
|
|
964
|
+
if (total === 0n) {
|
|
965
|
+
if (options.earnShares !== 0n) throw new Error('cannot allocate shares without rewards')
|
|
966
|
+
return new Map()
|
|
967
|
+
}
|
|
968
|
+
const rows = rewards.map((reward) => {
|
|
969
|
+
const numerator = reward.assets * options.earnShares
|
|
970
|
+
return { amount: numerator / total, recipient: reward.recipient, remainder: numerator % total }
|
|
971
|
+
})
|
|
972
|
+
let remaining = options.earnShares - rows.reduce((sum, row) => sum + row.amount, 0n)
|
|
973
|
+
rows.sort(
|
|
974
|
+
(left, right) =>
|
|
975
|
+
Number(right.remainder > left.remainder) - Number(right.remainder < left.remainder) ||
|
|
976
|
+
left.recipient.toLowerCase().localeCompare(right.recipient.toLowerCase()),
|
|
977
|
+
)
|
|
978
|
+
for (const row of rows) {
|
|
979
|
+
if (remaining === 0n) break
|
|
980
|
+
row.amount += 1n
|
|
981
|
+
remaining -= 1n
|
|
982
|
+
}
|
|
983
|
+
return new Map(rows.map((row) => [row.recipient, row.amount]))
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
export declare namespace allocate {
|
|
987
|
+
/** Inputs for exact minted-share allocation. */
|
|
988
|
+
type Options = {
|
|
989
|
+
/** Exact EarnShare units minted. */
|
|
990
|
+
earnShares: bigint
|
|
991
|
+
/** Per-recipient base-asset rewards. */
|
|
992
|
+
rewards: readonly { assets: bigint; recipient: Address }[]
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/** Whether an unpaid EarnShare balance meets its base-asset payout floor. */
|
|
997
|
+
export function meetsPayoutMinimum(options: meetsPayoutMinimum.Options): boolean {
|
|
998
|
+
const unpaid = options.cumulativeEntitlement - options.cumulativePaid
|
|
999
|
+
if (unpaid <= 0n) return false
|
|
1000
|
+
if (options.minimumAssets < 0n) throw new Error('minimum assets must be nonnegative')
|
|
1001
|
+
if (options.totalAssets < 0n || options.totalEarnShares <= 0n)
|
|
1002
|
+
throw new Error('payout valuation requires nonnegative assets and positive EarnShare supply')
|
|
1003
|
+
return unpaid * options.totalAssets >= options.minimumAssets * options.totalEarnShares
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
export declare namespace meetsPayoutMinimum {
|
|
1007
|
+
/** Cumulative entitlement and current vault-value inputs. */
|
|
1008
|
+
type Options = {
|
|
1009
|
+
/** Recipient's cumulative EarnShare entitlement. */
|
|
1010
|
+
cumulativeEntitlement: bigint
|
|
1011
|
+
/** Recipient's cumulative paid EarnShare amount. */
|
|
1012
|
+
cumulativePaid: bigint
|
|
1013
|
+
/** Minimum base-asset value required for automatic payout. */
|
|
1014
|
+
minimumAssets: bigint
|
|
1015
|
+
/** Current fee-inclusive vault assets. */
|
|
1016
|
+
totalAssets: bigint
|
|
1017
|
+
/** Current fee-inclusive EarnShare supply. */
|
|
1018
|
+
totalEarnShares: bigint
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/** Builds an OpenZeppelin StandardMerkleTree-compatible cumulative statement. */
|
|
1023
|
+
export function buildStatement(options: buildStatement.Options): Statement {
|
|
1024
|
+
if (options.entitlements.length === 0) throw new Error('statement requires an entitlement')
|
|
1025
|
+
const entries = options.entitlements
|
|
1026
|
+
.map((entry) => ({
|
|
1027
|
+
cumulativeAmount: BigInt(entry.cumulativeAmount).toString(),
|
|
1028
|
+
leaf: '' as Hex,
|
|
1029
|
+
recipient: getAddress(entry.recipient),
|
|
1030
|
+
}))
|
|
1031
|
+
.sort((left, right) =>
|
|
1032
|
+
left.recipient.toLowerCase().localeCompare(right.recipient.toLowerCase()),
|
|
1033
|
+
)
|
|
1034
|
+
let totalEntitlement = 0n
|
|
1035
|
+
for (const [index, entry] of entries.entries()) {
|
|
1036
|
+
const cumulativeAmount = BigInt(entry.cumulativeAmount)
|
|
1037
|
+
if (cumulativeAmount <= 0n || cumulativeAmount > maximumUint256)
|
|
1038
|
+
throw new Error(`invalid entitlement for ${entry.recipient}`)
|
|
1039
|
+
if (index > 0 && entry.recipient === entries[index - 1]!.recipient)
|
|
1040
|
+
throw new Error(`duplicate recipient ${entry.recipient}`)
|
|
1041
|
+
totalEntitlement += cumulativeAmount
|
|
1042
|
+
entry.leaf = rewardLeaf({ ...options, cumulativeAmount, recipient: entry.recipient })
|
|
1043
|
+
}
|
|
1044
|
+
if (totalEntitlement > maximumUint256) throw new Error('total entitlement exceeds uint256')
|
|
1045
|
+
const tree = makeTree(entries.map((entry) => entry.leaf))
|
|
1046
|
+
const payload = {
|
|
1047
|
+
campaignId: options.campaignId,
|
|
1048
|
+
chainId: options.chainId,
|
|
1049
|
+
distributor: getAddress(options.distributor),
|
|
1050
|
+
entries,
|
|
1051
|
+
root: tree.nodes[0]!,
|
|
1052
|
+
schemaVersion: 2 as const,
|
|
1053
|
+
totalEntitlement: totalEntitlement.toString(),
|
|
1054
|
+
}
|
|
1055
|
+
return { ...payload, statementHash: keccak256(stringToBytes(JSON.stringify(payload))) }
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
export declare namespace buildStatement {
|
|
1059
|
+
/** Domain and entitlement inputs for one statement. */
|
|
1060
|
+
type Options = {
|
|
1061
|
+
/** Zero-padded EarnVault campaign id. */
|
|
1062
|
+
campaignId: Hex
|
|
1063
|
+
/** Tempo chain containing the distributor. */
|
|
1064
|
+
chainId: number
|
|
1065
|
+
/** EarnShare distributor address. */
|
|
1066
|
+
distributor: Address
|
|
1067
|
+
/** Cumulative recipient entitlements. */
|
|
1068
|
+
entitlements: readonly Entitlement[]
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/** Splits a cumulative statement into contiguous multiproof payout batches. */
|
|
1073
|
+
export function buildPayoutBatches(
|
|
1074
|
+
statement: Statement,
|
|
1075
|
+
options: buildPayoutBatches.Options,
|
|
1076
|
+
): readonly PayoutBatch[] {
|
|
1077
|
+
if (!Number.isSafeInteger(options.maximumSize) || options.maximumSize <= 0)
|
|
1078
|
+
throw new Error('maximumSize must be a positive integer')
|
|
1079
|
+
const entries = statement.entries.flatMap((entry, index) =>
|
|
1080
|
+
!options.recipients || options.recipients.has(entry.recipient.toLowerCase())
|
|
1081
|
+
? [{ entry, index }]
|
|
1082
|
+
: [],
|
|
1083
|
+
)
|
|
1084
|
+
const leaves = statement.entries.map((entry) => entry.leaf)
|
|
1085
|
+
const tree = makeTree(leaves)
|
|
1086
|
+
const byPosition = new Map(tree.positions.map((position, index) => [position, index]))
|
|
1087
|
+
const result: PayoutBatch[] = []
|
|
1088
|
+
for (let offset = 0; offset < entries.length; offset += options.maximumSize) {
|
|
1089
|
+
const selected = entries.slice(offset, offset + options.maximumSize)
|
|
1090
|
+
const positions = selected
|
|
1091
|
+
.map(({ index }) => tree.positions[index]!)
|
|
1092
|
+
.sort((left, right) => right - left)
|
|
1093
|
+
const original = [...positions]
|
|
1094
|
+
const stack = [...positions]
|
|
1095
|
+
const multiproof: Hex[] = []
|
|
1096
|
+
const proofFlags: boolean[] = []
|
|
1097
|
+
while (stack.length > 0 && stack[0]! > 0) {
|
|
1098
|
+
const current = stack.shift()!
|
|
1099
|
+
const sibling = current % 2 === 0 ? current - 1 : current + 1
|
|
1100
|
+
const parent = Math.floor((current - 1) / 2)
|
|
1101
|
+
if (sibling === stack[0]) {
|
|
1102
|
+
proofFlags.push(true)
|
|
1103
|
+
stack.shift()
|
|
1104
|
+
} else {
|
|
1105
|
+
proofFlags.push(false)
|
|
1106
|
+
multiproof.push(tree.nodes[sibling]!)
|
|
1107
|
+
}
|
|
1108
|
+
stack.push(parent)
|
|
1109
|
+
}
|
|
1110
|
+
const ordered = original.map((position) => statement.entries[byPosition.get(position)!]!)
|
|
1111
|
+
result.push({
|
|
1112
|
+
cumulativeAmounts: ordered.map((entry) => entry.cumulativeAmount),
|
|
1113
|
+
multiproof,
|
|
1114
|
+
proofFlags,
|
|
1115
|
+
recipients: ordered.map((entry) => entry.recipient),
|
|
1116
|
+
})
|
|
1117
|
+
}
|
|
1118
|
+
return result
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
/** Rebuilds one individual recovery proof from the current cumulative statement. */
|
|
1122
|
+
export function buildProof(statement: Statement, recipient: Address): readonly Hex[] | undefined {
|
|
1123
|
+
const index = statement.entries.findIndex(
|
|
1124
|
+
(entry) => entry.recipient.toLowerCase() === recipient.toLowerCase(),
|
|
1125
|
+
)
|
|
1126
|
+
if (index < 0) return undefined
|
|
1127
|
+
return treeProof(makeTree(statement.entries.map((entry) => entry.leaf)), index)
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
export declare namespace buildPayoutBatches {
|
|
1131
|
+
/** Runtime batch constraints. */
|
|
1132
|
+
type Options = {
|
|
1133
|
+
/** Maximum recipients in one bounded payout call. */
|
|
1134
|
+
maximumSize: number
|
|
1135
|
+
/** Optional preflight-authorized recipient set. */
|
|
1136
|
+
recipients?: ReadonlySet<string> | undefined
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
/** Computes the distributor's domain-separated standard leaf. */
|
|
1141
|
+
export function rewardLeaf(options: rewardLeaf.Options): Hex {
|
|
1142
|
+
return keccak256(
|
|
1143
|
+
keccak256(
|
|
1144
|
+
encodeAbiParameters(leafParameters, [
|
|
1145
|
+
BigInt(options.chainId),
|
|
1146
|
+
getAddress(options.distributor),
|
|
1147
|
+
options.campaignId,
|
|
1148
|
+
getAddress(options.recipient),
|
|
1149
|
+
options.cumulativeAmount,
|
|
1150
|
+
]),
|
|
1151
|
+
'bytes',
|
|
1152
|
+
),
|
|
1153
|
+
)
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
export declare namespace rewardLeaf {
|
|
1157
|
+
/** Domain and recipient inputs for one leaf. */
|
|
1158
|
+
type Options = {
|
|
1159
|
+
/** Zero-padded EarnVault campaign id. */
|
|
1160
|
+
campaignId: Hex
|
|
1161
|
+
/** Tempo chain containing the distributor. */
|
|
1162
|
+
chainId: number
|
|
1163
|
+
/** Cumulative EarnShare amount. */
|
|
1164
|
+
cumulativeAmount: bigint
|
|
1165
|
+
/** EarnShare distributor address. */
|
|
1166
|
+
distributor: Address
|
|
1167
|
+
/** Committed recipient. */
|
|
1168
|
+
recipient: Address
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
type Tree = { nodes: Hex[]; positions: number[] }
|
|
1173
|
+
|
|
1174
|
+
function makeTree(leaves: readonly Hex[]): Tree {
|
|
1175
|
+
const sorted = leaves
|
|
1176
|
+
.map((hash, index) => ({ hash, index }))
|
|
1177
|
+
.sort((left, right) => left.hash.toLowerCase().localeCompare(right.hash.toLowerCase()))
|
|
1178
|
+
const nodes = Array.from<Hex>({ length: 2 * leaves.length - 1 })
|
|
1179
|
+
const positions = Array.from<number>({ length: leaves.length })
|
|
1180
|
+
for (const [index, leaf] of sorted.entries()) {
|
|
1181
|
+
const position = nodes.length - 1 - index
|
|
1182
|
+
nodes[position] = leaf.hash
|
|
1183
|
+
positions[leaf.index] = position
|
|
1184
|
+
}
|
|
1185
|
+
for (let index = nodes.length - 1 - leaves.length; index >= 0; index -= 1)
|
|
1186
|
+
nodes[index] = nodeHash(nodes[2 * index + 1]!, nodes[2 * index + 2]!)
|
|
1187
|
+
return { nodes, positions }
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
function nodeHash(left: Hex, right: Hex): Hex {
|
|
1191
|
+
return keccak256(
|
|
1192
|
+
concatHex(left.toLowerCase() < right.toLowerCase() ? [left, right] : [right, left]),
|
|
1193
|
+
)
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
function treeProof(tree: Tree, leafIndex: number): Hex[] {
|
|
1197
|
+
const result: Hex[] = []
|
|
1198
|
+
let index = tree.positions[leafIndex]!
|
|
1199
|
+
while (index > 0) {
|
|
1200
|
+
const sibling = index % 2 === 0 ? index - 1 : index + 1
|
|
1201
|
+
result.push(tree.nodes[sibling]!)
|
|
1202
|
+
index = Math.floor((index - 1) / 2)
|
|
1203
|
+
}
|
|
1204
|
+
return result
|
|
1205
|
+
}
|