Calls
addLiquidity
Add liquidity to Enabled trading pair, or add provision to Provisioning trading pair.- Add liquidity success will issue shares in current price which decided by the liquidity scale. Shares are temporarily not allowed to transfer and trade, it represents the proportion of assets in liquidity pool.
- Add provision success will record the provision, issue shares to caller in the initial price when trading pair convert to Enabled.
- Creates and enables TradingPair LP token if it does not exist for trading pair.
-
Fails to add liquidity for
NotEnabled
trading pair. -
token_a
: Asset id A. -
token_b
: Asset id B. -
amount_a_desired
: amount a desired to add. -
amount_b_desired
: amount b desired to add. -
amount_a_min
: amount a minimum willing to add. -
amount_b_min
: amount b minimum willing to add. -
to
: The recipient of the LP token. The caller is the default recipient if it is set to None. -
deadline
: The deadline of executing this extrinsic. The deadline won’t be checked if it is set to None
disableTradingPair
Disable anEnabled
trading pair.
-
Requires LP token to be created and in the
Enabled
status - Only root can disable trading pair
-
token_a
: Asset id A. -
token_b
: Asset id B.
reenableTradingPair
Re enable aNotEnabled
trading pair.
-
Requires LP token to be created and in the
NotEnabled
status - Only root can enable a disabled trading pair
-
token_a
: Asset id A. -
token_b
: Asset id B.
removeLiquidity
Remove liquidity from specific liquidity pool in the form of burning shares, and withdrawing currencies in trading pairs from liquidity pool in proportion, and withdraw liquidity incentive interest.-
note: liquidity can still be withdrawn for
NotEnabled
trading pairs. -
token_a
: Asset id A. -
token_b
: Asset id B. -
liquidity
: liquidity amount to remove. -
amount_a_min
: minimum amount of asset A to be withdrawn from LP token. -
amount_b_min
: minimum amount of asset B to be withdrawn from LP token. -
to
: The recipient of the withdrawn token assets. The caller is the default recipient if it is set to None. -
deadline
: The deadline of executing this extrinsic. The deadline won’t be checked if it is set to None
setFeeTo
Set theFeeTo
account. This operation requires root access.
-
note: analogous to Uniswapv2
setFeeTo
-
fee_to
: the new account or None assigned to FeeTo.
swapWithExactSupply
Trading with DEX, swap with exact supply amount. Specify your input; retrieve variable output.-
note: analogous to Uniswapv2
swapExactTokensForTokens
-
path
: trading path. -
amount_in
: exact supply amount. -
amount_out_min
: acceptable minimum target amount. -
to
: The recipient of the swapped token asset. The caller is the default recipient if it is set to None. -
deadline
: The deadline of executing this extrinsic. The deadline won’t be checked if it is set to None
swapWithExactTarget
Trading with DEX, swap with exact target amount. Specify your output; supply variable input.-
note: analogous to Uniswapv2
swapTokensForExactTokens
-
amount_out
: exact target amount. -
amount_in_max
: acceptable maximum supply amount. -
path
: trading path. -
to
: The recipient of the swapped token asset. The caller is the default recipient if it is set to None. -
deadline
: The deadline of executing this extrinsic. The deadline won’t be checked if it is set to None
Storage
feeTo
FeeTo account where network fees are deposited NamespaceliquidityPool
NamespaceliquidityPoolLastK
NamespacetradingPairLPToken
NamespacetradingPairStatuses
NamespaceEvents
AddLiquidity
Add liquidity success. [who, asset_id_0, reserve_0_increment, asset_id_1, reserve_1_increment, share_increment, to] NamespaceAddProvision
Add provision success. [who, asset_id_0, contribution_0, asset_id_1, contribution_1] NamespaceDisableTradingPair
Disable trading pair. [trading_pair] NamespaceEnableTradingPair
Enable trading pair. [trading_pair] NamespaceFeeToSet
Set FeeTo account success. [fee_to] NamespaceProvisioningToEnabled
Provisioning trading pair convert to Enabled. [trading_pair, pool_0_amount, pool_1_amount, total_share_amount] NamespaceRemoveLiquidity
Remove liquidity from the trading pool success. [who, asset_id_0, reserve_0_decrement, asset_id_1, reserve_1_decrement, share_decrement, to] NamespaceSwap
Use supply Asset to swap target Asset. [trader, trading_path, supply_Asset_amount, target_Asset_amount, to] NamespaceErrors
ExcessiveSupplyAmount
Supply amount is more than max_supply_amount NamespaceExpiredDeadline
The deadline has been missed NamespaceIdenticalTokenAddress
NamespaceInsufficientAmount
Insufficent amount NamespaceInsufficientAmountA
Insufficient asset_a liquidity amount NamespaceInsufficientAmountB
Insufficient asset_b liquidity amount NamespaceInsufficientInputAmount
Insufficient input amount NamespaceInsufficientLiquidity
Liquidity is not enough NamespaceInsufficientLiquidityBurnt
Insufficient liquidity burnt NamespaceInsufficientOutputAmount
Insufficient output amount NamespaceInsufficientTargetAmount
Target amount is less to min_target_amount NamespaceInsufficientWithdrawnAmountA
Insufficient withdraw amount for token A NamespaceInsufficientWithdrawnAmountB
Insufficient withdraw amount for token B NamespaceInvalidAssetId
Invalid Asset id NamespaceInvalidConstantProduct
Invalid constant product K NamespaceInvalidInputAmounts
Must provide non-zero amount of liquidity NamespaceInvalidLiquidityIncrement
The increment of liquidity is invalid NamespaceInvalidTradingPathLength
Invalid trading path length NamespaceLiquidityProviderTokenNotCreated
The Liquidity Provider token does not exist NamespaceMustBeEnabled
Trading pair must be in Enabled status NamespaceMustBeNotEnabled
Trading pair must be in NotEnabled status NamespaceZeroSupplyAmount
The supply amount is zero NamespaceZeroTargetAmount
The target amount is zero NamespaceConstants
defaultFeeTo
The default FeeTo account NamespacedexBurnPalletId
The DEX’s burn id, to provide for a redundant, unredeemable minter/burner address. NamespacegetExchangeFee
Trading fee rate The first item of the tuple is the numerator of the fee rate, second item is the denominator, fee_rate = numerator / denominator, use (u32, u32) overRate
type to minimize internal division operation.
Namespace