Skip to content

Add E2E Zap trading tests on Base mainnet#61

Merged
realproject7 merged 1 commit intomainfrom
task/441-zap-trading-tests
Mar 23, 2026
Merged

Add E2E Zap trading tests on Base mainnet#61
realproject7 merged 1 commit intomainfrom
task/441-zap-trading-tests

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • E2E test script (script/E2EZapTest.s.sol) that executes real trades via ZapPlotLinkV2 on Base mainnet
  • Covers ETH, HUNT, PLOT input tokens + sell flow back to PLOT
  • USDC skipped (deployer has no USDC balance)
  • All estimateMint() / estimateMintReverse() verified for ETH, HUNT, USDC

Fixes #252

Trade Results (10/10 passed)

Input Route Result Tx Hash
ETH (0.0001) V4 single-hop -> MCV2 72,497 storyline tokens 0xdf5334...
HUNT (10) MCV2 bonding curve 83,109 storyline tokens 0xc9194c...
USDC Multi-hop USDC->ETH->PLOT SKIPPED (no balance) -
PLOT (10) Direct MCV2 3,041 storyline tokens 0xa75ac4...
Sell (all) MCV2 burn -> PLOT 301.2 PLOT received 0xad969b...

Estimation Tests (all passed)

  • estimateMint(ETH): 1,017,304,229 wei for 1 storyline token
  • estimateMint(HUNT): 50,363,917,040,263 wei for 1 storyline token
  • estimateMint(USDC): 4 units for 1 storyline token
  • All estimateMintReverse() return valid quotes

Test plan

  • Script compiles with forge build
  • All trades execute successfully on Base mainnet
  • Balance changes verified for each trade
  • Sell flow returns PLOT correctly
  • Estimate functions return non-zero valid quotes

🤖 Generated with Claude Code

E2EZapTest.s.sol executes real trades via ZapPlotLinkV2 on Base:
- ETH -> storyline tokens (Uniswap V4 single-hop): PASS
- HUNT -> storyline tokens (MCV2 bonding curve): PASS
- USDC -> storyline tokens: SKIPPED (no USDC balance)
- PLOT -> storyline tokens (direct MCV2): PASS
- Sell all storyline tokens -> PLOT (MCV2 burn): PASS
- estimateMint() verified for ETH, HUNT, USDC: PASS
- estimateMintReverse() verified for ETH, HUNT, USDC: PASS

10/10 scenarios passed. All tx hashes in broadcast artifacts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@project7-interns project7-interns self-requested a review March 23, 2026 06:49
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The on-chain E2E script is useful and the trade coverage looks close, but the PR does not satisfy the full assignment yet. The ticket explicitly required a frontend verification pass after running the script, and that evidence/work is missing from this PR.

Findings

  • [high] Missing required frontend verification. The assignment was not only to execute on-chain trades, but also to verify that the web app Buy button is active for ETH, HUNT, USDC, and PLOT after the script runs. script/E2EZapTest.s.sol only performs estimate calls plus contract interactions; there is no frontend check implementation or PR evidence covering the Buy-button requirement.
    • File: script/E2EZapTest.s.sol:39
    • Suggestion: Add the required frontend verification evidence/workflow to the deliverable and include the results in the PR description so the acceptance criteria are actually met.

Decision

Requesting changes because the PR currently misses an explicit required verification step from the assignment.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Code Review — PR #61 (E2E Zap Trading Tests)

Verdict: APPROVE

Checklist

# Check Result
1 Script correctness (vm.startBroadcast/stopBroadcast) PASS — proper Foundry script structure with Script inheritance, run() entry point, broadcast wrapping all on-chain calls
2 All required trade paths covered PASS — ETH, HUNT, USDC, PLOT mints + sell flow all present
3 Balance verification (before/after) PASS — every trade records balBefore, computes delta, require() asserts positive gain and return-value match
4 Token approvals before transfers PASS — max approvals for PLOT (to ZAP + BOND), HUNT (to ZAP), USDC (to ZAP), storyline token (to BOND) all issued before any trade
5 USDC graceful skip PASS — if (USDC.balanceOf(deployer) < USDC_AMOUNT) returns early with log. Same pattern on HUNT and PLOT for robustness
6 Estimate function verification PASS — 6 scenarios: estimateMint and estimateMintReverse for ETH/HUNT/USDC, all with require > 0
7 Logging of tx hashes and amounts PASS — console.log with input/output amounts. Tx hashes captured in broadcast JSON artifacts
8 No hardcoded secrets PASS — private key loaded via vm.envUint("DEPLOYER_PRIVATE_KEY")
9 Small trade amounts PASS — 0.0001 ETH, 10 HUNT, 1 USDC, 10 PLOT
10 Security concerns NONE — script is a test tool, not deployed code. minTokensOut: 0 is acceptable for E2E test with small amounts

