XaiLocker Contract

Overview

This contract facilitates basic interactions with the XAI infrastructure, incorporating additional integrity checks to ensure secure operations.

All functions are designed to be invoked exclusively by the service contract.

The XaiLocker contract implements EIP-7201 to guarantee storage integrity through the transparent proxy pattern.

Structures

Misc

enum RequestStatus {
    Empty,
    Created,
    Completed,
    Cancelled
}

UnstakeRequest

struct UnstakeRequest {
    address pool;
    uint64 unstakeAfter;
    uint256 poolUnstakeIndex;
    uint128 amount;
    RequestStatus status;
}

RedemptionRequest

struct RedemptionRequest {
    uint256 esXaiIndex;
    uint128 amount;
    uint64 redeemableAfter;
    RequestStatus status;
}

LockerInfo

struct LockerInfo {
    address service;
    uint256 balance;
    UnstakeRequest[] unstakeRequests;
}

UserInfo

struct UserInfo {
    mapping(address => RedemptionRequest[]) requests;
}

Views

service

function service() view returns(address)

balance

function balance() view returns(uint256)

This value is used to check the solvency of the contract to perform basic actions.

getUnstakeRequest

function getUnstakeRequestCount()  view returns (uint256)
function getUnstakeRequest(uint256 index) view returns (UnstakeRequest memory)

getRedemptionRequest

function getRedemptionRequestCount() view returns (uint256)
function getRedemptionRequest(uint256 index) view 
    returns (IesXai.RedemptionRequest memory)

This view returns data from esXAI contract.

getUserRedemptionRequest

function getUserRedemptionRequestCount(address account) view returns (uint256)
function getUserRedemptionRequest(address account, uint256 index) view 
    returns (RedemptionRequest memory) 

Functions

Locking

function lockXaiFor(address, uint256 amount)
function lockEsXaiFor(address, uint256 amount)

The lock functions are designed to interact exclusively with the service contract. They assume that the required amount of tokens will be sent beforehand when invoking the function. The function signatures include an unused address parameter to maintain potential backward compatibility.

lockXaiFor

Solvency check performed inside the XAI infrastructure.

lockEsXaiFor

The function checks that enough tokens have been received by the contract by comparing with the stored internal balance.

Redeeming

Start redemption

function startRedemption(address user, uint256 amount, uint256 duration) 
    returns (uint256 redemptionIndex)

This function sends esXAI to the factory contract and initiates the redemption process for the specified duration.

Cancel redemption

function cancelRedemption(address user, uint256 index) 
    returns (uint256 requestAmount)

This function cancels the specified request and returns the esXAI to the locker.

Complete redemption

function completeRedemption(address user, uint256 index) 
    returns (uint256 requestAmount)

This function completes the redemption process by transferring the output XAI to the specified user.

Staking

Staking

function stakeToPool(address pool, uint256 amount) returns (bool)

Start unstake

function createUnstakeRequest(address pool, uint256 amount) 
    returns (uint256 createdRequestIndex)

Complete unstake

function unstakeFromPool(uint256 requestIndex) 
    returns (uint256 unstakedAmount)

Claim rewards

function claimFromPool(address pool) 
    returns (uint256 claimed)

Governance

function setService(address service)

Last updated