Examples

This guide provides examples for using Doppler V4 with Custom Fees and various optional govenance

Note on startTimeOffset: The startTimeOffset parameter is included in the type definitions but is not currently used by the SDK implementation. All pools will start 30 seconds after the transaction is confirmed. This will be addressed in a future update.

Prerequisites

import { 
  ReadWriteFactory,
  BeneficiaryData,
  V4MigratorData,
  DEAD_ADDRESS,
  DOPPLER_V4_ADDRESSES
} from 'doppler-v4-sdk';
import { createPublicClient, createWalletClient, http, parseEther } from 'viem';
import { base } from 'viem/chains';
import { Drift } from '@delvtech/drift';
import { viemAdapter } from '@delvtech/drift-viem';

// Setup clients
const publicClient = createPublicClient({
  chain: base,
  transport: http()
});

const walletClient = createWalletClient({
  chain: base,
  transport: http(),
  account: privateKeyToAccount('0x...') // Your private key
});

// Setup Drift
import { createDrift } from '@delvtech/drift';

const drift = createDrift({ adapter: viemAdapter({ publicClient, walletClient }) });

// Get addresses for your chain
const addresses = DOPPLER_V4_ADDRESSES[base.id];

// Initialize factory
const factory = new ReadWriteFactory(addresses.airlock, drift);

Example 1: Standard Token Launch with Governance

This example launches a token with standard governance, where 90% of liquidity goes to the timelock and 10% to the StreamableFeesLocker.

Example 2: No-Op Governance Launch (100% Locked Liquidity)

This example launches a token with no-op governance, where 100% of liquidity is permanently locked in the StreamableFeesLocker.

Example 3: Custom Quote Token Launch

This example shows launching with a custom quote token (not ETH).

Example 4: Multicurve Token Launch

This example shows launching with Doppler Multicurve.

Post-Launch Operations

After launching, you can interact with the StreamableFeesLocker:

Important Notes

  1. Governance Choice:

    • useGovernance: true (default) = 90% to timelock, 10% to locker (this split is automatic and handled by the V4Migrator contract)

    • useGovernance: false = 100% to locker, permanent lock

  2. Beneficiary Requirements:

    • Must be sorted by address (use sortBeneficiaries())

    • Shares must sum to exactly 1e18

    • Cannot have duplicate addresses

  3. Price Ranges:

    • For ETH pairs: prices in ETH (18 decimals)

    • For custom pairs: prices in quote token decimals

  4. Testing Recommendations:

    • Test on testnet first (Base Sepolia, Unichain Sepolia, etc.)

    • Verify beneficiary addresses

    • Double-check share calculations

    • Ensure sufficient quote token liquidity exists

Last updated