12 | | - | let betThreshold = 10 |
---|
13 | | - | |
---|
14 | | - | let betMin = 1 |
---|
15 | | - | |
---|
16 | | - | let betMax = 100 |
---|
17 | | - | |
---|
18 | | - | func q1Extract () = { |
---|
19 | | - | let q1 = if (isDefined("q1_next")) |
---|
20 | | - | then getIntegerValue(this, "q1_next") |
---|
21 | | - | else q1start |
---|
22 | | - | q1 |
---|
23 | | - | } |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | func q2Extract () = { |
---|
27 | | - | let q2 = if (isDefined("q2_next")) |
---|
28 | | - | then getIntegerValue(this, "q2_next") |
---|
29 | | - | else q2start |
---|
30 | | - | q2 |
---|
31 | | - | } |
---|
32 | | - | |
---|
33 | | - | |
---|
34 | | - | func debtAmount1Extract () = { |
---|
35 | | - | let debtAmount1 = if (isDefined("debtAmount1")) |
---|
36 | | - | then getIntegerValue(this, "debtAmount1") |
---|
37 | | - | else 0 |
---|
38 | | - | debtAmount1 |
---|
39 | | - | } |
---|
40 | | - | |
---|
41 | | - | |
---|
42 | | - | func debtAmount2Extract () = { |
---|
43 | | - | let debtAmount2 = if (isDefined("debtAmount2")) |
---|
44 | | - | then getIntegerValue(this, "debtAmount2") |
---|
45 | | - | else 0 |
---|
46 | | - | debtAmount2 |
---|
47 | | - | } |
---|
48 | | - | |
---|
49 | | - | |
---|
50 | | - | func calcCoefIfBigBet (event,betAmount) = { |
---|
51 | | - | let q = getIntegerValue(this, event) |
---|
52 | | - | let k = (((1 * 100000) - (q * 1000)) / (betMax - betThreshold)) |
---|
53 | | - | let b = ((1 * 100000) - (k * betMax)) |
---|
54 | | - | let qCorrected = (((betAmount * k) + b) / 1000) |
---|
55 | | - | qCorrected |
---|
56 | | - | } |
---|
57 | | - | |
---|
58 | | - | |
---|
59 | | - | func anothercoef (q,vig) = { |
---|
60 | | - | let anothercoef = pow(((vig + 1000) - (100000 / q)), 0, -1, 0, 5, DOWN) |
---|
61 | | - | anothercoef |
---|
62 | | - | } |
---|
63 | | - | |
---|
64 | | - | |
---|
65 | | - | func actualNewCoefs (betAmount,debtAmount1,debtAmount2) = if ((0 > debtAmount1)) |
---|
66 | | - | then { |
---|
67 | | - | let k = (((1 * 1000000) - (q1start * 10000)) / riskAmount) |
---|
68 | | - | let b = ((1 * 1000000) - (k * riskAmount)) |
---|
69 | | - | let q1 = ((-(k) * debtAmount1) + (b / 1000)) |
---|
70 | | - | let q2 = anothercoef(q1, vig) |
---|
71 | | - | [q1, q2] |
---|
72 | | - | } |
---|
73 | | - | else if ((debtAmount1 > 0)) |
---|
74 | | - | then { |
---|
75 | | - | let k = (((1 * 1000000) - (q1start * 10000)) / riskAmount) |
---|
76 | | - | let b = ((1 * 1000000) - (k * riskAmount)) |
---|
77 | | - | let q2 = ((-(k) * debtAmount2) + (b / 1000)) |
---|
78 | | - | let q1 = anothercoef(q2, vig) |
---|
79 | | - | [q1, q2] |
---|
80 | | - | } |
---|
81 | | - | else { |
---|
82 | | - | let q1 = q1start |
---|
83 | | - | let q2 = q2start |
---|
84 | | - | [q1, q2] |
---|
85 | | - | } |
---|
86 | | - | |
---|
| 12 | + | let script = base64'AAIDAAAAAAAAAAoIARIGCgQIAQgBAAAABQAAAAAPdHJhbnNhY3Rpb25UeXBlCQEAAAAOdGFrZVJpZ2h0Qnl0ZXMAAAACCQABmgAAAAEAAAAAAAAAAA0AAAAAAAAAAAEAAAAAB2NoYWluSWQJAQAAAA50YWtlUmlnaHRCeXRlcwAAAAIJAAGaAAAAAQAAAAAAAAAAVAAAAAAAAAAAAQAAAAAIaXNTY3JpcHQJAQAAAA50YWtlUmlnaHRCeXRlcwAAAAIJAAGaAAAAAQAAAAAAAAAAAQAAAAAAAAAAAQAAAAAMc2NyaXB0TGVuZ3RoCQEAAAAOdGFrZVJpZ2h0Qnl0ZXMAAAACCQABmgAAAAEAAAAAAAAAHDoAAAAAAAAAAAIAAAAABnNjcmlwdAEAABw6AAIDAAAAAAAAAAoIARIGCgQIAQgBAAAABQAAAAAPdHJhbnNhY3Rpb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AIJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAMsAAAACBQAAAA90cmFuc2FjdGlvblR5cGUJAQAAAA50YWtlUmlnaHRCeXRlcwAAAAIJAAGaAAAAAQUAAAAHdmVyc2lvbgAAAAAAAAAAAQUAAAAHY2hhaW5JZAkAAlkAAAABBQAAAA9zZW5kZXJQdWJsaWNLZXkFAAAACGlzU2NyaXB0BQAAAAxzY3JpcHRMZW5ndGgFAAAABnNjcmlwdAkAAZoAAAABBQAAAANmZWUJAAGbAAAAAQUAAAAJdGltZXN0YW1wAwkBAAAACWlzRGVmaW5lZAAAAAEJAAPpAAAAAQUAAAAEdHhJZAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAGb3JhY2xlAgAAAAExBQAAAANuaWwJAAACAAAAAQIAAAAIaW5jb3JyZXQAAAAADzYukw==' |
---|
89 | | - | func bet (event) = { |
---|
90 | | - | let betAmount = match contextObj.payment { |
---|
91 | | - | case p: AttachedPayment => |
---|
92 | | - | if ((betMin > p.amount)) |
---|
93 | | - | then throw("low payment") |
---|
94 | | - | else p.amount |
---|
95 | | - | case _ => |
---|
96 | | - | throw("Payment not attached") |
---|
97 | | - | } |
---|
98 | | - | let count = if (isDefined("count")) |
---|
99 | | - | then getIntegerValue(this, "count") |
---|
100 | | - | else 0 |
---|
101 | | - | let event1DebtForThisPlayer = getIntegerValue(this, (toString(contextObj.caller) + "_event1DebtForThisPlayer")) |
---|
102 | | - | let event2DebtForThisPlayer = getIntegerValue(this, (toString(contextObj.caller) + "_event2DebtForThisPlayer")) |
---|
103 | | - | let debtAmount1 = debtAmount1Extract() |
---|
104 | | - | let debtAmount2 = debtAmount2Extract() |
---|
105 | | - | let q1 = q1Extract() |
---|
106 | | - | let q2 = q2Extract() |
---|
107 | | - | let countNew = (count + 1) |
---|
108 | | - | if ((event == 1)) |
---|
109 | | - | then if ((betThreshold > betAmount)) |
---|
110 | | - | then { |
---|
111 | | - | let event1DebtForThisPlayerNew = (event1DebtForThisPlayer + (q1 * betAmount)) |
---|
112 | | - | let debtAmount1New = (debtAmount1 - (q1 * betAmount)) |
---|
113 | | - | let debtAmount2New = (debtAmount2 + betAmount) |
---|
114 | | - | let q1Nextq2Next = actualNewCoefs(betAmount, debtAmount1New, debtAmount2New) |
---|
115 | | - | let q1Next = q1Nextq2Next[0] |
---|
116 | | - | let q2Next = q1Nextq2Next[1] |
---|
117 | | - | WriteSet([DataEntry((toString(contextObj.caller) + "_event1DebtForThisPlayer"), event1DebtForThisPlayerNew), DataEntry((toString(countNew) + "_event"), event), DataEntry((toString(countNew) + "_qoef1"), q1), DataEntry((toString(countNew) + "_qoef2"), q2), DataEntry((toString(countNew) + "_amount"), betAmount), DataEntry((toString(countNew) + "_bettor"), toString(contextObj.caller)), DataEntry("q1_next", q1Next), DataEntry("q2_next", q2Next), DataEntry("count", countNew)]) |
---|
118 | | - | } |
---|
119 | | - | else if (if ((betAmount > betThreshold)) |
---|
120 | | - | then (betMax > betAmount) |
---|
121 | | - | else false) |
---|
122 | | - | then { |
---|
123 | | - | let q1Corrected = calcCoefIfBigBet("q1_next", betAmount) |
---|
124 | | - | let event1DebtForThisPlayerNew = (event1DebtForThisPlayer + (q1Corrected * betAmount)) |
---|
125 | | - | let debtAmount1New = (debtAmount1 - (q1Corrected * betAmount)) |
---|
126 | | - | let debtAmount2New = (debtAmount2 + betAmount) |
---|
127 | | - | let q1Nextq2Next = actualNewCoefs(betAmount, debtAmount1New, debtAmount2New) |
---|
128 | | - | let q1Next = q1Nextq2Next[0] |
---|
129 | | - | let q2Next = q1Nextq2Next[1] |
---|
130 | | - | WriteSet([DataEntry((toString(contextObj.caller) + "_event1DebtForThisPlayer"), event1DebtForThisPlayerNew), DataEntry((toString(countNew) + "_event"), event), DataEntry((toString(countNew) + "_qoef1"), q1), DataEntry((toString(countNew) + "_qoef2"), q2), DataEntry((toString(countNew) + "_amount"), betAmount), DataEntry((toString(countNew) + "_bettor"), toString(contextObj.caller)), DataEntry("q1_next", q1Next), DataEntry("q2_next", q2Next), DataEntry("count", countNew)]) |
---|
131 | | - | } |
---|
132 | | - | else throw("incorrect bet amount") |
---|
133 | | - | else if ((betThreshold > betAmount)) |
---|
134 | | - | then { |
---|
135 | | - | let event2DebtForThisPlayerNew = (event2DebtForThisPlayer + (q2 * betAmount)) |
---|
136 | | - | let debtAmount2New = (debtAmount2 - (q2 * betAmount)) |
---|
137 | | - | let debtAmount1New = (debtAmount1 + betAmount) |
---|
138 | | - | let q1Nextq2Next = actualNewCoefs(betAmount, debtAmount1New, debtAmount2New) |
---|
139 | | - | let q1Next = q1Nextq2Next[0] |
---|
140 | | - | let q2Next = q1Nextq2Next[1] |
---|
141 | | - | WriteSet([DataEntry((toString(contextObj.caller) + "_event2DebtForThisPlayer"), event2DebtForThisPlayerNew), DataEntry((toString(countNew) + "_event"), event), DataEntry((toString(countNew) + "_qoef1"), q1), DataEntry((toString(countNew) + "_qoef2"), q2), DataEntry((toString(countNew) + "_amount"), betAmount), DataEntry((toString(countNew) + "_bettor"), toString(contextObj.caller)), DataEntry("q1_next", q1Next), DataEntry("q2_next", q2Next), DataEntry("count", countNew)]) |
---|
142 | | - | } |
---|
143 | | - | else if (if ((betAmount > betThreshold)) |
---|
144 | | - | then (betMin > betAmount) |
---|
145 | | - | else false) |
---|
146 | | - | then { |
---|
147 | | - | let q2Corrected = calcCoefIfBigBet("q2_next", betAmount) |
---|
148 | | - | let event2DebtForThisPlayerNew = (event2DebtForThisPlayer + (q2Corrected * betAmount)) |
---|
149 | | - | let debtAmount2New = (debtAmount2 - (q2Corrected * betAmount)) |
---|
150 | | - | let debtAmount1New = (debtAmount1 + betAmount) |
---|
151 | | - | let q1Nextq2Next = actualNewCoefs(betAmount, debtAmount1New, debtAmount2New) |
---|
152 | | - | let q1Next = q1Nextq2Next[0] |
---|
153 | | - | let q2Next = q1Nextq2Next[1] |
---|
154 | | - | WriteSet([DataEntry((toString(contextObj.caller) + "_event2DebtForThisPlayer"), event2DebtForThisPlayerNew), DataEntry((toString(countNew) + "_event"), event), DataEntry((toString(countNew) + "_qoef1"), q1), DataEntry((toString(countNew) + "_qoef2"), q2), DataEntry((toString(countNew) + "_amount"), betAmount), DataEntry((toString(countNew) + "_bettor"), toString(contextObj.caller)), DataEntry("q1_next", q1Next), DataEntry("q2_next", q2Next), DataEntry("count", countNew)]) |
---|
155 | | - | } |
---|
156 | | - | else throw("incorrect bet amount") |
---|
157 | | - | } |
---|
158 | | - | |
---|
159 | | - | |
---|
160 | | - | |
---|
161 | | - | @Callable(contextObj) |
---|
162 | | - | func withdraw () = { |
---|
163 | | - | let event1amount = match getInteger(this, (toString(contextObj.caller) + "__event1DebtForThisPlayer")) { |
---|
164 | | - | case u: Unit => |
---|
165 | | - | 0 |
---|
166 | | - | case i: Int => |
---|
167 | | - | i |
---|
168 | | - | case _ => |
---|
169 | | - | throw() |
---|
170 | | - | } |
---|
171 | | - | let event2amount = match getInteger(this, (toString(contextObj.caller) + "__event2DebtForThisPlayer")) { |
---|
172 | | - | case u: Unit => |
---|
173 | | - | 0 |
---|
174 | | - | case i: Int => |
---|
175 | | - | i |
---|
176 | | - | case _ => |
---|
177 | | - | throw() |
---|
178 | | - | } |
---|
179 | | - | let event1 = match getBoolean(this, "result_event_1") { |
---|
180 | | - | case u: Unit => |
---|
181 | | - | false |
---|
182 | | - | case b: Boolean => |
---|
183 | | - | b |
---|
184 | | - | case _ => |
---|
185 | | - | throw() |
---|
186 | | - | } |
---|
187 | | - | let event2 = match getBoolean(this, "result_event_2") { |
---|
188 | | - | case u: Unit => |
---|
189 | | - | false |
---|
190 | | - | case b: Boolean => |
---|
191 | | - | b |
---|
192 | | - | case _ => |
---|
193 | | - | throw() |
---|
194 | | - | } |
---|
195 | | - | if (event1) |
---|
196 | | - | then ScriptResult(WriteSet([DataEntry((toString(contextObj.caller) + "_event1amount"), 0)]), TransferSet([ScriptTransfer(contextObj.caller, (event1amount * 1000000), unit)])) |
---|
197 | | - | else if (event2) |
---|
198 | | - | then ScriptResult(WriteSet([DataEntry((toString(contextObj.caller) + "_event2amount"), 0)]), TransferSet([ScriptTransfer(contextObj.caller, (event2amount * 1000000), unit)])) |
---|
199 | | - | else throw("event did not happen or you have zero win") |
---|
| 15 | + | func registerRandomRequestTx (senderPublicKey,fee,timestamp,version) = { |
---|
| 16 | + | let txId = blake2b256(((((((((transactionType + takeRightBytes(toBytes(version), 1)) + chainId) + fromBase58String(senderPublicKey)) + isScript) + scriptLength) + script) + toBytes(fee)) + toBytes(timestamp))) |
---|
| 17 | + | if (isDefined(transactionHeightById(txId))) |
---|
| 18 | + | then WriteSet([DataEntry("oracle", "1")]) |
---|
| 19 | + | else throw("incorret") |
---|