LeverageManager removeLeverage does not support advanced self-lending pods with podded fTKN as pairedLpTKN
Source: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/487
Found by
Honour, pkqs90
Summary
LeverageManager removeLeverage does not support advanced self-lending pods with podded fTKN as pairedLpTKN.
Root Cause
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 where _hasSelfLendingPairPod is set to true.
/// @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, back to removeLeverage feature. If borrowedTKN is not enough to repay the flashloan, we need to swap pTKN to acquire borrowedTKN. we can see in _acquireBorrowTokenForRepayment() function, if _isPodSelfLending(_props.positionId) is true, it conducts a pTKN -> pairedLpTKN swap, but it assumes pairedLpTKN is always a fTKN, and does not handle where the pairedLpTKN is a podded fTKN.
function _acquireBorrowTokenForRepayment(
LeverageFlashProps memory _props,
address _pod,
address _borrowToken,
uint256 _borrowNeeded,
uint256 _podAmtReceived,
uint256 _podSwapAmtOutMin,
uint256 _userProvidedDebtAmtMax
) internal returns (uint256 _podAmtRemaining) {
_podAmtRemaining = _podAmtReceived;
uint256 _borrowAmtNeededToSwap = _borrowNeeded;
if (_userProvidedDebtAmtMax > 0) {
uint256 _borrowAmtFromUser =
_userProvidedDebtAmtMax >= _borrowNeeded ? _borrowNeeded : _userProvidedDebtAmtMax;
_borrowAmtNeededToSwap -= _borrowAmtFromUser;
IERC20(_borrowToken).safeTransferFrom(_props.sender, address(this), _borrowAmtFromUser);
}
// sell pod token into LP for enough borrow token to get enough to repay
// if self-lending swap for lending pair then redeem for borrow token
if (_borrowAmtNeededToSwap > 0) {
if (_isPodSelfLending(_props.positionId)) {
_podAmtRemaining = _swapPodForBorrowToken(
_pod,
positionProps[_props.positionId].lendingPair,
_podAmtReceived,
// @audit-bug: If lendingPair is a podded fTKN, it does not support convertToShares at all.
@> IFraxlendPair(positionProps[_props.positionId].lendingPair).convertToShares(_borrowAmtNeededToSwap),
_podSwapAmtOutMin
);
// @audit-bug: This does not support the "advanced" feature where `_hasSelfLendingPairPod` is true.
@> IFraxlendPair(positionProps[_props.positionId].lendingPair).redeem(
IERC20(positionProps[_props.positionId].lendingPair).balanceOf(address(this)),
address(this),
address(this)
);
} else {
_podAmtRemaining = _swapPodForBorrowToken(
_pod, _borrowToken, _podAmtReceived, _borrowAmtNeededToSwap, _podSwapAmtOutMin
);
}
}
}
Internal pre-conditions
_hasSelfLendingPairPodis set to true, and a podded fTKN is used for a self lending pod.
External pre-conditions
N/A
Attack Path
N/A
Impact
removeLeverage will fail to for the podded fTKN self-lending pod.
PoC
N/A
Mitigation
Support the 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 business logic bug in Peapods. Sherlock made it public on 12 March 2025. Found in the 749 audit contest (finding M-29), also found by 1 other warden.
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.