CIP: 14 Title: Instant Lottery Authors: JP Janssen Discussions-To: https://counterpartytalk.org/t/cip-draft-instant-lottery/3020 Status: Deferred Type: Standards Created: 2017-06-08
Always have an active bet to play against, and settlement every few hours.
This is achieved by adding an automated contract address.
- Automated oracle feed that broadcasts a random value based on the blockhash
- Automated bets placed on "the house" side with a slight edge
Stimulate usage of the Counterparty betting system.
Have lotteries always available and not require a human counterparty, nor a trusted human oracle.
Increase demand for XCP from players, and have an automated player that accumulates XCP over time, effectively reducing the supply.
The oracle will broadcast a value every 24 blocks (roughly every 4 hours). A wide range of lotteries can be played on this one feed. The probabilites one can play on will be 1/2, 1/4, 1/8, etc, up to 1/1,048,576.
The automated player will always bet on the side that gives the lowest payout (and highest probability of winning) in return for a slight edge. This is similar to how the house operates in a casino.
Therefore there will always be an active lottery on Counterparty. A human player only needs to make one bet transaction to participate. Once it confirms it matches instantly. Within a few hours the oracle decides the outcome and the protocol pays out winnings.
Economically this will work since many humans, when faced with a potentially high payout, willingly accept a negative expected return. The automated player, on the other hand, will over time accumulate more and more XCP, allowing for larger bets.
The oracle will use a burn address - 1CounterbetXXXXXXXXXXXXXXXXXWhGbTM
- the address is valid, yet has no private key.
Every 24 blocks the oracle will broadcast either of the following values (with probabilities):
2 (1/2)
4 (1/4)
8 (1/8)
16 (1/16)
32 (1/32)
64 (1/64)
128 (1/128)
256 (1/256)
512 (1/512)
1024 (1/1024)
2048 (1/2048)
4096 (1/4096)
8192 (1/8192)
16384 (1/16384)
32768 (1/32768)
65536 (1/65536)
131072 (1/131072)
262144 (1/262144)
524288 (1/524288)
1048576 (1/1048576)
1048577 (1/1048576)
The fee will be 0.05% and the broadcast time will be set to the block height (not the block's timestamp).
The automated player will operate from the same address.
Every 24 blocks the player will place a not equal
bet on the next broadcast. It will alternate between the values
4, 8, 16, 32, 64, 128, and 1024. It will always wager half its balance but require a counterwager
that gives the human player a 99% expected payout.
For every block, prior to parsing transactions, calculate a = block_height MOD 24
If a = 0 prepare a broadcast.
If a = 1 prepare a bet.
Broadcast will carry parameters source
, fee_fraction
, text
, timestamp
, value
.
The constant ones are source = 1CounterbetXXXXXXXXXXXXXXXXXWhGbTM
, fee_fraction = 0.0005
and text = 'Random'
.
The timestamp
will be set to the current block_height
and the value
will be generated as follows:
Find b = block_hash MOD 1048576
If b >= 1048576/2 value = 2
Elseif b >= 1048576/4 value = 4
Elseif b >= 1048576/8 value = 8
...
Elseif b >= 1048576/524288 value = 524288
Elseif b >= 1048576/1048576 value = 1048576
Elseif b = 0 value = 1048577
The broadcast will be added to the DB as the first transaction of the current block.
Bet will carry parameters source
, feed_address
, bet_type
, deadline
, wager_quantity
, counterwager_quantity
, expiration
, target_value
, leverage
The constant ones are source = 1CounterbetXXXXXXXXXXXXXXXXXWhGbTM
, feed_address = 1CounterbetXXXXXXXXXXXXXXXXXWhGbTM
, bet_type = 3
, expiration = 22
and leverage = 5040
.
The deadline = block_height + 22
and wager_quantity = xcp_balance / 2
The target_value will be set as follows:
Find c = block_height MOD 7
If c = 4 target_value = 4
Elseif c = 0 target_value = 8
Elseif c = 3 target_value = 16
Elseif c = 6 target_value = 32
Elseif c = 2 target_value = 64
Elseif c = 5 target_value = 128
Elseif c = 1 target_value = 1024
The counterwager_quantity is determined the following way:
If target_value = 4 counterwager_quantity = wager_quantity * 0.33761189
If target_value = 8 counterwager_quantity = wager_quantity * 0.14442599
If target_value = 16 counterwager_quantity = wager_quantity * 0.06734949
If target_value = 32 counterwager_quantity = wager_quantity * 0.03257770
If target_value = 64 counterwager_quantity = wager_quantity * 0.01602778
If target_value = 128 counterwager_quantity = wager_quantity * 0.00795018
If target_value = 1024 counterwager_quantity = wager_quantity * 0.00098691
The bet will be added to the DB as the first transaction of the current block.
Choice of parameters and mathematical equations explained here
A 0.62 BTC bounty has been donated. Additional donations in BTC and XCP can be made to the following address (escrow by J-Dog): ___________
-
50% of BTC and 50% of XCP is paid out with a working implementation demonstrated on testnet. This included placing bets on the feed.
-
All remaining BTC and 50% of remaining XCP is paid out when merged to master on mainnet.
-
The remaining XCP is transfered to
1CounterbetXXXXXXXXXXXXXXXXXWhGbTM
This document is placed in the public domain.