sherlock-audit / 2024-06-leveraged-vaults-judging

9 stars 8 forks source link

lemonmon - The `PendlePTOracle` contract may return a wrong price when calculating the price with `getPtToAssetRate()` #101

Closed sherlock-admin2 closed 2 months ago

sherlock-admin2 commented 2 months ago

lemonmon

Medium

The PendlePTOracle contract may return a wrong price when calculating the price with getPtToAssetRate()

Summary

PendlePTOracle may return a wrong price after expiry, which is hardcoded to 1, if the Pendle oracle function getPtToAssetRate() is used before expiry.

Vulnerability Detail

Note: The term "after expiry" refers to line 115 inside PendlePTOracle.sol where expiry is checked. If expiry <= block.timestamp, it is "after expiry", otherwise it is not expired.

On line 86 inside PendlePTOracle.sol the flag useSyOracleRate is checked, and if it's false the function getPtToAssetRate() is used which may not always guaranteed to be 1:1 price. However, after expiry the protocol always returns a hardcoded price of 1 which is correct for PT-SY pair, but may be wrong for PT-Asset prices which may not be a 1:1 price.

Example:

The example shows that it may be not safe to hardcode the price to 1 for the case where getPtToAssetRate() is used.

Reference:

https://docs.pendle.finance/Developers/Contracts/StandardizedYield

https://docs.pendle.finance/Developers/Oracles/HowToIntegratePtAndLpOracle

Impact

A wrong oracle price may be returned after expiry in the case where the price is determined by using getPtToAssetRate(). This may result in a loss for the protocol or for the users.

Code Snippet

https://github.com/sherlock-audit/2024-06-leveraged-vaults/blob/14d3eaf0445c251c52c86ce88a84a3f5b9dfad94/leveraged-vaults-private/contracts/oracles/PendlePTOracle.sol#L115

https://github.com/sherlock-audit/2024-06-leveraged-vaults/blob/14d3eaf0445c251c52c86ce88a84a3f5b9dfad94/leveraged-vaults-private/contracts/oracles/PendlePTOracle.sol#L85-L90

Tool used

Manual Review

Recommendation

Consider not using a hardcoded price of 1 for the case where the function getPtToAssetRate() is used.

Duplicate of #69