InverseFinance / anchor

BSD 3-Clause "New" or "Revised" License
28 stars 25 forks source link

Hiring task: Create a price-based interest rate model #24

Open nourharidy opened 2 years ago

nourharidy commented 2 years ago

Background

Currently, BaseJumpRateModelV2 is used to calculate interest rates for all Anchor markets based on borrowing utilization rate of the market liquidity.

However, unlike other assets on Anchor, DOLA is a stablecoin that's originally minted on Anchor. Interest rates should be set not based on liqudity utilization, but rather based on the DOLA's $1 USD peg. If DOLA is <$1, then DOLA supply should be reduced in order to meet the decrease in demand. Therefore, DOLA interest rate should rise in order to incentivize borrower repayments, reducing the supply in circulation. If DOLA is >$1, then supply should be increased in order to meet increased demand. Therefore, interest rates should be decreased in order to incentivize more borrows, expanding supply in circulation.

Right now, we use a contract called the Fed in order to mint or redeem DOLA in the Anchor DOLA market in order to increase or reduce the interest rate. However, this requires manual intervention by an operator who doesn't always respond to DOLA price changes in time.

Requirements

tirtha4 commented 2 years ago

@nourharidy according to the requirements, getSupplyRate & getBorrowRate has no role. So is it okay to remove the unwanted functions & state vars from the forked BaseJumpRateModelV2.sol ?

nourharidy commented 2 years ago

@nourharidy according to the requirements, getSupplyRate & getBorrowRate has no role. So is it okay to remove the unwanted functions & state vars from the forked BaseJumpRateModelV2.sol ?

  • Also the address for cToken will also be passed via constructor right? Is cToken the base contract for DOLA ? From where should I get the source code for cToken in order to instantiate and use within this contract?

According to the requirement, you have to respect the InterestRateModel interface (used by cTokens). It's ok to remove anything that is not in the interface.

cToken address should be passed yup. cToken contract is in this repo. However, you do not need to import it in your own code.

noqcks commented 2 years ago

Added you as a collaborator to my private repo noqcks/inv-hiring-task