Pretty-print bet place, fill, refund, cancellation
This commit is contained in:
parent
596ab26eb5
commit
ad11c45415
2 changed files with 62 additions and 2 deletions
|
|
@ -1573,6 +1573,13 @@ class wallet_api
|
|||
|
||||
asset get_total_matched_bet_amount_for_betting_market_group(betting_market_group_id_type group_id);
|
||||
std::vector<event_object> get_events_containing_sub_string(const std::string& sub_string, const std::string& language);
|
||||
|
||||
/** Get an order book for a betting market, with orders aggregated into bins with similar
|
||||
* odds
|
||||
*
|
||||
* @param betting_market_id the betting market
|
||||
* @param precision the number of digits of precision for binning
|
||||
*/
|
||||
binned_order_book get_binned_order_book(graphene::chain::betting_market_id_type betting_market_id, int32_t precision);
|
||||
|
||||
vector<sport_object> list_sports() const;
|
||||
|
|
@ -1679,13 +1686,22 @@ class wallet_api
|
|||
fc::optional<internationalized_string_type> payout_condition,
|
||||
bool broadcast = false);
|
||||
|
||||
signed_transaction place_bet(string betting_account,
|
||||
/** Place a bet
|
||||
* @param bettor the account placing the bet
|
||||
* @param betting_market_id the market on which to bet
|
||||
* @param back_or_lay back or lay
|
||||
* @param amount the amount to bet
|
||||
* @param asset_symbol the asset to bet with (must be the same as required by the betting market group)
|
||||
* @param backer_multiplier the odds (use 2.0 for a 1:1 bet)
|
||||
* @param broadcast true to broadcast the transaction
|
||||
*/
|
||||
signed_transaction place_bet(string bettor,
|
||||
betting_market_id_type betting_market_id,
|
||||
bet_type back_or_lay,
|
||||
string amount,
|
||||
string asset_symbol,
|
||||
double backer_multiplier,
|
||||
bool broadcast /*= false*/);
|
||||
bool broadcast = false);
|
||||
|
||||
signed_transaction propose_resolve_betting_market_group(
|
||||
const string& proposing_account,
|
||||
|
|
|
|||
|
|
@ -137,6 +137,10 @@ public:
|
|||
std::string operator()(const asset_create_operation& op)const;
|
||||
std::string operator()(const asset_dividend_distribution_operation& op)const;
|
||||
std::string operator()(const tournament_payout_operation& op)const;
|
||||
std::string operator()(const bet_place_operation& op)const;
|
||||
std::string operator()(const bet_matched_operation& op)const;
|
||||
std::string operator()(const bet_canceled_operation& op)const;
|
||||
std::string operator()(const bet_adjusted_operation& op)const;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
|
@ -3326,6 +3330,46 @@ std::string operation_printer::operator()(const tournament_payout_operation& op)
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string operation_printer::operator()(const bet_place_operation& op)const
|
||||
{
|
||||
auto fee_asset = wallet.get_asset(op.fee.asset_id);
|
||||
auto asset = wallet.get_asset(op.amount_to_bet.asset_id);
|
||||
auto bettor = wallet.get_account(op.bettor_id);
|
||||
|
||||
out << bettor.name << " placed a " << fc::json::to_string(op.back_or_lay) << " bet for "
|
||||
<< asset.amount_to_pretty_string(op.amount_to_bet) << " at odds " << ((double)op.backer_multiplier / GRAPHENE_BETTING_ODDS_PRECISION)
|
||||
<< " on market " << fc::json::to_string(op.betting_market_id)
|
||||
<< " fee: " << fee_asset.amount_to_pretty_string(op.fee);
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string operation_printer::operator()(const bet_matched_operation& op)const
|
||||
{
|
||||
auto asset = wallet.get_asset(op.amount_bet.asset_id);
|
||||
auto bettor = wallet.get_account(op.bettor_id);
|
||||
|
||||
out << " " << bettor.name << "'s bet " << fc::json::to_string(op.bet_id) << " matched " << asset.amount_to_pretty_string(op.amount_bet) << " at odds " << ((double)op.backer_multiplier / GRAPHENE_BETTING_ODDS_PRECISION);
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string operation_printer::operator()(const bet_canceled_operation& op)const
|
||||
{
|
||||
auto asset = wallet.get_asset(op.stake_returned.asset_id);
|
||||
auto bettor = wallet.get_account(op.bettor_id);
|
||||
|
||||
out << " " << bettor.name << "'s bet " << fc::json::to_string(op.bet_id) << " was canceled, " << asset.amount_to_pretty_string(op.stake_returned) << " returned";
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string operation_printer::operator()(const bet_adjusted_operation& op)const
|
||||
{
|
||||
auto asset = wallet.get_asset(op.stake_returned.asset_id);
|
||||
auto bettor = wallet.get_account(op.bettor_id);
|
||||
|
||||
out << " " << bettor.name << "'s bet " << fc::json::to_string(op.bet_id) << " was adjusted, " << asset.amount_to_pretty_string(op.stake_returned) << " returned";
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string operation_result_printer::operator()(const void_result& x) const
|
||||
{
|
||||
return "";
|
||||
|
|
|
|||
Loading…
Reference in a new issue