Staking.sol

The Staking smart contract is compiled with solidity v0.8.4 and uses the following libraries (and related dependencies):

  • Pausable.sol from OpenZeppelin

  • IERC20.sol from OpenZeppelin

  • SafeERC20.sol from OpenZeppelin

  • Context.sol from OpenZeppelin

  • UniswapV2Pair.sol from UniswapV2

  • PRBMathUD60x18.sol from PRBMath

The contract emits events for logging deposits and withdrawals.

computeCeShareFromLp

/**
 * @dev Public View function to get ce share of LP deposit for a user.
 * This intializes a UniswapV2Pair on the LP token address (which will be on univ2)
 * It computes the CE share for an LP amount using the total supply of the LP token and then Reserve amounts for both tokens in the pair
 * It ensures an accurate compute by checking reserve token addresses in the pair
 * @param _pid the pool index
 * @param _amount the amount of LP token being deposited
 * @return amount of ce that corresponds to the lp deposit amount
 */
function computeCeShareFromLp(uint256 _pid, uint256 _amount) public view validatePoolByPid(_pid) returns (uint256) {
    PoolInfo storage pool = poolInfo[_pid];
    uint256 totalLpSupply = pool.lpToken.totalSupply();
    IUniswapV2Pair pair = IUniswapV2Pair(address(pool.lpToken));
    (uint112 res0, uint112 res1, ) = pair.getReserves();
    IERC20 token0 = IERC20(pair.token0());
    IERC20 token1 = IERC20(pair.token1());
    uint256 ceShare;
    if (address(token0) == address(CeToken)) {
        ceShare = _amount.mul(res0).div(totalLpSupply);
    } else if (address(token1) == address(CeToken)) {
        ceShare = _amount.mul(res1).div(totalLpSupply);
    } else {
        ceShare = 0;
    }
    return ceShare;
}

computeReward

getApySecScaled

getApyMonScaled

addTimeLock

add

deposit

withdraw

withdrawCooldown

propCeShare

pendingRewards

deposited

depositedCe

depositedTime

depositWithdrawRequest

validatePoolByPid

safeCeTransfer

Last updated