Skip to content

Commit

Permalink
chore: deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
alpanaca committed Mar 1, 2024
1 parent c1b2f9a commit deaa6e8
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"doubleSlope2": "0x89c53B34b5E6A1D0b2922941749e9Ee05ce58b42",
"doubleSlope3": "0x4132392C57B9D2DE1BA393A03f23Fcb880Bf8EE1",
"flatSlope1": "0x67e5308813382E4dd06246d3c72035209f6Bae3C",
"flatSlope2": "0x434B4fe3562fdcF4687b6c258eEc4e564Bc0A263"
"flatSlope2": "0x434B4fe3562fdcF4687b6c258eEc4e564Bc0A263",
"flatSlope3": ""
},
"sharedStrategies": {
"pancakeswap": {
Expand Down Expand Up @@ -396,4 +397,4 @@
"uniswapV2LikePathReader": ""
},
"swapHelper": ""
}
}
44 changes: 44 additions & 0 deletions deploy/config/set-non-collat-interest-model.ts
Original file line number Diff line number Diff line change
@@ -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"];
19 changes: 19 additions & 0 deletions deploy/core/interest-model/flat-slope.ts
Original file line number Diff line number Diff line change
@@ -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"];
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions script/BaseScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit deaa6e8

Please sign in to comment.