Skip to content

Commit

Permalink
db_market: stop using call_price after hf #1270
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Sep 13, 2018
1 parent 469a499 commit cb7bd0c
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions libraries/chain/db_market.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,15 @@ void database::execute_bid( const collateral_bid_object& bid, share_type debt_co
call.borrower = bid.bidder;
call.collateral = bid.inv_swan_price.base.amount + collateral_from_fund;
call.debt = debt_covered;
call.call_price = price::call_price(asset(debt_covered, bid.inv_swan_price.quote.asset_id),
asset(call.collateral, bid.inv_swan_price.base.asset_id),
current_feed.maintenance_collateral_ratio);
// don't calculate call_price after core-1270 hard fork
if( get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_1270_TIME )
// bid.inv_swan_price is in collateral / debt
call.call_price = price( asset( 1, bid.inv_swan_price.base.asset_id ),
asset( 1, bid.inv_swan_price.quote.asset_id ) );
else
call.call_price = price::call_price( asset(debt_covered, bid.inv_swan_price.quote.asset_id),
asset(call.collateral, bid.inv_swan_price.base.asset_id),
current_feed.maintenance_collateral_ratio );
});

// Note: CORE asset in collateral_bid_object is not counted in account_stats.total_core_in_orders
Expand Down Expand Up @@ -866,9 +872,17 @@ bool database::fill_call_order( const call_order_object& order, const asset& pay
collateral_freed = o.get_collateral();
o.collateral = 0;
}
else if( get_dynamic_global_properties().next_maintenance_time > HARDFORK_CORE_343_TIME )
o.call_price = price::call_price( o.get_debt(), o.get_collateral(),
mia.bitasset_data(*this).current_feed.maintenance_collateral_ratio );
else
{
auto maint_time = get_dynamic_global_properties().next_maintenance_time;
// update call_price after core-343 hard fork,
// but don't update call_price after core-1270 hard fork
if( maint_time <= HARDFORK_CORE_1270_TIME && maint_time > HARDFORK_CORE_343_TIME )
{
o.call_price = price::call_price( o.get_debt(), o.get_collateral(),
mia.bitasset_data(*this).current_feed.maintenance_collateral_ratio );
}
}
});

// update current supply
Expand Down

0 comments on commit cb7bd0c

Please sign in to comment.