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

GSM 4626 Deployment #445

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
149 changes: 149 additions & 0 deletions src/script/DeployGsm4626.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import {Script, console2} from 'forge-std/Script.sol';
import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';
import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol';
import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol';
import {ITransparentProxyFactory} from 'src/script/ITransparentProxyFactory.sol';
import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol';

import {Gsm4626} from 'src/contracts/facilitators/gsm/Gsm4626.sol';
import {FixedPriceStrategy4626} from 'src/contracts/facilitators/gsm/priceStrategy/FixedPriceStrategy4626.sol';
import {IGsm} from 'src/contracts/facilitators/gsm/interfaces/IGsm.sol';
import {OracleSwapFreezer} from 'src/contracts/facilitators/gsm/swapFreezer/OracleSwapFreezer.sol';

address constant TRANSPARENT_PROXY_FACTORY = 0xEB0682d148e874553008730f0686ea89db7DA412;

// GSM USDC
address constant NEW_USDC_STATA_TOKEN = 0xD4fa2D31b7968E448877f69A96DE69f5de8cD23E;
uint8 constant USDC_DECIMALS = 6;
uint128 constant USDC_EXPOSURE_CAP = 8_000_000e6;

// GSM USDT
address constant NEW_USDT_STATA_TOKEN = 0x7Bc3485026Ac48b6cf9BaF0A377477Fff5703Af8;
uint8 constant USDT_DECIMALS = 6;
uint128 constant USDT_EXPOSURE_CAP = 16_000_000e6;

uint256 constant GSM_PRICE_RATIO = 1e18;
uint128 constant SWAP_FREEZE_LOWER_BOUND = 0.99e8;
uint128 constant SWAP_FREEZE_UPPER_BOUND = 1.01e8;
uint128 constant SWAP_UNFREEZE_LOWER_BOUND = 0.995e8;
uint128 constant SWAP_UNFREEZE_UPPER_BOUND = 1.005e8;
bool constant SWAP_UNFREEZE_ALLOWED = true;

contract DeployGsm4626 is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint('PRIVATE_KEY');
address deployerAddress = vm.addr(deployerPrivateKey);
console2.log('Deployer Address: ', deployerAddress);
console2.log('Deployer Balance: ', address(deployerAddress).balance);
console2.log('Block Number: ', block.number);
vm.startBroadcast(deployerPrivateKey);
_deploy();
vm.stopBroadcast();
}

