A comprehensive smart contract implementation for Tomb Finance, an algorithmic stablecoin protocol built on Ethereum-compatible blockchains.
Tomb Finance is a decentralized algorithmic stablecoin protocol that aims to maintain TOMB token price stability through a combination of seigniorage expansion and contraction mechanisms. The protocol consists of three main tokens:
- TOMB: The main stablecoin that targets $1 USD
- TSHARE: The governance and staking token
- TBOND: The bond token used during contraction phases
The protocol implements a sophisticated monetary policy system with the following key components:
Tomb.sol- Main TOMB token contract with dynamic taxation and burn mechanismsTreasury.sol- Central monetary policy controller managing expansion/contractionMasonry.sol- Staking contract for TSHARE holdersOracle.sol- Price oracle for TOMB/USD pricingTaxOffice.sol- Dynamic tax calculation and collection system
- Seigniorage Expansion: When TOMB price > $1, new tokens are minted and distributed
- Seigniorage Contraction: When TOMB price < $1, bonds are sold to reduce supply
- Dynamic Taxation: Adaptive tax rates based on price performance
- Staking Rewards: TSHARE holders earn from protocol revenue
- Algorithmic Stability: Automated price stabilization mechanisms
- Dynamic Taxation: Tiered tax system based on price performance
- Liquidity Mining: Reward pools for various token pairs
- Governance: TSHARE-based governance system
- Timelock: Secure multi-signature governance with time delays
- Oracle Integration: Reliable price feeds for monetary policy decisions
contracts/
├── core/
│ ├── Tomb.sol # Main TOMB token
│ ├── TShare.sol # Governance token
│ ├── TBond.sol # Bond token
│ └── Treasury.sol # Monetary policy controller
├── distribution/
│ ├── TombRewardPool.sol # TOMB reward distribution
│ ├── TShareRewardPool.sol # TSHARE reward distribution
│ └── TombGenesisRewardPool.sol # Genesis pool rewards
├── governance/
│ ├── Masonry.sol # Staking contract
│ ├── Timelock.sol # Governance timelock
│ └── SimpleERCFund.sol # Treasury fund management
├── oracle/
│ ├── Oracle.sol # Price oracle
│ ├── TaxOracle.sol # Tax calculation oracle
│ └── TaxOffice.sol # Tax collection
├── interfaces/ # Contract interfaces
├── lib/ # Utility libraries
├── owner/ # Access control
└── utils/ # Helper contracts
- Solidity Version: 0.6.12
- OpenZeppelin: Latest compatible contracts for security
- License: MIT
- Network: Ethereum-compatible (originally Fantom Opera)
- Triggers when TOMB price > $1.05
- New TOMB tokens minted and distributed to stakers
- Expansion rate decreases over time
- Triggers when TOMB price < $0.95
- TBOND tokens sold at discount to reduce TOMB supply
- Contraction rate increases with price deviation
- Tax rates adjust based on price performance
- Higher taxes during poor performance periods
- Tax revenue used for protocol maintenance
- TSHARE holders stake to earn TOMB rewards
- Rewards proportional to stake amount and time
- Lock periods for enhanced rewards
- Reentrancy Protection: Guards against reentrancy attacks
- Access Control: Operator-based permissions for critical functions
- Timelock: Governance actions require time delays
- Safe Math: Overflow protection for all calculations
- Oracle Validation: Multiple price feed validation
- Node.js 14+
- Solidity 0.6.12
- Truffle or Hardhat framework
# Clone the repository
git clone https://github.com/your-username/tombfinance-program.git
cd tombfinance-program
# Install dependencies
npm install
# Compile contracts
npx hardhat compile# Run tests
npx hardhat test
# Run with coverage
npx hardhat coverage# Deploy to testnet
npx hardhat run scripts/deploy.js --network testnet
# Deploy to mainnet
npx hardhat run scripts/deploy.js --network mainnetThe protocol can be configured through various parameters:
- Epoch Duration: 6 hours (configurable)
- Expansion Thresholds: Price levels for triggering expansion
- Contraction Limits: Maximum supply reduction per epoch
- Tax Tiers: Dynamic tax rates based on performance
- Reward Distribution: Allocation percentages for different pools
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.