Submitted by Krace, also found by d3e4, immeas, 0xAadi, mojito_auditor, PENGUN, Yanchuan, D1r3Wolf, ether_sky, tnquanghuy0512, AS, leegh, lanrebayode77, bin2chen, 0xpiken, glcanvas, SpicyMeatball, and rvierdiiev
When users purchase new tokens, the old tokens they already own do not receive the fees from this purchase, resulting in a loss of funds for the users.
According to the explanation by the sponsor (Roman), when users buy new tokens, the recently purchased token is not eligible for a fee. However, the old shares that users already own should be eligible.
Roman:
Krace:
Roman:
However, the buy function will completely disregard the rewards associated with the buyers old shares for these fees.
Lets analyze the buy function:
The question arises: the fees from this purchase are not rewarded to the buyers old tokens between Step 2 and Step 3, yet the buyers rewardsLastClaimedValue is updated to the newest value. This results in the permanent loss of these rewards for the buyer.
The following POC shows the case mentioned. Add it to 1155tech-contracts/src/Market.t.sol and run it with forge test --match-test testBuyNoReward -vv.
The result is shown below; Alice gets no rewards for token1:
After my suggested patch, Alice can get the rewards for token1: 2200000000000000 - 2134000000000000 = 66000000000000.
Foundry
Split the fees before getting the rewards in buy:
Context
OpenCoreCH (Canto) confirmed, but disagreed with severity and commented:
0xTheC0der (judge) decreased severity to Medium
OpenCoreCH (Canto) commented:
Note: For full discussion, see here.
For this audit, 44 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by chaduke received the top score from the judge.
The following wardens also submitted reports: pontifex, MrPotatoMagic, adriro, Bauchibred, kaveyjoe, lsaudit, d3e4, OMEN, hunter_w3b, erebus, peanuts, cheatc0d3, ksk2345, pep7siup, ZanyBonzy, jasonxiale, tourist, osmanozdemir1, young, aslanbek, Pheonix, btk, bareli, Topmark, bart1e, sl1, T1MOH, SandNallani, zhaojie, MohammedRizwan, wisdomn_, 0xpiken, Matin, max10afternoon, ayden, bin2chen, shenwilly, codynhat, critical-or-high, sbaudh6, nailkhalimov, merlinboii, and firmanregar.
