-
Notifications
You must be signed in to change notification settings - Fork 0
Introducing BTCM and xUSD #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: testnet
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -555,45 +555,61 @@ void feed_publish_evaluator::do_apply( const feed_publish_operation& o ) | |
| } | ||
|
|
||
| void convert_evaluator::do_apply( const convert_operation& o ) | ||
| { | ||
| if( o.amount.asset_id == MUSE_SYMBOL ) | ||
| FC_ASSERT( db().has_hardfork( MUSE_HARDFORK_0_6 ), "XSD -> xUSD conversion only allowed after hardfork 6!" ); | ||
|
|
||
| const auto& owner = db().get_account( o.owner ); | ||
| FC_ASSERT( db().get_balance( owner, o.amount.asset_id ) >= o.amount ); | ||
|
|
||
| db().adjust_balance( owner, -o.amount ); | ||
|
|
||
| const auto& fhistory = db().get_feed_history(); | ||
| FC_ASSERT( !fhistory.effective_median_history.is_null() ); | ||
|
|
||
| if( o.amount.asset_id == MUSE_SYMBOL ) | ||
| { | ||
| const asset amount_to_issue = o.amount * fhistory.effective_median_history; | ||
|
|
||
| db().adjust_balance( owner, amount_to_issue ); | ||
|
|
||
| db().push_applied_operation( fill_convert_request_operation ( o.owner, o.requestid, o.amount, amount_to_issue ) ); | ||
|
|
||
| db().modify( db().get_dynamic_global_properties(), | ||
| [&o,&amount_to_issue,&fhistory]( dynamic_global_property_object& p ) | ||
| { | ||
| p.current_supply -= o.amount; | ||
| p.current_mbd_supply += amount_to_issue; | ||
| p.virtual_supply -= o.amount; | ||
| p.virtual_supply += amount_to_issue * fhistory.effective_median_history; | ||
| } ); | ||
| } | ||
| else | ||
| db().create<convert_request_object>( [&]( convert_request_object& obj ) | ||
| { | ||
| obj.owner = o.owner; | ||
| obj.requestid = o.requestid; | ||
| obj.amount = o.amount; | ||
| obj.conversion_date = db().head_block_time() + MUSE_CONVERSION_DELAY; // 1 week | ||
| }); | ||
|
|
||
| } | ||
| { | ||
| if( o.amount.asset_id == MUSE_SYMBOL || BTCM_SYMBOL ) | ||
| FC_ASSERT( db().has_hardfork( MUSE_HARDFORK_0_6 ), "XSD -> xUSD & XSD -> BTCM conversion only allowed after hardfork 6!" ); | ||
|
|
||
| const auto& owner = db().get_account( o.owner ); | ||
|
|
||
| if( o.amount.asset_id == MBD_SYMBOL ) { | ||
| FC_ASSERT( db().get_balance( owner, o.amount.asset_id ) >= o.amount ); | ||
| db().adjust_balance( owner, -o.amount );} | ||
|
|
||
| const auto& fhistory = db().get_feed_history(); | ||
| FC_ASSERT( !fhistory.effective_median_history.is_null() ); | ||
|
|
||
| if( o.amount.asset_id == MUSE_SYMBOL ) | ||
| { | ||
| const asset amount_to_issue = o.amount * fhistory.effective_median_history; | ||
| const asset amount_to_subtract = o; | ||
| amount_to_issue.amount.asset_id = MBD_SYMBOL; //making sure it's the new MBD asset id for safety | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this even compile? I think the |
||
| amount_to_subtract.amount.asset_id = BTCM_SYMBOL; //converts 1 USD worth of BTCM to MBD | ||
| FC_ASSERT( db().get_balance( owner, amount_to_subtract.amount.asset_id ) >= amount_to_subtract.amount ); | ||
| db().adjust_balance( owner, -amount_to_subtract.amount );} | ||
| db().adjust_balance( owner, amount_to_issue ); | ||
|
|
||
| db().push_applied_operation( fill_convert_request_operation ( o.owner, o.requestid, amount_to_subtract.amount, amount_to_issue ) ); | ||
|
|
||
| db().modify( db().get_dynamic_global_properties(), | ||
| [&o,&amount_to_issue,&fhistory]( dynamic_global_property_object& p ) | ||
| { | ||
| p.current_supply -= o.amount; | ||
| p.current_mbd_supply += amount_to_issue; | ||
| p.virtual_supply -= o.amount; | ||
| p.virtual_supply += amount_to_issue * fhistory.effective_median_history; | ||
| } ); | ||
| } | ||
| else if( o.amount.asset_id == BTCM_SYMBOL ) //this operation will convert MUSE into BTCM | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a possible way to do it. However,
|
||
| { | ||
| const asset amount_to_issue = o; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean |
||
| const asset amount_to_subtract = o; | ||
| amount_to_subract.amount.asset_id = MUSE_SYMBOL; | ||
| FC_ASSERT( db().get_balance( owner, amount_to_subtract.amount.asset_id ) >= amount_to_subtract.amount ); | ||
| db().adjust_balance( owner, -amount_to_subtract.amount ); | ||
| db().adjust_balance( owner, amount_to_issue.amount ); | ||
|
|
||
| db().push_applied_operation( fill_convert_request_operation ( o.owner, o.requestid, amount_to_subtract.amount, amount_to_issue ) ); //no supply updates are required | ||
| } | ||
| else | ||
| db().create<convert_request_object>( [&]( convert_request_object& obj ) | ||
| { | ||
| obj.owner = o.owner; | ||
| obj.requestid = o.requestid; | ||
| obj.amount = o.amount; | ||
| obj.conversion_date = db().head_block_time() + MUSE_CONVERSION_DELAY; // 1 week | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| void limit_order_create_evaluator::do_apply( const limit_order_create_operation& o ) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,8 +64,8 @@ const uint8_t streaming_platform_object::type_id; | |
|
|
||
| muse::chain::asset_id_type MUSE_SYMBOL=(muse::chain::asset_id_type(0)); | ||
| muse::chain::asset_id_type VESTS_SYMBOL=(muse::chain::asset_id_type(1)); | ||
| muse::chain::asset_id_type MBD_SYMBOL=(muse::chain::asset_id_type(2)); | ||
| muse::chain::asset_id_type MBD_SYMBOL=(muse::chain::asset_id_type(13)); //changing MBD id from 2 to 13 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't do that. This will retroactively change Also, you shouldn't use fixed IDs here. The 3 base assets are created by the core code automatically and therefore have known IDs, but anything after these will be assigned an ID upon creation. One way to deal with this could be to register the assets manually both in testnet and in mainnet, and then insert the resulting IDs into the codebase (which will likely be different between mainnet and testnet). |
||
| muse::chain::asset_id_type BTCM_SYMBOL=(muse::chain::asset_id_type(11)); //declaring BTCM as asset id 11 | ||
|
|
||
| inline u256 to256( const fc::uint128& t ) { | ||
| u256 v(t.hi); | ||
|
|
@@ -2156,7 +2156,7 @@ asset database::get_producer_reward() | |
|
|
||
| /** | ||
| * Iterates over all conversion requests with a conversion date before | ||
| * the head block time and then converts them to/from muse/mbd at the | ||
| * the head block time and then converts them to/from BTCM/mbd at the | ||
| * current median price feed history price times the premium | ||
| */ | ||
| void database::process_conversions() | ||
|
|
@@ -2176,11 +2176,13 @@ void database::process_conversions() | |
| { | ||
| const auto& user = get_account( itr->owner ); | ||
| auto amount_to_issue = itr->amount * fhistory.effective_median_history; | ||
| amount_to_issue.amount.asset_id = BTCM_SYMBOL; //the asset issued is modified to BTCM instead of MUSE | ||
|
|
||
|
|
||
| adjust_balance( user, amount_to_issue ); | ||
|
|
||
| net_mbd += itr->amount; | ||
| net_muse += amount_to_issue; | ||
| net_muse += amount_to_issue; //the total supply still needs to be added as BTCM is considered as an additional base asset | ||
|
|
||
| push_applied_operation( fill_convert_request_operation ( user.name, itr->requestid, itr->amount, amount_to_issue ) ); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,8 +55,8 @@ | |
| #define MUSE_ADDRESS_PREFIX "MUSE" | ||
| #define MUSE_SYMBOL_STRING (BASE_SYMBOL) | ||
| #define VESTS_SYMBOL_STRING "VESTS" | ||
| #define MBD_SYMBOL_STRING "MBD" | ||
|
|
||
| #define MBD_SYMBOL_STRING "XUSD" //Changing the stablecoin asset from MBD to XUSD | ||
| #define BTCM_SYMBOL_STRING "BTCM" //New base asset of Bitcoin Music | ||
| #define NULL_SYMBOL (uint64_t(3) ) | ||
|
|
||
| #define MUSE_GENESIS_TIME (fc::time_point_sec(1458835200)) | ||
|
|
@@ -92,7 +92,7 @@ | |
| #define MUSE_MAX_TIME_UNTIL_EXPIRATION (60*60) // seconds, aka: 1 hour | ||
| #define MUSE_MAX_MEMO_SIZE 2048 | ||
| #define MUSE_MAX_PROXY_RECURSION_DEPTH 4 | ||
| #define MUSE_VESTING_WITHDRAW_INTERVALS 13 | ||
| #define MUSE_VESTING_WITHDRAW_INTERVALS 4 //changing vesting period from 13 weeks to 4 weeks | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above: you cannot simply change this because the change would happen retroactively. You can define a new interval, and use one or the other depending on whether it happens before or after the upgrade. |
||
| #define MUSE_VESTING_WITHDRAW_INTERVAL_SECONDS (60*60*24*7) /// 1 week per interval | ||
| #define MUSE_MAX_WITHDRAW_ROUTES 10 | ||
| #define MUSE_VOTE_REGENERATION_SECONDS (5*60*60*24) // 5 day | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot assign
ohere. Did you mean0?