Skip to content

WhitelabeledUnitUpgradeable

Git Source

Inherits: IWhitelabeledUnit, ERC20PermitUpgradeable

Upgradeable implementation of a whitelabeled unit token that wraps underlying Generic units

This contract provides a concrete implementation of the IWhitelabeledUnit interface using OpenZeppelin's upgradeable contracts pattern. It enables wrapping of underlying unit tokens into a branded token with custom name and symbol while maintaining 1:1 conversion mechanics. Key features:

  • Upgradeable proxy pattern for future enhancements
  • EIP-2612 permit functionality for gasless approvals via off-chain signatures
  • 1:1 wrapping and unwrapping of underlying unit tokens
  • Safe token transfers using OpenZeppelin's SafeERC20
  • Event emission for transparent tracking of wrap/unwrap operations
  • Virtual functions allowing for customization in derived contracts

State Variables

_genericUnit

The address of the underlying Generic unit token that this contract wraps

IERC20 private _genericUnit

Functions

constructor

Contract constructor that disables initializers for the implementation contract

This prevents the implementation contract from being initialized directly. Only proxy contracts can call initializer functions, ensuring proper upgradeable pattern usage.

constructor() ;

__WhitelabeledUnit_init

Internal initialization function for setting up the whitelabeled unit token

This function initializes the ERC20Permit token with the provided name and symbol, sets up EIP-2612 permit functionality, and configures the underlying unit token address.

function __WhitelabeledUnit_init(
    string memory name_,
    string memory symbol_,
    IERC20 genericUnit_
)
    internal
    onlyInitializing;
Parameters
NameTypeDescription
name_stringThe human-readable name for the whitelabeled token (e.g., "Generic USD")
symbol_stringThe symbol for the whitelabeled token (e.g., "GUSD")
genericUnit_IERC20The address of the underlying Generic unit token to wrap

wrap

Wraps underlying unit tokens into whitelabeled tokens for a specified owner

Transfers amount of underlying unit tokens from the caller to this contract and mints an equivalent amount of whitelabeled tokens to the owner address. This maintains 1:1 parity between underlying units and whitelabeled tokens.

function wrap(address owner, uint256 amount) external virtual;
Parameters
NameTypeDescription
owneraddressThe address that will receive the minted whitelabeled tokens
amountuint256The amount of underlying unit tokens to wrap and whitelabeled tokens to mint

unwrap

Unwraps whitelabeled tokens back to underlying unit tokens

Burns amount of whitelabeled tokens from the owner's balance and transfers an equivalent amount of underlying unit tokens to the recipient. This maintains the 1:1 parity in reverse direction. If the caller is not the owner, the caller must have sufficient allowance to burn the owner's tokens.

function unwrap(address owner, address recipient, uint256 amount) external virtual;
Parameters
NameTypeDescription
owneraddressThe address that owns the whitelabeled tokens to be unwrapped
recipientaddressThe address that will receive the underlying unit tokens
amountuint256The amount of whitelabeled tokens to burn and unit tokens to receive

genericUnit

Returns the address of the underlying Generic unit token that this contract wraps

This is the ERC20 token address of the Generic units that back the whitelabeled tokens. The underlying token typically represents claims on protocol vault positions and may accrue yield over time through vault strategy operations.

function genericUnit() external view returns (address);
Returns
NameTypeDescription
<none>addressThe contract address of the underlying unit token

decimals

Returns the number of decimals used by the whitelabeled unit token

This function overrides the default ERC20 decimals implementation to match the decimals of the underlying unit token, ensuring consistency in value representation.

function decimals() public view override returns (uint8);