Developer Guide


Advanced orders are conceptually simple to understand. They can be executed by saying “If price is above or below a certain value, execute buy/sell order”. However, this sort of command is impossible to execute on a block chain. Any transaction on the block chain must be initiated by a user, therefore it is not possible to have this sort of conditionality.

Our solution at apex, is to utilise ‘keepers’. A keeper is anybody that monitors the orders that have been placed and calls the execute() function when their conditions have been met. In doing so, the order will be executed.

As keepers will have the ability to execute orders, we must ensure that it is never possible for a keeper to execute an order incorrectly. The smart contract must verify the conditions of the order before that order can be executed. If the conditions have not been met, then the execute() transaction will revert.

The keepers are providing a service (indeed, apex could not operate without keepers), therefore there must be an economic incentive for keepers to exist. Every order created on apex, will have a ‘botFee’ attached to it. This fee will go to the keeper that executes the orders.

Smart Contracts

The LimitOrderBook contains all the advanced orders within It has functions to create/modify/remove advanced orders (Limit, Stop, StopLimit, Trailing Stop, Trailing Stop Limit).

The SmartWalletFactory allows users to create and deploy their own smart wallets. It also ensures that each unique user can only create one smart wallet.

The SmartWallet is a hybrid between a smart contract and a personal wallet (hence the name). The owner of the smart wallet is able to relay functions as though it was the smart wallet executing those functions. This smart wallet will allow a keeper to execute an advanced order if and only if its conditions are met.

Last updated