CrystalDataHelper

The data helper contract is used to help the front-end query necessary information.

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

Name
Type
Description

account

address

Address to query token balance of

token

address

Token address

Return Values

Name
Type
Description

balance

uint256

The addresses' balance of the specified token.

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

Name
Type
Description

market

address

Market address

Return Values

Name
Type
Description

price

uint256

The mid price

_highestBid

uint256

The price of the highest buy order

_lowestAsk

uint256

The price of the lowest sell order

batchBalanceOf

function batchBalanceOf(address account, address[] calldata tokens) external view returns (uint256[] memory returnData)

Retrieves the balances of multiple tokens for an address.

Parameters

Name
Type
Description

account

address

Address to query token balance of

tokens

address[] calldata

Array of token addresses

Return Values

Name
Type
Description

returnData

uint256[] memory

List consisting of the addresses' balance of each token.

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

Name
Type
Description

markets

address[] calldata

List of market addresses

Return Values

Name
Type
Description

mids

uint256[] memory

Mid prices

highestBids

uint256[] memory

Prices of the highest buy order

lowestAsks

uint256[] memory

Prices of the lowest sell order

getOrderSizes

function getOrderSizes(uint256[] calldata orderData, address[] calldata markets) external view returns (uint256[] memory sizes)

Batch queries individual order sizes from markets.

Parameters

Name
Type
Description

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

Name
Type
Description

sizes

uint256[] memory

List consisting of the size of each order

Last updated