Prevent margin call from being triggered unless feed < call #436
This commit is contained in:
parent
6feadd77a5
commit
b80587e5b5
2 changed files with 16 additions and 16 deletions
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
#include <graphene/chain/asset_object.hpp>
|
||||
#include <graphene/chain/hardfork.hpp>
|
||||
#include <graphene/chain/market_evaluator.hpp>
|
||||
|
||||
#include <fc/uint128.hpp>
|
||||
|
|
@ -416,15 +417,8 @@ bool database::check_call_orders(const asset_object& mia, bool enable_black_swan
|
|||
auto limit_itr = limit_price_index.lower_bound( max_price );
|
||||
auto limit_end = limit_price_index.upper_bound( min_price );
|
||||
|
||||
if( limit_itr == limit_end ) {
|
||||
/*
|
||||
if( head_block_num() > 300000 )
|
||||
ilog( "no orders below between: ${p} and: ${m}",
|
||||
("p", bitasset.current_feed.max_short_squeeze_price())
|
||||
("m", max_price) );
|
||||
*/
|
||||
if( limit_itr == limit_end )
|
||||
return false;
|
||||
}
|
||||
|
||||
auto call_min = price::min( bitasset.options.short_backing_asset, mia.id );
|
||||
auto call_max = price::max( bitasset.options.short_backing_asset, mia.id );
|
||||
|
|
@ -434,14 +428,6 @@ bool database::check_call_orders(const asset_object& mia, bool enable_black_swan
|
|||
bool filled_limit = false;
|
||||
bool margin_called = false;
|
||||
|
||||
/*
|
||||
if( head_block_num() >= 11510 && head_block_num() <= 11512) {
|
||||
idump(("enter loop") );
|
||||
auto tmp = call_itr;
|
||||
while( tmp != call_end ) { edump( (*tmp) ); ++tmp; }
|
||||
}
|
||||
*/
|
||||
|
||||
while( !check_for_blackswan( mia, enable_black_swan ) && call_itr != call_end )
|
||||
{
|
||||
bool filled_call = false;
|
||||
|
|
@ -457,9 +443,22 @@ bool database::check_call_orders(const asset_object& mia, bool enable_black_swan
|
|||
|
||||
match_price.validate();
|
||||
|
||||
// would be margin called, but there is no matching order #436
|
||||
bool feed_protected = ( bitasset.current_feed.settlement_price > ~call_itr->call_price );
|
||||
if( feed_protected && (head_block_time() > HARDFORK_436_TIME) )
|
||||
return margin_called;
|
||||
|
||||
// would be margin called, but there is no matching order
|
||||
if( match_price > ~call_itr->call_price )
|
||||
return margin_called;
|
||||
|
||||
if( feed_protected )
|
||||
{
|
||||
ilog( "Feed protected margin call executing (HARDFORK_436_TIME not here yet)" );
|
||||
idump( (*call_itr) );
|
||||
idump( (*limit_itr) );
|
||||
}
|
||||
|
||||
// idump((*call_itr));
|
||||
// idump((*limit_itr));
|
||||
|
||||
|
|
|
|||
|
|
@ -27,3 +27,4 @@
|
|||
#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 ))
|
||||
#define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 ))
|
||||
#define HARDFORK_419_TIME (fc::time_point_sec( 1446652800 ))
|
||||
#define HARDFORK_436_TIME (fc::time_point_sec( 2000000000 ))
|
||||
|
|
|
|||
Loading…
Reference in a new issue