pub fn buy_asset<T: Config>(
    sold_asset_id: CurrencyIdOf<T>,
    bought_asset_id: CurrencyIdOf<T>,
    bought_asset_amount: BalanceOf<T>,
    max_amount_in: BalanceOf<T>
)
Expand description

Executes buy_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 bought of the bought asset is used to determine the sold asset amount. If the sold asset amount is higher than the max_amount_in 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 sold
  • bought_asset_id - The token being bought
  • bought_asset_amount: The amount of the bought token being bought
  • max_amount_in - The maximum amount of sold asset that must be sold 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::buy_asset.