Skip to content
Business logic Audit finding Intermediate

`getPrice` in `WeightedBPTOracle.sol` uses `totalSupply` for price calculations which can lead to wrong results

Vagner Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-07-blueberry-judging/issues/18

Found by

Vagner getPrice is used to calculate the price in USD of a given balancer LP, and it respects the recommendations of Balancer docs by calculating the invariant and using it to protect from manipulations, but it uses totalSupply for every LP calculated which can lead to wrong results and assumptions.

Vulnerability Detail

In the Balancer docs it is specified that There are three potential functions to query when determining the BPT supply depending on pool type. https://docs.balancer.fi/concepts/advanced/valuing-bpt/valuing-bpt.html#getting-bpt-supply

  • getActualSupply : which is used by the most recent Weighted and Stable Pools and it accounts for pre-minted BPT as well as due protocol fees:
  • getVirtualSupply : which is used by Linear Pools and "legacy" Stable Phantom Pools and it accounts just for pre-minted BPT
  • totalSupply : which makes sense to be called only by older legacy pools since those doesn't have pre-minted BPT

The getPrice uses every time totalSupply https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/oracle/WeightedBPTOracle.sol#L71-L73 which in the case of most recent pools can lead to very wrong calculations because of all the pre-minted BPT.

Impact

Impact is a medium one, since it can lead to wrong price assumptions

Code Snippet

https://github.com/sherlock-audit/2023-07-blueberry/blob/main/blueberry-core/contracts/oracle/WeightedBPTOracle.sol#L71-L73

Tool used

Manual Review

Recommendation

Consider implementing the more recent getActualSupply even if older pools doesn't have this functions , because it can lead to wrong assumptions and calculations.

Discussion

sherlock-admin2

1 comment(s) were left on this issue during the judging contest.

YakuzaKiawe commented:

invalid as this could be a factor to exploit the pool in future

The original report as published on Sherlock, by Vagner. 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.

What is known

A medium-severity business logic bug in Blueberry Update #3. Sherlock made it public on 26 August 2023. Found in the 104 audit contest (finding M-2).

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.

More by Vagner

View all

7 more disclosed reports, best first.

More from Blueberry Update #3

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.