XaiService Contract

Overview

This contract functions as the accountant and manager for staking operations. It utilizes EIP-7201 to ensure storage integrity through the use of a transparent proxy pattern.

Structures

Misc

enum LockAction {
    Delegate,
    DelegateAndStake
}

State

struct State {
    address locker;
    address shareToken;
    address liquidToken;
    address strategist;
    uint64 feePercent;
    bytes32[15] __gap;
}

Service Pool

struct ServicePool {
    address stakeCandidate;
    uint256 rewardDebt;
    EnumerableMap.AddressToUintMap poolToId;
    EnumerableMap.UintToAddressMap idToPool;
    mapping(uint256 => EnumerableSet.UintSet) unstakeData;
    EnumerableMap.AddressToUintMap userToId;
    EnumerableMap.UintToAddressMap idToUser;
    mapping(uint256 => EnumerableSet.UintSet) pendingRedemption;
    mapping(address => EnumerableSet.UintSet) redemption;
    EnumerableSet.UintSet pendingRedemptionList;
    bytes32[15] __gap;
}

Views

struct ServicePoolView {
        address stakeCandidate;
        uint256 rewardDebt;
        uint256 totalShares;
        PoolInfoView[] pools;
    }

    struct PoolInfoView {
        address pool;
        uint256 deposit;
        uint256[] unstakeData;
        uint256[] amounts;
        uint256[] unstakeAfter;
    }

    struct UserInfoView {
        address user;
        PendingRedemptionView[] pendingRedemption;
        RedemptionView[] redemption;
    }

    struct PendingRedemptionView {
        uint256 data;
        uint256 amount;
        uint256 duration;
    }

    struct RedemptionView {
        uint256 data;
        IXaiLocker.RedemptionRequest info;
    }

Preview token conversion

Liquidity

function previewLiquidityToShares(uint256 amount) view returns (uint256)

Used for converting XAI or alXAI into stXAI.

Shares

function previewSharesToLiquidity(uint256 amount) view returns (uint256)

Used for converting stXAI into XAI or alXAI.

User Info

function userInfo(address user) public view returns (UserInfoView memory info)

This function provides information about redemptions.

Functions

Locking

function lockXai(uint256 amount, LockAction action)
function lockEsXai(uint256 amount, LockAction action)

Both functions require that XAI or esXAI be pre-approved, as applicable.

Swap Delegation type

function sharesToLiquidity(uint256 amount)
function liquidityToShares(uint256 amount)

Both functions require pre-approved stXAI or alXAI, as applicable.

Redemption

Start Redemption

function startRedemption(uint256 amount, uint256 duration, bool fromLiquid)

This function creates a pending redemption request from stXAI or alXAI.

It requires pre-approved stXAI or alXAI, depending on the fromLiquid flag.

Cancel Redemption

Pending

function cancelPendingRedemption(uint256 pendingRedemptionData, bool toLiquid)

Fulfilled

function cancelRedemption(uint256 redemptionData, bool toLiquid)

In both cases, you can retrieve data from the userInfo view.

The toLiquid flag specifies the type of output token.

Redeem

function completeRedemption(uint256 redemptionData)

You can retrieve data from the userInfo view.

Last updated