Developers
Search…
WeightedPool2Tokens

More functions are inherited

This page breaks out the functions that are not common to all pools. See more functions on the Pools page.

API

onSwap

1
// Inherited from BaseMinimalSwapInfoPool
2
onSwap(SwapRequest request,
3
uint256 balanceTokenIn,
4
uint256 balanceTokenOut)
5
returns (uint256 amount[In/Out])
Copied!
When the Vault is handling a swap, it will call onSwap to ask the pool what the amounts should be. Pools that use weighted math only need the input/output tokens to determine price.

enableOracle

1
enableOracle()
Copied!
Enables the oracle functionality.

getMiscData

1
getMiscData()
2
returns (
3
int256 logInvariant,
4
int256 logTotalSupply,
5
uint256 oracleSampleCreationTimestamp,
6
uint256 oracleIndex,
7
bool oracleEnabled,
8
uint256 swapFeePercentage)
Copied!
Returns a variety of data fields, listed above.

getLargestSafeQueryWindow

1
getLargestSafeQueryWindow()
2
returns (uint256)
Copied!
Returns largest safe query window.

getLatest

1
enum Variable { PAIR_PRICE, BPT_PRICE, INVARIANT }
2
getLatest(Variable variable) returns (uint256)
Copied!
Returns latest pair price, BPT price, or invariant depending on what variable enum you pass.

getTimeWeightedAverage

1
enum Variable { PAIR_PRICE, BPT_PRICE, INVARIANT }
2
struct OracleAverageQuery {
3
Variable variable;
4
uint256 secs;
5
uint256 ago;
6
}
7
getTimeWeightedAverage(OracleAverageQuery[] queries)
8
returns (uint256[] results)
Copied!
Returns time weighted average prices corresponding to the variables in each query. secs is the duration of the query in seconds, and ago is the time in seconds from since end of that duration. Prices are represented as 18 decimal fixed point values.
Note that you can only call getTimeWeightedAverage after the buffer is full, or it will revert with ORACLE_NOT_INITIALIZED. If you call getSample(1023) and it returns 0's, that means the buffer's not full yet.

getPastAccumulators

1
enum Variable { PAIR_PRICE, BPT_PRICE, INVARIANT }
2
struct OracleAccumulatorQuery {
3
Variable variable;
4
uint256 ago;
5
}
6
getPastAccumulators(OracleAccumulatorQuery[] queries
7
returns (int256[] results)
Copied!
Returns estimates for the accumulator at a time ago seconds ago for each query.