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

fix(constructor): add parameter bounds & extract constants / wExp #66

Merged
merged 11 commits into from
Nov 16, 2023

Conversation

Rubilmax
Copy link
Contributor

The suggested bounds are purely arbitrary and open to debate

src/libraries/AdaptativeCurveIrmLib.sol Outdated Show resolved Hide resolved
src/SpeedJumpIrm.sol Outdated Show resolved Hide resolved
src/SpeedJumpIrm.sol Outdated Show resolved Hide resolved
src/libraries/AdaptativeCurveIrmLib.sol Outdated Show resolved Hide resolved
@Rubilmax Rubilmax changed the title fix(constructor): add parameter bounds fix(constructor): add parameter bounds & extract constants / wExp Nov 11, 2023
@Rubilmax Rubilmax linked an issue Nov 11, 2023 that may be closed by this pull request
Base automatically changed from fix/exp-overflow-35 to refactor/curve November 14, 2023 08:45
QGarchery
QGarchery previously approved these changes Nov 14, 2023
Copy link
Contributor

@QGarchery QGarchery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the min/max rate at target could be immutables actually (we already considered changing them in #64), but this can be done in another PR

@Rubilmax
Copy link
Contributor Author

This PR should not be merged before the underlying PR is merged otherwise we'll have file renamings mixed with file changes

@Rubilmax Rubilmax mentioned this pull request Nov 15, 2023
@Rubilmax Rubilmax force-pushed the fix/bound-constructor branch from 061f89f to c9a3e20 Compare November 16, 2023 15:04
int256 internal constant WEXP_UPPER_BOUND = 93.859467695000404319 ether;

/// @dev The value of wExp(`WEXP_UPPER_BOUND`).
int256 internal constant WEXP_UPPER_VALUE = 57716089161558943949701069502944508345128.422502756744429568 ether;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value was changed because the previous value didn't correspond to the bound from the unbounded wExp

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except that the code is correct (just checked)

@Rubilmax Rubilmax changed the base branch from refactor/curve to feat/riemann-avg November 16, 2023 15:07
int256 internal constant WEXP_UPPER_BOUND = 93.859467695000404319 ether;

/// @dev The value of wExp(`WEXP_UPPER_BOUND`).
int256 internal constant WEXP_UPPER_VALUE = 57716089161558943949701069502944508345128.422502756744429568 ether;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

except that the code is correct (just checked)

src/libraries/adaptative-curve/ConstantsLib.sol Outdated Show resolved Hide resolved
Jean-Grimal
Jean-Grimal previously approved these changes Nov 16, 2023
Base automatically changed from feat/riemann-avg to refactor/curve November 16, 2023 18:30
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

library ConstantsLib {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we need a constantLib for the IRM. Everything in the same file is great

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a file is handy for integrators (ourselves) and having it in an dedicated file avoids having to compile the IRM in case the constants are used by integrators (including ourselves)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and if we do follow this suggestion then there should be only 2 constants left in this lib and those would almost never be useful to integrators (who cares about the max curve steepness, you only really care about the curve steepness of the IRM you are interacting with)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same arguments could be used for Blue but still we extracted constants to a file because it's shown to be handy for our test suite alone ; having constants defined in IRM (such as the min/max rates) require to deploy the contract to test things using these bounds... For example what we do in ExpLib but thanks to the constants library we don't need to deploy an IRM to test the upper value of wExp

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying that we should never extract constants. My point is that min/max rates should really be immutables, and I think that the other constants would almost never be useful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me the benefit of having constants defined in a dedicated library and being able to access it outside of the IRM outweighs the loss of conciseness (now the IRM depends on 1 more file)

Whether min/max rates should be immutable is another topic that I'm open to discuss in a dedicated issue

Copy link
Contributor

@QGarchery QGarchery Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opened #96

I think that those topics are not so independent, but I'm fine with the current code in any case

MerlinEgalite
MerlinEgalite previously approved these changes Nov 16, 2023
Base automatically changed from refactor/curve to main November 16, 2023 18:43
@MerlinEgalite MerlinEgalite dismissed stale reviews from Jean-Grimal, QGarchery, and themself November 16, 2023 18:43

The base branch was changed.

@MerlinEgalite MerlinEgalite merged commit c2b1732 into main Nov 16, 2023
3 checks passed
@MerlinEgalite MerlinEgalite deleted the fix/bound-constructor branch November 16, 2023 19:02
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

Successfully merging this pull request may close these issues.

rename files after #54
5 participants