JavPriceImpact
General Description
The JavPriceImpact contract used for manage various settings related to price impact, such as open interest windows, depth factors, protection close factors, and cumulative factors. The contract is divided into management setters for configuring the system, interaction functions for updating open interest dynamically, and getters for retrieving various price impact-related data.
Core Functionalities
initializePriceImpact
initializePriceImpact
Initializes price impact settings, including the duration and count of open interest windows.
Parameters:
_windowsDuration
: Duration of each open interest window in seconds._windowsCount
: Number of open interest windows.
Access Control:
reinitializer(3)
.
setPriceImpactWindowsCount
setPriceImpactWindowsCount
Updates the number of open interest windows.
Parameters:
_newWindowsCount
: New count of open interest windows.
Access Control:
onlyRole(Role.GOV)
.
setPriceImpactWindowsDuration
setPriceImpactWindowsDuration
Updates the duration of open interest windows.
Parameters:
_newWindowsDuration
: New duration of open interest windows in seconds.
Access Control:
onlyRole(Role.GOV)
.
setPairDepths
setPairDepths
Sets the depth parameters for trading pairs.
Parameters:
_indices
: Array of trading pair indices._depthsAboveUsd
: Array of depth values above the current USD price._depthsBelowUsd
: Array of depth values below the current USD price.
Access Control:
onlyRole(Role.MANAGER)
.
setProtectionCloseFactors
setProtectionCloseFactors
Configures protection close factors for trading pairs.
Parameters:
_pairIndices
: Array of trading pair indices._protectionCloseFactors
: Array of close factor values for protection.
Access Control:
onlyRole(Role.GOV)
.
setProtectionCloseFactorBlocks
setProtectionCloseFactorBlocks
Sets the block duration for protection close factors.
Parameters:
_pairIndices
: Array of trading pair indices._protectionCloseFactorBlocks
: Array of block duration values.
Access Control:
onlyRole(Role.GOV)
.
setCumulativeFactors
setCumulativeFactors
Configures cumulative factors for trading pairs.
Parameters:
_pairIndices
: Array of trading pair indices._cumulativeFactors
: Array of cumulative factor values.
Access Control:
onlyRole(Role.GOV)
.
addPriceImpactOpenInterest
addPriceImpactOpenInterest
Updates the open interest impact for a trader based on their activity.
Parameters:
_trader
: Address of the trader._index
: Trading pair index._oiDeltaCollateral
: Change in open interest collateral._open
: Indicates if the position is being opened or closed.
Access Control:
onlySelf
.
getPriceImpactOi
getPriceImpactOi
Retrieves the open interest price impact for a given pair.
Parameters:
_pairIndex
: Index of the trading pair._long
: Indicates if the position is long.
Returns: The active open interest.
getTradePriceImpact
getTradePriceImpact
Calculates the price impact for a trade.
Parameters:
_marketPrice
: Current market price._pairIndex
: Trading pair index._long
: Indicates if the position is long._tradeOpenInterestUsd
: Open interest in USD._isPnlPositive
: Indicates if profit and loss is positive._open
: Indicates if the trade is opening or closing._lastPosIncreaseBlock
: Block number of the last position increase.
Returns:
priceImpactP
: Price impact percentage.priceAfterImpact
: Price after applying impact.
getPairDepth
getPairDepth
Retrieves the depth details for a trading pair.
Parameters:
_pairIndex
: Index of the trading pair.
Returns:
PairDepth
structure containing depth details.
getPairFactor
getPairFactor
Retrieves factors affecting a trading pair.
Parameters:
_pairIndex
: Index of the trading pair.
Returns:
PairFactors
structure containing factor details.
getOiWindowsSettings
getOiWindowsSettings
Retrieves settings related to open interest windows.
Returns:
OiWindowsSettings
structure.
getOiWindow
getOiWindow
Retrieves a specific open interest window's data.
Parameters:
_windowsDuration
: Duration of the window._pairIndex
: Trading pair index._windowId
: ID of the window.
Returns:
PairOi
structure for the specified window.
getOiWindows
getOiWindows
Retrieves data for multiple open interest windows.
Parameters:
_windowsDuration
: Duration of the windows._pairIndex
: Trading pair index._windowIds
: Array of window IDs.
Returns: Array of
PairOi
structures.
getPairDepths
getPairDepths
Retrieves depth details for multiple trading pairs.
Parameters:
_indices
: Array of trading pair indices.
Returns: Array of
PairDepth
structures.
getPairFactors
getPairFactors
Retrieves factors for multiple trading pairs.
Parameters:
_indices
: Array of trading pair indices.
Returns: Array of
PairFactors
structures.
Last updated