tx · 51vNC5dKpKsd6aahk5aZbbZKKMT5vHpbDmz9JV6frXRv 3N5nmMvMH8o3RPEyCKCaoWahBTYTexnZy62: -0.02000000 Waves 2020.09.16 13:50 [1179731] smart account 3N5nmMvMH8o3RPEyCKCaoWahBTYTexnZy62 > SELF 0.00000000 Waves
{ "type": 13, "id": "51vNC5dKpKsd6aahk5aZbbZKKMT5vHpbDmz9JV6frXRv", "fee": 2000000, "feeAssetId": null, "timestamp": 1600253457273, "version": 1, "sender": "3N5nmMvMH8o3RPEyCKCaoWahBTYTexnZy62", "senderPublicKey": "6PBV8fVJwLaUQbCyG7iqoKR3x1nqFRZFNeuN9qodoiTu", "proofs": [ "3sD7ZtB3iCwVttk3nyqCv6qFqUgkEXGzegP5SHg3C9fgLEfP1CkiTK2YC1QU48iGzB4w4H2WBCNmVzSHR88pw3UZ", "5J9V2hVFhogFGjbp3Node7AZ5EJVti1cYFqBJdSUBMZu5Q41kipxoX5sL4Z9P9R3qwhx5d4skmmMVhVsgwu11BPi", "2V9jqNgQNgKdfCJBXtLzjkgkhsTwabtYAYmao3p3rgK9dLwDjS3D8AFG4j5LTcJ2VAq5mbsXUE5h2L89BzjAghMv" ], "script": "base64:AAIEAAAAAAAAABEIAhIECgIBCBIAEgMKAQgSAAAAADkBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AAAAAAAAAAAAAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5CQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQIAAAAAAQAAABZnZXRCb29sQnlBZGRyZXNzQW5kS2V5AAAAAgAAAAdhZGRyZXNzAAAAA2tleQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABBsAAAACBQAAAAdhZGRyZXNzBQAAAANrZXkHAQAAABhnZXRTdHJpbmdCeUFkZHJlc3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AAAAAACAAAAAAAAAAAACQAAZwAAAAIFAAAABWNvdW50AAAAAAAAAAADuYCNkg==", "chainId": 84, "height": 1179731, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BEbxrNz7J4F1dE5LjzhQQ6oDh2h6Vwo16zsoTRa4GsKF Next: CbuxTXgujJpCcxsWrCB5c8yy6653gmqZrQPpTe6hQc3q Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | - | case a: Int => | |
6 | - | a | |
7 | - | case _ => | |
8 | - | 0 | |
9 | - | } | |
4 | + | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
10 | 5 | ||
11 | 6 | ||
12 | - | func getStringByKey (key) = match getString(this, key) { | |
13 | - | case a: String => | |
14 | - | a | |
15 | - | case _ => | |
16 | - | "" | |
17 | - | } | |
7 | + | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
18 | 8 | ||
19 | 9 | ||
20 | - | func getBoolByAddressAndKey (address,key) = match getBoolean(address, key) { | |
21 | - | case a: Boolean => | |
22 | - | a | |
23 | - | case _ => | |
24 | - | false | |
25 | - | } | |
10 | + | func getBoolByAddressAndKey (address,key) = valueOrElse(getBoolean(address, key), false) | |
26 | 11 | ||
27 | 12 | ||
28 | - | func getStringByAddressAndKey (address,key) = match getString(address, key) { | |
29 | - | case a: String => | |
30 | - | a | |
31 | - | case _ => | |
32 | - | "" | |
33 | - | } | |
13 | + | func getStringByAddressAndKey (address,key) = valueOrElse(getString(address, key), "") | |
34 | 14 | ||
35 | 15 | ||
36 | - | func getNumberByAddressAndKey (address,key) = match getInteger(address, key) { | |
37 | - | case a: Int => | |
38 | - | a | |
39 | - | case _ => | |
40 | - | 0 | |
41 | - | } | |
16 | + | func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(address, key), 0) | |
42 | 17 | ||
43 | 18 | ||
44 | 19 | let WAVELET = 100000000 | |
126 | 101 | ||
127 | 102 | let wavesLockedBalance = getNumberByAddressAndKey(neutrinoContract, WavesLockedBalanceKey) | |
128 | 103 | ||
129 | - | let reserve = (wavesBalance(neutrinoContract) - wavesLockedBalance) | |
104 | + | let reserve = (wavesBalance(neutrinoContract).regular - wavesLockedBalance) | |
130 | 105 | ||
131 | - | let neutrinoSupply = (((neutrinoLockedBalance + | |
106 | + | let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(liquidationContract, neutrinoAssetId)) | |
132 | 107 | ||
133 | 108 | let surplus = (convertWavesToNeutrino(reserve, currentPrice) - neutrinoSupply) | |
134 | 109 | ||
159 | 134 | let currentDefaultOrder = getStringByKey(CurrentDefaultOrderKey) | |
160 | 135 | ||
161 | 136 | func generateDataEntryToAddOrder (price,newOrderId,i,prevOrder,nextOrder,firstOrder) = { | |
162 | - | let amount = | |
137 | + | let amount = value(i.payments[0]).amount | |
163 | 138 | let isOneForOneOrder = (price == 100) | |
164 | 139 | let isFirstOrderEmty = (firstOrder == "") | |
165 | 140 | let isNewOrderPriceLowerThanCurrentFirstOrder = (getOrderPrice(firstOrder) > price) | |
168 | 143 | else if (isNewOrderPriceLowerThanCurrentFirstOrder) | |
169 | 144 | then newOrderId | |
170 | 145 | else firstOrder | |
171 | - | [ | |
146 | + | [StringEntry(getPrevOrderKey(newOrderId), prevOrder), StringEntry(getNextOrderKey(newOrderId), nextOrder), StringEntry(getNextOrderKey(prevOrder), if ((prevOrder == "")) | |
172 | 147 | then prevOrder | |
173 | - | else newOrderId), | |
148 | + | else newOrderId), StringEntry(getPrevOrderKey(nextOrder), if ((nextOrder == "")) | |
174 | 149 | then nextOrder | |
175 | - | else newOrderId), | |
150 | + | else newOrderId), StringEntry(FirstOrderKey, newFirstOrder), IntegerEntry(getOrderPriceKey(newOrderId), price), IntegerEntry(getOrderTotalKey(newOrderId), amount), StringEntry(getOrderOwnerKey(newOrderId), toString(i.caller)), IntegerEntry(getOrderHeightKey(newOrderId), height), StringEntry(getOrderStatusKey(newOrderId), NEW), StringEntry(CurrentDefaultOrderKey, if (isOneForOneOrder) | |
176 | 151 | then newOrderId | |
177 | 152 | else currentDefaultOrder)] | |
178 | 153 | } | |
179 | 154 | ||
180 | 155 | ||
181 | 156 | func internalAddLiquidationOrder (i,price,prevOrder) = { | |
182 | - | let pmt = | |
157 | + | let pmt = value(i.payments[0]) | |
183 | 158 | let newOrderId = toBase58String(keccak256((((toBytes(pmt.amount) + i.caller.bytes) + toBytes(height)) + i.transactionId))) | |
184 | 159 | let owner = toString(i.caller) | |
185 | 160 | let isEmptyPrevOrder = (prevOrder == "") | |
208 | 183 | else getNextOrder(prevOrder) | |
209 | 184 | let isEmptyNextOrder = (nextOrder == "") | |
210 | 185 | if (isEmptyFirstOrder) | |
211 | - | then | |
186 | + | then generateDataEntryToAddOrder(price, newOrderId, i, prevOrder, nextOrder, firstOrder) | |
212 | 187 | else { | |
213 | 188 | let nextOrderPrice = getNumberByKey(getOrderPriceKey(nextOrder)) | |
214 | 189 | let prevOrderPrice = getNumberByKey(getOrderPriceKey(prevOrder)) | |
222 | 197 | then true | |
223 | 198 | else isPrevOrderError) | |
224 | 199 | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
225 | - | else | |
200 | + | else generateDataEntryToAddOrder(price, newOrderId, i, prevOrder, nextOrder, firstOrder) | |
226 | 201 | } | |
227 | 202 | } | |
228 | 203 | } | |
234 | 209 | ||
235 | 210 | ||
236 | 211 | @Callable(i) | |
237 | - | func addLiquidationOrderWithPrice (price,prevOrder) = | |
212 | + | func addLiquidationOrderWithPrice (price,prevOrder) = throw("Method has been deprecated: please use addLiquidationOrder method without parameters") | |
238 | 213 | ||
239 | 214 | ||
240 | 215 | ||
263 | 238 | then throw("permission denied") | |
264 | 239 | else if ((getOrderStatus(orderId) != NEW)) | |
265 | 240 | then throw("invalid order status") | |
266 | - | else | |
241 | + | else [StringEntry(CurrentDefaultOrderKey, newDefaultOrder), StringEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
267 | 242 | then nextOrder | |
268 | - | else firstOrder), | |
243 | + | else firstOrder), StringEntry(getNextOrderKey(prevOrder), nextOrder), StringEntry(getPrevOrderKey(nextOrder), prevOrder), StringEntry(getOrderStatusKey(orderId), CANCELED), ScriptTransfer(i.caller, amount, bondAssetId)] | |
269 | 244 | } | |
270 | 245 | ||
271 | 246 | ||
287 | 262 | else if ((liquidationBalance == 0)) | |
288 | 263 | then throw("without base tokens to liquidate") | |
289 | 264 | else if ((returnAmount > 0)) | |
290 | - | then | |
265 | + | then [ScriptTransfer(neutrinoContract, returnAmount, neutrinoAssetId)] | |
291 | 266 | else if ((firstOrder == "")) | |
292 | 267 | then throw("empty orderbook") | |
293 | 268 | else { | |
295 | 270 | let filledTotal = getOrderFilledTotal(firstOrder) | |
296 | 271 | let nsbt2UsdnPrice = getOrderPrice(firstOrder) | |
297 | 272 | let remainedTotal = (getOrderTotal(firstOrder) - filledTotal) | |
298 | - | let totalUSDNRequiredToFillOrder = fraction(remainedTotal, nsbt2UsdnPrice, 100) | |
273 | + | let totalUSDNRequiredToFillOrderX100 = fraction(remainedTotal, nsbt2UsdnPrice, 1) | |
274 | + | let totalUSDNRequiredToFillOrder = (totalUSDNRequiredToFillOrderX100 / 100) | |
299 | 275 | let isOrderFullyFilable = (usdnAmount >= totalUSDNRequiredToFillOrder) | |
300 | - | let fillableOrderAmount = if (isOrderFullyFilable) | |
301 | - | then totalUSDNRequiredToFillOrder | |
302 | - | else usdnAmount | |
303 | - | let finalNBTFillable = fraction(fillableOrderAmount, 100, nsbt2UsdnPrice) | |
276 | + | let fillableOrderAmountX100 = if (isOrderFullyFilable) | |
277 | + | then totalUSDNRequiredToFillOrderX100 | |
278 | + | else (usdnAmount * 100) | |
279 | + | let finalNBTFillable = fraction(fillableOrderAmountX100, 1, nsbt2UsdnPrice) | |
280 | + | let fillableOrderAmount = (fillableOrderAmountX100 / 100) | |
304 | 281 | let nbTokensLiquidateCondition = (fraction((surplus + neutrinoSupply), 100, neutrinoSupply) >= nsbt2UsdnPrice) | |
305 | 282 | if (!(nbTokensLiquidateCondition)) | |
306 | 283 | then throw(("innapropriate surplus: " + toString(surplus))) | |
314 | 291 | else false) | |
315 | 292 | then FILLED | |
316 | 293 | else NEW | |
317 | - | ||
294 | + | [StringEntry(getPrevOrderKey(nextOrder), if ((newStatus == FILLED)) | |
318 | 295 | then "" | |
319 | - | else firstOrder), | |
296 | + | else firstOrder), StringEntry(FirstOrderKey, if ((newStatus == FILLED)) | |
320 | 297 | then nextOrder | |
321 | - | else firstOrder), | |
298 | + | else firstOrder), IntegerEntry(getOrderFilledTotalKey(firstOrder), (filledTotal + finalNBTFillable)), StringEntry(getOrderStatusKey(firstOrder), newStatus), StringEntry(CurrentDefaultOrderKey, if ((newStatus == NEW)) | |
322 | 299 | then currentDefaultOrder | |
323 | - | else computeCurrentDefaultOrder(firstOrder)) | |
300 | + | else computeCurrentDefaultOrder(firstOrder)), ScriptTransfer(addressFromStringValue(getOrderOwner(firstOrder)), fillableOrderAmount, neutrinoAssetId), ScriptTransfer(neutrinoContract, finalNBTFillable, bondAssetId)] | |
324 | 301 | } | |
325 | 302 | } | |
326 | - | } | |
327 | - | ||
328 | - | ||
329 | - | ||
330 | - | @Callable(i) | |
331 | - | func updateReservesAndNeutrinoSupply () = { | |
332 | - | func getNumberByKeyInternal (key) = match getInteger(this, key) { | |
333 | - | case a: Int => | |
334 | - | a | |
335 | - | case _ => | |
336 | - | 0 | |
337 | - | } | |
338 | - | ||
339 | - | let idx = getNumberByKeyInternal("updateReservesAndNeutrinoSupplyIdx") | |
340 | - | let newIdx = (idx + 1) | |
341 | - | WriteSet([DataEntry("updateReservesAndNeutrinoSupplyIdx", newIdx), DataEntry("reserve", reserve), DataEntry("neutrinoSupply", neutrinoSupply), DataEntry("surplus", surplus)]) | |
342 | 303 | } | |
343 | 304 | ||
344 | 305 |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | - | case a: Int => | |
6 | - | a | |
7 | - | case _ => | |
8 | - | 0 | |
9 | - | } | |
4 | + | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
10 | 5 | ||
11 | 6 | ||
12 | - | func getStringByKey (key) = match getString(this, key) { | |
13 | - | case a: String => | |
14 | - | a | |
15 | - | case _ => | |
16 | - | "" | |
17 | - | } | |
7 | + | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
18 | 8 | ||
19 | 9 | ||
20 | - | func getBoolByAddressAndKey (address,key) = match getBoolean(address, key) { | |
21 | - | case a: Boolean => | |
22 | - | a | |
23 | - | case _ => | |
24 | - | false | |
25 | - | } | |
10 | + | func getBoolByAddressAndKey (address,key) = valueOrElse(getBoolean(address, key), false) | |
26 | 11 | ||
27 | 12 | ||
28 | - | func getStringByAddressAndKey (address,key) = match getString(address, key) { | |
29 | - | case a: String => | |
30 | - | a | |
31 | - | case _ => | |
32 | - | "" | |
33 | - | } | |
13 | + | func getStringByAddressAndKey (address,key) = valueOrElse(getString(address, key), "") | |
34 | 14 | ||
35 | 15 | ||
36 | - | func getNumberByAddressAndKey (address,key) = match getInteger(address, key) { | |
37 | - | case a: Int => | |
38 | - | a | |
39 | - | case _ => | |
40 | - | 0 | |
41 | - | } | |
16 | + | func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(address, key), 0) | |
42 | 17 | ||
43 | 18 | ||
44 | 19 | let WAVELET = 100000000 | |
45 | 20 | ||
46 | 21 | let PAULI = 1000000 | |
47 | 22 | ||
48 | 23 | let PRICELET = 1000000 | |
49 | 24 | ||
50 | 25 | let CANCELED = "canceled" | |
51 | 26 | ||
52 | 27 | let NEW = "new" | |
53 | 28 | ||
54 | 29 | let FILLED = "filled" | |
55 | 30 | ||
56 | 31 | let NeutrinoContractKey = "neutrino_contract" | |
57 | 32 | ||
58 | 33 | let PriceKey = "price" | |
59 | 34 | ||
60 | 35 | let BondAssetIdKey = "bond_asset_id" | |
61 | 36 | ||
62 | 37 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
63 | 38 | ||
64 | 39 | let ControlContractKey = "control_contract" | |
65 | 40 | ||
66 | 41 | let BalanceLockedkKey = "balance_lock_" | |
67 | 42 | ||
68 | 43 | let WavesLockedBalanceKey = (BalanceLockedkKey + "waves") | |
69 | 44 | ||
70 | 45 | let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino") | |
71 | 46 | ||
72 | 47 | let FirstOrderKey = "order_first" | |
73 | 48 | ||
74 | 49 | let CurrentDefaultOrderKey = "order_default" | |
75 | 50 | ||
76 | 51 | func getOrderPriceKey (orderId) = ("order_price_" + orderId) | |
77 | 52 | ||
78 | 53 | ||
79 | 54 | func getOrderTotalKey (orderId) = ("order_total_" + orderId) | |
80 | 55 | ||
81 | 56 | ||
82 | 57 | func getOrderOwnerKey (orderId) = ("order_owner_" + orderId) | |
83 | 58 | ||
84 | 59 | ||
85 | 60 | func getOrderHeightKey (orderId) = ("order_height_" + orderId) | |
86 | 61 | ||
87 | 62 | ||
88 | 63 | func getOrderStatusKey (orderId) = ("order_status_" + orderId) | |
89 | 64 | ||
90 | 65 | ||
91 | 66 | func getOrderFilledTotalKey (orderId) = ("order_filled_total_" + orderId) | |
92 | 67 | ||
93 | 68 | ||
94 | 69 | func getPrevOrderKey (orderId) = ("order_prev_" + orderId) | |
95 | 70 | ||
96 | 71 | ||
97 | 72 | func getNextOrderKey (orderId) = ("order_next_" + orderId) | |
98 | 73 | ||
99 | 74 | ||
100 | 75 | func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, PRICELET, price), WAVELET, PAULI) | |
101 | 76 | ||
102 | 77 | ||
103 | 78 | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, PRICELET), PAULI, WAVELET) | |
104 | 79 | ||
105 | 80 | ||
106 | 81 | func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price) | |
107 | 82 | ||
108 | 83 | ||
109 | 84 | let neutrinoContract = addressFromStringValue(getStringByKey(NeutrinoContractKey)) | |
110 | 85 | ||
111 | 86 | let controlContract = addressFromStringValue(getStringByAddressAndKey(neutrinoContract, ControlContractKey)) | |
112 | 87 | ||
113 | 88 | let liquidationContract = this | |
114 | 89 | ||
115 | 90 | let neutrinoAssetId = fromBase58String(getStringByAddressAndKey(neutrinoContract, NeutrinoAssetIdKey)) | |
116 | 91 | ||
117 | 92 | let bondAssetId = fromBase58String("BGhPYquXSK6UYjnPLEn94gFhetp4Jvf7toekEY4x1VDH") | |
118 | 93 | ||
119 | 94 | let firstOrder = getStringByKey(FirstOrderKey) | |
120 | 95 | ||
121 | 96 | let isBlocked = getBoolByAddressAndKey(controlContract, "is_blocked") | |
122 | 97 | ||
123 | 98 | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
124 | 99 | ||
125 | 100 | let neutrinoLockedBalance = getNumberByAddressAndKey(neutrinoContract, NeutrinoLockedBalanceKey) | |
126 | 101 | ||
127 | 102 | let wavesLockedBalance = getNumberByAddressAndKey(neutrinoContract, WavesLockedBalanceKey) | |
128 | 103 | ||
129 | - | let reserve = (wavesBalance(neutrinoContract) - wavesLockedBalance) | |
104 | + | let reserve = (wavesBalance(neutrinoContract).regular - wavesLockedBalance) | |
130 | 105 | ||
131 | - | let neutrinoSupply = (((neutrinoLockedBalance + | |
106 | + | let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(liquidationContract, neutrinoAssetId)) | |
132 | 107 | ||
133 | 108 | let surplus = (convertWavesToNeutrino(reserve, currentPrice) - neutrinoSupply) | |
134 | 109 | ||
135 | 110 | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
136 | 111 | ||
137 | 112 | ||
138 | 113 | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
139 | 114 | ||
140 | 115 | ||
141 | 116 | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
142 | 117 | ||
143 | 118 | ||
144 | 119 | func getOrderStatus (id) = getStringByKey(getOrderStatusKey(id)) | |
145 | 120 | ||
146 | 121 | ||
147 | 122 | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
148 | 123 | ||
149 | 124 | ||
150 | 125 | func getOrderHeight (id) = getNumberByKey(getOrderHeightKey(id)) | |
151 | 126 | ||
152 | 127 | ||
153 | 128 | func getPrevOrder (id) = getStringByKey(getPrevOrderKey(id)) | |
154 | 129 | ||
155 | 130 | ||
156 | 131 | func getNextOrder (id) = getStringByKey(getNextOrderKey(id)) | |
157 | 132 | ||
158 | 133 | ||
159 | 134 | let currentDefaultOrder = getStringByKey(CurrentDefaultOrderKey) | |
160 | 135 | ||
161 | 136 | func generateDataEntryToAddOrder (price,newOrderId,i,prevOrder,nextOrder,firstOrder) = { | |
162 | - | let amount = | |
137 | + | let amount = value(i.payments[0]).amount | |
163 | 138 | let isOneForOneOrder = (price == 100) | |
164 | 139 | let isFirstOrderEmty = (firstOrder == "") | |
165 | 140 | let isNewOrderPriceLowerThanCurrentFirstOrder = (getOrderPrice(firstOrder) > price) | |
166 | 141 | let newFirstOrder = if (isFirstOrderEmty) | |
167 | 142 | then newOrderId | |
168 | 143 | else if (isNewOrderPriceLowerThanCurrentFirstOrder) | |
169 | 144 | then newOrderId | |
170 | 145 | else firstOrder | |
171 | - | [ | |
146 | + | [StringEntry(getPrevOrderKey(newOrderId), prevOrder), StringEntry(getNextOrderKey(newOrderId), nextOrder), StringEntry(getNextOrderKey(prevOrder), if ((prevOrder == "")) | |
172 | 147 | then prevOrder | |
173 | - | else newOrderId), | |
148 | + | else newOrderId), StringEntry(getPrevOrderKey(nextOrder), if ((nextOrder == "")) | |
174 | 149 | then nextOrder | |
175 | - | else newOrderId), | |
150 | + | else newOrderId), StringEntry(FirstOrderKey, newFirstOrder), IntegerEntry(getOrderPriceKey(newOrderId), price), IntegerEntry(getOrderTotalKey(newOrderId), amount), StringEntry(getOrderOwnerKey(newOrderId), toString(i.caller)), IntegerEntry(getOrderHeightKey(newOrderId), height), StringEntry(getOrderStatusKey(newOrderId), NEW), StringEntry(CurrentDefaultOrderKey, if (isOneForOneOrder) | |
176 | 151 | then newOrderId | |
177 | 152 | else currentDefaultOrder)] | |
178 | 153 | } | |
179 | 154 | ||
180 | 155 | ||
181 | 156 | func internalAddLiquidationOrder (i,price,prevOrder) = { | |
182 | - | let pmt = | |
157 | + | let pmt = value(i.payments[0]) | |
183 | 158 | let newOrderId = toBase58String(keccak256((((toBytes(pmt.amount) + i.caller.bytes) + toBytes(height)) + i.transactionId))) | |
184 | 159 | let owner = toString(i.caller) | |
185 | 160 | let isEmptyPrevOrder = (prevOrder == "") | |
186 | 161 | let isEmptyFirstOrder = (firstOrder == "") | |
187 | 162 | if (isBlocked) | |
188 | 163 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
189 | 164 | else if ((PAULI > pmt.amount)) | |
190 | 165 | then throw("order amount should be higher than 1 NSBT") | |
191 | 166 | else if ((100 > price)) | |
192 | 167 | then throw(("price should be equal or higher than 1 nsbt for 1 usdn. i.e. >= 100; price: " + toString(price))) | |
193 | 168 | else if ((pmt.assetId != bondAssetId)) | |
194 | 169 | then throw("can use appropriate neutrino base tokens (nsbt) only") | |
195 | 170 | else if ((getOrderOwner(newOrderId) != "")) | |
196 | 171 | then throw("the order already exists") | |
197 | 172 | else if (if (!(isEmptyPrevOrder)) | |
198 | 173 | then (getOrderStatus(prevOrder) != NEW) | |
199 | 174 | else false) | |
200 | 175 | then throw("prev order status is not new") | |
201 | 176 | else if (if (isEmptyFirstOrder) | |
202 | 177 | then !(isEmptyPrevOrder) | |
203 | 178 | else false) | |
204 | 179 | then throw("wrong prev order parameter") | |
205 | 180 | else { | |
206 | 181 | let nextOrder = if (isEmptyPrevOrder) | |
207 | 182 | then firstOrder | |
208 | 183 | else getNextOrder(prevOrder) | |
209 | 184 | let isEmptyNextOrder = (nextOrder == "") | |
210 | 185 | if (isEmptyFirstOrder) | |
211 | - | then | |
186 | + | then generateDataEntryToAddOrder(price, newOrderId, i, prevOrder, nextOrder, firstOrder) | |
212 | 187 | else { | |
213 | 188 | let nextOrderPrice = getNumberByKey(getOrderPriceKey(nextOrder)) | |
214 | 189 | let prevOrderPrice = getNumberByKey(getOrderPriceKey(prevOrder)) | |
215 | 190 | let isNextOrderError = if (!(isEmptyNextOrder)) | |
216 | 191 | then (price >= nextOrderPrice) | |
217 | 192 | else false | |
218 | 193 | let isPrevOrderError = if (!(isEmptyPrevOrder)) | |
219 | 194 | then (prevOrderPrice > price) | |
220 | 195 | else false | |
221 | 196 | if (if (isNextOrderError) | |
222 | 197 | then true | |
223 | 198 | else isPrevOrderError) | |
224 | 199 | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
225 | - | else | |
200 | + | else generateDataEntryToAddOrder(price, newOrderId, i, prevOrder, nextOrder, firstOrder) | |
226 | 201 | } | |
227 | 202 | } | |
228 | 203 | } | |
229 | 204 | ||
230 | 205 | ||
231 | 206 | func computeCurrentDefaultOrder (id) = if ((id != currentDefaultOrder)) | |
232 | 207 | then currentDefaultOrder | |
233 | 208 | else "" | |
234 | 209 | ||
235 | 210 | ||
236 | 211 | @Callable(i) | |
237 | - | func addLiquidationOrderWithPrice (price,prevOrder) = | |
212 | + | func addLiquidationOrderWithPrice (price,prevOrder) = throw("Method has been deprecated: please use addLiquidationOrder method without parameters") | |
238 | 213 | ||
239 | 214 | ||
240 | 215 | ||
241 | 216 | @Callable(i) | |
242 | 217 | func addLiquidationOrder () = internalAddLiquidationOrder(i, 100, currentDefaultOrder) | |
243 | 218 | ||
244 | 219 | ||
245 | 220 | ||
246 | 221 | @Callable(i) | |
247 | 222 | func cancelOrder (orderId) = { | |
248 | 223 | let owner = getOrderOwner(orderId) | |
249 | 224 | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
250 | 225 | let caller = toString(i.caller) | |
251 | 226 | let nextOrder = getNextOrder(orderId) | |
252 | 227 | let prevOrder = getPrevOrder(orderId) | |
253 | 228 | let isDefaultOrder = (orderId == currentDefaultOrder) | |
254 | 229 | let isPrevCanBecomeDefault = (getOrderStatus(prevOrder) == NEW) | |
255 | 230 | let newDefaultOrder = if (isDefaultOrder) | |
256 | 231 | then if (isPrevCanBecomeDefault) | |
257 | 232 | then prevOrder | |
258 | 233 | else "" | |
259 | 234 | else currentDefaultOrder | |
260 | 235 | if (isBlocked) | |
261 | 236 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
262 | 237 | else if ((owner != caller)) | |
263 | 238 | then throw("permission denied") | |
264 | 239 | else if ((getOrderStatus(orderId) != NEW)) | |
265 | 240 | then throw("invalid order status") | |
266 | - | else | |
241 | + | else [StringEntry(CurrentDefaultOrderKey, newDefaultOrder), StringEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
267 | 242 | then nextOrder | |
268 | - | else firstOrder), | |
243 | + | else firstOrder), StringEntry(getNextOrderKey(prevOrder), nextOrder), StringEntry(getPrevOrderKey(nextOrder), prevOrder), StringEntry(getOrderStatusKey(orderId), CANCELED), ScriptTransfer(i.caller, amount, bondAssetId)] | |
269 | 244 | } | |
270 | 245 | ||
271 | 246 | ||
272 | 247 | ||
273 | 248 | @Callable(i) | |
274 | 249 | func liquidateBond () = { | |
275 | 250 | let liquidationBalance = assetBalance(this, neutrinoAssetId) | |
276 | 251 | let surplusPositive = if ((0 >= surplus)) | |
277 | 252 | then 0 | |
278 | 253 | else surplus | |
279 | 254 | let usdnAmount = if ((surplusPositive >= liquidationBalance)) | |
280 | 255 | then liquidationBalance | |
281 | 256 | else surplusPositive | |
282 | 257 | let returnAmount = if ((surplusPositive >= liquidationBalance)) | |
283 | 258 | then 0 | |
284 | 259 | else (liquidationBalance - surplusPositive) | |
285 | 260 | if (isBlocked) | |
286 | 261 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
287 | 262 | else if ((liquidationBalance == 0)) | |
288 | 263 | then throw("without base tokens to liquidate") | |
289 | 264 | else if ((returnAmount > 0)) | |
290 | - | then | |
265 | + | then [ScriptTransfer(neutrinoContract, returnAmount, neutrinoAssetId)] | |
291 | 266 | else if ((firstOrder == "")) | |
292 | 267 | then throw("empty orderbook") | |
293 | 268 | else { | |
294 | 269 | let nextOrder = getNextOrder(firstOrder) | |
295 | 270 | let filledTotal = getOrderFilledTotal(firstOrder) | |
296 | 271 | let nsbt2UsdnPrice = getOrderPrice(firstOrder) | |
297 | 272 | let remainedTotal = (getOrderTotal(firstOrder) - filledTotal) | |
298 | - | let totalUSDNRequiredToFillOrder = fraction(remainedTotal, nsbt2UsdnPrice, 100) | |
273 | + | let totalUSDNRequiredToFillOrderX100 = fraction(remainedTotal, nsbt2UsdnPrice, 1) | |
274 | + | let totalUSDNRequiredToFillOrder = (totalUSDNRequiredToFillOrderX100 / 100) | |
299 | 275 | let isOrderFullyFilable = (usdnAmount >= totalUSDNRequiredToFillOrder) | |
300 | - | let fillableOrderAmount = if (isOrderFullyFilable) | |
301 | - | then totalUSDNRequiredToFillOrder | |
302 | - | else usdnAmount | |
303 | - | let finalNBTFillable = fraction(fillableOrderAmount, 100, nsbt2UsdnPrice) | |
276 | + | let fillableOrderAmountX100 = if (isOrderFullyFilable) | |
277 | + | then totalUSDNRequiredToFillOrderX100 | |
278 | + | else (usdnAmount * 100) | |
279 | + | let finalNBTFillable = fraction(fillableOrderAmountX100, 1, nsbt2UsdnPrice) | |
280 | + | let fillableOrderAmount = (fillableOrderAmountX100 / 100) | |
304 | 281 | let nbTokensLiquidateCondition = (fraction((surplus + neutrinoSupply), 100, neutrinoSupply) >= nsbt2UsdnPrice) | |
305 | 282 | if (!(nbTokensLiquidateCondition)) | |
306 | 283 | then throw(("innapropriate surplus: " + toString(surplus))) | |
307 | 284 | else { | |
308 | 285 | let isNothingToFillNow = (remainedTotal == 0) | |
309 | 286 | let isNothingToFillAtAll = ((filledTotal + finalNBTFillable) == getOrderTotal(firstOrder)) | |
310 | 287 | let newStatus = if (if (isOrderFullyFilable) | |
311 | 288 | then if (isNothingToFillNow) | |
312 | 289 | then true | |
313 | 290 | else isNothingToFillAtAll | |
314 | 291 | else false) | |
315 | 292 | then FILLED | |
316 | 293 | else NEW | |
317 | - | ||
294 | + | [StringEntry(getPrevOrderKey(nextOrder), if ((newStatus == FILLED)) | |
318 | 295 | then "" | |
319 | - | else firstOrder), | |
296 | + | else firstOrder), StringEntry(FirstOrderKey, if ((newStatus == FILLED)) | |
320 | 297 | then nextOrder | |
321 | - | else firstOrder), | |
298 | + | else firstOrder), IntegerEntry(getOrderFilledTotalKey(firstOrder), (filledTotal + finalNBTFillable)), StringEntry(getOrderStatusKey(firstOrder), newStatus), StringEntry(CurrentDefaultOrderKey, if ((newStatus == NEW)) | |
322 | 299 | then currentDefaultOrder | |
323 | - | else computeCurrentDefaultOrder(firstOrder)) | |
300 | + | else computeCurrentDefaultOrder(firstOrder)), ScriptTransfer(addressFromStringValue(getOrderOwner(firstOrder)), fillableOrderAmount, neutrinoAssetId), ScriptTransfer(neutrinoContract, finalNBTFillable, bondAssetId)] | |
324 | 301 | } | |
325 | 302 | } | |
326 | - | } | |
327 | - | ||
328 | - | ||
329 | - | ||
330 | - | @Callable(i) | |
331 | - | func updateReservesAndNeutrinoSupply () = { | |
332 | - | func getNumberByKeyInternal (key) = match getInteger(this, key) { | |
333 | - | case a: Int => | |
334 | - | a | |
335 | - | case _ => | |
336 | - | 0 | |
337 | - | } | |
338 | - | ||
339 | - | let idx = getNumberByKeyInternal("updateReservesAndNeutrinoSupplyIdx") | |
340 | - | let newIdx = (idx + 1) | |
341 | - | WriteSet([DataEntry("updateReservesAndNeutrinoSupplyIdx", newIdx), DataEntry("reserve", reserve), DataEntry("neutrinoSupply", neutrinoSupply), DataEntry("surplus", surplus)]) | |
342 | 303 | } | |
343 | 304 | ||
344 | 305 | ||
345 | 306 | @Verifier(tx) | |
346 | 307 | func verify () = { | |
347 | 308 | let pubKeyAdminsList = ["GXxmZaCigPgJsT6d1cLr8nUXA65nGX8V7FuAzzrY8wQE", "3xumx4hrPpeeoo79HLGbZCgfz95L39ZFdxxwWeSUC2Pu", "D4CqtK5fBsnzRo33ZMhrM7niLseDH2uRoK6weBq2JQ3A", "5WRXFSjwcTbNfKcJs8ZqXmSSWYsSVJUtMvMqZj5hH4Nc"] | |
348 | 309 | let count = ((((if (sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(pubKeyAdminsList[0]))) | |
349 | 310 | then 1 | |
350 | 311 | else 0) + (if (sigVerify(tx.bodyBytes, tx.proofs[1], fromBase58String(pubKeyAdminsList[1]))) | |
351 | 312 | then 1 | |
352 | 313 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[2], fromBase58String(pubKeyAdminsList[2]))) | |
353 | 314 | then 1 | |
354 | 315 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[3], fromBase58String(pubKeyAdminsList[3]))) | |
355 | 316 | then 2 | |
356 | 317 | else 0)) | |
357 | 318 | (count >= 3) | |
358 | 319 | } | |
359 | 320 |
github/deemru/w8io/026f985 55.69 ms ◑