Contains the logic for calculating the new weights of a QuantAMM pool and protections, must be implemented by all rules used in quantAMM
State Variables
REQ_PREV_MAVG_VAL
uint16privateconstant REQ_PREV_MAVG_VAL =1;
updateWeightRunner
addressprivateimmutable updateWeightRunner;
name
stringpublic name;
parameterDescriptions
string[]public parameterDescriptions;
Functions
constructor
CalculateNewWeights
Parameters
Name
Type
Description
_prevWeights
int256[]
the previous weights retrieved from the vault
_data
int256[]
the latest data from the signal, usually price
_pool
address
the target pool address
_parameters
int256[][]
the parameters of the rule that are not lambda
_lambdaStore
uint64[]
either vector or scalar lambda
_epsilonMax
uint64
the maximum weights can change in a given update interval
_absoluteWeightGuardRail
uint64
the minimum weight a token can have
_getWeights
Function that has to be implemented by update rules. Given previous weights, current data, and current gradient of the data, calculate the new weights.
Parameters
Name
Type
Description
_prevWeights
int256[]
w(t - 1), the weights at the previous timestamp
_data
int256[]
p(t), the data at the current timestamp, usually referring to prices (but could also be other values that are returned by an oracle)
_parameters
int256[][]
Arbitrary values that parametrize the rule, interpretation depends on rule
_poolParameters
QuantAMMPoolParameters
PoolParameters
Returns
Name
Type
Description
newWeights
int256[]
w(t), the updated weights
_requiresPrevMovingAverage
_setInitialIntermediateValues
Parameters
Name
Type
Description
_poolAddress
address
address of pool being initialised
_initialValues
int256[]
the initial intermediate values to be saved
_numberOfAssets
uint256
the number of assets in the pool
initialisePoolRuleIntermediateValues
top level initialisation function to be called during pool registration
Parameters
Name
Type
Description
_poolAddress
address
address of pool being initialised
_newMovingAverages
int256[]
the initial moving averages to be saved
_newInitialValues
int256[]
the initial intermediate values to be saved
_numberOfAssets
uint256
the number of assets in the pool
validParameters
Check if the given parameters are valid for the rule
Structs
QuantAMMUpdateRuleLocals
Struct to store local variables for the update rule
struct to avoid stack too deep issues
Properties
Name
Type
Description
i
uint256
index for looping
nMinusOne
uint256
number of assets minus one
numberOfAssets
uint256
number of assets in the pool
requiresPrevAverage
bool
boolean to determine if the rule requires the previous moving average