Skip to content

Commit

Permalink
Merge pull request #380 from VenusProtocol/chore/ven-2529
Browse files Browse the repository at this point in the history
[VEN-2529]: IRM for some assets of opbnb and ethereum. 2/3
  • Loading branch information
0xlucian authored Apr 19, 2024
2 parents 9841da2 + 158550f commit 92cd1ca
Show file tree
Hide file tree
Showing 15 changed files with 4,524 additions and 19 deletions.
69 changes: 69 additions & 0 deletions deploy/019-deploy-ir-models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { BigNumber, BigNumberish } from "ethers";
import { parseUnits } from "ethers/lib/utils";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { blocksPerYear, getConfig } from "../helpers/deploymentConfig";
import { InterestRateModels } from "../helpers/deploymentConfig";
import { toAddress } from "../helpers/deploymentUtils";

const mantissaToBps = (num: BigNumberish) => {
return BigNumber.from(num).div(parseUnits("1", 14)).toString();
};

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const { poolConfig, preconfiguredAddresses } = await getConfig(hre.network.name);

const accessControlManagerAddress = await toAddress(
preconfiguredAddresses.AccessControlManager || "AccessControlManager",
hre,
);

for (const pool of poolConfig) {
// Deploy IR Models
for (const vtoken of pool.vtokens) {
const { rateModel, baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_ } = vtoken;

const BLOCKS_PER_YEAR: number = blocksPerYear[hre.network.name];
if (rateModel === InterestRateModels.JumpRate.toString()) {
const [b, m, j, k] = [baseRatePerYear, multiplierPerYear, jumpMultiplierPerYear, kink_].map(mantissaToBps);
const rateModelName = `JumpRateModelV2_base${b}bps_slope${m}bps_jump${j}bps_kink${k}bps`;
console.log(`Deploying interest rate model ${rateModelName}`);
await deploy(rateModelName, {
from: deployer,
contract: "JumpRateModelV2",
args: [
BLOCKS_PER_YEAR,
baseRatePerYear,
multiplierPerYear,
jumpMultiplierPerYear,
kink_,
accessControlManagerAddress,
],
log: true,
autoMine: true,
});
} else {
const [b, m] = [baseRatePerYear, multiplierPerYear].map(mantissaToBps);
const rateModelName = `WhitePaperInterestRateModel_base${b}bps_slope${m}bps`;
console.log(`Deploying interest rate model ${rateModelName}`);
await deploy(rateModelName, {
from: deployer,
contract: "WhitePaperInterestRateModel",
args: [BLOCKS_PER_YEAR, baseRatePerYear, multiplierPerYear],
log: true,
autoMine: true,
});
}
console.log(`-----------------------------------------`);
}
}
};

func.tags = ["IR"];
func.skip = async (hre: HardhatRuntimeEnvironment) => !hre.network.live;

export default func;
Loading

0 comments on commit 92cd1ca

Please sign in to comment.