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";
|
|
|
|
|
import "../registry/UniversalAssetRegistry.sol";
|
|
|
|
|
import "./UniversalCCIPBridge.sol";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @title BridgeOrchestrator
|
|
|
|
|
* @notice Routes bridge requests to appropriate asset-specific bridges
|
|
|
|
|
* @dev Central routing layer for multi-asset bridge system
|
|
|
|
|
*/
|
|
|
|
|
contract BridgeOrchestrator is
|
|
|
|
|
Initializable,
|
|
|
|
|
AccessControlUpgradeable,
|
|
|
|
|
UUPSUpgradeable
|
|
|
|
|
{
|
|
|
|
|
bytes32 public constant ROUTER_ADMIN_ROLE = keccak256("ROUTER_ADMIN_ROLE");
|
|
|
|
|
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
|
|
|
|
|
|
|
|
|
|
// Core dependencies
|
|
|
|
|
UniversalAssetRegistry public assetRegistry;
|
|
|
|
|
UniversalCCIPBridge public defaultBridge;
|
|
|
|
|
|
|
|
|
|
// Asset type to bridge mapping
|
|
|
|
|
mapping(bytes32 => address) public assetTypeToBridge;
|
|
|
|
|
mapping(address => bool) public isRegisteredBridge;
|
|
|
|
|
|
|
|
|
|
// Routing statistics
|
|
|
|
|
struct RoutingStats {
|
|
|
|
|
uint256 totalBridges;
|
|
|
|
|
uint256 successfulBridges;
|
|
|
|
|
uint256 failedBridges;
|
|
|
|
|
uint256 lastBridgeTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mapping(address => RoutingStats) public bridgeStats;
|
|
|
|
|
mapping(UniversalAssetRegistry.AssetType => RoutingStats) public assetTypeStats;
|
|
|
|
|
|
|
|
|
|
event BridgeRouted(
|
|
|
|
|
address indexed token,
|
|
|
|
|
UniversalAssetRegistry.AssetType assetType,
|
|
|
|
|
address indexed bridgeContract,
|
|
|
|
|
bytes32 indexed messageId
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
event AssetTypeBridgeRegistered(
|
|
|
|
|
bytes32 indexed assetTypeHash,
|
|
|
|
|
UniversalAssetRegistry.AssetType assetType,
|
|
|
|
|
address bridgeContract
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
event BridgeUnregistered(
|
|
|
|
|
bytes32 indexed assetTypeHash,
|
|
|
|
|
address bridgeContract
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/// @custom:oz-upgrades-unsafe-allow constructor
|
|
|
|
|
constructor() {
|
|
|
|
|
_disableInitializers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function initialize(
|
|
|
|
|
address _assetRegistry,
|
|
|
|
|
address _defaultBridge,
|
|
|
|
|
address admin
|
|
|
|
|
) external initializer {
|
|
|
|
|
__AccessControl_init();
|
|
|
|
|
__UUPSUpgradeable_init();
|
|
|
|
|
|
|
|
|
|
require(_assetRegistry != address(0), "Zero registry");
|
|
|
|
|
require(_defaultBridge != address(0), "Zero bridge");
|
|
|
|
|
|
|
|
|
|
assetRegistry = UniversalAssetRegistry(_assetRegistry);
|
|
|
|
|
defaultBridge = UniversalCCIPBridge(payable(_defaultBridge));
|
|
|
|
|
|
|
|
|
|
_grantRole(DEFAULT_ADMIN_ROLE, admin);
|
|
|
|
|
_grantRole(ROUTER_ADMIN_ROLE, admin);
|
|
|
|
|
_grantRole(UPGRADER_ROLE, admin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function _authorizeUpgrade(address newImplementation)
|
|
|
|
|
internal override onlyRole(UPGRADER_ROLE) {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Route bridge request to appropriate bridge
|
|
|
|
|
*/
|
|
|
|
|
function bridge(
|
|
|
|
|
UniversalCCIPBridge.BridgeOperation calldata op
|
|
|
|
|
) external payable returns (bytes32 messageId) {
|
|
|
|
|
// Get asset information
|
|
|
|
|
UniversalAssetRegistry.UniversalAsset memory asset = assetRegistry.getAsset(op.token);
|
|
|
|
|
require(asset.isActive, "Asset not active");
|
|
|
|
|
|
|
|
|
|
// Get bridge contract for this asset type
|
|
|
|
|
bytes32 assetTypeHash = bytes32(uint256(asset.assetType));
|
|
|
|
|
address bridgeContract = assetTypeToBridge[assetTypeHash];
|
|
|
|
|
|
|
|
|
|
// Use default bridge if no specialized bridge
|
|
|
|
|
if (bridgeContract == address(0)) {
|
|
|
|
|
bridgeContract = address(defaultBridge);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
require(isRegisteredBridge[bridgeContract], "Bridge not registered");
|
|
|
|
|
|
|
|
|
|
// Forward call to specialized bridge
|
|
|
|
|
(bool success, bytes memory data) = bridgeContract.call{value: msg.value}(
|
|
|
|
|
abi.encodeWithSelector(
|
|
|
|
|
UniversalCCIPBridge.bridge.selector,
|
|
|
|
|
op
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
require(success, "Bridge call failed");
|
|
|
|
|
messageId = abi.decode(data, (bytes32));
|
|
|
|
|
|
|
|
|
|
// Update statistics
|
|
|
|
|
_updateStats(bridgeContract, asset.assetType, true);
|
|
|
|
|
|
|
|
|
|
emit BridgeRouted(op.token, asset.assetType, bridgeContract, messageId);
|
|
|
|
|
|
|
|
|
|
return messageId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Register asset type bridge
|
|
|
|
|
*/
|
|
|
|
|
function registerAssetTypeBridge(
|
|
|
|
|
UniversalAssetRegistry.AssetType assetType,
|
|
|
|
|
address bridgeContract
|
|
|
|
|
) external onlyRole(ROUTER_ADMIN_ROLE) {
|
|
|
|
|
require(bridgeContract != address(0), "Zero address");
|
|
|
|
|
require(bridgeContract.code.length > 0, "Not a contract");
|
|
|
|
|
|
|
|
|
|
bytes32 assetTypeHash = bytes32(uint256(assetType));
|
|
|
|
|
assetTypeToBridge[assetTypeHash] = bridgeContract;
|
|
|
|
|
isRegisteredBridge[bridgeContract] = true;
|
|
|
|
|
|
|
|
|
|
emit AssetTypeBridgeRegistered(assetTypeHash, assetType, bridgeContract);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Unregister bridge
|
|
|
|
|
*/
|
|
|
|
|
function unregisterBridge(
|
|
|
|
|
UniversalAssetRegistry.AssetType assetType
|
|
|
|
|
) external onlyRole(ROUTER_ADMIN_ROLE) {
|
|
|
|
|
bytes32 assetTypeHash = bytes32(uint256(assetType));
|
|
|
|
|
address bridgeContract = assetTypeToBridge[assetTypeHash];
|
|
|
|
|
|
|
|
|
|
delete assetTypeToBridge[assetTypeHash];
|
|
|
|
|
// Note: We don't remove from isRegisteredBridge in case it's used elsewhere
|
|
|
|
|
|
|
|
|
|
emit BridgeUnregistered(assetTypeHash, bridgeContract);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Update routing statistics
|
|
|
|
|
*/
|
|
|
|
|
function _updateStats(
|
|
|
|
|
address bridgeContract,
|
|
|
|
|
UniversalAssetRegistry.AssetType assetType,
|
|
|
|
|
bool success
|
|
|
|
|
) internal {
|
|
|
|
|
RoutingStats storage bridgeStat = bridgeStats[bridgeContract];
|
|
|
|
|
RoutingStats storage typeStat = assetTypeStats[assetType];
|
|
|
|
|
|
|
|
|
|
bridgeStat.totalBridges++;
|
|
|
|
|
typeStat.totalBridges++;
|
|
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
|
bridgeStat.successfulBridges++;
|
|
|
|
|
typeStat.successfulBridges++;
|
|
|
|
|
} else {
|
|
|
|
|
bridgeStat.failedBridges++;
|
|
|
|
|
typeStat.failedBridges++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bridgeStat.lastBridgeTime = block.timestamp;
|
|
|
|
|
typeStat.lastBridgeTime = block.timestamp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notice Set default bridge
|
|
|
|
|
*/
|
|
|
|
|
function setDefaultBridge(address _defaultBridge) external onlyRole(DEFAULT_ADMIN_ROLE) {
|
|
|
|
|
require(_defaultBridge != address(0), "Zero address");
|
|
|
|
|
defaultBridge = UniversalCCIPBridge(payable(_defaultBridge));
|
|
|
|
|
isRegisteredBridge[_defaultBridge] = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// View functions
|
|
|
|
|
|
|
|
|
|
function getBridgeForAssetType(UniversalAssetRegistry.AssetType assetType)
|
|
|
|
|
external view returns (address) {
|
|
|
|
|
bytes32 assetTypeHash = bytes32(uint256(assetType));
|
2026-03-02 12:14:09 -08:00
|
|
|
address bridgeAddr = assetTypeToBridge[assetTypeHash];
|
|
|
|
|
return bridgeAddr != address(0) ? bridgeAddr : address(defaultBridge);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getBridgeStats(address bridgeContract)
|
|
|
|
|
external view returns (RoutingStats memory) {
|
|
|
|
|
return bridgeStats[bridgeContract];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAssetTypeStats(UniversalAssetRegistry.AssetType assetType)
|
|
|
|
|
external view returns (RoutingStats memory) {
|
|
|
|
|
return assetTypeStats[assetType];
|
|
|
|
|
}
|
|
|
|
|
}
|