WConvexPools

The WConvexPools contract is a wrapper for Convex Finance LP token positions, allowing leverage to be applied to the LP tokens. The contract is designed to hold the leveraged LP tokens in the BlueberryBank and does not generate yields. LP tokens are identified by tokenIds encoded from the LP token address.

The contract inherits from ERC1155Upgradeable, ReentrancyGuardUpgradeable, OwnableUpgradeable, EnsureApprove, IERC20Wrapper, and IWConvexPools.

Contract Initialization

The initialize function initializes the contract with the addresses of the CVX token and Convex Pools contract.

function initialize(address cvx_, address cvxPools_) external initializer

Functions

encodeId

The encodeId function encodes the pool id (pid) and CVX amount per share (cvxPerShare) into an ERC1155 token id.

function encodeId(
    uint256 pid,
    uint256 cvxPerShare
) public pure returns (uint256 id)

decodeId

The decodeId function decodes an ERC1155 token id into the pool id (pid) and CVX amount per share (cvxPerShare).

function decodeId(
    uint256 id
) public pure returns (uint256 gid, uint256 cvxPerShare)

getUnderlyingToken

The getUnderlyingToken function returns the underlying ERC20 token for the given ERC1155 token id.

function getUnderlyingToken(
    uint256 id
) external view override returns (address uToken)

getPoolInfoFromPoolId

The getPoolInfoFromPoolId function returns the pool information (LP token, token, gauge, CRV rewards, stash, and shutdown status) for the given pool id.

function getPoolInfoFromPoolId(
    uint256 pid
) public view returns (
    address lptoken,
    address token,
    address gauge,
    address crvRewards,
    address stash,
    bool shutdown
)

pendingRewards

The pendingRewards function returns the pending rewards for the given ERC1155 token id and amount. Rewards can be multiple tokens.

function pendingRewards(
    uint256 tokenId,
    uint256 amount
) public view override returns (address[] memory tokens, uint256[] memory rewards)

mint

The mint function mints an ERC1155 token for the given LP token. It takes the Convex Pool id and token amount to wrap as input.

function mint(
    uint256 pid,
    uint256 amount
) external nonReentrant returns (uint256 id)

burn

The burn function burns the ERC1155 token to redeem the underlying ERC20 token. It takes the token id and amount to burn as input.

function burn(
    uint256 id,
    uint256 amount
) external nonReentrant returns (address[] memory rewardTokens, uint256[] memory rewards)

Last updated