mirror of
https://github.com/Instadapp/dsa-governance.git
synced 2024-07-29 22:27:52 +00:00
added wstETH market rate update
This commit is contained in:
parent
4ae94849ad
commit
0cd5dd2535
|
@ -305,7 +305,6 @@ interface IFluidVaultT1 {
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
returns (ConstantViews memory constantsView_);
|
returns (ConstantViews memory constantsView_);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IFluidVaultT1Factory {
|
interface IFluidVaultT1Factory {
|
||||||
|
@ -365,10 +364,7 @@ interface IDSAV2 {
|
||||||
string[] memory _targetNames,
|
string[] memory _targetNames,
|
||||||
bytes[] memory _datas,
|
bytes[] memory _datas,
|
||||||
address _origin
|
address _origin
|
||||||
)
|
) external payable returns (bytes32);
|
||||||
external
|
|
||||||
payable
|
|
||||||
returns (bytes32);
|
|
||||||
|
|
||||||
function isAuth(address user) external view returns (bool);
|
function isAuth(address user) external view returns (bool);
|
||||||
}
|
}
|
||||||
|
@ -395,7 +391,8 @@ contract PayloadIGP30 {
|
||||||
address public constant TEAM_MULTISIG =
|
address public constant TEAM_MULTISIG =
|
||||||
0x4F6F977aCDD1177DCD81aB83074855EcB9C2D49e;
|
0x4F6F977aCDD1177DCD81aB83074855EcB9C2D49e;
|
||||||
|
|
||||||
IDSAV2 public constant TREASURY = IDSAV2(0x28849D2b63fA8D361e5fc15cB8aBB13019884d09);
|
IDSAV2 public constant TREASURY =
|
||||||
|
IDSAV2(0x28849D2b63fA8D361e5fc15cB8aBB13019884d09);
|
||||||
|
|
||||||
IFluidLiquidityAdmin public constant LIQUIDITY =
|
IFluidLiquidityAdmin public constant LIQUIDITY =
|
||||||
IFluidLiquidityAdmin(0x52Aa899454998Be5b000Ad077a46Bbe360F4e497);
|
IFluidLiquidityAdmin(0x52Aa899454998Be5b000Ad077a46Bbe360F4e497);
|
||||||
|
@ -474,14 +471,17 @@ contract PayloadIGP30 {
|
||||||
function execute() external {
|
function execute() external {
|
||||||
require(address(this) == address(TIMELOCK), "not-valid-caller");
|
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();
|
action1();
|
||||||
|
|
||||||
/// Action 2: Deploy wBTC/USDC and wBTC/USDT vaults.
|
// Action 2: Deploy wBTC/USDC and wBTC/USDT vaults.
|
||||||
action2();
|
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();
|
action3();
|
||||||
|
|
||||||
|
// Action 4: Update wstETH market rate curve.
|
||||||
|
action4();
|
||||||
}
|
}
|
||||||
|
|
||||||
function verifyProposal() external view {}
|
function verifyProposal() external view {}
|
||||||
|
@ -520,7 +520,6 @@ contract PayloadIGP30 {
|
||||||
|
|
||||||
LIQUIDITY.updateTokenConfigs(params_);
|
LIQUIDITY.updateTokenConfigs(params_);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Action 2: Deploy wBTC/USDC and wBTC/USDT vaults.
|
/// @notice Action 2: Deploy wBTC/USDC and wBTC/USDT vaults.
|
||||||
|
@ -532,30 +531,27 @@ contract PayloadIGP30 {
|
||||||
supplyExpandPercent: 25 * 1e2, // 25%
|
supplyExpandPercent: 25 * 1e2, // 25%
|
||||||
supplyExpandDuration: 12 hours, // 12 hours
|
supplyExpandDuration: 12 hours, // 12 hours
|
||||||
supplyBaseLimitInUSD: 5_000_000, // $5M
|
supplyBaseLimitInUSD: 5_000_000, // $5M
|
||||||
|
|
||||||
borrowToken: address(0),
|
borrowToken: address(0),
|
||||||
borrowMode: 1, // Mode 1
|
borrowMode: 1, // Mode 1
|
||||||
borrowExpandPercent: 20 * 1e2, // 20%
|
borrowExpandPercent: 20 * 1e2, // 20%
|
||||||
borrowExpandDuration: 12 hours, // 12 hours
|
borrowExpandDuration: 12 hours, // 12 hours
|
||||||
borrowBaseLimitInUSD: 7_500_000, // $7.5M
|
borrowBaseLimitInUSD: 7_500_000, // $7.5M
|
||||||
borrowMaxLimitInUSD: 200_000_000, // $200M
|
borrowMaxLimitInUSD: 200_000_000, // $200M
|
||||||
|
|
||||||
supplyRateMagnifier: 100 * 1e2, // 1x
|
supplyRateMagnifier: 100 * 1e2, // 1x
|
||||||
borrowRateMagnifier: 100 * 1e2, // 1x
|
borrowRateMagnifier: 100 * 1e2, // 1x
|
||||||
collateralFactor: 80 * 1e2, // 80%
|
collateralFactor: 80 * 1e2, // 80%
|
||||||
liquidationThreshold: 85 * 1e2, // 85%
|
liquidationThreshold: 85 * 1e2, // 85%
|
||||||
liquidationMaxLimit: 90 * 1e2, // 90%
|
liquidationMaxLimit: 90 * 1e2, // 90%
|
||||||
withdrawGap: 5 * 1e2, // 5%
|
withdrawGap: 5 * 1e2, // 5%
|
||||||
liquidationPenalty: 0,
|
liquidationPenalty: 0,
|
||||||
borrowFee: 0 * 1e2, // 0%
|
borrowFee: 0 * 1e2, // 0%
|
||||||
|
|
||||||
oracle: address(0)
|
oracle: address(0)
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
vaultConfig.borrowToken = USDC_ADDRESS;
|
vaultConfig.borrowToken = USDC_ADDRESS;
|
||||||
|
|
||||||
vaultConfig.liquidationPenalty = 3 * 1e2; // 3%
|
vaultConfig.liquidationPenalty = 3 * 1e2; // 3%
|
||||||
|
|
||||||
vaultConfig.oracle = 0x131BA983Ab640Ce291B98694b3Def4288596cD09;
|
vaultConfig.oracle = 0x131BA983Ab640Ce291B98694b3Def4288596cD09;
|
||||||
|
|
||||||
|
@ -573,7 +569,7 @@ contract PayloadIGP30 {
|
||||||
{
|
{
|
||||||
vaultConfig.borrowToken = USDT_ADDRESS;
|
vaultConfig.borrowToken = USDT_ADDRESS;
|
||||||
|
|
||||||
vaultConfig.liquidationPenalty = 4 * 1e2; // 4%
|
vaultConfig.liquidationPenalty = 4 * 1e2; // 4%
|
||||||
|
|
||||||
vaultConfig.oracle = 0xFF272430E88B3f804d9E30886677A36021864Cc4;
|
vaultConfig.oracle = 0xFF272430E88B3f804d9E30886677A36021864Cc4;
|
||||||
|
|
||||||
|
@ -594,18 +590,46 @@ contract PayloadIGP30 {
|
||||||
string[] memory targets = new string[](1);
|
string[] memory targets = new string[](1);
|
||||||
bytes[] memory encodedSpells = new bytes[](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
|
// Spell 1: Transfer wBTC
|
||||||
{
|
{
|
||||||
uint256 wBTC_AMOUNT = 2 * 1e8; // 2 wBTC
|
uint256 wBTC_AMOUNT = 2 * 1e8; // 2 wBTC
|
||||||
targets[0] = "BASIC-A";
|
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));
|
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 |
|
| Proposal Payload Helpers |
|
||||||
|__________________________________*/
|
|__________________________________*/
|
||||||
|
@ -616,14 +640,12 @@ contract PayloadIGP30 {
|
||||||
uint256 supplyExpandPercent;
|
uint256 supplyExpandPercent;
|
||||||
uint256 supplyExpandDuration;
|
uint256 supplyExpandDuration;
|
||||||
uint256 supplyBaseLimitInUSD;
|
uint256 supplyBaseLimitInUSD;
|
||||||
|
|
||||||
address borrowToken;
|
address borrowToken;
|
||||||
uint8 borrowMode;
|
uint8 borrowMode;
|
||||||
uint256 borrowExpandPercent;
|
uint256 borrowExpandPercent;
|
||||||
uint256 borrowExpandDuration;
|
uint256 borrowExpandDuration;
|
||||||
uint256 borrowBaseLimitInUSD;
|
uint256 borrowBaseLimitInUSD;
|
||||||
uint256 borrowMaxLimitInUSD;
|
uint256 borrowMaxLimitInUSD;
|
||||||
|
|
||||||
uint256 supplyRateMagnifier;
|
uint256 supplyRateMagnifier;
|
||||||
uint256 borrowRateMagnifier;
|
uint256 borrowRateMagnifier;
|
||||||
uint256 collateralFactor;
|
uint256 collateralFactor;
|
||||||
|
@ -632,18 +654,19 @@ contract PayloadIGP30 {
|
||||||
uint256 withdrawGap;
|
uint256 withdrawGap;
|
||||||
uint256 liquidationPenalty;
|
uint256 liquidationPenalty;
|
||||||
uint256 borrowFee;
|
uint256 borrowFee;
|
||||||
|
|
||||||
address oracle;
|
address oracle;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deployVault(VaultConfig memory vaultConfig) internal returns (address vault_) {
|
function deployVault(
|
||||||
|
VaultConfig memory vaultConfig
|
||||||
|
) internal returns (address vault_) {
|
||||||
// Deploy vault.
|
// Deploy vault.
|
||||||
vault_ = VAULT_T1_FACTORY.deployVault(
|
vault_ = VAULT_T1_FACTORY.deployVault(
|
||||||
address(VAULT_T1_DEPLOYMENT_LOGIC),
|
address(VAULT_T1_DEPLOYMENT_LOGIC),
|
||||||
abi.encodeWithSelector(
|
abi.encodeWithSelector(
|
||||||
IFluidVaultT1DeploymentLogic.vaultT1.selector,
|
IFluidVaultT1DeploymentLogic.vaultT1.selector,
|
||||||
vaultConfig.supplyToken,
|
vaultConfig.supplyToken,
|
||||||
vaultConfig.borrowToken
|
vaultConfig.borrowToken
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -719,16 +742,22 @@ contract PayloadIGP30 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRawAmount(address token, uint256 amountInUSD, bool isSupply) public view returns(uint256){
|
function getRawAmount(
|
||||||
uint256 exchangePriceAndConfig_ =
|
address token,
|
||||||
LIQUIDITY.readFromStorage(
|
uint256 amountInUSD,
|
||||||
LiquiditySlotsLink.calculateMappingStorageSlot(
|
bool isSupply
|
||||||
LiquiditySlotsLink.LIQUIDITY_EXCHANGE_PRICES_MAPPING_SLOT,
|
) public view returns (uint256) {
|
||||||
token
|
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 usdPrice = 0;
|
||||||
uint256 decimals = 18;
|
uint256 decimals = 18;
|
||||||
|
@ -751,7 +780,11 @@ contract PayloadIGP30 {
|
||||||
revert("not-found");
|
revert("not-found");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 exchangePrice = isSupply ? supplyExchangePrice : borrowExchangePrice;
|
uint256 exchangePrice = isSupply
|
||||||
return (amountInUSD * 1e12 * (10 ** decimals)) / (usdPrice * exchangePrice);
|
? supplyExchangePrice
|
||||||
|
: borrowExchangePrice;
|
||||||
|
return
|
||||||
|
(amountInUSD * 1e12 * (10 ** decimals)) /
|
||||||
|
(usdPrice * exchangePrice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,7 +305,6 @@ interface IFluidVaultT1 {
|
||||||
external
|
external
|
||||||
view
|
view
|
||||||
returns (ConstantViews memory constantsView_);
|
returns (ConstantViews memory constantsView_);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IFluidVaultT1Factory {
|
interface IFluidVaultT1Factory {
|
||||||
|
@ -459,13 +458,13 @@ contract PayloadIGP31 {
|
||||||
function execute() external {
|
function execute() external {
|
||||||
require(address(this) == address(TIMELOCK), "not-valid-caller");
|
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();
|
action1();
|
||||||
|
|
||||||
/// Action 2: Deploy wstETH/wBTC and weETH/wBTC vaults.
|
// Action 2: Deploy wstETH/wBTC and weETH/wBTC vaults.
|
||||||
action2();
|
action2();
|
||||||
|
|
||||||
/// Action 3: Clone from old vault config to new vault
|
// Action 3: Clone from old vault config to new vault
|
||||||
action3();
|
action3();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +474,7 @@ contract PayloadIGP31 {
|
||||||
| Proposal Payload Actions |
|
| Proposal Payload Actions |
|
||||||
|__________________________________*/
|
|__________________________________*/
|
||||||
|
|
||||||
/// @notice Action 1: Deploy wBTC/ETH and ETH/wBTC vaults.
|
/// @notice Action 1: Deploy wBTC/ETH and ETH/wBTC vaults.
|
||||||
function action1() internal {
|
function action1() internal {
|
||||||
VaultConfig memory vaultConfig = VaultConfig({
|
VaultConfig memory vaultConfig = VaultConfig({
|
||||||
// user supply config for the vault on Liquidity Layer.
|
// user supply config for the vault on Liquidity Layer.
|
||||||
|
@ -484,23 +483,20 @@ contract PayloadIGP31 {
|
||||||
supplyExpandPercent: 25 * 1e2, // 25%
|
supplyExpandPercent: 25 * 1e2, // 25%
|
||||||
supplyExpandDuration: 12 hours, // 12 hours
|
supplyExpandDuration: 12 hours, // 12 hours
|
||||||
supplyBaseLimitInUSD: 5_000_000, // $5M
|
supplyBaseLimitInUSD: 5_000_000, // $5M
|
||||||
|
|
||||||
borrowToken: address(0),
|
borrowToken: address(0),
|
||||||
borrowMode: 1, // Mode 1
|
borrowMode: 1, // Mode 1
|
||||||
borrowExpandPercent: 20 * 1e2, // 20%
|
borrowExpandPercent: 20 * 1e2, // 20%
|
||||||
borrowExpandDuration: 12 hours, // 12 hours
|
borrowExpandDuration: 12 hours, // 12 hours
|
||||||
borrowBaseLimitInUSD: 7_500_000, // $7.5M
|
borrowBaseLimitInUSD: 7_500_000, // $7.5M
|
||||||
borrowMaxLimitInUSD: 200_000_000, // $200M
|
borrowMaxLimitInUSD: 200_000_000, // $200M
|
||||||
|
|
||||||
supplyRateMagnifier: 100 * 1e2, // 1x
|
supplyRateMagnifier: 100 * 1e2, // 1x
|
||||||
borrowRateMagnifier: 100 * 1e2, // 1x
|
borrowRateMagnifier: 100 * 1e2, // 1x
|
||||||
collateralFactor: 90 * 1e2, // 90%
|
collateralFactor: 90 * 1e2, // 90%
|
||||||
liquidationThreshold: 0,
|
liquidationThreshold: 0,
|
||||||
liquidationMaxLimit: 0,
|
liquidationMaxLimit: 0,
|
||||||
withdrawGap: 5 * 1e2, // 5%
|
withdrawGap: 5 * 1e2, // 5%
|
||||||
liquidationPenalty: 2 * 1e2, // 2%
|
liquidationPenalty: 2 * 1e2, // 2%
|
||||||
borrowFee: 0 * 1e2, // 0%
|
borrowFee: 0 * 1e2, // 0%
|
||||||
|
|
||||||
oracle: address(0)
|
oracle: address(0)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -509,10 +505,12 @@ contract PayloadIGP31 {
|
||||||
vaultConfig.supplyToken = wBTC_ADDRESS;
|
vaultConfig.supplyToken = wBTC_ADDRESS;
|
||||||
vaultConfig.borrowToken = ETH_ADDRESS;
|
vaultConfig.borrowToken = ETH_ADDRESS;
|
||||||
|
|
||||||
vaultConfig.liquidationThreshold = 91 * 1e2; // 91%
|
vaultConfig.liquidationThreshold = 91 * 1e2; // 91%
|
||||||
vaultConfig.liquidationMaxLimit = 93 * 1e2; // 93%
|
vaultConfig.liquidationMaxLimit = 93 * 1e2; // 93%
|
||||||
|
|
||||||
vaultConfig.oracle = address(0x4C57Ef1012bDFFCe68FDDcD793Bb2b8B7D27DC06);
|
vaultConfig.oracle = address(
|
||||||
|
0x4C57Ef1012bDFFCe68FDDcD793Bb2b8B7D27DC06
|
||||||
|
);
|
||||||
|
|
||||||
deployVault(vaultConfig);
|
deployVault(vaultConfig);
|
||||||
}
|
}
|
||||||
|
@ -522,10 +520,12 @@ contract PayloadIGP31 {
|
||||||
vaultConfig.supplyToken = ETH_ADDRESS;
|
vaultConfig.supplyToken = ETH_ADDRESS;
|
||||||
vaultConfig.borrowToken = wBTC_ADDRESS;
|
vaultConfig.borrowToken = wBTC_ADDRESS;
|
||||||
|
|
||||||
vaultConfig.liquidationThreshold = 93 * 1e2; // 93%
|
vaultConfig.liquidationThreshold = 93 * 1e2; // 93%
|
||||||
vaultConfig.liquidationMaxLimit = 95 * 1e2; // 95%
|
vaultConfig.liquidationMaxLimit = 95 * 1e2; // 95%
|
||||||
|
|
||||||
vaultConfig.oracle = address(0x63Ae926f97A480B18d58370268672766643f577F);
|
vaultConfig.oracle = address(
|
||||||
|
0x63Ae926f97A480B18d58370268672766643f577F
|
||||||
|
);
|
||||||
|
|
||||||
deployVault(vaultConfig);
|
deployVault(vaultConfig);
|
||||||
}
|
}
|
||||||
|
@ -542,23 +542,20 @@ contract PayloadIGP31 {
|
||||||
supplyExpandPercent: 25 * 1e2, // 25%
|
supplyExpandPercent: 25 * 1e2, // 25%
|
||||||
supplyExpandDuration: 12 hours, // 12 hours
|
supplyExpandDuration: 12 hours, // 12 hours
|
||||||
supplyBaseLimitInUSD: 5_000_000, // $5M
|
supplyBaseLimitInUSD: 5_000_000, // $5M
|
||||||
|
|
||||||
borrowToken: wBTC_ADDRESS,
|
borrowToken: wBTC_ADDRESS,
|
||||||
borrowMode: 1, // Mode 1
|
borrowMode: 1, // Mode 1
|
||||||
borrowExpandPercent: 20 * 1e2, // 20%
|
borrowExpandPercent: 20 * 1e2, // 20%
|
||||||
borrowExpandDuration: 12 hours, // 12 hours
|
borrowExpandDuration: 12 hours, // 12 hours
|
||||||
borrowBaseLimitInUSD: 7_500_000, // $7.5M
|
borrowBaseLimitInUSD: 7_500_000, // $7.5M
|
||||||
borrowMaxLimitInUSD: 200_000_000, // $200M
|
borrowMaxLimitInUSD: 200_000_000, // $200M
|
||||||
|
|
||||||
supplyRateMagnifier: 100 * 1e2, // 1x
|
supplyRateMagnifier: 100 * 1e2, // 1x
|
||||||
borrowRateMagnifier: 100 * 1e2, // 1x
|
borrowRateMagnifier: 100 * 1e2, // 1x
|
||||||
collateralFactor: 88 * 1e2, // 88%
|
collateralFactor: 88 * 1e2, // 88%
|
||||||
liquidationThreshold: 91 * 1e2, // 91%
|
liquidationThreshold: 91 * 1e2, // 91%
|
||||||
liquidationMaxLimit: 94 * 1e2, // 94%
|
liquidationMaxLimit: 94 * 1e2, // 94%
|
||||||
withdrawGap: 5 * 1e2, // 5%
|
withdrawGap: 5 * 1e2, // 5%
|
||||||
liquidationPenalty: 2 * 1e2, // 2%
|
liquidationPenalty: 2 * 1e2, // 2%
|
||||||
borrowFee: 0 * 1e2, // 0%
|
borrowFee: 0 * 1e2, // 0%
|
||||||
|
|
||||||
oracle: 0xD25c68bb507f8E19386F4F102462e1bfbfA7869F
|
oracle: 0xD25c68bb507f8E19386F4F102462e1bfbfA7869F
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -575,23 +572,20 @@ contract PayloadIGP31 {
|
||||||
supplyExpandPercent: 25 * 1e2, // 25%
|
supplyExpandPercent: 25 * 1e2, // 25%
|
||||||
supplyExpandDuration: 12 hours, // 12 hours
|
supplyExpandDuration: 12 hours, // 12 hours
|
||||||
supplyBaseLimitInUSD: 5_000_000, // $5M
|
supplyBaseLimitInUSD: 5_000_000, // $5M
|
||||||
|
|
||||||
borrowToken: wBTC_ADDRESS,
|
borrowToken: wBTC_ADDRESS,
|
||||||
borrowMode: 1, // Mode 1
|
borrowMode: 1, // Mode 1
|
||||||
borrowExpandPercent: 20 * 1e2, // 20%
|
borrowExpandPercent: 20 * 1e2, // 20%
|
||||||
borrowExpandDuration: 12 hours, // 12 hours
|
borrowExpandDuration: 12 hours, // 12 hours
|
||||||
borrowBaseLimitInUSD: 7_500_000, // $7.5M
|
borrowBaseLimitInUSD: 7_500_000, // $7.5M
|
||||||
borrowMaxLimitInUSD: 20_000_000, // $20M
|
borrowMaxLimitInUSD: 20_000_000, // $20M
|
||||||
|
|
||||||
supplyRateMagnifier: 100 * 1e2, // 1x
|
supplyRateMagnifier: 100 * 1e2, // 1x
|
||||||
borrowRateMagnifier: 100 * 1e2, // 1x
|
borrowRateMagnifier: 100 * 1e2, // 1x
|
||||||
collateralFactor: 80 * 1e2, // 80%
|
collateralFactor: 80 * 1e2, // 80%
|
||||||
liquidationThreshold: 85 * 1e2, // 85%
|
liquidationThreshold: 85 * 1e2, // 85%
|
||||||
liquidationMaxLimit: 90 * 1e2, // 90%
|
liquidationMaxLimit: 90 * 1e2, // 90%
|
||||||
withdrawGap: 5 * 1e2, // 5%
|
withdrawGap: 5 * 1e2, // 5%
|
||||||
liquidationPenalty: 5 * 1e2, // 5%
|
liquidationPenalty: 5 * 1e2, // 5%
|
||||||
borrowFee: 0 * 1e2, // 0%
|
borrowFee: 0 * 1e2, // 0%
|
||||||
|
|
||||||
oracle: 0xBD7ea28840B120E2a2645F103273B0Dc23599E05
|
oracle: 0xBD7ea28840B120E2a2645F103273B0Dc23599E05
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -617,14 +611,12 @@ contract PayloadIGP31 {
|
||||||
uint256 supplyExpandPercent;
|
uint256 supplyExpandPercent;
|
||||||
uint256 supplyExpandDuration;
|
uint256 supplyExpandDuration;
|
||||||
uint256 supplyBaseLimitInUSD;
|
uint256 supplyBaseLimitInUSD;
|
||||||
|
|
||||||
address borrowToken;
|
address borrowToken;
|
||||||
uint8 borrowMode;
|
uint8 borrowMode;
|
||||||
uint256 borrowExpandPercent;
|
uint256 borrowExpandPercent;
|
||||||
uint256 borrowExpandDuration;
|
uint256 borrowExpandDuration;
|
||||||
uint256 borrowBaseLimitInUSD;
|
uint256 borrowBaseLimitInUSD;
|
||||||
uint256 borrowMaxLimitInUSD;
|
uint256 borrowMaxLimitInUSD;
|
||||||
|
|
||||||
uint256 supplyRateMagnifier;
|
uint256 supplyRateMagnifier;
|
||||||
uint256 borrowRateMagnifier;
|
uint256 borrowRateMagnifier;
|
||||||
uint256 collateralFactor;
|
uint256 collateralFactor;
|
||||||
|
@ -633,18 +625,19 @@ contract PayloadIGP31 {
|
||||||
uint256 withdrawGap;
|
uint256 withdrawGap;
|
||||||
uint256 liquidationPenalty;
|
uint256 liquidationPenalty;
|
||||||
uint256 borrowFee;
|
uint256 borrowFee;
|
||||||
|
|
||||||
address oracle;
|
address oracle;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deployVault(VaultConfig memory vaultConfig) internal returns (address vault_) {
|
function deployVault(
|
||||||
|
VaultConfig memory vaultConfig
|
||||||
|
) internal returns (address vault_) {
|
||||||
// Deploy vault.
|
// Deploy vault.
|
||||||
vault_ = VAULT_T1_FACTORY.deployVault(
|
vault_ = VAULT_T1_FACTORY.deployVault(
|
||||||
address(VAULT_T1_DEPLOYMENT_LOGIC),
|
address(VAULT_T1_DEPLOYMENT_LOGIC),
|
||||||
abi.encodeWithSelector(
|
abi.encodeWithSelector(
|
||||||
IFluidVaultT1DeploymentLogic.vaultT1.selector,
|
IFluidVaultT1DeploymentLogic.vaultT1.selector,
|
||||||
vaultConfig.supplyToken,
|
vaultConfig.supplyToken,
|
||||||
vaultConfig.borrowToken
|
vaultConfig.borrowToken
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -744,12 +737,13 @@ contract PayloadIGP31 {
|
||||||
LiquiditySlotsLink.BITS_USER_SUPPLY_EXPAND_PERCENT) & X14,
|
LiquiditySlotsLink.BITS_USER_SUPPLY_EXPAND_PERCENT) & X14,
|
||||||
expandDuration: (userSupplyData_ >>
|
expandDuration: (userSupplyData_ >>
|
||||||
LiquiditySlotsLink.BITS_USER_SUPPLY_EXPAND_DURATION) & X24,
|
LiquiditySlotsLink.BITS_USER_SUPPLY_EXPAND_DURATION) & X24,
|
||||||
baseWithdrawalLimit:
|
baseWithdrawalLimit: BigMathMinified.fromBigNumber(
|
||||||
BigMathMinified.fromBigNumber(
|
(userSupplyData_ >>
|
||||||
(userSupplyData_ >> LiquiditySlotsLink.BITS_USER_SUPPLY_BASE_WITHDRAWAL_LIMIT) & X18,
|
LiquiditySlotsLink.BITS_USER_SUPPLY_BASE_WITHDRAWAL_LIMIT) &
|
||||||
DEFAULT_EXPONENT_SIZE,
|
X18,
|
||||||
DEFAULT_EXPONENT_MASK
|
DEFAULT_EXPONENT_SIZE,
|
||||||
)
|
DEFAULT_EXPONENT_MASK
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -778,18 +772,19 @@ contract PayloadIGP31 {
|
||||||
LiquiditySlotsLink.BITS_USER_BORROW_EXPAND_PERCENT) & X14,
|
LiquiditySlotsLink.BITS_USER_BORROW_EXPAND_PERCENT) & X14,
|
||||||
expandDuration: (userBorrowData_ >>
|
expandDuration: (userBorrowData_ >>
|
||||||
LiquiditySlotsLink.BITS_USER_BORROW_EXPAND_DURATION) & X24,
|
LiquiditySlotsLink.BITS_USER_BORROW_EXPAND_DURATION) & X24,
|
||||||
baseDebtCeiling:
|
baseDebtCeiling: BigMathMinified.fromBigNumber(
|
||||||
BigMathMinified.fromBigNumber(
|
(userBorrowData_ >>
|
||||||
(userBorrowData_ >> LiquiditySlotsLink.BITS_USER_BORROW_BASE_BORROW_LIMIT) & X18,
|
LiquiditySlotsLink.BITS_USER_BORROW_BASE_BORROW_LIMIT) &
|
||||||
DEFAULT_EXPONENT_SIZE,
|
X18,
|
||||||
DEFAULT_EXPONENT_MASK
|
DEFAULT_EXPONENT_SIZE,
|
||||||
),
|
DEFAULT_EXPONENT_MASK
|
||||||
maxDebtCeiling:
|
),
|
||||||
BigMathMinified.fromBigNumber(
|
maxDebtCeiling: BigMathMinified.fromBigNumber(
|
||||||
(userBorrowData_ >> LiquiditySlotsLink.BITS_USER_BORROW_MAX_BORROW_LIMIT) & X18,
|
(userBorrowData_ >>
|
||||||
DEFAULT_EXPONENT_SIZE,
|
LiquiditySlotsLink.BITS_USER_BORROW_MAX_BORROW_LIMIT) & X18,
|
||||||
DEFAULT_EXPONENT_MASK
|
DEFAULT_EXPONENT_SIZE,
|
||||||
)
|
DEFAULT_EXPONENT_MASK
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -854,16 +849,22 @@ contract PayloadIGP31 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRawAmount(address token, uint256 amountInUSD, bool isSupply) public view returns(uint256){
|
function getRawAmount(
|
||||||
uint256 exchangePriceAndConfig_ =
|
address token,
|
||||||
LIQUIDITY.readFromStorage(
|
uint256 amountInUSD,
|
||||||
LiquiditySlotsLink.calculateMappingStorageSlot(
|
bool isSupply
|
||||||
LiquiditySlotsLink.LIQUIDITY_EXCHANGE_PRICES_MAPPING_SLOT,
|
) public view returns (uint256) {
|
||||||
token
|
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 usdPrice = 0;
|
||||||
uint256 decimals = 18;
|
uint256 decimals = 18;
|
||||||
|
@ -886,7 +887,11 @@ contract PayloadIGP31 {
|
||||||
revert("not-found");
|
revert("not-found");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 exchangePrice = isSupply ? supplyExchangePrice : borrowExchangePrice;
|
uint256 exchangePrice = isSupply
|
||||||
return (amountInUSD * 1e12 * (10 ** decimals)) / (usdPrice * exchangePrice);
|
? supplyExchangePrice
|
||||||
|
: borrowExchangePrice;
|
||||||
|
return
|
||||||
|
(amountInUSD * 1e12 * (10 ** decimals)) /
|
||||||
|
(usdPrice * exchangePrice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user