IOrderController
Functions
deposit
Allows a user to deposit tokens and create a DEPOSIT order. It doesn't gurantee deposit
The order can be executed if there's a matching withdrawal request. The caller should approve tokens prior to calling this function.
function deposit(uint256 tokenAmount, uint256 iterationLimit) external;
Parameters
Name | Type | Description |
---|---|---|
tokenAmount | uint256 | The amount of tokens to deposit. |
iterationLimit | uint256 | The maximum number of orders to process in a single call. |
withdraw
Allows a user to withdraw tranches and create a WITHDRAW order.
The order can be executed if there's a matching deposit request. The caller should approve tranches prior to calling this function.
function withdraw(uint256 trancheAmount, uint256 iterationLimit) external;
Parameters
Name | Type | Description |
---|---|---|
trancheAmount | uint256 | The amount of tranches to withdraw. |
iterationLimit | uint256 | The maximum number of orders to process in a single call. |
cancelOrder
Allows a user to cancel their pending order.
This can be called by the user who placed the order only.
function cancelOrder() external;
cancelDustOrder
Allows any users to cancel dust order.
function cancelDustOrder(uint256 orderId) external;
Parameters
Name | Type | Description |
---|---|---|
orderId | uint256 | The order id to cancel. |
expectedTokenAmount
Calculate the expected token amount for a given tranche amount.
function expectedTokenAmount(uint256 trancheAmount) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
trancheAmount | uint256 | The amount of tranches to convert. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The expected token amount. |
expectedTrancheAmount
Calculate the expected tranche amount for a given token amount.
function expectedTrancheAmount(uint256 tokenAmount) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
tokenAmount | uint256 | The amount of tokens to convert. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The expected tranche amount. |
currentOrderType
Return the type of the current order in the linked list of orders
function currentOrderType() external view returns (OrderType);
getValidOrderCount
Return the count of valid orders and the current order type.
function getValidOrderCount() external view returns (uint256 count, OrderType orderType);
Returns
Name | Type | Description |
---|---|---|
count | uint256 | The count of valid orders. |
orderType | OrderType | The type of the current order. |
getValidOrders
Return the valid orders and the current order type.
function getValidOrders() external view returns (Order[] memory, OrderType);
Returns
Name | Type | Description |
---|---|---|
<none> | Order[] | orders The valid orders. |
<none> | OrderType | orderType The type of the order. |
getOrderCount
Return the count of all orders.
function getOrderCount() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The count of all orders. |
getOrders
Return all orders.
function getOrders() external view returns (Order[] memory);
Returns
Name | Type | Description |
---|---|---|
<none> | Order[] | The orders. |
getUserOrder
Return the order of the given user.
function getUserOrder(address user) external view returns (Order memory);
Parameters
Name | Type | Description |
---|---|---|
user | address | The user address. |
Returns
Name | Type | Description |
---|---|---|
<none> | Order | The order. |
dust
Return the min amount of an order.
function dust() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The minimum value. |
Events
DustUpdated
event DustUpdated(uint256 newDust);
Errors
InvalidAmount
error InvalidAmount();
InvalidOrderType
error InvalidOrderType();
InvalidOrderId
error InvalidOrderId();
InsufficientBalance
error InsufficientBalance();
InsufficientAllowance
error InsufficientAllowance();
PortfolioClosed
error PortfolioClosed();