Skip to content

Conversation

@pileks
Copy link
Contributor

@pileks pileks commented Dec 18, 2025

Restructures how AMM swap fees are distributed and adds a mechanism to extract accumulated liquidity as protocol fees.

Fee redistribution: Changed the taker fee split from 0.25% LP / 0.25% protocol to 0% LP / 0.5% protocol. All swap fees now go directly to the protocol rather than being added to LP reserves.

New collect_lp_fees instruction: Allows the MetaDAO multisig to withdraw liquidity from the spot AMM down to a specified target K value while preserving the current price. This addresses a gap in the previous design where LP fees were added to pool reserves but never tracked separately—making them indistinguishable from initial liquidity.

Mechanics

The collect_lp_fees instruction reduces pool reserves proportionally to maintain the price ratio:

x' = x × sqrt(K') / sqrt(K)
y' = y × sqrt(K') / sqrt(K)

Where K is current liquidity (x×y), K' is the target liquidity, and x'/y' are the new reserves. The difference (x - x', y - y') is transferred to the caller.

@pileks pileks self-assigned this Dec 18, 2025
@pileks pileks changed the title protocol should collect all fees Protocol/LP fee restructuring Dec 19, 2025
@pileks pileks marked this pull request as ready for review December 19, 2025 00:00
- properly increase sequence number
- Check for square root edge case due to floor/ceil square rooting
- Implement basic div_ceil for target reserves calculation, favoring the protocol for the one-off fee take
@metaproph3t metaproph3t merged commit 9dd5c52 into develop Dec 22, 2025
1 check passed
@metaproph3t metaproph3t deleted the futarchy-amm-fee-updates branch December 22, 2025 23:57
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