UpdateWeightRunner

Git Sourcearrow-up-right

Inherits: IUpdateWeightRunner

State Variables

ethOracle

main eth oracle that could be used to determine value of pools and assets.

this could be used for things like uplift only withdrawal fee hooks

OracleWrapper public ethOracle;

MASK_POOL_PERFORM_UPDATE

Mask to check if a pool is allowed to perform an update, some might only want to get data

uint256 private constant MASK_POOL_PERFORM_UPDATE = 1;

MASK_POOL_GET_DATA

Mask to check if a pool is allowed to get data

uint256 private constant MASK_POOL_GET_DATA = 2;

MASK_POOL_OWNER_UPDATES

Mask to check if a pool owner can update weights

MASK_POOL_QUANTAMM_ADMIN_UPDATES

Mask to check if a pool is allowed to perform admin updates

MASK_POOL_RULE_DIRECT_SET_WEIGHT

Mask to check if a pool is allowed to perform direct weight update from a rule

quantammAdmin

poolRuleSettings

key is pool address, value is rule settings for running the pool

poolOracles

Mapping of pool primary oracles keyed by pool address. Happy path oracles in the same order as the constituent assets

poolBackupOracles

Mapping of pool backup oracles keyed by pool address for each asset in the pool (in order of priority)

quantAMMSwapFeeTake

The % of the total swap fee that is allocated to the protocol for running costs.

approvedOracles

List of approved oracles that can be used for updating weights.

approvedPoolActions

Mapping of actions approved for a pool by the QuantAMM protocol team.

ruleOracleStalenessThreshold

mapping keyed of oracle address to staleness threshold in seconds. Created for gas efficincy.

rules

Mapping of pools to rules

Functions

constructor

setQuantAMMSwapFeeTake

getQuantAMMSwapFeeTake

setQuantAMMUpliftFeeTake

Set the quantAMM uplift fee % amount allocated to the protocol for running costs

Parameters

Name
Type
Description

_quantAMMUpliftFeeTake

uint256

The new uplift fee % amount allocated to the protocol for running costs

getQuantAMMUpliftFeeTake

Get the quantAMM uplift fee % amount allocated to the protocol for running costs

getQuantAMMAdmin

getOptimisedPoolOracle

Get the happy path primary oracles for the constituents of a pool

Parameters

Name
Type
Description

_poolAddress

address

Address of the pool

getPoolOracleAndBackups

Get the backup oracles for the constituents of a pool

Parameters

Name
Type
Description

_poolAddress

address

Address of the pool

getPoolRuleSettings

Get the rule settings for a pool

Parameters

Name
Type
Description

_poolAddress

address

Address of the pool

getPoolApprovedActions

Get the actions a pool has been approved for

Parameters

Name
Type
Description

_poolAddress

address

Address of the pool

getPoolRule

Get the rule for a pool

Parameters

Name
Type
Description

_poolAddress

address

Address of the pool

addOracle

Add a new oracle to the available oracles

Parameters

Name
Type
Description

_oracle

OracleWrapper

Oracle to add

removeOracle

Removes an existing oracle from the approved oracles

Parameters

Name
Type
Description

_oracleToRemove

OracleWrapper

The oracle to remove

setApprovedActionsForPool

Set the actions a pool is approved for

Parameters

Name
Type
Description

_pool

address

Pool to set actions for

_actions

uint256

setRuleForPoolAdminInitialise

Set the rule for a pool, called by the pool creator

CODEHAWKS M-02

Parameters

Name
Type
Description

_poolSettings

IQuantAMMWeightedPool.PoolSettings

Settings for the pool

_pool

address

Pool to set the rule for

setRuleForPool

Set a rule for a pool, called by the pool

Parameters

Name
Type
Description

_poolSettings

IQuantAMMWeightedPool.PoolSettings

Settings for the pool

_setRuleForPool

performUpdate

Run the update for the provided rule. Last update must be performed more than or equal (CODEHAWKS INFO /2/228) to updateInterval seconds ago.

