Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add farm #13

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open

Add farm #13

wants to merge 4 commits into from

Conversation

vito-kovalione
Copy link

@vito-kovalione vito-kovalione commented Jun 7, 2023

Add LP token farm

address _lpToken,
uint256 _allocPoint
) external override onlyOwner whenNotPaused {
poolInfos[_lpToken] = PoolInfo({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check if pool already exists. Otherwise we may override existing one with that action

}

function addPool(
address _lpToken,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also need to check for lpToken. minimum that it is contract. better - to verify token interface if thats possible


function addPool(
address _lpToken,
uint256 _allocPoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be zero? if no - need also to check it

}

function deposit(address _lpToken, uint256 _amount) external override whenNotPaused {
require(_lpToken != address(0), "Zero address");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for being contract is must, additionally if thats tech possible - check for interface



function updatePoolReward(address _lpToken) public override {
PoolInfo storage pool = poolInfos[_lpToken];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we won't have here revert for zero token for example. Thats why I recommend to move all code of this function to internal function _updatePoolReward. And add verifications to updatePoolReward. It will allow to keep code protected when _updatePoolReward is called externally in updatePoolReward and do not duplicate verifications when _updatePoolReward is called internally for example in deposit function

address _lpToken,
uint256 _amount
) external override whenNotPaused {
require(_lpToken != address(0), "Zero address");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same need more verification for input

Comment on lines +127 to +130
if (pending > 0) {
address(rewardToken).safeTransfer(msg.sender, pending);
emit LogRewardPaid(msg.sender, _lpToken, pending);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, lets think about making reward withdraw in separate function

function withdraw(
address _lpToken,
uint256 _amount
) external override whenNotPaused {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reentrancy protection

Comment on lines +25 to +28
address public rewardToken;

uint256 public rewardPerBlock;
uint256 public totalAllocPoint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make next improvement - have those details not at contract level, but for each particular pool

import "./IFarm.sol";
import "../core/interfaces/IERC20.sol";

contract Farm is IFarm, OwnableUpgradeable, PausableUpgradeable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can rename it to FarmFactory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants