Skip to content

Commit

Permalink
chore: update deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
134dd3v committed Jul 28, 2022
1 parent c329647 commit 10f2fe8
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 88 deletions.
33 changes: 30 additions & 3 deletions deploy/gmx-batching-manager.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,51 @@
import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { waitConfirmations } from './network-info';
import { getNetworkInfo, waitConfirmations } from './network-info';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {
deployments: { deploy },
deployments: { deploy, get, execute },
getNamedAccounts,
} = hre;

const { deployer } = await getNamedAccounts();

const networkInfo = getNetworkInfo(hre.network.config.chainId ?? 31337);

await deploy('GMXBatchingManager', {
contract: 'GMXBatchingManager',
from: deployer,
log: true,
waitConfirmations,
});

// if (gbm.newlyDeployed) {
// console.log('se87rngfie76rfgbiw');

// await execute(
// 'GMXBatchingManager',
// { from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
// 'initialize',
// networkInfo.SGLP_ADDRESS,
// networkInfo.REWARD_ROUTER_ADDRESS,
// networkInfo.GLP_MANAGER_ADDRESS,
// gys.address,
// networkInfo.KEEPER_ADDRESS,
// );

// console.log('se87rngfie76rfgbiw', gbm.address);
// await execute(
// 'GMXYieldStrategy',
// { from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
// 'updateGMXParams',
// 1000, // feeBps
// gbm.address, // batchingManager
// );
// console.log('se87rngfie76rfgbiw');
// }
};

export default func;

func.tags = ['GMXBatchingManager'];
func.dependencies = ['GMXYieldStrategy'];
// func.dependencies = ['GMXYieldStrategy'];
185 changes: 100 additions & 85 deletions deploy/gmx-yield-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,43 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

const networkInfo = getNetworkInfo(hre.network.config.chainId ?? 31337);

// const clearingHouseAddress: string = (await get('ClearingHouse')).address;
// const settlementTokenAddress: string = (await get('SettlementToken')).address;
// const ethPoolId: string = truncate((await get('ETH-vToken')).address);

// const collateralTokenDeployment = await get('CollateralToken');

// const clearingHouseLens = ClearingHouseLens__factory.connect(
// (await get('ClearingHouseLens')).address,
// await hre.ethers.getSigner(deployer),
// );

// const initializeArg: GMXYieldStrategy.GMXYieldStrategyInitParamsStruct = {
// eightyTwentyRangeStrategyVaultInitParams: {
// baseVaultInitParams: {
// rageErc4626InitParams: {
// asset: networkInfo.CURVE_TRICRYPTO_LP_TOKEN,
// name: '80-20 TriCrypto Strategy',
// symbol: 'TCS',
// },
// ethPoolId,
// swapSimulator: (await get('SwapSimulator')).address,
// clearingHouseLens: clearingHouseLens.address,
// rageClearingHouse: clearingHouseAddress,
// rageCollateralToken: collateralTokenDeployment.address,
// rageSettlementToken: settlementTokenAddress,
// },
// closePositionSlippageSqrtToleranceBps: 150,
// resetPositionThresholdBps: 2000,
// minNotionalPositionToCloseThreshold: 100e6,
// },
// gmx: GMX_ECOSYSTEM_ADDRESSES.GMX,
// glp: GMX_ECOSYSTEM_ADDRESSES.GLP,
// weth: addresses.WETH,
// esGMX: GMX_ECOSYSTEM_ADDRESSES.StakedGmx, // TODO needs to change
// glpManager: GMX_ECOSYSTEM_ADDRESSES.GlpManager,
// rewardRouter: GMX_ECOSYSTEM_ADDRESSES.RewardRouter,
// };
const clearingHouseAddress: string = (await get('ClearingHouse')).address;
const settlementTokenAddress: string = (await get('SettlementToken')).address;
const ethPoolId: string = truncate((await get('ETH-vToken')).address);

const collateralTokenDeployment = await get('CollateralToken');

const clearingHouseLens = ClearingHouseLens__factory.connect(
(await get('ClearingHouseLens')).address,
await hre.ethers.getSigner(deployer),
);

