Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Major refactor to support a critical feature:
Changelog
fund
anddraw
.HyperPool
struct. ReplaceslastPrice
withvirtualX
andvirtualY
variables. These are the WAD amounts of the x and y reserves per unit of liquidity. These are matched to real token balances with exact precision up to the maximum token decimals of 18._swapExactIn
output
argument to be used as theminAmountOut
variable for validating the swap output is more than expected._swap
to use the pool'svirtualX
andvirtualY
for computing the swap invariant, instead of being derived from price.priorityFeeGrowthGlobal
tracking from_swap
.Swap
event._computeSyncedPrice
to compute the invariant using thevirtualX
andvirtualY
amounts of the pool._syncPool
to updatevirtualX
andvirtualY
instead ofprice
._createPool
to update thevirtualX
andvirtualY
variables, computed from price argument, instead ofprice
.SwapInputTooSmall
custom error, used in the functionHyperLib.getAmountOut
HyperLib.getMaxLiquidity
to compute max liquidity using WAD amounts instead of scaled amounts.HyperLib.getAmountsWad
to return thevirtualX
andvirtualY
amounts of the pool's HyperPool data struct.computePriceChangeWithTime
function.HyperLib.getMaxSwapAssetInWad
andHyperLib.getMaxSwapQuoteInWad
functions to use theHyperLib.getAmountsWad
function instead of thePrice.computeReserves
function.HyperLib.getNextInvariant
to compute the invariant at the currentblock.timestamp
.HyperLib.getAmountOut
to match Hyper's_swap
function logic flow.Price.sol
library to accept theinvariant
as an argument ingetYWithX
,getXWithY
andcomputeReserves
.Price.computeCurveChanges
to get the next invariant after a change in time.Price.computeYWithChangeInTau
.Price.getXWithPrice
function to only compute price if the result of the price divided by strike is not zero.Price.getPriceWithX
to handle edge cases.Dependencies