Aster
  • OVERVIEW
    • What is Aster?
      • How to connect your wallet
      • Our smart contracts
  • Rewards Hub
  • PRODUCT
    • Product releases
    • AsterEX Pro
      • Pro fees
      • Margin
        • Calculating max transfers in Cross and Isolated margin
      • Mark price
      • Liquidations
      • Funding rate
      • Single asset mode & Multi-asset mode
      • Order types
      • Trailing Stop Order
      • Open Cost calculation
      • Grid Trading
        • Set-up Your Grid Trading Strategy
        • Futures Grid Trading Auto Parameters Guide
        • Long/Short Grid Trading introduction
      • VIP & MM program
        • Market maker requirement
      • ADL
      • Deposit/Withdraw Guide
      • Referral program
      • API
        • How to create API
        • API document
      • Delisting of a perps contract
    • AsterEX Simple
      • Leverage
      • Price oracles
      • Fees & slippage
      • Degen Trading Mode
      • Dumb mode
      • Manage your positions
      • Order types
      • Interact with the contract directly
    • Aster Earn
      • Mint asBNB
      • Mint asCAKE
      • Mint asUSDF
      • Mint asBTC
      • Aster ALP
        • How to mint ALP?
        • How to burn ALP?
        • ALP Fees
      • Ecosystem
        • PancakeSwap
          • LP on PancakeSwap
        • Pendle
          • asUSDF on Pendle
          • asBNB on Pendle
          • USDF on Pendle
          • How to calculate Au points for LP and YT
          • How to transfer liquidity to new pool
        • Tranchess
        • Restaking
        • Yield Strategies
    • USDF Stablecoin
      • Situating USDF in the Stablecoin Landscape
      • How USDF Works
      • Maintaining the Peg
      • Fund Custody & Risk Management
      • FAQs
      • Tutorials
    • AsterLayer
    • Help
  • Stage 1: Spectra
    • Aster Spectra: Stage 1
    • Mint to Earn Au
    • Au Trader Boost
    • Trade like a Pro, Earn like a Pro
    • Treasure Boost Campaign
    • Referral Bonus & Team Boosts
  • Brand & Community
    • Aster Media Kit
    • Official links
  • About us
    • Audit Reports
    • AsterDEX – Terms & Conditions
    • AsterDEX – Privacy Policy
Powered by GitBook
On this page
  • 1. How to open a position at the opening price
  • 2. How to place a limit order
  • 3. How to check a user’s position information
  • 4. How to check an open order
  • 5. How to close a position
  • 6. How to add margin
  • 7. How to adjust Take Profit and Stop Loss price
  • 8. How to cancel the Limit order
  • Resources
  1. PRODUCT
  2. AsterEX Simple

Interact with the contract directly

For Simple mode

Some users interact directly with the contract for full control, automation, or when the app interface is unavailable or limited.

How to get trading pair information

  • Contract address: 0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0

  • Method: ParisV3

Response:

  struct LeverageMargin {
        uint256 notionalUsd;
        uint16 tier;
        uint16 maxLeverage;
        uint16 initialLostP; // 1e4
        uint16 liqLostP;     // 1e4
    }

    struct SlippageConfig {
        string name;
        uint256 onePercentDepthAboveUsd;
        uint256 onePercentDepthBelowUsd;
        uint16 slippageLongP;       // 1e4
        uint16 slippageShortP;      // 1e4
        uint16 index;
        ISlippageManager.SlippageType slippageType;
        bool enable;
    }

    struct FeeConfig {
        string name;
        uint16 index;
        uint16 openFeeP;     // 1e4
        uint16 closeFeeP;    // 1e4
        bool enable;
        uint24 shareP;       // 1e5
        uint24 minCloseFeeP; // 1e5
    }

    struct PairView {
        // BTC/USD
        string name;
        // BTC address
        address base;
        uint16 basePosition;
        PairType pairType;
        PairStatus status;
        uint256 maxLongOiUsd;
        uint256 maxShortOiUsd;
        uint256 fundingFeePerBlockP;  // 1e18
        uint256 minFundingFeeR;       // 1e18
        uint256 maxFundingFeeR;       // 1e18

        LibPairsManager.LeverageMargin[] leverageMargins;

        uint16 slippageConfigIndex;
        uint16 slippagePosition;
        LibPairsManager.SlippageConfig slippageConfig;

        uint16 feeConfigIndex;
        uint16 feePosition;
        LibFeeManager.FeeConfig feeConfig;

        uint40 longHoldingFeeRate;    // 1e12
        uint40 shortHoldingFeeRate;   // 1e12
  }

