Skip to content

Commit

Permalink
remove buy hypha tokens with HUSD function
Browse files Browse the repository at this point in the history
Removing - we don't need this anymore, it will get out of sync and cause problems.
  • Loading branch information
n13 committed Nov 12, 2023
1 parent d38fe2e commit 0267bf6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 51 deletions.
16 changes: 2 additions & 14 deletions include/dao.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
)
}
}
Expand Down Expand Up @@ -527,8 +517,6 @@ namespace pricing {
std::optional<TimeShare>& 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);
Expand Down
37 changes: 0 additions & 37 deletions src/dao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<eosio::asset>(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<asset>(common::REWARD_TOKEN),
.peg = daoSettings->getOrFail<asset>(common::PEG_TOKEN),
.voice = daoSettings->getOrFail<asset>(common::VOICE_TOKEN)
};

std::unique_ptr<Payer> payer = std::unique_ptr<Payer>(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};
Expand Down

0 comments on commit 0267bf6

Please sign in to comment.