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. Example Codes

Add liquidity

Following the swap example, here's an example of adding an ETH-USDC LP. The context is in the previous example, so I'll just paste the core code.

Here we're showing an example of creating liquidity using both tokens in a pair, but since Velocore's LPs all allow imbalanced deposits, it doesn't matter if it's just one. The frontend shows this as a 'Magic deposit'.

**Always refer Example Codes to see what was the exact implementation of helper functions like toToken, toPoolId, toTokenInfo.

// Add LP involves 3 tokens. ETH, USDC, LP token.
Token[] memory tokens = new Token[](3);
tokens[0] = toToken(IERC20(usdc));
tokens[1] = NATIVE_TOKEN;
tokens[2] = toToken(IERC20(usdc_eth_lp));

// Adding LP is swapping 2 tokens to 1 lp. So op type is again, swap!
VelocoreOperation[] memory ops = new VelocoreOperation[](1);
ops[0].poolId = toPoolId(SWAP,usdc_eth_lp);
ops[0].tokenInformations = new bytes32[](3);
// We use "EXACTLY" for the amount we know and "AT_MOST" for what we don't know exactly but expect to receive at least a certain amount.
// Want to use 0.1e6 USDC(index 0) + 0.001e18 ETH(index 1) in exchange for at least 0 LP(index 2). (apply your slippage here)
ops[0].tokenInformations[0] = toTokenInfo(0x00,EXACTLY,0.1e6);
ops[0].tokenInformations[1] = toTokenInfo(0x01,EXACTLY,0.001e18);
ops[0].tokenInformations[2] = toTokenInfo(0x02,AT_MOST,0);
ops[0].data = "";

//we just called execute() here but of course if you are calling an external contract with ETH value transfer involved,
// you should write it like this : vault.execute{value:0.001e18}(tokens, new int128[](3), ops);
return execute(tokens, new int128[](3), ops);

Last updated 1 year ago