From 0267bf6415253b1c25178f799fc913b0a4eb2729 Mon Sep 17 00:00:00 2001 From: NIK Date: Mon, 13 Nov 2023 07:09:57 +0800 Subject: [PATCH] remove buy hypha tokens with HUSD function Removing - we don't need this anymore, it will get out of sync and cause problems. --- include/dao.hpp | 16 ++-------------- src/dao.cpp | 37 ------------------------------------- 2 files changed, 2 insertions(+), 51 deletions(-) diff --git a/include/dao.hpp b/include/dao.hpp index 54db057..cc31de0 100644 --- a/include/dao.hpp +++ b/include/dao.hpp @@ -434,23 +434,13 @@ namespace pricing { if (get_first_receiver() == pegContract && to == get_self() && from != get_self()) { - //Buying Hypha tokens with HUSD - if (memo == "buy") { - - EOS_CHECK( - quantity.symbol == hypha::common::S_HUSD, - "Buying HYPHA is only available with HUSD tokens" - ) - - on_husd(from, to, quantity, memo); - } - else if (memo == "redeem") { + if (memo == "redeem") { onCashTokenTransfer(from, to, quantity, memo); } else { EOS_CHECK( false, - "No available actions, please specify in the memo string [buy|redeem]" + "No available actions, please specify in the memo string [redeem]" ) } } @@ -527,8 +517,6 @@ namespace pricing { std::optional& lastUsedTimeShare, int64_t initTimeShare); - void on_husd(const name& from, const name& to, const asset& quantity, const string& memo); - void onCashTokenTransfer(const name& from, const name& to, const asset& quantity, const string& memo); void onNativeTokenTransfer(const name& from, const name& to, const asset& quantity, const string& memo); diff --git a/src/dao.cpp b/src/dao.cpp index ccb8111..0047962 100644 --- a/src/dao.cpp +++ b/src/dao.cpp @@ -3117,43 +3117,6 @@ void dao::onRewardTransfer(const name& from, const name& to, const asset& amount } } -void dao::on_husd(const name& from, const name& to, const asset& quantity, const string& memo) { - - EOS_CHECK(quantity.amount > 0, "quantity must be > 0"); - EOS_CHECK(quantity.is_valid(), "quantity invalid"); - - asset hyphaUsdVal = getSettingOrFail(common::HYPHA_USD_VALUE); - - EOS_CHECK( - hyphaUsdVal.symbol.precision() == 4, - to_str("Expected hypha_usd_value precision to be 4, but got:", hyphaUsdVal.symbol.precision()) - ); - - double factor = (hyphaUsdVal.amount / 10000.0); - - EOS_CHECK(common::S_HUSD.precision() == common::S_HYPHA.precision(), "unexpected precision mismatch"); - - asset hyphaAmount = asset(quantity.amount / factor, common::S_HYPHA); - - auto hyphaID = getDAOID("hypha"_n); - - EOS_CHECK( - hyphaID.has_value(), - "Missing hypha DAO entry" - ); - - auto daoSettings = getSettingsDocument(*hyphaID); - - auto daoTokens = AssetBatch{ - .reward = daoSettings->getOrFail(common::REWARD_TOKEN), - .peg = daoSettings->getOrFail(common::PEG_TOKEN), - .voice = daoSettings->getOrFail(common::VOICE_TOKEN) - }; - - std::unique_ptr payer = std::unique_ptr(PayerFactory::Factory(*this, daoSettings, hyphaAmount.symbol, eosio::name{ 0 }, daoTokens)); - payer->pay(from, hyphaAmount, string("Buy HYPHA for " + quantity.to_string())); -} - void dao::updateDaoURL(name dao, const Content::FlexValue& newURL) { auto newUrlCon = Content{to_str(common::URL, "_", dao), newURL};