pub fn redeem<T: Config>(
asset_id: T::AssetId,
amount: <<T as Config>::Fungibles as FungiblesInspect<<T as Config>::AccountId>>::Balance,
)Expand description
Swap internal for external stablecoin.
§Dispatch Origin
Must be Signed by the user performing the swap.
§Details
Burns amount internal from the caller minus fee (transferred to
Config::FeeDestination), then transfers the resulting amount in external
stablecoin from PSM to the caller. The fee is calculated using ceiling rounding
(mul_ceil), ensuring the protocol never undercharges.
§Parameters
asset_id: The external stablecoin to receive (must be inExternalAssets)amount: Amount of internal to redeem
§Errors
Error::UnsupportedAsset: Ifasset_idis not an approved external stablecoinError::AllSwapsStopped: If circuit breaker is atAllDisabledError::BelowMinimumSwap: Ifamountis belowConfig::MinSwapAmountError::InsufficientReserve: If PSM has insufficient external stablecoinError::DecimalsMismatch: If the asset’s decimals do not match the internal asset’s decimalsError::AmountTooSmallAfterConversion: if the conversion to the counter-asset rounds to zero; swap would transfer nothing
§Events
Event::Redeemed: Emitted on successful redemption
§Warning: Doc-Only
This function is an automatically generated, and is doc-only, uncallable
stub. See the real version in
Pallet::redeem.