Skip to content

Commit fed3eae

Browse files
Merge pull request #362 from euler-xyz/development
Sync dev into master
2 parents d49db64 + 14eed1e commit fed3eae

File tree

103 files changed

+3917
-466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+3917
-466
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ DEPLOYER_KEY=
44
SAFE_KEY=
55
SAFE_ADDRESS=
66
SAFE_NONCE=
7+
SAFE_API_KEY=
78
VERIFIER_URL=
89
VERIFIER_API_KEY=
910
TENDERLY_ACCESS_KEY=

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ broadcast/
1313

1414
# Scripts temporary files
1515
script/*.json
16+
17+
# Node.js
18+
node_modules/
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
.npm
23+
.yarn-integrity
24+
25+
# Logs
26+
logs
27+
*.log

foundry.lock

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"lib/ethereum-vault-connector": {
3+
"rev": "a7d3c29ef7e4964736e47675e0588630d6afbfd7"
4+
},
5+
"lib/euler-earn": {
6+
"rev": "1c0b329e864ebea843dcdc090c3fb92f2a96a200"
7+
},
8+
"lib/euler-price-oracle": {
9+
"rev": "ffc3cb82615fc7d003a7f431175bd1eaf0bf41c5"
10+
},
11+
"lib/euler-swap": {
12+
"rev": "b948f4052d7ab3116235ec754368b7125dbd5082"
13+
},
14+
"lib/euler-vault-kit": {
15+
"rev": "422bf2447047d32aa9f4e5bab4be16ab3ea67ec2"
16+
},
17+
"lib/fee-flow": {
18+
"rev": "4a419c94e9cd68f65e11f07da9a69f726177cb9c"
19+
},
20+
"lib/forge-std": {
21+
"rev": "b93cf4bc34ff214c099dc970b153f85ade8c9f66"
22+
},
23+
"lib/layerzero-devtools": {
24+
"rev": "cc871a1bd4a28931fd3db4bb097ca30a8e057501"
25+
},
26+
"lib/layerzero-v2": {
27+
"rev": "7da76840e41dc593d3c2007ce35b911b1d816b4b"
28+
},
29+
"lib/openzeppelin-contracts": {
30+
"rev": "69c8def5f222ff96f2b5beff05dfba996368aa79"
31+
},
32+
"lib/openzeppelin-contracts-upgradeable": {
33+
"rev": "fa525310e45f91eb20a6d3baa2644be8e0adba31"
34+
},
35+
"lib/reward-streams": {
36+
"rev": "9eb7b8a7fa31c275d688063c4abd07165b50b89f"
37+
},
38+
"lib/solidity-bytes-utils": {
39+
"rev": "e0115c4d231910df47ce3b60625ce562fe4af985"
40+
}
41+
}

script/03_OracleAdapters.s.sol

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {UniswapV3Oracle} from "euler-price-oracle/adapter/uniswap/UniswapV3Oracl
1717
import {FixedRateOracle} from "euler-price-oracle/adapter/fixed/FixedRateOracle.sol";
1818
import {RateProviderOracle} from "euler-price-oracle/adapter/rate/RateProviderOracle.sol";
1919
import {PendleOracle} from "euler-price-oracle/adapter/pendle/PendleOracle.sol";
20+
import {PendleUniversalOracle} from "euler-price-oracle/adapter/pendle/PendleUniversalOracle.sol";
2021
import {IdleTranchesOracle} from "euler-price-oracle/adapter/idle/IdleTranchesOracle.sol";
2122

2223
contract ChainlinkAdapter is ScriptUtils {
@@ -533,6 +534,52 @@ contract PendleAdapter is ScriptUtils {
533534
}
534535
}
535536

537+
contract PendleUniversalAdapter is ScriptUtils {
538+
function run() public broadcast returns (address adapter) {
539+
string memory inputScriptFileName = "03_PendleUniversalAdapter_input.json";
540+
string memory outputScriptFileName = "03_PendleUniversalAdapter_output.json";
541+
string memory json = getScriptFile(inputScriptFileName);
542+
address adapterRegistry = vm.parseJsonAddress(json, ".adapterRegistry");
543+
bool addToAdapterRegistry = vm.parseJsonBool(json, ".addToAdapterRegistry");
544+
address pendleOracle = vm.parseJsonAddress(json, ".pendleOracle");
545+
address pendleMarket = vm.parseJsonAddress(json, ".pendleMarket");
546+
address base = vm.parseJsonAddress(json, ".base");
547+
address quote = vm.parseJsonAddress(json, ".quote");
548+
uint32 twapWindow = uint32(vm.parseJsonUint(json, ".twapWindow"));
549+
550+
adapter = execute(adapterRegistry, addToAdapterRegistry, pendleOracle, pendleMarket, base, quote, twapWindow);
551+
552+
string memory object;
553+
object = vm.serializeAddress("oracleAdapters", "adapter", adapter);
554+
vm.writeJson(object, string.concat(vm.projectRoot(), "/script/", outputScriptFileName));
555+
}
556+
557+
function deploy(
558+
address adapterRegistry,
559+
bool addToAdapterRegistry,
560+
address pendleOracle,
561+
address pendleMarket,
562+
address base,
563+
address quote,
564+
uint32 twapWindow
565+
) public broadcast returns (address adapter) {
566+
adapter = execute(adapterRegistry, addToAdapterRegistry, pendleOracle, pendleMarket, base, quote, twapWindow);
567+
}
568+
569+
function execute(
570+
address adapterRegistry,
571+
bool addToAdapterRegistry,
572+
address pendleOracle,
573+
address pendleMarket,
574+
address base,
575+
address quote,
576+
uint32 twapWindow
577+
) public returns (address adapter) {
578+
adapter = address(new PendleUniversalOracle(pendleOracle, pendleMarket, base, quote, twapWindow));
579+
if (addToAdapterRegistry) SnapshotRegistry(adapterRegistry).add(adapter, base, quote);
580+
}
581+
}
582+
536583
contract IdleTranchesAdapter is ScriptUtils {
537584
function run() public broadcast returns (address adapter) {
538585
string memory inputScriptFileName = "03_IdleTranchesAdapter_input.json";

script/50_CoreAndPeriphery.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ contract CoreAndPeriphery is BatchBuilder, SafeMultisendBuilder {
881881
peripheryAddresses.eulerEarnFactoryPerspective == address(0)
882882
&& peripheryAddresses.eulerEarnGovernedPerspective == address(0)
883883
) {
884-
if (input.deployEulerEarn) {
884+
if (coreAddresses.eulerEarnFactory != address(0)) {
885885
console.log("+ Deploying EulerEarnFactoryPerspective and Euler Earn GovernedPerspective...");
886886
EulerEarnPerspectivesDeployer deployer = new EulerEarnPerspectivesDeployer();
887887
address[] memory perspectives = deployer.deploy(coreAddresses.eulerEarnFactory);

script/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ It should contain the following environment variables:
2121
- `SAFE_KEY` (the private key which will be used to sign Safe transactions; this is optional if you don't send transactions via Safe or provide a different option to derive the Safe signer key, i.e. `--ledger` or `--account ACC_NAME`)
2222
- `SAFE_ADDRESS` (the Safe address which will be used to send transactions via Safe; this is optional if you don't send transactions via Safe. you can use the `--safe-address` option in the command instead. you may also provide the key from the `MultisigAddresses.json` file instead of providing the address)
2323
- `SAFE_NONCE` (the Safe nonce which will be used to send transactions via Safe; this is optional and if not provided, the script will try to retrieve it from the Safe). you can use the `--safe-nonce` option in the command as well
24+
- `SAFE_API_KEY` (the Safe API key that can be generated by signing up here: https://developer.safe.global/; if not provided, the Safe API may not be functional)
2425
- `VERIFIER_URL` (url of the contract verifier, i.e. https://api.polygonscan.com/api; this is optional and only needed for contracts verification)
2526
- `VERIFIER_API_KEY` (verifier api key; this is optional and only needed for contracts verification)
2627
- `TENDERLY_ACCESS_KEY` (tenderly access key; this is optional and only used for advanced use cases)

script/interactiveDeployment.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,11 +1305,11 @@ while true; do
13051305
euler_swap_fee_owner=${euler_swap_fee_owner:-$multisig_dao}
13061306
euler_swap_fee_recipient_setter=${euler_swap_fee_recipient_setter:-$multisig_dao}
13071307

1308-
if [ -z "$eulerEarnFactory" ] || [ "$eulerEarnFactory" == "$addressZero" ]; then
1308+
if { [ -z "$eulerEarnFactory" ] || [ "$eulerEarnFactory" == "$addressZero" ]; } && [ "$deploy_euler_earn" = "y" ]; then
13091309
forge compile lib/euler-earn/src $eulerEarnCompilerOptions --force
13101310
fi
13111311

1312-
if [ -z "$eulerSwapFactory_v1" ] || [ "$eulerSwapFactory_v1" == "$addressZero" ]; then
1312+
if { [ -z "$eulerSwapV1Factory" ] || [ "$eulerSwapV1Factory" == "$addressZero" ]; } && [ "$deploy_euler_swap_v1" = "y" ]; then
13131313
forge compile lib/euler-swap/src $eulerSwapCompilerOptions --force
13141314
fi
13151315

script/production/CustomScripts.s.sol

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ import {
2323
import {VaultLens, VaultInfoFull} from "../../src/Lens/VaultLens.sol";
2424
import {AccountLens, AccountInfo, AccountMultipleVaultsInfo} from "../../src/Lens/AccountLens.sol";
2525

26-
abstract contract CustomScriptBase is BatchBuilder {
27-
function run() public {
28-
execute();
29-
saveAddresses();
30-
}
31-
32-
function execute() public virtual {}
33-
}
34-
3526
contract GetVaultInfoFull is ScriptUtils {
3627
function run(address vault) public view returns (VaultInfoFull memory) {
3728
return VaultLens(lensAddresses.vaultLens).getVaultInfoFull(vault);
@@ -81,13 +72,13 @@ contract BridgeEULToLabsMultisig is ScriptUtils, SafeMultisendBuilder {
8172
util.run(dstChainId, dstAddress, amount);
8273
} else {
8374
(address to, uint256 value, bytes memory rawCalldata) =
84-
util.getSendCalldata(dstChainId, dstAddress, amount, 1e4);
75+
util.getSendCalldata(safe, dstChainId, dstAddress, amount, 1e4);
8576
addMultisendItem(tokenAddresses.EUL, abi.encodeCall(IERC20.approve, (to, amount)));
8677
addMultisendItem(to, value, rawCalldata);
8778
}
8879
}
8980

90-
if (multisendItemExists()) executeMultisend(safe, safeNonce++, false);
81+
if (multisendItemExists()) executeMultisend(safe, safeNonce++, true, false);
9182
}
9283
}
9384

@@ -188,8 +179,7 @@ contract MigratePosition is BatchBuilder {
188179
address[] memory controllers = IEVC(coreAddresses.evc).getControllers(sourceAccount);
189180

190181
for (uint256 i = 0; i < collaterals.length; ++i) {
191-
uint256 amount = IEVault(collaterals[i]).balanceOf(sourceAccount);
192-
if (amount == 0) continue;
182+
if (IEVault(collaterals[i]).balanceOf(sourceAccount) == 0) continue;
193183

194184
addBatchItem(
195185
coreAddresses.evc,
@@ -199,7 +189,7 @@ contract MigratePosition is BatchBuilder {
199189
addBatchItem(
200190
collaterals[i],
201191
sourceAccount,
202-
abi.encodeCall(IEVault(collaterals[i]).transfer, (destinationAccount, amount))
192+
abi.encodeCall(IEVault(collaterals[i]).transferFromMax, (sourceAccount, destinationAccount))
203193
);
204194
addBatchItem(
205195
coreAddresses.evc, address(0), abi.encodeCall(IEVC.disableCollateral, (sourceAccount, collaterals[i]))
@@ -230,8 +220,8 @@ contract MigratePosition is BatchBuilder {
230220
}
231221
}
232222

233-
contract MergeSafeBatchBuilderFiles is CustomScriptBase, SafeMultisendBuilder {
234-
function execute() public override {
223+
contract MergeSafeBatchBuilderFiles is ScriptUtils, SafeMultisendBuilder {
224+
function run() public {
235225
address safe = getSafe();
236226
string memory basePath = string.concat(
237227
vm.projectRoot(), "/", getPath(), "/SafeBatchBuilder_", vm.toString(safeNonce), "_", vm.toString(safe), "_"
@@ -250,8 +240,8 @@ contract MergeSafeBatchBuilderFiles is CustomScriptBase, SafeMultisendBuilder {
250240
}
251241
}
252242

253-
contract UnpauseEVaultFactory is CustomScriptBase {
254-
function execute() public override {
243+
contract UnpauseEVaultFactory is BatchBuilder {
244+
function run() public {
255245
SafeTransaction transaction = new SafeTransaction();
256246

257247
transaction.create(
@@ -265,8 +255,8 @@ contract UnpauseEVaultFactory is CustomScriptBase {
265255
}
266256
}
267257

268-
contract DeployAndConfigureCapRiskSteward is CustomScriptBase {
269-
function execute() public override {
258+
contract DeployAndConfigureCRSAndGACE is BatchBuilder {
259+
function run() public {
270260
require(getConfigAddress("riskSteward") != address(0), "Risk steward config address not found");
271261
require(getConfigAddress("gauntlet") != address(0), "Gauntlet config address not found");
272262

@@ -411,11 +401,13 @@ contract DeployAndConfigureCapRiskSteward is CustomScriptBase {
411401
(bool success,) = targets[i].call{value: values[i]}(payloads[i]);
412402
require(success, "timelock execution simulation failed");
413403
}
404+
405+
saveAddresses();
414406
}
415407
}
416408

417-
contract RedeployOracleUtilsAndVaultLenses is CustomScriptBase {
418-
function execute() public override {
409+
contract RedeployOracleUtilsAndVaultLenses is BatchBuilder {
410+
function run() public {
419411
{
420412
LensOracleDeployer deployer = new LensOracleDeployer();
421413
lensAddresses.oracleLens = deployer.deploy(peripheryAddresses.oracleAdapterRegistry);
@@ -433,5 +425,7 @@ contract RedeployOracleUtilsAndVaultLenses is CustomScriptBase {
433425
LensEulerEarnVaultDeployer deployer = new LensEulerEarnVaultDeployer();
434426
lensAddresses.eulerEarnVaultLens = deployer.deploy(lensAddresses.utilsLens);
435427
}
428+
429+
saveAddresses();
436430
}
437431
}

script/production/DeployOracleAdapters.sh

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ fi
4949
read -p "Provide the deployment name used to save results (default: default): " deployment_name
5050
deployment_name=${deployment_name:-default}
5151

52-
if [[ "$@" == *"--account"* ]]; then
52+
if [ -n "$DEPLOYER_KEY" ]; then
53+
set -- "$@" --private-key "$DEPLOYER_KEY"
54+
fi
55+
56+
if [[ "$@" == *"--account"* && -z "$DEPLOYER_KEY" ]]; then
5357
read -s -p "Enter keystore password: " password
5458
set -- "$@" --password "$password"
5559
echo ""
@@ -377,6 +381,30 @@ while IFS=, read -r -a columns || [ -n "$columns" ]; do
377381
base="${columns[8]}"
378382
quote="${columns[9]}"
379383

384+
jq -n \
385+
--argjson addToAdapterRegistry false \
386+
--arg adapterRegistry "0x0000000000000000000000000000000000000000" \
387+
--arg pendleOracle "${columns[6]}" \
388+
--arg pendleMarket "${columns[7]}" \
389+
--arg base "${columns[8]}" \
390+
--arg quote "${columns[9]}" \
391+
--arg twapWindow "${columns[10]}" \
392+
'{
393+
addToAdapterRegistry: $addToAdapterRegistry,
394+
adapterRegistry: $adapterRegistry,
395+
pendleOracle: $pendleOracle,
396+
pendleMarket: $pendleMarket,
397+
base: $base,
398+
quote: $quote,
399+
twapWindow: $twapWindow
400+
}' --indent 4 > script/${jsonName}_input.json
401+
elif [[ "$provider" == "PendleUniversal" ]]; then
402+
scriptName=${baseName}.s.sol:PendleUniversalAdapter
403+
jsonName=03_PendleUniversalAdapter
404+
405+
base="${columns[8]}"
406+
quote="${columns[9]}"
407+
380408
jq -n \
381409
--argjson addToAdapterRegistry false \
382410
--arg adapterRegistry "0x0000000000000000000000000000000000000000" \
@@ -423,7 +451,23 @@ while IFS=, read -r -a columns || [ -n "$columns" ]; do
423451
continue
424452
fi
425453

426-
if script/utils/executeForgeScript.sh $scriptName "$@"; then
454+
skip=false
455+
if [[ "$provider" == *Pendle* ]]; then
456+
result=$(cast call "${columns[6]}" "getOracleState(address,uint32)(bool,uint16,bool)" ${columns[7]} ${columns[10]} --rpc-url $DEPLOYMENT_RPC_URL)
457+
increaseCardinalityRequired=$(echo "$result" | head -1)
458+
cardinalityRequired=$(echo "$result" | sed -n '2p')
459+
oldestObservationSatisfied=$(echo "$result" | tail -1)
460+
461+
if [[ "$increaseCardinalityRequired" == "true" ]]; then
462+
echo "Increasing observation cardinality for $adapterName..."
463+
cast send "${columns[7]}" "increaseObservationsCardinalityNext(uint16)" $cardinalityRequired --rpc-url $DEPLOYMENT_RPC_URL "$@"
464+
skip=true
465+
elif [[ "$oldestObservationSatisfied" == "false" ]]; then
466+
skip=true
467+
fi
468+
fi
469+
470+
if [[ "$skip" != "true" ]] && script/utils/executeForgeScript.sh $scriptName "$@"; then
427471
counter=$(script/utils/getFileNameCounter.sh "$deployment_dir/output/${jsonName}.json")
428472
adapter=$(jq -r '.adapter' "script/${jsonName}_output.json")
429473
entry="${baseSymbol},${quoteSymbol},${provider},${adapterName},${adapter},$base,$quote,${shouldWhitelist}"
@@ -442,7 +486,13 @@ while IFS=, read -r -a columns || [ -n "$columns" ]; do
442486
for json_file in script/*.json; do
443487
rm "$json_file"
444488
done
445-
echo "Error deploying $adapterName. Exiting..."
446-
exit 1
489+
490+
if [[ "$skip" == "true" ]]; then
491+
echo "Skipping deployment of $adapterName. Insufficient observation history."
492+
continue
493+
else
494+
echo "Error deploying $adapterName. Exiting..."
495+
exit 1
496+
fi
447497
fi
448498
done < <(tr -d '\r' < "$csv_file")

0 commit comments

Comments
 (0)