tapimo 0.7.0 → 0.7.2
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/ApiKeys.d.ts +24 -7
- package/dist/ApiKeys.d.ts.map +1 -1
- package/dist/ApiKeys.js +17 -5
- package/dist/ApiKeys.js.map +1 -1
- package/dist/App.d.ts +12104 -7861
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +191 -128
- package/dist/App.js.map +1 -1
- package/dist/Assets.d.ts +10 -0
- package/dist/Assets.d.ts.map +1 -1
- package/dist/Assets.js +17 -4
- package/dist/Assets.js.map +1 -1
- package/dist/Scope.d.ts +19 -8
- package/dist/Scope.d.ts.map +1 -1
- package/dist/Scope.js +25 -9
- package/dist/Scope.js.map +1 -1
- package/dist/Webhooks.d.ts +1 -1
- package/dist/admin/App.d.ts +601 -20
- package/dist/admin/App.d.ts.map +1 -1
- package/dist/admin/App.js +12 -2
- package/dist/admin/App.js.map +1 -1
- package/dist/admin/apps/api-keys.d.ts +94 -11
- package/dist/admin/apps/api-keys.d.ts.map +1 -1
- package/dist/admin/apps/api-keys.js +141 -32
- package/dist/admin/apps/api-keys.js.map +1 -1
- package/dist/admin/apps/earn-vaults.d.ts +1069 -0
- package/dist/admin/apps/earn-vaults.d.ts.map +1 -0
- package/dist/admin/apps/earn-vaults.js +409 -0
- package/dist/admin/apps/earn-vaults.js.map +1 -0
- package/dist/admin/apps/verified-tokens.d.ts +166 -166
- 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 -95
- package/dist/admin/ui.generated.js.map +1 -1
- package/dist/analytics/Analytics.d.ts +2 -0
- package/dist/analytics/Analytics.d.ts.map +1 -1
- package/dist/analytics/Analytics.js +18 -2
- package/dist/analytics/Analytics.js.map +1 -1
- package/dist/analytics/tables/requestEvents.d.ts +22 -1
- package/dist/analytics/tables/requestEvents.d.ts.map +1 -1
- package/dist/analytics/tables/requestEvents.js +59 -39
- package/dist/analytics/tables/requestEvents.js.map +1 -1
- package/dist/apps/Zones.d.ts +8335 -0
- package/dist/apps/Zones.d.ts.map +1 -0
- package/dist/apps/Zones.js +38 -0
- package/dist/apps/Zones.js.map +1 -0
- package/dist/apps/data/App.d.ts +14377 -10165
- package/dist/apps/data/App.d.ts.map +1 -1
- package/dist/apps/data/App.js +91 -19
- package/dist/apps/data/App.js.map +1 -1
- package/dist/apps/data/FxOracle.d.ts +1 -1
- package/dist/apps/data/FxOracle.d.ts.map +1 -1
- package/dist/apps/data/index.d.ts +0 -1
- package/dist/apps/data/index.d.ts.map +1 -1
- package/dist/apps/data/index.js +0 -1
- package/dist/apps/data/index.js.map +1 -1
- package/dist/apps/data/routes/activities.d.ts +32 -32
- package/dist/apps/data/routes/activities.d.ts.map +1 -1
- package/dist/apps/data/routes/activities.js +130 -65
- package/dist/apps/data/routes/activities.js.map +1 -1
- package/dist/apps/data/routes/addresses.d.ts +312 -312
- package/dist/apps/data/routes/balances.d.ts +18 -18
- package/dist/apps/data/routes/balances.js +5 -5
- package/dist/apps/data/routes/balances.js.map +1 -1
- package/dist/apps/data/routes/coingecko.d.ts +176 -176
- package/dist/apps/data/routes/coingecko.d.ts.map +1 -1
- package/dist/apps/data/routes/coingecko.js +62 -35
- package/dist/apps/data/routes/coingecko.js.map +1 -1
- package/dist/apps/data/routes/earn.d.ts +2144 -0
- package/dist/apps/data/routes/earn.d.ts.map +1 -0
- package/dist/apps/data/routes/earn.js +947 -0
- package/dist/apps/data/routes/earn.js.map +1 -0
- package/dist/apps/data/routes/exchanges.d.ts +1231 -324
- package/dist/apps/data/routes/exchanges.d.ts.map +1 -1
- package/dist/apps/data/routes/exchanges.js +656 -193
- package/dist/apps/data/routes/exchanges.js.map +1 -1
- package/dist/apps/data/routes/fee-amm.d.ts.map +1 -1
- package/dist/apps/data/routes/fee-amm.js +59 -8
- package/dist/apps/data/routes/fee-amm.js.map +1 -1
- package/dist/apps/data/routes/funding.d.ts +4092 -387
- package/dist/apps/data/routes/funding.d.ts.map +1 -1
- package/dist/apps/data/routes/funding.js +1403 -256
- package/dist/apps/data/routes/funding.js.map +1 -1
- package/dist/apps/data/routes/indexer.d.ts +5 -5
- package/dist/apps/data/routes/indexer.d.ts.map +1 -1
- package/dist/apps/data/routes/indexer.js +19 -2
- package/dist/apps/data/routes/indexer.js.map +1 -1
- package/dist/apps/data/routes/receipts.d.ts +265 -265
- package/dist/apps/data/routes/receipts.d.ts.map +1 -1
- package/dist/apps/data/routes/receipts.js +11 -11
- package/dist/apps/data/routes/receipts.js.map +1 -1
- package/dist/apps/data/routes/rpc.d.ts +5 -5
- package/dist/apps/data/routes/rpc.d.ts.map +1 -1
- package/dist/apps/data/routes/rpc.js +211 -22
- package/dist/apps/data/routes/rpc.js.map +1 -1
- package/dist/apps/data/routes/tokenlist.d.ts +36 -36
- package/dist/apps/data/routes/tokenlist.d.ts.map +1 -1
- package/dist/apps/data/routes/tokenlist.js +49 -9
- package/dist/apps/data/routes/tokenlist.js.map +1 -1
- package/dist/apps/data/routes/tokens.d.ts +116 -88
- package/dist/apps/data/routes/tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/tokens.js +198 -91
- package/dist/apps/data/routes/tokens.js.map +1 -1
- package/dist/apps/data/routes/transactions.d.ts +55 -55
- package/dist/apps/data/routes/transactions.d.ts.map +1 -1
- package/dist/apps/data/routes/transactions.js +78 -39
- package/dist/apps/data/routes/transactions.js.map +1 -1
- package/dist/apps/data/routes/transfers.d.ts +78 -29
- package/dist/apps/data/routes/transfers.d.ts.map +1 -1
- package/dist/apps/data/routes/transfers.js +165 -67
- package/dist/apps/data/routes/transfers.js.map +1 -1
- package/dist/apps/data/routes/valuation.d.ts +10 -10
- package/dist/apps/data/routes/valuation.js +2 -2
- package/dist/apps/data/routes/valuation.js.map +1 -1
- package/dist/apps/data/routes/verified-tokens.d.ts.map +1 -1
- package/dist/apps/data/routes/verified-tokens.js +34 -9
- package/dist/apps/data/routes/verified-tokens.js.map +1 -1
- package/dist/apps/data/routes/webhooks.d.ts +5 -3
- package/dist/apps/data/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/data/routes/webhooks.js +175 -65
- package/dist/apps/data/routes/webhooks.js.map +1 -1
- package/dist/apps/data/routes/zones.d.ts +281 -0
- package/dist/apps/data/routes/zones.d.ts.map +1 -0
- package/dist/apps/data/routes/zones.js +252 -0
- package/dist/apps/data/routes/zones.js.map +1 -0
- package/dist/apps/docs/reference.js +6 -5
- package/dist/apps/docs/reference.js.map +1 -1
- package/dist/apps/index.d.ts +2 -1
- package/dist/apps/index.d.ts.map +1 -1
- package/dist/apps/index.js +2 -1
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/management/App.d.ts +670 -670
- package/dist/apps/management/Billing.d.ts +8 -0
- package/dist/apps/management/Billing.d.ts.map +1 -1
- package/dist/apps/management/Billing.js +12 -0
- package/dist/apps/management/Billing.js.map +1 -1
- package/dist/apps/management/Error.d.ts +12 -0
- package/dist/apps/management/Error.d.ts.map +1 -0
- package/dist/apps/management/Error.js +10 -0
- package/dist/apps/management/Error.js.map +1 -0
- package/dist/apps/management/routes/api-keys.d.ts +5 -5
- package/dist/apps/management/routes/api-keys.d.ts.map +1 -1
- package/dist/apps/management/routes/api-keys.js +2 -8
- package/dist/apps/management/routes/api-keys.js.map +1 -1
- package/dist/apps/management/routes/billing.d.ts +119 -119
- package/dist/apps/management/routes/faucet.d.ts +35 -35
- package/dist/apps/management/routes/invitations.d.ts +62 -62
- package/dist/apps/management/routes/invitations.d.ts.map +1 -1
- package/dist/apps/management/routes/invitations.js +4 -10
- package/dist/apps/management/routes/invitations.js.map +1 -1
- package/dist/apps/management/routes/invite-links.d.ts +30 -30
- package/dist/apps/management/routes/me.d.ts +6 -6
- package/dist/apps/management/routes/members.d.ts +78 -78
- package/dist/apps/management/routes/orgs.d.ts +48 -48
- package/dist/apps/management/routes/orgs.d.ts.map +1 -1
- package/dist/apps/management/routes/orgs.js +2 -8
- package/dist/apps/management/routes/orgs.js.map +1 -1
- package/dist/apps/management/routes/projects.d.ts +9 -9
- package/dist/apps/management/routes/scopes.js +2 -2
- package/dist/apps/management/routes/scopes.js.map +1 -1
- package/dist/apps/management/routes/usage.d.ts +80 -80
- package/dist/apps/management/routes/verified-token-requests.d.ts +36 -36
- package/dist/apps/management/routes/webhooks.d.ts +50 -50
- package/dist/apps/management/routes/webhooks.d.ts.map +1 -1
- package/dist/apps/management/routes/webhooks.js +15 -3
- package/dist/apps/management/routes/webhooks.js.map +1 -1
- package/dist/apps/mpp/App.d.ts +55 -56
- package/dist/apps/mpp/App.d.ts.map +1 -1
- package/dist/apps/mpp/App.js +192 -27
- package/dist/apps/mpp/App.js.map +1 -1
- package/dist/apps/mpp/Mpp.d.ts +0 -20
- package/dist/apps/mpp/Mpp.d.ts.map +1 -1
- package/dist/apps/mpp/Mpp.js +0 -24
- package/dist/apps/mpp/Mpp.js.map +1 -1
- package/dist/apps/mpp/internal/Adapter.d.ts +40 -0
- package/dist/apps/mpp/internal/Adapter.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Adapter.js +66 -0
- package/dist/apps/mpp/internal/Adapter.js.map +1 -0
- package/dist/apps/mpp/internal/Error.d.ts +4 -0
- package/dist/apps/mpp/internal/Error.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Error.js +41 -0
- package/dist/apps/mpp/internal/Error.js.map +1 -0
- package/dist/apps/mpp/internal/Idempotency.d.ts +33 -0
- package/dist/apps/mpp/internal/Idempotency.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Idempotency.js +28 -0
- package/dist/apps/mpp/internal/Idempotency.js.map +1 -0
- package/dist/apps/mpp/internal/Policy.d.ts +46 -0
- package/dist/apps/mpp/internal/Policy.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Policy.js +57 -0
- package/dist/apps/mpp/internal/Policy.js.map +1 -0
- package/dist/apps/mpp/internal/ScreenManager.d.ts +27 -0
- package/dist/apps/mpp/internal/ScreenManager.d.ts.map +1 -0
- package/dist/apps/mpp/internal/ScreenManager.js +18 -0
- package/dist/apps/mpp/internal/ScreenManager.js.map +1 -0
- package/dist/apps/mpp/internal/Screening.d.ts +35 -0
- package/dist/apps/mpp/internal/Screening.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Screening.js +20 -0
- package/dist/apps/mpp/internal/Screening.js.map +1 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts +36 -0
- package/dist/apps/mpp/internal/Sponsorship.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Sponsorship.js +103 -0
- package/dist/apps/mpp/internal/Sponsorship.js.map +1 -0
- package/dist/apps/mpp/internal/Utils.d.ts +7 -0
- package/dist/apps/mpp/internal/Utils.d.ts.map +1 -0
- package/dist/apps/mpp/internal/Utils.js +24 -0
- package/dist/apps/mpp/internal/Utils.js.map +1 -0
- package/dist/apps/relay/App.js +184 -24
- package/dist/apps/relay/App.js.map +1 -1
- package/dist/apps/relay/Sponsorships.d.ts +4 -0
- package/dist/apps/relay/Sponsorships.d.ts.map +1 -1
- package/dist/apps/relay/Sponsorships.js +16 -7
- package/dist/apps/relay/Sponsorships.js.map +1 -1
- package/dist/db/Db.d.ts +20 -0
- package/dist/db/Db.d.ts.map +1 -1
- package/dist/db/Db.js +342 -0
- package/dist/db/Db.js.map +1 -1
- package/dist/db/Schema.d.ts +921 -1
- package/dist/db/Schema.d.ts.map +1 -1
- package/dist/db/Schema.js +269 -1
- package/dist/db/Schema.js.map +1 -1
- package/dist/db/tables/earnVaults.d.ts +68 -0
- package/dist/db/tables/earnVaults.d.ts.map +1 -0
- package/dist/db/tables/earnVaults.js +72 -0
- package/dist/db/tables/earnVaults.js.map +1 -0
- package/dist/db/tables/fundingCatalog.d.ts +56 -0
- package/dist/db/tables/fundingCatalog.d.ts.map +1 -0
- package/dist/db/tables/fundingCatalog.js +85 -0
- package/dist/db/tables/fundingCatalog.js.map +1 -0
- package/dist/db/tables/fundingDepositAddresses.d.ts +159 -0
- package/dist/db/tables/fundingDepositAddresses.d.ts.map +1 -0
- package/dist/db/tables/fundingDepositAddresses.js +206 -0
- package/dist/db/tables/fundingDepositAddresses.js.map +1 -0
- package/dist/db/tables/fundingDeposits.d.ts +115 -0
- package/dist/db/tables/fundingDeposits.d.ts.map +1 -0
- package/dist/db/tables/fundingDeposits.js +100 -0
- package/dist/db/tables/fundingDeposits.js.map +1 -0
- package/dist/db/tables/fundingIdempotency.d.ts +91 -0
- package/dist/db/tables/fundingIdempotency.d.ts.map +1 -0
- package/dist/db/tables/fundingIdempotency.js +103 -0
- package/dist/db/tables/fundingIdempotency.js.map +1 -0
- package/dist/db/tables/fundingTransferEvents.d.ts +12 -0
- package/dist/db/tables/fundingTransferEvents.d.ts.map +1 -0
- package/dist/db/tables/fundingTransferEvents.js +18 -0
- package/dist/db/tables/fundingTransferEvents.js.map +1 -0
- package/dist/db/tables/fundingTransferTransactions.d.ts +15 -0
- package/dist/db/tables/fundingTransferTransactions.d.ts.map +1 -0
- package/dist/db/tables/fundingTransferTransactions.js +27 -0
- package/dist/db/tables/fundingTransferTransactions.js.map +1 -0
- package/dist/db/tables/fundingTransfers.d.ts +82 -0
- package/dist/db/tables/fundingTransfers.d.ts.map +1 -0
- package/dist/db/tables/fundingTransfers.js +89 -0
- package/dist/db/tables/fundingTransfers.js.map +1 -0
- package/dist/db/tables/organizations.d.ts +8 -0
- package/dist/db/tables/organizations.d.ts.map +1 -1
- package/dist/db/tables/organizations.js +35 -0
- package/dist/db/tables/organizations.js.map +1 -1
- package/dist/db/tables/projects.d.ts +8 -0
- package/dist/db/tables/projects.d.ts.map +1 -1
- package/dist/db/tables/projects.js +16 -0
- package/dist/db/tables/projects.js.map +1 -1
- package/dist/db/tables/requestUsage.d.ts +13 -0
- package/dist/db/tables/requestUsage.d.ts.map +1 -1
- package/dist/db/tables/requestUsage.js +16 -0
- package/dist/db/tables/requestUsage.js.map +1 -1
- package/dist/db/tables/sponsoredTransactions.d.ts +4 -2
- package/dist/db/tables/sponsoredTransactions.d.ts.map +1 -1
- package/dist/db/tables/sponsoredTransactions.js +14 -4
- package/dist/db/tables/sponsoredTransactions.js.map +1 -1
- package/dist/db/tables/users.d.ts +8 -0
- package/dist/db/tables/users.d.ts.map +1 -1
- package/dist/db/tables/users.js +16 -0
- package/dist/db/tables/users.js.map +1 -1
- package/dist/db/tables/verifiedTokens.d.ts +14 -7
- package/dist/db/tables/verifiedTokens.d.ts.map +1 -1
- package/dist/db/tables/verifiedTokens.js +9 -7
- package/dist/db/tables/verifiedTokens.js.map +1 -1
- package/dist/db/tables/webhookSubscriptions.d.ts +31 -1
- package/dist/db/tables/webhookSubscriptions.d.ts.map +1 -1
- package/dist/db/tables/webhookSubscriptions.js +24 -3
- package/dist/db/tables/webhookSubscriptions.js.map +1 -1
- package/dist/handlers/relay.js +108 -108
- package/dist/handlers/relay.js.map +1 -1
- package/dist/internal/Auth.d.ts +26 -0
- package/dist/internal/Auth.d.ts.map +1 -1
- package/dist/internal/Auth.js +35 -2
- package/dist/internal/Auth.js.map +1 -1
- package/dist/internal/Cache.d.ts.map +1 -1
- package/dist/internal/Cache.js +16 -10
- package/dist/internal/Cache.js.map +1 -1
- package/dist/internal/Cursor.js +1 -1
- package/dist/internal/Cursor.js.map +1 -1
- package/dist/internal/EarnRates.d.ts +89 -0
- package/dist/internal/EarnRates.d.ts.map +1 -0
- package/dist/internal/EarnRates.js +266 -0
- package/dist/internal/EarnRates.js.map +1 -0
- package/dist/internal/EarnVaults.d.ts +171 -0
- package/dist/internal/EarnVaults.d.ts.map +1 -0
- package/dist/internal/EarnVaults.js +547 -0
- package/dist/internal/EarnVaults.js.map +1 -0
- package/dist/internal/EdgeCache.d.ts +9 -2
- package/dist/internal/EdgeCache.d.ts.map +1 -1
- package/dist/internal/EdgeCache.js +36 -9
- package/dist/internal/EdgeCache.js.map +1 -1
- package/dist/internal/Id.d.ts +11 -0
- package/dist/internal/Id.d.ts.map +1 -1
- package/dist/internal/Id.js +13 -0
- package/dist/internal/Id.js.map +1 -1
- package/dist/internal/Idempotency.d.ts +83 -0
- package/dist/internal/Idempotency.d.ts.map +1 -0
- package/dist/internal/Idempotency.js +113 -0
- package/dist/internal/Idempotency.js.map +1 -0
- package/dist/internal/Log.d.ts +64 -9
- package/dist/internal/Log.d.ts.map +1 -1
- package/dist/internal/Log.js +29 -7
- package/dist/internal/Log.js.map +1 -1
- package/dist/internal/MetricSink.d.ts.map +1 -1
- package/dist/internal/MetricSink.js +47 -1
- package/dist/internal/MetricSink.js.map +1 -1
- package/dist/internal/OpenApi.d.ts +1 -1
- package/dist/internal/OpenApi.d.ts.map +1 -1
- package/dist/internal/OpenApi.js +3 -0
- package/dist/internal/OpenApi.js.map +1 -1
- package/dist/internal/Provider.d.ts +14 -0
- package/dist/internal/Provider.d.ts.map +1 -0
- package/dist/internal/Provider.js +5 -0
- package/dist/internal/Provider.js.map +1 -0
- package/dist/internal/Schema.d.ts +8 -3
- package/dist/internal/Schema.d.ts.map +1 -1
- package/dist/internal/Schema.js +24 -13
- package/dist/internal/Schema.js.map +1 -1
- package/dist/internal/Store.d.ts +6 -0
- package/dist/internal/Store.d.ts.map +1 -1
- package/dist/internal/Store.js +35 -0
- package/dist/internal/Store.js.map +1 -1
- package/dist/internal/Tidx.d.ts +43 -24
- package/dist/internal/Tidx.d.ts.map +1 -1
- package/dist/internal/Tidx.js +79 -11
- package/dist/internal/Tidx.js.map +1 -1
- package/dist/internal/Viem.d.ts +82 -65
- package/dist/internal/Viem.d.ts.map +1 -1
- package/dist/internal/Viem.js +83 -12
- package/dist/internal/Viem.js.map +1 -1
- package/dist/internal/WebhookDestination.d.ts.map +1 -1
- package/dist/internal/WebhookDestination.js +34 -28
- package/dist/internal/WebhookDestination.js.map +1 -1
- package/dist/internal/Webhooks.d.ts +9 -0
- package/dist/internal/Webhooks.d.ts.map +1 -1
- package/dist/internal/Webhooks.js +15 -10
- package/dist/internal/Webhooks.js.map +1 -1
- package/dist/internal/exchange/Provider.d.ts +219 -0
- package/dist/internal/exchange/Provider.d.ts.map +1 -0
- package/dist/internal/exchange/Provider.js +117 -0
- package/dist/internal/exchange/Provider.js.map +1 -0
- package/dist/internal/exchange/index.d.ts +2 -0
- package/dist/internal/exchange/index.d.ts.map +1 -0
- package/dist/internal/exchange/index.js +2 -0
- package/dist/internal/exchange/index.js.map +1 -0
- package/dist/internal/exchange/providers/uniswap.d.ts +57 -0
- package/dist/internal/exchange/providers/uniswap.d.ts.map +1 -0
- package/dist/internal/exchange/providers/uniswap.js +553 -0
- package/dist/internal/exchange/providers/uniswap.js.map +1 -0
- package/dist/internal/funding/Action.d.ts +55 -0
- package/dist/internal/funding/Action.d.ts.map +1 -0
- package/dist/internal/funding/Action.js +74 -0
- package/dist/internal/funding/Action.js.map +1 -0
- package/dist/internal/funding/Catalog.d.ts +107 -0
- package/dist/internal/funding/Catalog.d.ts.map +1 -0
- package/dist/internal/funding/Catalog.js +270 -0
- package/dist/internal/funding/Catalog.js.map +1 -0
- package/dist/internal/funding/Chain.d.ts +76 -0
- package/dist/internal/funding/Chain.d.ts.map +1 -0
- package/dist/internal/funding/Chain.js +38 -0
- package/dist/internal/funding/Chain.js.map +1 -0
- package/dist/internal/funding/Deposit.d.ts +366 -0
- package/dist/internal/funding/Deposit.d.ts.map +1 -0
- package/dist/internal/funding/Deposit.js +286 -0
- package/dist/internal/funding/Deposit.js.map +1 -0
- package/dist/internal/funding/DepositAddress.d.ts +345 -0
- package/dist/internal/funding/DepositAddress.d.ts.map +1 -0
- package/dist/internal/funding/DepositAddress.js +189 -0
- package/dist/internal/funding/DepositAddress.js.map +1 -0
- package/dist/internal/funding/Evidence.d.ts +52 -0
- package/dist/internal/funding/Evidence.d.ts.map +1 -0
- package/dist/internal/funding/Evidence.js +314 -0
- package/dist/internal/funding/Evidence.js.map +1 -0
- package/dist/internal/funding/Provider.d.ts +1186 -0
- package/dist/internal/funding/Provider.d.ts.map +1 -0
- package/dist/internal/funding/Provider.js +1081 -0
- package/dist/internal/funding/Provider.js.map +1 -0
- package/dist/internal/funding/Reconciliation.d.ts +113 -0
- package/dist/internal/funding/Reconciliation.d.ts.map +1 -0
- package/dist/internal/funding/Reconciliation.js +676 -0
- package/dist/internal/funding/Reconciliation.js.map +1 -0
- package/dist/internal/funding/Route.d.ts +21 -0
- package/dist/internal/funding/Route.d.ts.map +1 -0
- package/dist/internal/funding/Route.js +5 -0
- package/dist/internal/funding/Route.js.map +1 -0
- package/dist/internal/funding/Subsidy.d.ts +113 -0
- package/dist/internal/funding/Subsidy.d.ts.map +1 -0
- package/dist/internal/funding/Subsidy.js +138 -0
- package/dist/internal/funding/Subsidy.js.map +1 -0
- package/dist/internal/funding/Token.d.ts +41 -0
- package/dist/internal/funding/Token.d.ts.map +1 -0
- package/dist/internal/funding/Token.js +22 -0
- package/dist/internal/funding/Token.js.map +1 -0
- package/dist/internal/funding/Transfer.d.ts +643 -0
- package/dist/internal/funding/Transfer.d.ts.map +1 -0
- package/dist/internal/funding/Transfer.js +332 -0
- package/dist/internal/funding/Transfer.js.map +1 -0
- package/dist/internal/funding/index.d.ts +13 -0
- package/dist/internal/funding/index.d.ts.map +1 -0
- package/dist/internal/funding/index.js +13 -0
- package/dist/internal/funding/index.js.map +1 -0
- package/dist/internal/funding/providers/across.d.ts +21 -0
- package/dist/internal/funding/providers/across.d.ts.map +1 -0
- package/dist/internal/funding/providers/across.js +117 -0
- package/dist/internal/funding/providers/across.js.map +1 -0
- package/dist/internal/funding/providers/relay.d.ts +46 -0
- package/dist/internal/funding/providers/relay.d.ts.map +1 -0
- package/dist/internal/funding/providers/relay.js +464 -0
- package/dist/internal/funding/providers/relay.js.map +1 -0
- package/dist/internal/funding/providers/rhino.d.ts +15 -0
- package/dist/internal/funding/providers/rhino.d.ts.map +1 -0
- package/dist/internal/funding/providers/rhino.js +116 -0
- package/dist/internal/funding/providers/rhino.js.map +1 -0
- package/dist/internal/funding/providers/squid.d.ts +19 -0
- package/dist/internal/funding/providers/squid.d.ts.map +1 -0
- package/dist/internal/funding/providers/squid.js +120 -0
- package/dist/internal/funding/providers/squid.js.map +1 -0
- package/dist/internal/funding/providers/symbiosis.d.ts +20 -0
- package/dist/internal/funding/providers/symbiosis.d.ts.map +1 -0
- package/dist/internal/funding/providers/symbiosis.js +176 -0
- package/dist/internal/funding/providers/symbiosis.js.map +1 -0
- package/dist/internal/index.d.ts +5 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +5 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/webhookDestinations/url.js +61 -57
- package/dist/internal/webhookDestinations/url.js.map +1 -1
- package/dist/providers/index.d.ts +43 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +19 -0
- package/dist/providers/index.js.map +1 -0
- package/package.json +9 -4
- package/src/ApiKeys.test.ts +11 -7
- package/src/ApiKeys.ts +37 -9
- package/src/App.test.ts +85 -10
- package/src/App.ts +224 -137
- package/src/Assets.ts +29 -4
- package/src/Client.test-d.ts +650 -30
- package/src/Scope.test.ts +19 -0
- package/src/Scope.ts +28 -11
- package/src/Webhooks.test.ts +25 -0
- package/src/Webhooks.ts +1 -1
- package/src/admin/App.test.ts +9 -2
- package/src/admin/App.ts +32 -9
- package/src/admin/apps/api-keys.test.ts +167 -23
- package/src/admin/apps/api-keys.ts +166 -28
- package/src/admin/apps/earn-vaults.test.ts +338 -0
- package/src/admin/apps/earn-vaults.ts +572 -0
- package/src/admin/apps/scopes.test.ts +16 -1
- package/src/admin/ui/plugin.ts +2 -2
- package/src/admin/ui/src/components/EarnVaultForm.tsx +137 -0
- package/src/admin/ui/src/components/MobileProfile.tsx +2 -2
- package/src/admin/ui/src/components/Page.tsx +1 -1
- package/src/admin/ui/src/components/ThemeToggle.tsx +1 -1
- package/src/admin/ui/src/lib/api-keys.ts +37 -7
- package/src/admin/ui/src/lib/client.ts +1 -1
- package/src/admin/ui/src/lib/config.ts +1 -1
- package/src/admin/ui/src/lib/early-access.ts +8 -9
- package/src/admin/ui/src/lib/earn-vaults.ts +207 -0
- package/src/admin/ui/src/lib/format.ts +13 -0
- package/src/admin/ui/src/lib/organizations.test.ts +14 -4
- package/src/admin/ui/src/lib/organizations.ts +7 -1
- package/src/admin/ui/src/lib/response.ts +22 -0
- package/src/admin/ui/src/lib/scopes.test.ts +19 -11
- package/src/admin/ui/src/lib/scopes.ts +28 -7
- package/src/admin/ui/src/lib/verified-tokens.ts +10 -9
- package/src/admin/ui/src/routeTree.gen.ts +70 -7
- package/src/admin/ui/src/router.tsx +2 -2
- package/src/admin/ui/src/routes/__root.tsx +9 -8
- package/src/admin/ui/src/routes/api-keys.tsx +475 -64
- package/src/admin/ui/src/routes/early-access.tsx +5 -12
- package/src/admin/ui/src/routes/earn.vaults.tsx +348 -0
- package/src/admin/ui/src/routes/earn.vaults_.$vaultId.edit.tsx +154 -0
- package/src/admin/ui/src/routes/earn.vaults_.new.tsx +190 -0
- package/src/admin/ui/src/routes/organizations.tsx +4 -7
- package/src/admin/ui/src/routes/organizations_.$orgId.tsx +56 -54
- package/src/admin/ui/src/routes/verified-tokens.tsx +4 -4
- package/src/admin/ui/vite.config.ts +4 -1
- package/src/admin/ui.generated.ts +189 -95
- package/src/analytics/Analytics.test.ts +69 -10
- package/src/analytics/Analytics.ts +20 -1
- package/src/analytics/tables/requestEvents.ts +79 -37
- package/src/apps/Zones.test.ts +33 -0
- package/src/apps/Zones.ts +40 -0
- package/src/apps/composition.test.ts +84 -1
- package/src/apps/data/App.test.ts +38 -9
- package/src/apps/data/App.ts +96 -33
- package/src/apps/data/FxOracle.ts +1 -1
- package/src/apps/data/index.ts +0 -1
- package/src/apps/data/routes/activities.test.ts +82 -6
- package/src/apps/data/routes/activities.ts +131 -71
- package/src/apps/data/routes/balances.test.ts +50 -37
- package/src/apps/data/routes/balances.ts +5 -5
- package/src/apps/data/routes/blocks.test.ts +2 -0
- package/src/apps/data/routes/coingecko.test.ts +22 -0
- package/src/apps/data/routes/coingecko.ts +84 -48
- package/src/apps/data/routes/earn.test.ts +1108 -0
- package/src/apps/data/routes/earn.ts +1391 -0
- package/src/apps/data/routes/exchanges.test.ts +82 -33
- package/src/apps/data/routes/exchanges.ts +842 -227
- package/src/apps/data/routes/fee-amm.test.ts +4 -6
- package/src/apps/data/routes/fee-amm.ts +69 -12
- package/src/apps/data/routes/funding.test.ts +2712 -221
- package/src/apps/data/routes/funding.ts +1604 -387
- package/src/apps/data/routes/indexer.test.ts +43 -34
- package/src/apps/data/routes/indexer.ts +19 -2
- package/src/apps/data/routes/receipts.test.ts +5 -3
- package/src/apps/data/routes/receipts.ts +13 -11
- package/src/apps/data/routes/rpc.test.ts +446 -28
- package/src/apps/data/routes/rpc.ts +243 -25
- package/src/apps/data/routes/tokenlist.test.ts +15 -0
- package/src/apps/data/routes/tokenlist.ts +88 -22
- package/src/apps/data/routes/tokens.ts +262 -86
- package/src/apps/data/routes/transactions.test.ts +2 -0
- package/src/apps/data/routes/transactions.ts +77 -42
- package/src/apps/data/routes/transfers.test.ts +166 -4
- package/src/apps/data/routes/transfers.ts +216 -78
- package/src/apps/data/routes/valuation.test.ts +62 -9
- package/src/apps/data/routes/valuation.ts +2 -2
- package/src/apps/data/routes/verified-tokens.test.ts +51 -0
- package/src/apps/data/routes/verified-tokens.ts +52 -15
- package/src/apps/data/routes/webhooks.test.ts +432 -33
- package/src/apps/data/routes/webhooks.ts +189 -79
- package/src/apps/data/routes/zones.test.ts +473 -0
- package/src/apps/data/routes/zones.ts +338 -0
- package/src/apps/docs/reference.ts +8 -6
- package/src/apps/index.ts +2 -1
- package/src/apps/management/Billing.test.ts +29 -0
- package/src/apps/management/Billing.ts +23 -0
- package/src/apps/management/Error.ts +12 -0
- package/src/apps/management/routes/api-keys.test.ts +5 -3
- package/src/apps/management/routes/api-keys.ts +2 -9
- package/src/apps/management/routes/invitations.ts +4 -11
- package/src/apps/management/routes/orgs.ts +2 -9
- package/src/apps/management/routes/scopes.test.ts +7 -2
- package/src/apps/management/routes/scopes.ts +2 -2
- package/src/apps/management/routes/webhooks.test.ts +6 -1
- package/src/apps/management/routes/webhooks.ts +15 -3
- package/src/apps/mpp/App.ts +276 -29
- package/src/apps/mpp/Mpp.test.ts +631 -26
- package/src/apps/mpp/Mpp.ts +0 -42
- package/src/apps/mpp/internal/Adapter.ts +108 -3
- package/src/apps/mpp/internal/Error.test.ts +33 -0
- package/src/apps/mpp/internal/Error.ts +44 -6
- package/src/apps/mpp/internal/Idempotency.test.ts +213 -0
- package/src/apps/mpp/internal/Idempotency.ts +59 -5
- package/src/apps/mpp/internal/Policy.test.ts +122 -0
- package/src/apps/mpp/internal/Policy.ts +98 -0
- package/src/apps/mpp/internal/ScreenManager.test.ts +68 -0
- package/src/apps/mpp/internal/ScreenManager.ts +41 -0
- package/src/apps/mpp/internal/Screening.ts +40 -3
- package/src/apps/mpp/internal/Sponsorship.ts +144 -0
- package/src/apps/mpp/internal/Utils.ts +30 -0
- package/src/apps/relay/App.test.ts +495 -64
- package/src/apps/relay/App.ts +234 -24
- package/src/apps/relay/Sponsorships.test.ts +51 -0
- package/src/apps/relay/Sponsorships.ts +19 -7
- package/src/db/Db.ts +439 -0
- package/src/db/Schema.ts +325 -2
- package/src/db/tables/earnVaults.test.ts +185 -0
- package/src/db/tables/earnVaults.ts +151 -0
- package/src/db/tables/fundingCatalog.test.ts +108 -0
- package/src/db/tables/fundingCatalog.ts +157 -0
- package/src/db/tables/fundingDepositAddresses.test.ts +580 -0
- package/src/db/tables/fundingDepositAddresses.ts +376 -0
- package/src/db/tables/fundingDeposits.test.ts +261 -0
- package/src/db/tables/fundingDeposits.ts +229 -0
- package/src/db/tables/fundingIdempotency.test.ts +182 -0
- package/src/db/tables/fundingIdempotency.ts +180 -0
- package/src/db/tables/fundingTransferEvents.ts +28 -0
- package/src/db/tables/fundingTransferTransactions.test.ts +69 -0
- package/src/db/tables/fundingTransferTransactions.ts +37 -0
- package/src/db/tables/fundingTransfers.test.ts +89 -0
- package/src/db/tables/fundingTransfers.ts +153 -0
- package/src/db/tables/organizations.test.ts +88 -0
- package/src/db/tables/organizations.ts +42 -1
- package/src/db/tables/projects.ts +16 -0
- package/src/db/tables/requestUsage.ts +23 -0
- package/src/db/tables/sponsoredTransactions.test.ts +52 -2
- package/src/db/tables/sponsoredTransactions.ts +18 -6
- package/src/db/tables/users.ts +16 -0
- package/src/db/tables/verifiedTokens.ts +19 -14
- package/src/db/tables/webhookSubscriptions.ts +58 -3
- package/src/handlers/relay.test.ts +2 -0
- package/src/handlers/relay.ts +95 -99
- package/src/internal/Auth.test.ts +48 -0
- package/src/internal/Auth.ts +61 -2
- package/src/internal/Cache.ts +13 -9
- package/src/internal/Cursor.test.ts +2 -2
- package/src/internal/Cursor.ts +1 -1
- package/src/internal/EarnRates.test.ts +125 -0
- package/src/internal/EarnRates.ts +409 -0
- package/src/internal/EarnVaults.test.ts +195 -0
- package/src/internal/EarnVaults.ts +876 -0
- package/src/internal/EdgeCache.test.ts +37 -5
- package/src/internal/EdgeCache.ts +39 -7
- package/src/internal/Id.ts +14 -0
- package/src/internal/Idempotency.test.ts +109 -0
- package/src/internal/Idempotency.ts +237 -0
- package/src/internal/Log.test-d.ts +41 -8
- package/src/internal/Log.test.ts +189 -8
- package/src/internal/Log.ts +124 -17
- package/src/internal/MetricSink.test.ts +244 -4
- package/src/internal/MetricSink.ts +51 -1
- package/src/internal/OpenApi.ts +3 -0
- package/src/internal/Provider.test.ts +17 -0
- package/src/internal/Provider.ts +17 -0
- package/src/internal/Schema.test.ts +13 -0
- package/src/internal/Schema.ts +41 -24
- package/src/internal/Store.test.ts +25 -0
- package/src/internal/Store.ts +46 -0
- package/src/internal/Tidx.local.test.ts +78 -3
- package/src/internal/Tidx.test.ts +212 -18
- package/src/internal/Tidx.ts +112 -32
- package/src/internal/VerifiedTokens.test.ts +15 -0
- package/src/internal/Viem.test.ts +170 -17
- package/src/internal/Viem.ts +111 -28
- package/src/internal/WebhookDestination.ts +25 -23
- package/src/internal/Webhooks.test.ts +59 -0
- package/src/internal/Webhooks.ts +34 -10
- package/src/internal/exchange/Provider.test.ts +216 -0
- package/src/internal/exchange/Provider.ts +326 -0
- package/src/internal/exchange/index.test.ts +6 -0
- package/src/internal/exchange/index.ts +1 -0
- package/src/internal/exchange/providers/uniswap.test.ts +122 -0
- package/src/internal/exchange/providers/uniswap.ts +682 -0
- package/src/internal/funding/Action.test.ts +138 -0
- package/src/internal/funding/Action.ts +117 -0
- package/src/internal/funding/Catalog.test.ts +311 -0
- package/src/internal/funding/Catalog.ts +347 -0
- package/src/internal/funding/Chain.test.ts +79 -0
- package/src/internal/funding/Chain.ts +120 -0
- package/src/internal/funding/Deposit.test.ts +26 -0
- package/src/internal/funding/Deposit.ts +453 -0
- package/src/internal/funding/DepositAddress.test.ts +18 -0
- package/src/internal/funding/DepositAddress.ts +312 -0
- package/src/internal/funding/Evidence.test.ts +297 -0
- package/src/internal/funding/Evidence.ts +430 -0
- package/src/internal/funding/Provider.test.ts +1328 -0
- package/src/internal/funding/Provider.ts +1796 -0
- package/src/internal/funding/Reconciliation.local.test.ts +504 -0
- package/src/internal/funding/Reconciliation.test.ts +2020 -0
- package/src/internal/funding/Reconciliation.ts +930 -0
- package/src/internal/funding/Route.test.ts +66 -0
- package/src/internal/funding/Route.ts +29 -0
- package/src/internal/funding/Subsidy.local.test.ts +152 -0
- package/src/internal/funding/Subsidy.test.ts +75 -0
- package/src/internal/funding/Subsidy.ts +260 -0
- package/src/internal/funding/Token.test.ts +47 -0
- package/src/internal/funding/Token.ts +59 -0
- package/src/internal/funding/Transfer.test.ts +369 -0
- package/src/internal/funding/Transfer.ts +522 -0
- package/src/internal/funding/index.test.ts +20 -0
- package/src/internal/funding/index.ts +12 -0
- package/src/internal/funding/providers/across.ts +149 -0
- package/src/{apps/data/FundingQuoteProviders.test.ts → internal/funding/providers/index.test.ts} +178 -157
- package/src/internal/funding/providers/relay.test.ts +474 -0
- package/src/internal/funding/providers/relay.ts +559 -0
- package/src/internal/funding/providers/rhino.ts +139 -0
- package/src/internal/funding/providers/squid.ts +151 -0
- package/src/internal/funding/providers/symbiosis.ts +221 -0
- package/src/internal/index.test.ts +5 -1
- package/src/internal/index.ts +5 -1
- package/src/internal/webhookDestinations/url.ts +49 -45
- package/src/providers/index.test.ts +14 -0
- package/src/providers/index.ts +54 -0
- package/dist/apps/data/FundingQuoteProviders.d.ts +0 -174
- package/dist/apps/data/FundingQuoteProviders.d.ts.map +0 -1
- package/dist/apps/data/FundingQuoteProviders.js +0 -775
- package/dist/apps/data/FundingQuoteProviders.js.map +0 -1
- package/dist/internal/FundingQuotes.d.ts +0 -864
- package/dist/internal/FundingQuotes.d.ts.map +0 -1
- package/dist/internal/FundingQuotes.js +0 -672
- package/dist/internal/FundingQuotes.js.map +0 -1
- package/src/apps/data/FundingQuoteProviders.ts +0 -1043
- package/src/internal/FundingQuotes.test.ts +0 -456
- package/src/internal/FundingQuotes.ts +0 -944
|
@@ -0,0 +1,676 @@
|
|
|
1
|
+
import { Hex } from 'ox';
|
|
2
|
+
import * as Db from '../../db/Db.js';
|
|
3
|
+
import * as FundingDepositAddresses from '../../db/tables/fundingDepositAddresses.js';
|
|
4
|
+
import * as FundingDeposits from '../../db/tables/fundingDeposits.js';
|
|
5
|
+
import * as Value from '../Value.js';
|
|
6
|
+
import * as Deposit from './Deposit.js';
|
|
7
|
+
import * as Provider from './Provider.js';
|
|
8
|
+
import * as Subsidy from './Subsidy.js';
|
|
9
|
+
const defaultBatchSize = 25;
|
|
10
|
+
const defaultLeaseMs = 2 * 60_000;
|
|
11
|
+
const defaultPollIntervalMs = 60_000;
|
|
12
|
+
const maximumPages = 100;
|
|
13
|
+
/** Creates a reusable-address reconciliation tracker. */
|
|
14
|
+
export function createTracker(options) {
|
|
15
|
+
const now = options.now ?? (() => new Date());
|
|
16
|
+
const batchSize = options.batchSize ?? defaultBatchSize;
|
|
17
|
+
const leaseMs = options.leaseMs ?? defaultLeaseMs;
|
|
18
|
+
const pollIntervalMs = options.pollIntervalMs ?? defaultPollIntervalMs;
|
|
19
|
+
const record = (outcome, providerId) => {
|
|
20
|
+
options.metrics?.count('funding_deposit_reconciliation_count', 1, {
|
|
21
|
+
outcome,
|
|
22
|
+
provider: providerId,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
async reconcile(message) {
|
|
27
|
+
const database = Db.get(options.db);
|
|
28
|
+
const startedAt = now();
|
|
29
|
+
const claimed = await claim(database, message, {
|
|
30
|
+
leaseUntil: new Date(startedAt.getTime() + leaseMs).toISOString(),
|
|
31
|
+
now: startedAt.toISOString(),
|
|
32
|
+
});
|
|
33
|
+
if (!claimed)
|
|
34
|
+
return { type: 'busy' };
|
|
35
|
+
const provider = options.providers.find((candidate) => candidate.id === claimed.providerId);
|
|
36
|
+
if (!provider || !Provider.canListDepositAddressRequests(provider)) {
|
|
37
|
+
await fail(database, claimed, startedAt, pollIntervalMs);
|
|
38
|
+
record('provider_unavailable', claimed.providerId);
|
|
39
|
+
return { type: 'provider_unavailable' };
|
|
40
|
+
}
|
|
41
|
+
const heartbeat = maintainLease(database, claimed, { leaseMs, now });
|
|
42
|
+
try {
|
|
43
|
+
await heartbeat.ready();
|
|
44
|
+
const requests = await listRequests(provider, {
|
|
45
|
+
address: claimed,
|
|
46
|
+
requestId: message.requestId,
|
|
47
|
+
signal: options.signal,
|
|
48
|
+
});
|
|
49
|
+
heartbeat.assert();
|
|
50
|
+
let created = 0;
|
|
51
|
+
let updated = 0;
|
|
52
|
+
const pendingRequestIds = new Set(requests.pendingRequestIds);
|
|
53
|
+
for (const request of requests.requests) {
|
|
54
|
+
const result = await reconcileRequest(database, {
|
|
55
|
+
address: claimed,
|
|
56
|
+
metrics: options.metrics,
|
|
57
|
+
request,
|
|
58
|
+
subsidies: options.subsidies,
|
|
59
|
+
verifyTransfers: options.verifyTransfers,
|
|
60
|
+
});
|
|
61
|
+
heartbeat.assert();
|
|
62
|
+
created += result.created;
|
|
63
|
+
updated += result.updated;
|
|
64
|
+
if (result.terminal)
|
|
65
|
+
pendingRequestIds.delete(request.id);
|
|
66
|
+
else
|
|
67
|
+
pendingRequestIds.add(request.id);
|
|
68
|
+
}
|
|
69
|
+
const leaseFailure = await heartbeat.stop();
|
|
70
|
+
if (leaseFailure !== undefined)
|
|
71
|
+
throw leaseFailure;
|
|
72
|
+
const completedAt = now();
|
|
73
|
+
const stored = await FundingDepositAddresses.completePoll(database, {
|
|
74
|
+
id: claimed.id,
|
|
75
|
+
lastPolledAt: completedAt.toISOString(),
|
|
76
|
+
nextPollAt: new Date(completedAt.getTime() + pollIntervalMs).toISOString(),
|
|
77
|
+
pollLeaseVersion: claimed.pollLeaseVersion,
|
|
78
|
+
providerRequestIds: claimed.providerRequestIds,
|
|
79
|
+
providerState: reconciliationState(claimed.providerState, requests, [
|
|
80
|
+
...pendingRequestIds,
|
|
81
|
+
]),
|
|
82
|
+
});
|
|
83
|
+
if (!stored)
|
|
84
|
+
return { type: 'stale' };
|
|
85
|
+
record('completed', claimed.providerId);
|
|
86
|
+
options.metrics?.histogram('funding_deposit_reconciliation_duration_ms', completedAt.getTime() - startedAt.getTime(), { provider: claimed.providerId });
|
|
87
|
+
return { created, type: 'completed', updated };
|
|
88
|
+
}
|
|
89
|
+
catch (cause) {
|
|
90
|
+
const leaseFailure = await heartbeat.stop();
|
|
91
|
+
await fail(database, claimed, now(), pollIntervalMs);
|
|
92
|
+
record('failed', claimed.providerId);
|
|
93
|
+
throw leaseFailure ?? cause;
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
options.metrics?.flush();
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
async tick() {
|
|
100
|
+
const database = Db.get(options.db);
|
|
101
|
+
const startedAt = now();
|
|
102
|
+
const leaseUntil = new Date(startedAt.getTime() + leaseMs).toISOString();
|
|
103
|
+
let claimed = 0;
|
|
104
|
+
let failed = 0;
|
|
105
|
+
for (const provider of options.providers) {
|
|
106
|
+
if (!Provider.canListDepositAddressRequests(provider))
|
|
107
|
+
continue;
|
|
108
|
+
const records = await FundingDepositAddresses.claimDue(database, {
|
|
109
|
+
leaseUntil,
|
|
110
|
+
limit: Math.max(0, batchSize - claimed),
|
|
111
|
+
now: startedAt.toISOString(),
|
|
112
|
+
providerId: provider.id,
|
|
113
|
+
});
|
|
114
|
+
for (const address of records) {
|
|
115
|
+
claimed += 1;
|
|
116
|
+
options.metrics?.histogram('funding_deposit_poll_lag_ms', Math.max(0, startedAt.getTime() - new Date(address.nextPollAt).getTime()), { provider: provider.id });
|
|
117
|
+
try {
|
|
118
|
+
await options.dispatch({
|
|
119
|
+
addressId: address.id,
|
|
120
|
+
pollLeaseVersion: address.pollLeaseVersion,
|
|
121
|
+
type: 'funding:deposit-address:reconcile',
|
|
122
|
+
});
|
|
123
|
+
record('enqueued', provider.id);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
failed += 1;
|
|
127
|
+
await fail(database, address, startedAt, pollIntervalMs);
|
|
128
|
+
record('enqueue_failed', provider.id);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (claimed >= batchSize)
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
options.metrics?.flush();
|
|
135
|
+
return { claimed, failed };
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
async function claim(db, message, options) {
|
|
140
|
+
if (message.pollLeaseVersion === undefined)
|
|
141
|
+
return FundingDepositAddresses.claim(db, {
|
|
142
|
+
id: message.addressId,
|
|
143
|
+
leaseUntil: options.leaseUntil,
|
|
144
|
+
now: options.now,
|
|
145
|
+
});
|
|
146
|
+
const current = await FundingDepositAddresses.get(db, message.addressId);
|
|
147
|
+
if (!current?.pollLeaseUntil ||
|
|
148
|
+
current.pollLeaseUntil <= options.now ||
|
|
149
|
+
current.pollLeaseVersion !== message.pollLeaseVersion)
|
|
150
|
+
return undefined;
|
|
151
|
+
return current;
|
|
152
|
+
}
|
|
153
|
+
async function fail(db, address, now, pollIntervalMs) {
|
|
154
|
+
const delay = Math.min(pollIntervalMs * 2 ** address.pollFailureCount, 15 * 60_000);
|
|
155
|
+
return FundingDepositAddresses.failPoll(db, {
|
|
156
|
+
id: address.id,
|
|
157
|
+
nextPollAt: new Date(now.getTime() + delay).toISOString(),
|
|
158
|
+
pollLeaseVersion: address.pollLeaseVersion,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function maintainLease(db, address, options) {
|
|
162
|
+
let failure;
|
|
163
|
+
let stopped = false;
|
|
164
|
+
const extend = async () => {
|
|
165
|
+
if (stopped || failure !== undefined)
|
|
166
|
+
return;
|
|
167
|
+
const renewed = await FundingDepositAddresses.renewPoll(db, {
|
|
168
|
+
id: address.id,
|
|
169
|
+
leaseUntil: new Date(options.now().getTime() + options.leaseMs).toISOString(),
|
|
170
|
+
pollLeaseVersion: address.pollLeaseVersion,
|
|
171
|
+
});
|
|
172
|
+
if (!renewed)
|
|
173
|
+
failure = new StaleLeaseError();
|
|
174
|
+
};
|
|
175
|
+
const captureFailure = (cause) => {
|
|
176
|
+
failure = cause;
|
|
177
|
+
};
|
|
178
|
+
let renewal = extend().catch(captureFailure);
|
|
179
|
+
const timer = setInterval(() => {
|
|
180
|
+
renewal = renewal.then(extend).catch(captureFailure);
|
|
181
|
+
}, Math.max(1, Math.floor(options.leaseMs / 2)));
|
|
182
|
+
return {
|
|
183
|
+
assert() {
|
|
184
|
+
if (failure !== undefined)
|
|
185
|
+
throw failure;
|
|
186
|
+
},
|
|
187
|
+
async ready() {
|
|
188
|
+
await renewal;
|
|
189
|
+
if (failure !== undefined)
|
|
190
|
+
throw failure;
|
|
191
|
+
},
|
|
192
|
+
async stop() {
|
|
193
|
+
if (!stopped) {
|
|
194
|
+
stopped = true;
|
|
195
|
+
clearInterval(timer);
|
|
196
|
+
}
|
|
197
|
+
await renewal;
|
|
198
|
+
return failure;
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
async function listRequests(provider, options) {
|
|
203
|
+
const highWater = readHighWater(options.address.providerState);
|
|
204
|
+
const highWaterRequestIds = new Set(highWater.requestIds);
|
|
205
|
+
const pendingRequestIds = new Set(highWater.pendingRequestIds);
|
|
206
|
+
const requests = [];
|
|
207
|
+
let continuation;
|
|
208
|
+
for (let page = 0; page < maximumPages; page++) {
|
|
209
|
+
const result = await provider.listDepositAddressRequests({ address: options.address.address, ...(continuation ? { continuation } : {}) }, options.signal ?? new AbortController().signal);
|
|
210
|
+
requests.push(...result.requests.filter((request) => !highWater.updatedAt ||
|
|
211
|
+
request.updatedAt > highWater.updatedAt ||
|
|
212
|
+
(request.updatedAt === highWater.updatedAt &&
|
|
213
|
+
(!highWaterRequestIds.has(request.id) || pendingRequestIds.has(request.id)))));
|
|
214
|
+
const reached = result.requests.some((request) => highWater.updatedAt && request.updatedAt < highWater.updatedAt);
|
|
215
|
+
continuation = result.continuation;
|
|
216
|
+
if (!continuation || reached)
|
|
217
|
+
break;
|
|
218
|
+
if (page === maximumPages - 1)
|
|
219
|
+
throw new PaginationLimitError();
|
|
220
|
+
}
|
|
221
|
+
const observed = new Set(requests.map((request) => request.id));
|
|
222
|
+
for (const requestId of unique([
|
|
223
|
+
...highWater.pendingRequestIds,
|
|
224
|
+
...(options.requestId ? [options.requestId] : []),
|
|
225
|
+
])) {
|
|
226
|
+
if (observed.has(requestId))
|
|
227
|
+
continue;
|
|
228
|
+
const result = await provider.listDepositAddressRequests({ address: options.address.address, requestId }, options.signal ?? new AbortController().signal);
|
|
229
|
+
requests.push(...result.requests);
|
|
230
|
+
}
|
|
231
|
+
const addressRequests = requests.filter((request) => !highWater.pendingRequestIds.includes(request.id));
|
|
232
|
+
const newest = addressRequests.reduce((value, request) => (!value || request.updatedAt > value ? request.updatedAt : value), highWater.updatedAt);
|
|
233
|
+
return {
|
|
234
|
+
highWaterRequestIds: newest
|
|
235
|
+
? unique([
|
|
236
|
+
...(newest === highWater.updatedAt ? highWater.requestIds : []),
|
|
237
|
+
...addressRequests
|
|
238
|
+
.filter((request) => request.updatedAt === newest)
|
|
239
|
+
.map((request) => request.id),
|
|
240
|
+
])
|
|
241
|
+
: [],
|
|
242
|
+
highWaterUpdatedAt: newest,
|
|
243
|
+
pendingRequestIds: highWater.pendingRequestIds,
|
|
244
|
+
requests,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function readHighWater(state) {
|
|
248
|
+
if (!state || typeof state !== 'object')
|
|
249
|
+
return { pendingRequestIds: [], requestIds: [] };
|
|
250
|
+
const reconciliation = state['reconciliation'];
|
|
251
|
+
if (!reconciliation || typeof reconciliation !== 'object')
|
|
252
|
+
return { pendingRequestIds: [], requestIds: [] };
|
|
253
|
+
const pendingRequestIds = 'pendingRequestIds' in reconciliation && Array.isArray(reconciliation.pendingRequestIds)
|
|
254
|
+
? reconciliation.pendingRequestIds.filter((value) => typeof value === 'string')
|
|
255
|
+
: [];
|
|
256
|
+
const requestIds = 'requestIds' in reconciliation && Array.isArray(reconciliation.requestIds)
|
|
257
|
+
? reconciliation.requestIds.filter((value) => typeof value === 'string')
|
|
258
|
+
: [];
|
|
259
|
+
return {
|
|
260
|
+
pendingRequestIds,
|
|
261
|
+
requestIds,
|
|
262
|
+
...('updatedAt' in reconciliation && typeof reconciliation.updatedAt === 'string'
|
|
263
|
+
? { updatedAt: reconciliation.updatedAt }
|
|
264
|
+
: {}),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function reconciliationState(state, requests, pendingRequestIds) {
|
|
268
|
+
const current = state && typeof state === 'object' ? state : {};
|
|
269
|
+
return {
|
|
270
|
+
...current,
|
|
271
|
+
reconciliation: {
|
|
272
|
+
pendingRequestIds,
|
|
273
|
+
requestIds: requests.highWaterRequestIds,
|
|
274
|
+
...(requests.highWaterUpdatedAt ? { updatedAt: requests.highWaterUpdatedAt } : {}),
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/** Reconciles one provider request against verified chain evidence. */
|
|
279
|
+
export async function reconcileRequest(db, options) {
|
|
280
|
+
let created = 0;
|
|
281
|
+
const observed = [];
|
|
282
|
+
// Persist provider observations first so transient chain failures do not hide acknowledged deposits.
|
|
283
|
+
for (const transactionHash of unique(options.request.sourceTransactionHashes)) {
|
|
284
|
+
let deposits = await FundingDeposits.listByProviderObservation(db, {
|
|
285
|
+
depositAddressId: options.address.id,
|
|
286
|
+
providerRequestId: options.request.id,
|
|
287
|
+
sourceTransactionHash: transactionHash,
|
|
288
|
+
});
|
|
289
|
+
if (deposits.length === 0)
|
|
290
|
+
deposits = await FundingDeposits.listBySourceTransaction(db, {
|
|
291
|
+
depositAddressId: options.address.id,
|
|
292
|
+
sourceTransactionHash: transactionHash,
|
|
293
|
+
});
|
|
294
|
+
if (deposits.length === 0) {
|
|
295
|
+
deposits = [
|
|
296
|
+
await Deposit.create(db, {
|
|
297
|
+
now: new Date(options.request.createdAt),
|
|
298
|
+
providerRequestId: options.request.id,
|
|
299
|
+
snapshot: {
|
|
300
|
+
depositAddressId: options.address.id,
|
|
301
|
+
destinationChain: options.address.snapshot.destinationChain,
|
|
302
|
+
destinationToken: options.address.snapshot.destinationToken,
|
|
303
|
+
provider: options.address.snapshot.provider,
|
|
304
|
+
recipient: options.address.recipient,
|
|
305
|
+
refundAddress: options.address.refundAddress,
|
|
306
|
+
sourceChain: options.address.snapshot.sourceChain,
|
|
307
|
+
sourceToken: options.address.snapshot.sourceToken,
|
|
308
|
+
sourceTransactionHashes: [transactionHash],
|
|
309
|
+
},
|
|
310
|
+
sourceTransactionHash: transactionHash,
|
|
311
|
+
}),
|
|
312
|
+
];
|
|
313
|
+
created += 1;
|
|
314
|
+
}
|
|
315
|
+
observed.push({ deposits, transactionHash, transfers: [] });
|
|
316
|
+
}
|
|
317
|
+
const sources = await Promise.all(observed.map(async (source) => ({
|
|
318
|
+
...source,
|
|
319
|
+
transfers: await options.verifyTransfers({
|
|
320
|
+
chain: options.address.snapshot.sourceChain,
|
|
321
|
+
recipient: options.address.address,
|
|
322
|
+
token: options.address.snapshot.sourceToken,
|
|
323
|
+
transactionHash: source.transactionHash,
|
|
324
|
+
}),
|
|
325
|
+
})));
|
|
326
|
+
const sourceEvidenceComplete = sources.length > 0 && sources.every((source) => source.transfers.length > 0);
|
|
327
|
+
let terminal = sourceEvidenceComplete;
|
|
328
|
+
const updatedIds = new Set();
|
|
329
|
+
const verified = [];
|
|
330
|
+
for (const source of sources) {
|
|
331
|
+
const transfers = [...source.transfers].sort((left, right) => left.transferIndex - right.transferIndex);
|
|
332
|
+
for (const [providerTransferIndex, transfer] of transfers.entries()) {
|
|
333
|
+
const required = destinationBaseUnits(BigInt(transfer.amount), options.address.snapshot.sourceToken.decimals, options.address.snapshot.destinationToken.decimals);
|
|
334
|
+
const sourceAmount = Value.tokenAmount({
|
|
335
|
+
baseUnits: transfer.amount,
|
|
336
|
+
currency: options.address.snapshot.sourceToken.currency,
|
|
337
|
+
decimals: options.address.snapshot.sourceToken.decimals,
|
|
338
|
+
});
|
|
339
|
+
const destinationAmountRequired = Value.tokenAmount({
|
|
340
|
+
baseUnits: required,
|
|
341
|
+
currency: options.address.snapshot.destinationToken.currency,
|
|
342
|
+
decimals: options.address.snapshot.destinationToken.decimals,
|
|
343
|
+
});
|
|
344
|
+
// Bind the placeholder to transfers in deterministic log order when one transaction contains several deposits.
|
|
345
|
+
let deposit = source.deposits.find((record) => record.providerRequestId === null
|
|
346
|
+
? record.sourceTransferIndex === transfer.transferIndex
|
|
347
|
+
: record.providerTransferIndex === providerTransferIndex);
|
|
348
|
+
if (!deposit) {
|
|
349
|
+
deposit = await Deposit.create(db, {
|
|
350
|
+
now: new Date(options.request.createdAt),
|
|
351
|
+
providerRequestId: options.request.id,
|
|
352
|
+
providerTransferIndex,
|
|
353
|
+
snapshot: {
|
|
354
|
+
depositAddressId: options.address.id,
|
|
355
|
+
...(options.address.snapshot.subsidize ? { destinationAmountRequired } : {}),
|
|
356
|
+
destinationChain: options.address.snapshot.destinationChain,
|
|
357
|
+
destinationToken: options.address.snapshot.destinationToken,
|
|
358
|
+
provider: options.address.snapshot.provider,
|
|
359
|
+
recipient: options.address.recipient,
|
|
360
|
+
refundAddress: options.address.refundAddress,
|
|
361
|
+
...(transfer.sender ? { sender: transfer.sender } : {}),
|
|
362
|
+
sourceAmount,
|
|
363
|
+
sourceChain: options.address.snapshot.sourceChain,
|
|
364
|
+
sourceToken: options.address.snapshot.sourceToken,
|
|
365
|
+
sourceTransactionHashes: [transfer.transactionHash],
|
|
366
|
+
},
|
|
367
|
+
sourceTransactionHash: transfer.transactionHash,
|
|
368
|
+
sourceTransferIndex: transfer.transferIndex,
|
|
369
|
+
});
|
|
370
|
+
source.deposits.push(deposit);
|
|
371
|
+
created += 1;
|
|
372
|
+
}
|
|
373
|
+
if (!Deposit.isTerminal(deposit.status)) {
|
|
374
|
+
const result = await Deposit.transition(db, {
|
|
375
|
+
expectedVersion: deposit.version,
|
|
376
|
+
id: deposit.id,
|
|
377
|
+
providerRequestIds: unique([...deposit.providerRequestIds, options.request.id]),
|
|
378
|
+
snapshot: {
|
|
379
|
+
...deposit.snapshot,
|
|
380
|
+
...(options.address.snapshot.subsidize ? { destinationAmountRequired } : {}),
|
|
381
|
+
...(transfer.sender ? { sender: transfer.sender } : {}),
|
|
382
|
+
sourceAmount,
|
|
383
|
+
},
|
|
384
|
+
sourceTransferIndex: transfer.transferIndex,
|
|
385
|
+
status: deposit.status === 'detected' ? 'bridging' : deposit.status,
|
|
386
|
+
});
|
|
387
|
+
if (result.type === 'applied') {
|
|
388
|
+
deposit = result.record;
|
|
389
|
+
updatedIds.add(deposit.id);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
verified.push({ deposit, required, sourceAmount: BigInt(transfer.amount) });
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (verified.length === 0)
|
|
396
|
+
return { created, terminal: false, updated: updatedIds.size };
|
|
397
|
+
if (!sourceEvidenceComplete)
|
|
398
|
+
return { created, terminal: false, updated: updatedIds.size };
|
|
399
|
+
const destinationEvidence = await Promise.all(options.request.destinationTransactionHashes.map((transactionHash) => options.verifyTransfers({
|
|
400
|
+
chain: options.address.snapshot.destinationChain,
|
|
401
|
+
recipient: options.address.recipient,
|
|
402
|
+
token: options.address.providerOutputToken,
|
|
403
|
+
transactionHash,
|
|
404
|
+
})));
|
|
405
|
+
const destinationTransfers = destinationEvidence.flat();
|
|
406
|
+
const providerEvidenceComplete = options.request.status === 'success' &&
|
|
407
|
+
destinationEvidence.every((transfers) => transfers.length > 0);
|
|
408
|
+
const providerOutput = destinationTransfers.reduce((total, transfer) => total + BigInt(transfer.amount), 0n);
|
|
409
|
+
const totalRequired = verified.reduce((total, entry) => total + entry.required, 0n);
|
|
410
|
+
let allocated = 0n;
|
|
411
|
+
let cumulativeRequired = 0n;
|
|
412
|
+
for (const entry of verified) {
|
|
413
|
+
const { required, sourceAmount } = entry;
|
|
414
|
+
cumulativeRequired += required;
|
|
415
|
+
const nextAllocated = totalRequired === 0n ? 0n : (providerOutput * cumulativeRequired) / totalRequired;
|
|
416
|
+
const delivered = nextAllocated - allocated;
|
|
417
|
+
allocated = nextAllocated;
|
|
418
|
+
const { deposit } = entry;
|
|
419
|
+
if (Deposit.isTerminal(deposit.status))
|
|
420
|
+
continue;
|
|
421
|
+
const settlement = await reconcileSubsidy({
|
|
422
|
+
address: options.address,
|
|
423
|
+
delivered,
|
|
424
|
+
deposit,
|
|
425
|
+
providerEvidenceComplete,
|
|
426
|
+
required,
|
|
427
|
+
sourceAmount,
|
|
428
|
+
subsidies: options.subsidies,
|
|
429
|
+
verifyTransfers: options.verifyTransfers,
|
|
430
|
+
});
|
|
431
|
+
if (settlement.outcome)
|
|
432
|
+
options.metrics?.count('funding_deposit_subsidy_count', 1, {
|
|
433
|
+
outcome: settlement.outcome,
|
|
434
|
+
provider: options.address.providerId,
|
|
435
|
+
});
|
|
436
|
+
if (settlement.status === 'bridging' || settlement.status === 'settling')
|
|
437
|
+
terminal = false;
|
|
438
|
+
const destinationAmount = Value.tokenAmount({
|
|
439
|
+
baseUnits: delivered + settlement.delivered,
|
|
440
|
+
currency: options.address.snapshot.destinationToken.currency,
|
|
441
|
+
decimals: options.address.snapshot.destinationToken.decimals,
|
|
442
|
+
});
|
|
443
|
+
const result = await Deposit.transition(db, {
|
|
444
|
+
expectedVersion: deposit.version,
|
|
445
|
+
id: deposit.id,
|
|
446
|
+
...(delivered > 0n
|
|
447
|
+
? {
|
|
448
|
+
providerOutputAmount: Value.tokenAmount({
|
|
449
|
+
baseUnits: delivered,
|
|
450
|
+
currency: options.address.providerOutputToken.currency,
|
|
451
|
+
decimals: options.address.providerOutputToken.decimals,
|
|
452
|
+
}),
|
|
453
|
+
}
|
|
454
|
+
: {}),
|
|
455
|
+
providerRequestIds: unique([...deposit.providerRequestIds, options.request.id]),
|
|
456
|
+
providerTransactionHashes: unique([
|
|
457
|
+
...deposit.providerTransactionHashes,
|
|
458
|
+
...options.request.destinationTransactionHashes,
|
|
459
|
+
]),
|
|
460
|
+
...(settlement.settlementTransaction
|
|
461
|
+
? { settlementTransaction: settlement.settlementTransaction }
|
|
462
|
+
: {}),
|
|
463
|
+
...(settlement.settlementTransactionHash
|
|
464
|
+
? { settlementTransactionHash: settlement.settlementTransactionHash }
|
|
465
|
+
: {}),
|
|
466
|
+
snapshot: {
|
|
467
|
+
...deposit.snapshot,
|
|
468
|
+
...(delivered + settlement.delivered > 0n ? { destinationAmount } : {}),
|
|
469
|
+
...(settlement.status === 'completed' && !options.address.snapshot.subsidize
|
|
470
|
+
? { destinationAmountRequired: destinationAmount }
|
|
471
|
+
: {}),
|
|
472
|
+
destinationTransactionHashes: unique([
|
|
473
|
+
...(deposit.snapshot.destinationTransactionHashes ?? []),
|
|
474
|
+
...destinationTransfers.map((evidence) => evidence.transactionHash),
|
|
475
|
+
...settlement.destinationTransactionHashes,
|
|
476
|
+
]),
|
|
477
|
+
},
|
|
478
|
+
status: settlement.status,
|
|
479
|
+
...(settlement.statusReason ? { statusReason: settlement.statusReason } : {}),
|
|
480
|
+
...(settlement.subsidyAmount ? { subsidyAmount: settlement.subsidyAmount } : {}),
|
|
481
|
+
...(settlement.tempoGasPaid ? { tempoGasPaid: settlement.tempoGasPaid } : {}),
|
|
482
|
+
});
|
|
483
|
+
if (result.type === 'applied') {
|
|
484
|
+
updatedIds.add(deposit.id);
|
|
485
|
+
if (settlement.broadcast && options.subsidies) {
|
|
486
|
+
await options.subsidies.broadcast(settlement.broadcast).catch((cause) => {
|
|
487
|
+
options.metrics?.count('funding_deposit_subsidy_count', 1, {
|
|
488
|
+
outcome: 'broadcast_failed',
|
|
489
|
+
provider: options.address.providerId,
|
|
490
|
+
});
|
|
491
|
+
throw cause;
|
|
492
|
+
});
|
|
493
|
+
options.metrics?.count('funding_deposit_subsidy_count', 1, {
|
|
494
|
+
outcome: 'broadcast',
|
|
495
|
+
provider: options.address.providerId,
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return { created, terminal, updated: updatedIds.size };
|
|
501
|
+
}
|
|
502
|
+
async function reconcileSubsidy(options) {
|
|
503
|
+
const empty = { delivered: 0n, destinationTransactionHashes: [] };
|
|
504
|
+
if (options.required === 0n)
|
|
505
|
+
return {
|
|
506
|
+
...empty,
|
|
507
|
+
status: 'action-required',
|
|
508
|
+
statusReason: {
|
|
509
|
+
code: 'source_amount_not_supported',
|
|
510
|
+
message: 'The source amount is smaller than one destination-token base unit.',
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
const deficit = options.required > options.delivered ? options.required - options.delivered : 0n;
|
|
514
|
+
const subsidyAmount = options.deposit.subsidyAmount ??
|
|
515
|
+
Value.tokenAmount({
|
|
516
|
+
baseUnits: deficit,
|
|
517
|
+
currency: options.address.snapshot.destinationToken.currency,
|
|
518
|
+
decimals: options.address.snapshot.destinationToken.decimals,
|
|
519
|
+
});
|
|
520
|
+
if (options.deposit.settlementTransaction && options.deposit.settlementTransactionHash) {
|
|
521
|
+
if (!options.subsidies)
|
|
522
|
+
return {
|
|
523
|
+
...empty,
|
|
524
|
+
outcome: 'unavailable',
|
|
525
|
+
status: 'action-required',
|
|
526
|
+
statusReason: {
|
|
527
|
+
code: 'subsidy_failed',
|
|
528
|
+
message: 'Tempo subsidy settlement is unavailable.',
|
|
529
|
+
},
|
|
530
|
+
subsidyAmount,
|
|
531
|
+
};
|
|
532
|
+
const hash = options.deposit.settlementTransactionHash;
|
|
533
|
+
const status = await options.subsidies.status({ hash });
|
|
534
|
+
if (status.type === 'reverted')
|
|
535
|
+
return {
|
|
536
|
+
...empty,
|
|
537
|
+
outcome: 'reverted',
|
|
538
|
+
status: 'action-required',
|
|
539
|
+
statusReason: {
|
|
540
|
+
code: 'subsidy_failed',
|
|
541
|
+
message: 'Tempo could not deliver the required subsidy.',
|
|
542
|
+
},
|
|
543
|
+
subsidyAmount,
|
|
544
|
+
tempoGasPaid: status.tempoGasPaid,
|
|
545
|
+
};
|
|
546
|
+
if (status.type === 'pending')
|
|
547
|
+
return {
|
|
548
|
+
...empty,
|
|
549
|
+
broadcast: {
|
|
550
|
+
hash,
|
|
551
|
+
transaction: options.deposit.settlementTransaction,
|
|
552
|
+
},
|
|
553
|
+
outcome: 'pending',
|
|
554
|
+
status: 'settling',
|
|
555
|
+
subsidyAmount,
|
|
556
|
+
};
|
|
557
|
+
const transfers = await options.verifyTransfers({
|
|
558
|
+
chain: options.address.snapshot.destinationChain,
|
|
559
|
+
recipient: options.address.recipient,
|
|
560
|
+
token: options.address.snapshot.destinationToken,
|
|
561
|
+
transactionHash: hash,
|
|
562
|
+
});
|
|
563
|
+
const delivered = transfers.reduce((total, transfer) => total + BigInt(transfer.amount), 0n);
|
|
564
|
+
return {
|
|
565
|
+
delivered,
|
|
566
|
+
destinationTransactionHashes: transfers.map((transfer) => transfer.transactionHash),
|
|
567
|
+
outcome: options.delivered + delivered >= options.required ? 'completed' : 'underfilled',
|
|
568
|
+
status: options.delivered + delivered >= options.required ? 'completed' : 'settling',
|
|
569
|
+
subsidyAmount,
|
|
570
|
+
tempoGasPaid: status.tempoGasPaid,
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
if (options.delivered >= options.required)
|
|
574
|
+
return { ...empty, status: 'completed' };
|
|
575
|
+
if (!options.address.snapshot.subsidize) {
|
|
576
|
+
if (!options.providerEvidenceComplete)
|
|
577
|
+
return { ...empty, status: 'bridging' };
|
|
578
|
+
if (options.delivered > 0n)
|
|
579
|
+
return { ...empty, status: 'completed' };
|
|
580
|
+
return {
|
|
581
|
+
...empty,
|
|
582
|
+
status: 'action-required',
|
|
583
|
+
statusReason: {
|
|
584
|
+
code: 'delivery_failed',
|
|
585
|
+
message: 'The provider completed without delivering destination funds.',
|
|
586
|
+
},
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
if (!options.providerEvidenceComplete)
|
|
590
|
+
return { ...empty, status: 'bridging' };
|
|
591
|
+
if (!options.subsidies)
|
|
592
|
+
return {
|
|
593
|
+
...empty,
|
|
594
|
+
outcome: 'unavailable',
|
|
595
|
+
status: 'action-required',
|
|
596
|
+
statusReason: {
|
|
597
|
+
code: 'subsidy_failed',
|
|
598
|
+
message: 'Tempo subsidy settlement is unavailable.',
|
|
599
|
+
},
|
|
600
|
+
};
|
|
601
|
+
if (!Subsidy.supports(options.subsidies.policy, {
|
|
602
|
+
amount: options.sourceAmount.toString(),
|
|
603
|
+
destinationToken: options.address.snapshot.destinationToken,
|
|
604
|
+
sourceToken: options.address.snapshot.sourceToken,
|
|
605
|
+
}))
|
|
606
|
+
return {
|
|
607
|
+
...empty,
|
|
608
|
+
outcome: 'unsupported',
|
|
609
|
+
status: 'action-required',
|
|
610
|
+
statusReason: {
|
|
611
|
+
code: 'source_amount_not_supported',
|
|
612
|
+
message: 'The source amount is outside the subsidized deposit limit.',
|
|
613
|
+
},
|
|
614
|
+
};
|
|
615
|
+
const prepared = await options.subsidies
|
|
616
|
+
.prepare({
|
|
617
|
+
amount: deficit,
|
|
618
|
+
depositId: options.deposit.id,
|
|
619
|
+
recipient: options.address.recipient,
|
|
620
|
+
token: options.address.snapshot.destinationToken.address,
|
|
621
|
+
})
|
|
622
|
+
.catch((cause) => {
|
|
623
|
+
if (cause instanceof Subsidy.BalanceUnavailableError)
|
|
624
|
+
return undefined;
|
|
625
|
+
if (cause instanceof Subsidy.LiquidityUnavailableError)
|
|
626
|
+
return null;
|
|
627
|
+
throw cause;
|
|
628
|
+
});
|
|
629
|
+
if (prepared === null)
|
|
630
|
+
return {
|
|
631
|
+
...empty,
|
|
632
|
+
outcome: 'liquidity_unavailable',
|
|
633
|
+
status: 'settling',
|
|
634
|
+
subsidyAmount,
|
|
635
|
+
};
|
|
636
|
+
if (!prepared)
|
|
637
|
+
return {
|
|
638
|
+
...empty,
|
|
639
|
+
outcome: 'balance_unavailable',
|
|
640
|
+
status: 'action-required',
|
|
641
|
+
statusReason: {
|
|
642
|
+
code: 'subsidy_balance_unavailable',
|
|
643
|
+
message: 'Tempo lacks enough pathUSD for the required subsidy.',
|
|
644
|
+
},
|
|
645
|
+
subsidyAmount,
|
|
646
|
+
};
|
|
647
|
+
return {
|
|
648
|
+
...empty,
|
|
649
|
+
broadcast: prepared,
|
|
650
|
+
outcome: 'prepared',
|
|
651
|
+
settlementTransaction: prepared.transaction,
|
|
652
|
+
settlementTransactionHash: prepared.hash,
|
|
653
|
+
status: 'settling',
|
|
654
|
+
subsidyAmount,
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function destinationBaseUnits(amount, sourceDecimals, destinationDecimals) {
|
|
658
|
+
if (destinationDecimals >= sourceDecimals)
|
|
659
|
+
return amount * 10n ** BigInt(destinationDecimals - sourceDecimals);
|
|
660
|
+
const divisor = 10n ** BigInt(sourceDecimals - destinationDecimals);
|
|
661
|
+
// Destination tokens cannot represent finer source precision, so retain only
|
|
662
|
+
// the amount expressible in destination base units.
|
|
663
|
+
return amount / divisor;
|
|
664
|
+
}
|
|
665
|
+
function unique(values) {
|
|
666
|
+
return [...new Set(values)];
|
|
667
|
+
}
|
|
668
|
+
/** Provider pagination exceeded the bounded reconciliation limit. */
|
|
669
|
+
export class PaginationLimitError extends Error {
|
|
670
|
+
name = 'Funding.Reconciliation.PaginationLimitError';
|
|
671
|
+
}
|
|
672
|
+
/** The reconciliation lease was claimed by another worker. */
|
|
673
|
+
export class StaleLeaseError extends Error {
|
|
674
|
+
name = 'Funding.Reconciliation.StaleLeaseError';
|
|
675
|
+
}
|
|
676
|
+
//# sourceMappingURL=Reconciliation.js.map
|