๐ ViewDataProvider
Contract with public view methods for getting data about Futures, Markets and Users.
Functions
activateMarket
function activateMarket(MarketId id) external;
Activates a market. Can only be called by contract owner.
deactivateMarket
function deactivateMarket(MarketId id) external;
Deactivates a market. Can only be called by contract owner.
getContractProvider
function getContractProvider() external view returns (IContractProvider);
Getter function for the ContractProvider address
Output values:
ContractProvider address
getMarketRiskParameters
function getMarketRiskParameters(
MarketId marketId
) external view returns (IMarketStorage.RiskParameters memory);
Retrieves the risk parameters for a specified market
Output values:
getMarketRewardParameters
function getMarketRewardParameters(
MarketId marketId
) external view returns (IMarketStorage.RewardParameters memory);
Retrieves the reward parameters for a specified market
Output values:
getFuturePauseConfiguration
function getFuturePauseConfiguration(
FutureId futureId
) external view returns (IFutureStorage.PauseConfiguration memory);
Retrieves the pause configuration for a specified future.
Output values:
getMarketPauseConfiguration
function getMarketPauseConfiguration(
MarketId marketId
) external view returns (IMarketStorage.PauseConfiguration memory);
Retrieves the pause configuration for a specified market.
Output values:
getProtocolFee
function getProtocolFee(
MarketId marketId
) external view returns (UD60x18);
Retrieves the protocol fee amount accrued to the market
Output values:
uint256
protocol fee amount
allActiveMarketAddresses
function allActiveMarketsAddresses(
uint offset,
uint limit
) external view returns (address[] memory);
Retrieves the addresses of all active markets. Contains pagination parameters for not bursting gas limits.
offset
uint
Number of items to skip
limit
uint
Number of items to return
Output values:
address[]
array of market addresses
allActiveMarketIds
function allActiveMarketsIds(
uint offset,
uint limit
) external view returns (MarketId[] memory);
Retrieves the IDs of all active markets. Contains pagination parameters for not bursting gas limits.
offset
uint
Number of items to skip
limit
uint
Number of items to return
Output values:
MarketId
[]
array of market identifiers
marketInfo
function marketInfo(
MarketId id,
OraclePackage[] calldata oraclePackages
) external view returns (MarketInfo memory);
Retrieves comprehensive information about a specific market.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
MarketInfo struct with market data
futureInfo
function futureInfo(
FutureId id,
OraclePackage[] calldata oraclePackages
) external view returns (FutureInfo memory);
Retrieves comprehensive information about a specific future.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
FutureInfo
struct with market data
activeMarketsInfo
function activeMarketsInfo(
uint offset,
uint limit,
ViewFloatIndexLogic.MarketOraclePackages[] calldata marketsOraclePackages
) external view returns (MarketInfo[] memory);
Retrieves comprehensive information for a range of active markets.
offset
uint
Number of items to skip
limit
uint
Number of items to return
marketsOraclePackages
An array of packages containing the latest known index for the market. and the marketId. Packages are provided by an Oracle service on demand.
Output values:
MarketInfo
[]
array of structs with market data
futureIdsCloseToMaturityWithoutIndex
function futureIdsCloseToMaturityWithoutIndex(
MarketId marketId,
uint maturityBufferSeconds
) external view returns (FutureId[] memory);
Retrieves list of future info objects that will mature within maturityBufferSeconds
seconds but do not have an index.
maturityBufferSeconds
uint
Time to maturity to be considered. If set to 0 it will return futures that have already matured.
Output values:
FutureId
[]
Array of future identifiers
futureInfoCloseToMaturityWithoutIndex
function futuresInfoCloseToMaturityWithoutIndex(
MarketId marketId,
uint maturityBufferSeconds
) external view returns (FutureInfoWithoutIndex[] memory);
Retrieves list of futures data that will mature within maturityBufferSeconds
seconds but do not have an index.
maturityBufferSeconds
uint
Time to maturity to be considered. If set to 0 it will return futures that have already matured.
Output values:
FutureInfoWithoutIndex
[]
Array of objects with future data
marginRequirement
function marginRequirement(
MarketId marketId,
address participant,
OraclePackage[] calldata oraclePackages
) external view returns (UD60x18);
Calculates the margin requirement for a market participant
participant
address
Address of the participant
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
uint256
The amount of margin required by the participant in this market
withdrawableMargin
function withdrawableMargin(
MarketId marketId,
address participant,
OraclePackage[] calldata oraclePackages
) external view returns (UD60x18);
Calculates the withdrawable margin for a market participant
participant
address
Address of the participant
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
uint256
The amount of margin that is withdrawable by the participant.
totalPosition
function totalPosition(
FutureId futureId,
address participant,
OraclePackage[] calldata oraclePackages
) external view returns (TotalPosition memory);
Retrieves the total position of a given participant in a specified future.
participant
address
Address of the participant
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
TotalPosition
Object detailing the participant's position in the specified future
marginDetails
function marginDetails(
MarketId marketId,
address participant,
OraclePackage[] calldata oraclePackages
) external view returns (ViewDataProviderLogic.MarginState memory);
Retrieves the margin details of a given participant in a specified market.
participant
address
Address of the participant
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
ViewDataProviderLogic.MarginState
Object detailing the participant's margin state in the specified market
marketPortfolio
function marketPortfolio(
MarketId marketId,
address participant,
OraclePackage[] calldata oraclePackages
) external view returns (MarketPortfolio memory);
Retrieves the market portfolio details of a given participant.
participant
address
Address of the participant
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
Output values:
MarketPortfolio
Object detailing the participant's market positions.
portfolioMarketIds
function portfolioMarketIds(
address participant,
uint offset,
uint limit
) external view returns (MarketId[] memory);
Retrieves the market ids associated with a participant's portfolio. This function filters out markets that are not relevant for the participant's portfolio.
participant
address
Address of the participant
offset
uint
Number of items to skip
limit
uint
Number of items to return
Output values:
MarketId
[]
Array of market identifiers
portfolio
function portfolio(
address participant,
uint offset,
uint limit,
ViewFloatIndexLogic.MarketOraclePackages[] calldata marketsOraclePackages
) external view returns (MarketPortfolio[] memory);
Retrieves the market ids associated with a participant's portfolio. This function filters out markets that are not relevant for the participant's portfolio.
participant
address
Address of the participant
offset
uint
Number of items to skip
limit
uint
Number of items to return
marketsOraclePackages
An array containing the latest known index per market. Packages are provided by an Oracle service on demand.
Output values:
MarketPortfolio
[]
Array of objects detailing the participant's market positions
checkForUnsettledMaturedFutures
function checkForUnsettledMaturedFutures(
MarketId marketId,
address participant
) external view returns (bool);
Checks if a participant has any unsettled futures that have reached maturity in a specified market
participant
address
Address of the participant
Output values:
bool
True if any of the participant's futures in the specified market have reached maturity and are unsettled. False otherwise.
makerLiquidityDistribution
function makerLiquidityDistribution(
FutureId futureId,
address maker,
uint offset,
uint limit
) external view returns (SD59x18 currentFutureRate, IntervalLiquidity[] memory intervals);
Retrieves maker's liquidity distribution details of a given future over a specified interval. offset
and limit
params can be used for pagination.
maker
address
Address of the maker
offset
uint
Number of items to skip
limit
uint
Number of items to return
Output values:
uint256
currentFutureRate - The current rate of the futureIntervalLiquidity
[]
intervals - Array of liquidity provisions
poolLiquidityDistribution
function poolLiquidityDistribution(
FutureId futureId,
OraclePackage[] calldata oraclePackages,
uint offset,
uint limit
) external view returns (
ProvisionDistribution memory provisionDistribution,
SD59x18 currentFutureRate,
IntervalLiquidity[] memory intervals
);
Retrieves the liquidity distribution details of a given future over a specified interval. offset
and limit
params can be used for pagination.
oraclePackages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
offset
uint
Number of items to skip
limit
uint
Number of items to return
Output values:
ProvisionDistribution
The total liquidity provision associated with the futureuint256
currentFutureRate - The current rate of the futureIntervalLiquidity
[]
intervals - Array of liquidity provisions
Structs
Documentation on the structs defined in this contract
IMarketStorage.RiskParameters
Parameters for configuring risk on a market.
struct RiskParameters {
UD2x18 minNotional;
UD2x18 liquidationThresholdDelta;
UD2x18 marginThresholdDelta;
UD2x18 marginThresholdTolerance;
UD2x18 maxRateImpactPerTrade;
SD1x18 hedgeMarginFactor;
uint32 marginRequirementSecondsFloor;
uint32 liquidationMarginRequirementSecondsFloor;
uint32 maturityLockoutSeconds;
}
minNotional
uint64
Minimum notional amount when providing liquidity to a market
liquidationThresholdDelta
uint64
Parameter for calculating liquidation thresholds of users trading futures in this market
marginThresholdDelta
uint64
Parameter for calculating margin thresholds of users trading futures in this market
marginThresholdTolerance
uint64
Parameter used to create a buffer between user's margin and withdrawable amount.
maxRateImpactPerTrade
uint64
Maximum allowed rate change per trade
hedgeMarginFactor
int64
Factor used for computing cross margin effects of positions in opposite directions to calculate margin requirements
marginRequirementSecondsFloor
uint32
Minimum time to maturity used in margin requirement calculations
liquidationMarginRequirementSecondsFloor
uint32
Minimum time to maturity used in liquidation margin calculations
maturityLockoutSeconds
uint32
Number of seconds from maturity after which the future is not tradable anymore
IMarketStorage.RewardParameters
Parameters for configuring rewards and fees of a market.
struct RewardParameters {
UD2x18 transferOwnershipReward;
UD2x18 positionLiquidationReward;
UD2x18 provisionCancellationReward;
UD2x18 lpPriceImpactFeeFactor;
UD2x18 lpNotionalFeeFactor;
UD2x18 minLpFee;
UD2x18 protocolPriceImpactFeeFactor;
UD2x18 protocolNotionalFeeFactor;
UD2x18 minProtocolFee;
}
transferOwnershipReward
uint64
Percentage of liquidated user's margin given as a reward to the liquidator on liquidation by novation
positionLiquidationReward
uint64
Percentage of liquidated user's margin given as a reward to the liquidator on position liquidation
provisionCancellationReward
uint64
Percentage of maker's margin given to caller on provision cancellations
lpPriceImpactFeeFactor
uint64
Parameter for adjusting maker fee of a trade according to its price impact
lpNotionalFeeFactor
uint64
Parameter for adjusting maker fee of a trade according to its notional amount
minLpFee
uint64
Minimum maker fee per trade
protocolPriceImpactFeeFactor
uint64
Parameter for adjusting protocol fee of a trade according to its price impact
protocolNotionalFeeFactor
uint64
Parameter for adjusting protocol fee of a trade according to its notional amount
minProtocolFee
uint64
Minimum protocol fee per trade
IFutureStorage.PauseConfiguration
Struct containing the pause state of different operations on a future
struct PauseConfiguration {
bool trade;
bool liquidityProvision;
bool liquidityRemoval;
bool liquidation;
bool positionsOwnershipTransfer;
}
trade
bool
If true, trading is paused in this future
liquidityProvision
bool
If true, liquidity provisions are paused in this future
liquidityRemoval
bool
If true, liquidity removals are paused in this future
liquidation
bool
If true, liquidations are paused in this future
positionOwnershipTransfer
bool
If true, liquidations by novation are paused in this future
IMarketStorage.PauseConfiguration
Struct containing the pause state of different operations on a market
struct PauseConfiguration {
bool withdraw;
bool deposit;
}
withdraw
bool
If true, withdraws are paused in this market
deposit
bool
If true, deposits are paused in this market
MarketInfo
Struct containing Market and its futures data
struct MarketInfo {
MarketDescriptor descriptor;
FutureInfo[] futures;
UD60x18 openInterest;
UD60x18 totalLiquidityNotional;
}
openInterest
uint256
The total notional value held by market participants in open futures in this market
totalLiquidityNotional
uint256
Total notional available for trading with market liquidity
MarketDescriptor
Struct containing market and its underlying token data.
struct MarketDescriptor {
MarketId id;
string sourceName;
string instrumentName;
string tag;
uint16 version;
address underlying;
string underlyingName;
uint8 underlyingDecimals;
bool underlyingIsWrappedNativeToken;
IRateMath.MathType rateMathType;
}
sourceName
string
Market source name
instrumentName
string
Market instrument name
tag
string
Market tag
version
uint16
Market version counter
underlying
address
Address of underlying ERC20 token
underlyingName
string
Name of underlying
underlyingDecimals
uint8
Decimals of underlying
underlyingIsWrappedNativeToken
bool
True if underlying is an ERC20 of the chain's native token
FutureInfo
Struct containing future and VAMM data.
struct FutureInfo {
FutureId id;
MarketId marketId;
uint64 termStart;
uint64 termLength;
VAMMParams vAMMParams;
UD60x18 totalLiquidityNotional;
UD60x18 openInterest;
}
termStart
uint64
Timestamp where the future started
termLength
uint64
Number of seconds between termStart and maturity
totalLiquidityNotional
uint256
Notional amount for all liquidity available on this future
openInterest
uint256
The total notional value held by market participants in this future
VAMMParams
Struct defining VAMM settings
struct VAMMParams {
SD59x18 lowerBoundRate;
SD59x18 currentFutureRate;
SD59x18 upperBoundRate;
UD60x18 intervalLength;
uint intervalsCount;
}
lowerBoundRate
int256
Future lowest possible rate
currentFutureRate
int256
Current future rate
upperBoundRate
int256
Future highest possible rate
intervalLength
uint256
Distance between 2 intervals. Set in percent of the rate, e.g: 0.001 * 10**18 = 0.1%
intervalsCount
uint
Number of intervals in the VAMM
ViewFloatIndexLogic.MarketOraclePackages
Struct defining OraclePackages for multiple markets
struct MarketOraclePackages {
MarketId marketId;
OraclePackage[] packages;
}
packages
An array of packages containing the latest known index for the market. Packages are provided by an Oracle service on demand.
FutureInfoWithoutIndex
Struct containing Future and VAMM data without open interest.
struct FutureInfoWithoutIndex {
FutureId id;
MarketId marketId;
uint64 termStart;
uint64 termLength;
VAMMParams vAMMParams;
UD60x18 totalLiquidityNotional;
}
termStart
uint64
Timestamp where the future started
termLength
uint64
Number of seconds between termStart and maturity
totalLiquidityNotional
uint256
Notional amount for all liquidity available on this future
TotalPosition
Struct detailing a user's position in a future
struct TotalPosition {
FixedAndFloatTokensPair.Value openPositionTokensPair;
SD59x18 openPositionNotional;
SD59x18 openPositionFloatTradeValue;
FixedAndFloatTokensPair.Value takerOpenPositionTokensPair;
SD59x18 takerOpenPositionNotional;
SD59x18 takerOpenPositionFloatTradeValue;
FixedAndFloatTokensPair.Value makerOpenPositionTokensPair;
SD59x18 makerOpenPositionNotional;
SD59x18 makerOpenPositionFloatTradeValue;
BoundedProvisionInfo[] makerProvisions;
RateBounds[] provisionsBounds;
ProvisionDistribution overallProvisionsNotional;
UD60x18 accruedLPFee;
UD60x18 incurredFee;
SD59x18 fee;
}
openPositionTokensPair
Amounts of fixed and float tokens across all open positions
openPositionNotional
int256
Total notional in open positions
openPositionFloatTradeValue
int256
Total value of the floating leg of a user's all open positions. Sum of takerOpenPositionFloatTradeValue
and makerOpenPositionFloatTradeValue
properties
takerOpenPositionsTokensPair
Amounts of fixed and float tokens across all open positions as taker
takerOpenPositionNotional
int256
Total notional in positions open as taker
takerOpenPositionFloatTradeValue
int256
Total value of the floating leg of a user's open positions as taker
makerOpenPositionsTokensPair
Amounts of fixed and float tokens across all open positions as maker
makerOpenPositionNotional
int256
Total notional in positions open as maker
makerOpenPositionFloatTradeValue
int256
Total value of the floating leg of a user's open positions as maker
overallProvisionsNotional
Distribution of all provided liquidity between payer and receiver sides
accruedLPFee
uint256
Total LP fee accrued by an user
incurredFee
uint256
Total fee incurred by an user doing trades
fee
int256
Difference between accruedLPFee
and incurredFee
BoundedProvisionInfo
struct BoundedProvisionInfo {
FixedAndFloatTokensPair.Value tokensPair;
UD60x18 accruedLPFee;
SD59x18 floatTradeValue;
SD59x18 positionNotional;
ProvisionDistribution provisionNotional;
}
accruedLPFee
uint256
Amount of LP fees accrued by user
floatTradeValue
int256
Value of floating leg of a provision using last available index
positionNotional
int256
Total notional of a LP position
RateBounds
Struct to define the rate limits
struct RateBounds {
SD59x18 lower;
SD59x18 upper;
}
lower
int256
Lower rate limit
upper
int256
Upper rate limit
ViewDataProviderLogic.MarginState
Struct containing details on the margin of a user
struct MarginState {
Margin.Value margin;
UD60x18 initialMarginThreshold;
UD60x18 liquidationMarginThreshold;
UD60x18 lpMarginThreshold;
UD60x18 dv01;
RiskDirection.Value riskDirection;
}
initialMarginThreshold
uint256
Initial margin requirement
liquidationMarginThreshold
uint256
Liquidation margin limit. User can be liquidated when his margin falls below this threshold
lpMarginThreshold
uint256
Liquidation margin limit for LPs. LPs can be liquidated or have their positions canceled if their margin falls below this threshold
dv01
uint256
Dollar duration
MarketPortfolio
Struct detailing a user's market positions
struct MarketPortfolio {
MarketDescriptor descriptor;
ViewDataProviderLogic.MarginState marginState;
FutureInfo[] futures;
FutureOpenPosition[] futureOpenPositions;
MakerFutureProvisions[] futureMakerProvisions;
}
FutureOpenPosition
Struct detailing a user's open future
struct FutureOpenPosition {
FutureId futureId;
FixedAndFloatTokensPair.Value tokensPair;
UD60x18 notional;
ProfitAndLoss.Value profitAndLoss;
SD59x18 requiredMargin;
UD60x18 dv01;
RiskDirection.Value riskDirection;
}
notional
uint256
Face value of the position
requiredMargin
int256
Amount of margin required for this position
dv01
uint256
Dollar duration of this position
MakerFuturePositions
struct MakerFutureProvisions {
FutureId futureId;
ProvisionInfo[] provisions;
}
ProvisionInfo
Struct containing data on a liquidity provision.
struct ProvisionInfo {
RateBounds bounds;
ProvisionDistribution notional;
SD59x18 requiredMargin;
UD60x18 payerDv01;
UD60x18 receiverDv01;
}
requiredMargin
int256
Margin required for this provision
payerDv01
uint256
Dollar duration in Payer direction
receivedDv01
uint256
Dollar duration in Received direction
IntervalLiquidity
Struct declaring a notional amount of a liquidity provision in specified bounds
struct IntervalLiquidity {
RateBounds bounds;
UD60x18 notional;
}
notional
uint256
Notional amount of maker position
Enums
IRateMath.MathType
Indicates the type of rate
enum MathType {
LINEAR,
COMPOUNDING
}
Last updated