Created
December 11, 2025 16:11
-
-
Save pranay5255/f28acdae821679b18176048207a8efa9 to your computer and use it in GitHub Desktop.
Deploy two tokens and Create a Uniswap v4 Pool (Traces Explanation)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # DeployTokenAndPool.sol run-latest.json (EVM trace with inline comments) | |
| Below is the raw trace pulled from `broadcast/DeployTokenAndPool.sol/84532/run-latest.json` (lines 679-824 from the terminal output). Explanations are embedded as comments on each line. | |
| ``` | |
| ## Setting up 1 EVM. // Foundry/forge spins up a local EVM instance | |
| ========================== // Trace header separator | |
| Simulated On-chain Traces: // All calls below are simulated, not mainnet | |
| [469388] → new MockCbBTC@0xb9B962177c15353cd6AA49E26c2b627b9CC35457 // Deploy MockCbBTC ERC20 | |
| ├─ emit Transfer(...to: 0x2394..., value: 5e9) // Mint 5e9 CbBTC to deployer | |
| ├─ emit Transfer(...to: 0x4db8..., value: 5e9) // Mint 5e9 CbBTC to secondary address | |
| └─ ← [Return] 1763 bytes of code // Deployed bytecode size | |
| [469394] → new MockUSDC@0xB6c34A382a45F93682B03dCa9C48e3710e76809F // Deploy MockUSDC ERC20 | |
| ├─ emit Transfer(...to: 0x2394..., value: 5e12) // Mint 5e12 USDC to deployer | |
| ├─ emit Transfer(...to: 0x4db8..., value: 5e12) // Mint 5e12 USDC to secondary address | |
| └─ ← [Return] 1763 bytes of code // Deployed bytecode size | |
| [29172] 0x05E7...::initialize(PoolKey(...), sqrtPriceX96=7.922e28) // Create/init pool USDC/CBTC, fee 0.3%, tickSpacing 60 | |
| ├─ emit Initialize(id: 0xa5a6..., ... tick: 0) // Pool initialized with starting sqrt price, tick 0 | |
| └─ ← [Return] 0 // Success | |
| [24735] MockUSDC::approve(0x0000...78BA3, max uint256) // Deployer gives Permit2/router unlimited USDC allowance | |
| ├─ emit Approval(owner: 0x2394..., spender: 0x0000...78BA3, value: max) | |
| └─ ← [Return] true | |
| [24735] MockCbBTC::approve(0x0000...78BA3, max uint256) // Deployer gives Permit2/router unlimited CbBTC allowance | |
| ├─ emit Approval(owner: 0x2394..., spender: 0x0000...78BA3, value: max) | |
| └─ ← [Return] true | |
| [25450] 0x0000...78BA3::approve(MockUSDC, spender=0x4B2C..., amount=1.461e48, expiration=2.814e14) // Permit2 sets USDC allowance for LP mgr | |
| ├─ emit Approval(owner: 0x2394..., token: MockUSDC, spender: 0x4B2C..., amount: 1.461e48, expiration: 2.814e14) | |
| └─ ← [Return] | |
| [25450] 0x0000...78BA3::approve(MockCbBTC, spender=0x4B2C..., amount=1.461e48, expiration=2.814e14) // Permit2 sets CbBTC allowance for LP mgr | |
| ├─ emit Approval(owner: 0x2394..., token: MockCbBTC, spender: 0x4B2C..., amount: 1.461e48, expiration: 2.814e14) | |
| └─ ← [Return] | |
| [394681] 0x4B2C...::modifyLiquidities(...), 1765469320 // LP manager starts liquidity add | |
| ├─ [389693] 0x05E7...::unlock(...) // Pool unlocks to run callback logic | |
| │ ├─ [387606] 0x4B2C...::unlockCallback(...) // Caller’s callback executes | |
| │ │ ├─ emit Transfer(...to: 0x2394..., value: 9233) // Small credit/mint to deployer (likely fee refund) | |
| │ │ ├─ [166250] 0x05E7...::modifyLiquidity(...liquidityDelta: 2.5e9, ticks: -887220 to 887220, salt: 0x2411) // Add wide-range liquidity | |
| │ │ │ ├─ emit ModifyLiquidity(...liquidityDelta: 2.5e9, ticks: full range, salt: 0x2411) // Position event | |
| │ │ │ └─ ← [Return] -8.507e47, 0 // Liquidity change + fees/owed info | |
| │ │ ├─ [859] 0x05E7...::exttload(0x274a...) [staticcall] // Read storage/bitmap slot | |
| │ │ │ └─ ← [Return] 0xffff...6afd0700 // Slot contents | |
| │ │ ├─ [6432] 0x05E7...::sync(MockUSDC) // Sync USDC balances before pull | |
| │ │ │ ├─ [2559] MockUSDC::balanceOf(pool) [staticcall] // Check pool USDC balance | |
| │ │ │ │ └─ ← [Return] 0 // No USDC yet | |
| │ │ │ └─ ← [Stop] | |
| │ │ ├─ [33625] 0x0000...78BA3::transferFrom(0x2394..., pool, 2.5e9, MockUSDC) // Router pulls 2.5e9 USDC to pool | |
| │ │ │ ├─ [30418] MockUSDC::transferFrom(0x2394..., pool, 2.5e9) // Underlying ERC20 transfer | |
| │ │ │ │ ├─ emit Transfer(from: 0x2394..., to: pool, value: 2.5e9) | |
| │ │ │ │ └─ ← [Return] true | |
| │ │ │ └─ ← [Return] | |
| │ │ ├─ [2533] 0x05E7...::settle() // Settle USDC side into pool state | |
| │ │ │ ├─ [559] MockUSDC::balanceOf(pool) [staticcall] // Confirm received USDC | |
| │ │ │ │ └─ ← [Return] 2.5e9 | |
| │ │ │ └─ ← [Return] 2.5e9 | |
| │ │ ├─ [859] 0x05E7...::exttload(0x04db...) [staticcall] // Another storage read | |
| │ │ │ └─ ← [Return] 0xffff...6afd0700 // Slot contents | |
| │ │ ├─ [6432] 0x05E7...::sync(MockCbBTC) // Sync CbBTC balances before pull | |
| │ │ │ ├─ [2559] MockCbBTC::balanceOf(pool) [staticcall] // Check pool CbBTC balance | |
| │ │ │ │ └─ ← [Return] 0 // No CbBTC yet | |
| │ │ │ └─ ← [Stop] | |
| │ │ ├─ [33625] 0x0000...78BA3::transferFrom(0x2394..., pool, 2.5e9, MockCbBTC) // Router pulls 2.5e9 CbBTC to pool | |
| │ │ │ ├─ [30418] MockCbBTC::transferFrom(0x2394..., pool, 2.5e9) // Underlying ERC20 transfer | |
| │ │ │ │ ├─ emit Transfer(from: 0x2394..., to: pool, value: 2.5e9) | |
| │ │ │ │ └─ ← [Return] true | |
| │ │ │ └─ ← [Return] | |
| │ │ ├─ [2533] 0x05E7...::settle() // Settle CbBTC side into pool state | |
| │ │ │ ├─ [559] MockCbBTC::balanceOf(pool) [staticcall] // Confirm received CbBTC | |
| │ │ │ │ └─ ← [Return] 2.5e9 | |
| │ │ │ └─ ← [Return] 2.5e9 | |
| │ │ └─ ← [Return] 0x...20...00 // Callback returns encoded data (likely empty bytes) | |
| │ └─ ← [Return] 0x // Unlock completed | |
| └─ ← [Stop] // modifyLiquidities finished without revert | |
| ``` | |
| ## TL;DR | |
| - Deployed two mock tokens (CbBTC, USDC) and minted to deployer + helper. | |
| - Initialized a Uniswap v4-style pool with fee 0.3% and wide tick spacing. | |
| - Granted router/Permit2 unlimited spend on both tokens, then granted the liquidity manager large allowances via the router. | |
| - Added a wide-range liquidity position depositing 2.5e9 USDC and 2.5e9 CbBTC into the pool, settling both sides successfully. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment