From f22bf4699596b09354dd18a21c00cd0e20972d2c Mon Sep 17 00:00:00 2001 From: max Date: Fri, 11 Aug 2023 10:48:57 +0100 Subject: [PATCH] added renouncePoolOwnership function --- markets/perps-market/storage.dump.sol | 26 +++++++++++++------ .../contracts/interfaces/IPoolModule.sol | 12 +++++++++ .../contracts/modules/core/PoolModule.sol | 15 +++++++++++ protocol/synthetix/storage.dump.sol | 8 +++++- 4 files changed, 52 insertions(+), 9 deletions(-) diff --git a/markets/perps-market/storage.dump.sol b/markets/perps-market/storage.dump.sol index 5579446c2d..b1f6dc9c36 100644 --- a/markets/perps-market/storage.dump.sol +++ b/markets/perps-market/storage.dump.sol @@ -423,10 +423,16 @@ interface IAsyncOrderSettlementModule { int128 newPositionSize; int128 sizeDelta; int256 pnl; + int256 accruedFunding; uint256 pnlUint; uint256 amountToDeduct; uint256 settlementReward; - PerpsMarketFactory.Data factory; + uint256 fillPrice; + uint256 totalFees; + uint256 referralFees; + uint256 feeCollectorFees; + Position.Data newPosition; + PerpsMarket.MarketUpdateData updateData; } } @@ -471,13 +477,8 @@ contract PerpsMarketFactoryModule { // @custom:artifact contracts/storage/AsyncOrder.sol:AsyncOrder library AsyncOrder { struct Data { - uint128 accountId; - uint128 marketId; - int128 sizeDelta; - uint128 settlementStrategyId; uint256 settlementTime; - uint256 acceptablePrice; - bytes32 trackingCode; + OrderCommitmentRequest request; } struct OrderCommitmentRequest { uint128 marketId; @@ -486,12 +487,18 @@ library AsyncOrder { uint128 settlementStrategyId; uint256 acceptablePrice; bytes32 trackingCode; + address referrer; } struct SimulateDataRuntime { + int128 sizeDelta; + uint128 accountId; + uint128 marketId; uint fillPrice; uint orderFees; uint availableMargin; uint currentLiquidationMargin; + uint accumulatedLiquidationRewards; + uint currentLiquidationReward; int128 newPositionSize; uint newNotionalValue; int currentAvailableMargin; @@ -530,6 +537,8 @@ library GlobalPerpsMarket { library GlobalPerpsMarketConfiguration { bytes32 private constant _SLOT_GLOBAL_PERPS_MARKET_CONFIGURATION = keccak256(abi.encode("io.synthetix.perps-market.GlobalPerpsMarketConfiguration")); struct Data { + address feeCollector; + mapping(address => uint256) referrerShare; mapping(uint128 => uint) maxCollateralAmounts; uint128[] synthDeductionPriority; uint minLiquidationRewardUsd; @@ -608,12 +617,13 @@ library PerpsMarketConfiguration { uint256 maxFundingVelocity; uint256 skewScale; uint256 initialMarginRatioD18; - uint256 maintenanceMarginRatioD18; + uint256 maintenanceMarginScalarD18; uint256 lockedOiRatioD18; uint256 maxLiquidationLimitAccumulationMultiplier; uint256 maxSecondsInLiquidationWindow; uint256 liquidationRewardRatioD18; uint256 minimumPositionMargin; + uint256 minimumInitialMarginRatioD18; } function load(uint128 marketId) internal pure returns (Data storage store) { bytes32 s = keccak256(abi.encode("io.synthetix.perps-market.PerpsMarketConfiguration", marketId)); diff --git a/protocol/synthetix/contracts/interfaces/IPoolModule.sol b/protocol/synthetix/contracts/interfaces/IPoolModule.sol index bda29dccfd..ac76830696 100644 --- a/protocol/synthetix/contracts/interfaces/IPoolModule.sol +++ b/protocol/synthetix/contracts/interfaces/IPoolModule.sol @@ -54,6 +54,12 @@ interface IPoolModule { */ event PoolNominationRenounced(uint128 indexed poolId, address indexed owner); + /** + * @notice Gets fired when pool owner renounces his own ownership. + * @param poolId The id of the pool for which the owner nomination was renounced. + */ + event PoolOwnershipRenounced(uint128 indexed poolId, address indexed owner); + /** * @notice Gets fired when pool name changes. * @param poolId The id of the pool whose name was updated. @@ -147,6 +153,12 @@ interface IPoolModule { */ function renouncePoolNomination(uint128 poolId) external; + /** + * @notice Allows the current owner to renounce his ownership. + * @param poolId The id of the pool for which the caller is renouncing ownership nomination. + */ + function renouncePoolOwnership(uint128 poolId) external; + /** * @notice Returns the current pool owner. * @param poolId The id of the pool whose ownership is being queried. diff --git a/protocol/synthetix/contracts/modules/core/PoolModule.sol b/protocol/synthetix/contracts/modules/core/PoolModule.sol index 93bed43105..7b378445a3 100644 --- a/protocol/synthetix/contracts/modules/core/PoolModule.sol +++ b/protocol/synthetix/contracts/modules/core/PoolModule.sol @@ -95,6 +95,21 @@ contract PoolModule is IPoolModule { emit PoolNominationRenounced(poolId, msg.sender); } + /** + * @inheritdoc IPoolModule + */ + function renouncePoolOwnership(uint128 poolId) external override { + Pool.Data storage pool = Pool.load(poolId); + + if (pool.owner != msg.sender) { + revert AccessError.Unauthorized(msg.sender); + } + + pool.owner = address(0); + + emit PoolOwnershipRenounced(poolId, msg.sender); + } + /** * @inheritdoc IPoolModule */ diff --git a/protocol/synthetix/storage.dump.sol b/protocol/synthetix/storage.dump.sol index da90361cdf..1bb8bc6792 100644 --- a/protocol/synthetix/storage.dump.sol +++ b/protocol/synthetix/storage.dump.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.4; +pragma solidity >=0.4.22<0.9.0; // @custom:artifact @synthetixio/core-contracts/contracts/ownership/OwnableStorage.sol:OwnableStorage library OwnableStorage { @@ -268,6 +268,7 @@ contract IssueUSDModule { bytes32 private constant _CONFIG_BURN_FEE_RATIO = "burnUsd_feeRatio"; bytes32 private constant _CONFIG_MINT_FEE_ADDRESS = "mintUsd_feeAddress"; bytes32 private constant _CONFIG_BURN_FEE_ADDRESS = "burnUsd_feeAddress"; + bytes32 private constant _CONFIG_TIMEOUT_BURN = "burnUsd_toAccount"; } // @custom:artifact contracts/modules/core/LiquidationModule.sol:LiquidationModule @@ -665,3 +666,8 @@ library CcipClient { bool strict; } } + +// @custom:artifact hardhat/console.sol:console +library console { + address internal constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67); +}