Socket Contract API
The vault contract is an entry point for a user request. When a user requests Bridge or BridgeAndCall with their cryptocurrency, the vault contract securely locks it until the opposite-directional bridge request occurs.
The socket contract receives and verifies event messages from users or relayers. If the requested message is determined as valid, the socket contract executes request-indicated actions (e.g. mint, lending, leveraged investment) and checks whether or not these actions are executed correctly.
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