Casa de Papel
The MasterChef of Interest Protocol. It is named after the popular Netflix show πŸ˜€. It will mint Interest Token to liquidity providers via farms.

Open Zeppelin Contracts

START_BLOCK

function START_BLOCK() external view returns(uint256);
Summary
It returns the block number, which this contract will start rewarding Interest Tokens.

INTEREST_TOKEN

function INTEREST_TOKEN() external view returns(address);
Summary
It returns the address of the Interest Token.

interestTokenPerBlock

function interestTokenPerBlock() external view returns(uint256);
Summary
It returns the number of Interest Tokens minted by this contract per block. Note that on BSC, the block time is around 3 seconds. But this varies greatly from chain to chain.

treasury

function treasury() external view returns(address);
Summary
It returns address of the treasury. This account receives 10% of all new minted tokens.

treasuryBalance

function treasuryBalance() external view returns(uint256);
Summary
It returns the treasury pending rewards.

pools

function pools(uint256 index) external view returns(
address stakingToken; // LP Token supported by this pool
uint256 allocationPoints; // How many allocation points are assigned to this pool
uint256 lastRewardBlock; // The last block that rewards were calculated for this pool
uint256 accruedIntPerShare; // Total amount of rewards per token this pool has accrrud since day 0
uint256 totalSupply; // Total amount of tokens stored in this pool
);
Parameters:
  1. 1.
    The id of the pool.
Summary
It returns an array with information about all pools supported by this contract.

userInfo

function userInfo(uint256 poolId, address account) external view returns(
uint256 amount; // How many LP tokens the user has in a specific pool.
uint256 rewardsPaid; // How many rewards the user has been paid so far.
);
Parameters:
  1. 1.
    The id of pool
  2. 2.
    The address of an account. Together with the Pool Id, the caller can find the user details for a specific pool.
Summary
It returns the information of a user for the pool with id Pool Id.

hasPool

function hasPool(address token) external view returns(bool);
Parameters:
  1. 1.
    The caller can uses this token to check if the contract has a pool for it.
Summary
Checks if a token has a farm in this contract.

getPoolId

function getPoolId(address token) external view returns(uint256);
Parameters:
  1. 1.
    The caller can uses this token to get the id of the token's pool.
Summary
It returns the pool id of a token.

totalAllocationPoints

function totalAllocationPoints() external view returns(uint256);
Summary
It returns to total allocation points in the MasterChef.

getPoolsLength

function getPoolsLength() external view returns(uint256);
Summary
It returns the total number of pools in the contract.

getUserPendingRewards

function getUserPendingRewards(uint256 poolId, address _user) external view returns (uint256);
Parameters:
  1. 1.
    The id of the pool, which the caller wishes to find out how many pending rewards a user has.
  2. 2.
    The address that owns the pending rewards in this pool.
Summary
It returns the pending rewards a user has accrued up until now. It is a front-end utility function.

mintTreasuryRewards

function mintTreasuryRewards() external;
Summary
It mints the treasury's pending rewards.

updatePool

function updatePool(uint256 poolId) external;
Parameters:
  1. 1.
    The caller will update the pool with this id.
Event
event UpdatePool(uint256 indexed poolId, uint256 blockNumber, uint256 accruedIntPerShare)l
Summary
It will update the rewards accrued by this pool. The reward Interest Token will only be minted during deposits and withdraws.

updateAllPools

function updateAllPools() external;
This function loops through all pools. So be careful of the gas cost.
Event
event UpdatePool(uint256 indexed poolId, uint256 blockNumber, uint256 accruedIntPerShare);
Summary
It calls updatePool in all pools. It can be very costly on congested chains.

stake

function stake(uint256 poolId, uint256 amount) external;
Parameters:
  1. 1.
    The id of the pool in which the tokens will be deposited.
  2. 2.
    The number of tokens the msg.sender wishes to deposit.
Restrictions:
  • allowance: It assumes the msg.sender has given enough allowance to this contract.
Event
event Stake(address indexed user, uint256 indexed poolId, uint256 amount);
Summary
It transfers the tokens from msg.sender to this contract and rewards his/her with Interest Tokens. It will send the rewards accrued to the msg.sender.

unstake

function unstake(uint256 poolId, uint256 amount) external;
Parameters:
  1. 1.
    The id of the pool from which the tokens will be withdrawn.
  2. 2.
    The number of tokens the msg.sender wishes to withdraw.
Restrictions:
  • require: The msg.sender must have deposited enough tokens to be withdrawn.
Event
event Unstake(address indexed user, uint256 indexed poolId, uint256 amount);
Summary
It returns the deposited tokens to the msg.sender . It will send any pending rewards accrued since the last deposit or withdrawal.

emergencyWithdraw

function emergencyWithdraw(uint256 poolId) external;
Parameters:
  1. 1.
    The id of the pool the msg.sender wishes to withdraw his/her tokens WITHOUT calculating any rewards.
Event
event EmergencyWithdraw(address indexed user, uint256 indexed poolId, uint256 amount);
Summary
It withdraws tokens from a pool without calculating or awarding any rewards.
Export as PDF
Copy link
On this page
Open Zeppelin Contracts
START_BLOCK
INTEREST_TOKEN
interestTokenPerBlock
treasury
treasuryBalance
pools
userInfo
hasPool
getPoolId
totalAllocationPoints
getPoolsLength
getUserPendingRewards
mintTreasuryRewards
updatePool
updateAllPools
stake
unstake
emergencyWithdraw