Skip to content

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

@nourharidy

Description

@nourharidy

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

  • Create a new interest rate model contract by forking BaseJumpRateModelV2 into your own private repo and invite me as a collaborator.
  • Any changes to the contract should respect the interface of InterestRateModel.
  • Instead of calculating borrow rate based on utilization, the borrow rate should be a fixed value baseRate provided by the owner in the constructor and can be changed using a setter function.
  • add an updateRate() function that is callable by anyone.
    • If DOLA price is under a negativeDepegThreshold price, increase the borrow rate by a fixed value rateStep up to a maximum maxRate.
    • If DOLA price is above a positiveDepegThreshold price, decrease the borrow rate by the same rateStep down to a minimum minRate.
    • If DOLA price is between the two thresholds AND borrow rate is not equal to baseRate, decrease or increase the borrow rate to the direction of baseRate by rateStep e.g. if the borrow rate is higher than baseRate, the borrow rate would decrease by rateStep on each function call until it reaches baseRate.
    • The function should execute all the above logic only if the last time it was called is more than updateRateInterval seconds ago. However, it should NOT revert otherwise. This is in order to allow other contracts to call it without causing them to fail.
    • Every time the borrow rate changes, call cToken.accrueInterest() in order to update the market contract.
    • DOLA price should be fetched from a constructor-provided Chainlink feed contract. See IFeed interface here as an example.
    • All values above should be provided in the constructor and have their own setter functions each.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions