@0xtorch/evm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/import/abis/erc1155.d.ts +245 -0
- package/dist/import/abis/erc1155.d.ts.map +1 -0
- package/dist/import/abis/erc20.d.ts +169 -0
- package/dist/import/abis/erc20.d.ts.map +1 -0
- package/dist/import/abis/erc721.d.ts +267 -0
- package/dist/import/abis/erc721.d.ts.map +1 -0
- package/dist/import/abis/index.d.ts +5 -0
- package/dist/import/abis/index.d.ts.map +1 -0
- package/dist/import/abis/weth.d.ts +214 -0
- package/dist/import/abis/weth.d.ts.map +1 -0
- package/dist/import/absoluteValue.d.mts +3 -0
- package/dist/import/absoluteValue.d.mts.map +1 -0
- package/dist/import/absoluteValue.d.ts +3 -0
- package/dist/import/absoluteValue.d.ts.map +1 -0
- package/dist/import/analyzer/analyze.d.ts +18 -0
- package/dist/import/analyzer/analyze.d.ts.map +1 -0
- package/dist/import/analyzer/analyzer.d.ts +4 -0
- package/dist/import/analyzer/analyzer.d.ts.map +1 -0
- package/dist/import/analyzer/axieMarketplace/analyze.d.ts +4 -0
- package/dist/import/analyzer/axieMarketplace/analyze.d.ts.map +1 -0
- package/dist/import/analyzer/axieMarketplace/index.d.ts +2 -0
- package/dist/import/analyzer/axieMarketplace/index.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/addLiquidity.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/addLiquidity.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/atomicArbitrage.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/atomicArbitrage.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/bridgeFrom.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/bridgeFrom.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/bridgeTo.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/bridgeTo.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/buyNft.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/buyNft.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/createAccountActionByAction.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/createAccountActionByAction.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/deposit.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/deposit.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/depositWithBond.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/depositWithBond.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/freeMintNft.d.ts +53 -0
- package/dist/import/analyzer/createAccountActionByAction/freeMintNft.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/index.d.ts +2 -0
- package/dist/import/analyzer/createAccountActionByAction/index.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/removeLiquidity.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/removeLiquidity.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/spam.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/spam.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/trade.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/trade.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/transactionFee.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/transactionFee.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/transfer.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/transfer.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/withdraw.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/withdraw.d.ts.map +1 -0
- package/dist/import/analyzer/createAccountActionByAction/withdrawWithBond.d.ts +59 -0
- package/dist/import/analyzer/createAccountActionByAction/withdrawWithBond.d.ts.map +1 -0
- package/dist/import/analyzer/gasFee/analyze.d.ts +4 -0
- package/dist/import/analyzer/gasFee/analyze.d.ts.map +1 -0
- package/dist/import/analyzer/gasFee/index.d.ts +2 -0
- package/dist/import/analyzer/gasFee/index.d.ts.map +1 -0
- package/dist/import/analyzer/index.d.ts +10 -0
- package/dist/import/analyzer/index.d.ts.map +1 -0
- package/dist/import/analyzer/json/analyze.d.ts +5 -0
- package/dist/import/analyzer/json/analyze.d.ts.map +1 -0
- package/dist/import/analyzer/json/generatorAnyLog.d.ts +55 -0
- package/dist/import/analyzer/json/generatorAnyLog.d.ts.map +1 -0
- package/dist/import/analyzer/json/generatorAnyTokenTransfer.d.ts +54 -0
- package/dist/import/analyzer/json/generatorAnyTokenTransfer.d.ts.map +1 -0
- package/dist/import/analyzer/json/generatorSpecificTokenTransfer.d.ts +55 -0
- package/dist/import/analyzer/json/generatorSpecificTokenTransfer.d.ts.map +1 -0
- package/dist/import/analyzer/json/index.d.ts +2 -0
- package/dist/import/analyzer/json/index.d.ts.map +1 -0
- package/dist/import/analyzer/json/types.d.ts +177 -0
- package/dist/import/analyzer/json/types.d.ts.map +1 -0
- package/dist/import/analyzer/seaport/analyze.d.ts +4 -0
- package/dist/import/analyzer/seaport/analyze.d.ts.map +1 -0
- package/dist/import/analyzer/seaport/index.d.ts +2 -0
- package/dist/import/analyzer/seaport/index.d.ts.map +1 -0
- package/dist/import/analyzer/seaport/orderFulfilled.d.ts +139 -0
- package/dist/import/analyzer/seaport/orderFulfilled.d.ts.map +1 -0
- package/dist/import/analyzer/spam/analyze.d.ts +4 -0
- package/dist/import/analyzer/spam/analyze.d.ts.map +1 -0
- package/dist/import/analyzer/spam/index.d.ts +2 -0
- package/dist/import/analyzer/spam/index.d.ts.map +1 -0
- package/dist/import/analyzer/swap/analyze.d.ts +4 -0
- package/dist/import/analyzer/swap/analyze.d.ts.map +1 -0
- package/dist/import/analyzer/swap/index.d.ts +2 -0
- package/dist/import/analyzer/swap/index.d.ts.map +1 -0
- package/dist/import/analyzer/swap/traderJoeLBPairSwap.d.ts +108 -0
- package/dist/import/analyzer/swap/traderJoeLBPairSwap.d.ts.map +1 -0
- package/dist/import/analyzer/swap/univ2PairSwap.d.ts +84 -0
- package/dist/import/analyzer/swap/univ2PairSwap.d.ts.map +1 -0
- package/dist/import/analyzer/swap/univ3PoolSwap.d.ts +96 -0
- package/dist/import/analyzer/swap/univ3PoolSwap.d.ts.map +1 -0
- package/dist/import/analyzer/swap/wrappedDeposit.d.ts +36 -0
- package/dist/import/analyzer/swap/wrappedDeposit.d.ts.map +1 -0
- package/dist/import/analyzer/swap/wrappedWithdrawal.d.ts +36 -0
- package/dist/import/analyzer/swap/wrappedWithdrawal.d.ts.map +1 -0
- package/dist/import/analyzer/transfer/analyze.d.ts +4 -0
- package/dist/import/analyzer/transfer/analyze.d.ts.map +1 -0
- package/dist/import/analyzer/transfer/index.d.ts +2 -0
- package/dist/import/analyzer/transfer/index.d.ts.map +1 -0
- package/dist/import/analyzer/types.d.ts +17 -0
- package/dist/import/analyzer/types.d.ts.map +1 -0
- package/dist/import/apps/index.d.ts +2 -0
- package/dist/import/apps/index.d.ts.map +1 -0
- package/dist/import/apps/types.d.ts +6 -0
- package/dist/import/apps/types.d.ts.map +1 -0
- package/dist/import/chains/definitions/arbitrumOne.d.ts +99 -0
- package/dist/import/chains/definitions/arbitrumOne.d.ts.map +1 -0
- package/dist/import/chains/definitions/astar.d.ts +64 -0
- package/dist/import/chains/definitions/astar.d.ts.map +1 -0
- package/dist/import/chains/definitions/avalancheC.d.ts +84 -0
- package/dist/import/chains/definitions/avalancheC.d.ts.map +1 -0
- package/dist/import/chains/definitions/base.d.ts +94 -0
- package/dist/import/chains/definitions/base.d.ts.map +1 -0
- package/dist/import/chains/definitions/bsc.d.ts +144 -0
- package/dist/import/chains/definitions/bsc.d.ts.map +1 -0
- package/dist/import/chains/definitions/defineChain.d.ts +3 -0
- package/dist/import/chains/definitions/defineChain.d.ts.map +1 -0
- package/dist/import/chains/definitions/ethereum.d.ts +129 -0
- package/dist/import/chains/definitions/ethereum.d.ts.map +1 -0
- package/dist/import/chains/definitions/fantom.d.ts +89 -0
- package/dist/import/chains/definitions/fantom.d.ts.map +1 -0
- package/dist/import/chains/definitions/index.d.ts +16 -0
- package/dist/import/chains/definitions/index.d.ts.map +1 -0
- package/dist/import/chains/definitions/linea.d.ts +69 -0
- package/dist/import/chains/definitions/linea.d.ts.map +1 -0
- package/dist/import/chains/definitions/mantle.d.ts +62 -0
- package/dist/import/chains/definitions/mantle.d.ts.map +1 -0
- package/dist/import/chains/definitions/metis.d.ts +52 -0
- package/dist/import/chains/definitions/metis.d.ts.map +1 -0
- package/dist/import/chains/definitions/moonbeam.d.ts +84 -0
- package/dist/import/chains/definitions/moonbeam.d.ts.map +1 -0
- package/dist/import/chains/definitions/moonriver.d.ts +64 -0
- package/dist/import/chains/definitions/moonriver.d.ts.map +1 -0
- package/dist/import/chains/definitions/optimism.d.ts +104 -0
- package/dist/import/chains/definitions/optimism.d.ts.map +1 -0
- package/dist/import/chains/definitions/polygonPos.d.ts +84 -0
- package/dist/import/chains/definitions/polygonPos.d.ts.map +1 -0
- package/dist/import/chains/definitions/ronin.d.ts +49 -0
- package/dist/import/chains/definitions/ronin.d.ts.map +1 -0
- package/dist/import/chains/externals/defillama/constants.d.ts +2 -0
- package/dist/import/chains/externals/defillama/constants.d.ts.map +1 -0
- package/dist/import/chains/externals/defillama/getBlockOfTimestamp.d.ts +10 -0
- package/dist/import/chains/externals/defillama/getBlockOfTimestamp.d.ts.map +1 -0
- package/dist/import/chains/externals/defillama/index.d.ts +2 -0
- package/dist/import/chains/externals/defillama/index.d.ts.map +1 -0
- package/dist/import/chains/externals/index.d.ts +2 -0
- package/dist/import/chains/externals/index.d.ts.map +1 -0
- package/dist/import/chains/index.d.ts +4 -0
- package/dist/import/chains/index.d.ts.map +1 -0
- package/dist/import/chains/types/chain.d.ts +22 -0
- package/dist/import/chains/types/chain.d.ts.map +1 -0
- package/dist/import/chains/types/index.d.ts +3 -0
- package/dist/import/chains/types/index.d.ts.map +1 -0
- package/dist/import/chains/types/rpc.d.ts +7 -0
- package/dist/import/chains/types/rpc.d.ts.map +1 -0
- package/dist/import/clients/definitions/defineClient.d.ts +3 -0
- package/dist/import/clients/definitions/defineClient.d.ts.map +1 -0
- package/dist/import/clients/definitions/index.d.ts +2 -0
- package/dist/import/clients/definitions/index.d.ts.map +1 -0
- package/dist/import/clients/definitions/viemClient.d.ts +59 -0
- package/dist/import/clients/definitions/viemClient.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/estimateFeesPerGas.d.ts +13 -0
- package/dist/import/clients/externals/viem/estimateFeesPerGas.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/getBalance.d.ts +15 -0
- package/dist/import/clients/externals/viem/getBalance.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/getBlock.d.ts +14 -0
- package/dist/import/clients/externals/viem/getBlock.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/getBlockNumber.d.ts +13 -0
- package/dist/import/clients/externals/viem/getBlockNumber.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/getEventLogs.d.ts +19 -0
- package/dist/import/clients/externals/viem/getEventLogs.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/getTransaction.d.ts +15 -0
- package/dist/import/clients/externals/viem/getTransaction.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/getTransactionCount.d.ts +15 -0
- package/dist/import/clients/externals/viem/getTransactionCount.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/getTransactionReceipt.d.ts +15 -0
- package/dist/import/clients/externals/viem/getTransactionReceipt.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/index.d.ts +11 -0
- package/dist/import/clients/externals/viem/index.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/middleware.d.ts +23 -0
- package/dist/import/clients/externals/viem/middleware.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/multicall.d.ts +14 -0
- package/dist/import/clients/externals/viem/multicall.d.ts.map +1 -0
- package/dist/import/clients/externals/viem/readContract.d.ts +14 -0
- package/dist/import/clients/externals/viem/readContract.d.ts.map +1 -0
- package/dist/import/clients/index.d.ts +3 -0
- package/dist/import/clients/index.d.ts.map +1 -0
- package/dist/import/clients/types.d.ts +64 -0
- package/dist/import/clients/types.d.ts.map +1 -0
- package/dist/import/createBigDecimal.d.mts +6 -0
- package/dist/import/createBigDecimal.d.mts.map +1 -0
- package/dist/import/createBigDecimal.d.ts +3 -0
- package/dist/import/createBigDecimal.d.ts.map +1 -0
- package/dist/import/creates/createEvmAccount.d.ts +5 -0
- package/dist/import/creates/createEvmAccount.d.ts.map +1 -0
- package/dist/import/decoder/decode.d.ts +3 -0
- package/dist/import/decoder/decode.d.ts.map +1 -0
- package/dist/import/decoder/decoder.d.ts +3 -0
- package/dist/import/decoder/decoder.d.ts.map +1 -0
- package/dist/import/decoder/index.d.ts +6 -0
- package/dist/import/decoder/index.d.ts.map +1 -0
- package/dist/import/decoder/parseErc1155TransferSingleLogs.d.ts +4 -0
- package/dist/import/decoder/parseErc1155TransferSingleLogs.d.ts.map +1 -0
- package/dist/import/decoder/parseErc20TransferLogs.d.ts +8 -0
- package/dist/import/decoder/parseErc20TransferLogs.d.ts.map +1 -0
- package/dist/import/decoder/parseErc721TransferLogs.d.ts +8 -0
- package/dist/import/decoder/parseErc721TransferLogs.d.ts.map +1 -0
- package/dist/import/decoder/types.d.ts +16 -0
- package/dist/import/decoder/types.d.ts.map +1 -0
- package/dist/import/divide.d.mts +8 -0
- package/dist/import/divide.d.mts.map +1 -0
- package/dist/import/divide.d.ts +3 -0
- package/dist/import/divide.d.ts.map +1 -0
- package/dist/import/equals.d.mts +3 -0
- package/dist/import/equals.d.mts.map +1 -0
- package/dist/import/equals.d.ts +3 -0
- package/dist/import/equals.d.ts.map +1 -0
- package/dist/import/explorers/definitions/blockscout.d.ts +60 -0
- package/dist/import/explorers/definitions/blockscout.d.ts.map +1 -0
- package/dist/import/explorers/definitions/defineExplorer.d.ts +3 -0
- package/dist/import/explorers/definitions/defineExplorer.d.ts.map +1 -0
- package/dist/import/explorers/definitions/etherscan.d.ts +61 -0
- package/dist/import/explorers/definitions/etherscan.d.ts.map +1 -0
- package/dist/import/explorers/definitions/index.d.ts +5 -0
- package/dist/import/explorers/definitions/index.d.ts.map +1 -0
- package/dist/import/explorers/definitions/roninExplorer.d.ts +62 -0
- package/dist/import/explorers/definitions/roninExplorer.d.ts.map +1 -0
- package/dist/import/explorers/definitions/routescan.d.ts +19 -0
- package/dist/import/explorers/definitions/routescan.d.ts.map +1 -0
- package/dist/import/explorers/externals/blockscout/getBlockNumberOfTimestamp.d.ts +11 -0
- package/dist/import/explorers/externals/blockscout/getBlockNumberOfTimestamp.d.ts.map +1 -0
- package/dist/import/explorers/externals/blockscout/getContractByAddress.d.ts +30 -0
- package/dist/import/explorers/externals/blockscout/getContractByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/blockscout/getInternalTransactionsByAddress.d.ts +62 -0
- package/dist/import/explorers/externals/blockscout/getInternalTransactionsByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/blockscout/getInternalTransactionsByTransactionHash.d.ts +54 -0
- package/dist/import/explorers/externals/blockscout/getInternalTransactionsByTransactionHash.d.ts.map +1 -0
- package/dist/import/explorers/externals/blockscout/getNormalTransactionsByAddress.d.ts +77 -0
- package/dist/import/explorers/externals/blockscout/getNormalTransactionsByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/blockscout/getTokenTransfersByAddress.d.ts +80 -0
- package/dist/import/explorers/externals/blockscout/getTokenTransfersByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/blockscout/index.d.ts +7 -0
- package/dist/import/explorers/externals/blockscout/index.d.ts.map +1 -0
- package/dist/import/explorers/externals/blockscout/middleware.d.ts +7 -0
- package/dist/import/explorers/externals/blockscout/middleware.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/getBlockNumberOfTimestamp.d.ts +12 -0
- package/dist/import/explorers/externals/etherscan/getBlockNumberOfTimestamp.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/getContractByAddress.d.ts +55 -0
- package/dist/import/explorers/externals/etherscan/getContractByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/getErc1155TokenTransfersByAddress.d.ts +83 -0
- package/dist/import/explorers/externals/etherscan/getErc1155TokenTransfersByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/getErc20TokenTransfersByAddress.d.ts +81 -0
- package/dist/import/explorers/externals/etherscan/getErc20TokenTransfersByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/getErc721TokenTransfersByAddress.d.ts +81 -0
- package/dist/import/explorers/externals/etherscan/getErc721TokenTransfersByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/getInternalTransactionsByAddress.d.ts +62 -0
- package/dist/import/explorers/externals/etherscan/getInternalTransactionsByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/getInternalTransactionsByTransactionHash.d.ts +55 -0
- package/dist/import/explorers/externals/etherscan/getInternalTransactionsByTransactionHash.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/getNormalTransactionsByAddress.d.ts +84 -0
- package/dist/import/explorers/externals/etherscan/getNormalTransactionsByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/index.d.ts +9 -0
- package/dist/import/explorers/externals/etherscan/index.d.ts.map +1 -0
- package/dist/import/explorers/externals/etherscan/middleware.d.ts +7 -0
- package/dist/import/explorers/externals/etherscan/middleware.d.ts.map +1 -0
- package/dist/import/explorers/externals/roninExplorer/getInternalTransactionByHash.d.ts +57 -0
- package/dist/import/explorers/externals/roninExplorer/getInternalTransactionByHash.d.ts.map +1 -0
- package/dist/import/explorers/externals/roninExplorer/getNormalTransactionsByAddress.d.ts +70 -0
- package/dist/import/explorers/externals/roninExplorer/getNormalTransactionsByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/roninExplorer/getTokenTransfersByAddress.d.ts +64 -0
- package/dist/import/explorers/externals/roninExplorer/getTokenTransfersByAddress.d.ts.map +1 -0
- package/dist/import/explorers/externals/roninExplorer/index.d.ts +4 -0
- package/dist/import/explorers/externals/roninExplorer/index.d.ts.map +1 -0
- package/dist/import/explorers/externals/roninExplorer/middleware.d.ts +5 -0
- package/dist/import/explorers/externals/roninExplorer/middleware.d.ts.map +1 -0
- package/dist/import/explorers/index.d.ts +3 -0
- package/dist/import/explorers/index.d.ts.map +1 -0
- package/dist/import/explorers/types.d.ts +43 -0
- package/dist/import/explorers/types.d.ts.map +1 -0
- package/dist/import/fix.d.mts +7 -0
- package/dist/import/fix.d.mts.map +1 -0
- package/dist/import/fix.d.ts +3 -0
- package/dist/import/fix.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/getAccountsTransactionFulls.d.ts +15 -0
- package/dist/import/getAccountsTransactionFulls/getAccountsTransactionFulls.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.d.ts +4 -0
- package/dist/import/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/getDecodedTransactionsPrices.d.ts +5 -0
- package/dist/import/getAccountsTransactionFulls/getDecodedTransactionsPrices.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/getHashesAndInternalTxs.d.ts +8 -0
- package/dist/import/getAccountsTransactionFulls/getHashesAndInternalTxs.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/getTransactionDetail.d.ts +5 -0
- package/dist/import/getAccountsTransactionFulls/getTransactionDetail.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/getTransactionDetails.d.ts +5 -0
- package/dist/import/getAccountsTransactionFulls/getTransactionDetails.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/getTransactionsApps.d.ts +8 -0
- package/dist/import/getAccountsTransactionFulls/getTransactionsApps.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/index.d.ts +3 -0
- package/dist/import/getAccountsTransactionFulls/index.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/types.d.ts +87 -0
- package/dist/import/getAccountsTransactionFulls/types.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/withD.d.ts +4 -0
- package/dist/import/getAccountsTransactionFulls/withD.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/withDA.d.ts +4 -0
- package/dist/import/getAccountsTransactionFulls/withDA.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/withP.d.ts +4 -0
- package/dist/import/getAccountsTransactionFulls/withP.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/withPD.d.ts +4 -0
- package/dist/import/getAccountsTransactionFulls/withPD.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/withPDA.d.ts +4 -0
- package/dist/import/getAccountsTransactionFulls/withPDA.d.ts.map +1 -0
- package/dist/import/getAccountsTransactionFulls/withUndefined.d.ts +4 -0
- package/dist/import/getAccountsTransactionFulls/withUndefined.d.ts.map +1 -0
- package/dist/import/getTransactionFull/getTransactionDetail.d.ts +5 -0
- package/dist/import/getTransactionFull/getTransactionDetail.d.ts.map +1 -0
- package/dist/import/getTransactionFull/getTransactionFull.d.ts +11 -0
- package/dist/import/getTransactionFull/getTransactionFull.d.ts.map +1 -0
- package/dist/import/getTransactionFull/getTransactionFullCustom.d.ts +4 -0
- package/dist/import/getTransactionFull/getTransactionFullCustom.d.ts.map +1 -0
- package/dist/import/getTransactionFull/index.d.ts +3 -0
- package/dist/import/getTransactionFull/index.d.ts.map +1 -0
- package/dist/import/getTransactionFull/types.d.ts +63 -0
- package/dist/import/getTransactionFull/types.d.ts.map +1 -0
- package/dist/import/getTransactionFull/withD.d.ts +4 -0
- package/dist/import/getTransactionFull/withD.d.ts.map +1 -0
- package/dist/import/getTransactionFull/withDA.d.ts +4 -0
- package/dist/import/getTransactionFull/withDA.d.ts.map +1 -0
- package/dist/import/getTransactionFull/withP.d.ts +4 -0
- package/dist/import/getTransactionFull/withP.d.ts.map +1 -0
- package/dist/import/getTransactionFull/withPD.d.ts +4 -0
- package/dist/import/getTransactionFull/withPD.d.ts.map +1 -0
- package/dist/import/getTransactionFull/withPDA.d.ts +4 -0
- package/dist/import/getTransactionFull/withPDA.d.ts.map +1 -0
- package/dist/import/getTransactionFull/withUndefined.d.ts +4 -0
- package/dist/import/getTransactionFull/withUndefined.d.ts.map +1 -0
- package/dist/import/greaterThan.d.mts +3 -0
- package/dist/import/greaterThan.d.mts.map +1 -0
- package/dist/import/greaterThan.d.ts +3 -0
- package/dist/import/greaterThan.d.ts.map +1 -0
- package/dist/import/index.d.mts +15 -0
- package/dist/import/index.d.mts.map +1 -0
- package/dist/import/index.d.ts +11 -0
- package/dist/import/index.d.ts.map +1 -0
- package/dist/import/index.mjs +1 -0
- package/dist/import/minus.d.mts +3 -0
- package/dist/import/minus.d.mts.map +1 -0
- package/dist/import/minus.d.ts +3 -0
- package/dist/import/minus.d.ts.map +1 -0
- package/dist/import/plus.d.mts +3 -0
- package/dist/import/plus.d.mts.map +1 -0
- package/dist/import/plus.d.ts +3 -0
- package/dist/import/plus.d.ts.map +1 -0
- package/dist/import/removeTrailingZeros.d.mts +6 -0
- package/dist/import/removeTrailingZeros.d.mts.map +1 -0
- package/dist/import/removeTrailingZeros.d.ts +3 -0
- package/dist/import/removeTrailingZeros.d.ts.map +1 -0
- package/dist/import/times.d.ts +3 -0
- package/dist/import/times.d.ts.map +1 -0
- package/dist/import/toStringBigDecimal.d.mts +6 -0
- package/dist/import/toStringBigDecimal.d.mts.map +1 -0
- package/dist/import/toStringBigDecimal.d.ts +3 -0
- package/dist/import/toStringBigDecimal.d.ts.map +1 -0
- package/dist/import/type.d.mts +5 -0
- package/dist/import/type.d.mts.map +1 -0
- package/dist/import/type.d.ts +5 -0
- package/dist/import/type.d.ts.map +1 -0
- package/dist/import/types/erc1155.d.ts +16 -0
- package/dist/import/types/erc1155.d.ts.map +1 -0
- package/dist/import/types/erc20.d.ts +19 -0
- package/dist/import/types/erc20.d.ts.map +1 -0
- package/dist/import/types/erc721.d.ts +18 -0
- package/dist/import/types/erc721.d.ts.map +1 -0
- package/dist/import/types/evmAccount.d.ts +10 -0
- package/dist/import/types/evmAccount.d.ts.map +1 -0
- package/dist/import/types/hex.d.ts +5 -0
- package/dist/import/types/hex.d.ts.map +1 -0
- package/dist/import/types/index.d.ts +12 -0
- package/dist/import/types/index.d.ts.map +1 -0
- package/dist/import/types/input.d.ts +26 -0
- package/dist/import/types/input.d.ts.map +1 -0
- package/dist/import/types/internalTransaction.d.ts +18 -0
- package/dist/import/types/internalTransaction.d.ts.map +1 -0
- package/dist/import/types/log.d.ts +118 -0
- package/dist/import/types/log.d.ts.map +1 -0
- package/dist/import/types/transaction.d.ts +44 -0
- package/dist/import/types/transaction.d.ts.map +1 -0
- package/dist/import/utils/bigint.d.ts +3 -0
- package/dist/import/utils/bigint.d.ts.map +1 -0
- package/dist/import/utils/index.d.ts +4 -0
- package/dist/import/utils/index.d.ts.map +1 -0
- package/dist/import/utils/timeout.d.ts +2 -0
- package/dist/import/utils/timeout.d.ts.map +1 -0
- package/dist/import/utils/types.d.ts +12 -0
- package/dist/import/utils/types.d.ts.map +1 -0
- package/dist/require/absoluteValue.d.ts +3 -0
- package/dist/require/absoluteValue.d.ts.map +1 -0
- package/dist/require/createBigDecimal.d.ts +6 -0
- package/dist/require/createBigDecimal.d.ts.map +1 -0
- package/dist/require/divide.d.ts +2 -0
- package/dist/require/divide.d.ts.map +1 -0
- package/dist/require/equals.d.ts +3 -0
- package/dist/require/equals.d.ts.map +1 -0
- package/dist/require/fix.d.ts +7 -0
- package/dist/require/fix.d.ts.map +1 -0
- package/dist/require/greaterThan.d.ts +3 -0
- package/dist/require/greaterThan.d.ts.map +1 -0
- package/dist/require/index.cjs +46 -0
- package/dist/require/index.d.cts +2 -0
- package/dist/require/index.d.cts.map +1 -0
- package/dist/require/index.d.ts +11 -0
- package/dist/require/index.d.ts.map +1 -0
- package/dist/require/minus.d.ts +3 -0
- package/dist/require/minus.d.ts.map +1 -0
- package/dist/require/plus.d.ts +3 -0
- package/dist/require/plus.d.ts.map +1 -0
- package/dist/require/removeTrailingZeros.d.ts +6 -0
- package/dist/require/removeTrailingZeros.d.ts.map +1 -0
- package/dist/require/times.d.ts +8 -0
- package/dist/require/times.d.ts.map +1 -0
- package/dist/require/toStringBigDecimal.d.ts +6 -0
- package/dist/require/toStringBigDecimal.d.ts.map +1 -0
- package/dist/require/type.d.ts +5 -0
- package/dist/require/type.d.ts.map +1 -0
- package/package.json +85 -0
- package/src/abis/erc1155.ts +314 -0
- package/src/abis/erc20.ts +222 -0
- package/src/abis/erc721.ts +346 -0
- package/src/abis/index.ts +4 -0
- package/src/abis/weth.ts +153 -0
- package/src/analyzer/analyze.ts +85 -0
- package/src/analyzer/analyzer.ts +5 -0
- package/src/analyzer/axieMarketplace/analyze.ts +326 -0
- package/src/analyzer/axieMarketplace/index.ts +1 -0
- package/src/analyzer/createAccountActionByAction/addLiquidity.ts +60 -0
- package/src/analyzer/createAccountActionByAction/atomicArbitrage.ts +115 -0
- package/src/analyzer/createAccountActionByAction/bridgeFrom.ts +61 -0
- package/src/analyzer/createAccountActionByAction/bridgeTo.ts +61 -0
- package/src/analyzer/createAccountActionByAction/buyNft.ts +106 -0
- package/src/analyzer/createAccountActionByAction/createAccountActionByAction.ts +181 -0
- package/src/analyzer/createAccountActionByAction/deposit.ts +64 -0
- package/src/analyzer/createAccountActionByAction/depositWithBond.ts +60 -0
- package/src/analyzer/createAccountActionByAction/freeMintNft.ts +54 -0
- package/src/analyzer/createAccountActionByAction/index.ts +1 -0
- package/src/analyzer/createAccountActionByAction/removeLiquidity.ts +60 -0
- package/src/analyzer/createAccountActionByAction/spam.ts +79 -0
- package/src/analyzer/createAccountActionByAction/trade.ts +105 -0
- package/src/analyzer/createAccountActionByAction/transactionFee.ts +51 -0
- package/src/analyzer/createAccountActionByAction/transfer.ts +95 -0
- package/src/analyzer/createAccountActionByAction/withdraw.ts +61 -0
- package/src/analyzer/createAccountActionByAction/withdrawWithBond.ts +60 -0
- package/src/analyzer/gasFee/analyze.test.ts +6 -0
- package/src/analyzer/gasFee/analyze.ts +72 -0
- package/src/analyzer/gasFee/index.ts +1 -0
- package/src/analyzer/index.ts +9 -0
- package/src/analyzer/json/analyze.test.ts +1819 -0
- package/src/analyzer/json/analyze.ts +536 -0
- package/src/analyzer/json/generatorAnyLog.ts +207 -0
- package/src/analyzer/json/generatorAnyTokenTransfer.ts +118 -0
- package/src/analyzer/json/generatorSpecificTokenTransfer.ts +425 -0
- package/src/analyzer/json/index.ts +1 -0
- package/src/analyzer/json/types.ts +239 -0
- package/src/analyzer/seaport/analyze.test.ts +2323 -0
- package/src/analyzer/seaport/analyze.ts +917 -0
- package/src/analyzer/seaport/index.ts +1 -0
- package/src/analyzer/seaport/orderFulfilled.ts +131 -0
- package/src/analyzer/spam/analyze.ts +219 -0
- package/src/analyzer/spam/index.ts +1 -0
- package/src/analyzer/swap/analyze.test.ts +2401 -0
- package/src/analyzer/swap/analyze.ts +939 -0
- package/src/analyzer/swap/index.ts +1 -0
- package/src/analyzer/swap/traderJoeLBPairSwap.ts +92 -0
- package/src/analyzer/swap/univ2PairSwap.ts +77 -0
- package/src/analyzer/swap/univ3PoolSwap.ts +83 -0
- package/src/analyzer/swap/wrappedDeposit.ts +51 -0
- package/src/analyzer/swap/wrappedWithdrawal.ts +53 -0
- package/src/analyzer/tests.ts +2 -0
- package/src/analyzer/transfer/analyze.test.ts +6 -0
- package/src/analyzer/transfer/analyze.ts +209 -0
- package/src/analyzer/transfer/index.ts +1 -0
- package/src/analyzer/types.ts +44 -0
- package/src/apps/index.ts +1 -0
- package/src/apps/types.ts +10 -0
- package/src/chains/definitions/arbitrumOne.test.ts +50 -0
- package/src/chains/definitions/arbitrumOne.ts +133 -0
- package/src/chains/definitions/astar.test.ts +51 -0
- package/src/chains/definitions/astar.ts +93 -0
- package/src/chains/definitions/avalancheC.test.ts +50 -0
- package/src/chains/definitions/avalancheC.ts +115 -0
- package/src/chains/definitions/base.test.ts +50 -0
- package/src/chains/definitions/base.ts +125 -0
- package/src/chains/definitions/bsc.test.ts +50 -0
- package/src/chains/definitions/bsc.ts +182 -0
- package/src/chains/definitions/defineChain.ts +7 -0
- package/src/chains/definitions/ethereum.test.ts +50 -0
- package/src/chains/definitions/ethereum.ts +169 -0
- package/src/chains/definitions/fantom.test.ts +50 -0
- package/src/chains/definitions/fantom.ts +123 -0
- package/src/chains/definitions/index.ts +88 -0
- package/src/chains/definitions/linea.test.ts +50 -0
- package/src/chains/definitions/linea.ts +95 -0
- package/src/chains/definitions/mantle.test.ts +50 -0
- package/src/chains/definitions/mantle.ts +75 -0
- package/src/chains/definitions/metis.test.ts +50 -0
- package/src/chains/definitions/metis.ts +60 -0
- package/src/chains/definitions/moonbeam.test.ts +50 -0
- package/src/chains/definitions/moonbeam.ts +117 -0
- package/src/chains/definitions/moonriver.test.ts +50 -0
- package/src/chains/definitions/moonriver.ts +94 -0
- package/src/chains/definitions/optimism.test.ts +50 -0
- package/src/chains/definitions/optimism.ts +139 -0
- package/src/chains/definitions/polygonPos.test.ts +50 -0
- package/src/chains/definitions/polygonPos.ts +121 -0
- package/src/chains/definitions/ronin.test.ts +50 -0
- package/src/chains/definitions/ronin.ts +75 -0
- package/src/chains/definitions/tests.ts +2884 -0
- package/src/chains/externals/defillama/constants.ts +1 -0
- package/src/chains/externals/defillama/getBlockOfTimestamp.test.ts +12 -0
- package/src/chains/externals/defillama/getBlockOfTimestamp.ts +26 -0
- package/src/chains/externals/defillama/index.ts +1 -0
- package/src/chains/externals/index.ts +1 -0
- package/src/chains/index.ts +62 -0
- package/src/chains/types/chain.ts +22 -0
- package/src/chains/types/index.ts +2 -0
- package/src/chains/types/rpc.ts +6 -0
- package/src/clients/definitions/defineClient.ts +7 -0
- package/src/clients/definitions/index.ts +1 -0
- package/src/clients/definitions/viemClient.ts +86 -0
- package/src/clients/externals/viem/estimateFeesPerGas.ts +23 -0
- package/src/clients/externals/viem/getBalance.ts +25 -0
- package/src/clients/externals/viem/getBlock.ts +29 -0
- package/src/clients/externals/viem/getBlockNumber.ts +23 -0
- package/src/clients/externals/viem/getEventLogs.test.ts +22 -0
- package/src/clients/externals/viem/getEventLogs.ts +40 -0
- package/src/clients/externals/viem/getTransaction.ts +25 -0
- package/src/clients/externals/viem/getTransactionCount.ts +25 -0
- package/src/clients/externals/viem/getTransactionReceipt.ts +25 -0
- package/src/clients/externals/viem/index.ts +10 -0
- package/src/clients/externals/viem/middleware.ts +437 -0
- package/src/clients/externals/viem/multicall.test.ts +26 -0
- package/src/clients/externals/viem/multicall.ts +27 -0
- package/src/clients/externals/viem/readContract.test.ts +20 -0
- package/src/clients/externals/viem/readContract.ts +38 -0
- package/src/clients/externals/viem/tests.ts +957 -0
- package/src/clients/index.ts +2 -0
- package/src/clients/types.ts +113 -0
- package/src/creates/createEvmAccount.ts +12 -0
- package/src/decoder/decode.test.ts +324 -0
- package/src/decoder/decode.ts +716 -0
- package/src/decoder/decoder.ts +6 -0
- package/src/decoder/index.ts +5 -0
- package/src/decoder/parseErc1155TransferSingleLogs.ts +40 -0
- package/src/decoder/parseErc20TransferLogs.ts +35 -0
- package/src/decoder/parseErc721TransferLogs.ts +40 -0
- package/src/decoder/tests.ts +502 -0
- package/src/decoder/types.ts +21 -0
- package/src/explorers/definitions/blockscout.test.ts +124 -0
- package/src/explorers/definitions/blockscout.ts +205 -0
- package/src/explorers/definitions/defineExplorer.ts +7 -0
- package/src/explorers/definitions/etherscan.test.ts +123 -0
- package/src/explorers/definitions/etherscan.ts +279 -0
- package/src/explorers/definitions/index.ts +4 -0
- package/src/explorers/definitions/roninExplorer.ts +150 -0
- package/src/explorers/definitions/routescan.ts +57 -0
- package/src/explorers/externals/blockscout/getBlockNumberOfTimestamp.ts +67 -0
- package/src/explorers/externals/blockscout/getContractByAddress.ts +81 -0
- package/src/explorers/externals/blockscout/getInternalTransactionsByAddress.ts +120 -0
- package/src/explorers/externals/blockscout/getInternalTransactionsByTransactionHash.ts +87 -0
- package/src/explorers/externals/blockscout/getNormalTransactionsByAddress.ts +116 -0
- package/src/explorers/externals/blockscout/getTokenTransfersByAddress.ts +127 -0
- package/src/explorers/externals/blockscout/index.ts +6 -0
- package/src/explorers/externals/blockscout/middleware.ts +56 -0
- package/src/explorers/externals/defillama/getBlockNumberOfTimestamp.ts +28 -0
- package/src/explorers/externals/defillama/index.ts +1 -0
- package/src/explorers/externals/etherscan/getBlockNumberOfTimestamp.ts +66 -0
- package/src/explorers/externals/etherscan/getContractByAddress.ts +86 -0
- package/src/explorers/externals/etherscan/getErc1155TokenTransfersByAddress.ts +133 -0
- package/src/explorers/externals/etherscan/getErc20TokenTransfersByAddress.ts +125 -0
- package/src/explorers/externals/etherscan/getErc721TokenTransfersByAddress.ts +125 -0
- package/src/explorers/externals/etherscan/getInternalTransactionsByAddress.ts +117 -0
- package/src/explorers/externals/etherscan/getInternalTransactionsByTransactionHash.ts +91 -0
- package/src/explorers/externals/etherscan/getNormalTransactionsByAddress.ts +122 -0
- package/src/explorers/externals/etherscan/index.ts +8 -0
- package/src/explorers/externals/etherscan/middleware.ts +77 -0
- package/src/explorers/externals/roninExplorer/getInternalTransactionByHash.ts +80 -0
- package/src/explorers/externals/roninExplorer/getNormalTransactionsByAddress.ts +79 -0
- package/src/explorers/externals/roninExplorer/getTokenTransfersByAddress.ts +81 -0
- package/src/explorers/externals/roninExplorer/index.ts +3 -0
- package/src/explorers/externals/roninExplorer/middleware.ts +49 -0
- package/src/explorers/index.ts +7 -0
- package/src/explorers/types.ts +56 -0
- package/src/getAccountsTransactionFulls/getAccountsTransactionFulls.test.ts +22 -0
- package/src/getAccountsTransactionFulls/getAccountsTransactionFulls.ts +46 -0
- package/src/getAccountsTransactionFulls/getAccountsTransactionFullsCustom.ts +106 -0
- package/src/getAccountsTransactionFulls/getDecodedTransactionsPrices.ts +97 -0
- package/src/getAccountsTransactionFulls/getHashesAndInternalTxs.ts +65 -0
- package/src/getAccountsTransactionFulls/getTransactionDetail.ts +49 -0
- package/src/getAccountsTransactionFulls/getTransactionDetails.ts +39 -0
- package/src/getAccountsTransactionFulls/getTransactionsApps.ts +42 -0
- package/src/getAccountsTransactionFulls/index.ts +2 -0
- package/src/getAccountsTransactionFulls/types.ts +122 -0
- package/src/getAccountsTransactionFulls/withD.ts +80 -0
- package/src/getAccountsTransactionFulls/withDA.ts +112 -0
- package/src/getAccountsTransactionFulls/withP.ts +120 -0
- package/src/getAccountsTransactionFulls/withPD.ts +141 -0
- package/src/getAccountsTransactionFulls/withPDA.ts +167 -0
- package/src/getAccountsTransactionFulls/withUndefined.ts +88 -0
- package/src/getContractAbi.ts +15 -0
- package/src/getTransactionFull/getTransactionDetail.ts +47 -0
- package/src/getTransactionFull/getTransactionFull.test.ts +34 -0
- package/src/getTransactionFull/getTransactionFull.ts +30 -0
- package/src/getTransactionFull/getTransactionFullCustom.ts +91 -0
- package/src/getTransactionFull/index.ts +2 -0
- package/src/getTransactionFull/types.ts +98 -0
- package/src/getTransactionFull/withD.ts +57 -0
- package/src/getTransactionFull/withDA.ts +78 -0
- package/src/getTransactionFull/withP.ts +69 -0
- package/src/getTransactionFull/withPD.ts +119 -0
- package/src/getTransactionFull/withPDA.ts +147 -0
- package/src/getTransactionFull/withUndefined.ts +39 -0
- package/src/index.cts +1 -0
- package/src/index.mts +110 -0
- package/src/tests.ts +1 -0
- package/src/types/erc1155.ts +17 -0
- package/src/types/erc20.ts +22 -0
- package/src/types/erc721.ts +19 -0
- package/src/types/evmAccount.ts +12 -0
- package/src/types/hex.test.ts +10 -0
- package/src/types/hex.ts +9 -0
- package/src/types/index.ts +16 -0
- package/src/types/input.ts +27 -0
- package/src/types/internalTransaction.ts +19 -0
- package/src/types/log.ts +68 -0
- package/src/types/transaction.ts +78 -0
- package/src/utils/bigint.ts +5 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/timeout.ts +5 -0
- package/src/utils/types.ts +12 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,939 @@
|
|
|
1
|
+
import { createBigDecimal } from '@0xtorch/big-decimal'
|
|
2
|
+
import type {
|
|
3
|
+
CryptoCurrency,
|
|
4
|
+
CryptoCurrencyPrice,
|
|
5
|
+
NormalActionAtomicArbitrage,
|
|
6
|
+
NormalActionTrade,
|
|
7
|
+
} from '@0xtorch/core'
|
|
8
|
+
import { zeroAddress } from 'viem'
|
|
9
|
+
import type { Chain } from '../../chains'
|
|
10
|
+
import { createEvmAccount } from '../../creates/createEvmAccount'
|
|
11
|
+
import type {
|
|
12
|
+
DecodedLog,
|
|
13
|
+
Erc20Transfer,
|
|
14
|
+
EvmAccount,
|
|
15
|
+
InternalTransaction,
|
|
16
|
+
LowerHex,
|
|
17
|
+
} from '../../types'
|
|
18
|
+
import { toLowerHex } from '../../types'
|
|
19
|
+
import { createAccountActionByAction } from '../createAccountActionByAction'
|
|
20
|
+
import type { AnalyzeParameters, AnalyzeReturnType } from '../types'
|
|
21
|
+
import type { TraderJoeLBPairSwapLog } from './traderJoeLBPairSwap'
|
|
22
|
+
import { parseToTraderJoeLBPairSwap } from './traderJoeLBPairSwap'
|
|
23
|
+
import type { UniV2PairSwapLog } from './univ2PairSwap'
|
|
24
|
+
import { parseToUniv2SwapLog } from './univ2PairSwap'
|
|
25
|
+
import type { UniV3PoolSwapLog } from './univ3PoolSwap'
|
|
26
|
+
import { parseToUniv3SwapLog } from './univ3PoolSwap'
|
|
27
|
+
import type { WrappedDepositLog } from './wrappedDeposit'
|
|
28
|
+
import { parseToWrappedDepositLog } from './wrappedDeposit'
|
|
29
|
+
import type { WrappedWithdrawalLog } from './wrappedWithdrawal'
|
|
30
|
+
import { parseToWrappedWithdrawalLog } from './wrappedWithdrawal'
|
|
31
|
+
|
|
32
|
+
export const analyzeSwap = <Price extends CryptoCurrencyPrice | undefined>({
|
|
33
|
+
chain,
|
|
34
|
+
transaction,
|
|
35
|
+
accountAddresses,
|
|
36
|
+
}: AnalyzeParameters<Price>): Promise<AnalyzeReturnType<Price> | undefined> => {
|
|
37
|
+
const {
|
|
38
|
+
transactionHash,
|
|
39
|
+
from,
|
|
40
|
+
to,
|
|
41
|
+
value,
|
|
42
|
+
erc20Transfers,
|
|
43
|
+
erc721Transfers,
|
|
44
|
+
erc1155Transfers,
|
|
45
|
+
internalTransactions,
|
|
46
|
+
block,
|
|
47
|
+
logs,
|
|
48
|
+
nativeTokenPrice,
|
|
49
|
+
} = transaction
|
|
50
|
+
const timestamp = Number(block.timestamp) * 1000
|
|
51
|
+
|
|
52
|
+
const nativeTransfer =
|
|
53
|
+
value > 0 && to !== null
|
|
54
|
+
? {
|
|
55
|
+
type: 'InternalTransaction' as const,
|
|
56
|
+
transactionHash,
|
|
57
|
+
from: toLowerHex(from),
|
|
58
|
+
to: toLowerHex(to),
|
|
59
|
+
contractAddress: undefined,
|
|
60
|
+
txType: '',
|
|
61
|
+
value:
|
|
62
|
+
value -
|
|
63
|
+
internalTransactions
|
|
64
|
+
.filter(
|
|
65
|
+
(internal) =>
|
|
66
|
+
internal.from === toLowerHex(to) &&
|
|
67
|
+
internal.to === toLowerHex(from),
|
|
68
|
+
)
|
|
69
|
+
.reduce(
|
|
70
|
+
(accumulator, internal) => accumulator + internal.value,
|
|
71
|
+
0n,
|
|
72
|
+
),
|
|
73
|
+
gas: 0n,
|
|
74
|
+
gasUsed: 0n,
|
|
75
|
+
isError: false,
|
|
76
|
+
input: undefined,
|
|
77
|
+
currency: chain.nativeToken.currency,
|
|
78
|
+
price: nativeTokenPrice,
|
|
79
|
+
}
|
|
80
|
+
: undefined
|
|
81
|
+
const allInternalTransactions: InternalTransaction<Price>[] = [
|
|
82
|
+
...(nativeTransfer === undefined ? [] : [nativeTransfer]),
|
|
83
|
+
...internalTransactions.filter(
|
|
84
|
+
(internal) =>
|
|
85
|
+
value === 0n ||
|
|
86
|
+
to === null ||
|
|
87
|
+
internal.from !== toLowerHex(to) ||
|
|
88
|
+
internal.to !== toLowerHex(from),
|
|
89
|
+
),
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
// If the transaction contains ERC721 or ERC1155 transfers, return undefined as a pattern mismatch.
|
|
93
|
+
if (erc721Transfers.length > 0 || erc1155Transfers.length > 0) {
|
|
94
|
+
return Promise.resolve(undefined)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// classify logs by type
|
|
98
|
+
const decodedLogs = logs
|
|
99
|
+
.map((log) => (log.type === 'decoded' ? log.log : undefined))
|
|
100
|
+
.filter((log): log is DecodedLog => log !== undefined)
|
|
101
|
+
const univ2SwapLogs = decodedLogs
|
|
102
|
+
.map((log) => parseToUniv2SwapLog(log))
|
|
103
|
+
.filter((log): log is UniV2PairSwapLog => log !== undefined)
|
|
104
|
+
const univ3SwapLogs = decodedLogs
|
|
105
|
+
.map((log) => parseToUniv3SwapLog(log))
|
|
106
|
+
.filter((log): log is UniV3PoolSwapLog => log !== undefined)
|
|
107
|
+
const traderJoeLBPairSwapLogs = decodedLogs
|
|
108
|
+
.map((log) => parseToTraderJoeLBPairSwap(log))
|
|
109
|
+
.filter((log): log is TraderJoeLBPairSwapLog => log !== undefined)
|
|
110
|
+
const depositLogs = decodedLogs
|
|
111
|
+
.map((log) => parseToWrappedDepositLog(log))
|
|
112
|
+
.filter((log): log is WrappedDepositLog => log !== undefined)
|
|
113
|
+
const withdrawalLogs = decodedLogs
|
|
114
|
+
.map((log) => parseToWrappedWithdrawalLog(log))
|
|
115
|
+
.filter((log): log is WrappedWithdrawalLog => log !== undefined)
|
|
116
|
+
|
|
117
|
+
// If the transaction does not contain any swap logs, return undefined as a pattern mismatch.
|
|
118
|
+
if (
|
|
119
|
+
univ2SwapLogs.length === 0 &&
|
|
120
|
+
univ3SwapLogs.length === 0 &&
|
|
121
|
+
traderJoeLBPairSwapLogs.length === 0
|
|
122
|
+
) {
|
|
123
|
+
return Promise.resolve(undefined)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// swap 生成
|
|
127
|
+
const univ2Swaps = univ2SwapLogs
|
|
128
|
+
.map((log) => createSwapFromUniv2SwapLog(log, erc20Transfers))
|
|
129
|
+
.filter((swap): swap is Swap<Price> => swap !== undefined)
|
|
130
|
+
const univ3Swaps = univ3SwapLogs
|
|
131
|
+
.map((log) => createSwapFromUniv3SwapLog(log, erc20Transfers))
|
|
132
|
+
.filter((swap): swap is Swap<Price> => swap !== undefined)
|
|
133
|
+
const traderJoeLBPairSwaps = traderJoeLBPairSwapLogs
|
|
134
|
+
.map((log) => createSwapFromTraderJoeLBPairSwapLog(log, erc20Transfers))
|
|
135
|
+
.filter((swap): swap is Swap<Price> => swap !== undefined)
|
|
136
|
+
const swaps = [...univ2Swaps, ...univ3Swaps, ...traderJoeLBPairSwaps]
|
|
137
|
+
|
|
138
|
+
// swap action の前後に残る Transfer log を抽出
|
|
139
|
+
const swapUsingIndexes = new Set(
|
|
140
|
+
swaps.flatMap((swap) => createSwapUsingIndexes(swap)),
|
|
141
|
+
)
|
|
142
|
+
// from,to が同一の transfer は除外
|
|
143
|
+
// from,to が zero address の transfer は除外
|
|
144
|
+
const unrelatedTransfers = erc20Transfers.filter(
|
|
145
|
+
(transfer) =>
|
|
146
|
+
!swapUsingIndexes.has(transfer.logIndex) &&
|
|
147
|
+
transfer.from !== transfer.to &&
|
|
148
|
+
transfer.from !== zeroAddress &&
|
|
149
|
+
transfer.to !== zeroAddress,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
// index で swap, transfer, deposit, withdrawal log をソート
|
|
153
|
+
const actions = [
|
|
154
|
+
...swaps,
|
|
155
|
+
...unrelatedTransfers,
|
|
156
|
+
...depositLogs,
|
|
157
|
+
...withdrawalLogs,
|
|
158
|
+
].toSorted((a, b) => getIndex(a) - getIndex(b))
|
|
159
|
+
|
|
160
|
+
// sort した action を結合できる場合は結合していく
|
|
161
|
+
const mergedActions = mergeActions(actions, chain.nativeToken.currency)
|
|
162
|
+
|
|
163
|
+
// 結合した action が swap 1 つのみで無ければパターン不一致として、 undefined を返す
|
|
164
|
+
if (mergedActions.length !== 1) {
|
|
165
|
+
return Promise.resolve(undefined)
|
|
166
|
+
}
|
|
167
|
+
const mergedAction = mergedActions[0]
|
|
168
|
+
if (mergedAction.type !== 'Swap') {
|
|
169
|
+
return Promise.resolve(undefined)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 結合できる internal transaction があれば結合する
|
|
173
|
+
const { swap, internalTransactions: remainInternalTransactions } =
|
|
174
|
+
mergeSwapAndInternalTransactions(mergedAction, allInternalTransactions)
|
|
175
|
+
|
|
176
|
+
// 結合後の internal transaction に account に関連する value > 0 の transaction があれば、
|
|
177
|
+
// パターン不一致として、 undefined を返す
|
|
178
|
+
if (
|
|
179
|
+
remainInternalTransactions.some(
|
|
180
|
+
(internalTransaction) =>
|
|
181
|
+
(internalTransaction.value > 0n &&
|
|
182
|
+
accountAddresses.includes(internalTransaction.from)) ||
|
|
183
|
+
(internalTransaction.to !== undefined &&
|
|
184
|
+
accountAddresses.includes(internalTransaction.to)),
|
|
185
|
+
)
|
|
186
|
+
) {
|
|
187
|
+
return Promise.resolve(undefined)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// 最終的に swap のみ残った場合は Trade / AtomicArbitrage / SwapTransfer のいずれかとして扱う
|
|
191
|
+
if (swap.transferOut.to === undefined) {
|
|
192
|
+
return Promise.resolve(undefined)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// normal action を生成
|
|
196
|
+
const normalAction = generateNormalAction(swap, chain, timestamp)
|
|
197
|
+
|
|
198
|
+
// account action を生成
|
|
199
|
+
const accountAction = createAccountActionByAction(
|
|
200
|
+
normalAction,
|
|
201
|
+
transaction,
|
|
202
|
+
accountAddresses,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
return Promise.resolve({
|
|
206
|
+
actions: [normalAction],
|
|
207
|
+
accountActions: accountAction === undefined ? [] : [accountAction],
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const generateNormalAction = <Price extends CryptoCurrencyPrice | undefined>(
|
|
212
|
+
swap: Swap<Price>,
|
|
213
|
+
chain: Chain,
|
|
214
|
+
timestamp: number,
|
|
215
|
+
):
|
|
216
|
+
| NormalActionAtomicArbitrage<EvmAccount, Price>
|
|
217
|
+
| NormalActionTrade<EvmAccount, Price, CryptoCurrency> => {
|
|
218
|
+
if (
|
|
219
|
+
swap.transferIn.type === 'InternalTransaction' &&
|
|
220
|
+
swap.transferOut.type === 'InternalTransaction'
|
|
221
|
+
) {
|
|
222
|
+
return generateNormalActionAtomicArbitrage(swap, chain, timestamp)
|
|
223
|
+
} else if (
|
|
224
|
+
swap.transferIn.type === 'Erc20Transfer' &&
|
|
225
|
+
swap.transferOut.type === 'Erc20Transfer' &&
|
|
226
|
+
swap.transferIn.token.contractAddress ===
|
|
227
|
+
swap.transferOut.token.contractAddress
|
|
228
|
+
) {
|
|
229
|
+
return generateNormalActionAtomicArbitrage(swap, chain, timestamp)
|
|
230
|
+
} else {
|
|
231
|
+
return generateNormalActionTrade(swap, chain, timestamp)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const generateNormalActionAtomicArbitrage = <
|
|
236
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
237
|
+
>(
|
|
238
|
+
swap: Swap<Price>,
|
|
239
|
+
chain: Chain,
|
|
240
|
+
timestamp: number,
|
|
241
|
+
): NormalActionAtomicArbitrage<EvmAccount, Price> => {
|
|
242
|
+
const { transferIn, transferOut } = swap
|
|
243
|
+
const transferInAsset =
|
|
244
|
+
transferIn.type === 'Erc20Transfer'
|
|
245
|
+
? transferIn.token.currency
|
|
246
|
+
: chain.nativeToken.currency
|
|
247
|
+
const transferOutAsset =
|
|
248
|
+
transferOut.type === 'Erc20Transfer'
|
|
249
|
+
? transferOut.token.currency
|
|
250
|
+
: chain.nativeToken.currency
|
|
251
|
+
if (
|
|
252
|
+
transferIn.to === undefined ||
|
|
253
|
+
transferOut.to === undefined ||
|
|
254
|
+
transferInAsset === undefined ||
|
|
255
|
+
transferOutAsset === undefined
|
|
256
|
+
) {
|
|
257
|
+
throw new Error('invalid swap')
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const transferInDecimals =
|
|
261
|
+
transferIn.type === 'Erc20Transfer'
|
|
262
|
+
? transferIn.token.decimals
|
|
263
|
+
: chain.nativeToken.decimals
|
|
264
|
+
const transferOutDecimals =
|
|
265
|
+
transferOut.type === 'Erc20Transfer'
|
|
266
|
+
? transferOut.token.decimals
|
|
267
|
+
: chain.nativeToken.decimals
|
|
268
|
+
return {
|
|
269
|
+
type: 'NormalAction',
|
|
270
|
+
action: 'atomic-arbitrage',
|
|
271
|
+
evidence: 'contract',
|
|
272
|
+
timestamp,
|
|
273
|
+
comment: undefined,
|
|
274
|
+
app: undefined,
|
|
275
|
+
transfers: [
|
|
276
|
+
{
|
|
277
|
+
target: transferIn.from,
|
|
278
|
+
direction: 'out',
|
|
279
|
+
from: createEvmAccount({ address: transferIn.from, chainId: chain.id }),
|
|
280
|
+
to: createEvmAccount({ address: transferIn.to, chainId: chain.id }),
|
|
281
|
+
asset: transferInAsset,
|
|
282
|
+
amount: createBigDecimal(transferIn.value, transferInDecimals),
|
|
283
|
+
price: transferIn.price,
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
target: transferOut.to,
|
|
287
|
+
direction: 'in',
|
|
288
|
+
from: createEvmAccount({
|
|
289
|
+
address: transferOut.from,
|
|
290
|
+
chainId: chain.id,
|
|
291
|
+
}),
|
|
292
|
+
to: createEvmAccount({ address: transferOut.to, chainId: chain.id }),
|
|
293
|
+
asset: transferOutAsset,
|
|
294
|
+
amount: createBigDecimal(transferOut.value, transferOutDecimals),
|
|
295
|
+
price: transferOut.price,
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const generateNormalActionTrade = <
|
|
302
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
303
|
+
>(
|
|
304
|
+
swap: Swap<Price>,
|
|
305
|
+
chain: Chain,
|
|
306
|
+
timestamp: number,
|
|
307
|
+
): NormalActionTrade<EvmAccount, Price, CryptoCurrency> => {
|
|
308
|
+
const { transferIn, transferOut } = swap
|
|
309
|
+
const transferInAsset =
|
|
310
|
+
transferIn.type === 'Erc20Transfer'
|
|
311
|
+
? transferIn.token.currency
|
|
312
|
+
: chain.nativeToken.currency
|
|
313
|
+
const transferOutAsset =
|
|
314
|
+
transferOut.type === 'Erc20Transfer'
|
|
315
|
+
? transferOut.token.currency
|
|
316
|
+
: chain.nativeToken.currency
|
|
317
|
+
if (
|
|
318
|
+
transferIn.to === undefined ||
|
|
319
|
+
transferOut.to === undefined ||
|
|
320
|
+
transferInAsset === undefined ||
|
|
321
|
+
transferOutAsset === undefined
|
|
322
|
+
) {
|
|
323
|
+
throw new Error('invalid swap')
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const transferInDecimals =
|
|
327
|
+
transferIn.type === 'Erc20Transfer'
|
|
328
|
+
? transferIn.token.decimals
|
|
329
|
+
: chain.nativeToken.decimals
|
|
330
|
+
const transferOutDecimals =
|
|
331
|
+
transferOut.type === 'Erc20Transfer'
|
|
332
|
+
? transferOut.token.decimals
|
|
333
|
+
: chain.nativeToken.decimals
|
|
334
|
+
return {
|
|
335
|
+
type: 'NormalAction',
|
|
336
|
+
action: 'trade',
|
|
337
|
+
evidence: 'contract',
|
|
338
|
+
timestamp,
|
|
339
|
+
comment: undefined,
|
|
340
|
+
app: undefined,
|
|
341
|
+
transfers: [
|
|
342
|
+
{
|
|
343
|
+
target: transferIn.from,
|
|
344
|
+
direction: 'out',
|
|
345
|
+
from: createEvmAccount({ address: transferIn.from, chainId: chain.id }),
|
|
346
|
+
to: createEvmAccount({ address: transferIn.to, chainId: chain.id }),
|
|
347
|
+
asset: transferInAsset,
|
|
348
|
+
amount: createBigDecimal(transferIn.value, transferInDecimals),
|
|
349
|
+
price: transferIn.price,
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
target: transferOut.to,
|
|
353
|
+
direction: 'in',
|
|
354
|
+
from: createEvmAccount({
|
|
355
|
+
address: transferOut.from,
|
|
356
|
+
chainId: chain.id,
|
|
357
|
+
}),
|
|
358
|
+
to: createEvmAccount({ address: transferOut.to, chainId: chain.id }),
|
|
359
|
+
asset: transferOutAsset,
|
|
360
|
+
amount: createBigDecimal(transferOut.value, transferOutDecimals),
|
|
361
|
+
price: transferOut.price,
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const getIndex = <Price extends CryptoCurrencyPrice | undefined>(
|
|
368
|
+
data:
|
|
369
|
+
| Swap<Price>
|
|
370
|
+
| Erc20Transfer<Price>
|
|
371
|
+
| WrappedDepositLog
|
|
372
|
+
| WrappedWithdrawalLog,
|
|
373
|
+
): number => {
|
|
374
|
+
switch (data.type) {
|
|
375
|
+
case 'WrappedDepositLog': {
|
|
376
|
+
return data.logIndex
|
|
377
|
+
}
|
|
378
|
+
case 'WrappedWithdrawalLog': {
|
|
379
|
+
return data.logIndex
|
|
380
|
+
}
|
|
381
|
+
case 'Erc20Transfer': {
|
|
382
|
+
return data.logIndex
|
|
383
|
+
}
|
|
384
|
+
case 'Swap': {
|
|
385
|
+
return data.swapLogIndex
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
type Swap<Price extends CryptoCurrencyPrice | undefined> = {
|
|
391
|
+
readonly type: 'Swap'
|
|
392
|
+
readonly contractAddress: LowerHex
|
|
393
|
+
readonly transferIn: Erc20Transfer<Price> | InternalTransaction<Price>
|
|
394
|
+
readonly transferOut: Erc20Transfer<Price> | InternalTransaction<Price>
|
|
395
|
+
readonly swapLogIndex: number
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const createSwapFromUniv2SwapLog = <
|
|
399
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
400
|
+
>(
|
|
401
|
+
log: UniV2PairSwapLog,
|
|
402
|
+
erc20TokenTransfers: readonly Erc20Transfer<Price>[],
|
|
403
|
+
): Swap<Price> | undefined => {
|
|
404
|
+
const { args, logIndex: swapLogIndex, address: contractAddress } = log
|
|
405
|
+
const { value: amount0In } = args[1]
|
|
406
|
+
const { value: amount1In } = args[2]
|
|
407
|
+
const { value: amount0Out } = args[3]
|
|
408
|
+
const { value: amount1Out } = args[4]
|
|
409
|
+
|
|
410
|
+
// swap log より前の transfer log を抽出
|
|
411
|
+
const beforeSwapTransfers = erc20TokenTransfers.filter(
|
|
412
|
+
(transfer) => transfer.logIndex < swapLogIndex,
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
// swap log から amountIn / amountOut を取得
|
|
416
|
+
const amountIn = amount0In + amount1In
|
|
417
|
+
const amountOut = amount0Out + amount1Out
|
|
418
|
+
|
|
419
|
+
// amountIn / amountOut が一致する transfer log を探す
|
|
420
|
+
const transferIn = beforeSwapTransfers.findLast(
|
|
421
|
+
(transfer) => transfer.value === amountIn,
|
|
422
|
+
)
|
|
423
|
+
const transferOut = beforeSwapTransfers.findLast(
|
|
424
|
+
(transfer) => transfer.value === amountOut,
|
|
425
|
+
)
|
|
426
|
+
|
|
427
|
+
// なければ undefined を返す
|
|
428
|
+
if (transferIn == undefined || transferOut === undefined) {
|
|
429
|
+
return undefined
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// あれば swap を生成して返す
|
|
433
|
+
return createSwap({
|
|
434
|
+
contractAddress,
|
|
435
|
+
transferIn,
|
|
436
|
+
transferOut,
|
|
437
|
+
swapLogIndex,
|
|
438
|
+
})
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const createSwapFromUniv3SwapLog = <
|
|
442
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
443
|
+
>(
|
|
444
|
+
log: UniV3PoolSwapLog,
|
|
445
|
+
erc20TokenTransfers: readonly Erc20Transfer<Price>[],
|
|
446
|
+
): Swap<Price> | undefined => {
|
|
447
|
+
const { args, logIndex: swapLogIndex, address: contractAddress } = log
|
|
448
|
+
const { value: amount0 } = args[2]
|
|
449
|
+
const { value: amount1 } = args[3]
|
|
450
|
+
|
|
451
|
+
// swap log より前の transfer log を抽出
|
|
452
|
+
const beforeSwapTransfers = erc20TokenTransfers.filter(
|
|
453
|
+
(transfer) => transfer.logIndex < swapLogIndex,
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
// amountIn / amountOut の片方がプラス、もう片方がマイナスの場合でなければ undefined を返す
|
|
457
|
+
if (
|
|
458
|
+
amount0 === 0n ||
|
|
459
|
+
amount1 === 0n ||
|
|
460
|
+
(amount0 > 0n && amount1 > 0n) ||
|
|
461
|
+
(amount0 < 0n && amount1 < 0n)
|
|
462
|
+
) {
|
|
463
|
+
return undefined
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// swap log から amountIn / amountOut を取得
|
|
467
|
+
const amountIn = amount0 > 0n ? amount0 : amount1
|
|
468
|
+
const amountOut = -1n * (amount0 > 0n ? amount1 : amount0)
|
|
469
|
+
|
|
470
|
+
// amountIn / amountOut が一致する transfer log を探す
|
|
471
|
+
const transferIn = beforeSwapTransfers.findLast(
|
|
472
|
+
(transfer) => transfer.value === amountIn,
|
|
473
|
+
)
|
|
474
|
+
const transferOut = beforeSwapTransfers.findLast(
|
|
475
|
+
(transfer) => transfer.value === amountOut,
|
|
476
|
+
)
|
|
477
|
+
|
|
478
|
+
// なければ undefined を返す
|
|
479
|
+
if (transferIn == undefined || transferOut === undefined) {
|
|
480
|
+
return undefined
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// あれば swap を生成して返す
|
|
484
|
+
return createSwap({
|
|
485
|
+
contractAddress: contractAddress,
|
|
486
|
+
transferIn,
|
|
487
|
+
transferOut,
|
|
488
|
+
swapLogIndex,
|
|
489
|
+
})
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
const createSwapFromTraderJoeLBPairSwapLog = <
|
|
493
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
494
|
+
>(
|
|
495
|
+
log: TraderJoeLBPairSwapLog,
|
|
496
|
+
erc20TokenTransfers: readonly Erc20Transfer<Price>[],
|
|
497
|
+
): Swap<Price> | undefined => {
|
|
498
|
+
const { args, logIndex: swapLogIndex, address: contractAddress } = log
|
|
499
|
+
|
|
500
|
+
// swap log から amountIn / amountOut を取得
|
|
501
|
+
const { value: amountIn } = args[4]
|
|
502
|
+
const { value: amountOut } = args[5]
|
|
503
|
+
const { value: fees } = args[7]
|
|
504
|
+
|
|
505
|
+
const amountInWithFees = amountIn + fees
|
|
506
|
+
|
|
507
|
+
// amountIn / amountOut が一致する transfer log を探す
|
|
508
|
+
const transferIn = erc20TokenTransfers.findLast(
|
|
509
|
+
(transfer) => transfer.value === amountInWithFees,
|
|
510
|
+
)
|
|
511
|
+
const transferOut = erc20TokenTransfers.findLast(
|
|
512
|
+
(transfer) => transfer.value === amountOut,
|
|
513
|
+
)
|
|
514
|
+
|
|
515
|
+
// なければ undefined を返す
|
|
516
|
+
if (transferIn == undefined || transferOut === undefined) {
|
|
517
|
+
return undefined
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// あれば swap を生成して返す
|
|
521
|
+
return createSwap({
|
|
522
|
+
contractAddress,
|
|
523
|
+
transferIn,
|
|
524
|
+
transferOut,
|
|
525
|
+
swapLogIndex,
|
|
526
|
+
})
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const createSwap = <Price extends CryptoCurrencyPrice | undefined>({
|
|
530
|
+
contractAddress,
|
|
531
|
+
transferIn,
|
|
532
|
+
transferOut,
|
|
533
|
+
swapLogIndex,
|
|
534
|
+
}: {
|
|
535
|
+
readonly contractAddress: LowerHex
|
|
536
|
+
readonly transferIn: Erc20Transfer<Price> | InternalTransaction<Price>
|
|
537
|
+
readonly transferOut: Erc20Transfer<Price> | InternalTransaction<Price>
|
|
538
|
+
readonly swapLogIndex: number
|
|
539
|
+
}): Swap<Price> => ({
|
|
540
|
+
type: 'Swap',
|
|
541
|
+
contractAddress,
|
|
542
|
+
transferIn,
|
|
543
|
+
transferOut,
|
|
544
|
+
swapLogIndex,
|
|
545
|
+
})
|
|
546
|
+
|
|
547
|
+
const createSwapUsingIndexes = <Price extends CryptoCurrencyPrice | undefined>({
|
|
548
|
+
swapLogIndex,
|
|
549
|
+
transferIn,
|
|
550
|
+
transferOut,
|
|
551
|
+
}: Swap<Price>): readonly number[] => {
|
|
552
|
+
const transferInLogIndex =
|
|
553
|
+
transferIn.type === 'Erc20Transfer' ? transferIn.logIndex : swapLogIndex
|
|
554
|
+
const transferOutLogIndex =
|
|
555
|
+
transferOut.type === 'Erc20Transfer' ? transferOut.logIndex : swapLogIndex
|
|
556
|
+
const minIndex = Math.min(
|
|
557
|
+
swapLogIndex,
|
|
558
|
+
transferInLogIndex,
|
|
559
|
+
transferOutLogIndex,
|
|
560
|
+
)
|
|
561
|
+
const maxIndex = Math.max(
|
|
562
|
+
swapLogIndex,
|
|
563
|
+
transferInLogIndex,
|
|
564
|
+
transferOutLogIndex,
|
|
565
|
+
)
|
|
566
|
+
const mut_indexes = []
|
|
567
|
+
for (let index = minIndex; index <= maxIndex; index++) {
|
|
568
|
+
mut_indexes.push(index)
|
|
569
|
+
}
|
|
570
|
+
return mut_indexes
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
type Action<Price extends CryptoCurrencyPrice | undefined> =
|
|
574
|
+
| Erc20Transfer<Price>
|
|
575
|
+
| WrappedDepositLog
|
|
576
|
+
| WrappedWithdrawalLog
|
|
577
|
+
| Swap<Price>
|
|
578
|
+
|
|
579
|
+
const mergeActions = <Price extends CryptoCurrencyPrice | undefined>(
|
|
580
|
+
actions: readonly Action<Price>[],
|
|
581
|
+
nativeTokenCryptocurrency: CryptoCurrency,
|
|
582
|
+
): readonly Action<Price>[] => {
|
|
583
|
+
const sequenceMergedActions = mergeActionsBySequenceSwap(actions)
|
|
584
|
+
const similarMergedActions = mergeActionsBySimilarSwap(sequenceMergedActions)
|
|
585
|
+
const mergedActions = mergeActionsBySwapAndOtherAction(
|
|
586
|
+
similarMergedActions,
|
|
587
|
+
nativeTokenCryptocurrency,
|
|
588
|
+
)
|
|
589
|
+
// TODO deposit - transfer と並んでいて、 deposit value と transfer value が一致 & wrapped token である場合、結合して良さそう
|
|
590
|
+
// [deposit, swap, withdraw] と残った場合のみ、 deposit - withdrawal の値が swap in と一致する場合は 3つ合わせて結合する
|
|
591
|
+
if (mergedActions.length === 3) {
|
|
592
|
+
const [deposit, swap, withdrawal] = mergedActions
|
|
593
|
+
if (
|
|
594
|
+
deposit.type === 'WrappedDepositLog' &&
|
|
595
|
+
swap.type === 'Swap' &&
|
|
596
|
+
withdrawal.type === 'WrappedWithdrawalLog' &&
|
|
597
|
+
deposit.args[1].value - withdrawal.args[1].value === swap.transferIn.value
|
|
598
|
+
) {
|
|
599
|
+
return [
|
|
600
|
+
createSwap({
|
|
601
|
+
...swap,
|
|
602
|
+
transferIn: {
|
|
603
|
+
type: 'InternalTransaction',
|
|
604
|
+
transactionHash: '0x',
|
|
605
|
+
from: swap.transferIn.from,
|
|
606
|
+
to: swap.transferIn.to,
|
|
607
|
+
contractAddress: undefined,
|
|
608
|
+
txType: '',
|
|
609
|
+
value: swap.transferIn.value,
|
|
610
|
+
gas: 0n,
|
|
611
|
+
gasUsed: 0n,
|
|
612
|
+
isError: false,
|
|
613
|
+
input: undefined,
|
|
614
|
+
currency: nativeTokenCryptocurrency,
|
|
615
|
+
price: swap.transferIn.price,
|
|
616
|
+
},
|
|
617
|
+
}),
|
|
618
|
+
]
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return mergedActions
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
const mergeActionsBySequenceSwap = <
|
|
625
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
626
|
+
>(
|
|
627
|
+
actions: readonly Action<Price>[],
|
|
628
|
+
): readonly Action<Price>[] => {
|
|
629
|
+
const mut_newActions: Action<Price>[] = []
|
|
630
|
+
let mut_previousAction: Action<Price> | undefined = undefined
|
|
631
|
+
for (const action of actions) {
|
|
632
|
+
if (mut_previousAction === undefined) {
|
|
633
|
+
mut_previousAction = action
|
|
634
|
+
continue
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
if (mut_previousAction.type === 'Swap' && action.type === 'Swap') {
|
|
638
|
+
// 前後の swap を結合するか試す
|
|
639
|
+
const mergedSwap: Swap<Price> | undefined = mergeSequenceSwaps([
|
|
640
|
+
mut_previousAction,
|
|
641
|
+
action,
|
|
642
|
+
])
|
|
643
|
+
if (mergedSwap === undefined) {
|
|
644
|
+
// 結合できていなければ、previous action を newActions に追加して、action を previous action に設定
|
|
645
|
+
mut_newActions.push(mut_previousAction)
|
|
646
|
+
mut_previousAction = action
|
|
647
|
+
} else {
|
|
648
|
+
// 結合できていれば、結合結果を previous action に設定
|
|
649
|
+
mut_previousAction = mergedSwap
|
|
650
|
+
}
|
|
651
|
+
} else {
|
|
652
|
+
// previous action を newActions に追加して、action を previous action に設定
|
|
653
|
+
mut_newActions.push(mut_previousAction)
|
|
654
|
+
mut_previousAction = action
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
// previous action が残っていれば newActions に追加
|
|
658
|
+
if (mut_previousAction !== undefined) {
|
|
659
|
+
mut_newActions.push(mut_previousAction)
|
|
660
|
+
}
|
|
661
|
+
return mut_newActions
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
const mergeActionsBySimilarSwap = <
|
|
665
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
666
|
+
>(
|
|
667
|
+
actions: readonly Action<Price>[],
|
|
668
|
+
): readonly Action<Price>[] => {
|
|
669
|
+
const mut_newActions: Action<Price>[] = []
|
|
670
|
+
let mut_previousAction: Action<Price> | undefined = undefined
|
|
671
|
+
for (const action of actions) {
|
|
672
|
+
if (mut_previousAction === undefined) {
|
|
673
|
+
mut_previousAction = action
|
|
674
|
+
continue
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
if (mut_previousAction.type === 'Swap' && action.type === 'Swap') {
|
|
678
|
+
// 前後の swap を結合するか試す
|
|
679
|
+
const mergedSwap: Swap<Price> | undefined = mergeSimilarSwaps([
|
|
680
|
+
mut_previousAction,
|
|
681
|
+
action,
|
|
682
|
+
])
|
|
683
|
+
if (mergedSwap === undefined) {
|
|
684
|
+
// 結合できていなければ、currentSwap を newActions に追加して、action を currentSwap に設定
|
|
685
|
+
mut_newActions.push(mut_previousAction)
|
|
686
|
+
mut_previousAction = action
|
|
687
|
+
} else {
|
|
688
|
+
// 結合できていれば、結合結果を currentSwap に設定
|
|
689
|
+
mut_previousAction = mergedSwap
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
// prevAction を newActions に追加して、action を prevAction に設定
|
|
693
|
+
mut_newActions.push(mut_previousAction)
|
|
694
|
+
mut_previousAction = action
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
// currentSwap が残っていれば newActions に追加
|
|
698
|
+
if (mut_previousAction !== undefined) {
|
|
699
|
+
mut_newActions.push(mut_previousAction)
|
|
700
|
+
}
|
|
701
|
+
return mut_newActions
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
const mergeActionsBySwapAndOtherAction = <
|
|
705
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
706
|
+
>(
|
|
707
|
+
actions: readonly Action<Price>[],
|
|
708
|
+
nativeTokenCryptocurrency: CryptoCurrency,
|
|
709
|
+
): readonly Action<Price>[] => {
|
|
710
|
+
const mut_newActions: Action<Price>[] = []
|
|
711
|
+
let mut_previousAction: Action<Price> | undefined = undefined
|
|
712
|
+
for (const action of actions) {
|
|
713
|
+
if (mut_previousAction === undefined) {
|
|
714
|
+
mut_previousAction = action
|
|
715
|
+
continue
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// 前後の action を結合するか試す
|
|
719
|
+
const mergedAction: Swap<Price> | undefined = mergeSwapAndOtherAction(
|
|
720
|
+
[mut_previousAction, action],
|
|
721
|
+
nativeTokenCryptocurrency,
|
|
722
|
+
)
|
|
723
|
+
if (mergedAction === undefined) {
|
|
724
|
+
// 結合できていなければ、previous action を newActions に追加して、action を previous action に設定
|
|
725
|
+
mut_newActions.push(mut_previousAction)
|
|
726
|
+
mut_previousAction = action
|
|
727
|
+
} else {
|
|
728
|
+
// 結合できていれば、結合結果を previous action に設定
|
|
729
|
+
mut_previousAction = mergedAction
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
// previous action が残っていれば newActions に追加
|
|
733
|
+
if (mut_previousAction !== undefined) {
|
|
734
|
+
mut_newActions.push(mut_previousAction)
|
|
735
|
+
}
|
|
736
|
+
return mut_newActions
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
const mergeSwapAndOtherAction = <Price extends CryptoCurrencyPrice | undefined>(
|
|
740
|
+
actions: readonly [Action<Price>, Action<Price>],
|
|
741
|
+
nativeTokenCryptocurrency: CryptoCurrency,
|
|
742
|
+
): Swap<Price> | undefined => {
|
|
743
|
+
const [action0, action1] = actions
|
|
744
|
+
if (action0.type === 'Swap') {
|
|
745
|
+
// action1=Transfer | action0.out の token/amount/address が一致する場合は結合
|
|
746
|
+
if (
|
|
747
|
+
action1.type === 'Erc20Transfer' &&
|
|
748
|
+
action0.transferOut.type === 'Erc20Transfer' &&
|
|
749
|
+
action0.transferOut.token.contractAddress ===
|
|
750
|
+
action1.token.contractAddress &&
|
|
751
|
+
action0.transferOut.to === action1.from &&
|
|
752
|
+
action0.transferOut.value === action1.value
|
|
753
|
+
) {
|
|
754
|
+
return createSwap({
|
|
755
|
+
...action0,
|
|
756
|
+
transferOut: action1,
|
|
757
|
+
})
|
|
758
|
+
}
|
|
759
|
+
// action1=Withdrawal で action0.out の token/amount/address が一致する場合は結合
|
|
760
|
+
if (
|
|
761
|
+
action1.type === 'WrappedWithdrawalLog' &&
|
|
762
|
+
action0.transferOut.type === 'Erc20Transfer' &&
|
|
763
|
+
action0.transferOut.token.contractAddress === action1.address &&
|
|
764
|
+
action0.transferOut.to === action1.args[0].value &&
|
|
765
|
+
action0.transferOut.value === action1.args[1].value
|
|
766
|
+
) {
|
|
767
|
+
return createSwap({
|
|
768
|
+
...action0,
|
|
769
|
+
transferOut: {
|
|
770
|
+
type: 'InternalTransaction',
|
|
771
|
+
transactionHash: '0x',
|
|
772
|
+
from: action0.transferOut.from,
|
|
773
|
+
to: action0.transferOut.to,
|
|
774
|
+
contractAddress: undefined,
|
|
775
|
+
txType: '',
|
|
776
|
+
value: action0.transferOut.value,
|
|
777
|
+
gas: 0n,
|
|
778
|
+
gasUsed: 0n,
|
|
779
|
+
isError: false,
|
|
780
|
+
input: undefined,
|
|
781
|
+
currency: nativeTokenCryptocurrency,
|
|
782
|
+
price: action0.transferOut.price,
|
|
783
|
+
},
|
|
784
|
+
})
|
|
785
|
+
}
|
|
786
|
+
} else if (action1.type === 'Swap') {
|
|
787
|
+
// action0=Transfer で action1.in の token/amount/address が一致する場合は結合
|
|
788
|
+
if (
|
|
789
|
+
action0.type === 'Erc20Transfer' &&
|
|
790
|
+
action1.transferIn.type === 'Erc20Transfer' &&
|
|
791
|
+
action1.transferIn.token.contractAddress ===
|
|
792
|
+
action0.token.contractAddress &&
|
|
793
|
+
action1.transferIn.from === action0.to &&
|
|
794
|
+
action1.transferIn.value === action0.value
|
|
795
|
+
) {
|
|
796
|
+
return createSwap({
|
|
797
|
+
...action1,
|
|
798
|
+
transferIn: action0,
|
|
799
|
+
})
|
|
800
|
+
}
|
|
801
|
+
// action0=Deposit で action1.in の token/amount/address が一致する場合は結合
|
|
802
|
+
if (
|
|
803
|
+
action0.type === 'WrappedDepositLog' &&
|
|
804
|
+
action1.transferIn.type === 'Erc20Transfer' &&
|
|
805
|
+
action1.transferIn.token.contractAddress === action0.address &&
|
|
806
|
+
action1.transferIn.from === action0.args[0].value &&
|
|
807
|
+
action1.transferIn.value === action0.args[1].value
|
|
808
|
+
) {
|
|
809
|
+
return createSwap({
|
|
810
|
+
...action1,
|
|
811
|
+
transferIn: {
|
|
812
|
+
type: 'InternalTransaction',
|
|
813
|
+
transactionHash: '0x',
|
|
814
|
+
from: action1.transferIn.from,
|
|
815
|
+
to: action1.transferIn.to,
|
|
816
|
+
contractAddress: undefined,
|
|
817
|
+
txType: '',
|
|
818
|
+
value: action1.transferIn.value,
|
|
819
|
+
gas: 0n,
|
|
820
|
+
gasUsed: 0n,
|
|
821
|
+
isError: false,
|
|
822
|
+
input: undefined,
|
|
823
|
+
currency: nativeTokenCryptocurrency,
|
|
824
|
+
price: action1.transferIn.price,
|
|
825
|
+
},
|
|
826
|
+
})
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return undefined
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/** swap0 -> swap1 が連続取引の場合に結合して返す */
|
|
833
|
+
const mergeSequenceSwaps = <Price extends CryptoCurrencyPrice | undefined>(
|
|
834
|
+
swaps: readonly [Swap<Price>, Swap<Price>],
|
|
835
|
+
): Swap<Price> | undefined =>
|
|
836
|
+
swaps[0].transferOut.type === 'Erc20Transfer' &&
|
|
837
|
+
swaps[1].transferIn.type === 'Erc20Transfer' &&
|
|
838
|
+
swaps[0].transferOut.value === swaps[1].transferIn.value &&
|
|
839
|
+
swaps[0].transferOut.token.contractAddress ===
|
|
840
|
+
swaps[1].transferIn.token.contractAddress
|
|
841
|
+
? createSwap({
|
|
842
|
+
...swaps[0],
|
|
843
|
+
transferOut: swaps[1].transferOut,
|
|
844
|
+
swapLogIndex: swaps[1].swapLogIndex,
|
|
845
|
+
})
|
|
846
|
+
: undefined
|
|
847
|
+
|
|
848
|
+
/** swap0 , swap1 の address,token が全て同じ場合に結合して返す */
|
|
849
|
+
const mergeSimilarSwaps = <Price extends CryptoCurrencyPrice | undefined>(
|
|
850
|
+
swaps: readonly [Swap<Price>, Swap<Price>],
|
|
851
|
+
): Swap<Price> | undefined =>
|
|
852
|
+
swaps[0].transferIn.type === 'Erc20Transfer' &&
|
|
853
|
+
swaps[0].transferOut.type === 'Erc20Transfer' &&
|
|
854
|
+
swaps[1].transferIn.type === 'Erc20Transfer' &&
|
|
855
|
+
swaps[1].transferOut.type === 'Erc20Transfer' &&
|
|
856
|
+
swaps[0].transferIn.from === swaps[1].transferIn.from &&
|
|
857
|
+
swaps[0].transferOut.to === swaps[1].transferOut.to &&
|
|
858
|
+
swaps[0].transferIn.token.contractAddress ===
|
|
859
|
+
swaps[1].transferIn.token.contractAddress &&
|
|
860
|
+
swaps[0].transferOut.token.contractAddress ===
|
|
861
|
+
swaps[1].transferOut.token.contractAddress
|
|
862
|
+
? createSwap({
|
|
863
|
+
...swaps[0],
|
|
864
|
+
transferIn: {
|
|
865
|
+
...swaps[0].transferIn,
|
|
866
|
+
value: swaps[0].transferIn.value + swaps[1].transferIn.value,
|
|
867
|
+
},
|
|
868
|
+
transferOut: {
|
|
869
|
+
...swaps[1].transferOut,
|
|
870
|
+
value: swaps[0].transferOut.value + swaps[1].transferOut.value,
|
|
871
|
+
},
|
|
872
|
+
swapLogIndex: swaps[1].swapLogIndex,
|
|
873
|
+
})
|
|
874
|
+
: undefined
|
|
875
|
+
|
|
876
|
+
const mergeSwapAndInternalTransactions = <
|
|
877
|
+
Price extends CryptoCurrencyPrice | undefined,
|
|
878
|
+
>(
|
|
879
|
+
swap: Swap<Price>,
|
|
880
|
+
internalTransactions: readonly InternalTransaction<Price>[],
|
|
881
|
+
): {
|
|
882
|
+
readonly swap: Swap<Price>
|
|
883
|
+
readonly internalTransactions: readonly InternalTransaction<Price>[]
|
|
884
|
+
} => {
|
|
885
|
+
// swap.transferIn = internalTx で、swap.transferIn.from への internal transaction があれば結合
|
|
886
|
+
if (swap.transferIn.type === 'InternalTransaction') {
|
|
887
|
+
const index = internalTransactions.findIndex(
|
|
888
|
+
(transaction) =>
|
|
889
|
+
transaction.to !== undefined &&
|
|
890
|
+
transaction.to === swap.transferIn.from &&
|
|
891
|
+
transaction.value === swap.transferIn.value,
|
|
892
|
+
)
|
|
893
|
+
const internalTransaction = internalTransactions[index]
|
|
894
|
+
if (
|
|
895
|
+
internalTransaction !== undefined &&
|
|
896
|
+
internalTransaction.to !== undefined
|
|
897
|
+
) {
|
|
898
|
+
return {
|
|
899
|
+
swap: createSwap({
|
|
900
|
+
...swap,
|
|
901
|
+
transferIn: internalTransaction,
|
|
902
|
+
}),
|
|
903
|
+
internalTransactions: internalTransactions.filter(
|
|
904
|
+
(_, index_) => index_ !== index,
|
|
905
|
+
),
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// swap.out = native で、swap.addressOut への internal transaction があれば結合
|
|
911
|
+
if (swap.transferOut.type === 'InternalTransaction') {
|
|
912
|
+
const index = internalTransactions.findIndex(
|
|
913
|
+
(transaction) =>
|
|
914
|
+
transaction.from !== undefined &&
|
|
915
|
+
transaction.from === swap.transferOut.to &&
|
|
916
|
+
transaction.value === swap.transferOut.value,
|
|
917
|
+
)
|
|
918
|
+
const internalTransaction = internalTransactions[index]
|
|
919
|
+
if (
|
|
920
|
+
internalTransaction !== undefined &&
|
|
921
|
+
internalTransaction.to !== undefined
|
|
922
|
+
) {
|
|
923
|
+
return {
|
|
924
|
+
swap: createSwap({
|
|
925
|
+
...swap,
|
|
926
|
+
transferOut: internalTransaction,
|
|
927
|
+
}),
|
|
928
|
+
internalTransactions: internalTransactions.filter(
|
|
929
|
+
(_, index_) => index_ !== index,
|
|
930
|
+
),
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
return {
|
|
936
|
+
swap,
|
|
937
|
+
internalTransactions,
|
|
938
|
+
}
|
|
939
|
+
}
|