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 KyberReserve
  • INDEX​
  • REFERENCE​

Was this helpful?

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

KyberReserve

PreviousIKyberReserveNextConversionRates

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 KyberReserve

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

Source:

The KyberReserve contract's role is to execute exchanges and provide rates for Kyber Network. The contract has no direct interaction with the end users (the only interaction with them is via the network platform). Its main interaction is with the reserve operator who manages the token inventory and feeds exchange rates every few minutes.


INDEX

<AUTOGENERATED_TABLE_OF_CONTENTS>

REFERENCE

Events

Event for logging of ERC20 token deposits.


event DepositToken(ERC20 token, uint amount) | Parameter | Type | Description | | --------- |:-----:|:----------------------------:| | token | ERC20 | ERC20 token contract address | | amount | uint | ERC20 token amount in wei |

\

Event for logging new token wallet address


event NewTokenWallet(ERC20 token, address wallet) | Parameter | Type | Description | | --------- |:-----:|:-----------------------------------------------------------:| | token | ERC20 | ERC20 token contract address | | wallet | address | token wallet address |

\

Event for logging the setting of contract addresses.


event SetContractAddresses(address network, address rate, address sanity) | Parameter | Type | Description | | --------- |:-------:|:--------------------------------:| | network | address | KyberNetwork contract address | | rate | address | ConversionRates contract address | | sanity | address | SanityRates contract address |

\

Event for logging if trade is enabled for the reserve.


event TradeEnabled(bool enable) | Parameter | Type | Description | | --------- |:-----:|:-----------------------------------------------------------:| | enable | bool | true if reserve is enabled, otherwise false if disabled |

\

Event for logging of executed trades.


event TradeExecute(address indexed origin, address src, uint srcAmount, address destToken, uint destAmount, address destAddress) | Parameter | Type | Description | | --------------|:-------:|:----------------------------------------------:| | origin | address | sender's address | | src | address | source ERC20 token contract address | | srcAmount | uint | wei amount of source ERC20 tokens | | destToken | address | destination ERC20 token contract address | | destAmount | uint | wei amount of destination ERC20 tokens | | destAddress | address | recipient address for destination ERC20 tokens |

\

Event for logging of enabling or disabling of withdrawal address for token.


event WithdrawAddressApproved(ERC20 token, address addr, bool approve) | Parameter | Type | Description | | ----------|:-------:|:----------------------------------------------------------------------:| | token | ERC20 | ERC20 token contract address | | addr | address | withdrawal address | | approve | bool | true if address is enabled, otherwise false if address is disabled |

\

Event for logging of withdrawn funds when withdraw function is invoked.


event WithdrawFunds(ERC20 token, uint amount, address destination) | Parameter | Type | Description | | --------------|:-------:|:---------------------------------------:| | token | ERC20 | ERC20 token contract address | | amount | uint | wei amount of tokens that was withdrawn | | destination | address | recipient address of withdrawn funds |\

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


function KyberReserve(address _kyberNetwork, ConversionRatesInterface _ratesContract, address _admin) public | Parameter | Type | Description | | -----------------|:------------------------:|:--------------------------------:| | _kyberNetwork | address | KyberNetwork contract address | | _ratesContract | ConversionRatesInterface | ConversionRates contract address | | _admin | address | admin's wallet address |

\

Adds or deletes a reserve's withdrawal address to or from the network. Only admin can invoke.


function approveWithdrawAddress(ERC20 token, address addr, bool approve) public onlyAdmin | Parameter | Type | Description | | ----------|:-------:|:----------------------------------------------------------------------:| | token | ERC20 | ERC20 token contract address | | addr | address | withdrawal address | | approve | bool | true if address is enabled, otherwise false if address is disabled |

\

Disable trading for the reserve. Only alerter can invoke.


function disableTrade() public onlyAlerter returns (bool)\ Returns:\ true if trade is successfully disabled, otherwise false

\

