Comment on page
TradingPlatform
The contract implements the token trading platform with different trading tools.
bytes32 ADMIN_ROLE
uint32 PRECISION
function activeOrdersLength() external view returns (uint256)
See {ITradingPlatform}
function activeOrderId(uint256 itemId) external view returns (uint256)
See {ITradingPlatform}
function activeOrdersIds(uint256 offset, uint256 limit) external view returns (uint256[] ordersIds)
See {ITradingPlatform}
function checkUpkeep(bytes checkData) external view returns (bool upkeepNeeded, bytes performData)
See {ITradingPlatform}
function getFeeRecipient() external view returns (address)
See {ITradingPlatform}
function getOrderCounter() external view returns (uint256)
See {ITradingPlatform}
function getProtocolFee() external view returns (uint32)
See {ITradingPlatform}
function getResultTokenOut(uint256 orderId) external view returns (uint256)
See {ITradingPlatform}
function getSwapHelper() external view returns (address)
See {ITradingPlatform}
function getTokenStatus(address token) external view returns (bool)
See {ITradingPlatform}
function getUserBalance(address user, address token) external view returns (uint256)
See {ITradingPlatform}
function getUserOrdersIds(address userAddress) external view returns (uint256[])
See {ITradingPlatform}
function getUserOrdersInfo(address userAddress) external view returns (struct ITradingPlatform.OrderInfo[])
See {ITradingPlatform}
function isActiveOrderExist(uint256 orderId) external view returns (bool)
See {ITradingPlatform}
function checkOrder(uint256 orderId) public view returns (bool)
See {ITradingPlatform}
function getOrdersInfo(uint256[] ordersIds) public view returns (struct ITradingPlatform.OrderInfo[] orders)
See {ITradingPlatform}
function shouldRebalance() public view returns (uint256[])
See {ITradingPlatform}
constructor(address uniswapHelperV3_, address admin, uint32 protocolFee_, address feeRecipient_) public
Initializes the TradingPlatform contract with the specified parameters.
The UniswapHelperV3 address, admin address, and fee recipient address must not be zero addresses. The protocol fee must be less than 100% (represented as 1,000,000 in 6 digits precision). Sets the DEFAULT_ADMIN_ROLE and ADMIN_ROLE roles to the admin address.
Parameters
Name | Type | Description |
---|---|---|
uniswapHelperV3_ | address | The address of the UniswapHelperV3 contract. |
admin | address | The address of the contract admin. |
protocolFee_ | uint32 | The protocol fee percentage, represented as a decimal with 6 digits precision. |
feeRecipient_ | address | The address where the protocol fees will be sent to. |
function addTokensToWhitelist(address[] tokens) external
See {ITradingPlatform}
function boundOrders(uint256 leftOrderId, uint256 rightOrderId) external
See {ITradingPlatform}
function cancelOrders(uint256[] ordersIds) external
See {ITradingPlatform}
function createOrder(struct ITradingPlatform.Order order) external returns (uint256)
See {ITradingPlatform}
function deposit(address token, uint256 amount) external returns (bool)
See {ITradingPlatform}
function executeOrders(uint256[] ordersIds) public returns (bool)
See {ITradingPlatform}
function performUpkeep(bytes performData) external
See {ITradingPlatform}
function removeTokensFromWhitelist(address[] tokens) external
See {ITradingPlatform}
function setProtocolFee(uint32 newProtocolFee) external
See {ITradingPlatform}
function withdraw(address token, uint256 amount) external returns (bool)
See {ITradingPlatform}
function executeOrder(uint256 orderId) internal
Executes an individual order based on the provided order ID.
This function is internal and should not be called directly from outside the contract. Emits a {OrderExecuted} event.
Parameters
Name | Type | Description |
---|---|---|
orderId | uint256 | ID of the order to be executed. |
function calculateFee(uint256 amount, uint32 protocolFeePercent) internal pure returns (uint256)
Calculates the fee amount based on the given token amount.
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The token amount for which the fee is calculated. |
protocolFeePercent | uint32 | |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 The calculated fee amount. |
function getPercent(uint256 amount, uint24 percent) internal pure returns (uint256)
Calculates the percentage of an amount.
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The base amount. |
percent | uint24 | The percentage value, represented as a decimal with 6 digits precision. |
Return Values
Name | Type | Description |
---|---|---|
[0] | uint256 | uint256 The calculated percentage amount. |
Last modified 6mo ago