WCurveGauge

This is the technical documentation for the WCurveGauge Solidity contract. The WCurveGauge contract is a wrapped Curve Gauge position that leverages LP tokens to be held in the BlueberryBank and does not generate yields. LP tokens are identified by tokenIds encoded from the LP token address.

Imports

The contract imports several OpenZeppelin contracts and other utility contracts and interfaces.

import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import "../utils/BlueBerryErrors.sol" as Errors;
import "../utils/EnsureApprove.sol";
import "../interfaces/IERC20Wrapper.sol";
import "../interfaces/IWCurveGauge.sol";
import "../interfaces/curve/ILiquidityGauge.sol";

Contract Inheritance

The WCurveGauge contract inherits from the following contracts:

  • ERC1155Upgradeable

  • ReentrancyGuardUpgradeable

  • OwnableUpgradeable

  • EnsureApprove

  • IERC20Wrapper

  • IWCurveGauge

contract WCurveGauge is
    ERC1155Upgradeable,
    ReentrancyGuardUpgradeable,
    OwnableUpgradeable,
    EnsureApprove,
    IERC20Wrapper,
    IWCurveGauge

State Variables

The contract maintains the following state variables:

  • registry: Address of Curve Registry

  • gaugeController: Address of Curve Gauge Controller

  • CRV: Address of CRV token

  • accCrvPerShares: Mapping from gauge id to accCrvPerShare

ICurveRegistry public registry;
ICurveGaugeController public gaugeController;
IERC20Upgradeable public CRV;
mapping(uint256 => uint256) public accCrvPerShares;

Functions

initialize

This function initializes the contract with the addresses of the CRV token, Curve Registry, and Curve Gauge Controller.

function initialize(
    address crv_,
    address crvRegistry_,
    address gaugeController_
) external initializer

encodeId

This function encodes the given pool id and CRV amount per share to an ERC1155 token id.

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

decodeId

This function decodes the given ERC1155 token id to a pool id and CRV amount per share.

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

getUnderlyingToken

This function returns the underlying ERC20 token of the given ERC1155 token id.

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

getLpFromGaugeId

This function returns the LP token address from the given gauge id.

function getLpFromGaugeId(uint256 gid) public view returns (address)

pendingRewards

This function returns the pending rewards from the farming pool.

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

mint

This function mints an ERC1155 token for the given LP token.

function burn(
    uint256 id,
    uint256 amount
) external nonReentrant returns (uint256 rewards)

_mintCrv

This internal function mints CRV rewards for the Curve gauge.

function _mintCrv(ILiquidityGauge gauge, uint256 gid) internal

Last updated