ISwap

Git Source

Functions

initialize

Initializes the MarketPlace, setting the WCSB contract address.

function initialize(address mira_, uint256 minCsb_, uint256 minMira_, address admin) external;

Parameters

NameTypeDescription
mira_addressThe address of MIRA contract.
minCsb_uint256The minimum amount of CSB to sell.
minMira_uint256The minimum amount of MIRA to sell.
adminaddressThe address of the contract admin.

pause

Pauses interaction with the contract. Requirements:

  • The caller must have the ADMIN_ROLE.
function pause() external;

unpause

Resumes interaction with the contract. Requirements:

  • The caller must have the ADMIN_ROLE.
function unpause() external;

setMinMira

Sets the minimum amount of MIRA to sell.

function setMinMira(uint256 minMira_) external;

Parameters

NameTypeDescription
minMira_uint256The minimum amount of MIRA to sell.

setMinCsb

Sets the minimum amount of CSB to sell.

function setMinCsb(uint256 minCsb_) external;

Parameters

NameTypeDescription
minCsb_uint256The minimum amount of CSB to sell.

sellMIRA

Sells MIRA for CSB. Creates a SellOrder and emits the SellMIRA event.

function sellMIRA(uint256 miraAmount, uint256 expectedCsbAmount) external returns (uint256 orderId);

Parameters

NameTypeDescription
miraAmountuint256The amount of MIRA to sell.
expectedCsbAmountuint256The expected amount of CSB to receive.

Returns

NameTypeDescription
orderIduint256The new created order id.

sellCSB

Sells CSB for MIRA. Creates a SellOrder and emits the SellCSB event.

The amount of CSB to sell must be specified in the msg.value.

function sellCSB(uint256 expectedMiraAmount) external payable returns (uint256 orderId);

Parameters

NameTypeDescription
expectedMiraAmountuint256The expected amount of MIRA to receive.

Returns

NameTypeDescription
orderIduint256The new created order id.

cancelOrder

Cancels a sell order and refunds to the seller. Deletes a given SellOrder and emits the SellOrderCanceled event.

function cancelOrder(uint256 orderId) external;

Parameters

NameTypeDescription
orderIduint256The order id to cancel.

acceptOrder

Accepts a sell order and transfers the tokens to the traders. Deletes a given SellOrder and emits the SellOrderMatched event.

function acceptOrder(uint256 orderId) external payable;

Parameters

NameTypeDescription
orderIduint256The order id to accept.

getOrder

Returns the SellOrder struct of a given order id.

function getOrder(uint256 orderId) external view returns (DataTypes.SellOrder memory);

Parameters

NameTypeDescription
orderIduint256The order id to get.

Returns

NameTypeDescription
<none>DataTypes.SellOrderorder The SellOrder struct.

mira

Returns the address of MIRA contract.

function mira() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of MIRA contract.

getMinMira

Returns the minimum amount of MIRA to sell.

function getMinMira() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The minimum amount of MIRA to sell.

getMinCsb

Returns the minimum amount of CSB to sell.

function getMinCsb() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The minimum amount of CSB to sell.