- Assert requires that an overpayment reduces the value of a loan. If
the overall loan interest is low enough, it could leave it unchanged.
Update the assert to require that the overpayment does not increase
the value of the loan.
- Adds a unit test provided by @gregtatcam to demonstrate this issue.
- Vault and LoanBroker pseudo-accounts can hold MPTs, regardless of MPTRequireAuth setting.
- Add requireAuth check in LoanBrokerCoverDeposit and LoanPay.
- Fail attempts to unauthorize pseudo-accounts by MPT issuers.
- Scale the loan to the Vault, so that amounts moving to the vault are
less likely to have rounding errors.
- Similar to LoanPay, when LoanManage defaults a loan, round the amounts
to the Vault scale (because the Vault scale can change) before
applying them to the Vault.
- Ensures a consistent fixed payment amount for the entire life of the
loan, except the final payment, which is guaranteed to be the same or
smaller.
- Convert some Loan structs to compute values that had need manual
updates to stay consistent.
- Fail the transaction in `LoanPay` if it violates the Vault `assetsAvailable <=
assetsTotal` invariant.
- Use constexpr to check that min mantissa value for Number and STAmount
is a power of 10, and compute the max in terms of the min.
- Improve unit tests:
- Use BrokerParameters and Loan Parameters instead of semi-global
class values
- In tests, check that the expected number of loan payments are made.
- Add LoanBatch manual test to generate a set number of random loans,
set them up, and pay them off.
- Add LoanArbitrary manual test to run a single test with specific
(hard-coded for now) parameters.
- Add Number support to XRP_t.
- sfCoverRateMinimum and sfCoverRateLiquidation must be both zero or
both non-zero, because both are used in the default amount
calculations, which is the only place they're really meaningful.
- Compute the next "true" state, round the values off, then compute the
deltas needed to get the current state to that state. Plus some data
integrity checks.
- Add `Number::zero`, which is longer to type, but more readable than
`Number{}`.
- Prepare to improve Loan unit tests: track managementFeeRate in
BrokerInfo, define a LoanParameters object for creation options and
start adding support for it, track and verify loan state while making
payments.
- Addresses FIND-013 from audit.
- Bases the limit on the current ledger time, and ensures that
"payments * interval <= limit". This allows a loan to potentially run through
"the end of time" successfully, but not go a second over.
- Wrote several test cases, including a few that go right to "the end of
time".
- FIND-005, FIND-009, and FIND-010.
- Add the finding number to existing tests - FIND-001, FIND-003,
FIND-012, FIND-007.
- Tweak the interest rate failure log messages in LoanSet.
- Addresses FIND-005 from audit.
- Tuning values defined in Protocol.h. Optimal values TBD.
- loanPaymentsPerFeeIncrement: calculateBaseFee estimates the number
of payments included in the Amount and charges
"baseFee * number / loanPaymentsPerFeeIncrement".
- loanMaximumPaymentsPerTransaction: If the number of payments
(including overpayments if applicable) hits this limit, stop
processing more payments, but DO NOT FAIL.
- Fix the rounding in LoanSet for Guard 4 (sufficient computed payments)
- Tweak several test parameters to account for the new limits.
- Change payment component rounding for IOUs to "towards_zero".
- Add some safety limits to loan calculations to prevent nonsensical
values.
- Addresses FIND-006 from audit.
- Removes the "minimum" check for sfLoanOriginationFee, and replaces it
with a "valid range" check with the max value being
sfPrincipalRequested.
- Reuses the test from the report, with some modifications.
- Also adds some more test cases for existing interest rate tests.
- Changes:
1. Removed the `AssetType` template parameter from all functions in
favor of just using the `Asset` class.
2. Fully moved all `ripple::detail` functions from .h to .cpp.
3. Moved all definitions of non `detail` functions from .h to .cpp,
except roundPeriodicPayment, just because it's small and I want it
to be visible. Left declarations in .h
4. Moved `PaymentSpecialCase`, `PaymentComponents` and
`computePaymentComponents` into `detail` and updated references.
- This is an intermediate commit. It leaves the old variables in place,
so I can do verifications that the new computations are correct. They
will be removed in the next commit.
- PaymentComponents is an class used internally to break a payment value
into principal, interest, and fees.
- Adds a check to the MPToken creation invariant to ensure none are created for the issuer.
- `addEmptyHolding()` will return success without doing anything for these scenarios. There is nothing to do, as with XRP.
---------
Co-authored-by: Ed Hennis <ed@ripple.com>
- Loan scale is completely irrelevant to integral types (XRP, MPT), and
the field is "soeDEFAULT", so when set to 0, it won't be stored on
ledger, saving a little bit of space.
- Move management fee calculations out of transactors an into the
appropriate functions in LendingHelpers.h.
- Rewrite how overpayments are handled. May changed based on numerical
analysis.
- Update, fix, and clean up unit tests. Includes adding tolerances for
some checks where an exact match is unlikely.
- Add "integral()" function to Asset to simplify a common check.
- Rename some of the helper functions / lambdas.
- Update tracked interestOwed field better at final payoff.
- Add checks in LoanSet that the fields can be represented in the asset
type, and update test that fails those checks
(testLoanPayComputePeriodicPaymentValidRateInvariant)
- Also check that the computed periodic payment can be represented as
the asset type, and doesn't round _UP_ to 0.
- Update asserts to account for more scenarios, including initial loan
computation.
- Implement AccountSendMulti
- Document the derivations of loan components.
- Add "loanPrincipalFromPeriodicPayment" helper.
- Removed sfReferencePrincipal
- LoanSet and LoanPay can create MPTokens as a side effect
- LoanPay will send the fee to cover if the broker owner is deep frozen,
and fail if both of them are deep frozen.
- LoanPay will check auth for the receivers, or create holdings for the
submitting account if needed.
- LoanSet will fail if principal requested is not positive
- Handle overpayment in a separate function
- Add a test helper to check that balance changes went as expected
- Fix more tests
- Tests not expected to pass.
- Check in LoanSet if a loan with interest actually has interest.
tecPRECISION_LOSS if not.
- Add checks in LoanPay for deep froze broker owner and pseudoaccount.
- Fix management fee calculations in LoanPay and associated LoanBroker
and Vault data updates.
- Make state tracking next payment due date optional.
- Add a test case showing multiple payments combined.
- Update more tests to work with the new fields.
- Primarily updating tests, and fixing stuff that didn't work.
- Tests still not expected to pass.
- Add Json::Value::isMember(StaticString) so SFields can be used.
- Validate more fields in ValidLoan Invariant
- Making a payment on an impaired loan will unimpair the loan, which
changes Vault.LossUnrealized.
- Add a step in unit tests to impair a loan before making a payment, to
verify, and prevent future similar regressions.
- Resolves regression RIPD-3650
- All current items are done
- Mostly comments
- Restructured PaymentParts (formerly PeriodicPaymentParts) to bring
along fees, and removed the computed / combined PeriodicPayment from
places that should be using PaymentParts instead.