Skip to content

[#638] Fix PLOT-mode MAX buy path and remove unnecessary delays#646

Merged
realproject7 merged 3 commits intomainfrom
task/638-ux-fixes
Mar 30, 2026
Merged

[#638] Fix PLOT-mode MAX buy path and remove unnecessary delays#646
realproject7 merged 3 commits intomainfrom
task/638-ux-fixes

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • TradingWidget.tsx: handleBuyMax no longer calls getZapQuote() in PLOT mode (which silently failed). Instead, uses binary search over getReserveForToken on the bonding curve to find the maximum storyline tokens mintable within the user's PLOT balance.
  • DonateWidget.tsx: Removed 5-second setTimeout delay before indexer call — unnecessary on Base mainnet.
  • usePublish.ts: Removed 5-second setTimeout delay before indexer call — unnecessary on Base mainnet.

Fixes #638
Tracks realproject7/agent-os#309

Test plan

  • In PLOT mode, clicking MAX successfully prepares the buy using the bonding-curve quote path
  • In non-PLOT mode (ETH/USDC/HUNT), clicking MAX still uses the zap flow as before
  • Donate flow proceeds without the extra 5-second delay
  • Publish flow proceeds without the extra 5-second delay

🤖 Generated with Claude Code

- handleBuyMax: skip getZapQuote in PLOT mode; binary-search
  getReserveForToken to find max mintable storyline tokens
- DonateWidget: remove 5s setTimeout (unnecessary on Base mainnet)
- usePublish: remove 5s setTimeout (unnecessary on Base mainnet)

Fixes #638

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
plotlink Ignored Ignored Mar 30, 2026 6:19pm

Request Review

Addresses T2b review feedback: the original binary search made up to 64
sequential RPC calls (~3-12s). Now uses multicall to batch probes:
1. Exponential search (1 multicall, 20 probes) finds the magnitude
2. Two rounds of 16-point linear probes (2 multicalls) narrow to answer
Total: 3 RPC round-trips instead of up to 64.

Also fixes upper-bound issue: exponential probing correctly handles
early-curve positions where tokens cost far less than 1 PLOT each.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 PR fixes the silent PLOT-mode failure and removes the artificial waits, but the new PLOT MAX path still does not reliably compute the actual maximum buyable amount.

Findings

  • [high] The binary-search upper bound assumes 1 storyline token <= 1 PLOT, which is not guaranteed by the bonding curve.
    • File: src/components/TradingWidget.tsx:185
    • Suggestion: Grow hi until getReserveForToken(tokenAddress, hi) exceeds the user's PLOT balance (for example by doubling from 1 token), then binary-search within that bracket. That keeps MAX correct when the marginal price is below 1 PLOT and the user can mint more than maxBalance token units.

Decision

Requesting changes because the current implementation can still underfill MAX buys in PLOT mode, so it does not meet the acceptance criterion that MAX works correctly.

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 revised multicall search fixes the earlier upper-bound / round-trip issues, but the PLOT-mode MAX path still misses a valid buy range below one full token.

Findings

  • [high] The probe ladder starts at 1e18 and returns early when that first whole-token probe is too expensive, so MAX still does nothing for wallets that can afford only a fractional token.
    • File: src/components/TradingWidget.tsx:188
    • Suggestion: Include sub-1-token probes (for example 1e17, 1e16, ...), or fall back to a finer-grained search in (0, 1e18) when the first probe exceeds maxBalance. The widget already accepts 18-decimal token amounts, so MAX needs to cover that range too.

Decision

Requesting changes because users who can buy less than one storyline token still get a broken MAX button, which does not satisfy the acceptance criterion that MAX works correctly in PLOT mode.

Exponential search now starts from 1e12 (0.000001 tokens) instead of
1e18 (1 whole token), so MAX works for wallets that can only afford a
fractional storyline token on the bonding curve.

Addresses T2a review: previous code no-oped when 1 whole token exceeded
the user's PLOT balance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 requested fixes are addressed. PLOT-mode MAX now uses the bonding-curve path instead of Zap, covers fractional token amounts, and the 5-second waits remain removed from donate and publish.

Findings

  • None.

Decision

Approving on code review. lint-and-typecheck is passing; the remaining checks are still running, but they do not block the review verdict.

@realproject7 realproject7 merged commit 35bd17e into main Mar 30, 2026
5 checks passed
@realproject7 realproject7 deleted the task/638-ux-fixes branch March 30, 2026 18:22
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.

Fix MAX button broken in PLOT mode + remove unnecessary 5s delays

2 participants