Skip to content

feat(launchpadv2): add indexing events to BondingV5 and FRouterV3#174

Open
psmiratisu wants to merge 7 commits into
mainfrom
feat/add-indexing-events
Open

feat(launchpadv2): add indexing events to BondingV5 and FRouterV3#174
psmiratisu wants to merge 7 commits into
mainfrom
feat/add-indexing-events

Conversation

@psmiratisu

@psmiratisu psmiratisu commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Adds additive, non-breaking on-chain events so bonding-curve activity (trades,
token creation, graduation) can be indexed directly from logs without RPC
round-trips or transfer-log inference.

Changes

FRouterV3

  • TradeExecuted emitted after every buy/sell: token, trader, pair,
    isBuy, quoteAsset, amountIn, tokenAmount, curveQuoteAmount,
    traderQuoteAmount, taxFee, antiSniperFee, post-trade reserves, lastPrice.

BondingV5

  • TokenCreated creation snapshot: virtualId, creator, token, metadata
    (name, symbol, description, image), curve params (saleAmount,
    graduationThreshold, targetRaiseAmount, initialVirtualLiquidity,
    initialPrice, initialPurchase), quoteAsset, pair, applicationId,
    launchParams, start time. Social URL fields (twitter, telegram, youtube,
    website) are intentionally excluded — they remain stored in tokenInfo.
  • MigrateExecuted at graduation: caller, token, pair, agentToken,
    applicationId, assetAmount, tokenAmount.

Safety

  • Purely additive — only new events and their emits; no existing lines removed or modified.
  • No function signature changes → non-breaking; no caller updates required.
  • No new storage variables → storage layout unchanged (upgrade-safe).
  • Events are inert: no effect on control flow or fund movement.
  • BondingV5 21.95 KiB < 24.576 KiB (EIP-170) deployed-size limit.

Testing

test/launchpadv5/indexingEvents.js walks one token through
preLaunch → launch → buy → sell → graduation and asserts every event fires with
correct values, cross-checked against actual token/asset balance movements
(not just internal consistency): TokenCreated metadata + curve params,
TradeExecuted amounts/fees/reserves/lastPrice, anti-sniper fee decay, and
Graduated + MigrateExecuted. 6/6 passing.

Follow-ups (not in this PR)

  • OpenZeppelin upgrade storage-layout validation against the deployed implementation
  • Audit review
  • Testnet deployment

🤖 Generated with Claude Code


Note

Low Risk
Changes are emit-only with no storage or signature changes; trade and launch behavior is unchanged aside from extra gas for logging and reserve reads on swaps.

Overview
Adds additive on-chain events so launchpad activity can be indexed from logs without inferring trades from transfers.

BondingV5 emits TokenCreated at the end of preLaunch, alongside existing PreLaunched. The payload includes creator/metadata, curve sizing (saleAmount, graduationThreshold, maxSupply), targetRaiseAmount (net quote to graduation, excluding buy/anti-sniper taxes), virtual liquidity, initial price/purchase, quote asset, pair, applicationId, launch params, and schedule fields.

FRouterV3 emits TradeExecuted after every buy and sell via a private _emitTradeExecuted helper that reads post-trade reserves and derives lastPrice. Fields cover direction, amounts (gross/net semantics per side), normal and anti-sniper fees, and reserve snapshots.

Tests: bondingV5Fixture passes the 8th BondingConfig init arg; indexingEvents.js walks preLaunch → launch → buy/sell → graduation and asserts events against balance deltas and pair reserves.

Reviewed by Cursor Bugbot for commit ebc45da. Bugbot is set up for automated code reviews on this repo. Configure here.

…MigrateExecuted)

Additive, non-breaking on-chain events to support external indexing of
bonding-curve activity. No function signatures or storage layout change.

FRouterV3:
- TradeExecuted after every buy/sell: token/trader/pair, isBuy, quote asset,
  amounts, fees (tax + anti-sniper), net trader quote, post-trade reserves,
  lastPrice.

BondingV5:
- TokenCreated creation snapshot: virtualId, creator, token, metadata, curve
  params (saleAmount, graduationThreshold, targetRaiseAmount,
  initialVirtualLiquidity, initialPrice), quoteAsset, pair, applicationId,
  launchParams, start time.
- MigrateExecuted at graduation (caller, token, pair, agentToken, applicationId,
  assetAmount, tokenAmount).

Verified: compiles; BondingV5 21.95 KiB < 24.576 KiB EIP-170 limit; storage
layout unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
taxFee: normalTxFee,
antiSniperFee: antiSniperTxFee
})
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Launch buy mislabels indexed trader

Medium Severity

TradeExecuted sets the indexed trader to the router to address (token recipient). On launch(), the creator’s initial purchase calls _buy with address(this) as to, so the event attributes that buy to the bonding contract instead of the creator, while quote and token amounts still reflect a real trade.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7c34f35. Configure here.

claude added 3 commits July 6, 2026 03:01
Remove the telegram and youtube fields from the TokenCreated event and its
emit in preLaunch. These social URLs are already stored on-chain in tokenInfo
and are not needed in the indexing log. twitter and website are retained.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UN11rp5HvZkdg7EePTrgrP
…teExecuted

TradeExecuted: collapse the four amount fields into three direction-aware
fields (amountIn/amountOut/amount), removing the per-direction duplicate
(amountIn == traderQuoteAmount on buys, == tokenAmount on sells):
  - buy:  amountIn = quote paid, amountOut = token received, amount = quote into curve after tax
  - sell: amountIn = token sold, amountOut = gross quote out, amount = net quote to trader after tax

MigrateExecuted: removed. It largely duplicated the existing Graduated event
(same token/agentToken, same transaction); the remaining fields are recoverable
from Graduated, TokenCreated, or storage.

Tests updated to the new field names and event set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UN11rp5HvZkdg7EePTrgrP
Restore telegram and youtube to the TokenCreated event and its emit so
preLaunch's creation snapshot is unchanged from the original proposal
(twitter, telegram, youtube, website all retained).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UN11rp5HvZkdg7EePTrgrP

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d8a8674. Configure here.

targetRaiseAmount,
liquidity * 2,
price,
initialPurchase,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inconsistent price units across events

Medium Severity

TokenCreated sets initialPrice as bondingCurveSupply / liquidity (token-per-quote, unscaled), while TradeExecuted sets lastPrice as (reserveAsset * 1 ether) / reserveToken (quote-per-token, 1e18-scaled). A log-only indexer treating both as the same price series will show a discontinuous or inverted curve at the first trade.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d8a8674. Configure here.

psmiratisu and others added 3 commits July 6, 2026 21:01
…vent

Remove twitter, telegram, youtube and website from the TokenCreated event
and its emit in preLaunch. The social URLs remain stored on-chain in
tokenInfo; they are not needed in the indexing log.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

3 participants