-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update BP rate Remove non implemented test Wrapping changes in TELOS BEGIN / END Moving native tests inside of blockchain tests Updated README Remove changes related to code supply - The supply was already computed elsewhere Remove native-tests
- Loading branch information
Showing
10 changed files
with
224 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// TELOS BEGIN | ||
#include <eosio/asset.hpp> | ||
|
||
namespace eosiosystem { | ||
double compute_bpay_rate(uint64_t tlos_price, eosio::asset total_telos_supply); | ||
} | ||
// TELOS END |
68 changes: 68 additions & 0 deletions
68
contracts/eosio.system/include/eosio.system/delphioracle.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// TELOS BEGIN | ||
#include <eosio/eosio.hpp> | ||
#include <math.h> | ||
|
||
using eosio::time_point; | ||
using eosio::const_mem_fun; | ||
using eosio::indexed_by; | ||
|
||
namespace delphioracle { | ||
|
||
const eosio::time_point NULL_TIME_POINT = eosio::time_point(eosio::microseconds(0)); | ||
|
||
|
||
enum class average_types: uint8_t { | ||
last_7_days = 0, | ||
last_14_days = 1, | ||
last_30_days = 2, | ||
last_45_days = 3, | ||
none = 255, | ||
}; | ||
|
||
TABLE daily_datapoints { | ||
uint64_t id; | ||
uint64_t value; | ||
time_point timestamp; | ||
|
||
uint64_t primary_key() const { | ||
return id; | ||
} | ||
uint64_t by_timestamp() const { | ||
return timestamp.elapsed.to_seconds(); | ||
} | ||
uint64_t by_value() const { | ||
return value; | ||
} | ||
}; | ||
|
||
TABLE averages { | ||
uint64_t id; | ||
uint8_t type = get_type(average_types::none); | ||
uint64_t value = 0; | ||
time_point timestamp = NULL_TIME_POINT; | ||
uint64_t primary_key() const { | ||
return id; | ||
} | ||
uint64_t by_timestamp() const { | ||
return timestamp.elapsed.to_seconds(); | ||
} | ||
|
||
static uint8_t get_type(average_types type) { | ||
return static_cast < uint8_t > (type); | ||
} | ||
}; | ||
|
||
typedef eosio::multi_index< | ||
"dailydatapnt"_n, | ||
daily_datapoints, | ||
indexed_by<"value"_n, const_mem_fun<daily_datapoints, uint64_t, &daily_datapoints::by_value>>, | ||
indexed_by<"timestamp"_n, const_mem_fun<daily_datapoints,uint64_t, &daily_datapoints::by_timestamp>> | ||
> dailydatapointstable; | ||
|
||
typedef eosio::multi_index< | ||
"averages"_n, | ||
averages,indexed_by <"timestamp"_n, const_mem_fun<averages, uint64_t, &averages::by_timestamp>> | ||
> averagestable; | ||
|
||
} | ||
// TELOS END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// TELOS BEGIN | ||
#include <eosio.system/bpay_rate.hpp> | ||
|
||
using eosio::asset; | ||
|
||
namespace eosiosystem { | ||
double compute_bpay_rate(uint64_t tlos_price, asset total_telos_supply) { | ||
const double MULTIPLIER_CONSTANT = 8.34; | ||
const double POWER_OF_CONSTANT = -0.516; | ||
const double ACTIVE_BP_COUNT = 21; | ||
const double STANDBY_BP_COUNT = 21; | ||
|
||
// 100k divided by (30-minutes divided by the Number-of-minutes-in-a-year) | ||
// 100k / 0.00005707762557 | ||
// This was pulled out of the bpay_rate formula | ||
const double _100K_DIVIDED_BY_TIME_PERIOD = 1752000000; | ||
|
||
const double raw_tlos_price = double(tlos_price) / 100; | ||
const double tlos_per_bp = MULTIPLIER_CONSTANT * pow((double) raw_tlos_price, POWER_OF_CONSTANT); | ||
const double tlos_in_30_mins = tlos_per_bp * (ACTIVE_BP_COUNT + 0.5 * STANDBY_BP_COUNT); | ||
|
||
double total_telos_supply_double = double(total_telos_supply.amount) / pow(10.0, total_telos_supply.symbol.precision()); | ||
|
||
const double bp_rate = round( | ||
(_100K_DIVIDED_BY_TIME_PERIOD* tlos_in_30_mins) / | ||
total_telos_supply_double | ||
); | ||
|
||
return bp_rate; | ||
} | ||
} | ||
// TELOS END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters