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

chore: adding fantom #86

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
114 changes: 70 additions & 44 deletions deploy/0_distributor.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
import { ChainId, CONTRACTS_ADDRESSES, CoreBorrow, CoreBorrow__factory, registry } from '@angleprotocol/sdk';
import { DeployFunction } from 'hardhat-deploy/types';
import yargs from 'yargs';
import * as readline from 'readline';
import * as readline from "readline";
import {
CONTRACTS_ADDRESSES,
ChainId,
CoreBorrow,
CoreBorrow__factory,
registry,
} from "@angleprotocol/sdk";
import type { DeployFunction } from "hardhat-deploy/types";
import yargs from "yargs";

import { Distributor, Distributor__factory } from '../typechain';
const argv = yargs.env('').boolean('ci').parseSync();
import { type Distributor, Distributor__factory } from "../typechain";
const argv = yargs.env("").boolean("ci").parseSync();

// Before running this deployment, make sure that on borrow-contracts the ProxyAdminAngleLabs and CoreMerkl
// contracts were deployed with:
// - governor of CoreMerkl: AngleLabs address
// - guardian: the deployer address
// Admin of ProxyAdmin: AngleLabs multisig
const func: DeployFunction = async ({ deployments, ethers, network }) => {
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();

let core: string;
// TODO: change the coreMerkl address to that of the desired chain
let core: string;
// TODO: change the coreMerkl address to that of the desired chain

core = '0xE9169817EdBFe5FCF629eD8b3C2a34E2a50ec84C';
const coreContract = new ethers.Contract(core, CoreBorrow__factory.createInterface(), deployer) as any;
if (await coreContract.GOVERNOR_ROLE()!= '0x7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55') throw 'Invalid Core Merkl'
core = "0x1746f9bb465d3747fe9C2CfE7759F4B871a06d3C";
const coreContract = new ethers.Contract(
core,
CoreBorrow__factory.createInterface(),
deployer,
) as any;
if (
(await coreContract.GOVERNOR_ROLE()) !=
"0x7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55"
)
throw "Invalid Core Merkl";

if (deployer.address !== '0x9f76a95AA7535bb0893cf88A146396e00ed21A12') throw `Invalid deployer address: ${deployer.address}`;
/*

if (deployer.address !== "0x9f76a95AA7535bb0893cf88A146396e00ed21A12")
throw `Invalid deployer address: ${deployer.address}`;
/*
if (!network.live) {
// If we're in mainnet fork, we're using the `CoreBorrow` address from mainnet
core = registry(ChainId.MAINNET)?.Merkl?.CoreMerkl!;
Expand All @@ -33,41 +49,51 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {
}
*/

console.log('Let us get started with deployment, deploying with this address');
console.log(deployer.address);
console.log(
"Let us get started with deployment, deploying with this address",
);
console.log(deployer.address);

console.log("Now deploying Distributor");
console.log("Starting with the implementation");

await deploy("Distributor_Implementation_V2_2", {
contract: "Distributor",
from: deployer.address,
log: !argv.ci,
});

console.log('Now deploying Distributor');
console.log('Starting with the implementation');
const implementationAddress = (
await ethers.getContract("Distributor_Implementation_V2_2")
).address;

await deploy('Distributor_Implementation_V2_2', {
contract: 'Distributor',
from: deployer.address,
log: !argv.ci,
});
console.log(
`Successfully deployed the implementation for Distributor at ${implementationAddress}`,
);
console.log("");

const implementationAddress = (await ethers.getContract('Distributor_Implementation_V2_2')).address;

console.log(`Successfully deployed the implementation for Distributor at ${implementationAddress}`);
console.log('');

console.log('Now deploying the Proxy');
console.log("Now deploying the Proxy");

await deploy('Distributor', {
contract: 'ERC1967Proxy',
from: deployer.address,
args: [implementationAddress, '0x'],
log: !argv.ci,
});
await deploy("Distributor", {
contract: "ERC1967Proxy",
from: deployer.address,
args: [implementationAddress, "0x"],
log: !argv.ci,
});

const distributor = (await deployments.get('Distributor')).address;
console.log(`Successfully deployed contract at the address ${distributor}`);
console.log('Initializing the contract');
const contract = new ethers.Contract(distributor, Distributor__factory.createInterface(), deployer) as Distributor;
await (await contract.connect(deployer).initialize(core)).wait();
console.log('Contract successfully initialized');
console.log('');
const distributor = (await deployments.get("Distributor")).address;
console.log(`Successfully deployed contract at the address ${distributor}`);
console.log("Initializing the contract");
const contract = new ethers.Contract(
distributor,
Distributor__factory.createInterface(),
deployer,
) as Distributor;
await (await contract.connect(deployer).initialize(core)).wait();
console.log("Contract successfully initialized");
console.log("");
};

func.tags = ['distributor'];
func.tags = ["distributor"];
// func.dependencies = ['mockCore'];
export default func;
138 changes: 80 additions & 58 deletions deploy/1_distributionCreator.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
import { DeployFunction } from 'hardhat-deploy/types';
import yargs from 'yargs';
import * as readline from 'readline';
import * as readline from "readline";
import type { DeployFunction } from "hardhat-deploy/types";
import yargs from "yargs";

import { DistributionCreator, DistributionCreator__factory } from '../typechain';
import { parseAmount } from '../utils/bignumber';
import { CoreBorrow__factory } from '@angleprotocol/sdk';
const argv = yargs.env('').boolean('ci').parseSync();
import { CoreBorrow__factory } from "@angleprotocol/sdk";
import {
type DistributionCreator,
DistributionCreator__factory,
} from "../typechain";
import { parseAmount } from "../utils/bignumber";
const argv = yargs.env("").boolean("ci").parseSync();

const func: DeployFunction = async ({ deployments, ethers, network }) => {
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();

let core: string;
core = '0xE9169817EdBFe5FCF629eD8b3C2a34E2a50ec84C';
const coreContract = new ethers.Contract(core, CoreBorrow__factory.createInterface(), deployer) as any;
if (await coreContract.GOVERNOR_ROLE()!= '0x7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55') throw 'Invalid Core Merkl'

if (deployer.address !== '0x9f76a95AA7535bb0893cf88A146396e00ed21A12') throw `Invalid deployer address: ${deployer.address}`;

/*
let core: string;
core = "0x1746f9bb465d3747fe9C2CfE7759F4B871a06d3C";
const coreContract = new ethers.Contract(
core,
CoreBorrow__factory.createInterface(),
deployer,
) as any;
if (
(await coreContract.GOVERNOR_ROLE()) !=
"0x7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55"
)
throw "Invalid Core Merkl";


if (deployer.address !== "0x9f76a95AA7535bb0893cf88A146396e00ed21A12")
throw `Invalid deployer address: ${deployer.address}`;

/*
if (!network.live) {
// If we're in mainnet fork, we're using the `CoreBorrow` address from mainnet
core = registry(ChainId.MAINNET)?.Merkl?.CoreMerkl!;
Expand All @@ -28,46 +42,54 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {
}
*/

console.log(deployer.address);
console.log('Now deploying DistributionCreator');
console.log('Starting with the implementation');
console.log('deployer ', await deployer.getBalance());
await deploy('DistributionCreator_Implementation_V2_0', {
contract: 'DistributionCreator',
from: deployer.address,
log: !argv.ci,
});

const implementationAddress = (await ethers.getContract('DistributionCreator_Implementation_V2_0')).address;

console.log(`Successfully deployed the implementation for DistributionCreator at ${implementationAddress}`);
console.log('');

const distributor = (await deployments.get('Distributor')).address;
console.log('Now deploying the Proxy');

await deploy('DistributionCreator', {
contract: 'ERC1967Proxy',
from: deployer.address,
args: [implementationAddress, '0x'],
log: !argv.ci,
});

const manager = (await deployments.get('DistributionCreator')).address;
console.log(`Successfully deployed contract at the address ${manager}`);
console.log('Initializing the contract');
const contract = new ethers.Contract(
manager,
DistributionCreator__factory.createInterface(),
deployer,
) as DistributionCreator;

await (await contract.connect(deployer).initialize(core, distributor, parseAmount.gwei('0.03'))).wait();
console.log('Contract successfully initialized');
console.log('');
console.log(await contract.core());

/* Once good some functions need to be called to have everything setup.
console.log(deployer.address);
console.log("Now deploying DistributionCreator");
console.log("Starting with the implementation");
console.log("deployer ", await deployer.getBalance());
await deploy("DistributionCreator_Implementation_V2_0", {
contract: "DistributionCreator",
from: deployer.address,
log: !argv.ci,
});

const implementationAddress = (
await ethers.getContract("DistributionCreator_Implementation_V2_0")
).address;

console.log(
`Successfully deployed the implementation for DistributionCreator at ${implementationAddress}`,
);
console.log("");

const distributor = (await deployments.get("Distributor")).address;
console.log("Now deploying the Proxy");

await deploy("DistributionCreator", {
contract: "ERC1967Proxy",
from: deployer.address,
args: [implementationAddress, "0x"],
log: !argv.ci,
});

const manager = (await deployments.get("DistributionCreator")).address;
console.log(`Successfully deployed contract at the address ${manager}`);
console.log("Initializing the contract");
const contract = new ethers.Contract(
manager,
DistributionCreator__factory.createInterface(),
deployer,
) as DistributionCreator;

await (
await contract
.connect(deployer)
.initialize(core, distributor, parseAmount.gwei("0.03"))
).wait();
console.log("Contract successfully initialized");
console.log("");
console.log(await contract.core());

/* Once good some functions need to be called to have everything setup.

In the `DistributionCreator` contract:
- `setRewardTokenMinAmounts`
Expand All @@ -82,6 +104,6 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {
*/
};

func.tags = ['distributionCreator'];
func.dependencies = ['distributor'];
func.tags = ["distributionCreator"];
func.dependencies = ["distributor"];
export default func;
1 change: 1 addition & 0 deletions deployments/fantom/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
250
Loading
Loading