Skip to content

Conversation

rudewalt
Copy link
Collaborator

No description provided.

@rudewalt rudewalt requested a review from optifat August 27, 2025 12:45
/// @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 {
Copy link
Collaborator

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)) {
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

@optifat optifat Aug 29, 2025

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,
Copy link
Collaborator

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

@rudewalt rudewalt merged commit 85de4f3 into master Sep 8, 2025
@rudewalt rudewalt deleted the feature/pendle-all-in-one branch September 8, 2025 07:40
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