Giter Site home page Giter Site logo

morpho-blue-irm's People

Contributors

jean-grimal avatar julien-devatom avatar mathisgd avatar merlinegalite avatar qgarchery avatar rubilmax avatar tomrpl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

morpho-blue-irm's Issues

There is no event emission

The Irm has a storage per market; values are not logged when modified.

I suggest adding an event during the borrowRate update.

Contract name is too general

  • There is no information about the specification of the Irm in the name. It can become harder to refer to this IRM when other irm are whitelisted.

I suggest adding a specific name for this IRM, such as PidIrm.

Test living vertigo mutations

Mutation testing report:
Number of mutations:    75
Killed:                 50 / 75

Mutations:
Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/AdaptiveCurveIrm.sol
    Line nr: 75
    Result: Lived
    Original line:
                 require(curveSteepness <= ConstantsLib.MAX_CURVE_STEEPNESS, ErrorsLib.INPUT_TOO_LARGE);

    Mutated line:
                 require(curveSteepness < ConstantsLib.MAX_CURVE_STEEPNESS, ErrorsLib.INPUT_TOO_LARGE);


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/AdaptiveCurveIrm.sol
    Line nr: 77
    Result: Lived
    Original line:
                 require(adjustmentSpeed <= ConstantsLib.MAX_ADJUSTMENT_SPEED, ErrorsLib.INPUT_TOO_LARGE);

    Mutated line:
                 require(adjustmentSpeed < ConstantsLib.MAX_ADJUSTMENT_SPEED, ErrorsLib.INPUT_TOO_LARGE);


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/AdaptiveCurveIrm.sol
    Line nr: 78
    Result: Lived
    Original line:
                 require(targetUtilization < WAD, ErrorsLib.INPUT_TOO_LARGE);

    Mutated line:
                 require(targetUtilization <= WAD, ErrorsLib.INPUT_TOO_LARGE);


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/AdaptiveCurveIrm.sol
    Line nr: 79
    Result: Lived
    Original line:
                 require(targetUtilization > 0, ErrorsLib.ZERO_INPUT);

    Mutated line:
                 require(targetUtilization >= 0, ErrorsLib.ZERO_INPUT);


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/AdaptiveCurveIrm.sol
    Line nr: 81
    Result: Lived
    Original line:
                 require(initialRateAtTarget <= ConstantsLib.MAX_RATE_AT_TARGET, ErrorsLib.INPUT_TOO_LARGE);

    Mutated line:
                 require(initialRateAtTarget < ConstantsLib.MAX_RATE_AT_TARGET, ErrorsLib.INPUT_TOO_LARGE);


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/AdaptiveCurveIrm.sol
    Line nr: 121
    Result: Lived
    Original line:
                 int256 errNormFactor = utilization > TARGET_UTILIZATION ? WAD - TARGET_UTILIZATION : TARGET_UTILIZATION;

    Mutated line:
                 int256 errNormFactor = utilization >= TARGET_UTILIZATION ? WAD - TARGET_UTILIZATION : TARGET_UTILIZATION;


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/libraries/adaptive-curve/ExpLib.sol
    Line nr: 27
    Result: Lived
    Original line:
                     if (x < LN_WEI_INT) return 0;

    Mutated line:
                     if (x <= LN_WEI_INT) return 0;


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/libraries/adaptive-curve/ExpLib.sol
    Line nr: 33
    Result: Lived
    Original line:
                     int256 roundingAdjustment = (x < 0) ? -(LN_2_INT / 2) : (LN_2_INT / 2);

    Mutated line:
                     int256 roundingAdjustment = (x <= 0) ? -(LN_2_INT / 2) : (LN_2_INT / 2);


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/lib/morpho-blue/src/libraries/MathLib.sol
    Line nr: 32
    Result: Lived
    Original line:
                 return (x * y + (d - 1)) / d;

    Mutated line:
                 return (x * y + (d - 1)) * d;


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/lib/morpho-blue/src/libraries/MathLib.sol
    Line nr: 32
    Result: Lived
    Original line:
                 return (x * y + (d - 1)) / d;

    Mutated line:
                 return (x * y - (d - 1)) / d;


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/lib/morpho-blue/src/libraries/MathLib.sol
    Line nr: 32
    Result: Lived
    Original line:
                 return (x * y + (d - 1)) / d;

    Mutated line:
                 return (x / y + (d - 1)) / d;


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/lib/morpho-blue/src/libraries/MathLib.sol
    Line nr: 32
    Result: Lived
    Original line:
                 return (x * y + (d - 1)) / d;

    Mutated line:
                 return (x * y + (d + 1)) / d;


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/lib/morpho-blue/src/libraries/MathLib.sol
    Line nr: 42
    Result: Lived
    Original line:
                 return firstTerm + secondTerm + thirdTerm;

    Mutated line:
                 return firstTerm + secondTerm - thirdTerm;


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/lib/morpho-blue/src/libraries/MathLib.sol
    Line nr: 42
    Result: Lived
    Original line:
                 return firstTerm + secondTerm + thirdTerm;

    Mutated line:
                 return firstTerm - secondTerm + thirdTerm;


Mutation:
    File: /home/rubilmax/sites/morpho.xyz/morpho-blue-irm/src/libraries/adaptive-curve/ConstantsLib.sol
    Line nr: 17
    Result: Lived
    Original line:
             int256 internal constant MAX_ADJUSTMENT_SPEED = int256(1_000 ether) / 365 days;

    Mutated line:
             int256 internal constant MAX_ADJUSTMENT_SPEED = int256(1_000 ether) * 365 days;

Higher the minimum rate ?

Currently the minimum rate is 1e-18 per second, which is very low (~1e-11% APR). If a market is abandoned and then re-used, this very low rate might take a long time to come back to reasonable values. Maybe it could be capped to something higher.

Not compound rate variation ?

          I seriously wonder if it is not a bit overkill. This computation cost a non-negligible amount of gas, and it is complex: it requires to ensure that there are no overflow in a computation up to a power of 12 (and it has also a limit when the linear variation is < -3).

Something simpler like

        uint256 variationMultiplier = WAD_INT + linearVariation;

would not have those issues. I understand that we would lose the property that having multiple updates in an interval is the same as having one update at the end, but this is only a third order loss in the worst case:

  • approximating an amount is a first order precision issue
  • approximating the rate (for example linear instead of compounded) is a second order precision issue
  • approximating the variation of the rate is a third order precision issue

It was already unclear for rates if it was worth the extra computation cost, it may be the case here that it's not worth at all

Originally posted by @QGarchery in #1 (comment)

Optimize wExp

There is this idea by @QGarchery, and probably other ideas. I estimate the current two wExp to be responsible for a little bit more than half of the total gas cost of the borrowRate function

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.