UNPKG

mev-inspect

Version:

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

36 lines 1.19 kB
import { isValidFactory, } from '../classifier/index.js'; function getPoolAddress(log) { if (log.classifier.type !== 'liquidity_withdrawal') { return ''; } if (log.classifier.protocol === 'BalancerV2') { const poolId = log.values.poolId; return poolId.substring(0, 42); } return log.address.toLowerCase(); } function getLiquidityWithdrawals(chainId, pools, transfers, logs) { return logs .map((log) => { if (log.classifier.type !== 'liquidity_withdrawal') { return null; } const poolAddress = getPoolAddress(log); const pool = pools.find((pool) => pool.address === poolAddress); if (!pool) { return null; } const protocol = log.classifier.protocol; if (!protocol) { return null; } const swapProtocol = protocol; if (!isValidFactory(chainId, swapProtocol, pool.factory)) { return null; } return log.classifier.parse(pool, log, transfers); }) .filter((withdrawal) => !!withdrawal); } export default getLiquidityWithdrawals; //# sourceMappingURL=liquidityWithdrawals.js.map