-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Custom | ||
*logs/ | ||
*scripts/dev.ipynb | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"from dotenv import load_dotenv\n", | ||
"from itertools import permutations\n", | ||
"import requests as req\n", | ||
"\n", | ||
"import sys\n", | ||
"\n", | ||
"sys.path.insert(0, \"../\")\n", | ||
"from src.logging import get_logger\n", | ||
"from src.network.oneinch import OneInchQuotes\n", | ||
"from src.configs import TOKEN_DTOs\n", | ||
"\n", | ||
"logger = get_logger(__name__)\n", | ||
"\n", | ||
"load_dotenv()\n", | ||
"INCH_API_KEY = os.getenv(\"1INCH_API_KEY\")\n", | ||
"assert INCH_API_KEY, \"Missing API Key in .env\"\n", | ||
"\n", | ||
"quoter = OneInchQuotes(INCH_API_KEY, TOKEN_DTOs, calls=20)\n", | ||
"tokens = list(TOKEN_DTOs.keys())\n", | ||
"# payload = quoter.all_quotes(tokens)\n", | ||
"# df = quoter.to_df(payload)\n", | ||
"# dh = DataHandler()\n", | ||
"# logger.info(\"Inserting...\")\n", | ||
"# dh.insert_quotes(df)\n", | ||
"pairs = list(permutations(tokens, 2))\n", | ||
"pair = pairs[0]\n", | ||
"calls = 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"quotes = quoter.quotes_for_pair(pair, calls=calls)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"in_token, out_token = pair\n", | ||
"in_amount = 1e18\n", | ||
"params = {\n", | ||
" \"src\": in_token,\n", | ||
" \"dst\": out_token,\n", | ||
" \"amount\": str(in_amount),\n", | ||
" \"includeGas\": True,\n", | ||
" \"includeTokensInfo\": True,\n", | ||
" \"includeProtocols\": True,\n", | ||
"}\n", | ||
"res = req.get(quoter.quote_url, params=params, headers=quoter.header)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"{'_content': b'',\n", | ||
" '_content_consumed': True,\n", | ||
" '_next': None,\n", | ||
" 'status_code': 429,\n", | ||
" 'headers': {'Date': 'Wed, 27 Dec 2023 16:45:23 GMT', 'Content-Length': '0', 'Connection': 'keep-alive', 'x-envoy-upstream-service-time': '1', 'CF-Cache-Status': 'DYNAMIC', 'Set-Cookie': '__cf_bm=nst4HJMsliPBaeOoWX0409tiJWUNlgjQ8IIST56DRZo-1703695523-1-AWEPmPSW7WTtTnfQkkO8mNVq4zSnpgC6XYVtW32LmXF3FgBe7olsGYaVyrIDfSZpNR/hmCWc0HhqgvtGYWHgXdM=; path=/; expires=Wed, 27-Dec-23 17:15:23 GMT; domain=.1inch.dev; HttpOnly; Secure; SameSite=None', 'Server': 'cloudflare', 'CF-RAY': '83c3089a6a0d0f75-EWR'},\n", | ||
" 'raw': <urllib3.response.HTTPResponse at 0x7f6b816b6c50>,\n", | ||
" 'url': 'https://api.1inch.dev/swap/v5.2/1/quote?src=0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48&dst=0xdac17f958d2ee523a2206206994597c13d831ec7&amount=1e%2B18&includeGas=True&includeTokensInfo=True&includeProtocols=True',\n", | ||
" 'encoding': None,\n", | ||
" 'history': [],\n", | ||
" 'reason': 'Too Many Requests',\n", | ||
" 'cookies': <RequestsCookieJar[Cookie(version=0, name='__cf_bm', value='nst4HJMsliPBaeOoWX0409tiJWUNlgjQ8IIST56DRZo-1703695523-1-AWEPmPSW7WTtTnfQkkO8mNVq4zSnpgC6XYVtW32LmXF3FgBe7olsGYaVyrIDfSZpNR/hmCWc0HhqgvtGYWHgXdM=', port=None, port_specified=False, domain='.1inch.dev', domain_specified=True, domain_initial_dot=True, path='/', path_specified=True, secure=True, expires=1703697323, discard=False, comment=None, comment_url=None, rest={'HttpOnly': None, 'SameSite': 'None'}, rfc2109=False)]>,\n", | ||
" 'elapsed': datetime.timedelta(microseconds=130544),\n", | ||
" 'request': <PreparedRequest [GET]>,\n", | ||
" 'connection': <requests.adapters.HTTPAdapter at 0x7f6b814f69d0>}" | ||
] | ||
}, | ||
"execution_count": 13, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"res.__dict__" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "venv", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters