# Table of Contents - [Welcome | trench-today](#welcome-trench-today) - [Unknown](#unknown) - [Getting Started | trench-today](#getting-started-trench-today) - [ABI Files | trench-today](#abi-files-trench-today) - [For Developers | trench-today](#for-developers-trench-today) - [Unknown](#unknown) - [Introduction | trench-today](#introduction-trench-today) - [Unknown](#unknown) - [Unknown](#unknown) - [Brand Assets | trench-today](#brand-assets-trench-today) - [Links | trench-today](#links-trench-today) - [Unknown](#unknown) - [How It Works | trench-today](#how-it-works-trench-today) - [Unknown](#unknown) - [Integration Guide | trench-today](#integration-guide-trench-today) - [Contract Reference | trench-today](#contract-reference-trench-today) - [Unknown](#unknown) - [Unknown](#unknown) - [Links | trench-today](#links-trench-today) - [Unknown](#unknown) - [Unknown](#unknown) - [Unknown](#unknown) - [trench-today](#trench-today) - [trench-today](#trench-today) - [trench-today](#trench-today) - [trench-today](#trench-today) --- # Welcome | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/readme.md) . ![Trench Today — Back to meme culture](https://trench-today.gitbook.io/trench-today/~gitbook/image?url=https%3A%2F%2F2106537636-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FRV6mTFBpKrc2LjpD9kzi%252Fuploads%252Fgit-blob-ff32142fd0be99332ff9249143328461b2e7abf5%252Fbanner.png%3Falt%3Dmedia&width=768&dpr=3&quality=100&sign=86537b0b&sv=2) > **Back to meme culture. Trench Today.** > > GitBook Assistant Memes used to start here. Now they do again. GitBook Assistant Trench is the ground it grows from — a permissionless launchpad built on the chain where the culture began. GitBook Assistant Trench Today. GitBook Assistant This documentation covers what Trench is, how to use it, the mechanics behind every trade, and the API for third‑party aggregators who want to plug in. GitBook Assistant [](https://trench-today.gitbook.io/trench-today#start-here) Start here --------------------------------------------------------------------------- [](https://trench-today.gitbook.io/trench-today/introduction) **Introduction** GitBook Assistant What Trench is and why it exists on Ethereum. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/getting-started) **Getting Started** GitBook Assistant Connect a wallet, launch a token, trade, and claim dev fees. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/how-it-works) **How It Works** GitBook Assistant Bonding curve, graduation, fee flow — in plain English. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/api) **For Developers** GitBook Assistant API reference for aggregators and integrations. GitBook Assistant [NextIntroduction](https://trench-today.gitbook.io/trench-today/introduction) Was this helpful? --- # Unknown \# trench-today ## Docs - \[Welcome\](https://trench-today.gitbook.io/trench-today/readme.md): Back to meme culture. Trench Today. - \[Introduction\](https://trench-today.gitbook.io/trench-today/introduction.md): What Trench is, who it's for, and why it's built on Ethereum, MegaETH, and Robinhood. - \[Getting Started\](https://trench-today.gitbook.io/trench-today/getting-started.md): Launch a token, trade the curve, and claim dev fees. - \[How It Works\](https://trench-today.gitbook.io/trench-today/how-it-works.md): The bonding curve, graduation, and fee flow — written for humans, not auditors. - \[For Developers\](https://trench-today.gitbook.io/trench-today/for-developers/api.md): Integrate Trench directly from your smart contract or off-chain app. - \[Contract Reference\](https://trench-today.gitbook.io/trench-today/for-developers/contracts.md): Deployed addresses, on-chain parameters, and the full ABI surface. - \[Integration Guide\](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide.md): Core concepts, integration patterns, and security checklist for on-chain integrators. - \[ABI Files\](https://trench-today.gitbook.io/trench-today/for-developers/abi-files.md): Downloadable JSON ABI files for all Trench contracts. - \[Links\](https://trench-today.gitbook.io/trench-today/resources/links.md): Official channels and where to reach the team. - \[Brand Assets\](https://trench-today.gitbook.io/trench-today/resources/brand-assets.md): Logo and visual assets. --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on a page URL with the \`ask\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/readme.md?ask= \`\`\` The question should be specific, self-contained, and written in natural language. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Getting Started | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/getting-started.md) . [](https://trench-today.gitbook.io/trench-today/getting-started#launch-a-token) Launch a token --------------------------------------------------------------------------------------------------- Hit **LAUNCH** on the homepage. Fill in the form: GitBook Assistant Field Notes **Coin Name** GitBook Assistant The token's full name. GitBook Assistant **Ticker** GitBook Assistant Conventionally uppercase, e.g. `PEPE2`. GitBook Assistant **Image** GitBook Assistant JPG / PNG / GIF / WebP, ≤ 5 MB. GitBook Assistant **Dev Buy (ETH)** GitBook Assistant ETH to buy on your own curve at launch. Can be `0`. GitBook Assistant **X / Website / Description** GitBook Assistant Optional. GitBook Assistant **Dev Buy** buys tokens in the same transaction as the deploy. Bots can't front-run you because there's nothing to front-run — your buy and the contract creation land in one tx. Set it to `0` if you want to start clean. GitBook Assistant Sign the transaction. Your token goes live instantly — chart, curve, buy/sell box all ready. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/getting-started#trade-on-the-curve) Trade on the curve ----------------------------------------------------------------------------------------------------------- Click any token to open its detail page. Everything is there: price, chart, curve progress bar, buy/sell box, trade history, holder rankings. GitBook Assistant Tokens trade on the bonding curve until graduation. When the curve fills, the token migrates automatically to Uniswap V2 with permanently locked LP — trading continues there without any action on your part. GitBook Assistant Once a token's state shows **migrating** or **migrated**, route trades to Uniswap V2. The curve is closed. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/getting-started#claim-dev-fees) Claim dev fees --------------------------------------------------------------------------------------------------- Every trade on your token's curve pays **0.3%** to you. Fees accrue to the wallet that deployed the token — no configuration needed. GitBook Assistant The **Fee Vault panel** on the homepage shows your total across all deployed tokens. Hit **CLAIM** to sweep everything in one transaction. GitBook Assistant Fees go to the deployer wallet only. No redirects, no splits. GitBook Assistant [PreviousIntroduction](https://trench-today.gitbook.io/trench-today/introduction) [NextHow It Works](https://trench-today.gitbook.io/trench-today/how-it-works) Last updated 2 months ago Was this helpful? * [Launch a token](https://trench-today.gitbook.io/trench-today/getting-started#launch-a-token) * [Trade on the curve](https://trench-today.gitbook.io/trench-today/getting-started#trade-on-the-curve) * [Claim dev fees](https://trench-today.gitbook.io/trench-today/getting-started#claim-dev-fees) Was this helpful? --- # ABI Files | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/for-developers/abi-files.md) . Download the JSON ABI files to use with ethers.js, viem, wagmi, or any other Ethereum library. GitBook Assistant Admin-only functions (`pause`, `unpause`, `withdraw`, `configFactory`, `configVault`, etc.) are excluded from these files. GitBook Assistant Ethereum Mainnet MegaETH Mainnet Robinhood Mainnet 16KB [ITrenchManagerV2.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-3c82d5ae9ebb415c825ce90e842914ec47ada7d5%2FITrenchManagerV2.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-3c82d5ae9ebb415c825ce90e842914ec47ada7d5%2FITrenchManagerV2.json?alt=media) ITrenchManagerV2 — Core trading functions (buy, sell, createCurve, quote) 6KB [IBondingCurve.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-20feaf38a6fe3ab6d8cb0c933cd31fe5f2a1d760%2FIBondingCurve.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-20feaf38a6fe3ab6d8cb0c933cd31fe5f2a1d760%2FIBondingCurve.json?alt=media) IBondingCurve — Read-only curve state queries 7KB [IBondingCurveFactory.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-0fcce306428a6c51fb81d3bee447314d3a502fb8%2FIBondingCurveFactory.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-0fcce306428a6c51fb81d3bee447314d3a502fb8%2FIBondingCurveFactory.json?alt=media) IBondingCurveFactory — Factory configuration 3KB [IERC20.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-72f2c966a4e268a393ebd6da625c0a513a007df8%2FIERC20.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-72f2c966a4e268a393ebd6da625c0a513a007df8%2FIERC20.json?alt=media) IERC20 — Standard ERC-20 interface [](https://trench-today.gitbook.io/trench-today/for-developers/abi-files#usage) Usage ------------------------------------------------------------------------------------------ GitBook AssistantAskCopy import { ethers } from "ethers"; import ITrenchManagerV2 from "./ITrenchManagerV2.json"; const MANAGER_ADDRESS = "0x974B2d86d6353c62f19110127aF1A5df4c6370f0"; const provider = new ethers.JsonRpcProvider(RPC_URL); const manager = new ethers.Contract(MANAGER_ADDRESS, ITrenchManagerV2, provider); // Quote a buy const [amountOut] = await manager.quoteBuyWithFee( ethers.parseEther("0.1"), tokenAddress, 0 // no platform fee ); console.log("Expected tokens:", ethers.formatEther(amountOut)); 36KB [ITrenchManagerV3.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-fc1c31de40155ee07f396633f91c213c49fbf12f%2FITrenchManagerV3.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-fc1c31de40155ee07f396633f91c213c49fbf12f%2FITrenchManagerV3.json?alt=media) ITrenchManagerV3 — Core trading functions (buy, sell, createCurve, quote, tokenInfo, migrateToV3) 6KB [IBondingCurve.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-20feaf38a6fe3ab6d8cb0c933cd31fe5f2a1d760%2FIBondingCurve.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-20feaf38a6fe3ab6d8cb0c933cd31fe5f2a1d760%2FIBondingCurve.json?alt=media) IBondingCurve (MegaETH) — Read-only curve state queries 7KB [IBondingCurveFactoryMegaETH.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-8e4a6ecb76955251e2e41192cd6aac956b5303d8%2FIBondingCurveFactoryMegaETH.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-8e4a6ecb76955251e2e41192cd6aac956b5303d8%2FIBondingCurveFactoryMegaETH.json?alt=media) IBondingCurveFactory (MegaETH) — Factory configuration 4KB [IFeeVault.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-6b0e7a5ba8517d5c72893367e9ef2c5bdce9e24d%2FIFeeVault.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-6b0e7a5ba8517d5c72893367e9ef2c5bdce9e24d%2FIFeeVault.json?alt=media) IFeeVault — Fee vault (devClaim, protocolClaim, creditsDev) 5KB [IToken.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-da0b52f162820a34e61f560f4e02911ec033ced9%2FIToken.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-da0b52f162820a34e61f560f4e02911ec033ced9%2FIToken.json?alt=media) IToken — ERC-20 with transfer mode control [](https://trench-today.gitbook.io/trench-today/for-developers/abi-files#usage-1) Usage -------------------------------------------------------------------------------------------- 18KB [ITrenchManagerRobinhood.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-8a9204c060416a5fffdbfedea0d14cbc050dd697%2FITrenchManagerRobinhood.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-8a9204c060416a5fffdbfedea0d14cbc050dd697%2FITrenchManagerRobinhood.json?alt=media) ITrenchManager — Core trading functions (buy, sell, createCurve, previewBuy/Sell, tokenInfo, migrate, lpFeeSplitter) 4KB [IBondingCurveRobinhood.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-f1745c5817490da51114bf06571f4486f691bc9c%2FIBondingCurveRobinhood.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-f1745c5817490da51114bf06571f4486f691bc9c%2FIBondingCurveRobinhood.json?alt=media) IBondingCurve (Robinhood) — Read-only curve state queries (quote-denominated reserves) 3KB [IBondingCurveFactoryRobinhood.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-3ef2c0f3257b136524126523ee80146c4520d154%2FIBondingCurveFactoryRobinhood.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-3ef2c0f3257b136524126523ee80146c4520d154%2FIBondingCurveFactoryRobinhood.json?alt=media) IBondingCurveFactory (Robinhood) — Factory configuration (getConfig by quote) 4KB [IFeeVaultRobinhood.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-2715e0e4c30c252f0692c6efcc0b530de0a60741%2FIFeeVaultRobinhood.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-2715e0e4c30c252f0692c6efcc0b530de0a60741%2FIFeeVaultRobinhood.json?alt=media) IFeeVault (Robinhood) — Fee vault (devClaim, protocolClaim, creditsDev, minClaimAmount) 6KB [ITokenRobinhood.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-9801b608e8d8738b23ec5dd922615fc214905b03%2FITokenRobinhood.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-9801b608e8d8738b23ec5dd922615fc214905b03%2FITokenRobinhood.json?alt=media) IToken (Robinhood) — ERC-20 with two-state transfer mode control 6KB [ILPFeeSplitterRobinhood.json](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-073ed0df6008fa62fead527c51ced8422f519837%2FILPFeeSplitterRobinhood.json?alt=media) Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-073ed0df6008fa62fead527c51ced8422f519837%2FILPFeeSplitterRobinhood.json?alt=media) ILPFeeSplitter (Robinhood) — Post-graduation Uniswap V3 swap-fee split (claim, creatorCredits, devShareBps) [](https://trench-today.gitbook.io/trench-today/for-developers/abi-files#usage-2) Usage -------------------------------------------------------------------------------------------- Post-graduation dev fees (Uniswap V3 swap-fee split) are read and claimed on the **LPFeeSplitter**, separately from the on-curve `FeeVault`: GitBook Assistant [PreviousIntegration Guide](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide) [NextLinks](https://trench-today.gitbook.io/trench-today/resources/links) Last updated 22 minutes ago Was this helpful? Was this helpful? GitBook AssistantAskCopy import { createPublicClient, http } from "viem"; import { mainnet } from "viem/chains"; import ITrenchManagerV2 from "./ITrenchManagerV2.json"; const client = createPublicClient({ chain: mainnet, transport: http() }); const amountOut = await client.readContract({ address: "0x974B2d86d6353c62f19110127aF1A5df4c6370f0", abi: ITrenchManagerV2, functionName: "quoteBuyWithFee", args: [parseEther("0.1"), tokenAddress, 0n], }); GitBook AssistantAskCopy import { ethers } from "ethers"; import ITrenchManagerV3 from "./ITrenchManagerV3.json"; const MANAGER_ADDRESS = "0x2978E15501C792152602eC85c299083aa61b1bd4"; const RPC_URL = "https://mainnet.megaeth.com/rpc"; const provider = new ethers.JsonRpcProvider(RPC_URL); const manager = new ethers.Contract(MANAGER_ADDRESS, ITrenchManagerV3, provider); // Quote a buy const [amountOut] = await manager.quoteBuyWithFee( ethers.parseEther("0.1"), tokenAddress, 0 // no platform fee ); console.log("Expected tokens:", ethers.formatEther(amountOut)); // Get all token state in one call const info = await manager.tokenInfo(tokenAddress); console.log("Real ETH in curve:", ethers.formatEther(info.realNativeReserves)); console.log("Migrating:", info.isMigrating); console.log("Migrated:", info.isMigrated); GitBook AssistantAskCopy import { createPublicClient, http, defineChain } from "viem"; import ITrenchManagerV3 from "./ITrenchManagerV3.json"; const megaeth = defineChain({ id: 4326, name: "MegaETH Mainnet", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: ["https://mainnet.megaeth.com/rpc"] } }, blockExplorers: { default: { name: "MegaExplorer", url: "https://megaexplorer.xyz" } }, }); const client = createPublicClient({ chain: megaeth, transport: http() }); const [amountOut] = await client.readContract({ address: "0x2978E15501C792152602eC85c299083aa61b1bd4", abi: ITrenchManagerV3, functionName: "quoteBuyWithFee", args: [parseEther("0.1"), tokenAddress, 0n], }); GitBook AssistantAskCopy import { ethers } from "ethers"; import ITrenchManager from "./ITrenchManagerRobinhood.json"; const MANAGER_ADDRESS = "0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d"; const provider = new ethers.JsonRpcProvider(RPC_URL); // request RPC from the team const manager = new ethers.Contract(MANAGER_ADDRESS, ITrenchManager, provider); // Quote a buy (Robinhood uses previewBuy, not quoteBuyWithFee) const [amountOut, fee] = await manager.previewBuy(tokenAddress, ethers.parseEther("0.1")); console.log("Expected tokens:", ethers.formatEther(amountOut)); console.log("Protocol fee:", ethers.formatEther(fee)); // Get all token state in one call — note the quote field and Quote-named reserves const info = await manager.tokenInfo(tokenAddress); console.log("Quote token:", info.quoteAddr); // address(0) = ETH console.log("Real quote in curve:", info.realQuoteReserves); console.log("Migrating:", info.isMigrating_, "Migrated:", info.isMigrated_); GitBook AssistantAskCopy import { createPublicClient, http, defineChain } from "viem"; import ITrenchManager from "./ITrenchManagerRobinhood.json"; const robinhood = defineChain({ id: 4663, name: "Robinhood Mainnet", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: [RPC_URL] } }, // request RPC from the team }); const client = createPublicClient({ chain: robinhood, transport: http() }); const [amountOut, fee] = await client.readContract({ address: "0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d", abi: ITrenchManager, functionName: "previewBuy", args: [tokenAddress, parseEther("0.1")], }); GitBook AssistantAskCopy import { ethers } from "ethers"; import ILPFeeSplitter from "./ILPFeeSplitterRobinhood.json"; const SPLITTER = "0x74a40b65320c717F0ECF74f68CcB910edCd08e22"; const ETH = "0x0000000000000000000000000000000000000000"; const splitter = new ethers.Contract(SPLITTER, ILPFeeSplitter, signer); // Already-booked claimable dev share (add uncollected pending × devShareBps for a full estimate) const booked = await splitter.creatorCredits(creator, ETH); // Claim across all of the creator's positions in one tx (WETH auto-unwrapped to ETH) await splitter.claim(creator); --- # For Developers | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/for-developers/api.md) . Trench exposes on-chain interfaces for aggregators, trading terminals, bots, and wallets to interact with the bonding curve directly from Solidity or any EVM library. GitBook Assistant All interactions go through the **TrenchManager** contract — the single entry point for creating tokens, buying, selling, and querying curve state. GitBook Assistant Chain Contract Address **Ethereum Mainnet** GitBook Assistant TrenchManagerV2 (Proxy) GitBook Assistant `0x974B2d86d6353c62f19110127aF1A5df4c6370f0` GitBook Assistant **MegaETH Mainnet** GitBook Assistant TrenchManagerV3 (Proxy) GitBook Assistant `0x2978E15501C792152602eC85c299083aa61b1bd4` GitBook Assistant **Robinhood Mainnet** GitBook Assistant TrenchManager (Proxy) GitBook Assistant `0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d` GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/api#quick-start) Quick start ------------------------------------------------------------------------------------------------ Ethereum MegaETH Robinhood GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManagerV2 { function buy( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline ) external payable returns (uint256 amountOut); } contract SimpleBuyer { ITrenchManagerV2 constant MANAGER = ITrenchManagerV2(0x974B2d86d6353c62f19110127aF1A5df4c6370f0); function buyTokens(address token, uint256 minTokens) external payable { MANAGER.buy{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300 ); } } [](https://trench-today.gitbook.io/trench-today/for-developers/api#in-this-section) In this section -------------------------------------------------------------------------------------------------------- * [Contract Reference](https://trench-today.gitbook.io/trench-today/for-developers/contracts) — addresses, on-chain parameters, full ABI GitBook Assistant * [Integration Guide](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide) — core concepts, patterns, security checklist GitBook Assistant * [ABI Files](https://trench-today.gitbook.io/trench-today/for-developers/abi-files) — downloadable JSON ABI files GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/api#support) Support ---------------------------------------------------------------------------------------- For integration support or API key requests, reach us through the channels listed under [Resources → Links](https://trench-today.gitbook.io/trench-today/resources/links) . GitBook Assistant [PreviousHow It Works](https://trench-today.gitbook.io/trench-today/how-it-works) [NextContract Reference](https://trench-today.gitbook.io/trench-today/for-developers/contracts) Last updated 22 hours ago Was this helpful? * [Quick start](https://trench-today.gitbook.io/trench-today/for-developers/api#quick-start) * [In this section](https://trench-today.gitbook.io/trench-today/for-developers/api#in-this-section) * [Support](https://trench-today.gitbook.io/trench-today/for-developers/api#support) Was this helpful? GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManagerV3 { function buy( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline ) external payable returns (uint256 amountOut); } contract SimpleBuyer { ITrenchManagerV3 constant MANAGER = ITrenchManagerV3(0x2978E15501C792152602eC85c299083aa61b1bd4); function buyTokens(address token, uint256 minTokens) external payable { MANAGER.buy{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300 ); } } GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManager { function buy( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline ) external payable returns (uint256 amountOut); } contract SimpleBuyer { ITrenchManager constant MANAGER = ITrenchManager(0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d); function buyTokens(address token, uint256 minTokens) external payable { MANAGER.buy{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300 ); } } --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/for-developers/abi-files.md). # ABI Files Download the JSON ABI files to use with ethers.js, viem, wagmi, or any other Ethereum library. Admin-only functions (\`pause\`, \`unpause\`, \`withdraw\`, \`configFactory\`, \`configVault\`, etc.) are excluded from these files. {% tabs %} {% tab title="Ethereum Mainnet" %} {% file src="/files/iqNscIURcPTKLmFnxfKE" %} ITrenchManagerV2 — Core trading functions (buy, sell, createCurve, quote) {% endfile %} {% file src="/files/IfeuvQGx6fptirtp6ya1" %} IBondingCurve — Read-only curve state queries {% endfile %} {% file src="/files/9EgFXwaZUMgkHeniEF4W" %} IBondingCurveFactory — Factory configuration {% endfile %} {% file src="/files/psuqlFjQewds1zuh1iwU" %} IERC20 — Standard ERC-20 interface {% endfile %} ## Usage \`\`\`javascript import { ethers } from "ethers"; import ITrenchManagerV2 from "./ITrenchManagerV2.json"; const MANAGER\_ADDRESS = "0x974B2d86d6353c62f19110127aF1A5df4c6370f0"; const provider = new ethers.JsonRpcProvider(RPC\_URL); const manager = new ethers.Contract(MANAGER\_ADDRESS, ITrenchManagerV2, provider); // Quote a buy const \[amountOut\] = await manager.quoteBuyWithFee( ethers.parseEther("0.1"), tokenAddress, 0 // no platform fee ); console.log("Expected tokens:", ethers.formatEther(amountOut)); \`\`\` \`\`\`javascript import { createPublicClient, http } from "viem"; import { mainnet } from "viem/chains"; import ITrenchManagerV2 from "./ITrenchManagerV2.json"; const client = createPublicClient({ chain: mainnet, transport: http() }); const amountOut = await client.readContract({ address: "0x974B2d86d6353c62f19110127aF1A5df4c6370f0", abi: ITrenchManagerV2, functionName: "quoteBuyWithFee", args: \[parseEther("0.1"), tokenAddress, 0n\], }); \`\`\` {% endtab %} {% tab title="MegaETH Mainnet" %} {% file src="/files/u81vSHPKbqo0jQcIr9AB" %} ITrenchManagerV3 — Core trading functions (buy, sell, createCurve, quote, tokenInfo, migrateToV3) {% endfile %} {% file src="/files/IfeuvQGx6fptirtp6ya1" %} IBondingCurve (MegaETH) — Read-only curve state queries {% endfile %} {% file src="/files/5M1C741sueO8VD52eqjf" %} IBondingCurveFactory (MegaETH) — Factory configuration {% endfile %} {% file src="/files/Jd5gpKR74fq8E57mnecX" %} IFeeVault — Fee vault (devClaim, protocolClaim, creditsDev) {% endfile %} {% file src="/files/s0ZtiIQY4pPAFt95bYm3" %} IToken — ERC-20 with transfer mode control {% endfile %} ## Usage \`\`\`javascript import { ethers } from "ethers"; import ITrenchManagerV3 from "./ITrenchManagerV3.json"; const MANAGER\_ADDRESS = "0x2978E15501C792152602eC85c299083aa61b1bd4"; const RPC\_URL = "https://mainnet.megaeth.com/rpc"; const provider = new ethers.JsonRpcProvider(RPC\_URL); const manager = new ethers.Contract(MANAGER\_ADDRESS, ITrenchManagerV3, provider); // Quote a buy const \[amountOut\] = await manager.quoteBuyWithFee( ethers.parseEther("0.1"), tokenAddress, 0 // no platform fee ); console.log("Expected tokens:", ethers.formatEther(amountOut)); // Get all token state in one call const info = await manager.tokenInfo(tokenAddress); console.log("Real ETH in curve:", ethers.formatEther(info.realNativeReserves)); console.log("Migrating:", info.isMigrating); console.log("Migrated:", info.isMigrated); \`\`\` \`\`\`javascript import { createPublicClient, http, defineChain } from "viem"; import ITrenchManagerV3 from "./ITrenchManagerV3.json"; const megaeth = defineChain({ id: 4326, name: "MegaETH Mainnet", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: \["https://mainnet.megaeth.com/rpc"\] } }, blockExplorers: { default: { name: "MegaExplorer", url: "https://megaexplorer.xyz" } }, }); const client = createPublicClient({ chain: megaeth, transport: http() }); const \[amountOut\] = await client.readContract({ address: "0x2978E15501C792152602eC85c299083aa61b1bd4", abi: ITrenchManagerV3, functionName: "quoteBuyWithFee", args: \[parseEther("0.1"), tokenAddress, 0n\], }); \`\`\` {% endtab %} {% tab title="Robinhood Mainnet" %} {% file src="/files/dakRsAlnxRPhPMzONfHk" %} ITrenchManager — Core trading functions (buy, sell, createCurve, previewBuy/Sell, tokenInfo, migrate, lpFeeSplitter) {% endfile %} {% file src="/files/aGEslLB3RBCiCx292gyS" %} IBondingCurve (Robinhood) — Read-only curve state queries (quote-denominated reserves) {% endfile %} {% file src="/files/de1PDq862NcYBaq28MfB" %} IBondingCurveFactory (Robinhood) — Factory configuration (getConfig by quote) {% endfile %} {% file src="/files/vRgU3yjnuoqmpBsDQZmq" %} IFeeVault (Robinhood) — Fee vault (devClaim, protocolClaim, creditsDev, minClaimAmount) {% endfile %} {% file src="/files/Zm9xfTRNHUmIaQtC8H64" %} IToken (Robinhood) — ERC-20 with two-state transfer mode control {% endfile %} {% file src="/files/QWhc79zRhJpkIPhmXVld" %} ILPFeeSplitter (Robinhood) — Post-graduation Uniswap V3 swap-fee split (claim, creatorCredits, devShareBps) {% endfile %} ## Usage \`\`\`javascript import { ethers } from "ethers"; import ITrenchManager from "./ITrenchManagerRobinhood.json"; const MANAGER\_ADDRESS = "0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d"; const provider = new ethers.JsonRpcProvider(RPC\_URL); // request RPC from the team const manager = new ethers.Contract(MANAGER\_ADDRESS, ITrenchManager, provider); // Quote a buy (Robinhood uses previewBuy, not quoteBuyWithFee) const \[amountOut, fee\] = await manager.previewBuy(tokenAddress, ethers.parseEther("0.1")); console.log("Expected tokens:", ethers.formatEther(amountOut)); console.log("Protocol fee:", ethers.formatEther(fee)); // Get all token state in one call — note the quote field and Quote-named reserves const info = await manager.tokenInfo(tokenAddress); console.log("Quote token:", info.quoteAddr); // address(0) = ETH console.log("Real quote in curve:", info.realQuoteReserves); console.log("Migrating:", info.isMigrating\_, "Migrated:", info.isMigrated\_); \`\`\` \`\`\`javascript import { createPublicClient, http, defineChain } from "viem"; import ITrenchManager from "./ITrenchManagerRobinhood.json"; const robinhood = defineChain({ id: 4663, name: "Robinhood Mainnet", nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { default: { http: \[RPC\_URL\] } }, // request RPC from the team }); const client = createPublicClient({ chain: robinhood, transport: http() }); const \[amountOut, fee\] = await client.readContract({ address: "0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d", abi: ITrenchManager, functionName: "previewBuy", args: \[tokenAddress, parseEther("0.1")\], }); \`\`\` Post-graduation dev fees (Uniswap V3 swap-fee split) are read and claimed on the \*\*LPFeeSplitter\*\*, separately from the on-curve \`FeeVault\`: \`\`\`javascript import { ethers } from "ethers"; import ILPFeeSplitter from "./ILPFeeSplitterRobinhood.json"; const SPLITTER = "0x74a40b65320c717F0ECF74f68CcB910edCd08e22"; const ETH = "0x0000000000000000000000000000000000000000"; const splitter = new ethers.Contract(SPLITTER, ILPFeeSplitter, signer); // Already-booked claimable dev share (add uncollected pending × devShareBps for a full estimate) const booked = await splitter.creatorCredits(creator, ETH); // Claim across all of the creator's positions in one tx (WETH auto-unwrapped to ETH) await splitter.claim(creator); \`\`\` {% endtab %} {% endtabs %} --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/for-developers/abi-files.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Introduction | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/introduction.md) . [](https://trench-today.gitbook.io/trench-today/introduction#what-is-trench) What is Trench ------------------------------------------------------------------------------------------------ **Trench** is a meme launchpad on Ethereum, MegaETH, and Robinhood. One transaction to deploy a token. Instant trading on a bonding curve from block zero. Automatic graduation to a DEX — with liquidity permanently secured — the moment the curve fills up. GitBook Assistant Every token on Trench is: GitBook Assistant * **Created in a single transaction.** No presale, no whitelist, no team allocation. GitBook Assistant * **Priced by a bonding curve from block one.** The market decides the price, not a deployer. GitBook Assistant * **Auto‑graduated to a DEX** once the curve fills up. Liquidity is locked or permanently held by the protocol. GitBook Assistant * **Fair‑launched by design.** Every buyer, from the deployer to the last sniper, uses the same curve. GitBook Assistant If you've launched a meme token before, you already know how to use Trench. The mechanics are familiar — the chains, the culture, and a few sharper edges are what's new. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/introduction#who-its-for) Who it's for ------------------------------------------------------------------------------------------- Devs Traders Aggregators & Integrators You have a meme, a mascot, a shitpost, or a brand‑new narrative. You want to deploy it in 30 seconds, earn a cut of every trade for as long as the token lives, and never touch a line of Solidity. GitBook Assistant → Go to [Getting Started](https://trench-today.gitbook.io/trench-today/getting-started) and launch your first token. GitBook Assistant You want to be first. You want to read the curve, not a whitepaper. You want to rotate from one trench to the next without leaving the site. GitBook Assistant → Go to [How It Works](https://trench-today.gitbook.io/trench-today/how-it-works) to understand what you're buying. GitBook Assistant You run an aggregator, a trading terminal, a bot, or a wallet. You want Trench's order flow inside your product. GitBook Assistant → Go to [API Overview](https://trench-today.gitbook.io/trench-today/for-developers/api) to plug in. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/introduction#supported-chains) Supported chains ---------------------------------------------------------------------------------------------------- Chain Status DEX at graduation **Ethereum Mainnet** GitBook Assistant Live GitBook Assistant Uniswap V2 GitBook Assistant **MegaETH Mainnet** GitBook Assistant Live GitBook Assistant Kumbaya V3 GitBook Assistant **Robinhood Mainnet** GitBook Assistant Live GitBook Assistant Uniswap V3 GitBook Assistant [](https://trench-today.gitbook.io/trench-today/introduction#why-ethereum) Why Ethereum -------------------------------------------------------------------------------------------- The deepest liquidity and the most expensive attention in crypto live here. Meme culture was born on Ethereum — and for years it's been launching everywhere else. What Ethereum has been missing is a **permissionless place where that culture crystallizes into a token in one click**. GitBook Assistant That's the Trench. GitBook Assistant Meme season is back on Ethereum, and this time the culture doesn't need to emigrate to launch. Trench is where ETH‑native memes ship from — closer to the money, closer to the history, closer to the scene that started all of this. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/introduction#why-megaeth) Why MegaETH ------------------------------------------------------------------------------------------ MegaETH is a real-time EVM chain — sub-millisecond block times, 100k+ TPS, and Ethereum-aligned architecture. For meme trading, speed is everything: price discovery, front-running defense, and user experience all improve when blocks are effectively instant. GitBook Assistant Trench on MegaETH uses **TrenchManagerV3**, which adds native Kumbaya V3 integration at graduation. The bonding curve mechanics are identical — the execution layer is orders of magnitude faster. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/introduction#why-robinhood) Why Robinhood ---------------------------------------------------------------------------------------------- Robinhood is an Arbitrum Orbit L2 with native ETH — an Ethereum-aligned execution environment with L2 economics. Trench on Robinhood runs a **single-layer** design: users call one **TrenchManager** contract directly, with no aggregation or vault layer in between, keeping the integration surface small and every trade one hop from the curve. GitBook Assistant Tokens are priced in native **ETH**, and curves graduate to **Uniswap V3** — with a full-range anchor pool pre-created at launch to lock the graduation price against front-running. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/introduction#the-thesis-in-one-paragraph) The thesis in one paragraph -------------------------------------------------------------------------------------------------------------------------- Every iconic coin was once a shitpost. Every narrative was once a joke. **Meme culture doesn't come from presales or PowerPoints — it comes from the trench.** Trench is the shortest path between "this is a meme" and "this is tradable." GitBook Assistant [](https://trench-today.gitbook.io/trench-today/introduction#whats-next) What's next ----------------------------------------------------------------------------------------- * Read [How It Works](https://trench-today.gitbook.io/trench-today/how-it-works) to understand the bonding curve and fee flow. GitBook Assistant * Jump into [Getting Started](https://trench-today.gitbook.io/trench-today/getting-started) if you just want to launch something. GitBook Assistant * Aggregators → [API Overview](https://trench-today.gitbook.io/trench-today/for-developers/api) . GitBook Assistant [PreviousWelcome](https://trench-today.gitbook.io/trench-today) [NextGetting Started](https://trench-today.gitbook.io/trench-today/getting-started) Last updated 22 hours ago Was this helpful? * [What is Trench](https://trench-today.gitbook.io/trench-today/introduction#what-is-trench) * [Who it's for](https://trench-today.gitbook.io/trench-today/introduction#who-its-for) * [Supported chains](https://trench-today.gitbook.io/trench-today/introduction#supported-chains) * [Why Ethereum](https://trench-today.gitbook.io/trench-today/introduction#why-ethereum) * [Why MegaETH](https://trench-today.gitbook.io/trench-today/introduction#why-megaeth) * [Why Robinhood](https://trench-today.gitbook.io/trench-today/introduction#why-robinhood) * [The thesis in one paragraph](https://trench-today.gitbook.io/trench-today/introduction#the-thesis-in-one-paragraph) * [What's next](https://trench-today.gitbook.io/trench-today/introduction#whats-next) Was this helpful? --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/getting-started.md). # Getting Started ## Launch a token Hit \*\*LAUNCH\*\* on the homepage. Fill in the form: | Field | Notes | | ----------------------------- | --------------------------------------------------- | | \*\*Coin Name\*\* | The token's full name. | | \*\*Ticker\*\* | Conventionally uppercase, e.g. \`PEPE2\`. | | \*\*Image\*\* | JPG / PNG / GIF / WebP, ≤ 5 MB. | | \*\*Dev Buy (ETH)\*\* | ETH to buy on your own curve at launch. Can be \`0\`. | | \*\*X / Website / Description\*\* | Optional. | {% hint style="info" %} \*\*Dev Buy\*\* buys tokens in the same transaction as the deploy. Bots can't front-run you because there's nothing to front-run — your buy and the contract creation land in one tx. Set it to \`0\` if you want to start clean. {% endhint %} Sign the transaction. Your token goes live instantly — chart, curve, buy/sell box all ready. ## Trade on the curve Click any token to open its detail page. Everything is there: price, chart, curve progress bar, buy/sell box, trade history, holder rankings. Tokens trade on the bonding curve until graduation. When the curve fills, the token migrates automatically to Uniswap V2 with permanently locked LP — trading continues there without any action on your part. {% hint style="info" %} Once a token's state shows \*\*migrating\*\* or \*\*migrated\*\*, route trades to Uniswap V2. The curve is closed. {% endhint %} ## Claim dev fees Every trade on your token's curve pays \*\*0.3%\*\* to you. Fees accrue to the wallet that deployed the token — no configuration needed. The \*\*Fee Vault panel\*\* on the homepage shows your total across all deployed tokens. Hit \*\*CLAIM\*\* to sweep everything in one transaction. {% hint style="warning" %} Fees go to the deployer wallet only. No redirects, no splits. {% endhint %} --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/getting-started.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/for-developers/api.md). # For Developers Trench exposes on-chain interfaces for aggregators, trading terminals, bots, and wallets to interact with the bonding curve directly from Solidity or any EVM library. All interactions go through the \*\*TrenchManager\*\* contract — the single entry point for creating tokens, buying, selling, and querying curve state. | Chain | Contract | Address | | --------------------- | ----------------------- | -------------------------------------------- | | \*\*Ethereum Mainnet\*\* | TrenchManagerV2 (Proxy) | \`0x974B2d86d6353c62f19110127aF1A5df4c6370f0\` | | \*\*MegaETH Mainnet\*\* | TrenchManagerV3 (Proxy) | \`0x2978E15501C792152602eC85c299083aa61b1bd4\` | | \*\*Robinhood Mainnet\*\* | TrenchManager (Proxy) | \`0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d\` | ## Quick start {% tabs %} {% tab title="Ethereum" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManagerV2 { function buy( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline ) external payable returns (uint256 amountOut); } contract SimpleBuyer { ITrenchManagerV2 constant MANAGER = ITrenchManagerV2(0x974B2d86d6353c62f19110127aF1A5df4c6370f0); function buyTokens(address token, uint256 minTokens) external payable { MANAGER.buy{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300 ); } } \`\`\` {% endtab %} {% tab title="MegaETH" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManagerV3 { function buy( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline ) external payable returns (uint256 amountOut); } contract SimpleBuyer { ITrenchManagerV3 constant MANAGER = ITrenchManagerV3(0x2978E15501C792152602eC85c299083aa61b1bd4); function buyTokens(address token, uint256 minTokens) external payable { MANAGER.buy{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300 ); } } \`\`\` {% endtab %} {% tab title="Robinhood" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManager { function buy( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline ) external payable returns (uint256 amountOut); } contract SimpleBuyer { ITrenchManager constant MANAGER = ITrenchManager(0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d); function buyTokens(address token, uint256 minTokens) external payable { MANAGER.buy{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300 ); } } \`\`\` {% endtab %} {% endtabs %} ## In this section \* \[Contract Reference\](/trench-today/for-developers/contracts.md) — addresses, on-chain parameters, full ABI \* \[Integration Guide\](/trench-today/for-developers/integration-guide.md) — core concepts, patterns, security checklist \* \[ABI Files\](/trench-today/for-developers/abi-files.md) — downloadable JSON ABI files ## Support For integration support or API key requests, reach us through the channels listed under \[Resources → Links\](/trench-today/resources/links.md). --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/for-developers/api.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Brand Assets | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/resources/brand-assets.md) . [](https://trench-today.gitbook.io/trench-today/resources/brand-assets#logo-variants) Logo variants -------------------------------------------------------------------------------------------------------- ![Trench logo — black](https://trench-today.gitbook.io/trench-today/~gitbook/image?url=https%3A%2F%2F2106537636-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FRV6mTFBpKrc2LjpD9kzi%252Fuploads%252Fgit-blob-05e58f77f11db0e23b48442ed18f7e0bd75f7762%252Flogo.png%3Falt%3Dmedia&width=768&dpr=3&quality=100&sign=56271618&sv=2) Black 3KB [logo.png](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-05e58f77f11db0e23b48442ed18f7e0bd75f7762%2Flogo.png?alt=media) image Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-05e58f77f11db0e23b48442ed18f7e0bd75f7762%2Flogo.png?alt=media) Trench Logo — Black 3KB [logo-black-transparent.png](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-db5e6cd00744faa4c3d4f3f5c835597145e209f9%2Flogo-black-transparent.png?alt=media) image Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-db5e6cd00744faa4c3d4f3f5c835597145e209f9%2Flogo-black-transparent.png?alt=media) Trench Logo — Black, Alpha Channel 3KB [logo-white-transparent.png](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-02a455743733821f449169c64ee516d556488d21%2Flogo-white-transparent.png?alt=media) image Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-02a455743733821f449169c64ee516d556488d21%2Flogo-white-transparent.png?alt=media) Trench Logo — White, Alpha Channel 3KB [logo-white.png](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-befb917c813df2babec8409176080a71a4b7bb5b%2Flogo-white.png?alt=media) image Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-befb917c813df2babec8409176080a71a4b7bb5b%2Flogo-white.png?alt=media) Trench Logo — White 28KB [banner-logo.svg](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-03b15e7ecb305e13cd8c3809547677fee59a1ac7%2Fbanner-logo.svg?alt=media) image Download[Open](https://2106537636-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRV6mTFBpKrc2LjpD9kzi%2Fuploads%2Fgit-blob-03b15e7ecb305e13cd8c3809547677fee59a1ac7%2Fbanner-logo.svg?alt=media) Trench Banner Logo — SVG [PreviousLinks](https://trench-today.gitbook.io/trench-today/resources/links) Last updated 2 months ago Was this helpful? Was this helpful? --- # Links | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/resources/links.md) . [](https://trench-today.gitbook.io/trench-today/resources/links#official-channels) Official channels --------------------------------------------------------------------------------------------------------- Website GitBook Assistant [trench.today](https://trench.today/) GitBook Assistant X (Twitter) GitBook Assistant [@TrenchToday01](https://x.com/TrenchToday01) GitBook Assistant Telegram GitBook Assistant [@axx\_dot](https://t.me/axx_dot) GitBook Assistant Email GitBook Assistant [service@trench.today](mailto:service@trench.today) GitBook Assistant Only trust the links listed on this page. If someone DMs you a "Trench" link that isn't one of the above, it's a scam. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/resources/links#for-aggregators-and-integrators) For aggregators and integrators ------------------------------------------------------------------------------------------------------------------------------------- Reach out through the official X account or Telegram for API key issuance, partnership discussions, or early access to the OpenAPI spec. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/resources/links#for-traders-and-devs) For traders and devs --------------------------------------------------------------------------------------------------------------- The fastest way to get support is through X or Telegram. General questions are best asked there so the answer is visible to everyone. GitBook Assistant [PreviousABI Files](https://trench-today.gitbook.io/trench-today/for-developers/abi-files) [NextBrand Assets](https://trench-today.gitbook.io/trench-today/resources/brand-assets) Last updated 2 months ago Was this helpful? * [Official channels](https://trench-today.gitbook.io/trench-today/resources/links#official-channels) * [For aggregators and integrators](https://trench-today.gitbook.io/trench-today/resources/links#for-aggregators-and-integrators) * [For traders and devs](https://trench-today.gitbook.io/trench-today/resources/links#for-traders-and-devs) Was this helpful? --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/introduction.md). # Introduction ## What is Trench \*\*Trench\*\* is a meme launchpad on Ethereum, MegaETH, and Robinhood. One transaction to deploy a token. Instant trading on a bonding curve from block zero. Automatic graduation to a DEX — with liquidity permanently secured — the moment the curve fills up. Every token on Trench is: \* \*\*Created in a single transaction.\*\* No presale, no whitelist, no team allocation. \* \*\*Priced by a bonding curve from block one.\*\* The market decides the price, not a deployer. \* \*\*Auto‑graduated to a DEX\*\* once the curve fills up. Liquidity is locked or permanently held by the protocol. \* \*\*Fair‑launched by design.\*\* Every buyer, from the deployer to the last sniper, uses the same curve. {% hint style="success" %} If you've launched a meme token before, you already know how to use Trench. The mechanics are familiar — the chains, the culture, and a few sharper edges are what's new. {% endhint %} ## Who it's for {% tabs %} {% tab title="Devs" %} You have a meme, a mascot, a shitpost, or a brand‑new narrative. You want to deploy it in 30 seconds, earn a cut of every trade for as long as the token lives, and never touch a line of Solidity. → Go to \[Getting Started\](/trench-today/getting-started.md) and launch your first token. {% endtab %} {% tab title="Traders" %} You want to be first. You want to read the curve, not a whitepaper. You want to rotate from one trench to the next without leaving the site. → Go to \[How It Works\](/trench-today/how-it-works.md) to understand what you're buying. {% endtab %} {% tab title="Aggregators & Integrators" %} You run an aggregator, a trading terminal, a bot, or a wallet. You want Trench's order flow inside your product. → Go to \[API Overview\](/trench-today/for-developers/api.md) to plug in. {% endtab %} {% endtabs %} ## Supported chains | Chain | Status | DEX at graduation | | --------------------- | ------ | ----------------- | | \*\*Ethereum Mainnet\*\* | Live | Uniswap V2 | | \*\*MegaETH Mainnet\*\* | Live | Kumbaya V3 | | \*\*Robinhood Mainnet\*\* | Live | Uniswap V3 | ## Why Ethereum The deepest liquidity and the most expensive attention in crypto live here. Meme culture was born on Ethereum — and for years it's been launching everywhere else. What Ethereum has been missing is a \*\*permissionless place where that culture crystallizes into a token in one click\*\*. That's the Trench. Meme season is back on Ethereum, and this time the culture doesn't need to emigrate to launch. Trench is where ETH‑native memes ship from — closer to the money, closer to the history, closer to the scene that started all of this. ## Why MegaETH MegaETH is a real-time EVM chain — sub-millisecond block times, 100k+ TPS, and Ethereum-aligned architecture. For meme trading, speed is everything: price discovery, front-running defense, and user experience all improve when blocks are effectively instant. Trench on MegaETH uses \*\*TrenchManagerV3\*\*, which adds native Kumbaya V3 integration at graduation. The bonding curve mechanics are identical — the execution layer is orders of magnitude faster. ## Why Robinhood Robinhood is an Arbitrum Orbit L2 with native ETH — an Ethereum-aligned execution environment with L2 economics. Trench on Robinhood runs a \*\*single-layer\*\* design: users call one \*\*TrenchManager\*\* contract directly, with no aggregation or vault layer in between, keeping the integration surface small and every trade one hop from the curve. Tokens are priced in native \*\*ETH\*\*, and curves graduate to \*\*Uniswap V3\*\* — with a full-range anchor pool pre-created at launch to lock the graduation price against front-running. ## The thesis in one paragraph Every iconic coin was once a shitpost. Every narrative was once a joke. \*\*Meme culture doesn't come from presales or PowerPoints — it comes from the trench.\*\* Trench is the shortest path between "this is a meme" and "this is tradable." ## What's next \* Read \[How It Works\](/trench-today/how-it-works.md) to understand the bonding curve and fee flow. \* Jump into \[Getting Started\](/trench-today/getting-started.md) if you just want to launch something. \* Aggregators → \[API Overview\](/trench-today/for-developers/api.md). --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/introduction.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # How It Works | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/how-it-works.md) . Every token on Trench follows the same lifecycle: **curve → graduation → DEX**. This page walks through each stage, explains where the price comes from, and traces the fee flow. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/how-it-works#the-two-stage-lifecycle) The two‑stage lifecycle ------------------------------------------------------------------------------------------------------------------ A token on Trench lives two lives. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#stage-1-bonding-curve) Stage 1 · Bonding Curve Only on Trench. Trades price automatically against a constant‑product curve. No order book, no market makers. GitBook Assistant The curve is where a token goes from zero holders to its first few hundred. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#stage-2-dex) Stage 2 · DEX Graduation triggers once the curve fills. Liquidity migrates automatically and the token trades like any other ERC‑20. GitBook Assistant On **Ethereum**, it graduates to **Uniswap V2** with LP permanently burned. On **MegaETH**, it graduates to **Kumbaya V3** with LP held by the protocol. On **Robinhood**, it graduates to **Uniswap V3** with LP held by the protocol. GitBook Assistant From here, Trench steps out of the way. GitBook Assistant The curve is closed the instant a token graduates. All trading moves to the DEX, and every aggregator that indexes it will see the token automatically. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/how-it-works#stage-1-the-bonding-curve) Stage 1 · The bonding curve ------------------------------------------------------------------------------------------------------------------------ ### [](https://trench-today.gitbook.io/trench-today/how-it-works#what-a-bonding-curve-actually-does) What a bonding curve actually does Think of the curve as a **vending machine with a sliding price**: GitBook Assistant * Every token you buy makes the next token slightly more expensive. GitBook Assistant * Every token you sell makes the next token slightly cheaper. GitBook Assistant * Nobody sets the price — it's a pure function of how much has been bought minus sold. GitBook Assistant There's no order book. No market makers. No front‑running your own price discovery. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#the-math-for-the-curious) The math (for the curious) Trench uses the classic **constant‑product formula**: GitBook Assistant x⋅y\=kx \\cdot y = kx⋅y\=k Where `x` is the ETH reserve, `y` is the token reserve, and `k` stays constant. Buying tokens raises `x` and lowers `y` — which means the price `x / y` rises. It's the same math Uniswap V2 uses, tuned for a fair‑launch context. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#starting-parameters) Starting parameters Every token on Trench starts with the same curve shape per chain, so every launch on the same chain is on equal footing. GitBook Assistant Parameter Ethereum Mainnet MegaETH Mainnet Robinhood Mainnet What it means Total supply GitBook Assistant 1,000,000,000 GitBook Assistant 1,000,000,000 GitBook Assistant 1,000,000,000 GitBook Assistant Hard cap. Minted once, at deploy. GitBook Assistant On the curve GitBook Assistant 80% (800 M) GitBook Assistant 80% (800 M) GitBook Assistant 80% (800 M) GitBook Assistant Real tokens sellable through the curve. GitBook Assistant Reserved for DEX GitBook Assistant 20% (200 M) GitBook Assistant 20% (200 M) GitBook Assistant 20% (200 M) GitBook Assistant Set aside to seed the DEX pool at graduation. GitBook Assistant Starting virtual ETH reserve GitBook Assistant ~2.009 ETH GitBook Assistant ~2.027 ETH GitBook Assistant ~1.712 ETH GitBook Assistant The ETH the curve pretends to start with. Shapes price impact. GitBook Assistant **Graduation threshold** GitBook Assistant **~6 ETH** GitBook Assistant **~5.5 ETH** GitBook Assistant **~5 ETH** GitBook Assistant Once this much ETH has been bought into the curve, the token graduates. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/how-it-works#stage-2-graduation) Stage 2 · Graduation ---------------------------------------------------------------------------------------------------------- ### [](https://trench-today.gitbook.io/trench-today/how-it-works#what-graduation-means) What graduation means When enough ETH has been bought into the curve, the token **graduates**. Three things happen in a single atomic sequence: GitBook Assistant 1 #### [](https://trench-today.gitbook.io/trench-today/how-it-works#the-curve-closes) The curve closes No more buys or sells happen on Trench's AMM. The curve contract is frozen. GitBook Assistant 2 #### [](https://trench-today.gitbook.io/trench-today/how-it-works#liquidity-migrates-to-the-dex) Liquidity migrates to the DEX The ETH collected by the curve, together with the **20% of supply** reserved at launch, becomes an LP position on the target DEX. GitBook Assistant 3 #### [](https://trench-today.gitbook.io/trench-today/how-it-works#lp-is-secured) LP is secured On **Ethereum**: LP tokens are burned to a dead address — liquidity is permanently locked forever. GitBook Assistant On **MegaETH**: the LP NFT (Kumbaya V3 full-range position) is sent to the protocol's LP receiver wallet and held by the protocol. GitBook Assistant On **Robinhood**: the LP NFT (Uniswap V3 full-range position) is sent to the protocol's LP receiver wallet and held by the protocol. GitBook Assistant From here, the token trades like any ERC‑20 on the DEX. Price discovery continues, arbitrageurs show up, and the token becomes visible on every aggregator that indexes the pool. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#why-lp-security-matters) Why LP security matters There is **no rug path**. The dev doesn't have the keys to pull liquidity. The platform controls the LP only to hold it — not to drain it. The liquidity belongs to the pool, not to any individual. GitBook Assistant This is the single most important property of a launchpad. Trench treats it as table stakes. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/how-it-works#fees) Fees ---------------------------------------------------------------------------- Trench keeps the fee model simple and transparent on the curve. After graduation, the DEX takes over and Trench steps out entirely. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#on-the-curve) On the curve Every trade pays a flat fee, split between the deployer and the protocol. The exact rate and split depend on the chain: GitBook Assistant Chain Trade fee Dev share Protocol share **Ethereum** GitBook Assistant 1.25% GitBook Assistant 0.3% (24% of fee) GitBook Assistant 0.95% (76% of fee) GitBook Assistant **MegaETH** GitBook Assistant 1.25% GitBook Assistant 0.3% (24% of fee) GitBook Assistant 0.95% (76% of fee) GitBook Assistant **Robinhood** GitBook Assistant 1% GitBook Assistant 0.3% (30% of fee) GitBook Assistant 0.7% (70% of fee) GitBook Assistant No buy tax. No sell tax. No hidden "liquidity fee" coming out of your trade — the trade fee is the whole number. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#at-graduation) At graduation Graduation costs real ETH. Deploying a DEX pool, seeding initial liquidity, and ensuring the migration succeeds all consume gas. A **listing fee** is deducted from the ETH raised by the curve at the moment of migration — this covers graduation expenses and seeds the initial LP. The rate is **8%** on Ethereum and MegaETH, and **2%** on Robinhood. GitBook Assistant The upshot: **no surprise cost after migration**, and no situation where a token gets stuck because graduation couldn't be funded. Every curve that fills up graduates, no friction. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#after-graduation) After graduation On **Ethereum**, Trench collects no fees after graduation — LP tokens are burned, so no one holds an LP position, and pool fees are effectively unclaimable. Trench is out of the picture. GitBook Assistant On **MegaETH**, the Kumbaya V3 LP NFT is held by the protocol's LP receiver wallet. The V3 pool charges a **0.01% fee** on every post-graduation trade, and those fees accrue to the LP position held by the protocol. Trench does not redistribute these fees to token creators or traders. GitBook Assistant On **Robinhood**, dev rewards keep flowing after graduation. The Uniswap V3 LP NFT is held by the **LPFeeSplitter** contract. The V3 pool charges a **1% fee** on every post-graduation trade, and the splitter divides the ETH-side fees **60% to the deployer, 40% to the protocol** (the meme side goes to the protocol). Liquidity still can't be removed — only the swap fees are split. So a Robinhood dev earns twice: the curve fee while trading on Trench, then a share of every DEX swap for the life of the token. (This applies to tokens that graduate after the split went live.) GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/how-it-works#dev-rewards-in-detail) Dev rewards in detail If you launched the token, you earn **0.3% of every trade on its curve** for as long as the curve is live. GitBook Assistant * **Payout:** Fees are paid in ETH to the **deployer wallet**. There's nothing to configure at launch — the wallet that signed the deploy is the wallet that earns. GitBook Assistant * **Where to claim:** The **Fee Vault panel** on the Trench homepage. It's visible to any wallet that has launched at least one token, and it aggregates fees across every token you've ever deployed. GitBook Assistant * **One button, one tx:** Claim sweeps all unclaimed fees across all your tokens in a single transaction. GitBook Assistant * **After graduation:** Curve fees stop for that token. On Ethereum and MegaETH the DEX takes over and Trench collects nothing for the dev. On **Robinhood**, the dev keeps earning **60% of the Uniswap V3 swap fees** via the LPFeeSplitter — claimed separately from the curve fees. GitBook Assistant Dev fees cannot be paid to an X handle, an email, or any off‑chain destination. They always go to the deployer wallet — the one that signed the `launch` transaction. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/how-it-works#next) Next ---------------------------------------------------------------------------- * [**Getting Started**](https://trench-today.gitbook.io/trench-today/getting-started) — launch, trade, claim. GitBook Assistant * [**API Overview**](https://trench-today.gitbook.io/trench-today/for-developers/api) — pull curve state, trades, and token metadata into your product. GitBook Assistant [PreviousGetting Started](https://trench-today.gitbook.io/trench-today/getting-started) [NextFor Developers](https://trench-today.gitbook.io/trench-today/for-developers/api) Last updated 0 minutes ago Was this helpful? * [The two‑stage lifecycle](https://trench-today.gitbook.io/trench-today/how-it-works#the-two-stage-lifecycle) * [Stage 1 · Bonding Curve](https://trench-today.gitbook.io/trench-today/how-it-works#stage-1-bonding-curve) * [Stage 2 · DEX](https://trench-today.gitbook.io/trench-today/how-it-works#stage-2-dex) * [Stage 1 · The bonding curve](https://trench-today.gitbook.io/trench-today/how-it-works#stage-1-the-bonding-curve) * [What a bonding curve actually does](https://trench-today.gitbook.io/trench-today/how-it-works#what-a-bonding-curve-actually-does) * [The math (for the curious)](https://trench-today.gitbook.io/trench-today/how-it-works#the-math-for-the-curious) * [Starting parameters](https://trench-today.gitbook.io/trench-today/how-it-works#starting-parameters) * [Stage 2 · Graduation](https://trench-today.gitbook.io/trench-today/how-it-works#stage-2-graduation) * [What graduation means](https://trench-today.gitbook.io/trench-today/how-it-works#what-graduation-means) * [Why LP security matters](https://trench-today.gitbook.io/trench-today/how-it-works#why-lp-security-matters) * [Fees](https://trench-today.gitbook.io/trench-today/how-it-works#fees) * [On the curve](https://trench-today.gitbook.io/trench-today/how-it-works#on-the-curve) * [At graduation](https://trench-today.gitbook.io/trench-today/how-it-works#at-graduation) * [After graduation](https://trench-today.gitbook.io/trench-today/how-it-works#after-graduation) * [Dev rewards in detail](https://trench-today.gitbook.io/trench-today/how-it-works#dev-rewards-in-detail) * [Next](https://trench-today.gitbook.io/trench-today/how-it-works#next) Was this helpful? --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/readme.md). # Welcome ![Trench Today — Back to meme culture](https://trench-today.gitbook.io/files/RrxaJztYI4HYp5CFYYvM) \> \*\*Back to meme culture. Trench Today.\*\* Memes used to start here. Now they do again. Trench is the ground it grows from — a permissionless launchpad built on the chain where the culture began. Trench Today. {% hint style="info" %} This documentation covers what Trench is, how to use it, the mechanics behind every trade, and the API for third‑party aggregators who want to plug in. {% endhint %} ## Start here | | | | | --- | --- | --- | | **Introduction** | What Trench is and why it exists on Ethereum. | [/pages/GnagHf0VCcnbQbpPuWYg](https://trench-today.gitbook.io/pages/GnagHf0VCcnbQbpPuWYg) | | **Getting Started** | Connect a wallet, launch a token, trade, and claim dev fees. | [/pages/XZplkUjzXnLt7ydUX4gp](https://trench-today.gitbook.io/pages/XZplkUjzXnLt7ydUX4gp) | | **How It Works** | Bonding curve, graduation, fee flow — in plain English. | [/pages/V2Gvjr6c0NwzNz7bE0oN](https://trench-today.gitbook.io/pages/V2Gvjr6c0NwzNz7bE0oN) | | **For Developers** | API reference for aggregators and integrations. | [/pages/xJYMvIjjTQZE2tlRUu8t](https://trench-today.gitbook.io/pages/xJYMvIjjTQZE2tlRUu8t) | \--- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/readme.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Integration Guide | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide.md) . [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#core-concepts) Core Concepts ------------------------------------------------------------------------------------------------------------------ ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#bonding-curve-mechanism) Bonding Curve Mechanism Trench uses a **constant-product bonding curve** (xy=k) with virtual reserves: GitBook Assistant * **Virtual Reserves**: Initial liquidity used for price calculation GitBook Assistant * **Real Reserves**: Actual ETH and tokens held by the curve GitBook Assistant * **Formula**: `virtualNative × virtualToken = k` (constant) GitBook Assistant **Key Parameters by chain**: GitBook Assistant Ethereum MegaETH Robinhood GitBook AssistantAskCopy virtualNative: ~2.009 ETH (2009158000000000000 wei) virtualToken: ~1.068e27 (1068000000000000000000000000 wei) targetToken: 200,000,000 tokens (20% of total supply) totalSupply: 1,000,000,000 tokens (1e27 wei) graduation: ~6 ETH gross spend GitBook AssistantAskCopy virtualNative: ~2.027 ETH (2026585820895522388 wei) virtualToken: ~1.099e27 (1098507462686567164179104478 wei) targetToken: 200,000,000 tokens (20% of total supply) totalSupply: 1,000,000,000 tokens (1e27 wei) graduation: ~5.5 ETH gross spend GitBook AssistantAskCopy virtualQuote: ~1.712 ETH (1712328767123287671 wei) virtualToken: ~1.074e27 (1073972602739726027397260274 wei) targetToken: 200,000,000 tokens (20% of total supply) totalSupply: 1,000,000,000 tokens (1e27 wei) graduation: ~5 ETH gross spend Robinhood reserves are named `Quote` (not `Native`) because the curve is quote-denominated. Native ETH is the live quote token. GitBook Assistant **Price Evolution**: GitBook Assistant * Initial price is determined by virtual reserves GitBook Assistant * As users buy: ETH reserves ↑, token reserves ↓ → price increases GitBook Assistant * As users sell: ETH reserves ↓, token reserves ↑ → price decreases GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#token-lifecycle) Token Lifecycle Ethereum MegaETH Robinhood Stage Condition Transfer Mode Created GitBook Assistant Token deployed GitBook Assistant `MODE_TRANSFER_CONTROLLED` (2) — only TrenchManager GitBook Assistant Trading GitBook Assistant Buying/selling active GitBook Assistant `MODE_TRANSFER_CONTROLLED` (2) GitBook Assistant Migrating GitBook Assistant 200M tokens sold GitBook Assistant `MODE_TRANSFER_CONTROLLED` (2) GitBook Assistant Listed GitBook Assistant Migrated to Uniswap V2 GitBook Assistant `MODE_NORMAL` (0) — free transfers GitBook Assistant Stage Condition Transfer Mode Created GitBook Assistant Token deployed GitBook Assistant `MODE_TRANSFER_CONTROLLED` (2) — only TrenchManager GitBook Assistant Trading GitBook Assistant Buying/selling active GitBook Assistant `MODE_TRANSFER_CONTROLLED` (2) GitBook Assistant Migrating GitBook Assistant 200M tokens sold GitBook Assistant `MODE_TRANSFER_CONTROLLED` (2) GitBook Assistant Listed GitBook Assistant Migrated to Kumbaya V3 GitBook Assistant `MODE_NORMAL` (0) — free transfers GitBook Assistant Stage Condition Transfer Mode Created GitBook Assistant Token deployed GitBook Assistant `restricted` (1) — only via TrenchManager GitBook Assistant Trading GitBook Assistant Buying/selling active GitBook Assistant `restricted` (1) GitBook Assistant Migrating GitBook Assistant 200M tokens sold GitBook Assistant `restricted` (1) GitBook Assistant Listed GitBook Assistant Migrated to Uniswap V3 GitBook Assistant `free` (0) — free transfers GitBook Assistant Robinhood tokens use a **two-state** mode (`0 = free`, `1 = restricted`) rather than MegaETH/Ethereum's three-state model. A restricted transfer reverts with `"Token: restricted"`. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#fee-model) Fee Model **Protocol fee (fixed)**: 1.25% on every trade. Split 24% to token creator, 76% to protocol. GitBook Assistant **Platform fee (optional)**: Available via `buyWithFee` / `sellWithFee`. Up to 5%. Paid to an address you specify. GitBook Assistant **Buy flow**: GitBook Assistant **Sell flow**: GitBook Assistant The fee denominator differs by chain: Ethereum and Robinhood use `10,000`; MegaETH uses `1,000,000,000` (1e9). A 0.5% platform fee is `50` on Ethereum/Robinhood and `5,000,000` on MegaETH. On Robinhood the protocol trade fee is **1%** (not 1.25%) and the platform-fee parameter is named `extraFeeRate` / `extraFeeReceiver`. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#math-model) Math Model The bonding curve uses the **constant-product** formula: GitBook Assistant **Buy** — purchasing with `amountIn` ETH: GitBook Assistant **Sell** — selling `amountIn` tokens: GitBook Assistant **Current price** (ETH per token): GitBook Assistant * * * [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#integration-patterns) Integration Patterns -------------------------------------------------------------------------------------------------------------------------------- ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#simple-buy-sell) Simple Buy/Sell Ethereum MegaETH Robinhood Robinhood quotes buys with `previewBuy(token, amountIn) → (amountOut, fee)` — a two-return helper — rather than MegaETH/Ethereum's `quoteBuyWithFee`. Tokens are quoted in native ETH, funded via `msg.value`. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#platform-fee-integration) Platform Fee Integration Collect a fee on every trade routed through your platform. GitBook Assistant Ethereum MegaETH Robinhood Fee breakdown for a 1 ETH buy with 0.5% platform fee: GitBook Assistant Fee breakdown for a 1 ETH buy with 0.5% platform fee: GitBook Assistant Fee breakdown for a 1 ETH buy with 0.5% extra fee (Robinhood protocol fee is **1%**): GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#batch-price-query) Batch Price Query Deploy this with the appropriate `TrenchManager` address for the chain you're targeting. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#event-monitoring-off-chain) Event Monitoring (Off-Chain) Ethereum MegaETH Robinhood Robinhood event names and fields differ: the price event is `Sync` (capital S) with `Quote`\-named reserves, `TokenCreate` carries an extra `quote` field, and graduation emits `Listing` (Uniswap V3) rather than `V3Listing`. GitBook Assistant * * * [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#security-checklist) Security Checklist ---------------------------------------------------------------------------------------------------------------------------- ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#slippage-protection) Slippage protection Always set `amountOutMin`. Quote first, then apply tolerance. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#deadline) Deadline Always set a deadline. `0` means no expiry — a stuck transaction could execute at an unexpected price. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#gwei-alignment-sell-only-ethereum-and-megaeth) Gwei alignment (sell only — Ethereum & MegaETH) On Ethereum and MegaETH, sell `amountIn` must satisfy `amountIn % 1e9 == 0`. Round down before selling. Robinhood has no such requirement. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#approval-management) Approval management Approve the exact amount, not `type(uint256).max`. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#migration-check) Migration check After migration, the bonding curve is closed. Check before acting. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#token-mode) Token mode Pre-graduation tokens cannot be moved directly between EOAs — only TrenchManager can. Do not attempt direct transfers before graduation. The mode encoding differs by chain: Ethereum/MegaETH use `MODE_TRANSFER_CONTROLLED` (2); Robinhood uses `restricted` (1) and reverts with `"Token: restricted"`. GitBook Assistant * * * [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#gas-estimates) Gas Estimates ------------------------------------------------------------------------------------------------------------------ Operation Gas ETH at 20 Gwei `createCurve` GitBook Assistant ~500k GitBook Assistant ~0.010 ETH GitBook Assistant `buy` GitBook Assistant ~150k GitBook Assistant ~0.003 ETH GitBook Assistant `buyWithFee` GitBook Assistant ~180k GitBook Assistant ~0.0036 ETH GitBook Assistant `sell` GitBook Assistant ~120k GitBook Assistant ~0.0024 ETH GitBook Assistant `sellWithFee` GitBook Assistant ~150k GitBook Assistant ~0.003 ETH GitBook Assistant `quoteBuyWithFee` / `previewBuy` GitBook Assistant ~50k GitBook Assistant free (view) GitBook Assistant _Estimates vary with network conditions and token state. On MegaETH, gas costs are significantly lower due to the chain's architecture. Robinhood is an Arbitrum Orbit L2 — gas is priced in ETH and typically far below Ethereum mainnet._ GitBook Assistant * * * [](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#faq) FAQ ---------------------------------------------------------------------------------------------- **Can I buy directly from the BondingCurve contract?** No. All trades must go through TrenchManager (V2 on Ethereum, V3 on MegaETH, the single `TrenchManager` on Robinhood). GitBook Assistant **What happens if I send ETH directly to TrenchManager?** It will revert. ETH must arrive via `buy()` or `buyWithFee()`. GitBook Assistant **How is Robinhood different from the other chains?** Robinhood is a single-layer launchpad — users call `TrenchManager` directly, with no aggregation or vault layer. Tokens are quoted in native ETH; curve reserves are named `Quote` rather than `Native`, and factory reads take a `quote` argument (`getConfig(quote)` — pass `address(0)` for ETH). The protocol trade fee is **1%** (dev 30% / protocol 70%), the listing fee is **2%**, buy quoting uses `previewBuy`, and there is no Gwei-alignment requirement on sells. GitBook Assistant **Can I remove liquidity after graduation?** On Ethereum: no — LP tokens are burned to `address(0)`, liquidity is permanently locked, and no one collects LP fees. On MegaETH: the LP NFT (Kumbaya V3 full-range position) is held by the protocol's LP receiver wallet. Liquidity cannot be removed by token creators or traders. The Kumbaya V3 pool charges a **0.01% fee** on every post-graduation swap; those fees accrue to the LP position held by the protocol. On Robinhood: graduation creates a Uniswap V3 full-range position (fee tier **1%**) whose LP NFT is held by the **LPFeeSplitter** contract; liquidity cannot be removed by creators or traders, but the pool's swap fees are split (see below). GitBook Assistant **Do devs earn after graduation on Robinhood?** Yes. Unlike the other chains, Robinhood shares the post-graduation Uniswap V3 swap fees. The graduation LP NFT mints to the **LPFeeSplitter** (`0x74a40b65320c717F0ECF74f68CcB910edCd08e22`), which splits the quote-side (ETH) fees **dev 60% / protocol 40%** (ratio in `devShareBps`, currently `6000`). This is separate from the on-curve `FeeVault` (dev 30% of the 1% trade fee). A creator claims with `LPFeeSplitter.claim(creator)` — one tx, no approval, WETH auto-unwrapped to ETH. To estimate claimable, read `creatorCredits(creator, address(0))` and add uncollected pending × `devShareBps`. Only tokens that graduate after this mechanism went live are covered. GitBook Assistant **Why does sell require Gwei alignment?** Internal precision requirement on Ethereum and MegaETH. Round down: `(amount / 1e9) * 1e9`. Robinhood has no such requirement. GitBook Assistant **What is the maximum platform fee?** 5% on all chains. Exceeding it reverts with `ERR_BUY_FEE_RATE` / `ERR_SELL_FEE_RATE` (Ethereum/MegaETH), or the `extraFeeRate` bound on Robinhood. GitBook Assistant **How do I detect when a token graduates?** Listen for the `LimitReach` event, or poll `IBondingCurve(curve).migrating()`. On MegaETH, listen for `V3Listing`; on Robinhood, listen for `Listing` to confirm migration to Uniswap V3 is complete. GitBook Assistant **What DEX does graduation target?** Ethereum → Uniswap V2. MegaETH → Kumbaya V3 (full-range position, fee tier 0.01%). Robinhood → Uniswap V3 (full-range position, fee tier 1%). GitBook Assistant [PreviousContract Reference](https://trench-today.gitbook.io/trench-today/for-developers/contracts) [NextABI Files](https://trench-today.gitbook.io/trench-today/for-developers/abi-files) Last updated 22 minutes ago Was this helpful? * [Core Concepts](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#core-concepts) * [Bonding Curve Mechanism](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#bonding-curve-mechanism) * [Token Lifecycle](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#token-lifecycle) * [Fee Model](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#fee-model) * [Math Model](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#math-model) * [Integration Patterns](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#integration-patterns) * [Simple Buy/Sell](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#simple-buy-sell) * [Platform Fee Integration](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#platform-fee-integration) * [Batch Price Query](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#batch-price-query) * [Event Monitoring (Off-Chain)](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#event-monitoring-off-chain) * [Security Checklist](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#security-checklist) * [Slippage protection](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#slippage-protection) * [Deadline](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#deadline) * [Gwei alignment (sell only — Ethereum & MegaETH)](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#gwei-alignment-sell-only-ethereum-and-megaeth) * [Approval management](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#approval-management) * [Migration check](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#migration-check) * [Token mode](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#token-mode) * [Gas Estimates](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#gas-estimates) * [FAQ](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide#faq) Was this helpful? GitBook AssistantAskCopy Created → Trading (Bonding Curve) → Migrating (Target Reached) → Listed (Uniswap V2) GitBook AssistantAskCopy Created → Trading (Bonding Curve) → Migrating (Target Reached) → Listed (Kumbaya V3) GitBook AssistantAskCopy Created → Trading (Bonding Curve) → Migrating (Target Reached) → Listed (Uniswap V3) GitBook AssistantAskCopy Platform fee = amountIn × buyFeeRate / feeDenominator → buyFeeReceiver Protocol fee = (amountIn − platform fee) × 1.25% → FeeVault Curve input = amountIn − platform fee − protocol fee GitBook AssistantAskCopy Curve output = calculated from bonding curve Protocol fee = curve output × 1.25% → FeeVault Platform fee = curve output × sellFeeRate / feeDenominator → sellFeeReceiver User receives = curve output − protocol fee − platform fee GitBook AssistantAskCopy k = virtualNative × virtualToken (constant) GitBook AssistantAskCopy newReserveIn = virtualNative + amountIn newReserveOut = ceil(k / newReserveIn) amountOut = virtualToken − newReserveOut GitBook AssistantAskCopy newReserveOut = virtualToken + amountIn newReserveIn = ceil(k / newReserveOut) amountOut = virtualNative − newReserveIn GitBook AssistantAskCopy price = virtualNative / virtualToken GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } interface ITrenchManagerV2 { function buy(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external payable returns (uint256); function sell(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external returns (uint256); function quoteBuyWithFee(uint256 amountIn, address token, uint256 buyFeeRate) external view returns (uint256, uint256, uint256, uint256, uint256, uint256); } contract SimpleTradingBot { ITrenchManagerV2 constant MANAGER = ITrenchManagerV2(0x974B2d86d6353c62f19110127aF1A5df4c6370f0); function buyWithSlippage(address token, uint256 ethAmount) external payable { require(msg.value == ethAmount, "ETH mismatch"); (uint256 expectedTokens, , , , ,) = MANAGER.quoteBuyWithFee(ethAmount, token, 0); uint256 minTokens = expectedTokens * 99 / 100; // 1% slippage MANAGER.buy{value: ethAmount}( ethAmount, minTokens, token, msg.sender, block.timestamp + 300 ); } function sellWithSlippage(address token, uint256 tokenAmount) external { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); MANAGER.sell( tokenAmount, 0, // set proper minOut in production token, msg.sender, block.timestamp + 300 ); } } GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } interface ITrenchManagerV3 { function buy(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external payable returns (uint256); function sell(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external returns (uint256); function quoteBuyWithFee(uint256 amountIn, address token, uint256 buyFeeRate) external view returns (uint256, uint256, uint256, uint256, uint256, uint256); } contract SimpleTradingBot { ITrenchManagerV3 constant MANAGER = ITrenchManagerV3(0x2978E15501C792152602eC85c299083aa61b1bd4); function buyWithSlippage(address token, uint256 ethAmount) external payable { require(msg.value == ethAmount, "ETH mismatch"); (uint256 expectedTokens, , , , ,) = MANAGER.quoteBuyWithFee(ethAmount, token, 0); uint256 minTokens = expectedTokens * 99 / 100; // 1% slippage MANAGER.buy{value: ethAmount}( ethAmount, minTokens, token, msg.sender, block.timestamp + 300 ); } function sellWithSlippage(address token, uint256 tokenAmount) external { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); MANAGER.sell( tokenAmount, 0, // set proper minOut in production token, msg.sender, block.timestamp + 300 ); } } GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } interface ITrenchManager { function buy(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external payable returns (uint256); function sell(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external returns (uint256); function previewBuy(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 fee); } contract SimpleTradingBot { // Robinhood uses a single TrenchManager (no V2/V3 suffix) ITrenchManager constant MANAGER = ITrenchManager(0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d); function buyWithSlippage(address token, uint256 ethAmount) external payable { require(msg.value == ethAmount, "ETH mismatch"); (uint256 expectedTokens, ) = MANAGER.previewBuy(token, ethAmount); uint256 minTokens = expectedTokens * 99 / 100; // 1% slippage MANAGER.buy{value: ethAmount}( ethAmount, minTokens, token, msg.sender, block.timestamp + 300 ); } function sellWithSlippage(address token, uint256 tokenAmount) external { // meme token is `restricted` pre-graduation — must approve MANAGER and route through sell() IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); MANAGER.sell( tokenAmount, 0, // set proper minOut in production token, msg.sender, block.timestamp + 300 ); } } GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManagerV2 { function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 buyFeeRate, address buyFeeReceiver ) external payable returns (uint256); function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 sellFeeRate, address sellFeeReceiver ) external returns (uint256); } contract PlatformIntegration { ITrenchManagerV2 constant MANAGER = ITrenchManagerV2(0x974B2d86d6353c62f19110127aF1A5df4c6370f0); address public platformTreasury; uint256 public constant PLATFORM_FEE_RATE = 50; // 0.5% (50/10000) constructor(address _treasury) { platformTreasury = _treasury; } function platformBuy(address token, uint256 minTokens) external payable returns (uint256) { return MANAGER.buyWithFee{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300, PLATFORM_FEE_RATE, platformTreasury ); } function platformSell(address token, uint256 tokenAmount, uint256 minETH) external returns (uint256) { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); return MANAGER.sellWithFee( tokenAmount, minETH, token, msg.sender, block.timestamp + 300, PLATFORM_FEE_RATE, platformTreasury ); } } GitBook AssistantAskCopy Platform fee (0.5%): 0.005 ETH → platformTreasury Protocol fee: 0.012 ETH → FeeVault (1.25% of 0.995 ETH) Curve input: 0.983 ETH → BondingCurve GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManagerV3 { function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 buyFeeRate, address buyFeeReceiver ) external payable returns (uint256); function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 sellFeeRate, address sellFeeReceiver ) external returns (uint256); } contract PlatformIntegration { ITrenchManagerV3 constant MANAGER = ITrenchManagerV3(0x2978E15501C792152602eC85c299083aa61b1bd4); address public platformTreasury; // MegaETH fee denominator is 1e9; 0.5% = 5,000,000 uint256 public constant PLATFORM_FEE_RATE = 5_000_000; constructor(address _treasury) { platformTreasury = _treasury; } function platformBuy(address token, uint256 minTokens) external payable returns (uint256) { return MANAGER.buyWithFee{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300, PLATFORM_FEE_RATE, platformTreasury ); } function platformSell(address token, uint256 tokenAmount, uint256 minETH) external returns (uint256) { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); return MANAGER.sellWithFee( tokenAmount, minETH, token, msg.sender, block.timestamp + 300, PLATFORM_FEE_RATE, platformTreasury ); } } GitBook AssistantAskCopy Platform fee (0.5%): 0.005 ETH → platformTreasury Protocol fee: 0.012 ETH → FeeVault (1.25% of 0.995 ETH) Curve input: 0.983 ETH → BondingCurve GitBook AssistantAskCopy // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManager { function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 extraFeeRate, address extraFeeReceiver ) external payable returns (uint256); function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 extraFeeRate, address extraFeeReceiver ) external returns (uint256); } contract PlatformIntegration { ITrenchManager constant MANAGER = ITrenchManager(0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d); address public platformTreasury; // Robinhood fee denominator is 10,000; 0.5% = 50 (max 500 = 5%) uint256 public constant PLATFORM_FEE_RATE = 50; constructor(address _treasury) { platformTreasury = _treasury; } function platformBuy(address token, uint256 minTokens) external payable returns (uint256) { return MANAGER.buyWithFee{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300, PLATFORM_FEE_RATE, platformTreasury ); } function platformSell(address token, uint256 tokenAmount, uint256 minETH) external returns (uint256) { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); return MANAGER.sellWithFee( tokenAmount, minETH, token, msg.sender, block.timestamp + 300, PLATFORM_FEE_RATE, platformTreasury ); } } GitBook AssistantAskCopy Extra fee (0.5%): 0.005 ETH → platformTreasury Protocol fee: 0.00995 ETH → FeeVault (1% of 0.995 ETH) Curve input: 0.98505 ETH → BondingCurve GitBook AssistantAskCopy interface IBondingCurve { function getVirtualReserves() external view returns (uint256, uint256); function realNativeReserves() external view returns (uint256); function realTokenReserves() external view returns (uint256); function migrating() external view returns (bool); } interface ITrenchManager { function curves(address token) external view returns (address); } contract PriceAggregator { ITrenchManager public immutable manager; constructor(address _manager) { manager = ITrenchManager(_manager); } struct TokenPrice { address token; uint256 pricePerToken; // wei per token (1e18 = 1 ETH/token) uint256 realNative; uint256 realToken; uint256 virtualNative; uint256 virtualToken; bool migrating; } function getBatchPrices(address[] calldata tokens) external view returns (TokenPrice[] memory prices) { prices = new TokenPrice[](tokens.length); for (uint256 i = 0; i < tokens.length; i++) { address curveAddr = manager.curves(tokens[i]); if (curveAddr == address(0)) continue; IBondingCurve curve = IBondingCurve(curveAddr); (uint256 vNative, uint256 vToken) = curve.getVirtualReserves(); prices[i] = TokenPrice({ token: tokens[i], pricePerToken: (vNative * 1e18) / vToken, realNative: curve.realNativeReserves(), realToken: curve.realTokenReserves(), virtualNative: vNative, virtualToken: vToken, migrating: curve.migrating() }); } } } GitBook AssistantAskCopy const { ethers } = require("ethers"); const MANAGER_ADDRESS = "0x974B2d86d6353c62f19110127aF1A5df4c6370f0"; const manager = new ethers.Contract(MANAGER_ADDRESS, ABI, provider); // New token launches manager.on("TokenCreate", (creator, curve, token, name, symbol) => { console.log(`New token: ${name} (${symbol}) at ${token}`); }); // Migration target reached manager.on("LimitReach", (token) => { console.log(`${token} ready for Uniswap V2 migration`); }); // Real-time price from sync events manager.on("sync", (token, realNative, realToken, virtualNative, virtualToken) => { const price = (BigInt(virtualNative) * BigInt(1e18)) / BigInt(virtualToken); console.log(`Price update for ${token}: ${ethers.formatEther(price)} ETH/token`); }); // Query historical events const currentBlock = await provider.getBlockNumber(); const events = await manager.queryFilter( manager.filters.TokenCreate(), currentBlock - 7200, // ~24 hours currentBlock ); GitBook AssistantAskCopy const { ethers } = require("ethers"); const MANAGER_ADDRESS = "0x2978E15501C792152602eC85c299083aa61b1bd4"; const RPC_URL = "https://mainnet.megaeth.com/rpc"; const provider = new ethers.JsonRpcProvider(RPC_URL); const manager = new ethers.Contract(MANAGER_ADDRESS, ABI, provider); // New token launches manager.on("TokenCreate", (creator, curve, token, name, symbol, launchTime, tokenURI) => { console.log(`New token: ${name} (${symbol}) at ${token}`); }); // Migration target reached manager.on("LimitReach", (token) => { console.log(`${token} ready for Kumbaya V3 migration`); }); // Full migration complete (V3) manager.on("V3Listing", (curve, token, pool, tokenId) => { console.log(`${token} migrated to Kumbaya V3 pool ${pool}`); }); // Real-time price from sync events manager.on("sync", (token, realNative, realToken, virtualNative, virtualToken) => { const price = (BigInt(virtualNative) * BigInt(1e18)) / BigInt(virtualToken); console.log(`Price update for ${token}: ${ethers.formatEther(price)} ETH/token`); }); GitBook AssistantAskCopy const { ethers } = require("ethers"); const MANAGER_ADDRESS = "0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d"; const provider = new ethers.JsonRpcProvider(RPC_URL); // request RPC from the team const manager = new ethers.Contract(MANAGER_ADDRESS, ABI, provider); // New token launches — note the `quote` field (address(0) = ETH) manager.on("TokenCreate", (creator, curve, token, quote, name, symbol, timestamp, tokenURI) => { console.log(`New token: ${name} (${symbol}) at ${token}, quote ${quote}`); }); // Migration target reached manager.on("LimitReach", (token) => { console.log(`${token} ready for Uniswap V3 migration`); }); // Migration to Uniswap V3 complete manager.on("Listing", (curve, token, pool, tokenId, liquidity) => { console.log(`${token} migrated to Uniswap V3 pool ${pool}`); }); // Real-time price from Sync events (capital S; quote-denominated reserves) manager.on("Sync", (token, realQuote, realToken, virtualQuote, virtualToken) => { // reserves are in ETH wei (18 decimals) const price = (BigInt(virtualQuote) * BigInt(1e18)) / BigInt(virtualToken); console.log(`Price update for ${token}: ${ethers.formatEther(price)} ETH/token`); }); GitBook AssistantAskCopy (uint256 expected, , , , ,) = manager.quoteBuyWithFee(amountIn, token, feeRate); uint256 minOut = expected * 99 / 100; // 1% tolerance manager.buy{value: amountIn}(amountIn, minOut, token, msg.sender, deadline); GitBook AssistantAskCopy block.timestamp + 300 // 5-minute deadline GitBook AssistantAskCopy uint256 aligned = (amount / 1e9) * 1e9; GitBook AssistantAskCopy IERC20(token).approve(address(MANAGER), amountToSell); GitBook AssistantAskCopy address curve = manager.curves(token); require(!IBondingCurve(curve).migrated(), "Token already graduated"); --- # Contract Reference | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/for-developers/contracts.md) . Ethereum Mainnet MegaETH Mainnet Robinhood Mainnet [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#deployments) Deployments ------------------------------------------------------------------------------------------------------ Contract Address **TrenchManagerV2** (Proxy) GitBook Assistant `0x974B2d86d6353c62f19110127aF1A5df4c6370f0` GitBook Assistant **FeeVault** GitBook Assistant `0x18D9Ddd296b676d68e6658BcC6Dcdb6C23C28457` GitBook Assistant **BondingCurveFactory** GitBook Assistant `0x02acb27BD38AB7aE4b569bA7251Ff31739Bd8E36` GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#on-chain-parameters) On-chain parameters ---------------------------------------------------------------------------------------------------------------------- Parameter Value Description Trade fee GitBook Assistant 1.25% (`12,500,000 / 1e9`) GitBook Assistant Applied to `amountIn` on every buy and sell. GitBook Assistant Creator share GitBook Assistant 24% of trade fee GitBook Assistant ≈ 0.3% of trade size. Accrues in FeeVault. GitBook Assistant Protocol share GitBook Assistant 76% of trade fee GitBook Assistant ≈ 0.95% of trade size. GitBook Assistant `virtualNative` GitBook Assistant `2009158000000000000` (~2.009 ETH) GitBook Assistant Starting virtual ETH reserve. GitBook Assistant `virtualToken` GitBook Assistant `1068000000000000000000000000` (~1.068 × 10²⁷) GitBook Assistant Starting virtual token reserve. GitBook Assistant Total supply GitBook Assistant `1000000000000000000000000000` (1 × 10²⁷, 1 billion tokens) GitBook Assistant Fixed, minted at deploy. GitBook Assistant Graduation threshold (`targetToken`) GitBook Assistant `200000000000000000000000000` (2 × 10²⁶, 200 M tokens) GitBook Assistant Migration triggers when real token reserves drop to this level. GitBook Assistant Max platform fee GitBook Assistant 5% (`500 / 10,000`) GitBook Assistant Max rate for `buyWithFee` / `sellWithFee`. GitBook Assistant Minimum claim GitBook Assistant 0.01 ETH GitBook Assistant Below this, `devClaim` is rejected. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trenchmanagerv2-abi) TrenchManagerV2 ABI ---------------------------------------------------------------------------------------------------------------------- ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trading-functions) Trading functions #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#createcurve) `createCurve` Deploy a new token and bonding curve. `msg.value` = `amountIn` (the initial dev buy, or 0). GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#buy) `buy` Buy tokens with ETH. No platform fee. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#buywithfee) `buyWithFee` Buy tokens with an additional platform fee (up to 5%). GitBook Assistant Fee flow: GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#sell) `sell` Sell tokens for ETH. No platform fee. Requires prior `ERC20.approve`. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#sellwithfee) `sellWithFee` Sell tokens with an additional platform fee (up to 5%). GitBook Assistant Fee flow: GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#quote-functions) Quote functions #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#quotebuywithfee) `quoteBuyWithFee` Estimate output and fee breakdown for a buy without sending a transaction. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#quotesellwithfee) `quoteSellWithFee` Estimate output and fee breakdown for a sell without sending a transaction. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#mapping-queries) Mapping queries [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ibondingcurve-abi) IBondingCurve ABI ------------------------------------------------------------------------------------------------------------------ One `BondingCurve` contract is deployed per token. Query it for reserves and graduation status. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ibondingcurvefactory-abi) IBondingCurveFactory ABI -------------------------------------------------------------------------------------------------------------------------------- [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#itoken-erc-20) IToken (ERC-20) ------------------------------------------------------------------------------------------------------------ Standard ERC-20 plus a `mode` field that controls transfer permissions before graduation. GitBook Assistant Mode Value Who can transfer `MODE_NORMAL` GitBook Assistant `0` GitBook Assistant Anyone (post-graduation) GitBook Assistant `MODE_TRANSFER_RESTRICTED` GitBook Assistant `1` GitBook Assistant No one (reserved) GitBook Assistant `MODE_TRANSFER_CONTROLLED` GitBook Assistant `2` GitBook Assistant Only TrenchManager (pre-graduation) GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#events) Events -------------------------------------------------------------------------------------------- Event Emitted when Key fields `TokenCreate` GitBook Assistant New token deployed GitBook Assistant `creator, curve, token, name, symbol, launchTime, tokenURI` GitBook Assistant `TokenPurchase` GitBook Assistant Buy executed GitBook Assistant `token, account, amountToken, amountQuote, protocolFee, buyFee, buyFeeReceiver, buyFeeRate` GitBook Assistant `TokenSale` GitBook Assistant Sell executed GitBook Assistant `token, account, amountToken, amountQuote, protocolFee, sellFee, sellFeeReceiver` GitBook Assistant `LimitReach` GitBook Assistant Graduation threshold hit GitBook Assistant `token` (indexed) GitBook Assistant `Listing` GitBook Assistant Migrated to Uniswap V2 GitBook Assistant `curve, token, pair` (all indexed), `listingWNativeAmount, listingTokenAmount, burnLiquidity` GitBook Assistant `sync` GitBook Assistant Reserves updated (every trade) GitBook Assistant `token, realNativeReserves, realTokenReserves, virtualNativeReserve, virtualTokenReserve` GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#error-codes) Error codes ------------------------------------------------------------------------------------------------------ ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trenchmanagerv2) TrenchManagerV2 Error Description `ERR_CORE_EXPIRED` GitBook Assistant Transaction deadline passed GitBook Assistant `ERR_CORE_INVALID_AMOUNT_IN` GitBook Assistant `msg.value` doesn't match `amountIn` GitBook Assistant `ERR_CORE_INVALID_AMOUNT_OUT` GitBook Assistant Output below `amountOutMin` (slippage) GitBook Assistant `ERR_CORE_CURVE_NOT_FOUND` GitBook Assistant Token has no bonding curve GitBook Assistant `ERR_CORE_CURVE_ALREADY_MIGRATED` GitBook Assistant Token already graduated GitBook Assistant `ERR_CORE_INVALID_FEE` GitBook Assistant Fee rate exceeds 5% maximum GitBook Assistant `ERR_CORE_GWEI` GitBook Assistant Sell `amountIn` not Gwei-aligned GitBook Assistant `ERR_BUY_FEE_RATE` GitBook Assistant `buyFeeRate` > 500 GitBook Assistant `ERR_BUY_FEE_RECEIVER` GitBook Assistant `buyFeeReceiver` is `address(0)` GitBook Assistant `ERR_SELL_FEE_RATE` GitBook Assistant `sellFeeRate` > 500 GitBook Assistant `ERR_SELL_FEE_RECEIVER` GitBook Assistant `sellFeeReceiver` is `address(0)` GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#bondingcurve) BondingCurve Error Description `ERR_BONDING_CURVE_NOT_TRADABLE` GitBook Assistant Curve is migrating or migrated GitBook Assistant `ERR_BONDING_CURVE_OVERFLOW_TARGET` GitBook Assistant Purchase would exceed graduation threshold GitBook Assistant `ERR_BONDING_CURVE_INSUFFICIENT_RESERVE` GitBook Assistant Insufficient reserves for sell GitBook Assistant `ERR_BONDING_CURVE_LIBRARY_INSUFFICIENT_LIQUIDITY` GitBook Assistant Trade size exceeds available liquidity GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#token) Token Error Description `ERR_TOKEN_TRANSFER_RESTRICTED` GitBook Assistant Direct transfer attempted in `MODE_TRANSFER_CONTROLLED` GitBook Assistant `ERR_TOKEN_INVALID_TRANSFER` GitBook Assistant Invalid transfer parameters GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#network-info) Network info -------------------------------------------------------------------------------------------------------- Chain ID GitBook Assistant `4326` GitBook Assistant RPC GitBook Assistant `https://mainnet.megaeth.com/rpc` GitBook Assistant Explorer GitBook Assistant `https://megaexplorer.xyz` GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#deployments-1) Deployments -------------------------------------------------------------------------------------------------------- Contract Address Description **TrenchManagerV3** (Proxy) GitBook Assistant `0x2978E15501C792152602eC85c299083aa61b1bd4` GitBook Assistant Main entry point for all interactions GitBook Assistant ProxyAdmin GitBook Assistant `0xbB9DBc3028D2318eC7D0Ada935711042A9ea69C2` GitBook Assistant Proxy admin contract GitBook Assistant TrenchManagerV3 Impl GitBook Assistant `0x95CCeBaf5C664E18cB569386Bf38a3771a804943` GitBook Assistant Current implementation GitBook Assistant BondingCurveFactory GitBook Assistant `0xA25890Dd71eF04955baF57F93D27380d1e235f8A` GitBook Assistant Curve and token factory GitBook Assistant FeeVault GitBook Assistant `0x6adaC2FC414032f49BC7C4B9F2C5EA7B2D4dd4AD` GitBook Assistant Protocol fee collection and distribution GitBook Assistant WETH (WNative) GitBook Assistant `0x4200000000000000000000000000000000000006` GitBook Assistant Wrapped ETH GitBook Assistant Kumbaya V3 Position Manager GitBook Assistant `0x2b781C57e6358f64864Ff8EC464a03Fdaf9974bA` GitBook Assistant V3 LP position NFT manager (graduation target) GitBook Assistant **Admin addresses**: GitBook Assistant Role Address Owner GitBook Assistant `0xbeb76A70c82B09E30B2008eAFa7F987987EC9e0b` GitBook Assistant Migrator GitBook Assistant `0xfB771beb315D7d6512b414496D012d3B084B17bF` GitBook Assistant LP Receiver GitBook Assistant `0xfB771beb315D7d6512b414496D012d3B084B17bF` GitBook Assistant Listing Fee Receiver GitBook Assistant `0x551c19aCbEAE33C07b98120cC2992Ec70e943e79` GitBook Assistant Protocol Fee Receiver (FeeVault) GitBook Assistant `0x39d91743ee3BB4CecfD3331e84185D29898Da34C` GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#on-chain-parameters-1) On-chain parameters ------------------------------------------------------------------------------------------------------------------------ ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trading-fee) Trading fee Parameter Value Description Trade fee GitBook Assistant 1.25% (`12,500,000 / 1e9`) GitBook Assistant Applied to every buy and sell. GitBook Assistant Creator share GitBook Assistant 24% of trade fee GitBook Assistant ≈ 0.3% of trade size. Accrues in FeeVault. GitBook Assistant Protocol share GitBook Assistant 76% of trade fee GitBook Assistant ≈ 0.95% of trade size. GitBook Assistant Max platform fee GitBook Assistant 5% (`50,000,000 / 1e9`) GitBook Assistant Max rate for `buyWithFee` / `sellWithFee`. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#bonding-curve-config) Bonding curve config Parameter Value Description Total supply GitBook Assistant `1,000,000,000` (1e27 wei, 18 decimals) GitBook Assistant Fixed per token. GitBook Assistant `virtualNative` (initial) GitBook Assistant `2026585820895522388` (~2.027 ETH) GitBook Assistant Starting virtual ETH reserve. GitBook Assistant `virtualToken` (initial) GitBook Assistant `1098507462686567164179104478` (~1.099e27) GitBook Assistant Starting virtual token reserve. GitBook Assistant Graduation threshold (`targetToken`) GitBook Assistant `200,000,000` (2e26 wei) GitBook Assistant Remaining tokens in curve at graduation. GitBook Assistant Expected ETH raised (net) GitBook Assistant ~5.43 ETH GitBook Assistant ETH in curve at graduation. GitBook Assistant Total user spend (inc. fee) GitBook Assistant ~5.5 ETH GitBook Assistant Gross ETH to fill curve. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#listing-migration) Listing / migration Parameter Value Description Listing fee rate GitBook Assistant 800 / 10000 = **8%** GitBook Assistant Deducted from raised ETH at graduation. GitBook Assistant Listing fee receiver GitBook Assistant `0x551c19aCbEAE33C07b98120cC2992Ec70e943e79` GitBook Assistant Receives listing fee at migration. GitBook Assistant Kumbaya V3 fee tier GitBook Assistant 100 (= 0.01%) GitBook Assistant V3 pool fee tier. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#feevault) FeeVault Parameter Value Min dev claim GitBook Assistant 0.001 ETH GitBook Assistant Min protocol claim GitBook Assistant 0.001 ETH GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trenchmanagerv3-abi) TrenchManagerV3 ABI ---------------------------------------------------------------------------------------------------------------------- ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trading-functions-1) Trading functions #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#createcurve-1) `createCurve` Deploy a new token and bonding curve. Optionally performs an initial dev buy. The contract pre-initializes a Kumbaya V3 anchor position at the graduation price using 1e12 wei from its own balance. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#buy-1) `buy` Buy tokens with ETH. No platform fee. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#buywithfee-1) `buyWithFee` Buy tokens with an additional platform fee (up to 5%). GitBook Assistant Fee flow: GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#sell-1) `sell` Sell tokens for ETH. Requires prior `ERC20.approve`. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#sellwithfee-1) `sellWithFee` Sell tokens with an additional platform fee (up to 5%). GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#quote-functions-1) Quote functions #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#quotebuywithfee-1) `quoteBuyWithFee` Simulate a buy. Returns estimated output and full fee breakdown. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#quotesellwithfee-1) `quoteSellWithFee` Simulate a sell. `amountIn` must be divisible by 1e9. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#query-functions) Query functions ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#migration-v3) Migration (V3) Only callable by the whitelisted migrator. Deducts listing fee (8%), seeds the Kumbaya V3 full-range position, sends the LP NFT to `LP_receiver`, and sets token mode to 0. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ibondingcurve-abi-1) IBondingCurve ABI -------------------------------------------------------------------------------------------------------------------- One `BondingCurve` contract is deployed per token. Query via `TrenchManagerV3.curves(token)`. GitBook Assistant Unlike Ethereum's BondingCurve, there is no `pair()` function — graduation goes to a Kumbaya V3 pool, not a V2 pair. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ibondingcurvefactory-abi-1) IBondingCurveFactory ABI ---------------------------------------------------------------------------------------------------------------------------------- [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ifeevault-abi) IFeeVault ABI ---------------------------------------------------------------------------------------------------------- [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#itoken-erc-20-1) IToken (ERC-20) -------------------------------------------------------------------------------------------------------------- Standard ERC-20 with transfer restriction modes: GitBook Assistant Mode Value Behavior `MODE_NORMAL` GitBook Assistant `0` GitBook Assistant Free transfer (post-graduation) GitBook Assistant `MODE_TRANSFER_RESTRICTED` GitBook Assistant `1` GitBook Assistant All transfers blocked (emergency) GitBook Assistant `MODE_TRANSFER_CONTROLLED` GitBook Assistant `2` GitBook Assistant Only transfers involving TrenchManager allowed (default at creation) GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#events-1) Events ---------------------------------------------------------------------------------------------- ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trenchmanagerv3) TrenchManagerV3 Event Key fields When `TokenCreate` GitBook Assistant `creator, curve, token, name, symbol, launchTime, tokenURI` GitBook Assistant New token created GitBook Assistant `TokenPurchase` GitBook Assistant `token, account, amountToken, amountQuote, protocolFee, buyFee, buyFeeReceiver, buyFeeRate` GitBook Assistant Token bought GitBook Assistant `TokenSale` GitBook Assistant `token, account, amountToken, amountQuote, protocolFee, sellFee, sellFeeReceiver` GitBook Assistant Token sold GitBook Assistant `sync` GitBook Assistant `token, realNativeReserves, realTokenReserves, virtualNativeReserve, virtualTokenReserve` GitBook Assistant After every trade GitBook Assistant `LimitReach` GitBook Assistant `token` (indexed) GitBook Assistant Curve filled — trading halted GitBook Assistant `TradeStop` GitBook Assistant `token` GitBook Assistant Trading halted GitBook Assistant `V3AnchorListing` GitBook Assistant `curve, token, pool, tokenId, liquidity, nativeAmount, tokenAmount, sqrtPriceX96, tickLower, tickUpper` GitBook Assistant Anchor LP minted at `createCurve` GitBook Assistant `V3Listing` GitBook Assistant `curve, token, pool, tokenId, liquidity, amount0, amount1, sqrtPriceX96, tickLower, tickUpper` GitBook Assistant Full migration to Kumbaya V3 complete GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#feevault-1) FeeVault Event Key fields When `Credit` GitBook Assistant `token` (indexed), `amount` GitBook Assistant Fee deposited from trade GitBook Assistant `DevClaim` GitBook Assistant `creator` (indexed), `amount` GitBook Assistant Creator claimed fee GitBook Assistant `TrechOwnerClaim` GitBook Assistant `amount` GitBook Assistant Protocol fee withdrawn GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#error-codes-1) Error codes -------------------------------------------------------------------------------------------------------- ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trenchmanagerv3-1) TrenchManagerV3 Error Description `ERR_CORE_CURVE_NOT_FOUND` GitBook Assistant Token not registered GitBook Assistant `ERR_CORE_INVALID_AMOUNT_OUT` GitBook Assistant Output below `amountOutMin` (slippage) GitBook Assistant `ERR_CORE_EXPIRED` GitBook Assistant Transaction deadline passed GitBook Assistant `ERR_CORE_INVALID_AMOUNT_IN` GitBook Assistant Zero or invalid input amount GitBook Assistant `ERR_CORE_INVALID_SEND_NATIVE` GitBook Assistant `msg.value < amountIn` GitBook Assistant `ERR_CORE_GWEI` GitBook Assistant Sell `amountIn` not Gwei-aligned GitBook Assistant `ERR_BUY_FEE_RATE` GitBook Assistant `buyFeeRate` > 5% GitBook Assistant `ERR_BUY_FEE_RECEIVER` GitBook Assistant `buyFeeRate > 0` but receiver is zero address GitBook Assistant `ERR_SELL_FEE_RATE` GitBook Assistant `sellFeeRate` > 5% GitBook Assistant `ERR_SELL_FEE_RECEIVER` GitBook Assistant `sellFeeRate > 0` but receiver is zero address GitBook Assistant `ERR_CORE_INVALID_ALLOWANCE` GitBook Assistant Insufficient ERC-20 approval for sell GitBook Assistant `ERR_CORE_CURVE_NOT_MIGRATING` GitBook Assistant Token not in migrating state GitBook Assistant `ERR_CORE_CURVE_ALREADY_MIGRATED` GitBook Assistant Token already migrated GitBook Assistant `ERR_CORE_ONLY_MIGRATOR` GitBook Assistant Caller is not whitelisted migrator GitBook Assistant `ERR_CORE_V3_NOT_CONFIGURED` GitBook Assistant V3 position manager or fee not set GitBook Assistant `ERR_CORE_V3_ZERO_LIQUIDITY` GitBook Assistant Minted LP has zero liquidity GitBook Assistant `ERR_CORE_INVALID_LP_RECEIVER` GitBook Assistant `LP_receiver` not set GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#bondingcurve-1) BondingCurve Error Description `ERR_BONDING_CURVE_ONLY_TRENCH_MANAGER` GitBook Assistant Only TrenchManager can call GitBook Assistant `ERR_BONDING_CURVE_FINISHED` GitBook Assistant Curve already graduated GitBook Assistant `ERR_BONDING_CURVE_INVALID_AMOUNT_OUT` GitBook Assistant Computed output too low GitBook Assistant `ERR_BONDING_CURVE_INVALID_AMOUNT_IN` GitBook Assistant Zero input GitBook Assistant `ERR_BONDING_CURVE_OVERFLOW_TARGET` GitBook Assistant Buy exceeds remaining capacity GitBook Assistant `ERR_BONDING_CURVE_NOT_TRADABLE` GitBook Assistant Trading halted (migrating state) GitBook Assistant `ERR_BONDING_CURVE_ALREADY_MIGRATED` GitBook Assistant Curve already migrated GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#token-1) Token Error Description `ERR_TOKEN_INVALID_TRANSFER` GitBook Assistant Transfer blocked by mode 2 GitBook Assistant `ERR_TOKEN_TRANSFER_RESTRICTED` GitBook Assistant Transfer blocked by mode 1 GitBook Assistant `ERR_TOKEN_INVALID_OWNER` GitBook Assistant Only TrenchManager can call `setMode` GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#feevault-2) FeeVault Error Description `TOO_SMALL` GitBook Assistant Claim amount below 0.001 ETH minimum GitBook Assistant `ERR_FEE_VAULT_ONLY_TRENCH_MANAGER` GitBook Assistant Only TrenchManager can call `credit()` GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#network-info-1) Network info ---------------------------------------------------------------------------------------------------------- Chain ID GitBook Assistant `4663` GitBook Assistant Architecture GitBook Assistant Arbitrum Orbit L2 GitBook Assistant Native currency GitBook Assistant ETH (18 decimals) GitBook Assistant Robinhood is a single-layer launchpad: users call **TrenchManager** directly, with no aggregation or vault layer in between. Tokens are quoted in native **ETH**. RPC endpoint is available from the team on request. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#deployments-2) Deployments -------------------------------------------------------------------------------------------------------- Contract Address Description **TrenchManager** GitBook Assistant `0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d` GitBook Assistant Single entry point for all interactions and the `approve` target GitBook Assistant BondingCurveFactory GitBook Assistant `0x2ECFb98BCe4f3616115E4a2A7a2379AF388DFbAA` GitBook Assistant Curve and token factory GitBook Assistant FeeVault GitBook Assistant `0x076e3Cd13E188e3646828e7cEBB766C7Dd6aDb8A` GitBook Assistant Protocol/dev fee collection on the curve (ETH) GitBook Assistant LPFeeSplitter GitBook Assistant `0x74a40b65320c717F0ECF74f68CcB910edCd08e22` GitBook Assistant Post-graduation Uniswap V3 swap-fee split (dev 60% / protocol 40%) GitBook Assistant WETH (WNative) GitBook Assistant `0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73` GitBook Assistant Wrapped ETH — used internally at graduation GitBook Assistant UniV3 NonfungiblePositionManager GitBook Assistant `0x73991a25C818Bf1f1128dEAaB1492D45638DE0D3` GitBook Assistant V3 LP position NFT manager (graduation target) GitBook Assistant UniV3 Factory GitBook Assistant `0x1f7d7550B1b028f7571E69A784071F0205FD2EfA` GitBook Assistant Uniswap V3 factory GitBook Assistant UniV3 SwapRouter GitBook Assistant `0xCaf681a66D020601342297493863E78C959E5cb2` GitBook Assistant Uniswap V3 swap router (post-graduation trading) GitBook Assistant Owner / Deployer GitBook Assistant `0xbeb76A70c82B09E30B2008eAFa7F987987EC9e0b` GitBook Assistant Contract owner GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#quote-token) Quote token ------------------------------------------------------------------------------------------------------ Tokens are priced in native ETH. GitBook Assistant Quote Address Decimals Buy funding Approve Native ETH GitBook Assistant `0x0000000000000000000000000000000000000000` GitBook Assistant 18 GitBook Assistant `msg.value` (payable) GitBook Assistant None GitBook Assistant `virtualQuote` / `realQuoteReserves` are denominated in ETH (18 decimals). The contract's trading methods take a `quoteAddr` argument (`address(0)` = ETH) so the curve can support additional quote tokens in the future; today only ETH is enabled. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#on-chain-parameters-2) On-chain parameters ------------------------------------------------------------------------------------------------------------------------ ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trading-fee-1) Trading fee Parameter Value Description Trade fee GitBook Assistant 1% (`FEE_NUMERATOR = 100 / FEE_DENOMINATOR = 10,000`) GitBook Assistant Applied to every buy and sell. GitBook Assistant Creator share GitBook Assistant 30% of trade fee GitBook Assistant ≈ 0.3% of trade size. Accrues in FeeVault. GitBook Assistant Protocol share GitBook Assistant 70% of trade fee GitBook Assistant ≈ 0.7% of trade size. GitBook Assistant Max extra fee GitBook Assistant 5% (`MAX_EXTRA_FEE_RATE = 500 / 10,000`) GitBook Assistant Max rate for `buyWithFee` / `sellWithFee`. GitBook Assistant Unlike MegaETH, Robinhood uses a `10,000` fee denominator (same as Ethereum). A 0.5% extra fee is `50`. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#bonding-curve-config-1) Bonding curve config Parameter Value Description Total supply GitBook Assistant `1,000,000,000` (1e27 wei, 18 decimals) GitBook Assistant Fixed per token. GitBook Assistant `virtualQuote` (initial) GitBook Assistant `1712328767123287671` (~1.712 ETH) GitBook Assistant Starting virtual ETH reserve. GitBook Assistant `virtualToken` (initial) GitBook Assistant `1073972602739726027397260274` (~1.074e27) GitBook Assistant Starting virtual token reserve. GitBook Assistant Graduation threshold (`targetToken`) GitBook Assistant `200,000,000` (2e26 wei) GitBook Assistant Curve graduates when `realTokenReserves ≤ targetToken`. GitBook Assistant Total user spend (inc. fee) GitBook Assistant ~5 ETH GitBook Assistant Gross ETH to fill the curve. GitBook Assistant Curve parameters are read via `getConfig(quote)` (pass `address(0)` for ETH). GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#listing-migration-1) Listing / migration Parameter Value Description Listing fee rate GitBook Assistant 200 / 10000 = **2%** GitBook Assistant Deducted from the raised quote at graduation. GitBook Assistant UniV3 fee tier GitBook Assistant 10000 (= **1%**) GitBook Assistant V3 pool fee tier. GitBook Assistant Graduation DEX GitBook Assistant Uniswap V3 GitBook Assistant Full-range anchor position pre-created at `createCurve`. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#feevault-claim-threshold-minclaimamount) FeeVault claim threshold (`minClaimAmount`) FeeVault Value ETH FeeVault (`0x076e…`) GitBook Assistant `1e12` wei (0.000001 ETH) GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trenchmanager-abi) TrenchManager ABI ------------------------------------------------------------------------------------------------------------------ ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trading-functions-2) Trading functions #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#createcurve-2) `createCurve` Deploy a new token and bonding curve, with an optional initial dev buy. Pre-builds a Uniswap V3 anchor pool at the graduation price to prevent front-running. Send `msg.value = amountIn` for the initial dev buy (pass `address(0)` as `quoteAddr` for ETH). GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#buy-2) `buy` Buy tokens with ETH — payable, `msg.value = amountIn`. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#buywithfee-2) `buyWithFee` Buy with an additional third-party fee (up to 5%). GitBook Assistant Fee flow: GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#sell-2) `sell` Sell tokens for ETH. Requires prior `ERC20.approve` of the **meme token** to TrenchManager. Net ETH is transferred to `to`. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#sellwithfee-2) `sellWithFee` Sell with an additional third-party fee (up to 5%). GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#quote-functions-2) Quote functions #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#previewbuy) `previewBuy` Estimate output and protocol fee for a buy without sending a transaction. GitBook Assistant #### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#previewsell) `previewSell` Estimate net quote out and protocol fee for a sell. GitBook Assistant `previewBuy` / `previewSell` return the **protocol** fee only. Any extra fee from `buyWithFee` / `sellWithFee` is applied on top by your own rate; compute it client-side. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#query-functions-1) Query functions ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#migration-v3-1) Migration (V3) Only callable by a whitelisted migrator, once the curve has filled (`isMigrating`). Deducts the 2% listing fee, seeds the Uniswap V3 full-range position, and sets the token to free-transfer mode. The graduation LP NFT (and the `createCurve` anchor position) mint to the **LPFeeSplitter**, which collects and splits the pool's swap fees (see below). GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ibondingcurve-abi-2) IBondingCurve ABI -------------------------------------------------------------------------------------------------------------------- One `BondingCurve` contract is deployed per token. Query via `TrenchManager.tokenInfo(token)` or `curves(token)`. Write methods are TrenchManager-only. GitBook Assistant Graduation condition: `realTokenReserves ≤ targetToken` (targetToken = 200 M = 20% of supply). Reserves are named `Quote` (not `Native`) because the curve is quote-parameterized; the live quote is ETH. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ibondingcurvefactory-abi-2) IBondingCurveFactory ABI ---------------------------------------------------------------------------------------------------------------------------------- `getConfig`, `getK`, and `getListingFeeRate` all take a quote address so the factory can hold config per quote token. Pass `address(0)` for ETH — the only enabled quote today. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ifeevault-abi-1) IFeeVault ABI ------------------------------------------------------------------------------------------------------------ The FeeVault collects and pays out native ETH (`quoteToken() == address(0)`). Split is **30% creator (dev) / 70% protocol**. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#ilpfeesplitter-abi) ILPFeeSplitter ABI -------------------------------------------------------------------------------------------------------------------- After graduation, a token trades on a Uniswap V3 pool (1% fee tier). The graduation LP NFT — and the anchor position pre-created at `createCurve` — mint to the **LPFeeSplitter** rather than to a plain LP-receiver wallet. It collects the pool's swap fees and splits the **quote side** (ETH) **dev 60% / protocol 40%**; the meme side goes entirely to the protocol. The dev share ratio is configurable (`devShareBps`, currently `6000`). GitBook Assistant This is a **separate, post-graduation** fee stream from the on-curve `FeeVault` (which pays dev 30% of the 1% trade fee). A dev earns from **both**: the curve `FeeVault` while the token is on the curve, and the `LPFeeSplitter` on every Uniswap V3 swap after graduation. Only tokens that graduate after this mechanism went live are covered — earlier graduates keep the old LP-receiver arrangement. GitBook Assistant The splitter uses an **accounting model**: any `collect` (dev `claim` or protocol `sweep`) pulls the pool fees into the contract and books credits by ratio — funds stay in the contract until each party withdraws, so dev and protocol claims are independent and neither pays for the other's gas. GitBook Assistant Claimable post-graduation fee = `creatorCredits[creator][quote]` (already collected) **plus** the uncollected pending quote fees × `devShareBps`. Estimate **both** parts — after a protocol `sweep`, the dev's share has moved into `creatorCredits` and pending resets to zero, so counting only pending under-reports. Read the ratio from `devShareBps()`; don't hard-code 60%. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#itoken-erc-20-2) IToken (ERC-20) -------------------------------------------------------------------------------------------------------------- Standard ERC-20 with a two-state transfer control. GitBook Assistant Mode Value Who can transfer `free` GitBook Assistant `0` GitBook Assistant Anyone (post-graduation) GitBook Assistant `restricted` GitBook Assistant `1` GitBook Assistant Only via TrenchManager (default at creation) GitBook Assistant A newly created token is `restricted` (mode 1): EOA-to-EOA transfers revert with `"Token: restricted"`, and only transfers where TrenchManager is the sender or recipient are allowed. This is why in-curve sells must approve the meme token to TrenchManager and route through `sell` — you cannot build your own pool pre-graduation. After migration completes, TrenchManager calls `setMode(0)` and the token trades freely on Uniswap V3. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#events-2) Events ---------------------------------------------------------------------------------------------- ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#trenchmanager) TrenchManager Event Key fields When `TokenCreate` GitBook Assistant `creator, curve, token, quote, name, symbol, timestamp, tokenURI` GitBook Assistant New token created GitBook Assistant `TokenPurchase` GitBook Assistant `token, buyer, amountOut, quoteAmountUsed, protocolFee, extraFee, extraFeeReceiver, extraFeeRate` GitBook Assistant Token bought GitBook Assistant `TokenSale` GitBook Assistant `token, seller, amountIn, netQuoteOut, protocolFee, extraFee, extraFeeReceiver` GitBook Assistant Token sold GitBook Assistant `Sync` GitBook Assistant `token, realQuoteReserves, realTokenReserves, virtualQuote, virtualToken` GitBook Assistant After every trade GitBook Assistant `LimitReach` GitBook Assistant `token` (indexed) GitBook Assistant Graduation threshold hit — enters migrating GitBook Assistant `Listing` GitBook Assistant `curve, token, pool, tokenId, liquidity, quoteAmount, tokenAmount, sqrtPriceX96, tickLower, tickUpper` GitBook Assistant Migrated to Uniswap V3 GitBook Assistant `TokenCreate` has `creator`, `curve`, and `token` indexed — `token` is the 3rd indexed topic, or read it from the return value. GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#feevault-3) FeeVault Event Key fields When `Credit` GitBook Assistant `token` (indexed), `amount` GitBook Assistant Fee deposited from a trade GitBook Assistant `DevClaim` GitBook Assistant `creator` (indexed), `amount` GitBook Assistant Creator claimed dev share GitBook Assistant `ProtocolClaim` GitBook Assistant `amount` GitBook Assistant Protocol fee withdrawn GitBook Assistant ### [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#lpfeesplitter) LPFeeSplitter Event Key fields When `RegisterPosition` GitBook Assistant `tokenId, creator, quoteToken` (all indexed) GitBook Assistant A graduation/anchor LP NFT registered to the splitter GitBook Assistant `CollectSplit` GitBook Assistant `tokenId` (indexed), `creator` (indexed), `quoteToken, quoteAmt, memeAmt` GitBook Assistant Pool fees collected and split GitBook Assistant `Claim` GitBook Assistant `creator` (indexed), `token` (indexed), `amount` GitBook Assistant Creator withdrew their post-graduation share GitBook Assistant `WithdrawCredit` GitBook Assistant `creator` (indexed), `token` (indexed), `amount` GitBook Assistant Booked credit withdrawn GitBook Assistant [](https://trench-today.gitbook.io/trench-today/for-developers/contracts#error-codes-2) Error codes -------------------------------------------------------------------------------------------------------- Robinhood contracts use OpenZeppelin custom errors plus string reverts. The most common ones integrators will hit: GitBook Assistant Revert Description `"Token: restricted"` GitBook Assistant Direct transfer attempted while the token is in `restricted` mode (pre-graduation) GitBook Assistant `OwnableUnauthorizedAccount(address)` GitBook Assistant Caller lacks the required owner/migrator role GitBook Assistant `ReentrancyGuardReentrantCall()` GitBook Assistant Reentrant call blocked GitBook Assistant `SafeERC20FailedOperation(address)` GitBook Assistant Underlying ERC-20 transfer/approve failed (e.g. missing token approval on sell) GitBook Assistant `ERC20InsufficientAllowance(...)` GitBook Assistant Selling without approving the meme token to TrenchManager GitBook Assistant `ERC20InsufficientBalance(...)` GitBook Assistant Insufficient token or ETH balance GitBook Assistant [PreviousFor Developers](https://trench-today.gitbook.io/trench-today/for-developers/api) [NextIntegration Guide](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide) Last updated 23 minutes ago Was this helpful? Was this helpful? GitBook AssistantAskCopy function createCurve( address creator, string name, string symbol, string tokenURI, uint256 amountIn, // ETH for initial dev buy; 0 = no dev buy uint256 amountOutMin, bytes32 salt ) external payable returns ( address curve, address token, uint256 virtualNative, uint256 virtualToken, uint256 amountOut ); GitBook AssistantAskCopy function buy( uint256 amountIn, // must equal msg.value uint256 amountOutMin, // slippage protection address token, address to, // token recipient uint256 deadline // unix timestamp; 0 = no deadline ) external payable returns (uint256 amountOut); GitBook AssistantAskCopy function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 buyFeeRate, // denominator 10,000; max 500 (= 5%) address buyFeeReceiver // must not be address(0) ) external payable returns (uint256 amountOut); GitBook AssistantAskCopy Platform fee = amountIn × buyFeeRate / 10000 → buyFeeReceiver Protocol fee = (amountIn − platform fee) × 1.25% → FeeVault Curve input = amountIn − platform fee − protocol fee GitBook AssistantAskCopy function sell( uint256 amountIn, // token wei — must be Gwei-aligned (amountIn % 1e9 == 0) uint256 amountOutMin, address token, address to, // ETH recipient uint256 deadline ) external returns (uint256 amountOut); GitBook AssistantAskCopy function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 sellFeeRate, // denominator 10,000; max 500 (= 5%) address sellFeeReceiver ) external returns (uint256 amountOut); GitBook AssistantAskCopy Curve output = calculated from bonding curve Protocol fee = curve output × 1.25% → FeeVault Platform fee = curve output × sellFeeRate / 10000 → sellFeeReceiver User receives = curve output − protocol fee − platform fee GitBook AssistantAskCopy function quoteBuyWithFee( uint256 amountIn, address token, uint256 buyFeeRate ) external view returns ( uint256 amountOut, // tokens user will receive uint256 protocolFee, uint256 buyFee, // platform fee uint256 grossAmountUsed, // ETH entering the curve uint256 totalAmountInUsed, // total ETH consumed uint256 refundAmount // ETH refunded if graduation hit mid-purchase ); GitBook AssistantAskCopy function quoteSellWithFee( uint256 amountIn, address token, uint256 sellFeeRate ) external view returns ( uint256 grossAmountOut, // total ETH from curve uint256 netAmountOut, // ETH user will receive after all fees uint256 protocolFee, uint256 sellFee // platform fee ); GitBook AssistantAskCopy function curves(address token) external view returns (address curve); // BondingCurve for a token function creators(address token) external view returns (address creator); // creator wallet for a token function factory() external view returns (address); function wNative() external view returns (address); // WETH function vault() external view returns (address); // FeeVault GitBook AssistantAskCopy function realNativeReserves() external view returns (uint256); function realTokenReserves() external view returns (uint256); function getVirtualReserves() external view returns (uint256 virtualNative, uint256 virtualToken); function getK() external view returns (uint256); function getTargetToken() external view returns (uint256); // 200 M tokens function getRemainingTokenToSell() external view returns (uint256); function migrating() external view returns (bool); // true = graduation threshold hit function migrated() external view returns (bool); // true = listed on Uniswap V2 function token() external view returns (address); function wNative() external view returns (address); function pair() external view returns (address); // Uniswap V2 pair (post-migration) GitBook AssistantAskCopy struct Config { uint256 listingFeeRate; uint256 tokenTotalSupply; // 1e27 uint256 virtualNative; // ~2.009 ETH uint256 virtualToken; // ~1.068e27 uint256 k; uint256 targetToken; // 200 M tokens uint256 realNativeReserves; // initial = 0 uint256 realTokenReserves; // initial = 1e27 } function getConfig() external view returns (Config memory); function wNative() external view returns (address); function getDexFactory() external view returns (address); // Uniswap V2 factory function getListingFeeRate() external view returns (uint256); GitBook AssistantAskCopy function mode() external view returns (uint8); // 0 = normal, 2 = controlled (pre-graduation) function trenchManager() external view returns (address); // Standard ERC-20 function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // always 18 function totalSupply() external view returns (uint256); // always 1e27 function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transfer(address to, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); GitBook AssistantAskCopy function createCurve( address creator, string name, string symbol, string tokenURI, uint256 amountIn, // ETH for initial dev buy; 0 = no dev buy uint256 amountOutMin, bytes32 salt ) external payable returns ( address curve, address token, uint256 virtualNative, uint256 virtualToken, uint256 amountOut ); GitBook AssistantAskCopy function buy( uint256 amountIn, // must equal msg.value uint256 amountOutMin, address token, address to, uint256 deadline ) external payable returns (uint256 amountOut); GitBook AssistantAskCopy function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 buyFeeRate, // denominator 1e9; max 50,000,000 (= 5%) address buyFeeReceiver ) external payable returns (uint256 amountOut); GitBook AssistantAskCopy Platform fee = amountIn × buyFeeRate / 1e9 → buyFeeReceiver Protocol fee = (amountIn − platform fee) × 1.25% → FeeVault Curve input = amountIn − platform fee − protocol fee GitBook AssistantAskCopy function sell( uint256 amountIn, // token wei — must be Gwei-aligned (amountIn % 1e9 == 0) uint256 amountOutMin, address token, address to, uint256 deadline ) external returns (uint256 amountOut); GitBook AssistantAskCopy function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 sellFeeRate, address sellFeeReceiver ) external returns (uint256 amountOut); GitBook AssistantAskCopy function quoteBuyWithFee( uint256 amountIn, address token, uint256 buyFeeRate ) external view returns ( uint256 amountOut, uint256 protocolFee, uint256 buyFee, uint256 newVirtualNative, uint256 newVirtualToken, uint256 newRealNative ); GitBook AssistantAskCopy function quoteSellWithFee( uint256 amountIn, address token, uint256 sellFeeRate ) external view returns ( uint256 amountOut, uint256 protocolFee, uint256 sellFee, uint256 newRealNative ); GitBook AssistantAskCopy function curves(address token) external view returns (address curve); function creators(address token) external view returns (address creator); function tokenInfo(address token) external view returns ( address curve, address creator, uint256 realNativeReserves, uint256 realTokenReserves, uint256 virtualNativeReserve, uint256 virtualTokenReserve, bool isMigrating, bool isMigrated ); function factory() external view returns (address); function vault() external view returns (address); function wNative() external view returns (address); function migrator() external view returns (address); GitBook AssistantAskCopy function migrateToV3( address token, uint256 amount0Min, uint256 amount1Min, uint256 deadline // 0 = no deadline ) external returns ( address pool, uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); GitBook AssistantAskCopy function getVirtualReserves() external view returns (uint256 virtualWNative, uint256 virtualToken); function getReserves() external view returns (uint256 reserveWNative, uint256 reserveToken); function getRemainingTokenToSell() external view returns (uint256); function getTargetToken() external view returns (uint256); // 200 M tokens function getK() external view returns (uint256); function isMigrating() external view returns (bool); // true = curve filled, awaiting migration function isMigrated() external view returns (bool); // true = migrated to Kumbaya V3 function migrating() external view returns (bool); // raw storage accessor function migrated() external view returns (bool); // raw storage accessor function token() external view returns (address); function realNativeReserves() external view returns (uint256); function realTokenReserves() external view returns (uint256); GitBook AssistantAskCopy struct Config { uint256 listingFeeRate; // 800 (8%) uint256 tokenTotalSupply; // 1e27 uint256 virtualNative; // 2026585820895522388 (~2.027 ETH) uint256 virtualToken; // 1098507462686567164179104478 uint256 k; uint256 targetToken; // 2e26 uint256 realNativeReserves; // 0 at init uint256 realTokenReserves; // 1e27 at init } function getConfig() external view returns (Config memory); function getK() external view returns (uint256); function getListingFeeRate() external view returns (uint256); function getDexFactory() external view returns (address); // legacy, unused on MegaETH function getOwner() external view returns (address); function getTrenchManager() external view returns (address); GitBook AssistantAskCopy function credit(address creator, address token, uint256 amount) external payable; function creditsDev(address creator) external view returns (uint256); // accrued dev fee function creditsProtocol() external view returns (uint256); // accrued protocol fee function devClaim(address creator) external; // anyone can call; ETH goes to creator function protocolClaim(uint256 amount) external; function feeReceiver() external view returns (address); function DEV_CLAIM_RATIO() external view returns (uint256); // 2400 function DEV_CLAIM_RATIO_DENOMINATOR() external view returns (uint256); // 10000 GitBook AssistantAskCopy function setMode(uint256 v) external; // only TrenchManager; cannot leave mode 0 function trenchManager() external view returns (address); function _mode() external view returns (uint256); function _metaUrl() external view returns (string memory); GitBook AssistantAskCopy function createCurve( address quoteAddr, // address(0) = ETH address creator, string name, string symbol, string tokenURI, uint256 amountIn, // initial dev buy in ETH; 0 = no dev buy uint256 amountOutMin, bytes32 salt ) external payable returns ( address curve, address token, uint256 virtualQuote, uint256 virtualToken, uint256 amountOut ); GitBook AssistantAskCopy function buy( uint256 amountIn, // must equal msg.value uint256 amountOutMin, // slippage protection address token, address to, // token recipient uint256 deadline // unix timestamp; 0 = no deadline ) external payable returns (uint256 amountOut); GitBook AssistantAskCopy function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 extraFeeRate, // denominator 10,000; max 500 (= 5%) address extraFeeReceiver // must not be address(0) when extraFeeRate > 0 ) external payable returns (uint256 amountOut); GitBook AssistantAskCopy Extra fee = amountIn × extraFeeRate / 10000 → extraFeeReceiver Protocol fee = (amountIn − extra fee) × 1% → FeeVault Curve input = amountIn − extra fee − protocol fee GitBook AssistantAskCopy function sell( uint256 amountIn, // token wei uint256 amountOutMin, address token, address to, // quote recipient uint256 deadline ) external returns (uint256 netQuoteOut); GitBook AssistantAskCopy function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 extraFeeRate, address extraFeeReceiver ) external returns (uint256 netQuoteOut); GitBook AssistantAskCopy function previewBuy(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 fee); GitBook AssistantAskCopy function previewSell(address token, uint256 amountIn) external view returns (uint256 netQuoteOut, uint256 fee); GitBook AssistantAskCopy function tokenInfo(address token) external view returns ( address curve, address creator, address quoteAddr, // address(0) = ETH uint256 realQuoteReserves, // ETH (18 decimals) uint256 realTokenReserves, uint256 virtualQuote, uint256 virtualToken, bool isMigrating_, bool isMigrated_ ); function curves(address token) external view returns (address curve); function creators(address token) external view returns (address creator); function tokenQuote(address token) external view returns (address); // the token's quote (ETH = address(0)) function allowedQuotes(address quote) external view returns (bool); function feeVaults(address quote) external view returns (address); // FeeVault for a given quote function factory() external view returns (address); function wNative() external view returns (address); // = WETH function v3PositionManager() external view returns (address); function poolFee() external view returns (uint24); // 10000 (1%) function anchorReserve(address quote) external view returns (uint256); // remaining anchor funding function lpFeeSplitter() external view returns (address); // LPFeeSplitter — post-graduation LP NFT holder GitBook AssistantAskCopy function migrate( address token, uint256 amount0Min, uint256 amount1Min, uint256 deadline ) external returns (address pool, uint256 tokenId, uint128 liquidity); GitBook AssistantAskCopy function getReserves() external view returns (uint256 realQuote, uint256 realToken); function getVirtualReserves() external view returns (uint256 virtualQuote, uint256 virtualToken); function getTargetToken() external view returns (uint256); // 200 M tokens function getRemainingTokenToSell() external view returns (uint256); // tokens left before graduation function getQuoteTarget() external view returns (uint256); // quote raise target function getRemainingQuoteToGraduate() external view returns (uint256); function getK() external view returns (uint256); function isMigrating() external view returns (bool); // curve filled, awaiting migration function isMigrated() external view returns (bool); // migrated to Uniswap V3 function migrating() external view returns (bool); // raw storage accessor function migrated() external view returns (bool); // raw storage accessor function quote() external view returns (address); // this curve's quote token function token() external view returns (address); function realQuoteReserves() external view returns (uint256); function realTokenReserves() external view returns (uint256); GitBook AssistantAskCopy struct Config { uint256 listingFeeRate; // 200 (2%) uint256 tokenTotalSupply; // 1e27 uint256 virtualQuote; // ETH: 1712328767123287671 uint256 virtualToken; // ETH: 1073972602739726027397260274 uint256 k; uint256 quoteTarget; // quote raise target uint256 targetToken; // 2e26 uint256 realQuoteReserves; // 0 at init uint256 realTokenReserves; // 1e27 at init } function getConfig(address quote) external view returns (Config memory); // pass address(0) for ETH function getListingFeeRate(address quote) external view returns (uint256); function getK(address quote) external view returns (uint256); function getCore() external view returns (address); // TrenchManager function INIT_REAL_TOKEN_RESERVES() external view returns (uint256); // 1e27 function LISTING_FEE_DENOMINATOR() external view returns (uint256); // 10000 GitBook AssistantAskCopy function quoteToken() external view returns (address); // address(0) = ETH function creditsDev(address creator) external view returns (uint256); // claimable dev balance (quote raw) function creditsProtocol() external view returns (uint256); // accrued protocol fee function minClaimAmount() external view returns (uint256); // decimals-aware claim floor function feeReceiver() external view returns (address); function trenchManager() external view returns (address); function devClaim(address creator) external; // creator claims dev share function protocolClaim(uint256 amount) external; // only feeReceiver function credit(address creator, address token, uint256 amount) external payable; function DEV_CLAIM_RATIO() external view returns (uint256); // 3000 function DEV_CLAIM_RATIO_DENOMINATOR() external view returns (uint256); // 10000 GitBook AssistantAskCopy // —— Dev (creator) claiming —— // Collects fees across all of the creator's positions, books credits, then // pays out the quote-side 60% to the creator (WETH auto-unwrapped to native ETH). // One call — no approve, no ticket. function claim(address creator) external; // Subset variant — when a creator has so many positions that claim() runs out of gas function claimPositions(address creator, uint256[] calldata tokenIds) external; // Withdraw already-booked credit without re-collecting (top-up / non-quote side) function withdrawCredit(address creator, address token) external; // —— Read (front-end estimation) —— function creatorPositions(address creator) external view returns (uint256[] memory); // creator's position tokenIds function creatorCredits(address creator, address token) external view returns (uint256); // booked, claimable (dev 60%) function protocolCredits(address token) external view returns (uint256); function positions(uint256 tokenId) external view returns (address creator, address quoteToken); function devShareBps() external view returns (uint256); // dev share in bps — currently 6000 (60%), configurable function BPS_DENOMINATOR() external view returns (uint256); // 10000 GitBook AssistantAskCopy function mode() external view returns (uint8); // 0 = free, 1 = restricted function tokenURI() external view returns (string memory); function core() external view returns (address); // TrenchManager function setMode(uint8 mode_) external; // only core (TrenchManager) // Standard ERC-20 function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // always 18 function totalSupply() external view returns (uint256); // always 1e27 function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/resources/links.md). # Links ## Official channels | | | | ----------- | --------------------------------------------- | | Website | \[trench.today\](https://trench.today) | | X (Twitter) | \[@TrenchToday01\](https://x.com/TrenchToday01) | | Telegram | \[@axx\\\_dot\](https://t.me/axx\_dot) | | Email | | {% hint style="warning" %} Only trust the links listed on this page. If someone DMs you a "Trench" link that isn't one of the above, it's a scam. {% endhint %} ## For aggregators and integrators Reach out through the official X account or Telegram for API key issuance, partnership discussions, or early access to the OpenAPI spec. ## For traders and devs The fastest way to get support is through X or Telegram. General questions are best asked there so the answer is visible to everyone. --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/resources/links.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/resources/brand-assets.md). # Brand Assets ## Logo variants
Trench logo — black

