LiquidityConversionRates

You are referring to the Legacy version of KyberSwap docs.

For the most updated information, please refer to:

contract LiquidityConversionRates

is ConversionRatesInterface, LiquidityFormula, Withdrawable, Utils\ imports ConversionRatesInterface, LiquidityFormula, Withdrawable, Utils

Source: LiquidityConversionRates.sol

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

LiquidityParamsSet

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 |

ReserveAddressSet

Event for logging the setting of the reserve contract address.


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

CollectedFeesReset

Event for logging of the resetting of the fees collected.


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

Functions

LiquidityConversionRates

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);

Code snippet reference: broadcastTx()

getRate

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

resetCollectedFees

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


function resetCollectedFees() public onlyAdmin Modifiers: onlyAdmin

setLiquidityParams

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


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: onlyAdmin

setReserveAddress

Sets the reserve contract address. Only admin can invoke.


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

Last updated

#477: Elastic fee tier and token launches

Change request updated