# Methods

### Token Operations

| `total_supply` | <p>Returns the total supply of a specified token</p><p></p><p><strong>Input</strong>: </p><p><code>token</code>: The contract address of the token</p><p></p><p><strong>Output</strong>: </p><p>Total supply as an unsigned 256-bit integer</p>                                                                                               |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `balanceOf`    | <p>Retrieves the balance of a specific address for a given token</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>address</code>: The address where the balance is to be retrieved</li><li><code>token</code>: The contract address of the token</li></ul><p><strong>Output</strong>: </p><p>Balance as an unsigned 256-bit integer</p> |
| `balancesOf`   | <p>Obtains the balances of multiple addresses and tokens.</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>addresses</code>: An array of addresses</li><li><code>tokens</code>: An array of token contract addresses</li></ul><p><strong>Output</strong>: </p><p>2D array of balances.</p>                                              |

### Contract Utilities

<table data-header-hidden><thead><tr><th width="222"></th><th></th></tr></thead><tbody><tr><td><code>get_wrapped_native_token</code></td><td>Returns the contract address of the wrapped native token used in the contract, which is used by default for gas payments</td></tr><tr><td><code>get_latest_gas_price</code></td><td><p>Fetches the latest gas price used in the contract. This contract property gets updated on each rollup performed</p><p></p><p><strong>Output</strong>: </p><p>Gas price as an unsigned 256-bit integer</p></td></tr><tr><td><code>get_fee_recipient</code></td><td>Retrieves the contract address of the fee recipient in the contract both for gas fees and trade fees (maker and taker fixed fees)</td></tr></tbody></table>

### Nonce Operations

