import * as z from 'zod/mini'; import type * as Db from '../../db/Db.js'; import * as FundingDeposits from '../../db/tables/fundingDeposits.js'; import * as Schema from '../Schema.js'; /** Mechanisms that can first detect a funding deposit. */ export declare const detectionTriggers: readonly ['chain', 'manual', 'poll', 'webhook']; /** Mechanism that first detected a funding deposit. */ export type DetectionTrigger = (typeof detectionTriggers)[number]; /** * Public funding deposit statuses: * * - `action-required`: Automatic processing stopped and requires recovery or operator action. * - `bridging`: The provider is moving the source funds to Tempo. * - `completed`: The full required amount reached the recipient. * - `detected`: The provider reported a source transfer that awaits chain verification. * - `refunded`: A verified refund reached the configured refund address. * - `refunding`: A refund started but is not yet verified. * - `settling`: Tempo is completing the required destination amount after provider delivery. */ export declare const statuses: readonly ['action-required', 'bridging', 'completed', 'detected', 'refunded', 'refunding', 'settling']; /** Lifecycle status of a detected funding deposit. */ export type Status = (typeof statuses)[number]; /** Statuses that never change after verified chain evidence. */ export declare const terminalStatuses: readonly ["completed", "refunded"]; /** * Customer-safe codes explaining a deposit that needs attention: * * - `delivery_failed`: The provider or Tempo could not complete destination delivery. * - `delivery_liquidity_unavailable`: The selected strategy cannot obtain the required destination amount. * - `manual_recovery_required`: Automatic processing cannot safely continue. * - `refund_failed`: The provider could not refund the source funds. * - `source_amount_not_supported`: The source amount is outside the supported limits. * - `source_token_mismatch`: The transfer used a token other than the configured source token. * - `subsidy_balance_unavailable`: Tempo lacks enough pathUSD for the required subsidy. * - `subsidy_failed`: Tempo could not deliver the required subsidy. */ export declare const statusReasonCodes: readonly ['delivery_failed', 'delivery_liquidity_unavailable', 'manual_recovery_required', 'refund_failed', 'source_amount_not_supported', 'source_token_mismatch', 'subsidy_balance_unavailable', 'subsidy_failed']; /** Stable customer-safe deposit status reason code. */ export type StatusReasonCode = (typeof statusReasonCodes)[number]; /** Bounded private state used by deposit reconciliation. */ export type PrivateState = Record; /** Returns whether a deposit status is terminal. */ export declare function isTerminal(status: Status): boolean; /** Returns whether the lifecycle allows moving between deposit statuses. */ export declare function canTransition(from: Status, to: Status): boolean; /** Generates a funding deposit id (`fdp_…`, lexically time-ordered). */ export declare function generateId(now?: Date): string; /** Zod schemas owned by the funding deposit resource. */ export declare namespace schema { /** Mechanism that first detected a funding deposit. */ const DetectionTrigger: z.ZodMiniEnum<{ chain: "chain"; manual: "manual"; poll: "poll"; webhook: "webhook"; }>; /** Funding deposit lifecycle status. */ const Status: z.ZodMiniEnum<{ "action-required": "action-required"; bridging: "bridging"; completed: "completed"; detected: "detected"; refunded: "refunded"; refunding: "refunding"; settling: "settling"; }>; /** Customer-safe explanation of a deposit status. */ const StatusReason: z.ZodMiniObject<{ code: z.ZodMiniEnum<{ delivery_failed: "delivery_failed"; delivery_liquidity_unavailable: "delivery_liquidity_unavailable"; manual_recovery_required: "manual_recovery_required"; refund_failed: "refund_failed"; source_amount_not_supported: "source_amount_not_supported"; source_token_mismatch: "source_token_mismatch"; subsidy_balance_unavailable: "subsidy_balance_unavailable"; subsidy_failed: "subsidy_failed"; }>; message: z.ZodMiniString; }, z.core.$strip>; /** Public fields persisted as the deposit snapshot. */ const Snapshot: z.ZodMiniObject<{ depositAddressId: z.ZodMiniString; destinationAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationAmountRequired: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; destinationToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; destinationTransactionHashes: z.ZodMiniOptional>>>; provider: z.ZodMiniObject<{ id: z.ZodMiniString; name: z.ZodMiniString; }, z.core.$strip>; recipient: z.ZodMiniString; refundAddress: z.ZodMiniString; refundAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; refundTransactionHashes: z.ZodMiniOptional>>>; sender: z.ZodMiniOptional>; sourceAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; sourceChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; sourceToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; sourceTransactionHashes: z.ZodMiniReadonly>>; }, z.core.$strip>; /** One detected funding deposit. */ const FundingDeposit: z.ZodMiniObject<{ createdAt: z.ZodMiniISODateTime; depositAddressId: z.ZodMiniString; detectionTrigger: z.ZodMiniOptional>; destinationAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationAmountRequired: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; destinationChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; destinationToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; destinationTransactionHashes: z.ZodMiniOptional>>>; id: z.ZodMiniString; provider: z.ZodMiniObject<{ id: z.ZodMiniString; name: z.ZodMiniString; }, z.core.$strip>; recipient: z.ZodMiniString; refundAddress: z.ZodMiniString; refundAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; refundTransactionHashes: z.ZodMiniOptional>>>; sender: z.ZodMiniOptional>; sourceAmount: z.ZodMiniOptional; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; formatted: z.ZodMiniString; }, z.core.$strip>>; sourceChain: z.ZodMiniObject<{ addressFormat: z.ZodMiniEnum<{ base58: "base58"; base58check: "base58check"; hex: "hex"; }>; id: z.ZodMiniString; kind: z.ZodMiniEnum<{ evm: "evm"; solana: "solana"; tron: "tron"; }>; name: z.ZodMiniString; }, z.core.$strip>; sourceToken: z.ZodMiniObject<{ address: z.ZodMiniString; currency: z.ZodMiniString; decimals: z.ZodMiniNumber; name: z.ZodMiniString; standard: z.ZodMiniString; symbol: z.ZodMiniString; tokenKey: z.ZodMiniString; verified: z.ZodMiniBoolean; }, z.core.$strip>; sourceTransactionHashes: z.ZodMiniReadonly>>; sourceTransferIndex: z.ZodMiniOptional>; status: z.ZodMiniEnum<{ "action-required": "action-required"; bridging: "bridging"; completed: "completed"; detected: "detected"; refunded: "refunded"; refunding: "refunding"; settling: "settling"; }>; statusReason: z.ZodMiniOptional; message: z.ZodMiniString; }, z.core.$strip>>; updatedAt: z.ZodMiniISODateTime; }, z.core.$strip>; } /** Stored public snapshot of a funding deposit. */ export type Snapshot = z.output; /** Customer-safe funding deposit status reason. */ export type StatusReason = z.output; /** A funding deposit as returned by reads. */ export type Public = z.output; /** Creates a durable record for one provider-observed source transaction. */ export declare function create(db: Db.Db, input: create.Input): Promise; /** Creates or returns the deposit for one verified chain transfer. */ export declare function createFromSource(db: Db.Db, input: createFromSource.Input): Promise; export declare namespace createFromSource { /** Verified source transfer used to create a chain-detected deposit. */ type Input = { /** Detection time override for deterministic tests. */ now?: Date | undefined; /** Public route and verified source amount. */ snapshot: Snapshot; /** Source transaction containing the deposited transfer. */ sourceTransactionHash: string; /** Verified transfer position within the source transaction. */ sourceTransferIndex: number; }; } export declare namespace create { /** Fields required to persist a provider-observed deposit. */ type Input = { /** Mechanism that first detected the deposit. */ detectionTrigger?: DetectionTrigger | undefined; /** Deposit id override for deterministic tests. */ id?: string | undefined; /** Detection time override for deterministic tests. */ now?: Date | undefined; /** When polling first observed the provider request. */ pollObservedAt?: string | undefined; /** Provider output amount confirmed on Tempo. */ providerOutputAmount?: z.output | undefined; /** Provider request that reported the source transaction. */ providerRequestId: string; /** Private provider request identifiers. */ providerRequestIds?: readonly string[] | undefined; /** Bounded private provider state. */ providerState?: PrivateState | undefined; /** Provider-leg transaction references. */ providerTransactionHashes?: readonly string[] | undefined; /** Deposit position within the provider request. */ providerTransferIndex?: number | undefined; /** Bounded private retry state. */ retryState?: PrivateState | undefined; /** Persisted settlement transaction bytes for exactly-once rebroadcast. */ settlementTransaction?: string | undefined; /** Persisted settlement transaction hash. */ settlementTransactionHash?: string | undefined; /** Public deposit snapshot. */ snapshot: Snapshot; /** Source transaction containing the deposited transfer. */ sourceTransactionHash: string; /** Verified transfer position within the source transaction. */ sourceTransferIndex?: number | undefined; /** Destination token amount supplied by Tempo. */ subsidyAmount?: z.output | undefined; /** Tempo gas paid for settlement, in base units. */ tempoGasPaid?: string | undefined; /** When Tempo first received an authenticated provider webhook. */ webhookReceivedAt?: string | undefined; }; } /** Applies a version-guarded material deposit change. */ export declare function transition(db: Db.Db, options: transition.Options): Promise; export declare namespace transition { /** Fields describing a material deposit change. */ type Options = { /** Version that the change was computed against. */ expectedVersion: number; /** Funding deposit id (`fdp_…`). */ id: string; /** Provider output amount confirmed on Tempo. */ providerOutputAmount?: z.output | undefined; /** Provider request attached after chain-first detection. */ providerRequestId?: string | undefined; /** Private provider request identifiers. */ providerRequestIds?: readonly string[] | undefined; /** Bounded private provider state. */ providerState?: PrivateState | undefined; /** Provider-leg transaction references. */ providerTransactionHashes?: readonly string[] | undefined; /** Deposit position within the attached provider request. */ providerTransferIndex?: number | undefined; /** Bounded private retry state. */ retryState?: PrivateState | undefined; /** Persisted settlement transaction bytes for exactly-once rebroadcast. */ settlementTransaction?: string | undefined; /** Persisted settlement transaction hash. */ settlementTransactionHash?: string | undefined; /** Replacement public snapshot. */ snapshot?: Snapshot | undefined; /** Verified transfer position within the source transaction. */ sourceTransferIndex?: number | undefined; /** New lifecycle status. */ status?: Status | undefined; /** Customer-safe reason attached to the current status. */ statusReason?: StatusReason | undefined; /** Destination token amount supplied by Tempo. */ subsidyAmount?: z.output | undefined; /** Tempo gas paid for settlement, in base units. */ tempoGasPaid?: string | undefined; }; /** Outcome of a guarded deposit transition. */ type Result = { record: FundingDeposits.Record; type: 'applied'; } | { current: FundingDeposits.Record; type: 'invalid'; } | { current: FundingDeposits.Record; type: 'stale'; } | { type: 'not_found'; }; } /** Serializes a stored deposit to the public read shape. */ export declare function toPublic(record: FundingDeposits.Record): Public; //# sourceMappingURL=Deposit.d.ts.map