Skip to content

Adds PriceCappedApi3ReaderProxyV1 #14

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

Merged
merged 5 commits into from
Jun 13, 2025

Conversation

acenolaza
Copy link
Collaborator

@acenolaza acenolaza requested a review from Siegrift June 12, 2025 16:20
Copy link
Contributor

@Siegrift Siegrift left a comment

Choose a reason for hiding this comment

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

👍 LGTM, but I'd support both lower/upper bound.

@acenolaza acenolaza force-pushed the 13-price-cap-stable-api3readerproxyv1 branch from 9faf9c3 to 3127a39 Compare June 12, 2025 16:51
@acenolaza
Copy link
Collaborator Author

👍 LGTM, but I'd support both lower/upper bound.

WDYT of also checking lower/upper bounds in constructor to prevent setting values that might not make sense? We could even add a helper function like isCapped() that might come handy for external callers

Copy link
Contributor

@Siegrift Siegrift left a comment

Choose a reason for hiding this comment

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

WDYT of also checking lower/upper bounds in constructor to prevent setting values that might not make sense? We could even add a helper function like isCapped() that might come handy for external callers

Yeah, that makes sense. Add it please.

About the name

I'd call it PriceCappedApi3ReaderProxyV1. I dislike the aave-capo name (the "stable" part is poorly named imo).

@acenolaza acenolaza force-pushed the 13-price-cap-stable-api3readerproxyv1 branch from 778c438 to 579ac4b Compare June 12, 2025 17:38
/// @param proxy_ IApi3ReaderProxy contract address
/// @param lowerBound_ The minimum price (inclusive) this proxy will report
/// @param upperBound_ The maximum price (inclusive) this proxy will report
constructor(address proxy_, int224 lowerBound_, int224 upperBound_) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ended up not checking the bounds against the current proxy value for 2 reasons:

  1. we are already trusting the deployer to provide a valid proxy value
  2. the proxy value might be outside of the lower/upper range and we still want to deploy to be able to apply the cap and return the either of bounds values.

revert LowerBoundMustBeNonNegative();
}
if (upperBound_ <= lowerBound_) {
revert UpperBoundMustBeGreaterThanLowerBound();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be UpperBoundMustBeGreaterOrEqualToLowerBound. But maybe just InvalidLowerBound and InvalidUpperBound so that it remains within 32 bytes.

Copy link
Collaborator Author

@acenolaza acenolaza Jun 12, 2025

Choose a reason for hiding this comment

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

Are you suggesting that both can be equal meaning that the contract will thenenforce fixed price comparison (constant price configuration)?

Copy link
Collaborator Author

@acenolaza acenolaza Jun 12, 2025

Choose a reason for hiding this comment

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

btw AFAIK there isn't a 32 bytes restriction on error names 🤔 (compiler internally uses the bytes4 selector)

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you suggesting that both can be equal meaning that the contract will thenenforce fixed price comparison (constant price configuration)?

Yeah, I think one might use this contract as a special case for a constant feed (although for that a more efficient version might make sense).

btw AFAIK there isn't a 32 bytes restriction on error names 🤔 (compiler internally uses the bytes4 selector)

I wasn't sure and remember this is the case with require errors. Feel free to leave as is.

@acenolaza acenolaza changed the title Adds PriceCapStableApi3ReaderProxyV1 Adds PriceCappedApi3ReaderProxyV1 Jun 12, 2025
@acenolaza acenolaza merged commit 3503ca8 into main Jun 13, 2025
2 checks passed
@acenolaza acenolaza deleted the 13-price-cap-stable-api3readerproxyv1 branch June 13, 2025 12:54
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.

2 participants