KyberSwap Docs
  • Introduction to KyberSwap
  • Getting Started
    • Quickstart
      • FAQ
    • Supported Exchanges And Networks
    • Foundational Topics
      • Decentralized Finance
        • Tokens
        • Stablecoins
        • DEX/DeFi Aggregator
        • Slippage
        • Price Impact
        • Zap
        • Maximal Extractable Value (MEV)
      • Decentralized Technologies
        • Wallets
        • Dapps
        • RPC
        • Oracles
        • On-Chain vs Off-Chain Data
      • Other Valuable Resources
  • KyberSwap Solutions
    • KyberSwap Interface
      • User Guides
        • Connect Your Wallet
        • Switching Networks
        • Instantly Swap At Superior Rates
        • Swap At Your Preferred Rates
        • Add Your Favourite Tokens
        • Get Crypto With Fiat
        • Bridge Your Assets Across Multiple Chains
        • Swap Between Different Tokens Across Chains
      • Profiles
        • Profile Creation
        • Profile Customization
        • Sync Profile Across Devices
      • Notifications
        • Notification Center
    • KyberSwap Aggregator
      • Concepts
        • Dynamic Trade Routing
      • User Guides
        • Instantly Swap At Superior Rates
      • Developer Guides
        • Execute A Swap With The Aggregator API
        • Upgrading To APIv1
      • Aggregator API Specification
        • EVM Swaps
        • Permit
      • Contracts
        • Aggregator Contract Addresses
      • DEX IDs
      • Subgraphs
      • FAQ
    • KyberSwap Zap as a Service
      • KyberSwap Zap as a Service (ZaaS) API
        • ZaaS HTTP API
        • ZaaS GRPC API
      • KyberSwap Zap Liquidity Widget
      • Zap Fee Model
      • Zap's Supported Chains/Dexes
      • Zap's Deployed Contract Addresses
      • Zap's DEX IDs
    • KyberSwap Widget
      • Developer Guides
        • Integrating The KyberSwap Widget
        • Customizing The KyberSwap Widget
      • iFrame Alternative
      • Widget/iFrame Fee
    • KyberSwap Liquidity Widget
      • Integrating The KyberSwap Liquidity Widget
    • Limit Order
      • Concepts
        • Off-Chain Relay, On-Chain Settlement
        • Gasless Cancellation
      • User Guides
        • Swap At Your Preferred Rates
        • Update Limit Orders
        • Cancel Limit Orders
      • Developer Guides
        • Create Limit Order
        • Gasless Cancel
        • Hard Cancel
        • Fill Limit Order
      • Contracts
        • Limit Order Contract Addresses
      • Limit Order API Specification
        • General APIs
        • Maker APIs
        • Taker APIs
      • FAQ
    • KyberSwap OnChain Price Service
    • Fee Schedule
  • Governance
    • KyberDAO
      • User Guides
        • Participating in KyberDAO
        • Staking
        • Voting
        • Stake KNC And Enjoy Gas Savings
      • Fees to KyberDAO
      • KyberDAO Operator MultiSig
      • Contracts
        • KyberDAO Contract Repo
        • KyberDAO Contract Addresses
      • FAQ - Others
    • KNC Token
      • KNC Tokenomics & Utility
      • Gas Refund Program
      • KNC Contract Addresses
  • Security
    • Audits
  • Reference
    • Legacy
      • KyberSwap Classic
        • Concepts
          • Programmable Pricing Curves
          • Dynamic Auto-Adjusting Fees
          • Virtual Balances
          • Protocol Fees
        • Contracts
          • Classic Contract Repo
          • Classic Contract Addresses
          • Classic Contract Farming Addresses
      • KyberSwap Elastic
        • Concepts
          • Concentrated Liquidity
          • Reinvestment Curve
          • Tick-Range Mechanism
          • Pool Process Flows
          • Anti-Sniping Mechanism
          • Tick-Based Farming
          • Elastic Zap
          • TWAP Oracle
          • Elastic APR Calculations
        • Contracts
          • Elastic Contract Repo
          • Elastic Contract Addresses
          • Elastic Farming Contract Addresses
          • Elastic Zap Contract Addresses
          • Elastic Core Contracts
          • Elastic Core Libraries
          • Elastic Periphery Core Contracts
          • Elastic Peripheral Library Contracts
          • Elastic Peripheral Base Contracts
        • Subgraphs
      • Whitepapers
      • Audits
      • KyberAI
        • KyberScore
        • Concepts
        • On-Chain Indicators
          • Number Of Trades
          • Trading Volume
          • Netflow To Whale Wallets
          • Netflow To CEX
          • Number Of Transfers
          • Volume Of Transfers
          • Number Of Holders
          • Top Holders
        • Technical Indicators
          • Live Charts
          • Support & Resistance Levels
          • Live Trades
          • Funding Rate On CEX
          • Liquidations On CEX
        • Liquidity Analysis
      • Elastic Legacy
        • Elastic Legacy Contract Repo
        • Elastic Legacy Contract Addresses
        • Elastic Legacy Farming Contract Addresses
        • Remove Elastic Legacy Liquidity
      • Protocol
        • Overview
        • Smart Contract Architecture
        • Trust and Security Model
      • Integrations
        • Getting Started
        • Use Cases
        • Integration Types
        • Smart Contracts
        • Ethers JS
        • RESTful API
        • Slippage Rate Protection
        • Price Feed Security
        • Contract Events
        • Platform Fees
      • Reserves
        • Getting Started
          • Overview
          • Why Develop On Kyber
          • Create New Reserve
          • Existing Reserves
          • Customising Existing Reserves
        • Development Guides
          • Fed Price Reserve
          • Automated Price Reserve
          • Reserves with Ganache
          • Orderbook Reserve
        • Operations
          • Listing Policies
          • Reserve IDs
          • Reserve Rebates
          • Sanity Rates
      • Addresses
        • Introduction
        • Mainnet
        • Kovan
        • Rinkeby
        • Ropsten
      • API/ABI
        • Introduction
        • RESTful API
          • RESTful API Overview
          • RESTful API
        • Core Smart Contracts
          • IKyberNetworkProxy
          • KyberNetworkProxy
          • IKyberNetwork
          • ISimpleKyberProxy
          • IKyberMatchingEngine
          • KyberMatchingEngine
          • IKyberHint
          • KyberHintHandler
          • IKyberHintHandler
          • IKyberFeeHandler
          • IKyberStaking
          • KyberStaking
          • IKyberDao
          • KyberDao
          • IKyberStorage
          • KyberStorage
          • IKyberHistory
          • KyberHistory
          • IKyberReserve
          • KyberReserve
          • ConversionRates
          • LiquidityConversionRates
          • EpochUtils
          • IEpochUtils
          • KyberFeeHandler
        • Contract ABIs
          • ABIs
        • Code Snippets
          • Token Quantity Conversion
        • Misc Contracts
          • KyberNetwork
          • ConversionRatesInterface
          • PermissionGroups
          • SanityRates
          • Withdrawable
          • OrderbookReserveInterface
          • OrderbookReserveLister
    • KyberSwap Operator MultiSig
    • Permitable Tokens
    • Third-Party Integrations
    • KyberSwap Analytics
    • KyberSwap App
    • GitHub
    • KyberSwap Analytics
    • KyberSwap Blog
    • Kyber Network Press Kit
  • Socials
    • X
    • Discord
    • Telegram
    • LinkedIn
    • Reddit
    • Instagram
    • Tik Tok
  • Support
    • KyberSwap Help Center
    • Complaints Handling Process
Powered by GitBook
On this page
  • contract ConversionRates
  • INDEX​
  • REFERENCE​

Was this helpful?

  1. Reference
  2. Legacy
  3. API/ABI
  4. Core Smart Contracts

ConversionRates

PreviousKyberReserveNextLiquidityConversionRates

Last updated 2 years ago

Was this helpful?

You are referring to the Legacy version of KyberSwap docs.

For the most updated information, please refer to:

contract ConversionRates

is , VolumeImbalanceRecorder, Utils\ imports ERC20Interface, VolumeImbalanceRecorder, , Utils

Source:

The ConversionRates contract's role is to allow reserve operators to make simple on-chain adjustment to the prices and is an optimized cheap (w.r.t gas consumption) interface to enter rate feeds.


INDEX

<AUTOGENERATED_TABLE_OF_CONTENTS>

REFERENCE

Structs

Property
Type
Description

x

int[]

Quantity for each step. Includes previous steps

y

int[]

Rate change per quantity step in bps

\

Property
Type
Description

listed

bool

true if added to reserve, false otherwise

enabled

bool

true if trades are enabled, false otherwise

compactDataArrayIndex

uint

Token position in compact data

compactDataFieldIndex

uint

Token position in compact data

baseBuyRate

uint

Base buy rate of token

