Managing Fee Liquidity
The Fee AMM converts transaction fees between stablecoins when users pay in a different token than the validator prefers. This guide shows you how to add and remove liquidity to enable fee conversions.
Manage Fee Liquidity
demoSteps
Check pool reserves
Before adding liquidity, check the current pool reserves to understand the pool state.
import { } from 'wagmi/tempo'
import { } from 'viem'
const = '0x20c0000000000000000000000000000000000002' // BetaUSD
const = '0x20c0000000000000000000000000000000000001' // AlphaUSD
function () {
const { : } = ..({
,
,
})
return (
<>
<>User token reserves: {(?. ?? 0n, 6)}</>
<>Validator token reserves: {(?. ?? 0n, 6)}</>
</>
)
}Add liquidity
Add validator token to the pool to receive LP tokens representing your share. The first liquidity provider to a new pool must burn 1,000 units of liquidity. This costs approximately 0.002 USD and prevents attacks on pool reserves. Learn more in the Fee AMM specification.
import { } from 'wagmi/tempo'
import { , } from 'viem'
import { } from 'wagmi'
const = '0x20c0000000000000000000000000000000000002' // BetaUSD
const = '0x20c0000000000000000000000000000000000001' // AlphaUSD
function () {
const { } = ()
const { : } = ..({
,
,
})
const = ..()
return (
<>
<>User token reserves: {(?. ?? 0n, 6)}</>
<>Validator token reserves: {(?. ?? 0n, 6)}</>
< ="button" ={() => {
if (!) return
.({
: ,
: ,
: ('100', 6),
: ,
: ,
})
}}>
Add Liquidity
</>
</>
)
}Check your LP balance
View your LP token balance to see your share of the pool.
import { } from 'wagmi/tempo'
import { , } from 'viem'
import { } from 'wagmi'
const = '0x20c0000000000000000000000000000000000002' // BetaUSD
const = '0x20c0000000000000000000000000000000000001' // AlphaUSD
function () {
const { } = ()
const { : } = ..({
,
,
})
const { : } = ..({
,
,
,
})
const = ..()
return (
<>
<>LP token balance: {( ?? 0n, 6)}</>
<>User token reserves: {(?. ?? 0n, 6)}</>
<>Validator token reserves: {(?. ?? 0n, 6)}</>
< ="button" ={() => {
if (!) return
.({
: ,
: ,
: ('100', 6),
: ,
: ,
})
}}>
Add Liquidity
</>
</>
)
}Remove liquidity
Burn LP tokens to withdraw your share of pool reserves plus accumulated fees.
import { } from 'wagmi/tempo'
import { , } from 'viem'
import { } from 'wagmi'
const = '0x20c0000000000000000000000000000000000002' // BetaUSD
const = '0x20c0000000000000000000000000000000000001' // AlphaUSD
function () {
const { } = ()
const { : } = ..({
,
,
})
const { : } = ..({
,
,
,
})
const = ..()
const = ..()
return (
<>
<>LP token balance: {( ?? 0n, 6)}</>
<>User token reserves: {(?. ?? 0n, 6)}</>
<>Validator token reserves: {(?. ?? 0n, 6)}</>
< ="button" ={() => {
if (!) return
.({
: ,
: ,
: ('100', 6),
: ,
: ,
})
}}>
Add Liquidity
</>
< ="button" ={() => {
if (!) return
.({
,
,
: ('10', 6), // Burn 10 LP tokens
: ,
})
}}>
Remove Liquidity
</>
</>
)
}Recipes
Monitor pool utilization
Track fee swap activity to understand pool utilization and revenue.
import * as React from 'react'
import { } from 'wagmi/tempo'
import { } from 'viem'
const = '0x20c0000000000000000000000000000000000002' // BetaUSD
const = '0x20c0000000000000000000000000000000000001' // AlphaUSD
function () {
const [, ] = React.<any[]>([])
..useWatchFeeSwap({
,
,
() {
for (const of ) {
(() => [..., {
: (.args.amountIn, 6),
: (.args.amountOut, 6),
: (.args.amountIn * 30n / 10000n, 6),
}])
}
},
})
return (
<>
{.((, ) => (
< ={}>
Swap: {.amountIn} → {.amountOut} (LP revenue: {.revenue})
</>
))}
</>
)
}Rebalance pools
You can rebalance pools by swapping validator tokens for accumulated user tokens at a fixed rate. Rebalancing restores validator token reserves and enables continued fee conversions. Learn more here.
import { } from 'wagmi/tempo'
import { , } from 'viem'
import { } from 'wagmi'
const = '0x20c0000000000000000000000000000000000002' // BetaUSD
const = '0x20c0000000000000000000000000000000000001' // AlphaUSD
function () {
const { } = ()
const { : } = ..({
,
,
})
const = ..()
return (
<>
<>User token reserves: {(?. ?? 0n, 6)}</>
<>Validator token reserves: {(?. ?? 0n, 6)}</>
< ="button" ={() => {
if (! || !) return
// Swap validator token for user token at 0.9985 rate
.({
,
,
: ., // Amount of user token to receive
: ,
})
}}>
Rebalance
</>
</>
)
}Best Practices
Monitor pool reserves
Regularly check pool reserves to ensure sufficient liquidity for fee conversions. Low reserves can prevent transactions from being processed.
Add liquidity when:
- Transaction rates increase for a given
userToken - Reserve levels drop below expected daily volume
- Multiple validators begin preferring the same token
Maintain adequate reserves
As an issuer, keep sufficient validator token reserves to handle expected transaction volume. Consider your anticipated fee conversion volume when determining reserve levels.
For new token pairs, provide the entire initial amount in the validator token. The pool naturally accumulates user tokens as fees are paid.
Deploy liquidity strategically
Focus liquidity on pools with:
- High transaction volume and frequent fee conversions
- New stablecoins that need initial bootstrapping
- Validator tokens preferred by multiple validators
Learning Resources
Complete technical specification of the Fee AMM protocol
Learn how the Fee AMM enables flexible fee payments
Enable users to pay fees using your stablecoin