Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve: rename Spoke Pool's hubPool variable to withdrawalRecipient #629

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions contracts/Arbitrum_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ contract Arbitrum_SpokePool is SpokePool, CircleCCTPAdapter {
* relay hash collisions.
* @param _l2GatewayRouter Address of L2 token gateway. Can be reset by admin.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(
uint32 _initialDepositId,
address _l2GatewayRouter,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient);
_setL2GatewayRouter(_l2GatewayRouter);
}

Expand Down Expand Up @@ -87,15 +88,15 @@ contract Arbitrum_SpokePool is SpokePool, CircleCCTPAdapter {
function _bridgeTokensToHubPool(uint256 amountToReturn, address l2TokenAddress) internal override {
// If the l2TokenAddress is UDSC, we need to use the CCTP bridge.
if (_isCCTPEnabled() && l2TokenAddress == address(usdcToken)) {
_transferUsdc(hubPool, amountToReturn);
_transferUsdc(withdrawalRecipient, amountToReturn);
} else {
// Check that the Ethereum counterpart of the L2 token is stored on this contract.
address ethereumTokenToBridge = whitelistedTokens[l2TokenAddress];
require(ethereumTokenToBridge != address(0), "Uninitialized mainnet token");
//slither-disable-next-line unused-return
ArbitrumL2ERC20GatewayLike(l2GatewayRouter).outboundTransfer(
ethereumTokenToBridge, // _l1Token. Address of the L1 token to bridge over.
hubPool, // _to. Withdraw, over the bridge, to the l1 hub pool contract.
withdrawalRecipient, // _to. Withdraw, over the bridge, to the l1 hub pool contract.
amountToReturn, // _amount.
"" // _data. We don't need to send any data for the bridging action.
);
Expand Down
7 changes: 4 additions & 3 deletions contracts/Base_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ contract Base_SpokePool is Ovm_SpokePool {
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, Lib_PredeployAddresses.OVM_ETH);
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient, Lib_PredeployAddresses.OVM_ETH);
}
}
7 changes: 4 additions & 3 deletions contracts/Blast_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ contract Blast_SpokePool is Ovm_SpokePool {
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
* @dev this method also sets yield settings for the Blast SpokePool.
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, Lib_PredeployAddresses.OVM_ETH);
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient, Lib_PredeployAddresses.OVM_ETH);

