contract GatewayBase {
// Core gateway state
ISuperPositions public superPositions;
IBaseRouter public superformRouter;
IMetaVault public vault;
address public receiverImplementation;
// Cross-chain tracking
mapping(bytes32 => address) public receivers;
mapping(uint256 => uint256) public pendingXChainInvests;
uint256 public totalpendingXChainInvests;
}
// Receiver contract deployment
function getReceiver(bytes32 key) public returns (address receiverAddress) {
receiverAddress = LibClone.clone(receiverImplementation);
ERC20Receiver(receiverAddress).initialize(key);
}
Engine Architecture Components
ERC7540EngineBase
└── Core withdrawal queue routing logic
└── State caching for cross-chain operations
└── Chain and vault selection algorithms
contract ERC7540EngineBase is ModuleBase {
// Core withdrawal routing functionality
function _prepareWithdrawalRoute(
ProcessRedeemRequestCache memory cache,
bool despiseDust
) internal view {
// Process local withdrawal queue
_exhaustWithdrawalQueue(cache, localWithdrawalQueue, false, despiseDust);
// Process cross-chain withdrawal queue
_exhaustWithdrawalQueue(cache, xChainWithdrawalQueue, true, despiseDust);
}
// Dust threshold management
function setDustThreshold(uint256 dustThreshold) external onlyRoles(ADMIN_ROLE) {
// Sets minimum threshold for cross-chain withdrawals
}
function getDustThreshold() public view returns (uint256) {
// Retrieves current minimum threshold
}
}
ERC7540EngineReader
└── Withdrawal simulation and preview
└── Route optimization analysis
contract ERC7540EngineReader is ERC7540EngineBase {
// Simulates withdrawal without execution
function previewWithdrawalRoute(
address controller,
uint256 shares,
bool despiseDust
) public view returns (ProcessRedeemRequestCache memory cachedRoute) {
// Simulates complete withdrawal route
// Calculates optimal asset sourcing from idle funds and vaults
// Returns detailed breakdown of withdrawal strategy
}
}