How to call Add Function Method in Masterchef Contract

Hello,

i deploy masterchef contract now i am unable to call pool/farm
How to call the function add in the masterchief to add LP token.

2 Likes

Hi, welcome!

Do you mean the pancake or other contracts? Could you please paste the original contract code?

I think there is some limitation to call this function, have got to look at the code.

2 Likes

Do you mean the function add in the masterchef? Just like it defined as following:

function add() public onlyOwner {}

So the caller should be the owner account, that is 0x41ab046424a3a4304ff105f713806995b1e22d72 in this contract.

1 Like

Could you please show me the failed transaction hash?

It depends on your own strategy.

1 Like

Contract approved successful but after refresh its say ApproveContract again
webURL

LPTOKEN

1 Like

Emmm, the second transaction is the failed one, but it seems like you are trying to call withdraw rather than add, so which function do you want to execute?

1 Like

how to set accEggPerShare uint256>>>???
there is no Tab

1 Like

There is not a function to change it directly, you can look at the function add():

function add(uint256 _allocPoint, IBEP20 _lpToken, uint16 _depositFeeBP, bool _withUpdate) public onlyOwner {
        require(_depositFeeBP <= 10000, "add: invalid deposit fee basis points");
        if (_withUpdate) {
            massUpdatePools();
        }
        uint256 lastRewardBlock = block.number > startBlock ? block.number : startBlock;
        totalAllocPoint = totalAllocPoint.add(_allocPoint);
        poolInfo.push(PoolInfo({
            lpToken: _lpToken,
            allocPoint: _allocPoint,
            lastRewardBlock: lastRewardBlock,
            accEggPerShare: 0,           <<<<<<<<<<<----------- Its initial value is 0
            depositFeeBP: _depositFeeBP
        }));
    }

And it is changed in the function updatePool:

// 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 bisReward = multiplier.mul(bisPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
        bis.mint(devaddr, bisReward.div(10));
        bis.mint(address(this), bisReward);
        pool.accEggPerShare = pool.accEggPerShare.add(bisReward.mul(1e12).div(lpSupply));   <<<<<-----  here!!!
        pool.lastRewardBlock = block.number;
    }
1 Like

Sorry, I am nor familiar with the BSC-Chain, and I do not have BNB.

1 Like

is there any Programmer who willing to help will pay for there work.
there is small part need to fix

1 Like

You can paste at here: Latest developer-wanted topics - OpenZeppelin Community

1 Like

Contact me on tg:
hahahaokfine

1 Like