Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative interest rate support #1423

Merged
merged 92 commits into from
Aug 29, 2022
Merged
Changes from 1 commit
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
e0ec4c3
Fixes type check on verbose parameter
dcorral Jun 13, 2022
66f2707
Merge branch 'master' of github.com:DeFiCh/ain into fix-getvault-verbose
dcorral Jul 6, 2022
4700496
Add high precission string for getvault verbose
dcorral Jul 7, 2022
35b00eb
Fixes error, return -1 when there are locked tokens
dcorral Jul 7, 2022
40d2fda
Remove Boost Thread and Chrono (#1349)
Bushstar Jul 11, 2022
16bc19e
Separate undo database from account database (#1362)
Bushstar Jul 11, 2022
e9ebb04
updatemasternode (#1343)
Bushstar Jul 11, 2022
e3fe62a
Revert "Separate undo database from account database (#1362)"
Bushstar Jul 11, 2022
2df6f72
TX version and expiration (#1346)
Bushstar Jul 11, 2022
67e12c8
Migrate undos to dedicated DB (#1381)
Bushstar Jul 12, 2022
5b91dc6
Merge branch 'master' into fix-getvault-verbose
dcorral Jul 13, 2022
6d5d5a9
Revert "Migrate undos to dedicated DB (#1381)"
Bushstar Jul 17, 2022
f224c4d
Negative Interest
Bushstar Jul 18, 2022
7b6148a
Merge branch 'fix-getvault-verbose' of github.com:DeFiCh/ain into neg…
dcorral Jul 18, 2022
304b7c0
Allows negative interests on loan tokens
dcorral Jul 18, 2022
d3851d8
tests: change error text
Bushstar Jul 18, 2022
8a92bcd
Order getmasternodeblocks results (#1388)
Bushstar Jul 19, 2022
21d0701
Revert "TX version and expiration (#1346)"
Bushstar Jul 25, 2022
bef9c14
Add testing to negative interest
dcorral Jul 28, 2022
e39414b
Remove breakpoint from failing test
dcorral Jul 28, 2022
2a329b1
Allow fallthrough from LoanMintingInterest
Bushstar Aug 2, 2022
14a0857
Update test to fail as expected
Bushstar Aug 2, 2022
ae92630
Apply token interest to all vaults immediately
Bushstar Aug 2, 2022
dc5066c
Partial negative vault interest
Bushstar Aug 4, 2022
6eb99b4
lint: Fix error
Bushstar Aug 4, 2022
3e815b5
Adds tests for negative interests
dcorral Aug 17, 2022
67a92e2
Add failing tests for discussion
dcorral Aug 17, 2022
4ce146a
Fix tests for correct behaviour
dcorral Aug 17, 2022
2425c53
Further negative interest rate updates
Bushstar Aug 18, 2022
79e8847
Check correct height value for incorrect amount. Restores behaviour.
Bushstar Aug 18, 2022
52ef2fc
TotalInterestCalculation use higher precision
Bushstar Aug 18, 2022
3f95ce1
Fix getinterest RPC when token param is passed
Jouzo Aug 18, 2022
cf46254
Add tests for loan paid by negative interest
dcorral Aug 18, 2022
b755727
Do not sub minted token
Bushstar Aug 19, 2022
801789e
Store negative interest the same as positive interest was stored
Bushstar Aug 19, 2022
400582d
Set negative bool in all branches
Bushstar Aug 19, 2022
4c16685
Remove unused variable
Bushstar Aug 19, 2022
da65598
Call EraseInterest on take loan
Bushstar Aug 19, 2022
715366d
Fixes tests to match new implementation
dcorral Aug 19, 2022
acc0e61
Total loan should not wrap around
Bushstar Aug 20, 2022
b20d3f3
Add getstoredinterest
Bushstar Aug 20, 2022
84ac0b1
Simplify interest addition lambda
Bushstar Aug 20, 2022
cd127ea
Add TotalInterestCalculation unit test
Jouzo Aug 20, 2022
439a451
Fix interest cal on tests after new updates
dcorral Aug 22, 2022
2164a44
Add new suite of functional test for getstoredinterest
dcorral Aug 22, 2022
1724978
Introduce helper functions and function template
dcorral Aug 22, 2022
2060940
Add helper functions
dcorral Aug 22, 2022
140a78b
Add stored interest test
Bushstar Aug 22, 2022
3cd816c
Add negative ITH positive IPB cases
Bushstar Aug 22, 2022
2f97316
Combine duplicate interest additions
Bushstar Aug 22, 2022
1a4e140
Update vault failing test
dcorral Aug 22, 2022
1ebf931
Pass new scheme to StoreInterest
Bushstar Aug 22, 2022
b910ffb
Add updatevault complete tests
dcorral Aug 22, 2022
d3da038
Remove subInterest assignation
dcorral Aug 22, 2022
be83d04
Adds test for takeloan
dcorral Aug 22, 2022
9c8a994
Wipe interest on take loan with negative interest
Bushstar Aug 23, 2022
bb3d90d
Test full payback
Bushstar Aug 23, 2022
a4edbd0
On take loan negate existing loan amount only
Bushstar Aug 24, 2022
1c8eeeb
Update negative interest test
Bushstar Aug 24, 2022
2c2c4d6
Do not sub balance on payback if loan negated
Bushstar Aug 24, 2022
0179613
Negative interest pays loan back first
Bushstar Aug 24, 2022
d2c134c
Add payback loan functional tests
Jouzo Aug 24, 2022
896f4e0
Adds remainning tests for takeloan
dcorral Aug 24, 2022
4f9950f
Merge branch 'master' into epic/v3
prasannavl Aug 25, 2022
227bbe8
Merge branch 'epic/v3' of ssh://github.com/DeFiCh/ain into negative-i…
prasannavl Aug 25, 2022
648e4f7
Revert "updatemasternode (#1343)"
prasannavl Aug 25, 2022
fcc8dd8
Checked expected ITH
Bushstar Aug 25, 2022
cd10158
Fix lint error
dcorral Aug 25, 2022
8ce856f
Extend basic negative interest tests
Bushstar Aug 25, 2022
3dd47d4
Add failing case for paid loan and take loan again
dcorral Aug 25, 2022
c32398a
Merge branch 'master' into feature/negative_interest
Jouzo Aug 25, 2022
d3939b7
Merge branch 'master' into feature/negative_interest
prasannavl Aug 26, 2022
ea4f6a2
Fix tests
dcorral Aug 26, 2022
457c9e1
Merge branch 'feature/negative_interest' of github.com:DeFiCh/ain int…
dcorral Aug 26, 2022
81eb92b
Reduce or remove loan amounts from auctions
Bushstar Aug 26, 2022
78ed2ab
Add takeloan input guards
prasannavl Aug 26, 2022
748e2a6
Add payback input guards
prasannavl Aug 26, 2022
4894d20
Fix string format
prasannavl Aug 26, 2022
1b91268
Reset interest on migration with recalculations
prasannavl Aug 26, 2022
6743c04
Bring payback amount checks in line with takeloan checks
prasannavl Aug 26, 2022
14d679c
Add fork guard to new amount guards
Bushstar Aug 26, 2022
f049adf
Floor negative interest
Bushstar Aug 26, 2022
b0886a0
Merge branch 'master' into feature/negative_interest
Bushstar Aug 26, 2022
d8ebeab
Do not store negative zero
Bushstar Aug 26, 2022
1780f33
Addapt test for rounding in negative interest amounts
dcorral Aug 26, 2022
9461e58
Merge branch 'master' into feature/negative_interest
prasannavl Aug 26, 2022
4010f1e
Handle zero "positive" interest before minimum interest introduced
Bushstar Aug 28, 2022
5d9f40c
Rename functions
Bushstar Aug 28, 2022
8c532fb
Update negative interest on withdraw from vault
Bushstar Aug 28, 2022
2ad9a91
Move fork guard
Bushstar Aug 29, 2022
a3da303
Sub full loan amount. Wipe negative interest in liquidation.
Bushstar Aug 29, 2022
e075fb7
Adds test for auction and negative interests
dcorral Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Pass new scheme to StoreInterest
  • Loading branch information
Bushstar committed Aug 22, 2022
commit 1ebf93102eb504d944ea7e8cd7fdbefc5c174d3b
6 changes: 3 additions & 3 deletions src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2976,7 +2976,8 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
return Res::Err("tx must have at least one input from token owner");

// loan scheme exists
if (!mnview.GetLoanScheme(obj.schemeId))
const auto scheme = mnview.GetLoanScheme(obj.schemeId);
if (!scheme)
return Res::Err("Cannot find existing loan scheme with id %s", obj.schemeId);

// loan scheme is not set to be destroyed
Expand All @@ -2995,7 +2996,6 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
if (!collateralsLoans)
return std::move(collateralsLoans);

auto scheme = mnview.GetLoanScheme(obj.schemeId);
if (collateralsLoans.val->ratio() < scheme->ratio)
return Res::Err("Vault does not have enough collateralization ratio defined by loan scheme - %d < %d", collateralsLoans.val->ratio(), scheme->ratio);
}
Expand All @@ -3006,7 +3006,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
for (const auto& [tokenId, tokenAmount] : loanTokens->balances) {
const auto loanToken = mnview.GetLoanTokenByID(tokenId);
assert(loanToken);
res = mnview.StoreInterest(height, obj.vaultId, vault->schemeId, tokenId, loanToken->interest, 0);
res = mnview.StoreInterest(height, obj.vaultId, obj.schemeId, tokenId, loanToken->interest, 0);
if (!res) {
return res;
}
Expand Down