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
  • Overview
  • Comparison with traditional pricing service
  • The Evolution of On-chain Price Service
  • System Components and Functionality

Was this helpful?

  1. KyberSwap Solutions

KyberSwap OnChain Price Service

Overview

Welcome to the first-ever completely on-chain price service, designed to deliver accurate, reliable, and more tradeable price information for a wide array of tokens. In this section, we will explain the enhancements we've made to our price service and how it benefits you.

Comparison with traditional pricing service

Other price services

Kyberswap on-chain price service

The quote symbol

- Fiat currencies (USD, EUR, GBP, AUD, etc.) - Well-known cryptocurrencies (BTC, ETH, BNB, XRP, etc.)

- Stablecoins (USDT, USDC). - Native tokens (ETH, BNB, MATIC, etc.).

Source of price

- Centralized Exchanges (CEXes) involving multiple pairs with different quote tokens. - Decentralized Exchanges (DEXes) with multiple pairs and possibly across different chains.

Decentralized Exchanges (DEXes) using multiple pairs with different quote tokens.

Type of target price

Provides a single final price without distinguishing between buy and sell prices. This aggregated price may not reflect real on-chain liquidity, which can lead to discrepancies when attempting to execute trades on Decentralized Exchanges.

Provides both buy and sell prices separately. Based on real on-chain liquidity, this ensures the prices are reflective of market conditions and executable in real trading scenarios, offering more accurate and trade-able prices on Decentralized Exchanges.

Network-Specific Pricing

Typically, other services aggregate prices from multiple networks and combine them into a single price. While this approach provides an overall average, it may not accurately reflect the liquidity depth or market conditions of each individual network.

Kyberswap provides network-specific prices that vary depending on the liquidity depth of each network. This ensures that the prices you see are reflective of the actual market conditions on each network, resulting in more accurate and tradeable prices tailored to where the liquidity is most concentrated.

The price formula

The final price is derived from an aggregation of various sources using a predefined formula, which may be average, median, or weighted-based. The exact method can vary depending on the price service.

- Utilizes a graph-based algorithm to build a graph of price from the pre-defined quote token (with a pre-defined amount) to all other tokens

+ Buy Price: Determined by finding the maximum output amount when converting the quote token to the target token (i.e., selling X amount of the quote token to determine the maximum amount of the target token that can be purchased).

+ Sell Price: Determined by finding the minimum input amount required to obtain the quote token from the target token (i.e., determining the minimum amount of the target token that needs to be sold to acquire X amount of the quote token). + After having the equation X quote token <-> Y target token , the price of the target token is derived.

Verification of Price Accuracy

There might be a combination of market data aggregation, cross-exchange comparisons, and advanced algorithms to ensure the accuracy of their prices. They might also implement anomaly detection and regular audits to maintain reliability.

- When passing the debug parameter in the request, the response will contain 3 more fields: + tracedTokens + tracedPools + tracedAmounts These fields can be used to verify the accuracy of the price calculation.

The Evolution of On-chain Price Service

Consistent and Reliable Price Calculation

Kyberswap's on-chain price service leverages the same route-finding algorithm employed in our token swap calculations.

By reusing the Kyberswap-dex-lib CalcAmountOut functions, we ensure consistency and precision in price determination, eliminating the need for a separate price calculation formula.

Network-Specific Pricing

Kyberswap’s price service provides network-specific prices that vary depending on the liquidity depth of each network. On-chain price now available on all chains that Kyberswap support. Unlike other services that aggregate prices from multiple networks into a single average, Kyberswap’s approach ensures that the prices are reflective of the actual market conditions and liquidity available on each specific network. This results in more accurate and trade-able prices tailored to the unique dynamics of each network.

Enhanced Token Coverage

Our new system supports a broader range of tokens, allowing for more accurate price information even for less common or exotic tokens.

This improvement ensures that you can trade confidently, knowing that you have access to precise and comprehensive price data across a wide array of tokens.

Improved Accuracy and Real-Time Updates

Kyberswap's on-chain price service utilizes the native token's price as a reference point, sourced from reliable data providers.

By continuously updating this data every 10 seconds, the service ensures that the prices you see are always accurate, up-to-date, and reflective of real-time market conditions. This approach guarantees that the pricing information is as precise and tradeable as possible.

System Components and Functionality

The Kyberswap on-chain price service is comprised of several key components, each playing a vital role in delivering accurate price information:

Token List Management:

  • The system regularly updates the list of common tokens available for trading on Kyberswap. This ensures that a comprehensive range of tokens is consistently supported, with up-to-date pricing information.

Price Graph Construction and Maintenance:

  • The system constructs a price graph in memory, utilizing data from various sources to calculate precise token prices. This graph is updated every 10 seconds to reflect the latest market conditions.

  • Latest prices are stored in Redis, while historical snapshots are archived in a time-series database, ensuring both real-time accuracy and long-term reliability.

API-based Price Retrieval:

  • The system efficiently handles API requests by retrieving the most recent price data stored in Redis. This enables users to obtain real-time price information, facilitating informed trading decisions.

Conclusion

This service guarantees precise, up-to-date and the most trade-able price information, enhancing your trading experience on Kyberswap. Enjoy more informed trading decisions and a streamlined experience with our advanced on-chain price service.

Enjoy trading on Kyberswap!

PreviousFAQNextFee Schedule

Last updated 9 months ago

Was this helpful?