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
  • Concentrated Liquidity Zaps
  • Minimizing Price Impact & Impermanent Loss
  • Aggregator Integration

Was this helpful?

  1. Reference
  2. Legacy
  3. KyberSwap Elastic
  4. Concepts

Elastic Zap

PreviousTick-Based FarmingNextTWAP Oracle

Last updated 1 year ago

Was this helpful?

Introduction To Zaps

For a conceptual overview of zapping, please refer to our primer on .

Concentrated Liquidity Zaps

KyberSwap is bringing an even more convenient LP experience by enabling zaps on KyberSwap Elastic. Unlike zaps on constant product pools where all pool liquidity is fungible (i.e. distributed equally across the whole price curve), zaps on concentrated liquidity pools need to take into account liquidity distribution across customized position ranges (see for more info). This adds significantly more complexity when implementing zaps on CLMM-type pools such as KyberSwap Elastic.

To enable LPs the option to zap into Elastic, KyberSwap has codified all the above complexities into zap-specific contracts which extends upon the core functionalities of the Elastic pool contracts. By functionally separating core and convenience operations, this paves the way for even more innovation based on contract modularity. The full list of Elastic Zap contract addresses can be found .

Minimizing Price Impact & Impermanent Loss

Aside from a much simpler LP experience, Elastic Zap is also primed to maximize LP yields through its integration with the . By taking the additional step of scanning for more optimal rates across , Elastic Zap greatly reduces LPs exposure to price impact and the resulting IL risks.

A Note On Gas Costs

Due to the complexity and multitude of steps required to achieve CLMM zaps with aggregator integration, zap transactions tend to consume more gas.

Nonetheless this has to be baselined against multiple swap + add transactions if the liquidity addition were to happen manually. In most cases when adding liquidity with a single token, this entails:

  • Initial swap from tokenA -> tokenB (requires manually calculating token ratio requirement)

  • Based on token ratio requirements, add the lower of tokenA:tokenB amounts

  • If the pool price moved between swap and add liquidity, repeat the process above for the remaining amount of tokenA or tokenB

For more active pools (or those with lower fee tiers), the pool price is more likely to move between the initial swap and liquidity addition. Critically, the narrower the position range selected and the closer the range boundaries are to the pool price, the larger the shift in token ratios required if the pool price changes.

Furthermore, the market for actively traded pairs will make sourcing the exact amounts from a market order extremely difficult. This is compounded for large trades where price impact considerations come into play.

Consequently, LPs would usually have to swap + add liquidity multiple times before their initial capital value has been fully added to CLMM pools. As DeFi users ourselves, we are also wary of this gas costs and are constantly exploring new ways to optimize gas usage. Expect cheaper Elastic Zaps as we continue to iterate upon our code base across multiple chains.

Aggregator Integration

When sourcing the token ratio for a zap in, swaps can be executed via the target pool itself or via other liquidity sources. In the latter case, LPs do not have to worry about the target pool price changing as a result of the swap transaction. That is, the pool which the LP is adding liquidity to will not experience a state change as the swap occurs external to the pool.

The example below highlights this fact conceptually when swapping against the target pool:

  • Target pool price is 1WETH:2,000USDC

  • LP zaps in 1,000USDC to the USDC-WETH pool

  • Assuming an equal ratio of tokens required, the token add liquidity ratio is 500USD worth of WETH and 500USD worth of USDC -> 0.25WETH:500USDC

  • Contract swaps the LP's 500USDC -> 0.25WETH against the target pool

  • The LP's 500USDC is added to the pool and 0.25WETH is transferred from the pool to the LP

  • As the pool now has more USDC relative to WETH, the pool price is now higher than the initial 1WETH:2,000USDC (i.e. WETH has gotten more expensive relative to USDC from the perspective of the pool)

  • Liquidity is added at the new pool price above the initial 1WETH:2,000USDC

As a consequence of the design, swapping against the pool prior to liquidity addition introduces additional technical complexities when computing the token ratio to be added (because the swap will change the pool price before addition). Critically, while the above can be solved mathematically, such LPs could also be exposed to further IL risks as a result of the zap in direction. This is especially so in cases where the pool price varies significantly from the market price.

In short, the of the intermediate swap will result in the newly created zap position being added further away from the market price (assuming pool price before swap = market price). Depending on the market direction, this might result in immediate IL upon creation of the position. This is compounded in cases where the target pool TVL is low relative to the trade volume.

To minimize such risks, leverages the to ensure that LPs always get superior rates when sourcing the intermediate swap. The Aggregator will compare rates across against the resulting target pool price (if intermediate swap was against the pool) and optimize the zap route accordingly. This minimizes the potential IL risks that LPs face when zapping into Elastic pools.

Zap
Tick-Range Mechanism
here
KyberSwap Aggregator
multiple DEXs
AMM
price impact
KyberSwap Elastic Zap
KyberSwap Aggregator
all integrated DEX liquidity sources