Skip to content

Commit

Permalink
Rename interest burn attribute keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Bushstar committed Jun 24, 2022
1 parent ec7fb91 commit 4da8232
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions src/masternodes/govvariables/attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ const std::map<uint8_t, std::map<std::string, uint8_t>>& ATTRIBUTES::allowedKeys
{"premium", DFIPKeys::Premium},
{"reward_pct", DFIPKeys::RewardPct},
{"block_period", DFIPKeys::BlockPeriod},
{"direct_interest_dusd_burn", DFIPKeys::DirectInterestDUSDBurn},
{"direct_loan_dusd_burn", DFIPKeys::DirectLoanDUSDBurn},
{"dusd_interest_burn", DFIPKeys::DUSDInterestBurn},
{"dusd_loan_burn", DFIPKeys::DUSDLoanBurn},
{"start_block", DFIPKeys::StartBlock},
}
},
Expand Down Expand Up @@ -194,8 +194,8 @@ const std::map<uint8_t, std::map<uint8_t, std::string>>& ATTRIBUTES::displayKeys
{DFIPKeys::MinSwap, "minswap"},
{DFIPKeys::RewardPct, "reward_pct"},
{DFIPKeys::BlockPeriod, "block_period"},
{DFIPKeys::DirectInterestDUSDBurn, "direct_interest_dusd_burn"},
{DFIPKeys::DirectLoanDUSDBurn, "direct_loan_dusd_burn"},
{DFIPKeys::DUSDInterestBurn, "dusd_interest_burn"},
{DFIPKeys::DUSDLoanBurn, "dusd_loan_burn"},
{DFIPKeys::StartBlock, "start_block"},
}
},
Expand Down Expand Up @@ -356,8 +356,8 @@ const std::map<uint8_t, std::map<uint8_t,
{DFIPKeys::MinSwap, VerifyFloat},
{DFIPKeys::RewardPct, VerifyPct},
{DFIPKeys::BlockPeriod, VerifyInt64},
{DFIPKeys::DirectInterestDUSDBurn, VerifyBool},
{DFIPKeys::DirectLoanDUSDBurn, VerifyBool},
{DFIPKeys::DUSDInterestBurn, VerifyBool},
{DFIPKeys::DUSDLoanBurn, VerifyBool},
{DFIPKeys::StartBlock, VerifyInt64},
}
},
Expand Down Expand Up @@ -505,8 +505,8 @@ Res ATTRIBUTES::ProcessVariable(const std::string& key, const std::string& value
}
}
} else if (typeId == ParamIDs::DFIP2206A) {
if (typeKey != DFIPKeys::DirectInterestDUSDBurn &&
typeKey != DFIPKeys::DirectLoanDUSDBurn) {
if (typeKey != DFIPKeys::DUSDInterestBurn &&
typeKey != DFIPKeys::DUSDLoanBurn) {
return Res::Err("Unsupported type for DFIP2206A {%d}", typeKey);
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/masternodes/govvariables/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ enum DFIPKeys : uint8_t {
MinSwap = 'c',
RewardPct = 'd',
BlockPeriod = 'e',
DirectInterestDUSDBurn = 'g',
DirectLoanDUSDBurn = 'h',
DUSDInterestBurn = 'g',
DUSDLoanBurn = 'h',
StartBlock = 'i',
};

Expand Down
4 changes: 2 additions & 2 deletions src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3414,7 +3414,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor

LogPrint(BCLog::LOAN, "CLoanPaybackLoanMessage(): Swapping %s to DFI and burning it - total loan %lld (%lld %s), height - %d\n", paybackToken->symbol, subLoan + subInterest, subInToken, paybackToken->symbol, height);

CDataStructureV0 directBurnKey{AttributeTypes::Param, ParamIDs::DFIP2206A, DFIPKeys::DirectLoanDUSDBurn};
CDataStructureV0 directBurnKey{AttributeTypes::Param, ParamIDs::DFIP2206A, DFIPKeys::DUSDLoanBurn};
auto directLoanBurn = attributes->GetValue(directBurnKey, false);

res = SwapToDFIorDUSD(mnview, paybackTokenId, subInToken, obj.from, consensus.burnAddress, height, !directLoanBurn);
Expand Down Expand Up @@ -4145,7 +4145,7 @@ Res SwapToDFIorDUSD(CCustomCSView & mnview, DCT_ID tokenId, CAmount amount, CSc
if (!attributes) {
return Res::Err("Attributes unavailable");
}
CDataStructureV0 directBurnKey{AttributeTypes::Param, ParamIDs::DFIP2206A, DFIPKeys::DirectInterestDUSDBurn};
CDataStructureV0 directBurnKey{AttributeTypes::Param, ParamIDs::DFIP2206A, DFIPKeys::DUSDInterestBurn};

// Direct swap from DUSD to DFI as defined in the CPoolSwapMessage.
if (tokenId == dUsdToken->first) {
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_loan_payback_dfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def run_test(self):
{account0: ["100@" + symbolBTC, "1000@" + symboldUSD]}, account0)
self.nodes[0].generate(1)

self.nodes[0].setgov({"ATTRIBUTES":{'v0/params/dfip2206a/direct_interest_dusd_burn':'true', 'v0/token/'+idTSLA+'/loan_payback/'+idBTC: 'true', 'v0/token/'+idTSLA+'/loan_payback/'+iddUSD: 'true'}})
self.nodes[0].setgov({"ATTRIBUTES":{'v0/params/dfip2206a/dusd_interest_burn':'true', 'v0/token/'+idTSLA+'/loan_payback/'+idBTC: 'true', 'v0/token/'+idTSLA+'/loan_payback/'+iddUSD: 'true'}})
self.nodes[0].generate(1)

burnAddress = "mfburnZSAM7Gs1hpDeNaMotJXSGA7edosG"
Expand Down Expand Up @@ -436,7 +436,7 @@ def run_test(self):
balanceDFIBefore = balanceDFIAfter
burn_before = burn_after

self.nodes[0].setgov({"ATTRIBUTES":{'v0/params/dfip2206a/direct_loan_dusd_burn':'true'}})
self.nodes[0].setgov({"ATTRIBUTES":{'v0/params/dfip2206a/dusd_loan_burn':'true'}})
self.nodes[0].generate(1)

self.nodes[0].paybackloan({
Expand Down
10 changes: 5 additions & 5 deletions test/functional/feature_setgov.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,16 +784,16 @@ def run_test(self):
assert_raises_rpc_error(-5, "Unsupported type for this DFIP", self.nodes[0].setgov, {"ATTRIBUTES":{'v0/params/dfip2206f/premium': '0.025'}})
assert_raises_rpc_error(-5, "Unsupported type for this DFIP", self.nodes[0].setgov, {"ATTRIBUTES":{'v0/params/dfip2206f/minswap': '0.025'}})
assert_raises_rpc_error(-32600, "ATTRIBUTES: Cannot set block period while DFIP2203 is active", self.nodes[0].setgov, {"ATTRIBUTES":{'v0/params/dfip2203/start_block':'0'}})
assert_raises_rpc_error(-5, "Boolean value must be either \"true\" or \"false\"", self.nodes[0].setgov, {"ATTRIBUTES":{'v0/params/dfip2206a/direct_interest_dusd_burn':'not_a_bool'}})
assert_raises_rpc_error(-5, "Boolean value must be either \"true\" or \"false\"", self.nodes[0].setgov, {"ATTRIBUTES":{'v0/params/dfip2206a/direct_loan_dusd_burn':'not_a_bool'}})
assert_raises_rpc_error(-5, "Boolean value must be either \"true\" or \"false\"", self.nodes[0].setgov, {"ATTRIBUTES":{'v0/params/dfip2206a/dusd_interest_burn':'not_a_bool'}})
assert_raises_rpc_error(-5, "Boolean value must be either \"true\" or \"false\"", self.nodes[0].setgov, {"ATTRIBUTES":{'v0/params/dfip2206a/dusd_loan_burn':'not_a_bool'}})

self.nodes[0].setgov({"ATTRIBUTES":{'v0/params/dfip2206a/direct_interest_dusd_burn':'true', 'v0/params/dfip2206a/direct_loan_dusd_burn':'true'}})
self.nodes[0].setgov({"ATTRIBUTES":{'v0/params/dfip2206a/dusd_interest_burn':'true', 'v0/params/dfip2206a/dusd_loan_burn':'true'}})
self.nodes[0].generate(1)

# Verify FCR results
result = self.nodes[0].getgov('ATTRIBUTES')['ATTRIBUTES']
assert_equal(result['v0/params/dfip2206a/direct_interest_dusd_burn'], 'true')
assert_equal(result['v0/params/dfip2206a/direct_loan_dusd_burn'], 'true')
assert_equal(result['v0/params/dfip2206a/dusd_interest_burn'], 'true')
assert_equal(result['v0/params/dfip2206a/dusd_loan_burn'], 'true')

# Set fee direction Gov vars
self.nodes[0].setgov({"ATTRIBUTES":{
Expand Down

0 comments on commit 4da8232

Please sign in to comment.