🤖XaiService

Overview

This contract used as accountant and manager of stake.

This contract uses EIP-7201 to ensure storage integrity using a transparent proxy pattern

Structs

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;
    }

Views

Preview token conversion

Liquidity

Used in case of conversion of XAI/alXAI to stXAI

function previewLiquidityToShares(uint256 amount) view returns (uint256)

Shares

Used in case of conversion of stXAI to XAI/alXAI

function previewSharesToLiquidity(uint256 amount) view returns (uint256)

User Info

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

This function returns information about redemptions.

Functions

Locking

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

Both functions require pre-approved XAI or esXAI respectively.

Swap Delegation type

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

Both functions require pre-approved stXAI or alXAI respectively.

Redemption

Start Redemption

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

This function creates pending redemption request from stXAI/alXAI.

Function require pre-approved stXAI or alXAI respectively to fromLiquid flag.

Cancel Redemption

Pending

function cancelPendingRedemption(uint256 pendingRedemptionData, bool toLiquid)

Fulfilled

function cancelRedemption(uint256 redemptionData, bool toLiquid)

In both cases, you can get data from userInfo view.

The toLiquid flag specifies the type of output token.

Redeem

function completeRedemption(uint256 redemptionData)

You can get data from userInfo view.

Last updated