/** * @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 { Rates } from '../ports.js'; /** * Holds the three CREDIT-to-USD rates a deployment configures for its {@link Rates} dual-rate credit * economy. Each rate is two integers (`rate` and `scale`), so conversion stays free of * floating-point error. These are business constants a deployment sets, not a live market feed. * * @see {@link https://economy-lab-docs.pages.dev/economy/concepts/money-model/ The money model} for * what the buy, par, and payout rates mean and how the buy-par spread funds the platform. * @see {@link https://economy-lab-docs.pages.dev/economy/ports/rates/ Rates} for the port these feed. */ export interface RatesConfig { buyRate: bigint; buyScale: number; parRate: bigint; parScale: number; payoutRate: bigint; payoutScale: number; } /** * Builds the production CREDIT-to-USD rate source from a deployment's configured rates, replacing the * 1:1 dev placeholder. Each returned rate carries a `rateId` naming the exact rate so a transaction * can record which one it priced against. * * Same-currency conversion returns 1:1. Only CREDIT and USD exist, so any other pair is a wiring bug * and throws. * * Construction asserts buy >= par >= payout (each read as USD per credit across its own scale) and * throws `CONFIG.INVALID` when the order fails: a credit that could cash out for more than it was * bought or backed at would drain the platform, so a misconfigured deployment fails at wiring, not * at the first cash out. * * @example * // Example rates: buy at ~120 credits/USD ($0.00833), backed and cashed out at ~200/USD ($0.005), * // a ~40% spread: * const rates = configuredRates({ * buyRate: 8333n, buyScale: 6, * parRate: 5n, parScale: 3, * payoutRate: 5n, payoutScale: 3, * }); * * @see {@link https://economy-lab-docs.pages.dev/economy/ports/rates/ Rates} for the dual-rate * credit economy this rate source feeds. */ export declare function configuredRates(config: RatesConfig): Rates;