APX Finance
  • 🚀What is APX Finance?
  • 🌙Brand Logo & Guidelines
  • Welcome
    • 📄$APX Token & Contracts
      • ⚡Allocation
      • 🔥Token Burn
      • 💲Tax
    • 💎ALP Liquidity Pool
      • 💡How to buy ALP?
      • 💡How to stake/unstake?
      • 💡How to sell?
      • 💡Fees for buying and selling ALP
      • ‼️Risk
    • ⛓️Trading on V2
      • ❓How does it work?
      • ⬇️How to interact directly with the contract
      • 🤝Powered by Pyth Oracle and Chainlink
      • 🐸Degen Trading Mode
        • 💰Dynamic close fee for Degen Mode
      • 🎰V2 Fees & Slippage
      • 💢MAD perpetual contracts
        • 💢MADBTCUSD
          • Index Details
        • 💢MADETHUSD
          • Index Details
        • 💢MADCAKEUSD
          • Index Details
      • 😎Dumb Mode
        • How to place orders
      • 📃DEGEN Inscriptions Airdrop
      • 📈Forex
      • 👥APX V2 Referral
      • 📖APX Testnet Walk through [Inactive]
      • 💡FAQ
        • 💡Connect wallet
        • 💡Opening a position
        • 💡How to place stop orders?
        • 💡Position management
        • 💡One click close all position feature
        • 💡Order Types
      • 📹Video Tutorials (V2)
    • 👋Trading on V1
      • 📡Pre-Launch Markets
        • BLAST Pre-Launch Futures
      • 💰Wallet Connection
      • 💡How to start trading on APX V1?
        • 💸Deposit & Withdrawal
        • 🪜Margin Mode & Leverage
        • ⬆️Position Mode
        • 💻Order Types
          • TP/SL orders (Strategy Order)
          • Trailing Stop Order
        • 🛑Closing Positions
        • 📈Grid Trading
          • 👾Set-up Your Grid Trading Strategy
          • 👾Futures Grid Trading Auto Parameters Guide
          • 👾Long/Short Grid Trading introduction
        • 💡Lite Mode
      • ❓FAQ
        • ❓Multi-Assets Mode
        • ❓How to Adjust the Margin Balance in Cross/Isolated Margin Modes
        • ❓How to Calculate the Cost of Opening a USDⓈ-M Perpetual Futures Contract Position
        • ❓Mark Price in USDⓈ-M Perpetual Futures Contracts
        • ❓Funding Rate
        • ❓Auto-Deleveraging (ADL)
        • ❓APX Futures Liquidation Protocol
        • ❓Delisting Process of A Futures Contract
        • ❓APX DEX Referral Guidelines
        • ❓How to Whitelist APX Emails?
      • 📹Video Tutorial (V1)
  • Features & Tutorials
    • ℹ️General
      • 💡What is Gas Fee?
      • 💡How to switch network?
      • 💡How to change language
      • 💡How to bind your social media account to receive notifications
    • 🖥️All about APX Web
      • 💡How to Connect Your Wallet? (Web version)
      • 💡How to find your DEX UID? (Web)
    • ⛓️Permissionless DEX Engine
      • Features and benefits of permissionless solution
      • FAQs
    • 👾Trading
      • 💡How to Buy Crypto on APX DEX via BANXA
      • 💡How to check your balance (V1)
      • 💡How to use Multi-Assets Mode
      • 💡How-to Guide: Use BONUSUSD to trade crypto futures on APX V1
  • Programs
    • 📞V2 ARB Incentive Season (Trading)
    • 📣V2 ARB Incentive Season (Weekly Bonus, ALP Staking)
    • 💰$100,000 Binance Web3 Wallet Trading Campaign Tutorial
    • 🪂Strategic Partnership with Lista DAO - Cosmic Adventure Challenge
    • 📏V2 Trading Rewards
    • ⛏️Retroactive Mining Rewards
  • APX DAO
    • 👨‍🚀How To Participate?
    • 📫DAO Staking
      • 🎫Get Voting Power
      • ⚡Staking Rewards & Repurchased Tokens
      • ⚡Trading Benefits
      • ⚡Penalty Fee
    • 🍀Governance
      • 🌡️Temperature Check
      • 🤚Standards for raising DAO proposals
  • API
    • 🖱️Create API
    • 💾API Documentation
  • Community
    • 🔗Social Media & Communities
  • About Us
    • 🗺️Roadmap
      • 🍁2023 Roadmap
      • 🍁2022 Milestones
      • 🍁2021-2022 Roadmap
    • 🔖Audit Reports
    • APX Team
    • Privacy Policy
    • Terms of Use
    • Restriction
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 user’s position information
  • 4. How to check 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
  • Attachment
  1. Welcome
  2. Trading on V2

How to interact directly with the contract

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 100USDT to place a pending order for a BTC Long position with Price: 20000 Qty: 0.001, and the take profit price is 25000, and the stop loss price is 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 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 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

Decimals Rules Summary Margin Amount Decimals: USDT:1e18 USDC:1e18 Price Decimal:1e8 Contract Qty Decimal:1e10

Attachment

1.ABI

2.The Ethereum Diamond Inspector Link

3.Index Price API

PreviousHow does it work?NextPowered by Pyth Oracle and Chainlink

Last updated 1 year ago

Users could real time price through

Link UrL:

⛓️
⬇️
https://www.apollox.com/fapi/v1/premiumIndex
https://api.thegraph.com/subgraphs/name/apollx-apx/apollox-perp-bnb
https://www.apollox.finance/fapi/v1/premiumIndex
LogoLouper - The Ethereum Diamond Inspector
126KB
Apollox V2 ABI.rtf