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

BAL Hookathon - Volatility Fee Hook #87

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

t-phoenix
Copy link

🪝Volatility Fee Hook

A dynamic Swap Fee hook based on volatiltiy of the pool. The Hook calculates utilization ratio based on Amount of Token Out and Balance of Token Out in the pool, and charges higher fee when the utilization ratio increases.


🔑Key Advantages

  • Increased Protection during Volatility
  • Smoother Market Conditions
  • Disincentivizes Pool Exploits
  • Customisable Fee Logic
  • Reduction in Impermanent Loss for LPs

⭐️Volatility Fee Hook v1

was developed simply to discretely distinguish fee ranges:
Technicals:

  1. Utilization Ratio > 10%, pool/hook will charge x5 the staticSwapFee
  2. Utilization Ratio > 20%, pool/hook will charge x10 the staticSwapFee
  3. Utilization Ratio > 30%, pool/hook will charge x20 the staticSwapFee
  4. Utilization Ratio > 40%, pool/hook will charge x50 the staticSwapFee

Developers can update the fee charge ranges in function _calculateSwapFee.

  • Hook.sol: packages/foundry/contracts/hooks/VolatiltiyFeeHook.sol
  • Test.t.sol: packages/foundry/test/VolatilityFeeHook.t.sol

✨Volatility Fee Hook V2

v2 is developed on a continuous exponential curve for charging Swap Fee.
The core equation behind charging these swap fee is:

feeMultiplier = 1 + (utilization Ratio^2 * 99)

multiplying by 99 ensures that at max utilization the fee multiplier reaches 100x

  • Hook.sol: packages/foundry/contracts/hooks/VolatiltiyFeeHookV2.sol
  • Script.s.sol: packages/foundry/scripts/08_DeployVolatiltiyFeePool.s.sol

Copy link

vercel bot commented Oct 3, 2024

Someone is attempting to deploy a commit to the Matt Pereira's projects Team on Vercel.

A member of the Team first needs to authorize it.

@t-phoenix t-phoenix changed the title BAL Hookathon - Volatiltiy Fee Hook BAL Hookathon - Volatility Fee Hook Oct 3, 2024
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.

1 participant