Yield farming with MasterChef

I don’t understand the logic here from goose finance code. The following code says egg minted to devAddress is 10% of the block reward but their docs say 9.04% of the emission is given to the devAddress. Not only this but other projects who have forked this code also have it in their docs as 9.04% given to devAddress. ( eg: slime finance, llama finance, panther swap). Am I wrong somewhere ? Or is it a market strategy to show less.

        // Update reward variables of the given pool to be up-to-date.
        function updatePool(uint256 _pid) public {
            PoolInfo storage pool = poolInfo[_pid];
            if (block.number <= pool.lastRewardBlock) {
                return;
            }
            uint256 lpSupply = pool.lpToken.balanceOf(address(this));
            if (lpSupply == 0 || pool.allocPoint == 0) {
                pool.lastRewardBlock = block.number;
                return;
            }
            uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
            uint256 eggReward = multiplier.mul(eggPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
            egg.mint(devaddr, eggReward.div(10));
            egg.mint(address(this), eggReward);
            pool.accEggPerShare = pool.accEggPerShare.add(eggReward.mul(1e12).div(lpSupply));
            pool.lastRewardBlock = block.number;
        }

egg.mint(devaddr, eggReward.div(10));

In the logic it mints 10% of the eggReward to the dev address.

You would need to show me the mint() function because without it how could we know for sure what happens there? There might be extra code which reduces the amount minted, resulting in 9.04%.

If we assume it is the standard mint() function then it would be 10%

I don’t see anything in the mint function too, I have cross checked that. The point is why would all the projects mention the same thing in their docs as 9.04% if the code says 10%. It’s not like they even copied each others docs. May be it would be better if you can check the full code too.
For your reference.

// EggToken with Governance.

contract EggToken is BEP20('Goose Golden Egg', 'EGG') {

    /// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).

    function mint(address _to, uint256 _amount) public onlyOwner {

        _mint(_to, _amount);

        _moveDelegates(address(0), _delegates[_to], _amount);

    }

function mint(uint256 amount) public onlyOwner returns (bool) {

        _mint(_msgSender(), amount);

        return true;

    }

function _mint(address account, uint256 amount) internal {

        require(account != address(0), 'BEP20: mint to the zero address');

        _totalSupply = _totalSupply.add(amount);

        _balances[account] = _balances[account].add(amount);

        emit Transfer(address(0), account, amount);

    }

For the full code, [https://github.com/goosedefi/goose-contracts/blob/master/contracts/MasterChefV2.sol](https://Goose finance)

You would have to ask the specific project on why they do things. I would be of the belief that it is still 10%. It might be because the math in solidity is done without fractions, so depending on what the eggReward is, it could improperly divide somehow. But the code still shows .div(10) so I believe it would be proper to say 10%.

Thanks @Tsushima_Yoshiko very much. I had one more request if you could look in to the whole contract once. Maybe I’m missing somewhere the token allocation ( like 10% of 90.4 which is maybe coming from different function. ) These yield farming projects have million TVL already and I’m pretty sure they wont do wrong marketing not all of them atleast.

Full code: [https://github.com/goosedefi/goose-contracts/blob/master/contracts/MasterChefV2.sol](https://Goose finance)

What are you asking me to do exactly?

If you want to do an audit for a contract I would compare their MasterChefV2 to the original and see what has changed.

If something looks suspicious just figure out what their code is doing exactly.

I understood the logic for 9.09% . It’s very simple maths.

eggReward = multiplier.mul(eggPerBlock).mul(pool.allocPoint).div(totalAllocPoint);  // Assume 100
egg.mint(devaddr, eggReward.div(10)); // 10 eggs go to dev
egg.mint(address(this), eggReward);  //  100 eggs go to contract

So total eggs that were minted in the block were 110 eggs. And 10 go to dev address
Hence, 10/110 = 9.09 %.

PS: I wrongly mentioned it as 9.04 but it’s 9.09 instead.
Thanks.

1 Like

I see that makes sense!

Good job on finding out. Thank you.