UnifiERC20.sol

Primary Uses - UnifiERC20.sol essentially ports the properties of ERC-20 tokens on to Unifi LP Tokens, or uTokens. An example of this in practice would be the 'approve' transaction.

uTrade V2 UnifiERC20 Code / Interfaces

uTrade V2 UnifiERC20 Contract Addresses

Each uTrade V2 Liquidity Pool uses the uTrade V2 ERC20 Interface in the contract. An example would be 0x96351b805FB389B761c1318B43a7dC0C679BEd5E (Link) for the UNIFI / ETH pair.

Events

Approval

event Approval(address indexed owner, address indexed spender, uint value);

The Approval event is emitted anytime an approve or permit function is called.

Transfer

event Transfer(address indexed from, address indexed to, uint value);

The Transfer event is emitted anytime a transfer of LP tokens occurs, by the transfer, transferFrom, mint, or burn functions.

Read-Only Functions

name

function name() external pure returns (string memory);

The name function will return "Unifi LPs" for all liquidity pool contracts.

symbol

function symbol() external pure returns (string memory);

The symbol function will return "Unifi-LP" for all liquidity pool contracts.

decimals

function decimals() external pure returns (uint8);

The decimals function returns "18" as a uint8 value, which is the precision for each uToken on uTrade V2.

totalSupply

function totalSupply() external view returns (uint);

The totalSupply function returns the total amount uTokens for a pair.

balanceOf

function balanceOf(address owner) external view returns (uint);

The balanceOf function returns the balance of uTokens for the provided address.

allowance

function allowance(address owner, address spender) external view returns (uint);

The allowance function returns the amount of tokens an address is approved to transfer when using the transferFrom function.

DOMAIN_SEPARATOR

function DOMAIN_SEPARATOR() external view returns (bytes32);

The DOMAIN_SEPARATOR function is used in the permit function, and is one of the components that allows transactions to get through without a prior approve transaction. Calling a read function returns the bytes32 data that is required for use in permit function.

PERMIT_TYPEHASH

function PERMIT_TYPEHASH() external view returns (bytes32);

The PERMIT_TYPEHASH function is used in the permit function, and is one of the components that allows transactions to get through without a prior approve transaction. Calling a read function returns the bytes32 data that is required for use in the permit function.

nonces

function nonces(address owner) external view returns (uint);

The nonces function is used in the permit function. It returns the current nonce of the address provided.

State-Changing Functions

approve

function approve(address spender, uint value) external returns (bool);

The approve function sets a value for the amount of LP tokens the address provided is allowed to transfer. Returns a boolean value and emits the Approval event.

transfer

function transfer(address to, uint value) external returns (bool);

The transfer function lets an address send uTokens from one address to another, and returns a boolean value and emits a Transfer event.

transferFrom

function transferFrom(address from, address to, uint value) external returns (bool);

The transferFrom function sends uTokens from one address to another. This requires the sending address to have approval to send uTokens. Returns a boolean value and emits a Transferevent.

permit

function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;

The permit function allows a sender to use a signature in lieu of an approval transaction, and sets the allowance for an address to send.

Function Parameter Breakdown

Interface Code

interface IUnifiERC20 {
    event Approval(address indexed owner, address indexed spender, uint value);
    event Transfer(address indexed from, address indexed to, uint value);

    function name() external pure returns (string memory);
    function symbol() external pure returns (string memory);
    function decimals() external pure returns (uint8);
    function totalSupply() external view returns (uint);
    function balanceOf(address owner) external view returns (uint);
    function allowance(address owner, address spender) external view returns (uint);

    function approve(address spender, uint value) external returns (bool);
    function transfer(address to, uint value) external returns (bool);
    function transferFrom(address from, address to, uint value) external returns (bool);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
    function PERMIT_TYPEHASH() external pure returns (bytes32);
    function nonces(address owner) external view returns (uint);

    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}

Last updated