Overview
The Treasury contract manages the economic pools of the Nexis Network. It receives inflows from agent slashing and early withdrawal penalties, distributes them across three pools (treasury, insurance, rewards), and enables authorized distribution of rewards to agents. Contract Address (Testnet):0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
Key Features:
- Three-pool system: Treasury, Insurance, Rewards
- Configurable distribution ratios
- Handles slashed stakes and early exit penalties
- Reward distribution to agents with REWARDS_ROLE authorization
- Pool withdrawal with WITHDRAW_ROLE authorization
- Multi-asset support (ETH and ERC20 tokens)
- Upgradeable UUPS proxy pattern
Contract Constants
Data Structures
DistributionConfig
- Treasury: 40% (4,000 bps)
- Insurance: 30% (3,000 bps)
- Rewards: 30% (3,000 bps)
PoolBalances
Pool Management
poolBalances
Query pool balances for a specific asset.Asset address (address(0) for ETH, token address for ERC20)
PoolBalances- Struct containing balances for all three pools
rewardsBalance
Query available rewards balance for a specific asset.Asset address
uint256- Available rewards balance
JavaScript
Solidity
Inflow Handling
These methods are called automatically by the Agents contract when stakes are slashed or early exit penalties are collected.handleSlash
Process slashed stake from an agent. Only callable by addresses with INFLOW_ROLE (typically the Agents contract).Agent ID that was slashed
Asset address
Amount slashed
For ETH, must equal amount; for ERC20, must be 0
JavaScript
Solidity
handleEarlyExitPenalty
Process early withdrawal penalty from an agent. Only callable by INFLOW_ROLE.Agent ID that paid penalty
Asset address
Penalty amount
JavaScript
Solidity
recordRewardDeposit
Record a direct deposit to the rewards pool (e.g., from Tasks contract or external contributions).Asset address
Amount deposited
For ETH, must equal amount; for ERC20, tokens must be transferred before calling
Reward Distribution
distributeReward
Distribute rewards from rewards pool to an agent. Only callable by REWARDS_ROLE.Agent ID to reward
Asset to distribute
Amount to distribute (must be ≤ rewards balance)
Address to send rewards (address(0) = agent owner)
Human-readable reason for distribution
- Agent must be registered
- Sufficient balance in rewards pool
- Caller must have REWARDS_ROLE
AgentNotKnown(uint256)- Agent not registeredInsufficientRewards(address asset, uint256 requested, uint256 available)- Not enough rewards
Pool Withdrawals
withdrawTreasury
Withdraw from treasury pool. Only callable by WITHDRAW_ROLE.Asset to withdraw
Amount to withdraw (must be ≤ treasury balance)
Recipient address (cannot be zero address)
JavaScript
Solidity
withdrawInsurance
Withdraw from insurance pool. Only callable by WITHDRAW_ROLE.Asset to withdraw
Amount to withdraw (must be ≤ insurance balance)
Recipient address
JavaScript
Solidity
Configuration
setDistribution
Update pool distribution ratios. Only callable by DEFAULT_ADMIN_ROLE.Treasury share in basis points (0-10000)
Insurance share in basis points (0-10000)
Rewards share in basis points (0-10000)
- Sum must equal 10,000 (100%)
InvalidBps()- Sum does not equal 10,000
setAgents
Update Agents contract address. Only callable by DEFAULT_ADMIN_ROLE.New Agents contract address (cannot be zero)
JavaScript
Solidity
Query Methods
distribution
JavaScript
agents
Complete Example: Reward Distribution Campaign
Here’s a complete example of distributing rewards to top-performing agents:Events Reference
Error Reference
Treasury Economics
Pool Purpose
Treasury Pool
Protocol development, operations, grants, and strategic initiatives
Insurance Pool
Coverage for black swan events, protocol bugs, or agent failures
Rewards Pool
Performance incentives, bounties, and community rewards
Inflow Sources
Best Practices
Distribution Ratios
Distribution Ratios
- Adjust based on protocol needs and growth stage
- Early stage: Higher rewards % for agent adoption
- Mature stage: Higher treasury % for sustainability
- Always maintain adequate insurance reserves
Reward Distribution
Reward Distribution
- Document clear criteria for rewards
- Use transparent, objective metrics (reputation, tasks completed)
- Consider time-based campaigns (monthly, quarterly)
- Batch distributions to save gas costs
Pool Management
Pool Management
- Monitor pool balances regularly
- Set thresholds for pool withdrawals
- Use multi-sig for WITHDRAW_ROLE
- Document all withdrawal purposes
Integration with Other Contracts
The Treasury contract is called by:-
Agents Contract:
handleSlash()- When stakes are slashedhandleEarlyExitPenalty()- When early withdrawals occur
-
Tasks Contract:
recordRewardDeposit()- When disputed tasks are resolved without refund
-
External Contributors:
recordRewardDeposit()- For direct reward contributions