diff --git a/.env copy b/.env copy new file mode 100644 index 0000000..80cfb26 --- /dev/null +++ b/.env copy @@ -0,0 +1,13 @@ +DEV_PASSPHRASE="Bond0070$" +SEPOLIA_RPC_URL="https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI" +MNEMONIC="here is where your extracted twelve words mnemonic phrase should be put" +PRIVATE_KEY="8be727fdeb112e7a0fc63b1b8582e0ae933fe4b26c2db8722147384108f77e73" +PRIVATE_KEY2="baf16cf0fd7302e963d01b0e0185bfd8a125aec661ced3669ee345ecb928b9dc" +PRIVATE_KEY3="78f43105e544a9a1fc72612a2491c8123a14a3e6df245164084c10fa38d84079" +POKT_API_KEY="********************************" +INFURA_API_KEY="********************************" +INFURA_API_SECRET="********************************" +ALCHEMY_API_KEY="alcht_qTqyinch9eBi0vF09MR064gABbQbLI" +ETHERSCAN_API_KEY="E6RSVJDUQT2CTR8R4NVXGXRAWDUTNJAYZW" +TOKEN_ADDRESS="0xA7C36711208b0D6c2dC417fD6fA806746194256D" +RPC_ENDPOINT_URL="https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b36b664 --- /dev/null +++ b/.gitignore @@ -0,0 +1,168 @@ +.chalice/deployments/ +.chalice/deployed/ +.chalice/venv/ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +.ruff_cache + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +**/*.DS_Store +**/*.onnx +**/*.txt +**/*.jpg +**/*.whl +**/data +*.sierra +*.proof + +# Pip files +pydantic-1.x +pydantic-2.x + +# Private Key info +pk.txt + +# Forge Compiler files +# examples/on-chain-mnist/contracts/cache/ +# examples/on-chain-mnist/contracts/out/ + +# Poetry lock file +poetry.lock + +# Cairo example files +examples/on-chain_mnist/cairo/ + +examples/on-chain_mnist/cairo/lofi_mnst_2 +examples/on-chain_mnist/cairo/soft +examples/on-chain_mnist/cairo/mnist_sierra +examples/on-chain_mnist/contracts/out + +# cache files +tmp \ No newline at end of file diff --git a/GizathonHackathon.md b/GizathonHackathon.md index bfa4e95..5b2656a 100644 --- a/GizathonHackathon.md +++ b/GizathonHackathon.md @@ -1413,7 +1413,7 @@ Enhance the security of your account by adding additional random input: Show mnemonic? [Y/n]: Y Create Passphrase to encrypt account: Repeat for confirmation: -INFO: Newly generated mnemonic is:XXX +INFO: Newly generated mnemonic is:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX SUCCESS: A new account '0x39BaE1e8dEc32d94181bCDa1DC25218Ef57a12c2' with HDPath m/44'/60'/0'/0/0 has been added with the id 'giza1' sent .1 ETH from my other Sepolia; @@ -1539,3 +1539,78 @@ $ giza verify --proof-id 967 ``` + + + + + + + + +# Portfolio Manager Project + + + +Sepolia - used chrome - on LL laptop - centralG profile for metamask. + + + +## documentation + +### Ape + +https://docs.apeworx.io/ape/stable/userguides/accounts.html + + + +https://docs.stackup.sh/docs/supported-erc-20-tokens + + + +### ETH to token swap + +https://www.quicknode.com/guides/defi/dexs/how-to-swap-tokens-on-uniswap-with-ethersjs + + + + + +https://ethereum.stackexchange.com/questions/111799/programmatically-wrap-eth-by-interacting-with-wrapped-ether-contract-in-web3-py + + + + + + + + + +This is WETH mint; + +[Sepolia Transaction Hash (Txhash) Details | Etherscan](https://sepolia.etherscan.io/tx/0x93e23ff8660d8ff10be6779cafdfac2cb1a0de03785a7bd996bb24a72ca03c25) + + + + + +### Create Agent + + + + + +https://docs.gizatech.xyz/tutorials/ai-agents/using-arbitrum-with-ai-agents + +looking at Aritrum example + +```bash +giza agents create --endpoint-id --name --description + +From earlier Diabetes example- gizaTest1.ipynb +[giza][2024-05-29 23:53:51.335] Endpoint created with id -> 234 ✅ + +giza agents create --endpoint-id 234 --name gizaTest1 --description diabetesTest +``` + + + diff --git a/addresses.py b/addresses.py new file mode 100644 index 0000000..59384fc --- /dev/null +++ b/addresses.py @@ -0,0 +1,46 @@ +# source: https://docs.uniswap.org/contracts/v3/reference/deployments +ADDRESSES = { + "WETH": { + 1: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + 11155111: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14", + 5: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + 42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", + }, + "WBTC": { + 1: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + # 11155111: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14", + 11155111: "0x779877A7B0D9E8603169DdbD7836e478b4624789", + 5: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + 42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", + }, + "UNI": { + 1: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", + 11155111: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", + 5: "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", + 42161: "0xFa7F8980b0f1E64A2062791cc3b0871572f1F7f0", + }, + "USDC": { + 1: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + 11155111: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", + 5: "", + 42161: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", + }, + "NonfungiblePositionManager": { + 1: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", + 11155111: "0x1238536071E1c677A632429e3655c799b22cDA52", + 5: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", + 42161: "0xC36442b4a4522E871399CD717aBDD847Ab11FE88", + }, + "PoolFactory": { + 1: "0x1F98431c8aD98523631AE4a59f267346ea31F984", + 11155111: "0x0227628f3F023bb0B980b67D528571c95c6DaC1c", + 5: "0x1F98431c8aD98523631AE4a59f267346ea31F984", + 42161: "0x1F98431c8aD98523631AE4a59f267346ea31F984", + }, + "Router": { + 1: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", + 11155111: "0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E", + 5: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", + 42161: "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", + }, +} \ No newline at end of file diff --git a/getToken.ipynb b/getToken.ipynb new file mode 100644 index 0000000..1956530 --- /dev/null +++ b/getToken.ipynb @@ -0,0 +1,923 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "3858b91f-6094-46ad-9f72-334066caddee", + "metadata": {}, + "outputs": [], + "source": [ + "import os" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "f9850659-7601-4640-a5ec-52b263a997c9", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\chuck.raghavan\\AppData\\Roaming\\Python\\Python311\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + } + ], + "source": [ + "from ape import Contract, accounts, chain, networks" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "b1151761-c854-463f-92fd-05eab049ec53", + "metadata": {}, + "outputs": [], + "source": [ + "from dotenv import find_dotenv, load_dotenv" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "c5756a2d-7190-46d4-a6eb-5c9b548f7918", + "metadata": {}, + "outputs": [], + "source": [ + "from addresses import ADDRESSES" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "671d37b2-c2b1-44a1-bd24-f2a7cd2ec6ae", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "load_dotenv(find_dotenv())" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "9e707861-d22e-4e49-9bf6-d1c5ad96b8ca", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Dotenv path: C:\\Users\\chuck.raghavan\\OneDrive - Los Angeles Unified School District\\Documents\\GitHub\\EncodeBootcamps\\Gizathon\\.env\n" + ] + } + ], + "source": [ + "dotenv_path = find_dotenv()\n", + "print(f\"Dotenv path: {dotenv_path}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "fd496240-e886-4d59-b168-f065cbf747e1", + "metadata": {}, + "outputs": [], + "source": [ + "dev_passphrase = os.environ.get(\"DEV_PASSPHRASE\")\n", + "sepolia_rpc_url = os.environ.get(\"SEPOLIA_RPC_URL\")" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "887d0a1d-5eb0-40c6-bf5d-61b9cc81436d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "INFO: Connecting to existing Geth node at https://eth-sepolia.g.alchemy.com/[hidden].\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "networks.parse_network_choice(f\"ethereum:sepolia:{sepolia_rpc_url}\").__enter__()" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "8218582b-01be-4508-acc2-096bafeb8622", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "11155111" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chain_id = chain.chain_id\n", + "chain_id" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "87f9dbf3-ad14-406c-9281-8f87263ba220", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{1: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n", + " 11155111: '0x779877A7B0D9E8603169DdbD7836e478b4624789',\n", + " 5: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6',\n", + " 42161: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1'}" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ADDRESSES[\"WBTC\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "ab3df22d-05c9-4b07-8a2a-ccf31c78b575", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'0x779877A7B0D9E8603169DdbD7836e478b4624789'" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "wbtcAddr = ADDRESSES[\"WBTC\"][chain_id]\n", + "wbtcAddr" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6dfb50ab-e0a4-4344-a6f8-508d783af8e0", + "metadata": {}, + "outputs": [], + "source": [ + "# Contract('0x473E58A0D2BcD5d985ab083dC6883f66c24EEFB6')" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "18b86749-2d09-4e53-b908-6262aeefa2ff", + "metadata": {}, + "outputs": [], + "source": [ + "weth_mint_amount = 0.01\n", + "pool_fee = 3000\n", + "uni = Contract(ADDRESSES[\"UNI\"][chain_id])\n", + "weth = Contract(ADDRESSES[\"WETH\"][chain_id])\n", + "# wbtc = Contract(ADDRESSES[\"WETH\"][chain_id])\n", + "wusdc = Contract(ADDRESSES[\"USDC\"][chain_id])\n", + "# wbtc = Contract('0x66194f6c999b28965e0303a84cb8b797273b6b8b')\n", + "weth_decimals = weth.decimals()\n", + "# wbtc_decimals = wbtc.decimals()\n", + "uni_decimals = uni.decimals()\n", + "wusdc_decimals = wusdc.decimals()\n", + "weth_mint_amount = int(weth_mint_amount * 10**weth_decimals)\n", + "uni_mint_amount = int(0.5 * weth_mint_amount)\n", + "# wbtc_mint_amount = int(0.5 * weth_mint_amount)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "d614e7c1-9fe6-4c01-9a30-fbf0aef81d88", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING: Danger! This account will now sign any transaction it's given.\n" + ] + } + ], + "source": [ + "pool_factory = Contract(ADDRESSES[\"PoolFactory\"][chain_id])\n", + "pool_address = \"0x287B0e934ed0439E2a7b1d5F0FC25eA2c24b64f7\"\n", + "pool = Contract(pool_address)\n", + "swap_router = Contract(ADDRESSES[\"Router\"][chain_id])\n", + "wallet = accounts.load(\"giza1\")\n", + "wallet.set_autosign(True, passphrase=dev_passphrase)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "72467c66-5720-4ac0-8d7d-32619cc89f74", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'0x39BaE1e8dEc32d94181bCDa1DC25218Ef57a12c2'" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "wallet.address" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "49f2448d-c432-43b1-a309-4eda62d2257a", + "metadata": {}, + "outputs": [], + "source": [ + "with accounts.use_sender(\"giza1\"):\n", + " print(f\"Minting {weth_mint_amount/10**weth_decimals} WETH\")\n", + " weth.deposit(value=weth_mint_amount)\n", + " print(\"Approving WETH for swap\")\n", + " weth.approve(swap_router.address, weth_mint_amount)\n", + " swap_params = {\n", + " \"tokenIn\": weth.address,\n", + " \"tokenOut\": uni.address,\n", + " \"fee\": pool_fee,\n", + " \"recipient\": wallet.address,\n", + " \"amountIn\": weth_mint_amount,\n", + " \"amountOutMinimum\": 0,\n", + " \"sqrtPriceLimitX96\": 0,\n", + " }\n", + " swap_params = tuple(swap_params.values())\n", + " print(\"Swapping WETH for UNI\")\n", + " amountOut = swap_router.exactInputSingle(swap_params)\n", + " print(f\"Successfully minted {uni_mint_amount/10**uni_decimals} UNI\")\n", + "\n", + "print(f\"Your WETH balance: {weth.balanceOf(wallet.address)/10**weth_decimals}\")\n", + "print(f\"Your UNI balance: {uni.balanceOf(wallet.address)/10**uni_decimals}\")" + ] + }, + { + "cell_type": "markdown", + "id": "45b420d9-dafe-467f-a29f-177df32b0ba4", + "metadata": {}, + "source": [ + "## Print current ETH balance in Sepolia" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ad67d2c4-030b-4e88-b247-6ab205407670", + "metadata": {}, + "outputs": [], + "source": [ + "wallet.balance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "66fe725f-e64d-4c26-a9fb-394e047f3010", + "metadata": {}, + "outputs": [], + "source": [ + "wallet.balance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5b0feaeb-ff52-492a-9819-5d1198b74b9d", + "metadata": {}, + "outputs": [], + "source": [ + "# https://docs.uniswap.org/contracts/v2/reference/smart-contracts/router-02\n", + "\n", + "# function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n", + "# external\n", + "# payable\n", + "# returns (uint[] memory amounts);\n", + "\n", + "\n", + "\n", + "# deadline = chain.pending_timestamp + 3600\n", + "# eth_amount = 50000000000000000\n", + "# swap_path = [weth, wusdc]\n", + "# # gas=40000\n", + "\n", + "# # receipt = swap_router.swapExactETHForTokens('amountOutMinimum': 0, 'path':swap_path, 'to':wallet, 'value':eth_amount, 'deadline':deadline)\n", + "\n", + "# receipt = swap_router.swapExactETHForTokens( 0, [weth, wusdc], wallet, deadline )\n", + "\n", + "# receipt\n", + "\n", + "\n", + "# Did not work ---- \n", + "# ApeAttributeError: 'SwapRouter02' has no attribute 'swapExactETHForTokens'.\n", + "\n", + " " + ] + }, + { + "cell_type": "markdown", + "id": "cb23a845-20c1-4ee5-a181-93455e81a1f5", + "metadata": {}, + "source": [ + "#### https://docs.apeworx.io/ape/stable/userguides/contracts.html\n", + "receipt = contract.withdraw(sender=account, value=123)\n", + "print(receipt.gas_used)\n", + "\n", + "NOTE: You can also use \"smart\" values such as `\"0.1 ether\"` or `\"100 gwei\"`:\n", + "_ = contract.withdraw(sender=account, value=\"0.1 ether\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d9aae1c5-6dfc-48e8-bede-99c001cff8a6", + "metadata": {}, + "outputs": [], + "source": [ + "# receipt = swap_router(sender=wallet, value=\"0.01 ether\", gas=40000)\n", + "# receipt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "46de2b0a-661a-4fef-917b-61e8b82c93f7", + "metadata": {}, + "outputs": [], + "source": [ + "# https://sepolia.etherscan.io/address/0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E#writeContract\n", + "# did not work too\n", + "# receipt = swap_router.wrapETH(eth_amount, sender=wallet, gas=40000)\n", + "# receipt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0614e8c8-2c38-4a49-9de0-c42ef532c398", + "metadata": {}, + "outputs": [], + "source": [ + "### - https://ethereum.stackexchange.com/questions/111799/programmatically-wrap-eth-by-interacting-with-wrapped-ether-contract-in-web3-py\n", + "tx = swap_router.deposit().buildTransaction({\n", + " 'chainId': 1,\n", + " 'gas': 100000,\n", + " # 'gasPrice': w3.eth.gas_price,\n", + " 'gasPrice': 2000000, \n", + " 'nonce': w3.eth.get_transaction_count(use_this_address),\n", + " 'value': weth_mint_amount\n", + " })\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "001b91fa-ccc3-4eb1-ba2b-5fcde8e1f3d4", + "metadata": {}, + "outputs": [], + "source": [ + " # with accounts.use_sender(\"dev\"):\n", + " # print(f\"Minting {weth_mint_amount/10**weth_decimals} WETH\")\n", + " # weth.deposit(value=weth_mint_amount)\n", + " # print(\"Approving WETH for swap\")\n", + " # weth.approve(swap_router.address, weth_mint_amount)\n", + " # swap_params = {\n", + " # \"tokenIn\": weth.address,\n", + " # \"tokenOut\": uni.address,\n", + " # \"fee\": pool_fee,\n", + " # \"recipient\": wallet.address,\n", + " # \"amountIn\": weth_mint_amount,\n", + " # \"amountOutMinimum\": 0,\n", + " # \"sqrtPriceLimitX96\": 0,\n", + " # }\n", + " # swap_params = tuple(swap_params.values())\n", + " # print(\"Swapping WETH for UNI\")\n", + " # amountOut = swap_router.exactInputSingle(swap_params)\n", + " # print(f\"Successfully minted {uni_mint_amount/10**uni_decimals} UNI\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d8d46bd0-e83e-4ef6-9975-cfd82476f519", + "metadata": {}, + "outputs": [], + "source": [ + "swap_params = {\n", + " \"tokenIn\": weth.address,\n", + " \"tokenOut\": uni.address,\n", + " \"fee\": pool_fee,\n", + " \"recipient\": wallet.address,\n", + " \"amountIn\": weth_mint_amount,\n", + " \"amountOutMinimum\": 0,\n", + " \"sqrtPriceLimitX96\": 0,\n", + "}\n", + "swap_params = tuple(swap_params.values())\n", + "swap_params" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c45ffa3f-a8b2-40a4-be86-bb2a12a538ed", + "metadata": {}, + "outputs": [], + "source": [ + " swap_params = {\n", + " \"chainId\": chain_id,\n", + " \"gas\": 2000000,\n", + " \"tokenOut\": uni.address,\n", + " \"fee\": pool_fee,\n", + " \"recipient\": wallet.address,\n", + " \"amountIn\": weth_mint_amount,\n", + " \"amountOutMinimum\": 0,\n", + " \"sqrtPriceLimitX96\": 0,\n", + " }" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "304ba544-9264-4f33-b6df-ae76d81fd437", + "metadata": {}, + "outputs": [], + "source": [ + "# # wrap eth\n", + "# tx = weth_contract.functions.deposit().build_transaction({\n", + "# # 'chainId': web3.eth.chain_id,\n", + "# 'gas': 2000000,\n", + "# \"maxPriorityFeePerGas\": web3.eth.max_priority_fee,\n", + "# \"maxFeePerGas\": 100 * 10**9,\n", + "# 'nonce': web3.eth.get_transaction_count(account.address),\n", + "# 'value': amount_in, # wrap 1 eth\n", + "# })\n", + "\n", + "# signed_transaction = web3.eth.account.sign_transaction(tx, private_key)\n", + "# tx_hash = web3.eth.send_raw_transaction(signed_transaction.rawTransaction)\n", + "\n", + "# tx_receipt = web3.eth.wait_for_transaction_receipt(tx_hash)\n", + "# print(f\"tx hash: {Web3.to_hex(tx_hash)}\")\n", + "# total_gas_used_buy += tx_receipt[\"gasUsed\"]\n", + "\n", + "# weth_balance = weth_contract.functions.balanceOf(account.address).call()\n", + "# print(f\"weth balance: {weth_balance / 10**18}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9a06ba8a-5ef0-47cf-aeee-e9eed172d18b", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "# Define the swap parameters\n", + "# eth_amount = to_wei(0.05, \"ether\") # Amount of ETH to swap\n", + "eth_amount = 50000000000000000\n", + "usdc_address = ADDRESSES[\"USDC\"][chain.chain_id]\n", + "# deadline = chain.time() + 600 # 10 minutes from the current block timestamp\n", + "deadline = chain.pending_timestamp + 3600\n", + "amountOutMin = 0 # Set to 0 for simplicity, but you should set a minimum amount to avoid front-running\n", + "\n", + "# Path for ETH to USDC swap\n", + "# swap_path = [AddressType(w3.eth.default_account), usdc_address]\n", + "swap_path = [usdc_address]\n", + "\n", + "# Perform the swap\n", + "with accounts.use_sender(wallet):\n", + " print(f\"Swapping {eth_amount / 10**18} ETH for USDC\")\n", + " tx = swap_router.swapExactETHForTokens(\n", + " amountOutMin,\n", + " swap_path,\n", + " wallet.address,\n", + " deadline,\n", + " value=eth_amount\n", + " )\n", + " tx.wait_for_receipt() # Wait for the transaction to be mined\n", + " print(\"Swap transaction completed\")\n", + "\n", + "# Check the USDC balance of the wallet\n", + "usdc = Contract(ADDRESSES[\"USDC\"][chain.chain_id])\n", + "usdc_balance = usdc.balanceOf(wallet.address)\n", + "print(f\"Your USDC balance: {usdc_balance / 10**usdc.decimals()} USDC\")\n", + "\n", + "# Check the ETH balance of the wallet\n", + "eth_balance = wallet.balance\n", + "eth_balance_in_ether = eth_balance / 10**18\n", + "print(f\"Your ETH balance: {eth_balance_in_ether} ETH\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "ca286094-d541-46dc-9c34-9fb65235b512", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Minting 0.01 WETH\n", + "WARNING: Using cached key for giza1\n", + "INFO: Submitted https://sepolia.etherscan.io/tx/0xa6fae58a12e56163f9a2b2f01eb302f73570784e0ee2ea64f6a59902f5f50874\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Confirmations (2/2): 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:28<00:00, 14.35s/it]\n" + ] + }, + { + "ename": "ProviderError", + "evalue": "400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:93\u001b[0m, in \u001b[0;36mAutoProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 92\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 93\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_proxy_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:111\u001b[0m, in \u001b[0;36mAutoProvider._proxy_request\u001b[1;34m(self, method, params, use_cache)\u001b[0m\n\u001b[0;32m 106\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CannotHandleRequest(\n\u001b[0;32m 107\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCould not discover provider while making request: \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 108\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mparams:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparams\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 109\u001b[0m )\n\u001b[1;32m--> 111\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\rpc.py:90\u001b[0m, in \u001b[0;36mHTTPProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 89\u001b[0m request_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_rpc_request(method, params)\n\u001b[1;32m---> 90\u001b[0m raw_response \u001b[38;5;241m=\u001b[39m \u001b[43mmake_post_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mendpoint_uri\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrequest_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_request_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 92\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecode_rpc_response(raw_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\_utils\\request.py:115\u001b[0m, in \u001b[0;36mmake_post_request\u001b[1;34m(endpoint_uri, data, *args, **kwargs)\u001b[0m\n\u001b[0;32m 114\u001b[0m response \u001b[38;5;241m=\u001b[39m get_response_from_post_request(endpoint_uri, data\u001b[38;5;241m=\u001b[39mdata, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 115\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1084\u001b[0m, in \u001b[0;36mWeb3Provider._make_request\u001b[1;34m(self, endpoint, parameters)\u001b[0m\n\u001b[0;32m 1083\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1084\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mweb3\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mRPCEndpoint\u001b[49m\u001b[43m(\u001b[49m\u001b[43mendpoint\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1085\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m HTTPError \u001b[38;5;28;01mas\u001b[39;00m err:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:95\u001b[0m, in \u001b[0;36mAutoProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n\u001b[1;32m---> 95\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_proxy_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_cache\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:111\u001b[0m, in \u001b[0;36mAutoProvider._proxy_request\u001b[1;34m(self, method, params, use_cache)\u001b[0m\n\u001b[0;32m 106\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CannotHandleRequest(\n\u001b[0;32m 107\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCould not discover provider while making request: \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 108\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mparams:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparams\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 109\u001b[0m )\n\u001b[1;32m--> 111\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\rpc.py:90\u001b[0m, in \u001b[0;36mHTTPProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 89\u001b[0m request_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_rpc_request(method, params)\n\u001b[1;32m---> 90\u001b[0m raw_response \u001b[38;5;241m=\u001b[39m \u001b[43mmake_post_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mendpoint_uri\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrequest_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_request_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 92\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecode_rpc_response(raw_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\_utils\\request.py:115\u001b[0m, in \u001b[0;36mmake_post_request\u001b[1;34m(endpoint_uri, data, *args, **kwargs)\u001b[0m\n\u001b[0;32m 114\u001b[0m response \u001b[38;5;241m=\u001b[39m get_response_from_post_request(endpoint_uri, data\u001b[38;5;241m=\u001b[39mdata, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 115\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[1;31mProviderError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1431\u001b[0m, in \u001b[0;36mEthereumNodeProvider.get_call_tree\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1429\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1430\u001b[0m \u001b[38;5;66;03m# Try the Parity traces first, in case node client supports it.\u001b[39;00m\n\u001b[1;32m-> 1431\u001b[0m tree \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_parity_call_tree\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1432\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (\u001b[38;5;167;01mValueError\u001b[39;00m, APINotImplementedError, ProviderError):\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1445\u001b[0m, in \u001b[0;36mEthereumNodeProvider._get_parity_call_tree\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1444\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_parity_call_tree\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn_hash: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m CallTreeNode:\n\u001b[1;32m-> 1445\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_make_request\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtrace_transaction\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1446\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m result:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1091\u001b[0m, in \u001b[0;36mWeb3Provider._make_request\u001b[1;34m(self, endpoint, parameters)\u001b[0m\n\u001b[0;32m 1087\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m APINotImplementedError(\n\u001b[0;32m 1088\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRPC method \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mendpoint\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m is not implemented by this node instance.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 1089\u001b[0m )\n\u001b[1;32m-> 1091\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ProviderError(\u001b[38;5;28mstr\u001b[39m(err)) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[0;32m 1093\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merror\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m result:\n", + "\u001b[1;31mProviderError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:93\u001b[0m, in \u001b[0;36mAutoProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 92\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 93\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_proxy_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:111\u001b[0m, in \u001b[0;36mAutoProvider._proxy_request\u001b[1;34m(self, method, params, use_cache)\u001b[0m\n\u001b[0;32m 106\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CannotHandleRequest(\n\u001b[0;32m 107\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCould not discover provider while making request: \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 108\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mparams:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparams\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 109\u001b[0m )\n\u001b[1;32m--> 111\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\rpc.py:90\u001b[0m, in \u001b[0;36mHTTPProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 89\u001b[0m request_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_rpc_request(method, params)\n\u001b[1;32m---> 90\u001b[0m raw_response \u001b[38;5;241m=\u001b[39m \u001b[43mmake_post_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mendpoint_uri\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrequest_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_request_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 92\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecode_rpc_response(raw_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\_utils\\request.py:115\u001b[0m, in \u001b[0;36mmake_post_request\u001b[1;34m(endpoint_uri, data, *args, **kwargs)\u001b[0m\n\u001b[0;32m 114\u001b[0m response \u001b[38;5;241m=\u001b[39m get_response_from_post_request(endpoint_uri, data\u001b[38;5;241m=\u001b[39mdata, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 115\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1084\u001b[0m, in \u001b[0;36mWeb3Provider._make_request\u001b[1;34m(self, endpoint, parameters)\u001b[0m\n\u001b[0;32m 1083\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1084\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mweb3\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mRPCEndpoint\u001b[49m\u001b[43m(\u001b[49m\u001b[43mendpoint\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1085\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m HTTPError \u001b[38;5;28;01mas\u001b[39;00m err:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:95\u001b[0m, in \u001b[0;36mAutoProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n\u001b[1;32m---> 95\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_proxy_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_cache\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:111\u001b[0m, in \u001b[0;36mAutoProvider._proxy_request\u001b[1;34m(self, method, params, use_cache)\u001b[0m\n\u001b[0;32m 106\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CannotHandleRequest(\n\u001b[0;32m 107\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCould not discover provider while making request: \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 108\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mparams:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparams\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 109\u001b[0m )\n\u001b[1;32m--> 111\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\rpc.py:90\u001b[0m, in \u001b[0;36mHTTPProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 89\u001b[0m request_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_rpc_request(method, params)\n\u001b[1;32m---> 90\u001b[0m raw_response \u001b[38;5;241m=\u001b[39m \u001b[43mmake_post_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mendpoint_uri\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrequest_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_request_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 92\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecode_rpc_response(raw_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\_utils\\request.py:115\u001b[0m, in \u001b[0;36mmake_post_request\u001b[1;34m(endpoint_uri, data, *args, **kwargs)\u001b[0m\n\u001b[0;32m 114\u001b[0m response \u001b[38;5;241m=\u001b[39m get_response_from_post_request(endpoint_uri, data\u001b[38;5;241m=\u001b[39mdata, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 115\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[1;31mProviderError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[16], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m accounts\u001b[38;5;241m.\u001b[39muse_sender(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgiza1\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[0;32m 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMinting \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mweth_mint_amount\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m10\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mweth_decimals\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m WETH\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m----> 3\u001b[0m \u001b[43mweth\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdeposit\u001b[49m\u001b[43m(\u001b[49m\u001b[43mvalue\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mweth_mint_amount\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mApproving WETH for swap\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 5\u001b[0m weth\u001b[38;5;241m.\u001b[39mapprove(swap_router\u001b[38;5;241m.\u001b[39maddress, weth_mint_amount)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\contracts\\base.py:373\u001b[0m, in \u001b[0;36mContractTransactionHandler.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 370\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m kwargs \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maccount_manager\u001b[38;5;241m.\u001b[39mdefault_sender \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 371\u001b[0m kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maccount_manager\u001b[38;5;241m.\u001b[39mdefault_sender\n\u001b[1;32m--> 373\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcontract_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\contracts\\base.py:307\u001b[0m, in \u001b[0;36mContractTransaction.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 304\u001b[0m private \u001b[38;5;241m=\u001b[39m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mprivate\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[0;32m 306\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m kwargs \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m], AccountAPI):\n\u001b[1;32m--> 307\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mkwargs\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msender\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 309\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (\n\u001b[0;32m 310\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_private_transaction(txn)\n\u001b[0;32m 311\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m private\n\u001b[0;32m 312\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_transaction(txn)\n\u001b[0;32m 313\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\accounts.py:180\u001b[0m, in \u001b[0;36mAccountAPI.call\u001b[1;34m(self, txn, send_everything, private, **signer_options)\u001b[0m\n\u001b[0;32m 174\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m txn\u001b[38;5;241m.\u001b[39msender:\n\u001b[0;32m 175\u001b[0m txn\u001b[38;5;241m.\u001b[39msender \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maddress\n\u001b[0;32m 177\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (\n\u001b[0;32m 178\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_private_transaction(signed_txn)\n\u001b[0;32m 179\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m private\n\u001b[1;32m--> 180\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msend_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[43msigned_txn\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 181\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:154\u001b[0m, in \u001b[0;36mWeb3Provider.__new__..post_tx_hook..send_tx_wrapper\u001b[1;34m(self, txn)\u001b[0m\n\u001b[0;32m 151\u001b[0m \u001b[38;5;129m@wraps\u001b[39m(send_tx)\n\u001b[0;32m 152\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21msend_tx_wrapper\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn: TransactionAPI) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m ReceiptAPI:\n\u001b[0;32m 153\u001b[0m receipt \u001b[38;5;241m=\u001b[39m send_tx(\u001b[38;5;28mself\u001b[39m, txn)\n\u001b[1;32m--> 154\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_post_send_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreceipt\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 155\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m receipt\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1026\u001b[0m, in \u001b[0;36mWeb3Provider._post_send_transaction\u001b[1;34m(self, tx, receipt)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;66;03m# TODO: Optional configuration?\u001b[39;00m\n\u001b[0;32m 1024\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m tx\u001b[38;5;241m.\u001b[39mreceiver \u001b[38;5;129;01mand\u001b[39;00m Address(tx\u001b[38;5;241m.\u001b[39mreceiver)\u001b[38;5;241m.\u001b[39mis_contract:\n\u001b[0;32m 1025\u001b[0m \u001b[38;5;66;03m# Look for and print any contract logging\u001b[39;00m\n\u001b[1;32m-> 1026\u001b[0m \u001b[43mreceipt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshow_debug_logs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1028\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConfirmed \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mreceipt\u001b[38;5;241m.\u001b[39mtxn_hash\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m (total fees paid = \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mreceipt\u001b[38;5;241m.\u001b[39mtotal_fees_paid\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\transactions.py:329\u001b[0m, in \u001b[0;36mReceiptAPI.show_debug_logs\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 325\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mshow_debug_logs\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m 326\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 327\u001b[0m \u001b[38;5;124;03m Output debug logs to logging system\u001b[39;00m\n\u001b[0;32m 328\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 329\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m ln \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug_logs_lines\u001b[49m:\n\u001b[0;32m 330\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m[DEBUG-LOG] \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mln\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\transactions.py:323\u001b[0m, in \u001b[0;36mReceiptAPI.debug_logs_lines\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 318\u001b[0m \u001b[38;5;129m@cached_property\u001b[39m\n\u001b[0;32m 319\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdebug_logs_lines\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m List[\u001b[38;5;28mstr\u001b[39m]:\n\u001b[0;32m 320\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 321\u001b[0m \u001b[38;5;124;03m Return any debug log data outputted by the transaction as strings suitable for printing\u001b[39;00m\n\u001b[0;32m 322\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 323\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;28mmap\u001b[39m(\u001b[38;5;28mstr\u001b[39m, ln)) \u001b[38;5;28;01mfor\u001b[39;00m ln \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug_logs_typed\u001b[49m]\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\transactions.py:218\u001b[0m, in \u001b[0;36mReceipt.debug_logs_typed\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 213\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 214\u001b[0m \u001b[38;5;124;03mExtract messages to console outputted by contracts via print() or console.log() statements\u001b[39;00m\n\u001b[0;32m 215\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 217\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 218\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall_tree\u001b[49m\n\u001b[0;32m 219\u001b[0m \u001b[38;5;66;03m# Some providers do not implement this, so skip\u001b[39;00m\n\u001b[0;32m 220\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m APINotImplementedError:\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\transactions.py:209\u001b[0m, in \u001b[0;36mReceipt.call_tree\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 207\u001b[0m \u001b[38;5;129m@cached_property\u001b[39m\n\u001b[0;32m 208\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcall_tree\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Optional[CallTreeNode]:\n\u001b[1;32m--> 209\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_call_tree\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1434\u001b[0m, in \u001b[0;36mEthereumNodeProvider.get_call_tree\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1432\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (\u001b[38;5;167;01mValueError\u001b[39;00m, APINotImplementedError, ProviderError):\n\u001b[0;32m 1433\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcan_use_parity_traces \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[1;32m-> 1434\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_geth_call_tree\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1435\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[0;32m 1436\u001b[0m logger\u001b[38;5;241m.\u001b[39merror(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnknown exception while checking for Parity-trace support: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00merr\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1454\u001b[0m, in \u001b[0;36mEthereumNodeProvider._get_geth_call_tree\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1453\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_geth_call_tree\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn_hash: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m CallTreeNode:\n\u001b[1;32m-> 1454\u001b[0m calls \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_transaction_trace_using_call_tracer\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1455\u001b[0m evm_call \u001b[38;5;241m=\u001b[39m get_calltree_from_geth_call_trace(calls)\n\u001b[0;32m 1456\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_call_tree_node(evm_call, txn_hash\u001b[38;5;241m=\u001b[39mtxn_hash)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1413\u001b[0m, in \u001b[0;36mEthereumNodeProvider._get_transaction_trace_using_call_tracer\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1412\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_transaction_trace_using_call_tracer\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn_hash: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Dict:\n\u001b[1;32m-> 1413\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_make_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1414\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdebug_traceTransaction\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43menableMemory\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtracer\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcallTracer\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m}\u001b[49m\u001b[43m]\u001b[49m\n\u001b[0;32m 1415\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1091\u001b[0m, in \u001b[0;36mWeb3Provider._make_request\u001b[1;34m(self, endpoint, parameters)\u001b[0m\n\u001b[0;32m 1086\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod not allowed\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mstr\u001b[39m(err)\u001b[38;5;241m.\u001b[39mlower():\n\u001b[0;32m 1087\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m APINotImplementedError(\n\u001b[0;32m 1088\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRPC method \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mendpoint\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m is not implemented by this node instance.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 1089\u001b[0m )\n\u001b[1;32m-> 1091\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ProviderError(\u001b[38;5;28mstr\u001b[39m(err)) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[0;32m 1093\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merror\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m result:\n\u001b[0;32m 1094\u001b[0m error \u001b[38;5;241m=\u001b[39m result[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merror\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n", + "\u001b[1;31mProviderError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI" + ] + } + ], + "source": [ + "with accounts.use_sender(\"giza1\"):\n", + " print(f\"Minting {weth_mint_amount/10**weth_decimals} WETH\")\n", + " weth.deposit(value=weth_mint_amount)\n", + " print(\"Approving WETH for swap\")\n", + " weth.approve(swap_router.address, weth_mint_amount)\n", + " swap_params = {\n", + " \"tokenIn\": weth.address,\n", + " \"tokenOut\": wusdc.address,\n", + " \"fee\": pool_fee,\n", + " \"recipient\": wallet.address,\n", + " \"amountIn\": weth_mint_amount/2,\n", + " \"amountOutMinimum\": 0,\n", + " \"sqrtPriceLimitX96\": 0,\n", + " }\n", + " swap_params = tuple(swap_params.values())\n", + " print(\"Swapping WETH for USDC\")\n", + " amountOut = swap_router.exactInputSingle(swap_params)\n", + " print(f\"Successfully minted {uni_mint_amount/10**uni_decimals} USDC\")\n", + "\n", + "print(f\"Your WETH balance: {weth.balanceOf(wallet.address)/10**weth_decimals}\")\n", + "print(f\"Your WUSDC balance: {wusdc.balanceOf(wallet.address)/10**wusdc_decimals}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "44ab63ad-b551-4dc1-b82c-973ab99ebdf5", + "metadata": {}, + "outputs": [], + "source": [ + "# try USDC deposit now.\n", + "\n", + "with accounts.use_sender(\"giza1\"):\n", + " print(f\"Minting {weth_mint_amount/10**wusdc_decimals} WUSDC\")\n", + " wusdc.deposit(value=weth_mint_amount/2)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "97c9c56a-870b-4604-ad2d-c4e6f7147b9e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "WARNING: Using cached key for giza1\n", + "INFO: Submitted https://sepolia.etherscan.io/tx/0x1fd24a91db42f1d8ee66f44cd26fd145243d115c326eacdc9221bc7ab75be31f\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Confirmations (2/2): 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:21<00:00, 10.77s/it]\n" + ] + }, + { + "ename": "ProviderError", + "evalue": "400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:93\u001b[0m, in \u001b[0;36mAutoProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 92\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 93\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_proxy_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:111\u001b[0m, in \u001b[0;36mAutoProvider._proxy_request\u001b[1;34m(self, method, params, use_cache)\u001b[0m\n\u001b[0;32m 106\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CannotHandleRequest(\n\u001b[0;32m 107\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCould not discover provider while making request: \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 108\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mparams:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparams\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 109\u001b[0m )\n\u001b[1;32m--> 111\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\rpc.py:90\u001b[0m, in \u001b[0;36mHTTPProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 89\u001b[0m request_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_rpc_request(method, params)\n\u001b[1;32m---> 90\u001b[0m raw_response \u001b[38;5;241m=\u001b[39m \u001b[43mmake_post_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mendpoint_uri\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrequest_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_request_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 92\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecode_rpc_response(raw_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\_utils\\request.py:115\u001b[0m, in \u001b[0;36mmake_post_request\u001b[1;34m(endpoint_uri, data, *args, **kwargs)\u001b[0m\n\u001b[0;32m 114\u001b[0m response \u001b[38;5;241m=\u001b[39m get_response_from_post_request(endpoint_uri, data\u001b[38;5;241m=\u001b[39mdata, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 115\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1084\u001b[0m, in \u001b[0;36mWeb3Provider._make_request\u001b[1;34m(self, endpoint, parameters)\u001b[0m\n\u001b[0;32m 1083\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1084\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mweb3\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mRPCEndpoint\u001b[49m\u001b[43m(\u001b[49m\u001b[43mendpoint\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1085\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m HTTPError \u001b[38;5;28;01mas\u001b[39;00m err:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:95\u001b[0m, in \u001b[0;36mAutoProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n\u001b[1;32m---> 95\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_proxy_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_cache\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:111\u001b[0m, in \u001b[0;36mAutoProvider._proxy_request\u001b[1;34m(self, method, params, use_cache)\u001b[0m\n\u001b[0;32m 106\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CannotHandleRequest(\n\u001b[0;32m 107\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCould not discover provider while making request: \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 108\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mparams:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparams\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 109\u001b[0m )\n\u001b[1;32m--> 111\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\rpc.py:90\u001b[0m, in \u001b[0;36mHTTPProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 89\u001b[0m request_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_rpc_request(method, params)\n\u001b[1;32m---> 90\u001b[0m raw_response \u001b[38;5;241m=\u001b[39m \u001b[43mmake_post_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mendpoint_uri\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrequest_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_request_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 92\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecode_rpc_response(raw_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\_utils\\request.py:115\u001b[0m, in \u001b[0;36mmake_post_request\u001b[1;34m(endpoint_uri, data, *args, **kwargs)\u001b[0m\n\u001b[0;32m 114\u001b[0m response \u001b[38;5;241m=\u001b[39m get_response_from_post_request(endpoint_uri, data\u001b[38;5;241m=\u001b[39mdata, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 115\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[1;31mProviderError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[17], line 5\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m accounts\u001b[38;5;241m.\u001b[39muse_sender(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgiza1\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n\u001b[0;32m 2\u001b[0m \u001b[38;5;66;03m# print(f\"Minting {weth_mint_amount/10**weth_decimals} WETH\")\u001b[39;00m\n\u001b[0;32m 3\u001b[0m \u001b[38;5;66;03m# weth.deposit(value=weth_mint_amount)\u001b[39;00m\n\u001b[0;32m 4\u001b[0m \u001b[38;5;66;03m# print(\"Approving WETH for swap\")\u001b[39;00m\n\u001b[1;32m----> 5\u001b[0m \u001b[43mweth\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapprove\u001b[49m\u001b[43m(\u001b[49m\u001b[43mswap_router\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43maddress\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweth_mint_amount\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 6\u001b[0m swap_params \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m 7\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtokenIn\u001b[39m\u001b[38;5;124m\"\u001b[39m: weth\u001b[38;5;241m.\u001b[39maddress,\n\u001b[0;32m 8\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtokenOut\u001b[39m\u001b[38;5;124m\"\u001b[39m: wusdc\u001b[38;5;241m.\u001b[39maddress,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 13\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msqrtPriceLimitX96\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;241m0\u001b[39m,\n\u001b[0;32m 14\u001b[0m }\n\u001b[0;32m 15\u001b[0m swap_params \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mtuple\u001b[39m(swap_params\u001b[38;5;241m.\u001b[39mvalues())\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\contracts\\base.py:373\u001b[0m, in \u001b[0;36mContractTransactionHandler.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 370\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m kwargs \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maccount_manager\u001b[38;5;241m.\u001b[39mdefault_sender \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 371\u001b[0m kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maccount_manager\u001b[38;5;241m.\u001b[39mdefault_sender\n\u001b[1;32m--> 373\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcontract_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\contracts\\base.py:307\u001b[0m, in \u001b[0;36mContractTransaction.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 304\u001b[0m private \u001b[38;5;241m=\u001b[39m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mprivate\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[0;32m 306\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m kwargs \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m], AccountAPI):\n\u001b[1;32m--> 307\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mkwargs\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msender\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 309\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (\n\u001b[0;32m 310\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_private_transaction(txn)\n\u001b[0;32m 311\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m private\n\u001b[0;32m 312\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_transaction(txn)\n\u001b[0;32m 313\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\accounts.py:180\u001b[0m, in \u001b[0;36mAccountAPI.call\u001b[1;34m(self, txn, send_everything, private, **signer_options)\u001b[0m\n\u001b[0;32m 174\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m txn\u001b[38;5;241m.\u001b[39msender:\n\u001b[0;32m 175\u001b[0m txn\u001b[38;5;241m.\u001b[39msender \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maddress\n\u001b[0;32m 177\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (\n\u001b[0;32m 178\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_private_transaction(signed_txn)\n\u001b[0;32m 179\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m private\n\u001b[1;32m--> 180\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msend_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[43msigned_txn\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 181\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:154\u001b[0m, in \u001b[0;36mWeb3Provider.__new__..post_tx_hook..send_tx_wrapper\u001b[1;34m(self, txn)\u001b[0m\n\u001b[0;32m 151\u001b[0m \u001b[38;5;129m@wraps\u001b[39m(send_tx)\n\u001b[0;32m 152\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21msend_tx_wrapper\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn: TransactionAPI) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m ReceiptAPI:\n\u001b[0;32m 153\u001b[0m receipt \u001b[38;5;241m=\u001b[39m send_tx(\u001b[38;5;28mself\u001b[39m, txn)\n\u001b[1;32m--> 154\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_post_send_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreceipt\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 155\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m receipt\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1026\u001b[0m, in \u001b[0;36mWeb3Provider._post_send_transaction\u001b[1;34m(self, tx, receipt)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;66;03m# TODO: Optional configuration?\u001b[39;00m\n\u001b[0;32m 1024\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m tx\u001b[38;5;241m.\u001b[39mreceiver \u001b[38;5;129;01mand\u001b[39;00m Address(tx\u001b[38;5;241m.\u001b[39mreceiver)\u001b[38;5;241m.\u001b[39mis_contract:\n\u001b[0;32m 1025\u001b[0m \u001b[38;5;66;03m# Look for and print any contract logging\u001b[39;00m\n\u001b[1;32m-> 1026\u001b[0m \u001b[43mreceipt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshow_debug_logs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1028\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConfirmed \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mreceipt\u001b[38;5;241m.\u001b[39mtxn_hash\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m (total fees paid = \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mreceipt\u001b[38;5;241m.\u001b[39mtotal_fees_paid\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\transactions.py:329\u001b[0m, in \u001b[0;36mReceiptAPI.show_debug_logs\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 325\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mshow_debug_logs\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m 326\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 327\u001b[0m \u001b[38;5;124;03m Output debug logs to logging system\u001b[39;00m\n\u001b[0;32m 328\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 329\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m ln \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug_logs_lines\u001b[49m:\n\u001b[0;32m 330\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m[DEBUG-LOG] \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mln\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\transactions.py:323\u001b[0m, in \u001b[0;36mReceiptAPI.debug_logs_lines\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 318\u001b[0m \u001b[38;5;129m@cached_property\u001b[39m\n\u001b[0;32m 319\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdebug_logs_lines\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m List[\u001b[38;5;28mstr\u001b[39m]:\n\u001b[0;32m 320\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 321\u001b[0m \u001b[38;5;124;03m Return any debug log data outputted by the transaction as strings suitable for printing\u001b[39;00m\n\u001b[0;32m 322\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 323\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;28mmap\u001b[39m(\u001b[38;5;28mstr\u001b[39m, ln)) \u001b[38;5;28;01mfor\u001b[39;00m ln \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug_logs_typed\u001b[49m]\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\transactions.py:218\u001b[0m, in \u001b[0;36mReceipt.debug_logs_typed\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 213\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 214\u001b[0m \u001b[38;5;124;03mExtract messages to console outputted by contracts via print() or console.log() statements\u001b[39;00m\n\u001b[0;32m 215\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 217\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 218\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall_tree\u001b[49m\n\u001b[0;32m 219\u001b[0m \u001b[38;5;66;03m# Some providers do not implement this, so skip\u001b[39;00m\n\u001b[0;32m 220\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m APINotImplementedError:\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\transactions.py:209\u001b[0m, in \u001b[0;36mReceipt.call_tree\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 207\u001b[0m \u001b[38;5;129m@cached_property\u001b[39m\n\u001b[0;32m 208\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcall_tree\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Optional[CallTreeNode]:\n\u001b[1;32m--> 209\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_call_tree\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1422\u001b[0m, in \u001b[0;36mEthereumNodeProvider.get_call_tree\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1419\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_parity_call_tree(txn_hash)\n\u001b[0;32m 1421\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcan_use_parity_traces \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m:\n\u001b[1;32m-> 1422\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_geth_call_tree\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1424\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merigon\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mclient_version\u001b[38;5;241m.\u001b[39mlower():\n\u001b[0;32m 1425\u001b[0m tree \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_parity_call_tree(txn_hash)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1454\u001b[0m, in \u001b[0;36mEthereumNodeProvider._get_geth_call_tree\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1453\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_geth_call_tree\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn_hash: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m CallTreeNode:\n\u001b[1;32m-> 1454\u001b[0m calls \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_transaction_trace_using_call_tracer\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1455\u001b[0m evm_call \u001b[38;5;241m=\u001b[39m get_calltree_from_geth_call_trace(calls)\n\u001b[0;32m 1456\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_call_tree_node(evm_call, txn_hash\u001b[38;5;241m=\u001b[39mtxn_hash)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1413\u001b[0m, in \u001b[0;36mEthereumNodeProvider._get_transaction_trace_using_call_tracer\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1412\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_transaction_trace_using_call_tracer\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn_hash: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Dict:\n\u001b[1;32m-> 1413\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_make_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1414\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdebug_traceTransaction\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43menableMemory\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtracer\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcallTracer\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m}\u001b[49m\u001b[43m]\u001b[49m\n\u001b[0;32m 1415\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1091\u001b[0m, in \u001b[0;36mWeb3Provider._make_request\u001b[1;34m(self, endpoint, parameters)\u001b[0m\n\u001b[0;32m 1086\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod not allowed\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mstr\u001b[39m(err)\u001b[38;5;241m.\u001b[39mlower():\n\u001b[0;32m 1087\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m APINotImplementedError(\n\u001b[0;32m 1088\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRPC method \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mendpoint\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m is not implemented by this node instance.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 1089\u001b[0m )\n\u001b[1;32m-> 1091\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ProviderError(\u001b[38;5;28mstr\u001b[39m(err)) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[0;32m 1093\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merror\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m result:\n\u001b[0;32m 1094\u001b[0m error \u001b[38;5;241m=\u001b[39m result[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merror\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n", + "\u001b[1;31mProviderError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI" + ] + } + ], + "source": [ + "with accounts.use_sender(\"giza1\"):\n", + " # print(f\"Minting {weth_mint_amount/10**weth_decimals} WETH\")\n", + " # weth.deposit(value=weth_mint_amount)\n", + " # print(\"Approving WETH for swap\")\n", + " weth.approve(swap_router.address, weth_mint_amount)\n", + " swap_params = {\n", + " \"tokenIn\": weth.address,\n", + " \"tokenOut\": wusdc.address,\n", + " \"fee\": pool_fee,\n", + " \"recipient\": wallet.address,\n", + " \"amountIn\": weth_mint_amount/2,\n", + " \"amountOutMinimum\": 0,\n", + " \"sqrtPriceLimitX96\": 0,\n", + " }\n", + " swap_params = tuple(swap_params.values())\n", + " print(\"Swapping WETH for USDC\")\n", + " amountOut = swap_router.exactInputSingle(swap_params)\n", + " print(f\"Successfully minted {uni_mint_amount/10**uni_decimals} USDC\")\n", + "\n", + "print(f\"Your WETH balance: {weth.balanceOf(wallet.address)/10**weth_decimals}\")\n", + "print(f\"Your WUSDC balance: {wusdc.balanceOf(wallet.address)/10**wusdc_decimals}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "c54659bc-405b-4561-9ac8-95ccada5f22f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3000" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pool_fee" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "7d509db2-0e1f-41ba-96d4-21ed7c39dde1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Swapping WETH for USDC\n", + "WARNING: Using cached key for giza1\n", + "INFO: Submitted https://sepolia.etherscan.io/tx/0xd48ce69b540e608adb89d75466d434e843fb93b2276c1cbcd6ff2c4b89839caf\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Confirmations (2/2): 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:29<00:00, 14.54s/it]\n" + ] + }, + { + "ename": "ProviderError", + "evalue": "400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:93\u001b[0m, in \u001b[0;36mAutoProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 92\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m---> 93\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_proxy_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:111\u001b[0m, in \u001b[0;36mAutoProvider._proxy_request\u001b[1;34m(self, method, params, use_cache)\u001b[0m\n\u001b[0;32m 106\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CannotHandleRequest(\n\u001b[0;32m 107\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCould not discover provider while making request: \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 108\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mparams:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparams\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 109\u001b[0m )\n\u001b[1;32m--> 111\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\rpc.py:90\u001b[0m, in \u001b[0;36mHTTPProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 89\u001b[0m request_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_rpc_request(method, params)\n\u001b[1;32m---> 90\u001b[0m raw_response \u001b[38;5;241m=\u001b[39m \u001b[43mmake_post_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mendpoint_uri\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrequest_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_request_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 92\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecode_rpc_response(raw_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\_utils\\request.py:115\u001b[0m, in \u001b[0;36mmake_post_request\u001b[1;34m(endpoint_uri, data, *args, **kwargs)\u001b[0m\n\u001b[0;32m 114\u001b[0m response \u001b[38;5;241m=\u001b[39m get_response_from_post_request(endpoint_uri, data\u001b[38;5;241m=\u001b[39mdata, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 115\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nDuring handling of the above exception, another exception occurred:\n", + "\u001b[1;31mHTTPError\u001b[0m Traceback (most recent call last)", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1084\u001b[0m, in \u001b[0;36mWeb3Provider._make_request\u001b[1;34m(self, endpoint, parameters)\u001b[0m\n\u001b[0;32m 1083\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1084\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mweb3\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mRPCEndpoint\u001b[49m\u001b[43m(\u001b[49m\u001b[43mendpoint\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1085\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m HTTPError \u001b[38;5;28;01mas\u001b[39;00m err:\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:95\u001b[0m, in \u001b[0;36mAutoProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 94\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mOSError\u001b[39;00m:\n\u001b[1;32m---> 95\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_proxy_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muse_cache\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\auto.py:111\u001b[0m, in \u001b[0;36mAutoProvider._proxy_request\u001b[1;34m(self, method, params, use_cache)\u001b[0m\n\u001b[0;32m 106\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m CannotHandleRequest(\n\u001b[0;32m 107\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCould not discover provider while making request: \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 108\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmethod\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mparams:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mparams\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 109\u001b[0m )\n\u001b[1;32m--> 111\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\providers\\rpc.py:90\u001b[0m, in \u001b[0;36mHTTPProvider.make_request\u001b[1;34m(self, method, params)\u001b[0m\n\u001b[0;32m 89\u001b[0m request_data \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mencode_rpc_request(method, params)\n\u001b[1;32m---> 90\u001b[0m raw_response \u001b[38;5;241m=\u001b[39m \u001b[43mmake_post_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mendpoint_uri\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrequest_data\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_request_kwargs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 92\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdecode_rpc_response(raw_response)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\web3\\_utils\\request.py:115\u001b[0m, in \u001b[0;36mmake_post_request\u001b[1;34m(endpoint_uri, data, *args, **kwargs)\u001b[0m\n\u001b[0;32m 114\u001b[0m response \u001b[38;5;241m=\u001b[39m get_response_from_post_request(endpoint_uri, data\u001b[38;5;241m=\u001b[39mdata, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m--> 115\u001b[0m \u001b[43mresponse\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_for_status\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 116\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\u001b[38;5;241m.\u001b[39mcontent\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\requests\\models.py:1024\u001b[0m, in \u001b[0;36mResponse.raise_for_status\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m http_error_msg:\n\u001b[1;32m-> 1024\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m HTTPError(http_error_msg, response\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m)\n", + "\u001b[1;31mHTTPError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[1;31mProviderError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[1;32mIn[20], line 17\u001b[0m\n\u001b[0;32m 15\u001b[0m swap_params \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mtuple\u001b[39m(swap_params\u001b[38;5;241m.\u001b[39mvalues())\n\u001b[0;32m 16\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSwapping WETH for USDC\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m---> 17\u001b[0m amountOut \u001b[38;5;241m=\u001b[39m \u001b[43mswap_router\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexactInputSingle\u001b[49m\u001b[43m(\u001b[49m\u001b[43mswap_params\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 18\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSuccessfully minted \u001b[39m\u001b[38;5;132;01m{\u001b[39;00muni_mint_amount\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m10\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39muni_decimals\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m USDC\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 20\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mYour WETH balance: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mweth\u001b[38;5;241m.\u001b[39mbalanceOf(wallet\u001b[38;5;241m.\u001b[39maddress)\u001b[38;5;241m/\u001b[39m\u001b[38;5;241m10\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mweth_decimals\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\contracts\\base.py:373\u001b[0m, in \u001b[0;36mContractTransactionHandler.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 370\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m kwargs \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maccount_manager\u001b[38;5;241m.\u001b[39mdefault_sender \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m 371\u001b[0m kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maccount_manager\u001b[38;5;241m.\u001b[39mdefault_sender\n\u001b[1;32m--> 373\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcontract_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\contracts\\base.py:307\u001b[0m, in \u001b[0;36mContractTransaction.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 304\u001b[0m private \u001b[38;5;241m=\u001b[39m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mprivate\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[0;32m 306\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m kwargs \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msender\u001b[39m\u001b[38;5;124m\"\u001b[39m], AccountAPI):\n\u001b[1;32m--> 307\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mkwargs\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43msender\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 309\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (\n\u001b[0;32m 310\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_private_transaction(txn)\n\u001b[0;32m 311\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m private\n\u001b[0;32m 312\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_transaction(txn)\n\u001b[0;32m 313\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\accounts.py:180\u001b[0m, in \u001b[0;36mAccountAPI.call\u001b[1;34m(self, txn, send_everything, private, **signer_options)\u001b[0m\n\u001b[0;32m 174\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m txn\u001b[38;5;241m.\u001b[39msender:\n\u001b[0;32m 175\u001b[0m txn\u001b[38;5;241m.\u001b[39msender \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maddress\n\u001b[0;32m 177\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (\n\u001b[0;32m 178\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprovider\u001b[38;5;241m.\u001b[39msend_private_transaction(signed_txn)\n\u001b[0;32m 179\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m private\n\u001b[1;32m--> 180\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msend_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[43msigned_txn\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 181\u001b[0m )\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:154\u001b[0m, in \u001b[0;36mWeb3Provider.__new__..post_tx_hook..send_tx_wrapper\u001b[1;34m(self, txn)\u001b[0m\n\u001b[0;32m 151\u001b[0m \u001b[38;5;129m@wraps\u001b[39m(send_tx)\n\u001b[0;32m 152\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21msend_tx_wrapper\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn: TransactionAPI) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m ReceiptAPI:\n\u001b[0;32m 153\u001b[0m receipt \u001b[38;5;241m=\u001b[39m send_tx(\u001b[38;5;28mself\u001b[39m, txn)\n\u001b[1;32m--> 154\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_post_send_transaction\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreceipt\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 155\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m receipt\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1026\u001b[0m, in \u001b[0;36mWeb3Provider._post_send_transaction\u001b[1;34m(self, tx, receipt)\u001b[0m\n\u001b[0;32m 1023\u001b[0m \u001b[38;5;66;03m# TODO: Optional configuration?\u001b[39;00m\n\u001b[0;32m 1024\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m tx\u001b[38;5;241m.\u001b[39mreceiver \u001b[38;5;129;01mand\u001b[39;00m Address(tx\u001b[38;5;241m.\u001b[39mreceiver)\u001b[38;5;241m.\u001b[39mis_contract:\n\u001b[0;32m 1025\u001b[0m \u001b[38;5;66;03m# Look for and print any contract logging\u001b[39;00m\n\u001b[1;32m-> 1026\u001b[0m \u001b[43mreceipt\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mshow_debug_logs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1028\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConfirmed \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mreceipt\u001b[38;5;241m.\u001b[39mtxn_hash\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m (total fees paid = \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mreceipt\u001b[38;5;241m.\u001b[39mtotal_fees_paid\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\transactions.py:329\u001b[0m, in \u001b[0;36mReceiptAPI.show_debug_logs\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 325\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mshow_debug_logs\u001b[39m(\u001b[38;5;28mself\u001b[39m):\n\u001b[0;32m 326\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 327\u001b[0m \u001b[38;5;124;03m Output debug logs to logging system\u001b[39;00m\n\u001b[0;32m 328\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 329\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m ln \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug_logs_lines\u001b[49m:\n\u001b[0;32m 330\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m[DEBUG-LOG] \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mln\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape\\api\\transactions.py:323\u001b[0m, in \u001b[0;36mReceiptAPI.debug_logs_lines\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 318\u001b[0m \u001b[38;5;129m@cached_property\u001b[39m\n\u001b[0;32m 319\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdebug_logs_lines\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m List[\u001b[38;5;28mstr\u001b[39m]:\n\u001b[0;32m 320\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 321\u001b[0m \u001b[38;5;124;03m Return any debug log data outputted by the transaction as strings suitable for printing\u001b[39;00m\n\u001b[0;32m 322\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m--> 323\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;28mmap\u001b[39m(\u001b[38;5;28mstr\u001b[39m, ln)) \u001b[38;5;28;01mfor\u001b[39;00m ln \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdebug_logs_typed\u001b[49m]\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\transactions.py:218\u001b[0m, in \u001b[0;36mReceipt.debug_logs_typed\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 213\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 214\u001b[0m \u001b[38;5;124;03mExtract messages to console outputted by contracts via print() or console.log() statements\u001b[39;00m\n\u001b[0;32m 215\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 217\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 218\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcall_tree\u001b[49m\n\u001b[0;32m 219\u001b[0m \u001b[38;5;66;03m# Some providers do not implement this, so skip\u001b[39;00m\n\u001b[0;32m 220\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m APINotImplementedError:\n", + "File \u001b[1;32m~\\AppData\\Local\\anaconda3\\envs\\giza3\\Lib\\functools.py:1001\u001b[0m, in \u001b[0;36mcached_property.__get__\u001b[1;34m(self, instance, owner)\u001b[0m\n\u001b[0;32m 999\u001b[0m val \u001b[38;5;241m=\u001b[39m cache\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname, _NOT_FOUND)\n\u001b[0;32m 1000\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m val \u001b[38;5;129;01mis\u001b[39;00m _NOT_FOUND:\n\u001b[1;32m-> 1001\u001b[0m val \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43minstance\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1002\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m 1003\u001b[0m cache[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mattrname] \u001b[38;5;241m=\u001b[39m val\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\transactions.py:209\u001b[0m, in \u001b[0;36mReceipt.call_tree\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 207\u001b[0m \u001b[38;5;129m@cached_property\u001b[39m\n\u001b[0;32m 208\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcall_tree\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Optional[CallTreeNode]:\n\u001b[1;32m--> 209\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mprovider\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_call_tree\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1422\u001b[0m, in \u001b[0;36mEthereumNodeProvider.get_call_tree\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1419\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_parity_call_tree(txn_hash)\n\u001b[0;32m 1421\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcan_use_parity_traces \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m:\n\u001b[1;32m-> 1422\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_geth_call_tree\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1424\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merigon\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mclient_version\u001b[38;5;241m.\u001b[39mlower():\n\u001b[0;32m 1425\u001b[0m tree \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_parity_call_tree(txn_hash)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1454\u001b[0m, in \u001b[0;36mEthereumNodeProvider._get_geth_call_tree\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1453\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_geth_call_tree\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn_hash: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m CallTreeNode:\n\u001b[1;32m-> 1454\u001b[0m calls \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_transaction_trace_using_call_tracer\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1455\u001b[0m evm_call \u001b[38;5;241m=\u001b[39m get_calltree_from_geth_call_trace(calls)\n\u001b[0;32m 1456\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_call_tree_node(evm_call, txn_hash\u001b[38;5;241m=\u001b[39mtxn_hash)\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1413\u001b[0m, in \u001b[0;36mEthereumNodeProvider._get_transaction_trace_using_call_tracer\u001b[1;34m(self, txn_hash)\u001b[0m\n\u001b[0;32m 1412\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_get_transaction_trace_using_call_tracer\u001b[39m(\u001b[38;5;28mself\u001b[39m, txn_hash: \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Dict:\n\u001b[1;32m-> 1413\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_make_request\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m 1414\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mdebug_traceTransaction\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mtxn_hash\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43menableMemory\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mtracer\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcallTracer\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m}\u001b[49m\u001b[43m]\u001b[49m\n\u001b[0;32m 1415\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\ape_ethereum\\provider.py:1091\u001b[0m, in \u001b[0;36mWeb3Provider._make_request\u001b[1;34m(self, endpoint, parameters)\u001b[0m\n\u001b[0;32m 1086\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmethod not allowed\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mstr\u001b[39m(err)\u001b[38;5;241m.\u001b[39mlower():\n\u001b[0;32m 1087\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m APINotImplementedError(\n\u001b[0;32m 1088\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRPC method \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mendpoint\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m is not implemented by this node instance.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 1089\u001b[0m )\n\u001b[1;32m-> 1091\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ProviderError(\u001b[38;5;28mstr\u001b[39m(err)) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[0;32m 1093\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merror\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;129;01min\u001b[39;00m result:\n\u001b[0;32m 1094\u001b[0m error \u001b[38;5;241m=\u001b[39m result[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124merror\u001b[39m\u001b[38;5;124m\"\u001b[39m]\n", + "\u001b[1;31mProviderError\u001b[0m: 400 Client Error: Bad Request for url: https://eth-sepolia.g.alchemy.com/v2/alcht_qTqyinch9eBi0vF09MR064gABbQbLI" + ] + } + ], + "source": [ + "with accounts.use_sender(\"giza1\"):\n", + " # print(f\"Minting {weth_mint_amount/10**weth_decimals} WETH\")\n", + " # weth.deposit(value=weth_mint_amount)\n", + " # print(\"Approving WETH for swap\")\n", + " # weth.approve(swap_router.address, weth_mint_amount)\n", + " swap_params = {\n", + " \"tokenIn\": weth.address,\n", + " \"tokenOut\": wusdc.address,\n", + " \"fee\": pool_fee,\n", + " \"recipient\": wallet.address,\n", + " \"amountIn\": weth_mint_amount,\n", + " \"amountOutMinimum\": 0,\n", + " \"sqrtPriceLimitX96\": 0,\n", + " }\n", + " swap_params = tuple(swap_params.values())\n", + " print(\"Swapping WETH for USDC\")\n", + " amountOut = swap_router.exactInputSingle(swap_params)\n", + " print(f\"Successfully minted {uni_mint_amount/10**uni_decimals} USDC\")\n", + "\n", + "print(f\"Your WETH balance: {weth.balanceOf(wallet.address)/10**weth_decimals}\")\n", + "print(f\"Your WUSDC balance: {wusdc.balanceOf(wallet.address)/10**wusdc_decimals}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "71dc1b7b-c35a-4c93-8441-fe9a541739ef", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "giza3", + "language": "python", + "name": "giza3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/get_tokens.py b/get_tokens.py new file mode 100644 index 0000000..62b00cf --- /dev/null +++ b/get_tokens.py @@ -0,0 +1,54 @@ +import os + +from ape import Contract, accounts, chain, networks +from dotenv import find_dotenv, load_dotenv + +from addresses import ADDRESSES + +load_dotenv(find_dotenv()) + +dev_passphrase = os.environ.get("DEV_PASSPHRASE") +sepolia_rpc_url = os.environ.get("SEPOLIA_RPC_URL") + +if __name__ == "__main__": + networks.parse_network_choice(f"ethereum:sepolia:{sepolia_rpc_url}").__enter__() + chain_id = chain.chain_id + weth_mint_amount = 0.01 + pool_fee = 3000 + uni = Contract(ADDRESSES["UNI"][chain_id]) + weth = Contract(ADDRESSES["WETH"][chain_id]) + wbtc = Contract(ADDRESSES["WBTC"][chain_id]) + weth_decimals = weth.decimals() + wbtc_decimals = wbtc.decimals() + uni_decimals = uni.decimals() + weth_mint_amount = int(weth_mint_amount * 10**weth_decimals) + uni_mint_amount = int(0.5 * weth_mint_amount) + wbtc_mint_amount = int(0.5 * weth_mint_amount) + + pool_factory = Contract(ADDRESSES["PoolFactory"][chain_id]) + pool_address = "0x287B0e934ed0439E2a7b1d5F0FC25eA2c24b64f7" + pool = Contract(pool_address) + swap_router = Contract(ADDRESSES["Router"][chain_id]) + wallet = accounts.load("dev") + wallet.set_autosign(True, passphrase=dev_passphrase) + with accounts.use_sender("dev"): + print(f"Minting {weth_mint_amount/10**weth_decimals} WETH") + weth.deposit(value=weth_mint_amount) + print("Approving WETH for swap") + weth.approve(swap_router.address, weth_mint_amount) + swap_params = { + "tokenIn": weth.address, + "tokenOut": uni.address, + "fee": pool_fee, + "recipient": wallet.address, + "amountIn": weth_mint_amount, + "amountOutMinimum": 0, + "sqrtPriceLimitX96": 0, + } + swap_params = tuple(swap_params.values()) + print("Swapping WETH for UNI") + amountOut = swap_router.exactInputSingle(swap_params) + print(f"Successfully minted {uni_mint_amount/10**uni_decimals} UNI") + + print(f"Your WETH balance: {weth.balanceOf(wallet.address)/10**weth_decimals}") + print(f"Your UNI balance: {uni.balanceOf(wallet.address)/10**uni_decimals}") \ No newline at end of file diff --git a/gizaAgentTest.ipynb b/gizaAgentTest.ipynb new file mode 100644 index 0000000..99d3a86 --- /dev/null +++ b/gizaAgentTest.ipynb @@ -0,0 +1,307 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "48530ee8-f107-4e80-a3e3-8bf326ec909a", + "metadata": {}, + "outputs": [], + "source": [ + "import argparse\n", + "import logging\n", + "import os\n", + "import pprint\n", + "from logging import getLogger" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "609cf662-423c-4769-a64d-fd3cfa4d3eb5", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "e4b7ff52-8e40-4354-bb37-8aca73b84a01", + "metadata": {}, + "outputs": [], + "source": [ + "from dotenv import find_dotenv, load_dotenv" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "15661fbb-fe0d-479b-b5ef-50b17991dbfb", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "C:\\Users\\chuck.raghavan\\AppData\\Roaming\\Python\\Python311\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + } + ], + "source": [ + "from giza.agents import AgentResult, GizaAgent\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "d56d3fc3-c801-4e4c-97bc-371da4aa5884", + "metadata": {}, + "outputs": [], + "source": [ + "from addresses import ADDRESSES" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "54bc08cb-6a45-4bea-8e01-72cd517c6353", + "metadata": {}, + "outputs": [], + "source": [ + "# from lp_tools import get_tick_range\n", + "# from uni_helpers import (approve_token, check_allowance, close_position,\n", + "# get_all_user_positions, get_mint_params)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "9ffff2fb-6391-4e4a-905e-0eb8401534b0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "load_dotenv(find_dotenv())\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "1ae54b10-d516-4cf5-8dd7-33d73735211f", + "metadata": {}, + "outputs": [], + "source": [ + "dev_passphrase = os.environ.get(\"DEV_PASSPHRASE\")\n", + "sepolia_rpc_url = os.environ.get(\"SEPOLIA_RPC_URL\")" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "fe79bc0f-f726-4951-8a4d-3c3040ee2f00", + "metadata": {}, + "outputs": [], + "source": [ + "logging.basicConfig(level=logging.INFO)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "05326b6e-7467-4f42-adae-25e7b8e39bf4", + "metadata": {}, + "outputs": [], + "source": [ + "def create_agent(\n", + " model_id: int, version_id: int, chain: str, contracts: dict, account: str\n", + "):\n", + " \"\"\"\n", + " Create a Giza agent for the volatility prediction model\n", + " \"\"\"\n", + " agent = GizaAgent(\n", + " contracts=contracts,\n", + " id=model_id,\n", + " version_id=version_id,\n", + " chain=chain,\n", + " account=account,\n", + " )\n", + " return agent" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "c2b4cc71-82fe-4ac7-8cb9-d07c98790846", + "metadata": {}, + "outputs": [], + "source": [ + "def predict(agent: GizaAgent, X: np.ndarray):\n", + " \"\"\"\n", + " Predict the next day volatility.\n", + "\n", + " Args:\n", + " X (np.ndarray): Input to the model.\n", + "\n", + " Returns:\n", + " int: Predicted value.\n", + " \"\"\"\n", + " prediction = agent.predict(input_feed={\"val\": X}, verifiable=True, job_size=\"XL\")\n", + " return prediction" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "2e157a36-ccb9-4209-af49-0503723414ff", + "metadata": {}, + "outputs": [], + "source": [ + "def get_pred_val(prediction: AgentResult):\n", + " \"\"\"\n", + " Get the value from the prediction.\n", + "\n", + " Args:\n", + " prediction (dict): Prediction from the model.\n", + "\n", + " Returns:\n", + " int: Predicted value.\n", + " \"\"\"\n", + " # This will block the executon until the prediction has generated the proof\n", + " # and the proof has been verified\n", + " return prediction.value[0][0]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6a81f969-55af-4a17-b0bc-f3155cf0cf4e", + "metadata": {}, + "outputs": [], + "source": [ + "def rebalance_lp(\n", + " tokenWETH_amount: int,\n", + " tokenUSDC_amount: int,\n", + " pred_model_id: int,\n", + " pred_version_id: int,\n", + " account=\"giza1\",\n", + " chain=f\"ethereum:sepolia:{sepolia_rpc_url}\",\n", + " nft_id=None,\n", + "):\n", + " logger = getLogger(\"agent_logger\")\n", + " networks.parse_network_choice(f\"ethereum:sepolia:{sepolia_rpc_url}\").__enter__()\n", + " chain_id = chain.chain_id\n", + " # weth_mint_amount = 0.01\n", + " weth_mint_amount = tokenWETH_amount\n", + " pool_fee = 3000\n", + " uni = Contract(ADDRESSES[\"UNI\"][chain_id])\n", + " weth = Contract(ADDRESSES[\"WETH\"][chain_id])\n", + " # wbtc = Contract(ADDRESSES[\"WETH\"][chain_id])\n", + " wusdc = Contract(ADDRESSES[\"USDC\"][chain_id])\n", + " # wbtc = Contract('0x66194f6c999b28965e0303a84cb8b797273b6b8b')\n", + " weth_decimals = weth.decimals()\n", + " # wbtc_decimals = wbtc.decimals()\n", + " uni_decimals = uni.decimals()\n", + " wusdc_decimals = wusdc.decimals()\n", + " weth_mint_amount = int(weth_mint_amount * 10**weth_decimals)\n", + " uni_mint_amount = int(0.5 * weth_mint_amount)\n", + " contracts = {\n", + " \"nft_manager\": nft_manager_address,\n", + " \"tokenA\": tokenA_address,\n", + " \"tokenB\": tokenB_address,\n", + " \"pool\": pool_address,\n", + " }\n", + "\n", + "\n", + "\n", + "\n", + " with accounts.use_sender(\"giza1\"):\n", + " # print(f\"Minting {weth_mint_amount/10**weth_decimals} WETH\")\n", + " # weth.deposit(value=weth_mint_amount)\n", + " # print(\"Approving WETH for swap\")\n", + " # weth.approve(swap_router.address, weth_mint_amount)\n", + " swap_params = {\n", + " \"tokenIn\": weth.address,\n", + " \"tokenOut\": wusdc.address,\n", + " \"fee\": pool_fee,\n", + " \"recipient\": wallet.address,\n", + " \"amountIn\": weth_mint_amount,\n", + " \"amountOutMinimum\": 0,\n", + " \"sqrtPriceLimitX96\": 0,\n", + " }\n", + " swap_params = tuple(swap_params.values())\n", + " print(\"Swapping WETH for USDC\")\n", + " amountOut = swap_router.exactInputSingle(swap_params)\n", + " print(f\"Successfully minted {uni_mint_amount/10**uni_decimals} USDC\")\n", + " \n", + " print(f\"Your WETH balance: {weth.balanceOf(wallet.address)/10**weth_decimals}\")\n", + " print(f\"Your WUSDC balance: {wusdc.balanceOf(wallet.address)/10**wusdc_decimals}\")\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "545a3bdb-21ee-4667-8b87-bd0a710d114e", + "metadata": {}, + "outputs": [], + "source": [ + "if __name__ == \"__main__\":\n", + " # Create the parser\n", + " # parser = argparse.ArgumentParser()\n", + "\n", + " # # Add arguments\n", + " # parser.add_argument(\"--model-id\", metavar=\"M\", type=int, help=\"model-id\")\n", + " # parser.add_argument(\"--version-id\", metavar=\"V\", type=int, help=\"version-id\")\n", + " # parser.add_argument(\"--tokenA-amount\", metavar=\"A\", type=int, help=\"tokenA-amount\")\n", + " # parser.add_argument(\"--tokenB-amount\", metavar=\"B\", type=int, help=\"tokenB-amount\")\n", + "\n", + " # # Parse arguments\n", + " # args = parser.parse_args()\n", + "\n", + " # for now we will just get it from .env\n", + " model_id = os.environ.get(\"MODEL_ID\")\n", + " version_id = os.environ.get(\"VERSION_ID\")\n", + " \n", + " MODEL_ID = model_id\n", + " VERSION_ID = version_id\n", + " tokenA_amount = args.tokenA_amount\n", + " tokenB_amount = args.tokenB_amount\n", + "\n", + " rebalance_lp(tokenA_amount, tokenB_amount, MODEL_ID, VERSION_ID)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "giza3", + "language": "python", + "name": "giza3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}