-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy path002_settlement.ts
More file actions
66 lines (59 loc) · 2.04 KB
/
002_settlement.ts
File metadata and controls
66 lines (59 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import WETH from "canonical-weth/build/contracts/WETH9.json";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import Authorizer from "../../balancer/Authorizer.json";
import Vault from "../../balancer/Vault.json";
import BALANCER_NETWORKS from "../../balancer/networks.json";
import { CONTRACT_NAMES, SALT } from "../ts/deploy";
const deploySettlement: DeployFunction = async function ({
deployments,
ethers,
getNamedAccounts,
network,
}: HardhatRuntimeEnvironment) {
const { deployer, manager } = await getNamedAccounts();
const { deploy, get } = deployments;
const { authenticator, settlement } = CONTRACT_NAMES;
const { address: authenticatorAddress } = await get(authenticator);
let vaultAddress: string;
if (network.name === "hardhat" || network.name === "localhost") {
const { address: authorizerAddress } = await deploy("VaultAuthorizer", {
from: deployer,
contract: Authorizer,
gasLimit: 3e6,
args: [manager],
});
const { address: wethAddress } = await deploy("WETH", {
from: deployer,
contract: WETH,
gasLimit: 3e6,
});
({ address: vaultAddress } = await deploy("Vault", {
from: deployer,
contract: Vault,
gasLimit: 8e6,
args: [authorizerAddress, wethAddress, 0, 0],
}));
} else {
const { chainId } = await ethers.provider.getNetwork();
const vaultNetworks = BALANCER_NETWORKS["Vault"] as Record<
number,
{ address: string } | undefined
>;
const vaultDeployment = vaultNetworks[chainId];
if (vaultDeployment === undefined) {
throw new Error(
`Vault not validated on chain ${chainId}. Make sure the Balancer deployment is safe to use first, then add it to the networks.json file`,
);
}
vaultAddress = vaultDeployment.address;
}
await deploy(settlement, {
from: deployer,
gasLimit: 5e6,
args: [authenticatorAddress, vaultAddress],
deterministicDeployment: SALT,
log: true,
});
};
export default deploySettlement;