Skip to content
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

[3.4 -> Main] Merge Tokenonmics Updates into Main #96

Merged
merged 56 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
47e44bd
push fees upgrade changes
DenisCarriere May 2, 2024
e4c75b8
push token upgrade
DenisCarriere May 2, 2024
b694722
Implement rex maturity changes
DenisCarriere May 3, 2024
a8afcee
Remove voting requirements for rex
DenisCarriere May 3, 2024
67c2429
Move to savings when buying REX
DenisCarriere May 3, 2024
6d791ad
Move to savings when buying REX & sell REX when matured
DenisCarriere May 3, 2024
d664b5a
implement unvest action
DenisCarriere May 3, 2024
7fb34dd
add supply tests
DenisCarriere May 3, 2024
812ffa6
Implement schedules
DenisCarriere May 4, 2024
6e79c48
add schedule with 0% annual rate
DenisCarriere May 4, 2024
669d966
add no schedule to execute tests
DenisCarriere May 4, 2024
5c0256c
rename to "unallocated bucket"
DenisCarriere May 8, 2024
32f62ab
a few extra tests
May 8, 2024
2789fb1
Merge pull request #79 from AntelopeIO/tokenomics-token-upgrade
nsjames May 8, 2024
85ef99c
make rex maturity settings as actions
DenisCarriere May 8, 2024
4358d70
refactor process_sell_matured_rex
DenisCarriere May 8, 2024
a9a79e1
direct continuous rate modification, extending tests
May 8, 2024
5a9176d
year typo in versting schedule test
May 8, 2024
c550e95
year typo in versting schedule test
May 8, 2024
bf8f948
Merge branch 'tokenomics' into tokenomics-vesting-upgrade
nsjames May 8, 2024
ff27f8c
extend unvest tests, enforce only unvested amount, and allow claiming…
May 9, 2024
8028ff7
add matured rex tests
DenisCarriere May 9, 2024
4239d20
allow setting a schedule in the past or msigs will break
May 10, 2024
9e3ac02
expose new action to allow setting pay factors without affecting cont…
May 10, 2024
b188adc
fixes for setpayfactor tests
May 10, 2024
981608a
update rex tests
DenisCarriere May 11, 2024
6a175c0
set global state
May 13, 2024
046f5a0
Merge pull request #81 from AntelopeIO/tokenomics-vesting-upgrade
nsjames May 13, 2024
dbd2eb4
validate rex return in tests
May 13, 2024
3cfbbda
merge in tokenomics branch
May 13, 2024
45473c9
Merge pull request #78 from AntelopeIO/tokenomics-fees-upgrade
nsjames May 13, 2024
33ab294
fix for setschedule docs
May 15, 2024
3803fd9
Merge pull request #84 from AntelopeIO/tokenomics-doc-fix
nsjames May 16, 2024
ded2d7f
add ricardians for unvest and donatetorex
May 17, 2024
59736cf
Merge pull request #86 from AntelopeIO/tokenomics-ricardians
nsjames May 21, 2024
4dff31f
interface test for buyramburn
ericpassmore May 21, 2024
917d722
Merge pull request #87 from AntelopeIO/ehp/interface-test-buyramburn
ericpassmore May 21, 2024
ca1b6ce
merged schedule structs in includes
ericpassmore May 24, 2024
1741995
preliminary tests and code for eosio.bpay
Jun 3, 2024
8e469fe
use headers from contracts instead of duplicating, extend tests
Jun 4, 2024
9646c7e
add bpay ricardians to cmakelists
Jun 4, 2024
47599f0
Merge pull request #98 from AntelopeIO/eosio.bpay
nsjames Jun 5, 2024
fee936f
Merge branch 'main' into merge-savanna-tokenonmics
ericpassmore Jun 6, 2024
60f3683
merge tokenomics into rex updates
Jun 10, 2024
e21f721
Split system_tests into multiple suites such that each of them can fi…
linh2931 Jun 10, 2024
1157964
Merge remote-tracking branch 'origin/split_system_tests' into merge-s…
ericpassmore Jun 11, 2024
2e865e5
rex2 docs update, ricardians, tests, rename maturity setter
Jun 13, 2024
126d5f8
remove unecessary tests
Jun 13, 2024
1a603bb
Merge pull request #80 from AntelopeIO/tokenomics-rex-upgrade
nsjames Jun 14, 2024
09e8c4f
merged main incorporating token split tests
ericpassmore Jun 14, 2024
ea167cf
Merge remote-tracking branch 'origin' into merge-savanna-tokenonmics
ericpassmore Jun 14, 2024
de38a52
resolved conflict num of blocks to produce for test
ericpassmore Jun 17, 2024
c2fac1a
resolve dup test name
ericpassmore Jun 17, 2024
551fd9e
use actual producer list to split rewards instead of configured max
Jun 25, 2024
1836e5c
Merge remote-tracking branch 'origin/tokenomics' into merge-savanna-t…
ericpassmore Jul 18, 2024
3282ef6
Merge remote-tracking branch 'origin/main' into merge-savanna-tokenon…
ericpassmore Jul 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell/custom-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ setacctram
setalimits
setcode
setinflation
setpayfactor
setparams
setpriv
setram
Expand Down
2 changes: 2 additions & 0 deletions contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,7 @@ add_subdirectory(eosio.msig)
add_subdirectory(eosio.system)
add_subdirectory(eosio.token)
add_subdirectory(eosio.wrap)
add_subdirectory(eosio.fees)
add_subdirectory(eosio.bpay)

