An experimental ETH-backed stablecoin system with a depositor-funded collateral buffer. Users mint and burn STC against ETH at a price provided by an on-chain Oracle, while liquidity providers deposit ETH to absorb deficits and earn fee-backed upside through DPC (DepositorCoin).
- Stablecoin core:
STCis minted by sending ETH, and burned to redeem ETH at the Oracle price. - Collateral buffer: depositors add ETH to cover deficits and receive
DPCrepresenting a claim on the surplus. - Fee flow: mint and burn fees stay in the contract and increase surplus for
DPCholders. - Manual Oracle: price is updated by an owner address (intended for testing / prototyping).
contracts/StableCoin.sol—STCmint/burn logic, fee accounting, collateral buffer entry/exit.contracts/DepositorCoin.sol—DPCERC20 minted/burned byStableCoinas the buffer share token.contracts/Oracle.sol— owner-updated ETH price feed.contracts/WadLib.sol— 18-decimal fixed-point math helpers.contracts/ERC20.sol— a minimalChillarERC20 token contract (not used byStableCoin).
- User sends ETH to
StableCoin.mint(). - If there are existing depositors, a fee (percentage of ETH) is retained in the contract.
STCminted equalsmsg.value * oraclePrice(in USD units; see decimals note below).
- User calls
StableCoin.burn(amount). - Contract verifies there is no deficit.
- User receives ETH based on
amount / oraclePrice, minus a fee if depositors exist.
depositCollateralBuffer()is used to cover a deficit and establish (or grow) surplus.- On first recapitalization, a 10% initial collateral ratio is enforced and a new
DPCtoken is deployed. - Subsequent deposits mint
DPCproportional to current surplus.
withdrawCollateralBuffer()burnsDPCand returns ETH based on the depositor share of surplus.
WadLiband token supplies assume 18 decimals.- The Oracle price should be provided in the same 18-decimal USD-per-ETH units to keep calculations consistent (e.g., $1,500 =
1500e18).
- Node.js (LTS recommended)
- npm
npm installnpx hardhat compilenpx hardhat nodeThe repo includes a sample deploy script, but it does not yet wire the StableCoin system. A typical local flow:
- Deploy
Oracle. - Set the ETH price on the Oracle.
- Deploy
StableCoinwith the Oracle address and a fee percentage. - Interact via Hardhat console or a custom script.
Example (Hardhat console):
npx hardhat console --network localhostconst Oracle = await ethers.getContractFactory("Oracle");
const oracle = await Oracle.deploy();
await oracle.deployed();
await oracle.setPrice(1500n * 10n ** 18n); // $1,500 with 18 decimals
const StableCoin = await ethers.getContractFactory("StableCoin");
const stc = await StableCoin.deploy(1, oracle.address); // 1% fee
await stc.deployed();
// Mint 1 ETH worth of STC
await stc.mint({ value: ethers.utils.parseEther("1") });contracts/— Solidity contracts.scripts/— deployment scripts (currently a sample).test/— tests (currently the Hardhat default sample).
- Tests and deploy script are placeholders from the Hardhat template and need to be updated for
StableCoin. - The system is experimental and not audited. Do not use in production or with real funds.
ISC (see package.json).