From 6ceedbf9aff4265e3d0e7638657e1342411bdd5c Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Mon, 16 Aug 2021 23:49:03 -0700 Subject: [PATCH] aave, erc20, weth moved into separated specs --- mev_inspect/classifiers/specs/__init__.py | 13 ++++++++-- mev_inspect/classifiers/specs/aave.py | 15 +++++++++++ mev_inspect/classifiers/specs/erc20.py | 16 ++++++++++++ mev_inspect/classifiers/specs/uniswap.py | 31 ----------------------- mev_inspect/classifiers/specs/weth.py | 17 +++++++++++++ 5 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 mev_inspect/classifiers/specs/aave.py create mode 100644 mev_inspect/classifiers/specs/erc20.py create mode 100644 mev_inspect/classifiers/specs/weth.py diff --git a/mev_inspect/classifiers/specs/__init__.py b/mev_inspect/classifiers/specs/__init__.py index 179cc74..605fd67 100644 --- a/mev_inspect/classifiers/specs/__init__.py +++ b/mev_inspect/classifiers/specs/__init__.py @@ -1,4 +1,13 @@ -from .uniswap import UNISWAP_CLASSIFIER_SPECS +from .aave import AAVE_CLASSIFIER_SPECS from .curve import CURVE_CLASSIFIER_SPECS +from .erc20 import ERC20_CLASSIFIER_SPECS +from .uniswap import UNISWAP_CLASSIFIER_SPECS +from .weth import WETH_CLASSIFIER_SPECS -ALL_CLASSIFIER_SPECS = CURVE_CLASSIFIER_SPECS + UNISWAP_CLASSIFIER_SPECS +ALL_CLASSIFIER_SPECS = ( + ERC20_CLASSIFIER_SPECS + + CURVE_CLASSIFIER_SPECS + + UNISWAP_CLASSIFIER_SPECS + + WETH_CLASSIFIER_SPECS + + AAVE_CLASSIFIER_SPECS +) diff --git a/mev_inspect/classifiers/specs/aave.py b/mev_inspect/classifiers/specs/aave.py new file mode 100644 index 0000000..c12e785 --- /dev/null +++ b/mev_inspect/classifiers/specs/aave.py @@ -0,0 +1,15 @@ +from mev_inspect.schemas.classified_traces import ( + Classification, + ClassifierSpec, + Protocol, +) + +AAVE_SPEC = ClassifierSpec( + abi_name="AaveLendingPool", + protocol=Protocol.aave, + classifications={ + "liquidationCall(address,address,address,uint256,bool)": Classification.liquidate, + }, +) + +AAVE_CLASSIFIER_SPECS = [AAVE_SPEC] diff --git a/mev_inspect/classifiers/specs/erc20.py b/mev_inspect/classifiers/specs/erc20.py new file mode 100644 index 0000000..02cd3ae --- /dev/null +++ b/mev_inspect/classifiers/specs/erc20.py @@ -0,0 +1,16 @@ +from mev_inspect.schemas.classified_traces import ( + Classification, + ClassifierSpec, +) + + +ERC20_SPEC = ClassifierSpec( + abi_name="ERC20", + classifications={ + "transferFrom(address,address,uint256)": Classification.transfer, + "transfer(address,uint256)": Classification.transfer, + "burn(address)": Classification.burn, + }, +) + +ERC20_CLASSIFIER_SPECS = [ERC20_SPEC] diff --git a/mev_inspect/classifiers/specs/uniswap.py b/mev_inspect/classifiers/specs/uniswap.py index 166d453..3bf17a8 100644 --- a/mev_inspect/classifiers/specs/uniswap.py +++ b/mev_inspect/classifiers/specs/uniswap.py @@ -90,40 +90,9 @@ UNISWAPPY_V2_PAIR_SPEC = ClassifierSpec( }, ) -ERC20_SPEC = ClassifierSpec( - abi_name="ERC20", - classifications={ - "transferFrom(address,address,uint256)": Classification.transfer, - "transfer(address,uint256)": Classification.transfer, - "burn(address)": Classification.burn, - }, -) - -AAVE_SPEC = ClassifierSpec( - abi_name="AaveLendingPool", - protocol=Protocol.aave, - classifications={ - "liquidationCall(address,address,address,uint256,bool)": Classification.liquidate, - }, -) - -WETH_SPEC = ClassifierSpec( - abi_name="WETH9", - protocol=Protocol.weth, - valid_contract_addresses=["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], - classifications={ - "transferFrom(address,address,uint256)": Classification.transfer, - "transfer(address,uint256)": Classification.transfer, - }, -) - - UNISWAP_CLASSIFIER_SPECS = [ *UNISWAP_V3_CONTRACT_SPECS, *UNISWAPPY_V2_CONTRACT_SPECS, - WETH_SPEC, - AAVE_SPEC, - ERC20_SPEC, UNISWAP_V3_POOL_SPEC, UNISWAPPY_V2_PAIR_SPEC, ] diff --git a/mev_inspect/classifiers/specs/weth.py b/mev_inspect/classifiers/specs/weth.py new file mode 100644 index 0000000..df85790 --- /dev/null +++ b/mev_inspect/classifiers/specs/weth.py @@ -0,0 +1,17 @@ +from mev_inspect.schemas.classified_traces import ( + Classification, + ClassifierSpec, + Protocol, +) + +WETH_SPEC = ClassifierSpec( + abi_name="WETH9", + protocol=Protocol.weth, + valid_contract_addresses=["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"], + classifications={ + "transferFrom(address,address,uint256)": Classification.transfer, + "transfer(address,uint256)": Classification.transfer, + }, +) + +WETH_CLASSIFIER_SPECS = [WETH_SPEC]