Flex
Flex exchange system
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
process_queue_state Class Reference

Processing orders queue state for PriceXchg. More...

#include <process_queue_state.hpp>

Collaboration diagram for process_queue_state:
Collaboration graph
[legend]

Public Member Functions

 process_queue_state (price_t price, address pair, Tip3Config major_tip3cfg, Tip3Config minor_tip3cfg, EversConfig ev_cfg, uint128 min_amount, unsigned deals_limit, unsigned msgs_limit, IFlexNotifyPtr notify_addr, unsigned sell_idx, unsigned buy_idx)
 
void on_expired (OrderInfoXchgWithIdx ord_idx, bool sell)
 
void on_out_of_evers (OrderInfoXchgWithIdx ord_idx, bool sell)
 
void on_order_done (OrderInfoXchgWithIdx ord_idx, bool sell)
 When order is done.
 
void on_no_post_order_done (OrderInfoXchgWithIdx ord_idx, bool sell)
 When we have order without post-order flag and other side queue is empty.
 
void check_ret (bool sell, unsigned idx, OrderRet ret)
 Check that order is the current requested order and we need to save return value.
 
void on_deal (bool seller_taker, uint128 deal_amount)
 When a deal is processed.
 
bool is_order_done (OrderInfoXchg ord) const
 Is the order done? Means the remaining amount is less than min_amount or minor_cost can't be calculated.
 
bool overlimit () const
 If we hit deals or messages limit.
 
void finalize (uint128 rest_sell_amount, uint128 rest_buy_amount)
 Finalize state - send AMM notifications about processed deals and canceled orders.
 

Public Attributes

price_t price_
 Price (rational value)
 
address pair_
 Address of XchgPair contract.
 
Tip3Config major_tip3cfg_
 Major tip3 configuration.
 
Tip3Config minor_tip3cfg_
 Minor tip3 configuration.
 
EversConfig ev_cfg_
 Evers processing costs configuration.
 
uint128 expired_
 Expired orders met during current processing.
 
uint128 out_of_evers_
 Out-of-evers orders met during current processing.
 
uint128 no_post_order_dones_
 Partially done orders without post-order flag.
 
uint128 deals_processed_
 Deals processed.
 
uint128 msgs_outs_
 Out messages to sent.
 
uint128 sum_deals_amount_
 Summarized amount of major tokens in all deals.
 
uint128 sum_taker_sells_amount_
 Summarized amount of major tokens in all taker-sell deals.
 
uint128 sum_taker_buys_amount_
 Summarized amount of major tokens in all taker-buy deals.
 
uint128 sell_cancels_amount_
 Canceled sell orders (ooe/expired)
 
uint128 buy_cancels_amount_
 Canceled buy orders (ooe/expired)
 
uint128 min_amount_
 Minimum amount of major tokens for a deal or an order.
 
unsigned deals_limit_
 Deals limit.
 
unsigned msgs_limit_
 Messages limit.
 
address tip3root_major_
 Address of RootTokenContract for major tip3 token.
 
address tip3root_minor_
 Address of RootTokenContract for minor tip3 token.
 
IFlexNotifyPtr notify_addr_
 Notification address for AMM (IFlexNotify).
 
unsigned sell_idx_
 If we are processing onTip3LendOwnership with sell, this index we can use for return value.
 
unsigned buy_idx_
 If we are processing onTip3LendOwnership with buy, this index we can use for return value.
 
opt< OrderRetret_
 Return value.
 

Static Public Attributes

static constexpr unsigned msgs_per_deal = 4
 Messages per deal completed.
 
static constexpr unsigned msgs_per_expired = 1
 Messages per order expired.
 
static constexpr unsigned msgs_per_out_of_evers = 2
 Messages per order out-of-evers.
 
static constexpr unsigned msgs_per_no_post_order_done = 2
 Messages per non-post-order partially done.
 

Detailed Description

Processing orders queue state for PriceXchg.

Constructor & Destructor Documentation

◆ process_queue_state()

process_queue_state ( price_t  price,
address  pair,
Tip3Config  major_tip3cfg,
Tip3Config  minor_tip3cfg,
EversConfig  ev_cfg,
uint128  min_amount,
unsigned  deals_limit,
unsigned  msgs_limit,
IFlexNotifyPtr  notify_addr,
unsigned  sell_idx,
unsigned  buy_idx 
)
inline
Parameters
pricePrice (rational value)
pairAddress of XchgPair
major_tip3cfgMajor tip3 configuration
minor_tip3cfgMinor tip3 configuration
ev_cfgProcessing costs configuration
min_amountMinimum amount of major tokens for a deal or an order
deals_limitDeals limit
msgs_limitMessages limit
notify_addrNotification address for AMM (IFlexNotify)
sell_idxIf we are processing onTip3LendOwnership with sell, this index we can use for return value
buy_idxIf we are processing onTip3LendOwnership with buy, this index we can use for return value

Member Function Documentation

◆ on_expired()

void on_expired ( OrderInfoXchgWithIdx  ord_idx,
bool  sell 
)
inline

When order is expired, sending IPriceCallback::onOrderFinished() notification with the remaining balance. We don't need to call returnOwnership.

◆ on_out_of_evers()

void on_out_of_evers ( OrderInfoXchgWithIdx  ord_idx,
bool  sell 
)
inline

When order has not enough evers to process deals, sending IPriceCallback::onOrderFinished() notification and calling ITONTokenWallet::returnOwnership() to unlock tip3 tokens in the client wallet.


The documentation for this class was generated from the following file: