FarmingInstance
Last updated
Last updated
Implementation of the logic of the UniV2 liquidity farming contract (version for ShibaSwap)
UniV2 farming implementation contract for Shibaswap with a main reward pool and several bonus (up to 9) pools. Main pool reward is esKNINE token which is minted by the farming contract.
uint8 public constant MAX_POOL_LENGTH = 10;
- maximum number of reward pools.
uint256 public constant MULTIPLIER = 10**20;
- calculations multiplier.
address public pool;
- liquidity pool address (ShibaSwap LP Token) for which the farming was created.
address public router;
- UniswapV2Router02 (ShibaSwap) contract address.
address public factory;
- FarmingFactory contract address.
LiquidityPool public liquidityPool;
- an object of LiquidityPool type.
Intermediate public intermediate;
- object of the Intermediate type (see below).
RewardPool[] public rewardPools;
- an array of reward pools like RewardPool.
struct Deposit {
- struct to describe the deposit.
uint256 liquidity;
- number of user LP tokens.
uint256[] accumulators;
- an array of batteries for each rewardPool.
uint256[] debts;
- an array of calculated 'not claimed' rewards (updated upon actions with a deposit) for each rewardPool.
}
struct Intermediate {
- struct for storing intermediary calculations.
uint256 totalLiquidity;
- the total amount of liquidity stored in farming pool at the moment.
uint256[] lastUpdate;
- an array of the latest updates timestamps for each rewardPool (will not be visible through mapping, check through the getUserDeposits method).
uint256[] accumulators;
- an array of accumulators for each rewardPool (will not be visible through mapping, check through the getUserDeposits method).
}
event Deposited(address user,
- user address.
uint256 liquidity
- number of LP tokens.
);
- Upon zap
or deposit
call.
event Withdrawed(address user,
- user address.
uint256 liquidity
- number of LP tokens.
);
- Upon withdraw
or unzap
call.
event ClaimedReward(
address user,
- user address.
uint256 halfId,
- reward pool id.
bool fromZap,
- true
- reward withdrawn for deposit made via zap; otherwise - false
address rewardToken,
- reward token.
uint256 amount
- number of cliamied rewards.
);
- upon reward withdrawal (claimRewards, claimRewardsAll, withdraw, unzap).
event Zap(address inputToken,
- token submitted for input.
uint256 amount,
- the number of tokens (except for phi) submitted to the input.
uint256 fee
- how many tokens went to the factory as a fee.
);
- upon zap
call.
event Unzap(address outputToken,
- output token.
uint256 amount,
- number of tokens at the output (excluding fee).
uint256 fee
- how many tokens were received by the factory as a fee.
);
- upon unzap
call.
event BonusPoolAdded(
uint256 halfId,
- index in the rewardPools array assigned to the created pool.
address rewardToken,
- reward token of the created pool.
uint64starts,
- start time.
uint64ends,
- end time.
uint256 rps
- reward per second.
);
- upon addBonusPool
call.
event BonusPoolStopped(uint256 halfId);
- upon stopBonusPool
or when the pool stopped itself by the endTime.
event MainRewardPoolStopped();
- upon stopMainPool
or when the pool stopped itself by the endTime.
event RewardPerSecondChanged(uint256 rps);
- upon changeRPS
, returns a new RPS value for the main pool.
Add a bonus pool (call from farmingFactory.addBonusPool).
Stop the bonus pool (call from farmingFactory.stopBonusPool).
Stop the main pool and all bonus ones (call with farmingFactory.stopFarming).
Change the RPS value in the main reward pool (call from farmingFactory.changeFarmingRPS
).
Initializer function, not called after initialization.
Depositing LP tokens.
Withdraw all LP tokens from user's deposits made via deposit
method.
Withdraw all rewards both from a deposit via zap
and from a regular deposit
at the same time (withdraws rewards from all pools).
Withdraw reward from the specified reward pool for the specified type of the deposit (made through zap == false
, otherwise == true
).
An option for making a deposit without the user having LP tokens.
Withdraw a deposit made through zap
.
Method for displaying earned rewards in a specific reward pool (will return two values: first for a deposit via deposit
, second for a deposit via zap
).
Method for displaying earned rewards in all reward pools.
Method for displaying a list of active reward pools (the ones that are still distributing rewards).
Method for displaying user deposits.
Method for displaying the intermediate variable in full.