StargateSynthChef

(coming soon..)

Git Source

Inherits: IProtocolSynthChef, Initializable, UUPSUpgradeable, AccessControlUpgradeable, OwnableUpgradeable

A contract for managing interactions with Stargate 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

stargateRouter

Interface of Stargate Router

IStargateRouter public stargateRouter;

lpStaking

Interface of LpStaking contract of Stargate ecosystem.

ILpStaking public lpStaking;

masterChefEnt

Entangle MasterChef address

address public masterChefEnt;

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 Stargate pool details.

mapping(uint32 poolId => Pool) public pools;

isPoolInitialized

Mapping to track if a pool is initialized.

mapping(uint32 poolId => bool) public isPoolInitialized;

Functions

isPoolExist

Modifier to ensure that the LP token exists.

modifier isPoolExist(address lpToken);

onlyCompounder

Modifier to restrict function access to the Compounder.

modifier onlyCompounder();

initialize

0 - Stargate Router, 1 - ADMIN, 2 - MASTER, 3 - Entangle Master Chef

function initialize(address[5] calldata initAddr) public initializer;

_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

Provide liquidity to pool and stake LP tokens. Can only be called by the Compounder.

function reinvest(uint32 poolId)
    external
    onlyCompounder
    isPoolExist(address(pools[poolId].LPToken))
    returns (uint256);

Parameters

withdraw

Withdraw LP tokens from farm and remove liquidity. Transfer all to entangle MasterChef. Can only be called by the MASTER.

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

Parameters

depositLP

Deposit LP tokens to farm. Can only be called by the MASTER.

function depositLP(uint32 poolId, uint256 lpAmount)
    external
    onlyRole(MASTER)
    isPoolExist(address(pools[poolId].LPToken));

Parameters

withdrawLP

Withdraw LP tokens from farm and transfer it to entangle MasterChef. Can only be called by the MASTER.

function withdrawLP(uint32 poolId, uint256 lpAmount)
    external
    onlyRole(MASTER)
    isPoolExist(address(pools[poolId].LPToken));

Parameters

harvest

Accrue rewards and transfer it to Compounder. Can only be called by the Compounder.

function harvest(uint32 poolId)
    external
    onlyCompounder
    isPoolExist(address(pools[poolId].LPToken))
    returns (address[] memory rewardTokens, uint256[] memory amounts);

Parameters

getTotalLpBalance

View function to get balance of LP tokens.

function getTotalLpBalance(uint32 poolId)
    public
    view
    isPoolExist(address(pools[poolId].LPToken))
    returns (uint256 amount);

Parameters

Returns

getPoolTokens

View function to get pool tokens addresses.

function getPoolTokens(uint32 poolId)
    external
    view
    isPoolExist(address(pools[poolId].LPToken))
    returns (address[] memory tokens);

Parameters

Returns

lpTokenAddress

View function to get address of lp tokens of specific pool.

function lpTokenAddress(uint32 poolId)
    external
    view
    isPoolExist(address(pools[poolId].LPToken))
    returns (address lpToken);

Parameters

Errors

StargateSynthChef__E1

error StargateSynthChef__E1();

StargateSynthChef__E2

error StargateSynthChef__E2();

StargateSynthChef__E3

error StargateSynthChef__E3();

StargateSynthChef__NotACompounder

error StargateSynthChef__NotACompounder();

Structs

Pool

Struct representing Stargate pool details.

struct Pool {
    IERC20Upgradeable LPToken;
    IERC20Upgradeable token;
    uint256 stargateLPStakingPoolID;
    uint256 stargateRouterPoolID;
}

Last updated