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.
- Address: 0xA188EEC8F81263234dA3622A406892F3D630f98c
- Source: sky-ecosystem/usds-wrappers (
UsdsPsmWrapper.sol) - Audit: ChainSecurity MakerDAO USDS Wrappers audit
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).maxindicates the sell direction is halted.tout: buy-gem fee in WAD.type(uint256).maxindicates 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 equalsgem.balanceOf(pocket).vow: Maker Vow address where collected fees are sent onchug().to18ConversionFactor: constant10^12, scales USDC (6 decimals) to WAD.HALTED:type(uint256).max, exposed for compatibility.live: returnsvat.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:
usdsOutin 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:
usdsInin 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. Withtout = 0, this simplifies togemAmt * 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 transfergemAmtUSDC 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.
- Address: 0xf6e72Db5454dd049d0788e411b06CfAF16853042
- Source: sky-ecosystem/dss-lite-psm (
DssLitePsm.sol) - Audits: dss-lite-psm audits directory
The core exposes a DAI-denominated surface (sellGem, buyGem, sellGemNoFee, buyGemNoFee) with the same semantics as the wrapper, plus three permissionless bookkeeping functions:
fill()— mintsrush()DAI from the Maker Vat into the PSM, bounded by the target debt calculation and the local/global debt ceilings.trim()— burnsgush()DAI and repays Vat debt when the PSM has excess debt or needs to reduce debt against its target.chug()— sweepscut()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.
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)—valueis USDC sold (6 decimals),feeis DAI fee retained (WAD).BuyGem(address indexed owner, uint256 value, uint256 fee)—valueis USDC bought (6 decimals),feeis 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);
}