Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More scripts #137

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Private key to interact with contracts using scripts inside /script
WALLET_PRIVATE_KEY=0xa26..
# RPC
MAINNET_RPC_URL="https://"
ARBITRUM_RPC_URL="https://"
Expand Down
7 changes: 4 additions & 3 deletions script/AddStrategies.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ contract AddStrategies is ScriptUtil {
EulerEarn eulerEarn;

function run() public {
// load wallet
uint256 userKey = vm.envUint("WALLET_PRIVATE_KEY");
address userAddress = vm.rememberKey(userKey);

// load JSON file
string memory inputScriptFileName = "AddStrategies_input.json";
string memory json = _getJsonFile(inputScriptFileName);

uint256 userKey = vm.parseJsonUint(json, ".userKey");
address userAddress = vm.rememberKey(userKey);

eulerEarn = EulerEarn(vm.parseJsonAddress(json, ".eulerEarn"));
address[] memory strategies = vm.parseJsonAddressArray(json, ".strategies");
uint256[] memory allocationPoints = vm.parseJsonUintArray(json, ".allocationPoints");
Expand Down
42 changes: 42 additions & 0 deletions script/AdjustAllocationPoints.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {ScriptUtil} from "./ScriptUtil.s.sol";
import {EulerEarn} from "../src/EulerEarn.sol";

/// @title Script to add strategies to an existent Euler Earn vault.
// to run:
// fill .env
// Run: source .env
// fil relevant json file
// Run: forge script ./script/AdjustAllocationPoints.s.sol --rpc-url arbitrum --broadcast --slow -vvvvvv
contract AdjustAllocationPoints is ScriptUtil {
error InputsMismatch();

/// @dev EulerEarnFactory contract.
EulerEarn eulerEarn;

function run() public {
// load wallet
uint256 userKey = vm.envUint("WALLET_PRIVATE_KEY");
address userAddress = vm.rememberKey(userKey);

// load JSON file
string memory inputScriptFileName = "AdjustAllocationPoints_input.json";
string memory json = _getJsonFile(inputScriptFileName);

eulerEarn = EulerEarn(vm.parseJsonAddress(json, ".eulerEarn"));
address[] memory strategies = vm.parseJsonAddressArray(json, ".strategies");
uint256[] memory allocationPoints = vm.parseJsonUintArray(json, ".newAllocationPoints");

require(strategies.length == allocationPoints.length, InputsMismatch());

vm.startBroadcast(userAddress);

for (uint256 i; i < strategies.length; i++) {
eulerEarn.adjustAllocationPoints(strategies[i], allocationPoints[i]);
}

vm.stopBroadcast();
}
}
7 changes: 4 additions & 3 deletions script/DeployEulerEarn.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ contract DeployEulerEarn is ScriptUtil {
EulerEarnFactory eulerEulerEarnFactory;

function run() public returns (address) {
// load wallet
uint256 userKey = vm.envUint("WALLET_PRIVATE_KEY");
address userAddress = vm.rememberKey(userKey);

// load JSON file
string memory inputScriptFileName = "DeployEulerEarn_input.json";
string memory json = _getJsonFile(inputScriptFileName);

uint256 userKey = vm.parseJsonUint(json, ".userKey");
address userAddress = vm.rememberKey(userKey);

eulerEulerEarnFactory = EulerEarnFactory(vm.parseJsonAddress(json, ".eulerEulerEarnFactory"));
address asset = vm.parseJsonAddress(json, ".asset");
string memory name = vm.parseJsonString(json, ".name");
Expand Down
7 changes: 4 additions & 3 deletions script/DeployProtocol.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ contract DeployProtocol is ScriptUtil {
EulerEarnFactory eulerEulerEarnFactory;

function run() public {
// load wallet
uint256 deployerKey = vm.envUint("WALLET_PRIVATE_KEY");
address deployerAddress = vm.rememberKey(deployerKey);

// load JSON file
string memory inputScriptFileName = "DeployProtocol_input.json";
string memory json = _getJsonFile(inputScriptFileName);

uint256 deployerKey = vm.parseJsonUint(json, "deployerKey");
address deployerAddress = vm.rememberKey(deployerKey);

address evc = vm.parseJsonAddress(json, "evc");
address balanceTracker = vm.parseJsonAddress(json, "balanceTracker");
address permit2 = vm.parseJsonAddress(json, "permit2");
Expand Down
7 changes: 4 additions & 3 deletions script/Harvest.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ contract Harvest is ScriptUtil {
EulerEarn eulerEarn;

function run() public {
// load wallet
uint256 userKey = vm.envUint("WALLET_PRIVATE_KEY");
address userAddress = vm.rememberKey(userKey);

// load JSON file
string memory inputScriptFileName = "Harvest_input.json";
string memory json = _getJsonFile(inputScriptFileName);

uint256 userKey = vm.parseJsonUint(json, ".userKey");
address userAddress = vm.rememberKey(userKey);

eulerEarn = EulerEarn(vm.parseJsonAddress(json, ".eulerEarn"));

vm.startBroadcast(userAddress);
Expand Down
7 changes: 4 additions & 3 deletions script/Rebalance.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ contract Rebalance is ScriptUtil {
EulerEarn eulerEarn;

function run() public {
// load wallet
uint256 userKey = vm.envUint("WALLET_PRIVATE_KEY");
address userAddress = vm.rememberKey(userKey);

// load JSON file
string memory inputScriptFileName = "Rebalance_input.json";
string memory json = _getJsonFile(inputScriptFileName);

uint256 userKey = vm.parseJsonUint(json, ".userKey");
address userAddress = vm.rememberKey(userKey);

eulerEarn = EulerEarn(vm.parseJsonAddress(json, ".eulerEarn"));
address[] memory strategies = vm.parseJsonAddressArray(json, ".strategies");

Expand Down
39 changes: 39 additions & 0 deletions script/RemoveStrategies.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {ScriptUtil} from "./ScriptUtil.s.sol";
import {EulerEarn} from "../src/EulerEarn.sol";

/// @title Script to add strategies to an existent Euler Earn vault.
// to run:
// fill .env
// Run: source .env
// fil relevant json file
// Run: forge script ./script/RemoveStrategies.s.sol --rpc-url arbitrum --broadcast --slow -vvvvvv
contract RemoveStrategies is ScriptUtil {
error InputsMismatch();

/// @dev EulerEarnFactory contract.
EulerEarn eulerEarn;

function run() public {
// load wallet
uint256 userKey = vm.envUint("WALLET_PRIVATE_KEY");
address userAddress = vm.rememberKey(userKey);

// load JSON file
string memory inputScriptFileName = "RemoveStrategies_input.json";
string memory json = _getJsonFile(inputScriptFileName);

eulerEarn = EulerEarn(vm.parseJsonAddress(json, ".eulerEarn"));
address[] memory strategies = vm.parseJsonAddressArray(json, ".strategies");

vm.startBroadcast(userAddress);

for (uint256 i; i < strategies.length; i++) {
eulerEarn.removeStrategy(strategies[i]);
}

vm.stopBroadcast();
}
}
1 change: 0 additions & 1 deletion script/json/AddStrategies_input.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"userKey": "0xabcd",
"eulerEarn": "0x2712DdE823026CeBa3030212EBaa2D876979E125",
"strategies": [
"0x6a47f0Dee6d11B8F43559792ca6ac20fbBE9c572",
Expand Down
11 changes: 11 additions & 0 deletions script/json/AdjustAllocationPoints_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"eulerEarn": "0x2712DdE823026CeBa3030212EBaa2D876979E125",
"strategies": [
"0x6a47f0Dee6d11B8F43559792ca6ac20fbBE9c572",
"0xC9216A2a8770f639eD6EfD9E068Bbd5De7665754"
],
"newAllocationPoints": [
"100",
"100"
]
}
1 change: 0 additions & 1 deletion script/json/DeployEulerEarn_input.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"userKey": "0xabcd",
"eulerEulerEarnFactory": "0xE141890d98B0a33adC6d10217Ed47daB035D393F",
"asset": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"name": "Earn Test 1",
Expand Down
1 change: 0 additions & 1 deletion script/json/DeployProtocol_input.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"deployerKey": "0xabcd",
"evc": "0xas",
"balanceTracker": "0xas",
"permit2": "0xas",
Expand Down
1 change: 0 additions & 1 deletion script/json/Harvest_input.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"userKey": "0xabcd",
"eulerEarn": "0x2712DdE823026CeBa3030212EBaa2D876979E125"
}
5 changes: 2 additions & 3 deletions script/json/Rebalance_input.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"userKey": "0xabcd",
"eulerEarn": "0x2712DdE823026CeBa3030212EBaa2D876979E125",
"strategies": [
"0x6a47f0Dee6d11B8F43559792ca6ac20fbBE9c572",
"0xC9216A2a8770f639eD6EfD9E068Bbd5De7665754"
"0xC9216A2a8770f639eD6EfD9E068Bbd5De7665754",
"0x6a47f0Dee6d11B8F43559792ca6ac20fbBE9c572"
]
}
7 changes: 7 additions & 0 deletions script/json/RemoveStrategies_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"eulerEarn": "0x2712DdE823026CeBa3030212EBaa2D876979E125",
"strategies": [
"0x6a47f0Dee6d11B8F43559792ca6ac20fbBE9c572",
"0xC9216A2a8770f639eD6EfD9E068Bbd5De7665754"
]
}
Loading