-
Notifications
You must be signed in to change notification settings - Fork 85
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
Fix: linear accrual not overpassing maturity #1842
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -812,3 +812,41 @@ fn with_unregister_price_id_and_oracle_not_required() { | |
); | ||
}); | ||
} | ||
|
||
#[test] | ||
fn with_external_pricing_and_overdue() { | ||
new_test_ext().execute_with(|| { | ||
let loan_id = util::create_loan(LoanInfo { | ||
..util::base_external_loan() | ||
}); | ||
|
||
let amount = ExternalAmount::new(QUANTITY, PRICE_VALUE); | ||
util::borrow_loan(loan_id, PrincipalInput::External(amount)); | ||
|
||
// The loan is overdue | ||
advance_time(YEAR * 2); | ||
|
||
let amount = ExternalAmount::new(QUANTITY, PRICE_VALUE); | ||
config_mocks(amount.balance().unwrap()); | ||
assert_ok!(Loans::repay( | ||
RuntimeOrigin::signed(BORROWER), | ||
POOL_A, | ||
loan_id, | ||
RepaidInput { | ||
principal: PrincipalInput::External(amount), | ||
interest: 0, | ||
unscheduled: 0, | ||
}, | ||
)); | ||
|
||
let active_loan = util::get_loan(loan_id); | ||
|
||
let settlement_price_updated = match active_loan.pricing() { | ||
ActivePricing::External(inner) => inner.settlement_price_updated(), | ||
_ => unreachable!(), | ||
}; | ||
|
||
// We must never overpass madurity date | ||
assert_eq!(active_loan.maturity_date(), settlement_price_updated); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we also check, that the linear pricing actually clamps with giving the notional baack? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would still like to test the case where
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's tested currently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it is repaid with one DAY of overdue, and the expected value is |
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.
I guess maturity not being passed already is checked by the
ensure_can_borrw()
?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.
But not in
repay()