import { type JSONColumnType, type Selectable } from 'kysely'; import type * as Db from '../Db.js'; import type * as db_Schema from '../Schema.js'; /** Columns of the `routes_deposits` table. */ export type Table = Omit & { /** Private provider request identifiers stored as JSON. */ providerRequestIds: JSONColumnType; /** Private provider transaction references stored as JSON. */ providerTransactionHashes: JSONColumnType; }; /** A stored route deposit. */ export type Record = Selectable; /** Ownership filter inherited from the deposit address. */ export type Owner = { /** Key environment. */ environment: Record['environment']; /** Owning organization id (`org_…`). */ orgId: string; /** Attributed project id for project-scoped API keys. */ projectId?: string | undefined; }; /** Optional filters shared by route deposit list and count queries. */ export type Filters = { /** Reusable source-chain address that received the funds. */ depositAddress?: string | undefined; /** Canonical destination token keys accepted by the filter. */ destinationTokenKeys?: readonly string[] | undefined; /** Route provider id. */ providerId?: string | undefined; /** Tempo account that receives completed deposits. */ recipient?: string | undefined; /** Canonical source chain ids accepted by the filter. */ sourceChainIds?: readonly string[] | undefined; /** Canonical source token keys accepted by the filter. */ sourceTokenKeys?: readonly string[] | undefined; /** Deposit lifecycle status. */ status?: Record['status'] | undefined; }; /** Aggregates active deposit states for bounded operational metrics. */ export declare function summarizeStates(db: Db.Db, options: summarizeStates.Options): Promise<{ count: string; environment: "production" | "sandbox"; oldestStatusUpdatedAt: string; providerId: string; reason: string | null; status: "action-required" | "bridging" | "completed" | "detected" | "refunded" | "refunding" | "settling"; }[]>; export declare namespace summarizeStates { /** Active-state aggregation options. */ type Options = { /** Lifecycle statuses still owned by platform processing or recovery. */ statuses: readonly Record['status'][]; }; } /** Inserts one provider-observed source transfer as a route deposit. */ export declare function insert(db: Db.Db, record: Record): Promise; /** Inserts a chain-observed source transfer or returns its existing deposit. */ export declare function insertOrGetSource(db: Db.Db, record: Record & { sourceTransferIndex: number; }): Promise; export declare namespace insertOrGetSource { /** Result of idempotently persisting one verified source transfer. */ type Result = { record: Record; type: 'created' | 'existing'; }; } /** Serializes source attribution for one address and transaction. */ export declare function withSourceTransaction(db: Db.Db, options: withSourceTransaction.Options): Promise; export declare namespace withSourceTransaction { /** Source identity and transaction-scoped work protected by its advisory lock. */ type Options = { /** Route deposit address that received the transfer. */ depositAddressId: string; /** Database work serialized for the source transaction. */ fn: (db: Db.Db) => Promise; /** Source transaction whose deposit attribution must not race. */ sourceTransactionHash: string; }; } /** Serializes subsidy preparation and persistence with organization deletion. */ export declare function withSubsidySettlement(db: Db.Db, options: withSubsidySettlement.Options): Promise; export declare namespace withSubsidySettlement { /** Organization and transaction-scoped work protected by its subsidy lock. */ type Options = { /** Database work serialized with organization deletion. */ fn: (db: Db.Db) => Promise; /** Organization whose subsidy liability may change. */ orgId: string; }; } /** Gets deposits created from one provider-observed source transaction. */ export declare function listByProviderObservation(db: Db.Db, options: listByProviderObservation.Options): Promise; export declare namespace listByProviderObservation { /** Provider observation fields that identify one source transaction. */ type Options = { /** Route deposit address that received the transfer. */ depositAddressId: string; /** Provider request that reported the transfer. */ providerRequestId: string; /** Provider-observed source transaction reference. */ sourceTransactionHash: string; }; } /** Attaches first-observation timestamps to every deposit from one provider request. */ export declare function recordRequestObservation(db: Db.Db, options: recordRequestObservation.Options): Promise; export declare namespace recordRequestObservation { /** First observations associated with one provider request. */ type Options = { /** Route deposit address id (`rda_…`). */ depositAddressId: string; /** When polling first observed the provider request. */ pollObservedAt?: string | undefined; /** Provider request identifier. */ providerRequestId: string; /** When Tempo first received an authenticated provider webhook. */ webhookReceivedAt?: string | undefined; }; } /** Gets deposits associated with one address and source transaction. */ export declare function listBySourceTransaction(db: Db.Db, options: listBySourceTransaction.Options): Promise; export declare namespace listBySourceTransaction { /** Source transaction fields scoped to one deposit address. */ type Options = { /** Route deposit address that received the transfer. */ depositAddressId: string; /** Provider-observed source transaction reference. */ sourceTransactionHash: string; }; } /** Lists a bounded page of source transfers awaiting provider attribution. */ export declare function listUnattributed(db: Db.Db, options: listUnattributed.Options): Promise; export declare namespace listUnattributed { /** Fixed sweep boundary and page position for one address. */ type Options = { /** Inclusive creation-time boundary retained until the sweep finishes. */ before: string; /** Last deposit attempted in this sweep. */ cursor?: listByAddress.Cursor | undefined; /** Route deposit address whose transfers are reconciled. */ depositAddressId: string; /** Maximum deposits returned. */ limit: number; }; } /** Returns whether an address has a source transfer awaiting provider attribution. */ export declare function hasUnattributed(db: Db.Db, depositAddressId: string): Promise; /** Gets a route deposit without ownership scoping. */ export declare function get(db: Db.Db, id: string): Promise; /** Gets the earliest source transfer detected for one reusable address. */ export declare function getFirstByAddress(db: Db.Db, addressId: string): Promise; /** Gets an owner-visible route deposit. */ export declare function getOwned(db: Db.Db, owner: Owner, id: string): Promise; /** Lists owner-visible route deposits newest-first. */ export declare function listByOwner(db: Db.Db, options: listByOwner.Options): Promise; export declare namespace listByOwner { /** Ownership and paging options for route deposits. */ type Options = Filters & { /** Exclusive lower bound from the previous page. */ cursor?: listByAddress.Cursor | undefined; /** Maximum rows to return. */ limit: number; /** Ownership filter derived from the authenticated API key. */ owner: Owner; }; } /** Lists filtered route deposits, newest update first. */ export declare function list(db: Db.Db, options: list.Options): Promise; export declare namespace list { /** Deposit filters and page bound. */ type Options = { /** Exclusive lower bound from the previous page. */ cursor?: Cursor | undefined; /** Restricts deposits to one deposit address. */ depositAddressId?: string | undefined; /** Restricts deposits to one route environment. */ environment?: Record['environment'] | undefined; /** Restricts deposits to any listed route environment. */ environments?: readonly Record['environment'][] | undefined; /** Restricts deposits to records with a positive provider or Tempo subsidy. */ hasSubsidy?: true | undefined; /** Maximum rows returned. */ limit: number; /** Restricts deposits to one organization. */ orgId?: string | undefined; /** Restricts deposits to one project. */ projectId?: string | undefined; /** Restricts deposits to one provider. */ providerId?: string | undefined; /** Restricts deposits to any listed provider. */ providerIds?: readonly string[] | undefined; /** Exact deposit id, deposit address, or transaction reference. */ query?: string | undefined; /** Restricts deposits to one source chain. */ sourceChainId?: string | undefined; /** Restricts deposits to any listed source chain. */ sourceChainIds?: readonly string[] | undefined; /** Restricts deposits to one lifecycle status. */ status?: Record['status'] | undefined; /** Restricts deposits to any listed lifecycle status. */ statuses?: readonly Record['status'][] | undefined; }; /** Cursor fields for the last deposit on the previous page. */ type Cursor = { /** Deposit id, used as a deterministic tie-breaker. */ id: string; /** Latest material update time. */ updatedAt: string; }; } /** Summarizes deposit work across the selected filters. */ export declare function summarize(db: Db.Db, options?: summarize.Options): Promise; export declare namespace summarize { /** Attribution and route filters. */ type Options = { /** Restricts deposits to one route environment. */ environment?: Record['environment'] | undefined; /** Restricts deposits to any listed route environment. */ environments?: readonly Record['environment'][] | undefined; /** Restricts deposits to one organization. */ orgId?: string | undefined; /** Restricts deposits to one project. */ projectId?: string | undefined; /** Restricts deposits to one provider. */ providerId?: string | undefined; /** Restricts deposits to any listed provider. */ providerIds?: readonly string[] | undefined; /** Restricts deposits to one source chain. */ sourceChainId?: string | undefined; /** Restricts deposits to any listed source chain. */ sourceChainIds?: readonly string[] | undefined; }; /** Current deposit work totals. */ type Result = { /** Deposits that require operator action. */ actionRequired: number; /** Deposits currently owned by platform processing or recovery. */ inProgress: number; /** When the oldest active deposit entered its current status. */ oldestActiveAt: string | null; }; } /** Counts owner-visible route deposits through the list's shared filters. */ export declare function count(db: Db.Db, options: count.Options): Promise; export declare namespace count { /** Ownership, filter, and cap options for counting route deposits. */ type Options = Filters & { /** Maximum exact count before returning the cap plus one. */ cap: number; /** Ownership filter derived from the authenticated API key. */ owner: Owner; }; } /** Lists one owner-visible address's deposits newest-first. */ export declare function listByAddress(db: Db.Db, owner: Owner, addressId: string, options: listByAddress.Options): Promise; export declare namespace listByAddress { /** Cursor fields for the last deposit returned by the previous page. */ type Cursor = { /** Deposit creation time. */ createdAt: string; /** Deposit id, used as a deterministic tie-breaker. */ id: string; }; /** Paging options for one address's deposits. */ type Options = { /** Exclusive lower bound from the previous page. */ cursor?: Cursor | undefined; /** Maximum rows to return. */ limit: number; }; } /** Lists deposits for one reusable source-chain address newest-first. */ export declare function listByDepositAddress(db: Db.Db, options: listByDepositAddress.Options): Promise; export declare namespace listByDepositAddress { /** Deposit address filter, ownership, and paging options. */ type Options = { /** Exclusive lower bound from the previous page. */ cursor?: listByAddress.Cursor | undefined; /** Reusable source-chain address that received the funds. */ depositAddress: string; /** Maximum rows to return. */ limit: number; /** Ownership filter derived from the authenticated API key. */ owner: Owner; }; } /** Lists one recipient's owner-visible deposits newest-first. */ export declare function listByRecipient(db: Db.Db, options: listByRecipient.Options): Promise; export declare namespace listByRecipient { /** Recipient filter, ownership, and paging options. */ type Options = { /** Exclusive lower bound from the previous page. */ cursor?: listByAddress.Cursor | undefined; /** Maximum rows to return. */ limit: number; /** Ownership filter derived from the authenticated API key. */ owner: Owner; /** Tempo account that receives completed deposits. */ recipient: string; }; } /** Returns provider-paid and settled Tempo subsidies for one deposit. */ export declare function subsidies(record: Record): { amount: { baseUnits: string; currency: string; decimals: number; formatted: string; }; provider: string; token: { address: string; currency: string; decimals: number; name: string; standard: string; symbol: string; tokenKey: string; verified: boolean; }; }[]; /** Lists verified production subsidies awaiting a Stripe acknowledgement. */ export declare function listUnreportedSubsidies(db: Db.Db, options?: listUnreportedSubsidies.Options): Promise; export declare namespace listUnreportedSubsidies { /** Options for the Routes subsidy reporting scan. */ type Options = { /** Maximum rows to return. */ limit?: number | undefined; /** Organization whose pending usage is listed. */ orgId?: string | undefined; }; } /** Stores the effective timestamp after Stripe acknowledges a Routes subsidy meter event. */ export declare function markSubsidyReported(db: Db.Db, id: string, meteredAt: string): Promise; /** Returns whether one organization has a Routes subsidy awaiting Stripe settlement. */ export declare function hasUnreportedSubsidies(db: Db.Db, options: hasUnreportedSubsidies.Options): Promise; export declare namespace hasUnreportedSubsidies { /** Organization filter for pending Routes subsidy usage. */ type Options = { /** Organization whose pending usage is checked. */ orgId: string; }; } /** Reads billable Routes subsidy usage for one organization and time window. */ export declare function subsidyUsage(db: Db.Db, options: subsidyUsage.Options): Promise; export declare namespace subsidyUsage { /** Organization and meter-event window for Routes subsidy usage. */ type Options = { /** Key environment to include. */ environment: Record['environment']; /** Inclusive meter-event lower bound. */ from: string; /** Organization whose subsidy usage is read. */ orgId: string; /** Inclusive meter-event upper bound. */ to: string; }; /** Billable Routes subsidy usage in fee-payer meter units. */ type Result = { /** USD subsidy total in six-decimal meter units. */ amount: bigint; /** Metered provider fees and Tempo top-ups. */ count: number; }; } /** Applies a version-guarded deposit update. */ export declare function update(db: Db.Db, options: update.Options): Promise; export declare namespace update { /** Guarded deposit update fields. */ type Options = { /** Stored version required for the update. */ expectedVersion: number; /** Route deposit id (`rdp_…`). */ id: string; /** When provider delivery was first verified. */ providerDeliveredAt: Record['providerDeliveredAt']; /** Provider output amount confirmed on Tempo. */ providerOutputAmount: Record['providerOutputAmount']; /** Provider request that first reported the deposit. */ providerRequestId: Record['providerRequestId']; /** Private provider request identifiers. */ providerRequestIds: Record['providerRequestIds']; /** Bounded private provider state. */ providerState: Record['providerState']; /** Provider-paid subsidy amount and token. */ providerSubsidy: Record['providerSubsidy']; /** Provider-leg transaction references. */ providerTransactionHashes: Record['providerTransactionHashes']; /** Deposit position within the provider request. */ providerTransferIndex: Record['providerTransferIndex']; /** Bounded private retry state. */ retryState: Record['retryState']; /** Persisted settlement transaction bytes for exactly-once rebroadcast. */ settlementTransaction: Record['settlementTransaction']; /** Persisted settlement transaction hash. */ settlementTransactionHash: Record['settlementTransactionHash']; /** Replacement public snapshot. */ snapshot: Record['snapshot']; /** Verified transfer position in the source transaction, or null. */ sourceTransferIndex: Record['sourceTransferIndex']; /** Replacement lifecycle status. */ status: Record['status']; /** Replacement customer-safe reason. */ statusReason: Record['statusReason']; /** When the deposit entered its current status. */ statusUpdatedAt: Record['statusUpdatedAt']; /** Destination token amount supplied by Tempo. */ subsidyAmount: Record['subsidyAmount']; /** Tempo gas paid for settlement, in base units. */ tempoGasPaid: Record['tempoGasPaid']; /** New material update time. */ updatedAt: string; /** New material version. */ version: number; }; } //# sourceMappingURL=routesDeposits.d.ts.map