Skip to main content

Sushiswap V2

Sushiswap V2 is a fork of Uniswap V2 with additional features and incentives. It operates as an automated market maker (AMM) that allows users to swap tokens, provide liquidity, and earn rewards.

Overview

Sushiswap V2 offers several key features:

  • Token Swaps: Exchange one ERC-20 token for another
  • Liquidity Provision: Add tokens to liquidity pools and earn fees
  • Yield Farming: Earn SUSHI tokens by staking LP tokens
  • Governance: Participate in protocol decisions through the SUSHI token
  • BentoBox: A vault system that powers various Sushi products

Integration with Bloctopus

When using Bloctopus with a forked Ethereum network, you can interact with Sushiswap V2 contracts that are already deployed on mainnet. This allows you to test your DeFi applications against real Sushiswap V2 liquidity pools.

info

This sample guide is for forked Ethereum networks but you can adapt the respective contract addresses when using other forked networks (e.g. Optimism, Arbitrum)

Key Contracts

The main Sushiswap V2 contracts you'll interact with:

  • Factory: 0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac
  • Router: 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F
  • MasterChef: 0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd

Sample Implementation

The DeFi Samples repository contains ready-to-use scripts for interacting with Sushiswap V2:

  • Query: query.js - Get information about Sushiswap V2 pairs and reserves
  • Quote: quote.js - Get price quotes for token swaps and compare with Uniswap
  • Swap: swap.js - Execute token swaps on Sushiswap V2

Running the Scripts

To run these scripts with Bloctopus:

  1. Clone the DeFi Samples repository:

    git clone https://github.com/LZeroAnalytics/defi-samples.git
    cd defi-samples
  2. Install dependencies:

    npm install
  3. Create a .env file with your Bloctopus RPC endpoint and private key:

    RPC_URL=https://your-bloctopus-rpc-endpoint
    PRIVATE_KEY=your-private-key
  4. Run a script:

    npx hardhat run scripts/protocols/sushiswap-v2/query.js
    npx hardhat run scripts/protocols/sushiswap-v2/quote.js
    npx hardhat run scripts/protocols/sushiswap-v2/swap.js

Testing with Bloctopus

To test Sushiswap V2 interactions using Bloctopus:

  1. Create a forked Ethereum network in Bloctopus
  2. Configure your Hardhat project to use the Bloctopus RPC endpoint
  3. Run your scripts or tests against the forked network

Resources