Cexles Finance
Search
K
Comment on page

TradingPlatform

The contract implements the token trading platform with different trading tools.

Solidity API

TradingPlatform

ADMIN_ROLE

bytes32 ADMIN_ROLE

PRECISION

uint32 PRECISION

activeOrdersLength

function activeOrdersLength() external view returns (uint256)
See {ITradingPlatform}

activeOrderId

function activeOrderId(uint256 itemId) external view returns (uint256)
See {ITradingPlatform}

activeOrdersIds

function activeOrdersIds(uint256 offset, uint256 limit) external view returns (uint256[] ordersIds)
See {ITradingPlatform}

checkUpkeep

function checkUpkeep(bytes checkData) external view returns (bool upkeepNeeded, bytes performData)
See {ITradingPlatform}

getFeeRecipient

function getFeeRecipient() external view returns (address)
See {ITradingPlatform}

getOrderCounter

function getOrderCounter() external view returns (uint256)
See {ITradingPlatform}

getProtocolFee

function getProtocolFee() external view returns (uint32)
See {ITradingPlatform}

getResultTokenOut

function getResultTokenOut(uint256 orderId) external view returns (uint256)
See {ITradingPlatform}

getSwapHelper

function getSwapHelper() external view returns (address)
See {ITradingPlatform}

getTokenStatus

function getTokenStatus(address token) external view returns (bool)
See {ITradingPlatform}

getUserBalance

function getUserBalance(address user, address token) external view returns (uint256)
See {ITradingPlatform}

getUserOrdersIds

function getUserOrdersIds(address userAddress) external view returns (uint256[])
See {ITradingPlatform}

getUserOrdersInfo

function getUserOrdersInfo(address userAddress) external view returns (struct ITradingPlatform.OrderInfo[])
See {ITradingPlatform}

isActiveOrderExist

function isActiveOrderExist(uint256 orderId) external view returns (bool)
See {ITradingPlatform}

checkOrder

function checkOrder(uint256 orderId) public view returns (bool)
See {ITradingPlatform}

getOrdersInfo

function getOrdersInfo(uint256[] ordersIds) public view returns (struct ITradingPlatform.OrderInfo[] orders)
See {ITradingPlatform}

shouldRebalance

function shouldRebalance() public view returns (uint256[])
See {ITradingPlatform}

constructor

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.

addTokensToWhitelist

function addTokensToWhitelist(address[] tokens) external
See {ITradingPlatform}

boundOrders

function boundOrders(uint256 leftOrderId, uint256 rightOrderId) external
See {ITradingPlatform}

cancelOrders

function cancelOrders(uint256[] ordersIds) external
See {ITradingPlatform}

createOrder

function createOrder(struct ITradingPlatform.Order order) external returns (uint256)
See {ITradingPlatform}

deposit

function deposit(address token, uint256 amount) external returns (bool)
See {ITradingPlatform}

executeOrders

function executeOrders(uint256[] ordersIds) public returns (bool)
See {ITradingPlatform}

performUpkeep

function performUpkeep(bytes performData) external
See {ITradingPlatform}

removeTokensFromWhitelist

function removeTokensFromWhitelist(address[] tokens) external
See {ITradingPlatform}

setProtocolFee

function setProtocolFee(uint32 newProtocolFee) external
See {ITradingPlatform}

withdraw

function withdraw(address token, uint256 amount) external returns (bool)
See {ITradingPlatform}

executeOrder

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.

calculateFee

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.

getPercent

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.