-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from VenusProtocol/feat/deploy-funds
[VEN-1736] Deploy ProtocolShareReserve, RiskFund, Shortfall
- Loading branch information
Showing
30 changed files
with
42,467 additions
and
11,405 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import deploySwapRouter from "@venusprotocol/venus-protocol/deploy/005-deploy-swaprouter"; | ||
import deploySwapRouter from "@venusprotocol/venus-protocol/dist/deploy/006-deploy-swaprouter"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
|
||
deploySwapRouter.tags = ["SwapRouter", "il"]; | ||
deploySwapRouter.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.live; | ||
|
||
export default deploySwapRouter; |
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,51 @@ | ||
import { ethers } from "hardhat"; | ||
import { DeployFunction } from "hardhat-deploy/types"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
|
||
import { PoolRegistry, VToken } from "../typechain"; | ||
|
||
const getAllMarkets = async (poolRegistry: PoolRegistry): Promise<VToken[]> => { | ||
const pools = await poolRegistry.getAllPools(); | ||
const markets = await Promise.all( | ||
pools.map(async ({ comptroller }: { comptroller: string }): Promise<VToken[]> => { | ||
const poolComptroller = await ethers.getContractAt("Comptroller", comptroller); | ||
const vTokenAddresses = await poolComptroller.getAllMarkets(); | ||
const vTokens = await Promise.all( | ||
vTokenAddresses.map((vTokenAddress: string) => ethers.getContractAt("VToken", vTokenAddress)), | ||
); | ||
return vTokens; | ||
}), | ||
); | ||
return markets.flat(); | ||
}; | ||
|
||
const setShortfallAddress = async (vToken: VToken, shortfallAddress: string) => { | ||
if ((await vToken.shortfall()) !== shortfallAddress) { | ||
const tx = await vToken.setShortfallContract(shortfallAddress); | ||
await tx.wait(); | ||
} | ||
}; | ||
|
||
const setProtocolShareReserveAddress = async (vToken: VToken, protocolShareReserveAddress: string) => { | ||
if ((await vToken.protocolShareReserve()) !== protocolShareReserveAddress) { | ||
const tx = await vToken.setProtocolShareReserve(protocolShareReserveAddress); | ||
await tx.wait(); | ||
} | ||
}; | ||
|
||
const func: DeployFunction = async function (_: HardhatRuntimeEnvironment) { | ||
const poolRegistry = await ethers.getContract<PoolRegistry>("PoolRegistry"); | ||
const vTokens = await getAllMarkets(poolRegistry); | ||
const protocolShareReserve = await ethers.getContract("ProtocolShareReserve"); | ||
const shortfall = await ethers.getContract("Shortfall"); | ||
|
||
for (const vToken of vTokens) { | ||
await setShortfallAddress(vToken, shortfall.address); | ||
await setProtocolShareReserveAddress(vToken, protocolShareReserve.address); | ||
} | ||
}; | ||
|
||
func.tags = ["FundsConfig", "il"]; | ||
func.skip = async (hre: HardhatRuntimeEnvironment) => hre.network.live; | ||
|
||
export default func; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.