Update plugins and wallet to remove shorts

This commit is contained in:
Daniel Larimer 2015-06-16 11:22:28 -04:00
parent 663036f2aa
commit 4cee2ca608
6 changed files with 20 additions and 72 deletions

View file

@ -215,22 +215,6 @@ namespace graphene { namespace app {
return result; 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 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>(); 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: case operation::tag<limit_order_create_operation>::value:
market = op.op.get<limit_order_create_operation>().get_market(); market = op.op.get<limit_order_create_operation>().get_market();
break; 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: case operation::tag<fill_order_operation>::value:
market = op.op.get<fill_order_operation>().get_market(); market = op.op.get<fill_order_operation>().get_market();
break; break;
/* /*
case operation::tag<limit_order_cancel_operation>::value: case operation::tag<limit_order_cancel_operation>::value:
case operation::tag<short_order_cancel_operation>::value:
*/ */
default: break; default: break;
} }

View file

@ -22,7 +22,7 @@
#include <graphene/chain/operation_history_object.hpp> #include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/asset_object.hpp> #include <graphene/chain/asset_object.hpp>
#include <graphene/chain/limit_order_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/chain/key_object.hpp>
#include <graphene/net/node.hpp> #include <graphene/net/node.hpp>
#include <fc/api.hpp> #include <fc/api.hpp>
@ -142,13 +142,6 @@ namespace graphene { namespace app {
* @return The limit orders, ordered from least price to greatest * @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; 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 * @brief Get call orders in a given asset
* @param a ID of asset being called * @param a ID of asset being called
@ -342,7 +335,6 @@ FC_API(graphene::app::database_api,
(get_named_account_balances) (get_named_account_balances)
(lookup_asset_symbols) (lookup_asset_symbols)
(get_limit_orders) (get_limit_orders)
(get_short_orders)
(get_call_orders) (get_call_orders)
(get_settle_orders) (get_settle_orders)
(list_assets) (list_assets)

View file

@ -141,9 +141,7 @@ struct operation_get_impacted_accounts
} }
void operator()( const limit_order_create_operation& o )const { } 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 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 call_order_update_operation& o )const { }
void operator()( const key_create_operation& o )const { } void operator()( const key_create_operation& o )const { }
void operator()( const custom_operation& o )const { } void operator()( const custom_operation& o )const { }

View file

@ -22,7 +22,7 @@
#include <graphene/chain/delegate_object.hpp> #include <graphene/chain/delegate_object.hpp>
#include <graphene/chain/witness_object.hpp> #include <graphene/chain/witness_object.hpp>
#include <graphene/chain/limit_order_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/proposal_object.hpp>
#include <graphene/chain/operation_history_object.hpp> #include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/withdraw_permission_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 ); return create_object_of_type< witness_object >( v );
case limit_order_object_type: case limit_order_object_type:
return create_object_of_type< limit_order_object >( v ); 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: case call_order_object_type:
return create_object_of_type< call_order_object >( v ); return create_object_of_type< call_order_object >( v );
/* /*

View file

@ -114,7 +114,6 @@ class wallet_api
vector<asset_object> list_assets(const string& lowerbound, uint32_t limit)const; 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<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<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<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; vector<force_settlement_object> get_settle_orders(string a, uint32_t limit)const;
global_property_object get_global_properties() const; global_property_object get_global_properties() const;
@ -204,7 +203,11 @@ class wallet_api
bool fill_or_kill = false, bool fill_or_kill = false,
bool broadcast = 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); string amount_of_collateral, bool broadcast = false);
signed_transaction create_asset(string issuer, signed_transaction create_asset(string issuer,
@ -272,7 +275,7 @@ FC_API( graphene::wallet::wallet_api,
(upgrade_account) (upgrade_account)
(create_account_with_brain_key) (create_account_with_brain_key)
(sell_asset) (sell_asset)
(short_sell_asset) (borrow_asset)
(transfer) (transfer)
(create_asset) (create_asset)
(issue_asset) (issue_asset)
@ -289,7 +292,6 @@ FC_API( graphene::wallet::wallet_api,
(load_wallet_file) (load_wallet_file)
(normalize_brain_key) (normalize_brain_key)
(get_limit_orders) (get_limit_orders)
(get_short_orders)
(get_call_orders) (get_call_orders)
(get_settle_orders) (get_settle_orders)
(save_wallet_file) (save_wallet_file)

View file

@ -1011,7 +1011,7 @@ public:
return sign_transaction( tx, broadcast ); 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) string amount_of_collateral, bool broadcast = false)
{ {
account_object seller = get_account(seller_name); account_object seller = get_account(seller_name);
@ -1019,11 +1019,10 @@ public:
FC_ASSERT(mia.is_market_issued()); FC_ASSERT(mia.is_market_issued());
asset_object collateral = get_asset(get_object(*mia.bitasset_data_id).options.short_backing_asset); asset_object collateral = get_asset(get_object(*mia.bitasset_data_id).options.short_backing_asset);
short_order_create_operation op; call_order_update_operation op;
op.seller = seller.id; op.funding_account = seller.id;
op.expiration = fc::time_point::now() + fc::days(365*10); op.amount_to_cover = -mia.amount_from_string(amount_to_sell);
op.amount_to_sell = mia.amount_from_string(amount_to_sell); op.collateral_to_add = collateral.amount_from_string(amount_of_collateral);
op.collateral = collateral.amount_from_string(amount_of_collateral);
signed_transaction trx; signed_transaction trx;
trx.operations = {op}; trx.operations = {op};
@ -1040,27 +1039,11 @@ public:
FC_ASSERT(order_id.space() == protocol_ids, "Invalid order ID ${id}", ("id", order_id)); FC_ASSERT(order_id.space() == protocol_ids, "Invalid order ID ${id}", ("id", order_id));
signed_transaction trx; signed_transaction trx;
switch( order_id.type() ) limit_order_cancel_operation op;
{ op.fee_paying_account = get_object<limit_order_object>(order_id).seller;
case short_order_object_type: { op.order = order_id;
short_order_cancel_operation op; op.fee = op.calculate_fee(_remote_db->get_global_properties().parameters.current_fees);
op.fee_paying_account = get_object<short_order_object>(order_id).seller; trx.operations = {op};
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));
}
trx.validate(); trx.validate();
return sign_transaction(trx, broadcast); 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); 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 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); 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); 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) string asset_symbol, string amount_of_collateral, bool broadcast)
{ {
FC_ASSERT(!is_locked()); 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);
} }
} } } }