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
  • Swap
  • Examples
  • Vote
  1. Technical Docs

Events & Chart Integration

Last updated 1 year ago

All events are emitted from Vault(=Router) contract.

CA references : ,

Vault interface file

SwapFacet implementation

Example event logs :

ETH->USDC swap

Add liquidity ETH+USDC

magic deposit USD+=>USDC-ETH LP (includes swap & staking)

Note that swap operation event includes swap, veVC conversion, and LP deposit/withdrawal. cf)

Swap

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

Whenever a user exchanges tokens with a pool, Swap event gets emitted.

  • pool

  • user is the user interacting with the pool.

  • tokenRef

    • Token: Velocore V2 supports not only ERC20 but also ERC721, ERC1155, and native tokens. Tokens are represented as a wrapped bytes32 (Token), specifically:

      • 1 byte of token type

        • 0x00: ERC20

        • 0x01: erc721

        • 0x02: erc1155

      • 11 bytes of token id:

        • always 0 for ERC20

        • nft id or token id for ERC721 and erc1155

        • token ids greater than 2^88 - 1 is unsupported

      • 20 bytes of token address

      • native token is represented as 0xeeeee...eeeee.

  • delta is the list of balance changes as the result of the interaction, in the same order as tokenRef

    • it is positive when pool received the token from the user (i.e. the user sold the token)

    • it is negative when user received the token from the pool (i.e. the user bought the token)

Swapis emitted both for LP deposit/withdrawal and simple swaps. The difference is that LP deposit/withdrawal event includes the LP token (having the same address as pool in the event), which represents that the user received/burned the LP token, whreas simple swaps dont.

function isSwap(pool, user, tokenRef, delta) {
    return (
        does any element of tokenRef has _pool_ as its last 20 bytes?
    );
}

Examples

  1. Pure swap event (Token<>ETH or Token<>Token)

Swap(
    pool: 0x42D106c4A1d0Bc5C482c11853A3868d807A3781d,
    user: 0x1234561fEd41DD2D867a038bBdB857f291864225,
    tokenRef: [
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x0000000000000000000000003355df6D4c9C3035724Fd0e3914dE96A5a83aaf4"
    ],
    delta: [
        100000000,
        -102301045
    ]
)

the event above tells that a user (0x1234561fEd41DD2D867a038bBdB857f291864225) interacted with the USDC/ETH pool (0x42D106c4A1d0Bc5C482c11853A3868d807A3781d, selling 100000000 wei of ethereum (0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) for 102301045 wei of USDC (ERC20:0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4).

Price, Volume, trader's info could be drawn directly from above example.

  1. LP related event (add/remove LP, magic deposit)

Swap(
    pool: 0x42D106c4A1d0Bc5C482c11853A3868d807A3781d,
    user: 0x1234561fEd41DD2D867a038bBdB857f291864225,
    tokenRef: [
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x0000000000000000000000003355df6D4c9C3035724Fd0e3914dE96A5a83aaf4",
        "0x00000000000000000000000042D106c4A1d0Bc5C482c11853A3868d807A3781d",
    ],
    delta: [
        101240000,
        102301045,
        -100000000
    ]
)

the event above tells that a user (0x1234561fEd41DD2D867a038bBdB857f291864225) interacted with the USDC/ETH pool (0x42D106c4A1d0Bc5C482c11853A3868d807A3781d, depositing 101240000 wei of ethereum (0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) and 102301045 wei of USDC (ERC20: 0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4), and received 100000000 wei of the LP token (42D106c4A1d0Bc5C482c11853A3868d807A3781d) in exchange.

Since unbalanced LP deposit(magic deposit) is possible, ratio here can't be used as a price feed unlike simple swap.

We recommend only using pure swap for price feed updates and chart volume data for easy integration. If the tokenRef contains an LP address, you can catch the event separately as an add/remove LP event and do not need to calculate the swap volume. This is because the swap volume generated by this will usually be a very small fraction of the total.

  1. Removing LP using Magic withdrawal ( ETH-USDC LP -> ETH )

Swap(
    pool: 0x42D106c4A1d0Bc5C482c11853A3868d807A3781d,
    user: 0x1234561fEd41DD2D867a038bBdB857f291864225,
    tokenRef: [
        "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
        "0x00000000000000000000000042D106c4A1d0Bc5C482c11853A3868d807A3781d",
    ],
    delta: [
        -202301045,
        100000000
    ]
)

the event above tells that a user (0x1234561fEd41DD2D867a038bBdB857f291864225) interacted with the USDC/ETH pool (0x42D106c4A1d0Bc5C482c11853A3868d807A3781d, returning 100000000 wei of the LP token (42D106c4A1d0Bc5C482c11853A3868d807A3781d), and receiving 202301045 wei of ethereum (0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) in exchange.

Same as above, you could exactly calculate the swap volume using the fee generated, but that would require a reserve query. We'd recommend ignoring the swap volume here and just considering it as an LP related transaction when integrating to the chart.

Vote

event Vote(IGauge indexed pool, address indexed user, int256 voteDelta);

whenever a user votes or claims bribe, Vote gets emitted.

voteDelta is positive when the user adds vote, and negative when user decreases vote.

voteDelta can be 0, which means that the user just claimed the bribe.

zkSyncEra
Linea
link
link
scan link
scan link
scan link
Operation types