Update plugins and wallet to remove shorts
This commit is contained in:
parent
663036f2aa
commit
4cee2ca608
6 changed files with 20 additions and 72 deletions
|
|
@ -215,22 +215,6 @@ namespace graphene { namespace app {
|
|||
return result;
|
||||
}
|
||||
|
||||
vector<short_order_object> database_api::get_short_orders(asset_id_type a, uint32_t limit)const
|
||||
{
|
||||
const auto& short_order_idx = _db.get_index_type<short_order_index>();
|
||||
const auto& sell_price_idx = short_order_idx.indices().get<by_price>();
|
||||
const asset_object& mia = _db.get(a);
|
||||
|
||||
FC_ASSERT( mia.is_market_issued(), "must be a market issued asset" );
|
||||
|
||||
price index_price = price::min(mia.get_id(), mia.bitasset_data(_db).options.short_backing_asset);
|
||||
|
||||
auto short_itr = sell_price_idx.lower_bound(index_price.max());
|
||||
auto short_end = sell_price_idx.upper_bound(index_price.min());
|
||||
|
||||
return vector<short_order_object>(short_itr, short_end);
|
||||
}
|
||||
|
||||
vector<call_order_object> database_api::get_call_orders(asset_id_type a, uint32_t limit)const
|
||||
{
|
||||
const auto& call_index = _db.get_index_type<call_order_index>().indices().get<by_price>();
|
||||
|
|
@ -358,15 +342,11 @@ namespace graphene { namespace app {
|
|||
case operation::tag<limit_order_create_operation>::value:
|
||||
market = op.op.get<limit_order_create_operation>().get_market();
|
||||
break;
|
||||
case operation::tag<short_order_create_operation>::value:
|
||||
market = op.op.get<limit_order_create_operation>().get_market();
|
||||
break;
|
||||
case operation::tag<fill_order_operation>::value:
|
||||
market = op.op.get<fill_order_operation>().get_market();
|
||||
break;
|
||||
/*
|
||||
case operation::tag<limit_order_cancel_operation>::value:
|
||||
case operation::tag<short_order_cancel_operation>::value:
|
||||
*/
|
||||
default: break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include <graphene/chain/operation_history_object.hpp>
|
||||
#include <graphene/chain/asset_object.hpp>
|
||||
#include <graphene/chain/limit_order_object.hpp>
|
||||
#include <graphene/chain/short_order_object.hpp>
|
||||
#include <graphene/chain/call_order_object.hpp>
|
||||
#include <graphene/chain/key_object.hpp>
|
||||
#include <graphene/net/node.hpp>
|
||||
#include <fc/api.hpp>
|
||||
|
|
@ -142,13 +142,6 @@ namespace graphene { namespace app {
|
|||
* @return The limit orders, ordered from least price to greatest
|
||||
*/
|
||||
vector<limit_order_object> get_limit_orders(asset_id_type a, asset_id_type b, uint32_t limit)const;
|
||||
/**
|
||||
* @brief Get short orders in a given asset
|
||||
* @param a ID of asset being sold
|
||||
* @param limit Maximum number of orders to retrieve
|
||||
* @return The short orders, ordered from least price to greatest
|
||||
*/
|
||||
vector<short_order_object> get_short_orders(asset_id_type a, uint32_t limit)const;
|
||||
/**
|
||||
* @brief Get call orders in a given asset
|
||||
* @param a ID of asset being called
|
||||
|
|
@ -342,7 +335,6 @@ FC_API(graphene::app::database_api,
|
|||
(get_named_account_balances)
|
||||
(lookup_asset_symbols)
|
||||
(get_limit_orders)
|
||||
(get_short_orders)
|
||||
(get_call_orders)
|
||||
(get_settle_orders)
|
||||
(list_assets)
|
||||
|
|
|
|||
|
|
@ -141,9 +141,7 @@ struct operation_get_impacted_accounts
|
|||
}
|
||||
|
||||
void operator()( const limit_order_create_operation& o )const { }
|
||||
void operator()( const short_order_create_operation& o )const { }
|
||||
void operator()( const limit_order_cancel_operation& o )const { }
|
||||
void operator()( const short_order_cancel_operation& o )const { }
|
||||
void operator()( const call_order_update_operation& o )const { }
|
||||
void operator()( const key_create_operation& o )const { }
|
||||
void operator()( const custom_operation& o )const { }
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include <graphene/chain/delegate_object.hpp>
|
||||
#include <graphene/chain/witness_object.hpp>
|
||||
#include <graphene/chain/limit_order_object.hpp>
|
||||
#include <graphene/chain/short_order_object.hpp>
|
||||
#include <graphene/chain/call_order_object.hpp>
|
||||
#include <graphene/chain/proposal_object.hpp>
|
||||
#include <graphene/chain/operation_history_object.hpp>
|
||||
#include <graphene/chain/withdraw_permission_object.hpp>
|
||||
|
|
@ -72,8 +72,6 @@ object* create_object( const variant& v )
|
|||
return create_object_of_type< witness_object >( v );
|
||||
case limit_order_object_type:
|
||||
return create_object_of_type< limit_order_object >( v );
|
||||
case short_order_object_type:
|
||||
return create_object_of_type< short_order_object >( v );
|
||||
case call_order_object_type:
|
||||
return create_object_of_type< call_order_object >( v );
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -114,7 +114,6 @@ class wallet_api
|
|||
vector<asset_object> list_assets(const string& lowerbound, uint32_t limit)const;
|
||||
vector<operation_history_object> get_account_history(string name, int limit)const;
|
||||
vector<limit_order_object> get_limit_orders(string a, string b, uint32_t limit)const;
|
||||
vector<short_order_object> get_short_orders(string a, uint32_t limit)const;
|
||||
vector<call_order_object> get_call_orders(string a, uint32_t limit)const;
|
||||
vector<force_settlement_object> get_settle_orders(string a, uint32_t limit)const;
|
||||
global_property_object get_global_properties() const;
|
||||
|
|
@ -204,7 +203,11 @@ class wallet_api
|
|||
bool fill_or_kill = false,
|
||||
bool broadcast = false);
|
||||
|
||||
signed_transaction short_sell_asset(string seller_name, string amount_to_sell, string asset_symbol,
|
||||
/**
|
||||
* This method will create a transaction with two operations, the first one will borrow amount_to_sell
|
||||
* given amount of collateral
|
||||
*/
|
||||
signed_transaction borrow_asset(string seller_name, string amount_to_sell, string asset_symbol,
|
||||
string amount_of_collateral, bool broadcast = false);
|
||||
|
||||
signed_transaction create_asset(string issuer,
|
||||
|
|
@ -272,7 +275,7 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(upgrade_account)
|
||||
(create_account_with_brain_key)
|
||||
(sell_asset)
|
||||
(short_sell_asset)
|
||||
(borrow_asset)
|
||||
(transfer)
|
||||
(create_asset)
|
||||
(issue_asset)
|
||||
|
|
@ -289,7 +292,6 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(load_wallet_file)
|
||||
(normalize_brain_key)
|
||||
(get_limit_orders)
|
||||
(get_short_orders)
|
||||
(get_call_orders)
|
||||
(get_settle_orders)
|
||||
(save_wallet_file)
|
||||
|
|
|
|||
|
|
@ -1011,7 +1011,7 @@ public:
|
|||
return sign_transaction( tx, broadcast );
|
||||
}
|
||||
|
||||
signed_transaction short_sell_asset(string seller_name, string amount_to_sell, string asset_symbol,
|
||||
signed_transaction borrow_asset(string seller_name, string amount_to_sell, string asset_symbol,
|
||||
string amount_of_collateral, bool broadcast = false)
|
||||
{
|
||||
account_object seller = get_account(seller_name);
|
||||
|
|
@ -1019,11 +1019,10 @@ public:
|
|||
FC_ASSERT(mia.is_market_issued());
|
||||
asset_object collateral = get_asset(get_object(*mia.bitasset_data_id).options.short_backing_asset);
|
||||
|
||||
short_order_create_operation op;
|
||||
op.seller = seller.id;
|
||||
op.expiration = fc::time_point::now() + fc::days(365*10);
|
||||
op.amount_to_sell = mia.amount_from_string(amount_to_sell);
|
||||
op.collateral = collateral.amount_from_string(amount_of_collateral);
|
||||
call_order_update_operation op;
|
||||
op.funding_account = seller.id;
|
||||
op.amount_to_cover = -mia.amount_from_string(amount_to_sell);
|
||||
op.collateral_to_add = collateral.amount_from_string(amount_of_collateral);
|
||||
|
||||
signed_transaction trx;
|
||||
trx.operations = {op};
|
||||
|
|
@ -1040,27 +1039,11 @@ public:
|
|||
FC_ASSERT(order_id.space() == protocol_ids, "Invalid order ID ${id}", ("id", order_id));
|
||||
signed_transaction trx;
|
||||
|
||||
switch( order_id.type() )
|
||||
{
|
||||
case short_order_object_type: {
|
||||
short_order_cancel_operation op;
|
||||
op.fee_paying_account = get_object<short_order_object>(order_id).seller;
|
||||
op.order = order_id;
|
||||
op.fee = op.calculate_fee(_remote_db->get_global_properties().parameters.current_fees);
|
||||
trx.operations = {op};
|
||||
break;
|
||||
}
|
||||
case limit_order_object_type: {
|
||||
limit_order_cancel_operation op;
|
||||
op.fee_paying_account = get_object<limit_order_object>(order_id).seller;
|
||||
op.order = order_id;
|
||||
op.fee = op.calculate_fee(_remote_db->get_global_properties().parameters.current_fees);
|
||||
trx.operations = {op};
|
||||
break;
|
||||
}
|
||||
default:
|
||||
FC_THROW("Invalid order ID ${id}", ("id", order_id));
|
||||
}
|
||||
limit_order_cancel_operation op;
|
||||
op.fee_paying_account = get_object<limit_order_object>(order_id).seller;
|
||||
op.order = order_id;
|
||||
op.fee = op.calculate_fee(_remote_db->get_global_properties().parameters.current_fees);
|
||||
trx.operations = {op};
|
||||
|
||||
trx.validate();
|
||||
return sign_transaction(trx, broadcast);
|
||||
|
|
@ -1384,11 +1367,6 @@ vector<limit_order_object> wallet_api::get_limit_orders(string a, string b, uint
|
|||
return my->_remote_db->get_limit_orders(get_asset(a).id, get_asset(b).id, limit);
|
||||
}
|
||||
|
||||
vector<short_order_object> wallet_api::get_short_orders(string a, uint32_t limit)const
|
||||
{
|
||||
return my->_remote_db->get_short_orders(get_asset(a).id, limit);
|
||||
}
|
||||
|
||||
vector<call_order_object> wallet_api::get_call_orders(string a, uint32_t limit)const
|
||||
{
|
||||
return my->_remote_db->get_call_orders(get_asset(a).id, limit);
|
||||
|
|
@ -1740,11 +1718,11 @@ signed_transaction wallet_api::sell_asset(string seller_account,
|
|||
symbol_to_receive, expiration, fill_or_kill, broadcast);
|
||||
}
|
||||
|
||||
signed_transaction wallet_api::short_sell_asset(string seller_name, string amount_to_sell,
|
||||
signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to_sell,
|
||||
string asset_symbol, string amount_of_collateral, bool broadcast)
|
||||
{
|
||||
FC_ASSERT(!is_locked());
|
||||
return my->short_sell_asset(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, broadcast);
|
||||
return my->borrow_asset(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, broadcast);
|
||||
}
|
||||
} }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue