Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Contract Reference

UsdsPsmWrapper (USDS-USDC)

The integrator-facing contract. Presents a USDS interface and routes through the underlying DAI LitePSM plus Maker's DAI and USDS join adapters.

State Getters

  • psm: address of the underlying LitePSM-DAI-USDC.
  • dai: backwards-compatibility getter that returns the USDS token address, not DAI.
  • usds: address of USDS.
  • gem: address of USDC (the "gem" token).
  • usdsJoin: Maker USDS join adapter used by the wrapper.
  • vat: Maker Vat address, exposed through the wrapper.
  • gemJoin: backwards-compatibility getter that returns the wrapper address itself.
  • dec: USDC decimals, exposed for compatibility.
  • ilk: collateral type identifier copied from the underlying core PSM.
  • tin: sell-gem fee in WAD. type(uint256).max indicates the sell direction is halted.
  • tout: buy-gem fee in WAD. type(uint256).max indicates the buy direction is halted.
  • buf: target DAI buffer maintained by the core PSM, in WAD.
  • pocket: immutable address holding USDC custody. Buy-side liquidity equals gem.balanceOf(pocket).
  • vow: Maker Vow address where collected fees are sent on chug().
  • to18ConversionFactor: constant 10^12, scales USDC (6 decimals) to WAD.
  • HALTED: type(uint256).max, exposed for compatibility.
  • live: returns vat.live(); it is not a wrapper-owned pause flag.

Write Functions

sellGem(address usr, uint256 gemAmt) → uint256 usdsOut

Swaps USDC for USDS.

  • Inputs:
    • usr — recipient of the USDS.
    • gemAmt — USDC amount to sell, in 6-decimal units.
  • Return: usdsOut in WAD.
  • Approval required: caller must approve(wrapper, gemAmt) on USDC before calling.
  • Reverts when tin == type(uint256).max (sell direction halted), when the caller has not approved enough USDC, or when the core PSM's external DAI balance is insufficient for the USDS output.

buyGem(address usr, uint256 gemAmt) → uint256 usdsIn

Swaps USDS for USDC.

  • Inputs:
    • usr — recipient of the USDC.
    • gemAmt — USDC amount to receive, in 6-decimal units.
  • Return: usdsIn in WAD (the USDS amount the caller is required to provide).
  • Approval required: caller must approve(wrapper, gemAmt * 10^12 * (WAD + tout) / WAD) on USDS before calling. With tout = 0, this simplifies to gemAmt * 10^12.
  • Reverts when tout == type(uint256).max (buy direction halted), when the caller has not approved enough USDS, or when the core PSM cannot transfer gemAmt USDC from the pocket.

LitePSM-DAI-USDC (Core)

The core DAI-denominated LitePSM that the wrapper delegates to. Integrators do not normally need to call this directly. It is documented here for completeness and for keeper integrations.

The core exposes a DAI-denominated surface (sellGem, buyGem, sellGemNoFee, buyGemNoFee) with the same semantics as the wrapper, plus three permissionless bookkeeping functions:

  • fill() — mints rush() DAI from the Maker Vat into the PSM, bounded by the target debt calculation and the local/global debt ceilings.
  • trim() — burns gush() DAI and repays Vat debt when the PSM has excess debt or needs to reduce debt against its target.
  • chug() — sweeps cut() accumulated fees to the Maker Vow.

The HALTED sentinel for both tin and tout is type(uint256).max. When set, the corresponding sellGem / buyGem reverts. The emergency halt is performed by the DssLitePsmMom contract on behalf of Sky governance.

The no-fee variants (sellGemNoFee, buyGemNoFee) are gated by a bud whitelist set by governance and are not generally available to integrators.

Pocket

The USDC custody address. The core LitePSM holds a max allowance to transfer USDC from this address during buyGem. The pocket address is immutable in the deployed core PSM.

Events

Emitted by the core LitePSM:

  • SellGem(address indexed owner, uint256 value, uint256 fee)value is USDC sold (6 decimals), fee is DAI fee retained (WAD).
  • BuyGem(address indexed owner, uint256 value, uint256 fee)value is USDC bought (6 decimals), fee is DAI fee retained (WAD).
  • Fill(uint256 wad) — DAI minted into the core PSM (WAD).
  • Trim(uint256 wad) — DAI burned from the core PSM (WAD).
  • Chug(uint256 wad) — DAI swept to the Vow (WAD).

ABI Snippet

interface IUsdsPsmWrapper {
    // Swaps
    function sellGem(address usr, uint256 gemAmt) external returns (uint256 usdsOut);
    function buyGem(address usr, uint256 gemAmt)  external returns (uint256 usdsIn);
 
    // State
    function psm() external view returns (address);
    function dai() external view returns (address); // compatibility getter; returns USDS
    function usds() external view returns (address);
    function gem() external view returns (address);
    function usdsJoin() external view returns (address);
    function vat() external view returns (address);
    function ilk() external view returns (bytes32);
    function pocket() external view returns (address);
    function dec() external view returns (uint256);
    function gemJoin() external view returns (address);
 
    // Forwarded from core PSM
    function tin()    external view returns (uint256);
    function tout()   external view returns (uint256);
    function buf()    external view returns (uint256);
    function vow()    external view returns (address);
    function live()   external view returns (uint256);
    function HALTED() external view returns (uint256);
    function to18ConversionFactor() external view returns (uint256);
}