How can I found the farming pool contract example?

I have deploy a ERC20 contract. and now, I want to build a liquidity farming pool.
what I am thinking is like this:
1.I build a smart contract for the farming pool.
2.user can stake the ERC20/BNB to the smart contract.
3.the smart contract connect to pancakeswap to put the staking into the liquidity pool of pancake.
4.the smart contract calculate the rewards of ERC20 to user.

If you can give me some example code. please help.

Use an interface to be able to transfer ERC20 tokens from user to your contract.
Use another interface for example pancakeswap so that you can create liquidity through your contract.
you can then say that the base is 365 tokens per year. divide that through 365 and you got 1 token per day in rewards. Now you can divide that by the total LP tokens your contract ownes, example:
(365 / 365) / 10 * 5 = 0.5
(reward per year) / (days per year) / (Total LP tokens in your contract) * (LP tokens from your user) = (daily rewards of user)