Skip to content
Business logic Audit finding Intermediate

RubiconMarket: buy() may not take any fee for tokens with low decimal precision

PierrickGT Follow with Evo, caventa and 2 others

Originally disclosed on Code4rena

Submitted by PierrickGT, also found by Evo, caventa, 0xNineDec and carlitox477.

In the buy function of the RubiconMarket contract, a fee is subtracted on taker trades. The default feeBPS is set to 1 which is equivalent to a fee of 0.01% or 0.0001 in decimal form.

For tokens like gUSD with a low decimal precision of 2, no fees will be taken on 3 figure trades since Solidity will round down the result to 0.

Proof of Concept

The taker fee is calculated in the buy function of the RubiconMarket contract on L338 and also in the calcAmountAfterFee function on L583.

The following reasoning also apply to the maker fee on L346 and L586.

Let’s take, for example, a 500 gUSD trade. Mathematically the fee would be: 500 * 0.0001 = 0.05.

In solidity, for a token with 2 decimal places, we would get: amount * feeBPS / 100_000 = 50000 * 1 / 100_000 = 0 cause it rounds down to 0.

It would allow a user to not pay any taker and/or maker fee on 3 figure trades.

Tools Used

Foundry unit test available here

Recommended Mitigation Steps

You could either not support these type of tokens or add the following requires:

  • Add require(fee != 0) to the buy function after calculating the fee on L338 of the RubiconMarket contract.
  • Add the same kind of require for the makerFee after L346.
  • And also add the same kind of require in the calcAmountAfterFee function after L583.

daoio (Rubicon) acknowledged and commented:

Wow, 2 decimals is something extraordinary lol, but we won’t support gUSD.

HickupHH3 (judge) commented:

FYI, EURS is another stablecoin that has 2 decimals (ETH mainnet + Polygon).

I suppose in general low decimal tokens aren’t really supported.


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

What is known

A medium-severity business logic bug in Rubicon v2. Code4rena made it public on 17 February 2025. Found in the 2023-04-rubicon audit contest (finding M-25), also found by 4 other wardens.

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 from Rubicon v2

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.