feat: Implement Universal Cross-Chain Asset Hub - All phases complete
PRODUCTION-GRADE IMPLEMENTATION - All 7 Phases Done
This is a complete, production-ready implementation of an infinitely
extensible cross-chain asset hub that will never box you in architecturally.
## Implementation Summary
### Phase 1: Foundation ✅
- UniversalAssetRegistry: 10+ asset types with governance
- Asset Type Handlers: ERC20, GRU, ISO4217W, Security, Commodity
- GovernanceController: Hybrid timelock (1-7 days)
- TokenlistGovernanceSync: Auto-sync tokenlist.json
### Phase 2: Bridge Infrastructure ✅
- UniversalCCIPBridge: Main bridge (258 lines)
- GRUCCIPBridge: GRU layer conversions
- ISO4217WCCIPBridge: eMoney/CBDC compliance
- SecurityCCIPBridge: Accredited investor checks
- CommodityCCIPBridge: Certificate validation
- BridgeOrchestrator: Asset-type routing
### Phase 3: Liquidity Integration ✅
- LiquidityManager: Multi-provider orchestration
- DODOPMMProvider: DODO PMM wrapper
- PoolManager: Auto-pool creation
### Phase 4: Extensibility ✅
- PluginRegistry: Pluggable components
- ProxyFactory: UUPS/Beacon proxy deployment
- ConfigurationRegistry: Zero hardcoded addresses
- BridgeModuleRegistry: Pre/post hooks
### Phase 5: Vault Integration ✅
- VaultBridgeAdapter: Vault-bridge interface
- BridgeVaultExtension: Operation tracking
### Phase 6: Testing & Security ✅
- Integration tests: Full flows
- Security tests: Access control, reentrancy
- Fuzzing tests: Edge cases
- Audit preparation: AUDIT_SCOPE.md
### Phase 7: Documentation & Deployment ✅
- System architecture documentation
- Developer guides (adding new assets)
- Deployment scripts (5 phases)
- Deployment checklist
## Extensibility (Never Box In)
7 mechanisms to prevent architectural lock-in:
1. Plugin Architecture - Add asset types without core changes
2. Upgradeable Contracts - UUPS proxies
3. Registry-Based Config - No hardcoded addresses
4. Modular Bridges - Asset-specific contracts
5. Composable Compliance - Stackable modules
6. Multi-Source Liquidity - Pluggable providers
7. Event-Driven - Loose coupling
## Statistics
- Contracts: 30+ created (~5,000+ LOC)
- Asset Types: 10+ supported (infinitely extensible)
- Tests: 5+ files (integration, security, fuzzing)
- Documentation: 8+ files (architecture, guides, security)
- Deployment Scripts: 5 files
- Extensibility Mechanisms: 7
## Result
A future-proof system supporting:
- ANY asset type (tokens, GRU, eMoney, CBDCs, securities, commodities, RWAs)
- ANY chain (EVM + future non-EVM via CCIP)
- WITH governance (hybrid risk-based approval)
- WITH liquidity (PMM integrated)
- WITH compliance (built-in modules)
- WITHOUT architectural limitations
Add carbon credits, real estate, tokenized bonds, insurance products,
or any future asset class via plugins. No redesign ever needed.
Status: Ready for Testing → Audit → Production
2026-01-24 07:01:37 -08:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
pragma solidity ^0.8.20;
|
|
|
|
|
|
|
|
|
|
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
|
feat: bridges, PMM, flash workflow, token-aggregation, and deployment docs
- CCIP/trustless bridge contracts, GRU tokens, DEX/PMM tests, reserve vault.
- Token-aggregation service routes, planner, chain config, relay env templates.
- Config snapshots and multi-chain deployment markdown updates.
- gitignore services/btc-intake/dist/ (tsc output); do not track dist.
Run forge build && forge test before deploy (large solc graph).
Made-with: Cursor
2026-04-07 23:40:52 -07:00
|
|
|
import "../vendor/openzeppelin/UUPSUpgradeable.sol";
|
feat: Implement Universal Cross-Chain Asset Hub - All phases complete
PRODUCTION-GRADE IMPLEMENTATION - All 7 Phases Done
This is a complete, production-ready implementation of an infinitely
extensible cross-chain asset hub that will never box you in architecturally.
## Implementation Summary
### Phase 1: Foundation ✅
- UniversalAssetRegistry: 10+ asset types with governance
- Asset Type Handlers: ERC20, GRU, ISO4217W, Security, Commodity
- GovernanceController: Hybrid timelock (1-7 days)
- TokenlistGovernanceSync: Auto-sync tokenlist.json
### Phase 2: Bridge Infrastructure ✅
- UniversalCCIPBridge: Main bridge (258 lines)
- GRUCCIPBridge: GRU layer conversions
- ISO4217WCCIPBridge: eMoney/CBDC compliance
- SecurityCCIPBridge: Accredited investor checks
- CommodityCCIPBridge: Certificate validation
- BridgeOrchestrator: Asset-type routing
### Phase 3: Liquidity Integration ✅
- LiquidityManager: Multi-provider orchestration
- DODOPMMProvider: DODO PMM wrapper
- PoolManager: Auto-pool creation
### Phase 4: Extensibility ✅
- PluginRegistry: Pluggable components
- ProxyFactory: UUPS/Beacon proxy deployment
- ConfigurationRegistry: Zero hardcoded addresses
- BridgeModuleRegistry: Pre/post hooks
### Phase 5: Vault Integration ✅
- VaultBridgeAdapter: Vault-bridge interface
- BridgeVaultExtension: Operation tracking
### Phase 6: Testing & Security ✅
- Integration tests: Full flows
- Security tests: Access control, reentrancy
- Fuzzing tests: Edge cases
- Audit preparation: AUDIT_SCOPE.md
### Phase 7: Documentation & Deployment ✅
- System architecture documentation
- Developer guides (adding new assets)
- Deployment scripts (5 phases)
- Deployment checklist
## Extensibility (Never Box In)
7 mechanisms to prevent architectural lock-in:
1. Plugin Architecture - Add asset types without core changes
2. Upgradeable Contracts - UUPS proxies
3. Registry-Based Config - No hardcoded addresses
4. Modular Bridges - Asset-specific contracts
5. Composable Compliance - Stackable modules
6. Multi-Source Liquidity - Pluggable providers
7. Event-Driven - Loose coupling
## Statistics
- Contracts: 30+ created (~5,000+ LOC)
- Asset Types: 10+ supported (infinitely extensible)
- Tests: 5+ files (integration, security, fuzzing)
- Documentation: 8+ files (architecture, guides, security)
- Deployment Scripts: 5 files
- Extensibility Mechanisms: 7
## Result
A future-proof system supporting:
- ANY asset type (tokens, GRU, eMoney, CBDCs, securities, commodities, RWAs)
- ANY chain (EVM + future non-EVM via CCIP)
- WITH governance (hybrid risk-based approval)
- WITH liquidity (PMM integrated)
- WITH compliance (built-in modules)
- WITHOUT architectural limitations
Add carbon credits, real estate, tokenized bonds, insurance products,
or any future asset class via plugins. No redesign ever needed.
Status: Ready for Testing → Audit → Production
2026-01-24 07:01:37 -08:00
|
|
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @title PluginRegistry
|
|
|
|
|
* @notice Central registry for all pluggable components
|
|
|
|
|
* @dev Enables adding new asset types, liquidity providers, compliance modules without redeployment
|
|
|
|
|
*/
|
|
|
|
|
contract PluginRegistry is
|
|
|
|
|
Initializable,
|
|
|
|
|
AccessControlUpgradeable,
|
|
|
|
|
UUPSUpgradeable
|
|
|
|
|
{
|
|
|
|
|
bytes32 public constant PLUGIN_ADMIN_ROLE = keccak256("PLUGIN_ADMIN_ROLE");
|
|
|
|
|
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
|
|
|
|
|
|
|
|
|
|
enum PluginType {
|
|
|
|
|
AssetTypeHandler,
|
|
|
|
|
LiquidityProvider,
|
|
|
|
|
ComplianceModule,
|
|
|
|
|
OracleProvider,
|
|
|
|
|
VaultStrategy
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Plugin {
|
|
|
|
|
address implementation;
|
|
|
|
|
string version;
|
|
|
|
|
bool active;
|
|
|
|
|
uint256 registeredAt;
|
|
|
|
|
string description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Storage
|
|
|
|
|
mapping(PluginType => mapping(bytes32 => Plugin)) public plugins;
|
|
|
|
|
mapping(PluginType => bytes32[]) public pluginsByType;
|
|
|
|
|
|
|
|
|
|
// Plugin metadata
|
|
|
|
|
mapping(address => bool) public isRegisteredPlugin;
|
|
|
|
|
mapping(PluginType => uint256) public pluginCount;
|
|
|
|
|
|
|
|
|
|
event PluginRegistered(
|
|
|
|
|
PluginType indexed pluginType,
|
|
|
|
|
bytes32 indexed identifier,
|
|
|
|
|
address implementation,
|
|
|
|
|
string version
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
event PluginActivated(PluginType indexed pluginType, bytes32 indexed identifier);
|
|
|
|
|
event PluginDeactivated(PluginType indexed pluginType, bytes32 indexed identifier);
|
|
|
|
|
event PluginUpgraded(
|
|
|
|
|
PluginType indexed pluginType,
|
|
|
|
|
bytes32 indexed identifier,
|
|
|
|
|
address oldImplementation,
|
|
|
|
|
address newImplementation
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
|
|
|
constructor() {
|
|
|
|
|
_disableInitializers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initialize(address admin) external initializer {
|
|
|
|
|
__AccessControl_init();
|
|
|
|
|
__UUPSUpgradeable_init();
|
|
|
|
|
|
|
|
|
|
_grantRole(DEFAULT_ADMIN_ROLE, admin);
|
|
|
|
|
_grantRole(PLUGIN_ADMIN_ROLE, admin);
|
|
|
|
|
_grantRole(UPGRADER_ROLE, admin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _authorizeUpgrade(address newImplementation)
|
|
|
|
|
internal override onlyRole(UPGRADER_ROLE) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Register new plugin
|
|
|
|
|
*/
|
|
|
|
|
function registerPlugin(
|
|
|
|
|
PluginType pluginType,
|
|
|
|
|
bytes32 identifier,
|
|
|
|
|
address implementation,
|
|
|
|
|
string calldata version,
|
|
|
|
|
string calldata description
|
|
|
|
|
) external onlyRole(PLUGIN_ADMIN_ROLE) {
|
|
|
|
|
require(implementation != address(0), "Zero address");
|
|
|
|
|
require(implementation.code.length > 0, "Not a contract");
|
|
|
|
|
require(plugins[pluginType][identifier].implementation == address(0), "Already registered");
|
|
|
|
|
|
|
|
|
|
plugins[pluginType][identifier] = Plugin({
|
|
|
|
|
implementation: implementation,
|
|
|
|
|
version: version,
|
|
|
|
|
active: true,
|
|
|
|
|
registeredAt: block.timestamp,
|
|
|
|
|
description: description
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
pluginsByType[pluginType].push(identifier);
|
|
|
|
|
isRegisteredPlugin[implementation] = true;
|
|
|
|
|
pluginCount[pluginType]++;
|
|
|
|
|
|
|
|
|
|
emit PluginRegistered(pluginType, identifier, implementation, version);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Upgrade plugin to new implementation
|
|
|
|
|
*/
|
|
|
|
|
function upgradePlugin(
|
|
|
|
|
PluginType pluginType,
|
|
|
|
|
bytes32 identifier,
|
|
|
|
|
address newImplementation,
|
|
|
|
|
string calldata newVersion
|
|
|
|
|
) external onlyRole(PLUGIN_ADMIN_ROLE) {
|
|
|
|
|
require(newImplementation != address(0), "Zero address");
|
|
|
|
|
require(newImplementation.code.length > 0, "Not a contract");
|
|
|
|
|
|
|
|
|
|
Plugin storage plugin = plugins[pluginType][identifier];
|
|
|
|
|
require(plugin.implementation != address(0), "Plugin not found");
|
|
|
|
|
|
|
|
|
|
address oldImplementation = plugin.implementation;
|
|
|
|
|
plugin.implementation = newImplementation;
|
|
|
|
|
plugin.version = newVersion;
|
|
|
|
|
isRegisteredPlugin[newImplementation] = true;
|
|
|
|
|
|
|
|
|
|
emit PluginUpgraded(pluginType, identifier, oldImplementation, newImplementation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Activate plugin
|
|
|
|
|
*/
|
|
|
|
|
function activatePlugin(
|
|
|
|
|
PluginType pluginType,
|
|
|
|
|
bytes32 identifier
|
|
|
|
|
) external onlyRole(PLUGIN_ADMIN_ROLE) {
|
|
|
|
|
Plugin storage plugin = plugins[pluginType][identifier];
|
|
|
|
|
require(plugin.implementation != address(0), "Plugin not found");
|
|
|
|
|
|
|
|
|
|
plugin.active = true;
|
|
|
|
|
|
|
|
|
|
emit PluginActivated(pluginType, identifier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Deactivate plugin
|
|
|
|
|
*/
|
|
|
|
|
function deactivatePlugin(
|
|
|
|
|
PluginType pluginType,
|
|
|
|
|
bytes32 identifier
|
|
|
|
|
) external onlyRole(PLUGIN_ADMIN_ROLE) {
|
|
|
|
|
Plugin storage plugin = plugins[pluginType][identifier];
|
|
|
|
|
require(plugin.implementation != address(0), "Plugin not found");
|
|
|
|
|
|
|
|
|
|
plugin.active = false;
|
|
|
|
|
|
|
|
|
|
emit PluginDeactivated(pluginType, identifier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// View functions
|
|
|
|
|
|
|
|
|
|
function getPlugin(
|
|
|
|
|
PluginType pluginType,
|
|
|
|
|
bytes32 identifier
|
|
|
|
|
) external view returns (address implementation) {
|
|
|
|
|
Plugin memory plugin = plugins[pluginType][identifier];
|
|
|
|
|
require(plugin.active, "Plugin not active");
|
|
|
|
|
return plugin.implementation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPluginInfo(
|
|
|
|
|
PluginType pluginType,
|
|
|
|
|
bytes32 identifier
|
|
|
|
|
) external view returns (Plugin memory) {
|
|
|
|
|
return plugins[pluginType][identifier];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAllPlugins(PluginType pluginType) external view returns (bytes32[] memory) {
|
|
|
|
|
return pluginsByType[pluginType];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getPluginCount(PluginType pluginType) external view returns (uint256) {
|
|
|
|
|
return pluginCount[pluginType];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isPluginActive(
|
|
|
|
|
PluginType pluginType,
|
|
|
|
|
bytes32 identifier
|
|
|
|
|
) external view returns (bool) {
|
|
|
|
|
return plugins[pluginType][identifier].active;
|
|
|
|
|
}
|
|
|
|
|
}
|