tx · Yuhn1h5Tnz9N7pg9e5vNkFuTxzFWGhZJ4A7W9r25rEf

3MypDvVCAuJeZ6TpPpcmwi2FaRxFUSUkLx7:  -0.01400000 Waves

2019.09.08 13:00 [666948] smart account 3MypDvVCAuJeZ6TpPpcmwi2FaRxFUSUkLx7 > SELF 0.00000000 Waves

{ "type": 13, "id": "Yuhn1h5Tnz9N7pg9e5vNkFuTxzFWGhZJ4A7W9r25rEf", "fee": 1400000, "feeAssetId": null, "timestamp": 1567936912751, "version": 1, "sender": "3MypDvVCAuJeZ6TpPpcmwi2FaRxFUSUkLx7", "senderPublicKey": "Cv3xSd2ankhDcqBfBHybjYZNcDCbXHV9HtUXPD1Na9jU", "proofs": [ "3xRP32gAALtXjaAKHAw2bje1j3jFJLyUo3mGHoPHvmjMWSEYpdEw2P5RnGzaGLDJUwFKDhVvdkBLNZbHcdPvQ3jN" ], "script": "base64:AAIDAAAAAAAAAAAAAAAIAAAAAAhkZXRlY3RvcgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAAAAAAAAAA2ZlZQAAAAAAAJiWgAAAAAAGbWF4RmVlAAAAAAAATEtAAAAAAAdkYXlTaXplCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAD6AAAAAAAAAAAPAAAAAAAAAAAPAAAAAAJZGF5TWFyZ2luCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAD6AAAAAAAAAAAPAAAAAAAAAAAHgAAAAALdHJhZGVNYXJnaW4JAABoAAAAAgkAAGgAAAACAAAAAAAAAAPoAAAAAAAAAAA8AAAAAAAAAAAKAAAAAA1kZXRlY3RvckdyYWNlCQAAaAAAAAIJAABoAAAAAgAAAAAAAAAD6AAAAAAAAAAAPAAAAAAAAAAACgEAAAALZ2V0SW50ZWdlcjAAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABa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5lcnNBbW91bnQFAAAADWxvb3NlcnNBbW91bnQEAAAADHBheW91dEFtb3VudAkAAGgAAAACCQAAaQAAAAIJAABoAAAAAgkAAGkAAAACBQAAAAt0b3RhbEFtb3VudAAAAAAAAA9CQAUAAAAGYW1vdW50BQAAAA13aW5uZXJzQW1vdW50AAAAAAAAD0JACQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAJcGF5b3V0S2V5BgUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAFb3duZXIFAAAADHBheW91dEFtb3VudAUAAAAEdW5pdAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAADaW52AAAABmNhbGxlcggFAAAAA2ludgAAAANmZWUFAAAABHVuaXQFAAAAA25pbAAAAADZc6bc", "chainId": 84, "height": 666948, "spentComplexity": 0 } View: original | compacted Prev: B5fJ3c3LuQDmJmCDbBSusth7HCQ1B3o5bKUwvT6rFvpU Next: none Full:
OldNewDifferences
1-{-# STDLIB_VERSION 2 #-}
2-{-# CONTENT_TYPE EXPRESSION #-}
3-let matcherPublicKey = base58''
1+{-# STDLIB_VERSION 3 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let detector = addressFromStringValue("")
5+
6+let fee = 10000000
7+
8+let maxFee = 5000000
9+
410 let daySize = ((1000 * 60) * 60)
11+
512 let dayMargin = ((1000 * 60) * 30)
13+
614 let tradeMargin = ((1000 * 60) * 10)
15+
716 let detectorGrace = ((1000 * 60) * 10)
8-match tx {
9- case d: DataTransaction =>
10- let exchangeTx = extract( match transactionById(tx.proofs[0]) {
11- case e: ExchangeTransaction =>
12- e
13- case _ =>
14- unit
15- })
16- let day = (exchangeTx.timestamp / daySize)
17- let tradePeriodStart = (((day + 1) * daySize) - tradeMargin)
18- let tradePeriodEnd = ((day + 1) * daySize)
19- let prefix = ("day_" + toString(day))
20- let maxPrice = match getInteger(tx.sender, (prefix + "_max_price")) {
21- case i: Int =>
22- i
23- case _ =>
24- 0
25- }
26- if (if (if (if (if (if (if ((size(d.data) == 2))
27- then (exchangeTx.price > maxPrice)
28- else false)
29- then (exchangeTx.timestamp >= tradePeriodStart)
30- else false)
31- then (tradePeriodEnd >= exchangeTx.timestamp)
32- else false)
33- then (d.data[0].key == (prefix + "_max_txid"))
34- else false)
35- then (d.data[0].value == toBase58String(tx.proofs[0]))
36- else false)
37- then (d.data[1].key == (prefix + "_max_price"))
38- else false)
39- then (d.data[1].value == exchangeTx.price)
40- else false
17+
18+func getInteger0 (key) = match getInteger(this, key) {
19+ case i: Int =>
20+ i
4121 case _ =>
42- sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
22+ 0
4323 }
24+
25+
26+@Callable(inv)
27+func bet (price,sideIsAbove) = {
28+ let payment = extract(inv.payment)
29+ if ((payment.assetId != unit))
30+ then throw("bet must be in WAVES")
31+ else {
32+ let amount = (payment.amount - fee)
33+ if ((0 > amount))
34+ then throw("amount too low")
35+ else {
36+ let currentDay = (lastBlock.timestamp / daySize)
37+ let beforeCurrentDayEnd = (((currentDay + 1) * daySize) - dayMargin)
38+ if ((lastBlock.timestamp > beforeCurrentDayEnd))
39+ then throw(("timestamp must be less then " + toString(beforeCurrentDayEnd)))
40+ else {
41+ let txid = toBase58String(inv.transactionId)
42+ let prefix = ((("bet_" + toString(currentDay)) + "_") + txid)
43+ let dayTotalBetKey = ("bettotal_" + toString(currentDay))
44+ let dayTotalBetCount = getInteger0(dayTotalBetKey)
45+ WriteSet([DataEntry((prefix + "_price"), price), DataEntry((prefix + "_day"), currentDay), DataEntry((prefix + "_bet_is_above"), sideIsAbove), DataEntry((prefix + "_amount"), amount), DataEntry((prefix + "_owner"), toBase58String(inv.caller.bytes)), DataEntry(dayTotalBetKey, (dayTotalBetCount + 1))])
46+ }
47+ }
48+ }
49+ }
50+
51+
52+
53+@Callable(inv)
54+func countBet (betId) = if ((inv.fee > maxFee))
55+ then throw("unreasonable large fee")
56+ else if ((inv.feeAssetId != unit))
57+ then throw("fee must be in WAVES")
58+ else if ((getBoolean(this, (betId + "_winner")) != unit))
59+ then throw("already spent")
60+ else {
61+ let amount = getIntegerValue(this, (betId + "_amount"))
62+ let price = getIntegerValue(this, (betId + "_price"))
63+ let day = getIntegerValue(this, (betId + "_day"))
64+ let betIsAbove = getBooleanValue(this, (betId + "_bet_is_above"))
65+ let currentDay = (lastBlock.timestamp / daySize)
66+ if ((day >= currentDay))
67+ then throw("only can process previous day bets")
68+ else {
69+ let detectorPrice = getIntegerValue(detector, (("day_" + toString(day)) + "_max"))
70+ let isAbove = (price >= detectorPrice)
71+ let isWinner = (isAbove == betIsAbove)
72+ let isWinnerString = if (isWinner)
73+ then "winners"
74+ else "loosers"
75+ let winloseKey = ((isWinnerString + "_") + toString(day))
76+ let currentAmount = getInteger0(winloseKey)
77+ let dayCountBetKey = ("betcount_" + toString(day))
78+ let currentCount = getInteger0(dayCountBetKey)
79+ ScriptResult(WriteSet([DataEntry((betId + "_winner"), isWinner), DataEntry(winloseKey, (currentAmount + amount)), DataEntry(dayCountBetKey, (currentCount + 1))]), TransferSet([ScriptTransfer(inv.caller, inv.fee, unit)]))
80+ }
81+ }
82+
83+
84+
85+@Callable(inv)
86+func payout (betId) = if ((inv.fee > maxFee))
87+ then throw("unreasonable large fee")
88+ else if ((inv.feeAssetId != unit))
89+ then throw("fee must be in WAVES")
90+ else {
91+ let payoutKey = (betId + "_paid")
92+ if ((getBoolean(this, payoutKey) != unit))
93+ then throw("already paid")
94+ else if ((getBoolean(this, (betId + "_winner")) != true))
95+ then throw("bet is not winner")
96+ else {
97+ let amount = getIntegerValue(this, (betId + "_amount"))
98+ let price = getIntegerValue(this, (betId + "_price"))
99+ let day = getIntegerValue(this, (betId + "_day"))
100+ let owner = getStringValue(this, (betId + "_owner"))
101+ let dayCountBetKey = ("betcount_" + toString(day))
102+ let dayTotalBetKey = ("bettotal_" + toString(day))
103+ if ((getIntegerValue(this, dayTotalBetKey) != getIntegerValue(this, dayCountBetKey)))
104+ then throw("plase count all tx first")
105+ else {
106+ let winnersAmount = getInteger0(("winners_" + toString(day)))
107+ let loosersAmount = getInteger0(("loosers_" + toString(day)))
108+ let totalAmount = (winnersAmount + loosersAmount)
109+ let payoutAmount = ((((totalAmount / 1000000) * amount) / winnersAmount) * 1000000)
110+ ScriptResult(WriteSet([DataEntry(payoutKey, true)]), TransferSet([ScriptTransfer(addressFromStringValue(owner), payoutAmount, unit), ScriptTransfer(inv.caller, inv.fee, unit)]))
111+ }
112+ }
113+ }
114+
115+

github/deemru/w8io/026f985 
27.30 ms