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

Extend loan instead of roll + small cleanup #54

Merged
merged 16 commits into from
Sep 12, 2023
Merged

Extend loan instead of roll + small cleanup #54

merged 16 commits into from
Sep 12, 2023

Conversation

ind-igo
Copy link
Collaborator

@ind-igo ind-igo commented Sep 8, 2023

Changes:

  • Remove roll loan logic, instead make function for lender to extend the loan in exchange for paying off the accrued interest
  • Split amounts due in cooler to principle and interest, which allows clearer logic on defaults, receivables accounting, and loan extension
  • recievables made into interestReceivables, which when combined with TRSRY.debt for the clearinghouse, can give you the total receivables. There is a case where the TRSRY.debt can be out of sync with the true recievables, for example when debt is repaid and interest has been decremented but principle hasn't. This case is fixed by calling rebalance().
  • Simplify coolers to be mostly an escrow with minimal interactions for lending. It is mostly now for borrowers to create requests, to hold collateral, and facilitate transfers between the lender and borrower. All other functions needed for lending assets to your cooler are done via the lender contract (clearinghouse)
  • The loan repayDirect logic is replaced with a method for the lender to change the repayment address for a cooler's loan, which simplifies repayment logic
  • consolidate some of the loan and interest calculation functions in the clearinghouse. the clearinghouse now its own functions for setting loan interest and collateral needed. The cooler has more general ones for non-Clearinghouse lenders to use.

loan.request.active = false;
// Update loan terms to reflect the extension.
loan.expiry += loan.request.duration * times_;
loan.interestDue = interestFor(
Copy link

Choose a reason for hiding this comment

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

So, as I understand it:

  1. Any amount repaid is ignored when the loan is extended
  2. At any point, the lender can extend the loan arbitrarily
  3. The borrower does not get a penny's worth of collateral back until they've paid back all the extra interest that the lender unilaterally demanded

I cannot sign off on this fix.

Copy link
Collaborator

@0xrusowsky 0xrusowsky Sep 16, 2023

Choose a reason for hiding this comment

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

we can probably discuss this better in discord, but:

  1. You are right, instead of loan.request.amount it should have been loan.principal.
  2. and 3. The premise was that it should always be favorable for a borrower to get an extension. Since the loans are fixed-term, it doesn't make sense to repay in advance, as you always need to pay the same interest. Following this idea, it makes even less sense to partially repay.

Nevertheless, I think your concern is still valid, as ideally, we want 0 trust assumptions between borrower and lender. We could slightly change the extension logic so that the interest due is not updated (therefore only benefiting the borrower with an extension). With this change, we would only need to slightly update the CH logic.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

So now Cooler loans function as an indefinite-period call option on gOhm? Not so allowing of attacks, but seems not great, economically.

I think this needs more thinking through before the final fix review.

Copy link
Collaborator

Choose a reason for hiding this comment

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

well this is exactly what the community voted... extending the loan is the same as repaying and getting another loan, we are just forcing them to prepay the interest in advance.

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.

3 participants