Aptos Data Analyst Guide: DeFi Swap Transactions (Part 2)

·

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:

  1. Coins: Traditional token standard (0x1::coin::CoinStore)
  2. Fungible Assets (FA): Flexible asset standard (0x1::fungible_asset)

Key differences:

DeFi Transaction Categories

  1. Spot trading (AMM, CLOB)
  2. Asset lending
  3. Liquidity staking derivatives

Analyzing Swap Transactions

1. Coin-Based Swap (Liquidswap)

Example Transaction: 2224014200

Key Observations:

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:

👉 Master Aptos analytics with Liquidswap


2. Fungible Asset Swap (Cellana)

Example Transaction: 2293960645

Key Differences:

Transaction Flow:

  1. APT deposited to Cellana's CoinStore
  2. Cellana mints FA-represented APT
  3. FA-APT swapped for FA-USDt via pool
  4. 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:

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

TypeExample Coin TypeFA Address
LayerZero USDC0xf22b...7fa::asset::USDC0xbae2...f3b
Wormhole USDT0xa2ed...852::coin::T0x357b...c2b

Oracle Implementations

  1. Pyth: Prices pushed to table items
  2. Switchboard: Prices in resources
  3. 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 handle

FAQ

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:

How do aggregators improve swap rates?

By:

  1. Comparing real-time liquidity across multiple pools
  2. Executing multi-hop swaps atomically
  3. Minimizing price impact through optimized routing

Conclusion

This guide equips analysts with practical techniques for dissecting Aptos DeFi transactions. Key takeaways:

For deeper analysis, leverage:

Exercise: Analyze these complex aggregated swaps: