소켓 컨트랙트 API

볼트 컨트랙트 (vault contract)는 사용자 요청의 진입점입니다. 사용자가 자신의 암호화폐로 브랏지 (Bridge) 또는 브리지앤콜 (BridgeAndCall)을 요청하면, 볼트 컨트랙트는 반대 방향의 브리지 요청이 발생할 때까지 해당 암호화폐를 안전하게 잠급니다.

소켓 컨트랙트 (socket contract)는 사용자나 릴레이어로부터 이벤트 메시지를 수신하고 검증합니다. 요청된 메시지가 유효하다고 판단되면, 소켓 컨트랙트는 요청에 명시된 액션 (예: 민팅, 대출, 레버리지 투자)을 실행하고 이러한 액션이 올바르게 실행되었는지 확인합니다.

Interfaces of Vault contract

interface IVault {
    // Events that occur when a user's request is generated or an asset is processed
    event Vault(uint8 type_, uint128 asset_id_, uint256 amount_);
    
    // Function that returns the address of the associated WBFC
    function WBFC() view returns (address);
    // Function that returns the address of the associated socket
    function socket() view returns (address);
    // Function that returns the address of the associated swap router
    function swap_router() view returns (address);
    
    // Entry point for the user to initiate a CCCP request
    function request(User_Request memory user_request) payable returns (bool);
    // Entry point for socket to execute user request
    function execute(Instruction memory instruction) returns (bool);
    // Entry point for socket to complete user request
    function resolve(Task_Params memory params) returns (bool);
    // Entry point for socket to rollback user request
    function rollback(Task_Params memory params) returns (bool);
    // Entry point to provide the liquidity
    function liquidity_deposit(uint128 _asset_index, uint256 _amount) payable returns ();
    
    // Function that returns a value that identifies the native coin in which the contract was deployed
    function this_chain_coin_index() view returns (uint128);
    // Function that returns the fee rate
    function fee_rate() view returns (uint256);
    
    // Function that returns the handler address of the associated lending service
    function lending_handlers(uint128) view returns (address);
    
    // Function that returns a value that identifies the asset(coin, token)
    function get_asset_id(address) view returns (uint128);
    // Function that returns a token(coin) registered with an asset identification value
    function assets(uint128) view returns (AssetInfo memory asset_info);

    struct Asset_Config {
        uint128 min_amount;
        uint128 max_amount;
        uint32 _type;
        uint64 fee_rate;
        address target;
    }
    struct AssetInfo {
        Asset_Config config;
        uint256 amount;
        uint256 fee;
    }
    struct User_Request {
        Instruction ins_code;
        Task_Params params;
    }

    struct Instruction {
        ChainIndex chain;
        RBCmethod method;
    }
    struct Task_Params {
        Asset_Index tokenIDX0; Asset_Index tokenIDX1;
        address refund;
        address to;
        uint256 amount;
        bytes variants;
    }
}

Interfaces of Socket contract

Last updated