Skip to content

Commit 537806e

Browse files
Merge pull request #278 from euler-xyz/development
Development
2 parents af4a193 + 270cbe3 commit 537806e

37 files changed

+776
-561
lines changed

audits/MixBytes CapRiskSteward.pdf

717 KB
Binary file not shown.
873 KB
Binary file not shown.

foundry.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ override_spacing = true
2626
wrap_comments = true
2727
ignore = [
2828
"script/production/mainnet/clusters/PrimeCluster.s.sol",
29-
"script/production/mainnet/clusters/PendeulCluster.s.sol",
3029
"script/production/mainnet/clusters/YieldCluster.s.sol",
30+
"script/production/mainnet/clusters/RepoCluster.s.sol",
3131
"script/production/base/clusters/BaseCluster.s.sol",
3232
"script/production/swell/clusters/SwellCluster.s.sol",
3333
"script/production/swell/clusters/SwellETHCluster.s.sol"

script/08_Lenses.s.sol

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ contract Lenses is ScriptUtils {
1515
string memory inputScriptFileName = "08_Lenses_input.json";
1616
string memory outputScriptFileName = "08_Lenses_output.json";
1717
string memory json = getScriptFile(inputScriptFileName);
18+
address eVaultFactory = vm.parseJsonAddress(json, ".eVaultFactory");
1819
address oracleAdapterRegistry = vm.parseJsonAddress(json, ".oracleAdapterRegistry");
1920
address kinkIRMFactory = vm.parseJsonAddress(json, ".kinkIRMFactory");
2021
address adaptiveCurveIRMFactory = vm.parseJsonAddress(json, ".adaptiveCurveIRMFactory");
2122

22-
lenses = execute(oracleAdapterRegistry, kinkIRMFactory, adaptiveCurveIRMFactory);
23+
lenses = execute(eVaultFactory, oracleAdapterRegistry, kinkIRMFactory, adaptiveCurveIRMFactory);
2324

2425
string memory object;
2526
object = vm.serializeAddress("lenses", "accountLens", lenses[0]);
@@ -31,23 +32,26 @@ contract Lenses is ScriptUtils {
3132
vm.writeJson(object, string.concat(vm.projectRoot(), "/script/", outputScriptFileName));
3233
}
3334

34-
function deploy(address oracleAdapterRegistry, address kinkIRMFactory, address adaptiveCurveIRMFactory)
35-
public
36-
broadcast
37-
returns (address[] memory lenses)
38-
{
39-
lenses = execute(oracleAdapterRegistry, kinkIRMFactory, adaptiveCurveIRMFactory);
35+
function deploy(
36+
address eVaultFactory,
37+
address oracleAdapterRegistry,
38+
address kinkIRMFactory,
39+
address adaptiveCurveIRMFactory
40+
) public broadcast returns (address[] memory lenses) {
41+
lenses = execute(eVaultFactory, oracleAdapterRegistry, kinkIRMFactory, adaptiveCurveIRMFactory);
4042
}
4143

42-
function execute(address oracleAdapterRegistry, address kinkIRMFactory, address adaptiveCurveIRMFactory)
43-
public
44-
returns (address[] memory lenses)
45-
{
44+
function execute(
45+
address eVaultFactory,
46+
address oracleAdapterRegistry,
47+
address kinkIRMFactory,
48+
address adaptiveCurveIRMFactory
49+
) public returns (address[] memory lenses) {
4650
lenses = new address[](6);
4751
lenses[0] = address(new AccountLens());
4852
lenses[1] = address(new OracleLens(oracleAdapterRegistry));
4953
lenses[2] = address(new IRMLens(kinkIRMFactory, adaptiveCurveIRMFactory));
50-
lenses[3] = address(new UtilsLens(address(lenses[1])));
54+
lenses[3] = address(new UtilsLens(eVaultFactory, address(lenses[1])));
5155
lenses[4] = address(new VaultLens(address(lenses[1]), address(lenses[3]), address(lenses[2])));
5256
lenses[5] = address(new EulerEarnVaultLens(address(lenses[1]), address(lenses[3])));
5357
}
@@ -158,21 +162,22 @@ contract LensUtilsDeployer is ScriptUtils {
158162
string memory inputScriptFileName = "08_LensUtils_input.json";
159163
string memory outputScriptFileName = "08_LensUtils_output.json";
160164
string memory json = getScriptFile(inputScriptFileName);
165+
address eVaultFactory = vm.parseJsonAddress(json, ".eVaultFactory");
161166
address oracleLens = vm.parseJsonAddress(json, ".oracleLens");
162167

163-
utilsLens = execute(oracleLens);
168+
utilsLens = execute(eVaultFactory, oracleLens);
164169

165170
string memory object;
166171
object = vm.serializeAddress("lens", "utilsLens", utilsLens);
167172
vm.writeJson(object, string.concat(vm.projectRoot(), "/script/", outputScriptFileName));
168173
}
169174

170-
function deploy(address oracleLens) public broadcast returns (address utilsLens) {
171-
utilsLens = execute(oracleLens);
175+
function deploy(address eVaultFactory, address oracleLens) public broadcast returns (address utilsLens) {
176+
utilsLens = execute(eVaultFactory, oracleLens);
172177
}
173178

174-
function execute(address oracleLens) public returns (address utilsLens) {
175-
utilsLens = address(new UtilsLens(oracleLens));
179+
function execute(address eVaultFactory, address oracleLens) public returns (address utilsLens) {
180+
utilsLens = address(new UtilsLens(eVaultFactory, oracleLens));
176181
}
177182
}
178183

script/50_CoreAndPeriphery.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,7 @@ contract CoreAndPeriphery is BatchBuilder, SafeMultisendBuilder {
935935
if (lensAddresses.utilsLens == address(0)) {
936936
console.log("+ Deploying LensUtils...");
937937
LensUtilsDeployer deployer = new LensUtilsDeployer();
938-
lensAddresses.utilsLens = deployer.deploy(lensAddresses.oracleLens);
938+
lensAddresses.utilsLens = deployer.deploy(coreAddresses.eVaultFactory, lensAddresses.oracleLens);
939939
} else {
940940
console.log("- LensUtils already deployed. Skipping...");
941941
}

script/README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ To use the interactive deployment script, run the following command:
4646
or with options, i.e.:
4747

4848
```sh
49-
./script/interactiveDeployment.sh --account ACC_NAME --verify
49+
./script/interactiveDeployment.sh --account ACC_NAME --rpc-url RPC_URL
5050
```
5151

5252
You will be walked through the deployment process step by step.
@@ -56,23 +56,23 @@ You will be walked through the deployment process step by step.
5656
### Core and Periphery contracts deployment and configuration
5757

5858
```sh
59-
./script/interactiveDeployment.sh --account ACC_NAME --verify
59+
./script/interactiveDeployment.sh --account ACC_NAME --rpc-url RPC_URL
6060
```
6161

6262
After that, select option 50 and provide necessary input values.
6363

6464
### Core contracts ownership transfer
6565

6666
```sh
67-
./script/interactiveDeployment.sh --account ACC_NAME --verify
67+
./script/interactiveDeployment.sh --account ACC_NAME --rpc-url RPC_URL
6868
```
6969

7070
After that, select option 51 and provide necessary input values.
7171

7272
### Periphery contracts ownership transfer
7373

7474
```sh
75-
./script/interactiveDeployment.sh --account ACC_NAME --verify
75+
./script/interactiveDeployment.sh --account ACC_NAME --rpc-url RPC_URL
7676
```
7777

7878
After that, select option 52 and provide necessary input values.
@@ -133,6 +133,16 @@ You can pass `--verify` option to the deployment script in order to verify the d
133133

134134
You can pass `--dry-run` option to the deployment script in order to simulate the deployment without actually executing transactions.
135135

136+
### RPC URL
137+
138+
You can pass the RPC to the script using the `--rpc-url RPC_URL` option.
139+
140+
### Private key management
141+
142+
You can use standard Foundry options for providing the private key to the script, i.e. `--account ACC_NAME` or `--ledger`.
143+
144+
If neither option is provided, the script will look for `DEPLOYER_KEY` in your `.env` file.
145+
136146
### Batch via Safe
137147

138148
You can pass `--batch-via-safe` option to the deployment script in order to create the a batch transaction in the Safe UI. This only works if the result of the script is a transaction to be executed via the EVC batch. For this option to be used, ensure that `SAFE_KEY` and `SAFE_ADDRESS` are defined in the `.env` file or provide a different option to derive the Safe signer key instead, i.e. `--ledger` or `--account ACC_NAME`. The address associated must either be a signer or a delegate of the Safe in order to be able to send the transactions. You can also provide the `--safe-address` option to the command instead of `SAFE_ADDRESS` environment variable.
@@ -144,3 +154,16 @@ In case a timelock controller is installed as part of the governor contracts sui
144154
### Risk Steward
145155

146156
In case a risk steward contract is installed as part of the governor contracts suite, you can additionally pass `--risk-steward-address` option with the risk steward contract address to the deployment script in order to execute the transactions via the risk steward contract instead of trying to execute it directly.
157+
158+
## Timelock transaction execution
159+
160+
A utility script is provided to execute scheduled timelock transactions automatically. To use it, run:
161+
162+
```sh
163+
./script/production/ExecuteSolidityScript.sh ./script/utils/ExecuteTimelockTx.s.sol --account <ACCOUNT> --timelock-address <TIMELOCK_ADDRESS> --timelock-id <TIMELOCK_ID> --rpc-url <RPC_URL>
164+
```
165+
166+
Required options:
167+
- `--timelock-address`: The address of the timelock controller contract
168+
- `--timelock-id`: The ID of the scheduled transaction, which can be found in the logs emitted when the transaction was scheduled
169+
- `--timelock-salt`: (Optional) The salt used for the timelock operation. If not provided, zero is assumed

script/interactiveDeployment.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,13 +770,16 @@ while true; do
770770
scriptName=${baseName}.s.sol:Lenses
771771
jsonName=08_Lenses
772772

773+
read -p "Enter the EVault Factory address: " eVaultFactory
773774
read -p "Enter the Oracle Adapter Registry address: " oracle_adapter_registry
774775
read -p "Enter the Kink IRM Factory address: " kink_irm_factory
775776

776777
jq -n \
778+
--arg eVaultFactory "$eVaultFactory" \
777779
--arg oracleAdapterRegistry "$oracle_adapter_registry" \
778780
--arg kinkIRMFactory "$kink_irm_factory" \
779781
'{
782+
eVaultFactory: $eVaultFactory,
780783
oracleAdapterRegistry: $oracleAdapterRegistry,
781784
kinkIRMFactory: $kinkIRMFactory
782785
}' --indent 4 > script/${jsonName}_input.json
@@ -858,11 +861,14 @@ while true; do
858861
scriptName=${baseName}.s.sol:LensUtilsDeployer
859862
jsonName=08_LensUtils
860863

864+
read -p "Enter the EVault Factory address: " eVaultFactory
861865
read -p "Enter the Oracle Lens address: " oracle_lens
862866

863867
jq -n \
868+
--arg eVaultFactory "$eVaultFactory" \
864869
--arg oracleLens "$oracle_lens" \
865870
'{
871+
eVaultFactory: $eVaultFactory,
866872
oracleLens: $oracleLens
867873
}' --indent 4 > script/${jsonName}_input.json
868874
;;

script/production/ManageClusterBase.s.sol

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -778,13 +778,15 @@ abstract contract ManageClusterBase is BatchBuilder {
778778
}
779779

780780
function simulatePendingTransactions() internal {
781+
if (isSkipPendingSimulation()) return;
782+
781783
if (isBatchViaSafe()) {
782784
SafeTransaction safeUtil = new SafeTransaction();
783785
if (!safeUtil.isTransactionServiceAPIAvailable()) return;
784786

785787
vm.recordLogs();
786788
console.log("Simulating pending safe transactions");
787-
SafeTransaction.TransactionSimple[] memory transactions = safeUtil.getPendingTransactions(getSafe());
789+
SafeTransaction.TransactionSimple[] memory transactions = safeUtil.getPendingTransactions(getSimulateSafe());
788790

789791
for (uint256 i = 0; i < transactions.length; ++i) {
790792
try safeUtil.simulate(
@@ -797,7 +799,7 @@ abstract contract ManageClusterBase is BatchBuilder {
797799
}
798800
}
799801

800-
address payable timelock = payable(getTimelock());
802+
address payable timelock = payable(getSimulateTimelock());
801803
if (timelock != address(0)) {
802804
console.log("Simulating pending timelock transactions");
803805

@@ -843,16 +845,15 @@ abstract contract ManageClusterBase is BatchBuilder {
843845

844846
Vm.Log[] memory logs = vm.getRecordedLogs();
845847
for (uint256 i = 0; i < logs.length; ++i) {
846-
bytes32 id = logs[i].topics[1];
847-
848848
if (
849-
timelock != logs[i].emitter || topic[0] != logs[i].topics[0]
850-
|| !TimelockController(timelock).isOperationPending(id)
849+
timelock != logs[i].emitter || logs[i].topics.length < 2 || topic[0] != logs[i].topics[0]
850+
|| !TimelockController(timelock).isOperationPending(logs[i].topics[1])
851851
) continue;
852852

853853
(address target, uint256 value, bytes memory data, bytes32 predecessor, uint256 delay) =
854854
abi.decode(logs[i].data, (address, uint256, bytes, bytes32, uint256));
855855

856+
bytes32 id = logs[i].topics[1];
856857
vm.store(
857858
timelock, keccak256(abi.encode(uint256(id), uint256(1))), bytes32(uint256(block.timestamp - delay))
858859
);

0 commit comments

Comments
 (0)