From b197323f2de364e0d4772914821ec8c2d512986d Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Fri, 8 Mar 2024 01:21:19 -0500 Subject: [PATCH 1/6] IGP9 Proposal --- contracts/payloads/IGP9/PayloadIGP9.sol | 320 ++++++++++++++++++++++++ 1 file changed, 320 insertions(+) create mode 100644 contracts/payloads/IGP9/PayloadIGP9.sol diff --git a/contracts/payloads/IGP9/PayloadIGP9.sol b/contracts/payloads/IGP9/PayloadIGP9.sol new file mode 100644 index 0000000..9d22dce --- /dev/null +++ b/contracts/payloads/IGP9/PayloadIGP9.sol @@ -0,0 +1,320 @@ +pragma solidity ^0.7.0; +pragma experimental ABIEncoderV2; + +interface IGovernorBravo { + function _acceptAdmin() external; + + function _setVotingDelay(uint newVotingDelay) external; + + function _setVotingPeriod(uint newVotingPeriod) external; + + function _acceptAdminOnTimelock() external; + + function _setImplementation(address implementation_) external; + + function propose( + address[] memory targets, + uint[] memory values, + string[] memory signatures, + bytes[] memory calldatas, + string memory description + ) external returns (uint); + + function admin() external view returns (address); + + function pendingAdmin() external view returns (address); + + function timelock() external view returns (address); + + function votingDelay() external view returns (uint256); + + function votingPeriod() external view returns (uint256); +} + +interface ITimelock { + function acceptAdmin() external; + + function setDelay(uint delay_) external; + + function setPendingAdmin(address pendingAdmin_) external; + + function queueTransaction( + address target, + uint value, + string memory signature, + bytes memory data, + uint eta + ) external returns (bytes32); + + function executeTransaction( + address target, + uint value, + string memory signature, + bytes memory data, + uint eta + ) external payable returns (bytes memory); + + function pendingAdmin() external view returns (address); + + function admin() external view returns (address); + + function delay() external view returns (uint256); +} + +interface IInstaIndex { + function changeMaster(address _newMaster) external; + function updateMaster() external; + function master() external view returns (address); +} + +interface AdminModuleStructs { + struct AddressBool { + address addr; + bool value; + } + + struct AddressUint256 { + address addr; + uint256 value; + } + + struct RateDataV1Params { + address token; + uint256 kink; + uint256 rateAtUtilizationZero; + uint256 rateAtUtilizationKink; + uint256 rateAtUtilizationMax; + } + + struct RateDataV2Params { + address token; + uint256 kink1; + uint256 kink2; + uint256 rateAtUtilizationZero; + uint256 rateAtUtilizationKink1; + uint256 rateAtUtilizationKink2; + uint256 rateAtUtilizationMax; + } + + struct TokenConfig { + address token; + uint256 fee; + uint256 threshold; + } + + struct UserSupplyConfig { + address user; + address token; + uint8 mode; + uint256 expandPercent; + uint256 expandDuration; + uint256 baseWithdrawalLimit; + } + + struct UserBorrowConfig { + address user; + address token; + uint8 mode; + uint256 expandPercent; + uint256 expandDuration; + uint256 baseDebtCeiling; + uint256 maxDebtCeiling; + } +} + +interface IFluidLiquidityAdmin { + /// @notice adds/removes auths. Auths generally could be contracts which can have restricted actions defined on contract. + /// auths can be helpful in reducing governance overhead where it's not needed. + /// @param authsStatus_ array of structs setting allowed status for an address. + /// status true => add auth, false => remove auth + function updateAuths(AdminModuleStructs.AddressBool[] calldata authsStatus_) external; + + /// @notice adds/removes guardians. Only callable by Governance. + /// @param guardiansStatus_ array of structs setting allowed status for an address. + /// status true => add guardian, false => remove guardian + function updateGuardians(AdminModuleStructs.AddressBool[] calldata guardiansStatus_) external; + + /// @notice changes the revenue collector address (contract that is sent revenue). Only callable by Governance. + /// @param revenueCollector_ new revenue collector address + function updateRevenueCollector(address revenueCollector_) external; + + /// @notice changes current status, e.g. for pausing or unpausing all user operations. Only callable by Auths. + /// @param newStatus_ new status + /// status = 2 -> pause, status = 1 -> resume. + function changeStatus(uint256 newStatus_) external; + + /// @notice update tokens rate data version 1. Only callable by Auths. + /// @param tokensRateData_ array of RateDataV1Params with rate data to set for each token + function updateRateDataV1s(AdminModuleStructs.RateDataV1Params[] calldata tokensRateData_) external; + + /// @notice update tokens rate data version 2. Only callable by Auths. + /// @param tokensRateData_ array of RateDataV2Params with rate data to set for each token + function updateRateDataV2s(AdminModuleStructs.RateDataV2Params[] calldata tokensRateData_) external; + + /// @notice updates token configs: fee charge on borrowers interest & storage update utilization threshold. + /// Only callable by Auths. + /// @param tokenConfigs_ contains token address, fee & utilization threshold + function updateTokenConfigs(AdminModuleStructs.TokenConfig[] calldata tokenConfigs_) external; + + /// @notice updates user classes: 0 is for new protocols, 1 is for established protocols. + /// Only callable by Auths. + /// @param userClasses_ struct array of uint256 value to assign for each user address + function updateUserClasses(AdminModuleStructs.AddressUint256[] calldata userClasses_) external; + + /// @notice sets user supply configs per token basis. Eg: with interest or interest-free and automated limits. + /// Only callable by Auths. + /// @param userSupplyConfigs_ struct array containing user supply config, see `UserSupplyConfig` struct for more info + function updateUserSupplyConfigs(AdminModuleStructs.UserSupplyConfig[] memory userSupplyConfigs_) external; + + /// @notice setting user borrow configs per token basis. Eg: with interest or interest-free and automated limits. + /// Only callable by Auths. + /// @param userBorrowConfigs_ struct array containing user borrow config, see `UserBorrowConfig` struct for more info + function updateUserBorrowConfigs(AdminModuleStructs.UserBorrowConfig[] memory userBorrowConfigs_) external; + + /// @notice pause operations for a particular user in class 0 (class 1 users can't be paused by guardians). + /// Only callable by Guardians. + /// @param user_ address of user to pause operations for + /// @param supplyTokens_ token addresses to pause withdrawals for + /// @param borrowTokens_ token addresses to pause borrowings for + function pauseUser(address user_, address[] calldata supplyTokens_, address[] calldata borrowTokens_) external; + + /// @notice unpause operations for a particular user in class 0 (class 1 users can't be paused by guardians). + /// Only callable by Guardians. + /// @param user_ address of user to unpause operations for + /// @param supplyTokens_ token addresses to unpause withdrawals for + /// @param borrowTokens_ token addresses to unpause borrowings for + function unpauseUser(address user_, address[] calldata supplyTokens_, address[] calldata borrowTokens_) external; + + /// @notice collects revenue for tokens to configured revenueCollector address. + /// @param tokens_ array of tokens to collect revenue for + /// @dev Note that this can revert if token balance is < revenueAmount (utilization > 100%) + function collectRevenue(address[] calldata tokens_) external; + + /// @notice gets the current updated exchange prices for n tokens and updates all prices, rates related data in storage. + /// @param tokens_ tokens to update exchange prices for + /// @return supplyExchangePrices_ new supply rates of overall system for each token + /// @return borrowExchangePrices_ new borrow rates of overall system for each token + function updateExchangePrices( + address[] calldata tokens_ + ) external returns (uint256[] memory supplyExchangePrices_, uint256[] memory borrowExchangePrices_); +} + +interface IstETHProtocol { + /// @notice initializes the contract with `owner_` as owner + function initialize(address owner_) external; + + /// @notice Sets an address as allowed user or not. Only callable by auths. + /// @param user_ address to set allowed value for + /// @param allowed_ bool flag for whether address is allowed as user or not + function setUserAllowed(address user_, bool allowed_) external; + + /// @notice Sets `maxLTV` to `maxLTV_` (in 1e2: 1% = 100, 100% = 10000). Must be > 0 and < 100%. + function setMaxLTV(uint16 maxLTV_) external; +} + +contract PayloadIGP9 { + uint256 public constant PROPOSAL_ID = 9; + + address public constant PROPOSER = + 0xA45f7bD6A5Ff45D31aaCE6bCD3d426D9328cea01; + + IGovernorBravo public constant GOVERNOR = + IGovernorBravo(0x0204Cd037B2ec03605CFdFe482D8e257C765fA1B); + ITimelock public immutable TIMELOCK = + ITimelock(0x2386DC45AdDed673317eF068992F19421B481F4c); + + address public immutable ADDRESS_THIS; + + address public constant LITE = + 0xA0D3707c569ff8C87FA923d3823eC5D81c98Be78; + address public constant LITE_DSA = + 0x9600A48ed0f931d0c422D574e3275a90D8b22745; + + + IstETHProtocol public constant STETH_PROTOCOL = IstETHProtocol(0x1F6B2bFDd5D1e6AdE7B17027ff5300419a56Ad6b); + IFluidLiquidityAdmin public constant LIQUIDITY = IFluidLiquidityAdmin(address(0)); // TODO + + address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; + + constructor() { + ADDRESS_THIS = address(this); + } + + function propose(string memory description) external { + require(msg.sender == PROPOSER, "msg.sender-not-proposer"); + + uint256 totalActions = 1; + address[] memory targets = new address[](totalActions); + uint256[] memory values = new uint256[](totalActions); + string[] memory signatures = new string[](totalActions); + bytes[] memory calldatas = new bytes[](totalActions); + + // Action 1: call executePayload on timelock contract to execute payload related to Fluid + targets[0] = address(TIMELOCK); + values[0] = 0; + signatures[0] = "executePayload(address,string,bytes)"; + calldatas[0] = abi.encode(ADDRESS_THIS, "execute()", abi.encode()); + + uint256 proposedId = GOVERNOR.propose( + targets, + values, + signatures, + calldatas, + description + ); + + require(proposedId == PROPOSAL_ID, "PROPOSAL_IS_NOT_SAME"); + } + + function execute() external { + // Action 1: remove Implementations + action1(); + + // Action 2: add implementations + action2(); + + // Action 3: set dummy implementations + action3(); + + // Action 4: Change ratios + action4(); + } + + function verifyProposal() external view {} + + /***********************************| + | Proposal Payload Actions | + |__________________________________*/ + + /// @notice Action 1: list stETH Protocol in Liquidity Layer with max debt ceiling of 5k ETH and base debt ceiling of 5k ETH + function action1() internal { + AdminModuleStructs.UserBorrowConfig[] memory configs_ = new AdminModuleStructs.UserBorrowConfig[](1); + + configs_[0] = AdminModuleStructs.UserBorrowConfig({ + user: address(STETH_PROTOCOL), + token: ETH_ADDRESS, + mode: 1, + expandPercent: 0, + expandDuration: 0, + baseDebtCeiling: 5000 * 1e18, + maxDebtCeiling: 5000 * 1e18 + }); + + LIQUIDITY.updateUserBorrowConfigs(configs_); + } + + /// @notice Action 2: initialize owner on stETH protocol as governance address + function action2() internal { + STETH_PROTOCOL.initialize(address(TIMELOCK)); + } + + /// @notice Action 3: Set Max LTV as 93%. + function action3() internal { + STETH_PROTOCOL.setMaxLTV(9300); + } + + /// @notice Action 4: Allow Lite DSA as user on stETH Protocol + function action4() internal { + STETH_PROTOCOL.setUserAllowed(LITE_DSA, true); + } +} From b249d2d9d0dc0ca5d9c5dee04aae70be1641ab23 Mon Sep 17 00:00:00 2001 From: Samyak Jain <34437877+KaymasJain@users.noreply.github.com> Date: Fri, 8 Mar 2024 15:07:24 +0400 Subject: [PATCH 2/6] Update contracts/payloads/IGP9/PayloadIGP9.sol --- contracts/payloads/IGP9/PayloadIGP9.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/payloads/IGP9/PayloadIGP9.sol b/contracts/payloads/IGP9/PayloadIGP9.sol index 9d22dce..3138372 100644 --- a/contracts/payloads/IGP9/PayloadIGP9.sol +++ b/contracts/payloads/IGP9/PayloadIGP9.sol @@ -295,7 +295,7 @@ contract PayloadIGP9 { token: ETH_ADDRESS, mode: 1, expandPercent: 0, - expandDuration: 0, + expandDuration: 1, baseDebtCeiling: 5000 * 1e18, maxDebtCeiling: 5000 * 1e18 }); From 2c684c10a164a60fdaf222996f624a89d89eb21a Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Fri, 8 Mar 2024 17:48:47 -0500 Subject: [PATCH 3/6] wip --- contracts/payloads/IGP9/PayloadIGP9.sol | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/contracts/payloads/IGP9/PayloadIGP9.sol b/contracts/payloads/IGP9/PayloadIGP9.sol index 3138372..ac03b1a 100644 --- a/contracts/payloads/IGP9/PayloadIGP9.sol +++ b/contracts/payloads/IGP9/PayloadIGP9.sol @@ -210,6 +210,11 @@ interface IstETHProtocol { /// @notice Sets `maxLTV` to `maxLTV_` (in 1e2: 1% = 100, 100% = 10000). Must be > 0 and < 100%. function setMaxLTV(uint16 maxLTV_) external; + + /// @notice Sets an address as allowed guardian or not. Only callable by owner. + /// @param guardian_ address to set guardian value for + /// @param allowed_ bool flag for whether address is allowed as guardian or not + function setGuardian(address guardian_, bool allowed_) external; } contract PayloadIGP9 { @@ -220,17 +225,19 @@ contract PayloadIGP9 { IGovernorBravo public constant GOVERNOR = IGovernorBravo(0x0204Cd037B2ec03605CFdFe482D8e257C765fA1B); - ITimelock public immutable TIMELOCK = + ITimelock public constant TIMELOCK = ITimelock(0x2386DC45AdDed673317eF068992F19421B481F4c); - address public immutable ADDRESS_THIS; + address public constant TEAM_MULTISIG = + 0x4F6F977aCDD1177DCD81aB83074855EcB9C2D49e; address public constant LITE = 0xA0D3707c569ff8C87FA923d3823eC5D81c98Be78; address public constant LITE_DSA = 0x9600A48ed0f931d0c422D574e3275a90D8b22745; - + address public immutable ADDRESS_THIS; + IstETHProtocol public constant STETH_PROTOCOL = IstETHProtocol(0x1F6B2bFDd5D1e6AdE7B17027ff5300419a56Ad6b); IFluidLiquidityAdmin public constant LIQUIDITY = IFluidLiquidityAdmin(address(0)); // TODO @@ -267,17 +274,20 @@ contract PayloadIGP9 { } function execute() external { - // Action 1: remove Implementations + // Action 1: list stETH Protocol in Liquidity Layer with max debt ceiling of 5k ETH and base debt ceiling of 5k ETH action1(); - // Action 2: add implementations + // Action 2: initialize owner on stETH protocol as governance address action2(); - // Action 3: set dummy implementations + // Action 3: Set Max LTV as 93%. action3(); - // Action 4: Change ratios + // Action 4: Allow Lite DSA as user on stETH Protocol action4(); + + // Action 5: Set Team Avocado Multisig as guardian + action5(); } function verifyProposal() external view {} @@ -317,4 +327,9 @@ contract PayloadIGP9 { function action4() internal { STETH_PROTOCOL.setUserAllowed(LITE_DSA, true); } + + /// @notice Action 5: Set Team Avocado Multisig as guardian + function action5() internal { + STETH_PROTOCOL.setGuardian(TEAM_MULTISIG, true); + } } From eed34e468619f1f114479f864b9ea44ad21eda1c Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Fri, 8 Mar 2024 18:14:46 -0500 Subject: [PATCH 4/6] wip --- contracts/payloads/IGP9/PayloadIGP9.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/payloads/IGP9/PayloadIGP9.sol b/contracts/payloads/IGP9/PayloadIGP9.sol index ac03b1a..3a989e7 100644 --- a/contracts/payloads/IGP9/PayloadIGP9.sol +++ b/contracts/payloads/IGP9/PayloadIGP9.sol @@ -274,6 +274,8 @@ contract PayloadIGP9 { } function execute() external { + require(address(this) == address(TIMELOCK), "not-valid-caller"); + // Action 1: list stETH Protocol in Liquidity Layer with max debt ceiling of 5k ETH and base debt ceiling of 5k ETH action1(); From 751ccf676221c8b4edaeac8f6569df0632398e7b Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Fri, 8 Mar 2024 18:21:28 -0500 Subject: [PATCH 5/6] fix --- contracts/payloads/IGP9/PayloadIGP9.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/payloads/IGP9/PayloadIGP9.sol b/contracts/payloads/IGP9/PayloadIGP9.sol index 3a989e7..6237ba7 100644 --- a/contracts/payloads/IGP9/PayloadIGP9.sol +++ b/contracts/payloads/IGP9/PayloadIGP9.sol @@ -239,7 +239,7 @@ contract PayloadIGP9 { address public immutable ADDRESS_THIS; IstETHProtocol public constant STETH_PROTOCOL = IstETHProtocol(0x1F6B2bFDd5D1e6AdE7B17027ff5300419a56Ad6b); - IFluidLiquidityAdmin public constant LIQUIDITY = IFluidLiquidityAdmin(address(0)); // TODO + IFluidLiquidityAdmin public constant LIQUIDITY = IFluidLiquidityAdmin(0x52Aa899454998Be5b000Ad077a46Bbe360F4e497); address public constant ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; From c4b88b4c3a8e3858fb76e11d208710103f005380 Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Fri, 8 Mar 2024 19:15:14 -0500 Subject: [PATCH 6/6] added small condition --- contracts/payloads/IGP9/PayloadIGP9.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/payloads/IGP9/PayloadIGP9.sol b/contracts/payloads/IGP9/PayloadIGP9.sol index 6237ba7..9acfd51 100644 --- a/contracts/payloads/IGP9/PayloadIGP9.sol +++ b/contracts/payloads/IGP9/PayloadIGP9.sol @@ -248,7 +248,7 @@ contract PayloadIGP9 { } function propose(string memory description) external { - require(msg.sender == PROPOSER, "msg.sender-not-proposer"); + require(msg.sender == PROPOSER || msg.sender == TEAM_MULTISIG, "msg.sender-not-proposer-or-multisig"); uint256 totalActions = 1; address[] memory targets = new address[](totalActions);