baseSellRate

uint

Base sell rate of token

buyRateQtyStepFunction

StepFunction

source ERC20 token balance of user

sellRateQtyStepFunction

StepFunction

destination ERC20 token balance of user

buyRateImbalanceStepFunction

StepFunction

source ERC20 token balance of user

sellRateImbalanceStepFunction

StepFunction

destination ERC20 token balance of user

\

Contract constructor. Note that constructor methods are called exactly once during contract instantiation and cannot be called again.


function ConversionRates(address _admin) public | Parameter | Type | Description | | ----------|:-------:|:----------------------:| | _admin | address | admin's wallet address |


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');

const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
const input = fs.readFileSync('ConversionRates.sol', 'utf8');
const output = await solc.compile(input, 1);
const bytecode = output.contracts['ConversionRates'].bytecode;
const abi = JSON.parse(output.contracts['ConversionRates'].interface);

const ConversionRates = new web3.eth.Contract(JSON.parse(abi));
const _admin = '<ADMIN ADDRESS>';

const deploy = ConversionRates.deploy({
  data: `0x${bytecode}`,
  arguments: [_admin],
});

broadcastTx(deploy);

Adding an ERC20 token which the reserve will support. Only admin can invoke.



Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const token = '0xdd974D5C2e2928deA5F71b9825b8b646686BD200'; // KNC
transactionData = ConversionRates.methods.addToken(token).encodeABI();

txReceipt = await web3.eth.sendTransaction({
  from: ADMIN_ADDRESS,
  to: CONVERSION_RATES_ADDRESS,
  data: transactionData,
});

\

Disables the reserve token from trades. Only alerter can invoke.



Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const token = '0xdd974D5C2e2928deA5F71b9825b8b646686BD200'; // KNC
transactionData = ConversionRates.methods.disableTokenTrade(token).encodeABI();

txReceipt = await web3.eth.sendTransaction({
  from: ALERTER_ADDRESS,
  to: CONVERSION_RATES_ADDRESS,
  data: transactionData,
});

\

Enables the reserve token to be traded. Only admin can invoke.



Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const token = '0xdd974D5C2e2928deA5F71b9825b8b646686BD200'; // KNC
transactionData = ConversionRates.methods.enableTokenTrade(token).encodeABI();

txReceipt = await web3.eth.sendTransaction({
  from: ADMIN_ADDRESS,
  to: CONVERSION_RATES_ADDRESS,
  data: transactionData,
});

\

To obtain the base buy or sell rate of a token.


function getBasicRate(ERC20 token, bool buy) public view returns (uint) | Parameter | Type | Description | | ----------|:-----:|:-------------------------------------------------------------------:| | token | ERC20 | ERC20 token contract address | | buy | bool | true to get the buy rate, otherwise false to get the sell rate | Returns:\ Base buy or sell rate of a token in wei amount


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const token = '0xdd974D5C2e2928deA5F71b9825b8b646686BD200'; // KNC
const buy = true;
result = await ConversionRates.methods.getBasicRate(token, buy).call();

