diff --git a/contracts/fio.common/fio.common.hpp b/contracts/fio.common/fio.common.hpp index d8de5e38..cccdd7e7 100644 --- a/contracts/fio.common/fio.common.hpp +++ b/contracts/fio.common/fio.common.hpp @@ -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. diff --git a/contracts/fio.common/fioerror.hpp b/contracts/fio.common/fioerror.hpp index d3bace58..7db2492b 100644 --- a/contracts/fio.common/fioerror.hpp +++ b/contracts/fio.common/fioerror.hpp @@ -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 diff --git a/contracts/fio.staking/fio.staking.cpp b/contracts/fio.staking/fio.staking.cpp index 4ddcb600..4d7f74f1 100644 --- a/contracts/fio.staking/fio.staking.cpp +++ b/contracts/fio.staking/fio.staking.cpp @@ -12,7 +12,7 @@ #include #include -#define ENABLESTAKINGREWARDSEPOCHSEC 1627686000 //July 30 5:00PM MST 11:00PM GMT +#define ENABLESTAKINGREWARDSEPOCHSEC 1637593200//NOV 22 2021 0800 MST namespace fioio { diff --git a/contracts/fio.system/src/voting.cpp b/contracts/fio.system/src/voting.cpp index 94bccfb7..747f9224 100755 --- a/contracts/fio.system/src/voting.cpp +++ b/contracts/fio.system/src/voting.cpp @@ -752,7 +752,7 @@ namespace eosiosystem { }else{ amount = damount; } - + }else{ //amount is balance - remaining locked. if (amount >= lockiter->remaining_locked_amount){ diff --git a/contracts/fio.token/include/fio.token/fio.token.hpp b/contracts/fio.token/include/fio.token/fio.token.hpp index f40df677..6d8c38aa 100755 --- a/contracts/fio.token/include/fio.token/fio.token.hpp +++ b/contracts/fio.token/include/fio.token/fio.token.hpp @@ -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, diff --git a/contracts/fio.token/src/fio.token.cpp b/contracts/fio.token/src/fio.token.cpp index 924b04de..24443869 100755 --- a/contracts/fio.token/src/fio.token.cpp +++ b/contracts/fio.token/src/fio.token.cpp @@ -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) { @@ -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))