added wstETH market rate update

This commit is contained in:
Samyak Jain 2024-07-04 03:01:19 +04:00
parent 4ae94849ad
commit 0cd5dd2535
2 changed files with 146 additions and 108 deletions

View File

@ -305,7 +305,6 @@ interface IFluidVaultT1 {
external
view
returns (ConstantViews memory constantsView_);
}
interface IFluidVaultT1Factory {
@ -365,10 +364,7 @@ interface IDSAV2 {
string[] memory _targetNames,
bytes[] memory _datas,
address _origin
)
external
payable
returns (bytes32);
) external payable returns (bytes32);
function isAuth(address user) external view returns (bool);
}
@ -395,7 +391,8 @@ contract PayloadIGP30 {
address public constant TEAM_MULTISIG =
0x4F6F977aCDD1177DCD81aB83074855EcB9C2D49e;
IDSAV2 public constant TREASURY = IDSAV2(0x28849D2b63fA8D361e5fc15cB8aBB13019884d09);
IDSAV2 public constant TREASURY =
IDSAV2(0x28849D2b63fA8D361e5fc15cB8aBB13019884d09);
IFluidLiquidityAdmin public constant LIQUIDITY =
IFluidLiquidityAdmin(0x52Aa899454998Be5b000Ad077a46Bbe360F4e497);
@ -474,14 +471,17 @@ contract PayloadIGP30 {
function execute() external {
require(address(this) == address(TIMELOCK), "not-valid-caller");
/// Action 1: Set wBTC token config and market rate curve on liquidity.
// Action 1: Set wBTC token config and market rate curve on liquidity.
action1();
/// Action 2: Deploy wBTC/USDC and wBTC/USDT vaults.
// Action 2: Deploy wBTC/USDC and wBTC/USDT vaults.
action2();
/// Action 3: call cast() - transfer 2 wBTC to Fluid Reserve contract from treasury.
// Action 3: call cast() - transfer 2 wBTC to Fluid Reserve contract from treasury.
action3();
// Action 4: Update wstETH market rate curve.
action4();
}
function verifyProposal() external view {}
@ -520,7 +520,6 @@ contract PayloadIGP30 {
LIQUIDITY.updateTokenConfigs(params_);
}
}
/// @notice Action 2: Deploy wBTC/USDC and wBTC/USDT vaults.
@ -532,14 +531,12 @@ contract PayloadIGP30 {
supplyExpandPercent: 25 * 1e2, // 25%
supplyExpandDuration: 12 hours, // 12 hours
supplyBaseLimitInUSD: 5_000_000, // $5M
borrowToken: address(0),
borrowMode: 1, // Mode 1
borrowExpandPercent: 20 * 1e2, // 20%
borrowExpandDuration: 12 hours, // 12 hours
borrowBaseLimitInUSD: 7_500_000, // $7.5M
borrowMaxLimitInUSD: 200_000_000, // $200M
supplyRateMagnifier: 100 * 1e2, // 1x
borrowRateMagnifier: 100 * 1e2, // 1x
collateralFactor: 80 * 1e2, // 80%
@ -548,7 +545,6 @@ contract PayloadIGP30 {
withdrawGap: 5 * 1e2, // 5%
liquidationPenalty: 0,
borrowFee: 0 * 1e2, // 0%
oracle: address(0)
});
@ -594,18 +590,46 @@ contract PayloadIGP30 {
string[] memory targets = new string[](1);
bytes[] memory encodedSpells = new bytes[](1);
string memory withdrawSignature = "withdraw(address,uint256,address,uint256,uint256)";
string
memory withdrawSignature = "withdraw(address,uint256,address,uint256,uint256)";
// Spell 1: Transfer wBTC
{
uint256 wBTC_AMOUNT = 2 * 1e8; // 2 wBTC
targets[0] = "BASIC-A";
encodedSpells[0] = abi.encodeWithSignature(withdrawSignature, wBTC_ADDRESS, wBTC_AMOUNT, FLUID_RESERVE, 0, 0);
encodedSpells[0] = abi.encodeWithSignature(
withdrawSignature,
wBTC_ADDRESS,
wBTC_AMOUNT,
FLUID_RESERVE,
0,
0
);
}
IDSAV2(TREASURY).cast(targets, encodedSpells, address(this));
}
/// @notice Action 4: Update wstETH market rate curve.
function action4() internal {
{
AdminModuleStructs.RateDataV2Params[]
memory paramsV2_ = new AdminModuleStructs.RateDataV2Params[](1);
paramsV2_[0] = AdminModuleStructs.RateDataV2Params({
token: wstETH_ADDRESS, // wstETH
kink1: 80 * 1e2, // 80%
kink2: 90 * 1e2, // 90%
rateAtUtilizationZero: 0, // 0%
rateAtUtilizationKink1: 5 * 1e2, // 5%
rateAtUtilizationKink2: 10 * 1e2, // 10%
rateAtUtilizationMax: 100 * 1e2 // 100%
});
LIQUIDITY.updateRateDataV2s(paramsV2_);
}
}
/***********************************|
| Proposal Payload Helpers |
|__________________________________*/
@ -616,14 +640,12 @@ contract PayloadIGP30 {
uint256 supplyExpandPercent;
uint256 supplyExpandDuration;
uint256 supplyBaseLimitInUSD;
address borrowToken;
uint8 borrowMode;
uint256 borrowExpandPercent;
uint256 borrowExpandDuration;
uint256 borrowBaseLimitInUSD;
uint256 borrowMaxLimitInUSD;
uint256 supplyRateMagnifier;
uint256 borrowRateMagnifier;
uint256 collateralFactor;
@ -632,11 +654,12 @@ contract PayloadIGP30 {
uint256 withdrawGap;
uint256 liquidationPenalty;
uint256 borrowFee;
address oracle;
}
function deployVault(VaultConfig memory vaultConfig) internal returns (address vault_) {
function deployVault(
VaultConfig memory vaultConfig
) internal returns (address vault_) {
// Deploy vault.
vault_ = VAULT_T1_FACTORY.deployVault(
address(VAULT_T1_DEPLOYMENT_LOGIC),
@ -719,16 +742,22 @@ contract PayloadIGP30 {
}
}
function getRawAmount(address token, uint256 amountInUSD, bool isSupply) public view returns(uint256){
uint256 exchangePriceAndConfig_ =
LIQUIDITY.readFromStorage(
function getRawAmount(
address token,
uint256 amountInUSD,
bool isSupply
) public view returns (uint256) {
uint256 exchangePriceAndConfig_ = LIQUIDITY.readFromStorage(
LiquiditySlotsLink.calculateMappingStorageSlot(
LiquiditySlotsLink.LIQUIDITY_EXCHANGE_PRICES_MAPPING_SLOT,
token
)
);
(uint256 supplyExchangePrice, uint256 borrowExchangePrice) = LiquidityCalcs.calcExchangePrices(exchangePriceAndConfig_);
(
uint256 supplyExchangePrice,
uint256 borrowExchangePrice
) = LiquidityCalcs.calcExchangePrices(exchangePriceAndConfig_);
uint256 usdPrice = 0;
uint256 decimals = 18;
@ -751,7 +780,11 @@ contract PayloadIGP30 {
revert("not-found");
}
uint256 exchangePrice = isSupply ? supplyExchangePrice : borrowExchangePrice;
return (amountInUSD * 1e12 * (10 ** decimals)) / (usdPrice * exchangePrice);
uint256 exchangePrice = isSupply
? supplyExchangePrice
: borrowExchangePrice;
return
(amountInUSD * 1e12 * (10 ** decimals)) /
(usdPrice * exchangePrice);
}
}

View File

@ -305,7 +305,6 @@ interface IFluidVaultT1 {
external
view
returns (ConstantViews memory constantsView_);
}
interface IFluidVaultT1Factory {
@ -459,13 +458,13 @@ contract PayloadIGP31 {
function execute() external {
require(address(this) == address(TIMELOCK), "not-valid-caller");
/// Action 1: Deploy wBTC/ETH and ETH/wBTC vaults.
// Action 1: Deploy wBTC/ETH and ETH/wBTC vaults.
action1();
/// Action 2: Deploy wstETH/wBTC and weETH/wBTC vaults.
// Action 2: Deploy wstETH/wBTC and weETH/wBTC vaults.
action2();
/// Action 3: Clone from old vault config to new vault
// Action 3: Clone from old vault config to new vault
action3();
}
@ -484,14 +483,12 @@ contract PayloadIGP31 {
supplyExpandPercent: 25 * 1e2, // 25%
supplyExpandDuration: 12 hours, // 12 hours
supplyBaseLimitInUSD: 5_000_000, // $5M
borrowToken: address(0),
borrowMode: 1, // Mode 1
borrowExpandPercent: 20 * 1e2, // 20%
borrowExpandDuration: 12 hours, // 12 hours
borrowBaseLimitInUSD: 7_500_000, // $7.5M
borrowMaxLimitInUSD: 200_000_000, // $200M
supplyRateMagnifier: 100 * 1e2, // 1x
borrowRateMagnifier: 100 * 1e2, // 1x
collateralFactor: 90 * 1e2, // 90%
@ -500,7 +497,6 @@ contract PayloadIGP31 {
withdrawGap: 5 * 1e2, // 5%
liquidationPenalty: 2 * 1e2, // 2%
borrowFee: 0 * 1e2, // 0%
oracle: address(0)
});
@ -512,7 +508,9 @@ contract PayloadIGP31 {
vaultConfig.liquidationThreshold = 91 * 1e2; // 91%
vaultConfig.liquidationMaxLimit = 93 * 1e2; // 93%
vaultConfig.oracle = address(0x4C57Ef1012bDFFCe68FDDcD793Bb2b8B7D27DC06);
vaultConfig.oracle = address(
0x4C57Ef1012bDFFCe68FDDcD793Bb2b8B7D27DC06
);
deployVault(vaultConfig);
}
@ -525,7 +523,9 @@ contract PayloadIGP31 {
vaultConfig.liquidationThreshold = 93 * 1e2; // 93%
vaultConfig.liquidationMaxLimit = 95 * 1e2; // 95%
vaultConfig.oracle = address(0x63Ae926f97A480B18d58370268672766643f577F);
vaultConfig.oracle = address(
0x63Ae926f97A480B18d58370268672766643f577F
);
deployVault(vaultConfig);
}
@ -542,14 +542,12 @@ contract PayloadIGP31 {
supplyExpandPercent: 25 * 1e2, // 25%
supplyExpandDuration: 12 hours, // 12 hours
supplyBaseLimitInUSD: 5_000_000, // $5M
borrowToken: wBTC_ADDRESS,
borrowMode: 1, // Mode 1
borrowExpandPercent: 20 * 1e2, // 20%
borrowExpandDuration: 12 hours, // 12 hours
borrowBaseLimitInUSD: 7_500_000, // $7.5M
borrowMaxLimitInUSD: 200_000_000, // $200M
supplyRateMagnifier: 100 * 1e2, // 1x
borrowRateMagnifier: 100 * 1e2, // 1x
collateralFactor: 88 * 1e2, // 88%
@ -558,7 +556,6 @@ contract PayloadIGP31 {
withdrawGap: 5 * 1e2, // 5%
liquidationPenalty: 2 * 1e2, // 2%
borrowFee: 0 * 1e2, // 0%
oracle: 0xD25c68bb507f8E19386F4F102462e1bfbfA7869F
});
@ -575,14 +572,12 @@ contract PayloadIGP31 {
supplyExpandPercent: 25 * 1e2, // 25%
supplyExpandDuration: 12 hours, // 12 hours
supplyBaseLimitInUSD: 5_000_000, // $5M
borrowToken: wBTC_ADDRESS,
borrowMode: 1, // Mode 1
borrowExpandPercent: 20 * 1e2, // 20%
borrowExpandDuration: 12 hours, // 12 hours
borrowBaseLimitInUSD: 7_500_000, // $7.5M
borrowMaxLimitInUSD: 20_000_000, // $20M
supplyRateMagnifier: 100 * 1e2, // 1x
borrowRateMagnifier: 100 * 1e2, // 1x
collateralFactor: 80 * 1e2, // 80%
@ -591,7 +586,6 @@ contract PayloadIGP31 {
withdrawGap: 5 * 1e2, // 5%
liquidationPenalty: 5 * 1e2, // 5%
borrowFee: 0 * 1e2, // 0%
oracle: 0xBD7ea28840B120E2a2645F103273B0Dc23599E05
});
@ -617,14 +611,12 @@ contract PayloadIGP31 {
uint256 supplyExpandPercent;
uint256 supplyExpandDuration;
uint256 supplyBaseLimitInUSD;
address borrowToken;
uint8 borrowMode;
uint256 borrowExpandPercent;
uint256 borrowExpandDuration;
uint256 borrowBaseLimitInUSD;
uint256 borrowMaxLimitInUSD;
uint256 supplyRateMagnifier;
uint256 borrowRateMagnifier;
uint256 collateralFactor;
@ -633,11 +625,12 @@ contract PayloadIGP31 {
uint256 withdrawGap;
uint256 liquidationPenalty;
uint256 borrowFee;
address oracle;
}
function deployVault(VaultConfig memory vaultConfig) internal returns (address vault_) {
function deployVault(
VaultConfig memory vaultConfig
) internal returns (address vault_) {
// Deploy vault.
vault_ = VAULT_T1_FACTORY.deployVault(
address(VAULT_T1_DEPLOYMENT_LOGIC),
@ -744,9 +737,10 @@ contract PayloadIGP31 {
LiquiditySlotsLink.BITS_USER_SUPPLY_EXPAND_PERCENT) & X14,
expandDuration: (userSupplyData_ >>
LiquiditySlotsLink.BITS_USER_SUPPLY_EXPAND_DURATION) & X24,
baseWithdrawalLimit:
BigMathMinified.fromBigNumber(
(userSupplyData_ >> LiquiditySlotsLink.BITS_USER_SUPPLY_BASE_WITHDRAWAL_LIMIT) & X18,
baseWithdrawalLimit: BigMathMinified.fromBigNumber(
(userSupplyData_ >>
LiquiditySlotsLink.BITS_USER_SUPPLY_BASE_WITHDRAWAL_LIMIT) &
X18,
DEFAULT_EXPONENT_SIZE,
DEFAULT_EXPONENT_MASK
)
@ -778,15 +772,16 @@ contract PayloadIGP31 {
LiquiditySlotsLink.BITS_USER_BORROW_EXPAND_PERCENT) & X14,
expandDuration: (userBorrowData_ >>
LiquiditySlotsLink.BITS_USER_BORROW_EXPAND_DURATION) & X24,
baseDebtCeiling:
BigMathMinified.fromBigNumber(
(userBorrowData_ >> LiquiditySlotsLink.BITS_USER_BORROW_BASE_BORROW_LIMIT) & X18,
baseDebtCeiling: BigMathMinified.fromBigNumber(
(userBorrowData_ >>
LiquiditySlotsLink.BITS_USER_BORROW_BASE_BORROW_LIMIT) &
X18,
DEFAULT_EXPONENT_SIZE,
DEFAULT_EXPONENT_MASK
),
maxDebtCeiling:
BigMathMinified.fromBigNumber(
(userBorrowData_ >> LiquiditySlotsLink.BITS_USER_BORROW_MAX_BORROW_LIMIT) & X18,
maxDebtCeiling: BigMathMinified.fromBigNumber(
(userBorrowData_ >>
LiquiditySlotsLink.BITS_USER_BORROW_MAX_BORROW_LIMIT) & X18,
DEFAULT_EXPONENT_SIZE,
DEFAULT_EXPONENT_MASK
)
@ -854,16 +849,22 @@ contract PayloadIGP31 {
}
}
function getRawAmount(address token, uint256 amountInUSD, bool isSupply) public view returns(uint256){
uint256 exchangePriceAndConfig_ =
LIQUIDITY.readFromStorage(
function getRawAmount(
address token,
uint256 amountInUSD,
bool isSupply
) public view returns (uint256) {
uint256 exchangePriceAndConfig_ = LIQUIDITY.readFromStorage(
LiquiditySlotsLink.calculateMappingStorageSlot(
LiquiditySlotsLink.LIQUIDITY_EXCHANGE_PRICES_MAPPING_SLOT,
token
)
);
(uint256 supplyExchangePrice, uint256 borrowExchangePrice) = LiquidityCalcs.calcExchangePrices(exchangePriceAndConfig_);
(
uint256 supplyExchangePrice,
uint256 borrowExchangePrice
) = LiquidityCalcs.calcExchangePrices(exchangePriceAndConfig_);
uint256 usdPrice = 0;
uint256 decimals = 18;
@ -886,7 +887,11 @@ contract PayloadIGP31 {
revert("not-found");
}
uint256 exchangePrice = isSupply ? supplyExchangePrice : borrowExchangePrice;
return (amountInUSD * 1e12 * (10 ** decimals)) / (usdPrice * exchangePrice);
uint256 exchangePrice = isSupply
? supplyExchangePrice
: borrowExchangePrice;
return
(amountInUSD * 1e12 * (10 ** decimals)) /
(usdPrice * exchangePrice);
}
}