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

Sherlock-72 (continuation - move quote token): Lenders pay deposit fees due to no slippage control #918

Merged
merged 2 commits into from
Jul 1, 2023

Conversation

grandizzy
Copy link
Contributor

Description of change

High level

Contract size

Pre Change

============ Deployment Bytecode Sizes ============
  ERC721Pool               -  24,532B  (99.82%)
  ERC20Pool                -  23,815B  (96.90%)
  LenderActions            -  10,669B  (43.41%)

Post Change

============ Deployment Bytecode Sizes ============
  ERC721Pool               -  24,567B  (99.96%)
  ERC20Pool                -  23,850B  (97.04%)
  LenderActions            -  10,715B  (43.60%)

Gas usage

Pre Change

| moveQuoteToken                       | 847             | 152897 | 106051 | 632900 | 39      |
| moveQuoteToken                         | 40229           | 45431  | 40397  | 65849    | 5       |

Post Change

| moveQuoteToken                       | 1918            | 144589 | 106768 | 634238 | 40      |
| moveQuoteToken                         | 41558           | 46707  | 41726  | 66912    | 5       |

Copy link
Contributor

@EdNoepel EdNoepel left a comment

Choose a reason for hiding this comment

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

This is consistent with the proposed approach.

Assume the lender is already below the LUP, but is trying to move above the LUP. Even if they pass true, seems they will not get a revert. So the slippage protection is really only for those lenders currently above the LUP?

@grandizzy
Copy link
Contributor Author

grandizzy commented Jun 30, 2023

that's correct. lenders moving from below LUP won't pay deposit fee so slippage control to protect against is not needed

Copy link
Contributor

@EdNoepel EdNoepel left a comment

Choose a reason for hiding this comment

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

Alright; makes sense.

@@ -290,7 +290,8 @@ contract PositionManager is PermitERC721, IPositionManager, Multicall, Reentranc
uint256 tokenId_,

Choose a reason for hiding this comment

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

Shouldn't revert list be expanded with revertIfBelowLup_ case:

https://github.com/ajna-finance/contracts/blob/1f9d10259db03a94318fb39d9dddcee74fce0cbd/src/PositionManager.sol#L267-L287

    /**
     *  @inheritdoc IPositionManagerOwnerActions
     *  @dev    External calls to `Pool` contract:
     *  @dev    `bucketInfo()`: get from bucket info
     *  @dev    `moveQuoteToken()`: move liquidity between buckets
     *  @dev    === Write state ===
     *  @dev    `TokenInfo.positionIndexes`: remove from bucket index
     *  @dev    `TokenInfo.positionIndexes`: add to bucket index
     *  @dev    `TokenInfo.positions`: update from bucket position
     *  @dev    `TokenInfo.positions`: update to bucket position
     *  @dev    === Revert on ===
     *  @dev    - `mayInteract`:
     *  @dev      token id is not a valid / minted id
     *  @dev      sender is not owner `NoAuth()`
     *  @dev      token id not minted for given pool `WrongPool()`
     *  @dev    - positions token to burn has liquidity `RemovePositionFailed()`
     *  @dev    - tried to move from bankrupt bucket `BucketBankrupt()`
     *  @dev    === Emit events ===
     *  @dev    - `MoveQuoteToken`
     *  @dev    - `MoveLiquidity`
     */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the possible underlying reverts are not listed here but only the reverts from function logic

Copy link

@dmitriia dmitriia left a comment

Choose a reason for hiding this comment

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

Looks ok

@grandizzy grandizzy merged commit 94be5c2 into develop Jul 1, 2023
3 checks passed
Copy link
Contributor

@prateek105 prateek105 left a comment

Choose a reason for hiding this comment

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

LGTM

@grandizzy grandizzy deleted the sherlock-72-cont branch July 12, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants