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
        • Cross-chain Swap
        • Add Your Favourite Tokens
        • Get Crypto With Fiat
        • Bridge Your Assets Across Multiple 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 LiquidityConversionRates
  • INDEX​
  • REFERENCE​

Was this helpful?

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

LiquidityConversionRates

PreviousConversionRatesNextEpochUtils

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 LiquidityConversionRates

is , LiquidityFormula, , Utils\ imports , LiquidityFormula, , Utils

Source:

The LiquidityConversionRates contract's role is to allow reserve operators to set liquidity parameters to the automated reserve for automated rate adjustment based on trades.


INDEX

<AUTOGENERATED_TABLE_OF_CONTENTS>

REFERENCE

Events

Event for logging the setting of liquidity parameters.


event LiquidityParamsSet(uint rInFp, uint pMinInFp, uint numFpBits, uint maxCapBuyInFp, uint maxEthCapSellInFp, uint feeInBps, uint formulaPrecision, uint maxQtyInFp, uint maxBuyRateInPrecision, uint minBuyRateInPrecision, uint maxSellRateInPrecision, uint minSellRateInPrecision) | Parameter | Type | Description | | --------- |:----------------------:|:---------------------------:| | uint | rInFp | price move per 1 ETH inventory change in formula precision | | uint | pMinInFp | pMin boundary in formula precision | | uint | numFpBits | formula precision (currently 40 is recommended) | | uint | maxCapBuyInFp | allowed ETH quantity for a single buy trade in ETH | | uint | maxEthCapSellInFp | allowed ETH quantity for a single sell trade in ETH | | uint | feeInBps | fees in base points | | uint | formulaPrecision | formula precision | | uint | maxQtyInFp | max quantity in formula precision | | uint | maxBuyRateInPrecision | maximum buy rate in formula precision | | uint | minBuyRateInPrecision | minimum buy rate in formula precision | | uint | maxSellRateInPrecision | maximum sell rate in formula precision | | uint | minSellRateInPrecision | minimum sell rate in formula precision |\

Event for logging the setting of the reserve contract address.


event ReserveAddressSet(address reserve) | Parameter | Type | Description | | --------- |:--------:|:---------------------------:| | address | reserve | reserve's contract address |\

Event for logging of the resetting of the fees collected.


event CollectedFeesReset(address reserve) | Parameter | Type | Description | | --------- |:----------------:|:---------------------------:| | uint | resetFeesInTwei | resetted fees in token wei |\

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


function LiquidityConversionRates(address _admin, ERC20 _token) public | Parameter | Type | Description | | ---------- |:-------:|:----------------------------:| | _admin | address | admin's wallet address | | _token | ERC20 | ERC20 token contract 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('LiquidityConversionRates.sol', 'utf8');
const output = await solc.compile(input, 1);
const bytecode = output.contracts['LiquidityConversionRates'].bytecode;
const abi = JSON.parse(output.contracts['LiquidityConversionRates'].interface);

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

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

broadcastTx(deploy);

\

Gets the conversion rate of the token to swap.


function getRate(ERC20 conversionToken, uint currentBlockNumber, bool buy, uint qtyInSrcWei) public view returns(uint) | Parameter | Type | Description | | --------- |:------------------:|:------------------------------------------------------------------:| | ERC20 | conversionToken | source ERC20 token contract address | | uint | currentBlockNumber | current block number | | bool | buy | true to get the buy rate, otherwise false to get the sell rate | | uint | qtyInSrcWei | quantity in wei for the source token | Returns:\ Conversion rate of the source token and reserve token

\

Reset the amount of collected fees. Collected fees can be read through the state variable collectedFeesInTwei. Only admin can invoke.


\

Sets the liquidity parameters of the automated reserve. Only admin can invoke.


\

Sets the reserve contract address. Only admin can invoke.


LiquidityParamsSet

ReserveAddressSet

CollectedFeesReset

Functions

LiquidityConversionRates

Code snippet reference:

getRate

resetCollectedFees

function resetCollectedFees() public onlyAdmin Modifiers:

setLiquidityParams

function setLiquidityParams(uint _rInFp, uint _pMinInFp, uint _numFpBits, uint _maxCapBuyInWei, uint _maxCapSellInWei, uint _feeInBps, uint _maxTokenToEthRateInPrecision, uint _minTokenToEthRateInPrecision) public onlyAdmin | Parameter | Type | Description | | --------- |:-----------------------------:|:---------------------------:| | uint | _rInFp | price move per 1 ETH inventory change in formula precision | | uint | _pMinInFp | pMin boundary in formula precision | | uint | _numFpBits | formula precision (currently 40 is recommended) | | uint | _maxCapBuyInWei | maximum token quantity in wei for a single buy trade | | uint | _maxCapSellInWei | maximum token quantity in wei for a single sell trade | | uint | _feeInBps | fees in base points | | uint | _maxTokenToEthRateInPrecision | maximum allowed token to ETH rate in formula precision | | uint | _minTokenToEthRateInPrecision | minimum allowed token to ETH rate in formula precision | Modifiers:

setReserveAddress

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

Classic
Elastic
Limit Order
Aggregator
ConversionRatesInterface
Withdrawable
ConversionRatesInterface
Withdrawable
LiquidityConversionRates.sol
​
​
​
​
​
​
​
​
broadcastTx()
​
​
onlyAdmin
​
onlyAdmin
​
onlyAdmin