BitShares-Core  6.1.0
BitShares blockchain implementation and command-line interface software
asset_ops.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
28 
29 namespace graphene { namespace protocol {
30 
32  {
35  // After BSIP81 activation, taker_fee_percent is the taker fee
37  };
39 
40  bool is_valid_symbol( const string& symbol );
41 
47  struct asset_options {
54  // BSIP81: Asset owners may specify different market fee rate for maker orders and taker orders
55  // After BSIP81 activation, market_fee_percent is the maker fee
56  uint16_t market_fee_percent = 0;
59 
61  uint16_t issuer_permissions = DEFAULT_UIA_ASSET_ISSUER_PERMISSION;
63  uint16_t flags = 0;
64 
66  uint16_t get_enabled_issuer_permissions_mask() const;
67 
72  price core_exchange_rate = price(asset(), asset(0, asset_id_type(1)));
73 
76  flat_set<account_id_type> whitelist_authorities;
81  flat_set<account_id_type> blacklist_authorities;
82 
84  flat_set<asset_id_type> whitelist_markets;
86  flat_set<asset_id_type> blacklist_markets;
87 
92  string description;
93  additional_asset_options_t extensions;
94 
97  void validate()const;
98 
101  void validate_flags( bool is_market_issued, bool allow_disable_collateral_bid = true )const;
102  };
103 
110 
113  {
117  global_settlement = 0,
123  no_settlement = 1,
129  individual_settlement_to_fund = 2,
134  individual_settlement_to_order = 3,
136  BSRM_TYPE_COUNT = 4
137  };
138 
139  struct ext
140  {
151  // https://github.com/bitshares/bitshares-core/issues/2467
153  };
154 
156  uint32_t feed_lifetime_sec = GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME;
158  uint8_t minimum_feeds = 1;
160  uint32_t force_settlement_delay_sec = GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY;
162  uint16_t force_settlement_offset_percent = GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET;
168  uint16_t maximum_force_settlement_volume = GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME;
171  asset_id_type short_backing_asset;
172 
174 
177  void validate()const;
178 
181  {
182  if( !extensions.value.black_swan_response_method.valid() )
183  return black_swan_response_type::global_settlement;
184  return static_cast<black_swan_response_type>( *extensions.value.black_swan_response_method );
185  }
186  };
187 
188 
193  {
195  uint64_t symbol3 = 500000 * GRAPHENE_BLOCKCHAIN_PRECISION;
196  uint64_t symbol4 = 300000 * GRAPHENE_BLOCKCHAIN_PRECISION;
197  uint64_t long_symbol = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION;
198  uint32_t price_per_kbyte = 10;
199  };
200 
203  account_id_type issuer;
205  string symbol;
207  uint8_t precision = 0;
208 
219  bool is_prediction_market = false;
221 
222  account_id_type fee_payer()const { return issuer; }
223  void validate()const;
224  share_type calculate_fee( const fee_parameters_type& k,
225  const optional<uint64_t>& sub_asset_creation_fee )const;
226  };
227 
239  {
240  struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; };
241 
243  account_id_type issuer;
244  asset_id_type asset_to_settle;
247 
248  account_id_type fee_payer()const { return issuer; }
249  void validate()const;
250  };
251 
268  {
276  uint64_t fee = 100 * GRAPHENE_BLOCKCHAIN_PRECISION;
277  };
278 
281  account_id_type account;
285 
286  account_id_type fee_payer()const { return account; }
287  void validate()const;
288  };
289 
294  {
296 
297  asset_settle_cancel_operation() = default;
298  asset_settle_cancel_operation( const force_settlement_id_type& fsid, const account_id_type& aid,
299  const asset& a ) : settlement(fsid), account(aid), amount(a) {}
300 
302  force_settlement_id_type settlement;
304  account_id_type account;
307 
308  account_id_type fee_payer()const { return account; }
309  /***
310  * This is a virtual operation and should never be placed in a block
311  * (i.e. in a proposal)
312  */
313  void validate() const { FC_ASSERT( !"Virtual operation"); }
314 
316  { return 0; }
317  };
318 
323  {
325 
327  account_id_type from_account;
328  asset_id_type asset_id;
331 
332  account_id_type fee_payer()const { return from_account; }
333  void validate()const;
334  };
335 
352  {
353  struct ext
354  {
361  };
362 
364  uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION;
365  uint32_t price_per_kbyte = 10;
366  };
367 
369 
371  account_id_type issuer;
372  asset_id_type asset_to_update;
373 
378 
379  account_id_type fee_payer()const { return issuer; }
380  void validate()const;
381  share_type calculate_fee(const fee_parameters_type& k)const;
382  };
383 
399  {
400  struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; };
401 
403  account_id_type issuer;
404  asset_id_type asset_to_update;
405 
408 
409  account_id_type fee_payer()const { return issuer; }
410  void validate()const;
411  };
412 
431  {
432  struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; };
433 
435  account_id_type issuer;
436  asset_id_type asset_to_update;
437 
438  flat_set<account_id_type> new_feed_producers;
440 
441  account_id_type fee_payer()const { return issuer; }
442  void validate()const;
443  };
444 
463  {
464  struct ext
465  {
468  };
469 
471 
473  account_id_type publisher;
474  asset_id_type asset_id;
477 
478  account_id_type fee_payer()const { return publisher; }
479  void validate()const;
480  };
481 
486  {
488  uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
489  uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION;
490  };
491 
493  account_id_type issuer;
495  account_id_type issue_to_account;
496 
497 
501 
502  account_id_type fee_payer()const { return issuer; }
503  void validate()const;
504  share_type calculate_fee(const fee_parameters_type& k)const;
505  };
506 
514  {
515  struct fee_parameters_type { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; };
516 
518  account_id_type payer;
521 
522  account_id_type fee_payer()const { return payer; }
523  void validate()const;
524  };
525 
530  {
532  uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
533  };
534 
536  {
543  };
544 
546  account_id_type issuer;
548 
550 
551  account_id_type fee_payer()const { return issuer; }
552  void validate()const;
553  };
554 
566  {
568  uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
569  };
570 
572  account_id_type issuer;
573  asset_id_type asset_to_update;
574  account_id_type new_issuer;
576 
577  account_id_type fee_payer()const { return issuer; }
578  void validate()const;
579 
580  void get_required_owner_authorities( flat_set<account_id_type>& a )const
581  { a.insert( issuer ); }
582 
583  void get_required_active_authorities( flat_set<account_id_type>& a )const
584  { }
585 
586  };
587 
602  {
604  uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
605  };
606 
608  account_id_type issuer;
609  asset_id_type asset_id;
612 
613  account_id_type fee_payer()const { return issuer; }
614  void validate()const;
615  };
616 
617 } } // graphene::protocol
618 
619 FC_REFLECT( graphene::protocol::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) )
622 
623 FC_REFLECT( graphene::protocol::asset_claim_pool_operation, (fee)(issuer)(asset_id)(amount_to_claim)(extensions) )
625 
627  (max_supply)
628  (market_fee_percent)
629  (max_market_fee)
630  (issuer_permissions)
631  (flags)
632  (core_exchange_rate)
633  (whitelist_authorities)
634  (blacklist_authorities)
635  (whitelist_markets)
636  (blacklist_markets)
637  (description)
638  (extensions)
639  )
640 
642  (initial_collateral_ratio)
643  (maintenance_collateral_ratio)
644  (maximum_short_squeeze_ratio)
645  (margin_call_fee_ratio)
646  (force_settle_fee_percent)
647  (black_swan_response_method)
648  )
649 
651  (feed_lifetime_sec)
652  (minimum_feeds)
653  (force_settlement_delay_sec)
654  (force_settlement_offset_percent)
655  (maximum_force_settlement_volume)
656  (short_backing_asset)
657  (extensions)
658  )
659 
662 
663 FC_REFLECT( graphene::protocol::asset_update_operation::ext, (new_precision)(skip_core_exchange_rate) )
665 
667  (symbol3)(symbol4)(long_symbol)(price_per_kbyte) )
668 
680 
681 
683  (fee)
684  (issuer)
685  (symbol)
686  (precision)
687  (common_options)
688  (bitasset_opts)
689  (is_prediction_market)
690  (extensions)
691  )
693  (fee)
694  (issuer)
695  (asset_to_update)
696  (new_issuer)
697  (new_options)
698  (extensions)
699  )
701  (fee)
702  (issuer)
703  (asset_to_update)
704  (new_issuer)
705  (extensions)
706  )
708  (fee)
709  (issuer)
710  (asset_to_update)
711  (new_options)
712  (extensions)
713  )
715  (fee)(issuer)(asset_to_update)(new_feed_producers)(extensions)
716  )
718  (fee)(publisher)(asset_id)(feed)(extensions) )
719 FC_REFLECT( graphene::protocol::asset_settle_operation, (fee)(account)(amount)(extensions) )
720 FC_REFLECT( graphene::protocol::asset_settle_cancel_operation, (fee)(settlement)(account)(amount) )
722  (fee)(issuer)(asset_to_settle)(settle_price)(extensions) )
724  (fee)(issuer)(asset_to_issue)(issue_to_account)(memo)(extensions) )
726  (fee)(payer)(amount_to_reserve)(extensions) )
727 
728 FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) )
729 
734 
737 
753 
fc::optional< uint16_t > force_settle_fee_percent
Definition: asset_ops.hpp:150
future_extensions::flat_set_type extensions_type
Definition: base.hpp:156
asset_id_type asset_id
asset for which the feed is published
Definition: asset_ops.hpp:474
account_id_type issuer
must match issuer of asset from which we claim fees
Definition: asset_ops.hpp:546
black_swan_response_type get_black_swan_response_method() const
Get the effective black swan response method.
Definition: asset_ops.hpp:180
fc::optional< flat_set< account_id_type > > whitelist_market_fee_sharing
Definition: asset_ops.hpp:34
Update the set of feed-producing accounts for a BitAssetBitAssets have price feeds selected by taking...
Definition: asset_ops.hpp:430
flat_set< account_id_type > blacklist_authorities
Definition: asset_ops.hpp:81
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
black_swan_response_type
Defines how a BitAsset would respond to black swan events.
Definition: asset_ops.hpp:112
extension< additional_options_type > extensions
Definition: asset_ops.hpp:549
asset amount
Amount of asset to force settle. This must be a market-issued asset.
Definition: asset_ops.hpp:283
Definition: api.cpp:48
fc::optional< uint16_t > maximum_short_squeeze_ratio
After BSIP75, the asset owner can update MSSR directly.
Definition: asset_ops.hpp:148
The asset_options struct contains options available on all assets in the network. ...
Definition: asset_ops.hpp:47
used to transfer accumulated fees back to the issuer&#39;s balance.
Definition: asset_ops.hpp:529
#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET
1%
Definition: config.hpp:70
extension< additional_asset_options > additional_asset_options_t
Definition: asset_ops.hpp:38
Schedules a market-issued asset for automatic settlementHolders of market-issued assests may request ...
Definition: asset_ops.hpp:267
#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY
1 day
Definition: config.hpp:69
flat_set< asset_id_type > blacklist_markets
Definition: asset_ops.hpp:86
#define GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME
20%
Definition: config.hpp:71
Publish price feeds for market-issued assetsPrice feed providers use this operation to publish their ...
Definition: asset_ops.hpp:462
fc::optional< uint16_t > initial_collateral_ratio
After BSIP77, price feed producers can feed ICR too.
Definition: asset_ops.hpp:467
string symbol
The ticker symbol of this asset.
Definition: asset_ops.hpp:205
fc::optional< uint16_t > reward_percent
Definition: asset_ops.hpp:33
used to take an asset out of circulation, returning to the issuer
Definition: asset_ops.hpp:513
flat_set< asset_id_type > whitelist_markets
Definition: asset_ops.hpp:84
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
fc::optional< uint16_t > maintenance_collateral_ratio
After BSIP75, the asset owner can update MCR directly.
Definition: asset_ops.hpp:146
The price struct stores asset prices in the BitShares system.
Definition: asset.hpp:108
share_type calculate_fee(const fee_parameters_type &params) const
Definition: asset_ops.hpp:315
#define GRAPHENE_BLOCKCHAIN_PRECISION
Definition: config.hpp:29
Update options specific to BitAssetsBitAssets have some options which are not relevant to other asset...
Definition: asset_ops.hpp:398
fc::optional< uint16_t > margin_call_fee_ratio
Definition: asset_ops.hpp:149
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
account_id_type account
Account requesting the force settlement. This account pays the fee.
Definition: asset_ops.hpp:281
account_id_type issuer
Must be asset_to_issue->asset_id->issuer.
Definition: asset_ops.hpp:493
Update options common to all assetsThere are a number of options which all assets in the network use...
Definition: asset_ops.hpp:351
fc::optional< uint8_t > black_swan_response_method
Definition: asset_ops.hpp:152
account_id_type issuer
This account must sign and pay the fee for this operation. Later, this account may update the asset...
Definition: asset_ops.hpp:203
asset_settle_cancel_operation(const force_settlement_id_type &fsid, const account_id_type &aid, const asset &a)
Definition: asset_ops.hpp:298
account_id_type account
Account requesting the force settlement. This account pays the fee.
Definition: asset_ops.hpp:304
Transfers BTS from the fee pool of a specified asset back to the issuer&#39;s balance.
Definition: asset_ops.hpp:601
defines market parameters for margin positions
Definition: asset.hpp:160
#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME
1 day
Definition: config.hpp:72
void get_required_owner_authorities(flat_set< account_id_type > &a) const
Definition: asset_ops.hpp:580
optional< bitasset_options > bitasset_opts
Options only available for BitAssets. MUST be non-null if and only if the asset is market-issued...
Definition: asset_ops.hpp:217
asset amount_to_claim
fee.asset_id must != asset_id
Definition: asset_ops.hpp:610
fc::optional< uint16_t > taker_fee_percent
Definition: asset_ops.hpp:36
constexpr int64_t GRAPHENE_MAX_SHARE_SUPPLY(1000000000000000LL)
flat_set< account_id_type > whitelist_authorities
Definition: asset_ops.hpp:76
asset amount
Amount of asset to force settle. This must be a market-issued asset.
Definition: asset_ops.hpp:306
Update issuer of an assetAn issuer has general administrative power of an asset and in some cases als...
Definition: asset_ops.hpp:565
void get_required_active_authorities(flat_set< account_id_type > &a) const
Definition: asset_ops.hpp:583
additional_asset_options_t extensions
Definition: asset_ops.hpp:93
fc::optional< uint16_t > initial_collateral_ratio
Definition: asset_ops.hpp:144
account_id_type issuer
must equal issuer of asset_to_settle
Definition: asset_ops.hpp:243
The bitasset_options struct contains configurable options available only to BitAssets.
Definition: asset_ops.hpp:109
bool is_valid_symbol(const string &symbol)
Definition: asset_ops.cpp:38
allows global settling of bitassets (black swan or prediction markets)
Definition: asset_ops.hpp:238
optional< account_id_type > new_issuer
If the asset is to be given a new issuer, specify his ID here.
Definition: asset_ops.hpp:375