Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
bot = SimpleBot()
bot.read_config("config.cfg")
pw.setNode(node=bot.node, chain=bot.chain)
pw.setMatcher(node=bot.matcher)
my_address = pw.Address(privateKey=bot.private_key)
waves_btc = pw.AssetPair(bot.amount_asset, bot.price_asset)
while True:
waves_balance = my_address.balance()
bot.log("Your balance is %18d" % waves_balance)
btc_balance = my_address.balance(bot.price_asset_id)
bot.log("Your balance is %18d" % btc_balance)
my_address.cancelOpenOrders(waves_btc)
order_book = waves_btc.orderbook()
best_bid = order_book["bids"][0]["price"]
best_ask = order_book["asks"][0]["price"]
spread_mean_price = ((best_bid + best_ask) // 2) * 10 ** (bot.price_asset.decimals - bot.amount_asset.decimals)
bid_price = spread_mean_price * (1 - bot.price_step)
ask_price = spread_mean_price * (1 + bot.price_step)
bid_amount = int((btc_balance / bid_price) * 10 ** pw.WAVES.decimals) - bot.order_fee
ORDER_LIFETIME = config.getint('main', 'order_lifetime')
PRIVATE_KEY = config.get('account', 'private_key')
amountAssetID = config.get('market', 'amount_asset')
priceAssetID = config.get('market', 'price_asset')
INTERVAL = config.getfloat('grid', 'interval')
TRANCHE_SIZE = config.getint('grid', 'tranche_size')
FLEXIBILITY = config.getint('grid', 'flexibility')
GRID_LEVELS = config.getint('grid', 'grid_levels')
GRID_BASE = config.get('grid', 'base').upper()
GRID_TYPE = config.get('grid', 'type').upper()
LOGFILE = config.get('logging', 'logfile')
BLACKBOT = pw.Address(privateKey=PRIVATE_KEY)
log("-" * 80)
log(" Address : %s" % BLACKBOT.address)
log(" Amount Asset ID : %s" % amountAssetID)
log(" Price Asset ID : %s" % priceAssetID)
log("-" * 80)
log("")
except:
log("Error reading config file")
log("Exiting.")
exit(1)
pw.setNode(NODE, "mainnet")
pw.setMatcher(MATCHER)
PAIR = pw.AssetPair(pw.Asset(amountAssetID), pw.Asset(priceAssetID))
# tx amount asset decimals
binary_data += chr(8)
# fee amount asset decimals
binary_data += chr(8)
# Tx info
#
# amount: 1
# asset: 9gqcTyupiDWuogWhKv8G3EMwjMaobkw9Lpys4EY2F62t
# from: 3PDCeakWckRvK5vVeJnCy1R2rE1utBcJMwt
# to: 3PMpANFyKGBwzvv1UVk2KdN23fJZ8sXSVEK
# attachment: privet
# fee: 0.001
# fee asset: WAVES
some_transfer_bytes = build_transfer_bytes('4ovEU8YpbHTurwzw8CDZaCD7m6LpyMTC4nrJcgDHb4Jh',
pw.Address('3PMpANFyKGBwzvv1UVk2KdN23fJZ8sXSVEK'),
pw.Asset('9gqcTyupiDWuogWhKv8G3EMwjMaobkw9Lpys4EY2F62t'), 1,
'privet', timestamp = 1526477921829)
input = raw_input(colors.fg.lightblue + "Please input message to sign (for example \"" + base58.b58encode(
str(some_transfer_bytes)) + "\")> " + colors.reset)
if len(input) == 0:
binary_data += some_transfer_bytes
print(colors.fg.lightgrey + "tx bytes: " + base58.b58encode(str(some_transfer_bytes)))
else:
binary_data += base58.b58decode(input)
print(colors.fg.lightgrey + "tx bytes: " + base58.b58encode(str(input)))
signature = None
while (True):
try:
offset = 0
while offset != len(binary_data):
if (len(binary_data) - offset) > CHUNK_SIZE:
def gateway_pywaves_address(gateway_waves_address_secret: model.KeyPair, waves_node: str, waves_chain: str, waves_chain_id: Optional[str] = None):
"""Creates an address instance from the pywaves library that represents the Gateway waves address."""
pywaves.setNode(waves_node, waves_chain, waves_chain_id)
address = pywaves.Address(privateKey=gateway_waves_address_secret.secret)
if address.address != gateway_waves_address_secret.public:
raise ValueError("Gateway account private key doesn't match the address provided")
return address
ONLY_ONE_TRANSACTION_RECEIVER = InjectionToken('ONLY_ONE_TRANSACTION_RECEIVER', bool)
COIN_TRANSACTION_WEB_LINK = InjectionToken('COIN_TRANSACTION_WEB_LINK', str)
WAVES_TRANSACTION_WEB_LINK = InjectionToken('WAVES_TRANSACTION_WEB_LINK', str)
COIN_ADDRESS_WEB_LINK = InjectionToken('COIN_ADDRESS_WEB_LINK', str)
WAVES_ADDRESS_WEB_LINK = InjectionToken('WAVES_ADDRESS_WEB_LINK', str)
ATTEMPT_LIST_MAX_COMPLETION_TRIES = InjectionToken('ATTEMPT_LIST_MAX_COMPLETION_TRIES', int)
GATEWAY_WAVES_ADDRESS_SECRET = InjectionToken('GATEWAY_WAVES_ADDRESS_SECRET', KeyPair)
GATEWAY_WAVES_ADDRESS = InjectionToken('GATEWAY_WAVES_ADDRESS', str)
NUM_ATTEMPT_LIST_WORKERS = InjectionToken('NUM_ATTEMPT_LIST_WORKERS', int)
GATEWAY_HOST = InjectionToken('GATEWAY_HOST', str)
GATEWAY_PORT = InjectionToken('GATEWAY_PORT', int)
WALLET_STORAGE_COLLECTION = InjectionToken('WALLET_STORAGE_COLLECTION', Collection)
MAP_STORAGE_COLLECTION = InjectionToken('MAP_STORAGE_COLLECTION', Collection)
KEY_VALUE_STORAGE_COLLECTION = InjectionToken('KEY_VALUE_STORAGE_COLLECTION', Collection)
TRANSACTION_ATTEMPT_LIST_STORAGE_COLLECTION = InjectionToken('TRANSACTION_ATTEMPT_LIST_STORAGE_COLLECTION', Collection)
GATEWAY_PYWAVES_ADDRESS = InjectionToken('GATEWAY_PYWAVES_ADDRESS', pywaves.Address)
COIN_CHAIN_QUERY_SERVICE_CONVERTER_PROXY = InjectionToken('COIN_CHAIN_QUERY_SERVICE_CONVERTER_PROXY')
WAVES_CHAIN_QUERY_SERVICE_CONVERTER_PROXY = InjectionToken('WAVES_CHAIN_QUERY_SERVICE_CONVERTER_PROXY')
FLASK_NAME = InjectionToken('FLASK_NAME', str)
COIN_MAX_HANDLE_TRANSACTION_TRIES = InjectionToken('COIN_MAX_HANDLE_TRANSACTION_TRIES', int)
WAVES_MAX_HANDLE_TRANSACTION_TRIES = InjectionToken('WAVES_MAX_HANDLE_TRANSACTION_TRIES', int)
WAVES_LAST_BLOCK_DISTANCE = InjectionToken('WAVES_LAST_BLOCK_DISTANCE', int)
COIN_LAST_BLOCK_DISTANCE = InjectionToken('COIN_LAST_BLOCK_DISTANCE', int)
WEB_PRIMARY_COLOR = InjectionToken('WEB_PRIMARY_COLOR', str)
WAVES_CHAIN_ID = InjectionToken('WAVES_CHAIN_ID', str)