price_per_kbyte = 40 # in BTS broadcast = False if __name__ == '__main__': graphene = GrapheneAPI("localhost", 8092) obj = graphene.getObject("2.0.0") current_fees = obj["parameters"]["current_fees"]["parameters"] old_fees = obj["parameters"]["current_fees"] scale = obj["parameters"]["current_fees"]["scale"] / 1e4 # General change of parameter changes = {} for f in current_fees: if ("price_per_kbyte" in f[1]) and (f[1]["price_per_kbyte"] is 20): print("Changing operation %s[%d]" % (getOperationNameForId(f[0]), f[0])) changes[getOperationNameForId(f[0])] = f[1].copy() changes[getOperationNameForId(f[0])]["price_per_kbyte"] = int(price_per_kbyte / scale * 1e5) # overwrite / set specific fees # changes["transfer"]["price_per_kbyte"] = int( 20 / scale * 1e5) # changes["account_update"]["price_per_kbyte"] = int( 5 / scale * 1e5) print("=" * 80) tx = graphene.rpc.propose_fee_change(proposer, expiration, changes, broadcast) new_fees = tx["operations"][0][1]["proposed_ops"][0]["op"][1]["new_parameters"]["current_fees"] print(json.dumps(DeepDiff(old_fees, new_fees), indent=4)) if not broadcast: print("=" * 80)
wallet_port = 8092 if __name__ == '__main__': rpc = GrapheneAPI("localhost", 8092) obj = rpc.get_object("2.0.0") current_fees = obj["parameters"]["current_fees"]["parameters"] old_fees = obj["parameters"]["current_fees"] scale = obj["parameters"]["current_fees"]["scale"] / 1e4 # General change of parameter changes = {} for f in current_fees: if ("price_per_kbyte" in f[1] and f[1]["price_per_kbyte"] != 0): print("Changing operation %s[%d]" % (getOperationNameForId(f[0]), f[0])) changes[getOperationNameForId(f[0])] = f[1].copy() changes[getOperationNameForId(f[0])]["price_per_kbyte"] = int( price_per_kbyte / scale * 1e5) if ("fee" in f[1] and f[1]["fee"] != 0): print("Changing operation %s[%d]" % (getOperationNameForId(f[0]), f[0])) changes[getOperationNameForId(f[0])] = f[1].copy() changes[getOperationNameForId(f[0])]["fee"] = int( everythin_flat_fee / scale * 1e5) # overwrite / set specific fees changes["transfer"]["price_per_kbyte"] = int(0) # changes["account_update"]["price_per_kbyte"] = int( 5 / scale * 1e5) print("=" * 80)
from grapheneexchange import GrapheneExchange from graphenebase.transactions import getOperationNameForId import json import config if __name__ == '__main__': dex = GrapheneExchange(config, safe_mode=False) graphene = dex.rpc # Get current fees obj = graphene.get_object("2.0.0")[0] fees = obj["parameters"]["current_fees"]["parameters"] scale = int(obj["parameters"]["current_fees"]["scale"]) / 1e4 core_asset = graphene.get_asset("1.3.0") # Get ticker/current price ticker = dex.returnTicker()[config.watch_markets[0]] core_exchange_rate = ticker["core_exchange_rate"] settlement_price = ticker["settlement_price"] fee_named = {} for f in fees: opName = getOperationNameForId(f[0]) fee_named[opName] = {} # derive in USD for o in f[1]: fee_named[opName][o] = int(f[1][o]) / 10 ** core_asset["precision"] * scale / core_exchange_rate print(json.dumps(fee_named, indent=4))
for op in prop_op : if op[0] == 31: fees = op[1]["new_parameters"]["current_fees"]["parameters"] scale = int(op[1]["new_parameters"]["current_fees"]["scale"]) / 1e4 # Get ticker/current price ticker = dex.returnTicker()[config.watch_markets[0]] core_exchange_rate = ticker["core_exchange_rate"] settlement_price = ticker["settlement_price"] fee_named = {} for f in fees: opName = getOperationNameForId(f[0]) fee_named[opName] = f[1].copy() for o in f[1]: if opName in config.native_fees : if config.force_integer_core_fee : fee_named[opName][o] = int(int(f[1][o]) / 10 ** core_asset["precision"]) * scale / core_exchange_rate else: fee_named[opName][o] = int(f[1][o]) / 10 ** core_asset["precision"] * scale / core_exchange_rate core_fee_ist = int(f[1][o]) / 10 ** core_asset["precision"] * scale core_fee_soll = config.native_fees[opName][o] * core_exchange_rate / scale if config.native_fees[opName][o] != 0.0: scalingfactor = (config.native_fees[opName][o] / fee_named[opName][o]) if fee_named[opName][o] else 999 if math.fabs(1 - scalingfactor) > config.tolerance_percentage / 100: print("%23s price for %41s differs by %8.3fx (proposal: %9.4f USD (%12.4f BTS) / target: %9.4f USD (%12.1f BTS))" %
class Wallet(): wallet_host = "localhost" wallet_port = 8092 if __name__ == '__main__': graphene = GrapheneClient(Wallet) obj = graphene.getObject("2.0.0") current_fees = obj["parameters"]["current_fees"]["parameters"] old_fees = obj["parameters"]["current_fees"] scale = obj["parameters"]["current_fees"]["scale"] / 1e4 # General change of parameter changes = {} for f in current_fees : if ("price_per_kbyte" in f[1]) and (f[1]["price_per_kbyte"] is 20): print("Changing operation %s[%d]" % (getOperationNameForId(f[0]), f[0])) changes[getOperationNameForId(f[0])] = f[1].copy() changes[getOperationNameForId(f[0])]["price_per_kbyte"] = int(price_per_kbyte / scale * 1e5) # overwrite / set specific fees # changes["transfer"]["price_per_kbyte"] = int( 20 / scale * 1e5) # changes["account_update"]["price_per_kbyte"] = int( 5 / scale * 1e5) print("=" * 80) tx = graphene.rpc.propose_fee_change(proposer, expiration, changes, broadcast) new_fees = tx["operations"][0][1]["proposed_ops"][0]["op"][1]["new_parameters"]["current_fees"] print(json.dumps(DeepDiff(old_fees, new_fees), indent=4)) if not broadcast: print("=" * 80)