Add custom curve#70
Conversation
| abi.decode(_hookParams, (int256, bool, uint256)); | ||
| if (amountIn <= 0) revert FixedFeeSwap__SwapAmountCannotBeZero(); | ||
| if (activeLiquidity == 0) revert FixedFeeSwap__NoActiveLiquidity(); | ||
| if (currentPrice == 0) currentPrice = tickToPrice(currentTick); |
There was a problem hiding this comment.
why the currentPrice == 0 condition here?
| return Hooks.Permissions({ | ||
| beforeInitialize: false, | ||
| afterInitialize: false, | ||
| beforeAddLiquidity: false, |
There was a problem hiding this comment.
we said we want this to be true right?
| afterInitialize: false, | ||
| beforeAddLiquidity: false, | ||
| afterAddLiquidity: false, | ||
| beforeRemoveLiquidity: false, |
| // want to make this better. Maturities may want | ||
| // to end at the same time. | ||
| constructor( | ||
| uint48 _lengthOfMarket, |
There was a problem hiding this comment.
should we add a check for this so it's not 0
There was a problem hiding this comment.
Let's add a min market length check.
| function _scaledTimeElapsedWad() internal view returns (uint256) { | ||
| uint256 elapsed = block.timestamp - START_TIME; | ||
| if (elapsed == 0) revert FixedFeeSwap__TimeElapsedIsZero(); | ||
| return (elapsed * WAD) / (MATURITY - START_TIME); |
There was a problem hiding this comment.
what happens at MATURITY? does this keep growing?
There was a problem hiding this comment.
The market should close at or near maturity to avoid this, good callout
| bytes calldata _hookParams | ||
| ) internal virtual override returns (bytes4, BeforeSwapDelta, uint24) { | ||
| if (_hookParams.length == 0) { | ||
| return (BaseHook.beforeSwap.selector, toBeforeSwapDelta(0, 0), 0); |
There was a problem hiding this comment.
if we just return, does PoolManager still makes a swap without the hook or does it revert?
There was a problem hiding this comment.
No, it still bypasses the swapping logic since swap delta is 0. Essentially no swap takes place, but we don't fail the route. Maybe we should
|
|
||
| return BalanceDelta({ | ||
| amount0: _getAmountPrincipleDelta(currentTick, _tickUpper, _liquidity).toInt128(), | ||
| amount1: _getAmountCashDelta(_tickLower, currentTick, _liquidity).toInt128() |
There was a problem hiding this comment.
Why _getAmountPrincipleDelta just multiply by tick difference, but _getAmountCashDelta needs tickToPrice() and time? – @thelostone-mc
| // Check price limit | ||
| if (ctx.priceLimitWad != 0) { | ||
| uint256 priceAbs = currentPrice.abs(); | ||
| if (ctx.principalForCash ? priceAbs <= ctx.priceLimitWad : priceAbs >= ctx.priceLimitWad) { |
|
|
||
| // Convert NET to GROSS. Clamp to remaining gross to handle rounding edge cases | ||
| // where _grossFromNet slightly overshoots due to rounding up. | ||
| stepGross = _grossFromNet(stepNet); |
c923373 to
647a86b
Compare
|
Coverage after merging chore/more-cleanup into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
No description provided.