diff --git a/lib/contracts/abi.ts b/lib/contracts/abi.ts index ac387367..a67be308 100644 --- a/lib/contracts/abi.ts +++ b/lib/contracts/abi.ts @@ -91,31 +91,33 @@ export const donateFunction = { // MCV2_Bond events (from MCV2_Bond.sol upstream) // --------------------------------------------------------------------------- -export const mcv2MintedEvent = { +export const mcv2MintEvent = { type: "event", - name: "Minted", + name: "Mint", inputs: [ { name: "token", type: "address", indexed: true }, - { name: "account", type: "address", indexed: true }, - { name: "tokenAmount", type: "uint256", indexed: false }, + { name: "user", type: "address", indexed: true }, + { name: "receiver", type: "address", indexed: false }, + { name: "amountMinted", type: "uint256", indexed: false }, + { name: "reserveToken", type: "address", indexed: true }, { name: "reserveAmount", type: "uint256", indexed: false }, - { name: "beneficiary", type: "address", indexed: false }, ], } as const; -export const mcv2BurnedEvent = { +export const mcv2BurnEvent = { type: "event", - name: "Burned", + name: "Burn", inputs: [ { name: "token", type: "address", indexed: true }, - { name: "account", type: "address", indexed: true }, - { name: "tokenAmount", type: "uint256", indexed: false }, + { name: "user", type: "address", indexed: true }, + { name: "receiver", type: "address", indexed: false }, + { name: "amountBurned", type: "uint256", indexed: false }, + { name: "reserveToken", type: "address", indexed: true }, { name: "refundAmount", type: "uint256", indexed: false }, - { name: "beneficiary", type: "address", indexed: false }, ], } as const; -export const mcv2BondEventAbi = [mcv2MintedEvent, mcv2BurnedEvent] as const; +export const mcv2BondEventAbi = [mcv2MintEvent, mcv2BurnEvent] as const; // --------------------------------------------------------------------------- // MCV2_Bond view functions diff --git a/src/app/api/cron/trade-history/route.ts b/src/app/api/cron/trade-history/route.ts index 932cc860..402b6877 100644 --- a/src/app/api/cron/trade-history/route.ts +++ b/src/app/api/cron/trade-history/route.ts @@ -108,7 +108,7 @@ export async function GET(req: Request) { topics: log.topics, }); - if (decoded.eventName !== "Minted" && decoded.eventName !== "Burned") { + if (decoded.eventName !== "Mint" && decoded.eventName !== "Burn") { skipped++; continue; } @@ -132,7 +132,7 @@ export async function GET(req: Request) { ); inserted++; } catch (err) { - // Skip events that don't decode as Minted/Burned + // Skip events that don't decode as Mint/Burn if (err instanceof Error && err.message.includes("could not find")) { skipped++; continue; @@ -171,15 +171,16 @@ async function processTradeEvent( ) { const args = decoded.args as { token: `0x${string}`; - account: `0x${string}`; - tokenAmount: bigint; + user: `0x${string}`; + amountMinted?: bigint; + amountBurned?: bigint; reserveAmount?: bigint; refundAmount?: bigint; }; - const isMint = decoded.eventName === "Minted"; + const isMint = decoded.eventName === "Mint"; const reserveAmount = isMint ? args.reserveAmount! : args.refundAmount!; - const tokenAmount = args.tokenAmount; + const tokenAmount = isMint ? args.amountMinted! : args.amountBurned!; // Compute price per token (reserve per token, 18 decimals) const pricePerToken = diff --git a/src/app/api/index/trade/route.ts b/src/app/api/index/trade/route.ts index 9f5a250c..011e5d19 100644 --- a/src/app/api/index/trade/route.ts +++ b/src/app/api/index/trade/route.ts @@ -61,20 +61,21 @@ export async function POST(req: Request) { topics: log.topics, }); - if (decoded.eventName !== "Minted" && decoded.eventName !== "Burned") continue; + if (decoded.eventName !== "Mint" && decoded.eventName !== "Burn") continue; const args = decoded.args as { token: `0x${string}`; - tokenAmount: bigint; + amountMinted?: bigint; + amountBurned?: bigint; reserveAmount?: bigint; refundAmount?: bigint; }; if (args.token.toLowerCase() !== tokenAddress) continue; - const isMint = decoded.eventName === "Minted"; + const isMint = decoded.eventName === "Mint"; const reserveAmount = isMint ? args.reserveAmount! : args.refundAmount!; - const tokenAmount = args.tokenAmount; + const tokenAmount = isMint ? args.amountMinted! : args.amountBurned!; const pricePerToken = tokenAmount > BigInt(0)