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

chore: tweak min share validation #169

Merged
merged 1 commit into from
Sep 11, 2024
Merged

chore: tweak min share validation #169

merged 1 commit into from
Sep 11, 2024

Conversation

ChefMist
Copy link
Collaborator

This PR tweaks the minBinShareForDonate from 1e18 to 1e3

Context:

  1. we added the limitation as part of this PR: [Ottersec-3-v2] feat: require min share before donate  #148
  2. 1e18 was a magic number we derived as for most cases, most pool will have at least that amount of liquidity easily

Why we change:

  1. potentially there might be other scenario that we've missed where pool might have lesser than 1e18 liqudity (eg. pool where token0 and token1 price differences are very big and very little token in pool)

  2. 1e3 would probably be a good min level (similar to pcs v2 of burning 10e3 lp), as attacker need at least 3x fund of victim to perform share inflation. eg. if they mint with 1000 token, attacker need 1000 * 1e3 tokens.

However we are keeping the initial 2 ** 128 for now until we see such cases where we need to adjust setMinBinSharesForDonate

@@ -303,7 +303,7 @@ contract BinPoolManager is IBinPoolManager, ProtocolFees, Extsload {

/// @inheritdoc IBinPoolManager
function setMinBinSharesForDonate(uint256 minBinShare) external override onlyOwner {
if (minBinShare < 1e18) revert MinShareTooSmall();
if (minBinShare < 1e3) revert MinShareTooSmall();
Copy link
Collaborator

Choose a reason for hiding this comment

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

One suggestion , we can remove the minBinShare limit check in BinPoolManager, then add limit in PCS poolManagerOwner contract.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeh good call, i think we can

1/ leave the updated check in PoolManager in this PR merged
2/ when the upcoming PR of poolManagerOwner contract come, then we can remove this check

@ChefMist ChefMist mentioned this pull request Sep 11, 2024
@ChefMist ChefMist merged commit c2719e0 into main Sep 11, 2024
2 checks passed
@ChefMist ChefMist deleted the feat/update-min-share branch September 11, 2024 05:37
Copy link

@Uzoke22 Uzoke22 left a comment

Choose a reason for hiding this comment

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

good 👍

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.

3 participants