CrystalDataHelper
The data helper contract is used to help the front-end query necessary information.
balanceOf
balanceOf
function balanceOf(address account, address token) public view returns (uint256)
Retrieves the balance of a token for an address. If the token address is 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
, the native token balance will be returned. If not, the ERC-20 token balance of the specified token is returned.
Parameters
account
address
Address to query token balance of
token
address
Token address
Return Values
balance
uint256
The addresses' balance of the specified token.
getPrice
getPrice
function getPrice(address market) public view returns (uint256 price, uint256 _highestBid, uint256 _lowestAsk)
Fetches the current mid price of a market, as well as the highest bid and lowest ask.
Parameters
market
address
Market address
Return Values
price
uint256
The mid price
_highestBid
uint256
The price of the highest buy order
_lowestAsk
uint256
The price of the lowest sell order
batchBalanceOf
batchBalanceOf
function batchBalanceOf(address account, address[] calldata tokens) external view returns (uint256[] memory returnData)
Retrieves the balances of multiple tokens for an address.
Parameters
account
address
Address to query token balance of
tokens
address[] calldata
Array of token addresses
Return Values
returnData
uint256[] memory
List consisting of the addresses' balance of each token.
getPrices
getPrices
function getPrices(address[] calldata markets) external view returns (uint256[] memory mids, uint256[] memory highestBids, uint256[] memory lowestAsks)
Fetches the current mid price, highest bid, and lowest ask of multiple markets.
Parameters
markets
address[] calldata
List of market addresses
Return Values
mids
uint256[] memory
Mid prices
highestBids
uint256[] memory
Prices of the highest buy order
lowestAsks
uint256[] memory
Prices of the lowest sell order
getOrderSizes
getOrderSizes
function getOrderSizes(uint256[] calldata orderData, address[] calldata markets) external view returns (uint256[] memory sizes)
Batch queries individual order sizes from markets.
Parameters
orderData
uint256[] calldata
The first 16 bytes represent the order price while the last 16 bytes represent the order id
markets
address[] calldata
List of market addresses
Return Values
sizes
uint256[] memory
List consisting of the size of each order
Last updated