diff --git a/.mainnet.json b/.mainnet.json index a99f68b4..8d1c66b9 100644 --- a/.mainnet.json +++ b/.mainnet.json @@ -38,7 +38,8 @@ "doubleSlope2": "0x89c53B34b5E6A1D0b2922941749e9Ee05ce58b42", "doubleSlope3": "0x4132392C57B9D2DE1BA393A03f23Fcb880Bf8EE1", "flatSlope1": "0x67e5308813382E4dd06246d3c72035209f6Bae3C", - "flatSlope2": "0x434B4fe3562fdcF4687b6c258eEc4e564Bc0A263" + "flatSlope2": "0x434B4fe3562fdcF4687b6c258eEc4e564Bc0A263", + "flatSlope3": "" }, "sharedStrategies": { "pancakeswap": { @@ -396,4 +397,4 @@ "uniswapV2LikePathReader": "" }, "swapHelper": "" -} \ No newline at end of file +} diff --git a/deploy/config/set-non-collat-interest-model.ts b/deploy/config/set-non-collat-interest-model.ts new file mode 100644 index 00000000..a09d5b0f --- /dev/null +++ b/deploy/config/set-non-collat-interest-model.ts @@ -0,0 +1,44 @@ +import { DeployFunction } from "hardhat-deploy/types"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { ConfigFileHelper } from "../file-helper.ts/config-file.helper"; +import { getDeployer } from "../utils/deployer-helper"; +import { IMoneyMarket__factory } from "../../typechain"; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const configFileHelper = new ConfigFileHelper(); + const config = configFileHelper.getConfig(); + + /* + ░██╗░░░░░░░██╗░█████╗░██████╗░███╗░░██╗██╗███╗░░██╗░██████╗░ + ░██║░░██╗░░██║██╔══██╗██╔══██╗████╗░██║██║████╗░██║██╔════╝░ + ░╚██╗████╗██╔╝███████║██████╔╝██╔██╗██║██║██╔██╗██║██║░░██╗░ + ░░████╔═████║░██╔══██║██╔══██╗██║╚████║██║██║╚████║██║░░╚██╗ + ░░╚██╔╝░╚██╔╝░██║░░██║██║░░██║██║░╚███║██║██║░╚███║╚██████╔╝ + ░░░╚═╝░░░╚═╝░░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═╝╚═╝░░╚══╝░╚═════╝░ + Check all variables below before execute the deployment script +*/ + + const INPUTS = [ + { + account: "0xD0dfE9277B1DB02187557eAeD7e25F74eF2DE8f3", + token: "", + model: "", + }, + ]; + + const deployer = await getDeployer(); + let nonce = await deployer.getTransactionCount(); + + for (const input of INPUTS) { + console.log(`>>> 🔧 Setting Interest Model ${input.model} for: ${input.token}`); + const moneyMarket = IMoneyMarket__factory.connect(config.moneyMarket.moneyMarketDiamond, deployer); + const tx = await moneyMarket.setNonCollatInterestModel(input.account, input.token, input.model, { nonce: nonce++ }); + await tx.wait(); + console.log(`> 🟢 Done | Tx hash: ${tx.hash}\n`); + } + + console.log("\n✅ All Done"); +}; + +export default func; +func.tags = ["SetNonCollatInterestModel"]; diff --git a/deploy/core/interest-model/flat-slope.ts b/deploy/core/interest-model/flat-slope.ts new file mode 100644 index 00000000..1a984b50 --- /dev/null +++ b/deploy/core/interest-model/flat-slope.ts @@ -0,0 +1,19 @@ +import { ethers } from "hardhat"; +import { DeployFunction } from "hardhat-deploy/types"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { getDeployer } from "../../utils/deployer-helper"; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const SLOPE_MODEL = "MMFlatSlopeModel3"; + + const deployer = await getDeployer(); + const InterestModel = await ethers.getContractFactory(SLOPE_MODEL, deployer); + + console.log(`Deploying Interest Model Contract`); + const model = await InterestModel.deploy(); + await model.deployed(); + console.log(`Deployed at: ${model.address}`); +}; + +export default func; +func.tags = ["FlatSlopeModelDeploy"]; diff --git a/package.json b/package.json index 880e33b8..5b309635 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "exec:bsc_mainnet:debt-token:deploy": "forge script script/deployments/DebtToken/deploy/DebtTokenImplementation.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:deploy": "forge script script/deployments/MoneyMarket/deploy/MoneyMarket.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:cut:flash-loan-facet": "forge script script/deployments/MoneyMarket/diamond-cut/FlashloanFacetCut.s.sol --rpc-url bsc_mainnet --broadcast --slow", - "exec:bsc_mainnet:money-market:config:set-interest-model": "forge script script/deployments/MoneyMarket/config/SetInterestModel.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:config:set-fees": "forge script script/deployments/MoneyMarket/config/SetFees.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:config:set-max-num-token": "forge script script/deployments/MoneyMarket/config/SetMaxNumOfToken.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:config:set-min-debt-size": "forge script script/deployments/MoneyMarket/config/SetMinDebtSize.s.sol --rpc-url bsc_mainnet --broadcast --slow", @@ -40,7 +39,6 @@ "exec:bsc_mainnet:money-market:config:withdraw-protocol-reserves": "forge script script/deployments/MoneyMarket/config/WithdrawProtocolReserves.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:config:set-flash-loan-params": "forge script script/deployments/MoneyMarket/config/SetFlashloanParams.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:config:set-non-collat-borrower-ok": "forge script script/deployments/MoneyMarket/config/SetNonCollatBorrowerOk.s.sol --rpc-url bsc_mainnet --broadcast --slow", - "exec:bsc_mainnet:money-market:config:set-non-collat-interest-model": "forge script script/deployments/MoneyMarket/config/SetNonCollatInterestModel.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:config:set-protocol-configs": "forge script script/deployments/MoneyMarket/config/SetProtocolConfigs.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:admin-facet:deploy": "forge script script/deployments/MoneyMarket/deploy/AdminFacet.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:money-market:flash-loan-facet:deploy": "forge script script/deployments/MoneyMarket/deploy/FlashloanFacet.s.sol --rpc-url bsc_mainnet --broadcast --slow", @@ -68,6 +66,7 @@ "exec:bsc_mainnet:double-slope-model3:deploy": "forge script script/deployments/InterestModels/deploy/MMDoubleSlopeModel3.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:flat-slope-model1:deploy": "forge script script/deployments/InterestModels/deploy/MMFlatSlopeModel1.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:flat-slope-model2:deploy": "forge script script/deployments/InterestModels/deploy/MMFlatSlopeModel2.s.sol --rpc-url bsc_mainnet --broadcast --slow", + "exec:bsc_mainnet:flat-slope-model3:deploy": "forge script script/deployments/InterestModels/deploy/MMFlatSlopeModel3.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:rewarder:deploy": "forge script script/deployments/Rewarder/deploy/Rewarder.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:rewarder:config:add-pool": "forge script script/deployments/Rewarder/config/AddPool.s.sol --rpc-url bsc_mainnet --broadcast --slow", "exec:bsc_mainnet:rewarder:config:set-pool": "forge script script/deployments/Rewarder/config/SetPool.s.sol --rpc-url bsc_mainnet --broadcast --slow", @@ -91,11 +90,13 @@ "exec:bsc_mainnet:money-market:lend-facet:deploy": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags LendFacetDeploy", "exec:bsc_mainnet:money-market:borrow-facet:deploy": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags BorrowFacetDeploy", "exec:bsc_mainnet:money-market:liquidation-facet:deploy": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags LiquidationFacetDeploy", + "exec:bsc_mainnet:money-market:interest-model:deploy": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags FlatSlopeModelDeploy", "exec:bsc_mainnet:money-market:diamond-cut": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags ExecuteDiamondCut", "exec:bsc_mainnet:money-market:upgrade:account-manager": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags UpgradeMoneyMarketAccountManager", "exec:bsc_mainnet:money-market:config:set-token-max-capacity": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags SetTokenMaxCapacity", "exec:bsc_mainnet:money-market:config:set-token-config": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags SetTokenConfig", "exec:bsc_mainnet:config:transfer-ownership": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags TransferOwnership", + "exec:bsc_mainnet:money-market:config:set-non-collat-interest-model": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags SetNonCollatInterestModel", "exec:bsc_mainnet:config:accept-ownership": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags AcceptOwnership", "exec:bsc_mainnet:money-market:config:open-market": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags OpenMarket", "exec:bsc_mainnet:chainlink-price-oracle:config:set-price-feeds": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags SetPriceFeed", diff --git a/script/BaseScript.sol b/script/BaseScript.sol index 5987ae20..d29783e7 100644 --- a/script/BaseScript.sol +++ b/script/BaseScript.sol @@ -69,6 +69,7 @@ abstract contract BaseScript is Script { address internal doubleSlope3; address internal flatSlope1; address internal flatSlope2; + address internal flatSlope3; // path reader address internal uniswapV2LikePathReader; @@ -122,6 +123,7 @@ abstract contract BaseScript is Script { doubleSlope3 = abi.decode(configJson.parseRaw(".sharedConfig.doubleSlope3"), (address)); flatSlope1 = abi.decode(configJson.parseRaw(".sharedConfig.flatSlope1"), (address)); flatSlope2 = abi.decode(configJson.parseRaw(".sharedConfig.flatSlope2"), (address)); + flatSlope3 = abi.decode(configJson.parseRaw(".sharedConfig.flatSlope3"), (address)); // path reader uniswapV2LikePathReader = abi.decode(configJson.parseRaw(".pathReader.uniswapV2LikePathReader"), (address));