JuiceDollar (JUSD)
An oracle-free, collateralized stablecoin forked from dEURO
This repository contains the smart contracts for JuiceDollar (JUSD), a decentralized stablecoin system with native protocol shares (JUICE).
Links:
Table of Contents
Smart Contracts Overview
All source code is located in the contracts folder.
Core Contracts
| JuiceDollar.sol | The JUSD ERC20 stablecoin token |
| Equity.sol | The JUICE ERC20 token (Juice Protocol) |
| Leadrate.sol | Leading interest rate module for the system |
Minting Hub V2
| MintingHub.sol | Oracle-free collateralized minting system |
| Position.sol | Individual collateralized loan position |
| PositionFactory.sol | Factory to create new positions |
| PositionRoller.sol | Roll positions into new ones |
Savings & Bridges
| Savings.sol | Interest distribution to JUSD holders |
| SavingsVaultJUSD.sol | ERC4626 vault for JUSD savings |
| StablecoinBridge.sol | 1:1 swaps with external stablecoins (StartUSD for bootstrap) |
Gateway Contracts (Frontend Rewards)
| FrontendGateway.sol | Rewards frontend providers for referrals |
| MintingHubGateway.sol | Minting with frontend provider rewards |
| SavingsGateway.sol | Savings with frontend provider rewards |
| CoinLendingGateway.sol | Native coin (cBTC) lending with custom liquidation |
Fork History
JuiceDollar is part of a three-generation fork chain:
Frankencoin-ZCHF (Original)
↓
d-EURO (December 2024 fork)
↓
JuiceDollar (Current repository)
Upstream: d-EURO/smartContracts
Origin: Frankencoin-ZCHF/FrankenCoin
Deployment Networks:
- Frankencoin-ZCHF: Ethereum Mainnet (native currency: ETH)
- dEURO: Ethereum Mainnet (native currency: ETH) | Testnet: Sepolia
- JuiceDollar: Citrea Mainnet (native currency: cBTC) | Testnet: Citrea Testnet
d-EURO forked from Frankencoin at commit a2ce625 (December 2, 2024), introducing significant protocol improvements. JuiceDollar continues this evolution with deployment on Citrea, using cBTC as the native currency.
Audit Reports
JuiceDollar inherits security audits from its upstream repositories:
Frankencoin Audits
dEURO-Specific Audits
| ChainSecurity | dEURO fork changes (Interest Accrual, Auction, Accounting) | Audit |
| Audit Boutique | dEURO smart contracts | Report PDF |
Bug Bounty
- JuiceDollar Bug Bounty: Program details will be announced soon
- Upstream Bug Bounty Programs:
Development Setup
Prerequisites
- Node.js & Yarn
- Hardhat
- (Optional) Foundry for fuzzing tests
1. Install Dependencies
yarn install
2. Environment Configuration
Create a .env file (see .env.example):
DEPLOYER_PRIVATE_KEY=your_private_key_here
3. Compile Contracts
yarn run compile
Testing
Run Tests
yarn run test
yarn run test test/TESTSCRIPT.ts
yarn run coverage
Auto-refresh Testing
npx tsc-watch --onCompilationComplete "npx hardhat test ./test/RollerTests.ts"
Deployment
Target Networks
- Mainnet: Citrea (native currency: cBTC)
- Testnet: Citrea Testnet
Manual Deployment (Hardhat Deploy)
Deploy to Citrea Testnet:
hh deploy --network citreaTestnet --tags MockTokens
hh deploy --network citreaTestnet --tags JuiceDollar
hh deploy --network citreaTestnet --tags PositionFactory
hh deploy --network citreaTestnet --tags MintingHub
hh deploy --network citreaTestnet --tags positions
Testing on local fork:
npx hardhat node
Deploy Stablecoin Bridges
NOTE: The bootstrap bridge (StartUSD → JUSD) is deployed automatically via deployProtocol.ts
For additional bridges:
BRIDGE_KEY=<KEY> npx hardhat run scripts/deployment/deploy/deployBridge.ts --network citrea
USE_FORK=true BRIDGE_KEY=<KEY> npx hardhat run scripts/deployment/deploy/deployBridge.ts --network hardhat
Bridge configurations: scripts/deployment/config/stablecoinBridgeConfig.ts
NPM Package
Package Info
First-Time Publish
npm login
yarn run publish
Publishing Updates
yarn run ts:export:abis
git add . && git commit -m "Release v1.0.1: Description"
yarn run publish
Note: The prepublishOnly script automatically runs yarn run build before publishing.
Package Exports
TypeScript ABIs (exports/abis/):
export const JuiceDollarABI = [...] as const;
Address Config (exports/address.config.ts):
export const ADDRESS: Record<number, ChainAddress> = {
[citrea.id]: { juiceDollar: '0x...', equity: '0x...' }
};
Foundry Fuzzing Tests
Overview
Invariant/stateful fuzzing tests verify system integrity under random operations.
Location: foundry-test/invariant/
Invariants.t.sol - Defines system invariants
Handler.t.sol - Defines random actions
Configuration: foundry.toml
Remappings: remappings.txt
Setup
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge install
Run Fuzzing Tests
forge clean
forge test
forge test -vvv | grep -v "Bound result"
forge test --show-progress
forge test --rerun
Debug Handler Reverts
Set in foundry.toml:
[invariant]
fail_on_revert = true
License
MIT License - See LICENSE file
Copyright (c) 2024 DistributedCollective
Contributing
This project is a fork of d-EURO, which itself is a fork of Frankencoin-ZCHF.
For contribution guidelines, please open an issue in this repository or refer to the upstream dEURO repository.
Built with ❤️ by the JuiceDollar team