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

feat: updated deployment scripts #103

Merged
merged 21 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
22ce45f
change imports
sogipec Jan 5, 2024
e181831
feat:deployment script for Transmuter
sogipec Jan 5, 2024
1fd4ccb
feat: Transmuter premining address
sogipec Jan 5, 2024
ca4e583
fixing failing test
sogipec Jan 5, 2024
fd204ee
feat: remove local file
sogipec Jan 9, 2024
fbf90e1
feat: deployment on Ethereum
sogipec Jan 10, 2024
5a5a0a2
feat: ready on savings deployment
sogipec Jan 10, 2024
75a670e
feat: stUSD deployment
sogipec Jan 11, 2024
97b412f
fix: remove impossible condition in redeem test
0xtekgrinder Jan 18, 2024
fba12ef
fix: load reserve minimum 1 to take fees regardless
0xtekgrinder Jan 18, 2024
4cc8bdc
fix: compute correctly mintedStables in testFuzz_MultiRedemptionCurve…
0xtekgrinder Jan 19, 2024
fa44a4e
fix: increase the minimum amount for savings test
0xtekgrinder Jan 19, 2024
d255cab
fix: wrong amountBurnt used in condition for testFuzz_MultiRedemption…
0xtekgrinder Jan 19, 2024
4e205b3
feat: handle when mintedStables is zero in testFuzz_MultiRedemptionCu…
0xtekgrinder Jan 19, 2024
fcd4c62
feat: transmuter
sogipec Jan 22, 2024
5a5ca39
fallback
sogipec Jan 22, 2024
c485266
style: remove brackets in a for loop inside testFuzz_DepositSingleRate
0xtekgrinder Jan 22, 2024
c3e806b
fix: revert back to amountBurnt for testFuzz_MultiRedemptionCurveRand…
0xtekgrinder Jan 22, 2024
56a2832
tests: retry if can't find selector up to three times
0xtekgrinder Jan 26, 2024
92f3042
chore: ignore solc version in slither
0xtekgrinder Jan 26, 2024
8627664
fix: invariant
sogipec Jan 31, 2024
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
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
},
"slither.solcPath": "",
"slither.hiddenDetectors": [],
"solidity.compileUsingRemoteVersion": "v0.8.19+commit.7dd6d404"
"solidity.compileUsingRemoteVersion": "v0.8.19+commit.7dd6d404",
"solidity.defaultCompiler": "localFile"
sogipec marked this conversation as resolved.
Show resolved Hide resolved
}
132 changes: 132 additions & 0 deletions contracts/transmuter/configs/ProductionUSD.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.19;
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

import "interfaces/external/chainlink/AggregatorV3Interface.sol";

import { LibDiamondEtherscan } from "../libraries/LibDiamondEtherscan.sol";
import "../libraries/LibOracle.sol";
import { LibSetters } from "../libraries/LibSetters.sol";
import { LibStorage as s } from "../libraries/LibStorage.sol";

import { DummyDiamondImplementation } from "../../../scripts/generated/DummyDiamondImplementation.sol";

Check warning on line 12 in contracts/transmuter/configs/ProductionUSD.sol

View workflow job for this annotation

GitHub Actions / lint

imported name DummyDiamondImplementation is not used

import "../../utils/Constants.sol";
import "../Storage.sol" as Storage;

struct CollateralSetupProd {
sogipec marked this conversation as resolved.
Show resolved Hide resolved
address token;
bytes oracleConfig;
uint64[] xMintFee;
int64[] yMintFee;
uint64[] xBurnFee;
int64[] yBurnFee;
}

