Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions config/indexer-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,56 @@ opensea_job:
- "0x5b3256965e7c3cf26e11fcaf296dfc8807c01073"

export_tokens_and_transfers_job:
weth_address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
weth_address: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"

eigen_layer_job:
export_eigen_layer_job:
STRATEGY_MANAGER:
address: "0x858646372cc42e1a627fce94aa7a7033e7cf075a"
DELEGATION:
address: "0x39053d51b77dc0d36036fc1fcc8cb819df8ef37a"

deposit_to_l2_job:
contract_info:
10:
- contract: "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1"
ABIFunction:
- token: "eth"
abi: "op_deposit_eth"
- token: "eth"
abi: "op_bridge_eth_to"
- token: "_l1Token"
abi: "op_deposit_erc20_to"
ABIEvent:
- abi: "op_transaction_deposited"
8453:
- contract: "0x3154Cf16ccdb4C6d922629664174b904d80F2C35"
ABIFunction:
- token: "eth"
abi: "op_deposit_eth"
- token: "eth"
abi: "op_bridge_eth_to"
42161:
- contract: "0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef"
ABIFunction:
- token: "_l1Token"
abi: "arbitrum_outbound_transfer"
- contract: "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f"
ABIFunction:
- token: "eth"
method_id: "0x439370b1"
59144:
- contract: "0xd19d4B5d358258f05D7B411E21A1460D11B0876F"
ABIFunction:
- token: "eth"
abi: "linea_send_message"
- contract: "0x051F1D88f0aF5763fB888eC4378b4D8B29ea3319"
ABIFunction:
- token: "_l1Token"
abi: "linea_bridge_token"
- contract: "0x504A330327A089d8364C4ab3811Ee26976d388ce"
ABIFunction:
- token: "usdc"
abi: "linea_deposit_to"
cache_config:
clean_mode: blocks
clean_limit_value: 1000
4 changes: 2 additions & 2 deletions enumeration/entity_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from indexer.modules.custom.address_index.domain.address_nft_1155_holders import AddressNft1155Holder
from indexer.modules.custom.all_features_value_record import AllFeatureValueRecordBlueChipHolders
from indexer.modules.custom.blue_chip.domain.feature_blue_chip import BlueChipHolder
from indexer.modules.custom.deposit_to_l2.domain.address_token_deposit import AddressTokenDeposit
from indexer.modules.custom.deposit_to_l2.domain.token_deposit_transaction import TokenDepositTransaction
from indexer.modules.custom.deposit_to_l2.domains.address_token_deposit import AddressTokenDeposit
from indexer.modules.custom.deposit_to_l2.domains.token_deposit_transaction import TokenDepositTransaction
from indexer.modules.custom.eigen_layer.domains.eigen_layer_domain import EigenLayerAction, EigenLayerAddressCurrent
from indexer.modules.custom.hemera_ens.ens_domain import (
ENSAddressChangeD,
Expand Down
24 changes: 24 additions & 0 deletions indexer/modules/custom/deposit_to_l2/abi/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Time : 2024/10/21 下午5:50
Author : xuzh
Project : hemera_indexer
"""
from common.utils.abi_code_utils import Event

OP_PROTOCOL_TRANSACTION_DEPOSITED_EVENT = Event(
{
"anonymous": False,
"inputs": [
{"indexed": True, "internalType": "address", "name": "from", "type": "address"},
{"indexed": True, "internalType": "address", "name": "to", "type": "address"},
{"indexed": True, "internalType": "uint256", "name": "version", "type": "uint256"},
{"indexed": False, "internalType": "bytes", "name": "opaqueData", "type": "bytes"},
],
"name": "TransactionDeposited",
"type": "event",
}
)

event_mapping = {"op_transaction_deposited": OP_PROTOCOL_TRANSACTION_DEPOSITED_EVENT}
121 changes: 121 additions & 0 deletions indexer/modules/custom/deposit_to_l2/abi/function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Time : 2024/10/21 下午5:50
Author : xuzh
Project : hemera_indexer
"""
from common.utils.abi_code_utils import Function

OP_PROTOCOL_DEPOSIT_ETH_FUNCTION = Function(
{
"inputs": [
{"internalType": "uint32", "name": "_minGasLimit", "type": "uint32"},
{"internalType": "bytes", "name": "_extraData", "type": "bytes"},
],
"name": "depositETH",
"outputs": [],
"stateMutability": "payable",
"type": "function",
}
)

OP_PROTOCOL_BRIDGE_ETH_TO_FUNCTION = Function(
{
"inputs": [
{"internalType": "address", "name": "_to", "type": "address"},
{"internalType": "uint32", "name": "_minGasLimit", "type": "uint32"},
{"internalType": "bytes", "name": "_extraData", "type": "bytes"},
],
"name": "bridgeETHTo",
"outputs": [],
"stateMutability": "payable",
"type": "function",
}
)

OP_PROTOCOL_DEPOSIT_ERC20_TO_FUNCTION = Function(
{
"inputs": [
{"internalType": "address", "name": "_l1Token", "type": "address"},
{"internalType": "address", "name": "_l2Token", "type": "address"},
{"internalType": "address", "name": "_to", "type": "address"},
{"internalType": "uint256", "name": "_amount", "type": "uint256"},
{"internalType": "uint32", "name": "_minGasLimit", "type": "uint32"},
{"internalType": "bytes", "name": "_extraData", "type": "bytes"},
],
"name": "depositERC20To",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
}
)

ARBITRUM_OUTBOUND_TRANSFER_FUNCTION = Function(
{
"inputs": [
{"name": "_l1Token", "type": "address", "internalType": "address"},
{"name": "_to", "type": "address", "internalType": "address"},
{"name": "_amount", "type": "uint256", "internalType": "uint256"},
{"name": "_maxGas", "type": "uint256", "internalType": "uint256"},
{"name": "_gasPriceBid", "type": "uint256", "internalType": "uint256"},
{"name": "_data", "type": "bytes", "internalType": "bytes"},
],
"name": "outboundTransfer",
"outputs": [],
"payable": False,
"stateMutability": "nonpayable",
"type": "function",
}
)

LINEA_PROTOCOL_SEND_MESSAGE_FUNCTION = Function(
{
"inputs": [
{"internalType": "address", "name": "_to", "type": "address"},
{"internalType": "uint256", "name": "_fee", "type": "uint256"},
{"internalType": "bytes", "name": "_calldata", "type": "bytes"},
],
"name": "sendMessage",
"outputs": [],
"stateMutability": "payable",
"type": "function",
}
)

LINEA_PROTOCOL_BRIDGE_TOKEN_FUNCTION = Function(
{
"inputs": [
{"internalType": "address", "name": "_l1Token", "type": "address"},
{"internalType": "uint256", "name": "_amount", "type": "uint256"},
{"internalType": "address", "name": "_recipient", "type": "address"},
],
"name": "bridgeToken",
"outputs": [],
"stateMutability": "payable",
"type": "function",
}
)

LINEA_PROTOCOL_DEPOSIT_FUNCTION = Function(
{
"inputs": [
{"internalType": "uint256", "name": "_amount", "type": "uint256"},
{"internalType": "address", "name": "_to", "type": "address"},
],
"name": "depositTo",
"outputs": [],
"stateMutability": "payable",
"type": "function",
}
)

function_mapping = {
"op_deposit_eth": OP_PROTOCOL_DEPOSIT_ETH_FUNCTION,
"op_bridge_eth_to": OP_PROTOCOL_BRIDGE_ETH_TO_FUNCTION,
"op_deposit_erc20_to": OP_PROTOCOL_DEPOSIT_ERC20_TO_FUNCTION,
"arbitrum_outbound_transfer": ARBITRUM_OUTBOUND_TRANSFER_FUNCTION,
"linea_send_message": LINEA_PROTOCOL_SEND_MESSAGE_FUNCTION,
"linea_bridge_token": LINEA_PROTOCOL_BRIDGE_TOKEN_FUNCTION,
"linea_deposit_to": LINEA_PROTOCOL_DEPOSIT_FUNCTION,
}
120 changes: 9 additions & 111 deletions indexer/modules/custom/deposit_to_l2/deposit_parser.py
Original file line number Diff line number Diff line change
@@ -1,109 +1,14 @@
import json
from typing import List, cast

from eth_typing import HexStr
from web3._utils.contracts import decode_transaction_data
from web3.types import ABIEvent, ABIFunction
from typing import List

from common.utils.abi_code_utils import Function
from indexer.domain.transaction import Transaction
from indexer.modules.custom.deposit_to_l2.domain.token_deposit_transaction import TokenDepositTransaction
from indexer.utils.abi import event_log_abi_to_topic, function_abi_to_4byte_selector_str
from indexer.modules.custom.deposit_to_l2.domains.token_deposit_transaction import TokenDepositTransaction

ETH_ADDRESS = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
USDC_ADDRESS = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"

ETH_DEPOSIT_INITIATED_EVENT = cast(
ABIEvent,
json.loads(
"""{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"ETHDepositInitiated","type":"event"}"""
),
)
ETH_DEPOSIT_INITIATED_EVENT_SIG = event_log_abi_to_topic(ETH_DEPOSIT_INITIATED_EVENT)

ETH_BRIDGE_INITIATED_EVENT = cast(
ABIEvent,
json.loads(
"""{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"extraData","type":"bytes"}],"name":"ETHBridgeInitiated","type":"event"}"""
),
)
ETH_BRIDGE_INITIATED_EVENT_SIG = event_log_abi_to_topic(ETH_BRIDGE_INITIATED_EVENT)

TRANSACTION_DEPOSITED_EVENT = cast(
ABIEvent,
json.loads(
"""{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"version","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"opaqueData","type":"bytes"}],"name":"TransactionDeposited","type":"event"}"""
),
)
TRANSACTION_DEPOSITED_EVENT_SIG = event_log_abi_to_topic(TRANSACTION_DEPOSITED_EVENT)

DEPOSIT_ETH_FUNCTION = cast(
ABIFunction,
json.loads(
"""{"inputs":[{"internalType":"uint32","name":"_minGasLimit","type":"uint32"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"}"""
),
)
DEPOSIT_ETH_FUNCTION_SIG = function_abi_to_4byte_selector_str(DEPOSIT_ETH_FUNCTION)

BRIDGE_ETH_TO_FUNCTION = cast(
ABIFunction,
json.loads(
"""{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint32","name":"_minGasLimit","type":"uint32"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"bridgeETHTo","outputs":[],"stateMutability":"payable","type":"function"}"""
),
)
BRIDGE_ETH_TO_FUNCTION_SIG = function_abi_to_4byte_selector_str(BRIDGE_ETH_TO_FUNCTION)

DEPOSIT_ERC20_TO_FUNCTION = cast(
ABIFunction,
json.loads(
"""{"inputs":[{"internalType":"address","name":"_l1Token","type":"address"},{"internalType":"address","name":"_l2Token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint32","name":"_minGasLimit","type":"uint32"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"depositERC20To","outputs":[],"stateMutability":"nonpayable","type":"function"}"""
),
)
DEPOSIT_ERC20_TO_FUNCTION_SIG = function_abi_to_4byte_selector_str(DEPOSIT_ERC20_TO_FUNCTION)

DEPOSIT_TRANSACTION_FUNCTION = cast(
ABIFunction,
json.loads(
"""{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"uint64","name":"_gasLimit","type":"uint64"},{"internalType":"bool","name":"_isCreation","type":"bool"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"depositTransaction","outputs":[],"stateMutability":"payable","type":"function"}"""
),
)
DEPOSIT_TRANSACTION_FUNCTION_SIG = function_abi_to_4byte_selector_str(DEPOSIT_TRANSACTION_FUNCTION)

DEPOSIT_ETH_TO_ARBI_FUNCTION_SIG = "0x439370b1"

OUT_BOUND_TRANSFER_FUNCTION = cast(
ABIFunction,
json.loads(
"""{"inputs":[{"name":"_l1Token","type":"address","internalType":"address"},{"name":"_to","type":"address","internalType":"address"},{"name":"_amount","type":"uint256","internalType":"uint256"},{"name":"_maxGas","type":"uint256","internalType":"uint256"},{"name":"_gasPriceBid","type":"uint256","internalType":"uint256"},{"name":"_data","type":"bytes","internalType":"bytes"}],"name":"outboundTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}"""
),
)
OUT_BOUND_TRANSFER_FUNCTION_SIG = function_abi_to_4byte_selector_str(OUT_BOUND_TRANSFER_FUNCTION)

DEPOSIT_ETH_TO_LINEA_FUNCTION = cast(
ABIFunction,
json.loads(
"""{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"},{"internalType":"bytes","name":"_calldata","type":"bytes"}],"name":"sendMessage","outputs":[],"stateMutability":"payable","type":"function"}"""
),
)
DEPOSIT_ETH_TO_LINEA_FUNCTION_SIG = function_abi_to_4byte_selector_str(DEPOSIT_ETH_TO_LINEA_FUNCTION)

BRIDGE_TOKEN_TO_LINEA_FUNCTION = cast(
ABIFunction,
json.loads(
"""{"inputs":[{"internalType":"address","name":"_l1Token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"bridgeToken","outputs":[],"stateMutability":"payable","type":"function"}"""
),
)
BRIDGE_TOKEN_TO_LINEA_FUNCTION_SIG = function_abi_to_4byte_selector_str(BRIDGE_TOKEN_TO_LINEA_FUNCTION)

DEPOSIT_USDC_TO_LINEA_FUNCTION = cast(
ABIFunction,
json.loads(
"""{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"depositTo","outputs":[],"stateMutability":"payable","type":"function"}"""
),
)
DEPOSIT_USDC_TO_LINEA_FUNCTION_SIG = function_abi_to_4byte_selector_str(DEPOSIT_USDC_TO_LINEA_FUNCTION)


def eth_deposit_parse(transaction: Transaction, chain_mapping: dict, function: ABIFunction) -> TokenDepositTransaction:
def eth_deposit_parse(transaction: Transaction, chain_mapping: dict, function: Function) -> TokenDepositTransaction:
return TokenDepositTransaction(
transaction_hash=transaction.hash,
wallet_address=transaction.from_address,
Expand All @@ -116,8 +21,8 @@ def eth_deposit_parse(transaction: Transaction, chain_mapping: dict, function: A
)


def usdc_deposit_parse(transaction: Transaction, chain_mapping: dict, function: ABIFunction) -> TokenDepositTransaction:
decoded_input = decode_transaction_data(function, HexStr(transaction.input))
def usdc_deposit_parse(transaction: Transaction, chain_mapping: dict, function: Function) -> TokenDepositTransaction:
decoded_input = function.decode_function_input_data(transaction.input)
return TokenDepositTransaction(
transaction_hash=transaction.hash,
wallet_address=transaction.from_address,
Expand All @@ -130,10 +35,8 @@ def usdc_deposit_parse(transaction: Transaction, chain_mapping: dict, function:
)


def token_deposit_parse(
transaction: Transaction, chain_mapping: dict, function: ABIFunction
) -> TokenDepositTransaction:
decoded_input = decode_transaction_data(function, HexStr(transaction.input))
def token_deposit_parse(transaction: Transaction, chain_mapping: dict, function: Function) -> TokenDepositTransaction:
decoded_input = function.decode_function_input_data(transaction.input)
return TokenDepositTransaction(
transaction_hash=transaction.hash,
wallet_address=transaction.from_address,
Expand Down Expand Up @@ -175,9 +78,4 @@ def parse_deposit_transaction_function(


if __name__ == "__main__":
print(BRIDGE_ETH_TO_FUNCTION_SIG)
print(DEPOSIT_ERC20_TO_FUNCTION_SIG)
print(DEPOSIT_ETH_FUNCTION_SIG)
print(DEPOSIT_ETH_TO_LINEA_FUNCTION_SIG)
print(BRIDGE_TOKEN_TO_LINEA_FUNCTION_SIG)
print(DEPOSIT_USDC_TO_LINEA_FUNCTION_SIG)
pass
Loading