Enables trading in the reserve. Only admin can invoke.


function enableTrade() public onlyAdmin returns (bool)\ Returns:\ true if trading is enabled, otherwise false\

Get the token balance of the reserve.


function getBalance(ERC20 token) public view returns (uint) | Parameter | Type | Description | | --------- |:-------:|:----------------------------:| | token | ERC20 | ERC20 token contract address | Returns:\ ERC20 token balance of the reserve in wei

\

Gets the conversion rate for a pair of tokens at block number.


function getConversionRate(ERC20 src, ERC20 dest, uint srcQty, uint blockNumber) public view returns (uint) | Parameter | Type | Description | | ------------- |:------:|:----------------------------------------:| | src | ERC20 | source ERC20 token contract address | | dest | ERC20 | destination ERC20 token contract address | | srcQty | uint | wei amount of source ERC20 token | | blockNumber | uint | current block height or block number | Returns:\ Current conversion rate of token pairs at block number

\

Get the calculated ERC20 token quantity in the destination wallet address.


function getDestQty(ERC20 src, ERC20 dest, uint srcQty, uint rate) public view returns (uint) | Parameter | Type | Description | | --------- |:-----:|:----------------------------------------:| | src | ERC20 | source ERC20 token contract address | | dest | ERC20 | destination ERC20 token contract address | | srcQty | uint | wei amount of source ERC20 token | | rate | uint | the conversion rate between src and dest | Returns:\ Calculated destination ERC20 token quantity in wei

\

Get the calculated ERC20 token quantity in the source wallet address.


function getSrcQty(ERC20 src, ERC20 dest, uint dstQty, uint rate) public view returns (uint) | Parameter | Type | Description | | --------- |:-----:|:----------------------------------------:| | src | ERC20 | source ERC20 token contract address | | dest | ERC20 | destination ERC20 token contract address | | dstQty | uint | wei amount of source ERC20 token | | rate | uint | the conversion rate between src and dest | Returns:\ Calculated source ERC20 token quantity in wei

\

Sets the contract addresses. Only admin can invoke.


\

Set the token wallet address to deposit / withdraw the specified token from / to. Only admin can invoke.


function setTokenWallet(ERC20 token, address wallet) public onlyAdmin | Parameter | Type | Description | | -------------------|:------------------------:|:----------------------------------------------:| | token | ERC20 | ERC20 token contract address | | wallet | address | wallet address |

\

Withdraw an ERC20 token from the reserve to the destination address. Only operator can invoke.


function withdraw(ERC20 token, uint amount, address destination) public onlyOperator returns (bool) | Parameter | Type | Description | | ------------- |:-------:|:----------------------------------------------:| | token | ERC20 | ERC20 token contract address | | amount | uint | ERC20 token amount in wei | | destination | address | recipient address for destination ERC20 tokens | Returns:\ true if the withdrawal was successful, otherwise false if unsuccessful

DepositToken

NewTokenWallet

SetContractAddresses

TradeEnabled

TradeExecute

WithdrawAddressApproved

WithdrawFunds

Functions

KyberReserve

approveWithdrawAddress

disableTrade

enableTrade

getBalance

getConversionRate

getDestQty

getSrcQty

setContracts

function setContracts(address _kyberNetwork, ConversionRatesInterface _conversionRates, SanityRatesInterface _sanity) public onlyAdmin | Parameter | Type | Description | | -------------------|:------------------------:|:----------------------------------------------:| | _kyberNetwork | address | KyberNetwork contract address | | _conversionRates | ConversionRatesInterface | ConversionRates contract address | | _sanity | SanityRatesInterface | SanityRates contract address | Modifiers:

setTokenWallet

withdraw

Classic
Elastic
Limit Order
Aggregator
IKyberReserve
Withdrawable
Withdrawable
ConversionRatesInterface
SanityRatesInterface
IKyberReserve
KyberReserve.sol
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
onlyAdmin
​
​