const baseBet = 100 // how many satoshis to bet initially
const target = 1.50 // target multiplier
const betMultiplier = 3 // what to multiply the bet size by when we lose a wager
const sleepTime = 300 // Ms - milliseconds to pause between bets
let lossCount = 0
this.log(`Starting half target script, balance ${this.balance / 100} bits.`)
while (true) {
const { multiplier } = await this.bet(betSize(lossCount), target)
await sleep(sleepTime)
if (multiplier < target) { // [LOSS]
lossCount++
this.log(`Lost bet. Multiplying bet size by ${betMultiplier} for new bet size of ${betSize(lossCount)} satoshis.`)
} else { // [WON]
lossCount = 0
this.log(`Won bet. Setting bet size to ${baseBet} satoshis.`)
}
}
function betSize(lossCount) {
const bet = baseBet * Math.pow(betMultiplier, lossCount)
return Math.round(bet / 100) * 100
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}