// Sets native yield to be claimable manually.
BLAST_YIELD_CONTRACT.configureClaimableYield();
Expand Down
12 changes: 9 additions & 3 deletions contracts/Boba_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ contract Boba_SpokePool is Ovm_SpokePool {
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, 0x4200000000000000000000000000000000000006);
__OvmSpokePool_init(
_initialDepositId,
_crossDomainAdmin,
_withdrawalRecipient,
0x4200000000000000000000000000000000000006
);
}
}
9 changes: 5 additions & 4 deletions contracts/Ethereum_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ contract Ethereum_SpokePool is SpokePool, OwnableUpgradeable {
* @dev crossDomainAdmin is unused on this contract.
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(uint32 _initialDepositId, address _hubPool) public initializer {
function initialize(uint32 _initialDepositId, address _withdrawalRecipient) public initializer {
__Ownable_init();
__SpokePool_init(_initialDepositId, _hubPool, _hubPool);
__SpokePool_init(_initialDepositId, _withdrawalRecipient, _withdrawalRecipient);
}

/**************************************
* INTERNAL FUNCTIONS *
**************************************/

function _bridgeTokensToHubPool(uint256 amountToReturn, address l2TokenAddress) internal override {
IERC20Upgradeable(l2TokenAddress).safeTransfer(hubPool, amountToReturn);
IERC20Upgradeable(l2TokenAddress).safeTransfer(withdrawalRecipient, amountToReturn);
}

// The SpokePool deployed to the same network as the HubPool must be owned by the HubPool.
Expand Down
13 changes: 7 additions & 6 deletions contracts/Linea_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,18 @@ contract Linea_SpokePool is SpokePool {
* @param _l2TokenBridge Address of Canonical Token Bridge. Can be reset by admin.
* @param _l2UsdcBridge Address of USDC Bridge. Can be reset by admin.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(
uint32 _initialDepositId,
IMessageService _l2MessageService,
ITokenBridge _l2TokenBridge,
IUSDCBridge _l2UsdcBridge,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient);
_setL2TokenBridge(_l2TokenBridge);
_setL2MessageService(_l2MessageService);
_setL2UsdcBridge(_l2UsdcBridge);
Expand Down Expand Up @@ -150,17 +151,17 @@ contract Linea_SpokePool is SpokePool {
// before the execution of any wrapped token refund leaf. So it must be unwrapped before being sent as a
// fee to the l2MessageService.
WETH9Interface(l2TokenAddress).withdraw(amountToReturn + msg.value); // Unwrap into ETH.
l2MessageService.sendMessage{ value: amountToReturn + msg.value }(hubPool, msg.value, "");
l2MessageService.sendMessage{ value: amountToReturn + msg.value }(withdrawalRecipient, msg.value, "");
}
// If the l1Token is USDC, then we need sent it via the USDC Bridge.
else if (l2TokenAddress == l2UsdcBridge.usdc()) {
IERC20(l2TokenAddress).safeIncreaseAllowance(address(l2UsdcBridge), amountToReturn);
l2UsdcBridge.depositTo{ value: msg.value }(amountToReturn, hubPool);
l2UsdcBridge.depositTo{ value: msg.value }(amountToReturn, withdrawalRecipient);
}
// For other tokens, we can use the Canonical Token Bridge.
else {
IERC20(l2TokenAddress).safeIncreaseAllowance(address(l2TokenBridge), amountToReturn);
l2TokenBridge.bridgeToken{ value: msg.value }(l2TokenAddress, amountToReturn, hubPool);
l2TokenBridge.bridgeToken{ value: msg.value }(l2TokenAddress, amountToReturn, withdrawalRecipient);
}
}

Expand Down
7 changes: 4 additions & 3 deletions contracts/Lisk_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ contract Lisk_SpokePool is Ovm_SpokePool {
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, Lib_PredeployAddresses.OVM_ETH);
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient, Lib_PredeployAddresses.OVM_ETH);
}
}
7 changes: 4 additions & 3 deletions contracts/Mode_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ contract Mode_SpokePool is Ovm_SpokePool {
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, Lib_PredeployAddresses.OVM_ETH);
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient, Lib_PredeployAddresses.OVM_ETH);
}
}
9 changes: 5 additions & 4 deletions contracts/Optimism_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,22 @@ contract Optimism_SpokePool is Ovm_SpokePool {
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool, Lib_PredeployAddresses.OVM_ETH);
__OvmSpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient, Lib_PredeployAddresses.OVM_ETH);
}

