Skip to content

Commit

Permalink
Merge pull request #104 from term-finance/deploy-strategy-collateral-set
Browse files Browse the repository at this point in the history
set collateral min ratios in deploy strategy
  • Loading branch information
aazhou1 authored Nov 20, 2024
2 parents 6908e24 + c3dfeb9 commit 6aec50f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/deploy-sepolia-strategy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ on:
description: 'Required reserve ratio'
required: false
default: '0.01'
collateralTokens:
description: 'Collateral tokens comma separated'
required: false
default: '0x'
minCollateralRatios:
description: 'Minimum collateral ratio comma separated'
required: false
default: '0.01'

jobs:
deploy:
Expand Down Expand Up @@ -66,4 +74,6 @@ jobs:
GOVERNOR_ROLE_ADDRESS: ${{ vars.GOVERNANCE_FACTORY }}
STRATEGY_MANAGEMENT_ADDRESS: ${{ github.event.inputs.strategyManagementAddress }}
NEW_REQUIRED_RESERVE_RATIO: ${{ github.event.inputs.requiredReserveRatio }}
COLLATERAL_TOKENS: ${{ github.event.inputs.collateralTokens }}
MIN_COLLATERAL_RATIOS: ${{ github.event.inputs.minCollateralRatios }}

23 changes: 18 additions & 5 deletions script/Strategy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ contract DeployStrategy is Script {

function run() external {
uint256 deployerPK = vm.envUint("PRIVATE_KEY");
uint256 governorDeployerPK = vm.envUint("GOVERNOR_DEPLOYER_KEY");

// Set up the RPC URL (optional if you're using the default foundry config)
string memory rpcUrl = vm.envString("RPC_URL");
Expand All @@ -138,25 +137,40 @@ contract DeployStrategy is Script {
// Retrieve environment variables
string memory name = vm.envString("STRATEGY_NAME");
address strategyManagement = vm.envAddress("STRATEGY_MANAGEMENT_ADDRESS");
address[] memory collateralTokens = stringToAddressArray(vm.envString("COLLATERAL_TOKEN_ADDRESSES"));
uint256[] memory minCollateralRatios = stringToUintArray(vm.envString("MIN_COLLATERAL_RATIO"));
address governorRoleAddress = vm.envAddress("GOVERNOR_ROLE_ADDRESS");

bool isTest = vm.envBool("IS_TEST");


TermVaultEventEmitter eventEmitter = _deployEventEmitter();

Strategy.StrategyParams memory params = buildStrategyParams(address(eventEmitter));
address deployer = vm.addr(deployerPK);

Strategy.StrategyParams memory params = buildStrategyParams(address(eventEmitter), deployer);

Strategy strategy = new Strategy(
name,
params
);

for (uint256 i = 0; i < collateralTokens.length; i++) {
strategy.setCollateralTokenParams(collateralTokens[i], minCollateralRatios[i]);
}


console.log("deployed strategy contract to");
console.log(address(strategy));

ITokenizedStrategy(address(strategy)).setPendingManagement(strategyManagement);
console.log("set pending management");
console.log(strategyManagement);

strategy.setPendingGovernor(governorRoleAddress);
console.log("set pending governor");
console.log(governorRoleAddress);

if (isTest) {
eventEmitter.pairVaultContract(address(strategy));
console.log("paired strategy contract with event emitter");
Expand All @@ -165,13 +179,12 @@ contract DeployStrategy is Script {
vm.stopBroadcast();
}

function buildStrategyParams(address eventEmitter) internal returns(Strategy.StrategyParams memory) {
function buildStrategyParams(address eventEmitter, address deployer) internal returns(Strategy.StrategyParams memory) {
address asset = vm.envAddress("ASSET_ADDRESS");
address yearnVaultAddress = vm.envAddress("YEARN_VAULT_ADDRESS");
address discountRateAdapterAddress = vm.envAddress("DISCOUNT_RATE_ADAPTER_ADDRESS");
address termController = vm.envAddress("TERM_CONTROLLER_ADDRESS");
uint256 discountRateMarkup = vm.envUint("DISCOUNT_RATE_MARKUP");
address governorRoleAddress = vm.envAddress("GOVERNOR_ROLE_ADDRESS");
uint256 timeToMaturityThreshold = vm.envUint("TIME_TO_MATURITY_THRESHOLD");
uint256 repoTokenConcentrationLimit = vm.envUint("REPOTOKEN_CONCENTRATION_LIMIT");
uint256 newRequiredReserveRatio = vm.envUint("NEW_REQUIRED_RESERVE_RATIO");
Expand All @@ -183,7 +196,7 @@ contract DeployStrategy is Script {
yearnVaultAddress,
discountRateAdapterAddress,
address(eventEmitter),
governorRoleAddress,
deployer,
termController,
repoTokenConcentrationLimit,
timeToMaturityThreshold,
Expand Down

0 comments on commit 6aec50f

Please sign in to comment.