\

To obtain the basis points (bps) adjustments of a token.


function getCompactData(ERC20 token) public view returns (uint, uint, byte, byte) | Parameter | Type | Description | | ----------|:-----:|:----------------------------:| | token | ERC20 | ERC20 token contract address | Returns:

  1. Array index of token

  2. fieldOffset of token

  3. bps adjustment to base buy rate of token

  4. bps adjustment to base sell rate of token


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const token = '0xdd974D5C2e2928deA5F71b9825b8b646686BD200'; // KNC
const result = await ConversionRates.methods.getCompactData(token).call();

let arrayIndex = result[0];
let fieldOffset = result[1];
let buyRateBPS = result[2];
let sellRateBPS = result[3];

\

Obtain a list of supported reserve tokens.


function getListedTokens() public view returns (ERC20[])


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

result = await ConversionRates.methods.getListedTokens().call();

\

To obtain the adjusted buy or sell rate of a token.


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 | to see if rates' adjustments are applicable on this ETH block number | | buy | bool | true to get the buy rate, otherwise false to get the sell rate | | qty | uint | token quantity | Returns:\ Adjusted buy or sell rate of a token in wei amount


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const token = '0xdd974D5C2e2928deA5F71b9825b8b646686BD200'; // KNC
const currentBlockNumber = 5878441;
const buy = true;
const qty = new web3.utils.BN('100000000000000000000');
result = await ConversionRates.methods
  .getRate(token, currentBlockNumber, buy, qty)
  .call();

\

To obtain the block number for which the basis points (bps) adjustments are valid from.


function getRateUpdateBlock(ERC20 token) public view returns (uint) | Parameter | Type | Description | | ----------|:-----:|:----------------------------:| | token | ERC20 | ERC20 token contract address | Returns:\ Block number for which the basis points (bps) adjustments are valid from


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const token = '0xdd974D5C2e2928deA5F71b9825b8b646686BD200'; // KNC
blockNumber = await ConversionRates.methods.getRateUpdateBlock(token).call();

\

To obtain data of the step function of a token.


function getStepFunctionData(ERC20 token, uint command, uint param) public view returns (int) | Parameter | Type | Description | | ----------|:-----:|:-------------------------------------:| | token | ERC20 | ERC20 token contract address | | command | uint | number within 0 to 15 inclusive | | param | uint | index of step function data to obtain |

Returns:\ Dependent on command

To determine what inputs to use, it is best to refer the solidity code below.

function getStepFunctionData(ERC20 token, uint command, uint param) public view returns(int) {
        if (command == 0) return int(tokenData[token].buyRateQtyStepFunction.x.length);
        if (command == 1) return tokenData[token].buyRateQtyStepFunction.x[param];
        if (command == 2) return int(tokenData[token].buyRateQtyStepFunction.y.length);
        if (command == 3) return tokenData[token].buyRateQtyStepFunction.y[param];

        if (command == 4) return int(tokenData[token].sellRateQtyStepFunction.x.length);
        if (command == 5) return tokenData[token].sellRateQtyStepFunction.x[param];
        if (command == 6) return int(tokenData[token].sellRateQtyStepFunction.y.length);
        if (command == 7) return tokenData[token].sellRateQtyStepFunction.y[param];

        if (command == 8) return int(tokenData[token].buyRateImbalanceStepFunction.x.length);
        if (command == 9) return tokenData[token].buyRateImbalanceStepFunction.x[param];
        if (command == 10) return int(tokenData[token].buyRateImbalanceStepFunction.y.length);
        if (command == 11) return tokenData[token].buyRateImbalanceStepFunction.y[param];

        if (command == 12) return int(tokenData[token].sellRateImbalanceStepFunction.x.length);
        if (command == 13) return tokenData[token].sellRateImbalanceStepFunction.x[param];
        if (command == 14) return int(tokenData[token].sellRateImbalanceStepFunction.y.length);
        if (command == 15) return tokenData[token].sellRateImbalanceStepFunction.y[param];

        revert();
    }

Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

