Skip to content

Commit

Permalink
Added WagyuSwap on VELAS chain
Browse files Browse the repository at this point in the history
  • Loading branch information
tsarbuig committed Apr 5, 2022
1 parent f0619ab commit fdfb69b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
20 changes: 18 additions & 2 deletions LimitSwap.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def printt_sell_price(token_dict, token_price, precision):

# Token Pair
if token_dict['USECUSTOMBASEPAIR'] == 'false':
price_message = f'{token_dict["_PAIR_SYMBOL"]} = {token_price:.{precision}f}'
price_message = f'{token_dict["_PAIR_SYMBOL"]} = {token_price:.{precision}f} {base_symbol}'
else:
price_message = f'{token_dict["_PAIR_SYMBOL"]} = {token_price:.{precision}f} {token_dict["BASESYMBOL"]}'

Expand Down Expand Up @@ -2785,6 +2785,22 @@ def calculate_base_price():
basePrice = Decimal((reserves[0] / DECIMALS_STABLES) / (reserves[1] / DECIMALS_ETH))
printt_debug("ADA PRICE: ", "{:.6f}".format(basePrice))

elif base_symbol == "VLX ":
DECIMALS_STABLES = 1000000000000000000
DECIMALS_ETH = 1000000000000000000

# USDC 0x0039f574ee5cc39bdd162e9a88e3eb1f111baf48

# address = Web3.toChecksumAddress('0x0039f574ee5cc39bdd162e9a88e3eb1f111baf48')
# pair_address = fetch_pair2(address, weth, factoryContract)

pair_address = '0x8e2B762Bee3E2bf2C8fB0cdd04274042748D6C23'

pair_contract = client.eth.contract(address=pair_address, abi=lpAbi)
reserves = pair_contract.functions.getReserves().call()
basePrice = Decimal((reserves[0] / DECIMALS_STABLES) / (reserves[1] / DECIMALS_ETH))
printt_debug("VLX PRICE: ", "{:.6f}".format(basePrice))

else:
printt_err("Unknown chain... please add it to calculate_base_price")
basePrice = 0
Expand Down Expand Up @@ -2841,7 +2857,7 @@ def calculate_base_balance(token):
elif base_symbol == "AVAX":
minimumbalance = 0.2
else:
minimumbalance = 0.03
minimumbalance = 0

try:
eth_balance = Web3.fromWei(client.eth.getBalance(settings['WALLETADDRESS']), 'ether')
Expand Down
37 changes: 37 additions & 0 deletions exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,43 @@ def getRouters(settings, Web3):
settings['_STABLE_BASES'] = {'USDC': {'address': '0x04068da6c83afcfa0e13ba15a6696662335d5b75', 'multiplier': 0},
'USDT': {'address': '0x049d68029688eabf473097a2fc38ef61633a3c7a', 'multiplier': 0}}

elif settings["EXCHANGE"] == 'wagyuswap':
if settings['USECUSTOMNODE'] == 'true':
my_provider = settings['CUSTOMNODE']
else:
my_provider = "https://evmexplorer.velas.com/rpc"

if not my_provider:
print(datetime.now().strftime('%m-%d %H:%M:%S.%f'), 'Custom node empty. Exiting')
exit(1)

if my_provider[0].lower() == 'h':
print(datetime.now().strftime('%m-%d %H:%M:%S.%f'), 'Using HTTPProvider')
client = Web3(Web3.HTTPProvider(my_provider))
elif my_provider[0].lower() == 'w':
print(datetime.now().strftime('%m-%d %H:%M:%S.%f'), 'Using WebsocketProvider')
client = Web3(Web3.WebsocketProvider(my_provider))
else:
print(datetime.now().strftime('%m-%d %H:%M:%S.%f'), 'Using IPCProvider')
client = Web3(Web3.IPCProvider(my_provider))

print(datetime.now().strftime('%m-%d %H:%M:%S.%f'), "VELAS Chain Connected =", client.isConnected())
print(datetime.now().strftime('%m-%d %H:%M:%S.%f'), "Loading Smart Contracts...")
routerAddress = Web3.toChecksumAddress("0x3D1c58B6d4501E34DF37Cf0f664A58059a188F00")
factoryAddress = Web3.toChecksumAddress("0x69f3212344A38b35844cCe4864C2af9c717F35e3")
routerContract = client.eth.contract(address=routerAddress, abi=routerAbi)
factoryContract = client.eth.contract(address=factoryAddress, abi=factoryAbi)
weth = Web3.toChecksumAddress("0xc579D1f3CF86749E05CD06f7ADe17856c2CE3126")
base_symbol = "VLX "
rugdocchain = '&chain=vlx'
modified = False
swapper_address = Web3.toChecksumAddress("0x000000000000000000000000000000000000dEaD")
swapper = client.eth.contract(address=swapper_address, abi=swapperAbi)

settings['_EXCHANGE_BASE_SYMBOL'] = 'VLX '
settings['_STABLE_BASES'] = {'BUSD': {'address': '0xc111c29A988AE0C0087D97b33C6E6766808A3BD3', 'multiplier': 0},
'USDT': {'address': '0x01445C31581c354b7338AC35693AB2001B50b9aE', 'multiplier': 0}}

elif settings["EXCHANGE"] == 'sushiswapftm':
if settings['USECUSTOMNODE'] == 'true':
my_provider = settings['CUSTOMNODE']
Expand Down

0 comments on commit fdfb69b

Please sign in to comment.