-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
296 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"MockToken": "0x50dc34a634F3E29CfBad79E9cECD2759a6bA8Eae", | ||
"Calendar": "0xb94879541CAF746bFe1b066421E7D64C94fC9738", | ||
"HumaConfig": "0xa0A16038D714F687679732dCb34e1d4051218Dc5", | ||
"HumaConfigTimelock": "0x503EA0E2d1180b74F3A6105F43C481d18C2e426d", | ||
"PoolConfigImpl": "0x41c82e7bA2Cea9b14B4CCd88d96739a1f1890384", | ||
"PoolFeeManagerImpl": "0xEDa33b3b92Af44D5D1Be70Fb77527e74CbE933f7", | ||
"PoolSafeImpl": "0xCc0a468E93e8D2eEA311c7e9135BB78207DB7EF9", | ||
"FirstLossCoverImpl": "0xDDf423278bBe8A5Fc0E608d68A577f05024a8Ed4", | ||
"RiskAdjustedTranchesPolicyImpl": "0xF1982c34E7256e02852e7dE664247aE04B0c71f2", | ||
"FixedSeniorYieldTranchesPolicyImpl": "0xBB867612c4428798F0Be599671530ED96B104D8a", | ||
"PoolImpl": "0x458594604Fbc36DE8016843D50e54688A639655B", | ||
"EpochManagerImpl": "0x03e84C522b834Bb8cF84A5B64b4d0824e492Fc68", | ||
"TrancheVaultImpl": "0x3DA2A11433eABBB1E661478BdBd03510F9D4b83b", | ||
"CreditLineImpl": "0xbaFF4a403AA31819B1bD23A254EaEd3d8cC87a41", | ||
"ReceivableBackedCreditLineImpl": "0x479f92d5F875f9Ced1C8C95cB8dcE6b7F6Ce9c92", | ||
"ReceivableFactoringCreditImpl": "0x9BF2A12eB9276314F26A7E575cdb99D041D06DF3", | ||
"CreditDueManagerImpl": "0x3e4c08aE5fD8d535033942B5fB7D761C271762e3", | ||
"CreditLineManagerImpl": "0xD19d0C1EAC63f1E1e41FE86F83C08774CA324155", | ||
"ReceivableBackedCreditLineManagerImpl": "0xd61F3595Da5563826875dcB239dD06b348f93702", | ||
"ReceivableFactoringCreditManagerImpl": "0xdf243D02f5a6611F1D5988Dd8376FB1269dDac89", | ||
"ReceivableImpl": "0xBA7525621EF5803FE0B0217F3Efb1889b9ca0686", | ||
"LibTimelockController": "0x0204CfeAE8B6e409a1695CfDeD4c3D6B403a213e", | ||
"PoolFactoryImpl": "0xb5d43a18c4c459DD705cc0924771D238514D1C5b", | ||
"PoolFactory": "0x88278d0370C8B13919F67c67f9a0067095Cf5447" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import hre, { network } from "hardhat"; | ||
import { deploy } from "../deployUtils.ts"; | ||
|
||
const HUMA_OWNER_ADDRESS = "0x60891b087E81Ee2a61B7606f68019ec112c539B9"; | ||
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 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); | ||
} | ||
|
||
deployContracts() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import hre, { network } from "hardhat"; | ||
import { | ||
getDeployedContracts, | ||
getInitilizedContract, | ||
sendTransaction, | ||
updateInitializedContract, | ||
} from "../deployUtils.ts"; | ||
|
||
let networkName; | ||
let deployer; | ||
let deployedContracts; | ||
const HUMA_TREASURY_ACCOUNT = "0x60891b087E81Ee2a61B7606f68019ec112c539B9"; | ||
const SENTINEL_ACCOUNT = "0x3C64b8A1431F2227E4aAD3aF15a7667b752A4537"; | ||
const contracts = [ | ||
"PoolConfig", | ||
"PoolFeeManager", | ||
"PoolSafe", | ||
"FirstLossCover", | ||
"RiskAdjustedTranchesPolicy", | ||
"FixedSeniorYieldTranchesPolicy", | ||
"Pool", | ||
"EpochManager", | ||
"TrancheVault", | ||
"CreditLine", | ||
"ReceivableBackedCreditLine", | ||
"ReceivableFactoringCredit", | ||
"CreditDueManager", | ||
"CreditLineManager", | ||
"ReceivableBackedCreditLineManager", | ||
"ReceivableFactoringCreditManager", | ||
"Receivable", | ||
]; | ||
|
||
async function transferOwnershipToTL(contractName, contractKey, timeLockKey) { | ||
if (!deployedContracts[timeLockKey]) { | ||
throw new Error(`${timeLockKey} not deployed yet!`); | ||
} | ||
|
||
if (!deployedContracts[contractKey]) { | ||
throw new Error(`${contractKey} not deployed yet!`); | ||
} | ||
|
||
const TimeLockController = await hre.ethers.getContractFactory("TimelockController"); | ||
const timeLockController = TimeLockController.attach(deployedContracts[timeLockKey]); | ||
|
||
const Contract = await hre.ethers.getContractFactory(contractName); | ||
const contract = Contract.attach(deployedContracts[contractKey]); | ||
|
||
await sendTransaction(contractKey, contract, "transferOwnership", [ | ||
timeLockController.address, | ||
]); | ||
|
||
const adminRole = await timeLockController.TIMELOCK_ADMIN_ROLE(); | ||
await sendTransaction(contractKey, timeLockController, "renounceRole", [ | ||
adminRole, | ||
deployer.address, | ||
]); | ||
} | ||
|
||
async function initHumaConfig() { | ||
const initilized = await getInitilizedContract("HumaConfig", networkName); | ||
if (initilized) { | ||
console.log("HumaConfig is already initialized!"); | ||
return; | ||
} | ||
|
||
if (!deployedContracts["HumaConfig"]) { | ||
throw new Error("HumaConfig not deployed yet!"); | ||
} | ||
|
||
if (!deployedContracts["MockToken"]) { | ||
throw new Error("MockToken not deployed yet!"); | ||
} | ||
|
||
const HumaConfig = await hre.ethers.getContractFactory("HumaConfig"); | ||
const humaConfig = HumaConfig.attach(deployedContracts["HumaConfig"]); | ||
|
||
await sendTransaction("HumaConfig", humaConfig, "setHumaTreasury", [HUMA_TREASURY_ACCOUNT]); | ||
await sendTransaction("HumaConfig", humaConfig, "setSentinelServiceAccount", [ | ||
SENTINEL_ACCOUNT, | ||
]); | ||
await sendTransaction("HumaConfig", humaConfig, "setLiquidityAsset", [ | ||
deployedContracts["MockToken"], | ||
true, | ||
]); | ||
// await transferOwnershipToTL("HumaConfig", "HumaConfig", "HumaConfigTimelock") | ||
|
||
await updateInitializedContract("HumaConfig", networkName); | ||
} | ||
|
||
async function initPoolFactory() { | ||
const initilized = await getInitilizedContract("PoolFactory", networkName); | ||
if (initilized) { | ||
console.log("PoolFactory is already initialized!"); | ||
return; | ||
} | ||
|
||
if (!deployedContracts["PoolFactory"]) { | ||
throw new Error("PoolFactory not deployed yet!"); | ||
} | ||
|
||
for (var contractName of contracts) { | ||
if (!deployedContracts[`${contractName}Impl`]) { | ||
throw new Error(contractName + " not deployed yet!"); | ||
} | ||
} | ||
|
||
const PoolFactory = await hre.ethers.getContractFactory("PoolFactory", { | ||
libraries: { LibTimelockController: deployedContracts["LibTimelockController"] }, | ||
}); | ||
const poolFactory = PoolFactory.attach(deployedContracts["PoolFactory"]); | ||
|
||
await sendTransaction("PoolFactory", poolFactory, "addDeployer", [deployer.address]); | ||
await sendTransaction("PoolFactory", poolFactory, "setCalendarAddress", [ | ||
deployedContracts["Calendar"], | ||
]); | ||
for (contractName of contracts) { | ||
await sendTransaction("PoolFactory", poolFactory, `set${contractName}ImplAddress`, [ | ||
deployedContracts[`${contractName}Impl`], | ||
]); | ||
} | ||
|
||
// await transferOwnershipToTL("HumaConfig", "HumaConfig", "HumaConfigTimelock") | ||
|
||
await updateInitializedContract("PoolFactory", networkName); | ||
} | ||
|
||
async function initContracts() { | ||
// const networkName = (await hre.ethers.provider.getNetworkName()).name; | ||
networkName = network.name; | ||
console.log("networkName : ", networkName); | ||
const accounts = await hre.ethers.getSigners(); | ||
[deployer] = await accounts; | ||
console.log("deployer address: " + deployer.address); | ||
// console.log("ea address: " + eaService.address); | ||
|
||
deployedContracts = await getDeployedContracts(networkName); | ||
console.log(deployedContracts); | ||
await initHumaConfig(); | ||
await initPoolFactory(); | ||
} | ||
|
||
initContracts() | ||
.then(() => process.exit(0)) | ||
.catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters