-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathUpgrade.s.sol
More file actions
60 lines (47 loc) · 2.36 KB
/
Copy pathUpgrade.s.sol
File metadata and controls
60 lines (47 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;
import "forge-std/Script.sol";
import {TransparentUpgradeableProxy} from "@openzeppelin/proxy/transparent/TransparentUpgradeableProxy.sol";
import {IPoolAddressesProvider} from "@aave-v3-core/interfaces/IPoolAddressesProvider.sol";
import {ATokenVaultV2} from "../src/ATokenVaultV2.sol";
contract Upgrade is Script {
// DEPLOYMENT PARAMETERS - CHANGE THESE FOR YOUR VAULT
// ===================================================
address constant VAULT_ADDRESS = address(0); // Vault to upgrade
address constant UNDERLYING_ASSET_ADDRESS = address(0); // Underlying asset listed in the Aave Protocol
uint16 constant REFERRAL_CODE = 0; // Referral code to use
address constant AAVE_POOL_ADDRESSES_PROVIDER_ADDRESS = address(0); // PoolAddressesProvider contract of the Aave Pool
// ===================================================
function getChainId() public view returns (uint256) {
uint256 chainId;
assembly {
chainId := chainid()
}
return chainId;
}
function run() external {
// require(vm.envExists("DEPLOYER_ADDRESS"), "DEPLOYER_ADDRESS env var not set");
address deployerAddress = vm.envAddress("DEPLOYER_ADDRESS");
console.log("Deployer address: ", deployerAddress);
console.log("Deployer balance: ", deployerAddress.balance);
console.log("BlockNumber: ", block.number);
console.log("ChainId: ", getChainId());
console.log("Deploying vault...");
vm.startBroadcast(deployerAddress);
// Deploy new implementation
ATokenVaultV2 newImple = new ATokenVaultV2(
UNDERLYING_ASSET_ADDRESS,
REFERRAL_CODE,
IPoolAddressesProvider(AAVE_POOL_ADDRESSES_PROVIDER_ADDRESS)
);
console.log("VaultV2 impl deployed at: ", address(newImple));
console.log("Initializing...");
// Encode the initializer call
bytes memory data = abi.encodeWithSelector(ATokenVaultV2.initializeV2.selector);
console.logBytes(data);
TransparentUpgradeableProxy proxy = TransparentUpgradeableProxy(payable(VAULT_ADDRESS));
proxy.upgradeToAndCall(address(newImple), data);
vm.stopBroadcast();
console.log("Vault proxy upgraded at: ", address(proxy), " with implementation: ", address(newImple));
}
}