function _deploy() internal {
// ------------------------------------------------
// 1. FixedPriceStrategy
// ------------------------------------------------
FixedPriceStrategy4626 gsmUsdcPriceStrategy = new FixedPriceStrategy4626(
GSM_PRICE_RATIO,
NEW_USDC_STATA_TOKEN,
USDC_DECIMALS
);
console2.log('GSM stataUSDC FixedPriceStrategy4626: ', address(gsmUsdcPriceStrategy));

FixedPriceStrategy4626 gsmUsdtPriceStrategy = new FixedPriceStrategy4626(
GSM_PRICE_RATIO,
NEW_USDT_STATA_TOKEN,
USDT_DECIMALS
);
console2.log('GSM stataUSDT FixedPriceStrategy4626: ', address(gsmUsdtPriceStrategy));

// ------------------------------------------------
// 2. GSM implementations
// ------------------------------------------------
Gsm4626 gsmUsdcImpl = new Gsm4626(
AaveV3EthereumAssets.GHO_UNDERLYING,
NEW_USDC_STATA_TOKEN,
address(gsmUsdcPriceStrategy)
);
console2.log('GSM stataUSDC Implementation: ', address(gsmUsdcImpl));

Gsm4626 gsmUsdtImpl = new Gsm4626(
AaveV3EthereumAssets.GHO_UNDERLYING,
NEW_USDT_STATA_TOKEN,
address(gsmUsdtPriceStrategy)
);
console2.log('GSM stataUSDT Implementation: ', address(gsmUsdtImpl));

gsmUsdcImpl.initialize(
GovernanceV3Ethereum.EXECUTOR_LVL_1,
address(AaveV3Ethereum.COLLECTOR),
USDC_EXPOSURE_CAP
);
gsmUsdtImpl.initialize(
GovernanceV3Ethereum.EXECUTOR_LVL_1,
address(AaveV3Ethereum.COLLECTOR),
USDT_EXPOSURE_CAP
);

// ------------------------------------------------
// 3. GSM proxy deployment and initialization
// ------------------------------------------------
bytes memory gsmUsdcInitParams = abi.encodeWithSignature(
'initialize(address,address,uint128)',
GovernanceV3Ethereum.EXECUTOR_LVL_1,
address(AaveV3Ethereum.COLLECTOR),
USDC_EXPOSURE_CAP
);
address gsmUsdcProxy = ITransparentProxyFactory(TRANSPARENT_PROXY_FACTORY).create(
address(gsmUsdcImpl),
GovernanceV3Ethereum.EXECUTOR_LVL_1,
gsmUsdcInitParams
);
console2.log('GSM stataUSDC Proxy: ', gsmUsdcProxy);

bytes memory gsmUsdtInitParams = abi.encodeWithSignature(
'initialize(address,address,uint128)',
GovernanceV3Ethereum.EXECUTOR_LVL_1,
address(AaveV3Ethereum.COLLECTOR),
USDT_EXPOSURE_CAP
);
address gsmUsdtProxy = ITransparentProxyFactory(TRANSPARENT_PROXY_FACTORY).create(
address(gsmUsdtImpl),
GovernanceV3Ethereum.EXECUTOR_LVL_1,
gsmUsdtInitParams
);
console2.log('GSM stataUSDT Proxy: ', gsmUsdtProxy);

// ------------------------------------------------
// 4. OracleSwapFreezers
// ------------------------------------------------
OracleSwapFreezer gsmUsdcOracleSwapFreezer = new OracleSwapFreezer(
IGsm(gsmUsdcProxy),
AaveV3EthereumAssets.USDC_UNDERLYING,
IPoolAddressesProvider(address(AaveV3Ethereum.POOL_ADDRESSES_PROVIDER)),
SWAP_FREEZE_LOWER_BOUND,
SWAP_FREEZE_UPPER_BOUND,
SWAP_UNFREEZE_LOWER_BOUND,
SWAP_UNFREEZE_UPPER_BOUND,
SWAP_UNFREEZE_ALLOWED
);
console2.log('GSM stataUSDC OracleSwapFreezer: ', address(gsmUsdcOracleSwapFreezer));

OracleSwapFreezer gsmUsdtOracleSwapFreezer = new OracleSwapFreezer(
IGsm(gsmUsdtProxy),
AaveV3EthereumAssets.USDT_UNDERLYING,
IPoolAddressesProvider(address(AaveV3Ethereum.POOL_ADDRESSES_PROVIDER)),
SWAP_FREEZE_LOWER_BOUND,
SWAP_FREEZE_UPPER_BOUND,
SWAP_UNFREEZE_LOWER_BOUND,
SWAP_UNFREEZE_UPPER_BOUND,
SWAP_UNFREEZE_ALLOWED
);
console2.log('GSM stataUSDT OracleSwapFreezer: ', address(gsmUsdtOracleSwapFreezer));
}
}
20 changes: 20 additions & 0 deletions src/script/ITransparentProxyFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

interface ITransparentProxyFactory {
/**
* @notice Creates a transparent proxy instance, doing the first initialization in construction
* @dev Version using CREATE
* @param logic The address of the implementation contract
* @param initialOwner The initial owner of the admin of the proxy.
* @param data abi encoded call to the function with `initializer` (or `reinitializer`) modifier.
* E.g. `abi.encodeWithSelector(mockImpl.initialize.selector, 2)`
* for an `initialize` function being `function initialize(uint256 foo) external initializer;`
* @return address The address of the proxy deployed
**/
function create(
address logic,
address initialOwner,
bytes memory data
) external returns (address);
Comment on lines +13 to +19

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return address The address of the proxy deployed
**/
function create(
address logic,
address initialOwner,
bytes memory data
) external returns (address);
* @return proxy The address of the proxy deployed
**/
function create(
address logic,
address initialOwner,
bytes memory data
) external returns (address proxy);

}