Curve V2
Curve V2 (also known as Curve Finance V2 or CurveFi V2) is an advanced decentralized exchange protocol specialized in efficient stablecoin trading with low slippage, even for large trades. V2 introduces significant improvements over V1, including concentrated liquidity and dynamic fees.
Overview
Curve V2 introduced several key innovations:
- Concentrated Liquidity: Improved capital efficiency through concentrated liquidity positions
- Dynamic Fees: Fees that adjust based on market volatility and pool utilization
- Tricrypto Pools: Support for pools with three different tokens, including non-stablecoins
- Metapools: Pools that combine a stablecoin with an LP token from another pool
- Lending Integration: Built-in lending functionality for improved capital efficiency
Integration with Bloctopus
When using Bloctopus with a forked Ethereum network, you can interact with Curve V2 contracts that are already deployed on mainnet. This allows you to test your DeFi applications against real Curve V2 liquidity pools.
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 Curve V2 contracts you'll interact with:
- Factory:
0xF18056Bbd320E96A48e3Fbf8bC061322531aac99
(CryptoSwapFactory) - Registry:
0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5
(Registry) - AddressProvider:
0x0000000022D53366457F9d5E68Ec105046FC4383
- Tricrypto Pool:
0xD51a44d3FaE010294C616388b506AcdA1bfAAE46
(Example: tricrypto2)
Sample Implementation
The DeFi Samples repository contains ready-to-use scripts for interacting with Curve V2:
- Query: query.js - Get information about Curve V2 pools and their current state
- Quote: quote.js - Get price quotes for token swaps between pool assets
- Swap: swap.js - Execute token swaps on Curve V2 pools
Running the Scripts
To run these scripts with Bloctopus:
Clone the DeFi Samples repository:
git clone https://github.com/LZeroAnalytics/defi-samples.git
cd defi-samplesInstall dependencies:
npm install
Create a
.env
file with your Bloctopus RPC endpoint and private key:RPC_URL=https://your-bloctopus-rpc-endpoint
PRIVATE_KEY=your-private-keyRun a script:
npx hardhat run scripts/protocols/curve-v2/query.js
npx hardhat run scripts/protocols/curve-v2/quote.js
npx hardhat run scripts/protocols/curve-v2/swap.js
Testing with Bloctopus
To test Curve V2 interactions using Bloctopus:
- Create a forked Ethereum network in Bloctopus
- Configure your Hardhat project to use the Bloctopus RPC endpoint
- Run your scripts or tests against the forked network