tx · AvNmEXL9mz6UCxcT6Hv42SYb7F2zBCH8XL2uKY9Tdzms 3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb: -0.01400000 Waves 2019.09.17 17:48 [680384] smart account 3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb > SELF 0.00000000 Waves
{ "type": 13, "id": "AvNmEXL9mz6UCxcT6Hv42SYb7F2zBCH8XL2uKY9Tdzms", "fee": 1400000, "feeAssetId": null, "timestamp": 1568731767247, "version": 1, "sender": "3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb", "senderPublicKey": "5vyi92HdgdTabKCQzDHGrgQ4ASjtoT3XrCUXr459sWuc", "proofs": [ "uLC8wP5aDLd6uDbNDx2bqf7H57po94uD8XZ3Fwwz86gCngWA7nNQE8vVdFNFKdbJBM24TYQDGkMRkiKwnfqdFbz" ], "script": "base64:AAIDAAAAAAAAAAAAAAAjAAAAAAROT05FAgAAAAABAAAAGGdldE51bWJlckJ5QWRkcmVzc0FuZEtleQAAAAIAAAAHYWRkcmVzcwAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAAdhZGRyZXNzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAEAAAAOZ2V0U3RyaW5nQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAA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YXZlbGV0BAAAAAZzdGF0dXMDCQAAZwAAAAIFAAAACmJvbmRBbW91bnQFAAAABmFtb3VudAUAAAAGRklMTEVEBQAAAANORVcJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxPcmRlckJvb2tLZXkFAAAADG5ld09yZGVyYm9vawkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAABNPcmRlckZpbGxlZFRvdGFsS2V5BQAAAAdvcmRlcklkCQAAZAAAAAIFAAAAC2ZpbGxlZFRvdGFsBQAAAAV0b3RhbAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAA5PcmRlclN0YXR1c0tleQUAAAAHb3JkZXJJZAUAAAAGc3RhdHVzBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAxmaWxsZWRBbW91bnQFAAAAC0JvbmRBc3NldElkCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAQTmV1dHJpbm9Db250cmFjdAUAAAAFdG90YWwFAAAAD05ldXRyaW5vQXNzZXRJZAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAEFAAAAEE5ldXRyaW5vQ29udHJhY3QFAAAADHJldHVybkFtb3VudAUAAAALQm9uZEFzc2V0SWQFAAAAA25pbAAAAAC/Mpf5", "chainId": 84, "height": 680384, "spentComplexity": 0 } View: original | compacted Prev: 6yq7WjkaBofqxGSfg3SF6Eetjb3gdHJ4tYRWYRdpmDDR Next: 82ff7UF6vdzGVw5Tiiv39a3tZj31vA1JngQFmQY9dXmc Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "" | |
5 | 5 | ||
6 | 6 | func getNumberByAddressAndKey (address,key) = match getInteger(addressFromStringValue(address), key) { | |
7 | 7 | case a: Int => | |
8 | 8 | a | |
9 | 9 | case _ => | |
10 | 10 | 0 | |
11 | 11 | } | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func getNumberByKey (key) = match getInteger(this, key) { | |
15 | 15 | case a: Int => | |
16 | 16 | a | |
17 | 17 | case _ => | |
18 | 18 | 0 | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func getStringByKey (key) = match getString(this, key) { | |
23 | 23 | case a: String => | |
24 | 24 | a | |
25 | 25 | case _ => | |
26 | 26 | NONE | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | let OrderBookKey = "orderbook" | |
31 | 31 | ||
32 | 32 | let OrderPriceKey = "order_price_" | |
33 | 33 | ||
34 | 34 | let OrderTotalKey = "order_total_" | |
35 | 35 | ||
36 | 36 | let OrderFilledTotalKey = "order_filled_total_" | |
37 | 37 | ||
38 | 38 | let OrderOwnerKey = "order_owner_" | |
39 | 39 | ||
40 | 40 | let OrderHeightKey = "order_height_" | |
41 | 41 | ||
42 | 42 | let OrderStatusKey = "order_status_" | |
43 | 43 | ||
44 | 44 | let PriceKey = "price" | |
45 | 45 | ||
46 | 46 | let BondAssetIdKey = "bond_asset_id" | |
47 | 47 | ||
48 | 48 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
49 | 49 | ||
50 | 50 | let NeutrinoContractKey = "neutrino_contract" | |
51 | 51 | ||
52 | 52 | let NeutrinoSupplyKey = "neutrino_supply" | |
53 | 53 | ||
54 | 54 | let WavesReserveKey = "waves_reserve" | |
55 | 55 | ||
56 | 56 | let orderbook = getStringByKey(OrderBookKey) | |
57 | 57 | ||
58 | 58 | func getOrderPrice (id) = getNumberByKey((OrderPriceKey + id)) | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func getOrderTotal (id) = getNumberByKey((OrderTotalKey + id)) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func getOrderOwner (id) = getStringByKey((OrderOwnerKey + id)) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func getOrderStatus (id) = getStringByKey((OrderStatusKey + id)) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func getOrderFilledTotal (id) = getNumberByKey((OrderFilledTotalKey + id)) | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | let NeutrinoContract = getStringByKey(NeutrinoContractKey) | |
74 | 74 | ||
75 | 75 | let reserve = getNumberByAddressAndKey(NeutrinoContract, WavesReserveKey) | |
76 | 76 | ||
77 | 77 | let neutrinoSupply = getNumberByAddressAndKey(NeutrinoContract, NeutrinoSupplyKey) | |
78 | 78 | ||
79 | 79 | let price = getNumberByAddressAndKey(NeutrinoContract, PriceKey) | |
80 | 80 | ||
81 | 81 | let OrderSplitSymbol = "_" | |
82 | 82 | ||
83 | 83 | let BondAssetId = fromBase58String(getStringByKey(BondAssetIdKey)) | |
84 | 84 | ||
85 | 85 | let NeutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey)) | |
86 | 86 | ||
87 | 87 | let Wavelet = 100000000 | |
88 | 88 | ||
89 | 89 | let CANCELED = "canceled" | |
90 | 90 | ||
91 | 91 | let NEW = "new" | |
92 | 92 | ||
93 | 93 | let FILLED = "filled" | |
94 | 94 | ||
95 | 95 | func calculateOrderbook (orderId,position) = { | |
96 | 96 | let orders = split(orderbook, OrderSplitSymbol) | |
97 | 97 | let newOrder = (orderId + OrderSplitSymbol) | |
98 | 98 | if ((position == 0)) | |
99 | 99 | then (newOrder + orderbook) | |
100 | 100 | else if ((position >= (size(orders) - 1))) | |
101 | 101 | then (orderbook + newOrder) | |
102 | 102 | else { | |
103 | 103 | let parts = split(orderbook, (orders[position] + OrderSplitSymbol)) | |
104 | 104 | (((parts[0] + newOrder) + (orders[position] + OrderSplitSymbol)) + parts[1]) | |
105 | 105 | } | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | @Callable(i) | |
110 | 110 | func setOrder (price,position) = { | |
111 | 111 | let pmt = extract(i.payment) | |
112 | 112 | let newOrderId = toBase58String(keccak256((((toBytes(price) + toBytes(pmt.amount)) + i.caller.bytes) + toBytes(height)))) | |
113 | 113 | if ((pmt.assetId != NeutrinoAssetId)) | |
114 | 114 | then throw("can use neutrino only") | |
115 | 115 | else if ((0 >= price)) | |
116 | 116 | then throw("price less zero") | |
117 | 117 | else if ((getOrderOwner(newOrderId) != NONE)) | |
118 | 118 | then throw("order exists") | |
119 | 119 | else { | |
120 | 120 | let orders = split(orderbook, OrderSplitSymbol) | |
121 | 121 | let nextOrderId = if ((position == 0)) | |
122 | 122 | then "" | |
123 | 123 | else orders[(position - 1)] | |
124 | 124 | let nextOrderPrice = getOrderPrice(nextOrderId) | |
125 | 125 | let isNextOrderError = if (if ((nextOrderId != "")) | |
126 | 126 | then (price > nextOrderPrice) | |
127 | 127 | else false) | |
128 | 128 | then true | |
129 | 129 | else false | |
130 | 130 | let prevOrderId = orders[position] | |
131 | 131 | let prevOrderPrice = getOrderPrice(prevOrderId) | |
132 | 132 | let isPrevOrderError = if ((prevOrderPrice >= price)) | |
133 | 133 | then true | |
134 | 134 | else false | |
135 | 135 | if (if (isNextOrderError) | |
136 | 136 | then true | |
137 | 137 | else isPrevOrderError) | |
138 | 138 | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
139 | 139 | else WriteSet([DataEntry(OrderBookKey, calculateOrderbook(newOrderId, position)), DataEntry((OrderPriceKey + newOrderId), price), DataEntry((OrderTotalKey + newOrderId), pmt.amount), DataEntry((OrderOwnerKey + newOrderId), toString(i.caller)), DataEntry((OrderHeightKey + newOrderId), height), DataEntry((OrderStatusKey + newOrderId), NEW)]) | |
140 | 140 | } | |
141 | 141 | } | |
142 | 142 | ||
143 | 143 | ||
144 | 144 | ||
145 | 145 | @Callable(i) | |
146 | 146 | func cancelOrder (orderId) = { | |
147 | 147 | let owner = getOrderOwner(orderId) | |
148 | 148 | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
149 | 149 | if ((owner != toString(i.caller))) | |
150 | 150 | then throw("permission denied") | |
151 | 151 | else { | |
152 | 152 | let parts = split(orderbook, (orderId + OrderSplitSymbol)) | |
153 | 153 | ScriptResult(WriteSet([DataEntry(OrderBookKey, (parts[0] + parts[1])), DataEntry((OrderStatusKey + orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, NeutrinoAssetId)])) | |
154 | 154 | } | |
155 | 155 | } | |
156 | 156 | ||
157 | 157 | ||
158 | 158 | ||
159 | 159 | @Callable(i) | |
160 | 160 | func executeOrder () = { | |
161 | 161 | let orderId = split(orderbook, OrderSplitSymbol)[0] | |
162 | 162 | let bondBalance = assetBalance(this, BondAssetId) | |
163 | 163 | let deficit = ((neutrinoSupply - ((reserve * price) / 100)) / Wavelet) | |
164 | 164 | let bondAmount = if ((deficit >= bondBalance)) | |
165 | 165 | then bondBalance | |
166 | 166 | else deficit | |
167 | 167 | let returnAmount = if ((deficit >= bondBalance)) | |
168 | 168 | then 0 | |
169 | 169 | else (bondBalance - deficit) | |
170 | 170 | if ((bondAmount == 0)) | |
171 | 171 | then TransferSet([ScriptTransfer(addressFromStringValue(NeutrinoContract), returnAmount, BondAssetId)]) | |
172 | 172 | else { | |
173 | 173 | let filledTotal = getOrderFilledTotal(orderId) | |
174 | 174 | let orderTotal = getOrderTotal(orderId) | |
175 | 175 | let orderPrice = getOrderPrice(orderId) | |
176 | 176 | let amount = ((((orderTotal - filledTotal) * 100) / orderPrice) / Wavelet) | |
177 | 177 | let newOrderbook = if ((bondAmount >= amount)) | |
178 | 178 | then split(orderbook, (orderId + OrderSplitSymbol))[1] | |
179 | 179 | else orderbook | |
180 | 180 | let filledAmount = if ((bondAmount >= amount)) | |
181 | 181 | then amount | |
182 | 182 | else bondAmount | |
183 | 183 | let total = (((filledAmount * orderPrice) / 100) * Wavelet) | |
184 | 184 | let status = if ((bondAmount >= amount)) | |
185 | 185 | then FILLED | |
186 | 186 | else NEW | |
187 | 187 | ScriptResult(WriteSet([DataEntry(OrderBookKey, newOrderbook), DataEntry((OrderFilledTotalKey + orderId), (filledTotal + total)), DataEntry((OrderStatusKey + orderId), status)]), TransferSet([ScriptTransfer(i.caller, filledAmount, BondAssetId), ScriptTransfer(addressFromStringValue(NeutrinoContract), total, NeutrinoAssetId), ScriptTransfer(addressFromStringValue(NeutrinoContract), returnAmount, BondAssetId)])) | |
188 | 188 | } | |
189 | 189 | } | |
190 | 190 | ||
191 | 191 |
github/deemru/w8io/169f3d6 36.23 ms ◑