Skip to content

Commit

Permalink
deploy temp pool factory
Browse files Browse the repository at this point in the history
  • Loading branch information
PlayJok3r committed Dec 30, 2024
1 parent c636963 commit fa75430
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 21 deletions.
2 changes: 1 addition & 1 deletion deployment/deployUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable no-undef */
import { BigNumber as BN, ethers } from "ethers";
import fs from "fs";
const DEPLOYED_PATH = "./deployment/";
const DEPLOYED_PATH = "./deployment/scroll-temp/";

const MAX_FEE_PER_GAS = 300_000_000;
const MAX_PRIORITY_FEE_PER_GAS = 100_000_000;
Expand Down
7 changes: 5 additions & 2 deletions deployment/scroll-deployed-contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"EpochManagerImpl": "0x5Cf4467F129e87274196a95a47BdE57f2C3F6C56",
"DrepcatedTrancheVaultImpl": "0x8e945C9ca71637D5582FA2cA6347bD4634261410",
"CreditLineImpl": "0x900DB77BB9c061051A4EB8A8Bdd8F02f1ee17EB6",
"ReceivableBackedCreditLineImpl": "0xc4789238b899d9f9E84Bc1ea01D0CF3923D4E33E",
"DrepcatedReceivableBackedCreditLineImpl": "0xc4789238b899d9f9E84Bc1ea01D0CF3923D4E33E",
"ReceivableFactoringCreditImpl": "0xA15e0D4Dd6010DAc65e3994DE8D97C548326eaF9",
"CreditDueManagerImpl": "0x11c5a1D28bBe81C22803f29fb7591AF4914ddc56",
"CreditLineManagerImpl": "0xF2AC6AD2d673A4c4aEc163FC5eAf989707edE9B0",
Expand All @@ -26,5 +26,8 @@
"PoolConfigImpl": "0x0da01955AB786a948A6F34317c3beE47c804ad4F",
"TrancheVaultImpl": "0x23E32ea325D4614634986264bF5A419304665116",
"PoolConfig6Month": "0x8A89942cda613BB9Dc7a8eF6Dbdc788EE3F29410",
"PoolConfig3Month": "0xEBA0756b813e49bA84Cb3B8E2d717bcF0C07fC99"
"BrokenPoolConfig3Month": "0xEBA0756b813e49bA84Cb3B8E2d717bcF0C07fC99",
"ReceivableBackedCreditLineImpl": "0x3Fee297FaD2e7c646a971c6A0408c27D62853d18",
"PoolConfig3Month": "0xEb78F0fB18f417b7b71E0Ee8391d2aA57069810f",
"FixedSeniorYieldTranchesPolicy": "0x7a0072555a6D06c1fb8CFBe3A71A384FFE729872"
}
29 changes: 29 additions & 0 deletions deployment/scroll-temp/scroll-deployed-contracts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"MockToken": "0x4730Ba92780b6783Ce97bD5f7AaD75337d6D180A",
"Calendar": "0x0562e6287dd69E76771E046f7E24ADC608c837b6",
"HumaConfig": "0x1691090fb0cFd3bd9b59128b57490eA882A09573",
"HumaConfigTimelock": "0x5B7841b94a3C7246662ef514745b034A6ceaAB15",
"PoolFeeManagerImpl": "0xf5F9297c74e464933e42F4a989e81D931fb20f83",
"PoolSafeImpl": "0x98f41d57C06b302AFf999f3F58f4ae7a3F884590",
"FirstLossCoverImpl": "0x87FD98F3eB172B5183F7527060DDbe8a8D17B924",
"RiskAdjustedTranchesPolicyImpl": "0x58AAF1f9cB10F335111A2129273056bbED251B61",
"FixedSeniorYieldTranchesPolicyImpl": "",
"PoolImpl": "",
"EpochManagerImpl": "",
"CreditLineImpl": "0x900DB77BB9c061051A4EB8A8Bdd8F02f1ee17EB6",
"ReceivableBackedCreditLineImpl": "",
"ReceivableFactoringCreditImpl": "0xA15e0D4Dd6010DAc65e3994DE8D97C548326eaF9",
"CreditDueManagerImpl": "0x11c5a1D28bBe81C22803f29fb7591AF4914ddc56",
"CreditLineManagerImpl": "0xF2AC6AD2d673A4c4aEc163FC5eAf989707edE9B0",
"ReceivableBackedCreditLineManagerImpl": "",
"ReceivableFactoringCreditManagerImpl": "0x79D1aC58F10F724B6aB67708A411c50ED4DA281d",
"ReceivableImpl": "0x0a76a396fc138f211d01D2d5844d4b469ae37B69",
"LibTimelockController": "0x78f95653fD62a5CFc15E3c25B2212BC13d85f195",
"PoolFactoryImpl": "0x97745a975a7596b2F62fa0ed1A7302ADAc9433f4",
"PoolFactory": "",
"PoolConfigImpl": "0x0da01955AB786a948A6F34317c3beE47c804ad4F",
"TrancheVaultImpl": "",
"PoolConfig6Month": "0x8A89942cda613BB9Dc7a8eF6Dbdc788EE3F29410",
"BrokenPoolConfig3Month": "0xEBA0756b813e49bA84Cb3B8E2d717bcF0C07fC99",
"PoolConfig3Month": "0xEb78F0fB18f417b7b71E0Ee8391d2aA57069810f"
}
166 changes: 166 additions & 0 deletions deployment/scroll/[temp]deploy-recovery-protocol-factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import hre, { network } from "hardhat";
import { deploy } from "../deployUtils.ts";

