Caviar Private Pools - savi0ur'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: 61/120

Findings: 2

Award: $40.33

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

9.3258 USDC - $9.33

Labels

bug
2 (Med Risk)
downgraded by judge
satisfactory
duplicate-669

External Links

Lines of code

https://github.com/code-423n4/2023-04-caviar/blob/main/src/PrivatePool.sol#L235-L236 https://github.com/code-423n4/2023-04-caviar/blob/main/src/PrivatePool.sol#L271-L285 https://github.com/code-423n4/2023-04-caviar/blob/main/src/PrivatePool.sol#L335

Vulnerability details

Impact

Loss of royalty share for the nft creator with more weightage

Proof of Concept

https://github.com/code-423n4/2023-04-caviar/blob/main/src/PrivatePool.sol#L235-L236

// calculate the sale price (assume it's the same for each NFT even if weights differ)
uint256 salePrice = (netInputAmount - feeAmount - protocolFeeAmount) / tokenIds.length;

https://github.com/code-423n4/2023-04-caviar/blob/main/src/PrivatePool.sol#L271-L285

if (payRoyalties) {
    for (uint256 i = 0; i < tokenIds.length; i++) {
        // get the royalty fee for the NFT
        (uint256 royaltyFee, address recipient) = _getRoyalty(tokenIds[i], salePrice);

        // transfer the royalty fee to the recipient if it's greater than 0
        if (royaltyFee > 0 && recipient != address(0)) {
            if (baseToken != address(0)) {
                ERC20(baseToken).safeTransfer(recipient, royaltyFee);
            } else {
                recipient.safeTransferETH(royaltyFee);
            }
        }
    }
}

If nft is having more weight, then its creator should get more royalty fee. Due to assuming average saleprice for all the nfts, there is a loss for the royalty recipient. As his share of royalty is calculated based on average salePrice.

Tools Used

Manual Review

Consider having some fare mechanism of distributing royalties based on NFT weights.

#0 - c4-pre-sort

2023-04-20T17:31:41Z

0xSorryNotSorry marked the issue as duplicate of #669

#1 - c4-judge

2023-04-30T15:34:21Z

GalloDaSballo changed the severity to 2 (Med Risk)

#2 - c4-judge

2023-05-01T07:27:13Z

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