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 in ExternalAssets)
amount: Amount of internal to redeem
Errors
[Error::UnsupportedAsset]: If asset_id is not an approved external stablecoin
[Error::AllSwapsStopped]: If circuit breaker is at AllDisabled
[Error::BelowMinimumSwap]: If amount is below [Config::MinSwapAmount]
[Error::InsufficientReserve]: If PSM has insufficient external stablecoin
[Error::DecimalsMismatch]: If the asset's decimals do not match the internal asset's
decimals
[Error::AmountTooSmallAfterConversion]: if the conversion to the counter-asset
rounds to zero; swap would transfer nothing
Events
[Event::Redeemed]: Emitted on successful redemption
Swap internal for external stablecoin.
Dispatch Origin
Must be
Signedby the user performing the swap.Details
Burns
amountinternal 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 redeemErrors
Error::UnsupportedAsset]: Ifasset_idis not an approved external stablecoinError::AllSwapsStopped]: If circuit breaker is atAllDisabledError::BelowMinimumSwap]: Ifamountis below [Config::MinSwapAmount]Error::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 nothingEvents
Event::Redeemed]: Emitted on successful redemption