const HUMA_OWNER_ADDRESS = "0xABd48A580F66ad5Ad0Fe983968De686F408c88EE";
let deployer;
let networkName;

async function deployImplementationContracts() {
const contracts = [
// "PoolConfig",
// "PoolFeeManager",
// "PoolSafe",
// "FirstLossCover",
// "RiskAdjustedTranchesPolicy",
// "FixedSeniorYieldTranchesPolicy",
// "Pool",
// "EpochManager",
// "TrancheVault",
// "CreditLine",
"ReceivableBackedCreditLine",
// "ReceivableFactoringCredit",
// "CreditDueManager",
// "CreditLineManager",
// "ReceivableBackedCreditLineManager",
// "ReceivableFactoringCreditManager",
// "Receivable",
];

for (var contractName of contracts) {
console.log(contractName);
await deploy(networkName, contractName, `${contractName}Impl`);
}
}

async function deployFactory(humaConfigAddress) {
const libTimelockController = await deploy(
networkName,
"LibTimelockController",
"LibTimelockController",
);
const poolFactoryImpl = await deploy(networkName, "PoolFactory", "PoolFactoryImpl", [], {
libraries: { LibTimelockController: libTimelockController.address },
});
console.log(humaConfigAddress);
const fragment = await poolFactoryImpl.interface.getFunction("initialize(address)");
const calldata = await poolFactoryImpl.interface.encodeFunctionData(fragment, [
humaConfigAddress,
]);
await deploy(networkName, "ERC1967Proxy", "PoolFactory", [poolFactoryImpl.address, calldata]);
}

async function deployProtocolContracts() {
await deploy(networkName, "Calendar", "Calendar");
const humaConfig = await deploy(networkName, "HumaConfig", "HumaConfig");
await deploy(networkName, "TimelockController", "HumaConfigTimelock", [
0,
[HUMA_OWNER_ADDRESS],
[deployer.address],
deployer.address,
]);

return humaConfig.address;
}

async function deployPoolConfigOne() {
const Contract = await hre.ethers.getContractFactory("PoolConfig");

const poolConfigImpl = Contract.attach("0x0da01955AB786a948A6F34317c3beE47c804ad4F");

const fragment = await poolConfigImpl.interface.getFunction("initialize(string,address[])");
const calldata = await poolConfigImpl.interface.encodeFunctionData(fragment, [
"Arf 6 month pool",
[
"0x1691090fb0cFd3bd9b59128b57490eA882A09573",
"0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
"0x0562e6287dd69E76771E046f7E24ADC608c837b6",
"0x1900e417869691277cfd20f4001b768B03375272",
"0xD6C357c40731a1F57173231eeeAb004eD8baE9b6",
"0xF1c6661dAd77F50D9Da9199b0705733Cd174f9f1",
"0xf6C0018bE7F400f77996096C56A3721301fE6620", //tranchesPolicy
"0x648186Cf2a78AB9356C82ec29EDA42798453C8d6",
"0xDe5eD603A376B93817b9656AF6E373218fD9b2bd",
"0x8413a7345cD8bF8Afe8c2EfE866a764A93B305e2",
"0x2e3A03C8Bd31300C2c027C9C9d1b762677F6FaA6",
"0xd92950BAe0582620106E1D6ed67a708fF3Eee08F",
"0xbC015F64b023d8B351484342d35dA0AF0d42a9de",
],
]);
await deploy(networkName, "ERC1967Proxy", "PoolConfig6Month", [
poolConfigImpl.address,
calldata,
]);
}

async function deployPoolConfigTwo() {
const Contract = await hre.ethers.getContractFactory("PoolConfig");

const poolConfigImpl = Contract.attach("0x0da01955AB786a948A6F34317c3beE47c804ad4F");

const fragment = await poolConfigImpl.interface.getFunction("initialize(string,address[])");
const calldata = await poolConfigImpl.interface.encodeFunctionData(fragment, [
"Arf 3 month pool",
[
"0x1691090fb0cFd3bd9b59128b57490eA882A09573",
"0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
"0x0562e6287dd69E76771E046f7E24ADC608c837b6",
"0x5227254a6aCa397e95F310b52f6D3143A5A9Ee14",
"0x7F4f55fAeE753D8dbB3E5F04861dB38E9DB70c3D",
"0xDD7FB0B032Fa571c1B65EDE318c1142297ED7AE7",
"0x13d8446B1b365d53B0696947fa96624b5CE19bf3",
"0x1a2C87Be5e785493310526faA7739Bbe4E10c0F6",
"0x4cdCedcF50266aD9ed809048BC9874320EC902bC",
"0x483D02C11f8F1E31C267040A6C86AaB80c428BaB",
"0xc6F10af4746784a0DD095f4E5718d53ff94eB4a0",
"0x2e906F96918eDBBeAe8a204FAD1E8F71376E3345",
"0x061411d05074Bc974f814AC86309D2204f4c265d",
],
]);
await deploy(networkName, "ERC1967Proxy", "PoolConfig3Month", [
poolConfigImpl.address,
calldata,
]);
}

