This repository contains smart contracts for the INTMAX2 reward system, including token contracts and reward distribution mechanisms for block builders and privacy mining.
The INTMAX2 reward system consists of three main components:
- Block Builder Reward System: Distributes sITX tokens to block builders based on their contributions to the L2 network
- ScrollINTMAXToken (sITX): An ERC20 token deployed on Scroll network with transfer restrictions
- Minter: Manages ITX token minting on mainnet and distribution to liquidity contracts for privacy mining rewards
graph TD
A[Block Builder] -->|Post Blocks| B[Rollup Contract]
B -->|Record Contributions| C[Contribution Contract]
D[Reward Manager] -->|Set Reward Amount| E[BlockBuilderReward Contract]
E -->|Read Contributions<br/>BLOCK_POST_TAG| C
E -->|Distribute sITX Tokens| A
F[ScrollINTMAXToken<br/>sITX] -->|Transfer Tokens| E
graph TD
A[Minter Contract] -->|Mint ITX| B[ITX Token Contract]
A -->|Transfer ITX| C[Liquidity Contract]
C -->|Privacy Mining<br/>Rewards| D[Users]
Scroll Network (Block Builder Rewards):
- Block builders contribute to the L2 network by posting blocks to the Rollup Contract
- The Rollup Contract records these contributions in the Contribution Contract with
BLOCK_POST_TAG - Reward managers set total reward amounts for each period in the BlockBuilderReward Contract
- The BlockBuilderReward Contract reads contribution data from the Contribution Contract
- Block builders can claim their proportional share of sITX tokens based on their contributions
Ethereum Mainnet (Privacy Mining):
- The Minter Contract mints ITX tokens from the mainnet ITX Token Contract
- Minted ITX tokens are transferred to the Liquidity Contract
- The Liquidity Contract distributes ITX tokens as privacy mining rewards to users
- sITX (ScrollINTMAXToken): Reward token on Scroll network, initially non-transferable
- ITX (INTMAXToken): Main token on Ethereum mainnet
- Future Integration: sITX tokens are planned to be exchangeable with mainnet ITX tokens (not yet implemented)
An ERC20 token implementation for INTMAX on the Scroll network with the following features:
Key Features:
- Transfer Restrictions: Transfers are disabled by default and can only be enabled by admin
- Role-Based Access: Uses
DISTRIBUTORrole for privileged transfers even when transfers are disabled - Upgradeable: Implements UUPS upgradeability pattern
- Burn Functionality: Token holders can burn their own tokens
Roles:
DEFAULT_ADMIN_ROLE: Can enable transfers and authorize upgradesDISTRIBUTOR: Can transfer tokens even when transfers are disabled (typically the reward contract)
Functions:
initialize(admin, rewardContract, mintAmount): Initialize the contract with roles and initial supplyallowTransfers(): Enable transfers for all users (irreversible)burn(amount): Burn tokens from caller's accountsupportsInterface(interfaceId): Check interface support
A contract for managing and distributing rewards to block builders based on their contributions.
Key Features:
- Period-Based Rewards: Rewards are set and distributed per period
- Proportional Distribution: Rewards are distributed proportionally based on contribution scores
- Contribution Integration: Reads contribution data from the L2 Contribution contract using
BLOCK_POST_TAG - Batch Operations: Support for claiming multiple periods in a single transaction
- Upgradeable: Implements UUPS upgradeability pattern
Roles:
DEFAULT_ADMIN_ROLE: Can authorize contract upgradesREWARD_MANAGER_ROLE: Can set reward amounts for periods
Core Functions:
setReward(periodNumber, amount): Set total reward amount for a specific periodclaimReward(periodNumber): Claim rewards for a specific periodbatchClaimReward(periodNumbers[]): Claim rewards for multiple periodsgetClaimableReward(periodNumber, user): Calculate claimable reward amountgetReward(periodNumber): Get reward information for a periodgetCurrentPeriod(): Get current period from Contribution contract
Reward Calculation:
userReward = (totalPeriodReward × userContribution) ÷ totalContributions
States and Validations:
- Periods must end before rewards can be claimed
- Rewards must be set by reward manager before claiming
- Users cannot claim the same period twice
- Zero total contributions prevent claiming
A contract responsible for minting INTMAX tokens on mainnet and distributing them to liquidity contracts for privacy mining rewards.
Key Features:
- Token Minting: Mints ITX tokens from the mainnet INTMAX token contract
- Liquidity Distribution: Transfers minted tokens to designated liquidity address
- Administrative Transfers: Allows admin to transfer tokens to arbitrary addresses
- Upgradeable: Implements UUPS upgradeability pattern
Roles:
DEFAULT_ADMIN_ROLE: Can authorize upgrades and transfer tokens to any addressTOKEN_MANAGER_ROLE: Can mint tokens and transfer to liquidity
Functions:
mint(): Mint new INTMAX tokens to this contracttransferToLiquidity(amount): Transfer tokens to the liquidity addresstransferTo(to, amount): Transfer tokens to a specific address (admin only)
Install Foundry:
curl -L https://foundry.paradigm.xyz | bash
foundryup- Clone the repository:
git clone https://github.com/InternetMaximalism/intmax2-reward-contract.git
cd intmax2-reward-contract- Install dependencies:
forge install- Copy environment file:
cp .env.example .env- Configure environment variables in
.env:
# Deployment
DEPLOYER_PRIVATE_KEY=your_private_key
ADMIN_ADDRESS=your_admin_address
REWARD_MANAGER_ADDRESS=your_reward_manager_address
CONTRIBUTION_CONTRACT_ADDRESS=your_contribution_contract_address
INITIAL_SUPPLY=1000000000000000000000000 # 1M tokens with 18 decimals
# RPC URLs
SCROLL_SEPOLIA_RPC_URL=https://sepolia-rpc.scroll.io
SCROLL_MAINNET_RPC_URL=https://rpc.scroll.io
ETHEREUM_MAINNET_RPC_URL=your_ethereum_rpc_urlforge compileDeploy both ScrollINTMAXToken and BlockBuilderReward contracts:
# Deploy to Scroll Sepolia
forge script script/DeployAll.s.sol --rpc-url scroll-sepolia --broadcast --verify
# Deploy to Scroll Mainnet
forge script script/DeployAll.s.sol --rpc-url scroll-mainnet --broadcast --verifyDeploy ScrollINTMAXToken only:
forge script script/DeployScrollINTMAXToken.s.sol --rpc-url scroll-sepolia --broadcast --verifyDeploy BlockBuilderReward only:
forge script script/DeployBlockBuilderReward.s.sol --rpc-url scroll-sepolia --broadcast --verifyDeploy Minter (Ethereum Mainnet):
forge script script/DeployMinter.s.sol --rpc-url ethereum-mainnet --broadcast --verifyRun all tests:
forge testRun tests with verbose output:
forge test -vvvRun specific test file:
forge test --match-path test/block-builder-reward/BlockBuilderReward.t.solRun tests with gas reporting:
forge test --gas-report- All contracts use OpenZeppelin's AccessControl for role management
- Critical functions are protected by appropriate roles
- Upgrade authorization is restricted to admin roles
- Contracts use UUPS proxy pattern for upgradeability
- Only authorized admins can perform upgrades
- Implementation contracts have initializers disabled
- sITX tokens have transfer restrictions by default
- Only distributors can transfer when restrictions are active
- Transfer enablement is irreversible
- Rewards can only be claimed after periods end
- Double claiming is prevented
- Reward calculations use integer division (potential precision loss)
This project is licensed under the MIT License - see the LICENSE file for details.