Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Get ready for mainnet flux deployment #384

Merged
merged 13 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
12 changes: 6 additions & 6 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## Etherscan explorer API config
## Etherscan and RPC url config
ETHERSCAN_API_KEY="put your key here plz"
MAINNET_URL="https://api.etherscan.io/"
GOERLI_RPC_URL="https://api-goerli.etherscan.io/"
MAINNET_RPC_URL="MAINNET RPC URL"
GOERLI_RPC_URL="GOERLI RPC URL"

## Polyscan explorer API config
## Polyscan and RPC url config
POLYSCAN_API_KEY="put your key here plz"
POLYGON_RPC_URL="https://api.polygonscan.com/"
MUMBAI_RPC_URL="https://api-testnet.polygonscan.com/"
POLYGON_RPC_URL="POLYGON RPC URL"
MUMBAI_RPC_URL="MUMBAI RPC URL"

##Solidity config settings
OPTIMIZER_FLAG=true
Expand Down
2 changes: 1 addition & 1 deletion config/env.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ETHERSCAN_API_KEY = extractString("ETHERSCAN_API_KEY");
const GOERLI_RPC_URL = extractString("GOERLI_RPC_URL");
const GANACHE_PRIVATE_KEY = extractString("GANACHE_PRIVATE_KEY");
const GANACHE_RPC_URL = extractString("GANACHE_RPC_URL");
const MAINNET_RPC_URL = extractString("MAINNET_URL");
const MAINNET_RPC_URL = extractString("MAINNET_RPC_URL");
const MUMBAI_RPC_URL = extractString("MUMBAI_RPC_URL");
const POLYGON_RPC_URL = extractString("POLYGON_RPC_URL");
const POLYSCAN_API_KEY = extractString("POLYSCAN_API_KEY");
Expand Down
81 changes: 81 additions & 0 deletions contracts/core/vault/scripts/deployVaultPair.ts
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();
}
25 changes: 23 additions & 2 deletions contracts/integrations/stratConfig.ts
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,
};
13 changes: 12 additions & 1 deletion contracts/integrations/strategy-addresses.json
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": ""
}
}
19 changes: 19 additions & 0 deletions fork.sh
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"preinstall": "npx only-allow yarn",
"format": "prettier --write './{config,contracts,eth-sdk,scripts,tasks,test,utils}/**/*.{ts,js,sol}'",
"fork": "hardhat node --fork $(grep MUMBAI_RPC_URL .env | cut -d '=' -f2 | sed -e 's/^\"//' -e 's/\"$//')",
"fork": "bash ./fork.sh",
"test": "hardhat test",
"compile": "bash ./compile.sh",
"deploy": "hardhat compile && hardhat deploy:AngelProtocol",
Expand Down
35 changes: 35 additions & 0 deletions tasks/deploy/deploySideChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {getOrDeployThirdPartyContracts} from "tasks/helpers";
import {Deployment} from "types";
import {
confirmAction,
getAddresses,
getAddressesByNetworkId,
getNetworkNameFromChainId,
getPrimaryChainId,
getSigners,
isLocalNetwork,
logger,
Expand Down Expand Up @@ -71,10 +75,41 @@ task("deploy:SideChain", "Will deploy complete side-chain infrastructure")
yes: true,
});

// Configure the registrar
const primaryChainId = await getPrimaryChainId(hre);
const primaryChainName = getNetworkNameFromChainId(primaryChainId);
const primaryAddresses = getAddressesByNetworkId(primaryChainId);
const addresses = await getAddresses(hre);

await hre.run("manage:registrar:setAccountsChainAndAddress", {
accountsDiamond: primaryAddresses.accounts.diamond,
chainName: primaryChainName,
apTeamSignerPkey: taskArgs.apTeamSignerPkey,
});

await hre.run("manage:registrar:setTokenAccepted", {
tokenAddress: addresses.tokens.usdc,
acceptanceState: true,
apTeamSignerPkey: taskArgs.apTeamSignerPkey,
});

await hre.run("manage:registrar:updateNetworkConnections", {
chainId: primaryChainId,
apTeamSignerPkey: taskArgs.apTeamSignerPkey,
yes: true,
});

await hre.run("manage:registrar:setVaultOperatorStatus", {
operator: addresses.router.proxy,
approved: true,
apTeamSignerPkey: taskArgs.apTeamSignerPkey,
});

await hre.run("manage:registrar:setAllFeeSettings", {
apTeamSignerPkey: taskArgs.apTeamSignerPkey,
});

// Verify if needed
if (!isLocalNetwork(hre) && !taskArgs.skipVerify) {
const deployments: Array<Deployment<ContractFactory>> = [
proxyAdminMultisig,
Expand Down
19 changes: 19 additions & 0 deletions tasks/deploy/integrations/deployFlux.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {task} from "hardhat/config";
import {FluxStrategy__factory} from "typechain-types";
import {getSigners, logger} from "utils";
import {deployStrategySet} from "./helpers";

const NAME = "flux";

task("Deploy:strategy:flux", `Will deploy ${NAME} and a pair of generic vaults`).setAction(
async (_, hre) => {
try {
logger.out(`Deploying strategy: ${NAME}`);
const {deployer} = await getSigners(hre);
const StrategyFactory = new FluxStrategy__factory(deployer);
await deployStrategySet(NAME, StrategyFactory, hre);
} catch (error) {
logger.out(error, logger.Level.Error);
}
}
);
66 changes: 0 additions & 66 deletions tasks/deploy/integrations/genericVault.ts

This file was deleted.

Loading