/** The platform per-wallet floor, under this module's own long-standing name. */ export { WALLET_FLOOR as MIN_WALLET, FEE_BUFFER } from "./min-budget.js"; /** Lifecycle-relevant per-instance funding inputs — the only fields this module reads. */ export interface FundingInstance { name: string; fundingShare: number | null; } export interface Shortfall { requested: number; available: number; usable: number; shortBy: number; wallets: number; shares: number[]; } export interface FundingPlan { /** instance name → initialBudget for the create call. */ amounts: Map; /** Non-null means HALT: the budget is a hard target, never silently scaled down. */ shortfall: Shortfall | null; } /** * Total USDC `strategy_create_custom_strategy` can fund from — its whole * waterfall, in order: HL perps → HL spot USDC → EVM USDC (auto-bridged). * * These are DISJOINT buckets, so reading one reads a FRACTION of the fundable * balance. `total_withdrawable` is deliberately EXCLUDED: it is free margin * sitting inside OTHER strategy wallets, not spendable here. * * Returns null when no bucket key is present at all — an unknown shape must * never halt a deploy the backend would have funded. */ export declare function accessibleUsd(payload: Record | null): number | null; /** A sleeve's effective share, as the funding plan will use it. */ export interface InstanceShare { name: string; share: number; } /** The shares allocate more than the whole budget — {@link sharesOverAuthorization}. */ export interface ShareOverrun { sum: number; shares: InstanceShare[]; } /** * Do the effective funding shares allocate MORE than the budget authorizes? * * `planFunding` checks its total against the accessible BALANCE and nothing else — it never * compares the plan to `--budget`. And `loadDeployPackage` deliberately does not validate * `funding_share` (the skills-side `_pkg.validate` does, and the verb is a direct path that never * runs it), so shares summing above 1 reach funding intact: `0.6` on both sleeves of a `--budget * 500` deploy requests $600, the balance check passes against a larger wallet, and no step, note or * `overall` in the report ever says the funded total exceeded the ask. The bigger the balance, the * bigger the silent overrun. * * Keyed on the SHARES, not on `requested > budget`, and the difference is load-bearing: * `planFunding` floors every wallet at {@link MIN_WALLET}, so two half-share sleeves at * `--budget 10` legitimately request $20. That is the floor doing its documented job — it has its * own surfaces and its own soft tier — and a gate keyed on the funded total would refuse every * correct low-budget multi-sleeve deploy. What is never legitimate is a plan that hands out more * than the whole authorization before the floor is applied at all. * * Reads the EFFECTIVE shares through the same {@link sharesOf} the plan uses, so a partly-declared * manifest (one sleeve at `0.8`, one undeclared and therefore `1/n`) is judged on what will * actually be funded rather than on the declared subset. One producer: a second reading of this * arithmetic is how the two sides of a split come to disagree. * * Returns null when the shares fit — the tolerance absorbs the float error an even split carries * (three sleeves at `1/3` sum to 1.0000000000000002), never a real overrun, which is at minimum a * whole extra percentage point. */ export declare function sharesOverAuthorization(instances: FundingInstance[]): ShareOverrun | null; /** * Per-instance `initialBudget` for the instances still needing a wallet, split * by `fundingShare` and floored at {@link MIN_WALLET}. * * The requested budget is a HARD TARGET: on shortfall the caller HALTS. Scaling * every wallet down to fit turned a "$1,000 across 2 wallets" request into two * floor wallets, silently — that is the bug this shape exists to prevent. */ export declare function planFunding(instances: FundingInstance[], budget: number, available: number | null): FundingPlan; /** * The largest budget `b` whose funding plan still fits within `usable`: * `b* = max { b : Σᵢ max(MIN_WALLET, round2(b·shareᵢ)) ≤ usable }`. * * Bisected in integer cents with the SAME per-wallet rounding `planFunding` * uses, so re-running deploy at the hinted budget round-trips with no shortfall * even for uneven shares — where the bare `usable` over-hints, because a floored * small leg pushes the funded total above the budget. */ export declare function maxFeasibleBudget(instances: Array<{ fundingShare: number | null; }>, usable: number): number; /** Money in agent-facing prose: comma-grouped, two decimals, never scientific notation. */ export declare function usd(value: number): string; /** * A dollar amount as the `--budget` flag accepts it: bare digits, no `$`, no * comma grouping. {@link usd}'s commas would not parse as a number, so a hinted * command an agent copies verbatim must render the flag value with this. */ export declare function budgetArg(value: number): string; /** * The re-run command every deploy surface emits — ONE producer, because the same report prints it * more than once (a refusal's copy and the report's `next` line) and two copies drifting would hand * the reader two different commands for one situation. `budget` undefined renders the placeholder * the caller must fill in, never a fabricated number. * * The path is single-quoted for the same reason `pkg.id` is wherever it is emitted: these strings * are copied into a shell verbatim, and a real workspace path with a space in it * ("/data/My Strategies/spider") would otherwise render a command that cannot run. Quoting is * unconditional — a conditional quote is a second rule to get wrong, and the quoted form is * correct for every path. */ export declare function resumeCommand(packageDir: string, budget?: number): string; /** * Agent-facing halt text for a funding shortfall. * * The lower-budget escape renders ONLY when the usable balance can still fund * every wallet at the {@link MIN_WALLET} floor. Below that no budget is valid, * and suggesting one produces nonsense the agent then follows ("--budget ≤ $0", * the M381223 churn). Codes: senpi-skills `docs/error-code-taxonomy.md`. */ export declare function underfundedNote(shortfall: Shortfall, instances: Array<{ fundingShare: number | null; }>, packageDir: string): string; //# sourceMappingURL=funding.d.ts.map