LpTokenStaker allows users to stake different LP tokens in order to receive EPS. It is based on the well known Sushi MasterChef contract, with some modifications to how per-pool incentives are calculated:

All pools added to the contract receive an equal APY. This is implemented on a technical level by modifying each pool's allocPoint any time there is a deposit or withdrawal, so the total alloc is equal to the total number of tokens deposited. For non-USD denominated LP tokens, a query to a Chainlink oracle provides a price per-token relative to USD which is then applied as a final modifier to the pool alloc.

The exception to this rule is the pool with pid 0 (the EPS/BNB pancake LP tokens). This pool always receives 20% of the total allocation regardless of it's size.

You can view the source code for LpTokenStaker on Github.

Querying Pool Info

poolInfo(uint256 pid) returns (address, uint256, uint256, uint256, uint256)

Data about each pool. Returns:

  • the address of the LP token staked within the pool.

  • The index of the oracle used for pricing the LP tokens (0 for USD assets). This corresponds to the oracles getter.

  • The number of allocation points the pool is assigned.

  • The last second that rewards were distributed for this pool.

  • The total accumulated rewards per share for the pool.

The allocation point numbers are less useful because the modified contract logic ensures all pools maintain a consistent APY. However, the data is left available in the getter to reduce the number of edits to the original contract.

rewardsPerSecond() returns (uint256)

The current number of reward tokens minted per second.

startTime() returns (uint256)

The second at which reward tokens are first minted.

emissionSchedule(uint256 i) returns (uint128, uint128)

Information about future reward rates given as (start offset in seconds, rewards per second). The emission schedule stored in reverse chronological order, whenever the number of seconds beyond startTime exceeds the next emission period offset, a new reward rate is applied.

oracles(uint256 i) returns (address)

A list of Chainlink oracle addresses, used to provide a base price for each LP token. The value at position 0 is always 0x00 and used to represent USD-denominated pools.

Querying User Info

claimableReward(uint256 pid, address user) returns (uint256)

Get the currently claimable reward amount for user from pool pid.

userInfo(uint256 pid, address user) returns (uint256, uint256)

Get the current deposit amount and reward debt for user in pool pid.

Depositing, Claiming Rewards and Withdrawing

deposit(uint256 pid, uint256 amount)

Deposit LP tokens into the contract. Making a deposit also triggers a claim for pending rewards.

  • pid: Pool ID to deposit to.

  • amount: Amount of tokens being deposited.

withdraw(uint256 pid, uint256 amount)

Withdraw LP tokens from the contract. Withdrawing also triggers a claim of any pending rewards.

  • pid: Pool ID to withdraw from.

  • amount: Amount of tokens being withdrawn.

emergencyWithdraw(uint256 pid)

Withdraw LP tokens without also claiming rewards. This should only be done in an emergency.

  • pid: Pool ID to withdraw from.

claim(uint256[] calldata pids)

Claim rewards for one or more pools. Note that rewards are not directly sent to the caller, they are instead vested within MultiFeeDistribution.

  • pids: An array of pool IDs to claim for.