Skip to content

Commit

Permalink
Fix claimnextper and proposals creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerard097 committed Aug 7, 2023
1 parent 77c4ba8 commit 3957270
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/dao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,11 +866,11 @@ void dao::claimnextper(uint64_t assignment_id)

if (daoTokens.peg.is_valid()) {
EOS_CHECK(ab.peg.is_valid(), "fatal error: PEG has to be a valid asset");
makePayment(daoSettings, periodToClaim.value().getID(), assignee, ab.voice, memo, eosio::name{ 0 }, daoTokens);
makePayment(daoSettings, periodToClaim.value().getID(), assignee, ab.peg, memo, eosio::name{ 0 }, daoTokens);
}

EOS_CHECK(ab.voice.is_valid(), "fatal error: VOICE has to be a valid asset");
makePayment(daoSettings, periodToClaim.value().getID(), assignee, ab.peg, memo, eosio::name{ 0 }, daoTokens);
makePayment(daoSettings, periodToClaim.value().getID(), assignee, ab.voice, memo, eosio::name{ 0 }, daoTokens);
}

// void dao::simclaimall(name account, uint64_t dao_id, bool only_ids)
Expand Down Expand Up @@ -975,9 +975,9 @@ AssetBatch dao::calculatePeriodPayout(Period& period,
int64_t periodEndSec = period.getEndTime().sec_since_epoch();

AssetBatch payout {
.reward = eosio::asset{ 0, daoTokens.reward.symbol },
.peg = eosio::asset{ 0, daoTokens.peg.symbol },
.voice = eosio::asset{ 0, daoTokens.voice.symbol }
.reward = daoTokens.reward.is_valid() ? asset{ 0, daoTokens.reward.symbol } : asset{},
.peg = daoTokens.peg.is_valid() ? asset{ 0, daoTokens.peg.symbol } : asset{},
.voice = asset{ 0, daoTokens.voice.symbol }
};

while (nextTimeShareOpt)
Expand Down Expand Up @@ -1036,8 +1036,8 @@ AssetBatch dao::calculatePeriodPayout(Period& period,
//Accumlate each of the currencies with the time share multiplier

payout.voice += adjustAsset(salary.voice, commitmentMultiplier);
payout.peg += adjustAsset(salary.peg, commitmentMultiplier);
payout.reward += adjustAsset(salary.reward, commitmentMultiplier);
if (daoTokens.peg.is_valid()) payout.peg += adjustAsset(salary.peg, commitmentMultiplier);
if (daoTokens.reward.is_valid()) payout.reward += adjustAsset(salary.reward, commitmentMultiplier);
}

return payout;
Expand Down
16 changes: 9 additions & 7 deletions src/proposals/assignment_proposal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,15 @@ namespace hypha
//TODO: Normalize all the tokens to allow different precisions on each token
//currently they all must be the same or the will not work correctly

auto rewardPegVal = m_daoSettings->getOrFail<eosio::asset>(common::REWARD_TO_PEG_RATIO);
auto tokens = AssetBatch {
.reward = m_daoSettings->getSettingOrDefault<asset>(common::REWARD_TOKEN),
.peg = m_daoSettings->getSettingOrDefault<asset>(common::PEG_TOKEN),
.voice = m_daoSettings->getOrFail<asset>(common::VOICE_TOKEN)
};

auto rewardPegVal = tokens.reward.is_valid() ?
m_daoSettings->getOrFail<eosio::asset>(common::REWARD_TO_PEG_RATIO) :
eosio::asset{};

SalaryConfig salaryConf {
.periodSalary = normalizeToken(usdSalaryPerPeriod.getAs<asset>()) * (timeShare / 100.0),
Expand All @@ -173,12 +181,6 @@ namespace hypha
.pegMultipler = static_cast<double>(m_daoSettings->getSettingOrDefault<int64_t>(common::PEG_MULTIPLIER, 1))
};

auto tokens = AssetBatch {
.reward = m_daoSettings->getSettingOrDefault<asset>(common::REWARD_TOKEN),
.peg = m_daoSettings->getSettingOrDefault<asset>(common::PEG_TOKEN),
.voice = m_daoSettings->getOrFail<asset>(common::VOICE_TOKEN)
};

AssetBatch salaries = calculateSalaries(salaryConf, tokens);

// add remaining derived per period salary amounts to this document
Expand Down
4 changes: 3 additions & 1 deletion src/proposals/payout_proposal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ void PayoutProposal::checkTokenItems(Settings* daoSettings, ContentWrapper conte
EOS_CHECK(deferred >= 0, DEFERRED + string(" must be greater than or equal to zero. You submitted: ") + std::to_string(deferred));
EOS_CHECK(deferred <= 100, DEFERRED + string(" must be less than or equal to 100 (=100%). You submitted: ") + std::to_string(deferred));

auto rewardPegVal = daoSettings->getOrFail<eosio::asset>(common::REWARD_TO_PEG_RATIO);
auto rewardPegVal = tokens.reward.is_valid() ?
daoSettings->getOrFail<eosio::asset>(common::REWARD_TO_PEG_RATIO) :
eosio::asset{};

auto salaries = calculateSalaries(SalaryConfig {
.periodSalary = normalizeToken(usd),
Expand Down

0 comments on commit 3957270

Please sign in to comment.