doc.md
you need to use this with a coin that have no sell orders, or you can modify the code to not open a buy order if there is a sell for that price. maybe when the nightly merges someone will make a coin that no one can mine so you can use this script safely idk.
you need to use this with a coin that have no sell orders, or you can modify the code to not open a buy order if there is a sell for that price. maybe when the nightly merges someone will make a coin that no one can mine so you can use this script safely idk.
script.src
Bank = {}
Bank.unit_price = 5000
Bank.last_cut = Bank.unit_price / 2
// params: login_wallet() obj, coin_name with no buy order preferably
Bank.init = function(wallet, coin_name)
	self.wallet = wallet
	self.coin_name = coin_name
end function
Bank.get_balance = function()
	self.wallet.cancel_pending_trade(self.coin_name)
	output = self.wallet.buy_coin(self.coin_name, 1, self.unit_price)
	
	if self.was_transaction_approved(output) then
		self.wallet.cancel_pending_trade(self.coin_name)
		self.new_unit_price = ceil(self.unit_price + self.last_cut)
		if self.new_unit_price == self.unit_price then
			self.balance = self.unit_price
			return
		else
			self.unit_price = self.new_unit_price
		end if
	else
		self.unit_price = floor(self.unit_price - self.last_cut)
		self.last_cut = floor(self.last_cut / 2)
	end if
	self.get_balance()
end function
Bank.was_transaction_approved = function(output)
	if output.indexOf("Transaction is pending") then return true
	if output.indexOf("Insufficient money in the bank") then return false
	exit(output)
end function
Bank.init(login_wallet("user" , "pass"), "coin")
Bank.get_balance
print(Bank.balance))
Bank.get_balance
print(Bank.balance)