function _bridgeTokensToHubPool(uint256 amountToReturn, address l2TokenAddress) internal virtual override {
// Handle custom SNX bridge which doesn't conform to the standard bridge interface.
if (l2TokenAddress == SNX)
SynthetixBridgeToBase(SYNTHETIX_BRIDGE).withdrawTo(
hubPool, // _to. Withdraw, over the bridge, to the l1 pool contract.
withdrawalRecipient, // _to. Withdraw, over the bridge, to the l1 pool contract.
amountToReturn // _amount.
);
else super._bridgeTokensToHubPool(amountToReturn, l2TokenAddress);
Expand Down
15 changes: 8 additions & 7 deletions contracts/Ovm_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,19 @@ contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* relay hash collisions.
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
* @param _l2Eth Address of L2 ETH token. Usually should be Lib_PreeployAddresses.OVM_ETH but sometimes this can
* be different, like with Boba which flips the WETH and OVM_ETH addresses.
*/
function __OvmSpokePool_init(
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool,
address _withdrawalRecipient,
address _l2Eth
) public onlyInitializing {
l1Gas = 5_000_000;
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient);
//slither-disable-next-line missing-zero-check
l2Eth = _l2Eth;
}
Expand Down Expand Up @@ -153,15 +154,15 @@ contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
l2TokenAddress = l2Eth; // Set the l2TokenAddress to ETH.
IL2ERC20Bridge(Lib_PredeployAddresses.L2_STANDARD_BRIDGE).withdrawTo{ value: amountToReturn }(
l2TokenAddress, // _l2Token. Address of the L2 token to bridge over.
hubPool, // _to. Withdraw, over the bridge, to the l1 pool contract.
withdrawalRecipient, // _to. Withdraw, over the bridge, to the l1 pool contract.
amountToReturn, // _amount.
l1Gas, // _l1Gas. Unused, but included for potential forward compatibility considerations
"" // _data. We don't need to send any data for the bridging action.
);
}
// If the token is USDC && CCTP bridge is enabled, then bridge USDC via CCTP.
else if (_isCCTPEnabled() && l2TokenAddress == address(usdcToken)) {
_transferUsdc(hubPool, amountToReturn);
_transferUsdc(withdrawalRecipient, amountToReturn);
}
// Note we'll default to withdrawTo instead of bridgeERC20To unless the remoteL1Tokens mapping is set for
// the l2TokenAddress. withdrawTo should be used to bridge back non-native L2 tokens
Expand All @@ -185,15 +186,15 @@ contract Ovm_SpokePool is SpokePool, CircleCCTPAdapter {
// remoteL1Token on the other chain does not recognize the local token as the correct
// pair token, the ERC20 bridge will fail and the tokens will be returned to sender on
// this chain.
hubPool, // _to
withdrawalRecipient, // _to
amountToReturn, // _amount
l1Gas, // _l1Gas
"" // _data
);
} else {
tokenBridge.withdrawTo(
l2TokenAddress, // _l2Token. Address of the L2 token to bridge over.
hubPool, // _to. Withdraw, over the bridge, to the l1 pool contract.
withdrawalRecipient, // _to. Withdraw, over the bridge, to the l1 pool contract.
amountToReturn, // _amount.
l1Gas, // _l1Gas. Unused, but included for potential forward compatibility considerations
"" // _data. We don't need to send any data for the bridging action.
Expand Down
11 changes: 6 additions & 5 deletions contracts/PolygonZkEVM_SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,16 @@ contract PolygonZkEVM_SpokePool is SpokePool, IBridgeMessageReceiver {
* @param _l2PolygonZkEVMBridge Address of Polygon zkEVM's canonical bridge contract on L2.
* @param _initialDepositId Starting deposit ID. Set to 0 unless this is a re-deployment in order to mitigate
* @param _crossDomainAdmin Cross domain admin to set. Can be changed by admin.
* @param _hubPool Hub pool address to set. Can be changed by admin.
* @param _withdrawalRecipient Address which receives token withdrawals. Can be changed by admin. For Spoke Pools on L2, this will
* likely be the hub pool.
*/
function initialize(
IPolygonZkEVMBridge _l2PolygonZkEVMBridge,
uint32 _initialDepositId,
address _crossDomainAdmin,
address _hubPool
address _withdrawalRecipient
) public initializer {
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _hubPool);
__SpokePool_init(_initialDepositId, _crossDomainAdmin, _withdrawalRecipient);
_setL2PolygonZkEVMBridge(_l2PolygonZkEVMBridge);
}

Expand Down Expand Up @@ -177,7 +178,7 @@ contract PolygonZkEVM_SpokePool is SpokePool, IBridgeMessageReceiver {
WETH9Interface(l2TokenAddress).withdraw(amountToReturn); // Unwrap into ETH.
l2PolygonZkEVMBridge.bridgeAsset{ value: amountToReturn }(
POLYGON_ZKEVM_L1_NETWORK_ID,
hubPool,
withdrawalRecipient,
amountToReturn,
address(0),
true, // Indicates if the new global exit root is updated or not, which is true for asset bridges
Expand All @@ -187,7 +188,7 @@ contract PolygonZkEVM_SpokePool is SpokePool, IBridgeMessageReceiver {
IERC20(l2TokenAddress).safeIncreaseAllowance(address(l2PolygonZkEVMBridge), amountToReturn);
l2PolygonZkEVMBridge.bridgeAsset(
POLYGON_ZKEVM_L1_NETWORK_ID,
hubPool,
withdrawalRecipient,
amountToReturn,
l2TokenAddress,
true, // Indicates if the new global exit root is updated or not, which is true for asset bridges
Expand Down
Loading
Loading