This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get ready for mainnet flux deployment (#384)
* Added new flexible fork script, small change to .env to match pattern of other rpcs * Started creating generic task for deploying new strategies * Reworked how we deploy vaults and strategies, genercized methods to simplify strategy-specific tasks * Added missing steps to deploySideChain for managing the registrar config * Lint * Added empty entry to strategy-addresses for flux * Fixed typo in task name * added token addresses, removed unused imports * Added stratParams update to the fullStrategy deployment flow * Update tasks/deploy/integrations/helpers/fullStrategy.ts Co-authored-by: Nenad Misic <[email protected]> * small fix from pr suggestion * Reordered to call registrar task with correct arg, renamed for clarity --------- Co-authored-by: Nenad Misic <[email protected]>
- Loading branch information
1 parent
210be39
commit 0240014
Showing
18 changed files
with
296 additions
and
187 deletions.
There are no files selected for viewing
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
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,81 @@ | ||
import {Signer} from "ethers"; | ||
import {HardhatRuntimeEnvironment} from "hardhat/types"; | ||
import {APVault_V1__factory, IVault, VaultEmitter__factory} from "typechain-types"; | ||
import {Deployment, VaultType} from "types"; | ||
import {deploy, getAddresses, logger} from "utils"; | ||
|
||
export type VaultDeploymentPair = { | ||
Locked: Deployment<APVault_V1__factory>; | ||
Liquid: Deployment<APVault_V1__factory>; | ||
}; | ||
|
||
export async function deployVaultPair( | ||
deployer: Signer, | ||
admin: string, | ||
config: IVault.VaultConfigStruct, | ||
hre: HardhatRuntimeEnvironment | ||
): Promise<VaultDeploymentPair> { | ||
// setup | ||
const APVault_V1 = new APVault_V1__factory(deployer); | ||
const addresses = await getAddresses(hre); | ||
|
||
// deploy | ||
const LockedDeployment = await deployVault( | ||
{ | ||
...config, | ||
vaultType: VaultType.LOCKED, | ||
apTokenName: config.apTokenName + "Lock", | ||
apTokenSymbol: config.apTokenSymbol + "Lock", | ||
}, | ||
APVault_V1, | ||
admin, | ||
addresses.vaultEmitter.proxy, | ||
hre | ||
); | ||
|
||
const LiquidDeployment = await deployVault( | ||
{ | ||
...config, | ||
vaultType: VaultType.LIQUID, | ||
apTokenName: config.apTokenName + "Liq", | ||
apTokenSymbol: config.apTokenSymbol + "Liq", | ||
}, | ||
APVault_V1, | ||
admin, | ||
addresses.vaultEmitter.proxy, | ||
hre | ||
); | ||
|
||
return { | ||
Locked: LockedDeployment, | ||
Liquid: LiquidDeployment, | ||
}; | ||
} | ||
|
||
async function deployVault( | ||
config: IVault.VaultConfigStruct, | ||
factory: APVault_V1__factory, | ||
admin: string, | ||
emitter: string, | ||
hre: HardhatRuntimeEnvironment | ||
): Promise<Deployment<APVault_V1__factory>> { | ||
const Deployment = await deploy(factory, [config, emitter, admin]); | ||
|
||
await registerVaultWithEmitter(factory.signer, Deployment.contract.address, config, hre); | ||
|
||
return Deployment; | ||
} | ||
|
||
async function registerVaultWithEmitter( | ||
deployer: Signer, | ||
address: string, | ||
config: IVault.VaultConfigStruct, | ||
hre: HardhatRuntimeEnvironment | ||
) { | ||
logger.out("Registering vault and emitting `VaultCreated` event..."); | ||
const addresses = await getAddresses(hre); | ||
const vaultEmitter = VaultEmitter__factory.connect(addresses.vaultEmitter.proxy, deployer); | ||
const tx = await vaultEmitter.vaultCreated(address, config); | ||
logger.out(`Tx hash: ${tx.hash}`); | ||
await tx.wait(); | ||
} |
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,18 +1,39 @@ | ||
import {ChainID, StrategyApprovalState, VaultType} from "types"; | ||
import {AllStratConfigs, StratConfig, getVaultAddress} from "utils"; | ||
import {AllStratConfigs, StratConfig, getNetworkNameFromChainId, getVaultAddress} from "utils"; | ||
|
||
export const dummy: StratConfig = { | ||
name: "dummy", | ||
id: "0x12345678", | ||
chainId: ChainID.goerli, | ||
tokenName: "TestVault", | ||
tokenSymbol: "TV", | ||
baseToken: "", | ||
yieldToken: "", | ||
params: { | ||
approvalState: StrategyApprovalState.APPROVED, | ||
network: "ethereum-2", | ||
network: getNetworkNameFromChainId(ChainID.goerli), | ||
lockedVaultAddr: getVaultAddress("dummy", VaultType.LOCKED), | ||
liquidVaultAddr: getVaultAddress("dummy", VaultType.LIQUID), | ||
}, | ||
}; | ||
|
||
export const flux: StratConfig = { | ||
name: "flux", | ||
id: "0x00000001", | ||
chainId: ChainID.ethereum, | ||
tokenName: "FluxVaultAP", | ||
tokenSymbol: "fUSDC_AP", | ||
baseToken: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", | ||
yieldToken: "0x465a5a630482f3abD6d3b84B39B29b07214d19e5", | ||
params: { | ||
approvalState: StrategyApprovalState.APPROVED, | ||
network: getNetworkNameFromChainId(ChainID.ethereum), | ||
lockedVaultAddr: getVaultAddress("flux", VaultType.LOCKED), | ||
liquidVaultAddr: getVaultAddress("flux", VaultType.LIQUID), | ||
}, | ||
}; | ||
|
||
export const allStrategyConfigs: AllStratConfigs = { | ||
dummy: dummy, | ||
flux: flux, | ||
}; |
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 +1,12 @@ | ||
{"dummy":{"strategy":"0xBe3865948ba88f479Ca05265E9B59869d99552de","locked":"0x3ab0ADa0d1De810cc6845B7433134554D98Ff39f","liquid":"0x9ed0fC3ba80c2c3B443b3dc51597245F840d9D5C"}} | ||
{ | ||
"dummy": { | ||
"strategy": "0xBe3865948ba88f479Ca05265E9B59869d99552de", | ||
"locked": "0x3ab0ADa0d1De810cc6845B7433134554D98Ff39f", | ||
"liquid": "0x9ed0fC3ba80c2c3B443b3dc51597245F840d9D5C" | ||
}, | ||
"flux": { | ||
"strategy": "", | ||
"locked": "", | ||
"liquid": "" | ||
} | ||
} |
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,19 @@ | ||
#!/bin/sh | ||
|
||
# turn logging on | ||
set -x; | ||
|
||
if [ "$1" == "mumbai" ]; then | ||
rpc=$(grep MUMBAI_RPC_URL .env | cut -d '=' -f2 | sed -e 's/^\"//' -e 's/\"$//'); | ||
elif [ "$1" == "polygon" ]; then | ||
rpc=$(grep POLYGON_RPC_URL .env | cut -d '=' -f2 | sed -e 's/^\"//' -e 's/\"$//'); | ||
elif [ "$1" == "goerli" ]; then | ||
rpc=$(grep GOERLI_RPC_URL .env | cut -d '=' -f2 | sed -e 's/^\"//' -e 's/\"$//'); | ||
elif [ "$1" == "mainnet" ]; then | ||
rpc=$(grep MAINNET_RPC_URL .env | cut -d '=' -f2 | sed -e 's/^\"//' -e 's/\"$//'); | ||
else | ||
echo ERROR: Select valid option from {mumbai, polygon, goerli, mainnet} | ||
exit 1; | ||
fi | ||
|
||
hardhat node --fork $rpc |
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
File renamed without changes.
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,27 @@ | ||
import {task} from "hardhat/config"; | ||
import {FluxStrategy__factory} from "typechain-types"; | ||
import {getSigners, logger} from "utils"; | ||
import {deployStrategySet} from "./helpers"; | ||
|
||
const NAME = "flux"; | ||
|
||
type TaskArgs = { | ||
apTeamSignerPkey?: string; | ||
}; | ||
|
||
task("Deploy:strategy:flux", `Will deploy ${NAME} and a pair of generic vaults`) | ||
.addOptionalParam( | ||
"apTeamSignerPkey", | ||
"If running on prod, provide a pkey for a valid APTeam Multisig Owner." | ||
) | ||
.setAction(async (taskArgs: TaskArgs, hre) => { | ||
try { | ||
logger.out(`Deploying strategy: ${NAME}`); | ||
const {deployer} = await getSigners(hre); | ||
const StrategyFactory = new FluxStrategy__factory(deployer); | ||
const signerPkey = taskArgs.apTeamSignerPkey ? taskArgs.apTeamSignerPkey : ""; | ||
await deployStrategySet(NAME, StrategyFactory, signerPkey, hre); | ||
} catch (error) { | ||
logger.out(error, logger.Level.Error); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.