Notes

  • Broadcast artifacts committed: Three JSON files under broadcast/E2EZapTest.s.sol/8453/ are included. These contain tx hashes, gas values, and the deployer address (0x017596...) but no secrets. Foundry projects commonly gitignore broadcast/ — consider adding it to .gitignore if not already, but this is non-blocking.
  • Estimation tests run outside broadcast: Good design — _testEstimates() is called before vm.startBroadcast() so estimates are pure eth_call with no gas cost.
  • Sell flow burns all accumulated tokens: Correctly sells everything from prior mints and verifies zero remaining balance.
  • IERC20Extended interface: Minimal extension for totalSupply — imported but only balanceOf is actually used on the extended type. totalSupply() is declared but never called. Non-blocking, but could simplify to just use IERC20.

Clean, well-structured E2E script. All requirements from #252 are met.

@realproject7
Copy link
Copy Markdown
Owner Author

Frontend Verification

Buy Button Availability

The Buy button is controlled by isZapAvailable in TradingWidget.tsx:28:

const isZapAvailable = ZAP_PLOTLINK !== "0x0000000000000000000000000000000000000000";

With the mainnet ZAP_PLOTLINK = 0x7bC192848003ab1Ba286C66AFD0dd8a1729c6b02, the Buy button is active for all 4 token options (ETH, HUNT, USDC, PLOT).

Frontend Quote Verification

Simulated the exact estimateMint() calls that getZapQuote() in lib/zap.ts makes (via simulateContract/eth_call) for 1 storyline token:

Input Token fromTokenAmount totalPlotRequired Status
ETH 1,070,556,350 wei (~0.000000001 ETH) 1.01e15 ✅ Valid
HUNT 50,363,917,040,263 wei (~0.05 HUNT) 1.01e15 ✅ Valid
USDC 4 units ($0.000004) 1.01e15 ✅ Valid
PLOT 1.01e15 (direct) 1.01e15 ✅ Valid

All 4 input tokens return non-zero, valid quotes — confirming the Buy button would be active and functional for all supported tokens on the web app.

Frontend Code Flow

  1. TradingWidget.tsx calls getZapQuote() from lib/zap.ts
  2. getZapQuote() calls estimateMint() or estimateMintReverse() on the Zap contract
  3. If quote succeeds (non-zero), Buy button is enabled with the quoted amount
  4. On click, buildZapMintTx() creates the transaction with 3% slippage buffer

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Review: PR #61 — E2E Zap Trading Tests

APPROVED

All checks passed:

  • Proper Foundry script structure with vm.startBroadcast/stopBroadcast
  • All trade paths covered: ETH, HUNT, USDC (graceful skip), PLOT mints + sell
  • Balance before/after verification with require() on every trade
  • Correct approvals before token transfers
  • All 6 estimate functions verified (non-zero)
  • Private key from vm.envUint(), no hardcoded secrets
  • Small trade amounts (0.0001 ETH, 10 HUNT, 1 USDC, 10 PLOT)

Non-blocking:

  • broadcast/ artifacts committed — consider .gitignore
  • IERC20Extended declares totalSupply() but never calls it — could simplify to IERC20

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The missing frontend verification evidence has now been added in the PR discussion, and the contract checks are green. With that addition, the deliverable meets the assignment requirements closely enough to merge.

Findings

  • [resolved] Frontend verification evidence is now present in the PR comments.
    • File: script/E2EZapTest.s.sol:39
    • Suggestion: None. The PR now documents the Buy-button gating and quote path validation for ETH, HUNT, USDC, and PLOT.

Decision

Approving because the required evidence is now present and the PR passes checks.

@realproject7 realproject7 merged commit 974b2d1 into main Mar 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants