Skip to content

Commit

Permalink
added renouncePoolOwnership function
Browse files Browse the repository at this point in the history
  • Loading branch information
fritzschoff committed Aug 11, 2023
1 parent 5b06e5d commit f22bf46
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
26 changes: 18 additions & 8 deletions markets/perps-market/storage.dump.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
12 changes: 12 additions & 0 deletions protocol/synthetix/contracts/interfaces/IPoolModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions protocol/synthetix/contracts/modules/core/PoolModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
8 changes: 7 additions & 1 deletion protocol/synthetix/storage.dump.sol
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -665,3 +666,8 @@ library CcipClient {
bool strict;
}
}

// @custom:artifact hardhat/console.sol:console
library console {
address internal constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
}

0 comments on commit f22bf46

Please sign in to comment.