diff --git a/deploy/exec/money-market/config/set-token-config.ts b/deploy/exec/money-market/config/set-token-config.ts new file mode 100644 index 00000000..0dae08d1 --- /dev/null +++ b/deploy/exec/money-market/config/set-token-config.ts @@ -0,0 +1,68 @@ +import { BigNumber } from "ethers"; +import { DeployFunction } from "hardhat-deploy/types"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { IMoneyMarket__factory } from "../../../../typechain"; +import { ConfigFileHelper } from "../../../file-helper.ts/config-file.helper"; +import { getDeployer } from "../../../utils/deployer-helper"; + +type SetTokenConfigInput = { + token: string; + tier?: BigNumber; + collateralFactor?: string; + borrowingFactor?: string; + maxCollateral?: BigNumber; + maxBorrow?: BigNumber; +}; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const configFileHelper = new ConfigFileHelper(); + const config = configFileHelper.getConfig(); + const deployer = await getDeployer(); + const moneyMarket = IMoneyMarket__factory.connect(config.moneyMarket.moneyMarketDiamond, deployer); + /* + ░██╗░░░░░░░██╗░█████╗░██████╗░███╗░░██╗██╗███╗░░██╗░██████╗░ + ░██║░░██╗░░██║██╔══██╗██╔══██╗████╗░██║██║████╗░██║██╔════╝░ + ░╚██╗████╗██╔╝███████║██████╔╝██╔██╗██║██║██╔██╗██║██║░░██╗░ + ░░████╔═████║░██╔══██║██╔══██╗██║╚████║██║██║╚████║██║░░╚██╗ + ░░╚██╔╝░╚██╔╝░██║░░██║██║░░██║██║░╚███║██║██║░╚███║╚██████╔╝ + ░░░╚═╝░░░╚═╝░░╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚══╝╚═╝╚═╝░░╚══╝░╚═════╝░ + Check all variables below before execute the deployment script + */ + + const TOKEN_CONFIG_INPUTS: SetTokenConfigInput[] = [ + // BUSD + { + token: "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56", + borrowingFactor: "9000", + }, + // ibBUSD + { + token: "0x3f38BA29AcC107E6F0b059a17c9bAb0598d0f249", + collateralFactor: "8500", + }, + ]; + + const tokens = TOKEN_CONFIG_INPUTS.map((config) => config.token); + const infos = await Promise.all( + TOKEN_CONFIG_INPUTS.map(async (input) => { + const TOKEN_CONFIG = await moneyMarket.getTokenConfig(input.token); + + return { + tier: input.tier || TOKEN_CONFIG.tier, + collateralFactor: input.collateralFactor || TOKEN_CONFIG.collateralFactor, + borrowingFactor: input.borrowingFactor || TOKEN_CONFIG.borrowingFactor, + maxCollateral: input.maxCollateral || TOKEN_CONFIG.maxCollateral, + maxBorrow: input.maxBorrow || TOKEN_CONFIG.maxBorrow, + }; + }) + ); + + const setTokenConfigTx = await moneyMarket.setTokenConfigs(tokens, infos); + + const setTokenConfigReceipt = await setTokenConfigTx.wait(); + + console.log(`✅ Done TokenConfig done at TX: ${setTokenConfigReceipt.transactionHash}`); +}; + +export default func; +func.tags = ["SetTokenConfig"]; diff --git a/package.json b/package.json index 7eda5ef4..42b79da1 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "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: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",