@kayenfi/v2-core
v0.0.3
Published
KayenFi V2 Smart Contracts (Foundry)
Readme
KayenFi V2 Contracts
KayenFi V2 smart contracts project built with Foundry.
Deployed Contracts & Configuration
CHILIZ Testnet (Chain ID: 88882)
Contract Addresses
| Contract | Address | Transaction Hash |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| KayenfiFactory | 0x1438de6d684ae273c9a7c38cfacadc62564409e4 | 0x142c8cd2cb1f9b59815d4231c9fdff8c3f1766c4c166795e6a65e73f7be8d959 |
| KayenfiRouter02 | 0x3393cbcc331615c8d4ba915eb67a462ba59e0a6a | 0xa53b398ae1482a6869a1c47924669c82d8b9d1526f020bed7bbae47ddc8181b4 |
| ChilizWrapperFactory | 0xe81671f425fd1d84127255270642CCD36E86EE7C | N/A (Existing contract, not deployed) |
| KayenfiMasterRouter | 0xbf2ce7f2757ecbd7d889ac375e8646c3b47b04e2 | 0xe46fc4fd314711bbcd417734a30ebdb6f6c76849c59aceca208be24f438bf0fe |
| KayenfiMasterRouterV2 | 0xdeae24ea3f8e44339fb8281fefe1cf9b82e72ded | 0xc701c2389fb0cc6470ef17a2fdd13e531cbacf7c55acaec5768fe9bbd55c1c34 |
Deployment Date: 2025-12-19
Block Number: 30839883
Contract ABIs & Bytecode (v1.0.0)
| Contract | Artifact File |
| ------------------------- | ------------------------------------------------------------------------------------ |
| KayenfiFactory | abis/v1.0.0/KayenfiFactory.json |
| KayenfiPair | abis/v1.0.0/KayenfiPair.json |
| KayenfiRouter02 | abis/v1.0.0/KayenfiRouter02.json |
| ChilizWrapperFactory | abis/v1.0.0/ChilizWrapperFactory.json |
| KayenfiMasterRouter | abis/v1.0.0/KayenfiMasterRouter.json |
| KayenfiMasterRouterV2 | abis/v1.0.0/KayenfiMasterRouterV2.json |
Admin Variables
| Variable | Contract | Address | Description |
| ------------- | -------------- | -------------------------------------------- | ------------------------------------------------------------------------- |
| feeSetter | KayenfiFactory | 0x6954a3aA9343aeA582D40331BcD52c38e95a3283 | Admin address that can set feeTo and transfer feeSetter role |
| feeTo | KayenfiFactory | 0x6954a3aA9343aeA582D40331BcD52c38e95a3283 | Address that receives protocol fees (automatically set during deployment) |
Note:
feeTois automatically set during deployment viaDeployments.s.sol. For existing deployments, usesetFeeTo.s.solto update it.
Chain Configuration
| Variable | Address | Description |
| ------------- | -------------------------------------------- | ------------------------------ |
| WETH | 0x678c34581db0a7808d0aC669d7025f1408C9a3C6 | Wrapped ETH address |
| feeSetter | 0x6954a3aA9343aeA582D40331BcD52c38e95a3283 | Admin address |
| feeTo | 0x6954a3aA9343aeA582D40331BcD52c38e95a3283 | Protocol fee recipient address |
CHILIZ Mainnet
Contract Addresses
| Contract | Address | | ------------------------- | ------- | | KayenfiFactory | TBD | | KayenfiRouter02 | TBD | | ChilizWrapperFactory | TBD | | KayenfiMasterRouter | TBD | | KayenfiMasterRouterV2 | TBD |
Admin Variables
| Variable | Contract | Address | Description | | ------------- | -------------- | ------- | ------------------------------------------------------------------------- | | feeSetter | KayenfiFactory | TBD | Admin address that can set feeTo and transfer feeSetter role | | feeTo | KayenfiFactory | TBD | Address that receives protocol fees (automatically set during deployment) |
Chain Configuration
| Variable | Address | Description | | ------------- | ------- | ------------------------------ | | WETH | TBD | Wrapped ETH address | | feeSetter | TBD | Admin address | | feeTo | TBD | Protocol fee recipient address |
Post-Deployment Admin Configuration
After deployment, the admin (feeToSetter) needs to configure the following settings on KayenfiFactory:
Required Settings
- Set FeeTo Address ✅ AUTOMATIC
- Function:
setFeeTo(address _feeTo) - Purpose: Sets the address that will receive protocol fees from liquidity pools
- Current State: Automatically set during deployment via
Deployments.s.sol - Action: No action required for new deployments. For existing deployments, use
script/setFeeTo.s.sol - Script (for existing deployments only): Use
script/setFeeTo.s.sol
export CHAIN=CHILIZ_TESTNET forge script script/setFeeTo.s.sol:setFeeTo \ --rpc-url $SPICY_TESTNET_RPC_URL \ --broadcast \ --legacy - Function:
Optional Settings
Set FeeToSetter (Optional)
- Function:
setFeeToSetter(address _feeToSetter) - Purpose: Transfer admin privileges to a new address (e.g., multisig wallet)
- Current State: Set to
0x6954a3aA9343aeA582D40331BcD52c38e95a3283during deployment - Recommendation: Transfer to a multisig wallet for better security
- Function:
Enable Flash Loans (Optional)
- Function:
setFlashOn(bool _flashOn) - Purpose: Enable/disable flash loan functionality
- Current State:
false(disabled) - Note: If enabled, also set
flashFee
- Function:
Set Flash Loan Fee (Optional)
- Function:
setFlashFee(uint _flashFee) - Purpose: Set the fee percentage for flash loans (in basis points, max 10000 = 100%)
- Current State: Not set
- Note: Only required if
flashOnis set totrue
- Function:
Deploy
Environment Variables Setup
Create a .env file and set the following variables:
PRIVATE_KEY=your_private_key_without_0x_prefix
CHAIN=CHILIZ_TESTNET # or CHILIZ_MAINNET
SPICY_TESTNET_RPC_URL=https://spicy-rpc.chiliz.com
CHILIZ_MAINNET_RPC_URL=https://rpc.ankr.com/chilizDeployment Scripts
# Full deployment (Factory, Router02, WrapperFactory, MasterRouter)
export CHAIN=CHILIZ_TESTNET
forge script script/Deployments.s.sol:Deployments \
--rpc-url $SPICY_TESTNET_RPC_URL \
--broadcast \
--legacy
## Main Contracts
- `KayenfiFactory.sol` - Factory contract
- `KayenfiPair.sol` - Pair contract
- `KayenfiRouter02.sol` - Router contract
- `KayenfiMasterRouter.sol` - Master router
- `KayenfiMasterRouterV2.sol` - Master router V2
## Configuration
Chain-specific configurations are managed in `script/Config.sol`. You can select a chain using the `CHAIN` environment variable:
- `CHILIZ_TESTNET` - Testnet configuration
- `CHILIZ_MAINNET` - Mainnet configuration
> **Note**: The addresses in `Config.sol` may differ from the deployed contract addresses. Always refer to the "Deployed Contracts" section above for the actual deployed addresses.