Black

{% file src="/files/dR6JtI9E9Pmh03AaUPrK" %} Trench Logo — Black {% endfile %} {% file src="/files/pTVgUKByK7Qtu4PcnfYF" %} Trench Logo — Black, Alpha Channel {% endfile %} {% file src="/files/nWwV1mvY5o6J1nZ7xNBy" %} Trench Logo — White, Alpha Channel {% endfile %} {% file src="/files/u3RtilAraodEDxuSNstX" %} Trench Logo — White {% endfile %} {% file src="/files/GZwV1k0I8uZjukQUMZlN" %} Trench Banner Logo — SVG {% endfile %} --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/resources/brand-assets.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Links | trench-today For the complete documentation index, see [llms.txt](https://trench-today.gitbook.io/trench-today/llms.txt) . This page is also available as [Markdown](https://trench-today.gitbook.io/trench-today/resources/links.md) . [](https://trench-today.gitbook.io/trench-today/resources#official-channels) Official channels --------------------------------------------------------------------------------------------------- Website GitBook Assistant [trench.today](https://trench.today/) GitBook Assistant X (Twitter) GitBook Assistant [@TrenchToday01](https://x.com/TrenchToday01) GitBook Assistant Telegram GitBook Assistant [@axx\_dot](https://t.me/axx_dot) GitBook Assistant Email GitBook Assistant [service@trench.today](mailto:service@trench.today) GitBook Assistant Only trust the links listed on this page. If someone DMs you a "Trench" link that isn't one of the above, it's a scam. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/resources#for-aggregators-and-integrators) For aggregators and integrators ------------------------------------------------------------------------------------------------------------------------------- Reach out through the official X account or Telegram for API key issuance, partnership discussions, or early access to the OpenAPI spec. GitBook Assistant [](https://trench-today.gitbook.io/trench-today/resources#for-traders-and-devs) For traders and devs --------------------------------------------------------------------------------------------------------- The fastest way to get support is through X or Telegram. General questions are best asked there so the answer is visible to everyone. GitBook Assistant [PreviousABI Files](https://trench-today.gitbook.io/trench-today/for-developers/abi-files) [NextBrand Assets](https://trench-today.gitbook.io/trench-today/resources/brand-assets) Last updated 2 months ago Was this helpful? --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide.md). # Integration Guide ## Core Concepts ### Bonding Curve Mechanism Trench uses a \*\*constant-product bonding curve\*\* (xy=k) with virtual reserves: \* \*\*Virtual Reserves\*\*: Initial liquidity used for price calculation \* \*\*Real Reserves\*\*: Actual ETH and tokens held by the curve \* \*\*Formula\*\*: \`virtualNative × virtualToken = k\` (constant) \*\*Key Parameters by chain\*\*: {% tabs %} {% tab title="Ethereum" %} \`\`\` virtualNative: ~2.009 ETH (2009158000000000000 wei) virtualToken: ~1.068e27 (1068000000000000000000000000 wei) targetToken: 200,000,000 tokens (20% of total supply) totalSupply: 1,000,000,000 tokens (1e27 wei) graduation: ~6 ETH gross spend \`\`\` {% endtab %} {% tab title="MegaETH" %} \`\`\` virtualNative: ~2.027 ETH (2026585820895522388 wei) virtualToken: ~1.099e27 (1098507462686567164179104478 wei) targetToken: 200,000,000 tokens (20% of total supply) totalSupply: 1,000,000,000 tokens (1e27 wei) graduation: ~5.5 ETH gross spend \`\`\` {% endtab %} {% tab title="Robinhood" %} \`\`\` virtualQuote: ~1.712 ETH (1712328767123287671 wei) virtualToken: ~1.074e27 (1073972602739726027397260274 wei) targetToken: 200,000,000 tokens (20% of total supply) totalSupply: 1,000,000,000 tokens (1e27 wei) graduation: ~5 ETH gross spend \`\`\` Robinhood reserves are named \`Quote\` (not \`Native\`) because the curve is quote-denominated. Native ETH is the live quote token. {% endtab %} {% endtabs %} \*\*Price Evolution\*\*: \* Initial price is determined by virtual reserves \* As users buy: ETH reserves ↑, token reserves ↓ → price increases \* As users sell: ETH reserves ↓, token reserves ↑ → price decreases ### Token Lifecycle {% tabs %} {% tab title="Ethereum" %} \`\`\` Created → Trading (Bonding Curve) → Migrating (Target Reached) → Listed (Uniswap V2) \`\`\` | Stage | Condition | Transfer Mode | | ------------ | ---------------------- | --------------------------------------------------- | | Created | Token deployed | \`MODE\_TRANSFER\_CONTROLLED\` (2) — only TrenchManager | | Trading | Buying/selling active | \`MODE\_TRANSFER\_CONTROLLED\` (2) | | Migrating | 200M tokens sold | \`MODE\_TRANSFER\_CONTROLLED\` (2) | | Listed | Migrated to Uniswap V2 | \`MODE\_NORMAL\` (0) — free transfers | | {% endtab %} | | | {% tab title="MegaETH" %} \`\`\` Created → Trading (Bonding Curve) → Migrating (Target Reached) → Listed (Kumbaya V3) \`\`\` | Stage | Condition | Transfer Mode | | ------------ | ---------------------- | --------------------------------------------------- | | Created | Token deployed | \`MODE\_TRANSFER\_CONTROLLED\` (2) — only TrenchManager | | Trading | Buying/selling active | \`MODE\_TRANSFER\_CONTROLLED\` (2) | | Migrating | 200M tokens sold | \`MODE\_TRANSFER\_CONTROLLED\` (2) | | Listed | Migrated to Kumbaya V3 | \`MODE\_NORMAL\` (0) — free transfers | | {% endtab %} | | | {% tab title="Robinhood" %} \`\`\` Created → Trading (Bonding Curve) → Migrating (Target Reached) → Listed (Uniswap V3) \`\`\` | Stage | Condition | Transfer Mode | | --------- | ---------------------- | ----------------------------------------- | | Created | Token deployed | \`restricted\` (1) — only via TrenchManager | | Trading | Buying/selling active | \`restricted\` (1) | | Migrating | 200M tokens sold | \`restricted\` (1) | | Listed | Migrated to Uniswap V3 | \`free\` (0) — free transfers | Robinhood tokens use a \*\*two-state\*\* mode (\`0 = free\`, \`1 = restricted\`) rather than MegaETH/Ethereum's three-state model. A restricted transfer reverts with \`"Token: restricted"\`. {% endtab %} {% endtabs %} ### Fee Model \*\*Protocol fee (fixed)\*\*: 1.25% on every trade. Split 24% to token creator, 76% to protocol. \*\*Platform fee (optional)\*\*: Available via \`buyWithFee\` / \`sellWithFee\`. Up to 5%. Paid to an address you specify. \*\*Buy flow\*\*: \`\`\` Platform fee = amountIn × buyFeeRate / feeDenominator → buyFeeReceiver Protocol fee = (amountIn − platform fee) × 1.25% → FeeVault Curve input = amountIn − platform fee − protocol fee \`\`\` \*\*Sell flow\*\*: \`\`\` Curve output = calculated from bonding curve Protocol fee = curve output × 1.25% → FeeVault Platform fee = curve output × sellFeeRate / feeDenominator → sellFeeReceiver User receives = curve output − protocol fee − platform fee \`\`\` {% hint style="info" %} The fee denominator differs by chain: Ethereum and Robinhood use \`10,000\`; MegaETH uses \`1,000,000,000\` (1e9). A 0.5% platform fee is \`50\` on Ethereum/Robinhood and \`5,000,000\` on MegaETH. On Robinhood the protocol trade fee is \*\*1%\*\* (not 1.25%) and the platform-fee parameter is named \`extraFeeRate\` / \`extraFeeReceiver\`. {% endhint %} ### Math Model The bonding curve uses the \*\*constant-product\*\* formula: \`\`\` k = virtualNative × virtualToken (constant) \`\`\` \*\*Buy\*\* — purchasing with \`amountIn\` ETH: \`\`\` newReserveIn = virtualNative + amountIn newReserveOut = ceil(k / newReserveIn) amountOut = virtualToken − newReserveOut \`\`\` \*\*Sell\*\* — selling \`amountIn\` tokens: \`\`\` newReserveOut = virtualToken + amountIn newReserveIn = ceil(k / newReserveOut) amountOut = virtualNative − newReserveIn \`\`\` \*\*Current price\*\* (ETH per token): \`\`\` price = virtualNative / virtualToken \`\`\` \*\*\* ## Integration Patterns ### Simple Buy/Sell {% tabs %} {% tab title="Ethereum" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } interface ITrenchManagerV2 { function buy(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external payable returns (uint256); function sell(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external returns (uint256); function quoteBuyWithFee(uint256 amountIn, address token, uint256 buyFeeRate) external view returns (uint256, uint256, uint256, uint256, uint256, uint256); } contract SimpleTradingBot { ITrenchManagerV2 constant MANAGER = ITrenchManagerV2(0x974B2d86d6353c62f19110127aF1A5df4c6370f0); function buyWithSlippage(address token, uint256 ethAmount) external payable { require(msg.value == ethAmount, "ETH mismatch"); (uint256 expectedTokens, , , , ,) = MANAGER.quoteBuyWithFee(ethAmount, token, 0); uint256 minTokens = expectedTokens \* 99 / 100; // 1% slippage MANAGER.buy{value: ethAmount}( ethAmount, minTokens, token, msg.sender, block.timestamp + 300 ); } function sellWithSlippage(address token, uint256 tokenAmount) external { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); MANAGER.sell( tokenAmount, 0, // set proper minOut in production token, msg.sender, block.timestamp + 300 ); } } \`\`\` {% endtab %} {% tab title="MegaETH" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } interface ITrenchManagerV3 { function buy(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external payable returns (uint256); function sell(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external returns (uint256); function quoteBuyWithFee(uint256 amountIn, address token, uint256 buyFeeRate) external view returns (uint256, uint256, uint256, uint256, uint256, uint256); } contract SimpleTradingBot { ITrenchManagerV3 constant MANAGER = ITrenchManagerV3(0x2978E15501C792152602eC85c299083aa61b1bd4); function buyWithSlippage(address token, uint256 ethAmount) external payable { require(msg.value == ethAmount, "ETH mismatch"); (uint256 expectedTokens, , , , ,) = MANAGER.quoteBuyWithFee(ethAmount, token, 0); uint256 minTokens = expectedTokens \* 99 / 100; // 1% slippage MANAGER.buy{value: ethAmount}( ethAmount, minTokens, token, msg.sender, block.timestamp + 300 ); } function sellWithSlippage(address token, uint256 tokenAmount) external { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); MANAGER.sell( tokenAmount, 0, // set proper minOut in production token, msg.sender, block.timestamp + 300 ); } } \`\`\` {% endtab %} {% tab title="Robinhood" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface IERC20 { function approve(address spender, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); } interface ITrenchManager { function buy(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external payable returns (uint256); function sell(uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline) external returns (uint256); function previewBuy(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 fee); } contract SimpleTradingBot { // Robinhood uses a single TrenchManager (no V2/V3 suffix) ITrenchManager constant MANAGER = ITrenchManager(0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d); function buyWithSlippage(address token, uint256 ethAmount) external payable { require(msg.value == ethAmount, "ETH mismatch"); (uint256 expectedTokens, ) = MANAGER.previewBuy(token, ethAmount); uint256 minTokens = expectedTokens \* 99 / 100; // 1% slippage MANAGER.buy{value: ethAmount}( ethAmount, minTokens, token, msg.sender, block.timestamp + 300 ); } function sellWithSlippage(address token, uint256 tokenAmount) external { // meme token is \`restricted\` pre-graduation — must approve MANAGER and route through sell() IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); MANAGER.sell( tokenAmount, 0, // set proper minOut in production token, msg.sender, block.timestamp + 300 ); } } \`\`\` {% hint style="info" %} Robinhood quotes buys with \`previewBuy(token, amountIn) → (amountOut, fee)\` — a two-return helper — rather than MegaETH/Ethereum's \`quoteBuyWithFee\`. Tokens are quoted in native ETH, funded via \`msg.value\`. {% endhint %} {% endtab %} {% endtabs %} ### Platform Fee Integration Collect a fee on every trade routed through your platform. {% tabs %} {% tab title="Ethereum" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManagerV2 { function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 buyFeeRate, address buyFeeReceiver ) external payable returns (uint256); function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 sellFeeRate, address sellFeeReceiver ) external returns (uint256); } contract PlatformIntegration { ITrenchManagerV2 constant MANAGER = ITrenchManagerV2(0x974B2d86d6353c62f19110127aF1A5df4c6370f0); address public platformTreasury; uint256 public constant PLATFORM\_FEE\_RATE = 50; // 0.5% (50/10000) constructor(address \_treasury) { platformTreasury = \_treasury; } function platformBuy(address token, uint256 minTokens) external payable returns (uint256) { return MANAGER.buyWithFee{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300, PLATFORM\_FEE\_RATE, platformTreasury ); } function platformSell(address token, uint256 tokenAmount, uint256 minETH) external returns (uint256) { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); return MANAGER.sellWithFee( tokenAmount, minETH, token, msg.sender, block.timestamp + 300, PLATFORM\_FEE\_RATE, platformTreasury ); } } \`\`\` Fee breakdown for a 1 ETH buy with 0.5% platform fee: \`\`\` Platform fee (0.5%): 0.005 ETH → platformTreasury Protocol fee: 0.012 ETH → FeeVault (1.25% of 0.995 ETH) Curve input: 0.983 ETH → BondingCurve \`\`\` {% endtab %} {% tab title="MegaETH" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManagerV3 { function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 buyFeeRate, address buyFeeReceiver ) external payable returns (uint256); function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 sellFeeRate, address sellFeeReceiver ) external returns (uint256); } contract PlatformIntegration { ITrenchManagerV3 constant MANAGER = ITrenchManagerV3(0x2978E15501C792152602eC85c299083aa61b1bd4); address public platformTreasury; // MegaETH fee denominator is 1e9; 0.5% = 5,000,000 uint256 public constant PLATFORM\_FEE\_RATE = 5\_000\_000; constructor(address \_treasury) { platformTreasury = \_treasury; } function platformBuy(address token, uint256 minTokens) external payable returns (uint256) { return MANAGER.buyWithFee{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300, PLATFORM\_FEE\_RATE, platformTreasury ); } function platformSell(address token, uint256 tokenAmount, uint256 minETH) external returns (uint256) { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); return MANAGER.sellWithFee( tokenAmount, minETH, token, msg.sender, block.timestamp + 300, PLATFORM\_FEE\_RATE, platformTreasury ); } } \`\`\` Fee breakdown for a 1 ETH buy with 0.5% platform fee: \`\`\` Platform fee (0.5%): 0.005 ETH → platformTreasury Protocol fee: 0.012 ETH → FeeVault (1.25% of 0.995 ETH) Curve input: 0.983 ETH → BondingCurve \`\`\` {% endtab %} {% tab title="Robinhood" %} \`\`\`solidity // SPDX-License-Identifier: MIT pragma solidity ^0.8.20; interface ITrenchManager { function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 extraFeeRate, address extraFeeReceiver ) external payable returns (uint256); function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 extraFeeRate, address extraFeeReceiver ) external returns (uint256); } contract PlatformIntegration { ITrenchManager constant MANAGER = ITrenchManager(0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d); address public platformTreasury; // Robinhood fee denominator is 10,000; 0.5% = 50 (max 500 = 5%) uint256 public constant PLATFORM\_FEE\_RATE = 50; constructor(address \_treasury) { platformTreasury = \_treasury; } function platformBuy(address token, uint256 minTokens) external payable returns (uint256) { return MANAGER.buyWithFee{value: msg.value}( msg.value, minTokens, token, msg.sender, block.timestamp + 300, PLATFORM\_FEE\_RATE, platformTreasury ); } function platformSell(address token, uint256 tokenAmount, uint256 minETH) external returns (uint256) { IERC20(token).transferFrom(msg.sender, address(this), tokenAmount); IERC20(token).approve(address(MANAGER), tokenAmount); return MANAGER.sellWithFee( tokenAmount, minETH, token, msg.sender, block.timestamp + 300, PLATFORM\_FEE\_RATE, platformTreasury ); } } \`\`\` Fee breakdown for a 1 ETH buy with 0.5% extra fee (Robinhood protocol fee is \*\*1%\*\*): \`\`\` Extra fee (0.5%): 0.005 ETH → platformTreasury Protocol fee: 0.00995 ETH → FeeVault (1% of 0.995 ETH) Curve input: 0.98505 ETH → BondingCurve \`\`\` {% endtab %} {% endtabs %} ### Batch Price Query \`\`\`solidity interface IBondingCurve { function getVirtualReserves() external view returns (uint256, uint256); function realNativeReserves() external view returns (uint256); function realTokenReserves() external view returns (uint256); function migrating() external view returns (bool); } interface ITrenchManager { function curves(address token) external view returns (address); } contract PriceAggregator { ITrenchManager public immutable manager; constructor(address \_manager) { manager = ITrenchManager(\_manager); } struct TokenPrice { address token; uint256 pricePerToken; // wei per token (1e18 = 1 ETH/token) uint256 realNative; uint256 realToken; uint256 virtualNative; uint256 virtualToken; bool migrating; } function getBatchPrices(address\[\] calldata tokens) external view returns (TokenPrice\[\] memory prices) { prices = new TokenPrice\[\](tokens.length); for (uint256 i = 0; i < tokens.length; i++) { address curveAddr = manager.curves(tokens\[i\]); if (curveAddr == address(0)) continue; IBondingCurve curve = IBondingCurve(curveAddr); (uint256 vNative, uint256 vToken) = curve.getVirtualReserves(); prices\[i\] = TokenPrice({ token: tokens\[i\], pricePerToken: (vNative \* 1e18) / vToken, realNative: curve.realNativeReserves(), realToken: curve.realTokenReserves(), virtualNative: vNative, virtualToken: vToken, migrating: curve.migrating() }); } } } \`\`\` Deploy this with the appropriate \`TrenchManager\` address for the chain you're targeting. ### Event Monitoring (Off-Chain) {% tabs %} {% tab title="Ethereum" %} \`\`\`javascript const { ethers } = require("ethers"); const MANAGER\_ADDRESS = "0x974B2d86d6353c62f19110127aF1A5df4c6370f0"; const manager = new ethers.Contract(MANAGER\_ADDRESS, ABI, provider); // New token launches manager.on("TokenCreate", (creator, curve, token, name, symbol) => { console.log(\`New token: ${name} (${symbol}) at ${token}\`); }); // Migration target reached manager.on("LimitReach", (token) => { console.log(\`${token} ready for Uniswap V2 migration\`); }); // Real-time price from sync events manager.on("sync", (token, realNative, realToken, virtualNative, virtualToken) => { const price = (BigInt(virtualNative) \* BigInt(1e18)) / BigInt(virtualToken); console.log(\`Price update for ${token}: ${ethers.formatEther(price)} ETH/token\`); }); // Query historical events const currentBlock = await provider.getBlockNumber(); const events = await manager.queryFilter( manager.filters.TokenCreate(), currentBlock - 7200, // ~24 hours currentBlock ); \`\`\` {% endtab %} {% tab title="MegaETH" %} \`\`\`javascript const { ethers } = require("ethers"); const MANAGER\_ADDRESS = "0x2978E15501C792152602eC85c299083aa61b1bd4"; const RPC\_URL = "https://mainnet.megaeth.com/rpc"; const provider = new ethers.JsonRpcProvider(RPC\_URL); const manager = new ethers.Contract(MANAGER\_ADDRESS, ABI, provider); // New token launches manager.on("TokenCreate", (creator, curve, token, name, symbol, launchTime, tokenURI) => { console.log(\`New token: ${name} (${symbol}) at ${token}\`); }); // Migration target reached manager.on("LimitReach", (token) => { console.log(\`${token} ready for Kumbaya V3 migration\`); }); // Full migration complete (V3) manager.on("V3Listing", (curve, token, pool, tokenId) => { console.log(\`${token} migrated to Kumbaya V3 pool ${pool}\`); }); // Real-time price from sync events manager.on("sync", (token, realNative, realToken, virtualNative, virtualToken) => { const price = (BigInt(virtualNative) \* BigInt(1e18)) / BigInt(virtualToken); console.log(\`Price update for ${token}: ${ethers.formatEther(price)} ETH/token\`); }); \`\`\` {% endtab %} {% tab title="Robinhood" %} \`\`\`javascript const { ethers } = require("ethers"); const MANAGER\_ADDRESS = "0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d"; const provider = new ethers.JsonRpcProvider(RPC\_URL); // request RPC from the team const manager = new ethers.Contract(MANAGER\_ADDRESS, ABI, provider); // New token launches — note the \`quote\` field (address(0) = ETH) manager.on("TokenCreate", (creator, curve, token, quote, name, symbol, timestamp, tokenURI) => { console.log(\`New token: ${name} (${symbol}) at ${token}, quote ${quote}\`); }); // Migration target reached manager.on("LimitReach", (token) => { console.log(\`${token} ready for Uniswap V3 migration\`); }); // Migration to Uniswap V3 complete manager.on("Listing", (curve, token, pool, tokenId, liquidity) => { console.log(\`${token} migrated to Uniswap V3 pool ${pool}\`); }); // Real-time price from Sync events (capital S; quote-denominated reserves) manager.on("Sync", (token, realQuote, realToken, virtualQuote, virtualToken) => { // reserves are in ETH wei (18 decimals) const price = (BigInt(virtualQuote) \* BigInt(1e18)) / BigInt(virtualToken); console.log(\`Price update for ${token}: ${ethers.formatEther(price)} ETH/token\`); }); \`\`\` {% hint style="info" %} Robinhood event names and fields differ: the price event is \`Sync\` (capital S) with \`Quote\`-named reserves, \`TokenCreate\` carries an extra \`quote\` field, and graduation emits \`Listing\` (Uniswap V3) rather than \`V3Listing\`. {% endhint %} {% endtab %} {% endtabs %} \*\*\* ## Security Checklist ### Slippage protection Always set \`amountOutMin\`. Quote first, then apply tolerance. \`\`\`solidity (uint256 expected, , , , ,) = manager.quoteBuyWithFee(amountIn, token, feeRate); uint256 minOut = expected \* 99 / 100; // 1% tolerance manager.buy{value: amountIn}(amountIn, minOut, token, msg.sender, deadline); \`\`\` ### Deadline Always set a deadline. \`0\` means no expiry — a stuck transaction could execute at an unexpected price. \`\`\`solidity block.timestamp + 300 // 5-minute deadline \`\`\` ### Gwei alignment (sell only — Ethereum & MegaETH) On Ethereum and MegaETH, sell \`amountIn\` must satisfy \`amountIn % 1e9 == 0\`. Round down before selling. Robinhood has no such requirement. \`\`\`solidity uint256 aligned = (amount / 1e9) \* 1e9; \`\`\` ### Approval management Approve the exact amount, not \`type(uint256).max\`. \`\`\`solidity IERC20(token).approve(address(MANAGER), amountToSell); \`\`\` ### Migration check After migration, the bonding curve is closed. Check before acting. \`\`\`solidity address curve = manager.curves(token); require(!IBondingCurve(curve).migrated(), "Token already graduated"); \`\`\` ### Token mode Pre-graduation tokens cannot be moved directly between EOAs — only TrenchManager can. Do not attempt direct transfers before graduation. The mode encoding differs by chain: Ethereum/MegaETH use \`MODE\_TRANSFER\_CONTROLLED\` (2); Robinhood uses \`restricted\` (1) and reverts with \`"Token: restricted"\`. \*\*\* ## Gas Estimates | Operation | Gas | ETH at 20 Gwei | | -------------------------------- | ------ | -------------- | | \`createCurve\` | \\~500k | \\~0.010 ETH | | \`buy\` | \\~150k | \\~0.003 ETH | | \`buyWithFee\` | \\~180k | \\~0.0036 ETH | | \`sell\` | \\~120k | \\~0.0024 ETH | | \`sellWithFee\` | \\~150k | \\~0.003 ETH | | \`quoteBuyWithFee\` / \`previewBuy\` | \\~50k | free (view) | \*Estimates vary with network conditions and token state. On MegaETH, gas costs are significantly lower due to the chain's architecture. Robinhood is an Arbitrum Orbit L2 — gas is priced in ETH and typically far below Ethereum mainnet.\* \*\*\* ## FAQ \*\*Can I buy directly from the BondingCurve contract?\*\* No. All trades must go through TrenchManager (V2 on Ethereum, V3 on MegaETH, the single \`TrenchManager\` on Robinhood). \*\*What happens if I send ETH directly to TrenchManager?\*\* It will revert. ETH must arrive via \`buy()\` or \`buyWithFee()\`. \*\*How is Robinhood different from the other chains?\*\* Robinhood is a single-layer launchpad — users call \`TrenchManager\` directly, with no aggregation or vault layer. Tokens are quoted in native ETH; curve reserves are named \`Quote\` rather than \`Native\`, and factory reads take a \`quote\` argument (\`getConfig(quote)\` — pass \`address(0)\` for ETH). The protocol trade fee is \*\*1%\*\* (dev 30% / protocol 70%), the listing fee is \*\*2%\*\*, buy quoting uses \`previewBuy\`, and there is no Gwei-alignment requirement on sells. \*\*Can I remove liquidity after graduation?\*\* On Ethereum: no — LP tokens are burned to \`address(0)\`, liquidity is permanently locked, and no one collects LP fees. On MegaETH: the LP NFT (Kumbaya V3 full-range position) is held by the protocol's LP receiver wallet. Liquidity cannot be removed by token creators or traders. The Kumbaya V3 pool charges a \*\*0.01% fee\*\* on every post-graduation swap; those fees accrue to the LP position held by the protocol. On Robinhood: graduation creates a Uniswap V3 full-range position (fee tier \*\*1%\*\*) whose LP NFT is held by the \*\*LPFeeSplitter\*\* contract; liquidity cannot be removed by creators or traders, but the pool's swap fees are split (see below). \*\*Do devs earn after graduation on Robinhood?\*\* Yes. Unlike the other chains, Robinhood shares the post-graduation Uniswap V3 swap fees. The graduation LP NFT mints to the \*\*LPFeeSplitter\*\* (\`0x74a40b65320c717F0ECF74f68CcB910edCd08e22\`), which splits the quote-side (ETH) fees \*\*dev 60% / protocol 40%\*\* (ratio in \`devShareBps\`, currently \`6000\`). This is separate from the on-curve \`FeeVault\` (dev 30% of the 1% trade fee). A creator claims with \`LPFeeSplitter.claim(creator)\` — one tx, no approval, WETH auto-unwrapped to ETH. To estimate claimable, read \`creatorCredits(creator, address(0))\` and add uncollected pending × \`devShareBps\`. Only tokens that graduate after this mechanism went live are covered. \*\*Why does sell require Gwei alignment?\*\* Internal precision requirement on Ethereum and MegaETH. Round down: \`(amount / 1e9) \* 1e9\`. Robinhood has no such requirement. \*\*What is the maximum platform fee?\*\* 5% on all chains. Exceeding it reverts with \`ERR\_BUY\_FEE\_RATE\` / \`ERR\_SELL\_FEE\_RATE\` (Ethereum/MegaETH), or the \`extraFeeRate\` bound on Robinhood. \*\*How do I detect when a token graduates?\*\* Listen for the \`LimitReach\` event, or poll \`IBondingCurve(curve).migrating()\`. On MegaETH, listen for \`V3Listing\`; on Robinhood, listen for \`Listing\` to confirm migration to Uniswap V3 is complete. \*\*What DEX does graduation target?\*\* Ethereum → Uniswap V2. MegaETH → Kumbaya V3 (full-range position, fee tier 0.01%). Robinhood → Uniswap V3 (full-range position, fee tier 1%). --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/for-developers/integration-guide.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/how-it-works.md). # How It Works Every token on Trench follows the same lifecycle: \*\*curve → graduation → DEX\*\*. This page walks through each stage, explains where the price comes from, and traces the fee flow. ## The two‑stage lifecycle A token on Trench lives two lives. {% columns %} {% column %} ### Stage 1 · Bonding Curve Only on Trench. Trades price automatically against a constant‑product curve. No order book, no market makers. The curve is where a token goes from zero holders to its first few hundred. {% endcolumn %} {% column %} ### Stage 2 · DEX Graduation triggers once the curve fills. Liquidity migrates automatically and the token trades like any other ERC‑20. On \*\*Ethereum\*\*, it graduates to \*\*Uniswap V2\*\* with LP permanently burned. On \*\*MegaETH\*\*, it graduates to \*\*Kumbaya V3\*\* with LP held by the protocol. On \*\*Robinhood\*\*, it graduates to \*\*Uniswap V3\*\* with LP held by the protocol. From here, Trench steps out of the way. {% endcolumn %} {% endcolumns %} {% hint style="info" %} The curve is closed the instant a token graduates. All trading moves to the DEX, and every aggregator that indexes it will see the token automatically. {% endhint %} ## Stage 1 · The bonding curve ### What a bonding curve actually does Think of the curve as a \*\*vending machine with a sliding price\*\*: \* Every token you buy makes the next token slightly more expensive. \* Every token you sell makes the next token slightly cheaper. \* Nobody sets the price — it's a pure function of how much has been bought minus sold. There's no order book. No market makers. No front‑running your own price discovery. ### The math (for the curious) Trench uses the classic \*\*constant‑product formula\*\*: $$ x \\cdot y = k $$ Where \`x\` is the ETH reserve, \`y\` is the token reserve, and \`k\` stays constant. Buying tokens raises \`x\` and lowers \`y\` — which means the price \`x / y\` rises. It's the same math Uniswap V2 uses, tuned for a fair‑launch context. ### Starting parameters Every token on Trench starts with the same curve shape per chain, so every launch on the same chain is on equal footing. | Parameter | Ethereum Mainnet | MegaETH Mainnet | Robinhood Mainnet | What it means | | ---------------------------- | ---------------- | --------------- | ----------------- | ----------------------------------------------------------------------- | | Total supply | 1,000,000,000 | 1,000,000,000 | 1,000,000,000 | Hard cap. Minted once, at deploy. | | On the curve | 80% (800 M) | 80% (800 M) | 80% (800 M) | Real tokens sellable through the curve. | | Reserved for DEX | 20% (200 M) | 20% (200 M) | 20% (200 M) | Set aside to seed the DEX pool at graduation. | | Starting virtual ETH reserve | \\~2.009 ETH | \\~2.027 ETH | \\~1.712 ETH | The ETH the curve pretends to start with. Shapes price impact. | | \*\*Graduation threshold\*\* | \*\*\\~6 ETH\*\* | \*\*\\~5.5 ETH\*\* | \*\*\\~5 ETH\*\* | Once this much ETH has been bought into the curve, the token graduates. | ## Stage 2 · Graduation ### What graduation means When enough ETH has been bought into the curve, the token \*\*graduates\*\*. Three things happen in a single atomic sequence: {% stepper %} {% step %} #### The curve closes No more buys or sells happen on Trench's AMM. The curve contract is frozen. {% endstep %} {% step %} #### Liquidity migrates to the DEX The ETH collected by the curve, together with the \*\*20% of supply\*\* reserved at launch, becomes an LP position on the target DEX. {% endstep %} {% step %} #### LP is secured On \*\*Ethereum\*\*: LP tokens are burned to a dead address — liquidity is permanently locked forever. On \*\*MegaETH\*\*: the LP NFT (Kumbaya V3 full-range position) is sent to the protocol's LP receiver wallet and held by the protocol. On \*\*Robinhood\*\*: the LP NFT (Uniswap V3 full-range position) is sent to the protocol's LP receiver wallet and held by the protocol. {% endstep %} {% endstepper %} From here, the token trades like any ERC‑20 on the DEX. Price discovery continues, arbitrageurs show up, and the token becomes visible on every aggregator that indexes the pool. ### Why LP security matters There is \*\*no rug path\*\*. The dev doesn't have the keys to pull liquidity. The platform controls the LP only to hold it — not to drain it. The liquidity belongs to the pool, not to any individual. This is the single most important property of a launchpad. Trench treats it as table stakes. ## Fees Trench keeps the fee model simple and transparent on the curve. After graduation, the DEX takes over and Trench steps out entirely. ### On the curve Every trade pays a flat fee, split between the deployer and the protocol. The exact rate and split depend on the chain: | Chain | Trade fee | Dev share | Protocol share | | ------------- | --------- | ----------------- | ------------------ | | \*\*Ethereum\*\* | 1.25% | 0.3% (24% of fee) | 0.95% (76% of fee) | | \*\*MegaETH\*\* | 1.25% | 0.3% (24% of fee) | 0.95% (76% of fee) | | \*\*Robinhood\*\* | 1% | 0.3% (30% of fee) | 0.7% (70% of fee) | No buy tax. No sell tax. No hidden "liquidity fee" coming out of your trade — the trade fee is the whole number. ### At graduation Graduation costs real ETH. Deploying a DEX pool, seeding initial liquidity, and ensuring the migration succeeds all consume gas. A \*\*listing fee\*\* is deducted from the ETH raised by the curve at the moment of migration — this covers graduation expenses and seeds the initial LP. The rate is \*\*8%\*\* on Ethereum and MegaETH, and \*\*2%\*\* on Robinhood. The upshot: \*\*no surprise cost after migration\*\*, and no situation where a token gets stuck because graduation couldn't be funded. Every curve that fills up graduates, no friction. ### After graduation On \*\*Ethereum\*\*, Trench collects no fees after graduation — LP tokens are burned, so no one holds an LP position, and pool fees are effectively unclaimable. Trench is out of the picture. On \*\*MegaETH\*\*, the Kumbaya V3 LP NFT is held by the protocol's LP receiver wallet. The V3 pool charges a \*\*0.01% fee\*\* on every post-graduation trade, and those fees accrue to the LP position held by the protocol. Trench does not redistribute these fees to token creators or traders. On \*\*Robinhood\*\*, dev rewards keep flowing after graduation. The Uniswap V3 LP NFT is held by the \*\*LPFeeSplitter\*\* contract. The V3 pool charges a \*\*1% fee\*\* on every post-graduation trade, and the splitter divides the ETH-side fees \*\*60% to the deployer, 40% to the protocol\*\* (the meme side goes to the protocol). Liquidity still can't be removed — only the swap fees are split. So a Robinhood dev earns twice: the curve fee while trading on Trench, then a share of every DEX swap for the life of the token. (This applies to tokens that graduate after the split went live.) ### Dev rewards in detail If you launched the token, you earn \*\*0.3% of every trade on its curve\*\* for as long as the curve is live. \* \*\*Payout:\*\* Fees are paid in ETH to the \*\*deployer wallet\*\*. There's nothing to configure at launch — the wallet that signed the deploy is the wallet that earns. \* \*\*Where to claim:\*\* The \*\*Fee Vault panel\*\* on the Trench homepage. It's visible to any wallet that has launched at least one token, and it aggregates fees across every token you've ever deployed. \* \*\*One button, one tx:\*\* Claim sweeps all unclaimed fees across all your tokens in a single transaction. \* \*\*After graduation:\*\* Curve fees stop for that token. On Ethereum and MegaETH the DEX takes over and Trench collects nothing for the dev. On \*\*Robinhood\*\*, the dev keeps earning \*\*60% of the Uniswap V3 swap fees\*\* via the LPFeeSplitter — claimed separately from the curve fees. {% hint style="warning" %} Dev fees cannot be paid to an X handle, an email, or any off‑chain destination. They always go to the deployer wallet — the one that signed the \`launch\` transaction. {% endhint %} ## Next \* \[\*\*Getting Started\*\*\](/trench-today/getting-started.md) — launch, trade, claim. \* \[\*\*API Overview\*\*\](/trench-today/for-developers/api.md) — pull curve state, trades, and token metadata into your product. --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/how-it-works.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # Unknown \> For the complete documentation index, see \[llms.txt\](https://trench-today.gitbook.io/trench-today/llms.txt). Markdown versions of documentation pages are available by appending \`.md\` to page URLs; this page is available as \[Markdown\](https://trench-today.gitbook.io/trench-today/for-developers/contracts.md). # Contract Reference {% tabs %} {% tab title="Ethereum Mainnet" %} ## Deployments | Contract | Address | | --------------------------- | -------------------------------------------- | | \*\*TrenchManagerV2\*\* (Proxy) | \`0x974B2d86d6353c62f19110127aF1A5df4c6370f0\` | | \*\*FeeVault\*\* | \`0x18D9Ddd296b676d68e6658BcC6Dcdb6C23C28457\` | | \*\*BondingCurveFactory\*\* | \`0x02acb27BD38AB7aE4b569bA7251Ff31739Bd8E36\` | ## On-chain parameters | Parameter | Value | Description | | ------------------------------------ | ----------------------------------------------------------- | --------------------------------------------------------------- | | Trade fee | 1.25% (\`12,500,000 / 1e9\`) | Applied to \`amountIn\` on every buy and sell. | | Creator share | 24% of trade fee | ≈ 0.3% of trade size. Accrues in FeeVault. | | Protocol share | 76% of trade fee | ≈ 0.95% of trade size. | | \`virtualNative\` | \`2009158000000000000\` (\\~2.009 ETH) | Starting virtual ETH reserve. | | \`virtualToken\` | \`1068000000000000000000000000\` (\\~1.068 × 10²⁷) | Starting virtual token reserve. | | Total supply | \`1000000000000000000000000000\` (1 × 10²⁷, 1 billion tokens) | Fixed, minted at deploy. | | Graduation threshold (\`targetToken\`) | \`200000000000000000000000000\` (2 × 10²⁶, 200 M tokens) | Migration triggers when real token reserves drop to this level. | | Max platform fee | 5% (\`500 / 10,000\`) | Max rate for \`buyWithFee\` / \`sellWithFee\`. | | Minimum claim | 0.01 ETH | Below this, \`devClaim\` is rejected. | ## TrenchManagerV2 ABI ### Trading functions #### \`createCurve\` Deploy a new token and bonding curve. \`msg.value\` = \`amountIn\` (the initial dev buy, or 0). \`\`\`solidity function createCurve( address creator, string name, string symbol, string tokenURI, uint256 amountIn, // ETH for initial dev buy; 0 = no dev buy uint256 amountOutMin, bytes32 salt ) external payable returns ( address curve, address token, uint256 virtualNative, uint256 virtualToken, uint256 amountOut ); \`\`\` #### \`buy\` Buy tokens with ETH. No platform fee. \`\`\`solidity function buy( uint256 amountIn, // must equal msg.value uint256 amountOutMin, // slippage protection address token, address to, // token recipient uint256 deadline // unix timestamp; 0 = no deadline ) external payable returns (uint256 amountOut); \`\`\` #### \`buyWithFee\` Buy tokens with an additional platform fee (up to 5%). \`\`\`solidity function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 buyFeeRate, // denominator 10,000; max 500 (= 5%) address buyFeeReceiver // must not be address(0) ) external payable returns (uint256 amountOut); \`\`\` Fee flow: \`\`\` Platform fee = amountIn × buyFeeRate / 10000 → buyFeeReceiver Protocol fee = (amountIn − platform fee) × 1.25% → FeeVault Curve input = amountIn − platform fee − protocol fee \`\`\` #### \`sell\` Sell tokens for ETH. No platform fee. Requires prior \`ERC20.approve\`. \`\`\`solidity function sell( uint256 amountIn, // token wei — must be Gwei-aligned (amountIn % 1e9 == 0) uint256 amountOutMin, address token, address to, // ETH recipient uint256 deadline ) external returns (uint256 amountOut); \`\`\` #### \`sellWithFee\` Sell tokens with an additional platform fee (up to 5%). \`\`\`solidity function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 sellFeeRate, // denominator 10,000; max 500 (= 5%) address sellFeeReceiver ) external returns (uint256 amountOut); \`\`\` Fee flow: \`\`\` Curve output = calculated from bonding curve Protocol fee = curve output × 1.25% → FeeVault Platform fee = curve output × sellFeeRate / 10000 → sellFeeReceiver User receives = curve output − protocol fee − platform fee \`\`\` ### Quote functions #### \`quoteBuyWithFee\` Estimate output and fee breakdown for a buy without sending a transaction. \`\`\`solidity function quoteBuyWithFee( uint256 amountIn, address token, uint256 buyFeeRate ) external view returns ( uint256 amountOut, // tokens user will receive uint256 protocolFee, uint256 buyFee, // platform fee uint256 grossAmountUsed, // ETH entering the curve uint256 totalAmountInUsed, // total ETH consumed uint256 refundAmount // ETH refunded if graduation hit mid-purchase ); \`\`\` #### \`quoteSellWithFee\` Estimate output and fee breakdown for a sell without sending a transaction. \`\`\`solidity function quoteSellWithFee( uint256 amountIn, address token, uint256 sellFeeRate ) external view returns ( uint256 grossAmountOut, // total ETH from curve uint256 netAmountOut, // ETH user will receive after all fees uint256 protocolFee, uint256 sellFee // platform fee ); \`\`\` ### Mapping queries \`\`\`solidity function curves(address token) external view returns (address curve); // BondingCurve for a token function creators(address token) external view returns (address creator); // creator wallet for a token function factory() external view returns (address); function wNative() external view returns (address); // WETH function vault() external view returns (address); // FeeVault \`\`\` ## IBondingCurve ABI One \`BondingCurve\` contract is deployed per token. Query it for reserves and graduation status. \`\`\`solidity function realNativeReserves() external view returns (uint256); function realTokenReserves() external view returns (uint256); function getVirtualReserves() external view returns (uint256 virtualNative, uint256 virtualToken); function getK() external view returns (uint256); function getTargetToken() external view returns (uint256); // 200 M tokens function getRemainingTokenToSell() external view returns (uint256); function migrating() external view returns (bool); // true = graduation threshold hit function migrated() external view returns (bool); // true = listed on Uniswap V2 function token() external view returns (address); function wNative() external view returns (address); function pair() external view returns (address); // Uniswap V2 pair (post-migration) \`\`\` ## IBondingCurveFactory ABI \`\`\`solidity struct Config { uint256 listingFeeRate; uint256 tokenTotalSupply; // 1e27 uint256 virtualNative; // ~2.009 ETH uint256 virtualToken; // ~1.068e27 uint256 k; uint256 targetToken; // 200 M tokens uint256 realNativeReserves; // initial = 0 uint256 realTokenReserves; // initial = 1e27 } function getConfig() external view returns (Config memory); function wNative() external view returns (address); function getDexFactory() external view returns (address); // Uniswap V2 factory function getListingFeeRate() external view returns (uint256); \`\`\` ## IToken (ERC-20) Standard ERC-20 plus a \`mode\` field that controls transfer permissions before graduation. \`\`\`solidity function mode() external view returns (uint8); // 0 = normal, 2 = controlled (pre-graduation) function trenchManager() external view returns (address); // Standard ERC-20 function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // always 18 function totalSupply() external view returns (uint256); // always 1e27 function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transfer(address to, uint256 amount) external returns (bool); function transferFrom(address from, address to, uint256 amount) external returns (bool); \`\`\` | Mode | Value | Who can transfer | | -------------------------- | ----- | ----------------------------------- | | \`MODE\_NORMAL\` | \`0\` | Anyone (post-graduation) | | \`MODE\_TRANSFER\_RESTRICTED\` | \`1\` | No one (reserved) | | \`MODE\_TRANSFER\_CONTROLLED\` | \`2\` | Only TrenchManager (pre-graduation) | ## Events | Event | Emitted when | Key fields | | --------------- | ------------------------------ | --------------------------------------------------------------------------------------------- | | \`TokenCreate\` | New token deployed | \`creator, curve, token, name, symbol, launchTime, tokenURI\` | | \`TokenPurchase\` | Buy executed | \`token, account, amountToken, amountQuote, protocolFee, buyFee, buyFeeReceiver, buyFeeRate\` | | \`TokenSale\` | Sell executed | \`token, account, amountToken, amountQuote, protocolFee, sellFee, sellFeeReceiver\` | | \`LimitReach\` | Graduation threshold hit | \`token\` (indexed) | | \`Listing\` | Migrated to Uniswap V2 | \`curve, token, pair\` (all indexed), \`listingWNativeAmount, listingTokenAmount, burnLiquidity\` | | \`sync\` | Reserves updated (every trade) | \`token, realNativeReserves, realTokenReserves, virtualNativeReserve, virtualTokenReserve\` | ## Error codes ### TrenchManagerV2 | Error | Description | | --------------------------------- | -------------------------------------- | | \`ERR\_CORE\_EXPIRED\` | Transaction deadline passed | | \`ERR\_CORE\_INVALID\_AMOUNT\_IN\` | \`msg.value\` doesn't match \`amountIn\` | | \`ERR\_CORE\_INVALID\_AMOUNT\_OUT\` | Output below \`amountOutMin\` (slippage) | | \`ERR\_CORE\_CURVE\_NOT\_FOUND\` | Token has no bonding curve | | \`ERR\_CORE\_CURVE\_ALREADY\_MIGRATED\` | Token already graduated | | \`ERR\_CORE\_INVALID\_FEE\` | Fee rate exceeds 5% maximum | | \`ERR\_CORE\_GWEI\` | Sell \`amountIn\` not Gwei-aligned | | \`ERR\_BUY\_FEE\_RATE\` | \`buyFeeRate\` > 500 | | \`ERR\_BUY\_FEE\_RECEIVER\` | \`buyFeeReceiver\` is \`address(0)\` | | \`ERR\_SELL\_FEE\_RATE\` | \`sellFeeRate\` > 500 | | \`ERR\_SELL\_FEE\_RECEIVER\` | \`sellFeeReceiver\` is \`address(0)\` | ### BondingCurve | Error | Description | | -------------------------------------------------- | ------------------------------------------ | | \`ERR\_BONDING\_CURVE\_NOT\_TRADABLE\` | Curve is migrating or migrated | | \`ERR\_BONDING\_CURVE\_OVERFLOW\_TARGET\` | Purchase would exceed graduation threshold | | \`ERR\_BONDING\_CURVE\_INSUFFICIENT\_RESERVE\` | Insufficient reserves for sell | | \`ERR\_BONDING\_CURVE\_LIBRARY\_INSUFFICIENT\_LIQUIDITY\` | Trade size exceeds available liquidity | ### Token | Error | Description | | ------------------------------- | ------------------------------------------------------- | | \`ERR\_TOKEN\_TRANSFER\_RESTRICTED\` | Direct transfer attempted in \`MODE\_TRANSFER\_CONTROLLED\` | | \`ERR\_TOKEN\_INVALID\_TRANSFER\` | Invalid transfer parameters | | {% endtab %} | | {% tab title="MegaETH Mainnet" %} ## Network info | | | | -------- | --------------------------------- | | Chain ID | \`4326\` | | RPC | \`https://mainnet.megaeth.com/rpc\` | | Explorer | \`https://megaexplorer.xyz\` | ## Deployments | Contract | Address | Description | | --------------------------- | -------------------------------------------- | ---------------------------------------------- | | \*\*TrenchManagerV3\*\* (Proxy) | \`0x2978E15501C792152602eC85c299083aa61b1bd4\` | Main entry point for all interactions | | ProxyAdmin | \`0xbB9DBc3028D2318eC7D0Ada935711042A9ea69C2\` | Proxy admin contract | | TrenchManagerV3 Impl | \`0x95CCeBaf5C664E18cB569386Bf38a3771a804943\` | Current implementation | | BondingCurveFactory | \`0xA25890Dd71eF04955baF57F93D27380d1e235f8A\` | Curve and token factory | | FeeVault | \`0x6adaC2FC414032f49BC7C4B9F2C5EA7B2D4dd4AD\` | Protocol fee collection and distribution | | WETH (WNative) | \`0x4200000000000000000000000000000000000006\` | Wrapped ETH | | Kumbaya V3 Position Manager | \`0x2b781C57e6358f64864Ff8EC464a03Fdaf9974bA\` | V3 LP position NFT manager (graduation target) | \*\*Admin addresses\*\*: | Role | Address | | -------------------------------- | -------------------------------------------- | | Owner | \`0xbeb76A70c82B09E30B2008eAFa7F987987EC9e0b\` | | Migrator | \`0xfB771beb315D7d6512b414496D012d3B084B17bF\` | | LP Receiver | \`0xfB771beb315D7d6512b414496D012d3B084B17bF\` | | Listing Fee Receiver | \`0x551c19aCbEAE33C07b98120cC2992Ec70e943e79\` | | Protocol Fee Receiver (FeeVault) | \`0x39d91743ee3BB4CecfD3331e84185D29898Da34C\` | ## On-chain parameters ### Trading fee | Parameter | Value | Description | | ---------------- | -------------------------- | ------------------------------------------ | | Trade fee | 1.25% (\`12,500,000 / 1e9\`) | Applied to every buy and sell. | | Creator share | 24% of trade fee | ≈ 0.3% of trade size. Accrues in FeeVault. | | Protocol share | 76% of trade fee | ≈ 0.95% of trade size. | | Max platform fee | 5% (\`50,000,000 / 1e9\`) | Max rate for \`buyWithFee\` / \`sellWithFee\`. | ### Bonding curve config | Parameter | Value | Description | | ------------------------------------ | ------------------------------------------- | ---------------------------------------- | | Total supply | \`1,000,000,000\` (1e27 wei, 18 decimals) | Fixed per token. | | \`virtualNative\` (initial) | \`2026585820895522388\` (\\~2.027 ETH) | Starting virtual ETH reserve. | | \`virtualToken\` (initial) | \`1098507462686567164179104478\` (\\~1.099e27) | Starting virtual token reserve. | | Graduation threshold (\`targetToken\`) | \`200,000,000\` (2e26 wei) | Remaining tokens in curve at graduation. | | Expected ETH raised (net) | \\~5.43 ETH | ETH in curve at graduation. | | Total user spend (inc. fee) | \\~5.5 ETH | Gross ETH to fill curve. | ### Listing / migration | Parameter | Value | Description | | -------------------- | -------------------------------------------- | --------------------------------------- | | Listing fee rate | 800 / 10000 = \*\*8%\*\* | Deducted from raised ETH at graduation. | | Listing fee receiver | \`0x551c19aCbEAE33C07b98120cC2992Ec70e943e79\` | Receives listing fee at migration. | | Kumbaya V3 fee tier | 100 (= 0.01%) | V3 pool fee tier. | ### FeeVault | Parameter | Value | | ------------------ | --------- | | Min dev claim | 0.001 ETH | | Min protocol claim | 0.001 ETH | ## TrenchManagerV3 ABI ### Trading functions #### \`createCurve\` Deploy a new token and bonding curve. Optionally performs an initial dev buy. The contract pre-initializes a Kumbaya V3 anchor position at the graduation price using 1e12 wei from its own balance. \`\`\`solidity function createCurve( address creator, string name, string symbol, string tokenURI, uint256 amountIn, // ETH for initial dev buy; 0 = no dev buy uint256 amountOutMin, bytes32 salt ) external payable returns ( address curve, address token, uint256 virtualNative, uint256 virtualToken, uint256 amountOut ); \`\`\` #### \`buy\` Buy tokens with ETH. No platform fee. \`\`\`solidity function buy( uint256 amountIn, // must equal msg.value uint256 amountOutMin, address token, address to, uint256 deadline ) external payable returns (uint256 amountOut); \`\`\` #### \`buyWithFee\` Buy tokens with an additional platform fee (up to 5%). \`\`\`solidity function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 buyFeeRate, // denominator 1e9; max 50,000,000 (= 5%) address buyFeeReceiver ) external payable returns (uint256 amountOut); \`\`\` Fee flow: \`\`\` Platform fee = amountIn × buyFeeRate / 1e9 → buyFeeReceiver Protocol fee = (amountIn − platform fee) × 1.25% → FeeVault Curve input = amountIn − platform fee − protocol fee \`\`\` #### \`sell\` Sell tokens for ETH. Requires prior \`ERC20.approve\`. \`\`\`solidity function sell( uint256 amountIn, // token wei — must be Gwei-aligned (amountIn % 1e9 == 0) uint256 amountOutMin, address token, address to, uint256 deadline ) external returns (uint256 amountOut); \`\`\` #### \`sellWithFee\` Sell tokens with an additional platform fee (up to 5%). \`\`\`solidity function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 sellFeeRate, address sellFeeReceiver ) external returns (uint256 amountOut); \`\`\` ### Quote functions #### \`quoteBuyWithFee\` Simulate a buy. Returns estimated output and full fee breakdown. \`\`\`solidity function quoteBuyWithFee( uint256 amountIn, address token, uint256 buyFeeRate ) external view returns ( uint256 amountOut, uint256 protocolFee, uint256 buyFee, uint256 newVirtualNative, uint256 newVirtualToken, uint256 newRealNative ); \`\`\` #### \`quoteSellWithFee\` Simulate a sell. \`amountIn\` must be divisible by 1e9. \`\`\`solidity function quoteSellWithFee( uint256 amountIn, address token, uint256 sellFeeRate ) external view returns ( uint256 amountOut, uint256 protocolFee, uint256 sellFee, uint256 newRealNative ); \`\`\` ### Query functions \`\`\`solidity function curves(address token) external view returns (address curve); function creators(address token) external view returns (address creator); function tokenInfo(address token) external view returns ( address curve, address creator, uint256 realNativeReserves, uint256 realTokenReserves, uint256 virtualNativeReserve, uint256 virtualTokenReserve, bool isMigrating, bool isMigrated ); function factory() external view returns (address); function vault() external view returns (address); function wNative() external view returns (address); function migrator() external view returns (address); \`\`\` ### Migration (V3) \`\`\`solidity function migrateToV3( address token, uint256 amount0Min, uint256 amount1Min, uint256 deadline // 0 = no deadline ) external returns ( address pool, uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); \`\`\` Only callable by the whitelisted migrator. Deducts listing fee (8%), seeds the Kumbaya V3 full-range position, sends the LP NFT to \`LP\_receiver\`, and sets token mode to 0. ## IBondingCurve ABI One \`BondingCurve\` contract is deployed per token. Query via \`TrenchManagerV3.curves(token)\`. \`\`\`solidity function getVirtualReserves() external view returns (uint256 virtualWNative, uint256 virtualToken); function getReserves() external view returns (uint256 reserveWNative, uint256 reserveToken); function getRemainingTokenToSell() external view returns (uint256); function getTargetToken() external view returns (uint256); // 200 M tokens function getK() external view returns (uint256); function isMigrating() external view returns (bool); // true = curve filled, awaiting migration function isMigrated() external view returns (bool); // true = migrated to Kumbaya V3 function migrating() external view returns (bool); // raw storage accessor function migrated() external view returns (bool); // raw storage accessor function token() external view returns (address); function realNativeReserves() external view returns (uint256); function realTokenReserves() external view returns (uint256); \`\`\` {% hint style="info" %} Unlike Ethereum's BondingCurve, there is no \`pair()\` function — graduation goes to a Kumbaya V3 pool, not a V2 pair. {% endhint %} ## IBondingCurveFactory ABI \`\`\`solidity struct Config { uint256 listingFeeRate; // 800 (8%) uint256 tokenTotalSupply; // 1e27 uint256 virtualNative; // 2026585820895522388 (~2.027 ETH) uint256 virtualToken; // 1098507462686567164179104478 uint256 k; uint256 targetToken; // 2e26 uint256 realNativeReserves; // 0 at init uint256 realTokenReserves; // 1e27 at init } function getConfig() external view returns (Config memory); function getK() external view returns (uint256); function getListingFeeRate() external view returns (uint256); function getDexFactory() external view returns (address); // legacy, unused on MegaETH function getOwner() external view returns (address); function getTrenchManager() external view returns (address); \`\`\` ## IFeeVault ABI \`\`\`solidity function credit(address creator, address token, uint256 amount) external payable; function creditsDev(address creator) external view returns (uint256); // accrued dev fee function creditsProtocol() external view returns (uint256); // accrued protocol fee function devClaim(address creator) external; // anyone can call; ETH goes to creator function protocolClaim(uint256 amount) external; function feeReceiver() external view returns (address); function DEV\_CLAIM\_RATIO() external view returns (uint256); // 2400 function DEV\_CLAIM\_RATIO\_DENOMINATOR() external view returns (uint256); // 10000 \`\`\` ## IToken (ERC-20) Standard ERC-20 with transfer restriction modes: | Mode | Value | Behavior | | -------------------------- | ----- | -------------------------------------------------------------------- | | \`MODE\_NORMAL\` | \`0\` | Free transfer (post-graduation) | | \`MODE\_TRANSFER\_RESTRICTED\` | \`1\` | All transfers blocked (emergency) | | \`MODE\_TRANSFER\_CONTROLLED\` | \`2\` | Only transfers involving TrenchManager allowed (default at creation) | \`\`\`solidity function setMode(uint256 v) external; // only TrenchManager; cannot leave mode 0 function trenchManager() external view returns (address); function \_mode() external view returns (uint256); function \_metaUrl() external view returns (string memory); \`\`\` ## Events ### TrenchManagerV3 | Event | Key fields | When | | ----------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------- | | \`TokenCreate\` | \`creator, curve, token, name, symbol, launchTime, tokenURI\` | New token created | | \`TokenPurchase\` | \`token, account, amountToken, amountQuote, protocolFee, buyFee, buyFeeReceiver, buyFeeRate\` | Token bought | | \`TokenSale\` | \`token, account, amountToken, amountQuote, protocolFee, sellFee, sellFeeReceiver\` | Token sold | | \`sync\` | \`token, realNativeReserves, realTokenReserves, virtualNativeReserve, virtualTokenReserve\` | After every trade | | \`LimitReach\` | \`token\` (indexed) | Curve filled — trading halted | | \`TradeStop\` | \`token\` | Trading halted | | \`V3AnchorListing\` | \`curve, token, pool, tokenId, liquidity, nativeAmount, tokenAmount, sqrtPriceX96, tickLower, tickUpper\` | Anchor LP minted at \`createCurve\` | | \`V3Listing\` | \`curve, token, pool, tokenId, liquidity, amount0, amount1, sqrtPriceX96, tickLower, tickUpper\` | Full migration to Kumbaya V3 complete | ### FeeVault | Event | Key fields | When | | ----------------- | ----------------------------- | ------------------------ | | \`Credit\` | \`token\` (indexed), \`amount\` | Fee deposited from trade | | \`DevClaim\` | \`creator\` (indexed), \`amount\` | Creator claimed fee | | \`TrechOwnerClaim\` | \`amount\` | Protocol fee withdrawn | ## Error codes ### TrenchManagerV3 | Error | Description | | --------------------------------- | ---------------------------------------------- | | \`ERR\_CORE\_CURVE\_NOT\_FOUND\` | Token not registered | | \`ERR\_CORE\_INVALID\_AMOUNT\_OUT\` | Output below \`amountOutMin\` (slippage) | | \`ERR\_CORE\_EXPIRED\` | Transaction deadline passed | | \`ERR\_CORE\_INVALID\_AMOUNT\_IN\` | Zero or invalid input amount | | \`ERR\_CORE\_INVALID\_SEND\_NATIVE\` | \`msg.value < amountIn\` | | \`ERR\_CORE\_GWEI\` | Sell \`amountIn\` not Gwei-aligned | | \`ERR\_BUY\_FEE\_RATE\` | \`buyFeeRate\` > 5% | | \`ERR\_BUY\_FEE\_RECEIVER\` | \`buyFeeRate > 0\` but receiver is zero address | | \`ERR\_SELL\_FEE\_RATE\` | \`sellFeeRate\` > 5% | | \`ERR\_SELL\_FEE\_RECEIVER\` | \`sellFeeRate > 0\` but receiver is zero address | | \`ERR\_CORE\_INVALID\_ALLOWANCE\` | Insufficient ERC-20 approval for sell | | \`ERR\_CORE\_CURVE\_NOT\_MIGRATING\` | Token not in migrating state | | \`ERR\_CORE\_CURVE\_ALREADY\_MIGRATED\` | Token already migrated | | \`ERR\_CORE\_ONLY\_MIGRATOR\` | Caller is not whitelisted migrator | | \`ERR\_CORE\_V3\_NOT\_CONFIGURED\` | V3 position manager or fee not set | | \`ERR\_CORE\_V3\_ZERO\_LIQUIDITY\` | Minted LP has zero liquidity | | \`ERR\_CORE\_INVALID\_LP\_RECEIVER\` | \`LP\_receiver\` not set | ### BondingCurve | Error | Description | | --------------------------------------- | -------------------------------- | | \`ERR\_BONDING\_CURVE\_ONLY\_TRENCH\_MANAGER\` | Only TrenchManager can call | | \`ERR\_BONDING\_CURVE\_FINISHED\` | Curve already graduated | | \`ERR\_BONDING\_CURVE\_INVALID\_AMOUNT\_OUT\` | Computed output too low | | \`ERR\_BONDING\_CURVE\_INVALID\_AMOUNT\_IN\` | Zero input | | \`ERR\_BONDING\_CURVE\_OVERFLOW\_TARGET\` | Buy exceeds remaining capacity | | \`ERR\_BONDING\_CURVE\_NOT\_TRADABLE\` | Trading halted (migrating state) | | \`ERR\_BONDING\_CURVE\_ALREADY\_MIGRATED\` | Curve already migrated | ### Token | Error | Description | | ------------------------------- | ------------------------------------- | | \`ERR\_TOKEN\_INVALID\_TRANSFER\` | Transfer blocked by mode 2 | | \`ERR\_TOKEN\_TRANSFER\_RESTRICTED\` | Transfer blocked by mode 1 | | \`ERR\_TOKEN\_INVALID\_OWNER\` | Only TrenchManager can call \`setMode\` | ### FeeVault | Error | Description | | ----------------------------------- | -------------------------------------- | | \`TOO\_SMALL\` | Claim amount below 0.001 ETH minimum | | \`ERR\_FEE\_VAULT\_ONLY\_TRENCH\_MANAGER\` | Only TrenchManager can call \`credit()\` | | {% endtab %} | | {% tab title="Robinhood Mainnet" %} ## Network info | | | | --------------- | ----------------- | | Chain ID | \`4663\` | | Architecture | Arbitrum Orbit L2 | | Native currency | ETH (18 decimals) | {% hint style="info" %} Robinhood is a single-layer launchpad: users call \*\*TrenchManager\*\* directly, with no aggregation or vault layer in between. Tokens are quoted in native \*\*ETH\*\*. RPC endpoint is available from the team on request. {% endhint %} ## Deployments | Contract | Address | Description | | -------------------------------- | -------------------------------------------- | ------------------------------------------------------------------ | | \*\*TrenchManager\*\* | \`0x77dC6f6361b7b99456FC3761ce5b7ddA80d83f9d\` | Single entry point for all interactions and the \`approve\` target | | BondingCurveFactory | \`0x2ECFb98BCe4f3616115E4a2A7a2379AF388DFbAA\` | Curve and token factory | | FeeVault | \`0x076e3Cd13E188e3646828e7cEBB766C7Dd6aDb8A\` | Protocol/dev fee collection on the curve (ETH) | | LPFeeSplitter | \`0x74a40b65320c717F0ECF74f68CcB910edCd08e22\` | Post-graduation Uniswap V3 swap-fee split (dev 60% / protocol 40%) | | WETH (WNative) | \`0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73\` | Wrapped ETH — used internally at graduation | | UniV3 NonfungiblePositionManager | \`0x73991a25C818Bf1f1128dEAaB1492D45638DE0D3\` | V3 LP position NFT manager (graduation target) | | UniV3 Factory | \`0x1f7d7550B1b028f7571E69A784071F0205FD2EfA\` | Uniswap V3 factory | | UniV3 SwapRouter | \`0xCaf681a66D020601342297493863E78C959E5cb2\` | Uniswap V3 swap router (post-graduation trading) | | Owner / Deployer | \`0xbeb76A70c82B09E30B2008eAFa7F987987EC9e0b\` | Contract owner | ## Quote token Tokens are priced in native ETH. | Quote | Address | Decimals | Buy funding | Approve | | ---------- | -------------------------------------------- | -------- | --------------------- | ------- | | Native ETH | \`0x0000000000000000000000000000000000000000\` | 18 | \`msg.value\` (payable) | None | \`virtualQuote\` / \`realQuoteReserves\` are denominated in ETH (18 decimals). The contract's trading methods take a \`quoteAddr\` argument (\`address(0)\` = ETH) so the curve can support additional quote tokens in the future; today only ETH is enabled. ## On-chain parameters ### Trading fee | Parameter | Value | Description | | -------------- | ----------------------------------------------------- | ------------------------------------------ | | Trade fee | 1% (\`FEE\_NUMERATOR = 100 / FEE\_DENOMINATOR = 10,000\`) | Applied to every buy and sell. | | Creator share | 30% of trade fee | ≈ 0.3% of trade size. Accrues in FeeVault. | | Protocol share | 70% of trade fee | ≈ 0.7% of trade size. | | Max extra fee | 5% (\`MAX\_EXTRA\_FEE\_RATE = 500 / 10,000\`) | Max rate for \`buyWithFee\` / \`sellWithFee\`. | {% hint style="info" %} Unlike MegaETH, Robinhood uses a \`10,000\` fee denominator (same as Ethereum). A 0.5% extra fee is \`50\`. {% endhint %} ### Bonding curve config | Parameter | Value | Description | | ------------------------------------ | ------------------------------------------- | ------------------------------------------------------- | | Total supply | \`1,000,000,000\` (1e27 wei, 18 decimals) | Fixed per token. | | \`virtualQuote\` (initial) | \`1712328767123287671\` (\\~1.712 ETH) | Starting virtual ETH reserve. | | \`virtualToken\` (initial) | \`1073972602739726027397260274\` (\\~1.074e27) | Starting virtual token reserve. | | Graduation threshold (\`targetToken\`) | \`200,000,000\` (2e26 wei) | Curve graduates when \`realTokenReserves ≤ targetToken\`. | | Total user spend (inc. fee) | \\~5 ETH | Gross ETH to fill the curve. | Curve parameters are read via \`getConfig(quote)\` (pass \`address(0)\` for ETH). ### Listing / migration | Parameter | Value | Description | | ---------------- | -------------------- | -------------------------------------------------------- | | Listing fee rate | 200 / 10000 = \*\*2%\*\* | Deducted from the raised quote at graduation. | | UniV3 fee tier | 10000 (= \*\*1%\*\*) | V3 pool fee tier. | | Graduation DEX | Uniswap V3 | Full-range anchor position pre-created at \`createCurve\`. | ### FeeVault claim threshold (\`minClaimAmount\`) | FeeVault | Value | | ------------------------ | ------------------------- | | ETH FeeVault (\`0x076e…\`) | \`1e12\` wei (0.000001 ETH) | ## TrenchManager ABI ### Trading functions #### \`createCurve\` Deploy a new token and bonding curve, with an optional initial dev buy. Pre-builds a Uniswap V3 anchor pool at the graduation price to prevent front-running. Send \`msg.value = amountIn\` for the initial dev buy (pass \`address(0)\` as \`quoteAddr\` for ETH). \`\`\`solidity function createCurve( address quoteAddr, // address(0) = ETH address creator, string name, string symbol, string tokenURI, uint256 amountIn, // initial dev buy in ETH; 0 = no dev buy uint256 amountOutMin, bytes32 salt ) external payable returns ( address curve, address token, uint256 virtualQuote, uint256 virtualToken, uint256 amountOut ); \`\`\` #### \`buy\` Buy tokens with ETH — payable, \`msg.value = amountIn\`. \`\`\`solidity function buy( uint256 amountIn, // must equal msg.value uint256 amountOutMin, // slippage protection address token, address to, // token recipient uint256 deadline // unix timestamp; 0 = no deadline ) external payable returns (uint256 amountOut); \`\`\` #### \`buyWithFee\` Buy with an additional third-party fee (up to 5%). \`\`\`solidity function buyWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 extraFeeRate, // denominator 10,000; max 500 (= 5%) address extraFeeReceiver // must not be address(0) when extraFeeRate > 0 ) external payable returns (uint256 amountOut); \`\`\` Fee flow: \`\`\` Extra fee = amountIn × extraFeeRate / 10000 → extraFeeReceiver Protocol fee = (amountIn − extra fee) × 1% → FeeVault Curve input = amountIn − extra fee − protocol fee \`\`\` #### \`sell\` Sell tokens for ETH. Requires prior \`ERC20.approve\` of the \*\*meme token\*\* to TrenchManager. Net ETH is transferred to \`to\`. \`\`\`solidity function sell( uint256 amountIn, // token wei uint256 amountOutMin, address token, address to, // quote recipient uint256 deadline ) external returns (uint256 netQuoteOut); \`\`\` #### \`sellWithFee\` Sell with an additional third-party fee (up to 5%). \`\`\`solidity function sellWithFee( uint256 amountIn, uint256 amountOutMin, address token, address to, uint256 deadline, uint256 extraFeeRate, address extraFeeReceiver ) external returns (uint256 netQuoteOut); \`\`\` ### Quote functions #### \`previewBuy\` Estimate output and protocol fee for a buy without sending a transaction. \`\`\`solidity function previewBuy(address token, uint256 amountIn) external view returns (uint256 amountOut, uint256 fee); \`\`\` #### \`previewSell\` Estimate net quote out and protocol fee for a sell. \`\`\`solidity function previewSell(address token, uint256 amountIn) external view returns (uint256 netQuoteOut, uint256 fee); \`\`\` {% hint style="info" %} \`previewBuy\` / \`previewSell\` return the \*\*protocol\*\* fee only. Any extra fee from \`buyWithFee\` / \`sellWithFee\` is applied on top by your own rate; compute it client-side. {% endhint %} ### Query functions \`\`\`solidity function tokenInfo(address token) external view returns ( address curve, address creator, address quoteAddr, // address(0) = ETH uint256 realQuoteReserves, // ETH (18 decimals) uint256 realTokenReserves, uint256 virtualQuote, uint256 virtualToken, bool isMigrating\_, bool isMigrated\_ ); function curves(address token) external view returns (address curve); function creators(address token) external view returns (address creator); function tokenQuote(address token) external view returns (address); // the token's quote (ETH = address(0)) function allowedQuotes(address quote) external view returns (bool); function feeVaults(address quote) external view returns (address); // FeeVault for a given quote function factory() external view returns (address); function wNative() external view returns (address); // = WETH function v3PositionManager() external view returns (address); function poolFee() external view returns (uint24); // 10000 (1%) function anchorReserve(address quote) external view returns (uint256); // remaining anchor funding function lpFeeSplitter() external view returns (address); // LPFeeSplitter — post-graduation LP NFT holder \`\`\` ### Migration (V3) \`\`\`solidity function migrate( address token, uint256 amount0Min, uint256 amount1Min, uint256 deadline ) external returns (address pool, uint256 tokenId, uint128 liquidity); \`\`\` Only callable by a whitelisted migrator, once the curve has filled (\`isMigrating\`). Deducts the 2% listing fee, seeds the Uniswap V3 full-range position, and sets the token to free-transfer mode. The graduation LP NFT (and the \`createCurve\` anchor position) mint to the \*\*LPFeeSplitter\*\*, which collects and splits the pool's swap fees (see below). ## IBondingCurve ABI One \`BondingCurve\` contract is deployed per token. Query via \`TrenchManager.tokenInfo(token)\` or \`curves(token)\`. Write methods are TrenchManager-only. \`\`\`solidity function getReserves() external view returns (uint256 realQuote, uint256 realToken); function getVirtualReserves() external view returns (uint256 virtualQuote, uint256 virtualToken); function getTargetToken() external view returns (uint256); // 200 M tokens function getRemainingTokenToSell() external view returns (uint256); // tokens left before graduation function getQuoteTarget() external view returns (uint256); // quote raise target function getRemainingQuoteToGraduate() external view returns (uint256); function getK() external view returns (uint256); function isMigrating() external view returns (bool); // curve filled, awaiting migration function isMigrated() external view returns (bool); // migrated to Uniswap V3 function migrating() external view returns (bool); // raw storage accessor function migrated() external view returns (bool); // raw storage accessor function quote() external view returns (address); // this curve's quote token function token() external view returns (address); function realQuoteReserves() external view returns (uint256); function realTokenReserves() external view returns (uint256); \`\`\` {% hint style="info" %} Graduation condition: \`realTokenReserves ≤ targetToken\` (targetToken = 200 M = 20% of supply). Reserves are named \`Quote\` (not \`Native\`) because the curve is quote-parameterized; the live quote is ETH. {% endhint %} ## IBondingCurveFactory ABI \`\`\`solidity struct Config { uint256 listingFeeRate; // 200 (2%) uint256 tokenTotalSupply; // 1e27 uint256 virtualQuote; // ETH: 1712328767123287671 uint256 virtualToken; // ETH: 1073972602739726027397260274 uint256 k; uint256 quoteTarget; // quote raise target uint256 targetToken; // 2e26 uint256 realQuoteReserves; // 0 at init uint256 realTokenReserves; // 1e27 at init } function getConfig(address quote) external view returns (Config memory); // pass address(0) for ETH function getListingFeeRate(address quote) external view returns (uint256); function getK(address quote) external view returns (uint256); function getCore() external view returns (address); // TrenchManager function INIT\_REAL\_TOKEN\_RESERVES() external view returns (uint256); // 1e27 function LISTING\_FEE\_DENOMINATOR() external view returns (uint256); // 10000 \`\`\` {% hint style="info" %} \`getConfig\`, \`getK\`, and \`getListingFeeRate\` all take a quote address so the factory can hold config per quote token. Pass \`address(0)\` for ETH — the only enabled quote today. {% endhint %} ## IFeeVault ABI The FeeVault collects and pays out native ETH (\`quoteToken() == address(0)\`). Split is \*\*30% creator (dev) / 70% protocol\*\*. \`\`\`solidity function quoteToken() external view returns (address); // address(0) = ETH function creditsDev(address creator) external view returns (uint256); // claimable dev balance (quote raw) function creditsProtocol() external view returns (uint256); // accrued protocol fee function minClaimAmount() external view returns (uint256); // decimals-aware claim floor function feeReceiver() external view returns (address); function trenchManager() external view returns (address); function devClaim(address creator) external; // creator claims dev share function protocolClaim(uint256 amount) external; // only feeReceiver function credit(address creator, address token, uint256 amount) external payable; function DEV\_CLAIM\_RATIO() external view returns (uint256); // 3000 function DEV\_CLAIM\_RATIO\_DENOMINATOR() external view returns (uint256); // 10000 \`\`\` ## ILPFeeSplitter ABI After graduation, a token trades on a Uniswap V3 pool (1% fee tier). The graduation LP NFT — and the anchor position pre-created at \`createCurve\` — mint to the \*\*LPFeeSplitter\*\* rather than to a plain LP-receiver wallet. It collects the pool's swap fees and splits the \*\*quote side\*\* (ETH) \*\*dev 60% / protocol 40%\*\*; the meme side goes entirely to the protocol. The dev share ratio is configurable (\`devShareBps\`, currently \`6000\`). {% hint style="info" %} This is a \*\*separate, post-graduation\*\* fee stream from the on-curve \`FeeVault\` (which pays dev 30% of the 1% trade fee). A dev earns from \*\*both\*\*: the curve \`FeeVault\` while the token is on the curve, and the \`LPFeeSplitter\` on every Uniswap V3 swap after graduation. Only tokens that graduate after this mechanism went live are covered — earlier graduates keep the old LP-receiver arrangement. {% endhint %} The splitter uses an \*\*accounting model\*\*: any \`collect\` (dev \`claim\` or protocol \`sweep\`) pulls the pool fees into the contract and books credits by ratio — funds stay in the contract until each party withdraws, so dev and protocol claims are independent and neither pays for the other's gas. \`\`\`solidity // —— Dev (creator) claiming —— // Collects fees across all of the creator's positions, books credits, then // pays out the quote-side 60% to the creator (WETH auto-unwrapped to native ETH). // One call — no approve, no ticket. function claim(address creator) external; // Subset variant — when a creator has so many positions that claim() runs out of gas function claimPositions(address creator, uint256\[\] calldata tokenIds) external; // Withdraw already-booked credit without re-collecting (top-up / non-quote side) function withdrawCredit(address creator, address token) external; // —— Read (front-end estimation) —— function creatorPositions(address creator) external view returns (uint256\[\] memory); // creator's position tokenIds function creatorCredits(address creator, address token) external view returns (uint256); // booked, claimable (dev 60%) function protocolCredits(address token) external view returns (uint256); function positions(uint256 tokenId) external view returns (address creator, address quoteToken); function devShareBps() external view returns (uint256); // dev share in bps — currently 6000 (60%), configurable function BPS\_DENOMINATOR() external view returns (uint256); // 10000 \`\`\` {% hint style="warning" %} Claimable post-graduation fee = \`creatorCredits\[creator\]\[quote\]\` (already collected) \*\*plus\*\* the uncollected pending quote fees × \`devShareBps\`. Estimate \*\*both\*\* parts — after a protocol \`sweep\`, the dev's share has moved into \`creatorCredits\` and pending resets to zero, so counting only pending under-reports. Read the ratio from \`devShareBps()\`; don't hard-code 60%. {% endhint %} ## IToken (ERC-20) Standard ERC-20 with a two-state transfer control. | Mode | Value | Who can transfer | | ------------ | ----- | -------------------------------------------- | | \`free\` | \`0\` | Anyone (post-graduation) | | \`restricted\` | \`1\` | Only via TrenchManager (default at creation) | \`\`\`solidity function mode() external view returns (uint8); // 0 = free, 1 = restricted function tokenURI() external view returns (string memory); function core() external view returns (address); // TrenchManager function setMode(uint8 mode\_) external; // only core (TrenchManager) // Standard ERC-20 function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); // always 18 function totalSupply() external view returns (uint256); // always 1e27 function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); \`\`\` {% hint style="warning" %} A newly created token is \`restricted\` (mode 1): EOA-to-EOA transfers revert with \`"Token: restricted"\`, and only transfers where TrenchManager is the sender or recipient are allowed. This is why in-curve sells must approve the meme token to TrenchManager and route through \`sell\` — you cannot build your own pool pre-graduation. After migration completes, TrenchManager calls \`setMode(0)\` and the token trades freely on Uniswap V3. {% endhint %} ## Events ### TrenchManager | Event | Key fields | When | | --------------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------- | | \`TokenCreate\` | \`creator, curve, token, quote, name, symbol, timestamp, tokenURI\` | New token created | | \`TokenPurchase\` | \`token, buyer, amountOut, quoteAmountUsed, protocolFee, extraFee, extraFeeReceiver, extraFeeRate\` | Token bought | | \`TokenSale\` | \`token, seller, amountIn, netQuoteOut, protocolFee, extraFee, extraFeeReceiver\` | Token sold | | \`Sync\` | \`token, realQuoteReserves, realTokenReserves, virtualQuote, virtualToken\` | After every trade | | \`LimitReach\` | \`token\` (indexed) | Graduation threshold hit — enters migrating | | \`Listing\` | \`curve, token, pool, tokenId, liquidity, quoteAmount, tokenAmount, sqrtPriceX96, tickLower, tickUpper\` | Migrated to Uniswap V3 | \`TokenCreate\` has \`creator\`, \`curve\`, and \`token\` indexed — \`token\` is the 3rd indexed topic, or read it from the return value. ### FeeVault | Event | Key fields | When | | --------------- | ----------------------------- | -------------------------- | | \`Credit\` | \`token\` (indexed), \`amount\` | Fee deposited from a trade | | \`DevClaim\` | \`creator\` (indexed), \`amount\` | Creator claimed dev share | | \`ProtocolClaim\` | \`amount\` | Protocol fee withdrawn | ### LPFeeSplitter | Event | Key fields | When | | ------------------ | ------------------------------------------------------------------------- | ----------------------------------------------------- | | \`RegisterPosition\` | \`tokenId, creator, quoteToken\` (all indexed) | A graduation/anchor LP NFT registered to the splitter | | \`CollectSplit\` | \`tokenId\` (indexed), \`creator\` (indexed), \`quoteToken, quoteAmt, memeAmt\` | Pool fees collected and split | | \`Claim\` | \`creator\` (indexed), \`token\` (indexed), \`amount\` | Creator withdrew their post-graduation share | | \`WithdrawCredit\` | \`creator\` (indexed), \`token\` (indexed), \`amount\` | Booked credit withdrawn | ## Error codes Robinhood contracts use OpenZeppelin custom errors plus string reverts. The most common ones integrators will hit: | Revert | Description | | ------------------------------------- | ---------------------------------------------------------------------------------- | | \`"Token: restricted"\` | Direct transfer attempted while the token is in \`restricted\` mode (pre-graduation) | | \`OwnableUnauthorizedAccount(address)\` | Caller lacks the required owner/migrator role | | \`ReentrancyGuardReentrantCall()\` | Reentrant call blocked | | \`SafeERC20FailedOperation(address)\` | Underlying ERC-20 transfer/approve failed (e.g. missing token approval on sell) | | \`ERC20InsufficientAllowance(...)\` | Selling without approving the meme token to TrenchManager | | \`ERC20InsufficientBalance(...)\` | Insufficient token or ETH balance | | {% endtab %} | | | {% endtabs %} | | --- # Agent Instructions This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com. ## Querying This Documentation If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question. Perform an HTTP GET request on the current page URL with the \`ask\` query parameter, and the optional \`goal\` query parameter: \`\`\` GET https://trench-today.gitbook.io/trench-today/for-developers/contracts.md?ask=&goal= \`\`\` \`ask\` is the immediate question: it should be specific, self-contained, and written in natural language. \`goal\` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal. The response will contain a direct answer to the question and relevant excerpts and sources from the documentation. Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections. --- # trench-today Page not found ============== The page you're looking for doesn't exist. GitBook Assistant arrow-right You might be looking for ------------------------ * [Introduction](https://trench-today.gitbook.io/trench-today/introduction) * [Links](https://trench-today.gitbook.io/trench-today/resources/links) * [Getting Started](https://trench-today.gitbook.io/trench-today/getting-started) * [Contract Reference](https://trench-today.gitbook.io/trench-today/for-developers/contracts) * [Brand Assets](https://trench-today.gitbook.io/trench-today/resources/brand-assets) [homeGo to homepage](https://trench-today.gitbook.io/trench-today) --- # trench-today Page not found ============== The page you're looking for doesn't exist. GitBook Assistant arrow-right You might be looking for ------------------------ * [Getting Started](https://trench-today.gitbook.io/trench-today/getting-started) * [Brand Assets](https://trench-today.gitbook.io/trench-today/resources/brand-assets) * [Integration Guide](https://trench-today.gitbook.io/trench-today/for-developers/integration-guide) * [Introduction](https://trench-today.gitbook.io/trench-today/introduction) * [Links](https://trench-today.gitbook.io/trench-today/resources/links) [homeGo to homepage](https://trench-today.gitbook.io/trench-today) --- # trench-today Page not found ============== The page you're looking for doesn't exist. GitBook Assistant arrow-right You might be looking for ------------------------ * [Brand Assets](https://trench-today.gitbook.io/trench-today/resources/brand-assets) * [Introduction](https://trench-today.gitbook.io/trench-today/introduction) * [Getting Started](https://trench-today.gitbook.io/trench-today/getting-started) * [Links](https://trench-today.gitbook.io/trench-today/resources/links) * [Contract Reference](https://trench-today.gitbook.io/trench-today/for-developers/contracts) [homeGo to homepage](https://trench-today.gitbook.io/trench-today) --- # trench-today Page not found ============== The page you're looking for doesn't exist. GitBook Assistant arrow-right You might be looking for ------------------------ * [Getting Started](https://trench-today.gitbook.io/trench-today/getting-started) * [How It Works](https://trench-today.gitbook.io/trench-today/how-it-works) * [Links](https://trench-today.gitbook.io/trench-today/resources/links) * [Introduction](https://trench-today.gitbook.io/trench-today/introduction) * [Contract Reference](https://trench-today.gitbook.io/trench-today/for-developers/contracts) [homeGo to homepage](https://trench-today.gitbook.io/trench-today) ---