const initializeArg: GMXYieldStrategy.GMXYieldStrategyInitParamsStruct = {
eightyTwentyRangeStrategyVaultInitParams: {
baseVaultInitParams: {
rageErc4626InitParams: {
asset: networkInfo.SGLP_ADDRESS,
name: '80-20 TriCrypto Strategy',
symbol: 'TCS',
},
ethPoolId,
swapSimulator: (await get('SwapSimulator')).address,
clearingHouseLens: clearingHouseLens.address,
rageClearingHouse: clearingHouseAddress,
rageCollateralToken: collateralTokenDeployment.address,
rageSettlementToken: settlementTokenAddress,
},
closePositionSlippageSqrtToleranceBps: 150,
resetPositionThresholdBps: 2000,
minNotionalPositionToCloseThreshold: 100e6,
},
gmx: networkInfo.GMX_ADDRESS,
glp: networkInfo.GLP_ADDRESS,
weth: networkInfo.WETH_ADDRESS,
esGMX: networkInfo.ESGMX_ADDRESS, // TODO needs to change
glpManager: networkInfo.GLP_MANAGER_ADDRESS,
rewardRouter: networkInfo.REWARD_ROUTER_ADDRESS,
};

const ProxyDeployment = await deploy('GMXYieldStrategy', {
contract: 'TransparentUpgradeableProxy',
Expand All @@ -63,62 +63,77 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [
gmxYieldStrategyLogicDeployment.address,
proxyAdminDeployment.address,
'0x',
// GMXYieldStrategy__factory.createInterface().encodeFunctionData('initialize', [initializeArg]),
GMXYieldStrategy__factory.createInterface().encodeFunctionData('initialize', [initializeArg]),
],
estimateGasExtra: 1_000_000,
waitConfirmations,
});
await save('GMXYieldStrategy', { ...ProxyDeployment, abi: gmxYieldStrategyLogicDeployment.abi });

// if (ProxyDeployment.newlyDeployed) {
// await execute(
// 'CurveYieldStrategy',
// { from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
// 'grantAllowances',
// );

// await execute(
// 'CurveYieldStrategy',
// { from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
// 'updateBaseParams',
// parseUnits(networkInfo.DEPOSIT_CAP_C3CLT.toString(), 18),
// networkInfo.KEEPER_ADDRESS,
// 86400, // rebalanceTimeThreshold
// 500, // rebalancePriceThresholdBps
// );

// await execute(
// 'CurveYieldStrategy',
// { from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
// 'updateCurveParams',
// 1000, // feeBps
// 100, // stablecoinSlippage
// parseUnits('2', 18), // crvHarvestThreshold
// 500, // crvSlippageTolerance
// networkInfo.CURVE_USD_ORACLE,
// );

// const MINTER_ROLE = await read('CollateralToken', 'MINTER_ROLE');
// await execute(
// 'CollateralToken',
// { from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
// 'grantRole',
// MINTER_ROLE,
// ProxyDeployment.address,
// );

