Skip to main content

LiquidityReward

LiquidityReward

UserInfo

struct UserInfo {
uint256 amount;
int256 rewardDebt;
}

PoolInfo

struct PoolInfo {
contract IERC20 lpToken;
uint256 lastRewardBlock;
uint256 accRewardPerShare;
}

reward

contract IERC20 reward

rewardPerBlock

uint256 rewardPerBlock

pool

struct LiquidityReward.PoolInfo pool

totalRewardDebt

int256 totalRewardDebt

totalSupply

uint256 totalSupply

userInfo

mapping(address => struct LiquidityReward.UserInfo) userInfo

endBlock

uint256 endBlock

CampaignStarted

event CampaignStarted(uint256 rewardRate, uint256 startBlock, uint256 endBlock)

CampaignStopped

event CampaignStopped(uint256 endBlock)

Deposit

event Deposit(address user, uint256 amount)

Withdraw

event Withdraw(address user, uint256 amount)

Claim

event Claim(address user, uint256 amount)

DrainExtraReward

event DrainExtraReward(address user, uint256 amount)

DrainExtraLP

event DrainExtraLP(address user, uint256 amount)

initialize

function initialize(contract IERC20 _reward, contract IERC20 _lpToken) external

Initializer for setting up Liquidity Reward internal state.

Parameters

NameTypeDescription
_rewardcontract IERC20Address of the reward token(OGN)
_lpTokencontract IERC20Address of the LP token(Uniswap Pair)

startCampaign

function startCampaign(uint256 _rewardPerBlock, uint256 _startBlock, uint256 _numBlocks) external

start a new reward campaign. This will calculate all rewards up to the current block at the old rate. This ensures that we pay everyone at the promised rate before update to the new rate.

Parameters

NameTypeDescription
_rewardPerBlockuint256Amount rewarded per block
_startBlockuint256Block number that we want to start the rewards at (0 for current block)
_numBlocksuint256number of blocks that the campaign should last

stopCampaign

function stopCampaign() external

drainExtraRewards

function drainExtraRewards() external

drainExtraLP

function drainExtraLP() external

campaignActive

function campaignActive() external view returns (bool)

balanceOf

function balanceOf(address _account) external view returns (uint256)

getCampaignMultiplier

function getCampaignMultiplier(uint256 _to) internal view returns (uint256)

calculate the number of blocks since we last updated within start and end as constraints

Parameters

NameTypeDescription
_touint256Block number of the ending point.

Return Values

NameTypeDescription
[0]uint256multiplier Multiplier over the given _from to _to block.

pendingRewards

function pendingRewards(address _user) external view returns (uint256)

View function to see pending rewards for each account on frontend.

Parameters

NameTypeDescription
_useraddressAddress of the account we're looking up.

Return Values

NameTypeDescription
[0]uint256reward Total rewards owed to this account.

_pendingRewards

function _pendingRewards(struct LiquidityReward.UserInfo user) internal view returns (uint256)

totalOutstandingRewards

function totalOutstandingRewards() external view returns (uint256)

View function to see total outstanding rewards for the entire contract. This is how much is owed when everyone pulls out.

Return Values

NameTypeDescription
[0]uint256reward Total rewards owed to everyone.

doUpdatePool

function doUpdatePool() external

External call for updating the pool.

updatePool

function updatePool() internal

Update the Liquidity Pool reward multiplier. This locks in the accRewardPerShare from the last update block number to now. Will fail if we do not have enough to pay everyone. Always call updatePool whenever the balance changes!

deposit

function deposit(uint256 _amount) external

Deposit LP tokens into contract, must be preapproved.

Parameters

NameTypeDescription
_amountuint256Amount of LPToken to deposit.

exit

function exit() external

Exit out of the contract completely, withdraw LP tokens and claim rewards

withdraw

function withdraw(uint256 _amount, bool _claim) external

Withdraw LP tokens from contract.

Parameters

NameTypeDescription
_amountuint256Amount of LPToken to withdraw.
_claimboolBoolean do we want to claim our rewards or not

_withdraw

function _withdraw(struct LiquidityReward.UserInfo user, uint256 _amount, bool _claim) internal

claim

function claim() external

Claim all pending rewards up to current block

subDebt

function subDebt(uint256 amount, int256 debt) internal pure returns (uint256 result)