dotmx logo

API Documentation

Advanced integrations and direct contract calls. Examples show parameter encodings, decimals, and GraphQL lookups for common integration tasks.

Contract Integration

The contract exposes pair metadata, order and trade entry points, and administrative configs. Below are the commonly used methods and the parameter shapes for direct interaction (ethers.js / web3).

Contract Address

BSC Mainnet
0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0
DiamondProxy
📈

Open Market Trade

Method: openMarketTrade

Send a tuple matching OpenDataInput. For market fills supply a worst acceptable price.

View parameters & example
struct OpenDataInput {
  address pairBase;
  bool isLong;
  address tokenIn;
  uint256 amountIn; // token decimals
  uint256 qty;      // 1e10
  uint256 price;    // 1e8
  uint256 stopLoss; // 1e8
  uint256 takeProfit;//1e8
  uint256 broker;
}

Example tuple:
["0x7130...ead9c", true, "0x55d3...7955", "100000000000000000000", "10000000", "2000000000000", "1900000000000", "2500000000000", 1]
📋

Limit Order

Method: createLimitOrder

Same OpenDataInput tuple — use price as the limit price. Limit orders are stored and executed by background processes.

🔒

Close Trade

Method: closeTrade

Pass the bytes32 tradeHash to close a trade from the caller's perspective.

⚙️

Manage Trade

Methods: addMargin, updateTradeTpAndSl

Add margin (amount in 1e10 units), update TP/SL (prices in 1e8), or cancel limit orders by hash.

Response Structures

Compact reference of the important fields returned by contract methods.

📋

PairView Struct

Solidity
struct PairView {
  string name; // BTC/USD
  address base;
  uint16 basePosition;
  PairType pairType;
  PairStatus status;
  uint256 maxLongOiUsd;
  uint256 maxShortOiUsd;
  uint256 fundingFeePerBlockP; // 1e18
  LibPairsManager.LeverageMargin[] leverageMargins;
  LibPairsManager.SlippageConfig slippageConfig;
  LibFeeManager.FeeConfig feeConfig;
}

GraphQL Integration

Fetch user order and trade history via our subgraph endpoints for comprehensive data analysis.

🔍

Query Example

GraphQL
query OrderAndTradeHistorys {
  orderAndTradeHistories(
    skip: 0
    first: 1000
    orderBy: timestamp
    orderDirection: desc
    where: { user: "0x04e5...b28f" }
  ) {
    id
    orderOrTradeHash
    actionType
    timestamp
    limitOrder { id pair { name } isLong token { symbol } amountIn limitPrice qty }
    trade { id pair { name } isLong token { symbol } entryPrice qty pnl }
  }
}

Decimals & Conventions

Important decimal precision standards used throughout the contract system.

💰

Margin Decimals

1e18

USDT / USDC margin amounts

💲

Price Decimals

1e8

All price values and oracle feeds

📊

Quantity Decimals

1e10

Contract quantity amounts

Developer Resources

Documentation

Perpetuals overview
Local ABI file (in repo)

⚠️Important Notes

  • • Always double-check decimals when building amounts
  • • Market calls accept a worst price to protect against slippage
  • • Test with small amounts on testnet before mainnet deployment