Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record filled amount in limit orders #2776

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion libraries/chain/db_market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,13 +1225,14 @@ database::match_result_type database::match_limit_settled_debt( const limit_orde
wlog( "Unexpected scene: obj.for_sale > bitasset.individual_settlement_fund" );
obj.for_sale = bitasset.individual_settlement_fund;
obj.sell_price = ~bitasset.get_individual_settlement_price();
} // GCOVR_EXEL_STOP
} // GCOVR_EXCL_STOP
}
else
{
obj.for_sale = bitasset.individual_settlement_fund;
obj.sell_price = ~bitasset.get_individual_settlement_price();
}
// Note: filled_amount is not updated, but it should be fine
});
// Note:
// After the price is updated, it is possible that the order can be matched with another order on the order
Expand Down Expand Up @@ -1325,6 +1326,7 @@ database::match_result_type database::match_settled_debt_limit( const limit_orde
obj.for_sale = bitasset.individual_settlement_fund;
obj.sell_price = ~bitasset.get_individual_settlement_price();
} // GCOVR_EXCL_STOP
// Note: filled_amount is not updated, but it should be fine
});
}

Expand Down Expand Up @@ -1889,6 +1891,7 @@ bool database::fill_limit_order( const limit_order_object& order, const asset& p
}
modify( order, [&pays,&new_take_profit_order_id]( limit_order_object& b ) {
b.for_sale -= pays.amount;
b.filled_amount += pays.amount.value;
b.deferred_fee = 0;
b.deferred_paid_fee.amount = 0;
if( new_take_profit_order_id.valid() ) // A new take profit order is created, link it to this order
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/graphene/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#define GRAPHENE_MAX_NESTED_OBJECTS (200)

const std::string GRAPHENE_CURRENT_DB_VERSION = "20230529";
const std::string GRAPHENE_CURRENT_DB_VERSION = "20230906";

#define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3
Expand Down
9 changes: 5 additions & 4 deletions libraries/chain/include/graphene/chain/market_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ using namespace graphene::db;
class limit_order_object : public abstract_object<limit_order_object, protocol_ids, limit_order_object_type>
{
public:
time_point_sec expiration;
account_id_type seller;
share_type for_sale; ///< asset id is sell_price.base.asset_id
price sell_price;
time_point_sec expiration; ///< When this limit order will expire
account_id_type seller; ///< Who is selling
share_type for_sale; ///< The amount for sale, asset id is sell_price.base.asset_id
price sell_price; ///< The seller's asking price
fc::uint128_t filled_amount = 0; ///< The amount that has been sold, asset id is sell_price.base.asset_id
share_type deferred_fee; ///< fee converted to CORE
asset deferred_paid_fee; ///< originally paid fee
bool is_settled_debt = false; ///< Whether this order is an individual settlement fund
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/market_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ share_type call_order_object::get_max_debt_to_cover( price match_price,

FC_REFLECT_DERIVED_NO_TYPENAME( graphene::chain::limit_order_object,
(graphene::db::object),
(expiration)(seller)(for_sale)(sell_price)(deferred_fee)(deferred_paid_fee)
(expiration)(seller)(for_sale)(sell_price)(filled_amount)(deferred_fee)(deferred_paid_fee)
(is_settled_debt)(on_fill)(take_profit_order_id)
)

Expand Down