This comprehensive guide explores DeFi swap transactions on the Aptos blockchain, analyzing exchange mechanisms across major DEXs like Liquidswap, Cellana, and Panora. Discover how to track on-chain data through events, resource changes, and GraphQL APIs while learning the differences between Coin and Fungible Asset (FA) transactions. The guide also covers stablecoins and oracles in the Aptos ecosystem.
Core Concepts in Aptos DeFi
Asset Standards in Aptos
Aptos supports two primary asset types:
- Coins: Traditional token standard (
0x1::coin::CoinStore) - Fungible Assets (FA): Flexible asset standard (
0x1::fungible_asset)
Key differences:
- Coins can exist in CoinStores or arbitrary resources
- Each FA requires a dedicated FungibleStore per owner
DeFi Transaction Categories
- Spot trading (AMM, CLOB)
- Asset lending
- Liquidity staking derivatives
Analyzing Swap Transactions
1. Coin-Based Swap (Liquidswap)
Example Transaction: 2224014200
Key Observations:
- 16.182 APT swapped for 48k MOOMOO
- 0.1% fee deducted (visible in Liquidswap pool events)
- Oracle price updates emitted mid-transaction
Data Extraction Methods:
-- BigQuery example
SELECT *
FROM `crypto_aptos_mainnet_us.transactions`
WHERE payload.entry_function_id_str = '0x9dd974aea0f927ead664b9e1c295e4215bd441a9fb4e53e5ea0bf22f356c8a2b::router::swap_exact_coin_for_coin_x1'Tracking Balance Changes:
- APT withdrawn from sender's CoinStore (Event Index 0)
- MOOMOO deposited to sender's CoinStore (Event Index 4)
- Intermediate assets held in pool resources (no associated events)
👉 Master Aptos analytics with Liquidswap
2. Fungible Asset Swap (Cellana)
Example Transaction: 2293960645
Key Differences:
- Uses FA instead of Coins
Requires FungibleStore lookups via deterministic address:
sha3_256(account_address | metadata_address | 0xFC)
Transaction Flow:
- APT deposited to Cellana's CoinStore
- Cellana mints FA-represented APT
- FA-APT swapped for FA-USDt via pool
- USDt deposited to sender's FungibleStore
GraphQL Query Example:
query GetFABalances {
fungible_asset_activities(
where: {transaction_version: {_eq: "2293960645"}}
) {
asset_type
amount
storage_id
}
}3. Aggregated Swap (Panora)
Example Transaction: 2221267359
Key Features:
- Atomic multi-pool routing (Thala v1 + Thala v2)
- Native coin↔FA migration (no emitted events)
- Migration detected via FA supply changes
Migration Mapping Logic:
# Coin-to-FA address conversion
sha3_256(apt_metadata_bytes + coin_type.encode() + 0xFE)👉 Optimize swaps with Panora aggregation
Stablecoins & Oracles
Bridged vs Native Assets
| Type | Example Coin Type | FA Address |
|---|---|---|
| LayerZero USDC | 0xf22b...7fa::asset::USDC | 0xbae2...f3b |
| Wormhole USDT | 0xa2ed...852::coin::T | 0x357b...c2b |
Oracle Implementations
- Pyth: Prices pushed to table items
- Switchboard: Prices in resources
- Chainlink: SmartTable-based feeds
Pyth Price Query Example:
SELECT
JSON_VALUE(value.content, "$.price_feed.price.price.magnitude") as price
FROM `crypto_aptos_mainnet_us.table_items`
WHERE address = '0xd132...c49' -- Pyth table handleFAQ
How do I track coins not in CoinStores?
Scan all resources containing 0x1::coin::Coin types - coins may be embedded in smart contract resources.
What's the advantage of FA over Coins?
Fungible Assets enable:
- Per-asset metadata customization
- Native migration capabilities
- Simplified AMM pool accounting
How do aggregators improve swap rates?
By:
- Comparing real-time liquidity across multiple pools
- Executing multi-hop swaps atomically
- Minimizing price impact through optimized routing
Conclusion
This guide equips analysts with practical techniques for dissecting Aptos DeFi transactions. Key takeaways:
- Coin vs FA transactions require different tracking approaches
- Events reveal intermediate steps, while resources show final state
- Native migration enables seamless coin↔FA conversions
For deeper analysis, leverage:
Exercise: Analyze these complex aggregated swaps: