Last active
August 18, 2019 04:11
-
-
Save dsetzer/e44c35a9a4b6767f7d85f04a3f3a185d to your computer and use it in GitHub Desktop.
bustadice fastbet chase script
This file contains hidden or 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
/******** SETTINGS ********/ | |
const BASE_WAGER = 50; // Initial lowest possible bet to start with. (Satoshis) | |
const BASE_TARGET = 200.00; // Target payout to chase for. (Actual payout format 2.00x = 2.00) | |
const AUTO_MULTIPLE = false; // Auto calculate and override BET_MULTIPLE for BASE_TARGET. | |
const BET_MULTIPLE = 1.005; // Multiply bet by this value (1 = no increase) after each loss. | |
const BET_INCREASE = 0; // Increase bet by this flat amount after each loss. (Satoshis) | |
const MAX_WAGER = 500 // Prevents script from placing bets larger than this amount.(Bits) | |
const STOP_ON_MAX = true; // Stop The script when MAX_WAGER is reached. | |
const RESET_ON_MAX = false; // Returns to base bet when MAX_WAGER is reached, | |
const STOP_ON_HIT = false; // Stop the script after hitting target payout. | |
const RESET_ON_HIT = true; // Returns to base bet after hitting target payout. | |
const STOP_PROFIT = 30000; // Stop the script when profits reach this amount. (Bits) or -1 to disable. | |
const STOP_BALANCE = 10000; // Stop if next bet would reduce balance below this amount. (Bits) or -1 to disable. | |
/****** ADV SETTINGS ******/ | |
const DEBUG_LOGS = true; | |
const DEBUG_MODE = false; | |
const QUEUE_SIZE = 100; // Adjusts bet concurrency. Keep it below 200. Don't be a hero.. | |
/**************************/ | |
let betCount = 0; | |
let totalOut = 0; | |
let totalIn = 0; | |
let ourProfits = 0; | |
const queue = new Array(QUEUE_SIZE); | |
let running = true; | |
const cl = console.log | |
console.log = (...args) => { if (DEBUG_LOGS) cl.apply(this, args) } | |
const getMultiple = function(target) { | |
((`${target}`).includes('.') || target < 100) ? target = Math.round(target * 100): null; | |
const d = (`${target}`).length - 1; | |
return (((Math.ceil((1 / (1 - (Math.ceil(((100 / 101) * (99 / (((target * 1) / 100) * 100 - 1))) * (Math.pow(10, d)))) / (Math.pow(10, d)))) * (Math.pow(100, (d - 1)))) / (Math.pow(100, (d - 1)))).toFixed(d)) / 1) | |
} | |
const betMultiple = AUTO_MULTIPLE ? getMultiple(`${BASE_TARGET*100}`) : BET_MULTIPLE; | |
console.log(`Bet multiple for ${BASE_TARGET}x is ${betMultiple} * wager on loss.`) | |
const getWager = function(totalOut) { | |
const wager = Math.round(((BASE_WAGER * Math.pow(betMultiple, totalOut)) + (BET_INCREASE * totalOut)) / 100) * 100; | |
if (wager >= MAX_WAGER){ | |
if(STOP_ON_MAX){ | |
console.log(`Stopping due to MAX_WAGER exceeded! (${wager / 100} bits)`) | |
running = false; | |
}else if(RESET_ON_MAX){ | |
totalOut = 0; | |
} | |
} | |
return ({ value: wager, target: BASE_TARGET }); | |
} | |
const roundBit = function(bet){ | |
return Math.max(100, Math.round(bet / 100) * 100); | |
} | |
const doResult = async function(context, result) { | |
totalIn++; | |
if (!DEBUG_MODE) { | |
if (result.multiplier < result.target) { | |
ourProfits -= result.value; | |
} else { | |
ourProfits += (result.value * result.target) - result.value | |
console.log(`Won. Profits at ${ourProfits/100}, next bet ${result.value/100} bits @ ${result.target}x`); | |
if (STOP_ON_HIT) { | |
console.log(`Stopping after hitting target`) | |
running = false; | |
} else if (STOP_PROFIT > 0 && (ourProfits / 100) >= STOP_PROFIT) { | |
console.log(`Stopping after reaching ${ourProfits / 100} bits profits`) | |
running = false; | |
} | |
if (RESET_ON_HIT) { | |
totalOut = 0; | |
} | |
} | |
console.log(`Current Chase Bets IN/OUT ${totalIn}/${totalOut} | Total Bets ${betCount}`); | |
} | |
} | |
const main = async function(context){ | |
const startTime = Date.now(); | |
while (running) { | |
const cycleStart = Date.now(); | |
let bet = null | |
let bal = context.balance; | |
for (let i = 0; i < QUEUE_SIZE; i++) { | |
bet = getWager(totalOut); | |
bal -= bet.value; | |
if(STOP_BALANCE > 0 && (bal / 100) < STOP_BALANCE){ | |
running = false; | |
console.log(`Stopping before STOP_BALANCE with ${bet.value / 100} bits wager!`); | |
break; | |
} | |
queue[i] = (DEBUG_MODE ? context.skip() : context.bet(roundBit(bet.value), bet.target)); | |
betCount++; | |
totalOut++; | |
console.log(`Inserted bet into queue slot [${bet.value/100}bits @ ${bet.target}x] Bet ID ${totalOut}`); | |
} | |
if(running){ | |
await Promise.all(queue.map(p => p.catch(e => e))).then(async (results) => { await results.forEach(result => doResult(context, result)) }); | |
await sleep(QUEUE_SIZE * 2); | |
} | |
const cycleEnd = Date.now(); | |
console.log(`Cycle efficiency at ${(QUEUE_SIZE / (cycleEnd - cycleStart)) * 1000} bets per second.`) | |
} | |
const endTime = Date.now(); | |
console.log(`Total script runtime ${(endTime - startTime) / 60000} minutes.`) | |
} | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
await main(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment