Skip to main content

Uniswap V4

AceSteps uses Uniswap V4 for decentralized song token trading.

Why Uniswap V4?

  • Hooks: Custom logic during swaps
  • Singleton Design: All pools in one contract
  • Native ETH: Trade with ETH directly
  • donate(): Add value to pools without swapping

Pool Configuration

const poolKey = {
currency0: ETH_ADDRESS,
currency1: songTokenAddress,
fee: 10000, // 1%
tickSpacing: 60,
hooks: revenueHookAddress
};

Hooks Used

afterSwap

Tracks swap activity for analytics:

function afterSwap(...) external {
emit SwapExecuted(tokenId, sender, amount);
}

Revenue distribution without swapping:

poolManager.donate(poolKey, ethAmount, 0, "");

Trading Interface

// Buy tokens
await uniswapRouter.swap({
poolKey,
params: {
zeroForOne: true, // ETH → Token
amountSpecified: ethAmount
}
});

// Sell tokens
await uniswapRouter.swap({
poolKey,
params: {
zeroForOne: false, // Token → ETH
amountSpecified: tokenAmount
}
});