VELOCORE V2
V1 DocszkSyncEraLineaTelos
  • Introduction
  • Our Philosophy
    • Vision
    • Gas Optimization
    • General Bedrock for All Kinds of AMM
    • Epoch-less Predictability
    • Free Flowing Easy Vote System
  • DEX Innovation
    • Token Vault
      • Flashloan
    • Gas Saving Matters : Benchmark
    • AMM Flexibility
    • Multi In/Out Swap
    • Batch Swap
    • Adjustable Trading Fee Mechanics
    • Accumulating Swap Fees in LP Tokens
  • ve(3,3) Innovation
    • Removing 'Epoch' Systems
      • Bribe Optimization
    • Fungible Votes ($veVC)
      • No Decay & Easy Liquidation
    • Decentralized Gauge Deployment
    • Rebase Elimination
  • Security & Contract Address
    • zkSyncEra Contracts
    • Linea Contracts
    • Telos Contracts
    • V1 zkSyncEra (deprecated)
    • Three Rounds of Audits
  • Technical Docs
    • Concepts
    • Architecture Overview
      • Source Files Overview
    • How to interact with VELOCORE
      • Uniswap compatible interface
    • How to Read Data
    • Example Codes
      • Swap
      • Add liquidity
      • Stake
      • Voting
      • Multicall operations
      • cf) wrapper functions
    • Typescript Examples for Integration
    • Pool Specifics
      • Generalized CPMM
      • Wombat Stableswap
    • Events & Chart Integration
      • Getting a pair list
      • Interpreting Swap / LP events
    • Flashloan
  • zkSync Era
    • Migration Plan
      • $VC 1:1 Exchange
      • veNFT -> $veVC
      • One-Step LP Migration
      • Migration Schedule
      • Emission Migration
    • V2 Tokenomics
      • $VC Gauge
      • Bribe Mechanics
      • $veVC VOTING
    • Paymaster as a Service
  • Linea
    • Launch Details
      • Getting Ready
      • Bridging
      • V2 Launch Event
      • $LVC Presale
    • $LVC Tokenomics
      • $LVC Gauge
      • Bribe Mechanics
      • $veLVC VOTING
  • Telos
    • Launch Details
      • Getting Ready
      • Bridging
      • Launch Event
    • $TVC Tokenomics
      • $TVC Gauge
      • Bribe Mechanics
      • $veTVC VOTING
  • Free Loot Box for Future Airdrops
  • PASSPORT - F'air drops
  • Legal Disclaimer
  • Velocore Brand Assets
Powered by GitBook
On this page
  1. Technical Docs
  2. Events & Chart Integration

Interpreting Swap / LP events

Last updated 1 year ago

Let's look into Swap/Liquidity Provision(=yield farming) example transactions to decode what happened!

Vault contract in Linea : here

both swap and LPing emits the same topic0,

Swap(address indexed pool, address indexed user, bytes32[] tokenRef, int128[] delta).

  • topic0: 0xbaec78ca3218aba6fc32d82b79acdd1a47663d7b8da46e0c00947206d08f2071

  • zip(tokenRef, delta) indicates the tokens and their amounts.

Example 1 : Swap

You could know these from the Logs above.

{
    pool: 0xe2c67a9b15e9e7ff8a9cb0dfb8fee5609923e5db,
    user: 0xd466896b200c616de9b9d08e40e912f4f401edfa,
    tokenRef: [
      000000000000000000000000176211869CA2B568F2A7D4EE941E073A821EE1FF, // address of USDC
      0xEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE, // this represents ETH
    ],
    delta: [
      -1736669, // amount of USDC, negative because the user received USDC.
      1107379247714709, // amount of ETH, positive because the user paid ETH.
    ]
  }
  • You should interpret sign(+ or -) in target pool's perspective. Negetive for USDC since USDC are removed from the pool and positive for ETH since it is added to the pool. See here for the details : How to interact with VELOCORE

Example 2 : Adding liquidity

//If tokenRef address is the pool address, it means you are exchanging with LP token
// Exchange with LP token means you are adding or removing liquidity!
const isLP = (event) => event.tokenRef.contains(event.pool)
{
    pool: 0xf3e3ec2861850dfa6ba3f52a271f499afffb8087,
    user: 0x1234561fed41dd2d867a038bbdb857f291864225,
    tokenRef: [
      0x000000000000000000000000CC22F6AA610D1B2A0E89EF228079CB3E1831B1D1, // address of LVC
      0x000000000000000000000000F3E3EC2861850DFA6BA3F52A271F499AFFFB8087, // address of the lp token, deducible as it equals the pool address
      0xEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE, // this represents ETH
    ],
    delta: [
      1000000000000000000, // amount of LVC, positive because the user paid LVC
      -2000673813932133, // amount of the lp token, negative because the user received lp token
      4002695726920, // amount of ETH, positive because the user paid ETH
    ]
  }

https://lineascan.build/tx/0xd284cff083295905ab93b261ba5ed9905e1d61e9de39249f8e957f8f871fe944#eventloglineascan.build
https://lineascan.build/tx/0x3f24c49fa8404fea51ecb4a79d204813cd5acdaf06640fdf3e1a7b530cf26fda#eventloglineascan.build