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

Loan: Interest calculation #621

Closed
uzyn opened this issue Jul 19, 2021 · 1 comment
Closed

Loan: Interest calculation #621

uzyn opened this issue Jul 19, 2021 · 1 comment
Assignees

Comments

@uzyn
Copy link
Contributor

uzyn commented Jul 19, 2021

At the tick of every block, blockchain should keep track of the total amount of outstanding balance, with interest included.

Similar to DEX rewards, interest is calculated at every block. For performance reasons, it should be calculated lazily, i.e. at the tick of a block there is no need to calculate loan value for every single vaults.

Interest can come in 2 forms:

  • Vault interest, based on loan scheme
  • Loan token interest

See https://github.com/DeFiCh/pinkpaper/tree/main/loan#interest-rate

Suggested data implementation

DB keeps track of

  • Loan tokens taken out
  • Interest balance
  • Interest balance calculated at block
  • Interest increment per block per loan tokens
  • Collateralization ratio
  • Liquidation block (only need to trigger liquidation if block number is larger than this)

Calculation needs to be triggered on the following events:

  • Oracle price updates. This should happen every 5-15 minutes and not on every block.
  • Vault changes, e.g. more loan / more deposit.
@uzyn uzyn added the area/loan label Jul 19, 2021
@defichain-bot
Copy link
Member

@uzyn: Thanks for opening an issue, it is currently awaiting triage.

The triage/accepted label can be added by foundation members by writing /triage accepted in a comment.

Details

I am a bot created to help the DeFiCh developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the DeFiCh/oss-governance-bot repository.

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

No branches or pull requests

3 participants