@pwngh/economy-lab
    Preparing search index...

    Variable requestPayoutConst

    requestPayout: (
        fields: FieldsOf<K>,
    ) => {
        actor: Principal;
        amount: Amount;
        idempotencyKey: string;
        kind: "requestPayout";
        userId: string;
    } = ...

    Builds a requestPayout operation: opens a seller's cash out. It debits the seller's earned account into PAYOUT_RESERVE and opens a payout saga in RESERVED, storing the USD quote at the request-time CREDIT-to-USD payout rate; the background worker later submits exactly that quote to the rail. No USD moves here and the credits never become spendable — only matured earned credit is payable. Rejects with BELOW_MINIMUM, PAYOUT_TOO_SOON (carries retryAfter), PAYEE_UNVERIFIED (when a payee directory is composed in), INSUFFICIENT_FUNDS, FUNDS_IMMATURE (the matured portion alone must cover the amount; carries availableAt), or ECONOMY_PAUSED for a user actor. A user may request only their own payout. The idempotencyKey makes a double-tapped cash out open one saga, not two; the committed transaction's meta.sagaId names the saga it opened.

    Type Declaration

      • (
            fields: FieldsOf<K>,
        ): {
            actor: Principal;
            amount: Amount;
            idempotencyKey: string;
            kind: "requestPayout";
            userId: string;
        }
      • Parameters

        • fields: FieldsOf<K>

        Returns {
            actor: Principal;
            amount: Amount;
            idempotencyKey: string;
            kind: "requestPayout";
            userId: string;
        }

        • actor: Principal
        • amount: Amount

          amount is the seller's earned credits. It is set aside in the payout-reserve account and ultimately paid out to them as real USD.

        • idempotencyKey: string
        • kind: "requestPayout"
        • userId: string
    const outcome = await economy.submit(requestPayout({
    idempotencyKey: idempotencyKey('payout', 'usr_seller', '2026-07'),
    actor: userActor('usr_seller'),
    userId: 'usr_seller',
    amount: toAmount('CREDIT', 2_500_000n), // cash out 25,000 credits
    }));