9 #include "../PriceXchg.hpp"
12 #include <tvm/suffixes.hpp>
14 namespace tvm {
namespace xchg {
27 Tip3Config major_tip3cfg,
28 Tip3Config minor_tip3cfg,
33 IFlexNotifyPtr notify_addr,
45 void on_expired(OrderInfoXchgWithIdx ord_idx,
bool sell) {
46 auto ord = ord_idx.second;
58 IPriceCallbackPtr(ord.tip3_wallet_provide)(Evers(ord.account.get())).
66 auto ord = ord_idx.second;
83 returnOwnership(ord.lend_amount);
84 IPriceCallbackPtr(ord.tip3_wallet_provide)(Evers(ord.account.get())).
91 auto ord = ord_idx.second;
95 IPriceCallbackPtr(ord.tip3_wallet_provide)(Evers(ord.account.get())).
101 auto ord = ord_idx.second;
118 returnOwnership(ord.lend_amount);
119 IPriceCallbackPtr(ord.tip3_wallet_provide)(Evers(ord.account.get())).
120 onOrderFinished(ret);
133 void on_deal(
bool seller_taker, uint128 deal_amount) {
153 void finalize(uint128 rest_sell_amount, uint128 rest_buy_amount) {
157 onXchgDealCompleted(seller_taker,
pair_,
__always_inline std::optional< uint128 > minor_cost(uint128 amount, price_t price)
Definition: PriceXchg.hpp:46
Processing orders queue state for PriceXchg.
Definition: process_queue_state.hpp:17
uint128 msgs_outs_
Out messages to sent.
Definition: process_queue_state.hpp:183
static constexpr unsigned msgs_per_expired
Messages per order expired.
Definition: process_queue_state.hpp:20
uint128 sum_taker_sells_amount_
Summarized amount of major tokens in all taker-sell deals.
Definition: process_queue_state.hpp:185
address tip3root_minor_
Address of RootTokenContract for minor tip3 token.
Definition: process_queue_state.hpp:193
unsigned sell_idx_
If we are processing onTip3LendOwnership with sell, this index we can use for return value.
Definition: process_queue_state.hpp:195
uint128 deals_processed_
Deals processed.
Definition: process_queue_state.hpp:182
void on_expired(OrderInfoXchgWithIdx ord_idx, bool sell)
Definition: process_queue_state.hpp:45
bool overlimit() const
If we hit deals or messages limit.
Definition: process_queue_state.hpp:148
unsigned msgs_limit_
Messages limit.
Definition: process_queue_state.hpp:191
void on_order_done(OrderInfoXchgWithIdx ord_idx, bool sell)
When order is done.
Definition: process_queue_state.hpp:90
price_t price_
Price (rational value)
Definition: process_queue_state.hpp:174
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.
Definition: process_queue_state.hpp:100
Tip3Config major_tip3cfg_
Major tip3 configuration.
Definition: process_queue_state.hpp:176
static constexpr unsigned msgs_per_deal
Messages per deal completed.
Definition: process_queue_state.hpp:19
opt< OrderRet > ret_
Return value.
Definition: process_queue_state.hpp:197
uint128 expired_
Expired orders met during current processing.
Definition: process_queue_state.hpp:179
IFlexNotifyPtr notify_addr_
Notification address for AMM (IFlexNotify).
Definition: process_queue_state.hpp:194
void check_ret(bool sell, unsigned idx, OrderRet ret)
Check that order is the current requested order and we need to save return value.
Definition: process_queue_state.hpp:125
unsigned buy_idx_
If we are processing onTip3LendOwnership with buy, this index we can use for return value.
Definition: process_queue_state.hpp:196
uint128 sum_taker_buys_amount_
Summarized amount of major tokens in all taker-buy deals.
Definition: process_queue_state.hpp:186
uint128 no_post_order_dones_
Partially done orders without post-order flag.
Definition: process_queue_state.hpp:181
void finalize(uint128 rest_sell_amount, uint128 rest_buy_amount)
Finalize state - send AMM notifications about processed deals and canceled orders.
Definition: process_queue_state.hpp:153
void on_out_of_evers(OrderInfoXchgWithIdx ord_idx, bool sell)
Definition: process_queue_state.hpp:65
unsigned deals_limit_
Deals limit.
Definition: process_queue_state.hpp:190
uint128 out_of_evers_
Out-of-evers orders met during current processing.
Definition: process_queue_state.hpp:180
uint128 min_amount_
Minimum amount of major tokens for a deal or an order.
Definition: process_queue_state.hpp:189
Tip3Config minor_tip3cfg_
Minor tip3 configuration.
Definition: process_queue_state.hpp:177
static constexpr unsigned msgs_per_out_of_evers
Messages per order out-of-evers.
Definition: process_queue_state.hpp:21
EversConfig ev_cfg_
Evers processing costs configuration.
Definition: process_queue_state.hpp:178
address pair_
Address of XchgPair contract.
Definition: process_queue_state.hpp:175
static constexpr unsigned msgs_per_no_post_order_done
Messages per non-post-order partially done.
Definition: process_queue_state.hpp:22
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 calculat...
Definition: process_queue_state.hpp:143
void on_deal(bool seller_taker, uint128 deal_amount)
When a deal is processed.
Definition: process_queue_state.hpp:133
uint128 buy_cancels_amount_
Canceled buy orders (ooe/expired)
Definition: process_queue_state.hpp:188
uint128 sell_cancels_amount_
Canceled sell orders (ooe/expired)
Definition: process_queue_state.hpp:187
uint128 sum_deals_amount_
Summarized amount of major tokens in all deals.
Definition: process_queue_state.hpp:184
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)
Definition: process_queue_state.hpp:24
address tip3root_major_
Address of RootTokenContract for major tip3 token.
Definition: process_queue_state.hpp:192
Error codes for PriceXchg.
Processing native funds value ...
Definition: EversConfig.hpp:12
uint128 send_notify
... to send notification about completed deal (IFlexNotify)
Definition: EversConfig.hpp:23
uint128 return_ownership
... to return tip3 ownership
Definition: EversConfig.hpp:16
tip3-tip3 exchange order info
Definition: PriceXchg.hpp:54
uint128 amount
Current remaining amount of major tokens to buy or sell.
Definition: PriceXchg.hpp:58
Notification struct about order to a client.
Definition: PriceCommon.hpp:16
Rational value - numerator/denominator.
Definition: RationalValue.hpp:12
uint128 denominator() const
Denominator part of rational number.
Definition: RationalValue.hpp:14
uint128 numerator() const
Numerator part of rational number.
Definition: RationalValue.hpp:13
static constexpr unsigned expired
Order is expired.
Definition: error_code.hpp:21
static constexpr unsigned out_of_tons
Partially processed because out of tons.
Definition: error_code.hpp:14
static constexpr unsigned no_post_order_partially_done
Order without post-order flag is partially done.
Definition: error_code.hpp:22