hats-finance / Circles-0x6ca9ca24d78af44582951825bef9eadcb210e5cf

Circles Protocol contracts
https://aboutcircles.com
GNU Affero General Public License v3.0
0 stars 0 forks source link

Not minting the correct amount of token for 14 days. #98

Open hats-bug-reporter[bot] opened 1 month ago

hats-bug-reporter[bot] commented 1 month ago

Github username: -- Twitter username: -- Submission hash (on-chain): 0x4116fc4fe0ab203d6634ef80359db88e7fdab9123a57017d0e6a83572555d1ec Severity: medium

Description: Description\

As per circle document, user is allowed to mint their own token one per hour.

But, for 14 days (336 hours.) the contrac mint around 335.5 tokens.

Attachments

  1. Proof of Concept (PoC) File

    function testMintCheck() public {
        // Alice registers in v2
        ITokenV1 tokenAlice = signupInV1(addresses[0]);
        vm.prank(addresses[0]);
        tokenAlice.stop();
        vm.prank(addresses[0]);
        mockHub.registerHuman(address(0), bytes32(0));
    
        // Bob registers in v2
        ITokenV1 tokenBob = signupInV1(addresses[1]);
        vm.prank(addresses[1]);
        tokenBob.stop();
        vm.prank(addresses[1]);
        mockHub.registerHuman(address(0), bytes32(0));
    
        console.log("bob balance", mockHub.balanceOf(addresses[0],mockHub.toTokenId(addresses[0])));
        console.log("alice balance", mockHub.balanceOf(addresses[1],mockHub.toTokenId(addresses[1])));
    
        // move time
        skipTime(14 days); //336hours
        // Alice can mint in V2
        vm.prank(addresses[0]);
        mockHub.personalMint();
        // Bob can mint in V2
        vm.prank(addresses[1]);
        mockHub.personalMint();
    
        console.log("bob balance", mockHub.balanceOf(addresses[0],mockHub.toTokenId(addresses[0])));
        console.log("alice balance", mockHub.balanceOf(addresses[1],mockHub.toTokenId(addresses[1])));
        //intentionally reverted to log the balance value.
        assert(1 == 2);
    }
    Logs:
    bob balance 0
    alice balance 0
    bob balance 335499787406064420311
    alice balance 335499787406064420311
  2. Revised Code File (Optional)

benjaminbollen commented 1 month ago

Analysis misses to take into account demurrage as documented and coded

0xpinky commented 1 month ago

Analysis misses to take into account demurrage as documented and coded

I don't know which one is original issue.

@benjaminbollen the issue is on the first mint itself. why do the demurrage applied here ?

benjaminbollen commented 1 month ago

demurrage is applied daily, let's call the daily demurrage factor d

so if you mint 14 days:

these terms added up is your total mint of 335.something CRC < 336 CRC