From 1e675725b48839179c23a89f30c7f9e19a87aade Mon Sep 17 00:00:00 2001 From: aalavandhann <6264334+aalavandhan@users.noreply.github.com> Date: Sat, 29 Mar 2025 16:42:48 -0400 Subject: [PATCH] upgraded fee policy impl without bounds on rollover fees --- spot-contracts/.openzeppelin/mainnet.json | 185 ++++++++++++++++++++++ spot-contracts/contracts/FeePolicy.sol | 8 +- spot-contracts/tasks/scripts/mainnet.sh | 3 +- spot-contracts/test/FeePolicy.ts | 19 --- 4 files changed, 188 insertions(+), 27 deletions(-) diff --git a/spot-contracts/.openzeppelin/mainnet.json b/spot-contracts/.openzeppelin/mainnet.json index e139eb59..7bbb2880 100644 --- a/spot-contracts/.openzeppelin/mainnet.json +++ b/spot-contracts/.openzeppelin/mainnet.json @@ -2840,6 +2840,191 @@ }, "namespaces": {} } + }, + "a0651b4cbe00a1624a6fc2c5b84c09b23347cbff34f3e4103c29fce3da7b9030": { + "address": "0xFad454b578a54c0602FB6D711F26fd701235FaB6", + "txHash": "0x6b08759f0988cf344fc4394829e8035a3427d2d166f58dc75bb7cc65fbac8ba6", + "layout": { + "solcVersion": "0.8.20", + "storage": [ + { + "label": "_initialized", + "offset": 0, + "slot": "0", + "type": "t_uint8", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:63", + "retypedFrom": "bool" + }, + { + "label": "_initializing", + "offset": 1, + "slot": "0", + "type": "t_bool", + "contract": "Initializable", + "src": "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:68" + }, + { + "label": "__gap", + "offset": 0, + "slot": "1", + "type": "t_array(t_uint256)50_storage", + "contract": "ContextUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:40" + }, + { + "label": "_owner", + "offset": 0, + "slot": "51", + "type": "t_address", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "label": "__gap", + "offset": 0, + "slot": "52", + "type": "t_array(t_uint256)49_storage", + "contract": "OwnableUpgradeable", + "src": "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "label": "targetSubscriptionRatio", + "offset": 0, + "slot": "101", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:80" + }, + { + "label": "deviationRatioBoundLower", + "offset": 0, + "slot": "102", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:83" + }, + { + "label": "deviationRatioBoundUpper", + "offset": 0, + "slot": "103", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:86" + }, + { + "label": "perpMintFeePerc", + "offset": 0, + "slot": "104", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:94" + }, + { + "label": "perpBurnFeePerc", + "offset": 0, + "slot": "105", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:97" + }, + { + "label": "perpRolloverFee", + "offset": 0, + "slot": "106", + "type": "t_struct(RolloverFeeSigmoidParams)5758_storage", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:109" + }, + { + "label": "vaultMintFeePerc", + "offset": 0, + "slot": "109", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:117" + }, + { + "label": "vaultBurnFeePerc", + "offset": 0, + "slot": "110", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:120" + }, + { + "label": "vaultUnderlyingToPerpSwapFeePerc", + "offset": 0, + "slot": "111", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:123" + }, + { + "label": "vaultPerpToUnderlyingSwapFeePerc", + "offset": 0, + "slot": "112", + "type": "t_uint256", + "contract": "FeePolicy", + "src": "contracts/FeePolicy.sol:126" + } + ], + "types": { + "t_address": { + "label": "address", + "numberOfBytes": "20" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]", + "numberOfBytes": "1568" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]", + "numberOfBytes": "1600" + }, + "t_bool": { + "label": "bool", + "numberOfBytes": "1" + }, + "t_int256": { + "label": "int256", + "numberOfBytes": "32" + }, + "t_struct(RolloverFeeSigmoidParams)5758_storage": { + "label": "struct FeePolicy.RolloverFeeSigmoidParams", + "members": [ + { + "label": "lower", + "type": "t_int256", + "offset": 0, + "slot": "0" + }, + { + "label": "upper", + "type": "t_int256", + "offset": 0, + "slot": "1" + }, + { + "label": "growth", + "type": "t_int256", + "offset": 0, + "slot": "2" + } + ], + "numberOfBytes": "96" + }, + "t_uint256": { + "label": "uint256", + "numberOfBytes": "32" + }, + "t_uint8": { + "label": "uint8", + "numberOfBytes": "1" + } + }, + "namespaces": {} + } } } } diff --git a/spot-contracts/contracts/FeePolicy.sol b/spot-contracts/contracts/FeePolicy.sol index 7376e105..42b5a497 100644 --- a/spot-contracts/contracts/FeePolicy.sol +++ b/spot-contracts/contracts/FeePolicy.sol @@ -67,10 +67,6 @@ contract FeePolicy is IFeePolicy, OwnableUpgradeable { /// @notice Fixed point representation of 1.0 or 100%. uint256 public constant ONE = (1 * 10 ** DECIMALS); - /// @notice Sigmoid asymptote bound. - /// @dev Set to 0.05 or 5%, i.e) the rollover fee can be at most 5% on either direction. - uint256 public constant SIGMOID_BOUND = ONE / 20; - /// @notice Target subscription ratio lower bound, 0.75 or 75%. uint256 public constant TARGET_SR_LOWER_BOUND = (ONE * 75) / 100; @@ -209,9 +205,7 @@ contract FeePolicy is IFeePolicy, OwnableUpgradeable { /// @notice Update the parameters determining the slope and asymptotes of the sigmoid fee curve. /// @param p Lower, Upper and Growth sigmoid paramters are fixed point numbers with {DECIMALS} places. function updatePerpRolloverFees(RolloverFeeSigmoidParams calldata p) external onlyOwner { - // If the bond duration is 28 days and 13 rollovers happen per year, - // perp can be inflated or enriched up to ~65% annually. - if (p.lower < -int256(SIGMOID_BOUND) || p.upper > int256(SIGMOID_BOUND) || p.lower > p.upper) { + if (p.lower > p.upper) { revert InvalidSigmoidAsymptotes(); } perpRolloverFee.lower = p.lower; diff --git a/spot-contracts/tasks/scripts/mainnet.sh b/spot-contracts/tasks/scripts/mainnet.sh index 1b6107cf..ef3ab9be 100644 --- a/spot-contracts/tasks/scripts/mainnet.sh +++ b/spot-contracts/tasks/scripts/mainnet.sh @@ -115,4 +115,5 @@ yarn hardhat --network mainnet validate_upgrade PerpetualTranche 0xC1f33e0cf7e40 yarn hardhat --network mainnet validate_upgrade RolloverVault 0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd yarn hardhat --network mainnet prepare_upgrade PerpetualTranche 0xC1f33e0cf7e40a67375007104B929E49a581bafE -yarn hardhat --network mainnet prepare_upgrade RolloverVault 0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd \ No newline at end of file +yarn hardhat --network mainnet prepare_upgrade RolloverVault 0x82A91a0D599A45d8E9Af781D67f695d7C72869Bd +yarn hardhat --network mainnet prepare_upgrade FeePolicy 0xE22977381506bF094CB3ed50CB8834E358F7ef6c \ No newline at end of file diff --git a/spot-contracts/test/FeePolicy.ts b/spot-contracts/test/FeePolicy.ts index b3eea137..8a3e5a86 100644 --- a/spot-contracts/test/FeePolicy.ts +++ b/spot-contracts/test/FeePolicy.ts @@ -174,25 +174,6 @@ describe("FeePolicy", function () { }); describe("when parameters are invalid", function () { - it("should revert", async function () { - await expect( - feePolicy.connect(deployer).updatePerpRolloverFees({ - lower: toPerc("-0.051"), - upper: toPerc("0.01"), - growth: toPerc("3"), - }), - ).to.be.revertedWithCustomError(feePolicy, "InvalidSigmoidAsymptotes"); - }); - it("should revert", async function () { - await expect( - feePolicy.connect(deployer).updatePerpRolloverFees({ - lower: toPerc("-0.01"), - upper: toPerc("0.051"), - growth: toPerc("3"), - }), - ).to.be.revertedWithCustomError(feePolicy, "InvalidSigmoidAsymptotes"); - }); - it("should revert", async function () { await expect( feePolicy.connect(deployer).updatePerpRolloverFees({