tx · AFY7L4kXfB76pdZijAFCkWLu2QQpMv8xi4GJi8aFZbJj

3ND17nVaEvRLifxdkwXmXZwBvuYwefCMErS:  -0.01400000 Waves

2019.08.06 20:13 [619338] smart account 3ND17nVaEvRLifxdkwXmXZwBvuYwefCMErS > SELF 0.00000000 Waves

{ "type": 13, "id": "AFY7L4kXfB76pdZijAFCkWLu2QQpMv8xi4GJi8aFZbJj", "fee": 1400000, "feeAssetId": null, "timestamp": 1565111635237, "version": 1, "sender": "3ND17nVaEvRLifxdkwXmXZwBvuYwefCMErS", "senderPublicKey": "GDy5pgY6ePCFGV6tWjg7nLZQ8U4tXHg2jxbKBe5MHXtd", "proofs": [ "eNJxmwDR7yYLg5WMqwFaz7hRpWwUmaE7HrLpSFoFBctQ4yHP4imR1CiQqBHhYGb5D5KxVipjrt2Pt1VUWWWiCSt" ], "script": "base64:AAIDAAAAAAAAAAAAAAAJAAAAAApiZXRBc3NldElkAQAAACAea7QCZF/XAXMBPEnDQ5kqHUHyOfWmXu9KHDHL6zcNNwAAAAAGbWF4RmVlAAAAAAAATEtAAAAAAAZtaW5CZXQAAAAAAABMS0AAAAAAD21pbk1hdGNoTm9taW5hbAAAAAAAAExLQAEAAAAIY2hlY2tGZWUAAAABAAAAAWkDCQAAZgAAAAIIBQAAAAFpAAAAA2ZlZQUAAAAGbWF4RmVlCQAAAgAAAAECAAAAFnVucmVhc29uYWJsZSBsYXJnZSBmZWUDCQEAAAACIT0AAAACCAUAAAABaQAAAApmZWVBc3NldElkBQAAAAR1bml0CQAAAgAAAAECAAAAFGZlZSBtdXN0IGJlIGluIFdBVkVTBgEAAAAIcmVwYXlGZWUAAAADAAAAAWkAAAACd3MAAAAGYW1vdW50AwkBAAAACGNoZWNrRmVlAAAAAQUAAAABaQkBAAAADFNjcmlwdFJlc3VsdAAAAAIFAAAAAndzCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpA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QAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAAB21hdGNoSWQCAAAABV9wYWlkBQAAAAZhbW91bnQFAAAAA25pbAUAAAAGYW1vdW50AAAAAApzTgI=", "chainId": 84, "height": 619338, "spentComplexity": 0 } View: original | compacted Prev: GhxYTQgZsJMj63TeLxnYjgQKxWseGuf5R9sn6JSE5YrG Next: 347qzHH7XZH6NJJbqcHPQsPBGGJnCXdJFUiNTeq8erCf Diff:
OldNewDifferences
6969 let amount = extract(getInteger(this, (betid + "_amount")))
7070 let spent = extract(getInteger(this, (betid + "_spent")))
7171 let cancelAmount = (amount - spent)
72- repayFee(i, WriteSet([DataEntry((betid + "_spent"), amount), DataEntry((betid + "_cancel_amount"), cancelAmount)]), cancelAmount)
72+ repayFee(i, WriteSet([DataEntry((betid + "_spent"), amount), DataEntry((betid + "_cancel_amount"), cancelAmount), DataEntry((betid + "_cancel_tx"), toBase58String(i.transactionId))]), cancelAmount)
7373 }
7474
7575
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), ScriptTransfer(i.caller, amount, betAssetId)]))
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)) + "_")
5252 let sequenceKey = ((("seq_" + event) + "_") + subevent)
5353 let sequence = match getInteger(this, sequenceKey) {
5454 case prevS: Int =>
5555 (prevS + 1)
5656 case _ =>
5757 1
5858 }
5959 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)
6060 }
6161 }
6262
6363
6464
6565 @Callable(i)
6666 func cancel (betid) = if (!(checkOwner(i, betid)))
6767 then throw("permission denied")
6868 else {
6969 let amount = extract(getInteger(this, (betid + "_amount")))
7070 let spent = extract(getInteger(this, (betid + "_spent")))
7171 let cancelAmount = (amount - spent)
72- repayFee(i, WriteSet([DataEntry((betid + "_spent"), amount), DataEntry((betid + "_cancel_amount"), cancelAmount)]), cancelAmount)
72+ repayFee(i, WriteSet([DataEntry((betid + "_spent"), amount), DataEntry((betid + "_cancel_amount"), cancelAmount), DataEntry((betid + "_cancel_tx"), toBase58String(i.transactionId))]), cancelAmount)
7373 }
7474
7575
7676
7777 @Callable(i)
7878 func betMatch (betFor,betAgainst) = if ((getString(this, (betFor + "_event")) != getString(this, (betAgainst + "_event"))))
7979 then throw("event id must match")
8080 else if ((getString(this, (betFor + "_subevent")) != getString(this, (betAgainst + "_subevent"))))
8181 then throw("subevent id must match")
8282 else if ((getString(this, (betFor + "_side")) != "for"))
8383 then throw("invalid *for* bet")
8484 else if ((getString(this, (betAgainst + "_side")) != "against"))
8585 then throw("invalid *against* bet")
8686 else {
8787 let betForOwner = getStringValue(this, (betFor + "_owner"))
8888 let betAgainstOwner = getStringValue(this, (betAgainst + "_owner"))
8989 let eventid = extract(getString(this, (betFor + "_event")))
9090 let matchid = (((((((("match_" + eventid) + "_") + takeRight(betForOwner, 10)) + "_") + takeRight(betAgainstOwner, 10)) + "_") + toBase58String(i.transactionId)) + "_")
9191 let odds = extract(getInteger(this, (betFor + "_odds")))
9292 let unspentFor = getUnspent(betFor)
9393 let unspentAgainst = getUnspent(betAgainst)
9494 let maxForNominal = unspentFor
9595 let maxAgainstNominal = ((unspentAgainst * 100) / (odds - 100))
9696 let matchNominal = if ((maxForNominal > maxAgainstNominal))
9797 then maxAgainstNominal
9898 else maxForNominal
9999 if ((minMatchNominal > matchNominal))
100100 then throw("match nominal too low")
101101 else {
102102 let spendFor = matchNominal
103103 let spendAgainst = ((matchNominal * (odds - 100)) / 100)
104104 let newSpentFor = (spendFor + extract(getInteger(this, (betFor + "_spent"))))
105105 let newSpentAgainst = (spendAgainst + extract(getInteger(this, (betAgainst + "_spent"))))
106106 if ((newSpentFor > extract(getInteger(this, (betFor + "_amount")))))
107107 then throw("invalid match")
108108 else if ((newSpentAgainst > extract(getInteger(this, (betAgainst + "_amount")))))
109109 then throw("invalid match")
110110 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)
111111 }
112112 }
113113
114114
115115
116116 @Callable(i)
117117 func approveDefeat (betId,defeat) = if (if (isDefined(getInteger(this, (betId + "_defeat"))))
118118 then (defeat == 2)
119119 else false)
120120 then throw("can't dispute after approve")
121121 else repayFee(i, WriteSet([DataEntry((betId + "_defeat"), defeat)]), 0)
122122
123123
124124
125125 @Callable(i)
126126 func payWinner (matchId) = if (isDefined(getInteger(this, (matchId + "_paid"))))
127127 then throw("already paid")
128128 else {
129129 let betForId = extract(getString(this, (matchId + "_for")))
130130 let betAgainstId = extract(getString(this, (matchId + "_against")))
131131 let betForDefeated = isDefeated(betForId)
132132 let betAgainstDefeated = isDefeated(betAgainstId)
133133 if (if (!(betForDefeated))
134134 then !(betAgainstDefeated)
135135 else false)
136136 then throw("no side approved defeat")
137137 else {
138138 let winnerId = if (betForDefeated)
139139 then betAgainstId
140140 else betForId
141141 let winnerAddress = getString(this, (winnerId + "_owner"))
142142 if ((winnerAddress != toBase58String(i.caller.bytes)))
143143 then throw("paywinner() should be called by winner only")
144144 else {
145145 let amount = extract(getInteger(this, (matchId + "_amount")))
146146 repayFee(i, WriteSet([DataEntry((matchId + "_paid"), amount)]), amount)
147147 }
148148 }
149149 }
150150
151151

github/deemru/w8io/026f985 
30.35 ms