Caviar Private Pools - joestakey's results

A fully on-chain NFT AMM that allows you to trade every NFT in a collection.

General Information

Platform: Code4rena

Start Date: 07/04/2023

Pot Size: $47,000 USDC

Total HM: 20

Participants: 120

Period: 6 days

Judge: GalloDaSballo

Total Solo HM: 4

Id: 230

League: ETH

Caviar

Findings Distribution

Researcher Performance

Rank: 113/120

Findings: 1

Award: $5.98

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

5.9827 USDC - $5.98

Labels

bug
2 (Med Risk)
satisfactory
duplicate-858

External Links

Lines of code

https://github.com/code-423n4/2023-04-caviar/blob/cd8a92667bcb6657f70657183769c244d04c015c/src/PrivatePool.sol#L733

Vulnerability details

PrivatePool.change does a call to changeFeeQuote() to calculate the fee amount.

It computes an exponent as ERC20(baseToken).decimals() - 4

File: src/PrivatePool.sol
731: function changeFeeQuote(uint256 inputAmount) public view returns (uint256 feeAmount, uint256 protocolFeeAmount) {
732:         // multiply the changeFee to get the fee per NFT (4 decimals of accuracy)
733:         uint256 exponent = baseToken == address(0) ? 18 - 4 : ERC20(baseToken).decimals() - 4;

This will revert for tokens with decimals less than 4. EURS is an example of such token, as it has 2 decimals.

Impact

The change function is not available for pools with a baseToken with less than 4 decimals. This means reduced functionality available for such pools.

Tools Used

Manual Analysis

Mitigation

Either change the changeFeeQuote() functionality to work with tokens with less than 4 decimals, or ensure there is a check in Factory to prevent the creation of pools with a _baseToken with less than 4 decimals

#0 - c4-pre-sort

2023-04-20T15:23:03Z

0xSorryNotSorry marked the issue as duplicate of #858

#1 - c4-judge

2023-05-01T07:14:08Z

GalloDaSballo marked the issue as satisfactory

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter