PancakeSwapSynthChef

PancakeSwapSynthChef

Git Source

Inherits: IProtocolSynthChef, Initializable, UUPSUpgradeable, AccessControlUpgradeable, OwnableUpgradeable, ReentrancyGuardUpgradeable

A contract for managing interactions with Pancake Finance for yield farming purposes.

This contract provides functionalities to interact with Pancake pools, deposit and withdraw LP tokens, harvest rewards, and more.

State Variables

chef

Interface of PancakeSwap MasterChef

IMasterChef public chef;

router

Interface of PancakeSwap Router

IRouter public router;

entMasterChef

Entangle MasterChef address

address public entMasterChef;

ADMIN

Role identifier for the admin.

bytes32 public constant ADMIN = keccak256("ADMIN");

MASTER

Role identifier for the master.

bytes32 public constant MASTER = keccak256("MASTER");

pools

Mapping from entangle internal pool Id to Pancake pool Id

mapping(uint32 poolId => uint256 protoPid) public pools;

isPoolInitialized

Mapping to track if a pool is initialized.

mapping(uint32 poolId => bool) public isPoolInitialized;

Functions

onlyCompounder

Modifier to restrict function access to the Compounder.

modifier onlyCompounder();

constructor

constructor();

initialize

Initializes the CurveConvexSynthChef contract with initial parameters.

This function is called during deployment to set up initial configuration.

function initialize(
    address pksMc,
    address pksRouter,
    address admin,
    address _entMasterChef,
    uint32[] calldata entanglePoolIds,
    uint256[] calldata pskPoolIds
) public initializer;

Parameters

_authorizeUpgrade

function _authorizeUpgrade(address) internal override onlyOwner;

addPool

Add a new pool. Can only be called by the ADMIN.

function addPool(uint32 poolId, bytes calldata poolInfo) external onlyRole(ADMIN);

Parameters

reinvest

Reinvests LP tokens into the farm.

This function can only be called by the Compounder and requires a valid pool ID.

function reinvest(uint32 poolId) external onlyCompounder nonReentrant returns (uint256);

Parameters

Returns

withdraw

Withdraws LP tokens from the farm and removes liquidity.

This function transfers the withdrawn tokens to the recipient address.

function withdraw(uint32 poolId, uint256 lpAmountToWithdraw, address recipient)
    external
    onlyRole(MASTER)
    nonReentrant
    returns (uint256[] memory amounts);

Parameters

depositLP

Deposits LP tokens into the farm.

This function can only be called by the MASTER and requires a valid pool ID.

function depositLP(uint32 poolId, uint256 lpAmount) external onlyRole(MASTER) nonReentrant;

Parameters

withdrawLP

Withdraws LP tokens from the farm and transfers them to the Entangle MasterChef.

This function can only be called by the MASTER and requires a valid pool ID.

function withdrawLP(uint32 poolId, uint256 lpAmount) external onlyRole(MASTER) nonReentrant;

Parameters

harvest

Accrues rewards and transfers them to the Compounder.

This function can only be called by the Compounder and requires a valid pool ID.

function harvest(uint32 poolId)
    external
    onlyCompounder
    nonReentrant
    returns (address[] memory rewardTokens, uint256[] memory amounts);

Parameters

Returns

getTotalLpBalance

Retrieves the total balance of LP tokens on the farm.

This function returns the LP token balance of this contract for a given pool ID.

function getTotalLpBalance(uint32 poolId) public view returns (uint256 amount);

Parameters

Returns

getPoolTokens

Retrieves the addresses of tokens in a pool.

This function returns an array of pool token addresses for a given pool ID.

function getPoolTokens(uint32 poolId) external view returns (address[] memory tokens);

Parameters

Returns

_optimalDeposit

Calculates the optimal amount of LP tokens to deposit into the farm.

This function computes the deposit amounts for each token in the pool based on the current balances.

function _optimalDeposit(address lpToken) internal returns (uint256);

Parameters

Returns

lpTokenAddress

Retrieves the LP token address for a given pool ID.

This function returns the address of the LP token for a specified pool ID.

function lpTokenAddress(uint32 poolId) external view returns (address lpToken);

Parameters

Returns

_ensureAllowance

Ensures that the contract has sufficient allowance to spend tokens.

This function ensures that the contract has the required allowance to spend tokens.

function _ensureAllowance(address token, address spender, uint256 amount) internal;

Parameters

getAvailableRewards

Retrieves the available rewards for a given pool ID.

This function returns the amount of rewards available for claiming for a specified pool ID.

function getAvailableRewards(uint32 poolId) external view returns (uint256 amount);

Parameters

Returns

Errors

PancakeSwapSynthChef__E1

PoolId already exists : PancakeSwapSynthChef

error PancakeSwapSynthChef__E1();

PancakeSwapSynthChef__E2

amount eq 0 : PancakeSwapSynthChef

error PancakeSwapSynthChef__E2();

PancakeSwapSynthChef__E3

Caller is not Entangle's Compounder

error PancakeSwapSynthChef__E3();

Last updated