add_subdirectory(test_contracts)
14 changes: 14 additions & 0 deletions contracts/eosio.bpay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
add_contract(eosio.bpay eosio.bpay ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.bpay.cpp)

target_include_directories(eosio.bpay PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../eosio.system/include
${CMAKE_CURRENT_SOURCE_DIR}/../eosio.token/include)

set_target_properties(eosio.bpay
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/ricardian/eosio.bpay.contracts.md.in ${CMAKE_CURRENT_BINARY_DIR}/ricardian/eosio.bpay.contracts.md @ONLY )

target_compile_options( eosio.bpay PUBLIC -R${CMAKE_CURRENT_SOURCE_DIR}/ricardian -R${CMAKE_CURRENT_BINARY_DIR}/ricardian )
55 changes: 55 additions & 0 deletions contracts/eosio.bpay/include/eosio.bpay/eosio.bpay.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once

#include <eosio/eosio.hpp>
#include <eosio.system/eosio.system.hpp>
#include <eosio.token/eosio.token.hpp>

using namespace std;

namespace eosio {
/**
* The `eosio.bpay` contract handles system bpay distribution.
*/
class [[eosio::contract("eosio.bpay")]] bpay : public contract {
public:
using contract::contract;

/**
* ## TABLE `rewards`
*
* @param owner - block producer owner account
* @param quantity - reward quantity in EOS
*
* ### example
*
* ```json
* [
* {
* "owner": "alice",
* "quantity": "8.800 EOS"
* }
* ]
* ```
*/
struct [[eosio::table("rewards")]] rewards_row {
name owner;
asset quantity;

uint64_t primary_key() const { return owner.value; }
};
typedef eosio::multi_index< "rewards"_n, rewards_row > rewards_table;

/**
* Claim rewards for a block producer.
*
* @param owner - block producer owner account
*/
[[eosio::action]]
void claimrewards( const name owner);

[[eosio::on_notify("eosio.token::transfer")]]
void on_transfer( const name from, const name to, const asset quantity, const string memo );

private:
};
} /// namespace eosio
10 changes: 10 additions & 0 deletions contracts/eosio.bpay/ricardian/eosio.bpay.contracts.md.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1 class="contract">claimrewards</h1>

---
spec_version: "0.2.0"
title: Claim Rewards
summary: '{{nowrap owner}} claims block production rewards'
icon: @ICON_BASE_URL@/@MULTISIG_ICON_URI@
---

{{owner}} claims block production rewards accumulated through network fees.
73 changes: 73 additions & 0 deletions contracts/eosio.bpay/src/eosio.bpay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include <eosio.bpay/eosio.bpay.hpp>