result = await ConversionRates.methods
  .getStepFunctionData(
    '0xdd974D5C2e2928deA5F71b9825b8b646686BD200', //ERC20 token: KNC
    0, //uint command
    0, //uint param
  )
  .call();

let buyRateQtyStepFunctionLength = result[0];

\

To obtain the basic information of a token


function getTokenBasicData(ERC20 token) public view returns (bool, bool) | Parameter | Type | Description | | -----------------|:------------------------:|:--------------------------------:| | token | ERC20 | Token contract address | Returns:

  1. Whether a token is listed

  2. Whether a token is enabled


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

result = await ConversionRates.methods
  .getTokenBasicData(
    '0xdd974D5C2e2928deA5F71b9825b8b646686BD200', //ERC20 token: KNC
  )
  .call();

let tokenListed = result[0];
let tokenEnabled = result[1];

\

To record the imbalance of a reserve token after a trade was executed. The reserve contract usually invokes this.


function recordImbalance(ERC20 token, int buyAmount, uint rateUpdateBlock, uint currentBlock) public | Parameter | Type | Description | | ------------------|:------:|:-----------------------------------------------:| | token | ERC20 | Token contract address | | buyAmount | int | Token wei amount bought or sold | | rateUpdateBlock | uint | block number for which the rates are valid from | | currentBlock | uint | block number for which trade was executed |\



Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const tokens = [
  '0xdd974D5C2e2928deA5F71b9825b8b646686BD200', // KNC
  '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07', // OMG
];
const baseBuy = [500000000000000000000, 600000000000000000000];
const baseSell = [1820000000000000, 1920000000000000];
const buy = [0x190a];
const sell = [0x190a];
const blockNumber = 5878441;
const indices = [0];

transactionData = ConversionRates.methods
  .setBaseRate(tokens, baseBuy, baseSell, buy, sell, blockNumber, indices)
  .encodeABI();

txReceipt = await web3.eth.sendTransaction({
  from: OPERATOR_ADDRESS,
  to: CONVERSION_RATES_ADDRESS,
  data: transactionData,
});

\



Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

const buy = [0x190ae2];
const sell = [0x39698e];
const blockNumber = 5878441;
const indices = [0];

transactionData = ConversionRates.methods
  .setCompactData(buy, sell, blockNumber, indices)
  .encodeABI();

txReceipt = await web3.eth.sendTransaction({
  from: OPERATOR_ADDRESS,
  to: CONVERSION_RATES_ADDRESS,
  data: transactionData,
});

\

Set adjustments for tokens' buy and sell rates depending on the size of a buy / sell order. Only operator can invoke.


  • Buy steps (xBuy) are used to change ASK prices, sell steps (xSell) are used to change BID prices

  • When yBuy and ySell numbers are non-positive (< 0) they will modify the rate to be lower, meaning the rate will be reduced by the Y-value set in each step. So negative steps mean worse rates for the user. Setting positive step values will give user better rates and could be considered as an advanced method to encourage users to "re balance" the inventory.


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

ConversionRates.methods
  .setQtyStepFunction(
    '0xdd974D5C2e2928deA5F71b9825b8b646686BD200', //KNC
    [
      100000000000000000000, 200000000000000000000, 300000000000000000000,
      5000000000000000000000,
    ], //uint[] xBuy
    [0, -30, -60, -80], //uint[] yBuy
    [
      100000000000000000000, 200000000000000000000, 300000000000000000000,
      5000000000000000000000,
    ], //uint[] xSell
    [0, -30, -60, -80], //uint[] ySell
  )
  .send(
    {
      from: fromAddress,
    },
    (err, res) => {
      console.log(`Err: ${err}`);
      console.log(`Res: ${res}`);
    },
  );

