tx · ZEyNxuFEWDP4ZzyYi1yrabGhF5apn1mxqbbPiA2X3me 3MtjjEoEs6Rcqkh8tYjPmBxZND58FuMtRWN: -0.05000000 Waves 2022.09.08 16:53 [2220209] smart account 3MtjjEoEs6Rcqkh8tYjPmBxZND58FuMtRWN > SELF 0.00000000 Waves
{ "type": 13, "id": "ZEyNxuFEWDP4ZzyYi1yrabGhF5apn1mxqbbPiA2X3me", "fee": 5000000, "feeAssetId": null, "timestamp": 1662645213357, "version": 2, "chainId": 84, "sender": "3MtjjEoEs6Rcqkh8tYjPmBxZND58FuMtRWN", "senderPublicKey": "GR35NTmt1JUgBMwuwSK6aFSmLN7g6eZKbYvfSV3ThdWR", "proofs": [ "zTWmNj5iknBf4FpE7ri89re9UWBjxecBrpvJ87Crh8521tYVoepBe3sDFLki9XS7fax28ipFHLqgbifH2k2wCnc" ], "script": "base64:AAIFAAAAAAAAABMIAhIECgIIARIDCgEIEgQKAggIAAAABQAAAAAPcHJveHlBZGRyZXNzU3RyAgAAACMzTkFtM3A2MmJvNHEzeU16V2pKNk00ZUVEQlJZWHhxa1hMUQEAAAAMdHJ5R2V0U3RyaW5nAAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWICAAAAAAEAAAANdHJ5R2V0SW50ZWdlcgAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAAAQAAAA5nZXRBc3NldFN0cmluZwAAAAEAAAAHYXNzZXRJZAQAAAAHJG1hdGNoMAUAAAAHYXNzZXRJZAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAKQnl0ZVZlY3RvcgQAAAAB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AQIAAAAXWW91IGNhbm5vdCBjYW5jZWwgb3JkZXIDAwkAAAAAAAACCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMFAAAAD3Byb3h5QWRkcmVzc1N0cgkBAAAAAiE9AAAAAgUAAAALcHJveHlDYWxsZXIFAAAACm9yZGVyT3duZXIHCQAAAgAAAAECAAAAF1lvdSBjYW5ub3QgY2FuY2VsIG9yZGVyAwkBAAAAAiE9AAAAAgUAAAALb3JkZXJTdGF0dXMCAAAABmFjdGl2ZQkAAAIAAAABAgAAABtvcmRlciBpcyBjbG9zZWQgb3IgY2FuY2VsZWQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAAKb3JkZXJPd25lcgUAAAAQb3JkZXJBbW91bnQwTGVmdAkBAAAADWdldEFzc2V0Qnl0ZXMAAAABBQAAAAtvcmRlckFzc2V0MAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAGb3JkZXJfBQAAAAdvcmRlcklkAgAAAAdfc3RhdHVzAgAAAAhjYW5jZWxlZAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXlVa58M", "height": 2220209, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6Mg8yw3pcR9ACUaWfYJmtemXxjVtzEFijULHqBHi8Tn1 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
99 | 99 | let orderFulfilled0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_fulfilled0")), "Cannot find fulfilled0") | |
100 | 100 | let orderAmount0Left = (orderAmount0 - orderFulfilled0) | |
101 | 101 | if (if ((toBase58String(i.caller.bytes) != orderOwner)) | |
102 | - | then | |
103 | - | else | |
102 | + | then (toBase58String(i.caller.bytes) != proxyAddressStr) | |
103 | + | else false) | |
104 | 104 | then throw("You cannot cancel order") | |
105 | 105 | else if (if ((toBase58String(i.caller.bytes) == proxyAddressStr)) | |
106 | 106 | then (proxyCaller != orderOwner) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let proxyAddressStr = "3NAm3p62bo4q3yMzWjJ6M4eEDBRYXxqkXLQ" | |
5 | 5 | ||
6 | 6 | func tryGetString (key) = match getString(this, key) { | |
7 | 7 | case b: String => | |
8 | 8 | b | |
9 | 9 | case _ => | |
10 | 10 | "" | |
11 | 11 | } | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func tryGetInteger (key) = match getInteger(this, key) { | |
15 | 15 | case b: Int => | |
16 | 16 | b | |
17 | 17 | case _ => | |
18 | 18 | 0 | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func getAssetString (assetId) = match assetId { | |
23 | 23 | case b: ByteVector => | |
24 | 24 | toBase58String(b) | |
25 | 25 | case _ => | |
26 | 26 | "WAVES" | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES")) | |
31 | 31 | then unit | |
32 | 32 | else fromBase58String(assetIdStr) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | @Callable(i) | |
36 | 36 | func createOrder (asset1,amount1) = { | |
37 | 37 | let newOrdersAmount = (tryGetInteger("global_ordersAmount") + 1) | |
38 | 38 | let orderId = toString(newOrdersAmount) | |
39 | 39 | if ((size(i.payments) != 1)) | |
40 | 40 | then throw("You should to provide payment") | |
41 | 41 | else if ((0 >= amount1)) | |
42 | 42 | then throw("Amount1 cannot be less or equals 0") | |
43 | 43 | else { | |
44 | 44 | let asset0 = getAssetString(i.payments[0].assetId) | |
45 | 45 | let amount0 = i.payments[0].amount | |
46 | 46 | let userOrders = tryGetString((("user_" + toString(i.caller)) + "_orders")) | |
47 | 47 | let newUserOrders = match userOrders { | |
48 | 48 | case _ => | |
49 | 49 | if (("" == $match0)) | |
50 | 50 | then orderId | |
51 | 51 | else ((userOrders + ",") + orderId) | |
52 | 52 | } | |
53 | 53 | [IntegerEntry("global_ordersAmount", newOrdersAmount), StringEntry((("order_" + orderId) + "_token0"), asset0), IntegerEntry((("order_" + orderId) + "_amount0"), amount0), IntegerEntry((("order_" + orderId) + "_amount1"), amount1), StringEntry((("order_" + orderId) + "_token1"), asset1), IntegerEntry((("order_" + orderId) + "_fulfilled0"), 0), IntegerEntry((("order_" + orderId) + "_fulfilled1"), 0), StringEntry((("order_" + orderId) + "_owner"), toString(i.caller)), StringEntry((("order_" + orderId) + "_status"), "active"), StringEntry((("user_" + toString(i.caller)) + "_orders"), newUserOrders)] | |
54 | 54 | } | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | 59 | @Callable(i) | |
60 | 60 | func fulfillOrder (orderId) = { | |
61 | 61 | let orderOwner = valueOrErrorMessage(getString((("order_" + orderId) + "_owner")), "Cannot find order owner") | |
62 | 62 | let orderStatus = getString((("order_" + orderId) + "_status")) | |
63 | 63 | let orderAsset0 = valueOrErrorMessage(getString((("order_" + orderId) + "_token0")), "Cannot find token0") | |
64 | 64 | let orderAmount0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_amount0")), "Cannot find amount0") | |
65 | 65 | let orderFulfilled0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_fulfilled0")), "Cannot find fulfilled0") | |
66 | 66 | let orderAmount0Left = (orderAmount0 - orderFulfilled0) | |
67 | 67 | let orderAsset1 = valueOrErrorMessage(getString((("order_" + orderId) + "_token1")), "Cannot find token1") | |
68 | 68 | let orderAmount1 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_amount1")), "Cannot find amount1") | |
69 | 69 | let orderFulfilled1 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_fulfilled1")), "Cannot find fulfilled1") | |
70 | 70 | let orderAmount1Left = (orderAmount1 - orderFulfilled1) | |
71 | 71 | if ((orderStatus != "active")) | |
72 | 72 | then throw("Order already closed or canceled") | |
73 | 73 | else if ((size(i.payments) != 1)) | |
74 | 74 | then throw("You should to provide payment") | |
75 | 75 | else { | |
76 | 76 | let callerAddress = i.caller | |
77 | 77 | let ownerAddress = addressFromStringValue(orderOwner) | |
78 | 78 | let paymentAsset1 = getAssetString(i.payments[0].assetId) | |
79 | 79 | let paymentAmount1 = i.payments[0].amount | |
80 | 80 | if ((paymentAsset1 != orderAsset1)) | |
81 | 81 | then throw("Wrong payment asset") | |
82 | 82 | else if ((paymentAmount1 >= orderAmount1Left)) | |
83 | 83 | then [ScriptTransfer(callerAddress, (paymentAmount1 - orderAmount1Left), getAssetBytes(orderAsset1)), ScriptTransfer(callerAddress, orderAmount0Left, getAssetBytes(orderAsset0)), ScriptTransfer(ownerAddress, orderAmount1Left, getAssetBytes(paymentAsset1)), IntegerEntry((("order_" + orderId) + "_fulfilled0"), (orderFulfilled0 + orderAmount0Left)), IntegerEntry((("order_" + orderId) + "_fulfilled1"), (orderFulfilled1 + orderAmount1Left)), StringEntry((("order_" + orderId) + "_status"), "closed")] | |
84 | 84 | else { | |
85 | 85 | let amount0 = fraction(orderAmount0, paymentAmount1, orderAmount1, FLOOR) | |
86 | 86 | [ScriptTransfer(ownerAddress, paymentAmount1, getAssetBytes(paymentAsset1)), ScriptTransfer(callerAddress, amount0, getAssetBytes(orderAsset0)), IntegerEntry((("order_" + orderId) + "_fulfilled0"), (orderFulfilled0 + amount0)), IntegerEntry((("order_" + orderId) + "_fulfilled1"), (orderFulfilled1 + paymentAmount1))] | |
87 | 87 | } | |
88 | 88 | } | |
89 | 89 | } | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Callable(i) | |
94 | 94 | func cancelOrder (orderId,proxyCaller) = { | |
95 | 95 | let orderOwner = valueOrErrorMessage(getString((("order_" + orderId) + "_owner")), "Cannot find order owner") | |
96 | 96 | let orderStatus = getString((("order_" + orderId) + "_status")) | |
97 | 97 | let orderAsset0 = valueOrErrorMessage(getString((("order_" + orderId) + "_token0")), "Cannot find token0") | |
98 | 98 | let orderAmount0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_amount0")), "Cannot find amount0") | |
99 | 99 | let orderFulfilled0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_fulfilled0")), "Cannot find fulfilled0") | |
100 | 100 | let orderAmount0Left = (orderAmount0 - orderFulfilled0) | |
101 | 101 | if (if ((toBase58String(i.caller.bytes) != orderOwner)) | |
102 | - | then | |
103 | - | else | |
102 | + | then (toBase58String(i.caller.bytes) != proxyAddressStr) | |
103 | + | else false) | |
104 | 104 | then throw("You cannot cancel order") | |
105 | 105 | else if (if ((toBase58String(i.caller.bytes) == proxyAddressStr)) | |
106 | 106 | then (proxyCaller != orderOwner) | |
107 | 107 | else false) | |
108 | 108 | then throw("You cannot cancel order") | |
109 | 109 | else if ((orderStatus != "active")) | |
110 | 110 | then throw("order is closed or canceled") | |
111 | 111 | else [ScriptTransfer(addressFromStringValue(orderOwner), orderAmount0Left, getAssetBytes(orderAsset0)), StringEntry((("order_" + orderId) + "_status"), "canceled")] | |
112 | 112 | } | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | @Verifier(tx) | |
116 | 116 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
117 | 117 |
github/deemru/w8io/026f985 48.84 ms ◑