Skip to content

Commit

Permalink
Add log number to debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Sep 5, 2023
1 parent f672a12 commit 61936e8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion eth_defi/uniswap_v3/swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,26 @@ def swap_with_slippage_protection(
if amount_out is not None:
raise ValueError("amount_in is specified, amount_out has to be None")

web3 = uniswap_v3_deployment.web3
block_number = web3.eth.block_number

estimated_min_amount_out: int = price_helper.get_amount_out(
amount_in=amount_in,
path=path,
fees=pool_fees,
slippage=max_slippage,
block_identifier=block_number,
)

logger.info("exactInput() amount in: %s, estimated_min_amount_out: %s, slippage tolerance: %f BPS, fees: %s, path: %s",
# Because slippage tolerance errors are very annoying to diagnose,
# try to capture as much possible diagnostics data to logs
logger.info("exactInput() amount in: %s, estimated_min_amount_out: %s, slippage tolerance: %f BPS, fees: %s, path: %s, block: %d",
amount_in,
estimated_min_amount_out,
max_slippage,
pool_fees,
path,
block_number
)

return router.functions.exactInput(
Expand Down

0 comments on commit 61936e8

Please sign in to comment.