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.
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.
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:
- QouterV2: Allows getting the expected amount out or amount in for a given swap without executing the swap.
- 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.
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.