\

Set the minimalRecordResolution, maxPerBlockImbalance and maxTotalImbalance of an ERC20 token


\

Set adjustments for tokens' buy and sell rates depending on the net traded amounts. Only operator can invoke.


  • Buy steps (xBuy) are used to change ASK prices, sell steps (xSell) are used to change BID prices

  • yBuy and ySell numbers should always be non-positive (<=0) because the smart contract reduces the output amount by the Y-value set in each step.


Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

ConversionRates.methods
  .setImbalanceStepFunction(
    '0xdd974D5C2e2928deA5F71b9825b8b646686BD200', //ERC20 token: KNC
    [
      100000000000000000000, 200000000000000000000, 300000000000000000000,
      5000000000000000000000,
    ], //uint[] xBuy
    [0, -30, -60, -80], //uint[] yBuy
    [-300000000000000000000, -200000000000000000000, -100000000000000000000, 0], //uint[] xSell
    [-70, -50, -25, 0], //uint[] ySell
  )
  .send(
    {
      from: fromAddress,
    },
    (err, res) => {
      console.log(`Err: ${err}`);
      console.log(`Res: ${res}`);
    },
  );

\

Set the duration (in blocks) for which the rates will be valid for. Only admin can invoke.



Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

ConversionRates.methods
  .setValidRateDurationInBlocks(
    24, //uint duration
  )
  .send(
    {
      from: fromAddress,
    },
    (err, res) => {
      console.log(`Err: ${err}`);
      console.log(`Res: ${res}`);
    },
  );

\

Set / change the reserve contract address. Only admin can invoke.



Web3 Example:

// DISCLAIMER: Code snippets in this guide are just examples and you
// should always do your own testing. If you have questions, visit our
// https://t.me/KyberDeveloper.

ConversionRates.methods
  .setReserveAddress(
    '0x63825c174ab367968EC60f061753D3bbD36A0D8F', //Eg. KyberReserve contract address
  )
  .send(
    {
      from: fromAddress,
    },
    (err, res) => {
      console.log(`Err: ${err}`);
      console.log(`Res: ${res}`);
    },
  );

StepFunction

TokenData

Functions

ConversionRates

Code snippet reference: \

addToken

function addToken(ERC20 token) public onlyAdmin | Parameter | Type | Description | | ----------|:-----:|:----------------------------:| | token | ERC20 | ERC20 token contract address | Modifiers:

disableTokenTrade

function disableTokenTrade(ERC20 token) public onlyAlerter | Parameter | Type | Description | | ----------|:-----:|:-------------------------------------------:| | token | ERC20 | ERC20 token contract address to be disabled | Modifiers:

enableTokenTrade

function enableTokenTrade(ERC20 token) public onlyAdmin | Parameter | Type | Description | | ----------|:-----:|:------------------------------------------:| | token | ERC20 | ERC20 token contract address to be enabled | Modifiers:

getBasicRate

getCompactData

getListedTokens

getRate

getRateUpdateBlock

getStepFunctionData

getTokenBasicData

recordImbalance

setBaseRate

Set tokens' base buy and sell rates, and optional adjustments to these rates. Only operator can invoke. Refer to on how to use this function.

function setBaseRate(ERC20[] tokens, uint[] baseBuy, uint[] baseSell, bytes14[] buy, bytes14[] sell, uint blockNumber, uint[] indices) public onlyOperator | Parameter | Type | Description | | --------------|:---------:|:-----------------------------------------------------------:| | tokens | ERC20[] | array of token contract addresses to set the base rates for | | baseBuy | uint[] | array of token buy rates in wei amount | | baseSell | uint[] | array of token sell rates in wei amount | | buy | bytes14[] | compact data representation of basis points (bps) to adjust tokens' buy rates. 1bps = 0.01% | | sell | bytes14[] | Compact data representation of basis points (bps) to adjust tokens' sell rates. 1bps = 0.01% | | blockNumber | uint | ETH block number for which the adjustments are valid from | | indices | uint[] | array of indexes to apply bps adjustments on | Modifiers:

