WRMB Protocol is a comprehensive DeFi ecosystem built on Ethereum, featuring wrapped RMB tokens, savings vaults, bond pools, and automated market operations. The protocol enables users to wrap sRMB tokens into interest-bearing sWRMB, participate in bond subscriptions, and benefit from automated liquidity management.
-
WRMB Token (
WRMB.sol)- ERC20 token with minting restrictions
- Only designated minter can mint new tokens
- Serves as the base currency for the ecosystem
-
WRMB Minter (
WRMBMinter.sol)- Controls WRMB token minting across different scenarios
- Supports minting for wrap operations, vault increases, and bond maturity
- Implements role-based access control
-
Savings Vault (
SavingsVault.sol)- ERC4626-compliant vault for WRMB tokens
- Issues sWRMB shares representing vault positions
- Integrates with AMO for dynamic asset management
- Supports keeper-triggered NAV increases
-
Wrap Manager (
WrapManager.sol)- Manages conversion from sRMB to sWRMB
- Handles fee calculations and oracle price feeds
- Integrates with savings vault for seamless wrapping
-
Active Liquidity AMO (
ActiveLiquidityAMO.sol)- Automated Market Operations for arbitrage and rebalancing
- Manages WRMB debt and liquidity positions
- Keeper-operated for automated execution
-
WRMB Bond Pool (
WRMBBondPool.sol)- Bond subscription system with compound interest
- Users deposit USDT to earn WRMB rewards
- Configurable bond terms and interest rates
-
Bond Liquidity AMO (
BondLiquidityAMO.sol)- Single-sided USDT liquidity provider for bond pool
- Automated rebalancing based on utilization rates
- Position management and yield optimization
-
Oracle Stub (
OracleStub.sol)- Mock oracle for testing and development
- Provides price feeds and TWAP functionality
- Supports batch price updates
- Node.js >= 16.0.0
- npm or yarn
- Hardhat development environment
# Clone the repository
git clone https://github.com/CINALabs/WRMB-protocol-contracts.git
cd WRMB-protocol-contracts
# Install dependencies
npm install
# Compile contracts
npm run build# Deploy to local network
npm run node
# In another terminal
npm run deploy
# Deploy to specific network
npx hardhat run scripts/deploy.ts --network <network-name># Run all tests
npm test
# Run specific test file
npx hardhat test test/WRMB.test.ts
# Run tests with coverage
npm run coverage// Approve sRMB to WrapManager
await srmb.approve(wrapManager.address, amount);
// Preview wrap operation
const [expectedSWRMB, expectedWRMB, fee] = await wrapManager.previewWrap(amount);
// Execute wrap
await wrapManager.wrap(amount);// Preview bond subscription
const [wrmbAmount, maturityTime, expectedReward] = await bondPool.previewSubscription(usdtAmount);
// Approve USDT to BondPool
await usdt.approve(bondPool.address, usdtAmount);
// Subscribe to bond
await bondPool.subscribeBond(usdtAmount);
// Mature bond after duration
await bondPool.matureBond(bondId);// Deposit WRMB to vault
await wrmb.approve(savingsVault.address, amount);
await savingsVault.deposit(amount, recipient);
// Redeem sWRMB for WRMB
await savingsVault.redeem(shares, recipient, owner);
// Check current NAV
const nav = await savingsVault.getNAV_sWRMB();The project includes comprehensive test suites for all contracts:
- Unit Tests: Individual contract functionality
- Integration Tests: Cross-contract interactions
- Scenario Tests: Real-world usage scenarios
- WRMB Token: Minting, transfers, access control
- Savings Vault: Deposits, withdrawals, NAV calculations
- Wrap Manager: sRMB wrapping, fee calculations
- Bond Pool: Subscriptions, maturity, compound interest
- AMO Contracts: Arbitrage, rebalancing, debt management
User β WrapManager β SavingsVault β WRMBMinter β WRMB Token
β β β β β
Approve GetNAV MintShares MintWRMB Transfer
sRMB Price (sWRMB) Tokens to Vault
User β BondPool β Oracle β WRMBMinter β WRMB Token
β β β β β
USDT GetPrice Price MintRewards Transfer
Deposit Feed Check (Maturity) to User
Create a .env file with the following variables:
# Network Configuration
INFURA_API_KEY=your_infura_key
PRIVATE_KEY=your_private_key
# Contract Addresses (after deployment)
WRMB_ADDRESS=0x...
MINTER_ADDRESS=0x...
VAULT_ADDRESS=0x...
# Oracle Configuration
ORACLE_UPDATE_INTERVAL=3600
PRICE_DEVIATION_THRESHOLD=500The project uses Hardhat with TypeScript support:
- Solidity version: 0.8.20
- Optimizer enabled with 200 runs
- TypeChain integration for type-safe contract interactions
- Gas reporting and coverage analysis
- Owner-only functions: Critical configuration changes
- Role-based minting: Separate minters for different scenarios
- Keeper operations: Automated functions with designated operators
- Emergency controls: Pause functionality and emergency withdrawals
- Slippage protection: Maximum slippage limits for operations
- Debt tracking: Accurate AMO debt accounting
- Cooldown periods: Rate limiting for sensitive operations
- Validation checks: Comprehensive input validation
- Reentrancy Protection: All external calls use ReentrancyGuard
- Integer Overflow: SafeMath equivalent checks in Solidity 0.8+
- Access Control: Comprehensive role-based permissions
- Oracle Security: Price staleness and manipulation checks
- Emergency Procedures: Pause and emergency withdrawal mechanisms
- TVL (Total Value Locked): Across all protocol components
- Utilization Rates: Vault and AMO utilization
- Bond Subscriptions: Active bonds and maturity schedule
- NAV Performance: sWRMB net asset value trends
- AMO Performance: Arbitrage profits and rebalancing efficiency
// Core protocol events
event BondSubscribed(address user, uint256 bondId, uint256 amount);
event WrapExecuted(address user, uint256 srmb, uint256 swrmb);
event NAVUpdated(uint256 oldNAV, uint256 newNAV);
event RebalanceExecuted(uint256 amount, string operation);- TypeChain: Type-safe contract interactions
- Hardhat: Development environment and testing
- OpenZeppelin: Security-audited contract libraries
- Solhint: Solidity linting and best practices
- Prettier: Code formatting for Solidity
# Development
npm run build # Compile contracts
npm run test # Run tests
npm run coverage # Test coverage
npm run lint # Lint Solidity code
# Deployment
npm run deploy # Deploy to local network
npm run verify # Verify contracts on Etherscan
# Utilities
npm run typechain # Generate TypeScript types
npm run clean # Clean build artifacts- GitHub Issues: Bug reports and feature requests
- Discord: Community discussions and support
- Documentation: Comprehensive guides and tutorials
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
- Follow Solidity style guide
- Write comprehensive tests
- Document all public functions
- Use meaningful commit messages
- Ensure all tests pass before submitting
Note: This is a development version. Do not use in production without proper auditing and testing.