ERC20 token info which is static and not going to change
attempt promise until it succeeds or the maximum number of allowed attempts is reached
a promise that will eventually error or resolve to the same type as the original promise
Calculates the compounding gains
annual percentage rate as a decimal eg 1 is a 100% apr
annual percentage yield coumpounded weekly
Calculates the Balancer LP token price given a list of tokens included in the pool
list of tokens included in the balancer pool
0 if no tokens are given, if the tokens have no USDC value or if the stakingToken supply is 0 otherwise returns the price of the LP token.
Calculates the trade price between two Balancer tokens. This price is dependent on the reserves deposited on each side within the Balancer pool, as well as the weighting of each.
weight and balance of token that is being sold
weight and balance of token that is being bought
percentage swap fee in decimals
Calcualtes the direction of the price movement
old market price
new market price
DOWN (2) if oldPrice > newPrice, NO_CHANGE (3) if newPrice = oldPrice, or UP (1) if newPrice > oldPrice
Calculates the effective multiplier returns for the longs. This amount varies depending on the skew between the long and short balances.
Gain and loss refer to whether the pool is receiving tokens from the other pool or transferring tokens to the opposite pool.
If there is more balance in the long pool than the short pools, you would expect the short pool to have
effectiveLongGain > leverage
.
Both sides of the pool will always have an effectiveLoss lower limit at leverage, ie you can never have effectiveLoss < leverage
.
quote balance of the short pool in quote units (eg USD)
quote balance of the long pool in quote units (eg USD)
pool leverage
the effective winning returns to the long pool on next rebalance
Calculates the effective gains multiplier for the shorts. This amount varies depending on the skew between the long and short balances.
Gain and loss refer to whether the pool is receiving tokens from the other pool or transferring tokens to the opposite pool.
If there is more balance in the long pool than the short pools, you would expect the short pool to have
effectiveLongGain > leverage
.
The pools effective losses will always have a lower limit at leverage, ie you can never have effectiveLoss < leverage
.
quote balance of the short pool in USD
quote balance of the long pool in USD
pool leverage
the effective gains to the short pool on next rebalance
Calculates how much value will be transferred between the pools
old market price
new market price
pool leverage
quote balance of the long pool in USD
quote balance of the short pool in USD
returns an object containing longValueTransfer and shortValueTransfer
Calculates the notional value of tokens
current price of tokens
number of tokens
notional value of the tokens
Calculates the percentage the losing pool must transfer to the winning pool on next upKeep. JS implementation of https://github.com/tracer-protocol/perpetual-pools-contracts/blob/pools-v2/contracts/libraries/PoolSwapLibrary.sol#L348-L362
old market price
new market price
pool leverage
the percentage the losing pool must transfer 2 / (1 + e^(-2 * leverage * (1 - (oldPrice / newPrice)))) - 1
calculates the expected state of the pool after applying the given pending commits to the given pool state
the expected state of the pool
Calculates the ratio of the old price to the new price
old market price
new market price
Calculate the pool tokens price Since totalQuoteValue will generally be in USD the returned amount will also be in USD
Calculate the expected execution given a commit timestamp, the frontRunningInterval, updateInterval and lastUpdate. This is just an estimate as there is a slight delay between possibleExecution and finalExecutionTimestamp See https://github.com/tracer-protocol/pools-js/blob/updated-calc/src/utils/calculations.ts#L280-L332 for a long clearer sudo codish written version
Generated using TypeDoc
Holds burn and mint pending amounts PendingAmounts.mint is the amount of quote token pending in the shadow pools PendingAmounts.burn is the amount of to be burned pool tokens in the shadow pools