diff --git a/markets/perps-market/cannonfile.test.toml b/markets/perps-market/cannonfile.test.toml index 2cd216bc57..6b8dab8bd6 100644 --- a/markets/perps-market/cannonfile.test.toml +++ b/markets/perps-market/cannonfile.test.toml @@ -31,18 +31,12 @@ artifact = "AsyncOrderModule" [contract.AsyncOrderSettlementModule] artifact = "AsyncOrderSettlementModule" -[contract.AtomicOrderModule] -artifact = "AtomicOrderModule" - [contract.PerpsAccountModule] artifact = "PerpsAccountModule" [contract.PerpsMarketModule] artifact = "PerpsMarketModule" -[contract.LimitOrderModule] -artifact = "LimitOrderModule" - [contract.LiquidationModule] artifact = "LiquidationModule" @@ -74,11 +68,9 @@ contracts = [ "PerpsMarketFactoryModule", "PerpsAccountModule", "PerpsMarketModule", - "AtomicOrderModule", "AsyncOrderModule", "AsyncOrderSettlementModule", "FeatureFlagModule", - "LimitOrderModule", "LiquidationModule", "MarketConfigurationModule", "GlobalPerpsMarketModule" @@ -87,13 +79,11 @@ depends = [ "import.synthetix", "contract.CoreModule", "contract.PerpsMarketFactoryModule", - "contract.AtomicOrderModule", "contract.AsyncOrderModule", "contract.AsyncOrderSettlementModule", "contract.PerpsAccountModule", "contract.PerpsMarketModule", "contract.FeatureFlagModule", - "contract.LimitOrderModule", "contract.LiquidationModule", "contract.MarketConfigurationModule", "contract.GlobalPerpsMarketModule" diff --git a/markets/perps-market/cannonfile.toml b/markets/perps-market/cannonfile.toml index 7607f61041..4095bed3b8 100644 --- a/markets/perps-market/cannonfile.toml +++ b/markets/perps-market/cannonfile.toml @@ -31,18 +31,12 @@ artifact = "AsyncOrderModule" [contract.AsyncOrderSettlementModule] artifact = "AsyncOrderSettlementModule" -[contract.AtomicOrderModule] -artifact = "AtomicOrderModule" - [contract.PerpsAccountModule] artifact = "PerpsAccountModule" [contract.PerpsMarketModule] artifact = "PerpsMarketModule" -[contract.LimitOrderModule] -artifact = "LimitOrderModule" - [contract.LiquidationModule] artifact = "LiquidationModule" @@ -74,11 +68,9 @@ contracts = [ "PerpsMarketFactoryModule", "PerpsAccountModule", "PerpsMarketModule", - "AtomicOrderModule", "AsyncOrderModule", "AsyncOrderSettlementModule", "FeatureFlagModule", - "LimitOrderModule", "LiquidationModule", "MarketConfigurationModule", "GlobalPerpsMarketModule" @@ -87,13 +79,11 @@ depends = [ "import.synthetix", "contract.CoreModule", "contract.PerpsMarketFactoryModule", - "contract.AtomicOrderModule", "contract.AsyncOrderModule", "contract.AsyncOrderSettlementModule", "contract.PerpsAccountModule", "contract.PerpsMarketModule", "contract.FeatureFlagModule", - "contract.LimitOrderModule", "contract.LiquidationModule", "contract.MarketConfigurationModule", "contract.GlobalPerpsMarketModule" diff --git a/markets/perps-market/contracts/interfaces/IAccountModule.sol b/markets/perps-market/contracts/interfaces/IAccountModule.sol index 32557815bc..2c141e738d 100644 --- a/markets/perps-market/contracts/interfaces/IAccountModule.sol +++ b/markets/perps-market/contracts/interfaces/IAccountModule.sol @@ -7,25 +7,70 @@ import {AsyncOrder} from "../storage/AsyncOrder.sol"; * @title Account module */ interface IAccountModule { - error InvalidAmountDelta(int amountDelta); - + /** + * @notice Gets fired when an account colateral is modified. + * @param accountId Id of the account. + * @param synthMarketId Id of the synth market used as collateral. Synth market id, 0 for snxUSD. + * @param amountDelta requested change in amount of collateral delegated to the account. + * @param sender address of the sender of the size modification. Authorized by account owner. + */ event CollateralModified( uint128 indexed accountId, uint128 indexed synthMarketId, - int amountDelta, + int256 amountDelta, address indexed sender ); + /** + * @notice Gets thrown when the amount delta is zero. + */ + error InvalidAmountDelta(int amountDelta); + + /** + * @notice Modify the collateral delegated to the account. + * @param accountId Id of the account. + * @param synthMarketId Id of the synth market used as collateral. Synth market id, 0 for snxUSD. + * @param amountDelta requested change in amount of collateral delegated to the account. + */ function modifyCollateral(uint128 accountId, uint128 synthMarketId, int amountDelta) external; + /** + * @notice Gets the account's collateral value for a specific collateral. + * @param accountId Id of the account. + * @param synthMarketId Id of the synth market used as collateral. Synth market id, 0 for snxUSD. + * @return collateralValue collateral value of the account. + */ + function getCollateralAmount( + uint128 accountId, + uint128 synthMarketId + ) external view returns (uint256); + + /** + * @notice Gets the account's total collateral value. + * @param accountId Id of the account. + * @return collateralValue total collateral value of the account. USD denominated. + */ function totalCollateralValue(uint128 accountId) external view returns (uint); + /** + * @notice Gets the account's total open interest value. + * @param accountId Id of the account. + * @return openInterestValue total open interest value of the account. + */ function totalAccountOpenInterest(uint128 accountId) external view returns (uint); + /** + * @notice Gets the details of an open position. + * @param accountId Id of the account. + * @param marketId Id of the position market. + * @return pnl pnl of the position. + * @return accruedFunding accrued funding of the position. + * @return size size of the position. + */ function getOpenPosition( uint128 accountId, uint128 marketId - ) external view returns (int, int, int); + ) external view returns (int pnl, int accruedFunding, int size); /** * @notice Get async order claim details @@ -38,10 +83,10 @@ interface IAccountModule { uint128 marketId ) external view returns (AsyncOrder.Data memory); + /** + * @notice Gets the available margin of an account. It can be negative due to pnl. + * @param accountId Id of the account. + * @return availableMargin available margin of the position. + */ function getAvailableMargin(uint128 accountId) external view returns (int); - - function getCollateralAmount( - uint128 accountId, - uint128 synthMarketId - ) external view returns (uint256); } diff --git a/markets/perps-market/contracts/interfaces/IAsyncOrderModule.sol b/markets/perps-market/contracts/interfaces/IAsyncOrderModule.sol index 5ebfd07873..c176a85573 100644 --- a/markets/perps-market/contracts/interfaces/IAsyncOrderModule.sol +++ b/markets/perps-market/contracts/interfaces/IAsyncOrderModule.sol @@ -8,6 +8,18 @@ import {SettlementStrategy} from "../storage/SettlementStrategy.sol"; * @title Module for committing and settling async orders. */ interface IAsyncOrderModule { + /** + * @notice Gets fired when a new order is committed. + * @param marketId Id of the market used for the trade. + * @param accountId Id of the account used for the trade. + * @param orderType Should send 0 (at time of writing) that correlates to the transaction type enum defined in SettlementStrategy.Type. + * @param sizeDelta requested change in size of the order sent by the user. + * @param acceptablePrice maximum or minimum, depending on the sizeDelta direction, accepted price to settle the order, set by the user. + * @param settlementTime Time at which the order can be settled. + * @param expirationTime Time at which the order expired. + * @param trackingCode Optional code for integrator tracking purposes. + * @param sender address of the sender of the order. Authorized to commit by account owner. + */ event OrderCommitted( uint128 indexed marketId, uint128 indexed accountId, @@ -20,6 +32,14 @@ interface IAsyncOrderModule { address sender ); + /** + * @notice Gets fired when a new order is canceled. + * @param marketId Id of the market used for the trade. + * @param accountId Id of the account used for the trade. + * @param acceptablePrice maximum or minimum, depending on the sizeDelta direction, accepted price to settle the order, set by the user. + * @param settlementTime Time at which the order can be settled. + */ + event OrderCanceled( uint128 indexed marketId, uint128 indexed accountId, @@ -27,16 +47,36 @@ interface IAsyncOrderModule { uint256 acceptablePrice ); + /** + * @notice Gets thrown when commit order is called when a pending order already exists. + */ error OrderAlreadyCommitted(uint128 marketId, uint128 accountId); + /** + * @notice Commit an async order via this function + * @param commitment Order commitment data (see AsyncOrder.OrderCommitmentRequest struct). + * @return retOrder order details (see AsyncOrder.Data struct). + * @return fees order fees (protocol + settler) + */ function commitOrder( AsyncOrder.OrderCommitmentRequest memory commitment ) external returns (AsyncOrder.Data memory retOrder, uint fees); + /** + * @notice Cancel an expired order via this function + * @param marketId Id of the market used for the trade. + * @param accountId Id of the account used for the trade. + */ + function cancelOrder(uint128 marketId, uint128 accountId) external; + + /** + * @notice Get an order details via this function + * @param marketId Id of the market used for the trade. + * @param accountId Id of the account used for the trade. + * @return order order details (see AsyncOrder.Data struct). + */ function getOrder( uint128 marketId, uint128 accountId - ) external returns (AsyncOrder.Data memory); - - function cancelOrder(uint128 marketId, uint128 accountId) external; + ) external returns (AsyncOrder.Data memory order); } diff --git a/markets/perps-market/contracts/interfaces/IAsyncOrderSettlementModule.sol b/markets/perps-market/contracts/interfaces/IAsyncOrderSettlementModule.sol index 012d8da767..ac962c609c 100644 --- a/markets/perps-market/contracts/interfaces/IAsyncOrderSettlementModule.sol +++ b/markets/perps-market/contracts/interfaces/IAsyncOrderSettlementModule.sol @@ -3,7 +3,13 @@ pragma solidity >=0.8.11 <0.9.0; import {SettlementStrategy} from "../storage/SettlementStrategy.sol"; interface IAsyncOrderSettlementModule { + /** + * @notice Gets thrown when settle order is called with invalid settlement strategy. + */ error SettlementStrategyNotFound(SettlementStrategy.Type strategyType); + /** + * @notice Gets thrown when settle order is called as a signal to the client to perform offchain lookup. + */ error OffchainLookup( address sender, string[] urls, @@ -12,6 +18,18 @@ interface IAsyncOrderSettlementModule { bytes extraData ); + /** + * @notice Gets fired when a new order is settled. + * @param marketId Id of the market used for the trade. + * @param accountId Id of the account used for the trade. + * @param fillPrice Price at which the order was settled. + * @param accountPnlRealized Realized PnL of the position at the time of settlement. + * @param newSize New size of the position after settlement. + * @param collectedFees Amount of fees collected by the protocol. + * @param settelementReward Amount of fees collected by the settler. + * @param trackingCode Optional code for integrator tracking purposes. + * @param settler address of the settler of the order. + */ event OrderSettled( uint128 indexed marketId, uint128 indexed accountId, @@ -36,7 +54,17 @@ interface IAsyncOrderSettlementModule { bytes32 trackingCode; } + /** + * @notice Settles an offchain order. It's expected to revert with the OffchainLookup error with the data needed to perform the offchain lookup. + * @param marketId Id of the market used for the trade. + * @param accountId Id of the account used for the trade. + */ function settle(uint128 marketId, uint128 accountId) external view; + /** + * @notice Settles an offchain order using the offchain retrieved data from pyth. + * @param result the blob of data retrieved offchain. + * @param extraData Extra data from OffchainLookupData. + */ function settlePythOrder(bytes calldata result, bytes calldata extraData) external payable; } diff --git a/markets/perps-market/contracts/interfaces/ICollateralModule.sol b/markets/perps-market/contracts/interfaces/ICollateralModule.sol index ea93a0403c..af7cd29034 100644 --- a/markets/perps-market/contracts/interfaces/ICollateralModule.sol +++ b/markets/perps-market/contracts/interfaces/ICollateralModule.sol @@ -1,13 +1,21 @@ //SPDX-License-Identifier: MIT pragma solidity >=0.8.11 <0.9.0; +/** + * @title Module for setting max collateral distribution. + */ interface ICollateralModule { /** - * @notice Gets fired when max collateral amount for synth is set by owner. - * @param synthId Synth market id, 0 for snxUSD. - * @param maxCollateralAmount max amount that was set for the synth + * @notice Gets fired when max collateral amount for synth collateral for the system is set by owner. + * @param synthMarketId Synth market id, 0 for snxUSD. + * @param collateralAmount max amount that was set for the synth */ - event MaxCollateralSet(uint128 indexed synthId, uint256 maxCollateralAmount); + event MaxCollateralSet(uint128 indexed synthMarketId, uint256 collateralAmount); - function setMaxCollateralAmount(uint128 synthId, uint maxCollateralAmount) external; + /** + * @notice Set the max collateral amoutn via this function + * @param synthMarketId Synth market id, 0 for snxUSD. + * @param collateralAmount max amount that for the synth + */ + function setMaxCollateralAmount(uint128 synthMarketId, uint collateralAmount) external; } diff --git a/markets/perps-market/contracts/interfaces/IGlobalPerpsMarketModule.sol b/markets/perps-market/contracts/interfaces/IGlobalPerpsMarketModule.sol index 781e9236d3..fa95e0fa07 100644 --- a/markets/perps-market/contracts/interfaces/IGlobalPerpsMarketModule.sol +++ b/markets/perps-market/contracts/interfaces/IGlobalPerpsMarketModule.sol @@ -1,27 +1,76 @@ //SPDX-License-Identifier: MIT pragma solidity >=0.8.11 <0.9.0; +/** + * @title Module for global Perps Market settings. + */ interface IGlobalPerpsMarketModule { + /** + * @notice Gets fired when max collateral amount for synth for all the markets is set by owner. + * @param synthMarketId Synth market id, 0 for snxUSD. + * @param collateralAmount max amount that was set for the synth + */ event MaxCollateralAmountSet(uint128 indexed synthMarketId, uint256 collateralAmount); + + /** + * @notice Gets fired when the synth deduction priority is updated by owner. + * @param newSynthDeductionPriority new synth id priority order for deductions. + */ event SynthDeductionPrioritySet(uint128[] newSynthDeductionPriority); + + /** + * @notice Gets fired when liquidation reward guard is set or updated. + * @param minLiquidationRewardUsd Minimum liquidation reward expressed as USD value. + * @param maxLiquidationRewardUsd Maximum liquidation reward expressed as USD value. + */ event LiquidationRewardGuardsSet( uint256 indexed minLiquidationRewardUsd, uint256 indexed maxLiquidationRewardUsd ); - function getMaxCollateralAmount(uint128 synthMarketId) external view returns (uint); - + /** + * @notice Sets the max collateral amount for a specific synth market. + * @param synthMarketId Synth market id, 0 for snxUSD. + * @param collateralAmount Max collateral amount to set for the synth market id. + */ function setMaxCollateralAmount(uint128 synthMarketId, uint collateralAmount) external; + /** + * @notice Gets the max collateral amount for a specific synth market. + * @param synthMarketId Synth market id, 0 for snxUSD. + * @return maxCollateralAmount max collateral amount of the specified synth market id + */ + function getMaxCollateralAmount(uint128 synthMarketId) external view returns (uint); + + /** + * @notice Sets the synth deduction priority ordered list. + * @dev The synth deduction priority is used to determine the order in which synths are deducted from an account. Id 0 is snxUSD and should be first in the list. + * @param newSynthDeductionPriority Ordered array of synth market ids for deduction priority. + */ function setSynthDeductionPriority(uint128[] memory newSynthDeductionPriority) external; + /** + * @notice Gets the synth deduction priority ordered list. + * @dev The synth deduction priority is used to determine the order in which synths are deducted from an account. Id 0 is snxUSD and should be first in the list. + * @return synthDeductionPriority Ordered array of synth market ids for deduction priority. + */ function getSynthDeductionPriority() external view returns (uint128[] memory); + /** + * @notice Sets the liquidation reward guard (min and max). + * @param minLiquidationRewardUsd Minimum liquidation reward expressed as USD value. + * @param maxLiquidationRewardUsd Maximum liquidation reward expressed as USD value. + */ function setLiquidationRewardGuards( uint256 minLiquidationRewardUsd, uint256 maxLiquidationRewardUsd ) external; + /** + * @notice Gets the liquidation reward guard (min and max). + * @return minLiquidationRewardUsd Minimum liquidation reward expressed as USD value. + * @return maxLiquidationRewardUsd Maximum liquidation reward expressed as USD value. + */ function getLiquidationRewardGuards() external view diff --git a/markets/perps-market/contracts/interfaces/ILimitOrderModule.sol b/markets/perps-market/contracts/interfaces/ILimitOrderModule.sol deleted file mode 100644 index 130505dd78..0000000000 --- a/markets/perps-market/contracts/interfaces/ILimitOrderModule.sol +++ /dev/null @@ -1,7 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity >=0.8.11 <0.9.0; - -// solhint-disable-next-line no-empty-blocks -interface ILimitOrderModule { - -} diff --git a/markets/perps-market/contracts/interfaces/IMarketConfigurationModule.sol b/markets/perps-market/contracts/interfaces/IMarketConfigurationModule.sol index b148a4787f..3a338b9eee 100644 --- a/markets/perps-market/contracts/interfaces/IMarketConfigurationModule.sol +++ b/markets/perps-market/contracts/interfaces/IMarketConfigurationModule.sol @@ -21,12 +21,36 @@ interface IMarketConfigurationModule { uint256 indexed strategyId ); + /** + * @notice Gets fired when order fees are updated. + * @param marketId udpates fees to this specific market. + * @param makerFeeRatio the maker fee ratio. + * @param takerFeeRatio the taker fee ratio. + */ event OrderFeesSet(uint128 indexed marketId, uint256 makerFeeRatio, uint256 takerFeeRatio); + + /** + * @notice Gets fired when funding parameters are updated. + * @param marketId udpates funding parameters to this specific market. + * @param skewScale the skew scale. + * @param maxFundingVelocity the max funding velocity. + */ event FundingParametersSet( uint128 indexed marketId, uint256 skewScale, uint256 maxFundingVelocity ); + + /** + * @notice Gets fired when liquidation parameters are updated. + * @param marketId udpates funding parameters to this specific market. + * @param initialMarginRatioD18 the initial margin ratio (as decimal with 18 digits precision). + * @param maintenanceMarginRatioD18 the maintenance margin ratio (as decimal with 18 digits precision). + * @param liquidationRewardRatioD18 the liquidation reward ratio (as decimal with 18 digits precision). + * @param maxLiquidationLimitAccumulationMultiplier the max liquidation limit accumulation multiplier. + * @param maxSecondsInLiquidationWindow the max seconds in liquidation window (used together with the acc multiplier to get max liquidation per window). + * @param minimumPositionMargin the minimum position margin. + */ event LiquidationParametersSet( uint128 indexed marketId, uint256 initialMarginRatioD18, @@ -36,23 +60,70 @@ interface IMarketConfigurationModule { uint256 maxSecondsInLiquidationWindow, uint256 minimumPositionMargin ); - event MaxMarketValueSet(uint128 indexed marketId, uint256 maxMarketValue); + + /** + * @notice Gets fired when max market value is updated. + * @param marketId udpates funding parameters to this specific market. + * @param maxMarketSize the max market value. + */ + event MaxMarketSizeSet(uint128 indexed marketId, uint256 maxMarketSize); + + /** + * @notice Gets fired when locked oi ratio is updated. + * @param marketId udpates funding parameters to this specific market. + * @param lockedOiRatioD18 the locked OI ratio skew scale (as decimal with 18 digits precision). + */ event LockedOiRatioD18Set(uint128 indexed marketId, uint256 lockedOiRatioD18); + + /** + * @notice Gets fired when a settlement strategy is enabled or disabled. + * @param marketId udpates funding parameters to this specific market. + * @param strategyId the specific strategy. + * @param enabled whether the strategy is enabled or disabled. + */ event SettlementStrategyEnabled(uint128 indexed marketId, uint256 strategyId, bool enabled); + /** + * @notice Add a new settlement strategy with this function. + * @param marketId id of the market to add the settlement strategy. + * @param strategy strategy details (see SettlementStrategy.Data struct). + * @return strategyId id of the new settlement strategy. + */ function addSettlementStrategy( uint128 marketId, SettlementStrategy.Data memory strategy ) external returns (uint256 strategyId); + /** + * @notice Set order fees for a market with this function. + * @param marketId id of the market to set order fees. + * @param makerFeeRatio the maker fee ratio. + * @param takerFeeRatio the taker fee ratio. + */ function setOrderFees(uint128 marketId, uint256 makerFeeRatio, uint256 takerFeeRatio) external; + /** + * @notice Set funding parameters for a market with this function. + * @param marketId id of the market to set funding parameters. + * @param skewScale the skew scale. + * @param maxFundingVelocity the max funding velocity. + */ function setFundingParameters( uint128 marketId, uint256 skewScale, uint256 maxFundingVelocity ) external; + /** + * @notice Set liquidation parameters for a market with this function. + * @param marketId id of the market to set liquidation parameters. + * @param initialMarginRatioD18 the initial margin ratio (as decimal with 18 digits precision). + * @param maintenanceMarginRatioD18 the maintenance margin ratio (as decimal with 18 digits precision). + * @param liquidationRewardRatioD18 the liquidation reward ratio (as decimal with 18 digits precision). + * @param maxLiquidationLimitAccumulationMultiplier the max liquidation limit accumulation multiplier. + * @param maxSecondsInLiquidationWindow the max seconds in liquidation window (used together with the acc multiplier to get max liquidation per window). + * @param minimumPositionMargin the minimum position margin. + */ function setLiquidationParameters( uint128 marketId, uint256 initialMarginRatioD18, @@ -63,21 +134,53 @@ interface IMarketConfigurationModule { uint256 minimumPositionMargin ) external; - function setMaxMarketValue(uint128 marketId, uint256 maxMarketValue) external; + /** + * @notice Set the max size of an specific market with this function. + * @dev This controls the maximum open interest a market can have on either side (Long | Short). So the total Open Interest (with zero skew) for a market can be up to max market size * 2. + * @param marketId id of the market to set the max market value. + * @param maxMarketSize the max market size in market asset units. + */ + function setMaxMarketSize(uint128 marketId, uint256 maxMarketSize) external; + /** + * @notice Set the locked OI Ratio for a market with this function. + * @param marketId id of the market to set locked OI ratio. + * @param lockedOiRatioD18 the locked OI ratio skew scale (as decimal with 18 digits precision). + */ function setLockedOiRatio(uint128 marketId, uint256 lockedOiRatioD18) external; + /** + * @notice Enable or disable a settlement strategy for a market with this function. + * @param marketId id of the market. + * @param strategyId the specific strategy. + * @param enabled whether the strategy is enabled or disabled. + */ function setSettlementStrategyEnabled( uint128 marketId, uint256 strategyId, bool enabled ) external; + /** + * @notice Gets the settlement strategy details. + * @param marketId id of the market. + * @param strategyId id of the settlement strategy. + * @return settlementStrategy strategy details (see SettlementStrategy.Data struct). + */ function getSettlementStrategy( uint128 marketId, uint256 strategyId ) external view returns (SettlementStrategy.Data memory settlementStrategy); + /** + * @notice Gets liquidation parameters details of a market. + * @param marketId id of the market. + * @return initialMarginRatioD18 the initial margin ratio (as decimal with 18 digits precision). + * @return maintenanceMarginRatioD18 the maintenance margin ratio (as decimal with 18 digits precision). + * @return liquidationRewardRatioD18 the liquidation reward ratio (as decimal with 18 digits precision). + * @return maxLiquidationLimitAccumulationMultiplier the max liquidation limit accumulation multiplier. + * @return maxSecondsInLiquidationWindow the max seconds in liquidation window (used together with the acc multiplier to get max liquidation per window). + */ function getLiquidationParameters( uint128 marketId ) @@ -91,15 +194,37 @@ interface IMarketConfigurationModule { uint256 maxSecondsInLiquidationWindow ); + /** + * @notice Gets funding parameters of a market. + * @param marketId id of the market. + * @return skewScale the skew scale. + * @return maxFundingVelocity the max funding velocity. + */ function getFundingParameters( uint128 marketId ) external view returns (uint256 skewScale, uint256 maxFundingVelocity); - function getMaxMarketValue(uint128 marketId) external view returns (uint256 maxMarketValue); + /** + * @notice Gets the max size of an specific market. + * @param marketId id of the market. + * @return maxMarketSize the max market size in market asset units. + */ + function getMaxMarketSize(uint128 marketId) external view returns (uint256 maxMarketSize); + /** + * @notice Gets the order fees of a market. + * @param marketId id of the market. + * @return makerFeeRatio the maker fee ratio. + * @return takerFeeRatio the taker fee ratio. + */ function getOrderFees( uint128 marketId - ) external view returns (uint256 makerFee, uint256 takerFee); + ) external view returns (uint256 makerFeeRatio, uint256 takerFeeRatio); + /** + * @notice Gets the locked OI ratio of a market. + * @param marketId id of the market. + * @return lockedOiRatioD18 the locked OI ratio skew scale (as decimal with 18 digits precision). + */ function getLockedOiRatioD18(uint128 marketId) external view returns (uint256 lockedOiRatioD18); } diff --git a/markets/perps-market/contracts/modules/AsyncOrderModule.sol b/markets/perps-market/contracts/modules/AsyncOrderModule.sol index 49be03d74e..8111d75cda 100644 --- a/markets/perps-market/contracts/modules/AsyncOrderModule.sol +++ b/markets/perps-market/contracts/modules/AsyncOrderModule.sol @@ -18,6 +18,10 @@ import {PerpsMarketConfiguration} from "../storage/PerpsMarketConfiguration.sol" import {SettlementStrategy} from "../storage/SettlementStrategy.sol"; import {PerpsMarketFactory} from "../storage/PerpsMarketFactory.sol"; +/** + * @title Module for committing and settling async orders. + * @dev See IAsyncOrderModule. + */ contract AsyncOrderModule is IAsyncOrderModule { using DecimalMath for int256; using DecimalMath for uint256; @@ -34,6 +38,9 @@ contract AsyncOrderModule is IAsyncOrderModule { using SafeCastU256 for uint256; using SafeCastI256 for int256; + /** + * @inheritdoc IAsyncOrderModule + */ function commitOrder( AsyncOrder.OrderCommitmentRequest memory commitment ) external override returns (AsyncOrder.Data memory retOrder, uint fees) { @@ -84,6 +91,9 @@ contract AsyncOrderModule is IAsyncOrderModule { return (order, feesAccrued); } + /** + * @inheritdoc IAsyncOrderModule + */ function getOrder( uint128 marketId, uint128 accountId @@ -91,6 +101,9 @@ contract AsyncOrderModule is IAsyncOrderModule { return PerpsMarket.loadValid(marketId).asyncOrders[accountId]; } + /** + * @inheritdoc IAsyncOrderModule + */ function cancelOrder(uint128 marketId, uint128 accountId) external override { AsyncOrder.Data storage order = PerpsMarket.loadValid(marketId).asyncOrders[accountId]; order.checkValidity(); diff --git a/markets/perps-market/contracts/modules/AsyncOrderSettlementModule.sol b/markets/perps-market/contracts/modules/AsyncOrderSettlementModule.sol index 084a3884a5..18bf2a7d75 100644 --- a/markets/perps-market/contracts/modules/AsyncOrderSettlementModule.sol +++ b/markets/perps-market/contracts/modules/AsyncOrderSettlementModule.sol @@ -38,6 +38,9 @@ contract AsyncOrderSettlementModule is IAsyncOrderSettlementModule, IMarketEvent int256 public constant PRECISION = 18; + /** + * @inheritdoc IAsyncOrderSettlementModule + */ function settle(uint128 marketId, uint128 accountId) external view { GlobalPerpsMarket.load().checkLiquidation(accountId); ( @@ -48,6 +51,9 @@ contract AsyncOrderSettlementModule is IAsyncOrderSettlementModule, IMarketEvent _settleOffchain(order, settlementStrategy); } + /** + * @inheritdoc IAsyncOrderSettlementModule + */ function settlePythOrder(bytes calldata result, bytes calldata extraData) external payable { (uint128 marketId, uint128 asyncOrderId) = abi.decode(extraData, (uint128, uint128)); ( @@ -78,6 +84,9 @@ contract AsyncOrderSettlementModule is IAsyncOrderSettlementModule, IMarketEvent _settleOrder(offchainPrice, order, settlementStrategy); } + /** + * @dev used for settleing offchain orders. This will revert with OffchainLookup. + */ function _settleOffchain( AsyncOrder.Data storage asyncOrder, SettlementStrategy.Data storage settlementStrategy @@ -102,6 +111,9 @@ contract AsyncOrderSettlementModule is IAsyncOrderSettlementModule, IMarketEvent ); } + /** + * @dev used for settleing an order. + */ function _settleOrder( uint256 price, AsyncOrder.Data storage asyncOrder, @@ -185,6 +197,9 @@ contract AsyncOrderSettlementModule is IAsyncOrderSettlementModule, IMarketEvent ); } + /** + * @dev performs the order validity checks (existance and timing). + */ function _performOrderValidityChecks( uint128 marketId, uint128 accountId @@ -200,6 +215,9 @@ contract AsyncOrderSettlementModule is IAsyncOrderSettlementModule, IMarketEvent return (order, settlementStrategy); } + /** + * @dev converts the settlement time into bytes8. + */ function _getTimeInBytes(uint256 settlementTime) private pure returns (bytes8) { bytes32 settlementTimeBytes = bytes32(abi.encode(settlementTime)); @@ -207,7 +225,9 @@ contract AsyncOrderSettlementModule is IAsyncOrderSettlementModule, IMarketEvent return bytes8(settlementTimeBytes << 192); } - // borrowed from PythNode.sol + /** + * @dev gets scaled price. Borrowed from PythNode.sol. + */ function _getScaledPrice(int64 price, int32 expo) private pure returns (int256) { int256 factor = PRECISION + expo; return factor > 0 ? price.upscale(factor.toUint()) : price.downscale((-factor).toUint()); diff --git a/markets/perps-market/contracts/modules/AtomicOrderModule.sol b/markets/perps-market/contracts/modules/AtomicOrderModule.sol deleted file mode 100644 index 9e0a90303b..0000000000 --- a/markets/perps-market/contracts/modules/AtomicOrderModule.sol +++ /dev/null @@ -1,4 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity >=0.8.11 <0.9.0; - -contract AtomicOrderModule {} diff --git a/markets/perps-market/contracts/modules/CoreModule.sol b/markets/perps-market/contracts/modules/CoreModule.sol index c5dd32bb82..0fdf35430a 100644 --- a/markets/perps-market/contracts/modules/CoreModule.sol +++ b/markets/perps-market/contracts/modules/CoreModule.sol @@ -3,6 +3,10 @@ pragma solidity >=0.8.11 <0.9.0; import {CoreModule as BaseCoreModule} from "@synthetixio/core-modules/contracts/modules/CoreModule.sol"; +/** + * @title Module that defines ownership and upgradability. + * See core-modules/../CoreModule + */ // solhint-disable-next-line no-empty-blocks contract CoreModule is BaseCoreModule { diff --git a/markets/perps-market/contracts/modules/GlobalPerpsMarketModule.sol b/markets/perps-market/contracts/modules/GlobalPerpsMarketModule.sol index 0f980edc71..8f3ad29ac5 100644 --- a/markets/perps-market/contracts/modules/GlobalPerpsMarketModule.sol +++ b/markets/perps-market/contracts/modules/GlobalPerpsMarketModule.sol @@ -5,9 +5,16 @@ import {GlobalPerpsMarketConfiguration} from "../storage/GlobalPerpsMarketConfig import {IGlobalPerpsMarketModule} from "../interfaces/IGlobalPerpsMarketModule.sol"; import {OwnableStorage} from "@synthetixio/core-contracts/contracts/ownership/OwnableStorage.sol"; +/** + * @title Module for global Perps Market settings. + * @dev See IGlobalPerpsMarketModule. + */ contract GlobalPerpsMarketModule is IGlobalPerpsMarketModule { using GlobalPerpsMarketConfiguration for GlobalPerpsMarketConfiguration.Data; + /** + * @inheritdoc IGlobalPerpsMarketModule + */ function setMaxCollateralAmount( uint128 synthMarketId, uint collateralAmount @@ -19,10 +26,16 @@ contract GlobalPerpsMarketModule is IGlobalPerpsMarketModule { emit MaxCollateralAmountSet(synthMarketId, collateralAmount); } + /** + * @inheritdoc IGlobalPerpsMarketModule + */ function getMaxCollateralAmount(uint128 synthMarketId) external view override returns (uint) { return GlobalPerpsMarketConfiguration.load().maxCollateralAmounts[synthMarketId]; } + /** + * @inheritdoc IGlobalPerpsMarketModule + */ function setSynthDeductionPriority( uint128[] memory newSynthDeductionPriority ) external override { @@ -33,10 +46,16 @@ contract GlobalPerpsMarketModule is IGlobalPerpsMarketModule { emit SynthDeductionPrioritySet(newSynthDeductionPriority); } + /** + * @inheritdoc IGlobalPerpsMarketModule + */ function getSynthDeductionPriority() external view override returns (uint128[] memory) { return GlobalPerpsMarketConfiguration.load().synthDeductionPriority; } + /** + * @inheritdoc IGlobalPerpsMarketModule + */ function setLiquidationRewardGuards( uint256 minLiquidationRewardUsd, uint256 maxLiquidationRewardUsd @@ -49,6 +68,9 @@ contract GlobalPerpsMarketModule is IGlobalPerpsMarketModule { emit LiquidationRewardGuardsSet(minLiquidationRewardUsd, maxLiquidationRewardUsd); } + /** + * @inheritdoc IGlobalPerpsMarketModule + */ function getLiquidationRewardGuards() external view diff --git a/markets/perps-market/contracts/modules/LimitOrderModule.sol b/markets/perps-market/contracts/modules/LimitOrderModule.sol deleted file mode 100644 index fdc3f5935e..0000000000 --- a/markets/perps-market/contracts/modules/LimitOrderModule.sol +++ /dev/null @@ -1,6 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity >=0.8.11 <0.9.0; - -import "../interfaces/ILimitOrderModule.sol"; - -contract LimitOrderModule is ILimitOrderModule {} diff --git a/markets/perps-market/contracts/modules/MarketConfigurationModule.sol b/markets/perps-market/contracts/modules/MarketConfigurationModule.sol index ee5e933db2..94ad50c28b 100644 --- a/markets/perps-market/contracts/modules/MarketConfigurationModule.sol +++ b/markets/perps-market/contracts/modules/MarketConfigurationModule.sol @@ -7,9 +7,16 @@ import {PerpsMarketConfiguration} from "../storage/PerpsMarketConfiguration.sol" import {PerpsMarket} from "../storage/PerpsMarket.sol"; import {OrderFee} from "../storage/OrderFee.sol"; +/** + * @title Module for updating configuration in relation to async order modules. + * @dev See IMarketConfigurationModule. + */ contract MarketConfigurationModule is IMarketConfigurationModule { using PerpsMarket for PerpsMarket.Data; + /** + * @inheritdoc IMarketConfigurationModule + */ function addSettlementStrategy( uint128 marketId, SettlementStrategy.Data memory strategy @@ -25,6 +32,9 @@ contract MarketConfigurationModule is IMarketConfigurationModule { emit SettlementStrategyAdded(marketId, strategy, strategyId); } + /** + * @inheritdoc IMarketConfigurationModule + */ function setSettlementStrategyEnabled( uint128 marketId, uint256 strategyId, @@ -38,6 +48,9 @@ contract MarketConfigurationModule is IMarketConfigurationModule { emit SettlementStrategyEnabled(marketId, strategyId, enabled); } + /** + * @inheritdoc IMarketConfigurationModule + */ function setOrderFees( uint128 marketId, uint256 makerFeeRatio, @@ -50,13 +63,19 @@ contract MarketConfigurationModule is IMarketConfigurationModule { emit OrderFeesSet(marketId, makerFeeRatio, takerFeeRatio); } - function setMaxMarketValue(uint128 marketId, uint256 maxMarketValue) external override { + /** + * @inheritdoc IMarketConfigurationModule + */ + function setMaxMarketSize(uint128 marketId, uint256 maxMarketSize) external override { PerpsMarket.load(marketId).onlyMarketOwner(); PerpsMarketConfiguration.Data storage config = PerpsMarketConfiguration.load(marketId); - config.maxMarketValue = maxMarketValue; - emit MaxMarketValueSet(marketId, maxMarketValue); + config.maxMarketSize = maxMarketSize; + emit MaxMarketSizeSet(marketId, maxMarketSize); } + /** + * @inheritdoc IMarketConfigurationModule + */ function setFundingParameters( uint128 marketId, uint256 skewScale, @@ -70,6 +89,9 @@ contract MarketConfigurationModule is IMarketConfigurationModule { emit FundingParametersSet(marketId, skewScale, maxFundingVelocity); } + /** + * @inheritdoc IMarketConfigurationModule + */ function setLiquidationParameters( uint128 marketId, uint256 initialMarginRatioD18, @@ -101,6 +123,9 @@ contract MarketConfigurationModule is IMarketConfigurationModule { ); } + /** + * @inheritdoc IMarketConfigurationModule + */ function setLockedOiRatio(uint128 marketId, uint256 lockedOiRatioD18) external override { PerpsMarket.load(marketId).onlyMarketOwner(); PerpsMarketConfiguration.Data storage config = PerpsMarketConfiguration.load(marketId); @@ -108,6 +133,9 @@ contract MarketConfigurationModule is IMarketConfigurationModule { emit LockedOiRatioD18Set(marketId, lockedOiRatioD18); } + /** + * @inheritdoc IMarketConfigurationModule + */ function getSettlementStrategy( uint128 marketId, uint256 strategyId @@ -115,6 +143,9 @@ contract MarketConfigurationModule is IMarketConfigurationModule { return PerpsMarketConfiguration.load(marketId).settlementStrategies[strategyId]; } + /** + * @inheritdoc IMarketConfigurationModule + */ function getLiquidationParameters( uint128 marketId ) @@ -139,6 +170,9 @@ contract MarketConfigurationModule is IMarketConfigurationModule { maxSecondsInLiquidationWindow = config.maxSecondsInLiquidationWindow; } + /** + * @inheritdoc IMarketConfigurationModule + */ function getFundingParameters( uint128 marketId ) external view override returns (uint256 skewScale, uint256 maxFundingVelocity) { @@ -148,14 +182,20 @@ contract MarketConfigurationModule is IMarketConfigurationModule { maxFundingVelocity = config.maxFundingVelocity; } - function getMaxMarketValue( + /** + * @inheritdoc IMarketConfigurationModule + */ + function getMaxMarketSize( uint128 marketId - ) external view override returns (uint256 maxMarketValue) { + ) external view override returns (uint256 maxMarketSize) { PerpsMarketConfiguration.Data storage config = PerpsMarketConfiguration.load(marketId); - maxMarketValue = config.maxMarketValue; + maxMarketSize = config.maxMarketSize; } + /** + * @inheritdoc IMarketConfigurationModule + */ function getOrderFees( uint128 marketId ) external view override returns (uint256 makerFee, uint256 takerFee) { @@ -165,6 +205,9 @@ contract MarketConfigurationModule is IMarketConfigurationModule { takerFee = config.orderFees.takerFee; } + /** + * @inheritdoc IMarketConfigurationModule + */ function getLockedOiRatioD18(uint128 marketId) external view override returns (uint256) { PerpsMarketConfiguration.Data storage config = PerpsMarketConfiguration.load(marketId); diff --git a/markets/perps-market/contracts/modules/PerpsAccountModule.sol b/markets/perps-market/contracts/modules/PerpsAccountModule.sol index 01fec8282e..452297fe9d 100644 --- a/markets/perps-market/contracts/modules/PerpsAccountModule.sol +++ b/markets/perps-market/contracts/modules/PerpsAccountModule.sol @@ -15,6 +15,10 @@ import {PerpsPrice} from "../storage/PerpsPrice.sol"; import {MathUtil} from "../utils/MathUtil.sol"; import {SafeCastU256, SafeCastI256} from "@synthetixio/core-contracts/contracts/utils/SafeCast.sol"; +/** + * @title Module to manage accounts + * @dev See IAccountModule. + */ contract PerpsAccountModule is IAccountModule { using PerpsAccount for PerpsAccount.Data; using Position for Position.Data; @@ -23,6 +27,9 @@ contract PerpsAccountModule is IAccountModule { using SafeCastI256 for int256; using GlobalPerpsMarket for GlobalPerpsMarket.Data; + /** + * @inheritdoc IAccountModule + */ function modifyCollateral( uint128 accountId, uint128 synthMarketId, @@ -68,14 +75,23 @@ contract PerpsAccountModule is IAccountModule { emit CollateralModified(accountId, synthMarketId, amountDelta, msg.sender); } + /** + * @inheritdoc IAccountModule + */ function totalCollateralValue(uint128 accountId) external view override returns (uint) { return PerpsAccount.load(accountId).getTotalCollateralValue(); } + /** + * @inheritdoc IAccountModule + */ function totalAccountOpenInterest(uint128 accountId) external view override returns (uint) { return PerpsAccount.load(accountId).getTotalNotionalOpenInterest(); } + /** + * @inheritdoc IAccountModule + */ function getOpenPosition( uint128 accountId, uint128 marketId @@ -90,6 +106,9 @@ contract PerpsAccountModule is IAccountModule { return (pnl, accruedFunding, position.size); } + /** + * @inheritdoc IAccountModule + */ function getAsyncOrderClaim( uint128 accountId, uint128 marketId @@ -101,10 +120,16 @@ contract PerpsAccountModule is IAccountModule { return asyncOrder; } + /** + * @inheritdoc IAccountModule + */ function getAvailableMargin(uint128 accountId) external view override returns (int) { return PerpsAccount.load(accountId).getAvailableMargin(); } + /** + * @inheritdoc IAccountModule + */ function getCollateralAmount( uint128 accountId, uint128 synthMarketId diff --git a/markets/perps-market/contracts/modules/PerpsMarketModule.sol b/markets/perps-market/contracts/modules/PerpsMarketModule.sol index 0cb3ec54f4..c49b4feb70 100644 --- a/markets/perps-market/contracts/modules/PerpsMarketModule.sol +++ b/markets/perps-market/contracts/modules/PerpsMarketModule.sol @@ -20,7 +20,7 @@ contract PerpsMarketModule is IPerpsMarketModule { } function maxOpenInterest(uint128 marketId) external view override returns (uint256) { - return PerpsMarketConfiguration.load(marketId).maxMarketValue; + return PerpsMarketConfiguration.load(marketId).maxMarketSize; } function currentFundingRate(uint128 marketId) external view override returns (int) { diff --git a/markets/perps-market/contracts/storage/AsyncOrder.sol b/markets/perps-market/contracts/storage/AsyncOrder.sol index 75d5793d99..5697824b86 100644 --- a/markets/perps-market/contracts/storage/AsyncOrder.sol +++ b/markets/perps-market/contracts/storage/AsyncOrder.sol @@ -202,7 +202,7 @@ library AsyncOrder { PerpsMarket.validatePositionSize( perpsMarketData, - marketConfig.maxMarketValue, + marketConfig.maxMarketSize, oldPosition.size, order.sizeDelta ); diff --git a/markets/perps-market/contracts/storage/LimitOrder.sol b/markets/perps-market/contracts/storage/LimitOrder.sol deleted file mode 100644 index 6ac84f5bf3..0000000000 --- a/markets/perps-market/contracts/storage/LimitOrder.sol +++ /dev/null @@ -1,2 +0,0 @@ -//SPDX-License-Identifier: MIT -pragma solidity >=0.8.11 <0.9.0; diff --git a/markets/perps-market/contracts/storage/PerpsMarketConfiguration.sol b/markets/perps-market/contracts/storage/PerpsMarketConfiguration.sol index 39a8233b86..35e8a6f74f 100644 --- a/markets/perps-market/contracts/storage/PerpsMarketConfiguration.sol +++ b/markets/perps-market/contracts/storage/PerpsMarketConfiguration.sol @@ -12,14 +12,14 @@ library PerpsMarketConfiguration { using DecimalMath for uint256; using SafeCastI128 for int128; - error MaxOpenInterestReached(uint128 marketId, uint256 maxMarketValue, int newSideSize); + error MaxOpenInterestReached(uint128 marketId, uint256 maxMarketSize, int newSideSize); error InvalidSettlementStrategy(uint128 settlementStrategyId); struct Data { OrderFee.Data orderFees; SettlementStrategy.Data[] settlementStrategies; - uint256 maxMarketValue; // oi cap + uint256 maxMarketSize; // oi cap uint256 maxFundingVelocity; uint256 skewScale; /** diff --git a/markets/perps-market/storage.dump.sol b/markets/perps-market/storage.dump.sol index 02a13f1596..29cfdf37c6 100644 --- a/markets/perps-market/storage.dump.sol +++ b/markets/perps-market/storage.dump.sol @@ -415,8 +415,8 @@ library OrderFees { } } -// @custom:artifact contracts/interfaces/IAsyncOrderModule.sol:IAsyncOrderModule -interface IAsyncOrderModule { +// @custom:artifact contracts/interfaces/IAsyncOrderSettlementModule.sol:IAsyncOrderSettlementModule +interface IAsyncOrderSettlementModule { struct SettleOrderRuntime { uint128 marketId; uint128 accountId; @@ -456,8 +456,8 @@ interface IPythVerifier { } } -// @custom:artifact contracts/modules/AsyncOrderModule.sol:AsyncOrderModule -contract AsyncOrderModule { +// @custom:artifact contracts/modules/AsyncOrderSettlementModule.sol:AsyncOrderSettlementModule +contract AsyncOrderSettlementModule { int256 public constant PRECISION = 18; } @@ -498,6 +498,7 @@ library AsyncOrder { uint initialRequiredMargin; uint totalRequiredMargin; Position.Data newPosition; + bytes32 trackingCode; } } @@ -588,6 +589,14 @@ library PerpsMarket { mapping(uint => AsyncOrder.Data) asyncOrders; mapping(uint => Position.Data) positions; } + struct MarketUpdateData { + uint128 marketId; + int256 skew; + uint256 size; + int256 sizeDelta; + int256 currentFundingRate; + int256 currentFundingVelocity; + } function load(uint128 marketId) internal pure returns (Data storage market) { bytes32 s = keccak256(abi.encode("io.synthetix.perps-market.PerpsMarket", marketId)); assembly { @@ -601,7 +610,7 @@ library PerpsMarketConfiguration { struct Data { OrderFee.Data orderFees; SettlementStrategy.Data[] settlementStrategies; - uint256 maxMarketValue; + uint256 maxMarketSize; uint256 maxFundingVelocity; uint256 skewScale; uint256 initialMarginRatioD18; diff --git a/markets/perps-market/test/integration/Market/CreateMarket.test.ts b/markets/perps-market/test/integration/Market/CreateMarket.test.ts index 30ce2281b8..fd465fe2c5 100644 --- a/markets/perps-market/test/integration/Market/CreateMarket.test.ts +++ b/markets/perps-market/test/integration/Market/CreateMarket.test.ts @@ -79,13 +79,13 @@ describe('Create Market test', () => { before('set max market value', async () => { tx = await systems() .PerpsMarket.connect(marketOwner) - .setMaxMarketValue(marketId, bn(99999999)); + .setMaxMarketSize(marketId, bn(99999999)); }); - it('should emit MaxMarketValueSet event', async () => { + it('should emit MaxMarketSizeSet event', async () => { await assertEvent( tx, - `MaxMarketValueSet(${marketId}, ${bn(99999999).toString()})`, + `MaxMarketSizeSet(${marketId}, ${bn(99999999).toString()})`, systems().PerpsMarket ); }); @@ -195,7 +195,7 @@ describe('Create Market test', () => { }); before('set max market value', async () => { - await systems().PerpsMarket.connect(marketOwner).setMaxMarketValue(marketId, bn(99999999)); + await systems().PerpsMarket.connect(marketOwner).setMaxMarketSize(marketId, bn(99999999)); }); before('create price nodes', async () => { diff --git a/markets/perps-market/test/integration/Market/MarketConfiguration.test.ts b/markets/perps-market/test/integration/Market/MarketConfiguration.test.ts index f1f5d62d74..e1c0dad491 100644 --- a/markets/perps-market/test/integration/Market/MarketConfiguration.test.ts +++ b/markets/perps-market/test/integration/Market/MarketConfiguration.test.ts @@ -131,8 +131,8 @@ describe('MarketConfiguration', async () => { await assertEvent( await systems() .PerpsMarket.connect(marketOwner) - .setMaxMarketValue(marketId, fixture.maxMarketValue), - 'MaxMarketValueSet(' + marketId.toString() + ', ' + fixture.maxMarketValue.toString() + ')', + .setMaxMarketSize(marketId, fixture.maxMarketValue), + 'MaxMarketSizeSet(' + marketId.toString() + ', ' + fixture.maxMarketValue.toString() + ')', systems().PerpsMarket ); }); @@ -207,7 +207,7 @@ describe('MarketConfiguration', async () => { `OnlyMarketOwner("${owner}", "${randomUserAddress}")` ); await assertRevert( - systems().PerpsMarket.connect(randomUser).setMaxMarketValue(marketId, fixture.maxMarketValue), + systems().PerpsMarket.connect(randomUser).setMaxMarketSize(marketId, fixture.maxMarketValue), `OnlyMarketOwner("${owner}", "${randomUserAddress}")` ); await assertRevert( @@ -239,7 +239,7 @@ describe('MarketConfiguration', async () => { }); it('get maxMarketValue', async () => { - const maxMarketValue = await systems().PerpsMarket.getMaxMarketValue(marketId); + const maxMarketValue = await systems().PerpsMarket.getMaxMarketSize(marketId); assertBn.equal(maxMarketValue, fixture.maxMarketValue); }); diff --git a/markets/perps-market/test/integration/bootstrap/bootstrapPerpsMarkets.ts b/markets/perps-market/test/integration/bootstrap/bootstrapPerpsMarkets.ts index 2705b08cab..618011f222 100644 --- a/markets/perps-market/test/integration/bootstrap/bootstrapPerpsMarkets.ts +++ b/markets/perps-market/test/integration/bootstrap/bootstrapPerpsMarkets.ts @@ -128,7 +128,7 @@ export const bootstrapPerpsMarkets = ( }); before('set max market value', async () => { - await contracts.PerpsMarket.connect(marketOwner).setMaxMarketValue( + await contracts.PerpsMarket.connect(marketOwner).setMaxMarketSize( marketId, maxMarketValue ? maxMarketValue : bn(10_000_000) );