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

Loans: multiple cashflows PoC #1408

Closed
wants to merge 4 commits into from
Closed

Loans: multiple cashflows PoC #1408

wants to merge 4 commits into from

Conversation

hieronx
Copy link
Contributor

@hieronx hieronx commented Jun 19, 2023

Description

Implements a basic PoC for multiple cashflows, specifically monthly or semi-annual interest payments, as well as a corresponding write-off trigger.

Checklist:

  • I have added Rust doc comments to structs, enums, traits and functions
  • I have made corresponding changes to the documentation
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works

Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like to much!

pallets/loans/src/lib.rs Outdated Show resolved Hide resolved
pallets/loans/src/types/mod.rs Outdated Show resolved Hide resolved
pallets/loans/src/types/mod.rs Outdated Show resolved Hide resolved
pallets/loans/src/types/mod.rs Outdated Show resolved Hide resolved
pallets/loans/src/lib.rs Outdated Show resolved Hide resolved
@@ -52,6 +52,7 @@ impl<Rate: FixedPointNumber> DiscountedCashFlow<Rate> {
})
}

// TODO: this should account for cashflows from interest payments
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should tackle this in a future PR

Balance: tokens::Balance + FixedPointOperand,
Rate: FixedPointNumber,
{
// TODO: once we implement a pay_down_schedule other than `None`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should tackle this in a future PR

Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor comment below. Tell me when it's ready for a final deep review

pallets/loans/src/entities/loans.rs Outdated Show resolved Hide resolved
@hieronx hieronx changed the base branch from main to loans/principal-and-interest July 5, 2023 09:35
Base automatically changed from loans/principal-and-interest to main July 10, 2023 17:32
@lemunozm
Copy link
Contributor

I've redo the PR because 99% of the changes were git conflicts with others PRs. I hope I did it well.

lemunozm added a commit that referenced this pull request Apr 5, 2024
@lemunozm lemunozm mentioned this pull request Apr 5, 2024
9 tasks
@lemunozm
Copy link
Contributor

lemunozm commented Apr 5, 2024

Re-created branch & PR #1797

Most of the code generated conflicts when rebasing, and I want to maintain this as it is as reference.

@lemunozm lemunozm closed this Apr 5, 2024
lemunozm added a commit that referenced this pull request Apr 15, 2024
lemunozm added a commit that referenced this pull request Jun 7, 2024
* updated from #1408

* add testing

* organize and polish cashflow module

* add Runtime API

* update types.md

* make it works without chronoutils

* minor changes

* add borrow check

* fix legacy increase_debt test

* add loan cashflow tests

* compute principal and interest

* correct validation

* add CashflowPayment type

* add variant error

* fix interest computation when months are partial

* remove Rate usage and use weight

* fix start date for cashflows

* rename api name

* fix benchmarks

* taplo fmt

* using a lower discount rate to simply benchmarking

* rewrite doc line

* interest computed at maturity

* remove borrow support

* fix compilation

* None to OnceAtMaturity variant

* compilation fixes

* Loans: multi cashflows fix external loan (#1864)

* correct principal/interest for both kind of loans

* support for external prices

* add external test

* simplify implementation

* start from repayments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants