-
Notifications
You must be signed in to change notification settings - Fork 0
add single pendle oracle #2
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
Conversation
/// @custom:security-contact security@euler.xyz | ||
/// @author Euler Labs (https://www.eulerlabs.com/) | ||
/// @notice Adapter for Pendle PT and LP Oracle. | ||
contract PendleAllInOneOracle is BaseAdapter, Ownable2Step { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This naming seems clumsy to me, I'd suggest PendleUnifiedOracle
or something
/// @return The converted amount using the Pendle oracle. | ||
function _getQuote(uint256 inAmount, address _base, address _quote) internal view override returns (uint256) { | ||
PairParams memory pairParams = _configuredPairs[_base][_quote]; | ||
if (pairParams.base == address(0) || pairParams.quote == address(0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove one of those: if pairParams.base != address(0)
then it's guarantied pairParams.quote != address(0)
pairParams.scale = ScaleUtils.calcScale(0, 0, FEED_DECIMALS); | ||
|
||
_configuredPairs[_base][_quote] = pairParams; | ||
_configuredPairs[_quote][_base] = pairParams; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Params resettings must be forbidden
/// @notice The address of the base asset, the PT address. | ||
address base; | ||
/// @notice The address of the quote asset, the SY or underlying address. | ||
address quote; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A gas optimization is possible here by saving some storage: the addresses are already required for fetching this struct from storage, you only need to figure out, which of those is base and quote respectively. So you can store something like
bool baseLessThanQuote = base < quote;
and then use it as
(address base, address quote) =
params.baseLessThanQuote == (_base < _quote) ? (_base, _quote) : (_quote, _base);
bool inverse = ScaleUtils.getDirectionOrRevert(_base, base, _quote, quote);
address pendleMarket, | ||
uint32 twapWindow, | ||
address base, | ||
address quote, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you decide to implement my last suggestion, I'd actually not changed this output format, since it's more convenient from human perspective
No description provided.