-
Notifications
You must be signed in to change notification settings - Fork 46
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] vault manages funds for custom curve hook #200
base: main
Are you sure you want to change the base?
Conversation
|
|
||
key.currency0.settle(vault, address(this), 1, false); | ||
key.currency1.settle(vault, address(this), 1, false); | ||
} else if (keccak256(action) == keccak256("deposit")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can regard this as vault.mint with reserveOfApp being updated
if (amount1 > 0) { | ||
key.currency1.settle(vault, address(this), amount1, false); | ||
} | ||
} else if (keccak256(action) == keccak256("withdraw")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can regard this as vault.burn with reserveOfApp being updated
ICLPoolManager.ModifyLiquidityParams calldata params, | ||
bytes calldata hookData | ||
) external override returns (bytes4) { | ||
revert("banned adding liquidity by non-hook"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be banned anyway even not taking this approach because custom curve will have its own liquidity logic
uint256 amount1, | ||
bytes calldata hookData | ||
) external override returns (bytes4) { | ||
revert("banned donating by non-hook"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fact, it's fine to allow ppl to donate because it will all goes to hook's liquidity position
if (params.zeroForOne) { | ||
// input token is token0, amt = amountSpecified, deposit it to vault | ||
key.currency0.take(vault, address(this), (-params.amountSpecified).toUint256(), false); | ||
_dispatch(abi.encode("deposit", abi.encode(key, (-params.amountSpecified).toUint256(), 0))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those two could be further combined i.e take() and settle() are exactly opposite direction hence could cancel out which means we could call donate without any settlement here :
- less gas
- reserveOfApp is updating but we don't need to have the token in the pool ahead of time
|
||
// output token is token1, amt = amountUnSpecified, withdraw it from vault | ||
_dispatch(abi.encode("withdraw", abi.encode(key, 0, amountUnSpecified, address(this)))); | ||
key.currency1.settle(vault, address(this), amountUnSpecified.toUint256(), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same logic, those two could be combined to simplify the flow
Make it WIP since we won't take it |
This POC expects to work as a reference in case third party integration and would like to manage funds and reflect it on reserveOfApps