Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: amountSpecified matches deltas #491

Merged
merged 2 commits into from
Mar 6, 2024
Merged

Conversation

ewilz
Copy link
Member

@ewilz ewilz commented Feb 29, 2024

Related Issue

Which issue does this pull request resolve?

Description of changes

@ewilz ewilz requested a review from hensha256 February 29, 2024 23:18
@@ -464,7 +464,7 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
modifyLiquidityRouter.modifyLiquidity{value: 1 ether}(nativeKey, liqParams, ZERO_BYTES);

IPoolManager.SwapParams memory params =
IPoolManager.SwapParams({zeroForOne: true, amountSpecified: 100, sqrtPriceLimitX96: SQRT_RATIO_1_2});
IPoolManager.SwapParams({zeroForOne: true, amountSpecified: -100, sqrtPriceLimitX96: SQRT_RATIO_1_2});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This identical struct is used all over this file, and DynamicFees.t.sol. I wonder if we should just save it as our default SWAP_PARAMS in Deployers.sol like we have LIQ_PARAMS etc in there. And then al these files can just use that constant defined in 1 place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or SWAP_EXACT_IN_PARAMS or something

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to our #390

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

Copy link
Contributor

@hensha256 hensha256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great, much simpler than i thought it was going to be lol

@hensha256 hensha256 mentioned this pull request Mar 5, 2024
@hensha256 hensha256 merged commit 1a76db2 into flip-the-deltas Mar 6, 2024
5 checks passed
@hensha256 hensha256 deleted the amountSpecified branch March 6, 2024 19:56
hensha256 added a commit that referenced this pull request Mar 13, 2024
* Remove access lock

* remove current hook

* Remove nested locking

* Locker library tests

* Rename empty lock test

* Test skeleton

* Test for a nested swap

* Tests for nested function calls

* snapshots

* Separate libs, rename error

* Remove lock caller

* merge errors

* Flipping the sign of deltas

* update comments

* remove unnecessary read of result

* move delta flip to sqrtprice lib

* remove duplicate test

* amountSpecified matches deltas (#491)

Co-authored-by: hensha256 <[email protected]>

* PR nits

---------

Co-authored-by: Emily Williams <[email protected]>
hensha256 added a commit that referenced this pull request May 9, 2024
* Remove access lock

* remove current hook

* Remove nested locking

* Locker library tests

* Rename empty lock test

* Test skeleton

* Test for a nested swap

* Tests for nested function calls

* snapshots

* Separate libs, rename error

* Remove lock caller

* merge errors

* Flipping the sign of deltas

* update comments

* refactor hook callsite

* linting

* first draft of swap impl

* Compiling and tests passing

* first test passing

* Add todo

* other TODO

* reduce calls to account delta

* check delta modification in callsite

* fix error and compiler warnings

* skeleton for modify position

* Test

* Add liquidity check in modify router

* add liq test

* linting

* remove unnecessary read of result

* move delta flip to sqrtprice lib

* remove duplicate test

* amountSpecified matches deltas (#491)

Co-authored-by: hensha256 <[email protected]>

* common var, and custom error

* refactor of hook callsites and perms

* PR comments, clean up swap comments

* Allow noop on the pool

* Update src/PoolManager.sol

Co-authored-by: saucepoint <[email protected]>

* correct delta taken from user

* PR comments

* liq to liquidity

* refactor logic into hook contract

* move all delta settling to the end

* Factor out swap logic into helper

* small refactor mdoify liq

* amountToSwap variable

* more tests

* beginning of fuzz work

* full fuzz test of beforeSwap return

* rename

* split comments on multiple lines

* Update src/libraries/Hooks.sol

Co-authored-by: Sara Reynolds <[email protected]>

* refactor processing hook deltas

* remove console imports

* nit PR comments

* remove unneeded check

* refactor logic into hook contract

* modifyLiquidity to match swap

* remove unneeded check

* PR comments

* fix fuzz test

* remove extra check and add comments

* correct gas snaps

* Natspec updates

* natspec

* PR comments

* comment protocol fee clearer

* PR comments

---------

Co-authored-by: Emily Williams <[email protected]>
Co-authored-by: saucepoint <[email protected]>
Co-authored-by: Sara Reynolds <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants