Skip to content

Commit

Permalink
:wq
Browse files Browse the repository at this point in the history
chore: adding fantom
  • Loading branch information
Lamicham committed Oct 23, 2024
1 parent 21e51b1 commit 2e1a590
Show file tree
Hide file tree
Showing 13 changed files with 5,479 additions and 758 deletions.
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

0 comments on commit 2e1a590

Please sign in to comment.