### Install Doppler SDK and viem Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/get-started Installs the Doppler SDK and viem library using different package managers. Viem is a modular TypeScript interface for interacting with Ethereum. ```bash npm install @whetstone-research/doppler-sdk viem ``` ```bash yarn add @whetstone-sdk/doppler-sdk viem ``` ```bash pnpm add @whetstone-research/doppler-sdk viem ``` -------------------------------- ### Create a Dynamic Auction Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/get-started Example of creating a dynamic auction using the Doppler SDK's DynamicAuctionBuilder. This includes configuring token details, sale parameters, pool settings, auction specifics, vesting, migration options, and user address before building and deploying the auction. ```typescript import { DynamicAuctionBuilder } from '@whetstone-research/doppler-sdk' const params = new DynamicAuctionBuilder() .tokenConfig({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/metadata.json' }) .saleConfig({ initialSupply: parseEther('1000000'), numTokensToSell: parseEther('900000'), numeraire: '0x...' }) .poolConfig({ fee: 3000, tickSpacing: 60 }) .auctionByTicks({ durationDays: 7, epochLength: 3600, startTick: -92103, endTick: -69080, minProceeds: parseEther('100'), maxProceeds: parseEther('1000'), numPdSlugs: 5, }) .withVesting({ duration: BigInt(365 * 24 * 60 * 60) }) .withMigration({ type: 'uniswapV4', fee: 3000, tickSpacing: 60, streamableFees: { lockDuration: 365 * 24 * 60 * 60, beneficiaries: [ { address: '0x...', percentage: 5000 }, { address: '0x...', percentage: 5000 }, ], }, }) .withUserAddress('0x...') .build() const result = await sdk.factory.createDynamicAuction(params) console.log('Hook address:', result.hookAddress) console.log('Token address:', result.tokenAddress) ``` -------------------------------- ### Initialize Doppler SDK with viem Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/get-started Sets up viem clients for interacting with the Ethereum blockchain and initializes the Doppler SDK. Requires a public client and a wallet client with a connected account. ```typescript import { DopplerSDK } from '@whetstone-research/doppler-sdk'; import { createPublicClient, createWalletClient, http } from 'viem'; import { base } from 'viem/chains'; // Set up viem clients const publicClient = createPublicClient({ chain: base, transport: http(), }); const walletClient = createWalletClient({ chain: base, transport: http(), account: '0x...', // Your wallet address }); // Initialize the SDK const sdk = new DopplerSDK({ publicClient, walletClient, chainId: base.id, }); ``` -------------------------------- ### Install Unified Doppler SDK Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Removes old Doppler SDK packages and installs the new unified SDK along with viem. ```bash # Remove old packages npm uninstall @doppler/v3-sdk @doppler/v4-sdk ethers # Install new packages npm install @whetstone-research/doppler-sdk viem ``` -------------------------------- ### Installation Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Instructions for removing old Doppler SDK packages and installing the new unified SDK along with viem. ```APIDOC ## Installation Remove the old packages and install the new unified SDK: ```bash # Remove old packages npm uninstall @doppler/v3-sdk @doppler/v4-sdk ethers # Install new packages npm install @whetstone-research/doppler-sdk viem ``` ``` -------------------------------- ### Initialization Changes Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Compares the initialization process for the Doppler SDK between V3, V4, and the unified SDK, demonstrating the shift to viem and the builder pattern. ```APIDOC ## Initialization Changes ### Before (V3 SDK) ```javascript import { ReadWriteFactory } from '@doppler/v3-sdk'; import { ethers } from 'ethers'; const provider = new ethers.providers.JsonRpcProvider(rpcUrl); const signer = new ethers.Wallet(privateKey, provider); const factory = new ReadWriteFactory(signer, chainId); ``` ### Before (V4 SDK) ```javascript import { ReadWriteFactory } from '@doppler/v4-sdk'; import { ethers } from 'ethers'; const provider = new ethers.providers.JsonRpcProvider(rpcUrl); const signer = new ethers.Wallet(privateKey, provider); const factory = new ReadWriteFactory(signer, chainId); ``` ### After (Unified SDK) ```javascript import { DopplerSDK } from '@whetstone-research/doppler-sdk'; import { createPublicClient, createWalletClient, http } from 'viem'; import { base } from 'viem/chains'; import { privateKeyToAccount } from 'viem/accounts'; const publicClient = createPublicClient({ chain: base, transport: http(rpcUrl), }); const walletClient = createWalletClient({ chain: base, transport: http(rpcUrl), account: privateKeyToAccount(privateKey), }); const sdk = new DopplerSDK({ publicClient, walletClient, chainId: base.id, }); ``` ``` -------------------------------- ### Setup Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/quotes-and-swaps Imports necessary components from the Doppler SDK and Viem for setting up clients and configurations. ```APIDOC ## Setup ### Description Imports necessary components from the Doppler SDK and Viem for setting up clients and configurations. ### Code Example ```javascript import { DopplerSDK, Quoter, getAddresses, DYNAMIC_FEE_FLAG } from '@whetstone-research/doppler-sdk' import { createPublicClient, createWalletClient, http, parseUnits } from 'viem' import { base } from 'viem/chains' const publicClient = createPublicClient({ chain: base, transport: http(rpcUrl) }) const walletClient = createWalletClient({ chain: base, transport: http(rpcUrl), account }) const sdk = new DopplerSDK({ publicClient, walletClient, chainId: base.id }) const quoter = new Quoter(publicClient, base.id) const addresses = getAddresses(base.id) ``` ``` -------------------------------- ### Initialize Doppler SDK (Legacy V3) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Initializes the Doppler v3 SDK using ethers.js providers and wallets. ```typescript import { ReadWriteFactory } from '@doppler/v3-sdk'; import { ethers } from 'ethers'; const provider = new ethers.providers.JsonRpcProvider(rpcUrl); const signer = new ethers.Wallet(privateKey, provider); const factory = new ReadWriteFactory(signer, chainId); ``` -------------------------------- ### Creating Static Auctions Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Demonstrates the migration from manually encoding data for V3 SDK to using the builder pattern for creating static auctions with the unified SDK. ```APIDOC ## Creating Auctions ### Static Auctions (Previously V3) **Before** ```javascript // Manually encode migration data const liquidityMigratorData = await factory.encodeV4MigratorData({ fee: 3000, tickSpacing: 60, lockDuration: 365 * 24 * 60 * 60, beneficiaries: sortedBeneficiaries, }); const { poolAddress, tokenAddress } = await factory.create({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/token', vestingDuration: 0, yearlyMintRate: 0, totalSupply: parseEther('1000000'), numTokensToSell: parseEther('500000'), startTick: -92103, endTick: -69080, fee: 3000, numeraire: wethAddress, initialRecipients: [], initialAmounts: [], contracts: { governor: governorAddress, tokenFactory: addresses.tokenFactory, poolInitializer: addresses.v3Initializer, liquidityMigrator: addresses.v4Migrator, airlock: addresses.airlock, }, integrator: integratorAddress, liquidityMigratorData, }); ``` **After (Builder pattern)** ```javascript import { StaticAuctionBuilder } from '@whetstone-research/doppler-sdk' const params = new StaticAuctionBuilder() .tokenConfig({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/token' }) .saleConfig({ initialSupply: parseEther('1000000'), numTokensToSell: parseEther('500000'), numeraire: wethAddress, }) .poolByTicks({ startTick: -92103, endTick: -69080, fee: 3000 }) .withMigration({ type: 'uniswapV4', fee: 3000, tickSpacing: 60, streamableFees: { lockDuration: 365 * 24 * 60 * 60, beneficiaries: sortedBeneficiaries }, }) .withVesting({ duration: 0n }) .withIntegrator(integratorAddress) .withUserAddress(governorAddress) .build() const result = await sdk.factory.createStaticAuction(params) ``` ``` -------------------------------- ### Get Price Quotes Across Uniswap V2, V3, and V4 with Doppler SDK Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/examples/quoting-monitoring-and-metrics This comprehensive example utilizes the Doppler SDK to interact with Uniswap V2, V3, and V4 for fetching price quotes. It demonstrates quoting exact input amounts, exact output amounts, and multi-hop swaps, providing insights into swap mechanics and gas estimates. Dependencies include 'viem' for blockchain interactions and specific chain configurations. ```typescript /** * Example: Price Quoter * * This example demonstrates: * - Getting price quotes across Uniswap V2, V3, and V4 * - Comparing quotes to find best prices * - Handling different swap types (exact input/output) */ // UNCOMMENT IF RUNNING LOCALLY // import { DopplerSDK } from '@whetstone-research/doppler-sdk'; import { DopplerSDK } from '../src'; import { createPublicClient, http, parseEther, formatEther, type Address } from 'viem' import { base } from 'viem/chains' const token = process.env.TOKEN as `0x${string}`; const rpcUrl = process.env.RPC_URL || 'https://mainnet.base.org' as string; if (!token) throw new Error('TOKEN is not set'); // Example token addresses (replace with actual addresses) const weth = '0x4200000000000000000000000000000000000006' as Address // WETH on Base const usdc = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' as Address // USDC on Base async function main() { // Initialize SDK const publicClient = createPublicClient({ chain: base, transport: http(rpcUrl) }) const sdk = new DopplerSDK({ publicClient, chainId: base.id }) const quoter = sdk.quoter console.log('šŸ’± Price Quoter Example') console.log('=====================') // Example 1: Quote exact input on V3 console.log('\nšŸ“Š Example 1: Swap 1 ETH for USDC on V3') try { const v3Quote = await quoter.quoteExactInputV3({ tokenIn: weth, tokenOut: usdc, amountIn: parseEther('1'), fee: 3000 // 0.3% fee tier }) console.log('- Amount out:', formatEther(v3Quote.amountOut), 'USDC') console.log('- Price impact (ticks crossed):', v3Quote.initializedTicksCrossed) console.log('- Gas estimate:', v3Quote.gasEstimate.toString()) console.log('- Final sqrtPriceX96:', v3Quote.sqrtPriceX96After.toString()) } catch (error) { console.error('V3 quote failed:', error.message) } // Example 2: Quote exact output on V3 console.log('\nšŸ“Š Example 2: Get exactly 2000 USDC, pay in ETH on V3') try { const v3QuoteOut = await quoter.quoteExactOutputV3({ tokenIn: weth, tokenOut: usdc, amountOut: parseEther('2000'), // Want exactly 2000 USDC fee: 3000 }) console.log('- Amount in required:', formatEther(v3QuoteOut.amountIn), 'ETH') console.log('- Price impact (ticks crossed):', v3QuoteOut.initializedTicksCrossed) console.log('- Gas estimate:', v3QuoteOut.gasEstimate.toString()) } catch (error) { console.error('V3 exact output quote failed:', error.message) } // Example 3: Quote on V2 (if available) console.log('\nšŸ“Š Example 3: Swap 1 ETH for USDC on V2') try { const v2Quote = await quoter.quoteExactInputV2({ amountIn: parseEther('1'), path: [weth, usdc] }) console.log('- Amount out:', formatEther(v2Quote[1]), 'USDC') console.log('- Simple constant product AMM pricing') } catch (error) { console.error('V2 quote failed:', error.message) } // Example 4: Multi-hop V2 quote console.log('\nšŸ“Š Example 4: Multi-hop swap ETH -> USDC -> TOKEN on V2') try { const multiHopQuote = await quoter.quoteExactInputV2({ amountIn: parseEther('1'), path: [weth, usdc, token] // ETH -> USDC -> TOKEN }) console.log('Hop results:') console.log('- Start:', formatEther(multiHopQuote[0]), 'ETH') console.log('- After hop 1:', formatEther(multiHopQuote[1]), 'USDC') console.log('- Final:', formatEther(multiHopQuote[2]), 'TOKEN') } catch (error) { console.error('Multi-hop quote failed:', error.message) } // Example 5: V4 quote (for graduated dynamic auctions) console.log('\nšŸ“Š Example 5: Swap on V4 pool') try { const v4PoolKey = { currency0: weth, currency1: token, fee: 3000, tickSpacing: 60, hooks: '0x0000000000000000000000000000000000000000' as Address // No hook for graduated pool } const v4Quote = await quoter.quoteExactInputV4({ poolKey: v4PoolKey, zeroForOne: true, // Swapping currency0 (WETH) for currency1 (TOKEN) exactAmount: parseEther('1') }) console.log('- Amount out:', formatEther(v4Quote.amountOut), 'TOKEN') console.log('- Gas estimate:', v4Quote.gasEstimate.toString()) } catch (error) { console.error('V4 quote failed:', error.message) } // Example 6: Compare quotes across versions console.log('\nšŸ”„ Comparing quotes for 1 ETH -> USDC:') const results: { version: string; amountOut: bigint; gas: bigint }[] = [] // Try V2 try { const v2 = await quoter.quoteExactInputV2({ amountIn: parseEther('1'), path: [weth, usdc] }) results.push({ version: 'V2', amountOut: v2[1], gas: BigInt(100000) // Approximate }) } catch {} // Try V3 try { const v3 = await quoter.quoteExactInputV3({ tokenIn: weth, tokenOut: usdc, amountIn: parseEther('1'), fee: 3000 }) results.push({ version: 'V3', amountOut: v3.amountOut, gas: v3.gasEstimate }) } catch {} console.log('Comparison results:') results.forEach(r => { console.log(`- ${r.version}: Amount Out = ${formatEther(r.amountOut)}, Gas = ${r.gas.toString()}`); }); } main().catch(console.error); ``` -------------------------------- ### Initialize Doppler SDK (Unified) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Initializes the Doppler SDK using viem clients for public and wallet interactions. This replaces the previous initialization methods used with ethers.js. ```typescript import { DopplerSDK } from '@whetstone-research/doppler-sdk'; import { createPublicClient, createWalletClient, http } from 'viem'; import { base } from 'viem/chains'; import { privateKeyToAccount } from 'viem/accounts'; const publicClient = createPublicClient({ chain: base, transport: http(rpcUrl), }); const walletClient = createWalletClient({ chain: base, transport: http(rpcUrl), account: privateKeyToAccount(privateKey), }); const sdk = new DopplerSDK({ publicClient, walletClient, chainId: base.id, }); ``` -------------------------------- ### Doppler SDK Token Interaction Example (TypeScript) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/examples/quoting-monitoring-and-metrics This TypeScript example demonstrates how to use the Doppler SDK to interact with DERC20 tokens. It covers setting up viem clients, creating token instances, fetching token details, checking balances, querying vesting information, and managing token approvals. It requires environment variables for private key, token address, spender, and RPC URL. ```typescript /** * Example: Token Interaction * * This example demonstrates: * - Interacting with DERC20 tokens launched via Doppler * - Checking balances and vesting data * - Approving spending and releasing vested tokens */ // UNCOMMENT IF RUNNING LOCALLY // import { Derc20, Eth } from '@whetstone-research/doppler-sdk'; import { Derc20, Eth } from '../src'; import { createPublicClient, createWalletClient, http, parseEther, formatEther, } from 'viem'; import { base } from 'viem/chains'; import { privateKeyToAccount } from 'viem/accounts'; // Configuration const spender = process.env.SPENDER as `0x${string}`; const privateKey = process.env.PRIVATE_KEY as `0x${string}`; const rpcUrl = process.env.RPC_URL || 'https://mainnet.base.org' as string; const tokenAddress = process.env.TOKEN_ADDRESS as `0x${string}`; if (!privateKey) throw new Error('PRIVATE_KEY is not set'); if (!tokenAddress) throw new Error('TOKEN_ADDRESS is not set'); if (!spender) throw new Error('SPENDER is not set'); async function main() { // 1. Set up clients const account = privateKeyToAccount(privateKey); const publicClient = createPublicClient({ chain: base, transport: http(rpcUrl), }); const walletClient = createWalletClient({ chain: base, transport: http(rpcUrl), account, }); console.log('šŸ’° Token Interaction Example'); console.log('==========================='); console.log('Account:', account.address); console.log('Token:', tokenAddress); // 2. Create token instance const token = new Derc20(publicClient, walletClient, tokenAddress); try { // 3. Get token information console.log('\nšŸ“‹ Token Information:'); const [name, symbol, decimals, totalSupply] = await Promise.all([ token.getName(), token.getSymbol(), token.getDecimals(), token.getTotalSupply(), ]); console.log('- Name:', name); console.log('- Symbol:', symbol); console.log('- Decimals:', decimals); console.log('- Total Supply:', formatEther(totalSupply), symbol); // 4. Check balances console.log('\nšŸ’ø Balances:'); const balance = await token.getBalanceOf(account.address); console.log('- Your balance:', formatEther(balance), symbol); // Also check ETH balance const eth = new Eth(publicClient); const ethBalance = await eth.getBalanceOf(account.address); console.log('- ETH balance:', formatEther(ethBalance), 'ETH'); // 5. Check vesting information console.log('\nā° Vesting Information:'); const [vestingDuration, vestingStart, vestedTotal] = await Promise.all([ token.getVestingDuration(), token.getVestingStart(), token.getVestedTotalAmount(), ]); if (vestingDuration > 0n) { const vestingEndTime = vestingStart + vestingDuration; const now = BigInt(Math.floor(Date.now() / 1000)); const isVestingActive = now < vestingEndTime; console.log( '- Vesting duration:', Number(vestingDuration) / 86400, 'days' ); console.log( '- Vesting start:', new Date(Number(vestingStart) * 1000).toLocaleString() ); console.log('- Total vested amount:', formatEther(vestedTotal), symbol); console.log('- Vesting active:', isVestingActive); // Check user's vesting data const vestingData = await token.getVestingData(account.address); console.log('\nšŸ“Š Your Vesting Data:'); console.log( '- Total vested:', formatEther(vestingData.totalAmount), symbol ); console.log( '- Already released:', formatEther(vestingData.releasedAmount), symbol ); // Calculate available to release const available = await token.getAvailableVestedAmount(account.address); console.log('- Available to release:', formatEther(available), symbol); // Release vested tokens if available if (available > 0n) { console.log('\nšŸŽÆ Releasing vested tokens...'); try { const txHash = await token.release(available); console.log('āœ… Tokens released! Transaction:', txHash); } catch (error) { console.error('āŒ Failed to release tokens:', error); } } } else { console.log('- No vesting configured for this token'); } // 6. Token approvals console.log('\nšŸ”“ Token Approvals:'); const currentAllowance = await token.getAllowance(account.address, spender); console.log('- Current allowance:', formatEther(currentAllowance), symbol); // Approve spending if needed const approvalAmount = parseEther('100'); if (currentAllowance < approvalAmount) { console.log( `\nšŸ“ Approving ${formatEther(approvalAmount)} ${symbol} for spender...` ); try { const txHash = await token.approve(spender, approvalAmount); console.log('āœ… Approval successful! Transaction:', txHash); } catch (error) { ``` -------------------------------- ### Token Interactions with Unified SDK (JavaScript) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Illustrates token interactions using the unified Doppler SDK. This includes getting token balances and vesting data for a given address. The SDK simplifies these operations compared to previous versions. ```javascript import { Derc20 } from '@whetstone-research/doppler-sdk'; const token = new Derc20(publicClient, walletClient, tokenAddress); const balance = await token.getBalanceOf(address); const vestingData = await token.getVestingData(address); ``` -------------------------------- ### Initialize Doppler SDK (Legacy V4) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Initializes the Doppler v4 SDK using ethers.js providers and wallets. ```typescript import { ReadWriteFactory } from '@doppler/v4-sdk'; import { ethers } from 'ethers'; const provider = new ethers.providers.JsonRpcProvider(rpcUrl); const signer = new ethers.Wallet(privateKey, provider); const factory = new ReadWriteFactory(signer, chainId); ``` -------------------------------- ### Install Doppler Router Helpers Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/quotes-and-swaps Installs the `doppler-router` package, which provides helpers for building swap inputs for the Uniswap Universal Router. ```bash npm install doppler-router ``` -------------------------------- ### Log Successful Example Completion in Node.js Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/examples/dynamic-auctions Logs a success message to the console indicating that an example process has completed successfully. ```javascript console.log('\n✨ Example completed!'); ``` -------------------------------- ### Create Static Auction (Legacy V3 SDK) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Demonstrates the creation of a static auction using the legacy Doppler v3 SDK, including encoding migration data. ```typescript // Manually encode migration data const liquidityMigratorData = await factory.encodeV4MigratorData({ fee: 3000, tickSpacing: 60, lockDuration: 365 * 24 * 60 * 60, beneficiaries: sortedBeneficiaries, }); const { poolAddress, tokenAddress } = await factory.create({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/token', vestingDuration: 0, yearlyMintRate: 0, totalSupply: parseEther('1000000'), numTokensToSell: parseEther('500000'), startTick: -92103, endTick: -69080, fee: 3000, numeraire: wethAddress, initialRecipients: [], initialAmounts: [], contracts: { governor: governorAddress, tokenFactory: addresses.tokenFactory, poolInitializer: addresses.v3Initializer, liquidityMigrator: addresses.v4Migrator, airlock: addresses.airlock, }, integrator: integratorAddress, liquidityMigratorData, }); ``` -------------------------------- ### Quoter Interaction with V3 SDK (JavaScript - Before Unified) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Shows how to interact with the Quoter from the Doppler V3 SDK to get quotes for token swaps. It details the `quoteExactInputSingle` method and its parameters. ```javascript import { Quoter } from 'doppler-v3-sdk'; const quoter = new Quoter(signer, chainId); const quote = await quoter.quoteExactInputSingle({ tokenIn, tokenOut, fee, amountIn, sqrtPriceLimitX96, }); ``` -------------------------------- ### Quoter Interaction with Unified SDK (JavaScript) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Demonstrates how to use the quoter from the Doppler SDK to get quotes for token swaps. It shows the updated method `quoteV3ExactInputSingle` and how the `sqrtPriceLimitX96` parameter is handled. ```javascript const quoter = sdk.quoter; const quote = await quoter.quoteV3ExactInputSingle({ tokenIn, tokenOut, fee, amountIn, sqrtPriceLimitX96: 0n, }); ``` -------------------------------- ### Create Static Auction (Builder Pattern) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Creates a static auction using the new builder pattern, configuring token and sale parameters, pool details, migration options, vesting, and integrator information. ```typescript import { StaticAuctionBuilder } from '@whetstone-research/doppler-sdk' const params = new StaticAuctionBuilder() .tokenConfig({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/token' }) .saleConfig({ initialSupply: parseEther('1000000'), numTokensToSell: parseEther('500000'), numeraire: wethAddress, }) .poolByTicks({ startTick: -92103, endTick: -69080, fee: 3000 }) .withMigration({ type: 'uniswapV4', fee: 3000, tickSpacing: 60, streamableFees: { lockDuration: 365 * 24 * 60 * 60, beneficiaries: sortedBeneficiaries }, }) .withVesting({ duration: 0n }) .withIntegrator(integratorAddress) .withUserAddress(governorAddress) .build() const result = await sdk.factory.createStaticAuction(params) ``` -------------------------------- ### Create Static Auction with Uniswap v4 Migration (TypeScript) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/examples/static-auctions Demonstrates how to create a static auction using the Doppler SDK. It includes configuring token details, sale parameters, tick ranges for pools, vesting schedules, and migrating to Uniswap v4 with specified fee, tick spacing, and streamable fees for beneficiaries. The example also shows how to get the auction details after creation. ```typescript import { DopplerSDK, getAirlockOwner } from '../src'; import { parseEther, createPublicClient, createWalletClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { base } from 'viem/chains'; const privateKey = process.env.PRIVATE_KEY as `0x${string}`; const rpcUrl = process.env.RPC_URL ?? "https://mainnet.base.org"; const account = privateKeyToAccount(privateKey); if (!privateKey) throw new Error('PRIVATE_KEY must be set'); // Example: Creating a static auction that migrates to Uniswap V4 async function createStaticAuctionExample() { // Create viem clients const publicClient = createPublicClient({ chain: base, transport: http(rpcUrl), }); const walletClient = createWalletClient({ chain: base, transport: http(rpcUrl), account: account, }); if (!publicClient || !walletClient) { throw new Error('Failed to create viem clients'); } // Initialize the SDK const sdk = new DopplerSDK({ publicClient, walletClient, chainId: 8453, // Base mainnet }); const airlockOwner = await getAirlockOwner(publicClient); // Configure the static auction with the builder const params = sdk .buildStaticAuction() .tokenConfig({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/token-metadata.json', }) .saleConfig({ initialSupply: parseEther('1000000000'), // 1 billion tokens numTokensToSell: parseEther('900000000'), // 900 million for sale numeraire: '0x4200000000000000000000000000000000000006', // WETH on Base }) .poolByTicks({ startTick: 175000, endTick: 225000, fee: 3000 }) .withVesting({ duration: BigInt(365 * 24 * 60 * 60), cliffDuration: 0 }) .withMigration({ type: 'uniswapV4', fee: 3000, tickSpacing: 60, streamableFees: { lockDuration: 365 * 24 * 60 * 60, // 1 year beneficiaries: [ { address: account.address, percentage: 9500 }, // 95% { address: airlockOwner, percentage: 500 }, // 5% ], }, }) .withUserAddress(account.address) .withGovernance({ type: "default" }) .build(); // Create the static auction const result = await sdk.factory.createStaticAuction(params); console.log('Pool created:', result.poolAddress); console.log('Token created:', result.tokenAddress); console.log('Transaction:', result.transactionHash); // Later, interact with the auction const auction = await sdk.getStaticAuction(result.poolAddress); const hasGraduated = await auction.hasGraduated(); if (hasGraduated) { console.log('Auction is ready for migration!'); } } const main = async () => { await createStaticAuctionExample(); }; main(); ``` -------------------------------- ### Setup Doppler SDK and Quoter Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/quotes-and-swaps Initializes the DopplerSDK and Quoter instances using viem for interacting with blockchain data. Requires public and wallet clients, chain ID, and RPC URL. ```javascript import { DopplerSDK, Quoter, getAddresses, DYNAMIC_FEE_FLAG } from '@whetstone-research/doppler-sdk' import { createPublicClient, createWalletClient, http, parseUnits } from 'viem' import { base } from 'viem/chains' const publicClient = createPublicClient({ chain: base, transport: http(rpcUrl) }) const walletClient = createWalletClient({ chain: base, transport: http(rpcUrl), account }) const sdk = new DopplerSDK({ publicClient, walletClient, chainId: base.id }) const quoter = new Quoter(publicClient, base.id) const addresses = getAddresses(base.id) ``` -------------------------------- ### Static Auction Builder Example (JavaScript) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/api-reference This example showcases the usage of the StaticAuctionBuilder to construct parameters for a Uniswap V3-style auction. It demonstrates chaining methods for token configuration, sale parameters, price range specification, vesting, governance, migration, and user address. ```javascript const params = new StaticAuctionBuilder() .tokenConfig({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/mtk.json' }) .saleConfig({ initialSupply: parseEther('1_000_000_000'), numTokensToSell: parseEther('900_000_000'), numeraire: weth }) .poolByPriceRange({ priceRange: { startPrice: 0.0001, endPrice: 0.001 }, fee: 3000 }) .withVesting({ duration: BigInt(365*24*60*60) }) .withGovernance() // required; no args → standard governance defaults .withMigration({ type: 'uniswapV2' }) .withUserAddress(user) .build() ``` -------------------------------- ### Manually Create Dynamic Auction (JavaScript - Before Builder) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Illustrates the manual process of creating a dynamic auction before the introduction of the builder pattern. This involves manually calculating parameters like gamma and mining the hook address, then encoding pool initializer data. ```javascript // Calculate gamma manually const gamma = calculateGamma(...); // Mine hook address const minedAddress = await hookAddressMiner.mine({ dopplerDeployer: addresses.dopplerDeployer, prefix: '0x00', }); const { hookAddress, tokenAddress } = await factory.create({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/token', // ... many parameters poolInitializerData: encodePoolInitializerData({ minimumProceeds, maximumProceeds, startingTime, endingTime, startingTick, endingTick, epochLength, gamma, isToken0, numPDSlugs, fee, tickSpacing, }), }); ``` -------------------------------- ### Manual Contract Calls for Auctions (JavaScript - Before Unified SDK) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Demonstrates manual contract calls using ethers to interact with auctions before the advent of the unified SDK. This involves instantiating contracts with ABI and provider to fetch data like slot0 and liquidity. ```javascript // Manual contract calls with ethers const pool = new ethers.Contract(poolAddress, poolAbi, provider); const slot0 = await pool.slot0(); const liquidity = await pool.liquidity(); ``` -------------------------------- ### Create Dynamic Auction with Builder Pattern (JavaScript) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Demonstrates creating a dynamic auction using the builder pattern provided by the Doppler SDK. This approach simplifies the configuration of auction parameters, including token details, sale configuration, pool settings, auction specifics, migration options, and user address. ```javascript import { DynamicAuctionBuilder } from '@whetstone-research/doppler-sdk' const params = new DynamicAuctionBuilder() .tokenConfig({ name: 'My Token', symbol: 'MTK', tokenURI: 'https://example.com/token' }) .saleConfig({ initialSupply: parseEther('1000000'), numTokensToSell: parseEther('500000'), numeraire: wethAddress }) .poolConfig({ fee: 3000, tickSpacing: 60 }) .auctionByPriceRange({ priceRange: { startPrice: 0.0001, endPrice: 0.01 }, minProceeds: parseEther('50'), maxProceeds: parseEther('500'), durationDays: 7, epochLength: 3600, }) .withMigration({ type: 'uniswapV4', fee: 3000, tickSpacing: 60, streamableFees: { lockDuration: 365 * 24 * 60 * 60, beneficiaries: [...] }, }) .withUserAddress(governorAddress) .build() const result = await sdk.factory.createDynamicAuction(params) ``` -------------------------------- ### Token Interactions with V3 SDK (JavaScript - Before Unified) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Shows token interactions using the older Doppler V3 SDK. It demonstrates how to instantiate a Derc20 token contract and retrieve a user's balance. ```javascript import { Derc20 } from 'doppler-v3-sdk'; const token = new Derc20(tokenAddress, signer); const balance = await token.balanceOf(address); ``` -------------------------------- ### Monitor Static Auction with Doppler SDK Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/examples/quoting-monitoring-and-metrics Monitors a static auction by fetching pool information, current price, and graduation status. Requires the Doppler SDK and viem for blockchain interactions. ```typescript /** * Example: Monitor Existing Auctions * * This example demonstrates: * - Monitoring static and dynamic auctions * - Checking graduation status * - Tracking key metrics and progress */ // UNCOMMENT IF RUNNING LOCALLY // import { DopplerSDK } from '@whetstone-research/doppler-sdk'; import { DopplerSDK } from '../src'; import { http, formatEther, type Address, createPublicClient, } from 'viem'; import { base } from 'viem/chains'; // Example addresses - replace with your actual auction addresses const staticPoolAddress = process.env.STATIC_POOL_ADDRESS as `0x${string}`; const dynamicHookAddress = process.env.DYNAMIC_HOOK_ADDRESS as `0x${string}`; const rpcUrl = process.env.RPC_URL || ('https://mainnet.base.org' as string); async function monitorStaticAuction(sdk: DopplerSDK, poolAddress: Address) { console.log('\nšŸ“Š Monitoring Static Auction...'); console.log('Pool address:', poolAddress); try { const auction = await sdk.getStaticAuction(poolAddress); // Get pool information const poolInfo = await auction.getPoolInfo(); console.log('\nPool Information:'); console.log('- Token:', poolInfo.tokenAddress); console.log('- Numeraire:', poolInfo.numeraireAddress); console.log('- Fee tier:', poolInfo.fee / 10000, '%'); console.log('- Liquidity:', formatEther(poolInfo.liquidity)); console.log('- SqrtPriceX96:', poolInfo.sqrtPriceX96.toString()); // Get current price const currentPrice = await auction.getCurrentPrice(); console.log('\nCurrent tick price:', currentPrice.toString()); // Check graduation status const hasGraduated = await auction.hasGraduated(); console.log( '\nGraduation status:', hasGraduated ? 'āœ… Graduated' : 'ā³ Active' ); // Get token address for further info const tokenAddress = await auction.getTokenAddress(); console.log('Token contract:', tokenAddress); } catch (error) { console.error('Error monitoring static auction:', error); } } async function monitorDynamicAuction(sdk: DopplerSDK, hookAddress: Address) { console.log('\nšŸ“Š Monitoring Dynamic Auction...'); console.log('Hook address:', hookAddress); try { const auction = await sdk.getDynamicAuction(hookAddress); // Get comprehensive hook information const hookInfo = await auction.getHookInfo(); console.log('\nHook Information:'); console.log('- Token:', hookInfo.tokenAddress); console.log('- Numeraire:', hookInfo.numeraireAddress); console.log('- Pool ID:', hookInfo.poolId); console.log('- Current epoch:', hookInfo.currentEpoch); console.log('\nSale Progress:'); console.log( '- Total proceeds:', formatEther(hookInfo.totalProceeds), 'ETH' ); console.log('- Tokens sold:', formatEther(hookInfo.totalTokensSold)); console.log( '- Min proceeds:', formatEther(hookInfo.minimumProceeds), 'ETH' ); console.log( '- Max proceeds:', formatEther(hookInfo.maximumProceeds), 'ETH' ); console.log('\nAuction Status:'); console.log('- Early exit:', hookInfo.earlyExit ? 'āœ… Yes' : 'āŒ No'); console.log( '- Insufficient proceeds:', hookInfo.insufficientProceeds ? 'āš ļø Yes' : 'āœ… No' ); // Calculate time remaining const now = BigInt(Math.floor(Date.now() / 1000)); if (now < hookInfo.endingTime) { const remaining = Number(hookInfo.endingTime - now); const hours = Math.floor(remaining / 3600); const minutes = Math.floor((remaining % 3600) / 60); console.log('- Time remaining:', `${hours}h ${minutes}m`); } else { console.log('- Time remaining: Auction ended'); } // Get current price tick const currentTick = await auction.getCurrentPrice(); console.log('\nCurrent tick:', currentTick.toString()); // Check if ended early const hasEndedEarly = await auction.hasEndedEarly(); if (hasEndedEarly) { console.log('\nšŸŽÆ Auction ended early due to reaching max proceeds'); } // Check graduation const hasGraduated = await auction.hasGraduated(); console.log( 'Graduation status:', hasGraduated ? 'āœ… Graduated' : 'ā³ Active' ); } catch (error) { console.error('Error monitoring dynamic auction:', error); } } async function main() { // Initialize SDK in read-only mode const publicClient = createPublicClient({ chain: base, transport: http(rpcUrl), }); const sdk = new DopplerSDK({ publicClient, chainId: base.id, }); console.log('šŸ” Doppler Auction Monitor'); console.log('=======================\n'); // Monitor static auction if address provided if (staticPoolAddress) { await monitorStaticAuction(sdk, staticPoolAddress); } else { console.log('\nāš ļø No static auction address provided'); } // Monitor dynamic auction if address provided if (dynamicHookAddress) { await monitorDynamicAuction(sdk, dynamicHookAddress); } else { console.log('\nāš ļø No dynamic auction address provided'); } } main().catch(console.error); ``` -------------------------------- ### Sort and Display Quotes using Doppler Lol SDK (JavaScript) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/examples/quoting-monitoring-and-metrics This snippet demonstrates how to sort quote results by output amount and display them in a user-friendly format. It utilizes the Doppler Lol SDK and assumes the `formatEther` function is available for formatting currency values. The code iterates through the sorted results, logging each quote's version, output amount, and gas estimate. ```javascript // Sort by best output results.sort((a, b) => Number(b.amountOut - a.amountOut)) console.log('\nBest quotes (sorted by output):') results.forEach((result, i) => { console.log(`${i + 1}. ${result.version}: ${formatEther(result.amountOut)} USDC (gas: ${result.gas})`) }) if (results.length > 0) { console.log(`\nāœ… Best option: ${results[0].version} with ${formatEther(results[0].amountOut)} USDC`) } console.log('\n✨ Example completed!') } main() ``` -------------------------------- ### Interact with Auctions using Unified SDK (JavaScript) Source: https://docs.doppler.lol/sdk/references/new-alpha-sdk/sdk-migration-guide Shows how to interact with both static and dynamic auctions using the unified Doppler SDK. This includes fetching pool information, checking graduation status for static auctions, and retrieving hook information and current epoch for dynamic auctions. ```javascript // Static Auction const staticAuction = await sdk.getStaticAuction(poolAddress); const poolInfo = await staticAuction.getPoolInfo(); const hasGraduated = await staticAuction.hasGraduated(); // Dynamic Auction const dynamicAuction = await sdk.getDynamicAuction(hookAddress); const hookInfo = await dynamicAuction.getHookInfo(); const currentEpoch = await dynamicAuction.getCurrentEpoch(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.