Submitted by nonseodion, also found by 0xStalin
When a PowerFarm position is created its keyId is used as a key in the isAave mapping to indicate if it is an Aave position or not. The keyId is the index of the Power Farm NFT linked with the position.
PendlePowerManager.sol#L129-L130
The keyId is also linked with another nftId. This other nftId is used to hold the keyIds Power Farm position in the WiseLending contract. They are linked together in the farmingKeys mapping of the MinterReserver contract.
MinterReserver.sol#L88C1-L91C46
The issue is the check if a position is an Aave position is done using the WiseLending nftId instead of the Power Farms keyId. This occurs five times in the code:
It is used in getLiveDebtRatio() to know the pool token borrowed so the borrowShares can be retrieved.
PendlePowerFarm.sol#L64-L70
It is used in _manuallyPaybackShares() to know the pool token to pay back.
PendlePowerFarm.sol#L127-L129
It is used in checkDebtRatio() to know the pool token borrowed so the borrowShares can be retrieved.
PendlePowerFarmMathLogic.sol#L396-L402
It is used in _coreLiquidation() to select a token to payback and to know the pool token borrowed so the borrowShares can be retrieved.
PendlePowerFarmLeverageLogic.sol#L575-L590
These have the following effects:
PendlePowerFarmLeverageLogic.sol#L571C1-L574C1
There are 3 tests below and they can all be run in PendlePowerFarmControllerBase.t.sol.
Consider checking if a position is an Aave position using the keyId of the position.
PendlePowerFarm.sol#L64-L70
PendlePowerFarm.sol#L127-L129
PendlePowerFarmMathLogic.sol#L396-L402
PendlePowerFarmLeverageLogic.sol#L575-L590
vm06007 (Wise Lending) commented:
Wise Lending commented:
