QuantAMMCovarianceBasedRule

Git Sourcearrow-up-right

Inherits:VectorRuleQuantAMMStoragearrow-up-right

This contract is abstract and needs to be inherited and implemented to be used. It also stores the intermediate values of all pools

State Variables

ONE

int256 private constant ONE = 1 * 1e18;

TENPOWEIGHTEEN

int256 private constant TENPOWEIGHTEEN = (10 ** 18);

intermediateCovarianceStates

mapping(address => int256[]) internal intermediateCovarianceStates;

Functions

getIntermediateCovarianceState

View function to get the intermediate covariance state for a given pool

Parameters

Name
Type
Description

poolAddress

address

The address of the pool

numberOfAssets

uint256

The number of assets in the pool

Returns

Name
Type
Description

<none>

int256[]

The unpacked intermediate covariance state as a 1D flattened array of int256

_calculateQuantAMMCovariance

Calculates the new intermediate state for the covariance update, i.e. A(t) = λA(t - 1) + (p(t) - p̅(t - 1))(p(t) - p̅(t))'

Parameters

Name
Type
Description

_newData

int256[]

p(t)

_poolParameters

QuantAMMPoolParameters

pool parameters

Returns

Name
Type
Description

<none>

int256[][]

newState new state of the covariance matrix

_setIntermediateCovariance

Parameters

Name
Type
Description

_poolAddress

address

the pool address being initialised

_initialValues

int256[][]

the values passed in during the creation of the pool

_numberOfAssets

uint256

the number of assets in the pool being initialised

Structs

QuantAMMCovariance

Struct to store local variables for the covariance calculation

struct to avoind stack to deep issues

Properties

Name
Type
Description

n

uint256

Dimension of square matrix

intermediateCovarianceState

int256[][]

intermediate state of the covariance matrix

newState

int256[][]

new state of the covariance matrix

u

int256[]

(p(t) - p̅(t - 1))

v

int256[]

(p(t) - p̅(t))

convertedLambda

int256

λ

oneMinusLambda

int256

1 - λ

intermediateState

int256

intermediate state during a covariance matrix calculation

Last updated