-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,897 additions
and
213 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"Account": "0xe5bB889B1f0B6B4B7384Bd19cbb37adBDDa941a6", | ||
"Events": "0xd5fE5beAa04270B32f81Bf161768c44DF9880D11", | ||
"Account": "0x10B04483d762Bd4F193F35600112ad52391004A7", | ||
"Events": "0x15725a8159629ca9763deC4211e309c94d9f5CB0", | ||
"Factory": "0xF877315CfC91E69e7f4c308ec312cf91D66a095F", | ||
"Settings": "0x33B725a1B2dE9178121D423D2A1c062C5452f310" | ||
"Settings": "0xb2a20fCdc506a685122847b21E34536359E94C56" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
{ | ||
"Account": "0xf274803c43AC4888205E7eE482E9b7a379Cb8DB6", | ||
"Events": "0xc3d16e00833355b48d2fD69D838c6ACF004cf4b6", | ||
"Factory": "0x8234F990b149Ae59416dc260305E565e5DAfEb54", | ||
"Settings": "0x865dA103d126b3Be3599D84caB57109A861F5631" | ||
"prod": { | ||
"Account": "0x0f716Fc517955863824CD9317603E4795EDfffb4", | ||
"Events": "0x6B32d15a6Cb77ea227A6Fb19532b2de542c45AC6", | ||
"Factory": "0x8234F990b149Ae59416dc260305E565e5DAfEb54", | ||
"Settings": "0xf36003a5dd0B17D51ca1525857dEf220E579447D" | ||
}, | ||
"test": { | ||
"Account": "0x8cb4A30aBae39583711AB4795e50A0f9211Da533", | ||
"Events": "0x6D214A7B65C6B1Bd47b9F51535fFD9badDB4D193", | ||
"Factory": "0xd385275CAe5541D7e7fD1d01942868D25e60eBD9", | ||
"Settings": "0x688D6d242fB577BD91416aB93Dad43F1B0D69395" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity 0.8.18; | ||
|
||
import {Script} from "lib/forge-std/src/Script.sol"; | ||
|
||
import {IAddressResolver} from "script/utils/interfaces/IAddressResolver.sol"; | ||
|
||
import {Account} from "src/Account.sol"; | ||
import {Events} from "src/Events.sol"; | ||
import {Settings} from "src/Settings.sol"; | ||
import {IAccount} from "src/interfaces/IAccount.sol"; | ||
|
||
import { | ||
OPTIMISM_GELATO, | ||
OPTIMISM_OPS, | ||
FUTURES_MARKET_MANAGER, | ||
OPTIMISM_FACTORY, | ||
OPTIMISM_SYNTHETIX_ADDRESS_RESOLVER, | ||
OPTIMISM_UNISWAP_PERMIT2, | ||
OPTIMISM_UNISWAP_UNIVERSAL_ROUTER, | ||
PERPS_V2_EXCHANGE_RATE, | ||
PROXY_SUSD, | ||
SYSTEM_STATUS, | ||
OPTIMISM_PDAO, | ||
OPTIMISM_DEPLOYER, | ||
OPTIMISM_USDC, | ||
OPTIMISM_DAI, | ||
OPTIMISM_USDT, | ||
OPTIMISM_LUSD | ||
} from "script/utils/parameters/OptimismParameters.sol"; | ||
|
||
import { | ||
OPTIMISM_SEPOLIA_DEPLOYER, | ||
OPTIMISM_SEPOLIA_SYNTHETIX_ADDRESS_RESOLVER, | ||
OPTIMISM_SEPOLIA_GELATO, | ||
OPTIMISM_SEPOLIA_OPS, | ||
OPTIMISM_SEPOLIA_FACTORY, | ||
OPTIMISM_SEPOLIA_UNISWAP_UNIVERSAL_ROUTER, | ||
OPTIMISM_SEPOLIA_UNISWAP_PERMIT2 | ||
} from "script/utils/parameters/OptimismSepoliaParameters.sol"; | ||
|
||
/// @title Script to upgrade the Account implementation v2.1.3 -> v2.1.4 | ||
/// @author JaredBorders ([email protected]) | ||
|
||
/// @dev steps to deploy and verify on Optimism: | ||
/// (1) load the variables in the .env file via `source .env` | ||
/// (2) run `forge script script/upgrades/v2.1.4/Upgrade.s.sol:UpgradeAccountOptimism --rpc-url $ARCHIVE_NODE_URL_L2 --broadcast --verify -vvvv` | ||
/// (3) Smart Margin Account Factory owner (i.e. Kwenta pDAO) will need to call `upgradeAccountImplementation` on the Factory with the address of the new Account implementation | ||
contract UpgradeAccountOptimism is Script { | ||
function run() public { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
upgrade(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function upgrade() public returns (address implementation) { | ||
IAddressResolver addressResolver = | ||
IAddressResolver(OPTIMISM_SYNTHETIX_ADDRESS_RESOLVER); | ||
|
||
address marginAsset = addressResolver.getAddress({name: PROXY_SUSD}); | ||
address perpsV2ExchangeRate = | ||
addressResolver.getAddress({name: PERPS_V2_EXCHANGE_RATE}); | ||
address futuresMarketManager = | ||
addressResolver.getAddress({name: FUTURES_MARKET_MANAGER}); | ||
address systemStatus = addressResolver.getAddress({name: SYSTEM_STATUS}); | ||
|
||
address events = address(new Events({_factory: OPTIMISM_FACTORY})); | ||
|
||
// set owner to deploy so that the owner can set the orderFlowFee and token whitelist | ||
address settings = address( | ||
new Settings({ | ||
_owner: (msg.sender == OPTIMISM_DEPLOYER) | ||
? OPTIMISM_DEPLOYER | ||
: address(this) | ||
}) | ||
); | ||
|
||
// USDC, DAI, USDT, LUSD token addresses whitelisted | ||
Settings(settings).setTokenWhitelistStatus(OPTIMISM_USDC, true); | ||
Settings(settings).setTokenWhitelistStatus(OPTIMISM_DAI, true); | ||
Settings(settings).setTokenWhitelistStatus(OPTIMISM_USDT, true); | ||
Settings(settings).setTokenWhitelistStatus(OPTIMISM_LUSD, true); | ||
|
||
// Order flow fee set to 0.5 BPS | ||
Settings(settings).setOrderFlowFee(5); | ||
|
||
// transfer ownership to pDAO following settings configuration | ||
// during the upgrade process | ||
Settings(settings).transferOwnership(OPTIMISM_PDAO); | ||
|
||
IAccount.AccountConstructorParams memory params = IAccount | ||
.AccountConstructorParams({ | ||
factory: OPTIMISM_FACTORY, | ||
events: events, | ||
marginAsset: marginAsset, | ||
perpsV2ExchangeRate: perpsV2ExchangeRate, | ||
futuresMarketManager: futuresMarketManager, | ||
systemStatus: systemStatus, | ||
gelato: OPTIMISM_GELATO, | ||
ops: OPTIMISM_OPS, | ||
settings: settings, | ||
universalRouter: OPTIMISM_UNISWAP_UNIVERSAL_ROUTER, | ||
permit2: OPTIMISM_UNISWAP_PERMIT2 | ||
}); | ||
|
||
implementation = address(new Account(params)); | ||
} | ||
} | ||
|
||
/// @dev steps to deploy and verify on Optimism Sepolia: | ||
/// (1) load the variables in the .env file via `source .env` | ||
/// (2) run `forge script script/upgrades/v2.1.4/Upgrade.s.sol:UpgradeAccountOptimismSepolia --rpc-url $ARCHIVE_NODE_URL_SEPOLIA_L2 --broadcast --verify -vvvv` | ||
/// (3) Smart Margin Account Factory owner (i.e. Kwenta pDAO) will need to call `upgradeAccountImplementation` on the Factory with the address of the new Account implementation | ||
contract UpgradeAccountOptimismSepolia is Script { | ||
function run() public { | ||
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY"); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
upgrade(); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
|
||
function upgrade() public returns (address implementation) { | ||
IAddressResolver addressResolver = | ||
IAddressResolver(OPTIMISM_SEPOLIA_SYNTHETIX_ADDRESS_RESOLVER); | ||
|
||
address marginAsset = addressResolver.getAddress({name: PROXY_SUSD}); | ||
address perpsV2ExchangeRate = | ||
addressResolver.getAddress({name: PERPS_V2_EXCHANGE_RATE}); | ||
address futuresMarketManager = | ||
addressResolver.getAddress({name: FUTURES_MARKET_MANAGER}); | ||
address systemStatus = addressResolver.getAddress({name: SYSTEM_STATUS}); | ||
|
||
address events = | ||
address(new Events({_factory: OPTIMISM_SEPOLIA_FACTORY})); | ||
|
||
address settings = | ||
address(new Settings({_owner: OPTIMISM_SEPOLIA_DEPLOYER})); | ||
|
||
// Order flow fee set to 0.5 BPS | ||
Settings(settings).setOrderFlowFee(5); | ||
|
||
// USDC token address whitelisted | ||
Settings(settings).setTokenWhitelistStatus( | ||
0x5fd84259d66Cd46123540766Be93DFE6D43130D7, true | ||
); | ||
|
||
IAccount.AccountConstructorParams memory params = IAccount | ||
.AccountConstructorParams({ | ||
factory: OPTIMISM_SEPOLIA_FACTORY, | ||
events: events, | ||
marginAsset: marginAsset, | ||
perpsV2ExchangeRate: perpsV2ExchangeRate, | ||
futuresMarketManager: futuresMarketManager, | ||
systemStatus: systemStatus, | ||
gelato: OPTIMISM_SEPOLIA_GELATO, | ||
ops: OPTIMISM_SEPOLIA_OPS, | ||
settings: settings, | ||
universalRouter: OPTIMISM_SEPOLIA_UNISWAP_UNIVERSAL_ROUTER, | ||
permit2: OPTIMISM_SEPOLIA_UNISWAP_PERMIT2 | ||
}); | ||
|
||
implementation = address(new Account(params)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.