MCDEX
Search…
Trade
This guild shows how to trade by using the ILiquidityPoolFull interface and estimated amount out for a trade, then execute a trade.

QueryTrade

Function

Can reference mai3-sdk/trade for learn more about queryTrade

Example

WARN: before calling queryTrade(), need to sync the state by using the forceToSyncState function.
1
ILiquidityPoolFull liquidityPool = ILiquidityPoolFull(liquidityPoolAddress)
2
liquidityPool.forceToSyncState()
3
(tradePrice, totalFee, cost) = liquidityPool.queryTrade(perpetualIndex, address(this), position, referrer, flags)
Copied!

Execute Trade

Function

Can reference mai3-sdk/trade for learn more about trade

Example

1
ILiquidityPoolFull liquidityPool = ILiquidityPoolFull(liquidityPoolAddress)
2
tradeAmount = liquidityPool.trade(perpetualIndex, address(this), amount, limitPrice, deadline, referrer, flags)
Copied!

Sample Code

Github
Last modified 14d ago