From f649f376d1bd8712a7c1a576babb084c70d664fb Mon Sep 17 00:00:00 2001 From: Alex Towle Date: Wed, 28 Feb 2024 23:52:52 -0600 Subject: [PATCH] Update the refund in `deployAndInitialize` to follow CEI --- contracts/src/factory/HyperdriveFactory.sol | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contracts/src/factory/HyperdriveFactory.sol b/contracts/src/factory/HyperdriveFactory.sol index 977dc7fe5..d1db96821 100644 --- a/contracts/src/factory/HyperdriveFactory.sol +++ b/contracts/src/factory/HyperdriveFactory.sol @@ -679,14 +679,6 @@ contract HyperdriveFactory is IHyperdriveFactory { ); } - // Refund any excess ether that was sent to this contract. - if (refund > 0) { - (bool success, ) = payable(msg.sender).call{ value: refund }(""); - if (!success) { - revert IHyperdriveFactory.TransferFailed(); - } - } - // Set the default pausers and transfer the governance status to the // hyperdrive governance address. for (uint256 i = 0; i < _defaultPausers.length; ) { @@ -697,6 +689,14 @@ contract HyperdriveFactory is IHyperdriveFactory { } hyperdrive.setGovernance(hyperdriveGovernance); + // Refund any excess ether that was sent to this contract. + if (refund > 0) { + (bool success, ) = payable(msg.sender).call{ value: refund }(""); + if (!success) { + revert IHyperdriveFactory.TransferFailed(); + } + } + return hyperdrive; }