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

Example Codes

Last updated 1 year ago

I'll define a few pseudo-code functions and constants to make snippets more concise.

Some are also defined in the

// Let's define a function for you to see more comfortably
function toTokenInfo(bytes1 _tokenRefIndex,uint8 _method,int128 _amount) pure returns (bytes32) {
    return bytes32(bytes1(_tokenRefIndex)) | bytes32(bytes2(uint16(_method))) | bytes32(uint256(uint128(uint256(int256(_amount)))));;
}
function toPoolId(uint8 _optype,address _pool) pure returns (bytes32){
    return bytes32(bytes1(_optype)) | bytes32(uint256(uint160(address(_pool))));
}
function toToken(IERC20 tok) pure returns (Token) {
    return Token.wrap(bytes32(uint256(uint160(address(tok)))));
}
function toToken(TokenSpecType spec_, uint88 id_, address addr_) pure returns (Token) {
    return Token.wrap(
        TokenSpecType.unwrap(spec_) | bytes32((bytes32(uint256(id_)) << ID_SHIFT) & ID_MASK)
            | bytes32(uint256(uint160(addr_)))
    );
}
// use NATIVE_TOKEN for ETH since we don't use weth internally
Token constant NATIVE_TOKEN = Token.wrap(0xEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE); //ref: lib/Token.sol
uint8 constant SWAP = 0;
uint8 constant GAUGE = 1;
uint8 constant CONVERT = 2;
uint8 constant VOTE = 3;
uint8 constant USERBALANCE = 4;

uint8 constant EXACTLY = 0;
uint8 constant AT_MOST = 1;
uint8 constant ALL = 2;

The helper functions above will help you populate the Token/poolId/TokenInfo struct.

These 3 components are all you need for execute!

Swap

Add liquidity

Stake

Voting

Multicall operations

cf) wrapper functions

lib/Token.sol