pub fn mint<T: Config>(
internal_asset: T::AssetId,
external_asset: T::AssetId,
external_amount: <<T as Config>::Fungibles as FungiblesInspect<<T as Config>::AccountId>>::Balance,
max_fee: Permill,
)Expand description
Swap external asset for internal on a specific PSM instance.
§Dispatch Origin
Must be Signed by the user performing the swap.
§Details
Transfers external_amount of external_asset from the caller to the
internal_asset’s PSM reserve account, then mints internal_asset to the
caller minus the minting fee. The fee is calculated using ceiling rounding
(mul_ceil), ensuring the protocol never undercharges. The fee is
transferred to PsmInfo::fee_destination of the targeted instance.
§Parameters
internal_asset: The internal stablecoin that identifies the PSM instance.external_asset: The external asset to deposit (must be approved oninternal_asset).external_amount: Amount of external asset to deposit.max_fee: Maximum minting fee rate accepted by the caller.
§Errors
Error::PsmNotFound: If no PSM is registered forinternal_asset.Error::UnsupportedAsset: Ifexternal_assetis not approved on this PSM.Error::MintingStopped: If the per-external circuit breaker is atMintingDisabledor higher.Error::BelowMinimumSwap: If the internal-equivalent ofexternal_amountis below the instance’smin_swap_amount.Error::FeeTooHigh: If the configured minting fee exceedsmax_fee.Error::ExceedsMaxPsmDebt: If minting would exceed this PSM’s debt ceiling (aggregate or per-asset).Error::DecimalsMismatch: If live decimals diverged from the snapshot taken at registration.Error::AmountTooSmallAfterConversion: If the conversion to the counter-asset rounds to zero; swap would transfer nothing.
§Events
Event::Minted: Emitted on successful mint.
§Warning: Doc-Only
This function is an automatically generated, and is doc-only, uncallable
stub. See the real version in
Pallet::mint.