RWA delegate contracts provide optional, asset-specific risk management and compliance controls for Real World Asset tokens. They are only deployed when custom risk controls beyond the token’s native functionality are required.Base Contract: src/RWADelegate.sol
RWA delegates are optional. If an RWA token already implements sufficient controls (e.g., built-in KYC, transfer restrictions), no delegate is needed.
Single global daily volume limit applied to all users
Per-user volume tracking compared against the global limit
Automatic reset at 2pm Singapore Time (UTC+8)
Implementation:
Copy
Ask AI
struct UserVolumeData { uint256 volume; // Cumulative volume for the current day uint32 lastResetDay; // Day number of last reset uint96 reserved;}uint256 public dailyVolumeLimit; // Global limit applied to every usermapping(address => UserVolumeData) public userVolumes;uint256 public constant RESET_HOUR = 6; // 2pm SGT = 6am UTCfunction checkRWAOut(address user, uint256 amount, bytes calldata) external override returns (bool){ UserVolumeData storage data = userVolumes[user]; uint32 currentDay = _currentDay(); // Reset if new day if (data.lastResetDay < currentDay) { data.volume = 0; data.lastResetDay = currentDay; } // Check against the global daily volume limit require( data.volume + amount <= dailyVolumeLimit, "Daily volume limit exceeded" ); // Update user volume data.volume += amount; return true;}
// Set the global daily volume limit (applies to all users)function setDailyVolumeLimit(uint256 limit) external onlyRole(ISSUER_ADMIN_ROLE);// Get current volume status for a specific userfunction getVolumeStatus(address user) external view returns (uint256 used, uint256 limit, uint256 available);