├── .github └── flaunch-header.png ├── .gitignore ├── .npmrc ├── CHANGELOG.md ├── LICENSE ├── PUBLISHING.md ├── README.md ├── llms-full.txt ├── package.json ├── pnpm-lock.yaml ├── rollup.config.js ├── scripts └── generate-llms-doc.js ├── src ├── abi │ ├── AnyPositionManager.ts │ ├── BidWall.ts │ ├── BidWallV1_1.ts │ ├── FairLaunch.ts │ ├── FairLaunchV1_1.ts │ ├── FastFlaunchZap.ts │ ├── FeeEscrow.ts │ ├── Flaunch.ts │ ├── FlaunchPositionManager.ts │ ├── FlaunchPositionManagerV1_1.ts │ ├── FlaunchV1_1.ts │ ├── FlaunchZap.ts │ ├── InitialPrice.ts │ ├── Memecoin.ts │ ├── Multicall.ts │ ├── Permit2.ts │ ├── PoolManager.ts │ ├── Quoter.ts │ ├── ReferralEscrow.ts │ ├── RevenueManager.ts │ ├── StateView.ts │ ├── TreasuryManagerFactory.ts │ ├── UniversalRouter.ts │ └── index.ts ├── addresses.ts ├── clients │ ├── AnyPositionManagerClient.ts │ ├── BidWallClient.ts │ ├── BidWallV1_1Client.ts │ ├── FairLaunchClient.ts │ ├── FairLaunchV1_1Client.ts │ ├── FastFlaunchClient.ts │ ├── FeeEscrowClient.ts │ ├── FlaunchClient.ts │ ├── FlaunchPositionManagerClient.ts │ ├── FlaunchPositionManagerV1_1Client.ts │ ├── FlaunchV1_1Client.ts │ ├── FlaunchZapClient.ts │ ├── InitialPriceClient.ts │ ├── MemecoinClient.ts │ ├── MulticallClient.ts │ ├── Permit2Client.ts │ ├── PoolManagerClient.ts │ ├── QuoterClient.ts │ ├── ReferralEscrowClient.ts │ ├── RevenueManagerClient.ts │ ├── StateViewClient.ts │ └── TreasuryManagerFactoryClient.ts ├── helpers │ ├── chainIdToChain.ts │ ├── hex.ts │ ├── index.ts │ └── ipfs.ts ├── hooks │ ├── FlaunchPositionManagerHooks.ts │ └── index.ts ├── index.ts ├── sdk │ ├── FlaunchSDK.ts │ ├── drift.ts │ └── factory.ts ├── types.ts └── utils │ ├── univ4.ts │ └── universalRouter.ts └── tsconfig.json /.github/flaunch-header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flayerlabs/flaunch-sdk/fa000175488fa8726fb2efd26abc70fc5654cc25/.github/flaunch-header.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .DS_Store 4 | *.log 5 | coverage 6 | .env 7 | docs -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | tag-version-prefix="@flaunch/sdk@" 2 | message="@flaunch/sdk v%s" -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to the @flaunch/sdk package will be documented in this file. 4 | 5 | ## [0.8.0] - 2025-05-23 6 | 7 | ### Added 8 | 9 | - New `AnyPositionManager` for external coin support with associated client and ABI 10 | - Fee Escrow system for managing creator revenue with `creatorRevenue` and `withdrawCreatorRevenue` functions 11 | - Referral Escrow system with `referralBalance` and `claimReferralBalance` functions 12 | - Coin price and market cap in USD with `coinPriceInUSD` and `coinMarketCapInUSD` functions 13 | - `createDrift` helper function for type-safe Drift SDK instantiation 14 | - `initialSqrtPriceX96` function for calculating initial launch price 15 | - `FlaunchVersion` enum (V1, V1.1, ANY) for better version management 16 | 17 | ### Changed 18 | 19 | - Refactored SDK to support multiple contract versions with `getCoinVersion` and version-aware helper functions 20 | - Updated Quoter and Universal Router to use `positionManagerAddress` instead of `isV1Coin` 21 | - Modified `createFlaunch` factory to use new `createDrift` helper 22 | - Added `totalSupply()` method to `ReadMemecoin` client 23 | - Updated README to reflect new launch parameters and deprecations 24 | 25 | ### Deprecated 26 | 27 | - `fastFlaunch` and `fastFlaunchIPFS` methods in favor of `flaunch` or `flaunchIPFS` 28 | 29 | ### Fixed 30 | 31 | - Consistent total supply calculation for market cap 32 | - Improved handling of position manager versions 33 | 34 | ## [0.7.1] - 2025-05-15 35 | 36 | ### Fixed 37 | 38 | - Fixed merkle root handling in FlaunchZapClient by using `zeroHash` instead of "0x" for empty bytes32 values 39 | - Fixes the error: "AbiEncodingBytesSizeMismatchError: Size of bytes "0x" (bytes0) does not match expected size (bytes32)." 40 | 41 | ## [0.7.0] - 2025-05-14 42 | 43 | ### Added 44 | 45 | - New `createFlaunch` factory function to simplify SDK initialization 46 | - Provides a more intuitive way to create SDK instances 47 | - Automatically handles Drift setup internally 48 | - Type-safe return types based on provided clients 49 | 50 | ### Changed 51 | 52 | - Removed `@delvtech/drift` as a peer dependency 53 | - Now included as a direct dependency 54 | - Users no longer need to install it separately 55 | - Simplified SDK setup process 56 | - Reduced boilerplate code for initialization 57 | - Better TypeScript type inference 58 | - Improved developer experience 59 | - Updated dependency on `@delvtech/drift` from 0.3.0 to ^0.8.4 60 | - Updated Viem from 2.23.2 to 2.29.2 61 | - Modified API calls to match latest Drift interfaces 62 | - Changed TypeScript module resolution to "bundler" with stricter type checking 63 | - Better handling of optional parameters in metadata uploads 64 | 65 | ### Fixed 66 | 67 | - Improved null checking in functions to prevent TypeScript errors 68 | - Fixed potential undefined parameter issues when filtering by coin 69 | 70 | ## [0.6.0] - 2025-05-13 71 | 72 | ### Added 73 | 74 | - New `ReadWritePermit2` client with direct approval support 75 | - Added `approve` function to execute token approvals via transaction 76 | - Improved TypeScript type safety and null checking 77 | 78 | ## [0.5.1] - 2025-05-09 79 | 80 | ### Added 81 | 82 | - Quoter functions added to the main SDK to simplify price quoting 83 | - `getSellQuoteExactInput`: Gets a quote for selling an exact amount of tokens for ETH 84 | - `getBuyQuoteExactInput`: Gets a quote for buying tokens with an exact amount of ETH 85 | - `getBuyQuoteExactOutput`: Gets a quote for buying an exact amount of tokens with ETH 86 | 87 | ## [0.5.0] - 2025-05-09 88 | 89 | ### Added 90 | 91 | - FlaunchZap integration for flaunches with premines 92 | - Auto-calculation of flaunching fees 93 | - Support for calculating premine cost in ETH 94 | - New helper functions: 95 | - `getFlaunchingFee`: Get the flaunching fee for a given initial price 96 | - `ethRequiredToFlaunch`: Calculate ETH required to flaunch a token including premine cost and fees 97 | - Detailed documentation for premine functionality 98 | 99 | ### Changed 100 | 101 | - Improved constructor flows with property initialization 102 | - Updated default flaunch flow to use FlaunchZap for better premine support 103 | - Updated parameter handling in flaunch functions (removed need for `flaunchingETHFees` param) 104 | 105 | ## [0.4.2] - 2025-05-06 106 | 107 | ### Added 108 | 109 | - Additional comments and documentation for better developer experience 110 | 111 | ### Fixed 112 | 113 | - IPFS gateway rate limiting issue fixed by implementing a gateway rotation system 114 | - Added multiple IPFS gateways to cycle through for fetching metadata 115 | - Prevents rate limiting when making multiple concurrent IPFS requests 116 | 117 | ## [0.4.1] - 2025-05-06 118 | 119 | ### Added 120 | 121 | - Custom IPFS resolver function via `setIPFSResolver` 122 | - Improved documentation in Publishing.md 123 | 124 | ### Fixed 125 | 126 | - Optimized IPFS handling to avoid rate limiting 127 | - Batch processing for IPFS requests with configurable batch size and delay 128 | 129 | ## [0.4.0] - 2025-05-02 130 | 131 | ### Added 132 | 133 | - Revenue Manager support for sophisticated revenue-sharing models 134 | - New functions for revenue sharing: 135 | - `deployRevenueManager`: Deploy a new revenue manager instance 136 | - `flaunchWithRevenueManager`: Launch tokens directly into a revenue manager 137 | - `flaunchIPFSWithRevenueManager`: Launch with IPFS metadata into a revenue manager 138 | - `revenueManagerBalance`: Check claimable ETH balance for specific recipient 139 | - `revenueManagerProtocolBalance`: Check claimable ETH balance for protocol 140 | - `revenueManagerProtocolClaim`: Claim protocol's share of revenue 141 | - `revenueManagerCreatorClaim`: Claim creator's share of revenue 142 | - `revenueManagerCreatorClaimForTokens`: Claim creator's share for specific tokens 143 | 144 | ### Changed 145 | 146 | - Updated creator claim functionality to support both general claims and token-specific claims 147 | - Improved documentation with comprehensive examples for revenue sharing 148 | 149 | ## [0.3.1] - 2025-03-26 150 | 151 | ### Added 152 | 153 | - FastFlaunchZap base mainnet address 154 | 155 | ## [0.3.0] - 2025-03-18 156 | 157 | ### Added 158 | 159 | - More clients and functions for expanded functionality 160 | - Made client instances publicly accessible for advanced use cases 161 | 162 | ## [0.2.0] - 2025-03-07 163 | 164 | ### Changed 165 | 166 | - Updated FastFlaunch address and ABI 167 | - Removed `createFeeAllocationPercent` parameter (deprecated) 168 | 169 | ## [0.1.1] - 2025-03-05 170 | 171 | ### Fixed 172 | 173 | - README badge URL fix 174 | - Documentation updates before publishing 175 | 176 | ## [0.1.0] - 2025-03-04 177 | 178 | ### Added 179 | 180 | - Initial release of the Flaunch SDK 181 | - Core functionality: 182 | - Flaunching new memecoins 183 | - Buying and selling memecoins via Uniswap V4 hooks 184 | - Read functions for token and pool data 185 | - Permit2 support for gasless approvals 186 | - Support for Base and Base Sepolia networks 187 | - Key features: 188 | - Token metadata handling via IPFS 189 | - Fair launch support 190 | - Swap functionality 191 | - Price queries 192 | - Pool data access 193 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) https://flaunch.gg/ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /PUBLISHING.md: -------------------------------------------------------------------------------- 1 | # Publishing Process for @flaunch/sdk 2 | 3 | This document outlines the process for versioning and publishing updates to the `@flaunch/sdk` package. 4 | 5 | ## Versioning Guidelines 6 | 7 | We follow [Semantic Versioning](https://semver.org/) (SemVer) with the following guidelines: 8 | 9 | - **MAJOR version (1.0.0 → 2.0.0)**: Incompatible API changes 10 | - **MINOR version (0.1.0 → 0.2.0)**: 11 | - For versions < 1.0.0: Breaking changes (as pre-1.0 is considered development phase) 12 | - For versions ≥ 1.0.0: Backward-compatible new features 13 | - **PATCH version (0.1.0 → 0.1.1)**: Backward-compatible bug fixes 14 | 15 | ## When to Update Versions 16 | 17 | - **Breaking Changes**: If you remove or rename parameters, change function signatures, or make any other changes that would break existing code using the SDK, increment the appropriate version (MAJOR for ≥1.0.0, MINOR for <1.0.0). 18 | - **New Features**: When adding new functionality without breaking existing code, increment the MINOR version. 19 | - **Bug Fixes**: When fixing bugs without changing the API, increment the PATCH version. 20 | 21 | ## Publishing Process 22 | 23 | ### 1. Update the Version 24 | 25 | Use the pnpm version command to update the version in package.json: 26 | 27 | ```bash 28 | # For bug fixes 29 | pnpm version patch 30 | 31 | # For breaking changes in pre-1.0 or new features in post-1.0 32 | pnpm version minor 33 | 34 | # For breaking changes in post-1.0 35 | pnpm version major 36 | ``` 37 | 38 | This command will: 39 | 40 | - Update the version in package.json 41 | - Create a git commit with the message "@flaunch/sdk v{version}" 42 | - Create a git tag with the name "@flaunch/sdk@{version}" 43 | 44 | ### 2. Push Changes to GitHub 45 | 46 | Push both the commit and the tag to GitHub: 47 | 48 | ```bash 49 | git push && git push --tags 50 | ``` 51 | 52 | ### 3. Build and Publish the Package 53 | 54 | Build the package and publish it to npm: 55 | 56 | ```bash 57 | pnpm publish 58 | ``` 59 | 60 | The `pnpm publish` command will automatically run the build script (via prepublishOnly) before publishing. 61 | 62 | ### 4. 63 | 64 | Update the llm docs: 65 | 66 | ```bash 67 | pnpm docs:llms 68 | ``` 69 | 70 | ## Configuration 71 | 72 | The versioning and commit message format is configured in the `.npmrc` file: 73 | 74 | ``` 75 | tag-version-prefix="@flaunch/sdk@" 76 | message="@flaunch/sdk v%s" 77 | ``` 78 | 79 | This ensures consistent tagging and commit messages across all releases. 80 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@flaunch/sdk", 3 | "version": "0.8.0", 4 | "description": "Flaunch SDK to easily interact with the Flaunch protocol", 5 | "license": "MIT", 6 | "author": "Apoorv Lathey ", 7 | "homepage": "https://github.com/flayerlabs/flaunch-sdk#readme", 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/flayerlabs/flaunch-sdk.git" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/flayerlabs/flaunch-sdk/issues" 14 | }, 15 | "publishConfig": { 16 | "access": "public" 17 | }, 18 | "keywords": [ 19 | "flaunch", 20 | "memecoin", 21 | "launchpad", 22 | "uniswap", 23 | "uniswap v4", 24 | "sdk" 25 | ], 26 | "main": "dist/index.cjs.js", 27 | "module": "dist/index.esm.js", 28 | "unpkg": "dist/index.umd.js", 29 | "types": "dist/index.d.ts", 30 | "exports": { 31 | ".": { 32 | "types": "./dist/index.d.ts", 33 | "import": "./dist/index.esm.js", 34 | "require": "./dist/index.cjs.js" 35 | }, 36 | "./abi": { 37 | "types": "./dist/abi/index.d.ts", 38 | "import": "./dist/abi/index.js", 39 | "require": "./dist/abi/index.cjs" 40 | }, 41 | "./addresses": { 42 | "types": "./dist/addresses.d.ts", 43 | "import": "./dist/addresses.js", 44 | "require": "./dist/addresses.cjs" 45 | }, 46 | "./helpers": { 47 | "types": "./dist/helpers/index.d.ts", 48 | "import": "./dist/helpers/index.js", 49 | "require": "./dist/helpers/index.cjs" 50 | }, 51 | "./hooks": { 52 | "types": "./dist/hooks/index.d.ts", 53 | "import": "./dist/hooks/index.js", 54 | "require": "./dist/hooks/index.cjs" 55 | } 56 | }, 57 | "files": [ 58 | "dist" 59 | ], 60 | "scripts": { 61 | "build": "tsc --emitDeclarationOnly && rollup -c", 62 | "dev": "rollup -c -w", 63 | "clean": "rimraf dist", 64 | "prebuild": "npm run clean", 65 | "prepublishOnly": "npm run build", 66 | "typecheck": "tsc --noEmit", 67 | "docs:generate": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts --excludeExternals --exclude '**/abi/**' --includeVersion", 68 | "docs:llms": "node scripts/generate-llms-doc.js" 69 | }, 70 | "packageManager": "pnpm@8.15.4", 71 | "devDependencies": { 72 | "@rollup/plugin-commonjs": "^22.0.0", 73 | "@rollup/plugin-json": "^4.1.0", 74 | "@rollup/plugin-node-resolve": "^13.3.0", 75 | "@rollup/plugin-terser": "^0.4.4", 76 | "@rollup/plugin-typescript": "^8.3.2", 77 | "@types/react": "^19.0.10", 78 | "rimraf": "^6.0.1", 79 | "rollup": "^2.75.6", 80 | "tslib": "^2.4.0", 81 | "typedoc": "^0.25.12", 82 | "typedoc-plugin-markdown": "^3.17.1", 83 | "typescript": "^5.3.3" 84 | }, 85 | "dependencies": { 86 | "@delvtech/drift": "^0.8.4", 87 | "@delvtech/drift-viem": "^0.8.4", 88 | "@uniswap/v3-sdk": "^3.24.1", 89 | "axios": "^1.8.1", 90 | "react": "^19.0.0", 91 | "viem": "^2.29.2" 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import typescript from "@rollup/plugin-typescript"; 2 | import resolve from "@rollup/plugin-node-resolve"; 3 | import commonjs from "@rollup/plugin-commonjs"; 4 | import json from "@rollup/plugin-json"; 5 | import terser from "@rollup/plugin-terser"; 6 | import pkg from "./package.json"; 7 | 8 | const external = [ 9 | ...Object.keys(pkg.dependencies || {}), 10 | ...Object.keys(pkg.peerDependencies || {}), 11 | ]; 12 | 13 | // Custom onwarn function to ignore circular dependency warnings from viem 14 | const onwarn = (warning, warn) => { 15 | // Ignore circular dependency warnings from viem 16 | if ( 17 | warning.code === "CIRCULAR_DEPENDENCY" && 18 | warning.message.includes("viem") 19 | ) { 20 | return; 21 | } 22 | // Use default warning for everything else 23 | warn(warning); 24 | }; 25 | 26 | const createConfig = (input, output, format, plugins = []) => ({ 27 | input, 28 | output: { 29 | ...output, 30 | sourcemap: true, 31 | exports: "named", 32 | }, 33 | plugins: [ 34 | typescript({ 35 | tsconfig: "./tsconfig.json", 36 | outDir: output.dir || "./dist", 37 | declaration: false, 38 | }), 39 | resolve(), 40 | commonjs(), 41 | json(), 42 | ...plugins, 43 | ], 44 | external, 45 | onwarn, 46 | }); 47 | 48 | // Main entry point configs 49 | const mainConfigs = [ 50 | // ESM 51 | createConfig("src/index.ts", { 52 | file: pkg.module, 53 | format: "esm", 54 | }), 55 | // CJS 56 | createConfig("src/index.ts", { 57 | file: pkg.main, 58 | format: "cjs", 59 | }), 60 | // UMD (minified) 61 | createConfig( 62 | "src/index.ts", 63 | { 64 | name: pkg.name.replace(/-/g, "").replace(/\//g, "_"), 65 | file: pkg.unpkg, 66 | format: "umd", 67 | globals: { 68 | "@delvtech/drift": "drift", 69 | viem: "viem", 70 | "@uniswap/v3-sdk": "v3Sdk", 71 | axios: "axios", 72 | react: "React", 73 | }, 74 | }, 75 | "umd", 76 | [terser()] 77 | ), 78 | ]; 79 | 80 | // Create configs for directory-based subpaths 81 | const directorySubpaths = ["abi", "helpers", "hooks"].map((subpath) => ({ 82 | name: subpath, 83 | input: `src/${subpath}/index.ts`, 84 | })); 85 | 86 | // Create configs for file-based subpaths 87 | const fileSubpaths = [{ name: "addresses", input: "src/addresses.ts" }]; 88 | 89 | // Create all subpath configs 90 | const subpathConfigs = [...directorySubpaths, ...fileSubpaths].flatMap( 91 | ({ name, input }) => [ 92 | // ESM for subpath 93 | createConfig(input, { 94 | dir: `dist/${name}`, 95 | format: "esm", 96 | entryFileNames: "index.js", 97 | }), 98 | // CJS for subpath 99 | createConfig(input, { 100 | dir: `dist/${name}`, 101 | format: "cjs", 102 | entryFileNames: "index.cjs", 103 | }), 104 | ] 105 | ); 106 | 107 | export default [...mainConfigs, ...subpathConfigs]; 108 | -------------------------------------------------------------------------------- /scripts/generate-llms-doc.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | 4 | function combineDocumentation() { 5 | // Read README 6 | const readmePath = path.join(__dirname, "..", "README.md"); 7 | const readme = fs.readFileSync(readmePath, "utf8"); 8 | 9 | // Read TypeDoc generated files 10 | const docsPath = path.join(__dirname, "..", "docs"); 11 | let combinedDocs = [readme, "\n\n# API Documentation\n\n"]; 12 | 13 | function readDocsRecursively(dir) { 14 | const files = fs.readdirSync(dir); 15 | 16 | for (const file of files) { 17 | const fullPath = path.join(dir, file); 18 | const stat = fs.statSync(fullPath); 19 | 20 | if (stat.isDirectory()) { 21 | readDocsRecursively(fullPath); 22 | } else if (file.endsWith(".md") && file !== "README.md") { 23 | let content = fs.readFileSync(fullPath, "utf8"); 24 | 25 | // Remove "Defined in" lines and GitHub URLs 26 | content = content.replace(/#### Defined in[\s\S]*?(?=\n\n|$)/g, ""); 27 | 28 | // Remove file paths (e.g., "flaunch-sdk/src/helpers/hex.ts:7") 29 | content = content.replace(/flaunch-sdk\/src\/.*:\d+/g, ""); 30 | 31 | // Remove empty markdown links 32 | content = content.replace(/\[\]\([^)]+\)\n?/g, ""); 33 | 34 | // Remove markdown links while keeping the text 35 | content = content.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1"); 36 | 37 | // Remove GitHub specific URLs 38 | content = content.replace(/https:\/\/github\.com\/[^\s\n]+/g, ""); 39 | 40 | // Remove "#### " prefixes from headings as they're not needed 41 | content = content.replace(/#### /g, ""); 42 | 43 | // Remove empty lines after removals 44 | content = content.replace(/\n{3,}/g, "\n\n"); 45 | 46 | // Remove lines that only contain dashes (horizontal rules) 47 | content = content.replace(/^-+$/gm, ""); 48 | 49 | // Remove any remaining empty sections 50 | content = content.replace(/###\s*\w+\s*\n\n(?=###|$)/g, ""); 51 | 52 | combinedDocs.push(content); 53 | combinedDocs.push("\n\n---\n\n"); 54 | } 55 | } 56 | } 57 | 58 | // Generate TypeDoc documentation first 59 | require("child_process").execSync("npm run docs:generate", { 60 | stdio: "inherit", 61 | }); 62 | 63 | // Combine all documentation 64 | readDocsRecursively(docsPath); 65 | 66 | // Write combined documentation 67 | const outputPath = path.join(__dirname, "..", "llms-full.txt"); 68 | fs.writeFileSync(outputPath, combinedDocs.join("")); 69 | 70 | console.log("Generated llms-full.txt successfully!"); 71 | } 72 | 73 | combineDocumentation(); 74 | -------------------------------------------------------------------------------- /src/abi/BidWall.ts: -------------------------------------------------------------------------------- 1 | export const BidwallAbi = [ 2 | { 3 | inputs: [ 4 | { internalType: "address", name: "_nativeToken", type: "address" }, 5 | { internalType: "address", name: "_poolManager", type: "address" }, 6 | { internalType: "address", name: "_protocolOwner", type: "address" }, 7 | ], 8 | stateMutability: "nonpayable", 9 | type: "constructor", 10 | }, 11 | { inputs: [], name: "AlreadyInitialized", type: "error" }, 12 | { inputs: [], name: "CallerIsNotCreator", type: "error" }, 13 | { inputs: [], name: "NewOwnerIsZeroAddress", type: "error" }, 14 | { inputs: [], name: "NoHandoverRequest", type: "error" }, 15 | { inputs: [], name: "NotPositionManager", type: "error" }, 16 | { inputs: [], name: "Unauthorized", type: "error" }, 17 | { 18 | anonymous: false, 19 | inputs: [ 20 | { 21 | indexed: true, 22 | internalType: "PoolId", 23 | name: "_poolId", 24 | type: "bytes32", 25 | }, 26 | { 27 | indexed: false, 28 | internalType: "address", 29 | name: "_recipient", 30 | type: "address", 31 | }, 32 | { 33 | indexed: false, 34 | internalType: "uint256", 35 | name: "_eth", 36 | type: "uint256", 37 | }, 38 | ], 39 | name: "BidWallClosed", 40 | type: "event", 41 | }, 42 | { 43 | anonymous: false, 44 | inputs: [ 45 | { 46 | indexed: true, 47 | internalType: "PoolId", 48 | name: "_poolId", 49 | type: "bytes32", 50 | }, 51 | { 52 | indexed: false, 53 | internalType: "uint256", 54 | name: "_added", 55 | type: "uint256", 56 | }, 57 | { 58 | indexed: false, 59 | internalType: "uint256", 60 | name: "_pending", 61 | type: "uint256", 62 | }, 63 | ], 64 | name: "BidWallDeposit", 65 | type: "event", 66 | }, 67 | { 68 | anonymous: false, 69 | inputs: [ 70 | { 71 | indexed: true, 72 | internalType: "PoolId", 73 | name: "_poolId", 74 | type: "bytes32", 75 | }, 76 | { indexed: false, internalType: "bool", name: "_disabled", type: "bool" }, 77 | ], 78 | name: "BidWallDisabledStateUpdated", 79 | type: "event", 80 | }, 81 | { 82 | anonymous: false, 83 | inputs: [ 84 | { 85 | indexed: true, 86 | internalType: "PoolId", 87 | name: "_poolId", 88 | type: "bytes32", 89 | }, 90 | { 91 | indexed: false, 92 | internalType: "uint256", 93 | name: "_eth", 94 | type: "uint256", 95 | }, 96 | { 97 | indexed: false, 98 | internalType: "int24", 99 | name: "_tickLower", 100 | type: "int24", 101 | }, 102 | { 103 | indexed: false, 104 | internalType: "int24", 105 | name: "_tickUpper", 106 | type: "int24", 107 | }, 108 | ], 109 | name: "BidWallInitialized", 110 | type: "event", 111 | }, 112 | { 113 | anonymous: false, 114 | inputs: [ 115 | { 116 | indexed: true, 117 | internalType: "PoolId", 118 | name: "_poolId", 119 | type: "bytes32", 120 | }, 121 | { 122 | indexed: false, 123 | internalType: "uint256", 124 | name: "_eth", 125 | type: "uint256", 126 | }, 127 | { 128 | indexed: false, 129 | internalType: "int24", 130 | name: "_tickLower", 131 | type: "int24", 132 | }, 133 | { 134 | indexed: false, 135 | internalType: "int24", 136 | name: "_tickUpper", 137 | type: "int24", 138 | }, 139 | ], 140 | name: "BidWallRepositioned", 141 | type: "event", 142 | }, 143 | { 144 | anonymous: false, 145 | inputs: [ 146 | { 147 | indexed: true, 148 | internalType: "PoolId", 149 | name: "_poolId", 150 | type: "bytes32", 151 | }, 152 | { 153 | indexed: false, 154 | internalType: "address", 155 | name: "_recipient", 156 | type: "address", 157 | }, 158 | { 159 | indexed: false, 160 | internalType: "uint256", 161 | name: "_tokens", 162 | type: "uint256", 163 | }, 164 | ], 165 | name: "BidWallRewardsTransferred", 166 | type: "event", 167 | }, 168 | { 169 | anonymous: false, 170 | inputs: [ 171 | { 172 | indexed: false, 173 | internalType: "uint256", 174 | name: "_newSwapFeeThreshold", 175 | type: "uint256", 176 | }, 177 | ], 178 | name: "FixedSwapFeeThresholdUpdated", 179 | type: "event", 180 | }, 181 | { 182 | anonymous: false, 183 | inputs: [ 184 | { 185 | indexed: true, 186 | internalType: "address", 187 | name: "pendingOwner", 188 | type: "address", 189 | }, 190 | ], 191 | name: "OwnershipHandoverCanceled", 192 | type: "event", 193 | }, 194 | { 195 | anonymous: false, 196 | inputs: [ 197 | { 198 | indexed: true, 199 | internalType: "address", 200 | name: "pendingOwner", 201 | type: "address", 202 | }, 203 | ], 204 | name: "OwnershipHandoverRequested", 205 | type: "event", 206 | }, 207 | { 208 | anonymous: false, 209 | inputs: [ 210 | { 211 | indexed: true, 212 | internalType: "address", 213 | name: "oldOwner", 214 | type: "address", 215 | }, 216 | { 217 | indexed: true, 218 | internalType: "address", 219 | name: "newOwner", 220 | type: "address", 221 | }, 222 | ], 223 | name: "OwnershipTransferred", 224 | type: "event", 225 | }, 226 | { 227 | inputs: [], 228 | name: "cancelOwnershipHandover", 229 | outputs: [], 230 | stateMutability: "payable", 231 | type: "function", 232 | }, 233 | { 234 | inputs: [ 235 | { 236 | components: [ 237 | { internalType: "Currency", name: "currency0", type: "address" }, 238 | { internalType: "Currency", name: "currency1", type: "address" }, 239 | { internalType: "uint24", name: "fee", type: "uint24" }, 240 | { internalType: "int24", name: "tickSpacing", type: "int24" }, 241 | { internalType: "contract IHooks", name: "hooks", type: "address" }, 242 | ], 243 | internalType: "struct PoolKey", 244 | name: "_key", 245 | type: "tuple", 246 | }, 247 | ], 248 | name: "closeBidWall", 249 | outputs: [], 250 | stateMutability: "nonpayable", 251 | type: "function", 252 | }, 253 | { 254 | inputs: [ 255 | { internalType: "address", name: "pendingOwner", type: "address" }, 256 | ], 257 | name: "completeOwnershipHandover", 258 | outputs: [], 259 | stateMutability: "payable", 260 | type: "function", 261 | }, 262 | { 263 | inputs: [ 264 | { 265 | components: [ 266 | { internalType: "Currency", name: "currency0", type: "address" }, 267 | { internalType: "Currency", name: "currency1", type: "address" }, 268 | { internalType: "uint24", name: "fee", type: "uint24" }, 269 | { internalType: "int24", name: "tickSpacing", type: "int24" }, 270 | { internalType: "contract IHooks", name: "hooks", type: "address" }, 271 | ], 272 | internalType: "struct PoolKey", 273 | name: "_poolKey", 274 | type: "tuple", 275 | }, 276 | { internalType: "uint256", name: "_ethSwapAmount", type: "uint256" }, 277 | { internalType: "int24", name: "_currentTick", type: "int24" }, 278 | { internalType: "bool", name: "_nativeIsZero", type: "bool" }, 279 | ], 280 | name: "deposit", 281 | outputs: [], 282 | stateMutability: "nonpayable", 283 | type: "function", 284 | }, 285 | { 286 | inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }], 287 | name: "isBidWallEnabled", 288 | outputs: [{ internalType: "bool", name: "", type: "bool" }], 289 | stateMutability: "view", 290 | type: "function", 291 | }, 292 | { 293 | inputs: [], 294 | name: "nativeToken", 295 | outputs: [{ internalType: "address", name: "", type: "address" }], 296 | stateMutability: "view", 297 | type: "function", 298 | }, 299 | { 300 | inputs: [], 301 | name: "owner", 302 | outputs: [{ internalType: "address", name: "result", type: "address" }], 303 | stateMutability: "view", 304 | type: "function", 305 | }, 306 | { 307 | inputs: [ 308 | { internalType: "address", name: "pendingOwner", type: "address" }, 309 | ], 310 | name: "ownershipHandoverExpiresAt", 311 | outputs: [{ internalType: "uint256", name: "result", type: "uint256" }], 312 | stateMutability: "view", 313 | type: "function", 314 | }, 315 | { 316 | inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }], 317 | name: "poolInfo", 318 | outputs: [ 319 | { internalType: "bool", name: "disabled", type: "bool" }, 320 | { internalType: "bool", name: "initialized", type: "bool" }, 321 | { internalType: "int24", name: "tickLower", type: "int24" }, 322 | { internalType: "int24", name: "tickUpper", type: "int24" }, 323 | { internalType: "uint256", name: "pendingETHFees", type: "uint256" }, 324 | { internalType: "uint256", name: "cumulativeSwapFees", type: "uint256" }, 325 | ], 326 | stateMutability: "view", 327 | type: "function", 328 | }, 329 | { 330 | inputs: [], 331 | name: "poolManager", 332 | outputs: [ 333 | { internalType: "contract IPoolManager", name: "", type: "address" }, 334 | ], 335 | stateMutability: "view", 336 | type: "function", 337 | }, 338 | { 339 | inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }], 340 | name: "position", 341 | outputs: [ 342 | { internalType: "uint256", name: "amount0_", type: "uint256" }, 343 | { internalType: "uint256", name: "amount1_", type: "uint256" }, 344 | { internalType: "uint256", name: "pendingEth_", type: "uint256" }, 345 | ], 346 | stateMutability: "view", 347 | type: "function", 348 | }, 349 | { 350 | inputs: [], 351 | name: "positionManager", 352 | outputs: [ 353 | { internalType: "contract PositionManager", name: "", type: "address" }, 354 | ], 355 | stateMutability: "view", 356 | type: "function", 357 | }, 358 | { 359 | inputs: [], 360 | name: "renounceOwnership", 361 | outputs: [], 362 | stateMutability: "payable", 363 | type: "function", 364 | }, 365 | { 366 | inputs: [], 367 | name: "requestOwnershipHandover", 368 | outputs: [], 369 | stateMutability: "payable", 370 | type: "function", 371 | }, 372 | { 373 | inputs: [ 374 | { 375 | components: [ 376 | { internalType: "Currency", name: "currency0", type: "address" }, 377 | { internalType: "Currency", name: "currency1", type: "address" }, 378 | { internalType: "uint24", name: "fee", type: "uint24" }, 379 | { internalType: "int24", name: "tickSpacing", type: "int24" }, 380 | { internalType: "contract IHooks", name: "hooks", type: "address" }, 381 | ], 382 | internalType: "struct PoolKey", 383 | name: "_key", 384 | type: "tuple", 385 | }, 386 | { internalType: "bool", name: "_disable", type: "bool" }, 387 | ], 388 | name: "setDisabledState", 389 | outputs: [], 390 | stateMutability: "nonpayable", 391 | type: "function", 392 | }, 393 | { 394 | inputs: [ 395 | { internalType: "uint256", name: "swapFeeThreshold", type: "uint256" }, 396 | ], 397 | name: "setSwapFeeThreshold", 398 | outputs: [], 399 | stateMutability: "nonpayable", 400 | type: "function", 401 | }, 402 | { 403 | inputs: [{ internalType: "address", name: "newOwner", type: "address" }], 404 | name: "transferOwnership", 405 | outputs: [], 406 | stateMutability: "payable", 407 | type: "function", 408 | }, 409 | ] as const; 410 | -------------------------------------------------------------------------------- /src/abi/FairLaunch.ts: -------------------------------------------------------------------------------- 1 | export const FairLaunchAbi = [ 2 | { 3 | inputs: [ 4 | { 5 | internalType: "contract IPoolManager", 6 | name: "_poolManager", 7 | type: "address", 8 | }, 9 | ], 10 | stateMutability: "nonpayable", 11 | type: "constructor", 12 | }, 13 | { inputs: [], name: "CannotModifyLiquidityDuringFairLaunch", type: "error" }, 14 | { inputs: [], name: "CannotSellTokenDuringFairLaunch", type: "error" }, 15 | { inputs: [], name: "NotPositionManager", type: "error" }, 16 | { 17 | anonymous: false, 18 | inputs: [ 19 | { 20 | indexed: true, 21 | internalType: "PoolId", 22 | name: "_poolId", 23 | type: "bytes32", 24 | }, 25 | { 26 | indexed: false, 27 | internalType: "uint256", 28 | name: "_tokens", 29 | type: "uint256", 30 | }, 31 | { 32 | indexed: false, 33 | internalType: "uint256", 34 | name: "_startsAt", 35 | type: "uint256", 36 | }, 37 | { 38 | indexed: false, 39 | internalType: "uint256", 40 | name: "_endsAt", 41 | type: "uint256", 42 | }, 43 | ], 44 | name: "FairLaunchCreated", 45 | type: "event", 46 | }, 47 | { 48 | anonymous: false, 49 | inputs: [ 50 | { 51 | indexed: true, 52 | internalType: "PoolId", 53 | name: "_poolId", 54 | type: "bytes32", 55 | }, 56 | { 57 | indexed: false, 58 | internalType: "uint256", 59 | name: "_revenue", 60 | type: "uint256", 61 | }, 62 | { 63 | indexed: false, 64 | internalType: "uint256", 65 | name: "_supply", 66 | type: "uint256", 67 | }, 68 | { 69 | indexed: false, 70 | internalType: "uint256", 71 | name: "_endedAt", 72 | type: "uint256", 73 | }, 74 | ], 75 | name: "FairLaunchEnded", 76 | type: "event", 77 | }, 78 | { 79 | inputs: [], 80 | name: "FAIR_LAUNCH_WINDOW", 81 | outputs: [{ internalType: "uint256", name: "", type: "uint256" }], 82 | stateMutability: "view", 83 | type: "function", 84 | }, 85 | { 86 | inputs: [ 87 | { 88 | components: [ 89 | { internalType: "Currency", name: "currency0", type: "address" }, 90 | { internalType: "Currency", name: "currency1", type: "address" }, 91 | { internalType: "uint24", name: "fee", type: "uint24" }, 92 | { internalType: "int24", name: "tickSpacing", type: "int24" }, 93 | { internalType: "contract IHooks", name: "hooks", type: "address" }, 94 | ], 95 | internalType: "struct PoolKey", 96 | name: "_poolKey", 97 | type: "tuple", 98 | }, 99 | { internalType: "uint256", name: "_tokenFees", type: "uint256" }, 100 | { internalType: "bool", name: "_nativeIsZero", type: "bool" }, 101 | ], 102 | name: "closePosition", 103 | outputs: [ 104 | { 105 | components: [ 106 | { internalType: "uint256", name: "startsAt", type: "uint256" }, 107 | { internalType: "uint256", name: "endsAt", type: "uint256" }, 108 | { internalType: "int24", name: "initialTick", type: "int24" }, 109 | { internalType: "uint256", name: "revenue", type: "uint256" }, 110 | { internalType: "uint256", name: "supply", type: "uint256" }, 111 | { internalType: "bool", name: "closed", type: "bool" }, 112 | ], 113 | internalType: "struct FairLaunch.FairLaunchInfo", 114 | name: "", 115 | type: "tuple", 116 | }, 117 | ], 118 | stateMutability: "nonpayable", 119 | type: "function", 120 | }, 121 | { 122 | inputs: [ 123 | { internalType: "PoolId", name: "_poolId", type: "bytes32" }, 124 | { internalType: "int24", name: "_initialTick", type: "int24" }, 125 | { internalType: "uint256", name: "_flaunchesAt", type: "uint256" }, 126 | { 127 | internalType: "uint256", 128 | name: "_initialTokenFairLaunch", 129 | type: "uint256", 130 | }, 131 | ], 132 | name: "createPosition", 133 | outputs: [ 134 | { 135 | components: [ 136 | { internalType: "uint256", name: "startsAt", type: "uint256" }, 137 | { internalType: "uint256", name: "endsAt", type: "uint256" }, 138 | { internalType: "int24", name: "initialTick", type: "int24" }, 139 | { internalType: "uint256", name: "revenue", type: "uint256" }, 140 | { internalType: "uint256", name: "supply", type: "uint256" }, 141 | { internalType: "bool", name: "closed", type: "bool" }, 142 | ], 143 | internalType: "struct FairLaunch.FairLaunchInfo", 144 | name: "", 145 | type: "tuple", 146 | }, 147 | ], 148 | stateMutability: "nonpayable", 149 | type: "function", 150 | }, 151 | { 152 | inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }], 153 | name: "fairLaunchInfo", 154 | outputs: [ 155 | { 156 | components: [ 157 | { internalType: "uint256", name: "startsAt", type: "uint256" }, 158 | { internalType: "uint256", name: "endsAt", type: "uint256" }, 159 | { internalType: "int24", name: "initialTick", type: "int24" }, 160 | { internalType: "uint256", name: "revenue", type: "uint256" }, 161 | { internalType: "uint256", name: "supply", type: "uint256" }, 162 | { internalType: "bool", name: "closed", type: "bool" }, 163 | ], 164 | internalType: "struct FairLaunch.FairLaunchInfo", 165 | name: "", 166 | type: "tuple", 167 | }, 168 | ], 169 | stateMutability: "view", 170 | type: "function", 171 | }, 172 | { 173 | inputs: [ 174 | { 175 | components: [ 176 | { internalType: "Currency", name: "currency0", type: "address" }, 177 | { internalType: "Currency", name: "currency1", type: "address" }, 178 | { internalType: "uint24", name: "fee", type: "uint24" }, 179 | { internalType: "int24", name: "tickSpacing", type: "int24" }, 180 | { internalType: "contract IHooks", name: "hooks", type: "address" }, 181 | ], 182 | internalType: "struct PoolKey", 183 | name: "_poolKey", 184 | type: "tuple", 185 | }, 186 | { internalType: "int256", name: "_amountSpecified", type: "int256" }, 187 | { internalType: "bool", name: "_nativeIsZero", type: "bool" }, 188 | ], 189 | name: "fillFromPosition", 190 | outputs: [ 191 | { 192 | internalType: "BeforeSwapDelta", 193 | name: "beforeSwapDelta_", 194 | type: "int256", 195 | }, 196 | { internalType: "BalanceDelta", name: "balanceDelta_", type: "int256" }, 197 | { 198 | components: [ 199 | { internalType: "uint256", name: "startsAt", type: "uint256" }, 200 | { internalType: "uint256", name: "endsAt", type: "uint256" }, 201 | { internalType: "int24", name: "initialTick", type: "int24" }, 202 | { internalType: "uint256", name: "revenue", type: "uint256" }, 203 | { internalType: "uint256", name: "supply", type: "uint256" }, 204 | { internalType: "bool", name: "closed", type: "bool" }, 205 | ], 206 | internalType: "struct FairLaunch.FairLaunchInfo", 207 | name: "fairLaunchInfo_", 208 | type: "tuple", 209 | }, 210 | ], 211 | stateMutability: "nonpayable", 212 | type: "function", 213 | }, 214 | { 215 | inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }], 216 | name: "inFairLaunchWindow", 217 | outputs: [{ internalType: "bool", name: "", type: "bool" }], 218 | stateMutability: "view", 219 | type: "function", 220 | }, 221 | { 222 | inputs: [ 223 | { internalType: "PoolId", name: "_poolId", type: "bytes32" }, 224 | { internalType: "int256", name: "_revenue", type: "int256" }, 225 | ], 226 | name: "modifyRevenue", 227 | outputs: [], 228 | stateMutability: "nonpayable", 229 | type: "function", 230 | }, 231 | { 232 | inputs: [], 233 | name: "poolManager", 234 | outputs: [ 235 | { internalType: "contract IPoolManager", name: "", type: "address" }, 236 | ], 237 | stateMutability: "view", 238 | type: "function", 239 | }, 240 | { 241 | inputs: [], 242 | name: "positionManager", 243 | outputs: [{ internalType: "address", name: "", type: "address" }], 244 | stateMutability: "view", 245 | type: "function", 246 | }, 247 | ] as const; 248 | -------------------------------------------------------------------------------- /src/abi/FairLaunchV1_1.ts: -------------------------------------------------------------------------------- 1 | export const FairLaunchV1_1Abi = [ 2 | { 3 | inputs: [ 4 | { 5 | internalType: "contract IPoolManager", 6 | name: "_poolManager", 7 | type: "address", 8 | }, 9 | ], 10 | stateMutability: "nonpayable", 11 | type: "constructor", 12 | }, 13 | { inputs: [], name: "AccessControlBadConfirmation", type: "error" }, 14 | { 15 | inputs: [ 16 | { internalType: "address", name: "account", type: "address" }, 17 | { internalType: "bytes32", name: "neededRole", type: "bytes32" }, 18 | ], 19 | name: "AccessControlUnauthorizedAccount", 20 | type: "error", 21 | }, 22 | { inputs: [], name: "CannotModifyLiquidityDuringFairLaunch", type: "error" }, 23 | { inputs: [], name: "CannotSellTokenDuringFairLaunch", type: "error" }, 24 | { inputs: [], name: "NotPositionManager", type: "error" }, 25 | { 26 | anonymous: false, 27 | inputs: [ 28 | { 29 | indexed: true, 30 | internalType: "PoolId", 31 | name: "_poolId", 32 | type: "bytes32", 33 | }, 34 | { 35 | indexed: false, 36 | internalType: "uint256", 37 | name: "_tokens", 38 | type: "uint256", 39 | }, 40 | { 41 | indexed: false, 42 | internalType: "uint256", 43 | name: "_startsAt", 44 | type: "uint256", 45 | }, 46 | { 47 | indexed: false, 48 | internalType: "uint256", 49 | name: "_endsAt", 50 | type: "uint256", 51 | }, 52 | ], 53 | name: "FairLaunchCreated", 54 | type: "event", 55 | }, 56 | { 57 | anonymous: false, 58 | inputs: [ 59 | { 60 | indexed: true, 61 | internalType: "PoolId", 62 | name: "_poolId", 63 | type: "bytes32", 64 | }, 65 | { 66 | indexed: false, 67 | internalType: "uint256", 68 | name: "_revenue", 69 | type: "uint256", 70 | }, 71 | { 72 | indexed: false, 73 | internalType: "uint256", 74 | name: "_supply", 75 | type: "uint256", 76 | }, 77 | { 78 | indexed: false, 79 | internalType: "uint256", 80 | name: "_endedAt", 81 | type: "uint256", 82 | }, 83 | ], 84 | name: "FairLaunchEnded", 85 | type: "event", 86 | }, 87 | { 88 | anonymous: false, 89 | inputs: [ 90 | { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, 91 | { 92 | indexed: true, 93 | internalType: "bytes32", 94 | name: "previousAdminRole", 95 | type: "bytes32", 96 | }, 97 | { 98 | indexed: true, 99 | internalType: "bytes32", 100 | name: "newAdminRole", 101 | type: "bytes32", 102 | }, 103 | ], 104 | name: "RoleAdminChanged", 105 | type: "event", 106 | }, 107 | { 108 | anonymous: false, 109 | inputs: [ 110 | { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, 111 | { 112 | indexed: true, 113 | internalType: "address", 114 | name: "account", 115 | type: "address", 116 | }, 117 | { 118 | indexed: true, 119 | internalType: "address", 120 | name: "sender", 121 | type: "address", 122 | }, 123 | ], 124 | name: "RoleGranted", 125 | type: "event", 126 | }, 127 | { 128 | anonymous: false, 129 | inputs: [ 130 | { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, 131 | { 132 | indexed: true, 133 | internalType: "address", 134 | name: "account", 135 | type: "address", 136 | }, 137 | { 138 | indexed: true, 139 | internalType: "address", 140 | name: "sender", 141 | type: "address", 142 | }, 143 | ], 144 | name: "RoleRevoked", 145 | type: "event", 146 | }, 147 | { 148 | inputs: [], 149 | name: "DEFAULT_ADMIN_ROLE", 150 | outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], 151 | stateMutability: "view", 152 | type: "function", 153 | }, 154 | { 155 | inputs: [ 156 | { 157 | components: [ 158 | { internalType: "Currency", name: "currency0", type: "address" }, 159 | { internalType: "Currency", name: "currency1", type: "address" }, 160 | { internalType: "uint24", name: "fee", type: "uint24" }, 161 | { internalType: "int24", name: "tickSpacing", type: "int24" }, 162 | { internalType: "contract IHooks", name: "hooks", type: "address" }, 163 | ], 164 | internalType: "struct PoolKey", 165 | name: "_poolKey", 166 | type: "tuple", 167 | }, 168 | { internalType: "uint256", name: "_tokenFees", type: "uint256" }, 169 | { internalType: "bool", name: "_nativeIsZero", type: "bool" }, 170 | ], 171 | name: "closePosition", 172 | outputs: [ 173 | { 174 | components: [ 175 | { internalType: "uint256", name: "startsAt", type: "uint256" }, 176 | { internalType: "uint256", name: "endsAt", type: "uint256" }, 177 | { internalType: "int24", name: "initialTick", type: "int24" }, 178 | { internalType: "uint256", name: "revenue", type: "uint256" }, 179 | { internalType: "uint256", name: "supply", type: "uint256" }, 180 | { internalType: "bool", name: "closed", type: "bool" }, 181 | ], 182 | internalType: "struct FairLaunch.FairLaunchInfo", 183 | name: "", 184 | type: "tuple", 185 | }, 186 | ], 187 | stateMutability: "nonpayable", 188 | type: "function", 189 | }, 190 | { 191 | inputs: [ 192 | { internalType: "PoolId", name: "_poolId", type: "bytes32" }, 193 | { internalType: "int24", name: "_initialTick", type: "int24" }, 194 | { internalType: "uint256", name: "_flaunchesAt", type: "uint256" }, 195 | { 196 | internalType: "uint256", 197 | name: "_initialTokenFairLaunch", 198 | type: "uint256", 199 | }, 200 | { internalType: "uint256", name: "_fairLaunchDuration", type: "uint256" }, 201 | ], 202 | name: "createPosition", 203 | outputs: [ 204 | { 205 | components: [ 206 | { internalType: "uint256", name: "startsAt", type: "uint256" }, 207 | { internalType: "uint256", name: "endsAt", type: "uint256" }, 208 | { internalType: "int24", name: "initialTick", type: "int24" }, 209 | { internalType: "uint256", name: "revenue", type: "uint256" }, 210 | { internalType: "uint256", name: "supply", type: "uint256" }, 211 | { internalType: "bool", name: "closed", type: "bool" }, 212 | ], 213 | internalType: "struct FairLaunch.FairLaunchInfo", 214 | name: "", 215 | type: "tuple", 216 | }, 217 | ], 218 | stateMutability: "nonpayable", 219 | type: "function", 220 | }, 221 | { 222 | inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }], 223 | name: "fairLaunchInfo", 224 | outputs: [ 225 | { 226 | components: [ 227 | { internalType: "uint256", name: "startsAt", type: "uint256" }, 228 | { internalType: "uint256", name: "endsAt", type: "uint256" }, 229 | { internalType: "int24", name: "initialTick", type: "int24" }, 230 | { internalType: "uint256", name: "revenue", type: "uint256" }, 231 | { internalType: "uint256", name: "supply", type: "uint256" }, 232 | { internalType: "bool", name: "closed", type: "bool" }, 233 | ], 234 | internalType: "struct FairLaunch.FairLaunchInfo", 235 | name: "", 236 | type: "tuple", 237 | }, 238 | ], 239 | stateMutability: "view", 240 | type: "function", 241 | }, 242 | { 243 | inputs: [ 244 | { 245 | components: [ 246 | { internalType: "Currency", name: "currency0", type: "address" }, 247 | { internalType: "Currency", name: "currency1", type: "address" }, 248 | { internalType: "uint24", name: "fee", type: "uint24" }, 249 | { internalType: "int24", name: "tickSpacing", type: "int24" }, 250 | { internalType: "contract IHooks", name: "hooks", type: "address" }, 251 | ], 252 | internalType: "struct PoolKey", 253 | name: "_poolKey", 254 | type: "tuple", 255 | }, 256 | { internalType: "int256", name: "_amountSpecified", type: "int256" }, 257 | { internalType: "bool", name: "_nativeIsZero", type: "bool" }, 258 | ], 259 | name: "fillFromPosition", 260 | outputs: [ 261 | { 262 | internalType: "BeforeSwapDelta", 263 | name: "beforeSwapDelta_", 264 | type: "int256", 265 | }, 266 | { internalType: "BalanceDelta", name: "balanceDelta_", type: "int256" }, 267 | { 268 | components: [ 269 | { internalType: "uint256", name: "startsAt", type: "uint256" }, 270 | { internalType: "uint256", name: "endsAt", type: "uint256" }, 271 | { internalType: "int24", name: "initialTick", type: "int24" }, 272 | { internalType: "uint256", name: "revenue", type: "uint256" }, 273 | { internalType: "uint256", name: "supply", type: "uint256" }, 274 | { internalType: "bool", name: "closed", type: "bool" }, 275 | ], 276 | internalType: "struct FairLaunch.FairLaunchInfo", 277 | name: "fairLaunchInfo_", 278 | type: "tuple", 279 | }, 280 | ], 281 | stateMutability: "nonpayable", 282 | type: "function", 283 | }, 284 | { 285 | inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }], 286 | name: "getRoleAdmin", 287 | outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], 288 | stateMutability: "view", 289 | type: "function", 290 | }, 291 | { 292 | inputs: [ 293 | { internalType: "bytes32", name: "role", type: "bytes32" }, 294 | { internalType: "address", name: "account", type: "address" }, 295 | ], 296 | name: "grantRole", 297 | outputs: [], 298 | stateMutability: "nonpayable", 299 | type: "function", 300 | }, 301 | { 302 | inputs: [ 303 | { internalType: "bytes32", name: "role", type: "bytes32" }, 304 | { internalType: "address", name: "account", type: "address" }, 305 | ], 306 | name: "hasRole", 307 | outputs: [{ internalType: "bool", name: "", type: "bool" }], 308 | stateMutability: "view", 309 | type: "function", 310 | }, 311 | { 312 | inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }], 313 | name: "inFairLaunchWindow", 314 | outputs: [{ internalType: "bool", name: "", type: "bool" }], 315 | stateMutability: "view", 316 | type: "function", 317 | }, 318 | { 319 | inputs: [ 320 | { internalType: "PoolId", name: "_poolId", type: "bytes32" }, 321 | { internalType: "int256", name: "_revenue", type: "int256" }, 322 | ], 323 | name: "modifyRevenue", 324 | outputs: [], 325 | stateMutability: "nonpayable", 326 | type: "function", 327 | }, 328 | { 329 | inputs: [], 330 | name: "poolManager", 331 | outputs: [ 332 | { internalType: "contract IPoolManager", name: "", type: "address" }, 333 | ], 334 | stateMutability: "view", 335 | type: "function", 336 | }, 337 | { 338 | inputs: [ 339 | { internalType: "bytes32", name: "role", type: "bytes32" }, 340 | { internalType: "address", name: "callerConfirmation", type: "address" }, 341 | ], 342 | name: "renounceRole", 343 | outputs: [], 344 | stateMutability: "nonpayable", 345 | type: "function", 346 | }, 347 | { 348 | inputs: [ 349 | { internalType: "bytes32", name: "role", type: "bytes32" }, 350 | { internalType: "address", name: "account", type: "address" }, 351 | ], 352 | name: "revokeRole", 353 | outputs: [], 354 | stateMutability: "nonpayable", 355 | type: "function", 356 | }, 357 | { 358 | inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], 359 | name: "supportsInterface", 360 | outputs: [{ internalType: "bool", name: "", type: "bool" }], 361 | stateMutability: "view", 362 | type: "function", 363 | }, 364 | ] as const; 365 | -------------------------------------------------------------------------------- /src/abi/FastFlaunchZap.ts: -------------------------------------------------------------------------------- 1 | export const FastFlaunchZapAbi = [ 2 | { 3 | inputs: [ 4 | { 5 | internalType: "contract PositionManager", 6 | name: "_positionManager", 7 | type: "address", 8 | }, 9 | ], 10 | stateMutability: "nonpayable", 11 | type: "constructor", 12 | }, 13 | { 14 | inputs: [], 15 | name: "CREATOR_FEE_ALLOCATION", 16 | outputs: [{ internalType: "uint24", name: "", type: "uint24" }], 17 | stateMutability: "view", 18 | type: "function", 19 | }, 20 | { 21 | inputs: [], 22 | name: "FAIR_LAUNCH_SUPPLY", 23 | outputs: [{ internalType: "uint256", name: "", type: "uint256" }], 24 | stateMutability: "view", 25 | type: "function", 26 | }, 27 | { 28 | inputs: [], 29 | name: "USDC_MARKET_CAP", 30 | outputs: [{ internalType: "uint256", name: "", type: "uint256" }], 31 | stateMutability: "view", 32 | type: "function", 33 | }, 34 | { 35 | inputs: [ 36 | { 37 | components: [ 38 | { internalType: "string", name: "name", type: "string" }, 39 | { internalType: "string", name: "symbol", type: "string" }, 40 | { internalType: "string", name: "tokenUri", type: "string" }, 41 | { internalType: "address", name: "creator", type: "address" }, 42 | ], 43 | internalType: "struct FastFlaunchZap.FastFlaunchParams", 44 | name: "_params", 45 | type: "tuple", 46 | }, 47 | ], 48 | name: "flaunch", 49 | outputs: [{ internalType: "address", name: "memecoin_", type: "address" }], 50 | stateMutability: "nonpayable", 51 | type: "function", 52 | }, 53 | { 54 | inputs: [], 55 | name: "positionManager", 56 | outputs: [ 57 | { internalType: "contract PositionManager", name: "", type: "address" }, 58 | ], 59 | stateMutability: "view", 60 | type: "function", 61 | }, 62 | ] as const; 63 | -------------------------------------------------------------------------------- /src/abi/FeeEscrow.ts: -------------------------------------------------------------------------------- 1 | export const FeeEscrowAbi = [ 2 | { 3 | inputs: [ 4 | { internalType: "address", name: "_nativeToken", type: "address" }, 5 | { internalType: "address", name: "_indexer", type: "address" }, 6 | ], 7 | stateMutability: "nonpayable", 8 | type: "constructor", 9 | }, 10 | { inputs: [], name: "AlreadyInitialized", type: "error" }, 11 | { inputs: [], name: "InvalidRecipient", type: "error" }, 12 | { inputs: [], name: "NewOwnerIsZeroAddress", type: "error" }, 13 | { inputs: [], name: "NoHandoverRequest", type: "error" }, 14 | { inputs: [], name: "PoolIdNotIndexed", type: "error" }, 15 | { inputs: [], name: "RecipientZeroAddress", type: "error" }, 16 | { inputs: [], name: "Unauthorized", type: "error" }, 17 | { 18 | anonymous: false, 19 | inputs: [ 20 | { 21 | indexed: true, 22 | internalType: "PoolId", 23 | name: "_poolId", 24 | type: "bytes32", 25 | }, 26 | { 27 | indexed: false, 28 | internalType: "address", 29 | name: "_payee", 30 | type: "address", 31 | }, 32 | { 33 | indexed: false, 34 | internalType: "address", 35 | name: "_token", 36 | type: "address", 37 | }, 38 | { 39 | indexed: false, 40 | internalType: "uint256", 41 | name: "_amount", 42 | type: "uint256", 43 | }, 44 | ], 45 | name: "Deposit", 46 | type: "event", 47 | }, 48 | { 49 | anonymous: false, 50 | inputs: [ 51 | { 52 | indexed: true, 53 | internalType: "address", 54 | name: "pendingOwner", 55 | type: "address", 56 | }, 57 | ], 58 | name: "OwnershipHandoverCanceled", 59 | type: "event", 60 | }, 61 | { 62 | anonymous: false, 63 | inputs: [ 64 | { 65 | indexed: true, 66 | internalType: "address", 67 | name: "pendingOwner", 68 | type: "address", 69 | }, 70 | ], 71 | name: "OwnershipHandoverRequested", 72 | type: "event", 73 | }, 74 | { 75 | anonymous: false, 76 | inputs: [ 77 | { 78 | indexed: true, 79 | internalType: "address", 80 | name: "oldOwner", 81 | type: "address", 82 | }, 83 | { 84 | indexed: true, 85 | internalType: "address", 86 | name: "newOwner", 87 | type: "address", 88 | }, 89 | ], 90 | name: "OwnershipTransferred", 91 | type: "event", 92 | }, 93 | { 94 | anonymous: false, 95 | inputs: [ 96 | { 97 | indexed: false, 98 | internalType: "address", 99 | name: "_sender", 100 | type: "address", 101 | }, 102 | { 103 | indexed: false, 104 | internalType: "address", 105 | name: "_recipient", 106 | type: "address", 107 | }, 108 | { 109 | indexed: false, 110 | internalType: "address", 111 | name: "_token", 112 | type: "address", 113 | }, 114 | { 115 | indexed: false, 116 | internalType: "uint256", 117 | name: "_amount", 118 | type: "uint256", 119 | }, 120 | ], 121 | name: "Withdrawal", 122 | type: "event", 123 | }, 124 | { 125 | inputs: [ 126 | { internalType: "PoolId", name: "_poolId", type: "bytes32" }, 127 | { internalType: "address", name: "_recipient", type: "address" }, 128 | { internalType: "uint256", name: "_amount", type: "uint256" }, 129 | ], 130 | name: "allocateFees", 131 | outputs: [], 132 | stateMutability: "nonpayable", 133 | type: "function", 134 | }, 135 | { 136 | inputs: [{ internalType: "address", name: "_recipient", type: "address" }], 137 | name: "balances", 138 | outputs: [{ internalType: "uint256", name: "_amount", type: "uint256" }], 139 | stateMutability: "view", 140 | type: "function", 141 | }, 142 | { 143 | inputs: [], 144 | name: "cancelOwnershipHandover", 145 | outputs: [], 146 | stateMutability: "payable", 147 | type: "function", 148 | }, 149 | { 150 | inputs: [ 151 | { internalType: "address", name: "pendingOwner", type: "address" }, 152 | ], 153 | name: "completeOwnershipHandover", 154 | outputs: [], 155 | stateMutability: "payable", 156 | type: "function", 157 | }, 158 | { 159 | inputs: [], 160 | name: "indexer", 161 | outputs: [ 162 | { internalType: "contract IndexerSubscriber", name: "", type: "address" }, 163 | ], 164 | stateMutability: "view", 165 | type: "function", 166 | }, 167 | { 168 | inputs: [], 169 | name: "nativeToken", 170 | outputs: [{ internalType: "address", name: "", type: "address" }], 171 | stateMutability: "view", 172 | type: "function", 173 | }, 174 | { 175 | inputs: [], 176 | name: "owner", 177 | outputs: [{ internalType: "address", name: "result", type: "address" }], 178 | stateMutability: "view", 179 | type: "function", 180 | }, 181 | { 182 | inputs: [ 183 | { internalType: "address", name: "pendingOwner", type: "address" }, 184 | ], 185 | name: "ownershipHandoverExpiresAt", 186 | outputs: [{ internalType: "uint256", name: "result", type: "uint256" }], 187 | stateMutability: "view", 188 | type: "function", 189 | }, 190 | { 191 | inputs: [], 192 | name: "renounceOwnership", 193 | outputs: [], 194 | stateMutability: "payable", 195 | type: "function", 196 | }, 197 | { 198 | inputs: [], 199 | name: "requestOwnershipHandover", 200 | outputs: [], 201 | stateMutability: "payable", 202 | type: "function", 203 | }, 204 | { 205 | inputs: [{ internalType: "address", name: "_indexer", type: "address" }], 206 | name: "setIndexer", 207 | outputs: [], 208 | stateMutability: "nonpayable", 209 | type: "function", 210 | }, 211 | { 212 | inputs: [{ internalType: "PoolId", name: "_poolId", type: "bytes32" }], 213 | name: "totalFeesAllocated", 214 | outputs: [{ internalType: "uint256", name: "_amount", type: "uint256" }], 215 | stateMutability: "view", 216 | type: "function", 217 | }, 218 | { 219 | inputs: [{ internalType: "address", name: "newOwner", type: "address" }], 220 | name: "transferOwnership", 221 | outputs: [], 222 | stateMutability: "payable", 223 | type: "function", 224 | }, 225 | { 226 | inputs: [ 227 | { internalType: "address", name: "_recipient", type: "address" }, 228 | { internalType: "bool", name: "_unwrap", type: "bool" }, 229 | ], 230 | name: "withdrawFees", 231 | outputs: [], 232 | stateMutability: "nonpayable", 233 | type: "function", 234 | }, 235 | { stateMutability: "payable", type: "receive" }, 236 | ] as const; 237 | -------------------------------------------------------------------------------- /src/abi/FlaunchZap.ts: -------------------------------------------------------------------------------- 1 | export const FlaunchZapAbi = [ 2 | { 3 | inputs: [ 4 | { 5 | internalType: "contract PositionManager", 6 | name: "_positionManager", 7 | type: "address", 8 | }, 9 | { 10 | internalType: "contract Flaunch", 11 | name: "_flaunchContract", 12 | type: "address", 13 | }, 14 | { internalType: "contract IFLETH", name: "_flETH", type: "address" }, 15 | { internalType: "contract PoolSwap", name: "_poolSwap", type: "address" }, 16 | { 17 | internalType: "contract ITreasuryManagerFactory", 18 | name: "_treasuryManagerFactory", 19 | type: "address", 20 | }, 21 | { 22 | internalType: "contract IMerkleAirdrop", 23 | name: "_merkleAirdrop", 24 | type: "address", 25 | }, 26 | { 27 | internalType: "contract WhitelistFairLaunch", 28 | name: "_whitelistFairLaunch", 29 | type: "address", 30 | }, 31 | ], 32 | stateMutability: "nonpayable", 33 | type: "constructor", 34 | }, 35 | { inputs: [], name: "CreatorCannotBeZero", type: "error" }, 36 | { inputs: [], name: "InsufficientMemecoinsForAirdrop", type: "error" }, 37 | { 38 | inputs: [ 39 | { internalType: "uint256", name: "_premineAmount", type: "uint256" }, 40 | { internalType: "uint256", name: "_slippage", type: "uint256" }, 41 | { internalType: "bytes", name: "_initialPriceParams", type: "bytes" }, 42 | ], 43 | name: "calculateFee", 44 | outputs: [ 45 | { internalType: "uint256", name: "ethRequired_", type: "uint256" }, 46 | ], 47 | stateMutability: "view", 48 | type: "function", 49 | }, 50 | { 51 | inputs: [], 52 | name: "flETH", 53 | outputs: [{ internalType: "contract IFLETH", name: "", type: "address" }], 54 | stateMutability: "view", 55 | type: "function", 56 | }, 57 | { 58 | inputs: [ 59 | { 60 | components: [ 61 | { internalType: "string", name: "name", type: "string" }, 62 | { internalType: "string", name: "symbol", type: "string" }, 63 | { internalType: "string", name: "tokenUri", type: "string" }, 64 | { 65 | internalType: "uint256", 66 | name: "initialTokenFairLaunch", 67 | type: "uint256", 68 | }, 69 | { 70 | internalType: "uint256", 71 | name: "fairLaunchDuration", 72 | type: "uint256", 73 | }, 74 | { internalType: "uint256", name: "premineAmount", type: "uint256" }, 75 | { internalType: "address", name: "creator", type: "address" }, 76 | { 77 | internalType: "uint24", 78 | name: "creatorFeeAllocation", 79 | type: "uint24", 80 | }, 81 | { internalType: "uint256", name: "flaunchAt", type: "uint256" }, 82 | { internalType: "bytes", name: "initialPriceParams", type: "bytes" }, 83 | { internalType: "bytes", name: "feeCalculatorParams", type: "bytes" }, 84 | ], 85 | internalType: "struct PositionManager.FlaunchParams", 86 | name: "_flaunchParams", 87 | type: "tuple", 88 | }, 89 | ], 90 | name: "flaunch", 91 | outputs: [ 92 | { internalType: "address", name: "memecoin_", type: "address" }, 93 | { internalType: "uint256", name: "ethSpent_", type: "uint256" }, 94 | { internalType: "address", name: "", type: "address" }, 95 | ], 96 | stateMutability: "payable", 97 | type: "function", 98 | }, 99 | { 100 | inputs: [ 101 | { 102 | components: [ 103 | { internalType: "string", name: "name", type: "string" }, 104 | { internalType: "string", name: "symbol", type: "string" }, 105 | { internalType: "string", name: "tokenUri", type: "string" }, 106 | { 107 | internalType: "uint256", 108 | name: "initialTokenFairLaunch", 109 | type: "uint256", 110 | }, 111 | { 112 | internalType: "uint256", 113 | name: "fairLaunchDuration", 114 | type: "uint256", 115 | }, 116 | { internalType: "uint256", name: "premineAmount", type: "uint256" }, 117 | { internalType: "address", name: "creator", type: "address" }, 118 | { 119 | internalType: "uint24", 120 | name: "creatorFeeAllocation", 121 | type: "uint24", 122 | }, 123 | { internalType: "uint256", name: "flaunchAt", type: "uint256" }, 124 | { internalType: "bytes", name: "initialPriceParams", type: "bytes" }, 125 | { internalType: "bytes", name: "feeCalculatorParams", type: "bytes" }, 126 | ], 127 | internalType: "struct PositionManager.FlaunchParams", 128 | name: "_flaunchParams", 129 | type: "tuple", 130 | }, 131 | { 132 | components: [ 133 | { internalType: "bytes32", name: "merkleRoot", type: "bytes32" }, 134 | { internalType: "string", name: "merkleIPFSHash", type: "string" }, 135 | { internalType: "uint256", name: "maxTokens", type: "uint256" }, 136 | ], 137 | internalType: "struct FlaunchZap.WhitelistParams", 138 | name: "_whitelistParams", 139 | type: "tuple", 140 | }, 141 | { 142 | components: [ 143 | { internalType: "uint256", name: "airdropIndex", type: "uint256" }, 144 | { internalType: "uint256", name: "airdropAmount", type: "uint256" }, 145 | { internalType: "uint256", name: "airdropEndTime", type: "uint256" }, 146 | { internalType: "bytes32", name: "merkleRoot", type: "bytes32" }, 147 | { internalType: "string", name: "merkleIPFSHash", type: "string" }, 148 | ], 149 | internalType: "struct FlaunchZap.AirdropParams", 150 | name: "_airdropParams", 151 | type: "tuple", 152 | }, 153 | { 154 | components: [ 155 | { internalType: "address", name: "manager", type: "address" }, 156 | { internalType: "bytes", name: "initializeData", type: "bytes" }, 157 | { internalType: "bytes", name: "depositData", type: "bytes" }, 158 | ], 159 | internalType: "struct FlaunchZap.TreasuryManagerParams", 160 | name: "_treasuryManagerParams", 161 | type: "tuple", 162 | }, 163 | ], 164 | name: "flaunch", 165 | outputs: [ 166 | { internalType: "address", name: "memecoin_", type: "address" }, 167 | { internalType: "uint256", name: "ethSpent_", type: "uint256" }, 168 | { internalType: "address", name: "deployedManager_", type: "address" }, 169 | ], 170 | stateMutability: "payable", 171 | type: "function", 172 | }, 173 | { 174 | inputs: [], 175 | name: "flaunchContract", 176 | outputs: [{ internalType: "contract Flaunch", name: "", type: "address" }], 177 | stateMutability: "view", 178 | type: "function", 179 | }, 180 | { 181 | inputs: [], 182 | name: "merkleAirdrop", 183 | outputs: [ 184 | { internalType: "contract IMerkleAirdrop", name: "", type: "address" }, 185 | ], 186 | stateMutability: "view", 187 | type: "function", 188 | }, 189 | { 190 | inputs: [], 191 | name: "poolSwap", 192 | outputs: [{ internalType: "contract PoolSwap", name: "", type: "address" }], 193 | stateMutability: "view", 194 | type: "function", 195 | }, 196 | { 197 | inputs: [], 198 | name: "positionManager", 199 | outputs: [ 200 | { internalType: "contract PositionManager", name: "", type: "address" }, 201 | ], 202 | stateMutability: "view", 203 | type: "function", 204 | }, 205 | { 206 | inputs: [], 207 | name: "treasuryManagerFactory", 208 | outputs: [ 209 | { 210 | internalType: "contract ITreasuryManagerFactory", 211 | name: "", 212 | type: "address", 213 | }, 214 | ], 215 | stateMutability: "view", 216 | type: "function", 217 | }, 218 | { 219 | inputs: [], 220 | name: "whitelistFairLaunch", 221 | outputs: [ 222 | { 223 | internalType: "contract WhitelistFairLaunch", 224 | name: "", 225 | type: "address", 226 | }, 227 | ], 228 | stateMutability: "view", 229 | type: "function", 230 | }, 231 | { stateMutability: "payable", type: "receive" }, 232 | ] as const; 233 | -------------------------------------------------------------------------------- /src/abi/InitialPrice.ts: -------------------------------------------------------------------------------- 1 | export const InitialPriceAbi = [ 2 | { 3 | inputs: [ 4 | { internalType: "address", name: "_protocolOwner", type: "address" }, 5 | { internalType: "address", name: "_poolManager", type: "address" }, 6 | { internalType: "address", name: "_ethToken", type: "address" }, 7 | { internalType: "address", name: "_usdcToken", type: "address" }, 8 | { 9 | internalType: "address", 10 | name: "_flaunchFeeExemption", 11 | type: "address", 12 | }, 13 | ], 14 | stateMutability: "nonpayable", 15 | type: "constructor", 16 | }, 17 | { inputs: [], name: "AlreadyInitialized", type: "error" }, 18 | { 19 | inputs: [ 20 | { internalType: "uint256", name: "_usdcMarketCap", type: "uint256" }, 21 | { 22 | internalType: "uint256", 23 | name: "_usdcMarketCapMinimum", 24 | type: "uint256", 25 | }, 26 | ], 27 | name: "MarketCapTooSmall", 28 | type: "error", 29 | }, 30 | { inputs: [], name: "NewOwnerIsZeroAddress", type: "error" }, 31 | { inputs: [], name: "NoHandoverRequest", type: "error" }, 32 | { inputs: [], name: "Unauthorized", type: "error" }, 33 | { 34 | anonymous: false, 35 | inputs: [ 36 | { 37 | indexed: false, 38 | internalType: "uint256", 39 | name: "_flaunchFeeThreshold", 40 | type: "uint256", 41 | }, 42 | ], 43 | name: "FlaunchFeeThresholdUpdated", 44 | type: "event", 45 | }, 46 | { 47 | anonymous: false, 48 | inputs: [ 49 | { 50 | indexed: true, 51 | internalType: "address", 52 | name: "pendingOwner", 53 | type: "address", 54 | }, 55 | ], 56 | name: "OwnershipHandoverCanceled", 57 | type: "event", 58 | }, 59 | { 60 | anonymous: false, 61 | inputs: [ 62 | { 63 | indexed: true, 64 | internalType: "address", 65 | name: "pendingOwner", 66 | type: "address", 67 | }, 68 | ], 69 | name: "OwnershipHandoverRequested", 70 | type: "event", 71 | }, 72 | { 73 | anonymous: false, 74 | inputs: [ 75 | { 76 | indexed: true, 77 | internalType: "address", 78 | name: "oldOwner", 79 | type: "address", 80 | }, 81 | { 82 | indexed: true, 83 | internalType: "address", 84 | name: "newOwner", 85 | type: "address", 86 | }, 87 | ], 88 | name: "OwnershipTransferred", 89 | type: "event", 90 | }, 91 | { 92 | inputs: [], 93 | name: "MINIMUM_USDC_MARKET_CAP", 94 | outputs: [{ internalType: "uint256", name: "", type: "uint256" }], 95 | stateMutability: "view", 96 | type: "function", 97 | }, 98 | { 99 | inputs: [], 100 | name: "cancelOwnershipHandover", 101 | outputs: [], 102 | stateMutability: "payable", 103 | type: "function", 104 | }, 105 | { 106 | inputs: [ 107 | { internalType: "address", name: "pendingOwner", type: "address" }, 108 | ], 109 | name: "completeOwnershipHandover", 110 | outputs: [], 111 | stateMutability: "payable", 112 | type: "function", 113 | }, 114 | { 115 | inputs: [], 116 | name: "ethToken", 117 | outputs: [{ internalType: "Currency", name: "", type: "address" }], 118 | stateMutability: "view", 119 | type: "function", 120 | }, 121 | { 122 | inputs: [], 123 | name: "flaunchFeeExemption", 124 | outputs: [ 125 | { 126 | internalType: "contract FlaunchFeeExemption", 127 | name: "", 128 | type: "address", 129 | }, 130 | ], 131 | stateMutability: "view", 132 | type: "function", 133 | }, 134 | { 135 | inputs: [], 136 | name: "flaunchFeeThreshold", 137 | outputs: [{ internalType: "uint256", name: "", type: "uint256" }], 138 | stateMutability: "view", 139 | type: "function", 140 | }, 141 | { 142 | inputs: [ 143 | { internalType: "address", name: "_sender", type: "address" }, 144 | { internalType: "bytes", name: "_initialPriceParams", type: "bytes" }, 145 | ], 146 | name: "getFlaunchingFee", 147 | outputs: [{ internalType: "uint256", name: "", type: "uint256" }], 148 | stateMutability: "view", 149 | type: "function", 150 | }, 151 | { 152 | inputs: [ 153 | { internalType: "bytes", name: "_initialPriceParams", type: "bytes" }, 154 | ], 155 | name: "getMarketCap", 156 | outputs: [{ internalType: "uint256", name: "", type: "uint256" }], 157 | stateMutability: "view", 158 | type: "function", 159 | }, 160 | { 161 | inputs: [ 162 | { internalType: "address", name: "", type: "address" }, 163 | { internalType: "bool", name: "_flipped", type: "bool" }, 164 | { internalType: "bytes", name: "_initialPriceParams", type: "bytes" }, 165 | ], 166 | name: "getSqrtPriceX96", 167 | outputs: [ 168 | { internalType: "uint160", name: "sqrtPriceX96_", type: "uint160" }, 169 | ], 170 | stateMutability: "view", 171 | type: "function", 172 | }, 173 | { 174 | inputs: [], 175 | name: "owner", 176 | outputs: [{ internalType: "address", name: "result", type: "address" }], 177 | stateMutability: "view", 178 | type: "function", 179 | }, 180 | { 181 | inputs: [ 182 | { internalType: "address", name: "pendingOwner", type: "address" }, 183 | ], 184 | name: "ownershipHandoverExpiresAt", 185 | outputs: [{ internalType: "uint256", name: "result", type: "uint256" }], 186 | stateMutability: "view", 187 | type: "function", 188 | }, 189 | { 190 | inputs: [], 191 | name: "poolId", 192 | outputs: [{ internalType: "PoolId", name: "", type: "bytes32" }], 193 | stateMutability: "view", 194 | type: "function", 195 | }, 196 | { 197 | inputs: [], 198 | name: "poolManager", 199 | outputs: [ 200 | { internalType: "contract IPoolManager", name: "", type: "address" }, 201 | ], 202 | stateMutability: "view", 203 | type: "function", 204 | }, 205 | { 206 | inputs: [], 207 | name: "renounceOwnership", 208 | outputs: [], 209 | stateMutability: "payable", 210 | type: "function", 211 | }, 212 | { 213 | inputs: [], 214 | name: "requestOwnershipHandover", 215 | outputs: [], 216 | stateMutability: "payable", 217 | type: "function", 218 | }, 219 | { 220 | inputs: [ 221 | { 222 | internalType: "uint256", 223 | name: "_flaunchFeeThreshold", 224 | type: "uint256", 225 | }, 226 | ], 227 | name: "setFlaunchFeeThreshold", 228 | outputs: [], 229 | stateMutability: "nonpayable", 230 | type: "function", 231 | }, 232 | { 233 | inputs: [ 234 | { 235 | components: [ 236 | { internalType: "Currency", name: "currency0", type: "address" }, 237 | { internalType: "Currency", name: "currency1", type: "address" }, 238 | { internalType: "uint24", name: "fee", type: "uint24" }, 239 | { internalType: "int24", name: "tickSpacing", type: "int24" }, 240 | { internalType: "contract IHooks", name: "hooks", type: "address" }, 241 | ], 242 | internalType: "struct PoolKey", 243 | name: "_poolKey", 244 | type: "tuple", 245 | }, 246 | ], 247 | name: "setPool", 248 | outputs: [], 249 | stateMutability: "nonpayable", 250 | type: "function", 251 | }, 252 | { 253 | inputs: [{ internalType: "address", name: "newOwner", type: "address" }], 254 | name: "transferOwnership", 255 | outputs: [], 256 | stateMutability: "payable", 257 | type: "function", 258 | }, 259 | { 260 | inputs: [], 261 | name: "usdcToken", 262 | outputs: [{ internalType: "Currency", name: "", type: "address" }], 263 | stateMutability: "view", 264 | type: "function", 265 | }, 266 | { 267 | inputs: [], 268 | name: "usdcToken0", 269 | outputs: [{ internalType: "bool", name: "", type: "bool" }], 270 | stateMutability: "view", 271 | type: "function", 272 | }, 273 | ] as const; 274 | -------------------------------------------------------------------------------- /src/abi/Multicall.ts: -------------------------------------------------------------------------------- 1 | export const MulticallAbi = [ 2 | { 3 | inputs: [ 4 | { 5 | components: [ 6 | { 7 | internalType: "address", 8 | name: "target", 9 | type: "address", 10 | }, 11 | { 12 | internalType: "bytes", 13 | name: "callData", 14 | type: "bytes", 15 | }, 16 | ], 17 | internalType: "struct Multicall3.Call[]", 18 | name: "calls", 19 | type: "tuple[]", 20 | }, 21 | ], 22 | name: "aggregate", 23 | outputs: [ 24 | { 25 | internalType: "uint256", 26 | name: "blockNumber", 27 | type: "uint256", 28 | }, 29 | { 30 | internalType: "bytes[]", 31 | name: "returnData", 32 | type: "bytes[]", 33 | }, 34 | ], 35 | stateMutability: "payable", 36 | type: "function", 37 | }, 38 | { 39 | inputs: [ 40 | { 41 | components: [ 42 | { 43 | internalType: "address", 44 | name: "target", 45 | type: "address", 46 | }, 47 | { 48 | internalType: "bool", 49 | name: "allowFailure", 50 | type: "bool", 51 | }, 52 | { 53 | internalType: "bytes", 54 | name: "callData", 55 | type: "bytes", 56 | }, 57 | ], 58 | internalType: "struct Multicall3.Call3[]", 59 | name: "calls", 60 | type: "tuple[]", 61 | }, 62 | ], 63 | name: "aggregate3", 64 | outputs: [ 65 | { 66 | components: [ 67 | { 68 | internalType: "bool", 69 | name: "success", 70 | type: "bool", 71 | }, 72 | { 73 | internalType: "bytes", 74 | name: "returnData", 75 | type: "bytes", 76 | }, 77 | ], 78 | internalType: "struct Multicall3.Result[]", 79 | name: "returnData", 80 | type: "tuple[]", 81 | }, 82 | ], 83 | stateMutability: "payable", 84 | type: "function", 85 | }, 86 | { 87 | inputs: [ 88 | { 89 | components: [ 90 | { 91 | internalType: "address", 92 | name: "target", 93 | type: "address", 94 | }, 95 | { 96 | internalType: "bool", 97 | name: "allowFailure", 98 | type: "bool", 99 | }, 100 | { 101 | internalType: "uint256", 102 | name: "value", 103 | type: "uint256", 104 | }, 105 | { 106 | internalType: "bytes", 107 | name: "callData", 108 | type: "bytes", 109 | }, 110 | ], 111 | internalType: "struct Multicall3.Call3Value[]", 112 | name: "calls", 113 | type: "tuple[]", 114 | }, 115 | ], 116 | name: "aggregate3Value", 117 | outputs: [ 118 | { 119 | components: [ 120 | { 121 | internalType: "bool", 122 | name: "success", 123 | type: "bool", 124 | }, 125 | { 126 | internalType: "bytes", 127 | name: "returnData", 128 | type: "bytes", 129 | }, 130 | ], 131 | internalType: "struct Multicall3.Result[]", 132 | name: "returnData", 133 | type: "tuple[]", 134 | }, 135 | ], 136 | stateMutability: "payable", 137 | type: "function", 138 | }, 139 | { 140 | inputs: [ 141 | { 142 | components: [ 143 | { 144 | internalType: "address", 145 | name: "target", 146 | type: "address", 147 | }, 148 | { 149 | internalType: "bytes", 150 | name: "callData", 151 | type: "bytes", 152 | }, 153 | ], 154 | internalType: "struct Multicall3.Call[]", 155 | name: "calls", 156 | type: "tuple[]", 157 | }, 158 | ], 159 | name: "blockAndAggregate", 160 | outputs: [ 161 | { 162 | internalType: "uint256", 163 | name: "blockNumber", 164 | type: "uint256", 165 | }, 166 | { 167 | internalType: "bytes32", 168 | name: "blockHash", 169 | type: "bytes32", 170 | }, 171 | { 172 | components: [ 173 | { 174 | internalType: "bool", 175 | name: "success", 176 | type: "bool", 177 | }, 178 | { 179 | internalType: "bytes", 180 | name: "returnData", 181 | type: "bytes", 182 | }, 183 | ], 184 | internalType: "struct Multicall3.Result[]", 185 | name: "returnData", 186 | type: "tuple[]", 187 | }, 188 | ], 189 | stateMutability: "payable", 190 | type: "function", 191 | }, 192 | { 193 | inputs: [], 194 | name: "getBasefee", 195 | outputs: [ 196 | { 197 | internalType: "uint256", 198 | name: "basefee", 199 | type: "uint256", 200 | }, 201 | ], 202 | stateMutability: "view", 203 | type: "function", 204 | }, 205 | { 206 | inputs: [ 207 | { 208 | internalType: "uint256", 209 | name: "blockNumber", 210 | type: "uint256", 211 | }, 212 | ], 213 | name: "getBlockHash", 214 | outputs: [ 215 | { 216 | internalType: "bytes32", 217 | name: "blockHash", 218 | type: "bytes32", 219 | }, 220 | ], 221 | stateMutability: "view", 222 | type: "function", 223 | }, 224 | { 225 | inputs: [], 226 | name: "getBlockNumber", 227 | outputs: [ 228 | { 229 | internalType: "uint256", 230 | name: "blockNumber", 231 | type: "uint256", 232 | }, 233 | ], 234 | stateMutability: "view", 235 | type: "function", 236 | }, 237 | { 238 | inputs: [], 239 | name: "getChainId", 240 | outputs: [ 241 | { 242 | internalType: "uint256", 243 | name: "chainid", 244 | type: "uint256", 245 | }, 246 | ], 247 | stateMutability: "view", 248 | type: "function", 249 | }, 250 | { 251 | inputs: [], 252 | name: "getCurrentBlockCoinbase", 253 | outputs: [ 254 | { 255 | internalType: "address", 256 | name: "coinbase", 257 | type: "address", 258 | }, 259 | ], 260 | stateMutability: "view", 261 | type: "function", 262 | }, 263 | { 264 | inputs: [], 265 | name: "getCurrentBlockDifficulty", 266 | outputs: [ 267 | { 268 | internalType: "uint256", 269 | name: "difficulty", 270 | type: "uint256", 271 | }, 272 | ], 273 | stateMutability: "view", 274 | type: "function", 275 | }, 276 | { 277 | inputs: [], 278 | name: "getCurrentBlockGasLimit", 279 | outputs: [ 280 | { 281 | internalType: "uint256", 282 | name: "gaslimit", 283 | type: "uint256", 284 | }, 285 | ], 286 | stateMutability: "view", 287 | type: "function", 288 | }, 289 | { 290 | inputs: [], 291 | name: "getCurrentBlockTimestamp", 292 | outputs: [ 293 | { 294 | internalType: "uint256", 295 | name: "timestamp", 296 | type: "uint256", 297 | }, 298 | ], 299 | stateMutability: "view", 300 | type: "function", 301 | }, 302 | { 303 | inputs: [ 304 | { 305 | internalType: "address", 306 | name: "addr", 307 | type: "address", 308 | }, 309 | ], 310 | name: "getEthBalance", 311 | outputs: [ 312 | { 313 | internalType: "uint256", 314 | name: "balance", 315 | type: "uint256", 316 | }, 317 | ], 318 | stateMutability: "view", 319 | type: "function", 320 | }, 321 | { 322 | inputs: [], 323 | name: "getLastBlockHash", 324 | outputs: [ 325 | { 326 | internalType: "bytes32", 327 | name: "blockHash", 328 | type: "bytes32", 329 | }, 330 | ], 331 | stateMutability: "view", 332 | type: "function", 333 | }, 334 | { 335 | inputs: [ 336 | { 337 | internalType: "bool", 338 | name: "requireSuccess", 339 | type: "bool", 340 | }, 341 | { 342 | components: [ 343 | { 344 | internalType: "address", 345 | name: "target", 346 | type: "address", 347 | }, 348 | { 349 | internalType: "bytes", 350 | name: "callData", 351 | type: "bytes", 352 | }, 353 | ], 354 | internalType: "struct Multicall3.Call[]", 355 | name: "calls", 356 | type: "tuple[]", 357 | }, 358 | ], 359 | name: "tryAggregate", 360 | outputs: [ 361 | { 362 | components: [ 363 | { 364 | internalType: "bool", 365 | name: "success", 366 | type: "bool", 367 | }, 368 | { 369 | internalType: "bytes", 370 | name: "returnData", 371 | type: "bytes", 372 | }, 373 | ], 374 | internalType: "struct Multicall3.Result[]", 375 | name: "returnData", 376 | type: "tuple[]", 377 | }, 378 | ], 379 | stateMutability: "payable", 380 | type: "function", 381 | }, 382 | { 383 | inputs: [ 384 | { 385 | internalType: "bool", 386 | name: "requireSuccess", 387 | type: "bool", 388 | }, 389 | { 390 | components: [ 391 | { 392 | internalType: "address", 393 | name: "target", 394 | type: "address", 395 | }, 396 | { 397 | internalType: "bytes", 398 | name: "callData", 399 | type: "bytes", 400 | }, 401 | ], 402 | internalType: "struct Multicall3.Call[]", 403 | name: "calls", 404 | type: "tuple[]", 405 | }, 406 | ], 407 | name: "tryBlockAndAggregate", 408 | outputs: [ 409 | { 410 | internalType: "uint256", 411 | name: "blockNumber", 412 | type: "uint256", 413 | }, 414 | { 415 | internalType: "bytes32", 416 | name: "blockHash", 417 | type: "bytes32", 418 | }, 419 | { 420 | components: [ 421 | { 422 | internalType: "bool", 423 | name: "success", 424 | type: "bool", 425 | }, 426 | { 427 | internalType: "bytes", 428 | name: "returnData", 429 | type: "bytes", 430 | }, 431 | ], 432 | internalType: "struct Multicall3.Result[]", 433 | name: "returnData", 434 | type: "tuple[]", 435 | }, 436 | ], 437 | stateMutability: "payable", 438 | type: "function", 439 | }, 440 | ] as const; 441 | -------------------------------------------------------------------------------- /src/abi/ReferralEscrow.ts: -------------------------------------------------------------------------------- 1 | export const ReferralEscrowAbi = [ 2 | { 3 | inputs: [ 4 | { internalType: "address", name: "_nativeToken", type: "address" }, 5 | { internalType: "address", name: "_positionManager", type: "address" }, 6 | ], 7 | stateMutability: "nonpayable", 8 | type: "constructor", 9 | }, 10 | { inputs: [], name: "AlreadyInitialized", type: "error" }, 11 | { inputs: [], name: "MismatchedTokensAndLimits", type: "error" }, 12 | { inputs: [], name: "NewOwnerIsZeroAddress", type: "error" }, 13 | { inputs: [], name: "NoHandoverRequest", type: "error" }, 14 | { inputs: [], name: "Unauthorized", type: "error" }, 15 | { 16 | anonymous: false, 17 | inputs: [ 18 | { 19 | indexed: true, 20 | internalType: "address", 21 | name: "pendingOwner", 22 | type: "address", 23 | }, 24 | ], 25 | name: "OwnershipHandoverCanceled", 26 | type: "event", 27 | }, 28 | { 29 | anonymous: false, 30 | inputs: [ 31 | { 32 | indexed: true, 33 | internalType: "address", 34 | name: "pendingOwner", 35 | type: "address", 36 | }, 37 | ], 38 | name: "OwnershipHandoverRequested", 39 | type: "event", 40 | }, 41 | { 42 | anonymous: false, 43 | inputs: [ 44 | { 45 | indexed: true, 46 | internalType: "address", 47 | name: "oldOwner", 48 | type: "address", 49 | }, 50 | { 51 | indexed: true, 52 | internalType: "address", 53 | name: "newOwner", 54 | type: "address", 55 | }, 56 | ], 57 | name: "OwnershipTransferred", 58 | type: "event", 59 | }, 60 | { 61 | anonymous: false, 62 | inputs: [ 63 | { 64 | indexed: true, 65 | internalType: "PoolId", 66 | name: "_poolId", 67 | type: "bytes32", 68 | }, 69 | { 70 | indexed: true, 71 | internalType: "address", 72 | name: "_user", 73 | type: "address", 74 | }, 75 | { 76 | indexed: true, 77 | internalType: "address", 78 | name: "_token", 79 | type: "address", 80 | }, 81 | { 82 | indexed: false, 83 | internalType: "uint256", 84 | name: "_amount", 85 | type: "uint256", 86 | }, 87 | ], 88 | name: "TokensAssigned", 89 | type: "event", 90 | }, 91 | { 92 | anonymous: false, 93 | inputs: [ 94 | { 95 | indexed: true, 96 | internalType: "address", 97 | name: "_user", 98 | type: "address", 99 | }, 100 | { 101 | indexed: false, 102 | internalType: "address", 103 | name: "_recipient", 104 | type: "address", 105 | }, 106 | { 107 | indexed: true, 108 | internalType: "address", 109 | name: "_token", 110 | type: "address", 111 | }, 112 | { 113 | indexed: false, 114 | internalType: "uint256", 115 | name: "_amount", 116 | type: "uint256", 117 | }, 118 | ], 119 | name: "TokensClaimed", 120 | type: "event", 121 | }, 122 | { 123 | anonymous: false, 124 | inputs: [ 125 | { 126 | indexed: true, 127 | internalType: "address", 128 | name: "_user", 129 | type: "address", 130 | }, 131 | { 132 | indexed: true, 133 | internalType: "address", 134 | name: "_token", 135 | type: "address", 136 | }, 137 | { 138 | indexed: false, 139 | internalType: "uint256", 140 | name: "_tokenIn", 141 | type: "uint256", 142 | }, 143 | { 144 | indexed: false, 145 | internalType: "uint256", 146 | name: "_ethOut", 147 | type: "uint256", 148 | }, 149 | ], 150 | name: "TokensSwapped", 151 | type: "event", 152 | }, 153 | { 154 | inputs: [ 155 | { internalType: "address", name: "_user", type: "address" }, 156 | { internalType: "address", name: "_token", type: "address" }, 157 | ], 158 | name: "allocations", 159 | outputs: [{ internalType: "uint256", name: "_amount", type: "uint256" }], 160 | stateMutability: "view", 161 | type: "function", 162 | }, 163 | { 164 | inputs: [ 165 | { internalType: "PoolId", name: "_poolId", type: "bytes32" }, 166 | { internalType: "address", name: "_user", type: "address" }, 167 | { internalType: "address", name: "_token", type: "address" }, 168 | { internalType: "uint256", name: "_amount", type: "uint256" }, 169 | ], 170 | name: "assignTokens", 171 | outputs: [], 172 | stateMutability: "nonpayable", 173 | type: "function", 174 | }, 175 | { 176 | inputs: [], 177 | name: "cancelOwnershipHandover", 178 | outputs: [], 179 | stateMutability: "payable", 180 | type: "function", 181 | }, 182 | { 183 | inputs: [ 184 | { internalType: "address[]", name: "_tokens", type: "address[]" }, 185 | { 186 | internalType: "uint160[]", 187 | name: "_sqrtPriceX96Limits", 188 | type: "uint160[]", 189 | }, 190 | { internalType: "address payable", name: "_recipient", type: "address" }, 191 | ], 192 | name: "claimAndSwap", 193 | outputs: [], 194 | stateMutability: "nonpayable", 195 | type: "function", 196 | }, 197 | { 198 | inputs: [ 199 | { internalType: "address[]", name: "_tokens", type: "address[]" }, 200 | { internalType: "address payable", name: "_recipient", type: "address" }, 201 | ], 202 | name: "claimTokens", 203 | outputs: [], 204 | stateMutability: "nonpayable", 205 | type: "function", 206 | }, 207 | { 208 | inputs: [ 209 | { internalType: "address", name: "pendingOwner", type: "address" }, 210 | ], 211 | name: "completeOwnershipHandover", 212 | outputs: [], 213 | stateMutability: "payable", 214 | type: "function", 215 | }, 216 | { 217 | inputs: [], 218 | name: "nativeToken", 219 | outputs: [{ internalType: "address", name: "", type: "address" }], 220 | stateMutability: "view", 221 | type: "function", 222 | }, 223 | { 224 | inputs: [], 225 | name: "owner", 226 | outputs: [{ internalType: "address", name: "result", type: "address" }], 227 | stateMutability: "view", 228 | type: "function", 229 | }, 230 | { 231 | inputs: [ 232 | { internalType: "address", name: "pendingOwner", type: "address" }, 233 | ], 234 | name: "ownershipHandoverExpiresAt", 235 | outputs: [{ internalType: "uint256", name: "result", type: "uint256" }], 236 | stateMutability: "view", 237 | type: "function", 238 | }, 239 | { 240 | inputs: [], 241 | name: "poolSwap", 242 | outputs: [{ internalType: "contract PoolSwap", name: "", type: "address" }], 243 | stateMutability: "view", 244 | type: "function", 245 | }, 246 | { 247 | inputs: [], 248 | name: "positionManager", 249 | outputs: [{ internalType: "address", name: "", type: "address" }], 250 | stateMutability: "view", 251 | type: "function", 252 | }, 253 | { 254 | inputs: [], 255 | name: "renounceOwnership", 256 | outputs: [], 257 | stateMutability: "payable", 258 | type: "function", 259 | }, 260 | { 261 | inputs: [], 262 | name: "requestOwnershipHandover", 263 | outputs: [], 264 | stateMutability: "payable", 265 | type: "function", 266 | }, 267 | { 268 | inputs: [{ internalType: "address", name: "_poolSwap", type: "address" }], 269 | name: "setPoolSwap", 270 | outputs: [], 271 | stateMutability: "nonpayable", 272 | type: "function", 273 | }, 274 | { 275 | inputs: [{ internalType: "address", name: "newOwner", type: "address" }], 276 | name: "transferOwnership", 277 | outputs: [], 278 | stateMutability: "payable", 279 | type: "function", 280 | }, 281 | { stateMutability: "payable", type: "receive" }, 282 | ] as const; 283 | -------------------------------------------------------------------------------- /src/abi/StateView.ts: -------------------------------------------------------------------------------- 1 | export const StateViewAbi = [ 2 | { 3 | inputs: [ 4 | { 5 | internalType: "contract IPoolManager", 6 | name: "_poolManager", 7 | type: "address", 8 | }, 9 | ], 10 | stateMutability: "nonpayable", 11 | type: "constructor", 12 | }, 13 | { 14 | inputs: [{ internalType: "PoolId", name: "poolId", type: "bytes32" }], 15 | name: "getFeeGrowthGlobals", 16 | outputs: [ 17 | { internalType: "uint256", name: "feeGrowthGlobal0", type: "uint256" }, 18 | { internalType: "uint256", name: "feeGrowthGlobal1", type: "uint256" }, 19 | ], 20 | stateMutability: "view", 21 | type: "function", 22 | }, 23 | { 24 | inputs: [ 25 | { internalType: "PoolId", name: "poolId", type: "bytes32" }, 26 | { internalType: "int24", name: "tickLower", type: "int24" }, 27 | { internalType: "int24", name: "tickUpper", type: "int24" }, 28 | ], 29 | name: "getFeeGrowthInside", 30 | outputs: [ 31 | { 32 | internalType: "uint256", 33 | name: "feeGrowthInside0X128", 34 | type: "uint256", 35 | }, 36 | { 37 | internalType: "uint256", 38 | name: "feeGrowthInside1X128", 39 | type: "uint256", 40 | }, 41 | ], 42 | stateMutability: "view", 43 | type: "function", 44 | }, 45 | { 46 | inputs: [{ internalType: "PoolId", name: "poolId", type: "bytes32" }], 47 | name: "getLiquidity", 48 | outputs: [{ internalType: "uint128", name: "liquidity", type: "uint128" }], 49 | stateMutability: "view", 50 | type: "function", 51 | }, 52 | { 53 | inputs: [ 54 | { internalType: "PoolId", name: "poolId", type: "bytes32" }, 55 | { internalType: "bytes32", name: "positionId", type: "bytes32" }, 56 | ], 57 | name: "getPositionInfo", 58 | outputs: [ 59 | { internalType: "uint128", name: "liquidity", type: "uint128" }, 60 | { 61 | internalType: "uint256", 62 | name: "feeGrowthInside0LastX128", 63 | type: "uint256", 64 | }, 65 | { 66 | internalType: "uint256", 67 | name: "feeGrowthInside1LastX128", 68 | type: "uint256", 69 | }, 70 | ], 71 | stateMutability: "view", 72 | type: "function", 73 | }, 74 | { 75 | inputs: [ 76 | { internalType: "PoolId", name: "poolId", type: "bytes32" }, 77 | { internalType: "address", name: "owner", type: "address" }, 78 | { internalType: "int24", name: "tickLower", type: "int24" }, 79 | { internalType: "int24", name: "tickUpper", type: "int24" }, 80 | { internalType: "bytes32", name: "salt", type: "bytes32" }, 81 | ], 82 | name: "getPositionInfo", 83 | outputs: [ 84 | { internalType: "uint128", name: "liquidity", type: "uint128" }, 85 | { 86 | internalType: "uint256", 87 | name: "feeGrowthInside0LastX128", 88 | type: "uint256", 89 | }, 90 | { 91 | internalType: "uint256", 92 | name: "feeGrowthInside1LastX128", 93 | type: "uint256", 94 | }, 95 | ], 96 | stateMutability: "view", 97 | type: "function", 98 | }, 99 | { 100 | inputs: [ 101 | { internalType: "PoolId", name: "poolId", type: "bytes32" }, 102 | { internalType: "bytes32", name: "positionId", type: "bytes32" }, 103 | ], 104 | name: "getPositionLiquidity", 105 | outputs: [{ internalType: "uint128", name: "liquidity", type: "uint128" }], 106 | stateMutability: "view", 107 | type: "function", 108 | }, 109 | { 110 | inputs: [{ internalType: "PoolId", name: "poolId", type: "bytes32" }], 111 | name: "getSlot0", 112 | outputs: [ 113 | { internalType: "uint160", name: "sqrtPriceX96", type: "uint160" }, 114 | { internalType: "int24", name: "tick", type: "int24" }, 115 | { internalType: "uint24", name: "protocolFee", type: "uint24" }, 116 | { internalType: "uint24", name: "lpFee", type: "uint24" }, 117 | ], 118 | stateMutability: "view", 119 | type: "function", 120 | }, 121 | { 122 | inputs: [ 123 | { internalType: "PoolId", name: "poolId", type: "bytes32" }, 124 | { internalType: "int16", name: "tick", type: "int16" }, 125 | ], 126 | name: "getTickBitmap", 127 | outputs: [{ internalType: "uint256", name: "tickBitmap", type: "uint256" }], 128 | stateMutability: "view", 129 | type: "function", 130 | }, 131 | { 132 | inputs: [ 133 | { internalType: "PoolId", name: "poolId", type: "bytes32" }, 134 | { internalType: "int24", name: "tick", type: "int24" }, 135 | ], 136 | name: "getTickFeeGrowthOutside", 137 | outputs: [ 138 | { 139 | internalType: "uint256", 140 | name: "feeGrowthOutside0X128", 141 | type: "uint256", 142 | }, 143 | { 144 | internalType: "uint256", 145 | name: "feeGrowthOutside1X128", 146 | type: "uint256", 147 | }, 148 | ], 149 | stateMutability: "view", 150 | type: "function", 151 | }, 152 | { 153 | inputs: [ 154 | { internalType: "PoolId", name: "poolId", type: "bytes32" }, 155 | { internalType: "int24", name: "tick", type: "int24" }, 156 | ], 157 | name: "getTickInfo", 158 | outputs: [ 159 | { internalType: "uint128", name: "liquidityGross", type: "uint128" }, 160 | { internalType: "int128", name: "liquidityNet", type: "int128" }, 161 | { 162 | internalType: "uint256", 163 | name: "feeGrowthOutside0X128", 164 | type: "uint256", 165 | }, 166 | { 167 | internalType: "uint256", 168 | name: "feeGrowthOutside1X128", 169 | type: "uint256", 170 | }, 171 | ], 172 | stateMutability: "view", 173 | type: "function", 174 | }, 175 | { 176 | inputs: [ 177 | { internalType: "PoolId", name: "poolId", type: "bytes32" }, 178 | { internalType: "int24", name: "tick", type: "int24" }, 179 | ], 180 | name: "getTickLiquidity", 181 | outputs: [ 182 | { internalType: "uint128", name: "liquidityGross", type: "uint128" }, 183 | { internalType: "int128", name: "liquidityNet", type: "int128" }, 184 | ], 185 | stateMutability: "view", 186 | type: "function", 187 | }, 188 | { 189 | inputs: [], 190 | name: "poolManager", 191 | outputs: [ 192 | { internalType: "contract IPoolManager", name: "", type: "address" }, 193 | ], 194 | stateMutability: "view", 195 | type: "function", 196 | }, 197 | ] as const; 198 | -------------------------------------------------------------------------------- /src/abi/TreasuryManagerFactory.ts: -------------------------------------------------------------------------------- 1 | export const TreasuryManagerFactoryAbi = [ 2 | { 3 | inputs: [ 4 | { internalType: "address", name: "_protocolOwner", type: "address" }, 5 | { internalType: "address", name: "_feeEscrow", type: "address" }, 6 | ], 7 | stateMutability: "nonpayable", 8 | type: "constructor", 9 | }, 10 | { inputs: [], name: "AccessControlBadConfirmation", type: "error" }, 11 | { 12 | inputs: [ 13 | { internalType: "address", name: "account", type: "address" }, 14 | { internalType: "bytes32", name: "neededRole", type: "bytes32" }, 15 | ], 16 | name: "AccessControlUnauthorizedAccount", 17 | type: "error", 18 | }, 19 | { inputs: [], name: "AlreadyInitialized", type: "error" }, 20 | { inputs: [], name: "NewOwnerIsZeroAddress", type: "error" }, 21 | { inputs: [], name: "NoHandoverRequest", type: "error" }, 22 | { inputs: [], name: "Unauthorized", type: "error" }, 23 | { inputs: [], name: "UnknownManagerImplemention", type: "error" }, 24 | { 25 | anonymous: false, 26 | inputs: [ 27 | { 28 | indexed: true, 29 | internalType: "address", 30 | name: "_manager", 31 | type: "address", 32 | }, 33 | { 34 | indexed: true, 35 | internalType: "address", 36 | name: "_managerImplementation", 37 | type: "address", 38 | }, 39 | ], 40 | name: "ManagerDeployed", 41 | type: "event", 42 | }, 43 | { 44 | anonymous: false, 45 | inputs: [ 46 | { 47 | indexed: true, 48 | internalType: "address", 49 | name: "_managerImplementation", 50 | type: "address", 51 | }, 52 | ], 53 | name: "ManagerImplementationApproved", 54 | type: "event", 55 | }, 56 | { 57 | anonymous: false, 58 | inputs: [ 59 | { 60 | indexed: true, 61 | internalType: "address", 62 | name: "_managerImplementation", 63 | type: "address", 64 | }, 65 | ], 66 | name: "ManagerImplementationUnapproved", 67 | type: "event", 68 | }, 69 | { 70 | anonymous: false, 71 | inputs: [ 72 | { 73 | indexed: true, 74 | internalType: "address", 75 | name: "pendingOwner", 76 | type: "address", 77 | }, 78 | ], 79 | name: "OwnershipHandoverCanceled", 80 | type: "event", 81 | }, 82 | { 83 | anonymous: false, 84 | inputs: [ 85 | { 86 | indexed: true, 87 | internalType: "address", 88 | name: "pendingOwner", 89 | type: "address", 90 | }, 91 | ], 92 | name: "OwnershipHandoverRequested", 93 | type: "event", 94 | }, 95 | { 96 | anonymous: false, 97 | inputs: [ 98 | { 99 | indexed: true, 100 | internalType: "address", 101 | name: "oldOwner", 102 | type: "address", 103 | }, 104 | { 105 | indexed: true, 106 | internalType: "address", 107 | name: "newOwner", 108 | type: "address", 109 | }, 110 | ], 111 | name: "OwnershipTransferred", 112 | type: "event", 113 | }, 114 | { 115 | anonymous: false, 116 | inputs: [ 117 | { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, 118 | { 119 | indexed: true, 120 | internalType: "bytes32", 121 | name: "previousAdminRole", 122 | type: "bytes32", 123 | }, 124 | { 125 | indexed: true, 126 | internalType: "bytes32", 127 | name: "newAdminRole", 128 | type: "bytes32", 129 | }, 130 | ], 131 | name: "RoleAdminChanged", 132 | type: "event", 133 | }, 134 | { 135 | anonymous: false, 136 | inputs: [ 137 | { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, 138 | { 139 | indexed: true, 140 | internalType: "address", 141 | name: "account", 142 | type: "address", 143 | }, 144 | { 145 | indexed: true, 146 | internalType: "address", 147 | name: "sender", 148 | type: "address", 149 | }, 150 | ], 151 | name: "RoleGranted", 152 | type: "event", 153 | }, 154 | { 155 | anonymous: false, 156 | inputs: [ 157 | { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, 158 | { 159 | indexed: true, 160 | internalType: "address", 161 | name: "account", 162 | type: "address", 163 | }, 164 | { 165 | indexed: true, 166 | internalType: "address", 167 | name: "sender", 168 | type: "address", 169 | }, 170 | ], 171 | name: "RoleRevoked", 172 | type: "event", 173 | }, 174 | { 175 | inputs: [], 176 | name: "DEFAULT_ADMIN_ROLE", 177 | outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], 178 | stateMutability: "view", 179 | type: "function", 180 | }, 181 | { 182 | inputs: [ 183 | { 184 | internalType: "address", 185 | name: "_managerImplementation", 186 | type: "address", 187 | }, 188 | ], 189 | name: "approveManager", 190 | outputs: [], 191 | stateMutability: "nonpayable", 192 | type: "function", 193 | }, 194 | { 195 | inputs: [ 196 | { 197 | internalType: "address", 198 | name: "_managerImplementation", 199 | type: "address", 200 | }, 201 | ], 202 | name: "approvedManagerImplementation", 203 | outputs: [{ internalType: "bool", name: "_approved", type: "bool" }], 204 | stateMutability: "view", 205 | type: "function", 206 | }, 207 | { 208 | inputs: [], 209 | name: "cancelOwnershipHandover", 210 | outputs: [], 211 | stateMutability: "payable", 212 | type: "function", 213 | }, 214 | { 215 | inputs: [ 216 | { internalType: "address", name: "pendingOwner", type: "address" }, 217 | ], 218 | name: "completeOwnershipHandover", 219 | outputs: [], 220 | stateMutability: "payable", 221 | type: "function", 222 | }, 223 | { 224 | inputs: [ 225 | { 226 | internalType: "address", 227 | name: "_managerImplementation", 228 | type: "address", 229 | }, 230 | { internalType: "address", name: "_owner", type: "address" }, 231 | { internalType: "bytes", name: "_data", type: "bytes" }, 232 | ], 233 | name: "deployAndInitializeManager", 234 | outputs: [ 235 | { internalType: "address payable", name: "manager_", type: "address" }, 236 | ], 237 | stateMutability: "nonpayable", 238 | type: "function", 239 | }, 240 | { 241 | inputs: [ 242 | { 243 | internalType: "address", 244 | name: "_managerImplementation", 245 | type: "address", 246 | }, 247 | ], 248 | name: "deployManager", 249 | outputs: [ 250 | { internalType: "address payable", name: "manager_", type: "address" }, 251 | ], 252 | stateMutability: "nonpayable", 253 | type: "function", 254 | }, 255 | { 256 | inputs: [], 257 | name: "feeEscrow", 258 | outputs: [ 259 | { internalType: "contract IFeeEscrow", name: "", type: "address" }, 260 | ], 261 | stateMutability: "view", 262 | type: "function", 263 | }, 264 | { 265 | inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }], 266 | name: "getRoleAdmin", 267 | outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], 268 | stateMutability: "view", 269 | type: "function", 270 | }, 271 | { 272 | inputs: [ 273 | { internalType: "bytes32", name: "role", type: "bytes32" }, 274 | { internalType: "address", name: "account", type: "address" }, 275 | ], 276 | name: "grantRole", 277 | outputs: [], 278 | stateMutability: "nonpayable", 279 | type: "function", 280 | }, 281 | { 282 | inputs: [ 283 | { internalType: "bytes32", name: "role", type: "bytes32" }, 284 | { internalType: "address", name: "account", type: "address" }, 285 | ], 286 | name: "hasRole", 287 | outputs: [{ internalType: "bool", name: "", type: "bool" }], 288 | stateMutability: "view", 289 | type: "function", 290 | }, 291 | { 292 | inputs: [{ internalType: "address", name: "_manager", type: "address" }], 293 | name: "managerImplementation", 294 | outputs: [ 295 | { 296 | internalType: "address", 297 | name: "_managerImplementation", 298 | type: "address", 299 | }, 300 | ], 301 | stateMutability: "view", 302 | type: "function", 303 | }, 304 | { 305 | inputs: [], 306 | name: "owner", 307 | outputs: [{ internalType: "address", name: "result", type: "address" }], 308 | stateMutability: "view", 309 | type: "function", 310 | }, 311 | { 312 | inputs: [ 313 | { internalType: "address", name: "pendingOwner", type: "address" }, 314 | ], 315 | name: "ownershipHandoverExpiresAt", 316 | outputs: [{ internalType: "uint256", name: "result", type: "uint256" }], 317 | stateMutability: "view", 318 | type: "function", 319 | }, 320 | { 321 | inputs: [], 322 | name: "renounceOwnership", 323 | outputs: [], 324 | stateMutability: "payable", 325 | type: "function", 326 | }, 327 | { 328 | inputs: [ 329 | { internalType: "bytes32", name: "role", type: "bytes32" }, 330 | { internalType: "address", name: "callerConfirmation", type: "address" }, 331 | ], 332 | name: "renounceRole", 333 | outputs: [], 334 | stateMutability: "nonpayable", 335 | type: "function", 336 | }, 337 | { 338 | inputs: [], 339 | name: "requestOwnershipHandover", 340 | outputs: [], 341 | stateMutability: "payable", 342 | type: "function", 343 | }, 344 | { 345 | inputs: [ 346 | { internalType: "bytes32", name: "role", type: "bytes32" }, 347 | { internalType: "address", name: "account", type: "address" }, 348 | ], 349 | name: "revokeRole", 350 | outputs: [], 351 | stateMutability: "nonpayable", 352 | type: "function", 353 | }, 354 | { 355 | inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], 356 | name: "supportsInterface", 357 | outputs: [{ internalType: "bool", name: "", type: "bool" }], 358 | stateMutability: "view", 359 | type: "function", 360 | }, 361 | { 362 | inputs: [{ internalType: "address", name: "newOwner", type: "address" }], 363 | name: "transferOwnership", 364 | outputs: [], 365 | stateMutability: "payable", 366 | type: "function", 367 | }, 368 | { 369 | inputs: [ 370 | { 371 | internalType: "address", 372 | name: "_managerImplementation", 373 | type: "address", 374 | }, 375 | ], 376 | name: "unapproveManager", 377 | outputs: [], 378 | stateMutability: "nonpayable", 379 | type: "function", 380 | }, 381 | ] as const; 382 | -------------------------------------------------------------------------------- /src/abi/UniversalRouter.ts: -------------------------------------------------------------------------------- 1 | export const UniversalRouterAbi = [ 2 | { 3 | inputs: [ 4 | { 5 | components: [ 6 | { internalType: "address", name: "permit2", type: "address" }, 7 | { internalType: "address", name: "weth9", type: "address" }, 8 | { internalType: "address", name: "v2Factory", type: "address" }, 9 | { internalType: "address", name: "v3Factory", type: "address" }, 10 | { 11 | internalType: "bytes32", 12 | name: "pairInitCodeHash", 13 | type: "bytes32", 14 | }, 15 | { 16 | internalType: "bytes32", 17 | name: "poolInitCodeHash", 18 | type: "bytes32", 19 | }, 20 | { internalType: "address", name: "v4PoolManager", type: "address" }, 21 | { 22 | internalType: "address", 23 | name: "v3NFTPositionManager", 24 | type: "address", 25 | }, 26 | { 27 | internalType: "address", 28 | name: "v4PositionManager", 29 | type: "address", 30 | }, 31 | ], 32 | internalType: "struct RouterParameters", 33 | name: "params", 34 | type: "tuple", 35 | }, 36 | ], 37 | stateMutability: "nonpayable", 38 | type: "constructor", 39 | }, 40 | { inputs: [], name: "BalanceTooLow", type: "error" }, 41 | { inputs: [], name: "ContractLocked", type: "error" }, 42 | { 43 | inputs: [{ internalType: "Currency", name: "currency", type: "address" }], 44 | name: "DeltaNotNegative", 45 | type: "error", 46 | }, 47 | { 48 | inputs: [{ internalType: "Currency", name: "currency", type: "address" }], 49 | name: "DeltaNotPositive", 50 | type: "error", 51 | }, 52 | { inputs: [], name: "ETHNotAccepted", type: "error" }, 53 | { 54 | inputs: [ 55 | { internalType: "uint256", name: "commandIndex", type: "uint256" }, 56 | { internalType: "bytes", name: "message", type: "bytes" }, 57 | ], 58 | name: "ExecutionFailed", 59 | type: "error", 60 | }, 61 | { inputs: [], name: "FromAddressIsNotOwner", type: "error" }, 62 | { inputs: [], name: "InputLengthMismatch", type: "error" }, 63 | { inputs: [], name: "InsufficientBalance", type: "error" }, 64 | { inputs: [], name: "InsufficientETH", type: "error" }, 65 | { inputs: [], name: "InsufficientToken", type: "error" }, 66 | { 67 | inputs: [{ internalType: "bytes4", name: "action", type: "bytes4" }], 68 | name: "InvalidAction", 69 | type: "error", 70 | }, 71 | { inputs: [], name: "InvalidBips", type: "error" }, 72 | { 73 | inputs: [{ internalType: "uint256", name: "commandType", type: "uint256" }], 74 | name: "InvalidCommandType", 75 | type: "error", 76 | }, 77 | { inputs: [], name: "InvalidEthSender", type: "error" }, 78 | { inputs: [], name: "InvalidPath", type: "error" }, 79 | { inputs: [], name: "InvalidReserves", type: "error" }, 80 | { inputs: [], name: "LengthMismatch", type: "error" }, 81 | { 82 | inputs: [{ internalType: "uint256", name: "tokenId", type: "uint256" }], 83 | name: "NotAuthorizedForToken", 84 | type: "error", 85 | }, 86 | { inputs: [], name: "NotPoolManager", type: "error" }, 87 | { inputs: [], name: "OnlyMintAllowed", type: "error" }, 88 | { inputs: [], name: "SliceOutOfBounds", type: "error" }, 89 | { inputs: [], name: "TransactionDeadlinePassed", type: "error" }, 90 | { inputs: [], name: "UnsafeCast", type: "error" }, 91 | { 92 | inputs: [{ internalType: "uint256", name: "action", type: "uint256" }], 93 | name: "UnsupportedAction", 94 | type: "error", 95 | }, 96 | { inputs: [], name: "V2InvalidPath", type: "error" }, 97 | { inputs: [], name: "V2TooLittleReceived", type: "error" }, 98 | { inputs: [], name: "V2TooMuchRequested", type: "error" }, 99 | { inputs: [], name: "V3InvalidAmountOut", type: "error" }, 100 | { inputs: [], name: "V3InvalidCaller", type: "error" }, 101 | { inputs: [], name: "V3InvalidSwap", type: "error" }, 102 | { inputs: [], name: "V3TooLittleReceived", type: "error" }, 103 | { inputs: [], name: "V3TooMuchRequested", type: "error" }, 104 | { 105 | inputs: [ 106 | { 107 | internalType: "uint256", 108 | name: "minAmountOutReceived", 109 | type: "uint256", 110 | }, 111 | { internalType: "uint256", name: "amountReceived", type: "uint256" }, 112 | ], 113 | name: "V4TooLittleReceived", 114 | type: "error", 115 | }, 116 | { 117 | inputs: [ 118 | { 119 | internalType: "uint256", 120 | name: "maxAmountInRequested", 121 | type: "uint256", 122 | }, 123 | { internalType: "uint256", name: "amountRequested", type: "uint256" }, 124 | ], 125 | name: "V4TooMuchRequested", 126 | type: "error", 127 | }, 128 | { 129 | inputs: [], 130 | name: "V3_POSITION_MANAGER", 131 | outputs: [ 132 | { 133 | internalType: "contract INonfungiblePositionManager", 134 | name: "", 135 | type: "address", 136 | }, 137 | ], 138 | stateMutability: "view", 139 | type: "function", 140 | }, 141 | { 142 | inputs: [], 143 | name: "V4_POSITION_MANAGER", 144 | outputs: [ 145 | { internalType: "contract IPositionManager", name: "", type: "address" }, 146 | ], 147 | stateMutability: "view", 148 | type: "function", 149 | }, 150 | { 151 | inputs: [ 152 | { internalType: "bytes", name: "commands", type: "bytes" }, 153 | { internalType: "bytes[]", name: "inputs", type: "bytes[]" }, 154 | ], 155 | name: "execute", 156 | outputs: [], 157 | stateMutability: "payable", 158 | type: "function", 159 | }, 160 | { 161 | inputs: [ 162 | { internalType: "bytes", name: "commands", type: "bytes" }, 163 | { internalType: "bytes[]", name: "inputs", type: "bytes[]" }, 164 | { internalType: "uint256", name: "deadline", type: "uint256" }, 165 | ], 166 | name: "execute", 167 | outputs: [], 168 | stateMutability: "payable", 169 | type: "function", 170 | }, 171 | { 172 | inputs: [], 173 | name: "msgSender", 174 | outputs: [{ internalType: "address", name: "", type: "address" }], 175 | stateMutability: "view", 176 | type: "function", 177 | }, 178 | { 179 | inputs: [], 180 | name: "poolManager", 181 | outputs: [ 182 | { internalType: "contract IPoolManager", name: "", type: "address" }, 183 | ], 184 | stateMutability: "view", 185 | type: "function", 186 | }, 187 | { 188 | inputs: [ 189 | { internalType: "int256", name: "amount0Delta", type: "int256" }, 190 | { internalType: "int256", name: "amount1Delta", type: "int256" }, 191 | { internalType: "bytes", name: "data", type: "bytes" }, 192 | ], 193 | name: "uniswapV3SwapCallback", 194 | outputs: [], 195 | stateMutability: "nonpayable", 196 | type: "function", 197 | }, 198 | { 199 | inputs: [{ internalType: "bytes", name: "data", type: "bytes" }], 200 | name: "unlockCallback", 201 | outputs: [{ internalType: "bytes", name: "", type: "bytes" }], 202 | stateMutability: "nonpayable", 203 | type: "function", 204 | }, 205 | { stateMutability: "payable", type: "receive" }, 206 | ] as const; 207 | -------------------------------------------------------------------------------- /src/abi/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./AnyPositionManager"; 2 | export * from "./BidWall"; 3 | export * from "./BidWallV1_1"; 4 | export * from "./FairLaunch"; 5 | export * from "./FairLaunchV1_1"; 6 | export * from "./FastFlaunchZap"; 7 | export * from "./FeeEscrow"; 8 | export * from "./Flaunch"; 9 | export * from "./FlaunchPositionManager"; 10 | export * from "./FlaunchPositionManagerV1_1"; 11 | export * from "./FlaunchV1_1"; 12 | export * from "./FlaunchZap"; 13 | export * from "./InitialPrice"; 14 | export * from "./Memecoin"; 15 | export * from "./Multicall"; 16 | export * from "./Permit2"; 17 | export * from "./PoolManager"; 18 | export * from "./Quoter"; 19 | export * from "./ReferralEscrow"; 20 | export * from "./RevenueManager"; 21 | export * from "./StateView"; 22 | export * from "./TreasuryManagerFactory"; 23 | export * from "./UniversalRouter"; 24 | -------------------------------------------------------------------------------- /src/addresses.ts: -------------------------------------------------------------------------------- 1 | import { base, baseSepolia } from "viem/chains"; 2 | import { Addresses, PoolKey } from "./types"; 3 | import { zeroAddress } from "viem"; 4 | 5 | // doesn't use FeeEscrow 6 | export const FlaunchPositionManagerAddress: Addresses = { 7 | [base.id]: "0x51Bba15255406Cfe7099a42183302640ba7dAFDC", 8 | [baseSepolia.id]: "0x9A7059cA00dA92843906Cb4bCa1D005cE848AFdC", 9 | }; 10 | 11 | export const FlaunchPositionManagerV1_1Address: Addresses = { 12 | [base.id]: "0xf785bb58059fab6fb19bdda2cb9078d9e546efdc", 13 | [baseSepolia.id]: "0x24347e0dd16357059abfc1b321df354873552fdc", 14 | }; 15 | 16 | export const AnyPositionManagerAddress: Addresses = { 17 | [base.id]: "0x69a96de474521f7c6c0be3ea0498e5cf2f0565dc", 18 | [baseSepolia.id]: "0xe999c5676b0e0f83292074441292f4b3b11d65dc", 19 | }; 20 | 21 | export const FeeEscrowAddress: Addresses = { 22 | [base.id]: "0x72e6f7948b1B1A343B477F39aAbd2E35E6D27dde", 23 | [baseSepolia.id]: "0x73E27908b7d35A9251a54799A8ef4C17e4ED9FF9", 24 | }; 25 | 26 | export const ReferralEscrowAddress: Addresses = { 27 | [base.id]: "0xBD39c7Be6D98BD1a3e4Ad482baF99d738947fE55", 28 | [baseSepolia.id]: "0x0651cadC51b6a13CB3465C134A22154a2b633779", 29 | }; 30 | 31 | export const FLETHAddress: Addresses = { 32 | [base.id]: "0x000000000D564D5be76f7f0d28fE52605afC7Cf8", 33 | [baseSepolia.id]: "0x79FC52701cD4BE6f9Ba9aDC94c207DE37e3314eb", 34 | }; 35 | 36 | export const FLETHHooksAddress: Addresses = { 37 | [base.id]: "0x9E433F32bb5481a9CA7DFF5b3af74A7ed041a888", 38 | [baseSepolia.id]: "0x4bd2ca15286c96e4e731337de8b375da6841e888", 39 | }; 40 | 41 | export const FairLaunchAddress: Addresses = { 42 | [base.id]: "0xCc7A4A00072ccbeEEbd999edc812C0ce498Fb63B", 43 | [baseSepolia.id]: "0x227Fc288aC56E169f2BfEA82e07F8635054d4136", 44 | }; 45 | 46 | // also supports AnyPositionManager 47 | export const FairLaunchV1_1Address: Addresses = { 48 | [base.id]: "0x4dc442403e8c758425b93c59dc737da522f32640", 49 | [baseSepolia.id]: "0x7922c1ead7c5825fb52ed6b14f397d064508acbe", 50 | }; 51 | 52 | export const FlaunchAddress: Addresses = { 53 | [base.id]: "0xCc7A4A00072ccbeEEbd999edc812C0ce498Fb63B", 54 | [baseSepolia.id]: "0x7D375C9133721083DF7b7e5Cb0Ed8Fc78862dfe3", 55 | }; 56 | 57 | // also supports AnyPositionManager 58 | export const FlaunchV1_1Address: Addresses = { 59 | [base.id]: "0xb4512bf57d50fbcb64a3adf8b17a79b2a204c18c", 60 | [baseSepolia.id]: "0x96be8ff5e244294a34bfa507a39190dc7a839baa", 61 | }; 62 | 63 | export const BidWallAddress: Addresses = { 64 | [base.id]: "0x66681f10BA90496241A25e33380004f30Dfd8aa8", 65 | [baseSepolia.id]: "0xa2107050ACEf4809c88Ab744F8e667605db5ACDB", 66 | }; 67 | 68 | // also supports AnyPositionManager 69 | export const BidWallV1_1Address: Addresses = { 70 | [base.id]: "0x7f22353d1634223a802D1c1Ea5308Ddf5DD0ef9c", 71 | [baseSepolia.id]: "0x6f2fa01a05ff8b6efbfefd91a3b85aaf19265a00", 72 | }; 73 | 74 | export const FastFlaunchZapAddress: Addresses = { 75 | [base.id]: "0x68d967d25806fef4aa134db031cdcc55d3e20f92", 76 | [baseSepolia.id]: "0x821d9f6075e7971cc71c379081de9d532f5f9957", 77 | }; 78 | 79 | export const FlaunchZapAddress: Addresses = { 80 | [base.id]: "0xfa9e8528ee95eb109bffd1a2d59cb95b300a672a", 81 | [baseSepolia.id]: "0xb2f5d987de90e026b61805e60b6002d367461474", 82 | }; 83 | 84 | export const RevenueManagerAddress: Addresses = { 85 | [base.id]: "0x712fa8ddc7347b4b6b029aa21710f365cd02d898", 86 | [baseSepolia.id]: "0x17E02501dE3e420347e7C5fCAe3AD787C5aea690", 87 | }; 88 | 89 | export const TreasuryManagerFactoryAddress: Addresses = { 90 | [base.id]: "0x48af8b28DDC5e5A86c4906212fc35Fa808CA8763", 91 | [baseSepolia.id]: "0xd2f3c6185e06925dcbe794c6574315b2202e9ccd", 92 | }; 93 | 94 | export const PoolManagerAddress: Addresses = { 95 | [base.id]: "0x498581fF718922c3f8e6A244956aF099B2652b2b", 96 | [baseSepolia.id]: "0x05E73354cFDd6745C338b50BcFDfA3Aa6fA03408", 97 | }; 98 | 99 | export const UniversalRouterAddress: Addresses = { 100 | [base.id]: "0x6fF5693b99212Da76ad316178A184AB56D299b43", 101 | [baseSepolia.id]: "0x492E6456D9528771018DeB9E87ef7750EF184104", 102 | }; 103 | 104 | export const QuoterAddress: Addresses = { 105 | [base.id]: "0x0d5e0f971ed27fbff6c2837bf31316121532048d", 106 | [baseSepolia.id]: "0x4a6513c898fe1b2d0e78d3b0e0a4a151589b1cba", 107 | }; 108 | 109 | export const StateViewAddress: Addresses = { 110 | [base.id]: "0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71", 111 | [baseSepolia.id]: "0x571291b572ed32ce6751a2Cb2486EbEe8DEfB9B4", 112 | }; 113 | 114 | export const Permit2Address: Addresses = { 115 | [base.id]: "0x000000000022D473030F116dDEE9F6B43aC78BA3", 116 | [baseSepolia.id]: "0x000000000022D473030F116dDEE9F6B43aC78BA3", 117 | }; 118 | 119 | export const USDCETHPoolKeys: { 120 | [chainId: number]: PoolKey; 121 | } = { 122 | [base.id]: { 123 | currency0: zeroAddress, 124 | currency1: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", 125 | fee: 500, 126 | tickSpacing: 10, 127 | hooks: zeroAddress, 128 | }, 129 | [baseSepolia.id]: { 130 | currency0: zeroAddress, 131 | currency1: "0x036CbD53842c5426634e7929541eC2318f3dCF7e", 132 | fee: 0, 133 | tickSpacing: 30, 134 | hooks: zeroAddress, 135 | }, 136 | }; 137 | -------------------------------------------------------------------------------- /src/clients/BidWallClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { BidwallAbi } from "../abi/BidWall"; 12 | 13 | export type BidwallABI = typeof BidwallAbi; 14 | 15 | /** 16 | * Client for interacting with the BidWall V1 contract in read-only mode 17 | * Provides methods to query bid wall positions and pool information 18 | */ 19 | export class ReadBidWall { 20 | public readonly contract: ReadContract; 21 | 22 | /** 23 | * Creates a new ReadBidWall instance 24 | * @param address - The address of the BidWall contract 25 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 26 | * @throws Error if address is not provided 27 | */ 28 | constructor(address: Address, drift: Drift = createDrift()) { 29 | if (!address) { 30 | throw new Error("Address is required"); 31 | } 32 | 33 | this.contract = drift.contract({ 34 | abi: BidwallAbi, 35 | address, 36 | }); 37 | } 38 | 39 | /** 40 | * Gets information about a bid wall position for a specific pool 41 | * @param poolId - The ID of the pool 42 | * @returns Promise<{amount0_: bigint, amount1_: bigint, pendingEth_: bigint}> - Position details including token amounts and pending ETH 43 | */ 44 | position({ poolId }: { poolId: HexString }) { 45 | return this.contract.read("position", { 46 | _poolId: poolId, 47 | }); 48 | } 49 | 50 | /** 51 | * Gets configuration information about a pool's bid wall 52 | * @param poolId - The ID of the pool 53 | * @returns Promise<{tickLower: number, tickUpper: number}> - Pool configuration including tick range 54 | */ 55 | poolInfo({ poolId }: { poolId: HexString }) { 56 | return this.contract.read("poolInfo", { 57 | _poolId: poolId, 58 | }); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/clients/BidWallV1_1Client.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { BidWallV1_1Abi } from "../abi/BidWallV1_1"; 12 | 13 | export type BidwallV1_1ABI = typeof BidWallV1_1Abi; 14 | 15 | /** 16 | * Client for interacting with the BidWall V1.1 contract in read-only mode 17 | * Provides methods to query bid wall positions and pool information 18 | * Enhanced version of the V1 contract with additional features 19 | */ 20 | export class ReadBidWallV1_1 { 21 | public readonly contract: ReadContract; 22 | 23 | /** 24 | * Creates a new ReadBidWallV1_1 instance 25 | * @param address - The address of the BidWall V1.1 contract 26 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 27 | * @throws Error if address is not provided 28 | */ 29 | constructor(address: Address, drift: Drift = createDrift()) { 30 | if (!address) { 31 | throw new Error("Address is required"); 32 | } 33 | 34 | this.contract = drift.contract({ 35 | abi: BidWallV1_1Abi, 36 | address, 37 | }); 38 | } 39 | 40 | /** 41 | * Gets information about a bid wall position for a specific pool 42 | * @param poolId - The ID of the pool 43 | * @returns Promise<{amount0_: bigint, amount1_: bigint, pendingEth_: bigint}> - Position details including token amounts and pending ETH 44 | */ 45 | position({ poolId }: { poolId: HexString }) { 46 | return this.contract.read("position", { 47 | _poolId: poolId, 48 | }); 49 | } 50 | 51 | /** 52 | * Gets configuration information about a pool's bid wall 53 | * @param poolId - The ID of the pool 54 | * @returns Promise<{tickLower: number, tickUpper: number}> - Pool configuration including tick range 55 | */ 56 | poolInfo({ poolId }: { poolId: HexString }) { 57 | return this.contract.read("poolInfo", { 58 | _poolId: poolId, 59 | }); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/clients/FairLaunchClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { FairLaunchAbi } from "../abi/FairLaunch"; 12 | 13 | export type FairLaunchABI = typeof FairLaunchAbi; 14 | 15 | /** 16 | * Client for interacting with the FairLaunch V1 contract in read-only mode 17 | * Provides methods to query fair launch information and status 18 | */ 19 | export class ReadFairLaunch { 20 | public readonly contract: ReadContract; 21 | 22 | /** 23 | * Creates a new ReadFairLaunch instance 24 | * @param address - The address of the FairLaunch contract 25 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 26 | * @throws Error if address is not provided 27 | */ 28 | constructor(address: Address, drift: Drift = createDrift()) { 29 | if (!address) { 30 | throw new Error("Address is required"); 31 | } 32 | 33 | this.contract = drift.contract({ 34 | abi: FairLaunchAbi, 35 | address, 36 | }); 37 | } 38 | 39 | fairLaunchDuration({ poolId }: { poolId: HexString }) { 40 | return 30 * 60; // 30 minutes 41 | } 42 | 43 | /** 44 | * Gets information about a fair launch for a specific pool 45 | * @param poolId - The ID of the pool 46 | * @returns Promise<{initialTick: number, closed: boolean, endsAt: number}> - Fair launch details 47 | */ 48 | fairLaunchInfo({ poolId }: { poolId: HexString }) { 49 | return this.contract.read("fairLaunchInfo", { 50 | _poolId: poolId, 51 | }); 52 | } 53 | 54 | /** 55 | * Checks if a fair launch is currently active 56 | * @param poolId - The ID of the pool 57 | * @returns Promise - True if the fair launch is active (not closed and not expired), false otherwise 58 | */ 59 | async isFairLaunchActive({ poolId }: { poolId: HexString }) { 60 | const { closed, endsAt } = await this.fairLaunchInfo({ poolId }); 61 | if (closed) { 62 | return false; 63 | } 64 | 65 | if (new Date().getTime() / 1000 > endsAt) { 66 | return false; 67 | } 68 | 69 | return true; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/clients/FairLaunchV1_1Client.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { FairLaunchV1_1Abi } from "../abi/FairLaunchV1_1"; 12 | 13 | export type FairLaunchV1_1ABI = typeof FairLaunchV1_1Abi; 14 | 15 | /** 16 | * Client for interacting with the FairLaunch V1.1 contract in read-only mode 17 | * Provides methods to query fair launch information and status 18 | * Enhanced version of the V1 contract with additional features like variable duration 19 | */ 20 | export class ReadFairLaunchV1_1 { 21 | public readonly contract: ReadContract; 22 | 23 | /** 24 | * Creates a new ReadFairLaunchV1_1 instance 25 | * @param address - The address of the FairLaunch V1.1 contract 26 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 27 | * @throws Error if address is not provided 28 | */ 29 | constructor(address: Address, drift: Drift = createDrift()) { 30 | if (!address) { 31 | throw new Error("Address is required"); 32 | } 33 | 34 | this.contract = drift.contract({ 35 | abi: FairLaunchV1_1Abi, 36 | address, 37 | }); 38 | } 39 | 40 | /** 41 | * Gets information about a fair launch for a specific pool 42 | * @param poolId - The ID of the pool 43 | * @returns Promise<{initialTick: number, closed: boolean, startsAt: number, endsAt: number}> - Fair launch details 44 | */ 45 | fairLaunchInfo({ poolId }: { poolId: HexString }) { 46 | return this.contract.read("fairLaunchInfo", { 47 | _poolId: poolId, 48 | }); 49 | } 50 | 51 | /** 52 | * Calculates the duration of a fair launch 53 | * @param poolId - The ID of the pool 54 | * @returns Promise - The duration in seconds between start and end time 55 | */ 56 | async fairLaunchDuration({ poolId }: { poolId: HexString }) { 57 | const { startsAt, endsAt } = await this.fairLaunchInfo({ poolId }); 58 | return endsAt - startsAt; 59 | } 60 | 61 | /** 62 | * Checks if a fair launch is currently active 63 | * @param poolId - The ID of the pool 64 | * @returns Promise - True if the fair launch is active (not closed and not expired), false otherwise 65 | */ 66 | async isFairLaunchActive({ poolId }: { poolId: HexString }) { 67 | const { closed, endsAt } = await this.fairLaunchInfo({ poolId }); 68 | if (closed) { 69 | return false; 70 | } 71 | 72 | if (new Date().getTime() / 1000 > endsAt) { 73 | return false; 74 | } 75 | 76 | return true; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/clients/FastFlaunchClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | createDrift, 9 | } from "@delvtech/drift"; 10 | import { FastFlaunchZapAbi } from "../abi/FastFlaunchZap"; 11 | import { generateTokenUri } from "../helpers/ipfs"; 12 | import { IPFSParams } from "../types"; 13 | 14 | export type FastFlaunchZapABI = typeof FastFlaunchZapAbi; 15 | 16 | /** 17 | * Base client for interacting with the FastFlaunchZap contract in read-only mode 18 | * Provides basic contract initialization 19 | */ 20 | export class ReadFastFlaunchZap { 21 | public readonly contract: ReadContract; 22 | 23 | /** 24 | * Creates a new ReadFastFlaunchZap instance 25 | * @param address - The address of the FastFlaunchZap contract 26 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 27 | * @throws Error if address is not provided 28 | */ 29 | constructor(address: Address, drift: Drift = createDrift()) { 30 | if (!address) { 31 | throw new Error("Address is required"); 32 | } 33 | this.contract = drift.contract({ 34 | abi: FastFlaunchZapAbi, 35 | address, 36 | }); 37 | } 38 | } 39 | 40 | /** 41 | * Parameters for creating a new fast flaunch with direct token URI 42 | */ 43 | export interface FastFlaunchParams { 44 | /** The name of the token */ 45 | name: string; 46 | /** The symbol of the token */ 47 | symbol: string; 48 | /** The URI containing the token metadata */ 49 | tokenUri: string; 50 | /** The address of the token creator */ 51 | creator: Address; 52 | } 53 | 54 | /** 55 | * Parameters for creating a new fast flaunch with IPFS metadata 56 | * Extends FastFlaunchParams (without tokenUri) and IPFSParams 57 | */ 58 | export interface FastFlaunchIPFSParams 59 | extends Omit, 60 | IPFSParams {} 61 | 62 | /** 63 | * Extended client for interacting with the FastFlaunchZap contract with write capabilities 64 | * Provides methods to create new fast flaunches with direct URI or IPFS metadata 65 | */ 66 | export class ReadWriteFastFlaunchZap extends ReadFastFlaunchZap { 67 | declare contract: ReadWriteContract; 68 | 69 | /** 70 | * Creates a new ReadWriteFastFlaunchZap instance 71 | * @param address - The address of the FastFlaunchZap contract 72 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 73 | */ 74 | constructor( 75 | address: Address, 76 | drift: Drift = createDrift() 77 | ) { 78 | super(address, drift); 79 | } 80 | 81 | /** 82 | * Creates a new fast flaunch with direct token URI 83 | * @param params - Parameters for the fast flaunch including name, symbol, tokenUri, and creator 84 | * @returns Transaction response for the flaunch creation 85 | */ 86 | fastFlaunch({ name, symbol, tokenUri, creator }: FastFlaunchParams) { 87 | return this.contract.write("flaunch", { 88 | _params: { 89 | name, 90 | symbol, 91 | tokenUri, 92 | creator, 93 | }, 94 | }); 95 | } 96 | 97 | /** 98 | * Creates a new fast flaunch with metadata stored on IPFS 99 | * @param params - Parameters for the fast flaunch including name, symbol, creator, metadata, and Pinata config 100 | * @returns Promise resolving to the transaction response for the flaunch creation 101 | */ 102 | async fastFlaunchIPFS({ 103 | name, 104 | symbol, 105 | creator, 106 | metadata, 107 | pinataConfig, 108 | }: FastFlaunchIPFSParams) { 109 | const tokenUri = await generateTokenUri(name, { 110 | metadata, 111 | pinataConfig, 112 | }); 113 | 114 | return this.fastFlaunch({ 115 | name, 116 | symbol, 117 | tokenUri, 118 | creator, 119 | }); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/clients/FeeEscrowClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type ReadWriteContract, 6 | type ReadWriteAdapter, 7 | createDrift, 8 | } from "@delvtech/drift"; 9 | import { FeeEscrowAbi } from "../abi/FeeEscrow"; 10 | 11 | export type FeeEscrowABI = typeof FeeEscrowAbi; 12 | 13 | /** 14 | * Client for interacting with the FeeEscrow contract in read-only mode 15 | * Provides methods to query fee balances and withdraw fees 16 | */ 17 | export class ReadFeeEscrow { 18 | public readonly contract: ReadContract; 19 | 20 | /** 21 | * Creates a new ReadFeeEscrow instance 22 | * @param address - The address of the FeeEscrow contract 23 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 24 | * @throws Error if address is not provided 25 | */ 26 | constructor(address: Address, drift: Drift = createDrift()) { 27 | if (!address) { 28 | throw new Error("Address is required"); 29 | } 30 | 31 | this.contract = drift.contract({ 32 | abi: FeeEscrowAbi, 33 | address, 34 | }); 35 | } 36 | 37 | /** 38 | * Gets the claimable balance of fees for a creator 39 | * @param creator - The address of the creator to check 40 | * @returns Promise - The claimable balance of fees 41 | */ 42 | balances(creator: Address) { 43 | return this.contract.read("balances", { 44 | _recipient: creator, 45 | }); 46 | } 47 | } 48 | 49 | /** 50 | * Extended client for interacting with the FeeEscrow contract with write capabilities 51 | * Provides methods to withdraw fees 52 | */ 53 | export class ReadWriteFeeEscrow extends ReadFeeEscrow { 54 | declare contract: ReadWriteContract; 55 | 56 | constructor( 57 | address: Address, 58 | drift: Drift = createDrift() 59 | ) { 60 | super(address, drift); 61 | } 62 | 63 | /** 64 | * Withdraws fees as ETH to a recipient 65 | * @param recipient - The address to receive the fees 66 | * @param unwrap - Whether to unwrap the native token before sending 67 | * @returns Promise 68 | */ 69 | withdrawFees(recipient: Address) { 70 | return this.contract.write("withdrawFees", { 71 | _recipient: recipient, 72 | _unwrap: true, 73 | }); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/clients/FlaunchClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { FlaunchAbi } from "../abi/Flaunch"; 12 | 13 | export type FlaunchABI = typeof FlaunchAbi; 14 | 15 | /** 16 | * Client for interacting with the Flaunch V1 contract in read-only mode 17 | * Provides methods to query token IDs and metadata URIs 18 | */ 19 | export class ReadFlaunch { 20 | public readonly contract: ReadContract; 21 | 22 | /** 23 | * Creates a new ReadFlaunch instance 24 | * @param address - The address of the Flaunch contract 25 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 26 | * @throws Error if address is not provided 27 | */ 28 | constructor(address: Address, drift: Drift = createDrift()) { 29 | if (!address) { 30 | throw new Error("Address is required"); 31 | } 32 | 33 | this.contract = drift.contract({ 34 | abi: FlaunchAbi, 35 | address, 36 | }); 37 | } 38 | 39 | /** 40 | * Gets the token ID associated with a memecoin 41 | * @param coinAddress - The address of the memecoin 42 | * @returns Promise - The token ID 43 | */ 44 | tokenId(coinAddress: Address) { 45 | return this.contract.read("tokenId", { 46 | _memecoin: coinAddress, 47 | }); 48 | } 49 | 50 | /** 51 | * Gets the metadata URI for a token 52 | * @param tokenId - The ID of the token 53 | * @returns Promise - The token's metadata URI 54 | */ 55 | tokenURI(tokenId: bigint) { 56 | return this.contract.read("tokenURI", { 57 | _tokenId: tokenId, 58 | }); 59 | } 60 | 61 | /** 62 | * Gets the memecoin address for a given token ID 63 | * @param tokenId - The ID of the token 64 | * @returns Promise
- The address of the memecoin 65 | */ 66 | memecoin(tokenId: bigint) { 67 | return this.contract.read("memecoin", { 68 | _tokenId: tokenId, 69 | }); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/clients/FlaunchV1_1Client.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { FlaunchV1_1Abi } from "../abi/FlaunchV1_1"; 12 | 13 | export type FlaunchV1_1ABI = typeof FlaunchV1_1Abi; 14 | 15 | /** 16 | * Client for interacting with the Flaunch V1.1 contract in read-only mode 17 | * Provides methods to query token IDs and metadata URIs 18 | * Enhanced version of the V1 contract with additional features 19 | */ 20 | export class ReadFlaunchV1_1 { 21 | public readonly contract: ReadContract; 22 | 23 | /** 24 | * Creates a new ReadFlaunchV1_1 instance 25 | * @param address - The address of the Flaunch V1.1 contract 26 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 27 | * @throws Error if address is not provided 28 | */ 29 | constructor(address: Address, drift: Drift = createDrift()) { 30 | if (!address) { 31 | throw new Error("Address is required"); 32 | } 33 | 34 | this.contract = drift.contract({ 35 | abi: FlaunchV1_1Abi, 36 | address, 37 | }); 38 | } 39 | 40 | /** 41 | * Gets the token ID associated with a memecoin 42 | * @param coinAddress - The address of the memecoin 43 | * @returns Promise - The token ID 44 | */ 45 | tokenId(coinAddress: Address) { 46 | return this.contract.read("tokenId", { 47 | _memecoin: coinAddress, 48 | }); 49 | } 50 | 51 | /** 52 | * Gets the metadata URI for a token 53 | * @param tokenId - The ID of the token 54 | * @returns Promise - The token's metadata URI 55 | */ 56 | tokenURI(tokenId: bigint) { 57 | return this.contract.read("tokenURI", { 58 | _tokenId: tokenId, 59 | }); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/clients/FlaunchZapClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { FlaunchZapAbi } from "../abi/FlaunchZap"; 12 | import { parseUnits, zeroAddress, zeroHash } from "viem"; 13 | import { encodeAbiParameters } from "viem"; 14 | import { generateTokenUri } from "../helpers/ipfs"; 15 | import { IPFSParams } from "../types"; 16 | import { ReadFlaunchPositionManagerV1_1 } from "./FlaunchPositionManagerV1_1Client"; 17 | import { FlaunchPositionManagerV1_1Address } from "addresses"; 18 | import { getAmountWithSlippage } from "utils/universalRouter"; 19 | import { ReadInitialPrice } from "./InitialPriceClient"; 20 | 21 | export type FlaunchZapABI = typeof FlaunchZapAbi; 22 | 23 | export interface FlaunchParams { 24 | name: string; 25 | symbol: string; 26 | tokenUri: string; 27 | fairLaunchPercent: number; 28 | fairLaunchDuration: number; 29 | initialMarketCapUSD: number; 30 | creator: Address; 31 | creatorFeeAllocationPercent: number; 32 | flaunchAt?: bigint; 33 | premineAmount?: bigint; 34 | } 35 | 36 | export interface FlaunchIPFSParams 37 | extends Omit, 38 | IPFSParams {} 39 | 40 | export interface FlaunchWithRevenueManagerParams extends FlaunchParams { 41 | revenueManagerInstanceAddress: Address; 42 | } 43 | 44 | export interface FlaunchWithRevenueManagerIPFSParams 45 | extends Omit, 46 | IPFSParams {} 47 | 48 | /** 49 | * Base client for interacting with the FlaunchZap contract in read-only mode 50 | * Provides basic contract initialization 51 | */ 52 | export class ReadFlaunchZap { 53 | drift: Drift; 54 | chainId: number; 55 | public readonly contract: ReadContract; 56 | public readonly TOTAL_SUPPLY = 100n * 10n ** 27n; // 100 Billion tokens in wei 57 | public readonly readPositionManagerV1_1: ReadFlaunchPositionManagerV1_1; 58 | 59 | /** 60 | * Creates a new ReadFlaunchZap instance 61 | * @param chainId - The chain ID of the contract 62 | * @param address - The address of the FlaunchZap contract 63 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 64 | * @throws Error if address is not provided 65 | */ 66 | constructor(chainId: number, address: Address, drift: Drift = createDrift()) { 67 | this.chainId = chainId; 68 | this.drift = drift; 69 | if (!address) { 70 | throw new Error("Address is required"); 71 | } 72 | this.contract = drift.contract({ 73 | abi: FlaunchZapAbi, 74 | address, 75 | }); 76 | this.readPositionManagerV1_1 = new ReadFlaunchPositionManagerV1_1( 77 | FlaunchPositionManagerV1_1Address[this.chainId], 78 | drift 79 | ); 80 | } 81 | 82 | async getPremineCostInWei(params: { 83 | initialPriceParams: HexString; 84 | premineAmount: bigint; 85 | slippagePercent?: number; 86 | }) { 87 | const mcapInWei = await this.readPositionManagerV1_1.getFlaunchingMarketCap( 88 | params.initialPriceParams 89 | ); 90 | const premineCostInWei = 91 | (mcapInWei * params.premineAmount) / this.TOTAL_SUPPLY; 92 | 93 | // increase the premine cost by the slippage percent 94 | const premineCostInWeiWithSlippage = getAmountWithSlippage( 95 | premineCostInWei, 96 | (params.slippagePercent ?? 0 / 100).toFixed(18).toString(), 97 | "EXACT_OUT" // as we know the output premine amount 98 | ); 99 | return premineCostInWeiWithSlippage; 100 | } 101 | 102 | async getFlaunchingFee(params: { 103 | sender: Address; 104 | initialPriceParams: HexString; 105 | slippagePercent?: number; 106 | }) { 107 | const readInitialPrice = new ReadInitialPrice( 108 | await this.readPositionManagerV1_1.initialPrice(), 109 | this.drift 110 | ); 111 | const flaunchingFee = await readInitialPrice.getFlaunchingFee(params); 112 | 113 | // increase the flaunching fee by the slippage percent 114 | const flaunchingFeeWithSlippage = getAmountWithSlippage( 115 | flaunchingFee, 116 | (params.slippagePercent ?? 0 / 100).toFixed(18).toString(), 117 | "EXACT_OUT" 118 | ); 119 | return flaunchingFeeWithSlippage; 120 | } 121 | 122 | /** 123 | * Calculates the ETH required to flaunch a token, takes into account the ETH for premine and the flaunching fee 124 | */ 125 | ethRequiredToFlaunch(params: { 126 | premineAmount: bigint; 127 | initialPriceParams: HexString; 128 | slippagePercent?: number; 129 | }) { 130 | return this.contract.read("calculateFee", { 131 | _premineAmount: params.premineAmount ?? 0n, 132 | _slippage: params.slippagePercent 133 | ? BigInt(params.slippagePercent * 100) 134 | : 0n, 135 | _initialPriceParams: params.initialPriceParams, 136 | }); 137 | } 138 | } 139 | 140 | /** 141 | * Extended client for interacting with the FlaunchZap contract with write capabilities 142 | */ 143 | export class ReadWriteFlaunchZap extends ReadFlaunchZap { 144 | declare contract: ReadWriteContract; 145 | 146 | constructor( 147 | chainId: number, 148 | address: Address, 149 | drift: Drift = createDrift() 150 | ) { 151 | super(chainId, address, drift); 152 | } 153 | 154 | /** 155 | * Flaunches a new token, supports premine 156 | * @param params - Parameters for the flaunch 157 | * @returns Transaction response for the flaunch creation 158 | */ 159 | async flaunch(params: FlaunchParams) { 160 | const initialMCapInUSDCWei = parseUnits( 161 | params.initialMarketCapUSD.toString(), 162 | 6 163 | ); 164 | const initialPriceParams = encodeAbiParameters( 165 | [ 166 | { 167 | type: "uint256", 168 | }, 169 | ], 170 | [initialMCapInUSDCWei] 171 | ); 172 | 173 | const fairLaunchInBps = BigInt(params.fairLaunchPercent * 100); 174 | const creatorFeeAllocationInBps = params.creatorFeeAllocationPercent * 100; 175 | 176 | const ethRequired = await this.ethRequiredToFlaunch({ 177 | premineAmount: params.premineAmount ?? 0n, 178 | initialPriceParams, 179 | slippagePercent: 5, 180 | }); 181 | 182 | return this.contract.write( 183 | "flaunch", 184 | { 185 | _flaunchParams: { 186 | name: params.name, 187 | symbol: params.symbol, 188 | tokenUri: params.tokenUri, 189 | initialTokenFairLaunch: 190 | (this.TOTAL_SUPPLY * fairLaunchInBps) / 10_000n, 191 | fairLaunchDuration: BigInt(params.fairLaunchDuration), 192 | premineAmount: params.premineAmount ?? 0n, 193 | creator: params.creator, 194 | creatorFeeAllocation: creatorFeeAllocationInBps, 195 | flaunchAt: params.flaunchAt ?? 0n, 196 | initialPriceParams, 197 | feeCalculatorParams: "0x", 198 | }, 199 | _treasuryManagerParams: { 200 | manager: zeroAddress, 201 | initializeData: "0x", 202 | depositData: "0x", 203 | }, 204 | _whitelistParams: { 205 | merkleRoot: zeroHash, 206 | merkleIPFSHash: "", 207 | maxTokens: 0n, 208 | }, 209 | _airdropParams: { 210 | airdropIndex: 0n, 211 | airdropAmount: 0n, 212 | airdropEndTime: 0n, 213 | merkleRoot: zeroHash, 214 | merkleIPFSHash: "", 215 | }, 216 | }, 217 | { 218 | value: ethRequired, 219 | } 220 | ); 221 | } 222 | 223 | async flaunchIPFS(params: FlaunchIPFSParams) { 224 | const tokenUri = await generateTokenUri(params.name, { 225 | metadata: params.metadata, 226 | pinataConfig: params.pinataConfig, 227 | }); 228 | 229 | return this.flaunch({ 230 | ...params, 231 | tokenUri, 232 | }); 233 | } 234 | 235 | /** 236 | * Flaunches a new token for a revenue manager 237 | * @param params - Parameters for the flaunch with revenue manager 238 | * @param params.name - The name of the token 239 | * @param params.symbol - The symbol of the token 240 | * @param params.tokenUri - The URI containing the token metadata 241 | * @param params.fairLaunchPercent - Percentage of total supply to be used in fair launch (0-100) 242 | * @param params.fairLaunchDuration - Duration of fair launch in seconds 243 | * @param params.initialMarketCapUSD - Initial market cap in USD 244 | * @param params.creator - Address of the token creator 245 | * @param params.creatorFeeAllocationPercent - Percentage of fees allocated to creator (0-100) 246 | * @param params.protocolRecipient - Address to receive protocol fees 247 | * @param params.protocolFeePercent - Percentage of fees allocated to protocol (0-100) 248 | * @param params.flaunchAt - Optional timestamp when the flaunch should start 249 | * @param params.premineAmount - Optional amount of tokens to premine 250 | * @returns Transaction response for the flaunch creation 251 | */ 252 | async flaunchWithRevenueManager(params: FlaunchWithRevenueManagerParams) { 253 | const initialMCapInUSDCWei = parseUnits( 254 | params.initialMarketCapUSD.toString(), 255 | 6 256 | ); 257 | const initialPriceParams = encodeAbiParameters( 258 | [ 259 | { 260 | type: "uint256", 261 | }, 262 | ], 263 | [initialMCapInUSDCWei] 264 | ); 265 | 266 | const fairLaunchInBps = BigInt(params.fairLaunchPercent * 100); 267 | const creatorFeeAllocationInBps = params.creatorFeeAllocationPercent * 100; 268 | 269 | const ethRequired = await this.ethRequiredToFlaunch({ 270 | premineAmount: params.premineAmount ?? 0n, 271 | initialPriceParams, 272 | slippagePercent: 5, 273 | }); 274 | 275 | return this.contract.write( 276 | "flaunch", 277 | { 278 | _flaunchParams: { 279 | name: params.name, 280 | symbol: params.symbol, 281 | tokenUri: params.tokenUri, 282 | initialTokenFairLaunch: 283 | (this.TOTAL_SUPPLY * fairLaunchInBps) / 10_000n, 284 | fairLaunchDuration: BigInt(params.fairLaunchDuration), 285 | premineAmount: params.premineAmount ?? 0n, 286 | creator: params.creator, 287 | creatorFeeAllocation: creatorFeeAllocationInBps, 288 | flaunchAt: params.flaunchAt ?? 0n, 289 | initialPriceParams, 290 | feeCalculatorParams: "0x", 291 | }, 292 | _treasuryManagerParams: { 293 | manager: params.revenueManagerInstanceAddress, 294 | initializeData: "0x", 295 | depositData: "0x", 296 | }, 297 | _whitelistParams: { 298 | merkleRoot: zeroHash, 299 | merkleIPFSHash: "", 300 | maxTokens: 0n, 301 | }, 302 | _airdropParams: { 303 | airdropIndex: 0n, 304 | airdropAmount: 0n, 305 | airdropEndTime: 0n, 306 | merkleRoot: zeroHash, 307 | merkleIPFSHash: "", 308 | }, 309 | }, 310 | { 311 | value: ethRequired, 312 | } 313 | ); 314 | } 315 | 316 | /** 317 | * Flaunches a new token for a revenue manager, storing the token metadata on IPFS 318 | * @param params - Parameters for the flaunch including all revenue manager params and IPFS metadata 319 | * @returns Promise resolving to the transaction response for the flaunch creation 320 | */ 321 | async flaunchIPFSWithRevenueManager( 322 | params: FlaunchWithRevenueManagerIPFSParams 323 | ) { 324 | const tokenUri = await generateTokenUri(params.name, { 325 | metadata: params.metadata, 326 | pinataConfig: params.pinataConfig, 327 | }); 328 | 329 | return this.flaunchWithRevenueManager({ 330 | ...params, 331 | tokenUri, 332 | }); 333 | } 334 | } 335 | -------------------------------------------------------------------------------- /src/clients/InitialPriceClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { InitialPriceAbi } from "../abi/InitialPrice"; 12 | import { zeroAddress } from "viem"; 13 | 14 | export type InitialPriceABI = typeof InitialPriceAbi; 15 | 16 | export class ReadInitialPrice { 17 | public readonly contract: ReadContract; 18 | 19 | constructor(address: Address, drift: Drift = createDrift()) { 20 | if (!address) { 21 | throw new Error("Address is required"); 22 | } 23 | 24 | this.contract = drift.contract({ 25 | abi: InitialPriceAbi, 26 | address, 27 | }); 28 | } 29 | 30 | /** 31 | * Returns a flaunching fee of 0.1% of the initial market cap IF the market cap is greater than 10k & the sender is not fee exempt 32 | * @param params - The parameters for the flaunching fee calculation 33 | * @param params.sender - The address of the sender 34 | * @param params.initialPriceParams - The initial price parameters 35 | * @returns The flaunching fee 36 | */ 37 | getFlaunchingFee(params: { sender: Address; initialPriceParams: HexString }) { 38 | return this.contract.read("getFlaunchingFee", { 39 | _sender: params.sender, 40 | _initialPriceParams: params.initialPriceParams, 41 | }); 42 | } 43 | 44 | getSqrtPriceX96(params: { 45 | isFLETHZero: boolean; 46 | initialPriceParams: HexString; 47 | }) { 48 | return this.contract.read("getSqrtPriceX96", { 49 | _flipped: !params.isFLETHZero, 50 | _initialPriceParams: params.initialPriceParams, 51 | 0: zeroAddress, // sender 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/clients/MemecoinClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { MemecoinAbi } from "../abi/Memecoin"; 12 | 13 | export type MemecoinABI = typeof MemecoinAbi; 14 | 15 | /** 16 | * Client for interacting with Memecoin (ERC20) contracts in read-only mode 17 | * Provides methods to query basic token information and balances 18 | */ 19 | export class ReadMemecoin { 20 | public readonly contract: ReadContract; 21 | 22 | /** 23 | * Creates a new ReadMemecoin instance 24 | * @param address - The address of the Memecoin contract 25 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 26 | * @throws Error if address is not provided 27 | */ 28 | constructor(address: Address, drift: Drift = createDrift()) { 29 | if (!address) { 30 | throw new Error("Address is required"); 31 | } 32 | 33 | this.contract = drift.contract({ 34 | abi: MemecoinAbi, 35 | address, 36 | }); 37 | } 38 | 39 | /** 40 | * Gets the name of the token 41 | * @returns Promise - The name of the token 42 | */ 43 | name() { 44 | return this.contract.read("name", {}); 45 | } 46 | 47 | /** 48 | * Gets the symbol of the token 49 | * @returns Promise - The symbol of the token 50 | */ 51 | symbol() { 52 | return this.contract.read("symbol"); 53 | } 54 | 55 | /** 56 | * Gets the token URI containing metadata 57 | * @returns Promise - The token URI 58 | */ 59 | tokenURI() { 60 | return this.contract.read("tokenURI"); 61 | } 62 | 63 | /** 64 | * Gets the total supply of the token 65 | * @returns Promise - The total supply 66 | */ 67 | totalSupply() { 68 | return this.contract.read("totalSupply"); 69 | } 70 | 71 | /** 72 | * Gets the token balance of a specific user 73 | * @param user - The address of the user to check 74 | * @returns Promise - The token balance 75 | */ 76 | balanceOf(user: Address) { 77 | return this.contract.read("balanceOf", { 78 | account: user, 79 | }); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/clients/MulticallClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { MulticallAbi } from "../abi/Multicall"; 12 | 13 | export type MulticallABI = typeof MulticallAbi; 14 | 15 | export class ReadMulticall { 16 | // same address across all chains 17 | public readonly address: Address = 18 | "0xcA11bde05977b3631167028862bE2a173976CA11"; 19 | 20 | public readonly contract: ReadContract; 21 | 22 | constructor(drift: Drift) { 23 | this.contract = drift.contract({ 24 | abi: MulticallAbi, 25 | address: this.address, 26 | }); 27 | } 28 | 29 | aggregate3(calls: { target: Address; callData: HexString }[]) { 30 | return this.contract.simulateWrite("aggregate3", { 31 | calls: calls.map((call) => ({ 32 | target: call.target, 33 | allowFailure: true, 34 | callData: call.callData, 35 | })), 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/clients/Permit2Client.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { Permit2Abi } from "../abi/Permit2"; 12 | 13 | export type Permit2ABI = typeof Permit2Abi; 14 | 15 | /** 16 | * Client for interacting with Uniswap's Permit2 contract in read-only mode 17 | * Provides methods to query token approvals and allowances 18 | */ 19 | export class ReadPermit2 { 20 | public readonly contract: ReadContract; 21 | 22 | /** 23 | * Creates a new ReadPermit2 instance 24 | * @param address - The address of the Permit2 contract 25 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 26 | * @throws Error if address is not provided 27 | */ 28 | constructor(address: Address, drift: Drift = createDrift()) { 29 | if (!address) { 30 | throw new Error("Address is required"); 31 | } 32 | 33 | this.contract = drift.contract({ 34 | abi: Permit2Abi, 35 | address, 36 | }); 37 | } 38 | 39 | /** 40 | * Gets the allowance and nonce for a token approval 41 | * @param owner - The address of the token owner 42 | * @param coinAddress - The address of the token contract 43 | * @param spender - The address of the spender 44 | * @returns Promise<{amount: bigint, expiration: bigint, nonce: bigint}> - The allowance details 45 | */ 46 | async allowance(owner: Address, coinAddress: Address, spender: Address) { 47 | return this.contract.read("allowance", { 48 | 0: owner, 49 | 1: coinAddress, 50 | 2: spender, 51 | }); 52 | } 53 | } 54 | 55 | export class ReadWritePermit2 extends ReadPermit2 { 56 | declare contract: ReadWriteContract; 57 | 58 | constructor( 59 | address: Address, 60 | drift: Drift = createDrift() 61 | ) { 62 | super(address, drift); 63 | } 64 | 65 | /** 66 | * Approves a spender to spend a token via transaction 67 | * @param params - The parameters for the approval 68 | * @returns The transaction response 69 | */ 70 | approve(params: { 71 | token: Address; 72 | spender: Address; 73 | amount: bigint; 74 | expiration: number; 75 | }) { 76 | return this.contract.write("approve", params); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/clients/PoolManagerClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type Contract, 3 | type ReadContract, 4 | type Address, 5 | type Drift, 6 | type EventLog, 7 | type ReadWriteContract, 8 | type ReadWriteAdapter, 9 | type HexString, 10 | createDrift, 11 | } from "@delvtech/drift"; 12 | import { keccak256, encodePacked, stringToHex, pad, hexToBigInt } from "viem"; 13 | import { bytes32ToUint256, uint256ToBytes32 } from "../helpers/hex"; 14 | import { PoolManagerAbi } from "../abi/PoolManager"; 15 | 16 | export type PoolManagerABI = typeof PoolManagerAbi; 17 | 18 | export interface PositionInfoParams { 19 | poolId: HexString; 20 | owner: Address; 21 | tickLower: number; 22 | tickUpper: number; 23 | salt: string; 24 | } 25 | 26 | export class ReadPoolManager { 27 | public readonly contract: ReadContract; 28 | 29 | constructor(address: Address, drift: Drift = createDrift()) { 30 | if (!address) { 31 | throw new Error("Address is required"); 32 | } 33 | 34 | this.contract = drift.contract({ 35 | abi: PoolManagerAbi, 36 | address, 37 | }); 38 | } 39 | 40 | poolStateSlot({ poolId }: { poolId: HexString }) { 41 | const POOLS_SLOT = uint256ToBytes32(6n); 42 | 43 | return keccak256( 44 | encodePacked(["bytes32", "bytes32"], [poolId, POOLS_SLOT]) 45 | ); 46 | } 47 | 48 | async poolSlot0({ poolId }: { poolId: HexString }) { 49 | const stateSlot = this.poolStateSlot({ poolId }); 50 | 51 | let res = { sqrtPriceX96: 0n, tick: 0, protocolFee: 0, lpFee: 0 }; 52 | 53 | try { 54 | const result = await this.contract.read("extsload", { 55 | slot: stateSlot, 56 | }); 57 | 58 | const data = (Array.isArray(result) ? result[0] : result) as HexString; 59 | 60 | // Convert the input hex to a BigInt for bitwise operations 61 | const dataAsBigInt = BigInt(data); 62 | 63 | // Extract sqrtPriceX96 (bottom 160 bits) 64 | const sqrtPriceX96Mask = BigInt( 65 | "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" 66 | ); 67 | const sqrtPriceX96 = dataAsBigInt & sqrtPriceX96Mask; 68 | 69 | // Extract tick (next 24 bits after sqrtPriceX96) 70 | // First, shift right by 160 bits to get the tick bits at the bottom 71 | const tickShifted = dataAsBigInt >> 160n; 72 | // Then mask to get only the 24 bits we want 73 | const tickMask = BigInt("0xFFFFFF"); 74 | const tickRaw = Number(tickShifted & tickMask); 75 | // Sign extend the 24-bit number if needed 76 | const tick = tickRaw > 0x7fffff ? tickRaw - 0x1000000 : tickRaw; 77 | 78 | // Extract protocolFee (next 24 bits) 79 | const protocolFeeShifted = dataAsBigInt >> 184n; 80 | const protocolFeeMask = BigInt("0xFFFFFF"); 81 | const protocolFee = Number(protocolFeeShifted & protocolFeeMask); 82 | 83 | // Extract lpFee (last 24 bits) 84 | const lpFeeShifted = dataAsBigInt >> 208n; 85 | const lpFeeMask = BigInt("0xFFFFFF"); 86 | const lpFee = Number(lpFeeShifted & lpFeeMask); 87 | 88 | res = { sqrtPriceX96, tick, protocolFee, lpFee }; 89 | } catch (error) { 90 | console.error(error); 91 | } 92 | 93 | return res; 94 | } 95 | 96 | async positionInfo({ 97 | poolId, 98 | owner, 99 | tickLower, 100 | tickUpper, 101 | salt, 102 | }: PositionInfoParams): Promise<{ 103 | liquidity: bigint; 104 | feeGrowthInside0LastX128: bigint; 105 | feeGrowthInside1LastX128: bigint; 106 | }> { 107 | const saltBytes32 = pad(stringToHex(salt), { size: 32, dir: "right" }); 108 | 109 | const positionKey = keccak256( 110 | encodePacked( 111 | ["address", "int24", "int24", "bytes32"], 112 | [owner, tickLower, tickUpper, saltBytes32] 113 | ) 114 | ); 115 | 116 | const stateSlot = this.poolStateSlot({ poolId }); 117 | 118 | const POSITIONS_OFFSET = 6n; 119 | const positionMapping = uint256ToBytes32( 120 | bytes32ToUint256(stateSlot) + POSITIONS_OFFSET 121 | ); 122 | 123 | const positionInfoSlot = keccak256( 124 | encodePacked(["bytes32", "bytes32"], [positionKey, positionMapping]) 125 | ); 126 | 127 | const data = (await this.contract.read("extsload", { 128 | startSlot: positionInfoSlot, 129 | nSlots: 3n, 130 | })) as HexString[]; 131 | 132 | // FIXME: data returned is not an array 133 | console.log({ data }); 134 | 135 | const liquidity = hexToBigInt(data[0]); 136 | const feeGrowthInside0LastX128 = hexToBigInt(data[1]); 137 | const feeGrowthInside1LastX128 = hexToBigInt(data[2]); 138 | 139 | return { 140 | liquidity, 141 | feeGrowthInside0LastX128, 142 | feeGrowthInside1LastX128, 143 | }; 144 | } 145 | 146 | async getStateSlot(stateSlot: HexString): Promise { 147 | const result = await this.contract.read("extsload", { 148 | slot: stateSlot, 149 | }); 150 | // Cast through unknown first to avoid type checking issues 151 | const firstResult = Array.isArray(result) ? result[0] : result; 152 | return firstResult as unknown as HexString; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/clients/QuoterClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { QuoterAbi } from "../abi/Quoter"; 12 | import { formatUnits, parseEther, zeroAddress } from "viem"; 13 | import { 14 | FlaunchPositionManagerAddress, 15 | FlaunchPositionManagerV1_1Address, 16 | FLETHAddress, 17 | FLETHHooksAddress, 18 | USDCETHPoolKeys, 19 | } from "addresses"; 20 | 21 | export type QuoterABI = typeof QuoterAbi; 22 | 23 | /** 24 | * Client for interacting with the Quoter contract to get price quotes for swaps 25 | * Provides methods to simulate trades and get expected output amounts 26 | */ 27 | export class ReadQuoter { 28 | chainId: number; 29 | public readonly contract: ReadContract; 30 | 31 | /** 32 | * Creates a new ReadQuoter instance 33 | * @param chainId - The chain ID where the Quoter contract is deployed 34 | * @param address - The address of the Quoter contract 35 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 36 | * @throws Error if address is not provided 37 | */ 38 | constructor(chainId: number, address: Address, drift: Drift = createDrift()) { 39 | this.chainId = chainId; 40 | if (!address) { 41 | throw new Error("Address is required"); 42 | } 43 | 44 | this.contract = drift.contract({ 45 | abi: QuoterAbi, 46 | address, 47 | }); 48 | } 49 | 50 | /** 51 | * Gets a quote for selling an exact amount of tokens for ETH 52 | * @param coinAddress - The address of the token to sell 53 | * @param amountIn - The exact amount of tokens to sell 54 | * @param positionManagerAddress - The address of the position manager to use 55 | * @returns Promise - The expected amount of ETH to receive 56 | */ 57 | async getSellQuoteExactInput( 58 | coinAddress: Address, 59 | amountIn: bigint, 60 | positionManagerAddress: Address 61 | ) { 62 | const res = await this.contract.simulateWrite("quoteExactInput", { 63 | params: { 64 | exactAmount: amountIn, 65 | exactCurrency: coinAddress, 66 | path: [ 67 | { 68 | fee: 0, 69 | tickSpacing: 60, 70 | hooks: positionManagerAddress, 71 | hookData: "0x", 72 | intermediateCurrency: FLETHAddress[this.chainId], 73 | }, 74 | { 75 | fee: 0, 76 | tickSpacing: 60, 77 | hookData: "0x", 78 | hooks: FLETHHooksAddress[this.chainId], 79 | intermediateCurrency: zeroAddress, 80 | }, 81 | ], 82 | }, 83 | }); 84 | 85 | return res.amountOut; 86 | } 87 | 88 | /** 89 | * Gets a quote for buying tokens with an exact amount of ETH 90 | * @param coinAddress - The address of the token to buy 91 | * @param ethIn - The exact amount of ETH to spend 92 | * @param positionManagerAddress - The address of the position manager to use 93 | * @returns Promise - The expected amount of tokens to receive 94 | */ 95 | async getBuyQuoteExactInput( 96 | coinAddress: Address, 97 | ethIn: bigint, 98 | positionManagerAddress: Address 99 | ) { 100 | const res = await this.contract.simulateWrite("quoteExactInput", { 101 | params: { 102 | exactAmount: ethIn, 103 | exactCurrency: zeroAddress, 104 | path: [ 105 | { 106 | fee: 0, 107 | tickSpacing: 60, 108 | hookData: "0x", 109 | hooks: FLETHHooksAddress[this.chainId], 110 | intermediateCurrency: FLETHAddress[this.chainId], 111 | }, 112 | { 113 | fee: 0, 114 | tickSpacing: 60, 115 | hooks: positionManagerAddress, 116 | hookData: "0x", 117 | intermediateCurrency: coinAddress, 118 | }, 119 | ], 120 | }, 121 | }); 122 | 123 | return res.amountOut; 124 | } 125 | 126 | /** 127 | * Gets a quote for buying an exact amount of tokens with ETH 128 | * @param coinAddress - The address of the token to buy 129 | * @param coinOut - The exact amount of tokens to receive 130 | * @param positionManagerAddress - The address of the position manager to use 131 | * @returns Promise - The required amount of ETH to spend 132 | */ 133 | async getBuyQuoteExactOutput( 134 | coinAddress: Address, 135 | coinOut: bigint, 136 | positionManagerAddress: Address 137 | ) { 138 | const res = await this.contract.simulateWrite("quoteExactOutput", { 139 | params: { 140 | path: [ 141 | { 142 | intermediateCurrency: zeroAddress, 143 | fee: 0, 144 | tickSpacing: 60, 145 | hookData: "0x", 146 | hooks: FLETHHooksAddress[this.chainId], 147 | }, 148 | { 149 | intermediateCurrency: FLETHAddress[this.chainId], 150 | fee: 0, 151 | tickSpacing: 60, 152 | hooks: positionManagerAddress, 153 | hookData: "0x", 154 | }, 155 | ], 156 | exactCurrency: coinAddress, 157 | exactAmount: coinOut, 158 | }, 159 | }); 160 | 161 | return res.amountIn; 162 | } 163 | 164 | /** 165 | * Gets the current ETH/USDC price from the pool 166 | * @returns Promise - The price of 1 ETH in USDC, formatted with 2 decimal places 167 | */ 168 | async getETHUSDCPrice() { 169 | const amountIn = parseEther("1"); 170 | 171 | const res = await this.contract.simulateWrite("quoteExactInput", { 172 | params: { 173 | exactAmount: amountIn, 174 | exactCurrency: zeroAddress, 175 | path: [ 176 | { 177 | fee: USDCETHPoolKeys[this.chainId].fee, 178 | tickSpacing: USDCETHPoolKeys[this.chainId].tickSpacing, 179 | hooks: USDCETHPoolKeys[this.chainId].hooks, 180 | hookData: "0x", 181 | intermediateCurrency: USDCETHPoolKeys[this.chainId].currency1, 182 | }, 183 | ], 184 | }, 185 | }); 186 | 187 | return Number(Number(formatUnits(res.amountOut, 6)).toFixed(2)); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/clients/ReferralEscrowClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type ReadWriteContract, 6 | type ReadWriteAdapter, 7 | createDrift, 8 | } from "@delvtech/drift"; 9 | import { ReferralEscrowAbi } from "../abi/ReferralEscrow"; 10 | 11 | export type ReferralEscrowABI = typeof ReferralEscrowAbi; 12 | 13 | /** 14 | * Client for interacting with the ReferralEscrow contract in read-only mode 15 | * Provides methods to query token allocations 16 | */ 17 | export class ReadReferralEscrow { 18 | public readonly contract: ReadContract; 19 | 20 | /** 21 | * Creates a new ReadReferralEscrow instance 22 | * @param address - The address of the ReferralEscrow contract 23 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 24 | * @throws Error if address is not provided 25 | */ 26 | constructor(address: Address, drift: Drift = createDrift()) { 27 | if (!address) { 28 | throw new Error("Address is required"); 29 | } 30 | 31 | this.contract = drift.contract({ 32 | abi: ReferralEscrowAbi, 33 | address, 34 | }); 35 | } 36 | 37 | /** 38 | * Gets the token allocation for a specific user and token 39 | * @param user - The address of the user to check 40 | * @param token - The address of the token 41 | * @returns Promise - The allocated token amount 42 | */ 43 | allocations(user: Address, token: Address) { 44 | return this.contract.read("allocations", { 45 | _user: user, 46 | _token: token, 47 | }); 48 | } 49 | } 50 | 51 | /** 52 | * Extended client for interacting with the ReferralEscrow contract with write capabilities 53 | * Provides methods to claim tokens 54 | */ 55 | export class ReadWriteReferralEscrow extends ReadReferralEscrow { 56 | declare contract: ReadWriteContract; 57 | 58 | constructor( 59 | address: Address, 60 | drift: Drift = createDrift() 61 | ) { 62 | super(address, drift); 63 | } 64 | 65 | /** 66 | * Claims tokens for a recipient 67 | * @param tokens - Array of token addresses to claim 68 | * @param recipient - The address to receive the claimed tokens 69 | * @returns Promise 70 | */ 71 | claimTokens(tokens: Address[], recipient: Address) { 72 | return this.contract.write("claimTokens", { 73 | _tokens: tokens, 74 | _recipient: recipient, 75 | }); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/clients/RevenueManagerClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { RevenueManagerAbi } from "../abi/RevenueManager"; 12 | import { ReadMulticall } from "./MulticallClient"; 13 | 14 | export type RevenueManagerABI = typeof RevenueManagerAbi; 15 | 16 | export class ReadRevenueManager { 17 | drift: Drift; 18 | public readonly contract: ReadContract; 19 | 20 | constructor(address: Address, drift: Drift = createDrift()) { 21 | this.drift = drift; 22 | this.contract = drift.contract({ 23 | abi: RevenueManagerAbi, 24 | address, 25 | }); 26 | } 27 | 28 | /** 29 | * Gets the claimable balance of ETH for the recipient 30 | * @param recipient - The address of the recipient to check 31 | * @returns Promise - The claimable balance of ETH 32 | */ 33 | balances(address: Address) { 34 | return this.contract.read("balances", { 35 | _recipient: address, 36 | }); 37 | } 38 | 39 | /** 40 | * Gets the protocol recipient address 41 | * @returns Promise
- The protocol recipient address 42 | */ 43 | protocolRecipient() { 44 | return this.contract.read("protocolRecipient"); 45 | } 46 | 47 | /** 48 | * Gets the total number of tokens managed by the revenue manager 49 | * @returns Promise - The total count of tokens 50 | */ 51 | async tokensCount() { 52 | const nextInternalId = await this.contract.read("nextInternalId"); 53 | return nextInternalId - 1n; 54 | } 55 | 56 | /** 57 | * Gets all tokens created by a specific creator address 58 | * @param creator - The address of the creator to query tokens for 59 | * @param sortByDesc - Optional boolean to sort tokens in descending order (default: false) 60 | * @returns Promise> - Array of token objects containing flaunch address and token ID 61 | */ 62 | async allTokensByCreator(creator: Address, sortByDesc: boolean = false) { 63 | const tokens = await this.contract.read("tokens", { 64 | _creator: creator, 65 | }); 66 | 67 | if (sortByDesc) { 68 | return [...tokens].reverse(); 69 | } 70 | 71 | return tokens; 72 | } 73 | 74 | /** 75 | * Gets all tokens currently managed by the revenue manager contract 76 | * @dev Uses multicall to batch requests for better performance 77 | * @param sortByDesc - Optional boolean to sort tokens in descending order (default: false) 78 | * @returns Promise> - Array of token objects containing flaunch address and token ID 79 | */ 80 | async allTokensInManager(sortByDesc: boolean = false) { 81 | const count = await this.tokensCount(); 82 | const multicall = new ReadMulticall(this.drift); 83 | 84 | let calldatas = Array.from({ length: Number(count) }, (_, i) => 85 | this.contract.encodeFunctionData("internalIds", { 86 | _internalId: BigInt(i + 1), 87 | }) 88 | ); 89 | 90 | // Reverse the array if sortByDesc is true 91 | if (sortByDesc) { 92 | calldatas = calldatas.reverse(); 93 | } 94 | 95 | const result = await multicall.aggregate3( 96 | calldatas.map((calldata) => ({ 97 | target: this.contract.address, 98 | callData: calldata, 99 | })) 100 | ); 101 | 102 | return result.map((r) => 103 | this.contract.decodeFunctionReturn("internalIds", r.returnData) 104 | ); 105 | } 106 | } 107 | 108 | export class ReadWriteRevenueManager extends ReadRevenueManager { 109 | declare contract: ReadWriteContract; 110 | 111 | constructor( 112 | address: Address, 113 | drift: Drift = createDrift() 114 | ) { 115 | super(address, drift); 116 | } 117 | 118 | /** 119 | * Allows the protocol recipient to claim the protocol's share of the revenue 120 | * @returns Promise - The transaction response 121 | */ 122 | protocolClaim() { 123 | return this.contract.write("claim", {}); 124 | } 125 | 126 | /** 127 | * Allows the creator to claim their total share of the revenue from a revenue manager 128 | * @returns Promise - The transaction response 129 | */ 130 | creatorClaim() { 131 | return this.contract.write("claim", {}); 132 | } 133 | 134 | /** 135 | * Allows the creator to claim their share of the revenue from specific flaunch tokens 136 | * @param flaunchTokens - The flaunch token ids to claim the revenue for 137 | * @returns Promise - The transaction response 138 | */ 139 | creatorClaimForTokens( 140 | flaunchTokens: { flaunch: Address; tokenId: bigint }[] 141 | ) { 142 | return this.contract.write("claim", { 143 | _flaunchToken: flaunchTokens, 144 | }); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/clients/StateViewClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { StateViewAbi } from "../abi/StateView"; 12 | import { PositionInfoParams } from "./PoolManagerClient"; 13 | import { stringToHex } from "viem"; 14 | import { pad } from "viem"; 15 | 16 | export type StateViewABI = typeof StateViewAbi; 17 | 18 | /** 19 | * Client for reading state information from Uniswap V4 pools 20 | * Provides methods to query pool states, positions, and tick liquidity 21 | */ 22 | export class ReadStateView { 23 | public readonly contract: ReadContract; 24 | 25 | /** 26 | * Creates a new ReadStateView instance 27 | * @param address - The address of the StateView contract 28 | * @param drift - Optional drift instance for contract interactions (creates new instance if not provided) 29 | * @throws Error if address is not provided 30 | */ 31 | constructor(address: Address, drift: Drift = createDrift()) { 32 | if (!address) { 33 | throw new Error("Address is required"); 34 | } 35 | 36 | this.contract = drift.contract({ 37 | abi: StateViewAbi, 38 | address, 39 | }); 40 | } 41 | 42 | /** 43 | * Gets the Slot0 data for a pool 44 | * @param poolId - The ID of the pool to query 45 | * @returns Promise<{tick: number, sqrtPriceX96: bigint, protocolFees: bigint}> - Current pool state 46 | */ 47 | poolSlot0({ poolId }: { poolId: HexString }) { 48 | return this.contract.read("getSlot0", { 49 | poolId, 50 | }); 51 | } 52 | 53 | /** 54 | * Gets information about a liquidity position 55 | * @param poolId - The ID of the pool 56 | * @param owner - The address of the position owner 57 | * @param tickLower - The lower tick of the position 58 | * @param tickUpper - The upper tick of the position 59 | * @param salt - The salt used to identify the position 60 | * @returns Promise<{liquidity: bigint, feeGrowthInside0LastX128: bigint, feeGrowthInside1LastX128: bigint, tokensOwed0: bigint, tokensOwed1: bigint}> - Position details 61 | */ 62 | positionInfo({ 63 | poolId, 64 | owner, 65 | tickLower, 66 | tickUpper, 67 | salt, 68 | }: PositionInfoParams) { 69 | const saltBytes32 = pad(stringToHex(salt), { size: 32, dir: "right" }); 70 | 71 | return this.contract.read("getPositionInfo", { 72 | poolId, 73 | owner, 74 | tickLower, 75 | tickUpper, 76 | salt: saltBytes32, 77 | }); 78 | } 79 | 80 | /** 81 | * Gets the liquidity at a specific tick 82 | * @param poolId - The ID of the pool 83 | * @param tick - The tick to query 84 | * @returns Promise<{liquidityGross: bigint, liquidityNet: bigint, feeGrowthOutside0X128: bigint, feeGrowthOutside1X128: bigint}> - Tick liquidity information 85 | */ 86 | getTickLiquidity({ poolId, tick }: { poolId: HexString; tick: number }) { 87 | return this.contract.read("getTickLiquidity", { 88 | poolId, 89 | tick, 90 | }); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/clients/TreasuryManagerFactoryClient.ts: -------------------------------------------------------------------------------- 1 | import { 2 | type ReadContract, 3 | type Address, 4 | type Drift, 5 | type EventLog, 6 | type ReadWriteContract, 7 | type ReadWriteAdapter, 8 | type HexString, 9 | createDrift, 10 | } from "@delvtech/drift"; 11 | import { TreasuryManagerFactoryAbi } from "../abi/TreasuryManagerFactory"; 12 | import { RevenueManagerAddress } from "addresses"; 13 | import { encodeAbiParameters } from "viem"; 14 | 15 | export type TreasuryManagerFactoryABI = typeof TreasuryManagerFactoryAbi; 16 | 17 | export class ReadTreasuryManagerFactory { 18 | public readonly contract: ReadContract; 19 | 20 | constructor(address: Address, drift: Drift = createDrift()) { 21 | if (!address) { 22 | throw new Error("Address is required"); 23 | } 24 | this.contract = drift.contract({ 25 | abi: TreasuryManagerFactoryAbi, 26 | address, 27 | }); 28 | } 29 | } 30 | 31 | export class ReadWriteTreasuryManagerFactory extends ReadTreasuryManagerFactory { 32 | chainId: number; 33 | declare contract: ReadWriteContract; 34 | 35 | constructor(chainId: number, address: Address, drift: Drift = createDrift()) { 36 | super(address, drift); 37 | this.chainId = chainId; 38 | } 39 | 40 | /** 41 | * Deploys a new revenue manager 42 | * @param params - Parameters for deploying the revenue manager 43 | * @param params.protocolRecipient - The address of the protocol recipient 44 | * @param params.protocolFeePercent - The percentage of the protocol fee 45 | * @returns Transaction response 46 | */ 47 | deployRevenueManager(params: { 48 | protocolRecipient: Address; 49 | protocolFeePercent: number; 50 | }) { 51 | return this.contract.write("deployAndInitializeManager", { 52 | _managerImplementation: RevenueManagerAddress[this.chainId], 53 | _owner: params.protocolRecipient, 54 | _data: encodeAbiParameters( 55 | [ 56 | { 57 | type: "tuple", 58 | components: [ 59 | { type: "address", name: "protocolRecipient" }, 60 | { type: "uint256", name: "protocolFee" }, 61 | ], 62 | }, 63 | ], 64 | [ 65 | { 66 | protocolRecipient: params.protocolRecipient, 67 | protocolFee: BigInt(params.protocolFeePercent * 100), // Convert percentage to basis points 68 | }, 69 | ] 70 | ), 71 | }); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/helpers/chainIdToChain.ts: -------------------------------------------------------------------------------- 1 | import { Chain } from "viem"; 2 | import { base, baseSepolia } from "viem/chains"; 3 | 4 | export const chainIdToChain: { 5 | [key: number]: Chain; 6 | } = { 7 | [base.id]: base, 8 | [baseSepolia.id]: baseSepolia, 9 | }; 10 | -------------------------------------------------------------------------------- /src/helpers/hex.ts: -------------------------------------------------------------------------------- 1 | import { encodeAbiParameters, Hex, hexToBigInt, pad } from "viem"; 2 | 3 | export const bytes32ToUint256 = (value: Hex) => { 4 | return hexToBigInt(value); 5 | }; 6 | 7 | export const uint256ToBytes32 = (value: bigint) => { 8 | return pad( 9 | encodeAbiParameters([{ type: "uint256", name: "value" }], [value]), 10 | { size: 32, dir: "right" } 11 | ); 12 | }; 13 | -------------------------------------------------------------------------------- /src/helpers/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./hex"; 2 | export * from "./ipfs"; 3 | export * from "./chainIdToChain"; 4 | -------------------------------------------------------------------------------- /src/helpers/ipfs.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | import { CoinMetadata, IPFSParams } from "../types"; 3 | 4 | // List of public IPFS gateways to cycle through 5 | const IPFS_GATEWAYS = [ 6 | "https://gateway.pinata.cloud/ipfs/", 7 | "https://ipfs.io/ipfs/", 8 | "https://dweb.link/ipfs/", 9 | ]; 10 | 11 | // Counter to track the current gateway index 12 | let currentGatewayIndex = 0; 13 | 14 | export const resolveIPFS = (value: string): string => { 15 | if (value.startsWith("ipfs://")) { 16 | const cid = value.slice(7); 17 | // Get the next gateway and increment the counter 18 | const gateway = IPFS_GATEWAYS[currentGatewayIndex]; 19 | // Update the counter, cycling back to 0 when we reach the end 20 | currentGatewayIndex = (currentGatewayIndex + 1) % IPFS_GATEWAYS.length; 21 | return `${gateway}${cid}`; 22 | } 23 | return value; 24 | }; 25 | 26 | export interface PinataConfig { 27 | jwt: string; 28 | } 29 | 30 | interface UploadResponse { 31 | IpfsHash: string; 32 | PinSize: number; 33 | Timestamp: string; 34 | isDuplicate: boolean; 35 | } 36 | 37 | /** 38 | * Uploads a file to IPFS using Pinata 39 | * @param params Configuration and file data 40 | * @returns Upload response with CID and other details 41 | */ 42 | export const uploadFileToIPFS = async (params: { 43 | pinataConfig: PinataConfig; 44 | file: File; 45 | name?: string; 46 | metadata?: Record; 47 | }): Promise => { 48 | try { 49 | const formData = new FormData(); 50 | formData.append("file", params.file); 51 | 52 | const pinataMetadata = { 53 | name: params.name || null, 54 | keyvalues: params.metadata || {}, 55 | }; 56 | formData.append("pinataMetadata", JSON.stringify(pinataMetadata)); 57 | 58 | const pinataOptions = { 59 | cidVersion: 1, 60 | }; 61 | formData.append("pinataOptions", JSON.stringify(pinataOptions)); 62 | 63 | const response = await axios.post( 64 | "https://api.pinata.cloud/pinning/pinFileToIPFS", 65 | formData, 66 | { 67 | headers: { 68 | Authorization: `Bearer ${params.pinataConfig.jwt}`, 69 | "Content-Type": "multipart/form-data", 70 | }, 71 | } 72 | ); 73 | 74 | return { 75 | IpfsHash: response.data.IpfsHash, 76 | PinSize: response.data.PinSize, 77 | Timestamp: response.data.Timestamp, 78 | isDuplicate: response.data.isDuplicate || false, 79 | }; 80 | } catch (error) { 81 | if (axios.isAxiosError(error)) { 82 | throw new Error( 83 | `Failed to upload file to IPFS: ${ 84 | error.response?.data?.message || error.message 85 | }` 86 | ); 87 | } 88 | throw error; 89 | } 90 | }; 91 | 92 | /** 93 | * Uploads JSON data to IPFS using Pinata 94 | * @param params Configuration and JSON data 95 | * @returns Upload response with CID and other details 96 | */ 97 | export const uploadJsonToIPFS = async (params: { 98 | pinataConfig: PinataConfig; 99 | json: Record; 100 | name?: string; 101 | metadata?: Record; 102 | }): Promise => { 103 | try { 104 | const requestBody = { 105 | pinataOptions: { 106 | cidVersion: 1, 107 | }, 108 | pinataMetadata: { 109 | name: params.name || null, 110 | keyvalues: params.metadata || {}, 111 | }, 112 | pinataContent: params.json, 113 | }; 114 | 115 | const response = await axios.post( 116 | "https://api.pinata.cloud/pinning/pinJSONToIPFS", 117 | requestBody, 118 | { 119 | headers: { 120 | Authorization: `Bearer ${params.pinataConfig.jwt}`, 121 | "Content-Type": "application/json", 122 | }, 123 | } 124 | ); 125 | 126 | return { 127 | IpfsHash: response.data.IpfsHash, 128 | PinSize: response.data.PinSize, 129 | Timestamp: response.data.Timestamp, 130 | isDuplicate: response.data.isDuplicate || false, 131 | }; 132 | } catch (error) { 133 | if (axios.isAxiosError(error)) { 134 | throw new Error( 135 | `Failed to upload JSON to IPFS: ${ 136 | error.response?.data?.message || error.message 137 | }` 138 | ); 139 | } 140 | throw error; 141 | } 142 | }; 143 | 144 | /** 145 | * Uploads a base64 image to IPFS using Pinata 146 | * @param params Configuration and base64 image data 147 | * @returns Upload response with CID and other details 148 | */ 149 | export const uploadImageToIPFS = async (params: { 150 | pinataConfig: PinataConfig; 151 | base64Image: string; 152 | name?: string; 153 | metadata?: Record; 154 | }): Promise => { 155 | try { 156 | const formData = new FormData(); 157 | 158 | // Convert base64 to Blob and then to File 159 | // Remove data URL prefix if present (e.g., "data:image/jpeg;base64,") 160 | const base64Data = params.base64Image.split(",")[1] || params.base64Image; 161 | const byteCharacters = atob(base64Data); 162 | const byteArrays = []; 163 | 164 | for (let offset = 0; offset < byteCharacters.length; offset += 1024) { 165 | const slice = byteCharacters.slice(offset, offset + 1024); 166 | const byteNumbers = new Array(slice.length); 167 | for (let i = 0; i < slice.length; i++) { 168 | byteNumbers[i] = slice.charCodeAt(i); 169 | } 170 | const byteArray = new Uint8Array(byteNumbers); 171 | byteArrays.push(byteArray); 172 | } 173 | 174 | // Detect mime type from base64 string 175 | let mimeType = "image/png"; // default 176 | if (params.base64Image.startsWith("data:")) { 177 | mimeType = params.base64Image.split(";")[0].split(":")[1]; 178 | } 179 | 180 | const blob = new Blob(byteArrays, { type: mimeType }); 181 | const fileName = params.name || `image.${mimeType.split("/")[1]}`; 182 | const file = new File([blob], fileName, { type: mimeType }); 183 | 184 | formData.append("file", file); 185 | 186 | const pinataMetadata = { 187 | name: params.name || null, 188 | keyvalues: params.metadata || {}, 189 | }; 190 | formData.append("pinataMetadata", JSON.stringify(pinataMetadata)); 191 | 192 | const pinataOptions = { 193 | cidVersion: 1, 194 | }; 195 | formData.append("pinataOptions", JSON.stringify(pinataOptions)); 196 | 197 | const response = await axios.post( 198 | "https://api.pinata.cloud/pinning/pinFileToIPFS", 199 | formData, 200 | { 201 | headers: { 202 | Authorization: `Bearer ${params.pinataConfig.jwt}`, 203 | "Content-Type": "multipart/form-data", 204 | }, 205 | } 206 | ); 207 | 208 | return { 209 | IpfsHash: response.data.IpfsHash, 210 | PinSize: response.data.PinSize, 211 | Timestamp: response.data.Timestamp, 212 | isDuplicate: response.data.isDuplicate || false, 213 | }; 214 | } catch (error) { 215 | if (axios.isAxiosError(error)) { 216 | throw new Error( 217 | `Failed to upload image to IPFS: ${ 218 | error.response?.data?.message || error.message 219 | }` 220 | ); 221 | } 222 | throw error; 223 | } 224 | }; 225 | 226 | export const generateTokenUri = async (name: string, params: IPFSParams) => { 227 | // 1. upload image to IPFS 228 | const imageRes = await uploadImageToIPFS({ 229 | pinataConfig: params.pinataConfig, 230 | base64Image: params.metadata.base64Image, 231 | }); 232 | 233 | // 2. upload metadata to IPFS 234 | const coinMetadata: CoinMetadata = { 235 | name, 236 | description: params.metadata.description, 237 | image: `ipfs://${imageRes.IpfsHash}`, 238 | external_link: params.metadata.websiteUrl || "", 239 | collaborators: [], 240 | discordUrl: params.metadata.discordUrl || "", 241 | twitterUrl: params.metadata.twitterUrl || "", 242 | telegramUrl: params.metadata.telegramUrl || "", 243 | }; 244 | 245 | const metadataRes = await uploadJsonToIPFS({ 246 | pinataConfig: params.pinataConfig, 247 | json: coinMetadata, 248 | }); 249 | 250 | return `ipfs://${metadataRes.IpfsHash}`; 251 | }; 252 | -------------------------------------------------------------------------------- /src/hooks/FlaunchPositionManagerHooks.ts: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | import { 3 | BuySwapLog, 4 | PoolCreatedLogs, 5 | SellSwapLog, 6 | } from "../clients/FlaunchPositionManagerClient"; 7 | import { ReadFlaunchSDK } from "../sdk/FlaunchSDK"; 8 | import { Address } from "viem"; 9 | 10 | /** 11 | * Hook to watch and track pool creation events from the Flaunch V1.1 contract 12 | * @param flaunch - Instance of ReadFlaunchSDK to interact with the contract 13 | * @param startBlockNumber - Optional block number to start watching events from 14 | * @returns Object containing: 15 | * - logs: Array of pool creation events in reverse chronological order 16 | * - isFetchingFromStart: Boolean indicating if initial historical events are being fetched 17 | */ 18 | export function usePoolCreatedEvents( 19 | flaunch: ReadFlaunchSDK, 20 | startBlockNumber?: bigint 21 | ) { 22 | const [logs, setLogs] = useState([]); 23 | const [isFetchingFromStart, setIsFetchingFromStart] = useState(false); 24 | 25 | useEffect(() => { 26 | const setupWatcher = async () => { 27 | const cleanup = await flaunch.watchPoolCreated({ 28 | onPoolCreated: ({ logs: newLogs, isFetchingFromStart }) => { 29 | setIsFetchingFromStart(isFetchingFromStart); 30 | setLogs((prevLogs) => [...newLogs, ...prevLogs]); 31 | }, 32 | startBlockNumber, 33 | }); 34 | return cleanup; 35 | }; 36 | 37 | const cleanupPromise = setupWatcher(); 38 | 39 | return () => { 40 | cleanupPromise.then(({ cleanup }) => cleanup()); 41 | }; 42 | }, [flaunch.chainId, startBlockNumber]); 43 | 44 | // Add effect to update times 45 | useEffect(() => { 46 | const timer = setInterval(() => { 47 | // Force re-render to update relative times 48 | setLogs((prev) => [...prev]); 49 | }, 1000); 50 | 51 | return () => clearInterval(timer); 52 | }, []); 53 | 54 | return { logs, isFetchingFromStart }; 55 | } 56 | 57 | /** 58 | * Hook to watch and track swap events (buys/sells) for a specific coin from the Flaunch V1.1 contract 59 | * @param flaunch - Instance of ReadFlaunchSDK to interact with the contract 60 | * @param coinAddress - Address of the coin to watch swaps for 61 | * @param startBlockNumber - Optional block number to start watching events from 62 | * @returns Object containing: 63 | * - logs: Array of swap events (both buys and sells) in reverse chronological order 64 | * - isFetchingFromStart: Boolean indicating if initial historical events are being fetched 65 | */ 66 | export function usePoolSwapEvents( 67 | flaunch: ReadFlaunchSDK, 68 | coinAddress: Address, 69 | startBlockNumber?: bigint 70 | ) { 71 | const [logs, setLogs] = useState<(BuySwapLog | SellSwapLog)[]>([]); 72 | const [isFetchingFromStart, setIsFetchingFromStart] = useState(false); 73 | 74 | useEffect(() => { 75 | const setupWatcher = async () => { 76 | const cleanup = await flaunch.watchPoolSwap({ 77 | onPoolSwap: ({ logs: newLogs, isFetchingFromStart }) => { 78 | setIsFetchingFromStart(isFetchingFromStart); 79 | setLogs((prevLogs) => [...newLogs, ...prevLogs]); 80 | }, 81 | filterByCoin: coinAddress, 82 | startBlockNumber, 83 | }); 84 | return cleanup; 85 | }; 86 | 87 | const cleanupPromise = setupWatcher(); 88 | 89 | return () => { 90 | cleanupPromise.then(({ cleanup }) => cleanup()); 91 | }; 92 | }, [flaunch.chainId, coinAddress, startBlockNumber]); 93 | 94 | // Add effect to update times 95 | useEffect(() => { 96 | const timer = setInterval(() => { 97 | // Force re-render to update relative times 98 | setLogs((prev) => [...prev]); 99 | }, 1000); 100 | 101 | return () => clearInterval(timer); 102 | }, []); 103 | 104 | return { logs, isFetchingFromStart }; 105 | } 106 | 107 | /** 108 | * Hook to watch and track pool creation events from the Flaunch V1 contract 109 | * @param flaunch - Instance of ReadFlaunchSDK to interact with the contract 110 | * @param startBlockNumber - Optional block number to start watching events from 111 | * @returns Object containing: 112 | * - logs: Array of pool creation events in reverse chronological order 113 | * - isFetchingFromStart: Boolean indicating if initial historical events are being fetched 114 | */ 115 | export function usePoolCreatedEventsV1( 116 | flaunch: ReadFlaunchSDK, 117 | startBlockNumber?: bigint 118 | ) { 119 | const [logs, setLogs] = useState([]); 120 | const [isFetchingFromStart, setIsFetchingFromStart] = useState(false); 121 | 122 | useEffect(() => { 123 | const setupWatcher = async () => { 124 | const cleanup = await flaunch.watchPoolCreated({ 125 | onPoolCreated: ({ logs: newLogs, isFetchingFromStart }) => { 126 | setIsFetchingFromStart(isFetchingFromStart); 127 | setLogs((prevLogs) => [...newLogs, ...prevLogs]); 128 | }, 129 | startBlockNumber, 130 | }); 131 | return cleanup; 132 | }; 133 | 134 | const cleanupPromise = setupWatcher(); 135 | 136 | return () => { 137 | cleanupPromise.then(({ cleanup }) => cleanup()); 138 | }; 139 | }, [flaunch.chainId, startBlockNumber]); 140 | 141 | // Add effect to update times 142 | useEffect(() => { 143 | const timer = setInterval(() => { 144 | // Force re-render to update relative times 145 | setLogs((prev) => [...prev]); 146 | }, 1000); 147 | 148 | return () => clearInterval(timer); 149 | }, []); 150 | 151 | return { logs, isFetchingFromStart }; 152 | } 153 | 154 | /** 155 | * Hook to watch and track swap events (buys/sells) for a specific coin from the Flaunch V1 contract 156 | * @param flaunch - Instance of ReadFlaunchSDK to interact with the contract 157 | * @param coinAddress - Address of the coin to watch swaps for 158 | * @param startBlockNumber - Optional block number to start watching events from 159 | * @returns Object containing: 160 | * - logs: Array of swap events (both buys and sells) in reverse chronological order 161 | * - isFetchingFromStart: Boolean indicating if initial historical events are being fetched 162 | */ 163 | export function usePoolSwapEventsV1( 164 | flaunch: ReadFlaunchSDK, 165 | coinAddress: Address, 166 | startBlockNumber?: bigint 167 | ) { 168 | const [logs, setLogs] = useState<(BuySwapLog | SellSwapLog)[]>([]); 169 | const [isFetchingFromStart, setIsFetchingFromStart] = useState(false); 170 | 171 | useEffect(() => { 172 | const setupWatcher = async () => { 173 | const cleanup = await flaunch.watchPoolSwap({ 174 | onPoolSwap: ({ logs: newLogs, isFetchingFromStart }) => { 175 | setIsFetchingFromStart(isFetchingFromStart); 176 | setLogs((prevLogs) => [...newLogs, ...prevLogs]); 177 | }, 178 | filterByCoin: coinAddress, 179 | startBlockNumber, 180 | }); 181 | return cleanup; 182 | }; 183 | 184 | const cleanupPromise = setupWatcher(); 185 | 186 | return () => { 187 | cleanupPromise.then(({ cleanup }) => cleanup()); 188 | }; 189 | }, [flaunch.chainId, coinAddress, startBlockNumber]); 190 | 191 | // Add effect to update times 192 | useEffect(() => { 193 | const timer = setInterval(() => { 194 | // Force re-render to update relative times 195 | setLogs((prev) => [...prev]); 196 | }, 1000); 197 | 198 | return () => clearInterval(timer); 199 | }, []); 200 | 201 | return { logs, isFetchingFromStart }; 202 | } 203 | -------------------------------------------------------------------------------- /src/hooks/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./FlaunchPositionManagerHooks"; 2 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { ReadFlaunchSDK, ReadWriteFlaunchSDK } from "./sdk/FlaunchSDK"; 2 | 3 | export * from "./abi"; 4 | export * from "./addresses"; 5 | export * from "./helpers"; 6 | export * from "./utils/univ4"; 7 | export * from "./types"; 8 | 9 | export type { 10 | BuySwapLog, 11 | PoolCreatedLogs, 12 | SellSwapLog, 13 | } from "./clients/FlaunchPositionManagerClient"; 14 | 15 | export { ReadFlaunchSDK, ReadWriteFlaunchSDK }; 16 | export { createFlaunch } from "./sdk/factory"; 17 | export type { CreateFlaunchParams } from "./sdk/factory"; 18 | export { createDrift } from "./sdk/drift"; 19 | 20 | export const FlaunchSDK = { 21 | ReadFlaunchSDK, 22 | ReadWriteFlaunchSDK, 23 | }; 24 | -------------------------------------------------------------------------------- /src/sdk/drift.ts: -------------------------------------------------------------------------------- 1 | import { 2 | createDrift as createDriftOriginal, 3 | Drift, 4 | ReadWriteAdapter, 5 | } from "@delvtech/drift"; 6 | import { viemAdapter } from "@delvtech/drift-viem"; 7 | import type { PublicClient, WalletClient } from "viem"; 8 | 9 | export type CreateDriftParams = { 10 | publicClient: PublicClient; 11 | walletClient?: WalletClient; 12 | }; 13 | 14 | /** 15 | * Creates a read-only Drift instance with only public client 16 | * @param params - Parameters with only publicClient 17 | * @returns Drift instance for read-only operations 18 | * @throws Error if publicClient.chain is not configured 19 | */ 20 | export function createDrift( 21 | params: Omit 22 | ): Drift; 23 | /** 24 | * Creates a read-write Drift instance with both public and wallet clients 25 | * @param params - Parameters with both publicClient and walletClient 26 | * @returns Drift instance for read and write operations 27 | * @throws Error if publicClient.chain is not configured 28 | */ 29 | export function createDrift( 30 | params: Required 31 | ): Drift; 32 | 33 | /** 34 | * Creates a Drift instance with the provided clients 35 | * @param params - Parameters for creating the Drift instance 36 | * @returns Drift instance configured with the appropriate clients 37 | * @throws Error if publicClient.chain is not configured 38 | */ 39 | export function createDrift( 40 | params: CreateDriftParams 41 | ): Drift | Drift { 42 | const { publicClient, walletClient } = params; 43 | 44 | if (!publicClient.chain) { 45 | throw new Error("publicClient must be configured with a chain"); 46 | } 47 | 48 | return walletClient 49 | ? createDriftOriginal({ 50 | adapter: viemAdapter({ publicClient, walletClient }), 51 | }) 52 | : createDriftOriginal({ 53 | adapter: viemAdapter({ publicClient }), 54 | }); 55 | } 56 | -------------------------------------------------------------------------------- /src/sdk/factory.ts: -------------------------------------------------------------------------------- 1 | import { createDrift } from "./drift"; 2 | import { viemAdapter } from "@delvtech/drift-viem"; 3 | import type { PublicClient, WalletClient } from "viem"; 4 | import { ReadFlaunchSDK, ReadWriteFlaunchSDK } from "./FlaunchSDK"; 5 | 6 | export type CreateFlaunchParams = { 7 | publicClient: PublicClient; 8 | walletClient?: WalletClient; 9 | }; 10 | 11 | /** 12 | * Creates a read-only Flaunch SDK instance with only public client 13 | * @param params - Parameters with only publicClient 14 | * @returns ReadFlaunchSDK for read-only operations 15 | * @throws Error if publicClient.chain is not configured 16 | */ 17 | export function createFlaunch( 18 | params: Omit 19 | ): ReadFlaunchSDK; 20 | /** 21 | * Creates a read-write Flaunch SDK instance with both public and wallet clients 22 | * @param params - Parameters with both publicClient and walletClient 23 | * @returns ReadWriteFlaunchSDK for read and write operations 24 | * @throws Error if publicClient.chain is not configured 25 | */ 26 | export function createFlaunch( 27 | params: Required 28 | ): ReadWriteFlaunchSDK; 29 | 30 | /** 31 | * Creates a Flaunch SDK instance with the provided clients 32 | * @param params - Parameters for creating the SDK 33 | * @returns ReadFlaunchSDK if only publicClient is provided, ReadWriteFlaunchSDK if walletClient is also provided 34 | * @throws Error if publicClient.chain is not configured 35 | */ 36 | export function createFlaunch(params: CreateFlaunchParams) { 37 | const { publicClient, walletClient } = params; 38 | 39 | if (!publicClient.chain) { 40 | throw new Error("publicClient must be configured with a chain"); 41 | } 42 | 43 | const chainId = publicClient.chain.id; 44 | 45 | // Return appropriate SDK type based on whether walletClient is provided 46 | return walletClient 47 | ? new ReadWriteFlaunchSDK( 48 | chainId, 49 | createDrift({ publicClient, walletClient }) 50 | ) 51 | : new ReadFlaunchSDK(chainId, createDrift({ publicClient })); 52 | } 53 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import { Address } from "viem"; 2 | import { PinataConfig } from "helpers/ipfs"; 3 | 4 | export interface Addresses { 5 | [chainId: number]: Address; 6 | } 7 | 8 | export interface PoolKey { 9 | currency0: Address; 10 | currency1: Address; 11 | fee: number; 12 | tickSpacing: number; 13 | hooks: Address; 14 | } 15 | 16 | export interface CoinMetadata { 17 | name: string; 18 | description: string; 19 | image: string; 20 | external_link: string; 21 | collaborators: string[]; 22 | discordUrl: string; 23 | twitterUrl: string; 24 | telegramUrl: string; 25 | } 26 | 27 | export interface IPFSParams { 28 | metadata: { 29 | base64Image: string; 30 | description: string; 31 | websiteUrl?: string; 32 | discordUrl?: string; 33 | twitterUrl?: string; 34 | telegramUrl?: string; 35 | }; 36 | pinataConfig: PinataConfig; 37 | } 38 | 39 | /** 40 | * Enumeration of Flaunch contract versions 41 | */ 42 | export enum FlaunchVersion { 43 | V1 = "V1", 44 | V1_1 = "V1_1", 45 | V1_1_1 = "V1_1_1", 46 | ANY = "ANY", 47 | } 48 | -------------------------------------------------------------------------------- /src/utils/univ4.ts: -------------------------------------------------------------------------------- 1 | import { concat, keccak256, pad, toHex } from "viem"; 2 | import { TickMath } from "@uniswap/v3-sdk"; 3 | import { PoolKey } from "../types"; 4 | 5 | // our min/max tick range that is valid for the tick spacing (60) 6 | export const TickFinder = { 7 | MIN_TICK: -887220, 8 | MAX_TICK: 887220, 9 | }; 10 | 11 | export const TICK_SPACING = 60; 12 | 13 | export const getPoolId = (poolKey: PoolKey) => { 14 | // Pack the data in the same order as Solidity struct 15 | const packed = concat([ 16 | pad(poolKey.currency0, { size: 32 }), // address padded to 32 bytes 17 | pad(poolKey.currency1, { size: 32 }), // address padded to 32 bytes 18 | pad(toHex(poolKey.fee), { size: 32 }), // uint24 padded to 32 bytes 19 | pad(toHex(poolKey.tickSpacing), { size: 32 }), // int24 padded to 32 bytes 20 | pad(poolKey.hooks, { size: 32 }), // address padded to 32 bytes 21 | ]); 22 | 23 | return keccak256(packed); 24 | }; 25 | 26 | export const orderPoolKey = (poolKey: PoolKey) => { 27 | const [currency0, currency1] = 28 | poolKey.currency0 < poolKey.currency1 29 | ? [poolKey.currency0, poolKey.currency1] 30 | : [poolKey.currency1, poolKey.currency0]; 31 | 32 | return { 33 | ...poolKey, 34 | currency0, 35 | currency1, 36 | }; 37 | }; 38 | 39 | export const getValidTick = ({ 40 | tick, 41 | tickSpacing, 42 | roundDown, 43 | }: { 44 | tick: number; 45 | tickSpacing: number; 46 | roundDown: boolean; 47 | }) => { 48 | // If the tick is already valid, exit early 49 | if (tick % tickSpacing === 0) { 50 | return tick; 51 | } 52 | 53 | // Division that rounds towards zero (like Solidity) 54 | let validTick = Math.trunc(tick / tickSpacing) * tickSpacing; 55 | 56 | // Handle negative ticks (Solidity behavior) 57 | if (tick < 0 && tick % tickSpacing !== 0) { 58 | validTick -= tickSpacing; 59 | } 60 | 61 | // If not rounding down, add TICK_SPACING to get the upper tick 62 | if (!roundDown) { 63 | validTick += tickSpacing; 64 | } 65 | 66 | return validTick; 67 | }; 68 | 69 | const getAmount0ForLiquidity = ( 70 | sqrtRatioAX96: bigint, 71 | sqrtRatioBX96: bigint, 72 | liquidity: bigint 73 | ) => { 74 | let [sqrtRatioA, sqrtRatioB] = [sqrtRatioAX96, sqrtRatioBX96]; 75 | 76 | if (sqrtRatioA > sqrtRatioB) { 77 | [sqrtRatioA, sqrtRatioB] = [sqrtRatioB, sqrtRatioA]; 78 | } 79 | 80 | const leftShiftedLiquidity = liquidity << 96n; 81 | const sqrtDiff = sqrtRatioB - sqrtRatioA; 82 | const multipliedRes = leftShiftedLiquidity * sqrtDiff; 83 | const numerator = multipliedRes / sqrtRatioB; 84 | const amount0 = numerator / sqrtRatioA; 85 | 86 | return amount0; 87 | }; 88 | 89 | const getAmount1ForLiquidity = ( 90 | sqrtRatioAX96: bigint, 91 | sqrtRatioBX96: bigint, 92 | liquidity: bigint 93 | ) => { 94 | let [sqrtRatioA, sqrtRatioB] = [sqrtRatioAX96, sqrtRatioBX96]; 95 | 96 | if (sqrtRatioA > sqrtRatioB) { 97 | [sqrtRatioA, sqrtRatioB] = [sqrtRatioB, sqrtRatioA]; 98 | } 99 | 100 | const sqrtDiff = sqrtRatioB - sqrtRatioA; 101 | const multipliedRes = liquidity * sqrtDiff; 102 | 103 | const amount1 = multipliedRes / 2n ** 96n; 104 | 105 | return amount1; 106 | }; 107 | 108 | export const getSqrtPriceX96FromTick = (tick: number): bigint => { 109 | return BigInt(TickMath.getSqrtRatioAtTick(tick).toString()); 110 | }; 111 | 112 | export const calculateUnderlyingTokenBalances = ( 113 | liquidity: bigint, 114 | tickLower: number, 115 | tickUpper: number, 116 | tickCurrent: number 117 | ): { amount0: bigint; amount1: bigint } => { 118 | const sqrtPriceCurrentX96 = getSqrtPriceX96FromTick(tickCurrent); 119 | const sqrtPriceLowerX96 = getSqrtPriceX96FromTick(tickLower); 120 | const sqrtPriceUpperX96 = getSqrtPriceX96FromTick(tickUpper); 121 | 122 | let amount0 = 0n; 123 | let amount1 = 0n; 124 | 125 | if (sqrtPriceCurrentX96 <= sqrtPriceLowerX96) { 126 | // Current price is below the position range 127 | amount0 = getAmount0ForLiquidity( 128 | sqrtPriceLowerX96, 129 | sqrtPriceUpperX96, 130 | liquidity 131 | ); 132 | } else if (sqrtPriceCurrentX96 < sqrtPriceUpperX96) { 133 | // Current price is within the position range 134 | amount0 = getAmount0ForLiquidity( 135 | sqrtPriceCurrentX96, 136 | sqrtPriceUpperX96, 137 | liquidity 138 | ); 139 | amount1 = getAmount1ForLiquidity( 140 | sqrtPriceLowerX96, 141 | sqrtPriceCurrentX96, 142 | liquidity 143 | ); 144 | } else { 145 | // Current price is above the position range 146 | amount1 = getAmount1ForLiquidity( 147 | sqrtPriceLowerX96, 148 | sqrtPriceUpperX96, 149 | liquidity 150 | ); 151 | } 152 | 153 | return { amount0, amount1 }; 154 | }; 155 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "module": "esnext", 5 | "moduleResolution": "bundler", 6 | "declaration": true, 7 | "declarationMap": true, 8 | "sourceMap": true, 9 | "outDir": "./dist", 10 | "rootDir": "./src", 11 | "esModuleInterop": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "skipLibCheck": true, 14 | "resolveJsonModule": true, 15 | "isolatedModules": true, 16 | "noImplicitAny": true, 17 | "noImplicitReturns": true, 18 | "strict": true, 19 | "baseUrl": "src", 20 | "paths": { 21 | "*": ["*"] 22 | } 23 | }, 24 | "include": ["src/**/*"], 25 | "exclude": ["node_modules", "dist", "**/*.test.ts"] 26 | } 27 | --------------------------------------------------------------------------------