spTKNMinimalOracle does not support advanced self-lending pods, where pairedLpTKN is a podded fraxlend token
Source: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/477
Found by
TessKimy, pkqs90
Summary
spTKNMinimalOracle does not support advanced self-lending pods, where pairedLpTKN is a podded fraxlend token.
Root Cause
spTKNMinimalOracle should work for self-lending pods. There are two kinds of self-lending pods. The first is the regular one, where the pairedLpTKN for a pod is a fraxlend paired fTKN. However, there is also an "advanced feature", so the pairedLpTKN is a podded fTKN (which makes it a pfTKN). This can be seen in LeverageManager.sol contract when initializing a leverage position.
/// @notice The ```initializePosition``` function initializes a new position and mints a new position NFT
/// @param _pod The pod to leverage against for the new position
/// @param _recipient User to receive the position NFT
/// @param _overrideLendingPair If it's a self-lending pod, an override lending pair the user will use
@> /// @param _hasSelfLendingPairPod bool Advanced implementation parameter that determines whether or not the self lending pod's paired LP asset (fTKN) is podded as well
function initializePosition(
address _pod,
address _recipient,
address _overrideLendingPair,
bool _hasSelfLendingPairPod
) external override returns (uint256 _positionId) {
_positionId = _initializePosition(_pod, _recipient, _overrideLendingPair, _hasSelfLendingPairPod);
}
Now, going back to the oracle. There are two flags in the oracle: BASE_IS_POD and BASE_IS_FRAX_PAIR.
BASE_IS_PODis used to support where pairedLpTKN is a normal pod token, e.g. pOHM.BASE_IS_FRAX_PAIRis used to support where pairedLpTKN is a normal fraxlend token, e.g. fUSDC.
However, there is no support for a podded fraxlend token.
function _calculateSpTknPerBase(uint256 _price18) internal view returns (uint256 _spTknBasePrice18) {
uint256 _priceBasePerPTkn18 = _calculateBasePerPTkn(_price18);
address _pair = _getPair();
(uint112 _reserve0, uint112 _reserve1) = V2_RESERVES.getReserves(_pair);
uint256 _k = uint256(_reserve0) * _reserve1;
uint256 _kDec = 10 ** IERC20Metadata(IUniswapV2Pair(_pair).token0()).decimals()
* 10 ** IERC20Metadata(IUniswapV2Pair(_pair).token1()).decimals();
uint256 _avgBaseAssetInLp18 = _sqrt((_priceBasePerPTkn18 * _k) / _kDec) * 10 ** (18 / 2);
uint256 _basePerSpTkn18 =
(2 * _avgBaseAssetInLp18 * 10 ** IERC20Metadata(_pair).decimals()) / IERC20(_pair).totalSupply();
require(_basePerSpTkn18 > 0, "V2R");
_spTknBasePrice18 = 10 ** (18 * 2) / _basePerSpTkn18;
// if the base asset is a pod, we will assume that the CL/chainlink pool(s) are
// pricing the underlying asset of the base asset pod, and therefore we will
// adjust the output price by CBR and unwrap fee for this pod for more accuracy and
// better handling accounting for liquidation path
if (BASE_IS_POD) {
@> _spTknBasePrice18 = _checkAndHandleBaseTokenPodConfig(_spTknBasePrice18);
} else if (BASE_IS_FRAX_PAIR) {
@> _spTknBasePrice18 = IFraxlendPair(BASE_TOKEN).convertToAssets(_spTknBasePrice18);
}
}
function _checkAndHandleBaseTokenPodConfig(uint256 _currentPrice18) internal view returns (uint256 _finalPrice18) {
_finalPrice18 = _accountForCBRInPrice(BASE_TOKEN, address(0), _currentPrice18);
_finalPrice18 = _accountForUnwrapFeeInPrice(BASE_TOKEN, _finalPrice18);
}
Internal pre-conditions
N/A
External pre-conditions
N/A
Attack Path
N/A
Impact
spTKNMinimalOracle does work for podded fraxlend tokens, which means this advanced feature cannot be used in LVF at all.
PoC
N/A
Mitigation
Support the podded fraxlend token feature.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity smart contracts bug in Peapods. Sherlock made it public on 12 March 2025. Found in the 749 audit contest (finding M-26), also found by 1 other warden.
About Smart contracts
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.