Skip to content

Orders Contract Interface

0xB87196E95A7C38192D57087D54b3a5F996D17F1A

Orders.sol manages open trades, limit orders, and stores user funds.

getOpenTrade

solidity
function getOpenTrade(uint256 tradeIndex) external view returns (Trade memory)

Retrieves an open trade for a given trade index.

Parameters

NameTypeDescription
tradeIndexuint256The index of the trade.

Returns

TypeDescription
Trade memoryThe open trade for the specified index.

getOpenTradeInfo

solidity
function getOpenTradeInfo(uint256 tradeIndex) external view returns (TradeInfo memory)

Retrieves the additional trade information for a given trade index.

Parameters

NameTypeDescription
tradeIndexuint256The index of the trade.

Returns

TypeDescription
TradeInfo memoryThe additional trade information for the specified trade.

getOpenTradesCount

solidity
function getOpenTradesCount(address trader, uint256 pairIndex) external view returns (uint256)

Retrieves the count of open trades for a given trader and pair index.

Parameters

NameTypeDescription
traderaddressThe address of the trader.
pairIndexuint256The index of the trading pair.

Returns

TypeDescription
uint256The count of open trades for the specified trader and pair.

getOpenTrades

solidity
function getOpenTrades(uint256 offset, uint256 count) external view returns (Trade[] memory)

Retrieves a range of open trades.

Parameters

NameTypeDescription
offsetuint256The starting index of the range.
countuint256The number of trades to retrieve.

Returns

TypeDescription
Trade[] memoryAn array of open trades within the specified range.

getOpenTradeInfos

solidity
function getOpenTradeInfos(uint256 offset, uint256 count) external view returns (TradeInfo[] memory)

Retrieves a range of additional trade information for open trades.

Parameters

NameTypeDescription
offsetuint256The starting index of the range.
countuint256The number of trade information entries to retrieve.

Returns

TypeDescription
TradeInfo[] memoryAn array of additional trade information within the specified range.

getOpenLimitOrder

solidity
function getOpenLimitOrder(uint256 limitIndex) external view returns (OpenLimitOrder memory)

Retrieves an open limit order for a given order index.

Parameters

NameTypeDescription
limitIndexuint256The index of the limit order.

Returns

TypeDescription
OpenLimitOrder memoryThe open limit order for the specified index.

getOpenLimitOrdersCount

solidity
function getOpenLimitOrdersCount(address trader, uint256 pairIndex) external view returns (uint256)

Retrieves the count of open limit orders for a given trader and pair index.

Parameters

NameTypeDescription
traderaddressThe address of the trader.
pairIndexuint256The index of the trading pair.

Returns

TypeDescription
uint256The count of open limit orders for the specified trader and pair.

getOpenLimitOrders

solidity
function getOpenLimitOrders(uint256 offset, uint256 count) external view returns (OpenLimitOrder[] memory)

Retrieves a range of open limit orders.

Parameters

NameTypeDescription
offsetuint256The starting index of the range.
countuint256The number of limit orders to retrieve.

Returns

TypeDescription
OpenLimitOrder[] memoryAn array of open limit orders within the specified range.

Structs

solidity
struct Trade {
    address trader;
    uint256 pairIndex;
    uint256 index; // don't need, will auto-fill
    uint256 initialPosToken; // 1e18
    uint256 positionSizeHoney; // 1e18
    uint256 openPrice; // PRECISION == 1e10
    bool buy;
    uint256 leverage;
    uint256 tp; // PRECISION
    uint256 sl; // PRECISION
}

struct TradeInfo {
    uint256 tokenPriceHoney; // PRECISION
    uint256 openInterestHoney; // positionSize * leverage (1e18)
    uint256 tpLastUpdated;
    uint256 slLastUpdated;
    uint256 openTime; // timestamp of opening
}

struct OpenLimitOrder {
    address trader;
    uint256 pairIndex;
    uint256 index;
    uint256 positionSize; // 1e18 (HONEY)
    bool buy;
    uint256 leverage;
    uint256 tp; // PRECISION (%)
    uint256 sl; // PRECISION (%)
    uint256 minPrice; // PRECISION
    uint256 maxPrice; // PRECISION
    uint256 openTime; // timestamp of opening
}

Enums

solidity
enum LimitOrder {
    TP,
    SL,
    LIQ,
    OPEN
}