Developer Guides

Code Samples To Get You Started

The guides in the following section are targeted at application developers as well as smart contract integrators that are interested in building on top of the KyberSwap Elastic ecosystem.

Elastic SDK

KyberSwap has created an Elastic SDK to make interacting with our Elastic smart contracts easier. You can refer to our Elastic SDK Developer Guides for step-by-step walkthroughs on how to achieve various Elastic operations in a TypeScript environment.

Project bootstrapping

Given the composability of DeFi protocols, we recommend using Hardhat's mainnet forking feature to best stimulate mainnet conditions. This will enable integrations to be conveniently tested against existing protocols without having to bootstrap each and every protocol individually.

Overview

KyberSwap Elastic consists of multiple smart contracts, each having been deliberately confined to a specific function. If you would like to view the full list of contracts as well as their respective functions and variables, the contracts have been split according to the below:

The contracts that are of particular interest are listed below:

  • Factory: Handles deployment of Kyberswap Elastic pools and where administrative configurations are held, such as the whitelisting of NFT position managers, and government fee settings.

  • Router: Handles the routing of swaps across an Elastic pool.

  • QouterV2: Allows getting the expected amount out or amount in for a given swap without executing the swap.

  • AntiSnipAttackPositionManager: Adds the anti-sniping attack feature to the liquidity additions or removals.

  • TicksFeeReader: Handles the management of ticks as well as the corresponding positions and fees.

  • TokenPositionDescriptor: Enables querying of position information.

  • TokenPositionDescriptionProxy: An ERC1967 contract that implements an upgradeable proxy for the TokenPositionDescriptor contract.

Please refer to Elastic Contract Addresses for the full list of contracts which have been deployed across the supported chains.

Next steps

As there are possibly multiple pools per token pair, the first step is to fetch pool addresses and determine which pool is most suitable for querying swap rates, trade execution and liquidity provision.

Traders and arbitrageurs who need to take liquidity should view the section on swap execution.

Last updated