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

Add UniswapV3 strategy #26

Open
wants to merge 60 commits into
base: dev
Choose a base branch
from
Open

Add UniswapV3 strategy #26

wants to merge 60 commits into from

Conversation

parv3213
Copy link
Member

@parv3213 parv3213 commented Oct 20, 2023

  • Fix and resolve all TODO
  • Add tests

I have added TODO in places that require higher focus for review. I will remove them ASAP.

@parv3213 parv3213 self-assigned this Oct 20, 2023
parv3213 and others added 10 commits October 25, 2023 18:38
Fix bug

Co-authored-by: arcantheon <140178288+arcantheon@users.noreply.github.com>
- As safeApprove reverts if allowance is not 0
1. Move nfpm, uniV3Factory and lpTokenId to UniswapPoolData
2. Remove setPTokenAddress and removePToken
3. Calling _setPTokenAddress inside initialize
4. Had to make `poolData` inside `allocate` as storage because updating `lpTokenId`
@parv3213

This comment was marked as outdated.

@parv3213
Copy link
Member Author

Stack-too-deep error persists. As at two places we are using-

(,,,,,,, uint128 liquidity,,,,) = INFPM(poolData.nfpm).positions(poolData.lpTokenId);

And running this line itself throws a stack-too-deep.

/// @notice Allocates deposited assets into the Uniswap V3 pool to provide liquidity.
/// @param _amounts An array containing the amounts of tokens to be allocated.
/// @param _minMintAmt An array specifying the minimum minting amounts for each token.
function allocate(uint256[2] calldata _amounts, uint256[2] calldata _minMintAmt) external onlyOwner nonReentrant {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Calculate minMintAmt inside the function rather than accepting it.

Make use of depositSlippage

minAmount = amount - amount * depositSlippage / Helpers.MAX_PERCENTAGE;

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah makes sense. We can do this.

/// @notice Redeems a specified amount of liquidity from the Uniswap V3 pool.
/// @param _liquidity The amount of liquidity to redeem.
/// @param _minBurnAmt An array specifying the minimum burn amounts for each token.
function redeem(uint256 _liquidity, uint256[2] calldata _minBurnAmt) external onlyOwner nonReentrant {
Copy link
Collaborator

Choose a reason for hiding this comment

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

variable name _minBurnAmt is not relevant with it's actual meaning. Consider renaming it with _minAmountOut

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in e353a38

}

/// @inheritdoc InitializableAbstractStrategy
/// @dev Calls checkBalance internally as the Uniswap V3 pools does not lock the deposited assets.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does not call checkBalance internally, kindly update the doc

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 48ad03c

getAmountsForLiquidity function.

/// @notice Redeems a specified amount of liquidity from the Uniswap V3 pool.
/// @param _liquidity The amount of liquidity to redeem.
/// @param _minAmountOut An array specifying the minimum burn amounts for each token.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update code doc, it still refers to burn amounts

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 48ad03c

@parv3213 parv3213 mentioned this pull request Nov 23, 2023
@parv3213 parv3213 marked this pull request as ready for review December 18, 2023 13:31
@parv3213
Copy link
Member Author

This file has some TODO text, please do not merge yet. I will remove the TODOs after the review.

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