Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Slippage in _eth_to_token_swap_output(...)? #42

Closed
Labels
bugSomething isn't working
@liquid-8

Description

@liquid-8

Hi!

Code is

def _eth_to_token_swap_output(        self, output_token: AddressLike, qty: int, recipient: Optional[AddressLike]    ) -> HexBytes:        """Convert ETH to tokens given an output amount."""        if self.version == 1:            token_funcs = self.exchange_contract(output_token).functions            eth_qty = self.get_eth_token_output_price(output_token, qty)            tx_params = self._get_tx_params(eth_qty)            func_params: List[Any] = [qty, self._deadline()]            if not recipient:                function = token_funcs.ethToTokenSwapOutput(*func_params)            else:                func_params.append(recipient)                function = token_funcs.ethToTokenTransferOutput(*func_params)            return self._build_and_send_tx(function, tx_params)        else:            if recipient is None:                recipient = self.address            eth_qty = self.get_eth_token_output_price(output_token, qty) #<----------------------------            return self._build_and_send_tx(                self.router.functions.swapETHForExactTokens(                    qty,                    [self.get_weth_address(), output_token],                    recipient,                    self._deadline(),                ),                self._get_tx_params(eth_qty),            )

It seems for me that highlighted string should be smth like that:

eth_qty = int(        (1 + self.max_slippage)*        self.get_eth_token_output_price(output_token, qty))

Am I right? As written I have no idea how slippage can be taken into account. Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp