Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
Market fork updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vikramrajkumar committed Sep 4, 2014
1 parent 9c0e2dc commit 40ba2b8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
3 changes: 2 additions & 1 deletion libraries/blockchain/include/bts/blockchain/checkpoints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ const static std::map<uint32_t, bts::blockchain::block_id_type> CHECKPOINT_BLOCK
{332000, bts::blockchain::block_id_type("2ab4e4de53568149de0a0a37f46fce05d861d43f")},
{341000, bts::blockchain::block_id_type("b77a53d3d3c8dfd1c03d04fb989606bc1a738166")},
{358310, bts::blockchain::block_id_type("4fb5498c0f1bce18740dca639389e307a194de2a")},
{384100, bts::blockchain::block_id_type("9f2ffbebd7722b566547507028954fb81cc37271")}
{384100, bts::blockchain::block_id_type("9f2ffbebd7722b566547507028954fb81cc37271")},
{398900, bts::blockchain::block_id_type("0260a868051d0e43316c165bc912cfb8444262ef")}
};
2 changes: 1 addition & 1 deletion libraries/blockchain/include/bts/blockchain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdint.h>

/* Define client version here */
#define BTS_CLIENT_VERSION "0.4.11"
#define BTS_CLIENT_VERSION "0.4.12"

/* Comment out this line for a non-test network */
//#define BTS_TEST_NETWORK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
#define BTSX_MARKET_FORK_2_BLOCK_NUM 316001
#define BTSX_MARKET_FORK_3_BLOCK_NUM 340000
#define BTSX_MARKET_FORK_4_BLOCK_NUM 357000
#define BTSX_MARKET_FORK_5_BLOCK_NUM 407500
#define BTSX_MARKET_FORK_5_BLOCK_NUM 408750
46 changes: 24 additions & 22 deletions libraries/blockchain/market_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ class market_engine
_current_bid.reset();
continue;
}
/**
* Don't allow shorts to be executed if they are too far over priced or they will be
* immediately under collateralized.
*/
if( mtrx.bid_price < market_stat->minimum_ask() )
{
//wlog( "skipping short ${x} < max_short_bid ${b}", ("x",mtrx.bid_price)("b", max_short_bid) );
// TODO: cancel the short order...
_current_ask.reset();
continue;
}
}
else
{
Expand All @@ -214,18 +225,6 @@ class market_engine
continue;
}
}
/**
* Don't allow shorts to be executed if they are too far over priced or they will be
* immediately under collateralized.
*/
if( mtrx.bid_price < market_stat->minimum_ask() )
{
//wlog( "skipping short ${x} < max_short_bid ${b}", ("x",mtrx.bid_price)("b", max_short_bid) );
// TODO: cancel the short order...
_current_ask.reset();
continue;
}

mtrx.ask_price = mtrx.bid_price;

// we want to sell enough XTS to cover our balance.
Expand Down Expand Up @@ -280,17 +279,20 @@ class market_engine
if( mtrx.ask_price < mtrx.bid_price )
break; // the call price has not been reached

/**
* Don't allow margin calls to be executed too far below
* the minimum ask, this could lead to an attack where someone
* walks the whole book to steal the collateral.
*/
if( mtrx.bid_price < market_stat->minimum_ask() )
if( pending_block_num >= BTSX_MARKET_FORK_5_BLOCK_NUM )
{
//wlog( "skipping short ${x} < max_short_bid ${b}", ("x",mtrx.bid_price)("b", max_short_bid) );
// TODO: cancel the short order...
_current_ask.reset();
continue;
/**
* Don't allow margin calls to be executed too far below
* the minimum ask, this could lead to an attack where someone
* walks the whole book to steal the collateral.
*/
if( mtrx.bid_price < market_stat->minimum_ask() )
{
//wlog( "skipping short ${x} < max_short_bid ${b}", ("x",mtrx.bid_price)("b", max_short_bid) );
// TODO: cancel the short order...
_current_ask.reset();
continue;
}
}

mtrx.ask_price = mtrx.bid_price;
Expand Down
2 changes: 1 addition & 1 deletion libraries/blockchain/original_market_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
if( trading_volume.amount > 0 && get_next_bid() && get_next_ask() )
{
market_history_key key(quote_id, base_id, market_history_key::each_block, _db_impl._head_block_header.timestamp);
market_history_record new_record(_current_bid->get_price(), _current_ask->get_price(), trading_volume.amount);
market_history_record new_record(_current_bid->get_price(), _current_ask->get_price(), price(), price(), trading_volume.amount);
//LevelDB iterators are dumb and don't support proper past-the-end semantics.
auto last_key_itr = _db_impl._market_history_db.lower_bound(key);
if( !last_key_itr.valid() )
Expand Down

0 comments on commit 40ba2b8

Please sign in to comment.