diff --git a/docs/bridge/docs/06-Services/06-RFQ-Indexer-API.md b/docs/bridge/docs/06-Services/06-RFQ-Indexer-API.md index 1cbb3ddca3..6a744e4cae 100644 --- a/docs/bridge/docs/06-Services/06-RFQ-Indexer-API.md +++ b/docs/bridge/docs/06-Services/06-RFQ-Indexer-API.md @@ -9,6 +9,6 @@ The RFQ Indexer API is a service designed to provide access to indexed RFQ bridg ## Key Features 1. **Real-Time and Historical Data** Indexes from a specified start block up to real-time events. 2. **On-chain Tracing** Tracks all on-chain transactions and events, helping to debug. -4. **GraphQL API**: Provides a GraphQL/IQL endpoint for easy data querying. +3. **GraphQL API**: Provides a GraphQL/IQL endpoint for easy data querying. diff --git a/packages/rfq-indexer/indexer/ponder.config.ts b/packages/rfq-indexer/indexer/ponder.config.ts index da8d6f8f57..df73b39d5e 100644 --- a/packages/rfq-indexer/indexer/ponder.config.ts +++ b/packages/rfq-indexer/indexer/ponder.config.ts @@ -15,212 +15,212 @@ const lineaChainId = 59144 const bnbChainId = 56 const configByChainId = { - [1]: { - transport: http(process.env.ETH_MAINNET_RPC), - chainName: 'ethereum', - FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', - // FastBridgeV2StartBlock: 19420718, first block - FastBridgeV2StartBlock: 20426589,// new block - }, - [10]: { - transport: http(process.env.OPTIMISM_MAINNET_RPC), - chainName: 'optimism', - FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', - // FastBridgeV2StartBlock: 117334308, first block - FastBridgeV2StartBlock: 123416470, // new block - }, - [42161]: { - transport: http(process.env.ARBITRUM_MAINNET_RPC), - chainName: 'arbitrum', - FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', - // FastBridgeV2StartBlock: 189700328, first block - FastBridgeV2StartBlock: 237979967, // new block - }, - [8453]: { - transport: http(process.env.BASE_MAINNET_RPC), - chainName: 'base', - FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', - // FastBridgeV2StartBlock: 12478374, first block - FastBridgeV2StartBlock: 17821292, // new block - }, - [81457]: { - transport: http(process.env.BLAST_MAINNET_RPC), - chainName: 'blast', - FastBridgeV2Address: '0x34F52752975222d5994C206cE08C1d5B329f24dD', - // FastBridgeV2StartBlock: 6378234, first block - FastBridgeV2StartBlock: 6811045, // new block - }, - [534352]: { - transport: http(process.env.SCROLL_MAINNET_RPC), - chainName: 'scroll', - FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', - // FastBridgeV2StartBlock: 5357000, first block - FastBridgeV2StartBlock: 7941653, // new block - }, - [59144]: { - transport: http(process.env.LINEA_MAINNET_RPC), - chainName: 'linea', - FastBridgeV2Address: '0x34F52752975222d5994C206cE08C1d5B329f24dD', - FastBridgeV2StartBlock: 7124666, // first block and new block - }, - [56]: { - transport: http(process.env.BNB_MAINNET_RPC), - chainName: 'bnb', - FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', - FastBridgeV2StartBlock: 40497843, // first block and new block - }, - disableCache: true, + [1]: { + transport: http(process.env.ETH_MAINNET_RPC), + chainName: 'ethereum', + FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', + // FastBridgeV2StartBlock: 19420718, first block + FastBridgeV2StartBlock: 20426589, // new block + }, + [10]: { + transport: http(process.env.OPTIMISM_MAINNET_RPC), + chainName: 'optimism', + FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', + // FastBridgeV2StartBlock: 117334308, first block + FastBridgeV2StartBlock: 123416470, // new block + }, + [42161]: { + transport: http(process.env.ARBITRUM_MAINNET_RPC), + chainName: 'arbitrum', + FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', + // FastBridgeV2StartBlock: 189700328, first block + FastBridgeV2StartBlock: 237979967, // new block + }, + [8453]: { + transport: http(process.env.BASE_MAINNET_RPC), + chainName: 'base', + FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', + // FastBridgeV2StartBlock: 12478374, first block + FastBridgeV2StartBlock: 17821292, // new block + }, + [81457]: { + transport: http(process.env.BLAST_MAINNET_RPC), + chainName: 'blast', + FastBridgeV2Address: '0x34F52752975222d5994C206cE08C1d5B329f24dD', + // FastBridgeV2StartBlock: 6378234, first block + FastBridgeV2StartBlock: 6811045, // new block + }, + [534352]: { + transport: http(process.env.SCROLL_MAINNET_RPC), + chainName: 'scroll', + FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', + // FastBridgeV2StartBlock: 5357000, first block + FastBridgeV2StartBlock: 7941653, // new block + }, + [59144]: { + transport: http(process.env.LINEA_MAINNET_RPC), + chainName: 'linea', + FastBridgeV2Address: '0x34F52752975222d5994C206cE08C1d5B329f24dD', + FastBridgeV2StartBlock: 7124666, // first block and new block + }, + [56]: { + transport: http(process.env.BNB_MAINNET_RPC), + chainName: 'bnb', + FastBridgeV2Address: '0x5523D3c98809DdDB82C686E152F5C58B1B0fB59E', + FastBridgeV2StartBlock: 40497843, // first block and new block + }, + disableCache: true, } export const networkDetails = { - [ethereumChainId]: { - name: configByChainId[ethereumChainId].chainName, - FastBridgeV2: { - address: configByChainId[ethereumChainId].FastBridgeV2Address, - abi: FastBridgeV2Abi, - startBlock: configByChainId[ethereumChainId].FastBridgeV2StartBlock, - }, + [ethereumChainId]: { + name: configByChainId[ethereumChainId].chainName, + FastBridgeV2: { + address: configByChainId[ethereumChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[ethereumChainId].FastBridgeV2StartBlock, }, - [optimismChainId]: { - name: configByChainId[optimismChainId].chainName, - FastBridgeV2: { - address: configByChainId[optimismChainId].FastBridgeV2Address, - abi: FastBridgeV2Abi, - startBlock: configByChainId[optimismChainId].FastBridgeV2StartBlock, - }, + }, + [optimismChainId]: { + name: configByChainId[optimismChainId].chainName, + FastBridgeV2: { + address: configByChainId[optimismChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[optimismChainId].FastBridgeV2StartBlock, }, - [arbitrumChainId]: { - name: configByChainId[arbitrumChainId].chainName, - FastBridgeV2: { - address: configByChainId[arbitrumChainId].FastBridgeV2Address, - abi: FastBridgeV2Abi, - startBlock: configByChainId[arbitrumChainId].FastBridgeV2StartBlock, - }, + }, + [arbitrumChainId]: { + name: configByChainId[arbitrumChainId].chainName, + FastBridgeV2: { + address: configByChainId[arbitrumChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[arbitrumChainId].FastBridgeV2StartBlock, }, - [baseChainId]: { - name: configByChainId[baseChainId].chainName, - FastBridgeV2: { - address: configByChainId[baseChainId].FastBridgeV2Address, - abi: FastBridgeV2Abi, - startBlock: configByChainId[baseChainId].FastBridgeV2StartBlock, - }, + }, + [baseChainId]: { + name: configByChainId[baseChainId].chainName, + FastBridgeV2: { + address: configByChainId[baseChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[baseChainId].FastBridgeV2StartBlock, }, - [blastChainId]: { - name: configByChainId[blastChainId].chainName, - FastBridgeV2: { - address: configByChainId[blastChainId].FastBridgeV2Address, - abi: FastBridgeV2Abi, - startBlock: configByChainId[blastChainId].FastBridgeV2StartBlock, - }, + }, + [blastChainId]: { + name: configByChainId[blastChainId].chainName, + FastBridgeV2: { + address: configByChainId[blastChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[blastChainId].FastBridgeV2StartBlock, }, - [scrollChainId]: { - name: configByChainId[scrollChainId].chainName, - FastBridgeV2: { - address: configByChainId[scrollChainId].FastBridgeV2Address, - abi: FastBridgeV2Abi, - startBlock: configByChainId[scrollChainId].FastBridgeV2StartBlock, - }, + }, + [scrollChainId]: { + name: configByChainId[scrollChainId].chainName, + FastBridgeV2: { + address: configByChainId[scrollChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[scrollChainId].FastBridgeV2StartBlock, }, - [lineaChainId]: { - name: configByChainId[lineaChainId].chainName, - FastBridgeV2: { - address: configByChainId[lineaChainId].FastBridgeV2Address, - abi: FastBridgeV2Abi, - startBlock: configByChainId[lineaChainId].FastBridgeV2StartBlock, - }, + }, + [lineaChainId]: { + name: configByChainId[lineaChainId].chainName, + FastBridgeV2: { + address: configByChainId[lineaChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[lineaChainId].FastBridgeV2StartBlock, }, - [bnbChainId]: { - name: configByChainId[bnbChainId].chainName, - FastBridgeV2: { - address: configByChainId[bnbChainId].FastBridgeV2Address, - abi: FastBridgeV2Abi, - startBlock: configByChainId[bnbChainId].FastBridgeV2StartBlock, - }, + }, + [bnbChainId]: { + name: configByChainId[bnbChainId].chainName, + FastBridgeV2: { + address: configByChainId[bnbChainId].FastBridgeV2Address, + abi: FastBridgeV2Abi, + startBlock: configByChainId[bnbChainId].FastBridgeV2StartBlock, }, + }, } as Record const config = createConfig({ - networks: { + networks: { + [configByChainId[ethereumChainId].chainName]: { + chainId: ethereumChainId, + transport: configByChainId[ethereumChainId].transport, + // disableCache: configByChainId.disableCache, + }, + [configByChainId[optimismChainId].chainName]: { + chainId: optimismChainId, + transport: configByChainId[optimismChainId].transport, + // disableCache: configByChainId.disableCache, + }, + [configByChainId[arbitrumChainId].chainName]: { + chainId: arbitrumChainId, + transport: configByChainId[arbitrumChainId].transport, + // disableCache: configByChainId.disableCache, + }, + [configByChainId[baseChainId].chainName]: { + chainId: baseChainId, + transport: configByChainId[baseChainId].transport, + // disableCache: configByChainId.disableCache, + }, + [configByChainId[blastChainId].chainName]: { + chainId: blastChainId, + transport: configByChainId[blastChainId].transport, + // disableCache: configByChainId.disableCache, + }, + [configByChainId[scrollChainId].chainName]: { + chainId: scrollChainId, + transport: configByChainId[scrollChainId].transport, + // disableCache: configByChainId.disableCache, + }, + [configByChainId[lineaChainId].chainName]: { + chainId: lineaChainId, + transport: configByChainId[lineaChainId].transport, + // disableCache: configByChainId.disableCache, + }, + [configByChainId[bnbChainId].chainName]: { + chainId: bnbChainId, + transport: configByChainId[bnbChainId].transport, + // disableCache: configByChainId.disableCache, + }, + }, + contracts: { + FastBridgeV2: { + network: { [configByChainId[ethereumChainId].chainName]: { - chainId: ethereumChainId, - transport: configByChainId[ethereumChainId].transport, - // disableCache: configByChainId.disableCache, + address: networkDetails[ethereumChainId]?.FastBridgeV2.address, + startBlock: networkDetails[ethereumChainId]?.FastBridgeV2.startBlock, }, [configByChainId[optimismChainId].chainName]: { - chainId: optimismChainId, - transport: configByChainId[optimismChainId].transport, - // disableCache: configByChainId.disableCache, + address: networkDetails[optimismChainId]?.FastBridgeV2.address, + startBlock: networkDetails[optimismChainId]?.FastBridgeV2.startBlock, }, [configByChainId[arbitrumChainId].chainName]: { - chainId: arbitrumChainId, - transport: configByChainId[arbitrumChainId].transport, - // disableCache: configByChainId.disableCache, + address: networkDetails[arbitrumChainId]?.FastBridgeV2.address, + startBlock: networkDetails[arbitrumChainId]?.FastBridgeV2.startBlock, }, [configByChainId[baseChainId].chainName]: { - chainId: baseChainId, - transport: configByChainId[baseChainId].transport, - // disableCache: configByChainId.disableCache, + address: networkDetails[baseChainId]?.FastBridgeV2.address, + startBlock: networkDetails[baseChainId]?.FastBridgeV2.startBlock, }, [configByChainId[blastChainId].chainName]: { - chainId: blastChainId, - transport: configByChainId[blastChainId].transport, - // disableCache: configByChainId.disableCache, + address: networkDetails[blastChainId]?.FastBridgeV2.address, + startBlock: networkDetails[blastChainId]?.FastBridgeV2.startBlock, }, [configByChainId[scrollChainId].chainName]: { - chainId: scrollChainId, - transport: configByChainId[scrollChainId].transport, - // disableCache: configByChainId.disableCache, + address: networkDetails[scrollChainId]?.FastBridgeV2.address, + startBlock: networkDetails[scrollChainId]?.FastBridgeV2.startBlock, }, [configByChainId[lineaChainId].chainName]: { - chainId: lineaChainId, - transport: configByChainId[lineaChainId].transport, - // disableCache: configByChainId.disableCache, + address: networkDetails[lineaChainId]?.FastBridgeV2.address, + startBlock: networkDetails[lineaChainId]?.FastBridgeV2.startBlock, }, [configByChainId[bnbChainId].chainName]: { - chainId: bnbChainId, - transport: configByChainId[bnbChainId].transport, - // disableCache: configByChainId.disableCache, + address: networkDetails[bnbChainId]?.FastBridgeV2.address, + startBlock: networkDetails[bnbChainId]?.FastBridgeV2.startBlock, }, }, - contracts: { - FastBridgeV2: { - network: { - [configByChainId[ethereumChainId].chainName]: { - address: networkDetails[ethereumChainId]?.FastBridgeV2.address, - startBlock: networkDetails[ethereumChainId]?.FastBridgeV2.startBlock, - }, - [configByChainId[optimismChainId].chainName]: { - address: networkDetails[optimismChainId]?.FastBridgeV2.address, - startBlock: networkDetails[optimismChainId]?.FastBridgeV2.startBlock, - }, - [configByChainId[arbitrumChainId].chainName]: { - address: networkDetails[arbitrumChainId]?.FastBridgeV2.address, - startBlock: networkDetails[arbitrumChainId]?.FastBridgeV2.startBlock, - }, - [configByChainId[baseChainId].chainName]: { - address: networkDetails[baseChainId]?.FastBridgeV2.address, - startBlock: networkDetails[baseChainId]?.FastBridgeV2.startBlock, - }, - [configByChainId[blastChainId].chainName]: { - address: networkDetails[blastChainId]?.FastBridgeV2.address, - startBlock: networkDetails[blastChainId]?.FastBridgeV2.startBlock, - }, - [configByChainId[scrollChainId].chainName]: { - address: networkDetails[scrollChainId]?.FastBridgeV2.address, - startBlock: networkDetails[scrollChainId]?.FastBridgeV2.startBlock, - }, - [configByChainId[lineaChainId].chainName]: { - address: networkDetails[lineaChainId]?.FastBridgeV2.address, - startBlock: networkDetails[lineaChainId]?.FastBridgeV2.startBlock, - }, - [configByChainId[bnbChainId].chainName]: { - address: networkDetails[bnbChainId]?.FastBridgeV2.address, - startBlock: networkDetails[bnbChainId]?.FastBridgeV2.startBlock, - }, - }, - abi: FastBridgeV2Abi, - }, + abi: FastBridgeV2Abi, + }, }, }) -export default config \ No newline at end of file +export default config diff --git a/packages/rfq-indexer/indexer/ponder.schema.ts b/packages/rfq-indexer/indexer/ponder.schema.ts index 67f34464d2..11c77753e6 100644 --- a/packages/rfq-indexer/indexer/ponder.schema.ts +++ b/packages/rfq-indexer/indexer/ponder.schema.ts @@ -38,7 +38,7 @@ export default createSchema((p) => ({ destChain: p.string(), blockNumber: p.bigint(), blockTimestamp: p.int(), - transactionHash: p.string() + transactionHash: p.string(), }), BridgeProofProvidedEvents: p.createTable({ @@ -63,7 +63,7 @@ export default createSchema((p) => ({ originChain: p.string(), blockNumber: p.bigint(), blockTimestamp: p.int(), - transactionHash: p.string() + transactionHash: p.string(), }), BridgeDepositClaimedEvents: p.createTable({ @@ -78,6 +78,17 @@ export default createSchema((p) => ({ originChain: p.string(), blockNumber: p.bigint(), blockTimestamp: p.int(), - transactionHash: p.string() + transactionHash: p.string(), + }), + + BridgeProofDisputedEvents: p.createTable({ + id: p.string(), + transactionId: p.string(), + relayer: p.string(), + chainId: p.int(), + chain: p.string(), + blockNumber: p.bigint(), + blockTimestamp: p.int(), + transactionHash: p.string(), }), -})) \ No newline at end of file +})) diff --git a/packages/rfq-indexer/indexer/src/index.ts b/packages/rfq-indexer/indexer/src/index.ts index cd770c49d4..15b0c6aabf 100644 --- a/packages/rfq-indexer/indexer/src/index.ts +++ b/packages/rfq-indexer/indexer/src/index.ts @@ -1,12 +1,11 @@ import { trim } from 'viem' - import { ponder } from '@/generated' import { formatAmount } from './utils/formatAmount' import { getChainName } from './utils/chains' /* ORIGIN CHAIN EVENTS */ - + ponder.on('FastBridgeV2:BridgeRequested', async ({ event, context }) => { const { db: { BridgeRequestEvents }, @@ -41,7 +40,7 @@ ponder.on('FastBridgeV2:BridgeRequested', async ({ event, context }) => { originToken: trim(originToken), destToken: trim(destToken), originAmount, - originAmountFormatted: formatAmount(originAmount, originToken), + originAmountFormatted: formatAmount(originAmount, originToken), destAmount, destAmountFormatted: formatAmount(destAmount, destToken), sendChainGas, @@ -51,147 +50,179 @@ ponder.on('FastBridgeV2:BridgeRequested', async ({ event, context }) => { }, }) }) - + ponder.on('FastBridgeV2:BridgeDepositRefunded', async ({ event, context }) => { - const { - args: { transactionId, to, token, amount }, - block: { timestamp }, - transaction: { hash }, - log: { blockNumber }, - } = event - - const { - db: { BridgeDepositRefundedEvents }, - network: { chainId }, - } = context - - await BridgeDepositRefundedEvents.create({ - id: transactionId, - data: { - transactionId, - to: trim(to), - token: trim(token), - amount, - amountFormatted: formatAmount(amount,token), - blockNumber: BigInt(blockNumber), - blockTimestamp: Number(timestamp), - transactionHash: hash, - originChainId: chainId, - originChain: getChainName(Number(chainId)) - }, - }) + const { + args: { transactionId, to, token, amount }, + block: { timestamp }, + transaction: { hash }, + log: { blockNumber }, + } = event + + const { + db: { BridgeDepositRefundedEvents }, + network: { chainId }, + } = context + + await BridgeDepositRefundedEvents.create({ + id: transactionId, + data: { + transactionId, + to: trim(to), + token: trim(token), + amount, + amountFormatted: formatAmount(amount, token), + blockNumber: BigInt(blockNumber), + blockTimestamp: Number(timestamp), + transactionHash: hash, + originChainId: chainId, + originChain: getChainName(Number(chainId)), + }, + }) }) ponder.on('FastBridgeV2:BridgeProofProvided', async ({ event, context }) => { - const { - args: { transactionId, relayer }, - block: { timestamp }, - transaction: { hash }, - log: { address, blockNumber }, // may want to add address here eventually - } = event - - const { - db: { BridgeProofProvidedEvents }, - network: { chainId }, - } = context - - await BridgeProofProvidedEvents.upsert({ - id: transactionId, - // Save the full data first time we index this event - create: { - transactionId, - relayer: trim(relayer), - originChainId: chainId, - originChain: getChainName(Number(chainId)), - blockNumber: BigInt(blockNumber), - blockTimestamp: Number(timestamp), - transactionHash: hash, - }, - // Update the data with the latest event data on subsequent indexes - update: { - relayer: trim(relayer), - blockNumber: BigInt(blockNumber), - blockTimestamp: Number(timestamp), - transactionHash: hash, - } - }) + const { + args: { transactionId, relayer }, + block: { timestamp }, + transaction: { hash }, + log: { address, blockNumber }, // may want to add address here eventually + } = event + + const { + db: { BridgeProofProvidedEvents }, + network: { chainId }, + } = context + + await BridgeProofProvidedEvents.upsert({ + id: transactionId, + // Save the full data first time we index this event + create: { + transactionId, + relayer: trim(relayer), + originChainId: chainId, + originChain: getChainName(Number(chainId)), + blockNumber: BigInt(blockNumber), + blockTimestamp: Number(timestamp), + transactionHash: hash, + }, + // Update the data with the latest event data on subsequent indexes + update: { + relayer: trim(relayer), + blockNumber: BigInt(blockNumber), + blockTimestamp: Number(timestamp), + transactionHash: hash, + }, + }) }) ponder.on('FastBridgeV2:BridgeDepositClaimed', async ({ event, context }) => { - const { - args: { transactionId, relayer, to, token, amount }, - block: { timestamp }, - transaction: { hash }, - log: { blockNumber }, - } = event - - const { - db: { BridgeDepositClaimedEvents }, - network: { chainId }, - } = context - - await BridgeDepositClaimedEvents.create({ - id: transactionId, - data: { - transactionId, - relayer: trim(relayer), - to: trim(to), - token: trim(token), - amount, - amountFormatted: formatAmount(amount, token), - originChainId: chainId, - originChain: getChainName(Number(chainId)), - blockNumber: BigInt(blockNumber), - blockTimestamp: Number(timestamp), - transactionHash: hash, - }, - }) + const { + args: { transactionId, relayer, to, token, amount }, + block: { timestamp }, + transaction: { hash }, + log: { blockNumber }, + } = event + + const { + db: { BridgeDepositClaimedEvents }, + network: { chainId }, + } = context + + await BridgeDepositClaimedEvents.create({ + id: transactionId, + data: { + transactionId, + relayer: trim(relayer), + to: trim(to), + token: trim(token), + amount, + amountFormatted: formatAmount(amount, token), + originChainId: chainId, + originChain: getChainName(Number(chainId)), + blockNumber: BigInt(blockNumber), + blockTimestamp: Number(timestamp), + transactionHash: hash, + }, + }) }) -/* DESTINATION CHAIN EVENTS */ +ponder.on('FastBridgeV2:BridgeProofDisputed', async ({ event, context }) => { + const { + args: { transactionId, relayer }, + block: { timestamp }, + transaction: { hash }, + log: { blockNumber }, + } = event + const { + db: { BridgeProofDisputedEvents }, + network: { chainId }, + } = context + + await BridgeProofDisputedEvents.upsert({ + id: transactionId, + create: { + transactionId, + relayer: trim(relayer), + chainId: Number(chainId), + chain: getChainName(Number(chainId)), + blockNumber: BigInt(blockNumber), + blockTimestamp: Number(timestamp), + transactionHash: hash, + }, + update: { + relayer: trim(relayer), + blockNumber: BigInt(blockNumber), + blockTimestamp: Number(timestamp), + transactionHash: hash, + }, + }) +}) + +/* DESTINATION CHAIN EVENTS */ ponder.on('FastBridgeV2:BridgeRelayed', async ({ event, context }) => { - const { - args: { - transactionId, - relayer, - to, - originChainId, - originToken, - destToken, - originAmount, - destAmount, - }, - block: { timestamp }, - transaction: { hash }, - log: { blockNumber }, - } = event - - const { - db: { BridgeRelayedEvents }, - network: { chainId }, - } = context - - await BridgeRelayedEvents.create({ - id: transactionId, - data: { - transactionId, - relayer: trim(relayer), - to: trim(to), - originChainId: Number(originChainId), - originChain: getChainName(Number(originChainId)), - destChainId: Number(chainId), - destChain: getChainName(Number(chainId)), - originToken: trim(originToken), - destToken: trim(destToken), - originAmount, - originAmountFormatted: formatAmount(originAmount, originToken), - destAmount, - destAmountFormatted: formatAmount(destAmount, destToken), - blockNumber: BigInt(blockNumber), - blockTimestamp: Number(timestamp), - transactionHash: hash, - }, - }) -}) \ No newline at end of file + const { + args: { + transactionId, + relayer, + to, + originChainId, + originToken, + destToken, + originAmount, + destAmount, + }, + block: { timestamp }, + transaction: { hash }, + log: { blockNumber }, + } = event + + const { + db: { BridgeRelayedEvents }, + network: { chainId }, + } = context + + await BridgeRelayedEvents.create({ + id: transactionId, + data: { + transactionId, + relayer: trim(relayer), + to: trim(to), + originChainId: Number(originChainId), + originChain: getChainName(Number(originChainId)), + destChainId: Number(chainId), + destChain: getChainName(Number(chainId)), + originToken: trim(originToken), + destToken: trim(destToken), + originAmount, + originAmountFormatted: formatAmount(originAmount, originToken), + destAmount, + destAmountFormatted: formatAmount(destAmount, destToken), + blockNumber: BigInt(blockNumber), + blockTimestamp: Number(timestamp), + transactionHash: hash, + }, + }) +}) diff --git a/packages/rfq-indexer/indexer/src/types.ts b/packages/rfq-indexer/indexer/src/types.ts index 673464d6ff..e1f2809a9a 100644 --- a/packages/rfq-indexer/indexer/src/types.ts +++ b/packages/rfq-indexer/indexer/src/types.ts @@ -7,4 +7,4 @@ export interface AddressConfig { abi: Abi startBlock: number } -} \ No newline at end of file +} diff --git a/packages/rfq-indexer/indexer/src/utils/chains.ts b/packages/rfq-indexer/indexer/src/utils/chains.ts index 618d532684..e521f65def 100644 --- a/packages/rfq-indexer/indexer/src/utils/chains.ts +++ b/packages/rfq-indexer/indexer/src/utils/chains.ts @@ -1,14 +1,14 @@ export const chainIdToName: { [key: number]: string } = { - 1: 'ethereum', - 10: 'optimism', - 42161: 'arbitrum', - 8453: 'base', - 81457: 'blast', - 534352: 'scroll', - 59144: 'linea', - 56: 'bnb' - } - - export const getChainName = (chainId: number): string => { - return chainIdToName[chainId] || 'unknown' - } \ No newline at end of file + 1: 'ethereum', + 10: 'optimism', + 42161: 'arbitrum', + 8453: 'base', + 81457: 'blast', + 534352: 'scroll', + 59144: 'linea', + 56: 'bnb', +} + +export const getChainName = (chainId: number): string => { + return chainIdToName[chainId] || 'unknown' +} diff --git a/packages/rfq-indexer/indexer/src/utils/generateEntryId.ts b/packages/rfq-indexer/indexer/src/utils/generateEntryId.ts index e90c02131a..91bfe0f3da 100644 --- a/packages/rfq-indexer/indexer/src/utils/generateEntryId.ts +++ b/packages/rfq-indexer/indexer/src/utils/generateEntryId.ts @@ -1,3 +1,3 @@ export const generateEntryId = (chainId: number, dbNonce: number) => { - return `${chainId}-${Number(dbNonce)}` - } \ No newline at end of file + return `${chainId}-${Number(dbNonce)}` +}