Function pallet_xyk::pallet::dispatchables::sell_asset
source · pub fn sell_asset<T: Config>(
sold_asset_id: CurrencyIdOf<T>,
bought_asset_id: CurrencyIdOf<T>,
sold_asset_amount: BalanceOf<T>,
min_amount_out: BalanceOf<T>
)
Expand description
Executes sell_asset swap. First the swap is prevalidated, if it is successful then the extrinsic is accepted. Beyond this point the exchange commission will be charged. The sold amount of the sold asset is used to determine the bought asset amount. If the bought asset amount is lower than the min_amount_out then it will fail on slippage. The percentage exchange commission is still charged even if the swap fails on slippage. Though the swap itself will be a no-op. The slippage is calculated based upon the sold_asset_amount. Upon slippage failure, the extrinsic is marked “successful”, but an event for the failure is emitted
Args:
sold_asset_id
- The token being soldbought_asset_id
- The token being boughtsold_asset_amount
: The amount of the sold token being soldmin_amount_out
- The minimum amount of bought asset that must be bought in order to not fail on slippage. Slippage failures still charge exchange commission.
Warning: Doc-Only
This function is an automatically generated, and is doc-only, uncallable
stub. See the real version in
Pallet::sell_asset
.