Skip to content
Business logic Audit finding Intermediate

calcMint always return poolId=0 and idx=0

The calcMint function in Zap.sol always returns poolId=0 and idx=0, contrary to its documentation which says it should return the most optimal route. This leads to suboptimal zap operations.

gzeon Follow

Originally disclosed on Code4rena

Submitted by gzeon

Impact

calcMint in Zap.sol always return poolId=0 and idx=0, while the docstring specified it should return the most optimal route instead. This will lead to suboptimal zap.

Proof of Concept

-Zap.sol L156

GalloDaSballo (BadgerDAO) commented:

Given the context that the warden has, the finding is valid, we’re missing two functions for calcMint

As for us, we have shifted to only using pool 0 as such the code works fine for us

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

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 lacks the logic to evaluate different pools and indices, so it defaults to zero.

Impact

Users may receive suboptimal zap results, but the system still functions for pool 0.

What the attacker needed

None

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 smart contract function that is supposed to pick the best way to convert tokens always picks the first option instead. This means users might get a worse deal than possible, but the code still works.

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 gzeon

View all

46 more disclosed reports, best first.

More from BadgerDAO Zaps contest

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.