-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
86f493c
commit b87489e
Showing
43 changed files
with
3,383 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sun Apr 29 10:11:13 2024 | ||
""" | ||
|
||
from bs4 import BeautifulSoup as bsp | ||
from selenium import webdriver | ||
from selenium.webdriver.firefox.options import Options | ||
from webdriver_manager.firefox import GeckoDriverManager | ||
|
||
|
||
def tokenAbi(address, driver=None): | ||
try: | ||
filename = f'ABI_{address}.txt' | ||
with open(f"data/{filename}") as f: | ||
abi = f.readlines() | ||
return abi[0] | ||
except IOError: | ||
abi = findAbi(address, driver) | ||
return abi | ||
|
||
|
||
def findAbi(address, driver): | ||
url = f'https://bscscan.com/address/{address}#code' | ||
|
||
if not driver: | ||
options = Options() | ||
options.headless = True | ||
driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(), options=options) | ||
|
||
driver.get(url) | ||
page_soup = bsp(driver.page_source, features="lxml") | ||
abi = page_soup.find_all("pre", {"class": "wordwrap js-copytextarea2"}) | ||
|
||
with open(f'data/ABI_{address}.txt', 'w') as f: | ||
f.write(abi[0].text) | ||
|
||
driver.delete_all_cookies() | ||
driver.get("chrome://settings/clearBrowserData"); | ||
# driver.close() | ||
return abi[0].text |
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,37 @@ | ||
import config | ||
import time | ||
|
||
|
||
def buyTokens(**kwargs): | ||
symbol = kwargs.get('symbol') | ||
web3 = kwargs.get('web3') | ||
walletAddress = kwargs.get('walletAddress') | ||
contractPancake = kwargs.get('contractPancake') | ||
TokenToBuyAddress = kwargs.get('TokenToSellAddress') | ||
WBNB_Address = kwargs.get('WBNB_Address') | ||
|
||
toBuyBNBAmount = input(f"Enter amount of BNB you want to buy {symbol}: ") | ||
toBuyBNBAmount = web3.toWei(toBuyBNBAmount, 'ether') | ||
|
||
pancakeSwap_txn = contractPancake.functions.swapExactETHForTokens(0, | ||
[WBNB_Address, TokenToBuyAddress], | ||
walletAddress, | ||
(int(time.time() + 10000))).buildTransaction({ | ||
'from': walletAddress, | ||
'value': toBuyBNBAmount, # Amount of BNB | ||
'gas': 160000, | ||
'gasPrice': web3.toWei('5', 'gwei'), | ||
'nonce': web3.eth.get_transaction_count(walletAddress) | ||
}) | ||
|
||
signed_txn = web3.eth.account.sign_transaction(pancakeSwap_txn, private_key=config.YOUR_PRIVATE_KEY) | ||
try: | ||
tx_token = web3.eth.send_raw_transaction(signed_txn.rawTransaction) | ||
result = [web3.toHex(tx_token), f"Bought {web3.fromWei(toBuyBNBAmount, 'ether')} BNB of {symbol}"] | ||
return result | ||
except ValueError as e: | ||
if e.args[0].get('message') in 'intrinsic gas too low': | ||
result = ["Failed", f"ERROR: {e.args[0].get('message')}"] | ||
else: | ||
result = ["Failed", f"ERROR: {e.args[0].get('message')} : {e.args[0].get('code')}"] | ||
return result |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> | ||
<Profiles> | ||
<Profile Name="(Default)" /> | ||
</Profiles> | ||
<Settings /> | ||
</SettingsFile> |
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,117 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root> | ||
<!-- | ||
Microsoft ResX Schema | ||
Version 2.0 | ||
The primary goals of this format is to allow a simple XML format | ||
that is mostly human readable. The generation and parsing of the | ||
various data types are done through the TypeConverter classes | ||
associated with the data types. | ||
Example: | ||
... ado.net/XML headers & schema ... | ||
<resheader name="resmimetype">text/microsoft-resx</resheader> | ||
<resheader name="version">2.0</resheader> | ||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | ||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | ||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | ||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | ||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | ||
<value>[base64 mime encoded serialized .NET Framework object]</value> | ||
</data> | ||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | ||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | ||
<comment>This is a comment</comment> | ||
</data> | ||
There are any number of "resheader" rows that contain simple | ||
name/value pairs. | ||
Each data row contains a name, and value. The row also contains a | ||
type or mimetype. Type corresponds to a .NET class that support | ||
text/value conversion through the TypeConverter architecture. | ||
Classes that don't support this are serialized and stored with the | ||
mimetype set. | ||
The mimetype is used for serialized objects, and tells the | ||
ResXResourceReader how to depersist the object. This is currently not | ||
extensible. For a given mimetype the value must be set accordingly: | ||
Note - application/x-microsoft.net.object.binary.base64 is the format | ||
that the ResXResourceWriter will generate, however the reader can | ||
read any of the formats listed below. | ||
mimetype: application/x-microsoft.net.object.binary.base64 | ||
value : The object must be serialized with | ||
: System.Serialization.Formatters.Binary.BinaryFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.soap.base64 | ||
value : The object must be serialized with | ||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter | ||
: and then encoded with base64 encoding. | ||
mimetype: application/x-microsoft.net.object.bytearray.base64 | ||
value : The object must be serialized into a byte array | ||
: using a System.ComponentModel.TypeConverter | ||
: and then encoded with base64 encoding. | ||
--> | ||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | ||
<xsd:element name="root" msdata:IsDataSet="true"> | ||
<xsd:complexType> | ||
<xsd:choice maxOccurs="unbounded"> | ||
<xsd:element name="metadata"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
<xsd:attribute name="type" type="xsd:string" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="assembly"> | ||
<xsd:complexType> | ||
<xsd:attribute name="alias" type="xsd:string" /> | ||
<xsd:attribute name="name" type="xsd:string" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="data"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> | ||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | ||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
<xsd:element name="resheader"> | ||
<xsd:complexType> | ||
<xsd:sequence> | ||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | ||
</xsd:sequence> | ||
<xsd:attribute name="name" type="xsd:string" use="required" /> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:choice> | ||
</xsd:complexType> | ||
</xsd:element> | ||
</xsd:schema> | ||
<resheader name="resmimetype"> | ||
<value>text/microsoft-resx</value> | ||
</resheader> | ||
<resheader name="version"> | ||
<value>2.0</value> | ||
</resheader> | ||
<resheader name="reader"> | ||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
<resheader name="writer"> | ||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | ||
</resheader> | ||
</root> |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Общие сведения об этой сборке предоставляются следующим набором | ||
// набора атрибутов. Измените значения этих атрибутов для изменения сведений, | ||
// связанных со сборкой. | ||
[assembly: AssemblyTitle("defi")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("defi")] | ||
[assembly: AssemblyCopyright("Copyright © 2024")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми | ||
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через | ||
// COM, следует установить атрибут ComVisible в TRUE для этого типа. | ||
[assembly: ComVisible(false)] | ||
|
||
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM | ||
[assembly: Guid("34c069f1-8cd9-4612-8d59-159f5f52b847")] | ||
|
||
// Сведения о версии сборки состоят из указанных ниже четырех значений: | ||
// | ||
// Основной номер версии | ||
// Дополнительный номер версии | ||
// Номер сборки | ||
// Редакция | ||
// | ||
// Можно задать все значения или принять номера сборки и редакции по умолчанию | ||
// используя "*", как показано ниже: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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,9 @@ | ||
import random | ||
|
||
class MeanReversionStrategy: | ||
def __init__(self, settings): | ||
self.settings = settings | ||
|
||
def decide(self, pair, amount): | ||
# This is a very basic strategy that randomly decides to buy or sell | ||
return "buy" if random.random() < 0.5 else "sell" |
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,12 @@ | ||
import os | ||
|
||
YOUR_WALLET_ADDRESS = os.environ.get('WALLET_ADDRESS') # Add Your Wallet Address here by removing whole line | ||
YOUR_PRIVATE_KEY = os.environ.get('PRIVATE_KEY') # Add Your Private Key here by removing whole line | ||
|
||
TRADE_TOKEN_ADDRESS = None # Add token address here example : "0xc66c8b40e9712708d0b4f27c9775dc934b65f0d9" | ||
WBNB_ADDRESS = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" | ||
PANCAKE_ROUTER_ADDRESS = "0x10ED43C718714eb63d5aA57B78B54704E256024E" | ||
SHOW_TX_ON_BROWSER = True | ||
|
||
SELL_TOKENS = None | ||
BUY_TOKENS = None |
Oops, something went wrong.