tx · ECMx6uzT9saTaxjDdHWmqWSdMQW8EPTvK3RCuD75K7mu 3Mv3BEQ8WS2wzrEXuSfxDm7U9UKb5qLSnUc: -0.01400000 Waves 2019.08.10 15:52 [624949] smart account 3Mv3BEQ8WS2wzrEXuSfxDm7U9UKb5qLSnUc > SELF 0.00000000 Waves
{ "type": 13, "id": "ECMx6uzT9saTaxjDdHWmqWSdMQW8EPTvK3RCuD75K7mu", "fee": 1400000, "feeAssetId": null, "timestamp": 1565441553374, "version": 1, "sender": "3Mv3BEQ8WS2wzrEXuSfxDm7U9UKb5qLSnUc", "senderPublicKey": "BoKgJQhf9RWMmneqYEhyMKeUXMCYRJRhaBTDd2w1Rtx", "proofs": [ "38CnGyuRu6bthaw13VhJrHnHANje6sz9sXwKu9YhogXnKJ8ahYHXaSCDaPoiJJkTdWTjq2RQLj8giVVG4uogeVPg" ], "script": "base64:AAIDAAAAAAAAAAAAAAACAAAAAApWU1RBc3NldElEAQAAACCucYFuBYSotpFz1qoINfKJVo0JlR9XCghLbxw/TM2XswAAAAANZWlnaHREZWNpbWFscwAAAAAABfXhAAAAAAYAAAABaQEAAAALbWFrZVNlbGxWU1QAAAABAAAABXByaWNlAwkAAGcAAAACAAAAAAAAAAAABQAAAAVwcmljZQkAAAIAAAABAgAAABZwcmljZSBtdXN0IGJlIHBvc2l0aXZlBAAAAAdwYXltZW50CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQDCQEAAAACIT0AAAACCAUAAAAHcGF5bWVudAAAAAdhc3NldElkBQAAAApWU1RBc3NldElECQAAAgAAAAEJAAEsAAAAAgIAAAARYXNzZXQgaWQgbXVzdCBiZSAJAAJYAAAAAQUAAAAKVlNUQXNzZXRJRAQAAAAHb3JkZXJJZAkAASwAAAACAgAAAAVzZWxsXwkAAlgAAAABCAUAAAABaQAAAA10cmFuc2FjdGlvbklkCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACC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0byByZXR1cm4JAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAAB29yZGVySWQCAAAABl9zcGVudAUAAAAGYW1vdW50BQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAxyZXR1cm5BbW91bnQFAAAAClZTVEFzc2V0SUQFAAAAA25pbAAAAADPvwYJ", "chainId": 84, "height": 624949, "spentComplexity": 0 } View: original | compacted Prev: ERez6Q6cANpEW59DejHKMXyjFddobRj7GRrpRBimVqNb Next: 98aJXBwkB6LwXbGfASM3CZZVzreBYBFA1Eghu4HVYD85 Diff:
Old | New | Differences | |
---|---|---|---|
6 | 6 | let eightDecimals = 100000000 | |
7 | 7 | ||
8 | 8 | @Callable(i) | |
9 | - | func makeSellVST (price) = { | |
10 | - | let payment = extract(i.payment) | |
11 | - | if ((payment.assetId != VSTAssetID)) | |
12 | - | then throw(("asset id must be " + toBase58String(VSTAssetID))) | |
13 | - | else { | |
14 | - | let orderId = ("sell_" + toBase58String(i.transactionId)) | |
15 | - | WriteSet([DataEntry((orderId + "_amount"), payment.amount), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
16 | - | } | |
17 | - | } | |
9 | + | func makeSellVST (price) = if ((0 >= price)) | |
10 | + | then throw("price must be positive") | |
11 | + | else { | |
12 | + | let payment = extract(i.payment) | |
13 | + | if ((payment.assetId != VSTAssetID)) | |
14 | + | then throw(("asset id must be " + toBase58String(VSTAssetID))) | |
15 | + | else { | |
16 | + | let orderId = ("sell_" + toBase58String(i.transactionId)) | |
17 | + | WriteSet([DataEntry((orderId + "_amount"), payment.amount), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
18 | + | } | |
19 | + | } | |
18 | 20 | ||
19 | 21 | ||
20 | 22 | ||
21 | 23 | @Callable(i) | |
22 | - | func makeBuyVST (price) = { | |
23 | - | let payment = extract(i.payment) | |
24 | - | if ((payment.assetId != unit)) | |
25 | - | then throw("asset id must be WAVES") | |
26 | - | else { | |
27 | - | let orderId = ("buy_" + toBase58String(i.transactionId)) | |
28 | - | WriteSet([DataEntry((orderId + "_amount"), ((payment.amount * price) / eightDecimals)), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
29 | - | } | |
30 | - | } | |
24 | + | func makeBuyVST (price) = if ((0 >= price)) | |
25 | + | then throw("price must be positive") | |
26 | + | else { | |
27 | + | let payment = extract(i.payment) | |
28 | + | if ((payment.assetId != unit)) | |
29 | + | then throw("asset id must be WAVES") | |
30 | + | else { | |
31 | + | let orderId = ("buy_" + toBase58String(i.transactionId)) | |
32 | + | WriteSet([DataEntry((orderId + "_amount"), ((payment.amount * price) / eightDecimals)), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
33 | + | } | |
34 | + | } | |
31 | 35 | ||
32 | 36 | ||
33 | 37 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let VSTAssetID = base58'CjxKp2kfytghpfforkYLSoXHzJyJ5QYKLYQYgN7pQV4E' | |
5 | 5 | ||
6 | 6 | let eightDecimals = 100000000 | |
7 | 7 | ||
8 | 8 | @Callable(i) | |
9 | - | func makeSellVST (price) = { | |
10 | - | let payment = extract(i.payment) | |
11 | - | if ((payment.assetId != VSTAssetID)) | |
12 | - | then throw(("asset id must be " + toBase58String(VSTAssetID))) | |
13 | - | else { | |
14 | - | let orderId = ("sell_" + toBase58String(i.transactionId)) | |
15 | - | WriteSet([DataEntry((orderId + "_amount"), payment.amount), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
16 | - | } | |
17 | - | } | |
9 | + | func makeSellVST (price) = if ((0 >= price)) | |
10 | + | then throw("price must be positive") | |
11 | + | else { | |
12 | + | let payment = extract(i.payment) | |
13 | + | if ((payment.assetId != VSTAssetID)) | |
14 | + | then throw(("asset id must be " + toBase58String(VSTAssetID))) | |
15 | + | else { | |
16 | + | let orderId = ("sell_" + toBase58String(i.transactionId)) | |
17 | + | WriteSet([DataEntry((orderId + "_amount"), payment.amount), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
18 | + | } | |
19 | + | } | |
18 | 20 | ||
19 | 21 | ||
20 | 22 | ||
21 | 23 | @Callable(i) | |
22 | - | func makeBuyVST (price) = { | |
23 | - | let payment = extract(i.payment) | |
24 | - | if ((payment.assetId != unit)) | |
25 | - | then throw("asset id must be WAVES") | |
26 | - | else { | |
27 | - | let orderId = ("buy_" + toBase58String(i.transactionId)) | |
28 | - | WriteSet([DataEntry((orderId + "_amount"), ((payment.amount * price) / eightDecimals)), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
29 | - | } | |
30 | - | } | |
24 | + | func makeBuyVST (price) = if ((0 >= price)) | |
25 | + | then throw("price must be positive") | |
26 | + | else { | |
27 | + | let payment = extract(i.payment) | |
28 | + | if ((payment.assetId != unit)) | |
29 | + | then throw("asset id must be WAVES") | |
30 | + | else { | |
31 | + | let orderId = ("buy_" + toBase58String(i.transactionId)) | |
32 | + | WriteSet([DataEntry((orderId + "_amount"), ((payment.amount * price) / eightDecimals)), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
33 | + | } | |
34 | + | } | |
31 | 35 | ||
32 | 36 | ||
33 | 37 | ||
34 | 38 | @Callable(i) | |
35 | 39 | func takeSellVST (id) = { | |
36 | 40 | let orderId = ("sell_" + id) | |
37 | 41 | let payment = extract(i.payment) | |
38 | 42 | if ((payment.assetId != unit)) | |
39 | 43 | then throw("asset must be WAVES") | |
40 | 44 | else { | |
41 | 45 | let price = getIntegerValue(this, (orderId + "_price")) | |
42 | 46 | let wavesAmount = payment.amount | |
43 | 47 | let vstAmount = ((wavesAmount * price) / eightDecimals) | |
44 | 48 | let amount = getIntegerValue(this, (orderId + "_amount")) | |
45 | 49 | let spent = getIntegerValue(this, (orderId + "_spent")) | |
46 | 50 | let newSpent = (spent + vstAmount) | |
47 | 51 | if ((newSpent > amount)) | |
48 | 52 | then throw("not enougth asset in order") | |
49 | 53 | else ScriptResult(WriteSet([DataEntry((orderId + "_spent"), newSpent)]), TransferSet([ScriptTransfer(i.caller, vstAmount, VSTAssetID)])) | |
50 | 54 | } | |
51 | 55 | } | |
52 | 56 | ||
53 | 57 | ||
54 | 58 | ||
55 | 59 | @Callable(i) | |
56 | 60 | func takeBuyVST (id) = { | |
57 | 61 | let orderId = ("buy_" + id) | |
58 | 62 | let payment = extract(i.payment) | |
59 | 63 | if ((payment.assetId != VSTAssetID)) | |
60 | 64 | then throw(("asset must be " + toBase58String(VSTAssetID))) | |
61 | 65 | else { | |
62 | 66 | let price = getIntegerValue(this, (orderId + "_price")) | |
63 | 67 | let vstAmount = payment.amount | |
64 | 68 | let wavesAmount = ((vstAmount * eightDecimals) / price) | |
65 | 69 | let amount = getIntegerValue(this, (orderId + "_amount")) | |
66 | 70 | let spent = getIntegerValue(this, (orderId + "_spent")) | |
67 | 71 | let newSpent = (spent + vstAmount) | |
68 | 72 | if ((newSpent > amount)) | |
69 | 73 | then throw("not enougth asset in order") | |
70 | 74 | else ScriptResult(WriteSet([DataEntry((orderId + "_spent"), newSpent)]), TransferSet([ScriptTransfer(i.caller, wavesAmount, unit)])) | |
71 | 75 | } | |
72 | 76 | } | |
73 | 77 | ||
74 | 78 | ||
75 | 79 | ||
76 | 80 | @Callable(i) | |
77 | 81 | func returnBuyVST (id) = { | |
78 | 82 | let orderId = ("buy_" + id) | |
79 | 83 | let owner = getStringValue(this, (orderId + "_owner")) | |
80 | 84 | if ((owner != toBase58String(i.caller.bytes))) | |
81 | 85 | then throw("return should be called by order owner") | |
82 | 86 | else { | |
83 | 87 | let amount = getIntegerValue(this, (orderId + "_amount")) | |
84 | 88 | let spent = getIntegerValue(this, (orderId + "_spent")) | |
85 | 89 | let price = getIntegerValue(this, (orderId + "_price")) | |
86 | 90 | let returnAmount = (((amount - spent) * eightDecimals) / price) | |
87 | 91 | if ((0 >= returnAmount)) | |
88 | 92 | then throw("nothing to return") | |
89 | 93 | else ScriptResult(WriteSet([DataEntry((orderId + "_spent"), amount)]), TransferSet([ScriptTransfer(i.caller, returnAmount, unit)])) | |
90 | 94 | } | |
91 | 95 | } | |
92 | 96 | ||
93 | 97 | ||
94 | 98 | ||
95 | 99 | @Callable(i) | |
96 | 100 | func returnSellVST (id) = { | |
97 | 101 | let orderId = ("sell_" + id) | |
98 | 102 | let owner = getStringValue(this, (orderId + "_owner")) | |
99 | 103 | if ((owner != toBase58String(i.caller.bytes))) | |
100 | 104 | then throw("return should be called by order owner") | |
101 | 105 | else { | |
102 | 106 | let amount = getIntegerValue(this, (orderId + "_amount")) | |
103 | 107 | let spent = getIntegerValue(this, (orderId + "_spent")) | |
104 | 108 | let returnAmount = (amount - spent) | |
105 | 109 | if ((0 >= returnAmount)) | |
106 | 110 | then throw("nothing to return") | |
107 | 111 | else ScriptResult(WriteSet([DataEntry((orderId + "_spent"), amount)]), TransferSet([ScriptTransfer(i.caller, returnAmount, VSTAssetID)])) | |
108 | 112 | } | |
109 | 113 | } | |
110 | 114 | ||
111 | 115 |
github/deemru/w8io/026f985 35.40 ms ◑