| `get_nonce` and `get_nonces` | <p>Retrieves the nonce value for a given address (maker)</p><p></p><p><strong>Inputs</strong>:</p><p><code>maker</code>: Address for <code>get\_nonce</code>; <code>makers</code>: array of addresses for <code>get\_nonces</code></p><p></p><p><strong>Output</strong>: </p><p>Nonce value(s) for inputted address(s)</p>                                                              |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apply_increase_nonce`       | <p>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</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>signed\_nonce</code>: The signed new nonce values for specified makers</li><li><code>gas\_price</code>: The actual gas price at the time of transaction</li></ul> |

### Router Operations

| `get_router`                      | <p>Returns the contract address of the Router associated with a given signer.</p><p></p><p><strong>Input</strong>:</p><p><code>signer</code>: The address of the signer.</p>                                                                                                                                                                                                  |
| --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `get_route_amount`                | <p>Retrieves the amount associated with routing.</p><p></p><p><strong>Output</strong>: </p><p>Amount as an unsigned 256-bit integer.</p>                                                                                                                                                                                                                                      |
| `router_deposit`                  | <p>Enables a Router to deposit a specified amount of a specific coin into the contract.</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>router</code>: The address of the Router receiver of the deposit.</li><li><code>amount</code>: The amount of the coin being deposited.</li><li><code>coin\_address</code>: The contract address of the coin.</li></ul><p></p>  |
| `router_withdraw`                 | <p>Allows a Router to withdraw a specified amount of a specific coin from the contract to a receiver's address.</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>amount</code>: The amount of the coin to withdraw.</li><li><code>coin\_address</code>: The address of the coin.</li><li><code>receiver\_address</code>: The address of the receiver.</li></ul>         |
| `register_router`                 | Registers a Router in the contract                                                                                                                                                                                                                                                                                                                                            |
| `add_router_binding`              | <p>Manages Router bindings</p><ul><li><code>add\_router\_binding</code>: Binds a new signer to a Router</li><li>Binds caller (Router) to signer\_address</li></ul><p><strong>Inputs</strong>:</p><ul><li><code>signer\_address</code>: The address of the signer</li></ul>                                                                                                    |
| `validate_router`                 | <p>Validates that a message was signed by a signer associated with a specific Router.</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>message</code>: The message to validate.</li><li><code>signature</code>: The message signature</li><li><code>signer</code>: The address of the signer.</li><li><code>router</code>: The Router associated with signer.</li></ul> |
| `get_punishment_factor_bips`      | Retrieves the punishment factor in basis points (bps) used in the contract.                                                                                                                                                                                                                                                                                                   |
| `is_registered`                   | <p>Checks if a Router is registered in the contract.</p><p></p><p><strong>Input</strong>:</p><p><code>router</code>: The address of the Router.</p>                                                                                                                                                                                                                           |
| `have_sufficient_amount_to_route` | <p>Verifies if a Router has sufficient funds to perform routing.</p><p></p><p><strong>Input</strong>:</p><p><code>router</code>: The address of the router.</p>                                                                                                                                                                                                               |
| `balance_of_router`               | <p>Retrieves the balance of a Router for a specific coin</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>router</code>: The address of the Router.</li><li><code>coin</code>: The address of the coin.</li></ul>                                                                                                                                                       |

### Trade Information

| `get_ecosystem_trade_info` | <p>Provides information on order fill info trades.</p><p></p><p><strong>Output</strong>: Details like the amount filled, last traded price, and number of trades that have happened.</p> |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

### Withdrawal Operations

| `get_pending_withdraw`                                  | <p>Retrieves information about pending withdrawals.</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>maker</code>: The address of the user for whom the pending withdrawal information is requested.</li><li><code>token</code>: The address of the token</li></ul><p><strong>Output</strong>:</p><ul><li>Returns details of the pending withdrawal, typically including the amount of the withdrawal, the token address, and the status of the withdrawal request.</li></ul> |
| ------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `request_onchain_withdraw` and `apply_onchain_withdraw` | <p>Handles the on-chain withdrawal process.</p><ul><li><code>request\_onchain\_withdraw</code>: Initiates a withdrawal request.</li><li><code>apply\_onchain\_withdraw</code>: Executes the withdrawal.</li></ul><p><strong>Inputs</strong>:</p><p><code>withdraw</code>: Details of the withdrawal request.</p>                                                                                                                                                                    |

### Signer Operations

| `bind_to_signer`               | <p>Binds a caller contract address to a signer.</p><p></p><p><strong>Inputs</strong>:</p><p><code>signer</code>: The address of the signer.</p>                                                                                                                                  |
| ------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `check_sign`                   | <p>Validates that a given message was correctly signed by the trader's signer.</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>trader</code>: The address of the trader.</li><li><code>message</code>: The message to validate.</li><li><code>signature</code>.</li></ul> |
| `get_signer` and `get_signers` | <p>Returns the signer address for a given trader.</p><ul><li><code>get\_signer</code>: For a single trader.</li><li><code>get\_signers</code>: For multiple traders.</li></ul><p><strong>Inputs</strong>:</p><p><code>trader</code>: The address of the trader.</p>              |

### Miscellaneous Operations

| `deposit`                                                    | <p>Allows depositing a specified amount of a token to a receiver's address.</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>amount</code>: The amount to deposit.</li><li><code>token</code>: The address of the token.</li><li><code>receiver</code>: The address of the receiver.</li></ul>                                                                                                         |
| ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `apply_withdraw`                                             | <p>Executes a withdrawal based on a signed withdrawal request and the current gas price. (for Exchange's internal use)</p><p></p><p><strong>Inputs</strong>:</p><ul><li><code>withdraw\_request</code>: The signed withdrawal request</li><li><code>gas\_price</code>: The current gas price</li></ul>                                                                                                       |
| `apply_ecosystem_trades` and `apply_single_exetuion_step(s)` | <p>Execute ecosystem and router trades respectively (for Exchange's internal use)</p><p></p><p><strong>Inputs:</strong></p><ul><li><code>apply\_ecosystem\_trades</code>: Handles an array of ecosystem trades.</li><li><code>apply\_router\_trade</code>: Deals with individual trades associated with a single taker order</li><li><code>apply\_router\_trades</code>: same as previous but bulk</li></ul> |
