-
Notifications
You must be signed in to change notification settings - Fork 86
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
Feat: decrease debt #1857
Feat: decrease debt #1857
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1857 +/- ##
==========================================
+ Coverage 46.52% 46.65% +0.12%
==========================================
Files 167 167
Lines 13105 13112 +7
==========================================
+ Hits 6097 6117 +20
+ Misses 7008 6995 -13 ☔ View full report in Codecov by Sentry. |
Subquery ticket: centrifuge/api#187 |
/// of the pool is updated to reflect the new present value of the loan. | ||
#[pallet::weight(T::WeightInfo::increase_debt(T::MaxActiveLoansPerPool::get()))] | ||
#[pallet::call_index(14)] | ||
pub fn decrease_debt( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: Add unit test(s) for this. We must not merge PRs which add/alter code without adding/updating tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not adding new logic IMO, just sparing the T::Pool::repay(..)
which will be mocked. So pub fn repay(..)
should already cover everything.
If you disagree, can still add a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a super simple fn increase_debt_does_not_withdraw()
test for the increase_debt()
case, maybe we can create a similar one in tests/repay_loan.rs
checking that nothing goes to the pool. Of course, paranoid mode-on just ensuring future refactors does not break the invariant here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from my suggestion above, LGTM!
|
||
assert_ok!(Loans::borrow( | ||
assert_ok!(Loans::increase_debt( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, amazing test haha. I had this modified in the cashflows. This is an example of how to not test correctly 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling the suggestions!
Description
Allows issuers to decrease the debt of any loan without actually repaying to the pool. Mostly useful for ensuring offchain cash is reflected accurately. This is basically an expense in most cases, should be covered by fees, but is a good increase of flexibility.
NOTE:
Changes and Descriptions
fn decrease_debt(..)
- same asfn repay(..)
but without moving tokens to the poolChecklist: