KyberDeveloper · Powering Liquidity for the Ecosystem

KyberDeveloper · Powering Liquidity for the Ecosystem

  • Home
  • Integrations
  • Reserves
  • KyberPRO
  • Addresses
  • API/ABI
  • Trade Debugger
  • Tracker
  • GitHub

›Misc Contracts

Getting Started

  • Introduction

RESTful API

  • RESTful API Overview
  • RESTful API

Widgets

  • Widgets Overview
  • KyberWidget
  • Sign In Widget

Core Smart Contracts

  • IKyberNetworkProxy
  • KyberNetworkProxy
  • IKyberNetwork
  • ISimpleKyberProxy
  • IKyberMatchingEngine
  • KyberMatchingEngine
  • IKyberHint
  • KyberHintHandler
  • IKyberFeeHandler
  • KyberFeeHandler
  • IKyberStaking
  • KyberStaking
  • IKyberDao
  • KyberDao
  • IKyberStorage
  • KyberStorage
  • IKyberHistory
  • KyberHistory
  • IKyberReserve
  • KyberReserve
  • ConversionRates
  • LiquidityConversionRates
  • IEpochUtils
  • EpochUtils

Contract ABIs

  • ABIs

Plugins

  • Plugins Overview
  • WooCommerce Plugin

Code Snippets

  • Token Quantity Conversion

Misc Contracts

  • KyberNetwork
  • ConversionRatesInterface
  • OrderbookReserveInterface
  • PermissionGroups
  • SanityRates
  • SanityRatesInterface
  • Withdrawable

KyberNetwork

//TODO KyberNetwork

is WithdrawableNoModifiers, Utils5, IKyberNetwork, ReentrancyGuard
imports WithdrawableNoModifiers, Utils5, ReentrancyGuard, SafeERC20, IKyberNetwork, IKyberReserve, IKyberFeeHandler, IKyberDao, IKyberMatchingEngine, IKyberStorage, IGasHelper

Source: KyberNetwork.sol


INDEX

  • EtherReceival
  • KyberFeeHandlerUpdated
  • KyberMatchingEngineUpdated
  • GasHelperUpdated
  • KyberDaoUpdated
  • KyberNetworkParamsSet
  • KyberNetworkSetEnable
  • KyberProxyAdded
  • KyberProxyRemoved
  • ListedReservesForToken
  • tradeWithHint
  • tradeWithHintAndFee
  • getExpectedRateWithHintAndFee
  • getExpectedRate
  • getNetworkData
  • getContracts
  • maxGasPrice
  • enabled

REFERENCE

Events

EtherReceival

Event logging the receival of ETH in the network contract.


event EtherReceival(address sender, uint256 amount)

ParameterTypeDescription
senderaddresssender's address
amountuint256amount of ETH received in wei

Signature: 0x75f33ed68675112c77094e7c5b073890598be1d23e27cd7f6907b4a7d98ac619


KyberFeeHandlerUpdated

Event logging the setting of the new KyberFeeHandler contract.


event KyberFeeHandlerUpdated(IKyberFeeHandler newKyberFeeHandler)

ParameterTypeDescription
newKyberFeeHandlerIKyberFeeHandlernew KyberFeeHandler contract

Signature: 0x5128fc9be01065f3cabe4c8b72796eb6b8a00284f39a2390cd71e91b509f90b6


KyberMatchingEngineUpdated

Event logging the setting of the new KyberMatchingEngine contract.


event KyberMatchingEngineUpdated(IKyberMatchingEngine newKyberMatchingEngine)

ParameterTypeDescription
newKyberMatchingEngineIKyberMatchingEngine//TODO: description

Signature: KyberMatchingEngineUpdated(IKyberMatchingEngine)


GasHelperUpdated

Event logging the setting of the new GasHelper contract.


event GasHelperUpdated(IGasHelper newGasHelper)

ParameterTypeDescription
newGasHelperIGasHelpernew GasHelper contract

Signature: 0x95ba6becebde78de944071b522d81414292f67e3d95db7d9df46bb8e8b3da8b8


KyberDaoUpdated

Event logging the setting of the new KyberDao contract.


