Skip to content
Business logic Audit finding Advanced

`spTKNMinimalOracle.sol` counts debond fee twice, which will make the end price (spTKN per base) higher than it should be

The spTKNMinimalOracle contract double-counts the debond fee when calculating the price of spTKN per base token, making the price higher than it should be. This inflated price could be used in Fraxlend to determine solvency and collateral amounts, potentially allowing a liquidator to receive more collateral than deserved.

0xSpearmint1 Follow with Honour, Silvermist and 7 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/386

Found by

0xSpearmint1, Honour, Silvermist, TessKimy, X77, ZoA, bretzel, exploitabilityexplorer, pkqs90, wickie

Summary

The spTKNMinimalOracle::_calculateBasePerPTkn will count unwrap fee twice, which will make the base per PTkn price lower than what it should be. Eventually the base per PTkn price will be reversed and calculated into spTKN per base price, which will be higher than what it should be. This inflated price of spTKN can be used to calculate the aspTkn price and in the fraxlend to determine solvency and also in the liquidation process. As the result the liquidator might get more than what they should get.

Root Cause

spTKNMinimalOracle::_calculateBasePerPTkn calculates the PTkn price based on the Tkn price. When it converts from Tkn price to pTkn price, it accounts for CBR and then account for unwrap fee:

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/oracle/spTKNMinimalOracle.sol#L169-L186

However, the _accountForCBRInPrice uses WeightedIndex::convertToAssets: https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/oracle/spTKNMinimalOracle.sol#L243

The WeightedIndex::convertToAssets already subtracts the debond fee from the assets returned: https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/WeightedIndex.sol#L120-L130

This PTkn price from convertToAssets will be accounted for the unwrap fee using _accountForUnwrapFeeInPrice which will subtract the debond fee once more: https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/oracle/spTKNMinimalOracle.sol#L246-L253

Also, if the base is pod, it uses _checkAndHandleBaseTokenPodConfig, which will as well use these two functions _accountForCBRInPrice and _accountForUnwrapFeeInPrice. Therefore it will as well count the debond fee twice.

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/oracle/spTKNMinimalOracle.sol#L164 https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/contracts/contracts/oracle/spTKNMinimalOracle.sol#L213-L216

Internal Pre-conditions

Either (does not need to be both)

  • DEBOND_FEE of the WeightedIndex is set to non-zero
  • or the BASE_IS_POD and the base has debond fee

External Pre-conditions

  • The aspTKNMinimalOracle.sol which inherits from spTKNMinimalOracle.sol, is used in the Fraxlend pair to determine the price of aspTKN per borrowTkn.

Attack Path

  1. liquidator liquidates

Impact

The price of spTKN per base will calculated higher than it should be. If this incorrect price is used in Fraxlend pair, this incorrect price may be used to determine solvency and the amount of collateral for liquidator:

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/fraxlend/src/contracts/FraxlendPairCore.sol#L232

https://github.com/sherlock-audit/2025-01-peapods-finance/blob/main/fraxlend/src/contracts/FraxlendPairCore.sol#L1135-L1136

For the solvency, it is result in effectively higher maxLTV, so it is less problematic. But for the calculation of collateral amounts for liquidator, the liquidator may get more collateral than they should get.

PoC

No response

Mitigation

Consider dropping the _accountForUnwrapFeeInPrice

The original report as published on Sherlock, by 0xSpearmint1. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, the function `_accountForCBRInPrice` already subtracts the debond fee via `WeightedIndex::convertToAssets`, and then `_accountForUnwrapFeeInPrice` subtracts it again.

Impact

The inflated price could cause a liquidator to receive more collateral than they should when the price is used in Fraxlend.

What the attacker needed

DEBOND_FEE is non-zero or BASE_IS_POD with debond fee; aspTKNMinimalOracle used in Fraxlend pair

The fix

The `_accountForUnwrapFeeInPrice` should be removed to avoid double-counting the debond fee.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A price oracle is a smart contract that tells other contracts the price of an asset. Here, the oracle mistakenly subtracted a fee twice when converting between token prices, so the reported price was too high. If a lending platform uses this wrong price, it might give a liquidator too much collateral.

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.

More by 0xSpearmint1

View all

3 more disclosed reports, best first.

More from Peapods

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.