Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bustadice fastbet chase script
/******** SETTINGS ********/
const BASE_WAGER = 100; // Initial lowest possible bet to start with. (Satoshis)
const BASE_TARGET = 200; // 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.1; // Increase bet by this flat amount after each loss. (Satoshis)
const TAR_MULTIPLE = 1; // Multiply target by this value (1 = no increase) on each loss.
const TAR_INCREASE = 0; // Increase target by this flat amount after each loss.
const MAX_WAGER = 5000 // 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 = true; // Returns to BASE_BET when MAX_WAGER is reached,
const MAX_TARGET = 300; // Prevents the script from betting past this target payout.
const STOP_MAX_TARG = true; // Stop the script when MAX_TARGET is reached.
const RESET_MAX_TARG = true; // Returns to BASE_TARGET when MAX_TARGET 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_TRAIL = 8000 // Stop if current streak losses exceed this amount (Bits) or -1 to disable.
const STOP_PROFIT = 30000; // Stop the script when profits reach this amount. (Bits) or -1 to disable.
const STOP_BALANCE = 5000; // Stop if next bet would reduce balance below this amount. (Bits) or -1 to disable.
const QUEUE_MODE = 0; // Sets queue mode ( 0 = Auto Latency Based / 1 = Manual Set QUEUE_SIZE )
const QUEUE_SIZE = 100; // Adjusts bet concurrency. Keep it below 200. Don't be a hero..
/****** ADV SETTINGS ******/
const DEBUG_OUTPUT = true; // Output log to the script log box on the site.
const DEBUG_CONSOLE = false; // Output log to the browser developer console / toolbox
const DEBUG_MODE = false; // Runs script like normal except bets are replaced by skips (no bets)
const DEBUG_TEST = false; // Tests speed/latency and stops script without betting.
/**************************/
let betCount = 0;
let totalOut = 0;
let totalIn = 0;
let queueSize = null
let ourProfits = 0;
let prevProfits = 0;
let queue = null
let running = true;
const cl = console.log
const ol = this.log
console.log = function () {
if (DEBUG_CONSOLE) { cl.apply(this, arguments); }
if (DEBUG_OUTPUT) { ol.apply(this, arguments); }
}
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 () {
let wager = Math.round(((BASE_WAGER * Math.pow(betMultiple, totalOut)) + (BET_INCREASE * totalOut)) / 100) * 100;
if (wager >= (MAX_WAGER * 100)) {
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 getWager();
}
}
let target = (BASE_TARGET * (TAR_MULTIPLE ** totalOut)) + (TAR_INCREASE * totalOut);
if (target >= MAX_TARGET) {
if (STOP_MAX_TARG) {
console.log(`Stopping due to MAX_TARGET exceeded! (${target}x)`)
running = false;
} else if (RESET_MAX_TARG) {
totalOut = 0;
//return getWager();
}
}
return ({ value: wager, target: 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;
if(STOP_TRAIL > 0 && prevProfits - ourProfits > (STOP_TRAIL * 100)){
console.log(`Stopping after hitting trailing stop at ${ourProfits / 100} bits profit retained!`)
running = false;
}
} else {
let profit = (result.value * result.target) - result.value
ourProfits += profit
if(ourProfits >= prevProfits){
prevProfits = ourProfits;
}
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 < queueSize; 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;
}
if (running) {
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}`);
} else {
break;
}
}
const genTime = Date.now();
if (running) {
await Promise.all(queue.map(p => p.catch(e => e))).then(async (results) => { await results.forEach(result => doResult(context, result)) });
await sleep(queueSize);
}
const cycleEnd = Date.now();
console.log(`Cycle efficiency at ${(queueSize / (genTime - startTime)) * 1000} + ${(queueSize / (cycleEnd - genTime)) * 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));
}
const getLatency = async function (context, count = 10, size = 5) {
let results = [];
while (results.length < count) {
let t0 = performance.now();
for (let t = 0; t < size; t++) {
await context.skip();
}
let t1 = performance.now();
results.push((t1 - t0) / 5);
}
let t1 = performance.now();
context.skip();
let t2 = performance.now();
return (results.reduce((a, b) => a + b, 0) / count) - ((t2 - t1) * count);
}
if (DEBUG_TEST) {
let latency = await getLatency(this);
this.log(`Measured latency at ${latency} ms`)
} else {
if (QUEUE_MODE === 0) {
this.log(`Calculating queue size..`)
queueSize = Math.round(await getLatency(this));
} else {
queueSize = Math.round(QUEUE_SIZE);
}
queue = new Array(queueSize);
this.log(`Starting script at ${queueSize} queue size`)
await main(this);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment