📖OrderBook

Order Book Contract is the main contract responsible for holding all information regarding orders as well as executing those orders via the help of the Margin ledger.

Custom Structures

Position

Struct Position is used to store data regarding the position.

Type
Name
Description

uint256

price

Price at which position was opened.

uint256

amount

Amount of underlying being sold/bought .

bool

isBuy

True = Long / False = Short

Maker Order

Structure to store information about any Limit Order

Type
Name
Description

address

maker

Address of the user who put in the Limit Order.

uint256

timestamp

Limit Order creation timestamp.

uint256

orderId

Unique Order ID for the given Limit Order.

position

Limit Order Position Information.

View Methods

FetchOrder

function fetchOrder(uint256 _orderId)

Returns the MakerOrderstructure for any given order ID.

Return Value : Maker Order

GetQuoteLot

function getQuoteLot()

Returns the QuoteLot for the given market.

FetchOrders

function fetchOrders(uint256[] _orderIds)

Returns the order structure for a given set of Order IDs.

CheckForAnyOpenOrders

function checkForAnyOpenOrder(address _user)

Returns trueif the address has any open limit order.

Write Methods

AddMakerOrder

function addMakerOrder(bytes _orderData)

Function call to add a Limit order.

Ensure Sufficient Margin balance before calling this function!

Any given address can maintain a maximum of 5 limit orders at any point.

Params need to be encoded in the format :

Param Name
Type
Description

maker

address

User Address.

amount

uint256

Amount of Asset to Long/Short.

price

uint256

Price of the Limit Order

isBuy

boolean

Side of the order. True=Long/ False=Short

Remove Order

function removeOrder(uint256 orderId)

Function to remove any given order using its unique order ID.

Ensure that the address sending the transaction is the maker of the given order

Params:

Param
Type
Description

orderId

uint256

Order ID of the Limit Order to be deleted.

Remove Order By Address

function removeOrderByAddress(address maker)

Function to remove all orders for a given maker using his address.

Params :

Param
Type
Description

maker

address

User address

Last updated