From cf8e4542f781751a3d6e79ba72e06c718befacfb Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Mon, 31 Jan 2022 15:59:36 +0530 Subject: [PATCH 1/2] Version 2.6.1 (#1090) --- configure.ac | 2 +- share/genbuild.sh | 2 +- src/version.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9cda15bcef6..9003810b306 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 2) define(_CLIENT_VERSION_MINOR, 6) -define(_CLIENT_VERSION_REVISION, 0) +define(_CLIENT_VERSION_REVISION, 1) define(_CLIENT_VERSION_BUILD, 0) define(_CLIENT_VERSION_RC, 0) define(_CLIENT_VERSION_IS_RELEASE, true) diff --git a/share/genbuild.sh b/share/genbuild.sh index 9f335f7e0ec..ebac191b2cc 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -46,7 +46,7 @@ if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$ SUFFIX="$(echo $CURRENT_BRANCH | sed 's/\//-/g')-$SUFFIX" fi - if [ "$CURRENT_BRANCH" != "hotfix" ]; then + if [ "$CURRENT_BRANCH" != "hotfix" ] && [ "$CURRENT_BRANCH" != "master" ]; then # if it's hotfix branch, don't mark dirty. # otherwise generate suffix from git, i.e. string like "59887e8-dirty". git diff-index --quiet HEAD -- || SUFFIX="$SUFFIX-dirty" diff --git a/src/version.h b/src/version.h index 52b540fac46..3c39cd83f86 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 70024; +static const int PROTOCOL_VERSION = 70025; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; From 31e160a05ee89086c9f3a5345efa369e120f26a9 Mon Sep 17 00:00:00 2001 From: Jouzo Date: Mon, 31 Jan 2022 13:54:23 +0100 Subject: [PATCH 2/2] Test getinterest calculation (#1092) * Add getinterest output test * Adds FCM height and adjust calculations * Add calculation post FCM and post FCH * Test takeloan of 1sat in loop * Update test description --- test/functional/feature_loan_get_interest.py | 189 +++++++++++++++++++ test/functional/feature_loan_payback_dfi.py | 6 +- test/functional/test_runner.py | 1 + 3 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 test/functional/feature_loan_get_interest.py diff --git a/test/functional/feature_loan_get_interest.py b/test/functional/feature_loan_get_interest.py new file mode 100644 index 00000000000..724baa3cf16 --- /dev/null +++ b/test/functional/feature_loan_get_interest.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python3 +# Copyright (c) 2014-2019 The Bitcoin Core developers +# Copyright (c) DeFi Blockchain Developers +# Distributed under the MIT software license, see the accompanying +# file LICENSE or http://www.opensource.org/licenses/mit-license.php. +"""Test Loan - get interest calculation.""" + +from test_framework.test_framework import DefiTestFramework +from test_framework.util import assert_equal + +import calendar +import time +from decimal import Decimal + +class LoanGetInterestTest (DefiTestFramework): + symbolDFI = "DFI" + symbolBTC = "BTC" + symboldUSD = "DUSD" + + def set_test_params(self): + self.num_nodes = 1 + self.setup_clean_chain = True + self.extra_args = [ + ['-txnotokens=0', '-amkheight=50', '-bayfrontheight=50', '-bayfrontgardensheight=1', + '-fortcanningheight=50', '-fortcanningmuseumheight=200', '-fortcanningparkheight=270', '-fortcanninghillheight=300', '-eunosheight=50', '-txindex=1'] + ] + + def setup(self): + self.nodes[0].generate(150) + + self.account0 = self.nodes[0].get_genesis_keys().ownerAuthAddress + + self.nodes[0].createtoken({ + "symbol": self.symbolBTC, + "name": "BTC token", + "isDAT": True, + "collateralAddress": self.account0 + }) + + self.nodes[0].generate(1) + + idDFI = list(self.nodes[0].gettoken(self.symbolDFI).keys())[0] + idBTC = list(self.nodes[0].gettoken(self.symbolBTC).keys())[0] + + self.nodes[0].utxostoaccount({self.account0: "1000@" + self.symbolDFI}) + + oracle_address1 = self.nodes[0].getnewaddress("", "legacy") + price_feeds1 = [ + {"currency": "USD", "token": "DFI"}, + {"currency": "USD", "token": "BTC"}, + ] + oracle_id1 = self.nodes[0].appointoracle( + oracle_address1, price_feeds1, 10) + self.nodes[0].generate(1) + + # feed oracle + oracle1_prices = [ + {"currency": "USD", "tokenAmount": "100000@DFI"}, + {"currency": "USD", "tokenAmount": "10@BTC"} + ] + timestamp = calendar.timegm(time.gmtime()) + self.nodes[0].setoracledata(oracle_id1, timestamp, oracle1_prices) + self.nodes[0].generate(1) + + self.nodes[0].setcollateraltoken({ + 'token': idDFI, + 'factor': 1, + 'fixedIntervalPriceId': "DFI/USD" + }) + + self.nodes[0].setcollateraltoken({ + 'token': idBTC, + 'factor': 1, + 'fixedIntervalPriceId': "BTC/USD"}) + + self.nodes[0].generate(1) + + self.nodes[0].setloantoken({ + 'symbol': self.symboldUSD, + 'name': "DUSD stable token", + 'fixedIntervalPriceId': "DUSD/USD", + 'mintable': True, + 'interest': 1 + }) + self.nodes[0].generate(1) + + self.nodes[0].createloanscheme(150, 100, 'LOAN150') + + self.nodes[0].generate(5) + + iddUSD = list(self.nodes[0].gettoken(self.symboldUSD).keys())[0] + + self.nodes[0].minttokens("300@" + self.symboldUSD) + self.nodes[0].generate(1) + + poolOwner = self.nodes[0].getnewaddress("", "legacy") + # create pool DUSD-DFI + self.nodes[0].createpoolpair({ + "tokenA": iddUSD, + "tokenB": idDFI, + "commission": Decimal('0.000'), + "status": True, + "ownerAddress": poolOwner, + "pairSymbol": "DUSD-DFI", + }) + self.nodes[0].generate(1) + + self.nodes[0].addpoolliquidity( + {self.account0: ["30@" + self.symbolDFI, "300@" + self.symboldUSD]}, self.account0) + self.nodes[0].generate(1) + + def run_test(self): + self.setup() + + vaultId = self.nodes[0].createvault(self.account0, 'LOAN150') + self.nodes[0].generate(1) + + self.nodes[0].deposittovault(vaultId, self.account0, "400@DFI") + self.nodes[0].generate(1) + + self.nodes[0].takeloan({ + 'vaultId': vaultId, + 'amounts': "2000@" + self.symboldUSD + }) + self.nodes[0].generate(1) + + self.nodes[0].generate(25) # Accrue interest + + getInterest = self.nodes[0].getinterest("LOAN150", "DUSD") + assert_equal(getInterest[0]['totalInterest'], Decimal('0.99923876')) + assert_equal(getInterest[0]['interestPerBlock'], Decimal('0.03843226')) + + self.nodes[0].deposittovault(vaultId, self.account0, "100@DFI") + self.nodes[0].generate(1) + + self.nodes[0].takeloan({ + 'vaultId': vaultId, + 'amounts': "500@" + self.symboldUSD + }) + self.nodes[0].generate(1) + + getInterest = self.nodes[0].getinterest("LOAN150", "DUSD") + assert_equal(getInterest[0]['totalInterest'], Decimal('1.08571134')) + assert_equal(getInterest[0]['interestPerBlock'], Decimal('0.04804032')) + + self.nodes[0].generate(10) # Activate FCM + + self.nodes[0].takeloan({ + 'vaultId': vaultId, + 'amounts': "500.2@" + self.symboldUSD + }) + self.nodes[0].generate(1) + + getInterest = self.nodes[0].getinterest("LOAN150", "DUSD") + assert_equal(getInterest[0]['totalInterest'], Decimal('1.62376677')) + assert_equal(getInterest[0]['interestPerBlock'], Decimal('0.05765223')) + + self.nodes[0].takeloan({ + 'vaultId': vaultId, + 'amounts': "0.00000001@" + self.symboldUSD + }) + self.nodes[0].generate(1) + + getInterest = self.nodes[0].getinterest("LOAN150", "DUSD") + print("getInterest", getInterest) + assert_equal(getInterest[0]['totalInterest'], Decimal('1.68141901')) + assert_equal(getInterest[0]['interestPerBlock'], Decimal('0.05765224')) + + self.nodes[0].takeloan({ + 'vaultId': vaultId, + 'amounts': "50000.00000001@" + self.symboldUSD + }) + self.nodes[0].generate(1) + + getInterest = self.nodes[0].getinterest("LOAN150", "DUSD") + assert_equal(getInterest[0]['totalInterest'], Decimal('2.69987797')) + assert_equal(getInterest[0]['interestPerBlock'], Decimal('1.01845896')) + + for i in range(1, 50): + self.nodes[0].takeloan({ + 'vaultId': vaultId, + 'amounts': "0.00000001@" + self.symboldUSD + }) + self.nodes[0].generate(1) + newInterest = self.nodes[0].getinterest("LOAN150", "DUSD") + assert_equal(newInterest[0]['totalInterest'], Decimal('2.69987797') + newInterest[0]['interestPerBlock'] * i) + +if __name__ == '__main__': + LoanGetInterestTest().main() diff --git a/test/functional/feature_loan_payback_dfi.py b/test/functional/feature_loan_payback_dfi.py index bcb193ab37a..4d85026a916 100755 --- a/test/functional/feature_loan_payback_dfi.py +++ b/test/functional/feature_loan_payback_dfi.py @@ -3,7 +3,7 @@ # Copyright (c) DeFi Blockchain Developers # Distributed under the MIT software license, see the accompanying # file LICENSE or http://www.opensource.org/licenses/mit-license.php. -"""Test Loan - payback loan.""" +"""Test Loan - payback loan dfi.""" from test_framework.test_framework import DefiTestFramework from test_framework.util import assert_equal, assert_raises_rpc_error @@ -13,7 +13,7 @@ from decimal import Decimal, ROUND_UP -class PaybackLoanTest (DefiTestFramework): +class PaybackDFILoanTest (DefiTestFramework): def set_test_params(self): self.num_nodes = 1 self.setup_clean_chain = True @@ -287,4 +287,4 @@ def run_test(self): if __name__ == '__main__': - PaybackLoanTest().main() + PaybackDFILoanTest().main() diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 383e5520fb7..4db7114cc6c 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -164,6 +164,7 @@ 'feature_loan_setloantoken.py', 'feature_loan_basics.py', 'feature_loan_payback_dfi.py', + 'feature_loan_get_interest.py', 'feature_loan_listauctions.py', 'feature_loan_auctions.py', 'feature_loan_dusd_as_collateral.py',