tapimo 0.12.0 → 0.14.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/dist/App.d.ts +11333 -9563
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +39 -3
- package/dist/App.js.map +1 -1
- package/dist/Scope.d.ts +2 -0
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +17 -0
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.js +2 -2
- package/dist/Webhooks.js.map +1 -1
- package/dist/admin/App.d.ts +1064 -924
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +80 -0
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +54 -0
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +63 -15
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -1
- package/dist/admin/apps/earn-vaults.js +2 -1
- package/dist/admin/apps/earn-vaults.js.map +1 -1
- package/dist/admin/apps/organizations.d.ts +92 -3
- package/dist/admin/apps/organizations.d.ts.map +1 -1
- package/dist/admin/apps/organizations.js +69 -7
- package/dist/admin/apps/organizations.js.map +1 -1
- package/dist/admin/apps/verified-tokens.d.ts +7 -7
- 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 +151 -151
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/apps/Zones.d.ts +28 -28
- package/dist/apps/Zones.js +7 -7
- package/dist/apps/data/App.d.ts +2909 -2523
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +26 -21
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/ZoneSelection.d.ts +8 -8
- package/dist/apps/data/ZoneSelection.d.ts.map +1 -1
- package/dist/apps/data/ZoneSelection.js +1 -1
- package/dist/apps/data/ZoneSelection.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +588 -584
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +1561 -1239
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +22 -22
- package/dist/apps/data/routes/balances.d.ts +26 -26
- package/dist/apps/data/routes/balances.d.ts.map +1 -1
- package/dist/apps/data/routes/balances.js +43 -16
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/blocks.d.ts +44 -44
- package/dist/apps/data/routes/blocks.d.ts.map +1 -1
- package/dist/apps/data/routes/blocks.js +21 -11
- package/dist/apps/data/routes/blocks.js.map +1 -1
- package/dist/apps/data/routes/coingecko.d.ts +3 -3
- package/dist/apps/data/routes/earn.d.ts +201 -25
- package/dist/apps/data/routes/earn.d.ts.map +1 -1
- package/dist/apps/data/routes/earn.js +434 -75
- package/dist/apps/data/routes/earn.js.map +1 -1
- package/dist/apps/data/routes/exchanges.d.ts +160 -145
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +180 -114
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts +2 -2
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +18 -19
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +155 -55
- package/dist/apps/data/routes/receipts.d.ts.map +1 -1
- package/dist/apps/data/routes/receipts.js +28 -10
- package/dist/apps/data/routes/receipts.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +13 -13
- package/dist/apps/data/routes/tokens.d.ts +5 -5
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +51 -20
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +7 -2
- package/dist/apps/data/routes/transactions.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.js +37 -17
- package/dist/apps/data/routes/transactions.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +13 -13
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +18 -12
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/valuation.d.ts +31 -31
- package/dist/apps/data/routes/valuation.d.ts.map +1 -1
- package/dist/apps/data/routes/valuation.js +12 -7
- package/dist/apps/data/routes/valuation.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts +8 -8
- package/dist/apps/data/routes/webhooks.d.ts +816 -113
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +47 -5
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +14 -14
- package/dist/apps/data/routes/zones.js +1 -1
- package/dist/apps/funding/App.d.ts +466 -44
- package/dist/apps/funding/App.d.ts.map +1 -1
- package/dist/apps/funding/App.js +1 -1
- package/dist/apps/funding/App.js.map +1 -1
- package/dist/apps/funding/routes/deposit-addresses.d.ts +17 -17
- package/dist/apps/funding/routes/deposit-addresses.d.ts.map +1 -1
- package/dist/apps/funding/routes/deposit-addresses.js +17 -12
- package/dist/apps/funding/routes/deposit-addresses.js.map +1 -1
- package/dist/apps/funding/routes/transfers.d.ts +650 -57
- package/dist/apps/funding/routes/transfers.d.ts.map +1 -1
- package/dist/apps/funding/routes/transfers.js +238 -24
- package/dist/apps/funding/routes/transfers.js.map +1 -1
- package/dist/apps/management/App.d.ts +5120 -4152
- package/dist/apps/management/App.d.ts.map +1 -1
- package/dist/apps/management/Billing.d.ts +1 -1
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +17 -1
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/routes/api-keys.d.ts +632 -81
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +236 -4
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +76 -76
- package/dist/apps/management/routes/faucet.d.ts +6 -6
- package/dist/apps/management/routes/invitations.d.ts +24 -24
- package/dist/apps/management/routes/invite-links.d.ts +4 -4
- package/dist/apps/management/routes/members.d.ts +16 -16
- package/dist/apps/management/routes/orgs.d.ts +20 -20
- package/dist/apps/management/routes/projects.d.ts +4 -4
- package/dist/apps/management/routes/usage.d.ts +8 -8
- package/dist/apps/management/routes/verified-token-requests.d.ts +17 -17
- package/dist/apps/management/routes/webhooks.d.ts +675 -25
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +21 -21
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/relay/App.d.ts.map +1 -1
- package/dist/apps/relay/App.js +115 -23
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +27 -1
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +34 -1
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +11 -5
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +21 -3
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/fundingCatalog.d.ts +4 -2
- package/dist/db/tables/fundingCatalog.d.ts.map +1 -1
- package/dist/db/tables/fundingCatalog.js +5 -1
- package/dist/db/tables/fundingCatalog.js.map +1 -1
- package/dist/db/tables/fundingTransferTransactions.d.ts +38 -0
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +1 -1
- package/dist/db/tables/fundingTransferTransactions.js +44 -3
- package/dist/db/tables/fundingTransferTransactions.js.map +1 -1
- package/dist/db/tables/fundingTransfers.d.ts +17 -0
- package/dist/db/tables/fundingTransfers.d.ts.map +1 -1
- package/dist/db/tables/fundingTransfers.js +21 -0
- package/dist/db/tables/fundingTransfers.js.map +1 -1
- package/dist/db/tables/organizations.d.ts +24 -0
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +27 -0
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +25 -1
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +26 -0
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts +44 -0
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +146 -13
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +10 -6
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +9 -6
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/internal/utils.d.ts.map +1 -1
- package/dist/handlers/internal/utils.js +9 -0
- package/dist/handlers/internal/utils.js.map +1 -1
- package/dist/internal/Auth.d.ts +3 -1
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +6 -3
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/EarnVaults.d.ts +3 -3
- package/dist/internal/EarnVaults.js +5 -5
- package/dist/internal/EarnVaults.js.map +1 -1
- package/dist/internal/Fetch.d.ts +23 -0
- package/dist/internal/Fetch.d.ts.map +1 -0
- package/dist/internal/Fetch.js +26 -0
- package/dist/internal/Fetch.js.map +1 -0
- package/dist/internal/Log.d.ts +4 -2
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +16 -3
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +5 -3
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +13 -3
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Response.d.ts +1 -1
- package/dist/internal/Response.d.ts.map +1 -1
- package/dist/internal/Schema.d.ts +6 -3
- package/dist/internal/Schema.d.ts.map +1 -1
- package/dist/internal/Schema.js +8 -2
- package/dist/internal/Schema.js.map +1 -1
- package/dist/internal/Store.d.ts +16 -3
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +82 -16
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +7 -2
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Timeout.d.ts +36 -0
- package/dist/internal/Timeout.d.ts.map +1 -0
- package/dist/internal/Timeout.js +37 -0
- package/dist/internal/Timeout.js.map +1 -0
- package/dist/internal/Timing.d.ts +9 -0
- package/dist/internal/Timing.d.ts.map +1 -1
- package/dist/internal/Timing.js +7 -0
- package/dist/internal/Timing.js.map +1 -1
- package/dist/internal/Viem.d.ts +16 -1
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +12 -2
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/WebhookDestination.d.ts.map +1 -1
- package/dist/internal/WebhookDestination.js +3 -0
- package/dist/internal/WebhookDestination.js.map +1 -1
- package/dist/internal/funding/Action.d.ts +9 -0
- package/dist/internal/funding/Action.d.ts.map +1 -1
- package/dist/internal/funding/Action.js +16 -8
- package/dist/internal/funding/Action.js.map +1 -1
- package/dist/internal/funding/Catalog.d.ts +9 -2
- package/dist/internal/funding/Catalog.d.ts.map +1 -1
- package/dist/internal/funding/Catalog.js +19 -8
- package/dist/internal/funding/Catalog.js.map +1 -1
- package/dist/internal/funding/DepositWebhook.d.ts.map +1 -1
- package/dist/internal/funding/DepositWebhook.js +2 -1
- package/dist/internal/funding/DepositWebhook.js.map +1 -1
- package/dist/internal/funding/Evidence.d.ts.map +1 -1
- package/dist/internal/funding/Evidence.js +2 -10
- package/dist/internal/funding/Evidence.js.map +1 -1
- package/dist/internal/funding/Provider.d.ts +108 -13
- package/dist/internal/funding/Provider.d.ts.map +1 -1
- package/dist/internal/funding/Provider.js +34 -8
- package/dist/internal/funding/Provider.js.map +1 -1
- package/dist/internal/funding/SourceObservation.d.ts.map +1 -1
- package/dist/internal/funding/SourceObservation.js +5 -7
- package/dist/internal/funding/SourceObservation.js.map +1 -1
- package/dist/internal/funding/Transfer.d.ts +114 -18
- package/dist/internal/funding/Transfer.d.ts.map +1 -1
- package/dist/internal/funding/Transfer.js +185 -55
- package/dist/internal/funding/Transfer.js.map +1 -1
- package/dist/internal/funding/TransferReconciliation.d.ts +52 -0
- package/dist/internal/funding/TransferReconciliation.d.ts.map +1 -0
- package/dist/internal/funding/TransferReconciliation.js +192 -0
- package/dist/internal/funding/TransferReconciliation.js.map +1 -0
- package/dist/internal/funding/TransferWebhook.d.ts +21 -0
- package/dist/internal/funding/TransferWebhook.d.ts.map +1 -0
- package/dist/internal/funding/TransferWebhook.js +43 -0
- package/dist/internal/funding/TransferWebhook.js.map +1 -0
- package/dist/internal/funding/index.d.ts +1 -0
- package/dist/internal/funding/index.d.ts.map +1 -1
- package/dist/internal/funding/index.js +1 -0
- package/dist/internal/funding/index.js.map +1 -1
- package/dist/internal/funding/providers/relay.d.ts.map +1 -1
- package/dist/internal/funding/providers/relay.js +3 -12
- package/dist/internal/funding/providers/relay.js.map +1 -1
- package/dist/internal/funding/providers/stargate.d.ts +127 -9
- package/dist/internal/funding/providers/stargate.d.ts.map +1 -1
- package/dist/internal/funding/providers/stargate.js +548 -112
- package/dist/internal/funding/providers/stargate.js.map +1 -1
- package/dist/internal/index.d.ts +1 -0
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +1 -0
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/webhookDestinations/slack.d.ts.map +1 -1
- package/dist/internal/webhookDestinations/slack.js +16 -0
- package/dist/internal/webhookDestinations/slack.js.map +1 -1
- package/package.json +2 -2
- package/src/App.test.ts +100 -0
- package/src/App.ts +43 -3
- package/src/Client.test-d.ts +129 -2
- package/src/Scope.test.ts +20 -0
- package/src/Scope.ts +16 -0
- package/src/Webhooks.ts +2 -2
- package/src/admin/apps/api-keys.test.ts +75 -0
- package/src/admin/apps/api-keys.ts +64 -0
- package/src/admin/apps/earn-vaults.test.ts +1 -1
- package/src/admin/apps/earn-vaults.ts +2 -1
- package/src/admin/apps/organizations.test.ts +53 -1
- package/src/admin/apps/organizations.ts +90 -5
- package/src/admin/ui/src/lib/api-keys.ts +19 -0
- package/src/admin/ui/src/lib/organizations.test.ts +112 -1
- package/src/admin/ui/src/lib/organizations.ts +55 -0
- package/src/admin/ui/src/routes/api-keys.tsx +89 -2
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +116 -0
- package/src/admin/ui.generated.ts +189 -151
- package/src/apps/Zones.test.ts +7 -7
- package/src/apps/Zones.ts +7 -7
- package/src/apps/composition.test.ts +2 -1
- package/src/apps/data/App.test.ts +41 -0
- package/src/apps/data/App.ts +30 -21
- package/src/apps/data/ZoneSelection.test.ts +2 -2
- package/src/apps/data/ZoneSelection.ts +8 -8
- package/src/apps/data/routes/activities.test.ts +1526 -12
- package/src/apps/data/routes/activities.ts +1774 -1356
- package/src/apps/data/routes/balances.ts +133 -97
- package/src/apps/data/routes/blocks.test.ts +533 -0
- package/src/apps/data/routes/blocks.ts +35 -16
- package/src/apps/data/routes/earn.test.ts +373 -16
- package/src/apps/data/routes/earn.ts +548 -79
- package/src/apps/data/routes/earn.zone-access.test.ts +6 -6
- package/src/apps/data/routes/exchanges.test.ts +740 -15
- package/src/apps/data/routes/exchanges.ts +954 -753
- package/src/apps/data/routes/fee-amm.ts +17 -18
- package/src/apps/data/routes/receipts.ts +47 -16
- package/src/apps/data/routes/tokens.test.ts +578 -0
- package/src/apps/data/routes/tokens.ts +283 -225
- package/src/apps/data/routes/transactions.ts +68 -29
- package/src/apps/data/routes/transfers.test.ts +421 -0
- package/src/apps/data/routes/transfers.ts +45 -27
- package/src/apps/data/routes/valuation.ts +94 -78
- package/src/apps/data/routes/webhooks.test.ts +21 -5
- package/src/apps/data/routes/webhooks.ts +63 -8
- package/src/apps/data/routes/zones.test.ts +2 -2
- package/src/apps/data/routes/zones.ts +1 -1
- package/src/apps/funding/App.ts +12 -2
- package/src/apps/funding/routes/deposit-addresses.test.ts +29 -7
- package/src/apps/funding/routes/deposit-addresses.ts +19 -14
- package/src/apps/funding/routes/quotes.test.ts +5 -9
- package/src/apps/funding/routes/transfers.test.ts +901 -23
- package/src/apps/funding/routes/transfers.ts +347 -64
- package/src/apps/management/Billing.ts +18 -5
- package/src/apps/management/routes/api-keys.test.ts +220 -0
- package/src/apps/management/routes/api-keys.ts +280 -3
- package/src/apps/management/routes/webhooks.test.ts +3 -3
- package/src/apps/management/routes/webhooks.ts +24 -25
- package/src/apps/relay/App.test.ts +212 -1
- package/src/apps/relay/App.ts +158 -29
- package/src/apps/relay/Sponsorships.ts +24 -1
- package/src/db/Db.ts +48 -1
- package/src/db/Schema.ts +22 -4
- package/src/db/tables/earnVaults.test.ts +9 -9
- package/src/db/tables/fundingCatalog.test.ts +16 -2
- package/src/db/tables/fundingCatalog.ts +9 -3
- package/src/db/tables/fundingTransferTransactions.test.ts +43 -0
- package/src/db/tables/fundingTransferTransactions.ts +79 -3
- package/src/db/tables/fundingTransfers.test.ts +26 -0
- package/src/db/tables/fundingTransfers.ts +36 -0
- package/src/db/tables/organizations.test.ts +41 -0
- package/src/db/tables/organizations.ts +49 -0
- package/src/db/tables/projects.test.ts +55 -0
- package/src/db/tables/projects.ts +46 -1
- package/src/db/tables/sponsoredTransactions.test.ts +338 -0
- package/src/db/tables/sponsoredTransactions.ts +197 -13
- package/src/db/tables/webhookSubscriptions.ts +18 -11
- package/src/handlers/internal/utils.test.ts +53 -0
- package/src/handlers/internal/utils.ts +15 -0
- package/src/internal/Auth.ts +12 -4
- package/src/internal/EarnVaults.capabilities.test.ts +2 -2
- package/src/internal/EarnVaults.test.ts +1 -1
- package/src/internal/EarnVaults.ts +5 -5
- package/src/internal/Fetch.test.ts +46 -0
- package/src/internal/Fetch.ts +56 -0
- package/src/internal/Log.test-d.ts +2 -0
- package/src/internal/Log.test.ts +21 -0
- package/src/internal/Log.ts +22 -5
- package/src/internal/OpenApi.ts +14 -4
- package/src/internal/Response.ts +1 -1
- package/src/internal/Schema.test.ts +2 -0
- package/src/internal/Schema.ts +12 -2
- package/src/internal/Store.test.ts +178 -0
- package/src/internal/Store.ts +104 -18
- package/src/internal/Tidx.test.ts +2 -1
- package/src/internal/Tidx.ts +7 -2
- package/src/internal/Timeout.test.ts +35 -0
- package/src/internal/Timeout.ts +73 -0
- package/src/internal/Timing.ts +16 -0
- package/src/internal/Viem.ts +39 -3
- package/src/internal/WebhookDestination.ts +3 -0
- package/src/internal/Webhooks.test.ts +45 -0
- package/src/internal/funding/Action.test.ts +41 -1
- package/src/internal/funding/Action.ts +69 -41
- package/src/internal/funding/Catalog.test.ts +34 -0
- package/src/internal/funding/Catalog.ts +28 -11
- package/src/internal/funding/DepositWebhook.ts +2 -1
- package/src/internal/funding/Evidence.ts +2 -13
- package/src/internal/funding/Provider.test.ts +73 -0
- package/src/internal/funding/Provider.ts +125 -28
- package/src/internal/funding/SourceObservation.ts +5 -9
- package/src/internal/funding/Transfer.test.ts +155 -0
- package/src/internal/funding/Transfer.ts +387 -147
- package/src/internal/funding/TransferReconciliation.test.ts +147 -0
- package/src/internal/funding/TransferReconciliation.ts +264 -0
- package/src/internal/funding/TransferWebhook.test.ts +128 -0
- package/src/internal/funding/TransferWebhook.ts +67 -0
- package/src/internal/funding/index.test.ts +1 -0
- package/src/internal/funding/index.ts +1 -0
- package/src/internal/funding/providers/index.test.ts +4 -167
- package/src/internal/funding/providers/relay.test.ts +2 -2
- package/src/internal/funding/providers/relay.ts +3 -15
- package/src/internal/funding/providers/stargate.test.ts +328 -0
- package/src/internal/funding/providers/stargate.ts +807 -135
- package/src/internal/index.test.ts +1 -0
- package/src/internal/index.ts +1 -0
- package/src/internal/webhookDestinations/slack.ts +15 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Hono } from 'hono';
|
|
2
2
|
import { Value as core_Value } from 'ox';
|
|
3
|
+
import { Abis } from 'viem/tempo';
|
|
3
4
|
import { ContractFunctionExecutionError, ContractFunctionRevertedError, ContractFunctionZeroDataError, zeroAddress, } from 'viem';
|
|
4
5
|
import * as z from 'zod/mini';
|
|
5
6
|
import * as Scope from '../../../Scope.js';
|
|
@@ -70,12 +71,12 @@ export var schema;
|
|
|
70
71
|
.enum(['erc4626', 'veda'])
|
|
71
72
|
.check(z.describe('Inferred vault engine type.'), z.meta({ examples: ['erc4626'] }));
|
|
72
73
|
const engine = Schema.describe(z.strictObject({
|
|
73
|
-
address: Schema.Address.check(z.describe('Current vault engine contract address.'), z.meta({ examples: ['
|
|
74
|
+
address: Schema.Address.check(z.describe('Current vault engine contract address.'), z.meta({ examples: ['0x59d27987bc7cc1521bba5f688a170c65840cbf43'] })),
|
|
74
75
|
type: z
|
|
75
76
|
.nullable(engineType)
|
|
76
77
|
.check(z.describe('Inferred engine type, or null when it is unknown.')),
|
|
77
78
|
venue: z
|
|
78
|
-
.nullable(Schema.Address.check(z.describe('Yield venue contract bound to the engine.'), z.meta({ examples: ['
|
|
79
|
+
.nullable(Schema.Address.check(z.describe('Yield venue contract bound to the engine.'), z.meta({ examples: ['0x9a044ae05e5e6290dcf56afd69548565e957a626'] })))
|
|
79
80
|
.check(z.describe('Yield venue, or null when the engine does not expose one.')),
|
|
80
81
|
}), 'Current vault engine.');
|
|
81
82
|
const include = z
|
|
@@ -90,34 +91,34 @@ export var schema;
|
|
|
90
91
|
const baseIncludeQuery = Schema.includeQuery(baseInclude, 'Comma-separated vault fields to include, such as `access,zone`.');
|
|
91
92
|
const zone = z
|
|
92
93
|
.strictObject({
|
|
93
|
-
chainId: Schema.ChainId.check(z.describe('Private Zone chain id.'), z.meta({ examples: [
|
|
94
|
+
chainId: Schema.ChainId.check(z.describe('Private Zone chain id.'), z.meta({ examples: [421700001] })),
|
|
94
95
|
inputTokens: z
|
|
95
96
|
.array(Schema.Address)
|
|
96
|
-
.check(z.describe('Tokens accepted by private deposits.'), z.meta({ examples: [['
|
|
97
|
+
.check(z.describe('Tokens accepted by private deposits.'), z.meta({ examples: [['0x20c0000000000000000000006fd9a167923ba194']] })),
|
|
97
98
|
name: z
|
|
98
99
|
.string()
|
|
99
|
-
.check(z.describe('Private Zone name.'), z.meta({ examples: ['zone-
|
|
100
|
+
.check(z.describe('Private Zone name.'), z.meta({ examples: ['zone-mainnet-internal'] })),
|
|
100
101
|
outputTokens: z
|
|
101
102
|
.array(Schema.Address)
|
|
102
|
-
.check(z.describe('Tokens supported by private redemptions.'), z.meta({ examples: [['
|
|
103
|
+
.check(z.describe('Tokens supported by private redemptions.'), z.meta({ examples: [['0x20c0000000000000000000006fd9a167923ba194']] })),
|
|
103
104
|
})
|
|
104
105
|
.check(z.describe('Private Zone route configured for a verified vault.'));
|
|
105
106
|
const zoneRoute = z
|
|
106
107
|
.strictObject({
|
|
107
|
-
chainId: Schema.ChainId.check(z.describe('Private Zone chain id.'), z.meta({ examples: [
|
|
108
|
+
chainId: Schema.ChainId.check(z.describe('Private Zone chain id.'), z.meta({ examples: [421700001] })),
|
|
108
109
|
deploymentBlock: z
|
|
109
110
|
.number()
|
|
110
|
-
.check(z.int(), z.nonnegative(), z.describe('Parent-chain block that deployed the Earn router.'), z.meta({ examples: [
|
|
111
|
-
earnRouter: Schema.Address.check(z.describe('Parent-chain router for this Zone and Earn vault.'), z.meta({ examples: ['
|
|
111
|
+
.check(z.int(), z.nonnegative(), z.describe('Parent-chain block that deployed the Earn router.'), z.meta({ examples: [35816964] })),
|
|
112
|
+
earnRouter: Schema.Address.check(z.describe('Parent-chain router for this Zone and Earn vault.'), z.meta({ examples: ['0x8117e0ba6239b9695f780deb010f72a2fa4bdfb6'] })),
|
|
112
113
|
inputTokens: z
|
|
113
114
|
.array(Schema.Address)
|
|
114
|
-
.check(z.describe('Tokens accepted by private deposits.'), z.meta({ examples: [['
|
|
115
|
+
.check(z.describe('Tokens accepted by private deposits.'), z.meta({ examples: [['0x20c0000000000000000000006fd9a167923ba194']] })),
|
|
115
116
|
name: z
|
|
116
117
|
.string()
|
|
117
|
-
.check(z.describe('Private Zone name.'), z.meta({ examples: ['zone-
|
|
118
|
+
.check(z.describe('Private Zone name.'), z.meta({ examples: ['zone-mainnet-internal'] })),
|
|
118
119
|
outputTokens: z
|
|
119
120
|
.array(Schema.Address)
|
|
120
|
-
.check(z.describe('Tokens returned by private redemptions.'), z.meta({ examples: [['
|
|
121
|
+
.check(z.describe('Tokens returned by private redemptions.'), z.meta({ examples: [['0x20c0000000000000000000006fd9a167923ba194']] })),
|
|
121
122
|
})
|
|
122
123
|
.check(z.describe('Verified Earn route through one private Zone.'));
|
|
123
124
|
const value = z.strictObject({
|
|
@@ -139,31 +140,58 @@ export var schema;
|
|
|
139
140
|
apy: z
|
|
140
141
|
.optional(z.nullable(EarnRates.schema.Apy))
|
|
141
142
|
.check(z.describe('Annualized share-price growth over the selected window, when requested via `include=apy` or by selecting `apy.window`. Null when the rate could not be measured: the vault predates the window, a boundary or historical quote is unavailable, the engine changed inside the window, or the growth is too extreme to annualize as a ratio.')),
|
|
142
|
-
assetToken: Tokens.schema.Token.check(z.describe('Asset accepted by the vault.')
|
|
143
|
+
assetToken: Tokens.schema.Token.check(z.describe('Asset accepted by the vault.'), z.meta({
|
|
144
|
+
examples: [
|
|
145
|
+
{
|
|
146
|
+
address: '0x20c0000000000000000000000000000000000000',
|
|
147
|
+
currency: 'USD',
|
|
148
|
+
decimals: 6,
|
|
149
|
+
id: '0x20c0000000000000000000000000000000000000',
|
|
150
|
+
name: 'PathUSD',
|
|
151
|
+
symbol: 'pathUSD',
|
|
152
|
+
verified: true,
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
})),
|
|
143
156
|
capabilities: z
|
|
144
157
|
.optional(EarnVaults.schema.Discovery.shape.capabilities)
|
|
145
158
|
.check(z.describe('Vault capabilities, when requested.')),
|
|
146
159
|
description: z
|
|
147
160
|
.nullable(z.string())
|
|
148
|
-
.check(z.describe('Curated vault description, or null when the vault is not verified.'), z.meta({ examples: ['
|
|
161
|
+
.check(z.describe('Curated vault description, or null when the vault is not verified.'), z.meta({ examples: ['deelUSD deposited into the canonical Tempo Earn deployment.'] })),
|
|
149
162
|
engine,
|
|
150
|
-
id: Schema.Address.check(z.describe('Stable vault id, equal to the lowercase vault address.'), z.meta({ examples: ['
|
|
163
|
+
id: Schema.Address.check(z.describe('Stable vault id, equal to the lowercase vault address.'), z.meta({ examples: ['0x4f94590b636f5878bce585e82379de81e1ec174f'] })),
|
|
151
164
|
instantLiquidity: EarnVaults.schema.Discovery.shape.instantLiquidity.check(z.describe('Assets the venue would release right now, capped at the vault backing, in asset base units. Null when the engine interface cannot report a reliable number.')),
|
|
165
|
+
instantLiquidityValue: z
|
|
166
|
+
.optional(z.nullable(value))
|
|
167
|
+
.check(z.describe('Instant liquidity valued in USD, when requested via `include=tvl`, or null when liquidity is unavailable or the asset has no priced display currency.')),
|
|
152
168
|
label: z
|
|
153
169
|
.string()
|
|
154
|
-
.check(z.describe('Vault display label.'), z.meta({ examples: ['
|
|
170
|
+
.check(z.describe('Vault display label.'), z.meta({ examples: ['deelUSD Earn'] })),
|
|
155
171
|
sharePrice: z
|
|
156
172
|
.nullable(value)
|
|
157
173
|
.check(z.describe('Assets returned for one whole earn share, in the asset display currency, or null when the engine cannot quote an exit.')),
|
|
158
|
-
shareToken: Tokens.schema.Token.check(z.describe('Token representing vault shares.')
|
|
174
|
+
shareToken: Tokens.schema.Token.check(z.describe('Token representing vault shares.'), z.meta({
|
|
175
|
+
examples: [
|
|
176
|
+
{
|
|
177
|
+
address: '0x20c000000000000000000000c3268d803b51d448',
|
|
178
|
+
currency: 'USD',
|
|
179
|
+
decimals: 6,
|
|
180
|
+
id: '0x20c000000000000000000000c3268d803b51d448',
|
|
181
|
+
name: 'Sentora pathUSD (Earn)',
|
|
182
|
+
symbol: 'senpathUSDE',
|
|
183
|
+
verified: false,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
})),
|
|
159
187
|
slug: z
|
|
160
188
|
.nullable(z.string())
|
|
161
|
-
.check(z.describe('Curated URL slug, or null when the vault is not verified.'), z.meta({ examples: ['
|
|
189
|
+
.check(z.describe('Curated URL slug, or null when the vault is not verified.'), z.meta({ examples: ['deelusd-earn'] })),
|
|
162
190
|
state: EarnVaults.schema.Discovery.shape.state,
|
|
163
191
|
tvl: z
|
|
164
192
|
.optional(z.nullable(value))
|
|
165
193
|
.check(z.describe('Total assets valued in USD, when requested via `include=tvl`, or null when the asset has no priced display currency.')),
|
|
166
|
-
vaultAddress: Schema.Address.check(z.describe('Earn vault contract address.'), z.meta({ examples: ['
|
|
194
|
+
vaultAddress: Schema.Address.check(z.describe('Earn vault contract address.'), z.meta({ examples: ['0x4f94590b636f5878bce585e82379de81e1ec174f'] })),
|
|
167
195
|
verified: z
|
|
168
196
|
.boolean()
|
|
169
197
|
.check(z.describe('Whether this vault is in the curated earn registry.'), z.meta({ examples: [true] })),
|
|
@@ -174,12 +202,12 @@ export var schema;
|
|
|
174
202
|
examples: [
|
|
175
203
|
[
|
|
176
204
|
{
|
|
177
|
-
chainId:
|
|
178
|
-
deploymentBlock:
|
|
179
|
-
earnRouter: '
|
|
180
|
-
inputTokens: ['
|
|
181
|
-
name: 'zone-
|
|
182
|
-
outputTokens: ['
|
|
205
|
+
chainId: 421700001,
|
|
206
|
+
deploymentBlock: 35816964,
|
|
207
|
+
earnRouter: '0x8117e0ba6239b9695f780deb010f72a2fa4bdfb6',
|
|
208
|
+
inputTokens: ['0x20c0000000000000000000006fd9a167923ba194'],
|
|
209
|
+
name: 'zone-mainnet-internal',
|
|
210
|
+
outputTokens: ['0x20c0000000000000000000006fd9a167923ba194'],
|
|
183
211
|
},
|
|
184
212
|
],
|
|
185
213
|
],
|
|
@@ -200,25 +228,42 @@ export var schema;
|
|
|
200
228
|
const position = z.strictObject({
|
|
201
229
|
account: Schema.Address.check(z.describe('Account whose earn position was read.'), z.meta({ examples: ['0xbe058e1c4df8a4366a387bf595b284246a93039e'] })),
|
|
202
230
|
assetAllowance: Schema.DecimalString.check(z.describe('Assets the vault may spend from this account, in asset base units.'), z.meta({ examples: ['0'] })),
|
|
203
|
-
assetBalance: Schema.DecimalString.check(z.describe('Assets this account
|
|
231
|
+
assetBalance: Schema.DecimalString.check(z.describe('Assets held by this account at the observation block, in asset base units.'), z.meta({ examples: ['250000000'] })),
|
|
204
232
|
assetToken: Schema.tokenAddress('0x20c000000000000000000000b9537d11c60e8b50').check(z.describe('TIP-20 asset token accepted by the vault.')),
|
|
205
233
|
id: Schema.Address.check(z.describe('Stable resource ID for this vault position, equal to the account address.'), z.meta({ examples: ['0xbe058e1c4df8a4366a387bf595b284246a93039e'] })),
|
|
206
234
|
shareAllowance: Schema.DecimalString.check(z.describe('Earn shares the vault may spend from this account, in share base units.'), z.meta({ examples: ['0'] })),
|
|
207
|
-
shareBalance: Schema.DecimalString.check(z.describe('Earn shares this account
|
|
235
|
+
shareBalance: Schema.DecimalString.check(z.describe('Earn shares held by this account at the observation block, in share base units.'), z.meta({ examples: ['99500000'] })),
|
|
208
236
|
shareToken: Schema.tokenAddress('0x20c000000000000000000000300e14ab91a10769').check(z.describe('TIP-20 token representing earn shares.')),
|
|
209
|
-
value: Schema.DecimalString.check(z.describe('
|
|
237
|
+
value: Schema.DecimalString.check(z.describe('Asset value of this account’s earn shares at the observation block, including fees, in asset base units.'), z.meta({ examples: ['100000000'] })),
|
|
210
238
|
});
|
|
239
|
+
const lifetimeCashFlows = z.union([
|
|
240
|
+
z.strictObject({
|
|
241
|
+
status: z
|
|
242
|
+
.literal('complete')
|
|
243
|
+
.check(z.describe('Cash flows are complete through the indexed boundary.'), z.meta({ examples: ['complete'] })),
|
|
244
|
+
totalDeposited: Schema.DecimalString.check(z.describe('Assets deposited with this account as receiver over indexed vault history.')),
|
|
245
|
+
totalWithdrawn: Schema.DecimalString.check(z.describe('Assets returned by completed withdrawals over indexed vault history.')),
|
|
246
|
+
}),
|
|
247
|
+
z.strictObject({
|
|
248
|
+
status: z
|
|
249
|
+
.literal('incomplete_history')
|
|
250
|
+
.check(z.describe('Cash flows are omitted because asset deposit history is incomplete.'), z.meta({ examples: ['incomplete_history'] })),
|
|
251
|
+
}),
|
|
252
|
+
]);
|
|
211
253
|
const addressPosition = z.strictObject({
|
|
212
254
|
assetAmount: value.check(z.describe('Current asset value of the held shares, including fees, in `assetToken` units.')),
|
|
213
255
|
assetToken: Tokens.schema.Token.check(z.describe('Asset accepted by the vault.')),
|
|
214
|
-
id: Schema.Address.check(z.describe('Stable resource ID for this position, equal to the vault address.'), z.meta({ examples: ['
|
|
256
|
+
id: Schema.Address.check(z.describe('Stable resource ID for this position, equal to the vault address.'), z.meta({ examples: ['0x4f94590b636f5878bce585e82379de81e1ec174f'] })),
|
|
257
|
+
lifetimeCashFlows: z
|
|
258
|
+
.optional(lifetimeCashFlows)
|
|
259
|
+
.check(z.describe('Lifetime deposits and completed withdrawals, when requested.')),
|
|
215
260
|
shareAmount: value.check(z.describe('Earn share balance this account holds, in `shareToken` units.')),
|
|
216
261
|
shareToken: Tokens.schema.Token.check(z.describe('Token representing vault shares.')),
|
|
217
262
|
valuation: z
|
|
218
263
|
.optional(z.nullable(Valuation.schema.Value))
|
|
219
264
|
.check(z.describe('The position’s nominal value when `valuation.currency` is requested, or `null` when ' +
|
|
220
265
|
'the asset token is unverified, its display currency has no rate, or rates were unavailable.')),
|
|
221
|
-
vaultAddress: Schema.Address.check(z.describe('Earn vault contract address holding this position.'), z.meta({ examples: ['
|
|
266
|
+
vaultAddress: Schema.Address.check(z.describe('Earn vault contract address holding this position.'), z.meta({ examples: ['0x4f94590b636f5878bce585e82379de81e1ec174f'] })),
|
|
222
267
|
verified: z
|
|
223
268
|
.boolean()
|
|
224
269
|
.check(z.describe('Whether the vault is in the curated earn registry.'), z.meta({ examples: [true] })),
|
|
@@ -237,6 +282,8 @@ export var schema;
|
|
|
237
282
|
lifetimeEarnings: z
|
|
238
283
|
.string()
|
|
239
284
|
.check(z.regex(/^-?\d+$/), z.describe('Current share value plus completed redemptions, exact withdrawals, and finalized async assets, minus asset deposits, at the latest indexed block.'), z.meta({ examples: ['0'] })),
|
|
285
|
+
totalDeposited: Schema.DecimalString.check(z.describe('Assets deposited with this account as receiver over complete indexed vault history.'), z.meta({ examples: ['1000000'] })),
|
|
286
|
+
totalWithdrawn: Schema.DecimalString.check(z.describe('Assets returned by completed redemptions and exact withdrawals initiated by this account over complete indexed vault history.'), z.meta({ examples: ['1000000'] })),
|
|
240
287
|
period: z
|
|
241
288
|
.literal('lifetime')
|
|
242
289
|
.check(z.describe('Returns lifetime net asset earnings.'), z.meta({ examples: ['lifetime'] })),
|
|
@@ -274,11 +321,21 @@ export var schema;
|
|
|
274
321
|
}),
|
|
275
322
|
z.extend(earningsBase, {
|
|
276
323
|
period: z
|
|
277
|
-
.
|
|
278
|
-
.check(z.describe('
|
|
324
|
+
.literal('30d')
|
|
325
|
+
.check(z.describe('Trailing period with an unresolved async redemption.'), z.meta({ examples: ['30d'] })),
|
|
326
|
+
status: z
|
|
327
|
+
.literal('pending_redemption')
|
|
328
|
+
.check(z.describe('Earnings are unavailable while an async redemption remains open.'), z.meta({ examples: ['pending_redemption'] })),
|
|
329
|
+
}),
|
|
330
|
+
z.extend(earningsBase, {
|
|
331
|
+
period: z
|
|
332
|
+
.literal('lifetime')
|
|
333
|
+
.check(z.describe('Lifetime period with an unresolved async redemption.'), z.meta({ examples: ['lifetime'] })),
|
|
279
334
|
status: z
|
|
280
335
|
.literal('pending_redemption')
|
|
281
336
|
.check(z.describe('Earnings are unavailable while an async redemption remains open.'), z.meta({ examples: ['pending_redemption'] })),
|
|
337
|
+
totalDeposited: Schema.DecimalString.check(z.describe('Assets deposited over complete indexed vault history.')),
|
|
338
|
+
totalWithdrawn: Schema.DecimalString.check(z.describe('Assets withdrawn over complete indexed vault history.')),
|
|
282
339
|
}),
|
|
283
340
|
]);
|
|
284
341
|
const meta = z
|
|
@@ -356,6 +413,7 @@ export var schema;
|
|
|
356
413
|
.strictObject({
|
|
357
414
|
chainId: Schema.ChainIdQuery,
|
|
358
415
|
cursor: Schema.Cursor,
|
|
416
|
+
include: Schema.includeQuery(z.enum(['earnings']), 'Comma-separated position fields to include, such as `earnings`.'),
|
|
359
417
|
limit: Schema.Limit,
|
|
360
418
|
'valuation.currency': Schema.Denomination.check(z.describe('When present, include each position’s nominal value in this denomination. ' +
|
|
361
419
|
'Case-insensitive and must be priced by the configured FX oracle.')),
|
|
@@ -405,19 +463,42 @@ export var schema;
|
|
|
405
463
|
/** Schemas for the getEarnVaultPosition operation. */
|
|
406
464
|
let getEarnVaultPosition;
|
|
407
465
|
(function (getEarnVaultPosition) {
|
|
466
|
+
const asOf = z.iso.datetime({ offset: true });
|
|
408
467
|
/** Path parameters identifying the Earn vault and account. */
|
|
409
468
|
getEarnVaultPosition.Params = z
|
|
410
469
|
.strictObject({
|
|
411
470
|
address: Schema.Address.check(z.describe('Account whose earn position to read.')),
|
|
412
|
-
vaultId: Schema.address('
|
|
471
|
+
vaultId: Schema.address('0x4f94590b636f5878bce585e82379de81e1ec174f').check(z.describe('Earn vault contract address.')),
|
|
413
472
|
})
|
|
414
473
|
.check(z.describe('Path parameters identifying an earn vault position.'));
|
|
415
474
|
/** Query parameters selecting the chain containing the vault. */
|
|
416
475
|
getEarnVaultPosition.Query = z
|
|
417
|
-
.strictObject({
|
|
476
|
+
.strictObject({
|
|
477
|
+
asOf: z
|
|
478
|
+
.optional(asOf)
|
|
479
|
+
.check(z.describe('ISO 8601 timestamp at which to read the position. Resolves the latest indexed block at or before this time.'), z.meta({ examples: ['2026-07-21T09:00:00.000Z'] })),
|
|
480
|
+
chainId: Schema.ChainIdQuery,
|
|
481
|
+
})
|
|
418
482
|
.check(z.describe('Query parameters selecting an earn vault position.'));
|
|
419
|
-
|
|
420
|
-
|
|
483
|
+
const Block = z
|
|
484
|
+
.strictObject({
|
|
485
|
+
number: z
|
|
486
|
+
.number()
|
|
487
|
+
.check(z.int(), z.nonnegative(), z.describe('Indexed observation block.'), z.meta({ examples: [31039238] })),
|
|
488
|
+
timestamp: z.iso
|
|
489
|
+
.datetime()
|
|
490
|
+
.check(z.describe('Timestamp of the indexed observation block.'), z.meta({ examples: ['2026-07-21T09:00:00.000Z'] })),
|
|
491
|
+
})
|
|
492
|
+
.check(z.describe('Indexed block used for a historical Earn position observation.'));
|
|
493
|
+
/** Current or historical asset and Earn-share state for one account in one vault. */
|
|
494
|
+
getEarnVaultPosition.Response = Schema.describe(z.extend(position, {
|
|
495
|
+
asOf: z
|
|
496
|
+
.optional(asOf)
|
|
497
|
+
.check(z.describe('Requested historical observation time, when supplied.'), z.meta({ examples: ['2026-07-21T09:00:00.000Z'] })),
|
|
498
|
+
block: z
|
|
499
|
+
.optional(Block)
|
|
500
|
+
.check(z.describe('Indexed block used for a historical Earn position observation, when requested.')),
|
|
501
|
+
}), 'Current or historical asset and earn-share balances, allowances, and asset value for an account in one earn vault.');
|
|
421
502
|
})(getEarnVaultPosition = schema.getEarnVaultPosition || (schema.getEarnVaultPosition = {}));
|
|
422
503
|
/** Schemas for the getEarnVaultEarnings operation. */
|
|
423
504
|
let getEarnVaultEarnings;
|
|
@@ -465,7 +546,7 @@ export function earn(options = {}) {
|
|
|
465
546
|
Cache.response({
|
|
466
547
|
cacheControl: Cache.policies.state,
|
|
467
548
|
key: (c) => vaultCacheKey(c, schema.getEarnVaults.Query),
|
|
468
|
-
name: 'tempo-api:earn-vaults:
|
|
549
|
+
name: 'tempo-api:earn-vaults:v4',
|
|
469
550
|
}), async (c) => {
|
|
470
551
|
if (Auth.narrowAccess)
|
|
471
552
|
return Auth.paidAccessError(c);
|
|
@@ -502,7 +583,7 @@ export function earn(options = {}) {
|
|
|
502
583
|
}), Cache.response({
|
|
503
584
|
cacheControl: Cache.policies.state,
|
|
504
585
|
key: (c) => vaultCacheKey(c, schema.getVerifiedEarnVaults.Query),
|
|
505
|
-
name: 'tempo-api:earn-vaults:
|
|
586
|
+
name: 'tempo-api:earn-vaults:v4',
|
|
506
587
|
}), async (c) => {
|
|
507
588
|
if (Auth.narrowAccess)
|
|
508
589
|
return Auth.paidAccessError(c);
|
|
@@ -528,7 +609,7 @@ export function earn(options = {}) {
|
|
|
528
609
|
code: 'query_invalid',
|
|
529
610
|
message: 'Invalid query parameters',
|
|
530
611
|
}), OpenApi.describeRoute({
|
|
531
|
-
description: 'Lists every earn vault where an account currently holds shares, with
|
|
612
|
+
description: 'Lists every earn vault where an account currently holds shares, with current balances and optional lifetime cash flows.',
|
|
532
613
|
operationId: 'getEarnAddressPositions',
|
|
533
614
|
responses: OpenApi.responses({
|
|
534
615
|
errors: {
|
|
@@ -555,7 +636,7 @@ export function earn(options = {}) {
|
|
|
555
636
|
Cache.response({
|
|
556
637
|
cacheControl: Cache.policies.noStore,
|
|
557
638
|
key: (c) => Cache.urlKey(c, schema.getEarnAddressPositions.Query),
|
|
558
|
-
name: 'tempo-api:earn-address-positions:
|
|
639
|
+
name: 'tempo-api:earn-address-positions:v2',
|
|
559
640
|
}), async (c) => {
|
|
560
641
|
if (Auth.narrowAccess)
|
|
561
642
|
return Auth.paidAccessError(c);
|
|
@@ -601,7 +682,7 @@ export function earn(options = {}) {
|
|
|
601
682
|
code: 'query_invalid',
|
|
602
683
|
message: 'Invalid query parameters',
|
|
603
684
|
}), OpenApi.describeRoute({
|
|
604
|
-
description: 'Gets an account’s asset and earn-share balances, allowances, and
|
|
685
|
+
description: 'Gets an account’s asset and earn-share balances, allowances, and asset value for one earn vault, optionally at an ISO 8601 timestamp.',
|
|
605
686
|
operationId: 'getEarnVaultPosition',
|
|
606
687
|
responses: OpenApi.responses({
|
|
607
688
|
errors: {
|
|
@@ -620,16 +701,18 @@ export function earn(options = {}) {
|
|
|
620
701
|
502: 'Could not read the earn vault position.',
|
|
621
702
|
},
|
|
622
703
|
success: {
|
|
623
|
-
description: 'Current earn position for one account in one vault.',
|
|
704
|
+
description: 'Current or historical earn position for one account in one vault.',
|
|
624
705
|
schema: schema.getEarnVaultPosition.Response,
|
|
625
706
|
},
|
|
626
707
|
}),
|
|
627
708
|
summary: 'Get account position',
|
|
628
709
|
tags: ['Earn'],
|
|
629
|
-
}),
|
|
630
|
-
|
|
710
|
+
}),
|
|
711
|
+
// Account holdings must read fresh immediately after a deposit or redemption.
|
|
712
|
+
Cache.response({
|
|
713
|
+
cacheControl: Cache.policies.noStore,
|
|
631
714
|
key: (c) => Cache.urlKey(c, schema.getEarnVaultPosition.Query),
|
|
632
|
-
name: 'tempo-api:earn-vault-positions:
|
|
715
|
+
name: 'tempo-api:earn-vault-positions:v2',
|
|
633
716
|
}), async (c) => {
|
|
634
717
|
if (Auth.narrowAccess)
|
|
635
718
|
return Auth.paidAccessError(c);
|
|
@@ -658,34 +741,85 @@ export function earn(options = {}) {
|
|
|
658
741
|
const { address, vaultId } = c.req.valid('param');
|
|
659
742
|
const query = c.req.valid('query');
|
|
660
743
|
const chainId = query.chainId ?? c.get('chainId');
|
|
744
|
+
const client = c.get('getClient')(chainId);
|
|
661
745
|
try {
|
|
662
|
-
const
|
|
663
|
-
|
|
664
|
-
.
|
|
665
|
-
return c.json(Response.validated(schema.getEarnVaultPosition.Response, {
|
|
666
|
-
account: address,
|
|
667
|
-
assetAllowance: position.assetAllowance.toString(),
|
|
668
|
-
assetBalance: position.assetBalance.toString(),
|
|
669
|
-
assetToken: position.assetToken,
|
|
670
|
-
id: address,
|
|
671
|
-
shareAllowance: position.shareAllowance.toString(),
|
|
672
|
-
shareBalance: position.shareBalance.toString(),
|
|
673
|
-
shareToken: position.shareToken,
|
|
674
|
-
value: position.value.toString(),
|
|
675
|
-
}), 200);
|
|
676
|
-
}
|
|
677
|
-
catch (cause) {
|
|
746
|
+
const block = query.asOf === undefined
|
|
747
|
+
? undefined
|
|
748
|
+
: await getIndexedBlockAtOrBefore(c.get('getTidx')(chainId), query.asOf);
|
|
678
749
|
try {
|
|
679
|
-
await
|
|
750
|
+
const position = await client.earn.getPosition({
|
|
751
|
+
account: address,
|
|
752
|
+
...(block ? { blockNumber: BigInt(block.number) } : {}),
|
|
753
|
+
vault: vaultId,
|
|
754
|
+
});
|
|
755
|
+
return c.json(Response.validated(schema.getEarnVaultPosition.Response, {
|
|
756
|
+
account: address,
|
|
757
|
+
assetAllowance: position.assetAllowance.toString(),
|
|
758
|
+
assetBalance: position.assetBalance.toString(),
|
|
759
|
+
assetToken: position.assetToken,
|
|
760
|
+
asOf: query.asOf,
|
|
761
|
+
block,
|
|
762
|
+
id: address,
|
|
763
|
+
shareAllowance: position.shareAllowance.toString(),
|
|
764
|
+
shareBalance: position.shareBalance.toString(),
|
|
765
|
+
shareToken: position.shareToken,
|
|
766
|
+
value: position.value.toString(),
|
|
767
|
+
}), 200);
|
|
680
768
|
}
|
|
681
|
-
catch (
|
|
682
|
-
if (
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
769
|
+
catch (cause) {
|
|
770
|
+
if (block) {
|
|
771
|
+
try {
|
|
772
|
+
// These immutable bindings establish historical vault identity
|
|
773
|
+
// without repeating fallible token or redemption subreads.
|
|
774
|
+
const [asset, shareToken] = await Promise.all([
|
|
775
|
+
client.readContract({
|
|
776
|
+
abi: Abis.earnVault,
|
|
777
|
+
address: vaultId,
|
|
778
|
+
blockNumber: BigInt(block.number),
|
|
779
|
+
functionName: 'asset',
|
|
780
|
+
}),
|
|
781
|
+
client.readContract({
|
|
782
|
+
abi: Abis.earnVault,
|
|
783
|
+
address: vaultId,
|
|
784
|
+
blockNumber: BigInt(block.number),
|
|
785
|
+
functionName: 'earnShare',
|
|
786
|
+
}),
|
|
787
|
+
]);
|
|
788
|
+
if (asset === zeroAddress || shareToken === zeroAddress)
|
|
789
|
+
return Response.error(c, {
|
|
790
|
+
code: 'earn_vault_not_found',
|
|
791
|
+
message: 'Earn vault not found',
|
|
792
|
+
status: 404,
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
catch (identityCause) {
|
|
796
|
+
if (isIncompatible(identityCause))
|
|
797
|
+
return Response.error(c, {
|
|
798
|
+
code: 'earn_vault_not_found',
|
|
799
|
+
message: 'Earn vault not found',
|
|
800
|
+
status: 404,
|
|
801
|
+
});
|
|
802
|
+
return Response.upstream(c, identityCause);
|
|
803
|
+
}
|
|
804
|
+
return Response.upstream(c, cause);
|
|
805
|
+
}
|
|
806
|
+
try {
|
|
807
|
+
await resolveVaultDiscovery(c, { chainId, include: [], vaultAddress: vaultId });
|
|
808
|
+
}
|
|
809
|
+
catch (vaultCause) {
|
|
810
|
+
if (isIncompatible(vaultCause))
|
|
811
|
+
return Response.error(c, {
|
|
812
|
+
code: 'earn_vault_not_found',
|
|
813
|
+
message: 'Earn vault not found',
|
|
814
|
+
status: 404,
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
return Response.upstream(c, cause);
|
|
688
818
|
}
|
|
819
|
+
}
|
|
820
|
+
catch (cause) {
|
|
821
|
+
if (cause instanceof IndexedBlockNotFoundError || cause instanceof IndexedCoverageError)
|
|
822
|
+
return Response.error(c, { code: 'query_invalid', message: cause.message, status: 400 });
|
|
689
823
|
return Response.upstream(c, cause);
|
|
690
824
|
}
|
|
691
825
|
})
|
|
@@ -724,7 +858,7 @@ export function earn(options = {}) {
|
|
|
724
858
|
}), Cache.response({
|
|
725
859
|
cacheControl: Cache.policies.state,
|
|
726
860
|
key: (c) => Cache.urlKey(c, schema.getEarnVaultEarnings.Query),
|
|
727
|
-
name: 'tempo-api:earn-vault-earnings:
|
|
861
|
+
name: 'tempo-api:earn-vault-earnings:v4',
|
|
728
862
|
}), async (c) => {
|
|
729
863
|
if (Auth.narrowAccess)
|
|
730
864
|
return Auth.paidAccessError(c);
|
|
@@ -804,7 +938,7 @@ export function earn(options = {}) {
|
|
|
804
938
|
}), Cache.response({
|
|
805
939
|
cacheControl: Cache.policies.state,
|
|
806
940
|
key: (c) => vaultCacheKey(c, schema.getEarnVault.Query),
|
|
807
|
-
name: 'tempo-api:earn-vaults:
|
|
941
|
+
name: 'tempo-api:earn-vaults:v4',
|
|
808
942
|
}), async (c) => {
|
|
809
943
|
if (Auth.narrowAccess)
|
|
810
944
|
return Auth.paidAccessError(c);
|
|
@@ -911,10 +1045,20 @@ export async function getVaultEarnings(c, options) {
|
|
|
911
1045
|
};
|
|
912
1046
|
if (history.incompleteCostBasis || externalShareTransfer)
|
|
913
1047
|
return { ...base, status: 'incomplete_cost_basis' };
|
|
1048
|
+
const totalWithdrawn = history.redeemed + history.withdrewExact + history.finalized;
|
|
1049
|
+
const cashFlows = {
|
|
1050
|
+
totalDeposited: history.deposited.toString(),
|
|
1051
|
+
totalWithdrawn: totalWithdrawn.toString(),
|
|
1052
|
+
};
|
|
914
1053
|
if (history.pendingRedemption)
|
|
915
|
-
return { ...base, status: 'pending_redemption' };
|
|
916
|
-
const lifetimeEarnings = current.value +
|
|
917
|
-
return {
|
|
1054
|
+
return { ...base, ...cashFlows, status: 'pending_redemption' };
|
|
1055
|
+
const lifetimeEarnings = current.value + totalWithdrawn - history.deposited;
|
|
1056
|
+
return {
|
|
1057
|
+
...base,
|
|
1058
|
+
...cashFlows,
|
|
1059
|
+
lifetimeEarnings: lifetimeEarnings.toString(),
|
|
1060
|
+
status: 'complete',
|
|
1061
|
+
};
|
|
918
1062
|
}
|
|
919
1063
|
/** Reads cash-flow-adjusted earnings over a trailing indexed window. */
|
|
920
1064
|
async function getWindowVaultEarnings(c, options) {
|
|
@@ -1003,6 +1147,53 @@ async function getLatestIndexedBlock(tidx) {
|
|
|
1003
1147
|
throw new Error('TIDX returned no indexed block.');
|
|
1004
1148
|
return { number, timestamp };
|
|
1005
1149
|
}
|
|
1150
|
+
/** Resolves the latest indexed block at or before a historical position timestamp. */
|
|
1151
|
+
async function getIndexedBlockAtOrBefore(tidx, asOf) {
|
|
1152
|
+
const timestamp = new Date(asOf).toISOString().replace('T', ' ').replace(/Z$/, '');
|
|
1153
|
+
const result = await tidx.fetch({
|
|
1154
|
+
engine: 'clickhouse',
|
|
1155
|
+
// SAFETY: Zod restricts `asOf` to ISO 8601, so the formatted timestamp cannot alter SQL.
|
|
1156
|
+
query: `
|
|
1157
|
+
SELECT 'boundary' AS kind, num, timestamp
|
|
1158
|
+
FROM (
|
|
1159
|
+
SELECT num, timestamp
|
|
1160
|
+
FROM blocks
|
|
1161
|
+
WHERE timestamp <= '${timestamp}'
|
|
1162
|
+
ORDER BY timestamp DESC, num DESC
|
|
1163
|
+
LIMIT 1
|
|
1164
|
+
)
|
|
1165
|
+
UNION ALL
|
|
1166
|
+
SELECT 'head' AS kind, num, timestamp
|
|
1167
|
+
FROM (
|
|
1168
|
+
SELECT num, timestamp
|
|
1169
|
+
FROM blocks
|
|
1170
|
+
ORDER BY num DESC
|
|
1171
|
+
LIMIT 1
|
|
1172
|
+
)
|
|
1173
|
+
`,
|
|
1174
|
+
});
|
|
1175
|
+
return parseIndexedBlockAtOrBefore({ asOf, rows: result.rows });
|
|
1176
|
+
}
|
|
1177
|
+
/** Decodes the indexed head and historical position boundary from TIDX rows. */
|
|
1178
|
+
export function parseIndexedBlockAtOrBefore(options) {
|
|
1179
|
+
const head = options.rows.find((row) => row['kind'] === 'head');
|
|
1180
|
+
if (!head)
|
|
1181
|
+
throw new Error('TIDX returned no indexed head for a historical Earn position.');
|
|
1182
|
+
const headNumber = Value.toNumber(head['num']);
|
|
1183
|
+
const headAt = Value.toIsoDateTime(head['timestamp']);
|
|
1184
|
+
if (headNumber === undefined || headAt === undefined)
|
|
1185
|
+
throw new Error('TIDX returned a malformed indexed head for a historical Earn position.');
|
|
1186
|
+
const boundary = options.rows.find((row) => row['kind'] === 'boundary');
|
|
1187
|
+
if (!boundary)
|
|
1188
|
+
throw new IndexedBlockNotFoundError(options.asOf);
|
|
1189
|
+
const number = Value.toNumber(boundary['num']);
|
|
1190
|
+
const indexedAt = Value.toIsoDateTime(boundary['timestamp']);
|
|
1191
|
+
if (number === undefined || indexedAt === undefined)
|
|
1192
|
+
throw new Error('TIDX returned a malformed historical Earn position boundary.');
|
|
1193
|
+
if (Date.parse(headAt) < Date.parse(options.asOf))
|
|
1194
|
+
throw new IndexedCoverageError(options.asOf);
|
|
1195
|
+
return { number, timestamp: indexedAt };
|
|
1196
|
+
}
|
|
1006
1197
|
/** Resolves the last indexed block at or before a trailing-day boundary. */
|
|
1007
1198
|
async function getWindowStartBlockNumber(tidx, options) {
|
|
1008
1199
|
const cutoff = new Date(Date.parse(options.timestamp) - Ttl.days(options.days)).toISOString();
|
|
@@ -1128,6 +1319,7 @@ async function getVaultEarningsHistory(tidx, options) {
|
|
|
1128
1319
|
return {
|
|
1129
1320
|
deposited: BigInt(deposited),
|
|
1130
1321
|
finalized: BigInt(finalized),
|
|
1322
|
+
incompleteCashFlows: venueDeposits > 0,
|
|
1131
1323
|
incompleteCostBasis: transferredCancellations > 0 || venueDeposits > 0,
|
|
1132
1324
|
pendingRedemption: pendingRedemptions > 0,
|
|
1133
1325
|
redeemed: BigInt(redeemed),
|
|
@@ -1779,7 +1971,17 @@ export async function listPositions(c, options) {
|
|
|
1779
1971
|
}
|
|
1780
1972
|
}
|
|
1781
1973
|
const page = matches.slice(0, options.limit);
|
|
1782
|
-
const
|
|
1974
|
+
const indexedBlock = page.length > 0 && options.include.includes('earnings')
|
|
1975
|
+
? await getLatestIndexedBlock(c.get('getTidx')(options.chainId))
|
|
1976
|
+
: undefined;
|
|
1977
|
+
const [cashFlows, tokens, snapshot] = await Promise.all([
|
|
1978
|
+
indexedBlock
|
|
1979
|
+
? getVaultLifetimeCashFlows(c.get('getTidx')(options.chainId), {
|
|
1980
|
+
account: options.address,
|
|
1981
|
+
blockNumber: indexedBlock.number,
|
|
1982
|
+
vaults: page.map(({ vaultAddress }) => Schema.Address.parse(vaultAddress)),
|
|
1983
|
+
})
|
|
1984
|
+
: undefined,
|
|
1783
1985
|
(async () => {
|
|
1784
1986
|
const addresses = [
|
|
1785
1987
|
...new Set(page.flatMap(({ position }) => [position.assetToken, position.shareToken])),
|
|
@@ -1815,6 +2017,7 @@ export async function listPositions(c, options) {
|
|
|
1815
2017
|
: undefined;
|
|
1816
2018
|
return {
|
|
1817
2019
|
data: page.map((match) => serializePosition({
|
|
2020
|
+
cashFlows: cashFlows?.get(match.vaultAddress),
|
|
1818
2021
|
denomination,
|
|
1819
2022
|
position: match.position,
|
|
1820
2023
|
rates,
|
|
@@ -1881,6 +2084,7 @@ function serializePosition(options) {
|
|
|
1881
2084
|
assetAmount: valueFor(position.value, assetToken),
|
|
1882
2085
|
assetToken,
|
|
1883
2086
|
id: vaultAddress,
|
|
2087
|
+
...(options.cashFlows ? { lifetimeCashFlows: options.cashFlows } : {}),
|
|
1884
2088
|
shareAmount: valueFor(position.shareBalance, shareToken),
|
|
1885
2089
|
shareToken,
|
|
1886
2090
|
...(options.denomination
|
|
@@ -1897,6 +2101,129 @@ function serializePosition(options) {
|
|
|
1897
2101
|
verified: options.verified,
|
|
1898
2102
|
};
|
|
1899
2103
|
}
|
|
2104
|
+
/** Reads complete protocol cash flows for one account and a set of vaults. */
|
|
2105
|
+
export async function getVaultLifetimeCashFlows(tidx, options) {
|
|
2106
|
+
const vaults = [...new Set(options.vaults.map((vault) => vault.toLowerCase()))];
|
|
2107
|
+
const cashFlows = new Map();
|
|
2108
|
+
if (vaults.length === 0)
|
|
2109
|
+
return cashFlows;
|
|
2110
|
+
const addresses = vaults.map((vault) => `'${vault}'`).join(', ');
|
|
2111
|
+
const seeds = vaults
|
|
2112
|
+
.map((vault) => `
|
|
2113
|
+
SELECT '${vault}' AS vault,
|
|
2114
|
+
toUInt256(0) AS deposited_assets,
|
|
2115
|
+
toUInt256(0) AS finalized_assets,
|
|
2116
|
+
toUInt256(0) AS redeemed_assets,
|
|
2117
|
+
toUInt64(0) AS venue_deposits,
|
|
2118
|
+
toUInt256(0) AS withdrew_exact`)
|
|
2119
|
+
.join('\n UNION ALL');
|
|
2120
|
+
const result = await tidx.fetch({
|
|
2121
|
+
engine: 'clickhouse',
|
|
2122
|
+
query: `
|
|
2123
|
+
SELECT vault,
|
|
2124
|
+
toString(sum(deposited_assets)) AS deposited_assets,
|
|
2125
|
+
toString(sum(finalized_assets)) AS finalized_assets,
|
|
2126
|
+
toString(sum(redeemed_assets)) AS redeemed_assets,
|
|
2127
|
+
sum(venue_deposits) AS venue_deposits,
|
|
2128
|
+
toString(sum(withdrew_exact)) AS withdrew_exact
|
|
2129
|
+
FROM (
|
|
2130
|
+
${seeds}
|
|
2131
|
+
UNION ALL
|
|
2132
|
+
SELECT address AS vault, sum(toUInt256(assets)) AS deposited_assets,
|
|
2133
|
+
toUInt256(0) AS finalized_assets, toUInt256(0) AS redeemed_assets,
|
|
2134
|
+
toUInt64(0) AS venue_deposits, toUInt256(0) AS withdrew_exact
|
|
2135
|
+
FROM Deposited
|
|
2136
|
+
WHERE address IN (${addresses})
|
|
2137
|
+
AND receiver = '${options.account}'
|
|
2138
|
+
AND block_num > ${beforeFirstBlockNumber}
|
|
2139
|
+
AND block_num <= ${options.blockNumber}
|
|
2140
|
+
GROUP BY address
|
|
2141
|
+
UNION ALL
|
|
2142
|
+
SELECT finalized.address AS vault, toUInt256(0) AS deposited_assets,
|
|
2143
|
+
sum(toUInt256(finalized.assets)) AS finalized_assets,
|
|
2144
|
+
toUInt256(0) AS redeemed_assets, toUInt64(0) AS venue_deposits,
|
|
2145
|
+
toUInt256(0) AS withdrew_exact
|
|
2146
|
+
FROM RedeemFinalized AS finalized
|
|
2147
|
+
INNER JOIN RedeemRequested AS requested
|
|
2148
|
+
ON requested.address = finalized.address
|
|
2149
|
+
AND requested."requestId" = finalized."requestId"
|
|
2150
|
+
WHERE finalized.address IN (${addresses})
|
|
2151
|
+
AND requested.requester = '${options.account}'
|
|
2152
|
+
AND finalized.block_num > ${beforeFirstBlockNumber}
|
|
2153
|
+
AND finalized.block_num <= ${options.blockNumber}
|
|
2154
|
+
AND requested.block_num <= ${options.blockNumber}
|
|
2155
|
+
GROUP BY finalized.address
|
|
2156
|
+
UNION ALL
|
|
2157
|
+
SELECT address AS vault, toUInt256(0) AS deposited_assets,
|
|
2158
|
+
toUInt256(0) AS finalized_assets, sum(toUInt256(assets)) AS redeemed_assets,
|
|
2159
|
+
toUInt64(0) AS venue_deposits,
|
|
2160
|
+
toUInt256(0) AS withdrew_exact
|
|
2161
|
+
FROM Redeemed
|
|
2162
|
+
WHERE address IN (${addresses})
|
|
2163
|
+
AND caller = '${options.account}'
|
|
2164
|
+
AND block_num > ${beforeFirstBlockNumber}
|
|
2165
|
+
AND block_num <= ${options.blockNumber}
|
|
2166
|
+
GROUP BY address
|
|
2167
|
+
UNION ALL
|
|
2168
|
+
SELECT address AS vault, toUInt256(0) AS deposited_assets,
|
|
2169
|
+
toUInt256(0) AS finalized_assets, toUInt256(0) AS redeemed_assets,
|
|
2170
|
+
count() AS venue_deposits, toUInt256(0) AS withdrew_exact
|
|
2171
|
+
FROM VenueSharesDeposited
|
|
2172
|
+
WHERE address IN (${addresses})
|
|
2173
|
+
AND receiver = '${options.account}'
|
|
2174
|
+
AND block_num > ${beforeFirstBlockNumber}
|
|
2175
|
+
AND block_num <= ${options.blockNumber}
|
|
2176
|
+
GROUP BY address
|
|
2177
|
+
UNION ALL
|
|
2178
|
+
SELECT address AS vault, toUInt256(0) AS deposited_assets,
|
|
2179
|
+
toUInt256(0) AS finalized_assets, toUInt256(0) AS redeemed_assets,
|
|
2180
|
+
toUInt64(0) AS venue_deposits, sum(toUInt256(assets)) AS withdrew_exact
|
|
2181
|
+
FROM WithdrewExact
|
|
2182
|
+
WHERE address IN (${addresses})
|
|
2183
|
+
AND caller = '${options.account}'
|
|
2184
|
+
AND block_num > ${beforeFirstBlockNumber}
|
|
2185
|
+
AND block_num <= ${options.blockNumber}
|
|
2186
|
+
GROUP BY address
|
|
2187
|
+
) AS histories
|
|
2188
|
+
GROUP BY vault
|
|
2189
|
+
`,
|
|
2190
|
+
signatures: [
|
|
2191
|
+
depositedSignature,
|
|
2192
|
+
redeemFinalizedSignature,
|
|
2193
|
+
redeemRequestedSignature,
|
|
2194
|
+
redeemedSignature,
|
|
2195
|
+
venueSharesDepositedSignature,
|
|
2196
|
+
withdrewExactSignature,
|
|
2197
|
+
],
|
|
2198
|
+
});
|
|
2199
|
+
for (const row of result.rows) {
|
|
2200
|
+
const vault = Schema.Address.safeParse(Value.toText(row['vault']));
|
|
2201
|
+
const deposited = Value.toIntegerString(row['deposited_assets']);
|
|
2202
|
+
const finalized = Value.toIntegerString(row['finalized_assets']);
|
|
2203
|
+
const redeemed = Value.toIntegerString(row['redeemed_assets']);
|
|
2204
|
+
const venueDeposits = Value.toNumber(row['venue_deposits']);
|
|
2205
|
+
const withdrewExact = Value.toIntegerString(row['withdrew_exact']);
|
|
2206
|
+
if (!vault.success ||
|
|
2207
|
+
deposited === undefined ||
|
|
2208
|
+
finalized === undefined ||
|
|
2209
|
+
redeemed === undefined ||
|
|
2210
|
+
venueDeposits === undefined ||
|
|
2211
|
+
withdrewExact === undefined)
|
|
2212
|
+
throw new Error('TIDX returned invalid Earn lifetime cash flows.');
|
|
2213
|
+
cashFlows.set(vault.data.toLowerCase(), venueDeposits > 0
|
|
2214
|
+
? { status: 'incomplete_history' }
|
|
2215
|
+
: {
|
|
2216
|
+
status: 'complete',
|
|
2217
|
+
totalDeposited: deposited,
|
|
2218
|
+
totalWithdrawn: (BigInt(finalized) +
|
|
2219
|
+
BigInt(redeemed) +
|
|
2220
|
+
BigInt(withdrewExact)).toString(),
|
|
2221
|
+
});
|
|
2222
|
+
}
|
|
2223
|
+
if (cashFlows.size !== vaults.length)
|
|
2224
|
+
throw new Error('TIDX returned incomplete Earn lifetime cash flows.');
|
|
2225
|
+
return cashFlows;
|
|
2226
|
+
}
|
|
1900
2227
|
/** Renders a base-unit amount in the token's display currency and precision. */
|
|
1901
2228
|
function valueFor(amount, token) {
|
|
1902
2229
|
return {
|
|
@@ -2104,11 +2431,27 @@ async function resolveVault(c, options) {
|
|
|
2104
2431
|
token: options.snapshot.byAddress.get(discovery.assetToken.address),
|
|
2105
2432
|
})
|
|
2106
2433
|
: undefined;
|
|
2434
|
+
const liquidityValue = options.include.includes('tvl') && discovery.instantLiquidity !== null
|
|
2435
|
+
? Valuation.valuationFor({
|
|
2436
|
+
amount: BigInt(discovery.instantLiquidity),
|
|
2437
|
+
denomination: tvlDenomination,
|
|
2438
|
+
rates: options.rates,
|
|
2439
|
+
token: options.snapshot.byAddress.get(discovery.assetToken.address),
|
|
2440
|
+
})
|
|
2441
|
+
: undefined;
|
|
2107
2442
|
return serializeVault({
|
|
2108
2443
|
apy: options.apy?.get(discovery.vaultAddress) ?? null,
|
|
2109
2444
|
assetToken: getToken(options.tokens, discovery.assetToken.address),
|
|
2110
2445
|
discovery,
|
|
2111
2446
|
include: options.include,
|
|
2447
|
+
instantLiquidityValue: liquidityValue
|
|
2448
|
+
? {
|
|
2449
|
+
amount: core_Value.from(liquidityValue.amount, tvlDecimals).toString(),
|
|
2450
|
+
currency: liquidityValue.currency,
|
|
2451
|
+
decimals: tvlDecimals,
|
|
2452
|
+
formatted: liquidityValue.amount,
|
|
2453
|
+
}
|
|
2454
|
+
: null,
|
|
2112
2455
|
record,
|
|
2113
2456
|
shareToken: getToken(options.tokens, discovery.shareToken.address),
|
|
2114
2457
|
tvl: valued
|
|
@@ -2144,6 +2487,9 @@ export function serializeVault(options) {
|
|
|
2144
2487
|
},
|
|
2145
2488
|
id: vaultAddress,
|
|
2146
2489
|
instantLiquidity: discovery.instantLiquidity,
|
|
2490
|
+
...(options.include.includes('tvl')
|
|
2491
|
+
? { instantLiquidityValue: options.instantLiquidityValue }
|
|
2492
|
+
: {}),
|
|
2147
2493
|
label: record?.label ?? options.shareToken.name,
|
|
2148
2494
|
sharePrice: discovery.sharePrice === null
|
|
2149
2495
|
? null
|
|
@@ -2301,4 +2647,17 @@ export function isIncompatible(cause) {
|
|
|
2301
2647
|
export class NotFoundError extends Error {
|
|
2302
2648
|
name = 'Earn.NotFoundError';
|
|
2303
2649
|
}
|
|
2650
|
+
/** Thrown when a historical position boundary is not indexed. */
|
|
2651
|
+
class IndexedBlockNotFoundError extends Error {
|
|
2652
|
+
name = 'Earn.IndexedBlockNotFoundError';
|
|
2653
|
+
constructor(asOf) {
|
|
2654
|
+
super(`No indexed block exists at or before ${asOf}.`);
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
class IndexedCoverageError extends Error {
|
|
2658
|
+
name = 'Earn.IndexedCoverageError';
|
|
2659
|
+
constructor(asOf) {
|
|
2660
|
+
super(`Indexed history does not yet cover ${asOf}.`);
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2304
2663
|
//# sourceMappingURL=earn.js.map
|