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

create custom CompoundTokenAdapters per InterestRateModel #55

Open
thetechnocratic opened this issue Jul 27, 2022 · 1 comment
Open

Comments

@thetechnocratic
Copy link
Contributor

No description provided.

@thetechnocratic
Copy link
Contributor Author

different cTokens use different InterestRateModels

in Legacy, getBorrowRate returns 2 uint256 values
in JumpRateModel, getBorrowRate returns 1 uint256

    /**
      * @notice Calculates the current borrow interest rate per block
      * @param cash The total amount of cash the market has
      * @param borrows The total amount of borrows the market has outstanding
      * @param reserves The total amount of reserves the market has
      * @return error code (0 = no error), The borrow rate per block (as a percentage, and scaled by 1e18)
      */
    function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint,uint);

vs

    /**
      * @notice Calculates the current borrow interest rate per block
      * @param cash The total amount of cash the market has
      * @param borrows The total amount of borrows the market has outstanding
      * @param reserves The total amnount of reserves the market has
      * @return The borrow rate per block (as a percentage, and scaled by 1e18)
      */
    function getBorrowRate(uint cash, uint borrows, uint reserves) external view returns (uint);

therefore, we need separate token adapters depending on which InterestRateModel a cToken uses. we should modify the LibCompound and add another function account for this.
we should also check the codehash of the InterestRateModel to be sure it hasn't changed without us noticing (and revert the call with InvalidState if it has)

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

1 participant