Re-bake Beans

Once your rewards start to accumulate, you will be able to use the Re-bake Beans function.

When that time comes, you will need to use the "Re-Bake" button to compound your rewards into the locked TVL. When this function is activated, your rewards counter will reset to zero and your "beans" balance will increase. The amount of TVL combined with the number of re-baked rewards will determine the bean increase.

Let's dissect the rebakeBeans function:

  1. Initialization Check:

    require(initialized);

    This ensures that the contract is initialized before proceeding.

  2. Rebake Cooldown Check:

    require(block.timestamp > (lastHatch[msg.sender] + 3600), "Please Wait");

    This enforces a cooldown period of one hour since the user's last hatch to prevent immediate rebaking.

  3. Self-Referral Check:

    if (ref == msg.sender) {
        ref = address(0);
    }

    If the user refers themselves, it sets the referral to address(0) to avoid self-referral.

  4. Set Referral:

    if (referrals[msg.sender] == address(0) && referrals[msg.sender] != msg.sender) {
        referrals[msg.sender] = ref;
    }

    If the user doesn't have a referral set, and the referral isn't themselves, it sets the referral.

  5. Calculate and Update New Miners:

    uint256 eggsUsed = getMyEggs(msg.sender);
    uint256 newMiners = eggsUsed / EGGS_TO_HATCH_1MINERS;
    hatcheryMiners[msg.sender] += newMiners;
    claimedEggs[msg.sender] = 0;
    lastHatch[msg.sender] = block.timestamp;

    This retrieves the user's claimed eggs, calculates how many miners these eggs can hatch, updates the user's miner count, resets claimed eggs to 0, and updates the last hatch timestamp to the current time.

  6. Update Referral's Last Hatch:

    if (lastHatch[referrals[msg.sender]] == 0) {
        lastHatch[referrals[msg.sender]] = block.timestamp;
    }

    If the referral hasn't hatched any eggs yet, it sets their last hatch timestamp to the current time.

  7. Update Referral's Miners:

    hatcheryMiners[referrals[msg.sender]] += ((eggsUsed / 100) / EGGS_TO_HATCH_1MINERS);
    claimedEggs[referrals[msg.sender]] = 0;

    This adds a small number of miners to the referral's account based on 1% of the eggs used by the user and resets the referral's claimed eggs to 0.

  8. Add Eggs to Market:

    marketEggs += (eggsUsed / 5);

    Finally, it adds 20% of the eggs used to the market eggs, which could be a pool for future calculations or distributions.


We have removed the referral system that Baked Beans OG used and replaced it with a fixed percent to avoid the front-running of the referral reward system. The referral reward will be given to the referrer every time the user they referred rebakes beans. **The referral reward won't be deducted from the eggs of the referral.

Last updated