namespace eosio {

void bpay::claimrewards( const name owner ) {
require_auth( owner );

rewards_table _rewards( get_self(), get_self().value );

const auto& row = _rewards.get( owner.value, "no rewards to claim" );

eosio::token::transfer_action transfer( "eosio.token"_n, { get_self(), "active"_n });
transfer.send( get_self(), owner, row.quantity, "producer block pay" );

_rewards.erase(row);
}

void bpay::on_transfer( const name from, const name to, const asset quantity, const string memo ) {
if (from == get_self() || to != get_self()) {
return;
}

// ignore eosio system incoming transfers (caused by bpay income transfers eosio => eosio.bpay => producer)
if ( from == "eosio"_n) return;

symbol system_symbol = eosiosystem::system_contract::get_core_symbol();

check( quantity.symbol == system_symbol, "only core token allowed" );

rewards_table _rewards( get_self(), get_self().value );
eosiosystem::producers_table _producers( "eosio"_n, "eosio"_n.value );

eosiosystem::global_state_singleton _global("eosio"_n, "eosio"_n.value);
check( _global.exists(), "global state does not exist");
uint16_t producer_count = _global.get().last_producer_schedule_size;

// get producer with the most votes
// using `by_votes` secondary index
auto idx = _producers.get_index<"prototalvote"_n>();
auto prod = idx.begin();

// get top n producers by vote, excluding inactive
std::vector<name> top_producers;
while (true) {
if (prod == idx.end()) break;
if (prod->is_active == false) continue;

top_producers.push_back(prod->owner);

if (top_producers.size() == producer_count) break;

prod++;
}

asset reward = quantity / top_producers.size();

// distribute rewards to top producers
for (auto producer : top_producers) {
auto row = _rewards.find( producer.value );
if (row == _rewards.end()) {
_rewards.emplace( get_self(), [&](auto& row) {
row.owner = producer;
row.quantity = reward;
});
} else {
_rewards.modify(row, get_self(), [&](auto& row) {
row.quantity += reward;
});
}
}
}

} /// namespace eosio
11 changes: 11 additions & 0 deletions contracts/eosio.fees/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
add_contract(eosio.fees eosio.fees ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.fees.cpp)

target_include_directories(eosio.fees PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../eosio.system/include)

set_target_properties(eosio.fees
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")

target_compile_options( eosio.fees PUBLIC )
35 changes: 35 additions & 0 deletions contracts/eosio.fees/include/eosio.fees/eosio.fees.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <eosio/asset.hpp>
#include <eosio/eosio.hpp>
#include <eosio.system/eosio.system.hpp>

#include <string>

namespace eosiosystem {
class system_contract;
}

namespace eosio {

using std::string;
/**
* The eosio.fees smart contract facilitates the collection of transaction fees from system accounts and their subsequent distribution to the Resource Exchange (REX) pool.
*
* This contract serves as an essential component for inclusion in system-level unit tests.
*
* A comprehensive implementation of the eosio.fees contract can be accessed at EOS Network Foundation GitHub repository.
* https://github.com/eosnetworkfoundation/eosio.fees
*/
class [[eosio::contract("eosio.fees")]] fees : public contract {
public:
using contract::contract;

[[eosio::on_notify("eosio.token::transfer")]]
void on_transfer( const name from, const name to, const asset quantity, const string memo );

[[eosio::action]]
void noop();
};

}
21 changes: 21 additions & 0 deletions contracts/eosio.fees/src/eosio.fees.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <eosio.fees/eosio.fees.hpp>

namespace eosio {

void fees::on_transfer( const name from, const name to, const asset quantity, const string memo )
{
if ( to != get_self() ) {
return;
}
if (eosiosystem::system_contract::rex_available()) {
eosiosystem::system_contract::donatetorex_action donatetorex( "eosio"_n, { get_self(), "active"_n });
donatetorex.send(get_self(), quantity, memo);
}
}

void fees::noop()
{
require_auth( get_self() );
}

} /// namespace eosio
Loading
Loading