/** * @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 { Ctx, Operation, Outcome } from '../contract.js'; import type { Unit } from '../ports.js'; /** * Undo a past sale, making the buyer whole even when a seller already spent their cut. * * A naive sign-flip breaks once a seller spent their cut: reversing their credit drives the earned * balance negative, the ledger rejects the posting, and the buyer goes unpaid. Instead this returns * the buyer the full price and claws back from each seller (and REVENUE) only up to what each still * holds, booking the uncollectable rest to `SYSTEM.RECEIVABLE` so debits and credits still cancel. * * Refund and an order-tied clawback share the order-scoped key `reversed:` to stay mutually * exclusive; a lost claim returns the recorded transaction as `duplicate`. The buyer's SKU * entitlement is revoked in the same database transaction. Returns `committed`, `duplicate`, or * `rejected` with `UNKNOWN_ORDER`. * * @see {@link https://economy-lab-docs.pages.dev/economy/reference/operations/refund/ Refund} for * the make-the-buyer-whole coverage plan. */ export declare function refund(operation: Operation, unit: Unit, ctx: Ctx): Promise;