Skip to content

Commit

Permalink
Fix dex loan token burns (#1100)
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Fieroni <[email protected]>
  • Loading branch information
bvbfan authored Feb 15, 2022
1 parent c26078f commit 612bc1a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/masternodes/rpc_accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,8 @@ UniValue getburninfo(const JSONRPCRequest& request) {
CBalances dexfeeburn;
UniValue dfipaybacktokens{UniValue::VARR};

LOCK(cs_main);

auto calcBurn = [&](AccountHistoryKey const & key, CLazySerialize<AccountHistoryValue> valueLazy) -> bool
{
const auto & value = valueLazy.get();
Expand Down Expand Up @@ -1766,7 +1768,11 @@ UniValue getburninfo(const JSONRPCRequest& request) {
if (value.category == uint8_t(CustomTxType::PoolSwap)
|| value.category == uint8_t(CustomTxType::PoolSwapV2)) {
for (auto const & diff : value.diff) {
dexfeeburn.Add({diff.first, diff.second});
if (pcustomcsview->GetLoanTokenByID(diff.first)) {
dexfeeburn.Add({diff.first, diff.second});
} else {
burntTokens.Add({diff.first, diff.second});
}
}
return true;
}
Expand All @@ -1792,8 +1798,6 @@ UniValue getburninfo(const JSONRPCRequest& request) {
result.pushKV("paybackburn", ValueFromAmount(paybackFee));
result.pushKV("dexfeetokens", AmountsToJSON(dexfeeburn.balances));

LOCK(cs_main);

if (auto attributes = pcustomcsview->GetAttributes()) {
CDataStructureV0 liveKey{AttributeTypes::Live, ParamIDs::Economy, EconomyKeys::PaybackDFITokens};
auto tokenBalances = attributes->GetValue(liveKey, CBalances{});
Expand Down

0 comments on commit 612bc1a

Please sign in to comment.