Can somebody explain how betting works or point me out where to read. Let's say I would like to bet on the increase of BTC/USD price using porquepine feed, so I create a bet saying btc price will be higher than X at the end of block N and the valid bet transactions have to be submitted before block M. The winner side takes all from the losing side, each participant will be paid out proportionally to his wager / all winner side wager. Is this how it works ?
The bets are directly matched with another participant.
When a bet is placed the protocol places the amount of the Wager in escrow and creates an 'open bet'.
Then if a bet is made taking the opposite side (Bear/Bull or Equal/Not Equal pair - with matching leverage and deadline), the protocol will see how much of the two positions can be matched and automatically proceed to match them.
When the Deadline is reached or if the funds of one side are exhausted entirely, the funds that were held in Escrow are credited to the Addresses involved in the bet in accordance with the price movement (for a CFD) - or as winner takes all (for Equal/Not Equal).
I'll write up a better description to put up on the site later today.
it may not be at the end, the contract could get filled during the period leading to block N; different type of option style. i, as you, am uncertain how the event trigger is coded to function.
The current system calculates the change on every broadcast - but only settles the Bet if one of two conditions has occurred: The Deadline was reached (settled on deadline), or the escrowed funds of one side were exhausted entirely (Contract liquidated).