Skip to main content

IPrimitiveEngineView.sol

Read code on GitHub

Methods

BUFFER

Solidity
function BUFFER() external view returns (uint256)

Returns

NameTypeDescription
_0uint256Amount of seconds after pool expiry which allows swaps, no swaps after buffer

MIN_LIQUIDITY

Solidity
function MIN_LIQUIDITY() external view returns (uint256)

Returns

NameTypeDescription
_0uint256Amount of liquidity burned on create() calls

PRECISION

Solidity
function PRECISION() external view returns (uint256)

Returns

NameTypeDescription
_0uint256Precision units to scale to when doing token related calculations

calibrations

Fetches Calibration pool parameters

Solidity
function calibrations(bytes32 poolId) external view returns (uint128 strike, uint32 sigma, uint32 maturity, uint32 lastTimestamp, uint32 gamma)

Parameters

NameTypeDescription
poolIdbytes32Keccak256 hash of the engine address, strike, sigma, maturity, and gamma

Returns

NameTypeDescription
strikeuint128Marginal price of the pool's risky token at maturity, with the same decimals as the stable token, valid [0, 2^128-1]
sigmauint32AKA Implied Volatility in basis points, determines the price impact of swaps, valid for (1, 10_000_000)
maturityuint32Timestamp which starts the BUFFER countdown until swaps will cease, in seconds, valid for (block.timestamp, 2^32-1]
lastTimestampuint32Last timestamp used to calculate time until expiry, aka "tau"
gammauint32Multiplied against swap in amounts to apply fee, equal to 1 - fee % but units are in basis points, valid for (9_000, 10_000)

factory

Solidity
function factory() external view returns (address)

Returns

NameTypeDescription
_0addressundefined

invariantOf

Fetches the current invariant, notation is usually k, based on risky and stable token reserves of pool with poolId

Solidity
function invariantOf(bytes32 poolId) external view returns (int128 invariant)

Parameters

NameTypeDescription
poolIdbytes32Keccak256 hash of the engine address, strike, sigma, maturity, and gamma

Returns

NameTypeDescription
invariantint128Signed fixed point 64.64 number, invariant of poolId

liquidity

Fetches position liquidity an account address and poolId

Solidity
function liquidity(address account, bytes32 poolId) external view returns (uint256 liquidity)

Parameters

NameTypeDescription
accountaddressundefined
poolIdbytes32Keccak256 hash of the engine address, strike, sigma, maturity, and gamma

Returns

NameTypeDescription
liquidityuint256Liquidity owned by account in poolId

margins

Fetches the margin balances of account

Solidity
function margins(address account) external view returns (uint128 balanceRisky, uint128 balanceStable)

Parameters

NameTypeDescription
accountaddressMargin account to fetch

Returns

NameTypeDescription
balanceRiskyuint128Balance of the risky token
balanceStableuint128Balance of the stable token

reserves

Fetches the global reserve state for a pool with poolId

Solidity
function reserves(bytes32 poolId) external view returns (uint128 reserveRisky, uint128 reserveStable, uint128 liquidity, uint32 blockTimestamp, uint256 cumulativeRisky, uint256 cumulativeStable, uint256 cumulativeLiquidity)

Parameters

NameTypeDescription
poolIdbytes32Keccak256 hash of the engine address, strike, sigma, maturity, and gamma

Returns

NameTypeDescription
reserveRiskyuint128Risky token balance in the reserve
reserveStableuint128Stable token balance in the reserve
liquidityuint128Total supply of liquidity for the curve
blockTimestampuint32Timestamp when the cumulative reserve values were last updated
cumulativeRiskyuint256Cumulative sum of risky token reserves of the previous update
cumulativeStableuint256Cumulative sum of stable token reserves of the previous update
cumulativeLiquidityuint256Cumulative sum of total supply of liquidity of the previous update

risky

Solidity
function risky() external view returns (address)

Returns

NameTypeDescription
_0addressundefined

scaleFactorRisky

Solidity
function scaleFactorRisky() external view returns (uint256)

Returns

NameTypeDescription
_0uint256Multiplier to scale amounts to/from, equal to 10^(18 - riskyDecimals)

scaleFactorStable

Solidity
function scaleFactorStable() external view returns (uint256)

Returns

NameTypeDescription
_0uint256Multiplier to scale amounts to/from, equal to 10^(18 - stableDecimals)

stable

Solidity
function stable() external view returns (address)

Returns

NameTypeDescription
_0addressStable token address, a more accurate name is the quote token