/// @dev This contract is used only once to initialize the diamond proxy.
contract ProductionUSD {
function initialize(
IAccessControlManager _accessControlManager,
address _agToken,
address dummyImplementation
) external {
address usdc = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
/*
require(address(_accessControlManager) == 0x5bc6BEf80DA563EBf6Df6D6913513fa9A7ec89BE);
require(address(_agToken) == 0x0000206329b97DB379d5E1Bf586BbDB969C63274);
*/

// Set Collaterals
CollateralSetupProd[] memory collaterals = new CollateralSetupProd[](1);
// USDC
{
uint64[] memory xMintFeeUsdc = new uint64[](1);

Check warning

Code scanning / Slither

Variable names too similar Warning

xMintFeeUsdc[0] = uint64(0);

int64[] memory yMintFeeUsdc = new int64[](1);
yMintFeeUsdc[0] = int64(0);

uint64[] memory xBurnFeeUsdc = new uint64[](1);

Check warning

Code scanning / Slither

Variable names too similar Warning

xBurnFeeUsdc[0] = uint64(BASE_9);

int64[] memory yBurnFeeUsdc = new int64[](1);
yBurnFeeUsdc[0] = int64(0);

bytes memory oracleConfig;
{
AggregatorV3Interface[] memory circuitChainlink = new AggregatorV3Interface[](1);
uint32[] memory stalePeriods = new uint32[](1);
uint8[] memory circuitChainIsMultiplied = new uint8[](1);
uint8[] memory chainlinkDecimals = new uint8[](1);

// Chainlink USDC/USD oracle
circuitChainlink[0] = AggregatorV3Interface(0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6);
stalePeriods[0] = 1 days;
circuitChainIsMultiplied[0] = 1;
chainlinkDecimals[0] = 8;
OracleQuoteType quoteType = OracleQuoteType.UNIT;
bytes memory readData = abi.encode(
circuitChainlink,
stalePeriods,
circuitChainIsMultiplied,
chainlinkDecimals,
quoteType
);
bytes memory targetData;

Check warning

Code scanning / Slither

Uninitialized local variables Medium

oracleConfig = abi.encode(
Storage.OracleReadType.CHAINLINK_FEEDS,
Storage.OracleReadType.STABLE,
readData,
targetData
);
}
collaterals[0] = CollateralSetupProd(
usdc,
oracleConfig,
xMintFeeUsdc,
yMintFeeUsdc,
xBurnFeeUsdc,
yBurnFeeUsdc
);
}

LibSetters.setAccessControlManager(_accessControlManager);

TransmuterStorage storage ts = s.transmuterStorage();
ts.statusReentrant = NOT_ENTERED;
ts.normalizer = uint128(BASE_27);
ts.agToken = IAgToken(_agToken);

// Setup each collateral
uint256 collateralsLength = collaterals.length;
for (uint256 i; i < collateralsLength; i++) {
CollateralSetupProd memory collateral = collaterals[i];
LibSetters.addCollateral(collateral.token);
LibSetters.setOracle(collateral.token, collateral.oracleConfig);
// Mint fees
LibSetters.setFees(collateral.token, collateral.xMintFee, collateral.yMintFee, true);
// Burn fees
LibSetters.setFees(collateral.token, collateral.xBurnFee, collateral.yBurnFee, false);
LibSetters.togglePause(collateral.token, ActionType.Mint);
LibSetters.togglePause(collateral.token, ActionType.Burn);
}

// setRedemptionCurveParams
LibSetters.togglePause(usdc, ActionType.Redeem);
uint64[] memory xRedeemFee = new uint64[](4);
xRedeemFee[0] = uint64((75 * BASE_9) / 100);
xRedeemFee[1] = uint64((85 * BASE_9) / 100);
xRedeemFee[2] = uint64((95 * BASE_9) / 100);
xRedeemFee[3] = uint64((97 * BASE_9) / 100);

int64[] memory yRedeemFee = new int64[](4);
yRedeemFee[0] = int64(uint64((995 * BASE_9) / 1000));
yRedeemFee[1] = int64(uint64((950 * BASE_9) / 1000));
yRedeemFee[2] = int64(uint64((950 * BASE_9) / 1000));
yRedeemFee[3] = int64(uint64((995 * BASE_9) / 1000));
LibSetters.setRedemptionCurveParams(xRedeemFee, yRedeemFee);

// setDummyImplementation
LibDiamondEtherscan.setDummyImplementation(dummyImplementation);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"compile": "forge build",
"compile:dev": "FOUNDRY_PROFILE=dev forge build",
"deploy": "forge script --skip test --broadcast --verify --slow -vvvv --rpc-url polygonzkevm scripts/DeploySavings.s.sol",
"deploy:fork": "source .env && forge script --skip test --slow --fork-url fork --broadcast scripts/DeployRebalancer.s.sol -vvvv",
"deploy:fork": "source .env && forge script --skip test --slow --fork-url fork --broadcast scripts/DeployTransmuterWithoutFacets.s.sol -vvvv",
"generate": "FOUNDRY_PROFILE=dev forge script scripts/utils/GenerateSelectors.s.sol",
"deploy:check": "FOUNDRY_PROFILE=dev forge script --fork-url fork scripts/test/CheckTransmuter.s.sol",
"gas": "yarn test --gas-report",
Expand Down
24 changes: 23 additions & 1 deletion scripts/Constants.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,31 @@ address constant PROXY_ADMIN_GUARDIAN = 0xD9F1A8e00b0EEbeDddd9aFEaB55019D55fcec0
address constant TREASURY_EUR = 0x8667DBEBf68B0BFa6Db54f550f41Be16c4067d60;
address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e2130213B802212439497;
address constant DEPLOYER = 0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185;
address constant TRANSMUTER = 0x00253582b2a3FE112feEC532221d9708c64cEFAb;
address constant TRANSMUTER_EUR = 0x00253582b2a3FE112feEC532221d9708c64cEFAb;
sogipec marked this conversation as resolved.
Show resolved Hide resolved

address constant EUROC = 0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c;
address constant EUROE = 0x820802Fa8a99901F52e39acD21177b0BE6EE2974;
address constant EURE = 0x3231Cb76718CDeF2155FC47b5286d82e6eDA273f;
address constant BC3M = 0x2F123cF3F37CE3328CC9B5b8415f9EC5109b45e7;

address constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FACET ADDRESSES
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant DIAMOND_CUT_FACET = 0x53B7d70013dEC21A97F216e80eEFCF45F25c2900;
address constant DIAMOND_ETHERSCAN_FACET = 0xFa94Cd9d711de75695693c877BecA5473462Cf12;
address constant DIAMOND_LOUPE_FACET = 0x65Ddeedf8e68f26D787B678E28Af13fde0249967;
address constant GETTERS_FACET = 0xd1b575ED715e4630340BfdC4fB8A37dF3383C84a;
address constant REWARD_HANDLER_FACET = 0x770756e43b9ac742538850003791deF3020211F3;
address constant SETTERS_GOVERNOR_FACET = 0x1F37F93c6aA7d987AE04786145d3066EAb8EEB43;
address constant SETTERS_GUARDIAN_FACET = 0xdda8f002925a0DfB151c0EaCb48d7136ce6a999F;
address constant SWAPPER_FACET = 0x06c33a0C80C3970cbeDDE641C7A6419d703D93d7;
address constant REDEEMER_FACET = 0x1e45b65CdD3712fEf0024d063d6574A609985E59;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0xfD2cCc920d498db30FBE9c13D5705aE2C72670F9;
6 changes: 6 additions & 0 deletions scripts/ConstantsArbitrum.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ address constant GUARDIAN = 0x55F01DDaE74b60e3c255BD2f619FEbdFce560a9C;
address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e2130213B802212439497;
address constant PROXY_ADMIN = 0x9a5b060Bd7b8f86c4C0D720a17367729670AfB19;
address constant PROXY_ADMIN_GUARDIAN = 0xf2eDa0829E8A9CF53EBCB8AFCBb558D2eABCEF64;

sogipec marked this conversation as resolved.
Show resolved Hide resolved
/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0xadF56645e6796E32a805e5bC70267C656D0EaF7c;
6 changes: 6 additions & 0 deletions scripts/ConstantsAvalanche.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e21302
address constant CHAIN_AGEUR = 0xAEC8318a9a59bAEb39861d10ff6C7f7bf1F96C57;
address constant PROXY_ADMIN = 0x7AB641E661a9728913A44e06f6a4879481142DDb;
address constant ACCESS_CONTROL_MANAGER = 0xe9f183FC656656f1F17af1F2b0dF79b8fF9ad8eD;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0xdd8670B64B8Ec2c4f7dA9F8f6d1F757D107e1895;
6 changes: 6 additions & 0 deletions scripts/ConstantsBSC.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e21302
address constant CHAIN_AGEUR = 0x12f31B73D812C6Bb0d735a218c086d44D5fe5f89;
address constant PROXY_ADMIN = 0x9a5b060Bd7b8f86c4C0D720a17367729670AfB19;
address constant ACCESS_CONTROL_MANAGER = 0x31429d1856aD1377A8A0079410B297e1a9e214c2;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0x1E5B48c08D6b5efE0792d04f27602bD90026514a;
6 changes: 6 additions & 0 deletions scripts/ConstantsBase.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e21302
address constant CHAIN_AGEUR = 0xA61BeB4A3d02decb01039e378237032B351125B4;
address constant PROXY_ADMIN = 0x1D941EF0D3Bba4ad67DBfBCeE5262F4CEE53A32b;
address constant ACCESS_CONTROL_MANAGER = 0x4b1E2c2762667331Bc91648052F646d1b0d35984;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0x07C89CC845D046aEad377DddC61114AA9D920Ac0;
6 changes: 6 additions & 0 deletions scripts/ConstantsCelo.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e21302
address constant CHAIN_AGEUR = 0xC16B81Af351BA9e64C1a069E3Ab18c244A1E3049;
address constant PROXY_ADMIN = 0x5183f032bf42109cD370B9559FD22207e432301E;
address constant ACCESS_CONTROL_MANAGER = 0x59153e939c5b4721543251ff3049Ea04c755373B;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0xb1F2A25fFB2b095E99f430cAF507cC31F9A3EaAB;
6 changes: 6 additions & 0 deletions scripts/ConstantsGnosis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e21302
address constant CHAIN_AGEUR = 0x4b1E2c2762667331Bc91648052F646d1b0d35984;
address constant PROXY_ADMIN = 0x9a5b060Bd7b8f86c4C0D720a17367729670AfB19;
address constant ACCESS_CONTROL_MANAGER = 0x3E399AE5B4D8bc0021e53b51c8BCdD66DD62c03b;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0x6C04c39B9E73aC91106D12F828e2E29Fd8ef1024;
6 changes: 6 additions & 0 deletions scripts/ConstantsOptimism.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e21302
address constant CHAIN_AGEUR = 0x9485aca5bbBE1667AD97c7fE7C4531a624C8b1ED;
address constant PROXY_ADMIN = 0xC16B81Af351BA9e64C1a069E3Ab18c244A1E3049;
address constant ACCESS_CONTROL_MANAGER = 0x1a7e4e63778B4f12a199C062f3eFdD288afCBce8;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0xB2378660Daebb9BA6c1ce2a38d3ee1d6a6E4Dc14;
6 changes: 6 additions & 0 deletions scripts/ConstantsPolygon.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e21302
address constant CHAIN_AGEUR = 0xE0B52e49357Fd4DAf2c15e02058DCE6BC0057db4;
address constant PROXY_ADMIN = 0xBFca293e17e067e8aBdca30A5D35ADDd0cBaE6D6;
address constant ACCESS_CONTROL_MANAGER = 0x78754109cb73772d70A6560297037657C2AF51b8;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0xA7C8AF476558fD8C91422daE19E783dfdf6Ffbb3;
6 changes: 6 additions & 0 deletions scripts/ConstantsPolygonZkEVM.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ address constant IMMUTABLE_CREATE2_FACTORY_ADDRESS = 0x0000000000FFe8B47B3e21302
address constant CHAIN_AGEUR = 0xA61BeB4A3d02decb01039e378237032B351125B4;
address constant PROXY_ADMIN = 0x31429d1856aD1377A8A0079410B297e1a9e214c2;
address constant ACCESS_CONTROL_MANAGER = 0x4b1E2c2762667331Bc91648052F646d1b0d35984;

/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SAVINGS IMPLEM
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/

address constant SAVINGS_IMPLEM = 0x5EE94c25e3d5113CD055537340B9d19CFA4D9217;
5 changes: 4 additions & 1 deletion scripts/DeployRebalancer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ contract DeployRebalancer is Utils {

address deployer = vm.addr(deployerPrivateKey);
console.log("Deployer address: ", deployer);
Rebalancer rebalancer = new Rebalancer(IAccessControlManager(ACCESS_CONTROL_MANAGER), ITransmuter(TRANSMUTER));
Rebalancer rebalancer = new Rebalancer(
IAccessControlManager(ACCESS_CONTROL_MANAGER),
ITransmuter(TRANSMUTER_EUR)
);
console.log("Rebalancer deployed at: ", address(rebalancer));

vm.stopBroadcast();
Expand Down
76 changes: 76 additions & 0 deletions scripts/DeploySavingsNoImplem.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;

import { Utils } from "./utils/Utils.s.sol";
import { console } from "forge-std/console.sol";
import { stdJson } from "forge-std/StdJson.sol";
import "stringutils/strings.sol";
import { Savings } from "contracts/savings/Savings.sol";
import { IAccessControlManager } from "contracts/utils/AccessControl.sol";
import "./ConstantsPolygonZkEVM.s.sol";
import "oz/interfaces/IERC20.sol";
import "oz-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol";
import { TransparentUpgradeableProxy } from "oz/proxy/transparent/TransparentUpgradeableProxy.sol";

import { ImmutableCreate2Factory } from "./utils/TransmuterDeploymentHelper.s.sol";

import { MockTreasury } from "../test/mock/MockTreasury.sol";

/// @dev To deploy on a different chain, just replace the import of the `Constants.s.sol` file by a file which has the
/// constants defined for the chain of your choice.
contract DeploySavingsNoImplem is Utils {
using stdJson for string;
using strings for *;

function run() external {
// TODO: make sure that deployer has a 1 stablecoin (=1e18) balance
// TODO: check the import of the constants file if it corresponds to the chain you're deploying on
uint256 deployerPrivateKey = vm.deriveKey(vm.envString("MNEMONIC_MAINNET"), "m/44'/60'/0'/0/", 0);
ImmutableCreate2Factory create2Factory = ImmutableCreate2Factory(IMMUTABLE_CREATE2_FACTORY_ADDRESS);
string memory jsonVanity = vm.readFile(JSON_VANITY_PATH);
bytes32 salt = jsonVanity.readBytes32(string.concat("$.", "salt"));
vm.startBroadcast(deployerPrivateKey);

address deployer = vm.addr(deployerPrivateKey);
console.log("Deployer address: ", deployer);
// No need to deploy the implementation here
// TODO: update addresses based on deployment
address agToken = CHAIN_AGEUR;
address accessControlManager = ACCESS_CONTROL_MANAGER;
address treasury = address(new MockTreasury());

// Then deploying the proxy.
// To maintain chain consistency, we deploy with the deployer as a proxyAdmin before transferring
// to another address
// We use a contract that is widely deployed across many chains as an implementation to make it resilient
// to possible implementation changes

bytes memory emptyData;
bytes memory initCode = abi.encodePacked(
type(TransparentUpgradeableProxy).creationCode,
abi.encode(IMMUTABLE_CREATE2_FACTORY_ADDRESS, deployer, emptyData)
);
console.log("Proxy bytecode");
console.logBytes(initCode);
console.log("");

address computedAddress = create2Factory.findCreate2Address(salt, initCode);
console.log("Supposed to deploy: %s", computedAddress);
if (computedAddress != 0x004626A008B1aCdC4c74ab51644093b155e59A23) revert();
sogipec marked this conversation as resolved.
Show resolved Hide resolved
address saving = create2Factory.safeCreate2(salt, initCode);
console.log("Savings deployed at: ", address(saving));
TransparentUpgradeableProxy(payable(saving)).upgradeTo(address(SAVINGS_IMPLEM));
TransparentUpgradeableProxy(payable(saving)).changeAdmin(PROXY_ADMIN);
IERC20MetadataUpgradeable(agToken).approve(address(saving), 1e18);
Savings(saving).initialize(
IAccessControlManager(accessControlManager),
IERC20MetadataUpgradeable(agToken),
"Staked agUSD",
"stUSD",
1
);

MockTreasury(treasury).addMinter(agToken, saving);
vm.stopBroadcast();
}
}
Loading
Loading