@@ -14,7 +14,14 @@ import {
1414} from "./L1TokenBridgeRetryableSender.sol " ;
1515import {L1GatewayRouter} from "./gateway/L1GatewayRouter.sol " ;
1616import {L1OrbitGatewayRouter} from "./gateway/L1OrbitGatewayRouter.sol " ;
17- import {L1GatewayDeployer} from "./L1GatewayDeployer.sol " ;
17+ import {L1ERC20Gateway} from "./gateway/L1ERC20Gateway.sol " ;
18+ import {L1CustomGateway} from "./gateway/L1CustomGateway.sol " ;
19+ import {L1WethGateway} from "./gateway/L1WethGateway.sol " ;
20+ import {L1YbbERC20Gateway} from "./gateway/L1YbbERC20Gateway.sol " ;
21+ import {L1YbbCustomGateway} from "./gateway/L1YbbCustomGateway.sol " ;
22+ import {IMasterVaultFactory} from "../libraries/vault/IMasterVaultFactory.sol " ;
23+ import {IGatewayRouter} from "../libraries/gateway/IGatewayRouter.sol " ;
24+ import {ClonableBeaconProxy} from "../libraries/ClonableBeaconProxy.sol " ;
1825import {
1926 L2AtomicTokenBridgeFactory,
2027 OrbitSalts,
@@ -315,87 +322,122 @@ contract L1AtomicTokenBridgeCreator is Initializable, OwnableUpgradeable {
315322 );
316323 }
317324
325+ bool isFeeTokenBased = feeToken != address (0 );
326+
318327 if (args.isYieldBearingBridge) {
319- // Delegate YBB deployment to library
320- L1GatewayDeployer.YbbDeploymentResult memory ybbResult =
321- L1GatewayDeployer.deployYbbGateways (
322- L1GatewayDeployer.YbbDeploymentParams ({
323- inbox: args.inbox,
324- proxyAdmin: proxyAdmin,
325- upgradeExecutor: upgradeExecutor,
326- router: l1Deployment.router,
327- l2StandardGateway: l2Deployment.standardGateway,
328- l2CustomGateway: l2Deployment.customGateway,
329- l2BeaconProxyFactory: l2Deployment.beaconProxyFactory,
330- isFeeTokenBased: feeToken != address (0 )
331- }),
332- L1GatewayDeployer.YbbTemplates ({
333- ybbStandardGatewayTemplate: ybbL1Templates.ybbStandardGatewayTemplate,
334- ybbCustomGatewayTemplate: ybbL1Templates.ybbCustomGatewayTemplate,
335- feeTokenBasedYbbStandardGatewayTemplate: ybbL1Templates.feeTokenBasedYbbStandardGatewayTemplate,
336- feeTokenBasedYbbCustomGatewayTemplate: ybbL1Templates.feeTokenBasedYbbCustomGatewayTemplate,
337- masterVaultFactoryTemplate: ybbL1Templates.masterVaultFactoryTemplate
338- }),
339- _getL1Salt (OrbitSalts.L1_MASTER_VAULT_FACTORY, args.inbox),
340- _getL1Salt (OrbitSalts.L1_STANDARD_GATEWAY, args.inbox),
341- _getL1Salt (OrbitSalts.L1_CUSTOM_GATEWAY, args.inbox)
328+ // deploy master vault factory
329+ address masterVaultFactory = _deployProxyWithSalt (
330+ _getL1Salt (OrbitSalts.L1_MASTER_VAULT_FACTORY, args.inbox),
331+ ybbL1Templates.masterVaultFactoryTemplate,
332+ proxyAdmin
333+ );
334+
335+ // deploy ybb standard gateway
336+ {
337+ address template = isFeeTokenBased
338+ ? ybbL1Templates.feeTokenBasedYbbStandardGatewayTemplate
339+ : ybbL1Templates.ybbStandardGatewayTemplate;
340+
341+ l1Deployment.standardGateway = _deployProxyWithSalt (
342+ _getL1Salt (OrbitSalts.L1_STANDARD_GATEWAY, args.inbox), template, proxyAdmin
342343 );
343344
344- // Initialize MasterVaultFactory after router is deployed
345- L1GatewayDeployer.initializeMasterVaultFactory (
346- ybbResult.masterVaultFactory,
347- ybbL1Templates.masterVaultTemplate,
348- upgradeExecutor,
349- l1Deployment.router
350- );
345+ L1YbbERC20Gateway (l1Deployment.standardGateway)
346+ .initialize (
347+ l2Deployment.standardGateway,
348+ l1Deployment.router,
349+ args.inbox,
350+ keccak256 (type (ClonableBeaconProxy).creationCode),
351+ l2Deployment.beaconProxyFactory,
352+ masterVaultFactory
353+ );
354+ }
355+
356+ // deploy ybb custom gateway
357+ {
358+ address template = isFeeTokenBased
359+ ? ybbL1Templates.feeTokenBasedYbbCustomGatewayTemplate
360+ : ybbL1Templates.ybbCustomGatewayTemplate;
361+
362+ l1Deployment.customGateway = _deployProxyWithSalt (
363+ _getL1Salt (OrbitSalts.L1_CUSTOM_GATEWAY, args.inbox), template, proxyAdmin
364+ );
351365
352- l1Deployment.standardGateway = ybbResult.standardGateway;
353- l1Deployment.customGateway = ybbResult.customGateway;
366+ L1YbbCustomGateway (l1Deployment.customGateway)
367+ .initialize (
368+ l2Deployment.customGateway,
369+ l1Deployment.router,
370+ args.inbox,
371+ upgradeExecutor,
372+ masterVaultFactory
373+ );
374+ }
375+
376+ // initialize master vault factory
377+ IMasterVaultFactory (masterVaultFactory)
378+ .initialize (
379+ ybbL1Templates.masterVaultTemplate,
380+ upgradeExecutor,
381+ IGatewayRouter (l1Deployment.router)
382+ );
354383 } else {
355- // Delegate standard gateway deployment to library
356- L1GatewayDeployer.StandardDeploymentResult memory standardResult =
357- L1GatewayDeployer.deployStandardGateways (
358- L1GatewayDeployer.StandardDeploymentParams ({
359- inbox: args.inbox,
360- proxyAdmin: proxyAdmin,
361- upgradeExecutor: upgradeExecutor,
362- router: l1Deployment.router,
363- l2StandardGateway: l2Deployment.standardGateway,
364- l2CustomGateway: l2Deployment.customGateway,
365- l2BeaconProxyFactory: l2Deployment.beaconProxyFactory,
366- isFeeTokenBased: feeToken != address (0 )
367- }),
368- L1GatewayDeployer.StandardTemplates ({
369- standardGatewayTemplate: l1Templates.standardGatewayTemplate,
370- feeTokenBasedStandardGatewayTemplate: l1Templates.feeTokenBasedStandardGatewayTemplate,
371- customGatewayTemplate: l1Templates.customGatewayTemplate,
372- feeTokenBasedCustomGatewayTemplate: l1Templates.feeTokenBasedCustomGatewayTemplate
373- }),
374- _getL1Salt (OrbitSalts.L1_STANDARD_GATEWAY, args.inbox),
375- _getL1Salt (OrbitSalts.L1_CUSTOM_GATEWAY, args.inbox)
384+ // deploy standard gateway
385+ {
386+ address template = isFeeTokenBased
387+ ? l1Templates.feeTokenBasedStandardGatewayTemplate
388+ : l1Templates.standardGatewayTemplate;
389+
390+ l1Deployment.standardGateway = _deployProxyWithSalt (
391+ _getL1Salt (OrbitSalts.L1_STANDARD_GATEWAY, args.inbox), template, proxyAdmin
392+ );
393+
394+ L1ERC20Gateway (l1Deployment.standardGateway)
395+ .initialize (
396+ l2Deployment.standardGateway,
397+ l1Deployment.router,
398+ args.inbox,
399+ keccak256 (type (ClonableBeaconProxy).creationCode),
400+ l2Deployment.beaconProxyFactory
401+ );
402+ }
403+
404+ // deploy custom gateway
405+ {
406+ address template = isFeeTokenBased
407+ ? l1Templates.feeTokenBasedCustomGatewayTemplate
408+ : l1Templates.customGatewayTemplate;
409+
410+ l1Deployment.customGateway = _deployProxyWithSalt (
411+ _getL1Salt (OrbitSalts.L1_CUSTOM_GATEWAY, args.inbox), template, proxyAdmin
376412 );
377413
378- l1Deployment.standardGateway = standardResult.standardGateway;
379- l1Deployment.customGateway = standardResult.customGateway;
414+ L1CustomGateway (l1Deployment.customGateway)
415+ .initialize (
416+ l2Deployment.customGateway,
417+ l1Deployment.router,
418+ args.inbox,
419+ upgradeExecutor
420+ );
421+ }
380422 }
381423
382424 // l1 weth gateway deployment block
383- if (feeToken == address (0 )) {
384- L1GatewayDeployer.WethDeploymentResult memory wethResult =
385- L1GatewayDeployer.deployWethGateway (
386- L1GatewayDeployer.WethDeploymentParams ({
387- inbox: args.inbox,
388- proxyAdmin: proxyAdmin,
389- router: l1Deployment.router,
390- l2WethGateway: l2Deployment.wethGateway,
391- l1Weth: l1Weth,
392- l2Weth: l2Deployment.weth
393- }),
394- l1Templates.wethGatewayTemplate,
395- _getL1Salt (OrbitSalts.L1_WETH_GATEWAY, args.inbox)
425+ if (! isFeeTokenBased) {
426+ l1Deployment.wethGateway = _deployProxyWithSalt (
427+ _getL1Salt (OrbitSalts.L1_WETH_GATEWAY, args.inbox),
428+ l1Templates.wethGatewayTemplate,
429+ proxyAdmin
430+ );
431+
432+ L1WethGateway (payable (l1Deployment.wethGateway))
433+ .initialize (
434+ l2Deployment.wethGateway,
435+ l1Deployment.router,
436+ args.inbox,
437+ l1Weth,
438+ l2Deployment.weth
396439 );
397440
398- l1Deployment.wethGateway = wethResult.wethGateway;
399441 l1Deployment.weth = l1Weth;
400442 }
401443
0 commit comments