tx · AyGhNRRjwJZeotFT4HmhjTvzj2ueVujUtM4XZXAjGA8E 3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv: -0.01400000 Waves 2019.09.13 01:39 [673552] smart account 3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv > SELF 0.00000000 Waves
{ "type": 13, "id": "AyGhNRRjwJZeotFT4HmhjTvzj2ueVujUtM4XZXAjGA8E", "fee": 1400000, "feeAssetId": null, "timestamp": 1568327834383, "version": 1, "sender": "3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv", "senderPublicKey": "BxHnTcjvN9ZtnKfdKYp6aKRdkMB4ZHxHnTDr5dWx5Vz2", "proofs": [ "3KhxTyr7gddWFmEEtqS3mhnKxAsih2NdSQP1Fx7wAauSwtmXyJLRTwqXs1CsQZ4NB84zm5F54CjASKs3XhMjbAHz" ], "script": "base64:AAIDAAAAAAAAAAAAAAAAAAAAAwAAAAFpAQAAAAhtYWtlU2VsbAAAAAIAAAAKcHJpY2VBc3NldAAAAAVwcmljZQMDCQEAAAACIT0AAAACBQAAAApwcmljZUFzc2V0AgAAAAVXQVZFUwkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQkAA+wAAAABCQACWQAAAAEFAAAACnByaWNlQXNzZXQHCQAAAgAAAAECAAAAI1RoZXJlIGlzIG5vIGFzc2V0IHdpdGggc3BlY2lmaWVkIGlkAwkAAGcAAAACAAAAAAAAAAAABQAAAAVwcmljZQkAAAIAAAABAgAAABZwcmljZSBtdXN0IGJlIHBvc2l0aXZlBAAAAAdwYXltZW50CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIIBQAAAAFpAAAAB3BheW1lbnQCAAAAEXdoZXJlIGlzIHBheW1lbnQ/AwkAAGcAAAACAAAAAAAAAAAACAUAAAAHcGF5bWVudAAAAAZhbW91bnQJAAACAAAAAQIAAAAXYW1vdW50IG11c3QgYmUgcG9zaXRpdmUEAAAAB29yZGVySWQJAAEsAAAAAg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RoaXMJAAEsAAAAAgUAAAAHb3JkZXJJZAIAAAAGX3NwZW50AwkAAGYAAAACBQAAAAlidXlBbW91bnQJAABlAAAAAgUAAAAGYW1vdW50BQAAAAVzcGVudAkAAAIAAAABAgAAABpub3QgZW5vdWd0aCBhc3NldCBpbiBvcmRlcgkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAHb3JkZXJJZAIAAAAGX3NwZW50CQAAZAAAAAIFAAAABXNwZW50BQAAAAlidXlBbW91bnQFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAACWJ1eUFtb3VudAMJAAAAAAAAAgUAAAALYW1vdW50QXNzZXQCAAAABVdBVkVTBQAAAAR1bml0CQACWQAAAAEFAAAAC2Ftb3VudEFzc2V0CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAABW93bmVyCAUAAAAHcGF5bWVudAAAAAZhbW91bnQDCQAAAAAAAAIFAAAACnByaWNlQXNzZXQCAAAABVdBVkVTBQAAAAR1bml0CQACWQAAAAEFAAAACnByaWNlQXNzZXQFAAAAA25pbAAAAADzw2Hm", "chainId": 84, "height": 673552, "spentComplexity": 0 } View: original | compacted Prev: 2o3byrNsvjNQE8iZ2QJxWZ3ZYTwiAyezBtfjabg81wx8 Next: 6sqhkPor8Z35qph7Qgos3gpnv69H9UoiuSFZyMg4iXWA Diff:
Old | New | Differences | |
---|---|---|---|
88 | 88 | let m = if ((f == "WAVES")) | |
89 | 89 | then 8 | |
90 | 90 | else value(assetInfo(fromBase58String(f))).decimals | |
91 | - | let n = (d.amount / c) | |
91 | + | let n = ((d.amount * pow(10, 0, m, 0, 0, CEILING)) / c) | |
92 | 92 | if ((n == 0)) | |
93 | 93 | then throw("invalid amount") | |
94 | 94 | else { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(a) | |
7 | 7 | func makeSell (b,c) = if (if ((b != "WAVES")) | |
8 | 8 | then !(isDefined(assetInfo(fromBase58String(b)))) | |
9 | 9 | else false) | |
10 | 10 | then throw("There is no asset with specified id") | |
11 | 11 | else if ((0 >= c)) | |
12 | 12 | then throw("price must be positive") | |
13 | 13 | else { | |
14 | 14 | let d = valueOrErrorMessage(a.payment, "where is payment?") | |
15 | 15 | if ((0 >= d.amount)) | |
16 | 16 | then throw("amount must be positive") | |
17 | 17 | else { | |
18 | 18 | let e = ("sell_" + toBase58String(a.transactionId)) | |
19 | 19 | let f = { | |
20 | 20 | let g = d.assetId | |
21 | 21 | if ($isInstanceOf(g, "ByteVector")) | |
22 | 22 | then { | |
23 | 23 | let h = g | |
24 | 24 | toBase58String(h) | |
25 | 25 | } | |
26 | 26 | else "WAVES" | |
27 | 27 | } | |
28 | 28 | WriteSet([DataEntry((e + "_amount"), d.amount), DataEntry((e + "_amount_asset"), f), DataEntry((e + "_price"), c), DataEntry((e + "_price_asset"), b), DataEntry((e + "_owner"), toBase58String(a.caller.bytes)), DataEntry((e + "_spent"), 0)]) | |
29 | 29 | } | |
30 | 30 | } | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | 34 | @Callable(a) | |
35 | 35 | func makeBuy (f,c) = if (if ((f != "WAVES")) | |
36 | 36 | then !(isDefined(assetInfo(fromBase58String(f)))) | |
37 | 37 | else false) | |
38 | 38 | then throw("There is no asset with specified id") | |
39 | 39 | else if ((0 >= c)) | |
40 | 40 | then throw("price must be positive") | |
41 | 41 | else { | |
42 | 42 | let d = valueOrErrorMessage(a.payment, "where is payment?") | |
43 | 43 | if ((0 >= d.amount)) | |
44 | 44 | then throw("amount must be positive") | |
45 | 45 | else { | |
46 | 46 | let e = ("buy_" + toBase58String(a.transactionId)) | |
47 | 47 | let b = { | |
48 | 48 | let g = d.assetId | |
49 | 49 | if ($isInstanceOf(g, "ByteVector")) | |
50 | 50 | then { | |
51 | 51 | let h = g | |
52 | 52 | toBase58String(h) | |
53 | 53 | } | |
54 | 54 | else "WAVES" | |
55 | 55 | } | |
56 | 56 | WriteSet([DataEntry((e + "_amount"), (d.amount / c)), DataEntry((e + "_amount_asset"), f), DataEntry((e + "_price"), c), DataEntry((e + "_price_asset"), b), DataEntry((e + "_owner"), toBase58String(a.caller.bytes)), DataEntry((e + "_spent"), 0)]) | |
57 | 57 | } | |
58 | 58 | } | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | 62 | @Callable(a) | |
63 | 63 | func takeSell (i) = { | |
64 | 64 | let d = valueOrErrorMessage(a.payment, "where is payment?") | |
65 | 65 | if ((0 >= d.amount)) | |
66 | 66 | then throw("amount must be positive") | |
67 | 67 | else { | |
68 | 68 | let e = ("sell_" + i) | |
69 | 69 | let j = { | |
70 | 70 | let g = d.assetId | |
71 | 71 | if ($isInstanceOf(g, "ByteVector")) | |
72 | 72 | then { | |
73 | 73 | let h = g | |
74 | 74 | toBase58String(h) | |
75 | 75 | } | |
76 | 76 | else "WAVES" | |
77 | 77 | } | |
78 | 78 | let b = valueOrErrorMessage(getString(this, (e + "_price_asset")), "there is no order with specified id") | |
79 | 79 | if ((b != j)) | |
80 | 80 | then throw(("payment asset must be " + b)) | |
81 | 81 | else { | |
82 | 82 | let c = getIntegerValue(this, (e + "_price")) | |
83 | 83 | let k = getIntegerValue(this, (e + "_amount")) | |
84 | 84 | let f = getStringValue(this, (e + "_amount_asset")) | |
85 | 85 | let l = if ((j == "WAVES")) | |
86 | 86 | then 8 | |
87 | 87 | else value(assetInfo(fromBase58String(j))).decimals | |
88 | 88 | let m = if ((f == "WAVES")) | |
89 | 89 | then 8 | |
90 | 90 | else value(assetInfo(fromBase58String(f))).decimals | |
91 | - | let n = (d.amount / c) | |
91 | + | let n = ((d.amount * pow(10, 0, m, 0, 0, CEILING)) / c) | |
92 | 92 | if ((n == 0)) | |
93 | 93 | then throw("invalid amount") | |
94 | 94 | else { | |
95 | 95 | let o = value(addressFromString(getStringValue(this, (e + "_owner")))) | |
96 | 96 | let p = getIntegerValue(this, (e + "_spent")) | |
97 | 97 | if ((n > (k - p))) | |
98 | 98 | then throw("not enougth asset in order") | |
99 | 99 | else ScriptResult(WriteSet([DataEntry((e + "_spent"), (p + n))]), TransferSet([ScriptTransfer(a.caller, n, if ((f == "WAVES")) | |
100 | 100 | then unit | |
101 | 101 | else fromBase58String(f)), ScriptTransfer(o, d.amount, if ((b == "WAVES")) | |
102 | 102 | then unit | |
103 | 103 | else fromBase58String(b))])) | |
104 | 104 | } | |
105 | 105 | } | |
106 | 106 | } | |
107 | 107 | } | |
108 | 108 | ||
109 | 109 |
github/deemru/w8io/169f3d6 29.65 ms ◑