diff --git a/script/AddLeafX509.s.sol b/script/AddLeafX509.s.sol index 9a6f6f98..2f2b8695 100644 --- a/script/AddLeafX509.s.sol +++ b/script/AddLeafX509.s.sol @@ -4,7 +4,6 @@ pragma solidity >=0.8.0 <0.9.0; import { BaseScript } from "script/BaseScript.s.sol"; import { IEnclaveVerifier } from "puffer/interface/IEnclaveVerifier.sol"; import { stdJson } from "forge-std/StdJson.sol"; -import { Strings } from "openzeppelin/utils/Strings.sol"; /** * @title Deposit ETH script @@ -15,8 +14,7 @@ import { Strings } from "openzeppelin/utils/Strings.sol"; */ contract AddLeaftX509 is BaseScript { function run(bytes calldata leafX509Cert) external broadcast { - string memory guardiansDeployment = - vm.readFile(string.concat("./output/", Strings.toString(block.chainid), "-guardians.json")); + string memory guardiansDeployment = vm.readFile("./output/puffer.json"); address payable enclaveVerifier = payable(stdJson.readAddress(guardiansDeployment, ".enclaveVerifier")); IEnclaveVerifier(enclaveVerifier).addLeafX509(leafX509Cert); diff --git a/script/DeployPuffer.s.sol b/script/DeployPuffer.s.sol index 15785aae..a9d32350 100644 --- a/script/DeployPuffer.s.sol +++ b/script/DeployPuffer.s.sol @@ -21,7 +21,6 @@ import { UpgradeableBeacon } from "openzeppelin/proxy/beacon/UpgradeableBeacon.s import { GuardiansDeployment, PufferProtocolDeployment } from "./DeploymentStructs.sol"; import { ValidatorTicket } from "puffer/ValidatorTicket.sol"; import { IPufferOracle } from "pufETH/interface/IPufferOracle.sol"; -import { IWETH } from "pufETH/interface/Other/IWETH.sol"; /** * @title DeployPuffer diff --git a/script/3_DepositETH.s.sol b/script/DepositETH.s.sol similarity index 75% rename from script/3_DepositETH.s.sol rename to script/DepositETH.s.sol index bb39c45c..d3845275 100644 --- a/script/3_DepositETH.s.sol +++ b/script/DepositETH.s.sol @@ -2,8 +2,8 @@ pragma solidity >=0.8.0 <0.9.0; import { BaseScript } from "script/BaseScript.s.sol"; -import { IPufferPool } from "puffer/interface/IPufferPool.sol"; import { stdJson } from "forge-std/StdJson.sol"; +import { PufferVaultMainnet } from "pufETH/PufferVaultMainnet.sol"; /** * @title Deposit ETH script @@ -18,8 +18,8 @@ contract DepositETH is BaseScript { */ function run(uint256 ethAmount) external broadcast { string memory pufferDeployment = vm.readFile("./output/puffer.json"); - address payable pool = payable(stdJson.readAddress(pufferDeployment, ".pufferPool")); + address payable vault = payable(stdJson.readAddress(pufferDeployment, ".PufferVault")); - IPufferPool(pool).depositETH{ value: ethAmount }(); + PufferVaultMainnet(vault).depositETH{ value: ethAmount }(_broadcaster); } } diff --git a/script/SetGuardianEnclaveMeasurements.s.sol b/script/SetGuardianEnclaveMeasurements.s.sol index f5d6c436..30242fda 100644 --- a/script/SetGuardianEnclaveMeasurements.s.sol +++ b/script/SetGuardianEnclaveMeasurements.s.sol @@ -4,7 +4,6 @@ pragma solidity >=0.8.0 <0.9.0; import { BaseScript } from "script/BaseScript.s.sol"; import { GuardianModule } from "../src/GuardianModule.sol"; import { stdJson } from "forge-std/StdJson.sol"; -import { Strings } from "openzeppelin/utils/Strings.sol"; /** * @title Deposit ETH script @@ -15,8 +14,7 @@ import { Strings } from "openzeppelin/utils/Strings.sol"; */ contract SetEnclaveMeasurements is BaseScript { function run(bytes32 mrenclave, bytes32 mrsigner) external broadcast { - string memory guardiansDeployment = - vm.readFile(string.concat("./output/", Strings.toString(block.chainid), "-guardians.json")); + string memory guardiansDeployment = vm.readFile("./output/puffer.json"); address payable module = payable(stdJson.readAddress(guardiansDeployment, ".guardianModule")); diff --git a/shell-scripts/deploy_puffer_protocol.sh b/shell-scripts/deploy_puffer_protocol.sh index 5c4a80c8..0f51b052 100755 --- a/shell-scripts/deploy_puffer_protocol.sh +++ b/shell-scripts/deploy_puffer_protocol.sh @@ -9,6 +9,9 @@ export IS_LOCAL_ANVIL=true export MR_ENCLAVE=2f1488bd64b2c85fc3fe4fa535a89cfa5282ae960e902664ff5390909333e78c export MR_SIGNER=83d719e77deaca1470f6baf62a4d774303c899db69020f9c70ee1dfc08c7ce9e +# 500 ETHER, replace with whatever amount you want to deposit +export ETH_AMOUNT=500000000000000000000 + echo "DEPLOYING" forge script script/DeployEverything.s.sol:DeployEverything --rpc-url=$RPC_URL --sig 'run(address[] calldata, uint256)' "[0xDDDeAfB492752FC64220ddB3E7C9f1d5CcCdFdF0]" 1 --broadcast @@ -20,3 +23,6 @@ forge script script/AddLeafX509.s.sol:AddLeaftX509 --rpc-url=$RPC_URL --broadcas # Send 10 ETH to PUFFER_SHARED_WALLET cast send 0xDDDeAfB492752FC64220ddB3E7C9f1d5CcCdFdF0 --value 10ether --private-key $PK --rpc-url=$RPC_URL + +echo "Deposit initial liquidity for PufferVault 500 ETH" +forge script script/DepositETH.s.sol:DepositETH --rpc-url=$RPC_URL --broadcast --sig "run(uint256)" $ETH_AMOUNT -vvvv --private-key $PK \ No newline at end of file diff --git a/src/LibGuardianMessages.sol b/src/LibGuardianMessages.sol index 4bd93cbf..b4c5e167 100644 --- a/src/LibGuardianMessages.sol +++ b/src/LibGuardianMessages.sol @@ -29,9 +29,10 @@ library LibGuardianMessages { bytes32 depositDataRoot ) internal pure returns (bytes32) { return keccak256( - //solhint-disable-next-line func-named-parameters abi.encode(validatorIndex, vtBurnOffset, pubKey, withdrawalCredentials, signature, depositDataRoot) - ).toEthSignedMessageHash(); + ) + //solhint-disable-next-line func-named-parameters + .toEthSignedMessageHash(); } /** diff --git a/src/interface/IPufferPool.sol b/src/interface/IPufferPool.sol deleted file mode 100644 index faea9940..00000000 --- a/src/interface/IPufferPool.sol +++ /dev/null @@ -1,104 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.8.0 <0.9.0; - -import { IERC20 } from "openzeppelin/token/ERC20/IERC20.sol"; - -/** - * @title IPufferPool - * @author Puffer Finance - * @custom:security-contact security@puffer.fi - */ -interface IPufferPool is IERC20 { - /** - * @notice Thrown if the sender did not send enough ETH in the transaction - * @dev Signature "0x242b035c" - */ - error InvalidETHAmount(); - - /** - * Thrown if the "rescued" token is pufETH - * @dev Signature "0x961c9a4f" - */ - error InvalidToken(address token); - - /** - * @notice Emitted when ETH is deposited to PufferPool - * @param pufETHRecipient is the recipient address - * @param ethAmountDeposited is the ETH amount deposited - * @param pufETHAmount is the pufETH amount received in return - * @dev Signature "0x73a19dd210f1a7f902193214c0ee91dd35ee5b4d920cba8d519eca65a7b488ca" - */ - event Deposited(address pufETHRecipient, uint256 ethAmountDeposited, uint256 pufETHAmount); - - /** - * @notice Deposits ETH and `msg.sender` receives pufETH in return - * @return pufETH amount minted - * @dev Signature "0xf6326fb3" - */ - function depositETH() external payable returns (uint256); - - /** - * - * @notice Burns `pufETHAmount` from the transaction sender - * @dev Signature "0x42966c68" - */ - function burn(uint256 pufETHAmount) external; - - /** - * @notice Calculates the equivalent pufETH amount for a given `amount` of ETH based on the current ETH:pufETH exchange rate - * Suppose that the exchange rate is 1 : 1.05 and the user is wondering how much `pufETH` will he receive if he deposits `amount` ETH. - * - * outputAmount = amount * (1 / exchangeRate) // because the exchange rate is 1 to 1.05 - * outputAmount = amount * (1 / 1.05) - * outputAmount = amount * 0.95238095238 - * - * if the user is depositing 1 ETH, he would get 0.95238095238 pufETH in return - * - * @param amount The amount of ETH to be converted to pufETH - * @dev Signature "0x1b5ebe05" - * @return The equivalent amount of pufETH - */ - function calculateETHToPufETHAmount(uint256 amount) external view returns (uint256); - - /** - * @notice Calculates the equivalent ETH amount for a given `pufETHAmount` based on the current ETH:pufETH exchange rate - * - * Suppose that the exchange rate is 1 : 1.05 and the user is wondering how much `pufETH` will he receive if he wants to redeem `pufETHAmount` worth of pufETH. - * - * outputAmount = pufETHAmount * (1.05 / 1) // because the exchange rate is 1 to 1.05 (ETH to pufETH) - * outputAmount = pufETHAmount * 1.05 - * - * if the user is redeeming 1 pufETH, he would get 1.05 ETH in return - * - * NOTE: The calculation does not take in the account any withdrawal fee. - * - * @param pufETHAmount The amount of pufETH to be converted to ETH - * @dev Signature "0x149a74ed" - * @return The equivalent amount of ETH - */ - function calculatePufETHtoETHAmount(uint256 pufETHAmount) external view returns (uint256); - - /** - * @notice Returns the exchange rate of pufETH to ETH - * - * The exchange rate starts at 1:1, because there is equal amount of ETH and pufETH in the protocol. - * As the Validators join and pay Smoothing Commitments, there will be more ETH than pufETH in the protocol, - * meaning that the exchange rate will change. - * - * conversion rate = (deposits + rewards - penalties) / pufETH supply - * - * At the protocol’s inception, Bob stakes 10 ETH and receives 10 pufETH. - * Then, after some time, the protocol earns 2 ETH of rewards from smoothing commitments and restaking. - * Now Bob’s 10 pufETH is backed by 12 ETH, making the conversion rate (10+2−0)/10=1.2 ETH per pufETH. - * - * @dev Signature "0x38220d4d" - * @return The current exchange rate of pufETH to ETH - */ - function getPufETHtoETHExchangeRate() external view returns (uint256); - - /** - * @notice Transfers `ethAmount` to `to` - * @dev Signature "0x7b1a4909" - */ - function transferETH(address to, uint256 ethAmount) external; -}