BitShares-Core  4.0.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 )const;
102  };
103 
110 
111  struct ext
112  {
123  };
124 
126  uint32_t feed_lifetime_sec = GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME;
128  uint8_t minimum_feeds = 1;
130  uint32_t force_settlement_delay_sec = GRAPHENE_DEFAULT_FORCE_SETTLEMENT_DELAY;
132  uint16_t force_settlement_offset_percent = GRAPHENE_DEFAULT_FORCE_SETTLEMENT_OFFSET;
138  uint16_t maximum_force_settlement_volume = GRAPHENE_DEFAULT_FORCE_SETTLEMENT_MAX_VOLUME;
141  asset_id_type short_backing_asset;
142 
144 
147  void validate()const;
148  };
149 
150 
155  {
157  uint64_t symbol3 = 500000 * GRAPHENE_BLOCKCHAIN_PRECISION;
158  uint64_t symbol4 = 300000 * GRAPHENE_BLOCKCHAIN_PRECISION;
159  uint64_t long_symbol = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION;
160  uint32_t price_per_kbyte = 10;
161  };
162 
165  account_id_type issuer;
167  string symbol;
169  uint8_t precision = 0;
170 
181  bool is_prediction_market = false;
183 
184  account_id_type fee_payer()const { return issuer; }
185  void validate()const;
186  share_type calculate_fee( const fee_parameters_type& k, optional<uint64_t> sub_asset_creation_fee )const;
187  };
188 
200  {
201  struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; };
202 
204  account_id_type issuer;
205  asset_id_type asset_to_settle;
208 
209  account_id_type fee_payer()const { return issuer; }
210  void validate()const;
211  };
212 
227  {
235  uint64_t fee = 100 * GRAPHENE_BLOCKCHAIN_PRECISION;
236  };
237 
240  account_id_type account;
244 
245  account_id_type fee_payer()const { return account; }
246  void validate()const;
247  };
248 
253  {
255 
257  force_settlement_id_type settlement;
259  account_id_type account;
263 
264  account_id_type fee_payer()const { return account; }
265  /***
266  * This is a virtual operation and should never be placed in a block
267  * (i.e. in a proposal)
268  */
269  void validate() const { FC_ASSERT( !"Virtual operation"); }
270 
272  { return 0; }
273  };
274 
279  {
281 
283  account_id_type from_account;
284  asset_id_type asset_id;
287 
288  account_id_type fee_payer()const { return from_account; }
289  void validate()const;
290  };
291 
308  {
309  struct ext
310  {
317  };
318 
320  uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION;
321  uint32_t price_per_kbyte = 10;
322  };
323 
325 
327  account_id_type issuer;
328  asset_id_type asset_to_update;
329 
334 
335  account_id_type fee_payer()const { return issuer; }
336  void validate()const;
337  share_type calculate_fee(const fee_parameters_type& k)const;
338  };
339 
354  {
355  struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; };
356 
358  account_id_type issuer;
359  asset_id_type asset_to_update;
360 
363 
364  account_id_type fee_payer()const { return issuer; }
365  void validate()const;
366  };
367 
385  {
386  struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; };
387 
389  account_id_type issuer;
390  asset_id_type asset_to_update;
391 
392  flat_set<account_id_type> new_feed_producers;
394 
395  account_id_type fee_payer()const { return issuer; }
396  void validate()const;
397  };
398 
416  {
417  struct ext
418  {
421  };
422 
424 
426  account_id_type publisher;
427  asset_id_type asset_id;
430 
431  account_id_type fee_payer()const { return publisher; }
432  void validate()const;
433  };
434 
439  {
441  uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
442  uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION;
443  };
444 
446  account_id_type issuer;
448  account_id_type issue_to_account;
449 
450 
454 
455  account_id_type fee_payer()const { return issuer; }
456  void validate()const;
457  share_type calculate_fee(const fee_parameters_type& k)const;
458  };
459 
467  {
468  struct fee_parameters_type { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; };
469 
471  account_id_type payer;
474 
475  account_id_type fee_payer()const { return payer; }
476  void validate()const;
477  };
478 
483  {
485  uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
486  };
487 
489  {
496  };
497 
499  account_id_type issuer;
501 
503 
504  account_id_type fee_payer()const { return issuer; }
505  void validate()const;
506  };
507 
519  {
521  uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
522  };
523 
525  account_id_type issuer;
526  asset_id_type asset_to_update;
527  account_id_type new_issuer;
529 
530  account_id_type fee_payer()const { return issuer; }
531  void validate()const;
532 
533  void get_required_owner_authorities( flat_set<account_id_type>& a )const
534  { a.insert( issuer ); }
535 
536  void get_required_active_authorities( flat_set<account_id_type>& a )const
537  { }
538 
539  };
540 
555  {
557  uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
558  };
559 
561  account_id_type issuer;
562  asset_id_type asset_id;
565 
566  account_id_type fee_payer()const { return issuer; }
567  void validate()const;
568  };
569 
570 } } // graphene::protocol
571 
572 FC_REFLECT( graphene::protocol::asset_claim_fees_operation, (fee)(issuer)(amount_to_claim)(extensions) )
575 
576 FC_REFLECT( graphene::protocol::asset_claim_pool_operation, (fee)(issuer)(asset_id)(amount_to_claim)(extensions) )
578 
580  (max_supply)
581  (market_fee_percent)
582  (max_market_fee)
583  (issuer_permissions)
584  (flags)
585  (core_exchange_rate)
586  (whitelist_authorities)
587  (blacklist_authorities)
588  (whitelist_markets)
589  (blacklist_markets)
590  (description)
591  (extensions)
592  )
593 
595  (initial_collateral_ratio)
596  (maintenance_collateral_ratio)
597  (maximum_short_squeeze_ratio)
598  (margin_call_fee_ratio)
599  (force_settle_fee_percent)
600  )
601 
603  (feed_lifetime_sec)
604  (minimum_feeds)
605  (force_settlement_delay_sec)
606  (force_settlement_offset_percent)
607  (maximum_force_settlement_volume)
608  (short_backing_asset)
609  (extensions)
610  )
611 
614 
615 FC_REFLECT( graphene::protocol::asset_update_operation::ext, (new_precision)(skip_core_exchange_rate) )
617 
619  (symbol3)(symbol4)(long_symbol)(price_per_kbyte) )
620 
632 
633 
635  (fee)
636  (issuer)
637  (symbol)
638  (precision)
639  (common_options)
640  (bitasset_opts)
641  (is_prediction_market)
642  (extensions)
643  )
645  (fee)
646  (issuer)
647  (asset_to_update)
648  (new_issuer)
649  (new_options)
650  (extensions)
651  )
653  (fee)
654  (issuer)
655  (asset_to_update)
656  (new_issuer)
657  (extensions)
658  )
660  (fee)
661  (issuer)
662  (asset_to_update)
663  (new_options)
664  (extensions)
665  )
667  (fee)(issuer)(asset_to_update)(new_feed_producers)(extensions)
668  )
670  (fee)(publisher)(asset_id)(feed)(extensions) )
671 FC_REFLECT( graphene::protocol::asset_settle_operation, (fee)(account)(amount)(extensions) )
672 FC_REFLECT( graphene::protocol::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) )
673 FC_REFLECT( graphene::protocol::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) )
675  (fee)(issuer)(asset_to_issue)(issue_to_account)(memo)(extensions) )
677  (fee)(payer)(amount_to_reserve)(extensions) )
678 
679 FC_REFLECT( graphene::protocol::asset_fund_fee_pool_operation, (fee)(from_account)(asset_id)(amount)(extensions) );
680 
685 
688 
703 
fc::optional< uint16_t > force_settle_fee_percent
Definition: asset_ops.hpp:122
future_extensions::flat_set_type extensions_type
Definition: base.hpp:128
asset_id_type asset_id
asset for which the feed is published
Definition: asset_ops.hpp:427
share_type calculate_fee(const fee_parameters_type &params) const
Definition: asset_ops.hpp:271
account_id_type issuer
must match issuer of asset from which we claim fees
Definition: asset_ops.hpp:499
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:384
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:386
extension< additional_options_type > extensions
Definition: asset_ops.hpp:502
asset amount
Amount of asset to force settle. This must be a market-issued asset.
Definition: asset_ops.hpp:242
Definition: api.cpp:56
fc::optional< uint16_t > maximum_short_squeeze_ratio
After BSIP75, the asset owner can update MSSR directly.
Definition: asset_ops.hpp:120
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:482
#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:226
#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:415
fc::optional< uint16_t > initial_collateral_ratio
After BSIP77, price feed producers can feed ICR too.
Definition: asset_ops.hpp:420
#define GRAPHENE_MAX_SHARE_SUPPLY
Definition: config.hpp:38
string symbol
The ticker symbol of this asset.
Definition: asset_ops.hpp:167
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:466
flat_set< asset_id_type > whitelist_markets
Definition: asset_ops.hpp:84
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:73
fc::optional< uint16_t > maintenance_collateral_ratio
After BSIP75, the asset owner can update MCR directly.
Definition: asset_ops.hpp:118
The price struct stores asset prices in the BitShares system.
Definition: asset.hpp:114
#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:353
fc::optional< uint16_t > margin_call_fee_ratio
Definition: asset_ops.hpp:121
#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:240
account_id_type issuer
Must be asset_to_issue->asset_id->issuer.
Definition: asset_ops.hpp:446
void get_required_active_authorities(flat_set< account_id_type > &a) const
Definition: asset_ops.hpp:536
Update options common to all assetsThere are a number of options which all assets in the network use...
Definition: asset_ops.hpp:307
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:165
account_id_type account
Account requesting the force settlement. This account pays the fee.
Definition: asset_ops.hpp:259
Transfers BTS from the fee pool of a specified asset back to the issuer&#39;s balance.
Definition: asset_ops.hpp:554
defines market parameters for margin positions
Definition: asset.hpp:164
#define GRAPHENE_DEFAULT_PRICE_FEED_LIFETIME
1 day
Definition: config.hpp:72
optional< bitasset_options > bitasset_opts
Definition: asset_ops.hpp:179
asset amount_to_claim
fee.asset_id must != asset_id
Definition: asset_ops.hpp:563
fc::optional< uint16_t > taker_fee_percent
Definition: asset_ops.hpp:36
flat_set< account_id_type > whitelist_authorities
Definition: asset_ops.hpp:76
account_id_type fee_payer() const
Definition: asset_ops.hpp:455
void get_required_owner_authorities(flat_set< account_id_type > &a) const
Definition: asset_ops.hpp:533
asset amount
Amount of asset to force settle. This must be a market-issued asset.
Definition: asset_ops.hpp:261
Update issuer of an assetAn issuer has general administrative power of an asset and in some cases als...
Definition: asset_ops.hpp:518
additional_asset_options_t extensions
Definition: asset_ops.hpp:93
fc::optional< uint16_t > initial_collateral_ratio
Definition: asset_ops.hpp:116
account_id_type issuer
must equal asset_to_settle->issuer
Definition: asset_ops.hpp:204
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:199
optional< account_id_type > new_issuer
If the asset is to be given a new issuer, specify his ID here.
Definition: asset_ops.hpp:331