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

[FIP-22] Retire action #208

Merged
merged 33 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6c08615
FIP-22 first steps
May 11, 2021
7b81ac1
use remaining
May 11, 2021
de25df1
add some checks
May 11, 2021
8dac563
Merge branch 'feature/BD-2516-retire' into feature/BD-2516-retire-FIP…
May 19, 2021
2075adf
update retire, general lock update support
May 21, 2021
9009026
Merge branch 'feature/FIP-21-Staking-fio-contracts-develop-03212021' …
May 21, 2021
824b8b9
include updlocks, fix unassigned value bug
May 27, 2021
4d588b2
Merge branch 'feature/FIP-21-Staking-fio-contracts-develop-03212021' …
May 27, 2021
05740ff
use fio errors on fio.token::retire
Jun 3, 2021
c2afa1f
Merge branch 'feature/FIP-21-Staking-fio-contracts-develop-03212021' …
Jun 3, 2021
c28085d
use general_locks_table_v2
Jun 3, 2021
4899a83
refactor retre
Jun 15, 2021
62e9060
Merge branch 'feature/FIP-21-Staking-fio-contracts-develop-03212021' …
Jun 15, 2021
d11aec6
Merge branch 'develop' into feature/BD-2516-retire-FIP-21-base
adsorptionenthalpy Aug 3, 2021
70a79f7
Merge branch 'develop' into feature/BD-2516-retire-FIP-21-base
adsorptionenthalpy Oct 15, 2021
ddb1fc5
Merge branch 'develop' into feature/BD-2516-retire-FIP-21-base
adsorptionenthalpy Oct 28, 2021
a8d9d98
support spec changes for retire'
adsorptionenthalpy Nov 11, 2021
4d0a163
Update retire to burn remaining from burnable - quantity
adsorptionenthalpy Nov 12, 2021
03fd0ce
fix assertion
adsorptionenthalpy Nov 12, 2021
898ba8f
Insufficient balance has no ,
adsorptionenthalpy Nov 12, 2021
11718ab
trx size check goes on the end
adsorptionenthalpy Nov 12, 2021
7a81f98
update ram bump for staking to become 512
Nov 12, 2021
ff5b864
cleanup
adsorptionenthalpy Nov 12, 2021
ca6fab6
Merge branch 'develop' into feature/BD2989-nov10
adsorptionenthalpy Nov 12, 2021
e0ca0ec
set the rewards enable date time for test net rollout to be nov 22 08…
Nov 12, 2021
78b629c
fix expression
adsorptionenthalpy Nov 12, 2021
85416cb
Correction: use AND not OR
adsorptionenthalpy Nov 16, 2021
a5b02f2
Merge branch 'feature/FIP-21-staking-r2-6-x-11102021' into feature/BD…
adsorptionenthalpy Nov 16, 2021
9d843fb
Allow retire of mainnet locks
adsorptionenthalpy Nov 16, 2021
40a5f1c
include can_transfer assertion
adsorptionenthalpy Nov 16, 2021
61b52a3
Update 404 errors
adsorptionenthalpy Nov 16, 2021
842c372
Improve logic
adsorptionenthalpy Nov 16, 2021
7a4c6e9
remove unused updlocks
Nov 29, 2021
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
4 changes: 2 additions & 2 deletions contracts/fio.common/fio.common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ namespace fioio {
static const uint64_t INITIALACCOUNTRAM = 25600;
static const uint64_t ADDITIONALRAMBPDESCHEDULING = 25600;

static const uint64_t STAKEFIOTOKENSRAM = 256; //integrated.
static const uint64_t UNSTAKEFIOTOKENSRAM = 256; //integrated.
static const uint64_t STAKEFIOTOKENSRAM = 512; //integrated.
static const uint64_t UNSTAKEFIOTOKENSRAM = 512; //integrated.
static const uint64_t REGDOMAINRAM = 2560; //integrated.
static const uint64_t REGADDRESSRAM = 2560; //integrated.
static const uint64_t ADDADDRESSRAM = 512; //integrated.
Expand Down
2 changes: 2 additions & 0 deletions contracts/fio.common/fioerror.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ namespace fioio {
constexpr auto ErrorUnexpectedNumberResults = ident | httpLocationError | 156; // unexpected number of results
constexpr auto ErrorNoFioActionsFound = ident | httpLocationError | 157; // no actions found
constexpr auto ErrorDomainOwner = ident | httpInvalidError | 158;
constexpr auto ErrorRetireQuantity = ident | httpDataError | 159;
constexpr auto ErrorInvalidMemo = ident | httpDataError | 160;

/**
* Helper funtions for detecting rich error messages and extracting bitfielded values
Expand Down
2 changes: 1 addition & 1 deletion contracts/fio.staking/fio.staking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <fio.fee/fio.fee.hpp>
#include <fio.system/include/fio.system/fio.system.hpp>

#define ENABLESTAKINGREWARDSEPOCHSEC 1627686000 //July 30 5:00PM MST 11:00PM GMT
#define ENABLESTAKINGREWARDSEPOCHSEC 1637593200//NOV 22 2021 0800 MST

namespace fioio {

Expand Down
2 changes: 1 addition & 1 deletion contracts/fio.system/src/voting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ namespace eosiosystem {
}else{
amount = damount;
}

}else{
//amount is balance - remaining locked.
if (amount >= lockiter->remaining_locked_amount){
Expand Down
2 changes: 1 addition & 1 deletion contracts/fio.token/include/fio.token/fio.token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace eosio {
void mintfio(const name &to, const uint64_t &amount);

[[eosio::action]]
void retire(asset quantity, string memo);
void retire(const int64_t &quantity, const string &memo, const name &actor);

[[eosio::action]]
void transfer(name from,
Expand Down
62 changes: 45 additions & 17 deletions contracts/fio.token/src/fio.token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,59 @@ namespace eosio {
}
}

void token::retire(asset quantity, string memo) {
const symbol sym = quantity.symbol;
check(sym.is_valid(), "invalid symbol name");
check(memo.size() <= 256, "memo has more than 256 bytes");

stats statstable(_self, sym.code().raw());
auto existing = statstable.find(sym.code().raw());
check(existing != statstable.end(), "token with symbol does not exist");
void token::retire(const int64_t &quantity, const string &memo, const name &actor) {
require_auth(actor);
fio_400_assert(memo.size() <= 256, "memo", memo, "memo has more than 256 bytes", ErrorInvalidMemo);
fio_400_assert(quantity >= 1000000000000ULL,"quantity", std::to_string(quantity), "Minimum 1000 FIO has to be retired", ErrorRetireQuantity);
stats statstable(_self, FIOSYMBOL.code().raw());
auto existing = statstable.find(FIOSYMBOL.code().raw());
const auto &st = *existing;

require_auth(FIOISSUER);
check(quantity.is_valid(), "invalid quantity");
check(quantity.amount > 0, "must retire positive quantity");
check(quantity.symbol == FIOSYMBOL, "symbol precision mismatch");
auto stakeiter = accountstaking.find(actor.value);
if (stakeiter != accountstaking.end()) {
fio_400_assert(!(stakeiter->total_staked_fio > 0), "actor", to_string(actor.value), "Account staking cannot retire", ErrorRetireQuantity); //signature error if user has stake
}
auto genlockiter = generalLockTokensTable.find(actor.value);
if (genlockiter != generalLockTokensTable.end()) {
fio_400_assert(!(genlockiter->remaining_lock_amount > 0), "actor", to_string(actor.value), "Account with partially locked balance cannot retire", ErrorRetireQuantity); //signature error if user has general lock
}
const asset my_balance = eosio::token::get_balance("fio.token"_n, actor, FIOSYMBOL.code());

check(quantity.symbol == st.supply.symbol, "symbol precision mismatch");
fio_400_assert(quantity <= my_balance.amount && can_transfer(actor, 0, quantity, false), "actor", to_string(actor.value),
"Insufficient balance",
ErrorInsufficientUnlockedFunds);

auto lockiter = lockedTokensTable.find(actor.value);
if (lockiter != lockedTokensTable.end()) {
uint64_t genesislockedamount = lockiter->remaining_locked_amount;
if (genesislockedamount > 0) {

if (genesislockedamount >= quantity) {
genesislockedamount = quantity;
}

INLINE_ACTION_SENDER(eosiosystem::system_contract, updlocked)
("eosio"_n, {{_self, "active"_n}},
{actor, genesislockedamount}
);
}
}

sub_balance(actor, asset(quantity, FIOSYMBOL));
statstable.modify(st, same_payer, [&](auto &s) {
s.supply -= quantity;
s.supply.amount -= quantity;
});

sub_balance(FIOISSUER, quantity);
const string response_string = string("{\"status\": \"OK\"}");

send_response(response_string.c_str());

fio_400_assert(transaction_size() <= MAX_TRX_SIZE, "transaction_size", std::to_string(transaction_size()),
"Transaction is too large", ErrorTransactionTooLarge);

}


bool token::can_transfer(const name &tokenowner, const uint64_t &feeamount, const uint64_t &transferamount,
const bool &isfee) {

Expand Down Expand Up @@ -564,5 +593,4 @@ namespace eosio {
}
} /// namespace eosio

EOSIO_DISPATCH( eosio::token, (create)(issue)(mintfio)(transfer)(trnsfiopubky)(trnsloctoks)
(retire))
EOSIO_DISPATCH( eosio::token, (create)(issue)(mintfio)(transfer)(trnsfiopubky)(trnsloctoks)(retire))