import { type ColumnType, type JSONColumnType } from 'kysely'; import type { Address, Hex } from 'viem'; import * as Campaigns from '../../internal/rewards/Campaigns.js'; import type * as Db from '../Db.js'; import type * as db_Schema from '../Schema.js'; /** Columns of the `reward_runs` table. */ export type Table = Omit & { /** Bigint chain id, read as a string from pg and written as a number. */ chainId: ColumnType; /** Configuration snapshot consumed by the run. */ config: JSONColumnType; /** Resumable calculation and delivery evidence, compacted after completion. */ evidence: JSONColumnType; /** Latest cumulative statement. */ statement: JSONColumnType; }; /** A stored reward execution. */ export type Record = Omit & { /** Completed calculation evidence, or null before calculation finishes. */ evidence: Campaigns.RunEvidence | null; }; /** Compact execution fields used by the campaign administration surface. */ export type ExecutionSummary = Pick; /** Compact delivered-run fields used for public rates and source fallback. */ export type DeliveredSummary = Pick; /** Compact delivered-run fields keyed by EarnVault. */ export type DeliveredVaultSummary = DeliveredSummary & Pick; /** Creates or returns the unique contiguous run starting after one boundary. */ export declare function ensure(db: Db.Db, options: ensure.Options): Promise; export declare namespace ensure { /** Identity and snapshot for one contiguous run. */ type Options = { /** Chain containing the vault. */ chainId: number; /** Configuration snapshot. */ config: Campaigns.Config; /** Exclusive final boundary. */ endsAt: number; /** Previously delivered boundary. */ startsAfter: number; /** EarnVault address. */ vaultAddress: Address; }; } /** Acquires an expired or unowned run lease and increments its fencing token. */ export declare function acquire(db: Db.Db, options: acquire.Options): Promise; export declare namespace acquire { /** Lease selector and lifetime. */ type Options = { /** Run id. */ id: string; /** Lease duration. */ leaseMilliseconds: number; }; } /** Extends an active run lease without changing its fencing token. */ export declare function renew(db: Db.Db, options: renew.Options): Promise; export declare namespace renew { /** Fenced lease renewal. */ type Options = { /** Expected lease fencing token. */ fence: string; /** Run id. */ id: string; /** Replacement lease expiry. */ leaseExpiresAt: string; }; } /** Persists resumable calculation evidence under the current run fence and phase. */ export declare function writeCheckpoint(db: Db.Db, options: writeCheckpoint.Options): Promise; export declare namespace writeCheckpoint { /** Fenced calculation checkpoint. */ type Options = { /** Resumable calculation evidence. */ evidence: Campaigns.RunCheckpointEvidence; /** Expected lease fencing token. */ fence: string; /** Run id. */ id: string; }; } /** Reads resumable calculation evidence without treating completed evidence as a checkpoint. */ export declare function getCheckpoint(db: Db.Db, options: getCheckpoint.Options): Promise; export declare namespace getCheckpoint { /** Run containing resumable evidence. */ type Options = { /** Run id. */ id: string; }; } /** Applies one fenced phase transition. */ export declare function transition(db: Db.Db, options: transition.Options): Promise; /** Records an execution error and releases the fenced lease without regressing its phase. */ export declare function releaseWithError(db: Db.Db, options: releaseWithError.Options): Promise; export declare namespace releaseWithError { /** Fenced lease and diagnostic. */ type Options = { /** Actionable error text. */ error: string; /** Expected lease fencing token. */ fence: string; /** Run id. */ id: string; }; } export declare namespace transition { /** Fenced phase transition. */ type Options = { /** Expected lease fencing token. */ fence: string; /** Run id. */ id: string; /** Next execution phase. */ phase: Record['phase']; /** Durable outputs produced by the completed phase. */ patch: Partial<{ error: string | null; evidence: Campaigns.RunEvidence | null; fundedAssets: string | null; liability: string | null; mintedEarnShares: string | null; root: Hex | null; rootVersion: string | null; statement: Campaigns.Statement | null; statementHash: Hex | null; }>; }; } /** Reads one run. */ export declare function get(db: Db.Db, runId: string): Promise; /** Reads the newest run without loading its potentially large Merkle statement. */ export declare function latestSummary(db: Db.Db, options: latestSummary.Options): Promise; export declare namespace latestSummary { /** Campaign identity. */ type Options = { /** Chain containing the vault. */ chainId: number; /** EarnVault address. */ vaultAddress: string; }; } /** Reads the latest confirmed statement for one campaign. */ export declare function latestStatement(db: Db.Db, options: latestStatement.Options): Promise; /** Reads the latest delivered run for rate fallback and monitoring. */ export declare function latestDelivered(db: Db.Db, options: latestDelivered.Options): Promise; /** Reads the latest delivered run for each bounded EarnVault. */ export declare function listLatestDelivered(db: Db.Db, options: listLatestDelivered.Options): Promise; export declare namespace listLatestDelivered { /** Bounded delivered-run selector. */ type Options = { /** Chain containing every vault. */ chainId: number; /** EarnVault addresses. */ vaultAddresses: readonly string[]; }; } /** Clears superseded proof-bearing statements while retaining their accounting evidence. */ export declare function pruneStatements(db: Db.Db, options: pruneStatements.Options): Promise; export declare namespace pruneStatements { /** Campaign and run whose full statement remains live. */ type Options = { /** Chain containing the vault. */ chainId: number; /** Run retaining the latest full statement. */ keepRunId: string; /** EarnVault address. */ vaultAddress: string; }; } export declare namespace latestDelivered { /** Campaign identity. */ type Options = { /** Chain containing the vault. */ chainId: number; /** EarnVault address. */ vaultAddress: string; }; } export declare namespace latestStatement { /** Campaign identity. */ type Options = { /** Chain containing the vault. */ chainId: number; /** EarnVault address. */ vaultAddress: string; }; } //# sourceMappingURL=rewardRuns.d.ts.map