MCDEX
Search…
MCDEX
Overview
Protocol
Mai Protocol V3
V3 AMM Design
Tunable Oracle
Audits
DAO
MCDEX DAO
MCB Tokenomics
Developer
Mai3 Contracts
Quick Start
Get Pool Info
Get Perpetual Info
Get Account
Adding Margin
Removing Margin
Trade
Adding Liquidity
Removing Liquidity
Liquidate
Mai3 SDK
Mai3 Subgraph
Deployed Contracts
Bug Bounty
Trader
Basis Trading
LP Hedging
Powered By
GitBook
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
Previous
Removing Margin
Next
Adding Liquidity
Last modified
5mo ago
Copy link
Contents
QueryTrade
Function
Example
Execute Trade
Function
Example
Sample Code