@@ -23,9 +23,6 @@ contract AtomicBridgeInitiator is IAtomicBridgeInitiator, OwnableUpgradeable {
23
23
// Mapping of bridge transfer ids to BridgeTransfer structs
24
24
mapping (bytes32 => BridgeTransfer) public bridgeTransfers;
25
25
26
- // Total WETH pool balance
27
- uint256 public poolBalance;
28
-
29
26
address public counterpartyAddress;
30
27
IWETH9 public weth;
31
28
uint256 private nonce;
@@ -34,18 +31,15 @@ contract AtomicBridgeInitiator is IAtomicBridgeInitiator, OwnableUpgradeable {
34
31
uint256 public initiatorTimeLockDuration;
35
32
36
33
// Initialize the contract with WETH address, owner, custom time lock duration, and initial pool balance
37
- function initialize (address _weth , address owner , uint256 _timeLockDuration , uint256 _initialPoolBalance ) public initializer {
38
- if (_weth == address (0 )) {
34
+ function initialize (address _weth , address owner , uint256 _timeLockDuration ) public initializer {
35
+ if (_weth == address (0 ) && owner == address ( 0 ) ) {
39
36
revert ZeroAddress ();
40
37
}
41
38
weth = IWETH9 (_weth);
42
39
__Ownable_init (owner);
43
40
44
41
// Set the custom time lock duration
45
42
initiatorTimeLockDuration = _timeLockDuration;
46
-
47
- // Set the initial pool balance
48
- poolBalance = _initialPoolBalance;
49
43
}
50
44
51
45
function setCounterpartyAddress (address _counterpartyAddress ) external onlyOwner {
@@ -75,9 +69,6 @@ contract AtomicBridgeInitiator is IAtomicBridgeInitiator, OwnableUpgradeable {
75
69
if (! weth.transferFrom (originator, address (this ), wethAmount)) revert WETHTransferFailed ();
76
70
}
77
71
78
- // Update the pool balance
79
- poolBalance += totalAmount;
80
-
81
72
// Generate a unique nonce to prevent replay attacks, and generate a transfer ID
82
73
bridgeTransferId = keccak256 (abi.encodePacked (originator, recipient, hashLock, initiatorTimeLockDuration, block .timestamp , nonce++ ));
83
74
@@ -110,8 +101,6 @@ contract AtomicBridgeInitiator is IAtomicBridgeInitiator, OwnableUpgradeable {
110
101
if (block .timestamp < bridgeTransfer.timeLock) revert TimeLockNotExpired ();
111
102
bridgeTransfer.state = MessageState.REFUNDED;
112
103
113
- // Decrease pool balance and transfer WETH back to originator
114
- poolBalance -= bridgeTransfer.amount;
115
104
if (! weth.transfer (bridgeTransfer.originator, bridgeTransfer.amount)) revert WETHTransferFailed ();
116
105
117
106
emit BridgeTransferRefunded (bridgeTransferId);
@@ -120,8 +109,6 @@ contract AtomicBridgeInitiator is IAtomicBridgeInitiator, OwnableUpgradeable {
120
109
// Counterparty contract to withdraw WETH for originator
121
110
function withdrawWETH (address recipient , uint256 amount ) external {
122
111
if (msg .sender != counterpartyAddress) revert Unauthorized ();
123
- if (poolBalance < amount) revert InsufficientWethBalance ();
124
- poolBalance -= amount;
125
112
if (! weth.transfer (recipient, amount)) revert WETHTransferFailed ();
126
113
}
127
114
}
0 commit comments