setCompactData

Setting minor adjustments in basis points (bps) to tokens' buy and sell rates. 1bps = 0.01%. Only operator can invoke. Refer to on how to use this function.

function setCompactData(bytes14[] buy, bytes14[] sell, uint blockNumber, uint[] indices) public onlyOperator | Parameter | Type | Description | | --------------|:---------:|:--------------------------------------------------------------:| | buy | bytes14[] | basis points to adjust tokens' buy rates | | sell | bytes14[] | basis points to adjust tokens' sell rates | | blockNumber | uint | ETH block number for which the adjustment rates are valid from | | indices | uint[] | array of indexes to apply the buy / sell rate adjustments on | Modifiers:

setQtyStepFunction

function setQtyStepFunction(ERC20 token, int[] xBuy, int[] yBuy, int[] xSell, int[] ySell) public onlyOperator | Parameter | Type | Description | | -----------------|:------------------------:|:--------------------------------:| | token | ERC20 | token contract address to set the base rates for | | xBuy | int[] | array of buy steps in wei amount | | yBuy | int[] | impact on buy rate in basis points (bps). 1 bps = 0.01% Eg. -30 = -0.3% | | xSell | int[] | array of sell steps in wei amount | | ySell | int[] | impact on sell rate in basis points (bps). 1 bps = 0.01% Eg. -30 = -0.3% | Modifiers:

setTokenControlInfo

function setTokenControlInfo(ERC20 token, uint minimalRecordResolution, uint maxPerBlockImbalance, uint maxTotalImbalance) public onlyAdmin | Parameter | Type | Description | | ------------------------- |:-----:|:----------------------------:| | token | ERC20 | ERC20 token contract address | | minimalRecordResolution | uint | minimum denominator in token wei that can be changed | | maxPerBlockImbalance | uint | maximum wei amount of net absolute (+/-) change for a token in an ethereum block | | maxTotalImbalance | uint | wei amount of the maximum net token change allowable that happens between 2 price updates | Modifiers: \ Returns:\ Data comprising minimalRecordResolution, maxPerBlockImbalance, and maxTotalImbalance

setImbalanceStepFunction

function setImbalanceStepFunction(ERC20 token, int[] xBuy, int[] yBuy, int[] xSell, int[] ySell) public onlyOperator | Parameter | Type | Description | | -----------------|:------------------------:|:--------------------------------:| | token | ERC20 | token contract address to set the base rates for | | xBuy | int[] | array of buy steps in wei amount | | yBuy | int[] | impact on buy rate in basis points (bps). 1 bps = 0.01% Eg. -30 = -0.3% | | xSell | int[] | array of sell steps in wei amount | | ySell | int[] | impact on sell rate in basis points (bps). 1 bps = 0.01% Eg. -30 = -0.3% | Modifiers:

setValidRateDurationInBlocks

function setValidRateDurationInBlocks(uint duration) public onlyAdmin | Parameter | Type | Description | | -----------------|:------------------------:|:--------------------------------:| | duration | uint | Number of blocks for which the rates will be valid | Modifiers:

setReserveAddress

function setReserveAddress(address reserve) public onlyAdmin | Parameter | Type | Description | | -----------------|:------------------------:|:--------------------------------:| | reserve | address | reserve contract address | Modifiers:

Classic
Elastic
Limit Order
Aggregator
ConversionRatesInterface
ConversionRatesInterface
ConversionRates.sol
​
​
​
​
​
​
​
broadcastTx()
​
onlyAdmin
​
onlyAlerter
​
onlyAdmin
​
​
​
​
​
​
​
​
​
this guide
onlyOperator
​
this guide
onlyOperator
​
onlyOperator
​
onlyAdmin
​
onlyOperator
​
onlyAdmin
​
onlyAdmin