1. How to open a position at the opening price

  • Contract address: 0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0

  • Method: openMarketTrade

  • Parameters: data (tuple) Tuple: A tuple is an array of values e.g. [ "0x4sd…","100","100"..]. It can contain strings, integers, and boolean values. The structure for this tuple is:

struct OpenDataInput {
        // Pair.base
        address pairBase;
        bool isLong;
        // BUSD/USDT address
        address tokenIn;
        uint256 amountIn;   // tokenIn decimals
        uint256 qty;        // 1e10
        // Limit Order: limit price
        // Market Trade: worst price acceptable
        uint256 price;      // 1e8
        uint256 stopLoss;   // 1e8
        uint256 takeProfit; // 1e8
        uint256 broker;
    }

Example: If the user wants to use 100 USDT to place a pending order for a BTC Long position with Price 20000, Quantity 0.001, Take Profit Price 25000, and Stop Poss price 19000, the inPutData should be:["0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c","True","0x55d398326f99059fF775485246999027B3197955","100000000000000000000","10000000",,"2000000000000"2500000000000","1900000000000",1]

2. How to place a limit order

  • Contract address: 0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0

  • Method: createLimitOrder(

  • Parameters: data (tuple)

struct OpenDataInput {
        // Pair.base
        address pairBase;
        bool isLong;
        // BUSD/USDT address
        address tokenIn;
        uint256 amountIn;   // tokenIn decimals
        uint256 qty;        // 1e10
        // Limit Order: limit price
        // Market Trade: worst price acceptable (acceptable price=index Price*(1+/- spread)
        uint256 price;      // 1e8
        uint256 stopLoss;   // 1e8
        uint256 takeProfit; // 1e8
        uint256 broker;
    }

3. How to check a user’s position information

query OrderAndTradeHistorys {
    orderAndTradeHistories(
        skip: 0
        first: 1000
        orderBy: timestamp
        orderDirection: desc
        where: { user: "0x04e5fe43af1306e5fc2d4b0f9daa04d3a587b28f" }
    ) {
        id
        orderOrTradeHash
        actionType
        timestamp
        marginIncrement
        txHash
        limitOrder {
            id
            pair {
                name
            }
            isLong
            token {
                symbol
            }
            amountIn
            limitPrice
            qty
            takeProfit
            stopLoss
        }
        trade {
            id
            pair {
                name
            }
            isLong
            token {
                symbol
            }
            margin
            entryPrice
            qty
            openFee
            executionFee
            closeType
            closePrice
            closeFee
            fundingFee
            holdingFee
            pnl
            actualPnl
            broker {
                name
            }
        }
        user {
            id
        }
    }
}

4. How to check an open order

  • Contract address: 0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0

  • Method: getLimitOrders

Parameters:

  • User: address

  • Pairs: 0x0000000000000000000000000000000000000000

Response:

struct Position {

5. How to close a position

Contract address: 0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0

Method: closeTrade

Parameters:

bytes32 tradeHash

6. How to add margin

  • Contract address: 0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0

  • Method: addMargin

Parameters:

  bytes32 tradeHash;
    unit256 amount;   // 1e10

7. How to adjust Take Profit and Stop Loss price

  • Contract address: 0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0

  • Method: updateTradeTpAndSl

Parameters:

bytes32 tradeHash;
    unit256 stopLossPrice;     // 1e8
    unit256 takeProfitPrice;   // 1e8

8. How to cancel the Limit order

  • Contract address: 0x1b6f2d3844c6ae7d56ceb3c3643b9060ba28feb0

  • Method: cancelLimitOrder

Parameters:

bytes32 tradeHash

Margin amount decimals:

  • USDT: 1e18

  • USDC: 1e18

  • Price decimal: 1e8

  • Contract qty decimal: 1e10

Resources

  • ABI:

PreviousOrder typesNextAster Earn

Last updated 6 days ago

The Ethereum Diamond Inspector:

Index price API:

https://louper.dev/diamond/0x1b6F2d3844C6ae7D56ceb3C3643b9060ba28FEb0?network=bsc
https://www.apollox.finance/fapi/v1/premiumIndex
126KB
AsterEX ABI.rtf