Skip to main content

almanak_library.receipt_parser.uniswap_v3_receipt

pprint

Any

Dict

List

Optional

cast

HexBytes

ActionType

Chain

ExecutionStatus

Network

Protocol

TransactionType

Action

ApproveReceipt

ClosePositionReceipt

OpenPositionReceipt

Receipt

SwapReceipt

UnwrapReceipt

WrapReceipt

ISDK

IReceiptParser

UniswapV3SDK

Config

get_logger

get_protocol_sdk

DEBUG

logger

ReceiptParserUniswapV3 Objects

class ReceiptParserUniswapV3(IReceiptParser)

identify log based on topic[0] find the receipt based on the transaction hash in the log link action and receipt based on the action id

__init__

def __init__(protocol: Protocol, network: Network, chain: Chain)

initialize_sdk

def initialize_sdk() -> ISDK

find_logs_from_signature_bytes

@staticmethod
def find_logs_from_signature_bytes(logs: List[dict],
event_signature_bytes: str) -> list

Helper function to filter logs based on the event signature bytes. Returns a list of logs that match the event signature bytes. In most cases, only 1 log is expected.

filter_logs_by_action

@staticmethod
def filter_logs_by_action(logs: List[dict], action: Action) -> list

flatten_logs

def flatten_logs(receipts: List[Dict[str, Any]]) -> List[Dict[str, Any]]

Flatten the logs from all receipts into a single list.

find_receipt_by_transaction_hash

def find_receipt_by_transaction_hash(
transaction_hash: HexBytes,
receipts: List[Dict[str, Any]]) -> Optional[Dict[str, Any]]

Find a receipt that matches the given transactionHash from a list of receipts.

Arguments:

  • transaction_hash str - The transaction hash to search for.
  • receipts List[Dict[str, Any]] - The list of receipts to search within.

Returns:

Optional[Dict[str, Any]]: The matching receipt if found, otherwise None.

unwrap_parser

def unwrap_parser(action: Action, chain: Chain, transfer_offset: int,
multicall_action: bool,
receipts: List[Dict[str, Any]]) -> Optional[Receipt]

wrap_parser

def wrap_parser(action: Action, chain: Chain, transfer_offset: int,
mulitcall_action: bool,
receipts: List[Dict[str, Any]]) -> Optional[Receipt]

approve_parser

def approve_parser(action: Action, chain: Chain, transfer_offset: int,
multicall_action: bool,
receipts: List[Dict[str, Any]]) -> Optional[Receipt]

swap_parser

def swap_parser(action: Action, chain: Chain, transfer_offset: int,
multicall_action: bool,
receipts: List[Dict[str, Any]]) -> Optional[Receipt]

Validates the swap actions and retrieves the executed amounts using transaction receipts.

Transactions: TX: Swap

  • Log 0: Transfer Pool -> Recipient
  • Log 1: Transfer Recipient -> Pool

open_position_parser

def open_position_parser(action: Action, chain: Chain, offset: int,
multicall_action: bool,
receipts: List[Dict[str, Any]]) -> Optional[Receipt]

Validates the open position actions and retrieves the executed amounts using transaction receipts.

Transactions: TX: Open Position (mint NFT)

  • Log 0: Transfer (Token0)
  • Log 1: Transfer (Token1)
  • Log 2: Mint (Pool)
  • Log 3: Transfer (Mint NFT)
  • Log 4: IncreaseLiquidity (NFT)

close_position_parser_multicall

def close_position_parser_multicall(
action: Action, chain: Chain, transfer_offset: int,
multicall_action: bool,
receipts: List[Dict[str, Any]]) -> Optional[Receipt]

Parses the amounts from closing the position (liquidity + fees) using a multicall transaction receipt.

Transaction logs:

  • Log 0: Burn
  • Log 1: DecreaseLiquidity (NFT)
  • Log 2: Transfer (token0 from UV3 Pool to LP)
  • Log 3: Transfer (token1 from UV3 Pool to LP)
  • Log 4: Collect (Pool)
  • Log 5: Collect (NFT)
  • Log 6: Transfer (to lp)
  • Log 7: Transfer (to lp)

example: https://etherscan.io/tx/0xb2ed92c210ae8baa186555cc72d719d164acd3e9c74b94bae1abec0c73032220#eventlog