tx · CLkt2Pv4NSBZtBj5TdfVXrZ6em71oni56eEGXRCsV8Hc 3Mungn3ygy3DzpbDUKPbJQaeNKfQHu9fkK8: -0.11200000 Waves 2022.11.16 13:00 [2319520] smart account 3Mungn3ygy3DzpbDUKPbJQaeNKfQHu9fkK8 > SELF 0.00000000 Waves
{ "type": 13, "id": "CLkt2Pv4NSBZtBj5TdfVXrZ6em71oni56eEGXRCsV8Hc", "fee": 11200000, "feeAssetId": null, "timestamp": 1668592824469, "version": 2, "chainId": 84, "sender": "3Mungn3ygy3DzpbDUKPbJQaeNKfQHu9fkK8", "senderPublicKey": "6L7iBerXuPa5E74WCM6fLSB2VM1bMG9jgASH8tu9orHN", "proofs": [ "4vog1zUZtq8YxFPcizTCi1UYT1ykhcmZTwfLTnPManWxnzRZ2k2hXhXX82yM4pvTna8pooWmFoFuBXjpEfXbhwwJ" ], "script": "base64:BgIoCAISBwoFAQgBAQgSBgoEAQEICBIDCgEBEgQKAgEIEgQKAhEYEgASACsAD0dBTUVfVFlQRV9HUk9VUAIFR3JvdXAAEUdBTUVfVFlQRV9QTEFUT0ZGAghQbGF5LW9mZgAKR0FNRV9UWVBFUwkAzAgCBQ9HQU1FX1RZUEVfR1JPVVAJAMwIAgURR0FNRV9UWVBFX1BMQVRPRkYFA25pbAAEVVNEVAEgbySjyqsw3FIpmOgsYVruWn8jTcItdbvpnapU4NLQB8EAB01JTl9CRVQAwIQ9AAhPTkVfSE9VUgkAaAIJAGgCAAUAPADoBwARTU9ORVlfQk9YX0FERFJFRVMJAQdBZGRyZXNzAQEaAVSxYgy7BRV2F+zuKtUZtXyHmoiep9yqU84AB0JFVF9GRUUA9AMACUZFRV9TQ0FMRQCQTgAHa0FjdGl2ZQIGYWN0aXZlAAtrQWN0aXZlR2xvYgIUYWN0aXZlX2FsbF9jb250cmFjdHMABmtDYXVzZQIOc2h1dGRvd25fY2F1c2UADWtHYW1lU3RyYVRpbWUCDl9zdGFydEdhbWVUaW1lAAlrR2FtZVR5cG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AzQgCBQxnYW1lc0VudHJpZXMJAQxJbnRlZ2VyRW50cnkCBQtrTGFzdEdhbWVJZAUHbmV3TEdJZAFpAQhzaHV0ZG93bgADCQEBIQEFBmFjdGl2ZQkAAgEJAKwCAgIiREFwcCBpcyBhbHJlYWR5IHN1c3BlbmRlZC4gQ2F1c2U6IAkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzBQZrQ2F1c2UCGnRoZSBjYXVzZSB3YXNuJ3Qgc3BlY2lmaWVkAwkBASEBCQEPY29udGFpbnNFbGVtZW50AgkAzAgCBQxhZG1pblB1YktleTEJAMwIAgUMYWRtaW5QdWJLZXkyCQDMCAIFDGFkbWluUHViS2V5MwUDbmlsCAUBaQ9jYWxsZXJQdWJsaWNLZXkJAAIBAiFPbmx5IGFkbWluIGNhbiBjYWxsIHRoaXMgZnVuY3Rpb24JAQdzdXNwZW5kAQIPUGF1c2VkIGJ5IGFkbWluAWkBCGFjdGl2YXRlAAMFBmFjdGl2ZQkAAgECFkRBcHAgaXMgYWxyZWFkeSBhY3RpdmUDCQEBIQEJAQ9jb250YWluc0VsZW1lbnQCCQDMCAIFDGFkbWluUHViS2V5MQkAzAgCBQxhZG1pblB1YktleTIJAMwIAgUMYWRtaW5QdWJLZXkzBQNuaWwIBQFpD2NhbGxlclB1YmxpY0tleQkAAgECIU9ubHkgYWRtaW4gY2FuIGNhbGwgdGhpcyBmdW5jdGlvbgkAzAgCCQEMQm9vbGVhbkVudHJ5AgUHa0FjdGl2ZQYJAMwIAgkBC0RlbGV0ZUVudHJ5AQUGa0NhdXNlBQNuaWwAxmce5Q==", "height": 2319520, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2BsK41cRUTmGFMd2P2aPTgKX8didF1h9uQtL5GDYh78G Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let GAME_TYPE_GROUP = "Group" | |
5 | 5 | ||
6 | 6 | let GAME_TYPE_PLATOFF = "Play-off" | |
7 | 7 | ||
8 | 8 | let GAME_TYPES = [GAME_TYPE_GROUP, GAME_TYPE_PLATOFF] | |
9 | 9 | ||
10 | 10 | let USDT = base58'8UrfDVd5GreeUwm7uPk7eYz1eMv376kzR52C6sANPkwS' | |
11 | 11 | ||
12 | 12 | let MIN_BET = 1000000 | |
13 | 13 | ||
14 | 14 | let ONE_HOUR = ((5 * 60) * 1000) | |
15 | 15 | ||
16 | 16 | let MONEY_BOX_ADDREES = Address(base58'3N65zqVKchaFdW4gS7FxCRibjfkVgJvo7PT') | |
17 | 17 | ||
18 | 18 | let BET_FEE = 500 | |
19 | 19 | ||
20 | 20 | let FEE_SCALE = 10000 | |
21 | 21 | ||
22 | 22 | let kActive = "active" | |
23 | 23 | ||
24 | 24 | let kActiveGlob = "active_all_contracts" | |
25 | 25 | ||
26 | 26 | let kCause = "shutdown_cause" | |
27 | 27 | ||
28 | 28 | let kGameStraTime = "_startGameTime" | |
29 | 29 | ||
30 | 30 | let kGameType = "_GameType" | |
31 | 31 | ||
32 | 32 | let kLastGameId = "last_game_id" | |
33 | 33 | ||
34 | 34 | let kTotalBets = "_totalBets" | |
35 | 35 | ||
36 | 36 | let kToWinA = "_toWinA" | |
37 | 37 | ||
38 | 38 | let kToWinB = "_toWinB" | |
39 | 39 | ||
40 | 40 | let kOnDraw = "_onDraw" | |
41 | 41 | ||
42 | 42 | let kGameResult = "_result" | |
43 | 43 | ||
44 | 44 | let kBank = "_bank" | |
45 | 45 | ||
46 | 46 | let kFinalTime = "_finalTime" | |
47 | 47 | ||
48 | 48 | let kTotalBetsForType = "_totalBetsForType" | |
49 | 49 | ||
50 | 50 | let kUserBet = "_userBet" | |
51 | 51 | ||
52 | 52 | let kUserRefId = "_refId" | |
53 | 53 | ||
54 | 54 | let kUserClaimed = "_claimed" | |
55 | 55 | ||
56 | 56 | let kAdminPubKey1 = "admin_pub_1" | |
57 | 57 | ||
58 | 58 | let kAdminPubKey2 = "admin_pub_2" | |
59 | 59 | ||
60 | 60 | let kAdminPubKey3 = "admin_pub_3" | |
61 | 61 | ||
62 | 62 | let oracle = Address(base58'3PEbqViERCoKnmcSULh6n2aiMvUdSQdCsom') | |
63 | 63 | ||
64 | 64 | func getBase58FromOracle (key) = match getString(oracle, key) { | |
65 | 65 | case string: String => | |
66 | 66 | fromBase58String(string) | |
67 | 67 | case nothing => | |
68 | 68 | throw((key + "is empty")) | |
69 | 69 | } | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | let adminPubKey1 = getBase58FromOracle(kAdminPubKey1) | |
73 | 73 | ||
74 | 74 | let adminPubKey2 = getBase58FromOracle(kAdminPubKey2) | |
75 | 75 | ||
76 | 76 | let adminPubKey3 = getBase58FromOracle(kAdminPubKey3) | |
77 | 77 | ||
78 | 78 | let active = valueOrElse(getBoolean(this, kActive), true) | |
79 | 79 | ||
80 | 80 | let activeGlob = valueOrElse(getBoolean(oracle, kActiveGlob), true) | |
81 | 81 | ||
82 | 82 | func isActive () = if (if (active) | |
83 | 83 | then activeGlob | |
84 | 84 | else false) | |
85 | 85 | then unit | |
86 | 86 | else throw("DApp is inactive at this moment") | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | func isAdminCall (i) = if (containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey)) | |
90 | 90 | then unit | |
91 | 91 | else throw("Only admin can call this function") | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | func suspend (cause) = [BooleanEntry(kActive, false), StringEntry(kCause, cause)] | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func getUserBetKey (user,gameId,type,result) = (((((((user + "_") + toString(gameId)) + "_") + toString(type)) + "_") + result) + kUserBet) | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | func getTotalBetsForTypeKey (gameId,type,result) = (((((toString(gameId) + "_") + toString(type)) + "_") + result) + kTotalBetsForType) | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | func validateBet (gameType,type,result) = if ((type == 1)) | |
104 | 104 | then if ((size(result) != 1)) | |
105 | 105 | then throw("Game result must contain only one letter: A,B,D") | |
106 | 106 | else if (!(contains("ABD", result))) | |
107 | 107 | then throw("Game result must contain only one letter: A,B,D") | |
108 | 108 | else if (if ((gameType == GAME_TYPE_PLATOFF)) | |
109 | 109 | then !(contains("AB", result)) | |
110 | 110 | else false) | |
111 | 111 | then throw("Game result must contain only one letter: A,B") | |
112 | 112 | else true | |
113 | 113 | else if ((type == 2)) | |
114 | 114 | then { | |
115 | 115 | let splited = split(result, "_") | |
116 | 116 | if ((size(splited) != 2)) | |
117 | 117 | then throw("Inncorrect game result") | |
118 | 118 | else { | |
119 | 119 | let ballsA = valueOrErrorMessage(parseInt(splited[0]), "Inncorrect game result") | |
120 | 120 | let ballsB = valueOrErrorMessage(parseInt(splited[1]), "Inncorrect game result") | |
121 | 121 | if ((ballsA == ballsB)) | |
122 | 122 | then throw("Inncorrect game result. A and B cannot be equal") | |
123 | 123 | else true | |
124 | 124 | } | |
125 | 125 | } | |
126 | 126 | else if ((type == 3)) | |
127 | 127 | then { | |
128 | 128 | let splited = split(result, "_") | |
129 | 129 | if ((size(splited) != 2)) | |
130 | 130 | then throw("Inncorrect game result") | |
131 | 131 | else { | |
132 | 132 | let team = splited[0] | |
133 | 133 | let ballsAmount = valueOrErrorMessage(parseInt(splited[1]), "Inncorrect game result") | |
134 | 134 | if ((0 >= ballsAmount)) | |
135 | 135 | then throw("Inncorrect game result, balls amount must be greater then 0") | |
136 | 136 | else if (if ((size(team) != 1)) | |
137 | 137 | then true | |
138 | 138 | else !(contains("AB", team))) | |
139 | 139 | then throw("Game result must contain only one letter: A,B") | |
140 | 140 | else true | |
141 | 141 | } | |
142 | 142 | } | |
143 | 143 | else false | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | func calcClaim (gameId,userAddress,result,type,amount) = { | |
147 | 147 | let spldRes = split(result, "_") | |
148 | 148 | let $t039684494 = if ((type == 1)) | |
149 | 149 | then if ((result == "A")) | |
150 | 150 | then $Tuple3("1_0", 1, 0) | |
151 | 151 | else if ((result == "B")) | |
152 | 152 | then $Tuple3("0_1", 0, 1) | |
153 | 153 | else $Tuple3("1_1", 1, 1) | |
154 | 154 | else if ((type == 2)) | |
155 | 155 | then $Tuple3(result, parseIntValue(spldRes[0]), parseIntValue(spldRes[1])) | |
156 | 156 | else if ((type == 3)) | |
157 | 157 | then if ((spldRes[0] == "A")) | |
158 | 158 | then $Tuple3((spldRes[1] + "_0"), parseIntValue(spldRes[1]), 0) | |
159 | 159 | else $Tuple3(("0_" + spldRes[1]), 0, parseIntValue(spldRes[1])) | |
160 | 160 | else $Tuple3(result, parseIntValue(spldRes[0]), parseIntValue(spldRes[1])) | |
161 | 161 | let gameResult = $t039684494._1 | |
162 | 162 | let ballsA = $t039684494._2 | |
163 | 163 | let ballsB = $t039684494._3 | |
164 | 164 | let diff = if ((ballsA > ballsB)) | |
165 | 165 | then (ballsA - ballsB) | |
166 | 166 | else (ballsB - ballsA) | |
167 | 167 | let winner = if ((ballsA > ballsB)) | |
168 | 168 | then "A" | |
169 | 169 | else if ((ballsB > ballsA)) | |
170 | 170 | then "B" | |
171 | 171 | else "D" | |
172 | 172 | let G1 = (valueOrElse(getInteger(this, getTotalBetsForTypeKey(gameId, 1, winner)), 0) + (if ((type == 1)) | |
173 | 173 | then amount | |
174 | 174 | else 0)) | |
175 | 175 | let G2 = (valueOrElse(getInteger(this, getTotalBetsForTypeKey(gameId, 2, gameResult)), 0) + (if ((type == 2)) | |
176 | 176 | then amount | |
177 | 177 | else 0)) | |
178 | 178 | let G3 = (valueOrElse(getInteger(this, getTotalBetsForTypeKey(gameId, 3, ((winner + "_") + toString(diff)))), 0) + (if ((type == 3)) | |
179 | 179 | then amount | |
180 | 180 | else 0)) | |
181 | 181 | let totalWinValue = ((G1 + G2) + G3) | |
182 | 182 | let totalBets = (valueOrElse(getInteger(this, (toString(gameId) + kTotalBets)), 0) + amount) | |
183 | 183 | let bankWithFee = (totalBets - totalWinValue) | |
184 | 184 | let fee = fraction(bankWithFee, BET_FEE, FEE_SCALE) | |
185 | 185 | let B = (bankWithFee - fee) | |
186 | 186 | let UB1 = (valueOrElse(getInteger(this, getUserBetKey(userAddress, gameId, 1, winner)), 0) + (if ((type == 1)) | |
187 | 187 | then amount | |
188 | 188 | else 0)) | |
189 | 189 | let UB2 = (valueOrElse(getInteger(this, getUserBetKey(userAddress, gameId, 2, gameResult)), 0) + (if ((type == 2)) | |
190 | 190 | then amount | |
191 | 191 | else 0)) | |
192 | 192 | let UB3 = (valueOrElse(getInteger(this, getUserBetKey(userAddress, gameId, 3, ((winner + "_") + toString(diff)))), 0) + (if ((type == 3)) | |
193 | 193 | then amount | |
194 | 194 | else 0)) | |
195 | 195 | let totalWinValueMax = ((G1 + (G2 * 3)) + (G3 * 2)) | |
196 | 196 | let D1 = if ((G1 == 0)) | |
197 | 197 | then 0 | |
198 | 198 | else fraction((G1 + fraction((G1 * B), 1, totalWinValueMax)), UB1, G1) | |
199 | 199 | let D2 = if ((G2 == 0)) | |
200 | 200 | then 0 | |
201 | 201 | else fraction((G2 + fraction((G2 * B), 3, totalWinValueMax)), UB2, G2) | |
202 | 202 | let D3 = if ((G3 == 0)) | |
203 | 203 | then 0 | |
204 | 204 | else fraction((G3 + fraction((G3 * B), 2, totalWinValueMax)), UB3, G3) | |
205 | 205 | let claimAmount = if ((B == 0)) | |
206 | 206 | then ((UB1 + UB2) + UB3) | |
207 | 207 | else ((D1 + D2) + D3) | |
208 | 208 | claimAmount | |
209 | 209 | } | |
210 | 210 | ||
211 | 211 | ||
212 | 212 | @Callable(i) | |
213 | 213 | func potentialWinnings (gameId,userAddress,amount,type,result) = { | |
214 | 214 | let claimAmount = calcClaim(gameId, userAddress, result, type, amount) | |
215 | 215 | $Tuple2(nil, claimAmount) | |
216 | 216 | } | |
217 | 217 | ||
218 | 218 | ||
219 | 219 | ||
220 | 220 | @Callable(i) | |
221 | 221 | func bet (gameId,type,result,refId) = valueOrElse(isActive(), { | |
222 | 222 | let user = toString(i.caller) | |
223 | 223 | let gIdStr = toString(gameId) | |
224 | 224 | let $t065166591 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
225 | 225 | let pmtAmount = $t065166591._1 | |
226 | 226 | let pmtAssetId = $t065166591._2 | |
227 | 227 | let gameStartTime = valueOrElse(getInteger(this, (toString(gameId) + kGameStraTime)), 0) | |
228 | 228 | let gameType = getStringValue(this, (toString(gameId) + kGameType)) | |
229 | 229 | if ((pmtAssetId != USDT)) | |
230 | 230 | then throw("Pamyment must be In USDT asset") | |
231 | 231 | else if ((MIN_BET > pmtAmount)) | |
232 | 232 | then throw((("Min bet " + toString((MIN_BET / 1000000))) + "USDT")) | |
233 | 233 | else if ((gameStartTime == 0)) | |
234 | 234 | then throw(("There is no game with id" + toString(gameId))) | |
235 | 235 | else if (((lastBlock.timestamp + ONE_HOUR) >= gameStartTime)) | |
236 | 236 | then throw("Bets on this game are no longer accepted") | |
237 | 237 | else if (!(validateBet(gameType, type, result))) | |
238 | 238 | then throw("Incorrect bet type") | |
239 | 239 | else { | |
240 | 240 | let spldRes = split(result, "_") | |
241 | 241 | let userBetKey = getUserBetKey(user, gameId, type, result) | |
242 | 242 | let totalBetsForTypeBetKey = getTotalBetsForTypeKey(gameId, type, result) | |
243 | 243 | let userBet = (valueOrElse(getInteger(this, userBetKey), 0) + pmtAmount) | |
244 | 244 | let totalBetsForTypeBet = (valueOrElse(getInteger(this, totalBetsForTypeBetKey), 0) + pmtAmount) | |
245 | 245 | let totalBets = (valueOrElse(getInteger(this, (gIdStr + kTotalBets)), 0) + pmtAmount) | |
246 | 246 | let toWinA = (valueOrElse(getInteger(this, (gIdStr + kToWinA)), 0) + (if (if ((type == 1)) | |
247 | 247 | then (result == "A") | |
248 | 248 | else false) | |
249 | 249 | then pmtAmount | |
250 | 250 | else if (if ((type == 2)) | |
251 | 251 | then (parseIntValue(spldRes[0]) > parseIntValue(spldRes[1])) | |
252 | 252 | else false) | |
253 | 253 | then pmtAmount | |
254 | 254 | else if (if ((type == 3)) | |
255 | 255 | then (spldRes[0] == "A") | |
256 | 256 | else false) | |
257 | 257 | then pmtAmount | |
258 | 258 | else 0)) | |
259 | 259 | let toWinB = (valueOrElse(getInteger(this, (gIdStr + kToWinB)), 0) + (if (if ((type == 1)) | |
260 | 260 | then (result == "B") | |
261 | 261 | else false) | |
262 | 262 | then pmtAmount | |
263 | 263 | else if (if ((type == 2)) | |
264 | 264 | then (parseIntValue(spldRes[1]) > parseIntValue(spldRes[0])) | |
265 | 265 | else false) | |
266 | 266 | then pmtAmount | |
267 | 267 | else if (if ((type == 3)) | |
268 | 268 | then (spldRes[0] == "B") | |
269 | 269 | else false) | |
270 | 270 | then pmtAmount | |
271 | 271 | else 0)) | |
272 | 272 | let onDraw = (valueOrElse(getInteger(this, (gIdStr + kOnDraw)), 0) + (if (if ((type == 1)) | |
273 | 273 | then (result == "D") | |
274 | 274 | else false) | |
275 | 275 | then pmtAmount | |
276 | 276 | else 0)) | |
277 | 277 | ([IntegerEntry(userBetKey, userBet), IntegerEntry(totalBetsForTypeBetKey, totalBetsForTypeBet), IntegerEntry((gIdStr + kTotalBets), totalBets), IntegerEntry((gIdStr + kToWinA), toWinA), IntegerEntry((gIdStr + kToWinB), toWinB), IntegerEntry((gIdStr + kOnDraw), onDraw)] ++ (if (!(isDefined(getString(this, (user + kUserRefId))))) | |
278 | 278 | then [StringEntry((user + kUserRefId), refId)] | |
279 | 279 | else nil)) | |
280 | 280 | } | |
281 | 281 | }) | |
282 | 282 | ||
283 | 283 | ||
284 | 284 | ||
285 | 285 | @Callable(i) | |
286 | 286 | func claim (gameId) = valueOrElse(isActive(), { | |
287 | 287 | let user = toString(i.caller) | |
288 | 288 | let gIdStr = toString(gameId) | |
289 | 289 | let finalTime = valueOrErrorMessage(getInteger(this, (gIdStr + kFinalTime)), "You can claim only after game finish") | |
290 | 290 | if (((finalTime + ONE_HOUR) > lastBlock.timestamp)) | |
291 | 291 | then throw("You can claim only after one hour pass after final time") | |
292 | 292 | else if (isDefined(getBoolean(this, (((user + "_") + gIdStr) + kUserClaimed)))) | |
293 | 293 | then throw("You are alredy claimed") | |
294 | 294 | else { | |
295 | 295 | let gameResult = getStringValue(this, (gIdStr + kGameResult)) | |
296 | 296 | let claimAmount = calcClaim(gameId, user, gameResult, 0, 0) | |
297 | 297 | if ((claimAmount == 0)) | |
298 | 298 | then throw("Nothing to claim") | |
299 | 299 | else $Tuple2([BooleanEntry((((user + "_") + gIdStr) + kUserClaimed), true), ScriptTransfer(i.caller, claimAmount, USDT)], claimAmount) | |
300 | 300 | } | |
301 | 301 | }) | |
302 | 302 | ||
303 | 303 | ||
304 | 304 | ||
305 | 305 | @Callable(i) | |
306 | 306 | func gameSummary (gameId,result) = { | |
307 | 307 | let gIdStr = toString(gameId) | |
308 | 308 | let gameStartTime = valueOrElse(getInteger(this, (toString(gameId) + kGameStraTime)), 0) | |
309 | 309 | if ((gameStartTime == 0)) | |
310 | 310 | then throw(("There is no game with id" + toString(gameId))) | |
311 | 311 | else { | |
312 | 312 | let spldRes = split(result, "_") | |
313 | 313 | let ballsA = valueOrErrorMessage(parseInt(spldRes[0]), "Inncorrect game result") | |
314 | 314 | let ballsB = valueOrErrorMessage(parseInt(spldRes[1]), "Inncorrect game result") | |
315 | 315 | let diff = if ((ballsA > ballsB)) | |
316 | 316 | then (ballsA - ballsB) | |
317 | 317 | else (ballsB - ballsA) | |
318 | 318 | let winner = if ((ballsA > ballsB)) | |
319 | 319 | then "A" | |
320 | 320 | else if ((ballsB > ballsA)) | |
321 | 321 | then "B" | |
322 | 322 | else "D" | |
323 | 323 | let totalWinType1 = valueOrElse(getInteger(this, getTotalBetsForTypeKey(gameId, 1, winner)), 0) | |
324 | 324 | let totalWinType2 = valueOrElse(getInteger(this, getTotalBetsForTypeKey(gameId, 2, result)), 0) | |
325 | 325 | let totalWinType3 = valueOrElse(getInteger(this, getTotalBetsForTypeKey(gameId, 3, ((winner + "_") + toString(diff)))), 0) | |
326 | 326 | let totalWinValue = ((totalWinType1 + totalWinType2) + totalWinType3) | |
327 | 327 | let totalBets = valueOrElse(getInteger(this, (toString(gameId) + kTotalBets)), 0) | |
328 | 328 | let bankWithFee = (totalBets - totalWinValue) | |
329 | 329 | let $t01065310811 = if ((totalWinValue == 0)) | |
330 | 330 | then $Tuple2(bankWithFee, 0) | |
331 | 331 | else { | |
332 | 332 | let f = fraction(bankWithFee, BET_FEE, FEE_SCALE) | |
333 | 333 | $Tuple2(f, (bankWithFee - f)) | |
334 | 334 | } | |
335 | 335 | let fee = $t01065310811._1 | |
336 | 336 | let bank = $t01065310811._2 | |
337 | 337 | [StringEntry((gIdStr + kGameResult), result), IntegerEntry((gIdStr + kBank), bank), IntegerEntry((gIdStr + kFinalTime), lastBlock.timestamp), ScriptTransfer(MONEY_BOX_ADDREES, fee, USDT)] | |
338 | 338 | } | |
339 | 339 | } | |
340 | 340 | ||
341 | 341 | ||
342 | 342 | ||
343 | 343 | @Callable(i) | |
344 | 344 | func initGames (startGameTimes,types) = { | |
345 | 345 | func initGame (acc,startGameTime) = { | |
346 | 346 | let $t01119511229 = acc | |
347 | 347 | let entries = $t01119511229._1 | |
348 | 348 | let lastGameId = $t01119511229._2 | |
349 | 349 | let j = $t01119511229._3 | |
350 | 350 | let newGameId = (lastGameId + 1) | |
351 | 351 | if ((lastBlock.timestamp > startGameTime)) | |
352 | 352 | then throw("startGameTime must be in the future") | |
353 | 353 | else if (!(containsElement(GAME_TYPES, types[j]))) | |
354 | 354 | then throw(("type must contain one of values: " + makeString(GAME_TYPES, ","))) | |
355 | 355 | else { | |
356 | 356 | let gameEntries = [IntegerEntry((toString(newGameId) + kGameStraTime), startGameTime), StringEntry((toString(newGameId) + kGameType), types[j])] | |
357 | 357 | $Tuple3((entries ++ gameEntries), newGameId, (j + 1)) | |
358 | 358 | } | |
359 | 359 | } | |
360 | 360 | ||
361 | 361 | let lastGameId = valueOrElse(getInteger(this, kLastGameId), 0) | |
362 | 362 | let $t01177211857 = { | |
363 | 363 | let $l = startGameTimes | |
364 | 364 | let $s = size($l) | |
365 | 365 | let $acc0 = $Tuple3(nil, lastGameId, 0) | |
366 | 366 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
367 | 367 | then $a | |
368 | 368 | else initGame($a, $l[$i]) | |
369 | 369 | ||
370 | 370 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
371 | 371 | then $a | |
372 | 372 | else throw("List size exceeds 50") | |
373 | 373 | ||
374 | 374 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50) | |
375 | 375 | } | |
376 | 376 | let gamesEntries = $t01177211857._1 | |
377 | 377 | let newLGId = $t01177211857._2 | |
378 | 378 | (gamesEntries :+ IntegerEntry(kLastGameId, newLGId)) | |
379 | 379 | } | |
380 | 380 | ||
381 | 381 | ||
382 | 382 | ||
383 | 383 | @Callable(i) | |
384 | 384 | func shutdown () = if (!(active)) | |
385 | 385 | then throw(("DApp is already suspended. Cause: " + valueOrElse(getString(this, kCause), "the cause wasn't specified"))) | |
386 | 386 | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))) | |
387 | 387 | then throw("Only admin can call this function") | |
388 | 388 | else suspend("Paused by admin") | |
389 | 389 | ||
390 | 390 | ||
391 | 391 | ||
392 | 392 | @Callable(i) | |
393 | 393 | func activate () = if (active) | |
394 | 394 | then throw("DApp is already active") | |
395 | 395 | else if (!(containsElement([adminPubKey1, adminPubKey2, adminPubKey3], i.callerPublicKey))) | |
396 | 396 | then throw("Only admin can call this function") | |
397 | 397 | else [BooleanEntry(kActive, true), DeleteEntry(kCause)] | |
398 | 398 | ||
399 | 399 |
github/deemru/w8io/026f985 50.13 ms ◑