0

I'm trying to swap a pair not having wbnb on pancakeswap. For ex. BUSD -> LUNA. As far as the pair doesn't have wbnb I use swapExactTokensForTokens (meanwhile WBNB -> BUSD with swapExactETHForTokens works well)

Preparing transaction call and trying to estimate gas beforehand, but it fails with

web3.exceptions.ContractLogicError: execution reverted

build function..

func = self._router_contract.functions.swapExactTokensForTokens( <= self._router_contract - pancake router2
 20000000000000000,  <= amount_min
 79925366079999995746,   <= amount_out_min
 ['0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', '0x55d398326f99059fF775485246999027B3197955', '0x156ab3346823B651294766e23e6Cf87254d68962'], <= path BUSD->USDT->LUNA
 self._settings.self_address, <= my wallet 
 1652635609, <= deadline

)

Вот сама оценка газа

  func.estimateGas(
      {
          "from": self._settings.self_address,
          "value": amount_min,
          "gas_price": gas_price,
      }
  )

Digging for many hours, but no success(

2 Answers 2

0

This may have to do with the state of the LUNA liquidity pool. You may be trying to buy more LUNA than exists, given your inputs and the low price of LUNA. Try using the periphery contract quote() function and/or the pair's getReserves() to verify the amounts in question.

It's not clear to me why your question includes the fact that WBNB->BUSD works well, when based on the question, it seems you're actually trying to go BUSD->WBNB->LUNA.

1
  • Thanks for your reply.. The same error is for other swaps (like BUSD->Cake) where swapExactTokensForTokens is used in contrast to swapExactETHForTokens... So I assume there is an error in the function used or in the parameters passed... May 16, 2022 at 7:28
0

Particularly here it was an error in min output amount calculations.

But it's easier to put output_min as 0 and let the contract to make calculations. BTW original uniswap example in their repo uses 0 in such a way.

Also it worth to consult with contract's source as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.