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 Classic 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 Classic implements two smart contract variants that correspond to the fee setting for the pool as the fee logic differs significantly between the two. The contract variants are differentiated based on the smart contract name prefix whereby:
KS: KyberSwap Classic with static fees
DMM: KyberSwap Classic with dynamic fees
In terms of contracts, there are two contracts of particular interest:
Factory. The different contracts and their purposes are listed below:
Router: Handles the core flows which includes liquidity provision, token rate queries, and token swap execution.
Factory: Contract that eables the creation of KyberSwap Classic pools.
ZapIn: Enable users to zap into and out of the pool.
Multicall: Ensures data synchronization by aggregating multiple smart contract function calls into a single call.
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.