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

feat: discrete swap fee accounting #8

Merged
merged 10 commits into from
Sep 16, 2024
Merged

feat: discrete swap fee accounting #8

merged 10 commits into from
Sep 16, 2024

Conversation

parketh
Copy link
Contributor

@parketh parketh commented Sep 16, 2024

Summary

This PR updates the swap fee accounting approach used by Solvers. Under the old architecture, swap fees are aggregated along with other pool deposits. This accounting approach is simple, but introduces three limitations:

  1. fee APYs become hard to estimate
  2. relatedly, it is hard to attribute fee earnings to individual pool depositors
  3. as fees are charged (implicitly) via a spread in the virtual liquidity position, LPs of higher-spread pools are unfairly penalised because the higher spread is results in lower liquidity concentration (and STRK rewards)

Updates

This PR adds explicit swap fee balances to each Solver market to more accurately track accrued swap fees. To account for the different fee balances accrued by depositors over time, we introduce a new 'fee per share' accumulator variable, similar to the fee factor used in our core AMM implementation (or Uniswap V3's seconds per liquidity).

This also results in a number of consequential changes to the contract interfaces and emitted events, which we have updated documentation for.

Testing

scarb build
snforge test --max-n-steps 4294967295  

@parketh parketh merged commit b6bef80 into main Sep 16, 2024
1 check passed
@parketh parketh deleted the feat/explicit-swap-fees branch September 16, 2024 15:00
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