musdQueryKeys: {
    adjustPreview: (
        chainId: number,
        owner: string,
        legs: AdjustPreviewLegs,
    ) => readonly [
        "musd",
        number,
        "adjustPreview",
        string,
        null
        | string,
        null | string,
        null | string,
        null | string,
    ];
    balance: (
        chainId: number,
        address: `0x${string}`,
    ) => readonly ["musd", number, "balance", `0x${string}`];
    borrowingCapacity: (
        chainId: number,
        owner: string,
    ) => readonly ["musd", number, "borrowingCapacity", string];
    borrowingPower: (
        chainId: number,
        collateral: bigint,
        account?: string,
    ) => readonly ["musd", number, "borrowingPower", string, null | string];
    borrowPreview: (
        chainId: number,
        owner: string,
        amount: undefined | bigint,
    ) => readonly ["musd", number, "borrowPreview", string, null | string];
    closePreview: (
        chainId: number,
        owner: string,
    ) => readonly ["musd", number, "closePreview", string];
    drawForMargin: (
        chainId: number,
        collateral: bigint,
        account: undefined | string,
        horizonSeconds: undefined | bigint,
        priceFallBps: undefined | bigint,
    ) => readonly [
        "musd",
        number,
        "drawForMargin",
        string,
        null
        | string,
        null | string,
        null | string,
    ];
    maxWithdrawable: (
        chainId: number,
        owner: string,
    ) => readonly ["musd", number, "maxWithdrawable", string];
    oraclePrice: (chainId: number) => readonly ["musd", number, "oraclePrice"];
    redeemPreview: (
        chainId: number,
        redeemer: string,
        amount: undefined | bigint,
    ) => readonly ["musd", number, "redeemPreview", string, null | string];
    refinancePreview: (
        chainId: number,
        owner: string,
    ) => readonly ["musd", number, "refinancePreview", string];
    trove: (
        chainId: number,
        address: `0x${string}`,
    ) => readonly ["musd", number, "trove", `0x${string}`];
    withdrawCollateralPreview: (
        chainId: number,
        owner: string,
        amount: undefined | bigint,
    ) => readonly [
        "musd",
        number,
        "withdrawCollateralPreview",
        string,
        null
        | string,
    ];
} = ...

Stable TanStack query keys (chainId + method + args). Hooks that share a key dedupe to a single fetch (e.g. useTrove / useHealthFactor / useLiquidationPrice for one address differ only by select). bigints are stringified, TanStack hashes keys with JSON.stringify, which throws on bigint.

Type declaration

  • ReadonlyadjustPreview: (
        chainId: number,
        owner: string,
        legs: AdjustPreviewLegs,
    ) => readonly [
        "musd",
        number,
        "adjustPreview",
        string,
        null
        | string,
        null | string,
        null | string,
        null | string,
    ]

    MK-042. Carries all four legs, because a preview for "add 1 BTC" and one for "add 1 BTC and borrow 500" are different questions with different answers.

    MK-085. The legs arrive as the same object the fetch sends, not as four positional values assembled a second time, so the key cannot describe a different call from the one that was made. An ABSENT leg is null here and a leg of 0n is "0", because on chain those are different inputs: _adjustTrove takes _isDebtIncrease independently of _mUSDChange (BorrowerOperations.sol:757-758) and refuses (0, true) at :785-787. Encoding both as 0 made "no debt leg" and "a debt increase of zero" share a cache entry.

  • Readonlybalance: (
        chainId: number,
        address: `0x${string}`,
    ) => readonly ["musd", number, "balance", `0x${string}`]

    Query key for an MUSD balance read.

  • ReadonlyborrowingCapacity: (
        chainId: number,
        owner: string,
    ) => readonly ["musd", number, "borrowingCapacity", string]

    Key for useBorrowingCapacity: one entry per owner (MK-002).

  • ReadonlyborrowingPower: (
        chainId: number,
        collateral: bigint,
        account?: string,
    ) => readonly ["musd", number, "borrowingPower", string, null | string]

    Query key for the borrowing power ceiling (collateral stringified, keys are JSON-hashed).

  • ReadonlyborrowPreview: (
        chainId: number,
        owner: string,
        amount: undefined | bigint,
    ) => readonly ["musd", number, "borrowPreview", string, null | string]

    Key for useBorrowPreview: one entry per owner and draw (MK-002).

    MK-085. amount is optional and an ABSENT amount is null, not "0". The hook disables itself without one, and a disabled TanStack query still reads whatever sits at its key, so encoding "not asked yet" as 0 let an empty input box render the verdict computed for a draw of zero. Every amount-carrying key below follows the same rule.

  • ReadonlyclosePreview: (
        chainId: number,
        owner: string,
    ) => readonly ["musd", number, "closePreview", string]

    MK-042. Whether closing is permitted, and the MUSD the caller must hold to do it.

  • ReadonlydrawForMargin: (
        chainId: number,
        collateral: bigint,
        account: undefined | string,
        horizonSeconds: undefined | bigint,
        priceFallBps: undefined | bigint,
    ) => readonly [
        "musd",
        number,
        "drawForMargin",
        string,
        null
        | string,
        null | string,
        null | string,
    ]

    Query key for a margin draw (MK-240): the ceiling's key parts, and the caller's margin. A different margin is a different answer, so both inputs are in the key; an absent one is null, which the hook never fetches, and never a default written out.

  • ReadonlymaxWithdrawable: (
        chainId: number,
        owner: string,
    ) => readonly ["musd", number, "maxWithdrawable", string]

    MK-042. The largest withdrawal the contract would accept now, and which gate caps it.

  • ReadonlyoraclePrice: (chainId: number) => readonly ["musd", number, "oraclePrice"]

    Query key for the oracle BTC/USD price.

  • ReadonlyredeemPreview: (
        chainId: number,
        redeemer: string,
        amount: undefined | bigint,
    ) => readonly ["musd", number, "redeemPreview", string, null | string]

    MK-048. What a single redeemCollateral call will actually redeem, per redeemer and amount.

  • ReadonlyrefinancePreview: (
        chainId: number,
        owner: string,
    ) => readonly ["musd", number, "refinancePreview", string]

    Key for useRefinancePreview: one entry per owner (MK-003).

  • Readonlytrove: (
        chainId: number,
        address: `0x${string}`,
    ) => readonly ["musd", number, "trove", `0x${string}`]

    Query key for a Trove read (shared by useTrove/useHealthFactor/useLiquidationPrice).

  • ReadonlywithdrawCollateralPreview: (
        chainId: number,
        owner: string,
        amount: undefined | bigint,
    ) => readonly [
        "musd",
        number,
        "withdrawCollateralPreview",
        string,
        null
        | string,
    ]

    MK-042. A pure collateral withdrawal of amount, keyed per owner and per amount.