Introduce PSM pallet (part of the pUSD Project)#11068
Introduce PSM pallet (part of the pUSD Project)#11068lrazovic wants to merge 34 commits intoparitytech:masterfrom
Conversation
muharem
left a comment
There was a problem hiding this comment.
Looks good.
One issue I see is that the pallet assumes both pUSD and the external stablecoin share the same decimal precision. The asset pallet does not know the precision. Either we only add assets with the same precision (how we don’t forget this), or we make the pallet aware of the precision and normalize the values.
|
@lrazovic actually I was wrong, there is the metadata inspect trait that fetches the I think we should add the support for assets with different I would snapshot the what you think? |
I agree we could make the PSM generic over assets with different decimal precisions, since the asset owner could technical change the decimals of the asset, but I don’t think that extra complexity is justified for the current scope. The pallet is intended for a small, governance-curated set of stables (e.g. USDC and USDT), so I’d prefer to keep the accounting simple and make the assumption explicit. We can enforce an invariant when adding a new external asset: its decimals must match pUSD decimals, i.e. Another small issue: unfortunately there's no |
|
I will provide |
|
we need prdoc |
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
kianenigma
left a comment
There was a problem hiding this comment.
Can only approve once the minor stuff is addressed, but looks pretty ready to me.
| amount, | ||
| )); | ||
| } | ||
| test(); |
There was a problem hiding this comment.
You should call your do_try_state() here
| /// Whether this level allows modifying per-asset ceiling weights. | ||
| /// Both Full and Emergency levels can set asset ceilings. | ||
| pub const fn can_set_asset_ceiling(&self) -> bool { | ||
| true |
There was a problem hiding this comment.
contradicts with
polkadot-sdk/substrate/frame/psm/src/lib.rs
Line 182 in c4d7de6
also if there only a single external asset, we cannot really change ceiling with set_asset_ceiling_weight. only disable asset by setting 0
Description
This PR introduces
pallet-psm, a new FRAME pallet that implements a Peg Stability Module (PSM) for pUSD. The pallet enables 1:1 swaps between pUSD and approved external stablecoins (e.g. USDC/USDT), with configurable mint/redeem fees and per-asset circuit breakers.The pallet enforces a three-tier debt ceiling model before minting:
MaximumIssuance)MaxPsmDebtOfTotal)AssetCeilingWeight)It also adds cross-pallet interfaces in
frame_support::traits::tokens::stable:VaultsInterface(PSM -> Vaults): query system issuance ceilingPsmInterface(Vaults/others -> PSM): query reserved PSM capacityIntegration
For Runtime Developers
To integrate
pallet-psminto your runtime:Cargo.toml:construct_runtime!:For Pallet Developers
Other pallets can query PSM-reserved issuance capacity via
PsmInterface:This can be used to account for PSM-reserved issuance when computing vault minting headroom.
Review Notes
Key Features
mint(external -> pUSD) andredeem(pUSD -> external)add_external_asset/remove_external_asset)AllEnabled->MintingDisabled->AllDisabledFull: all parameter and asset-management operationsEmergency: can only set circuit breaker statusFeeHandlerFeeHandlerPsmDebt(not just raw reserve), preventing withdrawal of donated reservesSwap Lifecycle
Mint (External -> pUSD):
mint(asset_id, external_amount)FeeHandlerPsmDebt[asset_id]Redeem (pUSD -> External):
redeem(asset_id, pusd_amount)FeeHandlerPsmDebt[asset_id]Governance/Operations
set_minting_feeset_redemption_feeset_max_psm_debtset_asset_ceiling_weightset_asset_statusadd_external_assetremove_external_asset(requires zero debt; cleans up config storage)Config Trait
FungiblesAssetIdVaultsInterfaceManagerOriginPsmManagerLevel(Full/Emergency).WeightInfoStableAssetfungibletype (typicallyItemOf<Assets, StablecoinAssetId>). Must implementFungibleMutate+FungibleBalanced.FeeHandlerOnUnbalancedhandler for fee credits.PalletIdMinSwapAmountMaxExternalAssetsTesting
The pallet includes comprehensive coverage for:
v0 -> v1and skip-when-already-v1)