Skip to content

Commit

Permalink
document GlobalPerpsMarketModule
Browse files Browse the repository at this point in the history
  • Loading branch information
leomassazza committed Jul 4, 2023
1 parent 9d1287e commit f375ec4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface IGlobalPerpsMarketModule {
function setMaxCollateralAmount(uint128 synthMarketId, uint collateralAmount) external;

/**
* @notice Obtain the max collateral amount for a specific synth market.
* @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
*/
Expand All @@ -49,13 +49,28 @@ interface IGlobalPerpsMarketModule {
*/
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
Expand Down
22 changes: 22 additions & 0 deletions markets/perps-market/contracts/modules/GlobalPerpsMarketModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -49,6 +68,9 @@ contract GlobalPerpsMarketModule is IGlobalPerpsMarketModule {
emit LiquidationRewardGuardsSet(minLiquidationRewardUsd, maxLiquidationRewardUsd);
}

/**
* @inheritdoc IGlobalPerpsMarketModule
*/
function getLiquidationRewardGuards()
external
view
Expand Down

0 comments on commit f375ec4

Please sign in to comment.