eosnetworkfoundation / eos-system-contracts

Other
28 stars 20 forks source link

Implement "Set/Delete/Exec Schedules" ACTION #136

Closed DenisCarriere closed 5 months ago

DenisCarriere commented 6 months ago

Purpose

Create setschedule, delschedule, execschedule, setpayfactor ACTION & schedules TABLE to allow for the scheduling of system annual inflation rate changes to be executed at a future time.

Feedback provided by

setschedule ACTION

/**
 * Set the schedule for pre-determined annual rate changes.
 *
 * @param start_time - the time to start the schedule.
 * @param annual_rate - the annual inflation rate of the core token supply.
 *     (eg. For 5% Annual inflation => annual_rate=500
 *          For 1.5% Annual inflation => annual_rate=150
 */
[[eosio::action]]
void setschedule( const time_point_sec start_time, int64_t annual_rate );

delschedule ACTION

/**
 * Delete the schedule for pre-determined annual rate changes.
 *
 * @param start_time - the time to start the schedule.
 */
[[eosio::action]]
void delschedule( const time_point_sec start_time );

execschedule ACTION

 /**
  * Executes the next schedule for pre-determined annual rate changes.
  *
  * Start time of the schedule must be in the past.
  *
  * Can be executed by any account.
  */
 void execschedule();

setpayfactor ACTION

/**
 * Change how inflated or vested tokens will be distributed based on the following structure.
 *
 * @param inflation_pay_factor - Inverse of the fraction of the inflation used to reward block producers.
 *     The remaining inflation will be sent to the `eosio.saving` account.
 *     (eg. For 20% of inflation going to block producer rewards   => inflation_pay_factor = 50000
 *          For 100% of inflation going to block producer rewards  => inflation_pay_factor = 10000).
 * @param votepay_factor - Inverse of the fraction of the block producer rewards to be distributed proportional to blocks produced.
 *     The remaining rewards will be distributed proportional to votes received.
 *     (eg. For 25% of block producer rewards going towards block pay => votepay_factor = 40000
 *          For 75% of block producer rewards going towards block pay => votepay_factor = 13333).
 */
[[eosio::action]]
void setpayfactor( int64_t inflation_pay_factor, int64_t votepay_factor );

schedules TABLE

/**
 * Defines the schedule for pre-determined annual rate changes.
 */
struct [[eosio::table]] schedules {
    time_point_sec start_time;
    int64_t annual_rate;

    uint64_t primary_key() const { return start_time.sec_since_epoch(); }
};

Preconditions

References

Note: changes should be pushed to Antelope Reference contracts https://github.com/AntelopeIO/reference-contracts

DenisCarriere commented 5 months ago

Implemented in v3.4.0 https://github.com/eosnetworkfoundation/eos-system-contracts/releases/tag/v3.4.0-rc1