From 9e2295f07099071e475c7e7c53948da0a9a01c8a Mon Sep 17 00:00:00 2001 From: Thrilok kumar Date: Wed, 13 Mar 2024 21:11:51 -0400 Subject: [PATCH] fix folder name --- .../{IGP112 => IGP12}/PayloadIGP12.sol | 48 ++++++++++++++++++- .../libraries/bigMathMinified.sol | 0 .../libraries/liquiditySlotsLink.sol | 0 3 files changed, 46 insertions(+), 2 deletions(-) rename contracts/payloads/{IGP112 => IGP12}/PayloadIGP12.sol (92%) rename contracts/payloads/{IGP112 => IGP12}/libraries/bigMathMinified.sol (100%) rename contracts/payloads/{IGP112 => IGP12}/libraries/liquiditySlotsLink.sol (100%) diff --git a/contracts/payloads/IGP112/PayloadIGP12.sol b/contracts/payloads/IGP12/PayloadIGP12.sol similarity index 92% rename from contracts/payloads/IGP112/PayloadIGP12.sol rename to contracts/payloads/IGP12/PayloadIGP12.sol index 0c8777e..01b472f 100644 --- a/contracts/payloads/IGP112/PayloadIGP12.sol +++ b/contracts/payloads/IGP12/PayloadIGP12.sol @@ -555,12 +555,56 @@ contract PayloadIGP12 { } - - /***********************************| | Proposal Payload Helpers | |__________________________________*/ + function getSupplyTokenConfig(address token_, address user_, uint256 expandPercent) internal returns(AdminModuleStructs.UserSupplyConfig memory config_){ + bytes32 _LIQUDITY_PROTOCOL_SUPPLY_SLOT = LiquiditySlotsLink.calculateDoubleMappingStorageSlot( + LiquiditySlotsLink.LIQUIDITY_USER_SUPPLY_DOUBLE_MAPPING_SLOT, + user_, + token_ + ); + + bytes32 userSupplyData_ = LIQUIDITY.readFromStorage(_LIQUDITY_PROTOCOL_SUPPLY_SLOT); + + config_ = AdminModuleStructs.UserSupplyConfig({ + user: user_, + token: token_, + mode: uint8(userSupplyData_ & 1), + expandPercent: expandPercent, + expandDuration: (userSupplyData_ >> LiquiditySlotsLink.BITS_USER_SUPPLY_EXPAND_DURATION) & X24, + baseWithdrawalLimit: BigMathMinified.fromBigNumber( + (userSupplyData_ >> LiquiditySlotsLink.BITS_USER_SUPPLY_BASE_WITHDRAWAL_LIMIT) & X18, + DEFAULT_EXPONENT_SIZE, + DEFAULT_EXPONENT_MASK + ) + }); + } + + function getBorrowTokenConfig(address token_, address user_, uint256 expandPercent) internal returns(AdminModuleStructs.UserSupplyConfig memory config_){ + bytes32 _LIQUDITY_PROTOCOL_SUPPLY_SLOT = LiquiditySlotsLink.calculateDoubleMappingStorageSlot( + LiquiditySlotsLink.LIQUIDITY_USER_SUPPLY_DOUBLE_MAPPING_SLOT, + user_, + token_ + ); + + bytes32 userSupplyData_ = LIQUIDITY.readFromStorage(_LIQUDITY_PROTOCOL_SUPPLY_SLOT); + + config_ = AdminModuleStructs.UserSupplyConfig({ + user: user_, + token: token_, + mode: uint8(userSupplyData_ & 1), + expandPercent: expandPercent, + expandDuration: (userSupplyData_ >> LiquiditySlotsLink.BITS_USER_SUPPLY_EXPAND_DURATION) & X24, + baseWithdrawalLimit: BigMathMinified.fromBigNumber( + (userSupplyData_ >> LiquiditySlotsLink.BITS_USER_SUPPLY_BASE_WITHDRAWAL_LIMIT) & X18, + DEFAULT_EXPONENT_SIZE, + DEFAULT_EXPONENT_MASK + ) + }); + } + function getUserSupplyData(address token_, address user_) internal returns(AdminModuleStructs.UserSupplyConfig memory config_) { bytes32 _LIQUDITY_PROTOCOL_SUPPLY_SLOT = LiquiditySlotsLink.calculateDoubleMappingStorageSlot( LiquiditySlotsLink.LIQUIDITY_USER_SUPPLY_DOUBLE_MAPPING_SLOT, diff --git a/contracts/payloads/IGP112/libraries/bigMathMinified.sol b/contracts/payloads/IGP12/libraries/bigMathMinified.sol similarity index 100% rename from contracts/payloads/IGP112/libraries/bigMathMinified.sol rename to contracts/payloads/IGP12/libraries/bigMathMinified.sol diff --git a/contracts/payloads/IGP112/libraries/liquiditySlotsLink.sol b/contracts/payloads/IGP12/libraries/liquiditySlotsLink.sol similarity index 100% rename from contracts/payloads/IGP112/libraries/liquiditySlotsLink.sol rename to contracts/payloads/IGP12/libraries/liquiditySlotsLink.sol