Skip to content

Commit

Permalink
Fix swap call (#66)
Browse files Browse the repository at this point in the history
* Replace Swap call with transact

* Add an EVM-only script

* Re-added call to get transaction result, and wait for transaction.

---------

Co-authored-by: Maria Kotsifakou <[email protected]>
  • Loading branch information
malturki and mariaKt authored Nov 7, 2024
1 parent 0514c97 commit 250f969
Show file tree
Hide file tree
Showing 3 changed files with 486 additions and 4 deletions.
9 changes: 7 additions & 2 deletions WEth_Solidity_to_DAi_Rust_Tokens_Swap_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def main():
######################################### SwapSingleHopExactAmountIn Test ##########################################
print("")
print("Starting SwapSingleHopExactAmountIn Test...")

weth_amount = 1 * 10**18
weth_amount_hex = "{:064x}".format(weth_amount)
two_weth_amount = 2 * weth_amount
Expand Down Expand Up @@ -383,10 +383,15 @@ def main():
print("Synced WETH-DAI pair: ", tx_receipt["status"] == 1 and "Success" or "Failed")
if RECEIPTS:
print(tx_receipt)

# Swap WETH to DAI
daiAmountOut = swap.functions.swapSingleHopExactAmountIn(weth_amount,dai_amount_min).call()

tx_hash = swap.functions.swapSingleHopExactAmountIn(weth_amount,dai_amount_min).transact({'from': dev_account_address})
tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
print(f'Sucessfully swapped {weth_amount} WETH to DAI: {daiAmountOut}')
if RECEIPTS:
print(tx_receipt)


# Here is the transaction of swap WETH to DAI just for reference
Expand Down
Loading

0 comments on commit 250f969

Please sign in to comment.