Skip to content

Commit

Permalink
chore: set token config script
Browse files Browse the repository at this point in the history
  • Loading branch information
jr-alpaca committed Dec 4, 2023
1 parent ced0ad1 commit f63f115
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
68 changes: 68 additions & 0 deletions deploy/exec/money-market/config/set-token-config.ts
Original file line number Diff line number Diff line change
@@ -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"];
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f63f115

Please sign in to comment.