event KyberDaoUpdated(IKyberDao newKyberDao)

ParameterTypeDescription
newKyberDaoIKyberDaonew KyberDao contract

Signature: 0x16a2e1af8449067f38aa765b54d479785c94d8ebdfbba7b410e3488b0877c1e4


KyberNetworkParamsSet

Event logging the setting of the maxGasPrice and negligibleRateDiffBps params in the network.


event KyberNetworkParamsSet(uint256 maxGasPrice, uint256 negligibleRateDiffBps)

ParameterTypeDescription
maxGasPriceuint256maximum gas price limit to prevent front running
negligibleRateDiffBpsuint256negligible rate difference in BPS

Signature: 0xc1e6729d7fd9a615adc03ebe7d8ff15649d8eed7516bf6c30538a1e722bb1975


KyberNetworkSetEnable

Event logging the enabling or disabling of trading in the network


event KyberNetworkSetEnable(bool isEnabled)

ParameterTypeDescription
isEnabledbooltrue if network is enabled, otherwise false

Signature: 0x8a846a525e22497042ee2f99423a8ff8bbb831d3ae5384692bf6040f591c1eba


KyberProxyAdded

Event logging the adding of a new proxy contract.


event KyberProxyAdded(address kyberProxy)

ParameterTypeDescription
kyberProxyaddressadded KyberNetworkProxy contract

Signature: 0x0b008ff10c7e378a96d6566635e1aa748886d16fb87659faee2aa20608fec815


KyberProxyRemoved

Event logging the removal of a proxy contract.


event KyberProxyRemoved(address kyberProxy)

ParameterTypeDescription
kyberProxyaddressremoved KyberNetworkProxy contract

Signature: 0xbb9ee888852ae070b75270fa50ea2845ba32102d3a96842c7c416d12aad2f487


ListedReservesForToken

Event logging the listing of a list of reserves for a token.


event ListedReservesForToken(IERC20 token, address[] reserves, bool add)

ParameterTypeDescription
tokenIERC20ERC20 token address
reservesaddress[]list of reserve addresses
addbooltrue if to list, false otherwise

Signature: 0xd4b0877e3beef91cd767680ac04114217ec7c9cb3a4705c03fc8061de81168fc


Functions


tradeWithHint

Makes a trade between src and dest token and send dest tokens to destAddress, with an additional hint parameter for reserve routing. Function is backwards compatible to pre-Katalyst.


function tradeWithHint(address payable trader, ERC20 src, uint256 srcAmount, ERC20 dest, address payable destAddress, uint256 maxDestAmount, uint256 minConversionRate, address payable walletId, bytes hint) external payable returns (uint256 destAmount)

ParameterTypeDescription
traderaddresstrader's address
srcERC20source ERC20 token contract address
srcAmountuint256source ERC20 token amount in its token decimals
destERC20destination ERC20 token contract address
destAddressaddressrecipient address for destination ERC20 token
maxDestAmountuint256limit on the amount of destination tokens
minConversionRateuintminimum conversion rate; trade is canceled if actual rate is lower
walletIdaddresswallet address to send part of the fees to
hintbytesfor filtering permissionless reserves

Returns:
destAmount - Amount of actual destination tokens


tradeWithHintAndFee

Executes a trade between src and dest token and send dest tokens to destAddress; includes the platform fee.


function tradeWithHintAndFee(address payable trader, IERC20 src, uint256 srcAmount, IERC20 dest, address payable destAddress, uint256 maxDestAmount, uint256 minConversionRate, address payable platformWallet, uint256 platformFeeBps, bytes hint) external payable override returns (uint256 destAmount)

ParameterTypeDescription
traderaddresstrader's address
srcIERC20source ERC20 token contract address
srcAmountuint256source ERC20 token amount in its token decimals
destIERC20destination ERC20 token contract address
destAddressaddressrecipient address for destination ERC20 token
maxDestAmountuint256limit on the amount of destination tokens
minConversionRateuint256minimum conversion rate; trade is canceled if actual rate is lower
platformWalletaddressaddress receiving the platform fee
platformFeeBpsuint256platform fee in BPS to be used in this trade
hintbyteshint in bytes for reserve routing