// // transfer ownership to team multisig
// await execute(
// 'CurveYieldStrategy',
// { from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
// 'transferOwnership',
// networkInfo.MULTISIG,
// );
// }
if (ProxyDeployment.newlyDeployed) {
await execute(
'GMXYieldStrategy',
{ from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
'grantAllowances',
);

await execute(
'GMXYieldStrategy',
{ from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
'updateBaseParams',
parseUnits(networkInfo.DEPOSIT_CAP_C3CLT.toString(), 18),
networkInfo.KEEPER_ADDRESS,
86400, // rebalanceTimeThreshold
500, // rebalancePriceThresholdBps
);

const gbm = await get('GMXBatchingManager');
await execute(
'GMXBatchingManager',
{ from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
'initialize',
networkInfo.SGLP_ADDRESS,
networkInfo.REWARD_ROUTER_ADDRESS,
networkInfo.GLP_MANAGER_ADDRESS,
gbm.address,
networkInfo.KEEPER_ADDRESS,
);

await execute(
'GMXYieldStrategy',
{ from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
'updateGMXParams',
1000, // feeBps
gbm.address, // batchingManager
);

// transfer ownership to team multisig
await execute(
'GMXYieldStrategy',
{ from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
'transferOwnership',
networkInfo.MULTISIG,
);

const MINTER_ROLE = await read('CollateralToken', 'MINTER_ROLE');
await execute(
'CollateralToken',
{ from: deployer, estimateGasExtra: 1_000_000, waitConfirmations },
'grantRole',
MINTER_ROLE,
ProxyDeployment.address,
);
}
};

export default func;

func.tags = ['GMXYieldStrategy'];
func.dependencies = ['GMXYieldStrategyLogic', 'CollateralToken', 'ProxyAdmin', 'vETH', 'SwapSimulator'];
func.dependencies = [
'GMXBatchingManager',
'GMXYieldStrategyLogic',
'CollateralToken',
'ProxyAdmin',
'vETH',
'SwapSimulator',
];
28 changes: 28 additions & 0 deletions deploy/network-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export interface NetworkInfo {
WETH_ADDRESS: string;
WBTC_ADDRESS: string;
USDT_ADDRESS: string;

GMX_ADDRESS: string;
GLP_ADDRESS: string;
SGLP_ADDRESS: string;
ESGMX_ADDRESS: string;
GLP_MANAGER_ADDRESS: string;
REWARD_ROUTER_ADDRESS: string;
}

export const UNISWAP_V3_FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984';
Expand Down Expand Up @@ -70,6 +77,13 @@ export const arbitrumInfo: () => NetworkInfo = () => ({
WETH_ADDRESS: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
WBTC_ADDRESS: '0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
USDT_ADDRESS: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',

GMX_ADDRESS: '0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a',
GLP_ADDRESS: '0x4277f8F2c384827B5273592FF7CeBd9f2C1ac258',
SGLP_ADDRESS: '0x2F546AD4eDD93B956C8999Be404cdCAFde3E89AE',
ESGMX_ADDRESS: '0x0000000000000000000000000000000000001111', // TODO needs to change
GLP_MANAGER_ADDRESS: '0x321F653eED006AD1C29D174e17d96351BDe22649',
REWARD_ROUTER_ADDRESS: '0xA906F338CB21815cBc4Bc87ace9e68c87eF8d8F1',
});

export const arbitrumTestnetInfo: () => NetworkInfo = () => ({
Expand Down Expand Up @@ -103,6 +117,13 @@ export const arbitrumTestnetInfo: () => NetworkInfo = () => ({
WETH_ADDRESS: '0xFCfbfcC11d12bCf816415794E5dc1BBcc5304e01',
USDT_ADDRESS: '0x237b3B5238D2022aA80cAd1f67dAE53f353F74bF',
WBTC_ADDRESS: '0xF2bf2a5CF00c9121A18d161F6738D39Ab576DB68',

GMX_ADDRESS: '0x0000000000000000000000000000000000001111',
GLP_ADDRESS: '0x0000000000000000000000000000000000001111',
SGLP_ADDRESS: '0x0000000000000000000000000000000000001111',
ESGMX_ADDRESS: '0x0000000000000000000000000000000000001111', // TODO needs to change
GLP_MANAGER_ADDRESS: '0x0000000000000000000000000000000000001111',
REWARD_ROUTER_ADDRESS: '0x0000000000000000000000000000000000001111',
});

// arbitrum mainnet fork
Expand Down Expand Up @@ -138,6 +159,13 @@ export const hardhatNetworkInfo: () => NetworkInfo = () => ({
WETH_ADDRESS: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
WBTC_ADDRESS: '0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
USDT_ADDRESS: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',

GMX_ADDRESS: '0xfc5A1A6EB076a2C7aD06eD22C90d7E710E35ad0a',
GLP_ADDRESS: '0x4277f8F2c384827B5273592FF7CeBd9f2C1ac258',
SGLP_ADDRESS: '0x2F546AD4eDD93B956C8999Be404cdCAFde3E89AE',
ESGMX_ADDRESS: '0x0000000000000000000000000000000000001111', // TODO needs to change
GLP_MANAGER_ADDRESS: '0x321F653eED006AD1C29D174e17d96351BDe22649',
REWARD_ROUTER_ADDRESS: '0xA906F338CB21815cBc4Bc87ace9e68c87eF8d8F1',
});

export function getNetworkInfo(chainId?: number): NetworkInfo {
Expand Down

0 comments on commit 10f2fe8

Please sign in to comment.