# ConversionRatesInterface

{% hint style="warning" %}
You are referring to the **`Legacy`** version of KyberSwap docs.

For the most updated information, please refer to:

* [**`Classic`**](https://github.com/KyberNetwork/kyberswap-documentation/blob/main/reference/legacy/api-abi/misc-contracts/broken-reference/README.md)
* [**`Elastic`**](/reference/legacy/kyberswap-elastic.md)
* [**`Limit Order`**](/kyberswap-solutions/limit-order.md)
* [**`Aggregator`**](/kyberswap-solutions/kyberswap-aggregator.md)
  {% endhint %}

## interface ConversionRatesInterface

*Source*: [ConversionRatesInterface.sol](https://github.com/KyberNetwork/smart-contracts/blob/master/contracts/sol4/ConversionRatesInterface.sol)

***

### INDEX[​](https://docs.kyberswap.com/Legacy/api-abi/misc/api_abi-conversionratesinterface#index) <a href="#index" id="index"></a>

\<AUTOGENERATED\_TABLE\_OF\_CONTENTS>

### REFERENCE[​](https://docs.kyberswap.com/Legacy/api-abi/misc/api_abi-conversionratesinterface#reference) <a href="#reference" id="reference"></a>

#### Functions[​](https://docs.kyberswap.com/Legacy/api-abi/misc/api_abi-conversionratesinterface#functions) <a href="#functions" id="functions"></a>

#### `getRate`[​](https://docs.kyberswap.com/Legacy/api-abi/misc/api_abi-conversionratesinterface#getrate) <a href="#getrate" id="getrate"></a>

Gets the conversion rate of the ERC20 token depending on quantity at block height

***

function **getRate**(ERC20 token, uint currentBlockNumber, bool buy, uint qty) public view returns (uint) | Parameter | Type | Description | | -------------------- |:-----:|:------------------------------------------------------------------:| | `token` | ERC20 | ERC20 token contract address | | `currentBlockNumber` | uint | current block height or block number | | `buy` | bool | `true` if action is to buy, otherwise `false` if action is to sell | | `qty` | uint | wei amount of ERC20 tokens | **Returns:**\ Conversion rate of ERC20 token depending on quantity at block height\\

#### `recordImbalance`[​](https://docs.kyberswap.com/Legacy/api-abi/misc/api_abi-conversionratesinterface#recordimbalance) <a href="#recordimbalance" id="recordimbalance"></a>

Records the wei amount of net absolute (+/-) change for a token in a block

***

function **recordImbalance**(ERC20 token, int buyAmount, uint rateUpdateBlock, uint currentBlock) public | Parameter | Type | Description | | ----------------- |:-----:|:------------------------------------:| | `token` | ERC20 | ERC20 token contract address | | `buyAmount` | int | buy amount of ERC20 tokens in wei | | `rateUpdateBlock` | uint | **NOT SURE** | | `currentBlock` | uint | current block height or block number |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kyberswap.com/reference/legacy/api-abi/misc-contracts/conversionratesinterface.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