setETHUSDOracle

Change the ETH/USD oracle

Parameters

Name
Type
Description

_ethUsdOracle

address

The new oracle address to use for ETH/USD

InitialisePoolLastRunTime

Sets the timestamp of when an update was last run for a pool. Can by used as a breakgrass measure to retrigger an update.

Parameters

Name
Type
Description

_poolAddress

address

the target pool address

_time

uint40

the time to initialise the last update run to

getData

Wrapper for if someone wants to get the oracle data the rule is using from an external source

Parameters

Name
Type
Description

_pool

address

Pool to get data for

_getData

Get the data for a pool from the oracles and return it in the same order as the assets in the pool

Parameters

Name
Type
Description

_pool

address

Pool to get data for

internalCall

bool

Internal call flag to detect if the function was called internally for emission and permissions

_getUpdatedWeightsAndOracleData

_performUpdateAndGetData

Perform the update for a pool and get the new data

Parameters

Name
Type
Description

_poolAddress

address

Pool to update

_ruleSettings

PoolRuleSettings

Settings for the rule to use for the update (lambda, epsilonMax, absolute guard rails, ruleParameters)

flattenDynamicDataWeightAndMutlipliers

Flatten the weights and multipliers into a single array

Parameters

Name
Type
Description

firstFourWeightsAndMultipliers

int256[]

The first four weights and multipliers w,w,w,w,m,m,m,m

secondFourWeightsAndMultipliers

int256[]

The second four weights and multipliers w,w,w,w,m,m,m,m

Returns

Name
Type
Description

<none>

int256[]

The flattened weights and multipliers w,w,w,w,w,w,w,w,m,m,m,m,m,m,m,m

_calculateMultiplerAndSetWeights

Calculate the multiplier and set the weights for a pool.

The multipler is the amount per block to add/remove from the last successful weight update.

Parameters

Name
Type
Description

local

CalculateMuliplierAndSetWeightsLocal

Local data for the function

calculateMultiplierAndSetWeightsFromRule

Ability to set weights from a rule without calculating new weights being triggered for approved configured pools

requested for use in zk rules where weights are calculated with circuit and this is only called post verifier call

Parameters

Name
Type
Description

params

CalculateMuliplierAndSetWeightsLocal

Local data for the function

setTargetWeightsManually

Breakglass function to allow the admin or the pool manager to set the quantammAdmins weights manually

this function is different to setWeightsManually as it is more timelock friendly

Parameters

Name
Type
Description

_weights

int256[]

the new weights

_poolAddress

address

the target pool

_interpolationTime

uint40

the time required to calcluate the multiplier

_numberOfAssets

uint256

the number of assets in the pool

setWeightsManually

Breakglass function to allow the admin or the pool manager to set the quantammAdmins weights manually

Parameters

Name
Type
Description

_weights

int256[]

the new weights

_poolAddress

address

the target pool

_lastInterpolationTimePossible

uint40

the last time that the interpolation will work

_numberOfAssets

uint256

the number of assets in the pool

setIntermediateValuesManually

Breakglass function to allow the admin or the pool manager to set the intermediate values of the rule manually

Parameters

Name
Type
Description

_poolAddress

address

the target pool

_newMovingAverages

int256[]

manual new moving averages

_newParameters

int256[]

manual new parameters

_numberOfAssets

uint256

number of assets in the pool

Events

OracleAdded

OracleRemved

SetWeightManual

SetIntermediateValuesManually

SwapFeeTakeSet

UpliftFeeTakeSet

UpdatePerformed

UpdatePerformedQuantAMM

SetApprovedActionsForPool

ETHUSDOracleSet

PoolLastRunSet

PoolRuleSetAdminOverride

CalculateWeightsRequest

CalculateWeightsResponse

WeightsUpdated

Emitted when the weights of the pool are updated

Structs

CalculateMuliplierAndSetWeightsLocal

Last updated