UNPKG

mev-inspect

Version:

A JS port of 'mev-inspect-py' optimised for ease of use.

82 lines 2.19 kB
import { ZeroAddress } from 'ethers'; import exchangeAbi from '../../abi/x2y2V1.js'; import { nativeAsset } from '../index.js'; function isValid(event) { return event.name === 'EvInventory'; } function getPoolCalls() { return []; } function processPoolCalls(_results, address) { return { factoryAddress: address.toLowerCase(), asset: '', collection: '', metadata: {}, }; } function parse(pool, event, chainId) { const { values, transactionFrom, transactionHash: hash, transactionIndex, gasUsed, logIndex, address, blockHash, blockNumber, } = event; const taker = values.taker.toLowerCase(); const currency = values.currency.toLowerCase(); const price = values.item.price; const data = values.item.data.toLowerCase(); const from = taker; const to = taker; return { contract: { address: pool.address, protocol: { abi: 'X2Y2V1', factory: pool.factory, }, }, block: { hash: blockHash, number: blockNumber, }, transaction: { from: transactionFrom.toLowerCase(), hash, index: transactionIndex, gasUsed, }, event: { address: address.toLowerCase(), logIndex, }, from, to, assetIn: currency === ZeroAddress ? { type: 'erc20', address: nativeAsset[chainId], } : { type: 'erc20', address: currency, }, amountIn: price, assetOut: { type: 'erc721', collection: `0x${data.substring(154, 194)}`, id: BigInt(`0x${data.substring(194, 258)}`), }, amountOut: 1n, }; } const CLASSIFIER = { nftSwap: { type: 'nft_swap', protocol: 'X2Y2V1', abi: exchangeAbi, isValid, parse, pool: { getCalls: getPoolCalls, processCalls: processPoolCalls, }, }, }; export default CLASSIFIER; //# sourceMappingURL=x2y2V1.js.map