tx · 4gUdK8m5AW1i7V99LMhDzajkGG64k8UExbA9waGYMBBK 3N7d3jPxKqSi3XVnAgg8oFsHLcrgctFWpVw: -0.01400000 Waves 2019.11.01 22:39 [746228] smart account 3N7d3jPxKqSi3XVnAgg8oFsHLcrgctFWpVw > SELF 0.00000000 Waves
{ "type": 13, "id": "4gUdK8m5AW1i7V99LMhDzajkGG64k8UExbA9waGYMBBK", "fee": 1400000, "feeAssetId": null, "timestamp": 1572637219642, "version": 1, "sender": "3N7d3jPxKqSi3XVnAgg8oFsHLcrgctFWpVw", "senderPublicKey": "GHnaLgezSnGCGe7LuhRy8j4JzCcySjwndqh6X9xHQNhz", "proofs": [ "4QnYEj4KKApPMKTD3PSyas8YD9PCK9GAacLLsYS5euqnzqm6N7RoqWYDQPqNXpiZK3JmMdFZH3RLKUgo3SmxtmKV" ], "script": "base64:AAIDAAAAAAAAAA8IARIECgIBARIDCgEIEgAAAAA6AQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAgAAAAABAAAAGGdldFN0cmluZ0J5QWRkcmVzc0FuZEtleQAAAAIAAAAHYWRkcmVzcwAAAANrZXkEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWECAAAAAAEAAAAYZ2V0TnVtYmVyQn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HQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxPcmRlckJvb2tLZXkFAAAADG5ld09yZGVyYm9vawkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAFmdldE9yZGVyRmlsbGVkVG90YWxLZXkAAAABBQAAAAdvcmRlcklkCQAAZAAAAAIFAAAAC2ZpbGxlZFRvdGFsBQAAAAV0b3RhbAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAEWdldE9yZGVyU3RhdHVzS2V5AAAAAQUAAAAHb3JkZXJJZAUAAAAGc3RhdHVzCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0T3JkZXJIaXN0b3J5S2V5AAAAAQUAAAAGaGVpZ2h0BQAAAApvcmRlclByaWNlBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAApvcmRlck93bmVyBQAAAAxmaWxsZWRBbW91bnQFAAAAC2JvbmRBc3NldElkCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAAEG5ldXRyaW5vQ29udHJhY3QFAAAABXRvdGFsBQAAAA9uZXV0cmlub0Fzc2V0SWQFAAAAA25pbAAAAABkLao/", "chainId": 84, "height": 746228, "spentComplexity": 0 } View: original | compacted Prev: EKrJfYM3KNJPPPu5F4Lt9vZGZjbGXDcm8LzGvim2MJ69 Next: CNns7pQLLqUrW5yAop7oY5rvxAFWPA2YPRWqrUiWHdaR Diff:
Old | New | Differences | |
---|---|---|---|
47 | 47 | ||
48 | 48 | let PERCENTACCURACY = 1000 | |
49 | 49 | ||
50 | + | let MAXDISCOUNT = 50 | |
51 | + | ||
50 | 52 | let OrderBookKey = "orderbook" | |
51 | 53 | ||
52 | 54 | let OrderPriceKey = "order_price_" | |
74 | 76 | let OrderHistoryKey = "order_history_" | |
75 | 77 | ||
76 | 78 | let SwapLockedBalanceKey = "swap_locked_balance" | |
79 | + | ||
80 | + | let SwapNeutrinoLockedBalanceKey = "swap_neutrino_locked_balance" | |
77 | 81 | ||
78 | 82 | func getOrderPriceKey (orderId) = (OrderPriceKey + orderId) | |
79 | 83 | ||
119 | 123 | ||
120 | 124 | let swapLockedBalance = getNumberByAddressAndKey(neutrinoContract, SwapLockedBalanceKey) | |
121 | 125 | ||
126 | + | let swapNeutrinoLockedBalance = getNumberByAddressAndKey(neutrinoContract, SwapNeutrinoLockedBalanceKey) | |
127 | + | ||
122 | 128 | let neutrinoAssetId = fromBase58String(getStringByAddressAndKey(neutrinoContract, NeutrinoAssetIdKey)) | |
123 | 129 | ||
124 | 130 | let bondAssetId = fromBase58String(getStringByAddressAndKey(neutrinoContract, BondAssetIdKey)) | |
125 | 131 | ||
126 | 132 | let orderbook = getStringByKey(OrderBookKey) | |
127 | 133 | ||
128 | - | let reserve = (wavesBalance( | |
134 | + | let reserve = (wavesBalance(neutrinoContract) - swapLockedBalance) | |
129 | 135 | ||
130 | 136 | let neutrinoSupply = { | |
131 | 137 | let info = extract(assetInfo(neutrinoAssetId)) | |
132 | - | (info.quantity - assetBalance( | |
138 | + | ((info.quantity - assetBalance(this, neutrinoAssetId)) + swapNeutrinoLockedBalance) | |
133 | 139 | } | |
134 | 140 | ||
135 | 141 | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve)) | |
176 | 182 | func setOrder (price,position) = { | |
177 | 183 | let pmt = extract(i.payment) | |
178 | 184 | let newOrderId = toBase58String(keccak256((((toBytes(price) + toBytes(pmt.amount)) + i.caller.bytes) + toBytes(height)))) | |
179 | - | if ((pmt.assetId != neutrinoAssetId)) | |
180 | - | then throw("can use neutrino only") | |
181 | - | else if ((0 >= price)) | |
182 | - | then throw("price less zero") | |
183 | - | else if ((getOrderOwner(newOrderId) != "")) | |
184 | - | then throw("order exists") | |
185 | - | else { | |
186 | - | let orders = split(orderbook, ORDERSPLITSYMBOL) | |
187 | - | let nextOrderId = if ((position == 0)) | |
188 | - | then "" | |
189 | - | else orders[(position - 1)] | |
190 | - | let nextOrderPrice = getOrderPrice(nextOrderId) | |
191 | - | let isNextOrderError = if (if ((nextOrderId != "")) | |
192 | - | then (price > nextOrderPrice) | |
193 | - | else false) | |
194 | - | then true | |
195 | - | else false | |
196 | - | let prevOrderId = orders[position] | |
197 | - | let prevOrderPrice = getOrderPrice(prevOrderId) | |
198 | - | let isPrevOrderError = if ((prevOrderPrice >= price)) | |
199 | - | then true | |
200 | - | else false | |
201 | - | if (if (isNextOrderError) | |
202 | - | then true | |
203 | - | else isPrevOrderError) | |
204 | - | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
205 | - | else WriteSet([DataEntry(OrderBookKey, addOrder(newOrderId, position)), DataEntry(getOrderPriceKey(newOrderId), price), DataEntry(getOrderTotalKey(newOrderId), pmt.amount), DataEntry(getOrderOwnerKey(newOrderId), toString(i.caller)), DataEntry(getOrderHeightKey(newOrderId), height), DataEntry(getOrderStatusKey(newOrderId), NEW)]) | |
206 | - | } | |
185 | + | if ((MAXDISCOUNT > price)) | |
186 | + | then throw("max discount is 50%") | |
187 | + | else if ((pmt.assetId != neutrinoAssetId)) | |
188 | + | then throw("can use neutrino only") | |
189 | + | else if ((0 >= price)) | |
190 | + | then throw("price less zero") | |
191 | + | else if ((getOrderOwner(newOrderId) != "")) | |
192 | + | then throw("order exists") | |
193 | + | else { | |
194 | + | let orders = split(orderbook, ORDERSPLITSYMBOL) | |
195 | + | let nextOrderId = if ((position == 0)) | |
196 | + | then "" | |
197 | + | else orders[(position - 1)] | |
198 | + | let nextOrderPrice = getOrderPrice(nextOrderId) | |
199 | + | let isNextOrderError = if (if ((nextOrderId != "")) | |
200 | + | then (price > nextOrderPrice) | |
201 | + | else false) | |
202 | + | then true | |
203 | + | else false | |
204 | + | let prevOrderId = orders[position] | |
205 | + | let prevOrderPrice = getOrderPrice(prevOrderId) | |
206 | + | let isPrevOrderError = if ((prevOrderPrice >= price)) | |
207 | + | then true | |
208 | + | else false | |
209 | + | if (if (isNextOrderError) | |
210 | + | then true | |
211 | + | else isPrevOrderError) | |
212 | + | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
213 | + | else WriteSet([DataEntry(OrderBookKey, addOrder(newOrderId, position)), DataEntry(getOrderPriceKey(newOrderId), price), DataEntry(getOrderTotalKey(newOrderId), pmt.amount), DataEntry(getOrderOwnerKey(newOrderId), toString(i.caller)), DataEntry(getOrderHeightKey(newOrderId), height), DataEntry(getOrderStatusKey(newOrderId), NEW)]) | |
214 | + | } | |
207 | 215 | } | |
208 | 216 | ||
209 | 217 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | 5 | case a: Int => | |
6 | 6 | a | |
7 | 7 | case _ => | |
8 | 8 | 0 | |
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | func getStringByKey (key) = match getString(this, key) { | |
13 | 13 | case a: String => | |
14 | 14 | a | |
15 | 15 | case _ => | |
16 | 16 | "" | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getStringByAddressAndKey (address,key) = match getString(address, key) { | |
21 | 21 | case a: String => | |
22 | 22 | a | |
23 | 23 | case _ => | |
24 | 24 | "" | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getNumberByAddressAndKey (address,key) = match getInteger(address, key) { | |
29 | 29 | case a: Int => | |
30 | 30 | a | |
31 | 31 | case _ => | |
32 | 32 | 0 | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | let WAVELET = 100000000 | |
37 | 37 | ||
38 | 38 | let ORDERSPLITSYMBOL = "_" | |
39 | 39 | ||
40 | 40 | let PAULI = 100 | |
41 | 41 | ||
42 | 42 | let CANCELED = "canceled" | |
43 | 43 | ||
44 | 44 | let NEW = "new" | |
45 | 45 | ||
46 | 46 | let FILLED = "filled" | |
47 | 47 | ||
48 | 48 | let PERCENTACCURACY = 1000 | |
49 | 49 | ||
50 | + | let MAXDISCOUNT = 50 | |
51 | + | ||
50 | 52 | let OrderBookKey = "orderbook" | |
51 | 53 | ||
52 | 54 | let OrderPriceKey = "order_price_" | |
53 | 55 | ||
54 | 56 | let OrderTotalKey = "order_total_" | |
55 | 57 | ||
56 | 58 | let OrderFilledTotalKey = "order_filled_total_" | |
57 | 59 | ||
58 | 60 | let OrderOwnerKey = "order_owner_" | |
59 | 61 | ||
60 | 62 | let OrderHeightKey = "order_height_" | |
61 | 63 | ||
62 | 64 | let OrderStatusKey = "order_status_" | |
63 | 65 | ||
64 | 66 | let PriceKey = "price" | |
65 | 67 | ||
66 | 68 | let BondAssetIdKey = "bond_asset_id" | |
67 | 69 | ||
68 | 70 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
69 | 71 | ||
70 | 72 | let NeutrinoContractKey = "neutrino_contract" | |
71 | 73 | ||
72 | 74 | let ControlContractKey = "control_contract" | |
73 | 75 | ||
74 | 76 | let OrderHistoryKey = "order_history_" | |
75 | 77 | ||
76 | 78 | let SwapLockedBalanceKey = "swap_locked_balance" | |
79 | + | ||
80 | + | let SwapNeutrinoLockedBalanceKey = "swap_neutrino_locked_balance" | |
77 | 81 | ||
78 | 82 | func getOrderPriceKey (orderId) = (OrderPriceKey + orderId) | |
79 | 83 | ||
80 | 84 | ||
81 | 85 | func getOrderTotalKey (orderId) = (OrderTotalKey + orderId) | |
82 | 86 | ||
83 | 87 | ||
84 | 88 | func getOrderOwnerKey (orderId) = (OrderOwnerKey + orderId) | |
85 | 89 | ||
86 | 90 | ||
87 | 91 | func getOrderHeightKey (orderId) = (OrderHeightKey + orderId) | |
88 | 92 | ||
89 | 93 | ||
90 | 94 | func getOrderStatusKey (orderId) = (OrderStatusKey + orderId) | |
91 | 95 | ||
92 | 96 | ||
93 | 97 | func getOrderFilledTotalKey (orderId) = (OrderFilledTotalKey + orderId) | |
94 | 98 | ||
95 | 99 | ||
96 | 100 | func getOrderHistoryKey (height) = (OrderHistoryKey + toString(height)) | |
97 | 101 | ||
98 | 102 | ||
99 | 103 | let neutrinoContract = addressFromStringValue(getStringByKey(NeutrinoContractKey)) | |
100 | 104 | ||
101 | 105 | let controlContract = addressFromStringValue(getStringByAddressAndKey(neutrinoContract, ControlContractKey)) | |
102 | 106 | ||
103 | 107 | let priceNeutrino = getNumberByAddressAndKey(controlContract, PriceKey) | |
104 | 108 | ||
105 | 109 | func convertNeutrinoToWaves (amount) = ((((amount * 100) / priceNeutrino) * WAVELET) / PAULI) | |
106 | 110 | ||
107 | 111 | ||
108 | 112 | func convertWavesToNeutrino (amount) = ((((amount * priceNeutrino) / 100) * PAULI) / WAVELET) | |
109 | 113 | ||
110 | 114 | ||
111 | 115 | func convertNeutrinoToBond (amount) = (amount / PAULI) | |
112 | 116 | ||
113 | 117 | ||
114 | 118 | func convertBondToNeutrino (amount) = (amount * PAULI) | |
115 | 119 | ||
116 | 120 | ||
117 | 121 | func convertWavesToBond (amount) = convertNeutrinoToBond(convertWavesToNeutrino(amount)) | |
118 | 122 | ||
119 | 123 | ||
120 | 124 | let swapLockedBalance = getNumberByAddressAndKey(neutrinoContract, SwapLockedBalanceKey) | |
121 | 125 | ||
126 | + | let swapNeutrinoLockedBalance = getNumberByAddressAndKey(neutrinoContract, SwapNeutrinoLockedBalanceKey) | |
127 | + | ||
122 | 128 | let neutrinoAssetId = fromBase58String(getStringByAddressAndKey(neutrinoContract, NeutrinoAssetIdKey)) | |
123 | 129 | ||
124 | 130 | let bondAssetId = fromBase58String(getStringByAddressAndKey(neutrinoContract, BondAssetIdKey)) | |
125 | 131 | ||
126 | 132 | let orderbook = getStringByKey(OrderBookKey) | |
127 | 133 | ||
128 | - | let reserve = (wavesBalance( | |
134 | + | let reserve = (wavesBalance(neutrinoContract) - swapLockedBalance) | |
129 | 135 | ||
130 | 136 | let neutrinoSupply = { | |
131 | 137 | let info = extract(assetInfo(neutrinoAssetId)) | |
132 | - | (info.quantity - assetBalance( | |
138 | + | ((info.quantity - assetBalance(this, neutrinoAssetId)) + swapNeutrinoLockedBalance) | |
133 | 139 | } | |
134 | 140 | ||
135 | 141 | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve)) | |
136 | 142 | ||
137 | 143 | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
138 | 144 | ||
139 | 145 | ||
140 | 146 | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
141 | 147 | ||
142 | 148 | ||
143 | 149 | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
144 | 150 | ||
145 | 151 | ||
146 | 152 | func getOrderStatus (id) = getStringByKey(getOrderStatusKey(id)) | |
147 | 153 | ||
148 | 154 | ||
149 | 155 | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
150 | 156 | ||
151 | 157 | ||
152 | 158 | func getOrderElementById (id) = (id + ORDERSPLITSYMBOL) | |
153 | 159 | ||
154 | 160 | ||
155 | 161 | func addOrder (orderId,position) = { | |
156 | 162 | let orders = split(orderbook, ORDERSPLITSYMBOL) | |
157 | 163 | let newOrder = getOrderElementById(orderId) | |
158 | 164 | if ((position == 0)) | |
159 | 165 | then (newOrder + orderbook) | |
160 | 166 | else if ((position >= (size(orders) - 1))) | |
161 | 167 | then (orderbook + newOrder) | |
162 | 168 | else { | |
163 | 169 | let parts = split(orderbook, getOrderElementById(orders[position])) | |
164 | 170 | (((parts[0] + newOrder) + getOrderElementById(orders[position])) + parts[1]) | |
165 | 171 | } | |
166 | 172 | } | |
167 | 173 | ||
168 | 174 | ||
169 | 175 | func dropOrder (orderId) = { | |
170 | 176 | let parts = split(orderbook, getOrderElementById(orderId)) | |
171 | 177 | (parts[0] + parts[1]) | |
172 | 178 | } | |
173 | 179 | ||
174 | 180 | ||
175 | 181 | @Callable(i) | |
176 | 182 | func setOrder (price,position) = { | |
177 | 183 | let pmt = extract(i.payment) | |
178 | 184 | let newOrderId = toBase58String(keccak256((((toBytes(price) + toBytes(pmt.amount)) + i.caller.bytes) + toBytes(height)))) | |
179 | - | if ((pmt.assetId != neutrinoAssetId)) | |
180 | - | then throw("can use neutrino only") | |
181 | - | else if ((0 >= price)) | |
182 | - | then throw("price less zero") | |
183 | - | else if ((getOrderOwner(newOrderId) != "")) | |
184 | - | then throw("order exists") | |
185 | - | else { | |
186 | - | let orders = split(orderbook, ORDERSPLITSYMBOL) | |
187 | - | let nextOrderId = if ((position == 0)) | |
188 | - | then "" | |
189 | - | else orders[(position - 1)] | |
190 | - | let nextOrderPrice = getOrderPrice(nextOrderId) | |
191 | - | let isNextOrderError = if (if ((nextOrderId != "")) | |
192 | - | then (price > nextOrderPrice) | |
193 | - | else false) | |
194 | - | then true | |
195 | - | else false | |
196 | - | let prevOrderId = orders[position] | |
197 | - | let prevOrderPrice = getOrderPrice(prevOrderId) | |
198 | - | let isPrevOrderError = if ((prevOrderPrice >= price)) | |
199 | - | then true | |
200 | - | else false | |
201 | - | if (if (isNextOrderError) | |
202 | - | then true | |
203 | - | else isPrevOrderError) | |
204 | - | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
205 | - | else WriteSet([DataEntry(OrderBookKey, addOrder(newOrderId, position)), DataEntry(getOrderPriceKey(newOrderId), price), DataEntry(getOrderTotalKey(newOrderId), pmt.amount), DataEntry(getOrderOwnerKey(newOrderId), toString(i.caller)), DataEntry(getOrderHeightKey(newOrderId), height), DataEntry(getOrderStatusKey(newOrderId), NEW)]) | |
206 | - | } | |
185 | + | if ((MAXDISCOUNT > price)) | |
186 | + | then throw("max discount is 50%") | |
187 | + | else if ((pmt.assetId != neutrinoAssetId)) | |
188 | + | then throw("can use neutrino only") | |
189 | + | else if ((0 >= price)) | |
190 | + | then throw("price less zero") | |
191 | + | else if ((getOrderOwner(newOrderId) != "")) | |
192 | + | then throw("order exists") | |
193 | + | else { | |
194 | + | let orders = split(orderbook, ORDERSPLITSYMBOL) | |
195 | + | let nextOrderId = if ((position == 0)) | |
196 | + | then "" | |
197 | + | else orders[(position - 1)] | |
198 | + | let nextOrderPrice = getOrderPrice(nextOrderId) | |
199 | + | let isNextOrderError = if (if ((nextOrderId != "")) | |
200 | + | then (price > nextOrderPrice) | |
201 | + | else false) | |
202 | + | then true | |
203 | + | else false | |
204 | + | let prevOrderId = orders[position] | |
205 | + | let prevOrderPrice = getOrderPrice(prevOrderId) | |
206 | + | let isPrevOrderError = if ((prevOrderPrice >= price)) | |
207 | + | then true | |
208 | + | else false | |
209 | + | if (if (isNextOrderError) | |
210 | + | then true | |
211 | + | else isPrevOrderError) | |
212 | + | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
213 | + | else WriteSet([DataEntry(OrderBookKey, addOrder(newOrderId, position)), DataEntry(getOrderPriceKey(newOrderId), price), DataEntry(getOrderTotalKey(newOrderId), pmt.amount), DataEntry(getOrderOwnerKey(newOrderId), toString(i.caller)), DataEntry(getOrderHeightKey(newOrderId), height), DataEntry(getOrderStatusKey(newOrderId), NEW)]) | |
214 | + | } | |
207 | 215 | } | |
208 | 216 | ||
209 | 217 | ||
210 | 218 | ||
211 | 219 | @Callable(i) | |
212 | 220 | func cancelOrder (orderId) = { | |
213 | 221 | let owner = getOrderOwner(orderId) | |
214 | 222 | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
215 | 223 | if ((owner != toString(i.caller))) | |
216 | 224 | then throw("permission denied") | |
217 | 225 | else if ((getOrderStatus(orderId) != NEW)) | |
218 | 226 | then throw("invalid order status") | |
219 | 227 | else ScriptResult(WriteSet([DataEntry(OrderBookKey, dropOrder(orderId)), DataEntry(getOrderStatusKey(orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, neutrinoAssetId)])) | |
220 | 228 | } | |
221 | 229 | ||
222 | 230 | ||
223 | 231 | ||
224 | 232 | @Callable(i) | |
225 | 233 | func executeOrder () = { | |
226 | 234 | let bondBalance = assetBalance(this, bondAssetId) | |
227 | 235 | let deficitPositive = if ((0 >= deficit)) | |
228 | 236 | then 0 | |
229 | 237 | else deficit | |
230 | 238 | let bondAmount = if ((deficitPositive >= bondBalance)) | |
231 | 239 | then bondBalance | |
232 | 240 | else deficitPositive | |
233 | 241 | let returnAmount = if ((deficitPositive >= bondBalance)) | |
234 | 242 | then 0 | |
235 | 243 | else (bondBalance - deficitPositive) | |
236 | 244 | if (if ((returnAmount == 0)) | |
237 | 245 | then (bondAmount == 0) | |
238 | 246 | else false) | |
239 | 247 | then throw("without deficit") | |
240 | 248 | else if ((bondAmount == 0)) | |
241 | 249 | then TransferSet([ScriptTransfer(neutrinoContract, returnAmount, bondAssetId)]) | |
242 | 250 | else { | |
243 | 251 | let orderId = split(orderbook, ORDERSPLITSYMBOL)[0] | |
244 | 252 | let filledTotal = getOrderFilledTotal(orderId) | |
245 | 253 | let orderTotal = getOrderTotal(orderId) | |
246 | 254 | let orderPrice = getOrderPrice(orderId) | |
247 | 255 | let orderOwner = getOrderOwner(orderId) | |
248 | 256 | let amount = convertNeutrinoToBond((((orderTotal - filledTotal) * 100) / orderPrice)) | |
249 | 257 | let newOrderbook = if ((bondAmount >= amount)) | |
250 | 258 | then dropOrder(orderId) | |
251 | 259 | else orderbook | |
252 | 260 | let filledAmount = if ((bondAmount >= amount)) | |
253 | 261 | then amount | |
254 | 262 | else bondAmount | |
255 | 263 | let total = (((filledAmount * orderPrice) * PAULI) / 100) | |
256 | 264 | let status = if ((bondAmount >= amount)) | |
257 | 265 | then FILLED | |
258 | 266 | else NEW | |
259 | 267 | if ((total == 0)) | |
260 | 268 | then throw("total equal zero") | |
261 | 269 | else ScriptResult(WriteSet([DataEntry(OrderBookKey, newOrderbook), DataEntry(getOrderFilledTotalKey(orderId), (filledTotal + total)), DataEntry(getOrderStatusKey(orderId), status), DataEntry(getOrderHistoryKey(height), orderPrice)]), TransferSet([ScriptTransfer(addressFromStringValue(orderOwner), filledAmount, bondAssetId), ScriptTransfer(neutrinoContract, total, neutrinoAssetId)])) | |
262 | 270 | } | |
263 | 271 | } | |
264 | 272 | ||
265 | 273 |
github/deemru/w8io/169f3d6 40.97 ms ◑