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
initializePriceImpactInitializes 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
setPriceImpactWindowsCountUpdates the number of open interest windows.
Parameters:
_newWindowsCount: New count of open interest windows.
Access Control:
onlyRole(Role.GOV).
setPriceImpactWindowsDuration
setPriceImpactWindowsDurationUpdates the duration of open interest windows.
Parameters:
_newWindowsDuration: New duration of open interest windows in seconds.
Access Control:
onlyRole(Role.GOV).
setPairDepths
setPairDepthsSets 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
setProtectionCloseFactorsConfigures 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
setProtectionCloseFactorBlocksSets 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
setCumulativeFactorsConfigures cumulative factors for trading pairs.
Parameters:
_pairIndices: Array of trading pair indices._cumulativeFactors: Array of cumulative factor values.
Access Control:
onlyRole(Role.GOV).
addPriceImpactOpenInterest
addPriceImpactOpenInterestUpdates 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
getPriceImpactOiRetrieves 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
getTradePriceImpactCalculates 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
getPairDepthRetrieves the depth details for a trading pair.
Parameters:
_pairIndex: Index of the trading pair.
Returns:
PairDepthstructure containing depth details.
getPairFactor
getPairFactorRetrieves factors affecting a trading pair.
Parameters:
_pairIndex: Index of the trading pair.
Returns:
PairFactorsstructure containing factor details.
getOiWindowsSettings
getOiWindowsSettingsRetrieves settings related to open interest windows.
Returns:
OiWindowsSettingsstructure.
getOiWindow
getOiWindowRetrieves a specific open interest window's data.
Parameters:
_windowsDuration: Duration of the window._pairIndex: Trading pair index._windowId: ID of the window.
Returns:
PairOistructure for the specified window.
getOiWindows
getOiWindowsRetrieves data for multiple open interest windows.
Parameters:
_windowsDuration: Duration of the windows._pairIndex: Trading pair index._windowIds: Array of window IDs.
Returns: Array of
PairOistructures.
getPairDepths
getPairDepthsRetrieves depth details for multiple trading pairs.
Parameters:
_indices: Array of trading pair indices.
Returns: Array of
PairDepthstructures.
getPairFactors
getPairFactorsRetrieves factors for multiple trading pairs.
Parameters:
_indices: Array of trading pair indices.
Returns: Array of
PairFactorsstructures.
Last updated
Was this helpful?