Overview
Of course, interacting directly with our smart contracts is also a possibility. In this section you will find a quick overview of all the methods available to interacting with 2PI.
All function definitions here are expressed using Solidity.

poolLength() external view returns (uint)
Returns the current pool count.
poolInfo(uint pid) external view returns (PoolInfo)
Returns the pool information for the given pool ID. The following attributes are expected:
Attribute
Type
Description
want
address
Pool token contract address
weighing
uint256
Internal weight assigned to the pool on 2PI token distribution.
lastRewardBlock
uint256
The block when 2PI token distribution last occurred.
accPiTokenPerShare
uint256
Accumulated 2PI tokens per share, times SHARE_PRECISION.
controller
address
Address of the token controller

deposit(uint pid, uint amount, address referrer) public
Deposit the specified amount (expressed in wei for the expected token) on the given pool. The referrer argument is only used during the initial interaction of the sender with this contract (unless it's used on all previous occasions with the zero address or the sender address, either case is ignored).
depositAll(uint pid, address referrer) external
Same as deposit, but using all sender balance as amount.

withdraw(uint pid, uint shares) public
Pulls the specified shares for the given pool. You can query how many shares has any account using the balanceOf(uint pid, address user) function.
withdrawAll(uint pid) external
Same as withdraw but using all sender shares for the given pool.

balance(uint pid) external view returns (uint)
Total balance (in shares) for the given pool.
balanceOf(uint pid, address user) external view returns (uint)
Returns the user balance (in shares) for a given user address in a given pool.

pendingPiToken(uint pid, address user) external view returns (uint)
Returns how many 2PI tokens the given user has pending to claim.
massUpdatePools() public
Update rewards and other internal state for all pools. It's a nice way to throw away gas for others =)
updatePool(uint pid) public
Update rewards and other internal state for the given pool. Another nice way to throw away gas.
depositNative(uint pid, address referrer) external payable
Deposit on the native pool (that is, MATIC on Polygon, AVAX on Avalanche, ETH on Ethereum, etc.).
harvest(uint pid) public
Claim all sender's pending rewards for the given pool.
harvestAll() external
Same as harvest, but for all existing pools.
paidRewards(uint pid) public view returns (uint)
Returns the amount of rewards already paid to the sender.
paidRewards(uint pid, address user) public view returns (uint)
Returns the amount of rewards already paid to the given user.

getPricePerFullShare(uint pid) external view returns (uint)
Returns the price of the given pool shares. Used to convert shares into wei units of the pool's underlying token.
decimals(uint pid) public view returns (uint)
Returns the decimals for the given pool. This, combined with shares and price per full share needs to be used to display or calculate the amount deposited on the pool.
piTokenPerBlock() public view returns (uint)
How many 2PI tokens will be minted in total per block.
Copy link
On this page
Not admin public methods
Pools
Deposits
Withdraws
Balances
Rewards
Utils