tx · J93oV3u4Y7Z3hzJ53iZQVYw8AUF17Waea528bGXZq2DE

3MqLtJ49xFdzpVh8kJoaumrRN9GYXLrScMk:  -0.01400000 Waves

2019.07.30 16:42 [608911] smart account 3MqLtJ49xFdzpVh8kJoaumrRN9GYXLrScMk > SELF 0.00000000 Waves

{ "type": 13, "id": "J93oV3u4Y7Z3hzJ53iZQVYw8AUF17Waea528bGXZq2DE", "fee": 1400000, "feeAssetId": null, "timestamp": 1564494172769, "version": 1, "sender": "3MqLtJ49xFdzpVh8kJoaumrRN9GYXLrScMk", "senderPublicKey": "5XLU4PwAQXZGmcUD3QtB2pXeV3VBEBp8cvA9NnTiv2mW", "proofs": [ "jZPgHrNzJJcdLWdWJDquE5g32QBroAXYm6jFRBXEeJstZcM3VRpe5E4QhVJCWfJZbUBe4JmYY58FZMUpRaDT76R" ], "script": "base64:AAIDAAAAAAAAAAAAAAAJAAAAAApiZXRBc3NldElkAQAAACAea7QCZF/XAXMBPEnDQ5kqHUHyOfWmXu9KHDHL6zcNNwAAAAAGbWF4RmVlAAAAAAAATEtAAAAAAAZtaW5CZXQAAAAAAABMS0AAAAAAD21pbk1hdGNoTm9taW5hbAAAAAAAAExLQAEAAAAIY2hlY2tGZWUAAAABAAAAAWkDCQAAZgAAAAIIBQAAAAFpAAAAA2ZlZQUAAAAGbWF4RmVlCQAAAgAAAAECAAAAFnVucmVhc29uYWJsZSBsYXJnZSBmZWUDCQEAAAACIT0AAAACCAUAAAABaQAAAApmZWVBc3NldElkBQAAAAR1bml0CQAAAgAAAAECAAAAFGZlZSBtdXN0IGJlIGluIFdBVkVTBgEAAAAIcmVwYXlGZWUAAAADAAAAAWkAAAACd3MAAAAGYW1vdW50AwkBAAAACGNoZWNrRmVlAAAAAQUAAAABaQkBAAAADFNjcmlwdFJlc3VsdAAAAAIFAAAAAndzCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAA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RkcmVzcwkABB0AAAACBQAAAAR0aGlzCQABLAAAAAIFAAAACHdpbm5lcklkAgAAAAZfb3duZXIDCQEAAAACIT0AAAACBQAAAA13aW5uZXJBZGRyZXNzCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMJAAACAAAAAQIAAAArcGF5d2lubmVyKCkgc2hvdWxkIGJlIGNhbGxlZCBieSB3aW5uZXIgb25seQQAAAAGYW1vdW50CQEAAAAHZXh0cmFjdAAAAAEJAAQaAAAAAgUAAAAEdGhpcwkAASwAAAACBQAAAAdtYXRjaElkAgAAAAdfYW1vdW50CQEAAAAIcmVwYXlGZWUAAAADBQAAAAFpCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAAB21hdGNoSWQCAAAABV9wYWlkBQAAAAZhbW91bnQFAAAAA25pbAUAAAAGYW1vdW50AAAAAHjb8fo=", "chainId": 84, "height": 608911, "spentComplexity": 0 } View: original | compacted Prev: 6t5YZKTzbM3YyYw85eJKABYHBnUx1GT5Z9jmbRvVfdnc Next: 6rZLBkh4zbw5gbdwa2scvGEuW4Exsbhrgt9ryQ7vhTao Diff:
OldNewDifferences
4949 then throw("unexpected side")
5050 else {
5151 let betid = (((((("bet_" + event) + "_") + toBase58String(i.caller.bytes)) + "_") + take(toBase64String(i.transactionId), 15)) + "_")
52- let sequence = match getInteger(this, ((("seq_" + event) + "_") + subevent)) {
52+ let sequenceKey = ((("seq_" + event) + "_") + subevent)
53+ let sequence = match getInteger(this, sequenceKey) {
5354 case prevS: Int =>
5455 (prevS + 1)
5556 case _ =>
5657 1
5758 }
58- repayFee(i, WriteSet([DataEntry((betid + "owner"), owner), DataEntry((betid + "event"), event), DataEntry((betid + "subevent"), subevent), DataEntry((betid + "side"), side), DataEntry((betid + "odds"), odds), DataEntry((betid + "amount"), payment.amount), DataEntry((betid + "spent"), 0), DataEntry((betid + "timestamp"), lastBlock.timestamp), DataEntry((betid + "sequence"), sequence)]), 0)
59+ repayFee(i, WriteSet([DataEntry((betid + "owner"), owner), DataEntry((betid + "event"), event), DataEntry((betid + "subevent"), subevent), DataEntry((betid + "side"), side), DataEntry((betid + "odds"), odds), DataEntry((betid + "amount"), payment.amount), DataEntry((betid + "spent"), 0), DataEntry((betid + "timestamp"), lastBlock.timestamp), DataEntry((betid + "sequence"), sequence), DataEntry(sequenceKey, sequence)]), 0)
5960 }
6061 }
6162
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let betAssetId = base58'33kV5hRVtgEGpYqhp9wQn2g9hP1fNWSYGCzzYk1T9Hyg'
55
66 let maxFee = 5000000
77
88 let minBet = 5000000
99
1010 let minMatchNominal = 5000000
1111
1212 func checkFee (i) = if ((i.fee > maxFee))
1313 then throw("unreasonable large fee")
1414 else if ((i.feeAssetId != unit))
1515 then throw("fee must be in WAVES")
1616 else true
1717
1818
1919 func repayFee (i,ws,amount) = if (checkFee(i))
2020 then ScriptResult(ws, TransferSet([ScriptTransfer(i.caller, i.fee, unit)]))
2121 else throw("error")
2222
2323
2424 func checkOwner (i,betid) = (getString(this, (betid + "_owner")) == toBase58String(i.caller.bytes))
2525
2626
2727 func getUnspent (betid) = (extract(getInteger(this, (betid + "_amount"))) - extract(getInteger(this, (betid + "_spent"))))
2828
2929
3030 func isDefeated (betid) = {
3131 let defeatStatus = getInteger(this, (betid + "_defeat"))
3232 if ((defeatStatus == 1))
3333 then true
3434 else (defeatStatus == 3)
3535 }
3636
3737
3838 @Callable(i)
3939 func bet (event,subevent,side,odds) = {
4040 let owner = toBase58String(i.caller.bytes)
4141 let payment = extract(i.payment)
4242 if ((payment.assetId != betAssetId))
4343 then throw(("bet must be in asset " + toBase58String(betAssetId)))
4444 else if ((minBet > payment.amount))
4545 then throw(("minimum allowed bet is " + toString(minBet)))
4646 else if (if ((side != "for"))
4747 then (side != "against")
4848 else false)
4949 then throw("unexpected side")
5050 else {
5151 let betid = (((((("bet_" + event) + "_") + toBase58String(i.caller.bytes)) + "_") + take(toBase64String(i.transactionId), 15)) + "_")
52- let sequence = match getInteger(this, ((("seq_" + event) + "_") + subevent)) {
52+ let sequenceKey = ((("seq_" + event) + "_") + subevent)
53+ let sequence = match getInteger(this, sequenceKey) {
5354 case prevS: Int =>
5455 (prevS + 1)
5556 case _ =>
5657 1
5758 }
58- repayFee(i, WriteSet([DataEntry((betid + "owner"), owner), DataEntry((betid + "event"), event), DataEntry((betid + "subevent"), subevent), DataEntry((betid + "side"), side), DataEntry((betid + "odds"), odds), DataEntry((betid + "amount"), payment.amount), DataEntry((betid + "spent"), 0), DataEntry((betid + "timestamp"), lastBlock.timestamp), DataEntry((betid + "sequence"), sequence)]), 0)
59+ repayFee(i, WriteSet([DataEntry((betid + "owner"), owner), DataEntry((betid + "event"), event), DataEntry((betid + "subevent"), subevent), DataEntry((betid + "side"), side), DataEntry((betid + "odds"), odds), DataEntry((betid + "amount"), payment.amount), DataEntry((betid + "spent"), 0), DataEntry((betid + "timestamp"), lastBlock.timestamp), DataEntry((betid + "sequence"), sequence), DataEntry(sequenceKey, sequence)]), 0)
5960 }
6061 }
6162
6263
6364
6465 @Callable(i)
6566 func cancel (betid) = if (!(checkOwner(i, betid)))
6667 then throw("permission denied")
6768 else {
6869 let amount = extract(getInteger(this, (betid + "_amount")))
6970 let spent = extract(getInteger(this, (betid + "_spent")))
7071 let cancelAmount = (amount - spent)
7172 repayFee(i, WriteSet([DataEntry((betid + "_spent"), amount), DataEntry((betid + "_cancel_amount"), cancelAmount)]), cancelAmount)
7273 }
7374
7475
7576
7677 @Callable(i)
7778 func betMatch (betFor,betAgainst) = if ((getString(this, (betFor + "_event")) != getString(this, (betAgainst + "_event"))))
7879 then throw("event id must match")
7980 else if ((getString(this, (betFor + "_subevent")) != getString(this, (betAgainst + "_subevent"))))
8081 then throw("subevent id must match")
8182 else if ((getString(this, (betFor + "_side")) != "for"))
8283 then throw("invalid *for* bet")
8384 else if ((getString(this, (betAgainst + "_side")) != "against"))
8485 then throw("invalid *against* bet")
8586 else {
8687 let eventid = extract(getString(this, (betFor + "_event")))
8788 let matchid = (((((((("match_" + betFor) + "_") + betAgainst) + "_") + eventid) + "_") + toBase58String(i.transactionId)) + "_")
8889 let odds = extract(getInteger(this, (betFor + "_odds")))
8990 let unspentFor = getUnspent(betFor)
9091 let unspentAgainst = getUnspent(betAgainst)
9192 let maxForNominal = unspentFor
9293 let maxAgainstNominal = ((unspentAgainst * 100) / odds)
9394 let matchNominal = if ((maxForNominal > maxAgainstNominal))
9495 then maxAgainstNominal
9596 else maxForNominal
9697 if ((minMatchNominal > matchNominal))
9798 then throw("match nominal too low")
9899 else {
99100 let spendFor = matchNominal
100101 let spendAgainst = ((matchNominal * odds) / 100)
101102 let newSpentFor = (spendFor + unspentFor)
102103 let newSpentAgainst = (spendAgainst + unspentAgainst)
103104 if ((newSpentFor > extract(getInteger(this, (betFor + "_amount")))))
104105 then throw("invalid match")
105106 else if ((newSpentAgainst > extract(getInteger(this, (betAgainst + "_amount")))))
106107 then throw("invalid match")
107108 else repayFee(i, WriteSet([DataEntry((matchid + "amount"), (spendFor + spendAgainst)), DataEntry((matchid + "for"), betFor), DataEntry((matchid + "against"), betAgainst), DataEntry((betFor + "_spent"), newSpentFor), DataEntry((betAgainst + "_spent"), newSpentAgainst)]), 0)
108109 }
109110 }
110111
111112
112113
113114 @Callable(i)
114115 func approveDefeat (betId,defeat) = if (if (isDefined(getInteger(this, (betId + "_defeat"))))
115116 then (defeat == 2)
116117 else false)
117118 then throw("can't dispute after approve")
118119 else repayFee(i, WriteSet([DataEntry((betId + "_defeat"), defeat)]), 0)
119120
120121
121122
122123 @Callable(i)
123124 func payWinner (matchId) = if (isDefined(getInteger(this, (matchId + "_paid"))))
124125 then throw("already paid")
125126 else {
126127 let betForId = extract(getString(this, (matchId + "_for")))
127128 let betAgainstId = extract(getString(this, (matchId + "_against")))
128129 let betForDefeated = isDefeated(betForId)
129130 let betAgainstDefeated = isDefeated(betAgainstId)
130131 if (if (!(betForDefeated))
131132 then !(betAgainstDefeated)
132133 else false)
133134 then throw("no side approved defeat")
134135 else {
135136 let winnerId = if (betForDefeated)
136137 then betAgainstId
137138 else betForId
138139 let winnerAddress = getString(this, (winnerId + "_owner"))
139140 if ((winnerAddress != toBase58String(i.caller.bytes)))
140141 then throw("paywinner() should be called by winner only")
141142 else {
142143 let amount = extract(getInteger(this, (matchId + "_amount")))
143144 repayFee(i, WriteSet([DataEntry((matchId + "_paid"), amount)]), amount)
144145 }
145146 }
146147 }
147148
148149

github/deemru/w8io/169f3d6 
34.79 ms