Skip to content
Business logic Audit finding Intermediate

BunniPrice.getBunniTokenPrice doesn't include fees

The BunniPrice.getBunniTokenPrice function calculates the price of a Bunni token without including the fees earned by the position, so the price is lower than the real value. An attacker could potentially exploit this mispricing, but the text does not specify a concrete attack.

dany.armstrong90 Follow with rvierdiiev and tvdung94

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-11-olympus-judging/issues/37

Found by

dany.armstrong90, rvierdiiev, tvdung94

Summary

BunniPrice.getBunniTokenPrice doesn't include fees into calculation, which means that price will be smaller.

Vulnerability Detail

BunniPrice.getBunniTokenPrice function should return usd cost of bunniToken_. After initial checks this function actually do 2 things:

  • validate deviation
  • calculates total cost of token

Let's check how it's done to calculate total cost of token. It's done using _getTotalValue function.

So we get token reserves using _getBunniReserves function and the convert them to usd value and return the sum. _getBunniReserves in it's turn just fetches amount of token0 and token1 that can be received in case if you swap all bunni token liquidity right now in the pool.

The problem is that this function doesn't include fees that are earned by the position. As result total cost of bunni token is smaller than in reality. The difference depends on the amount of fees there were earned and not returned back.

Also when you do burn in the uniswap v3, then amount of token0/token1 is not send back to the caller, but they are added to the position and can be collected later. So in case if BunniPrice.getBunniTokenPrice will be called for the token, where some liquidity is burnt but not collected, then difference in real token price can be huge.

Impact

Price for the bunni token can be calculated in wrong way.

Code Snippet

Provided above

Tool used

Manual Review

Recommendation

Include collected amounts and additionally earned fees to the position reserves.

Discussion

sherlock-admin2

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

nirohgo commented:

duplicate of 137

0xJem

IMO this is medium or low severity - the fees will be compounded regularly, and so aren't going to increasing to a significant amount.

nevillehuang

Hi @0xJem, since this could occur naturally without any external factors, I think it could constitute high severity given important price values could be directly affected.

Does the following mean uncollected fees are going to be collected by olympus regularly?

the fees will be compounded regularly

0xJem

Hi @0xJem, since this could occur naturally without any external factors, I think it could constitute high severity given important price values could be directly affected.

Does the following mean uncollected fees are going to be collected by olympus regularly?

the fees will be compounded regularly

Yes we will have a keeper function calling the harvest() function on BunniManager. It can be called maximum once in 24 hours.

0xrusowsky

https://github.com/OlympusDAO/bophades/pull/244

IAm0x52

Escalate

This is simply another occurrence of #49 in a different location and should be grouped with it

sherlock-admin2

Escalate

This is simply another occurrence of #49 in a different location and should be grouped with it

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

nevillehuang

Agree with @IAm0x52 , root cause is the same although with different impact, can be duplicated.

Arabadzhiew

This issue and its duplicates refer to an issue in the BunniPrice contract, while issue #49 and its duplicates refer to an issue that is inside of the BunniSupply contract. The root causes are clearly not the same, so I believe those two issues should stay separated in 2 different families.

0xJem

IMO it is separate. 49 refers to the TWAP and reserves check, whereas this is valuing the LP position.

IAm0x52

Fix looks good. Fees are now also accounted for here as well.

Czar102

@IAm0x52 could you take another look and let me know if you agree with the above comments?

nevillehuang

@Czar102 I think there was a separate fix with the 246 pull request for issue #49, so could indicate that they are not duplicates

Czar102

Result: Medium Has duplicates

Escalation's author hasn't provided enough information to justify a change in status of the issue.

sherlock-admin2

Escalations have been resolved successfully!

Escalation status:

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

The price calculation function only sums the token reserves from the pool and ignores the fees that have been earned but not yet collected.

Impact

The price of the Bunni token could be calculated incorrectly, potentially leading to financial loss if used in other protocols.

What the attacker needed

None

The fix

The fix should include collected amounts and additionally earned fees in the position reserves.

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.

This report is about a smart contract function that calculates the price of a special token representing a share in a liquidity pool. The function forgets to add the trading fees that the pool has earned, so the price it returns is too low. That could cause problems if other contracts rely on this price.

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 dany.armstrong90

View all

4 more disclosed reports, best first.

More from Olympus RBS 2.0

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.