referrerpolicy=no-referrer-when-downgrade

Crate pallet_psm

Crate pallet_psm 

Source
Expand description

§Peg Stability Module (PSM) Pallet

A module enabling 1:1 swaps between the runtime’s internal stablecoin and pre-approved external stablecoins.

§Pallet API

See the pallet module for more information about the interfaces this pallet exposes, including its configuration trait, dispatchables, storage items, events and errors.

§Terminology

Throughout this pallet two distinct token roles are referenced:

  • Internal — the stablecoin issued and burned by the PSM. It is a single asset configured via Config::InternalAsset (e.g. a runtime’s pUSD). Mint operations credit the user with the internal asset; redeem operations burn it. Fees are collected in the internal asset and forwarded to Config::FeeDestination.
  • External — third-party stablecoins (e.g. USDC, USDT) approved via Pallet::add_external_asset and held in reserve by the PSM. Users deposit external to mint internal, and burn internal to redeem external. Multiple external assets can be approved simultaneously, each identified by asset_id.

§Overview

The PSM strengthens the internal asset’s peg by providing arbitrage opportunities:

  • When the internal asset trades above $1: Users swap external stablecoins for the internal asset and sell for profit
  • When the internal asset trades below $1: Users buy cheap internal asset and swap for external stablecoins

This creates a price corridor bounded by the minting and redemption fees.

§Key Concepts

  • Minting: Deposit external stablecoin → receive internal asset (minus fee)
  • Redemption: Burn internal asset → receive external stablecoin (minus fee)
  • Reserve: External stablecoin balance held by the PSM account (derived, not stored)
  • PSM Debt: Total internal asset minted through PSM, backed 1:1 by external stablecoins
  • Circuit Breaker: Emergency control to disable minting or all swaps

§Supported Assets

The PSM supports multiple pre-approved external stablecoins (e.g., USDC, USDT). Each swap operation specifies which asset to use via the asset_id parameter.

§Fee Structure

  • Minting Fee (MintingFee): Deducted from internal-asset output during minting
  • Redemption Fee (RedemptionFee): Deducted from external stablecoin output during redemption

Fees are collected in the internal asset and transferred to Config::FeeDestination.

§Example

// Mint internal asset by depositing USDC
Psm::mint(RuntimeOrigin::signed(user), USDC_ASSET_ID, 1000 * UNIT)?;

// Redeem USDC by burning the internal asset
Psm::redeem(RuntimeOrigin::signed(user), USDC_ASSET_ID, 1000 * UNIT)?;

Re-exports§

pub use weights::WeightInfo;
pub use pallet::*;

Modules§

migrations
Migrations for the PSM pallet.
pallet
The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.
weights
Autogenerated weights for pallet_psm

Traits§

BenchmarkHelper
Helper trait for benchmark setup.