SWAPS
Introduction
Swaps are the primary method for exchanging tokens on HOOKED!. The process is simple: users select a token they want to sell and a token they want to receive. The protocol automatically calculates the exchange rate, deducts a small fee that goes to liquidity providers, and executes the trade. All swaps are permissionless, meaning anyone can trade without requiring approval.
Web interfaces built on top of HOOKED! may add their own restrictions or modify execution behavior. For the most direct experience, interact with the protocol contracts directly.
HOOKED! swaps differ fundamentally from traditional exchange models. Instead of matching buyers and sellers through an order book, swaps execute against a shared liquidity pool. Liquidity providers contribute capital to these pools and earn fees based on their proportional share, creating a passive income model that doesn't require active order management.
Price Impact
In traditional markets, large orders can consume multiple limit orders at different prices, resulting in an average execution price somewhere between the best and worst prices filled.
Automated market makers create a similar effect through a different mechanism. As a swap executes, the relative price between the two assets shifts continuously. The final execution price reflects where the price started and where it ended after consuming liquidity through the price curve.
This price movement is inherent to AMM design and affects every swap on HOOKED!. The magnitude of price impact depends on two factors: the size of the swap and the depth of available liquidity. More liquidity means smaller price movements for the same trade size. Less liquidity means larger price movements.
The HOOKED! interface calculates expected price impact before you submit a transaction and displays warnings if impact is unusually high. This gives users the information they need to make informed trading decisions.
Slippage
Slippage refers to price changes that can occur between when you submit a transaction and when it actually executes on-chain.
On Ethereum, transaction execution order depends on gas fees. Higher fees get processed faster, while lower fees may wait in the mempool for extended periods. During this waiting time, other swaps can change the market price, potentially affecting your trade's execution price.
Slippage tolerance sets an acceptable price range for your swap. If you set 1% slippage, for example, your transaction will execute as long as the final price is within 1% of the expected price. If price moves beyond this tolerance, the transaction reverts to protect you from unfavorable execution.
Think of it like placing a market order that might execute minutes later. You know the approximate price when you submit, but market conditions can change before execution completes.
Safety Checks
Since both price impact and slippage can change while transactions are pending, HOOKED! includes multiple safety mechanisms to protect users from unexpected outcomes:
Expired: Transactions include a deadline timestamp. If your transaction hasn't executed by this deadline, it automatically fails. This prevents trades from executing after extended delays when market conditions may have changed significantly.
INSUFFICIENT_OUTPUT_AMOUNT: Before submitting, the interface shows an estimated amount you'll receive. If the actual output would fall outside your slippage tolerance, the transaction reverts. This protects against scenarios where price moves unfavorably while your transaction is pending.
These checks work together to ensure users maintain control over their trades and aren't surprised by execution prices that differ substantially from expectations.