-
Notifications
You must be signed in to change notification settings - Fork 62
feat(launchpadv2): add indexing events to BondingV5 and FRouterV3 #174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7c34f35
b7df3ae
b8674f8
d8a8674
ebc45da
6cb2ecc
a7adaf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,18 @@ contract FRouterV3 is | |
| IBondingV5ForRouter public bondingV5; | ||
| IBondingConfigForRouter public bondingConfig; | ||
|
|
||
| struct TradeEventData { | ||
| address token; | ||
| address trader; | ||
| address pair; | ||
| bool isBuy; | ||
| uint256 amountIn; | ||
| uint256 amountOut; | ||
| uint256 amount; | ||
| uint256 taxFee; | ||
| uint256 antiSniperFee; | ||
| } | ||
|
|
||
| event PrivatePoolDrained( | ||
| address indexed token, | ||
| address indexed recipient, | ||
|
|
@@ -67,6 +79,22 @@ contract FRouterV3 is | |
| uint256 veTokenAmount | ||
| ); | ||
|
|
||
| event TradeExecuted( | ||
| address indexed token, | ||
| address indexed trader, | ||
| address indexed pair, | ||
| bool isBuy, | ||
| address quoteAsset, | ||
| uint256 amountIn, | ||
| uint256 amountOut, | ||
| uint256 amount, | ||
| uint256 taxFee, | ||
| uint256 antiSniperFee, | ||
| uint256 reserveTokenAfter, | ||
| uint256 reserveAssetAfter, | ||
| uint256 lastPrice | ||
| ); | ||
|
|
||
| /// @custom:oz-upgrades-unsafe-allow constructor | ||
| constructor() { | ||
| _disableInitializers(); | ||
|
|
@@ -184,6 +212,20 @@ contract FRouterV3 is | |
|
|
||
| pair.swap(amountIn, 0, 0, amountOut); | ||
|
|
||
| _emitTradeExecuted( | ||
| TradeEventData({ | ||
| token: tokenAddress, | ||
| trader: to, | ||
| pair: pairAddress, | ||
| isBuy: false, | ||
| amountIn: amountIn, | ||
| amountOut: amountOut, | ||
| amount: amount, | ||
| taxFee: normalTxFee, | ||
| antiSniperFee: antiSniperTxFee | ||
| }) | ||
| ); | ||
|
|
||
| return (amountIn, amountOut); | ||
| } | ||
|
|
||
|
|
@@ -240,6 +282,20 @@ contract FRouterV3 is | |
|
|
||
| IFPairV2(pair).swap(0, amountOut, amount, 0); | ||
|
|
||
| _emitTradeExecuted( | ||
| TradeEventData({ | ||
| token: tokenAddress, | ||
| trader: to, | ||
| pair: pair, | ||
| isBuy: true, | ||
| amountIn: amountIn, | ||
| amountOut: amountOut, | ||
| amount: amount, | ||
| taxFee: normalTxFee, | ||
| antiSniperFee: antiSniperTxFee | ||
| }) | ||
| ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Launch buy mislabels indexed traderMedium Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit 7c34f35. Configure here. |
||
|
|
||
| return (amount, amountOut); | ||
| } | ||
|
|
||
|
|
@@ -372,6 +428,30 @@ contract FRouterV3 is | |
| return finalTaxStartTime; | ||
| } | ||
|
|
||
| function _emitTradeExecuted(TradeEventData memory trade) private { | ||
| IFPairV2 pair = IFPairV2(trade.pair); | ||
| (uint256 remainingForSale, uint256 totalRaised) = pair.getReserves(); | ||
| uint256 lastPrice = remainingForSale == 0 | ||
| ? 0 | ||
| : ((totalRaised * 1 ether) / remainingForSale); // last price multiplied by 10 * 10^18 | ||
|
|
||
| emit TradeExecuted( | ||
| trade.token, | ||
| trade.trader, | ||
| trade.pair, | ||
| trade.isBuy, | ||
| assetToken, | ||
| trade.amountIn, | ||
| trade.amountOut, | ||
| trade.amount, | ||
| trade.taxFee, | ||
| trade.antiSniperFee, | ||
| remainingForSale, | ||
| totalRaised, | ||
| lastPrice | ||
| ); | ||
| } | ||
|
|
||
| function hasAntiSniperTax(address pairAddress) public view returns (bool) { | ||
| return | ||
| _calculateAntiSniperBuyTax(pairAddress) > 0 || | ||
|
|
||


There was a problem hiding this comment.
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
TokenCreatedsetsinitialPriceasbondingCurveSupply / liquidity(token-per-quote, unscaled), whileTradeExecutedsetslastPriceas(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)
contracts/launchpadv2/FRouterV3.sol#L399-L402Reviewed by Cursor Bugbot for commit d8a8674. Configure here.