This repository contains the core smart contract code for KUSD, KalyChain's native stablecoin system. KUSD is a fork of MakerDAO's DAI (DSS) adapted for the KalyChain ecosystem.
Built with Foundry for fast compilation and modern Solidity tooling.
forge build --skip testforge test# Load environment
source .env
# Deploy to mainnet
forge script script/Deploy.s.sol:Deploy --rpc-url https://rpc.kalychain.io/rpc --broadcast --private-key $PRIVATE_KEY --gas-price 21000000000 --legacy -vvvv- Network: KalyChain Mainnet (Chain ID: 3888)
- RPC: https://rpc.kalychain.io/rpc
- Explorer: https://kalyscan.io
- Network: KalyChain Testnet (Chain ID: 3889)
- RPC: https://testnetrpc.kalychain.io/rpc
- Explorer: https://testnet.kalyscan.io
| Contract | Address |
|---|---|
| Vat | 0xd3f7d3fdb52bc3ae7c69e12c2a87af49b632505c |
| KUSD | 0xcd02480926317748e95c5bbbbb7d1070b2327f1a |
| sKLC | 0x86c0ea2bf60f86c88a227b00308cac07b38deb2c |
| Spotter | 0xf76f2447fbe15582e47218d0510216f835a80db7 |
| Jug | 0x70806c83da93635a452e3c395cfde55e283ed1a4 |
| Pot | 0x2268c2da9f04230d6ba451afece52c244f235c44 |
| Dog | 0xae50bf432f64a77f0bea6961458da4e486e997b9 |
| Vow | 0x334f479678cc6c8017743effef22818aca9ff7ef |
| Flapper | 0x40475623957bccf0ac55b9ac7f6ebe472852aa0c |
| Flopper | 0x4d611877b59543caa972359bc4def7775b22ec58 |
| End | 0x71b342a953fbd6483f8d520d841665f8d7b2a619 |
| Cure | 0x609317bfa3007e0c57a4a750d82f8733f890c9ac |
| KusdJoin | 0x90fdfd47dfaf84ccd568a596dc70ec2c0d80c571 |
| Contract | Address |
|---|---|
| ProxyRegistry | 0x5649cfb8fca0657b6b33461a2d2ac26e62713c49 |
| ProxyFactory | 0x7dBd86439CcFfA5b0883667631FdE919f0184B27 |
| ProxyActions | 0x888c259ed3740a7f79e3c443d5e731389c4c98f3 |
| Contract | Address |
|---|---|
| Token | 0xaA77D4a26d432B82DB07F8a47B7f7F623fd92455 |
| GemJoin | 0xb1c48ad6d623a72c07e7ece7b141f548c35ae6fb |
| Clipper | 0x13e96f537709f7a79d4fc9be0e3e4d863232f63e |
| Oracle | 0x28f51A114Ffcf36FB77D6ded40807a6415782f5d |
| Contract | Address |
|---|---|
| Token | 0xfdbB253753dDE60b11211B169dC872AaE672879b |
| GemJoin | 0x632e9740d63b7c88a2cb42105ccc264b1038cf6c |
| Clipper | 0xa6bb3dc8bd773080f23afe4248e8d47f85f359a6 |
| Oracle | 0x80E64f28656e1C95F4dF231536D8dC411822053c |
| Contract | Address |
|---|---|
| Token | 0x2CA775C77B922A51FcF3097F52bFFdbc0250D99A |
| GemJoin | 0xade482e0abf693d4a4f02ffe90756288cfd5e720 |
| Clipper | 0x3b0eedaa0a6cb7d3a5b3e59b76c261fb5d738eaa |
| Oracle | 0xC5342aDDbecabF78d92Ca3c218879d4F767a0D30 |
| Contract | Address |
|---|---|
| Token | 0x9cAb0c396cF0F4325913f2269a0b72BD4d46E3A9 |
| GemJoin | 0x0eb899b93f9a97d13878dcb785675222fb8948a5 |
| Clipper | 0xe658b15137f3081cd62a25873bb7d3d73e9d3233 |
| Oracle | 0xF89dE104147bb36f5473c30eC1d2C067c81ff04E |
| Contract | Address |
|---|---|
| Token | 0x6E92CAC380F7A7B86f4163fad0df2F277B16Edc6 |
| GemJoin | 0xcdb96345acc74000211b5235dd1b4da97e130108 |
| Clipper | 0xfb9fd22a23953a50e0f49d1e4eb64653560118db |
| Oracle | 0x7Ef8fe406191CB2a7C2671FF724f2eAbCbbd22cF |
- docs/DEVELOPING.md - Development guide
- docs/TESTNET_TESTING.md - Testnet testing guide
- docs/ONCHAIN_FLOWS.md - System architecture and flows
- docs/DEBT_CEILING_EXPLAINED.md - Understanding debt ceilings
- CHANGELOG.md - Changes from original MakerDAO DSS
KUSD is a collateralized stablecoin system where users deposit collateral (WBTC, WETH, USDT, USDC, DAI) to mint KUSD. The system uses sKLC (Stable Kaly Coin - wrapped KLC) for auction participation.
| Contract | Purpose |
|---|---|
| Vat | Core accounting engine - tracks all vaults and debt |
| Kusd | The stablecoin token (ERC20) |
| sKLC | Wrapped KLC token for auctions (Lock Model) |
| Dog | Liquidation engine - triggers undercollateralized vault liquidations |
| Clipper | Dutch auctions for liquidated collateral |
| Flapper | Surplus auctions - sells excess KUSD for sKLC |
| Flopper | Debt auctions - mints sKLC to cover bad debt |
| Spotter | Price oracle interface |
| Jug | Stability fee collector |
| Pot | KUSD Savings Rate (DSR) module |
Surplus Auctions (Flapper): When the system has excess KUSD from stability fees, it auctions the surplus for sKLC. The winning sKLC is locked in the contract.
Debt Auctions (Flopper): When bad debt occurs from failed liquidations, the system auctions off newly minted sKLC to cover the debt.
- Token agnostic - System operates independently of external token implementations
- Verifiable - Core CDP engine makes no external calls and has no precision loss
- Modular - Multi-contract design allows for upgrades and new collateral types
Each collateral type has an adapter (GemJoin) that standardizes token behavior. Adapters manipulate the slip function in Vat to modify user collateral balances.
The system requires oracle price feeds for each collateral type. The Spotter contract converts oracle prices to the system's internal spot price format.
Contracts use a wards mapping for authorization. Trusted contracts can call privileged functions. Governance manages which contracts are authorized.