/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ import type { EnvMap } from './env.js'; import type { Secrets } from './config.js'; import type { FeePolicy } from './contract.js'; import type { Processor, Rates, Signer } from './ports.js'; /** * The dev rate table `openPorts` and `memoryPorts` wire outside production: buy ~$0.00833 per * credit, backing peg and cash-out $0.005. Public so a host or console that displays or re-mints * the dev rates shares this one definition; production rates come from env or the init. */ export declare const DEV_RATES: RatesConfig; /** * The exact integer knobs `configuredRates` takes; accepted anywhere a Rates instance is (a * PortsInit `rates` field, for one). Each pair states one CREDIT-to-USD rate as rate / 10^scale * USD per credit — exact integers, never a float. Construction refuses a table whose buy rate * sits below par, since every top-up would then book a loss. */ export type RatesConfig = { /** What a buyer pays per credit: buyRate / 10^buyScale USD. */ readonly buyRate: bigint; readonly buyScale: number; /** The backing peg: the USD per credit the trust must hold against custodial balances. */ readonly parRate: bigint; readonly parScale: number; /** The cash-out rate: the USD per credit a payout settles at. */ readonly payoutRate: bigint; readonly payoutScale: number; }; export type ExternalInit = { signer?: Signer; processor?: Processor; rates?: Rates | RatesConfig; pricing?: FeePolicy; }; export type Externals = { signer: Signer; processor: Processor; rates: Rates; pricing: FeePolicy; }; /** * The env keys production requires but that are missing or malformed — the six CREDIT-to-USD * rate knobs and the payout provider URL — skipping any family the init already supplies. * Empty outside production. The single source `preflight` reports and `openPorts` throws on. */ export declare function missingExternals(env: EnvMap, init?: ExternalInit): string[]; /** * Refuses a malformed port at wiring time, so the deploy fails at startup rather than deep * inside a request or sweep. The classic slip is passing a factory (`silentLogger`) where its * product (`silentLogger()`) belongs. */ export declare function requireCallable(owner: string, service: unknown, methods: ReadonlyArray): void; /** * Resolves the external ports from `env` and `secrets`, letting the init win over anything * derived. Dev fills sane defaults; production requires the real values for the ports not * overridden and throws `CONFIG.INVALID` listing every missing knob at once. */ export declare function resolveExternals(env: EnvMap, init: ExternalInit, secrets: Secrets): Externals; /** * The Ed25519 signer the secrets bag names: the signing secret hashed to a seed, each rotated-out * prior transformed the same way so checkpoints sealed under one still verify. A blank secret * (dev only — production refuses it upstream) falls back to a fixed non-secret. */ export declare function signerFromSecrets(secrets: Secrets): Signer;