Methods

Token Operations

total_supply

Returns the total supply of a specified token

Input:

token: The contract address of the token

Output:

Total supply as an unsigned 256-bit integer

balanceOf

Retrieves the balance of a specific address for a given token

Inputs:

  • address: The address where the balance is to be retrieved

  • token: The contract address of the token

Output:

Balance as an unsigned 256-bit integer

balancesOf

Obtains the balances of multiple addresses and tokens.

Inputs:

  • addresses: An array of addresses

  • tokens: An array of token contract addresses

Output:

2D array of balances.

Contract Utilities

get_wrapped_native_token

Returns the contract address of the wrapped native token used in the contract, which is used by default for gas payments

get_latest_gas_price

Fetches the latest gas price used in the contract. This contract property gets updated on each rollup performed

Output:

Gas price as an unsigned 256-bit integer

get_fee_recipient

Retrieves the contract address of the fee recipient in the contract both for gas fees and trade fees (maker and taker fixed fees)

Nonce Operations

get_nonce and get_nonces

Retrieves the nonce value for a given address (maker)

Inputs:

maker: Address for get_nonce; makers: array of addresses for get_nonces

Output:

Nonce value(s) for inputted address(s)

apply_increase_nonce

Applies an increase to the nonce value for a specific maker. This can be performed only by whitelisted addresses that are responsible for executing rollups

Inputs:

  • signed_nonce: The signed new nonce values for specified makers

  • gas_price: The actual gas price at the time of transaction

Router Operations

get_router

Returns the contract address of the Router associated with a given signer.

Input:

signer: The address of the signer.

get_route_amount

Retrieves the amount associated with routing.

Output:

Amount as an unsigned 256-bit integer.

router_deposit

Enables a Router to deposit a specified amount of a specific coin into the contract.

Inputs:

  • router: The address of the Router receiver of the deposit.

  • amount: The amount of the coin being deposited.

  • coin_address: The contract address of the coin.

router_withdraw

Allows a Router to withdraw a specified amount of a specific coin from the contract to a receiver's address.

Inputs:

  • amount: The amount of the coin to withdraw.

  • coin_address: The address of the coin.

  • receiver_address: The address of the receiver.

register_router

Registers a Router in the contract

add_router_binding

Manages Router bindings

  • add_router_binding: Binds a new signer to a Router

  • Binds caller (Router) to signer_address

Inputs:

  • signer_address: The address of the signer

validate_router

Validates that a message was signed by a signer associated with a specific Router.

Inputs:

  • message: The message to validate.

  • signature: The message signature

  • signer: The address of the signer.

  • router: The Router associated with signer.

get_punishment_factor_bips

Retrieves the punishment factor in basis points (bps) used in the contract.

is_registered

Checks if a Router is registered in the contract.

Input:

router: The address of the Router.

have_sufficient_amount_to_route

Verifies if a Router has sufficient funds to perform routing.

Input:

router: The address of the router.

balance_of_router

Retrieves the balance of a Router for a specific coin

Inputs:

  • router: The address of the Router.

  • coin: The address of the coin.

Trade Information

get_ecosystem_trade_info

Provides information on order fill info trades.

Output: Details like the amount filled, last traded price, and number of trades that have happened.

Withdrawal Operations

get_pending_withdraw

Retrieves information about pending withdrawals.

Inputs:

  • maker: The address of the user for whom the pending withdrawal information is requested.

  • token: The address of the token

Output:

  • Returns details of the pending withdrawal, typically including the amount of the withdrawal, the token address, and the status of the withdrawal request.

request_onchain_withdraw and apply_onchain_withdraw

Handles the on-chain withdrawal process.

  • request_onchain_withdraw: Initiates a withdrawal request.

  • apply_onchain_withdraw: Executes the withdrawal.

Inputs:

withdraw: Details of the withdrawal request.

Signer Operations

bind_to_signer

Binds a caller contract address to a signer.

Inputs:

signer: The address of the signer.

check_sign

Validates that a given message was correctly signed by the trader's signer.

Inputs:

  • trader: The address of the trader.

  • message: The message to validate.

  • signature.

get_signer and get_signers

Returns the signer address for a given trader.

  • get_signer: For a single trader.

  • get_signers: For multiple traders.

Inputs:

trader: The address of the trader.

Miscellaneous Operations

deposit

Allows depositing a specified amount of a token to a receiver's address.

Inputs:

  • amount: The amount to deposit.

  • token: The address of the token.

  • receiver: The address of the receiver.

apply_withdraw

Executes a withdrawal based on a signed withdrawal request and the current gas price. (for Exchange's internal use)

Inputs:

  • withdraw_request: The signed withdrawal request

  • gas_price: The current gas price

apply_ecosystem_trades and apply_single_exetuion_step(s)

Execute ecosystem and router trades respectively (for Exchange's internal use)

Inputs:

  • apply_ecosystem_trades: Handles an array of ecosystem trades.

  • apply_router_trade: Deals with individual trades associated with a single taker order

  • apply_router_trades: same as previous but bulk

Last updated