The createMusdClient surface: live reads, preview math, hints, lifecycle writes, and the redemption/keeper functions, all bound to one chain + clients.

interface MusdClient {
    addresses: MusdAddresses;
    chainId: number;
    contracts: MusdContracts;
    fixed: {
        CCR: 1500000000000000000n;
        DECIMAL_PRECISION: 1000000000000000000n;
        MCR: 1100000000000000000n;
        MIN_NET_DEBT_MIN: 50000000000000000000n;
        MUSD_GAS_COMPENSATION: 200000000000000000000n;
        ONE_HUNDRED_PCT: 1000000000000000000n;
        PERCENT_DIVISOR: 200n;
    };
    addCollateral(params: { amount: bigint }): Promise<WriteResult>;
    adjustTrove(params: AdjustTroveParams): Promise<WriteResult>;
    balanceOf(address: `0x${string}`): Promise<bigint>;
    batchLiquidate(borrowers: readonly `0x${string}`[]): Promise<WriteResult>;
    borrow(params: BorrowParams): Promise<WriteResult>;
    claim(): Promise<ClaimResult>;
    close(): Promise<WriteResult>;
    computeEntireDebt(params: ComputeEntireDebtParams): bigint;
    computeHints(params: ComputeHintsParams): Promise<Hints>;
    computeICR(params: ComputeICRParams): bigint;
    computeLiquidationPrice(params: ComputeLiquidationPriceParams): bigint;
    computeNICR(params: ComputeNICRParams): bigint;
    getBorrowingFee(debt: bigint): Promise<bigint>;
    getBorrowingPower(params: GetBorrowingPowerParams): Promise<bigint>;
    getClaimableCollateral(address: `0x${string}`): Promise<bigint>;
    getConstants(): Promise<MusdConstants>;
    getHealthFactor(params: { icr: bigint }): number;
    getOraclePrice(): Promise<bigint>;
    getSystemState(): Promise<SystemState>;
    getTrove(address: `0x${string}`): Promise<Trove>;
    isLiquidatable(address: `0x${string}`): Promise<boolean>;
    liquidate(borrower: `0x${string}`): Promise<WriteResult>;
    openTrove(params: OpenTroveParams): Promise<WriteResult>;
    previewOpen(params: PreviewOpenParams): Promise<OpenPreview>;
    redeem(params: RedeemParams): Promise<RedeemResult>;
    refinance(): Promise<WriteResult>;
    repay(params: { amount: bigint }): Promise<WriteResult>;
    verifyDeployment(): Promise<void>;
    withdrawCollateral(params: { amount: bigint }): Promise<WriteResult>;
}

Properties

addresses: MusdAddresses
chainId: number
contracts: MusdContracts
fixed: {
    CCR: 1500000000000000000n;
    DECIMAL_PRECISION: 1000000000000000000n;
    MCR: 1100000000000000000n;
    MIN_NET_DEBT_MIN: 50000000000000000000n;
    MUSD_GAS_COMPENSATION: 200000000000000000000n;
    ONE_HUNDRED_PCT: 1000000000000000000n;
    PERCENT_DIVISOR: 200n;
}

The bundled fixed constants (synchronous, no network).

Methods

  • BTC surplus claimable by address (CollSurplusPool), pair with claim().

    Parameters

    • address: `0x${string}`

    Returns Promise<bigint>

  • Defense-in-depth: read MCR/CCR from the chain and assert they equal the bundled fixed constants. Cached after the first success.

    Returns Promise<void>