Skip to content

Commit

Permalink
Add logging to swap_with_slippage_protection()
Browse files Browse the repository at this point in the history
  • Loading branch information
miohtama committed Jul 31, 2023
1 parent ff80168 commit 774bcbf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.22.1

- Add logging to `swap_with_slippage_protection()` on Uniswap v3
to trace slippage issues

# 0.22

- Refactor a lot of functionality to a new submodule [eth_defi.provider](https://web3-ethereum-defi.readthedocs.io/api/provider/index.html)
Expand Down
8 changes: 8 additions & 0 deletions eth_defi/uniswap_v3/swap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Uniswap v3 swap helper functions."""
import warnings
from typing import Callable
import logging

from eth_typing import HexAddress
from web3.contract import Contract
Expand All @@ -10,6 +11,9 @@
from eth_defi.uniswap_v3.utils import encode_path


logger = logging.getLogger(__name__)


def swap_with_slippage_protection(
uniswap_v3_deployment: UniswapV3Deployment,
*,
Expand Down Expand Up @@ -102,6 +106,8 @@ def swap_with_slippage_protection(
slippage=max_slippage,
)

logger.info("exactInput() amount in: %s, estimated_min_amount_out: %s", amount_in, estimated_min_amount_out)

return router.functions.exactInput(
(
encoded_path,
Expand All @@ -122,6 +128,8 @@ def swap_with_slippage_protection(
slippage=max_slippage,
)

logger.info("exactInput() amount out: %s, estimated_max_amount_in: %s", amount_out, estimated_max_amount_in)

return router.functions.exactOutput(
(
encoded_path,
Expand Down

0 comments on commit 774bcbf

Please sign in to comment.