Returns:
destAmount - Amount of actual destination tokens in twei


getExpectedRateWithHintAndFee

Get the token conversion rate after processing the hint and includes the platform fee.


function getExpectedRateWithHintAndFee(IERC20 src, IERC20 dest, uint256 srcQty, uint256 platformFeeBps, bytes hint) external view override returns (uint256 rateWithNetworkFee, uint256 rateWithAllFees)

ParameterTypeDescription
srcIERC20source ERC20 token contract address
destIERC20destination ERC20 token contract address
srcQtyuint256source ERC20 token amount in its token decimals
platformFeeBpsuint256platform fee in BPS
hintbyteshint in bytes for reserve routing

Returns:
rateWithNetworkFee - conversion rate of the src and dest tokens after deducting the network fee. rateWithAllFees - conversion rate of the src and dest tokens after deducting the network and platform fee.


getExpectedRate

Get the token expected and worst rates. worstRate is hardcoded as 3% lower of expectedRate. Function is backwards compatible to pre-Katalyst.


function getExpectedRate(ERC20 src, ERC20 dest, uint256 srcQty) external view returns (uint256 expectedRate, uint256 worstRate)

ParameterTypeDescription
srcERC20source ERC20 token contract address
destERC20destination ERC20 token contract address
srcQtyuint256source ERC20 token amount in its token decimals

Returns:
expectedRate - rate for a trade after deducting network fee worstRate - rate for a trade, calculated to be expectedRate * 97 / 100


getNetworkData

Returns basic network data.


function getNetworkData() external view override returns (uint256 negligibleDiffBps, uint256 networkFeeBps, uint256 expiryTimestamp)
Returns:
negligibleDiffBps - neglibigle difference in BPS networkFeeBps - network fees in BPS expiryTimestamp - expiry timestamp in epoch time when the network fees will expire and need to be updated


getContracts

Returns the Kyber contracts used by the network.


function getContracts() external returns (IKyberFeeHandler kyberFeeHandlerAddress, IKyberDao kyberDaoAddress, IKyberMatchingEngine kyberMatchingEngineAddress, IKyberStorage kyberStorageAddress, IGasHelper gasHelperAddress, IKyberNetworkProxy[] kyberProxyAddresses)
Returns:
kyberFeeHandlerAddress - KyberFeeHandler contract address kyberDaoAddress - KyberDao contract address kyberMatchingEngineAddress - KyberMatchingEngine contract address kyberStorageAddress - KyberStorage contract address gasHelperAddress - GasHelper contract address kyberProxyAddresses - array of KyberNetworkProxy contract addresses


maxGasPrice

Returns the maximum gas price limit to prevent front running.


function maxGasPrice() external view override returns (uint256)
Returns:
The maximum gas price limit


enabled

Returns a boolean determining if trading is enabled on the network.


function enabled() external view override returns (bool)
Returns:
Returns true if the network is enabled for trading, otherwise false.

← Token Quantity ConversionNext →
  • INDEX
  • REFERENCE
    • Events
    • EtherReceival
    • KyberFeeHandlerUpdated
    • KyberMatchingEngineUpdated
    • GasHelperUpdated
    • KyberDaoUpdated
    • KyberNetworkParamsSet
    • KyberNetworkSetEnable
    • KyberProxyAdded
    • KyberProxyRemoved
    • ListedReservesForToken
    • Functions
    • tradeWithHint
    • tradeWithHintAndFee
    • getExpectedRateWithHintAndFee
    • getExpectedRate
    • getNetworkData
    • getContracts
    • maxGasPrice
    • enabled
KyberDeveloper · Powering Liquidity for the Ecosystem
EssentialsGetting StartedDesign PrinciplesProtocol OverviewSmart Contract Architecture
IntegrationsDAppsVendorsWalletsPlatform Fees
ReservesFed PriceAutomated Price
© 2019 Kyber Network. All rights reserved.
Follow us on Facebook
Follow us on Twitter
Follow us on Github
Follow us on Reddit
Join our Telegram group
Subscribe to our Youtube channel
Read our blog on Medium