Examples
Basic Setup
import { ethers } from 'ethers';
import { VinuSwap } from './sdk/core';
import { encodePrice, decodePrice } from './sdk/utils';
import { nearestUsableTick } from '@uniswap/v3-sdk';
// Configuration
const config = {
rpcUrl: 'https://rpc.vinuchain.org',
factory: '0xd74dEe1C78D5C58FbdDe619b707fcFbAE50c3EEe',
quoter: '0xEed635Fa2343355d9bA726C379F2B5dEa70fE65C',
router: '0x48f450475a8b501A7480C1Fd02935a7327F713Ad',
positionManager: '0xF699ec0764741f66F81068665eFFAeefA3c6037a',
wvc: '0xEd8c5530a0A086a12f57275728128a60DFf04230', // Wrapped VC (native token)
usdt: '0xC0264277fcCa5FCfabd41a8bC01c1FcAF8383E41', // USDT on VinuChain
pool: '0x...' // Pool address (depends on token pair)
};
// Helper: convert price to tick
function priceToTick(price: number): number {
return Math.floor(Math.log(price) / Math.log(1.0001));
}
// Setup
const provider = new ethers.providers.JsonRpcProvider(config.rpcUrl);
const signer = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);
async function getSDK() {
const sdk = await VinuSwap.create(
config.wvc,
config.usdt,
config.pool,
config.quoter,
config.router,
config.positionManager,
provider
);
return sdk.connect(signer);
}Swap Examples
Simple Swap
Swap with Price Limit
Multi-Hop Swap
Liquidity Examples
Create Position
Add to Existing Position
Collect Fees
Close Position
Pool Monitoring
Watch Pool State
Get Position Value
Error Handling
Full DApp Example
Last updated