async function deployTranchesPolicy() {
const Contract = await hre.ethers.getContractFactory("FixedSeniorYieldTranchesPolicy");

const Impl = Contract.attach("0x941687792107eaC859B820d1636936382F3189aa");

const fragment = await Impl.interface.getFunction("initialize(address)");
const calldata = await Impl.interface.encodeFunctionData(fragment, [
"0xEb78F0fB18f417b7b71E0Ee8391d2aA57069810f",
]);

await deploy(networkName, "ERC1967Proxy", "FixedSeniorYieldTranchesPolicy", [
Impl.address,
calldata,
]);
}

async function deployContracts() {
// const networkName = (await hre.ethers.provider.getNetworkName()).name;
networkName = network.name;
console.log("networkName : ", networkName);
const accounts = await hre.ethers.getSigners();
if (accounts.length == 0) {
throw new Error("Accounts not set!");
}
[deployer] = await accounts;
console.log("deployer address: " + deployer.address);

await deploy(networkName, "MockToken", "MockToken");
const humaConfigAddress = await deployProtocolContracts();
await deployImplementationContracts();
// await deployFactory(humaConfigAddress);
// await deployPoolConfigOne();
// await deployPoolConfigTwo();
await deployTranchesPolicy();
}

deployContracts()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
53 changes: 35 additions & 18 deletions deployment/scroll/deploy-protocol-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ let networkName;
async function deployImplementationContracts() {
const contracts = [
"PoolConfig",
// "PoolFeeManager",
// "PoolSafe",
// "FirstLossCover",
// "RiskAdjustedTranchesPolicy",
// "FixedSeniorYieldTranchesPolicy",
// "Pool",
// "EpochManager",
"PoolFeeManager",
"PoolSafe",
"FirstLossCover",
"RiskAdjustedTranchesPolicy",
"FixedSeniorYieldTranchesPolicy",
"Pool",
"EpochManager",
"TrancheVault",
// "CreditLine",
// "ReceivableBackedCreditLine",
// "ReceivableFactoringCredit",
// "CreditDueManager",
// "CreditLineManager",
// "ReceivableBackedCreditLineManager",
// "ReceivableFactoringCreditManager",
// "Receivable",
"CreditLine",
"ReceivableBackedCreditLine",
"ReceivableFactoringCredit",
"CreditDueManager",
"CreditLineManager",
"ReceivableBackedCreditLineManager",
"ReceivableFactoringCreditManager",
"Receivable",
];

for (var contractName of contracts) {
Expand Down Expand Up @@ -99,7 +99,7 @@ async function deployPoolConfigTwo() {

const fragment = await poolConfigImpl.interface.getFunction("initialize(string,address[])");
const calldata = await poolConfigImpl.interface.encodeFunctionData(fragment, [
"Arf 6 month pool",
"Arf 3 month pool",
[
"0x1691090fb0cFd3bd9b59128b57490eA882A09573",
"0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4",
Expand All @@ -122,6 +122,22 @@ async function deployPoolConfigTwo() {
]);
}

async function deployTranchesPolicy() {
const Contract = await hre.ethers.getContractFactory("FixedSeniorYieldTranchesPolicy");

const Impl = Contract.attach("0x941687792107eaC859B820d1636936382F3189aa");

const fragment = await Impl.interface.getFunction("initialize(address)");
const calldata = await Impl.interface.encodeFunctionData(fragment, [
"0xEb78F0fB18f417b7b71E0Ee8391d2aA57069810f",
]);

await deploy(networkName, "ERC1967Proxy", "FixedSeniorYieldTranchesPolicy", [
Impl.address,
calldata,
]);
}

async function deployContracts() {
// const networkName = (await hre.ethers.provider.getNetworkName()).name;
networkName = network.name;
Expand All @@ -137,8 +153,9 @@ async function deployContracts() {
const humaConfigAddress = await deployProtocolContracts();
await deployImplementationContracts();
await deployFactory(humaConfigAddress);
await deployPoolConfigOne();
await deployPoolConfigTwo();
// await deployPoolConfigOne();
// await deployPoolConfigTwo();
// await deployTranchesPolicy();
}

deployContracts()
Expand Down
4 changes: 4 additions & 0 deletions hardhat.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const config: HardhatUserConfig = {
}
: undefined,
},
localhost: {
url: "http://localhost:8545",
accounts: [deployer],
},
sepolia: {
url: sepoliaUrl,
accounts: [deployer],
Expand Down

0 comments on commit fa75430

Please sign in to comment.