tx · GhN8QV1Z67tpAc8Ng12Di2WdpUhPLRf5mMCMLNBhioLq 3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv: -0.01400000 Waves 2019.10.01 17:50 [700785] smart account 3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv > SELF 0.00000000 Waves
{ "type": 13, "id": "GhN8QV1Z67tpAc8Ng12Di2WdpUhPLRf5mMCMLNBhioLq", "fee": 1400000, "feeAssetId": null, "timestamp": 1569941416921, "version": 1, "sender": "3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv", "senderPublicKey": "BxHnTcjvN9ZtnKfdKYp6aKRdkMB4ZHxHnTDr5dWx5Vz2", "proofs": [ "2Zpa4p5NBs94RxELdvM6fQVH4NS7xzMYx5EJv1mQsECmUyhUVucvMZp8ke5yMyZsicmDoDLCMbjFqNujojvDfvWy" ], "script": "base64:AAIDAAAAAAAAAAAAAAADAAAAAAh1VG9rZW5JZAEAAAAgg1ag/CIT1AiojH1skJ2ufidI0Eb3a9g5aB0rTX7UN7gBAAAAC2NoZWNrU3RhdHVzAAAAAQAAAAdhZGRyZXNzBAAAAA9zdGF0dXNVbmxpbWl0ZWQEAAAAByRtYXRjaDAJAAQbAAAAAgUAAAAEdGhpcwkAASwAAAACBQAAAAdhZGRyZXNzAgAAAApfdW5saW1pdGVkAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAdCb29sZWFuBAAAAARib29sBQAAAAckbWF0Y2gwBQAAAARib29sAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAARVbml0BwkBAAAABXRocm93AAAAAAQAAAAKc3RhdHVzVGltZQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIFAAAAB2FkZHJlc3MCAAAABV90aW1lAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAA2ludAUAAAAHJG1hdGNoMAUAAAADaW50AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAARVbml0AAAAA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EYXRhRW50cnkAAAACAgAAAAZvcmRlcnMFAAAACW5ld09yZGVycwkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAHb3JkZXJJZAUAAAAHbmV3RGF0YQUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAMcmV0dXJuQW1vdW50AwkAAAAAAAACBQAAAA9vcmRlclByaWNlQXNzZXQCAAAABVdBVkVTBQAAAAR1bml0CQACWQAAAAEFAAAAD29yZGVyUHJpY2VBc3NldAUAAAADbmlsAAAAALnx/8c=", "chainId": 84, "height": 700785, "spentComplexity": 0 } View: original | compacted Prev: Do9boHeu51KxmWGzdqvKSVHdSNrJ6c1EKyFaKrHexBmN Next: none Diff:
Old | New | Differences | |
---|---|---|---|
23 | 23 | if (statusUnlimited) | |
24 | 24 | then true | |
25 | 25 | else (statusTime > lastBlock.timestamp) | |
26 | + | } | |
27 | + | ||
28 | + | ||
29 | + | func checkDecimals (amountAsset,priceAsset) = { | |
30 | + | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
31 | + | then 8 | |
32 | + | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
33 | + | let priceAssetDecimals = if ((priceAsset == "WAVES")) | |
34 | + | then 8 | |
35 | + | else value(assetInfo(fromBase58String(priceAsset))).decimals | |
36 | + | (priceAssetDecimals >= amountAssetDecimals) | |
26 | 37 | } | |
27 | 38 | ||
28 | 39 | ||
107 | 118 | ||
108 | 119 | ||
109 | 120 | @Callable(i) | |
110 | - | func makeSell (priceAsset, | |
121 | + | func makeSell (priceAsset,priceAssetAmount,all,password) = if (if ((priceAsset != "WAVES")) | |
111 | 122 | then !(isDefined(assetInfo(fromBase58String(priceAsset)))) | |
112 | 123 | else false) | |
113 | 124 | then throw("There is no asset with specified id") | |
114 | - | else if ((0 >= | |
115 | - | then throw("price must be positive") | |
125 | + | else if ((0 >= priceAssetAmount)) | |
126 | + | then throw("Amount of price asset must be positive") | |
116 | 127 | else { | |
117 | - | let payment = valueOrErrorMessage(i.payment, " | |
128 | + | let payment = valueOrErrorMessage(i.payment, "Where is payment?") | |
118 | 129 | if ((0 >= payment.amount)) | |
119 | - | then throw(" | |
130 | + | then throw("Amount must be positive") | |
120 | 131 | else { | |
121 | 132 | let amountAsset = match payment.assetId { | |
122 | 133 | case p: ByteVector => | |
148 | 159 | throw() | |
149 | 160 | } | |
150 | 161 | let passwordValid = fromBase58String(password) | |
151 | - | let data = ((((((((((((((toString(payment.amount) + "_") + amountAsset) + "_") + toString( | |
162 | + | let data = (((((((((((((((("sell" + "_") + toString(payment.amount)) + "_") + amountAsset) + "_") + toString(priceAssetAmount)) + "_") + priceAsset) + "_") + address) + "_") + toString(all)) + "_") + password) + "_") + toString(0)) | |
152 | 163 | WriteSet([DataEntry("orders", (orders + orderId)), DataEntry(orderId, data)]) | |
153 | 164 | } | |
154 | 165 | } | |
158 | 169 | ||
159 | 170 | ||
160 | 171 | @Callable(i) | |
161 | - | func makeBuy (amountAsset, | |
172 | + | func makeBuy (amountAsset,amount,all,password) = if (if ((amountAsset != "WAVES")) | |
162 | 173 | then !(isDefined(assetInfo(fromBase58String(amountAsset)))) | |
163 | 174 | else false) | |
164 | 175 | then throw("There is no asset with specified id") | |
165 | - | else if ((0 >= | |
166 | - | then throw(" | |
176 | + | else if ((0 >= amount)) | |
177 | + | then throw("Amount must be positive") | |
167 | 178 | else { | |
168 | 179 | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
169 | - | if ((0 >= payment.amount)) | |
180 | + | let priceAssetAmount = payment.amount | |
181 | + | if ((0 >= priceAssetAmount)) | |
170 | 182 | then throw("amount must be positive") | |
171 | 183 | else { | |
172 | 184 | let priceAsset = match payment.assetId { | |
198 | 210 | case _ => | |
199 | 211 | throw() | |
200 | 212 | } | |
201 | - | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
202 | - | then 8 | |
203 | - | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
204 | - | let buyAmount = ((payment.amount * pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) / price) | |
205 | - | if ((buyAmount == 0)) | |
213 | + | if ((amount == 0)) | |
206 | 214 | then throw("invalid buy amount") | |
207 | 215 | else { | |
208 | - | let data = ((((((((((((((toString( | |
209 | - | WriteSet([DataEntry("orders", (orders + orderId)), DataEntry(orderId, data)]) | |
216 | + | let data = (((((((((((((((("buy" + "_") + toString(amount)) + "_") + amountAsset) + "_") + toString(priceAssetAmount)) + "_") + priceAsset) + "_") + address) + "_") + toString(all)) + "_") + password) + "_") + toString(0)) | |
217 | + | WriteSet([DataEntry("orders", (orders + orderId)), DataEntry(("buy_" + orderId), data)]) | |
210 | 218 | } | |
211 | 219 | } | |
212 | 220 | } | |
217 | 225 | ||
218 | 226 | @Callable(i) | |
219 | 227 | func takeSell (orderId,sig) = { | |
220 | - | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
221 | - | if ((0 >= payment.amount)) | |
222 | - | then throw("amount must be positive") | |
228 | + | let payment = valueOrErrorMessage(i.payment, "Where is payment?") | |
229 | + | let priceAssetAmount = payment.amount | |
230 | + | if ((0 >= priceAssetAmount)) | |
231 | + | then throw("Amount must be positive") | |
223 | 232 | else { | |
224 | - | let | |
233 | + | let priceAsset = match payment.assetId { | |
225 | 234 | case p: ByteVector => | |
226 | 235 | toBase58String(p) | |
227 | 236 | case _ => | |
228 | 237 | "WAVES" | |
229 | 238 | } | |
230 | 239 | let data = valueOrErrorMessage(getString(this, orderId), "Invalid order id") | |
231 | - | let amount = parseIntValue(split(data, "_")[0]) | |
232 | - | let amountAsset = split(data, "_")[1] | |
233 | - | let price = parseIntValue(split(data, "_")[2]) | |
234 | - | let priceAsset = split(data, "_")[3] | |
235 | - | let owner = value(addressFromString(split(data, "_")[4])) | |
236 | - | let all = if ((split(data, "_")[5] == "true")) | |
240 | + | let orderType = split(data, "_")[0] | |
241 | + | let orderAmount = parseIntValue(split(data, "_")[1]) | |
242 | + | let orderAmountAsset = split(data, "_")[2] | |
243 | + | let orderPriceAssetAmount = parseIntValue(split(data, "_")[3]) | |
244 | + | let orderPriceAsset = split(data, "_")[4] | |
245 | + | let orderOwner = value(addressFromString(split(data, "_")[5])) | |
246 | + | let orderAll = if ((split(data, "_")[6] == "true")) | |
237 | 247 | then true | |
238 | 248 | else false | |
239 | - | let password = split(data, "_")[6] | |
240 | - | let spent = parseIntValue(split(data, "_")[7]) | |
241 | - | if ((priceAsset != paymentAsset)) | |
242 | - | then throw(("Payment asset must be " + priceAsset)) | |
243 | - | else { | |
244 | - | let valid = if ((password != "")) | |
245 | - | then sigVerify(i.callerPublicKey, fromBase58String(sig), fromBase58String(password)) | |
246 | - | else true | |
247 | - | if (!(valid)) | |
248 | - | then throw("The order is private") | |
249 | - | else { | |
250 | - | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
251 | - | then 8 | |
252 | - | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
253 | - | let buyAmount = ((payment.amount * pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) / price) | |
254 | - | if ((buyAmount == 0)) | |
255 | - | then throw("Invalid amount") | |
256 | - | else if (if (all) | |
257 | - | then (amount > buyAmount) | |
258 | - | else false) | |
259 | - | then throw("You must take all or none") | |
260 | - | else if ((buyAmount > (amount - spent))) | |
261 | - | then throw("Not enougth asset in order") | |
262 | - | else { | |
263 | - | let orders = match getString(this, "orders") { | |
264 | - | case s: String => | |
265 | - | s | |
266 | - | case _: Unit => | |
267 | - | "" | |
268 | - | case _ => | |
269 | - | throw() | |
270 | - | } | |
271 | - | let newData = (dropRight(data, size(split(data, "_")[7])) + toString((spent + buyAmount))) | |
272 | - | let index = value(indexOf(orders, orderId)) | |
273 | - | let newOrders = if ((amount == (buyAmount + spent))) | |
274 | - | then (take(orders, index) + drop(orders, (index + size(orderId)))) | |
275 | - | else orders | |
276 | - | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, buyAmount, if ((amountAsset == "WAVES")) | |
277 | - | then unit | |
278 | - | else fromBase58String(amountAsset)), ScriptTransfer(owner, payment.amount, if ((priceAsset == "WAVES")) | |
279 | - | then unit | |
280 | - | else fromBase58String(priceAsset))])) | |
281 | - | } | |
282 | - | } | |
283 | - | } | |
249 | + | let orderPassword = split(data, "_")[7] | |
250 | + | let orderSpent = parseIntValue(split(data, "_")[8]) | |
251 | + | if ((orderType != "sell")) | |
252 | + | then throw("Invalid order type") | |
253 | + | else if ((orderPriceAsset != priceAsset)) | |
254 | + | then throw(("Payment asset must be " + orderPriceAsset)) | |
255 | + | else { | |
256 | + | let valid = if ((orderPassword != "")) | |
257 | + | then sigVerify(i.callerPublicKey, fromBase58String(sig), fromBase58String(orderPassword)) | |
258 | + | else true | |
259 | + | if (!(valid)) | |
260 | + | then throw("The order is private") | |
261 | + | else { | |
262 | + | let amount = ((priceAssetAmount * orderAmount) / orderPriceAssetAmount) | |
263 | + | if ((amount == 0)) | |
264 | + | then throw("Invalid amount") | |
265 | + | else if (if (orderAll) | |
266 | + | then (orderAmount > amount) | |
267 | + | else false) | |
268 | + | then throw("You must take all or none") | |
269 | + | else if ((amount > (orderAmount - orderSpent))) | |
270 | + | then throw("Not enougth asset in order") | |
271 | + | else { | |
272 | + | let orders = match getString(this, "orders") { | |
273 | + | case s: String => | |
274 | + | s | |
275 | + | case _: Unit => | |
276 | + | "" | |
277 | + | case _ => | |
278 | + | throw() | |
279 | + | } | |
280 | + | let newData = (dropRight(data, size(split(data, "_")[7])) + toString((orderSpent + amount))) | |
281 | + | let index = value(indexOf(orders, orderId)) | |
282 | + | let newOrders = if ((orderAmount == (amount + orderSpent))) | |
283 | + | then (take(orders, index) + drop(orders, (index + size(orderId)))) | |
284 | + | else orders | |
285 | + | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, amount, if ((orderAmountAsset == "WAVES")) | |
286 | + | then unit | |
287 | + | else fromBase58String(orderAmountAsset)), ScriptTransfer(orderOwner, priceAssetAmount, if ((orderPriceAsset == "WAVES")) | |
288 | + | then unit | |
289 | + | else fromBase58String(orderPriceAsset))])) | |
290 | + | } | |
291 | + | } | |
292 | + | } | |
284 | 293 | } | |
285 | 294 | } | |
286 | 295 | ||
289 | 298 | @Callable(i) | |
290 | 299 | func takeBuy (orderId,sig) = { | |
291 | 300 | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
292 | - | if ((0 >= payment.amount)) | |
301 | + | let amount = payment.amount | |
302 | + | if ((0 >= amount)) | |
293 | 303 | then throw("amount must be positive") | |
294 | 304 | else { | |
295 | - | let | |
305 | + | let amountAsset = match payment.assetId { | |
296 | 306 | case p: ByteVector => | |
297 | 307 | toBase58String(p) | |
298 | 308 | case _ => | |
299 | 309 | "WAVES" | |
300 | 310 | } | |
301 | 311 | let data = valueOrErrorMessage(getString(this, orderId), "Invalid order id") | |
302 | - | let amount = parseIntValue(split(data, "_")[0]) | |
303 | - | let amountAsset = split(data, "_")[1] | |
304 | - | let price = parseIntValue(split(data, "_")[2]) | |
305 | - | let priceAsset = split(data, "_")[3] | |
306 | - | let owner = value(addressFromString(split(data, "_")[4])) | |
307 | - | let all = if ((split(data, "_")[5] == "true")) | |
312 | + | let orderType = split(data, "_")[0] | |
313 | + | let orderAmount = parseIntValue(split(data, "_")[1]) | |
314 | + | let orderAmountAsset = split(data, "_")[2] | |
315 | + | let orderPriceAssetAmount = parseIntValue(split(data, "_")[3]) | |
316 | + | let orderPriceAsset = split(data, "_")[4] | |
317 | + | let orderOwner = value(addressFromString(split(data, "_")[5])) | |
318 | + | let orderAll = if ((split(data, "_")[6] == "true")) | |
308 | 319 | then true | |
309 | 320 | else false | |
310 | - | let password = split(data, "_")[6] | |
311 | - | let spent = parseIntValue(split(data, "_")[7]) | |
312 | - | if ((amountAsset != paymentAsset)) | |
313 | - | then throw(("payment asset must be " + amountAsset)) | |
314 | - | else { | |
315 | - | let valid = if ((password != "")) | |
316 | - | then sigVerify(i.callerPublicKey, fromBase58String(sig), fromBase58String(password)) | |
317 | - | else true | |
318 | - | if (!(valid)) | |
319 | - | then throw("The order is private") | |
320 | - | else { | |
321 | - | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
322 | - | then 8 | |
323 | - | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
324 | - | let priceAmount = ((payment.amount * price) / pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) | |
325 | - | if ((priceAmount == 0)) | |
326 | - | then throw("invalid amount") | |
327 | - | else if (if (all) | |
328 | - | then (amount > priceAmount) | |
329 | - | else false) | |
330 | - | then throw("You must take all or none") | |
331 | - | else if ((payment.amount > (amount - spent))) | |
332 | - | then throw("not enougth asset in order") | |
333 | - | else { | |
334 | - | let orders = match getString(this, "orders") { | |
335 | - | case s: String => | |
336 | - | s | |
337 | - | case _: Unit => | |
338 | - | "" | |
339 | - | case _ => | |
340 | - | throw() | |
341 | - | } | |
342 | - | let newData = (dropRight(data, size(split(data, "_")[7])) + toString((spent + payment.amount))) | |
343 | - | let index = value(indexOf(orders, orderId)) | |
344 | - | let newOrders = if ((amount == (payment.amount + spent))) | |
345 | - | then (take(orders, index) + drop(orders, (index + size(orderId)))) | |
346 | - | else orders | |
347 | - | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, priceAmount, if ((priceAsset == "WAVES")) | |
348 | - | then unit | |
349 | - | else fromBase58String(priceAsset)), ScriptTransfer(owner, payment.amount, if ((amountAsset == "WAVES")) | |
350 | - | then unit | |
351 | - | else fromBase58String(amountAsset))])) | |
352 | - | } | |
353 | - | } | |
354 | - | } | |
321 | + | let orderPassword = split(data, "_")[7] | |
322 | + | let orderSpent = parseIntValue(split(data, "_")[8]) | |
323 | + | if ((orderType != "buy")) | |
324 | + | then throw("Invalid order type") | |
325 | + | else if ((orderAmountAsset != amountAsset)) | |
326 | + | then throw(("payment asset must be " + orderAmountAsset)) | |
327 | + | else { | |
328 | + | let valid = if ((orderPassword != "")) | |
329 | + | then sigVerify(i.callerPublicKey, fromBase58String(sig), fromBase58String(orderPassword)) | |
330 | + | else true | |
331 | + | if (!(valid)) | |
332 | + | then throw("The order is private") | |
333 | + | else { | |
334 | + | let priceAssetAmount = ((amount * orderPriceAssetAmount) / orderAmount) | |
335 | + | if ((priceAssetAmount == 0)) | |
336 | + | then throw("Invalid amount") | |
337 | + | else if (if (orderAll) | |
338 | + | then (orderPriceAssetAmount > priceAssetAmount) | |
339 | + | else false) | |
340 | + | then throw("You must take all or none") | |
341 | + | else if ((priceAssetAmount > (orderPriceAssetAmount - orderSpent))) | |
342 | + | then throw("not enougth asset in order") | |
343 | + | else { | |
344 | + | let orders = match getString(this, "orders") { | |
345 | + | case s: String => | |
346 | + | s | |
347 | + | case _: Unit => | |
348 | + | "" | |
349 | + | case _ => | |
350 | + | throw() | |
351 | + | } | |
352 | + | let newData = (dropRight(data, size(split(data, "_")[7])) + toString((orderSpent + priceAssetAmount))) | |
353 | + | let index = value(indexOf(orders, orderId)) | |
354 | + | let newOrders = if ((orderPriceAssetAmount == (priceAssetAmount + orderSpent))) | |
355 | + | then (take(orders, index) + drop(orders, (index + size(orderId)))) | |
356 | + | else orders | |
357 | + | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, priceAssetAmount, if ((orderPriceAsset == "WAVES")) | |
358 | + | then unit | |
359 | + | else fromBase58String(orderPriceAsset)), ScriptTransfer(orderOwner, amount, if ((orderAmountAsset == "WAVES")) | |
360 | + | then unit | |
361 | + | else fromBase58String(orderAmountAsset))])) | |
362 | + | } | |
363 | + | } | |
364 | + | } | |
355 | 365 | } | |
366 | + | } | |
367 | + | ||
368 | + | ||
369 | + | ||
370 | + | @Callable(i) | |
371 | + | func returnSell (orderId) = { | |
372 | + | let data = valueOrErrorMessage(getString(this, ("sell_" + orderId)), "Invalid order id") | |
373 | + | let orderType = split(data, "_")[0] | |
374 | + | let orderAmount = parseIntValue(split(data, "_")[1]) | |
375 | + | let orderAmountAsset = split(data, "_")[2] | |
376 | + | let orderPriceAssetAmount = parseIntValue(split(data, "_")[3]) | |
377 | + | let orderPriceAsset = split(data, "_")[4] | |
378 | + | let orderOwner = value(addressFromString(split(data, "_")[5])) | |
379 | + | let orderAll = if ((split(data, "_")[6] == "true")) | |
380 | + | then true | |
381 | + | else false | |
382 | + | let orderPassword = split(data, "_")[7] | |
383 | + | let orderSpent = parseIntValue(split(data, "_")[8]) | |
384 | + | if ((orderType != "sell")) | |
385 | + | then throw("Invalid order type") | |
386 | + | else if ((orderOwner != i.caller)) | |
387 | + | then throw("return should be called by order owner") | |
388 | + | else { | |
389 | + | let returnAmount = (orderAmount - orderSpent) | |
390 | + | if ((0 >= returnAmount)) | |
391 | + | then throw("nothing to return") | |
392 | + | else { | |
393 | + | let orders = match getString(this, "orders") { | |
394 | + | case s: String => | |
395 | + | s | |
396 | + | case _: Unit => | |
397 | + | "" | |
398 | + | case _ => | |
399 | + | throw() | |
400 | + | } | |
401 | + | let newData = (dropRight(data, size(split(data, "_")[7])) + toString(orderAmount)) | |
402 | + | let index = value(indexOf(orders, orderId)) | |
403 | + | let newOrders = (take(orders, index) + drop(orders, (index + size(orderId)))) | |
404 | + | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, returnAmount, if ((orderAmountAsset == "WAVES")) | |
405 | + | then unit | |
406 | + | else fromBase58String(orderAmountAsset))])) | |
407 | + | } | |
408 | + | } | |
356 | 409 | } | |
357 | 410 | ||
358 | 411 | ||
360 | 413 | @Callable(i) | |
361 | 414 | func returnBuy (orderId) = { | |
362 | 415 | let data = valueOrErrorMessage(getString(this, orderId), "Invalid order id") | |
363 | - | let amount = parseIntValue(split(data, "_")[0]) | |
364 | - | let amountAsset = split(data, "_")[1] | |
365 | - | let price = parseIntValue(split(data, "_")[2]) | |
366 | - | let priceAsset = split(data, "_")[3] | |
367 | - | let owner = value(addressFromString(split(data, "_")[4])) | |
368 | - | let all = if ((split(data, "_")[5] == "true")) | |
416 | + | let orderType = split(data, "_")[0] | |
417 | + | let orderAmount = parseIntValue(split(data, "_")[1]) | |
418 | + | let orderAmountAsset = split(data, "_")[2] | |
419 | + | let orderPriceAssetAmount = parseIntValue(split(data, "_")[3]) | |
420 | + | let orderPriceAsset = split(data, "_")[4] | |
421 | + | let orderOwner = value(addressFromString(split(data, "_")[5])) | |
422 | + | let orderAll = if ((split(data, "_")[6] == "true")) | |
369 | 423 | then true | |
370 | 424 | else false | |
371 | - | let password = split(data, "_")[6] | |
372 | - | let spent = parseIntValue(split(data, "_")[7]) | |
373 | - | if ((owner != i.caller)) | |
374 | - | then throw("Return should be called by order owner") | |
375 | - | else { | |
376 | - | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
377 | - | then 8 | |
378 | - | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
379 | - | let returnAmount = (((amount - spent) * price) / pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) | |
380 | - | if ((0 >= returnAmount)) | |
381 | - | then throw("nothing to return") | |
382 | - | else { | |
383 | - | let orders = match getString(this, "orders") { | |
384 | - | case s: String => | |
385 | - | s | |
386 | - | case _: Unit => | |
387 | - | "" | |
388 | - | case _ => | |
389 | - | throw() | |
390 | - | } | |
391 | - | let newData = (dropRight(data, size(split(data, "_")[7])) + toString(amount)) | |
392 | - | let index = value(indexOf(orders, orderId)) | |
393 | - | let newOrders = (take(orders, index) + drop(orders, (index + size(orderId)))) | |
394 | - | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, returnAmount, if ((priceAsset == "WAVES")) | |
395 | - | then unit | |
396 | - | else fromBase58String(priceAsset))])) | |
397 | - | } | |
398 | - | } | |
399 | - | } | |
400 | - | ||
401 | - | ||
402 | - | ||
403 | - | @Callable(i) | |
404 | - | func returnSell (orderId) = { | |
405 | - | let data = valueOrErrorMessage(getString(this, orderId), "Invalid order id") | |
406 | - | let amount = parseIntValue(split(data, "_")[0]) | |
407 | - | let amountAsset = split(data, "_")[1] | |
408 | - | let price = parseIntValue(split(data, "_")[2]) | |
409 | - | let priceAsset = split(data, "_")[3] | |
410 | - | let owner = value(addressFromString(split(data, "_")[4])) | |
411 | - | let all = if ((split(data, "_")[5] == "true")) | |
412 | - | then true | |
413 | - | else false | |
414 | - | let password = split(data, "_")[6] | |
415 | - | let spent = parseIntValue(split(data, "_")[7]) | |
416 | - | if ((owner != i.caller)) | |
417 | - | then throw("return should be called by order owner") | |
418 | - | else { | |
419 | - | let returnAmount = (amount - spent) | |
420 | - | if ((0 >= returnAmount)) | |
421 | - | then throw("nothing to return") | |
422 | - | else { | |
423 | - | let orders = match getString(this, "orders") { | |
424 | - | case s: String => | |
425 | - | s | |
426 | - | case _: Unit => | |
427 | - | "" | |
428 | - | case _ => | |
429 | - | throw() | |
430 | - | } | |
431 | - | let newData = (dropRight(data, size(split(data, "_")[7])) + toString(amount)) | |
432 | - | let index = value(indexOf(orders, orderId)) | |
433 | - | let newOrders = (take(orders, index) + drop(orders, (index + size(orderId)))) | |
434 | - | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, returnAmount, if ((amountAsset == "WAVES")) | |
435 | - | then unit | |
436 | - | else fromBase58String(amountAsset))])) | |
437 | - | } | |
438 | - | } | |
425 | + | let orderPassword = split(data, "_")[7] | |
426 | + | let orderSpent = parseIntValue(split(data, "_")[8]) | |
427 | + | if ((orderType != "buy")) | |
428 | + | then throw("Invalid order type") | |
429 | + | else if ((orderOwner != i.caller)) | |
430 | + | then throw("Return should be called by order owner") | |
431 | + | else { | |
432 | + | let returnAmount = (orderPriceAssetAmount - orderSpent) | |
433 | + | if ((0 >= returnAmount)) | |
434 | + | then throw("nothing to return") | |
435 | + | else { | |
436 | + | let orders = match getString(this, "orders") { | |
437 | + | case s: String => | |
438 | + | s | |
439 | + | case _: Unit => | |
440 | + | "" | |
441 | + | case _ => | |
442 | + | throw() | |
443 | + | } | |
444 | + | let newData = (dropRight(data, size(split(data, "_")[7])) + toString(orderPriceAssetAmount)) | |
445 | + | let index = value(indexOf(orders, orderId)) | |
446 | + | let newOrders = (take(orders, index) + drop(orders, (index + size(orderId)))) | |
447 | + | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, returnAmount, if ((orderPriceAsset == "WAVES")) | |
448 | + | then unit | |
449 | + | else fromBase58String(orderPriceAsset))])) | |
450 | + | } | |
451 | + | } | |
439 | 452 | } | |
440 | 453 | ||
441 | 454 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let uTokenId = base58'9qh2MiJhfqNS1o3R5wcUrAAWpeqZs9R8SLwQvCx88Vaf' | |
5 | 5 | ||
6 | 6 | func checkStatus (address) = { | |
7 | 7 | let statusUnlimited = match getBoolean(this, (address + "_unlimited")) { | |
8 | 8 | case bool: Boolean => | |
9 | 9 | bool | |
10 | 10 | case _: Unit => | |
11 | 11 | false | |
12 | 12 | case _ => | |
13 | 13 | throw() | |
14 | 14 | } | |
15 | 15 | let statusTime = match getInteger(this, (address + "_time")) { | |
16 | 16 | case int: Int => | |
17 | 17 | int | |
18 | 18 | case _: Unit => | |
19 | 19 | 0 | |
20 | 20 | case _ => | |
21 | 21 | throw() | |
22 | 22 | } | |
23 | 23 | if (statusUnlimited) | |
24 | 24 | then true | |
25 | 25 | else (statusTime > lastBlock.timestamp) | |
26 | + | } | |
27 | + | ||
28 | + | ||
29 | + | func checkDecimals (amountAsset,priceAsset) = { | |
30 | + | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
31 | + | then 8 | |
32 | + | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
33 | + | let priceAssetDecimals = if ((priceAsset == "WAVES")) | |
34 | + | then 8 | |
35 | + | else value(assetInfo(fromBase58String(priceAsset))).decimals | |
36 | + | (priceAssetDecimals >= amountAssetDecimals) | |
26 | 37 | } | |
27 | 38 | ||
28 | 39 | ||
29 | 40 | @Callable(i) | |
30 | 41 | func addAsset (assetId) = { | |
31 | 42 | let addingPrice = (100 * 100000000) | |
32 | 43 | let addingPriceStr = "100" | |
33 | 44 | let payment = valueOrErrorMessage(i.payment, "Where is payment?") | |
34 | 45 | if (if (isDefined(payment.assetId)) | |
35 | 46 | then (payment.assetId != uTokenId) | |
36 | 47 | else false) | |
37 | 48 | then throw("OTCu or WAVES only") | |
38 | 49 | else if ((payment.amount != addingPrice)) | |
39 | 50 | then throw((("You have to pay " + addingPriceStr) + " OTCu or WAVES")) | |
40 | 51 | else if (!(isDefined(assetInfo(fromBase58String(assetId))))) | |
41 | 52 | then throw("There is no asset with specified id") | |
42 | 53 | else { | |
43 | 54 | let assets = match getString(this, "assets") { | |
44 | 55 | case str: String => | |
45 | 56 | str | |
46 | 57 | case _: Unit => | |
47 | 58 | "" | |
48 | 59 | case _ => | |
49 | 60 | throw() | |
50 | 61 | } | |
51 | 62 | if (isDefined(indexOf(assets, assetId))) | |
52 | 63 | then throw("Asset is already available") | |
53 | 64 | else WriteSet([DataEntry("assets", (assets + assetId))]) | |
54 | 65 | } | |
55 | 66 | } | |
56 | 67 | ||
57 | 68 | ||
58 | 69 | ||
59 | 70 | @Callable(i) | |
60 | 71 | func pro (unlimited) = { | |
61 | 72 | let address = toBase58String(i.caller.bytes) | |
62 | 73 | let unlimitedPrice = (50 * 100000000) | |
63 | 74 | let unlimitedPriceStr = "50" | |
64 | 75 | let monthPrice = (10 * 100000000) | |
65 | 76 | let monthPriceStr = "10" | |
66 | 77 | let payment = valueOrErrorMessage(i.payment, "Where is payment?") | |
67 | 78 | if (if (isDefined(payment.assetId)) | |
68 | 79 | then (payment.assetId != uTokenId) | |
69 | 80 | else false) | |
70 | 81 | then throw("OTCu or WAVES only") | |
71 | 82 | else if (if (unlimited) | |
72 | 83 | then (payment.amount != unlimitedPrice) | |
73 | 84 | else false) | |
74 | 85 | then throw((("You have to pay " + unlimitedPriceStr) + " OTCu or WAVES")) | |
75 | 86 | else if (if (!(unlimited)) | |
76 | 87 | then (payment.amount != monthPrice) | |
77 | 88 | else false) | |
78 | 89 | then throw((("You have to pay " + monthPriceStr) + " OTCu or WAVES")) | |
79 | 90 | else { | |
80 | 91 | let currentUnlimited = match getBoolean(this, (address + "_unlimited")) { | |
81 | 92 | case bool: Boolean => | |
82 | 93 | bool | |
83 | 94 | case _: Unit => | |
84 | 95 | false | |
85 | 96 | case _ => | |
86 | 97 | throw() | |
87 | 98 | } | |
88 | 99 | let currentTime = match getInteger(this, (address + "_time")) { | |
89 | 100 | case int: Int => | |
90 | 101 | int | |
91 | 102 | case _: Unit => | |
92 | 103 | 0 | |
93 | 104 | case _ => | |
94 | 105 | throw() | |
95 | 106 | } | |
96 | 107 | if (currentUnlimited) | |
97 | 108 | then throw("You have unlimited PRO status already. What do you want?") | |
98 | 109 | else { | |
99 | 110 | let month = 2629743000 | |
100 | 111 | WriteSet([DataEntry((address + "_unlimited"), unlimited), DataEntry((address + "_time"), if (unlimited) | |
101 | 112 | then 0 | |
102 | 113 | else (currentTime + month))]) | |
103 | 114 | } | |
104 | 115 | } | |
105 | 116 | } | |
106 | 117 | ||
107 | 118 | ||
108 | 119 | ||
109 | 120 | @Callable(i) | |
110 | - | func makeSell (priceAsset, | |
121 | + | func makeSell (priceAsset,priceAssetAmount,all,password) = if (if ((priceAsset != "WAVES")) | |
111 | 122 | then !(isDefined(assetInfo(fromBase58String(priceAsset)))) | |
112 | 123 | else false) | |
113 | 124 | then throw("There is no asset with specified id") | |
114 | - | else if ((0 >= | |
115 | - | then throw("price must be positive") | |
125 | + | else if ((0 >= priceAssetAmount)) | |
126 | + | then throw("Amount of price asset must be positive") | |
116 | 127 | else { | |
117 | - | let payment = valueOrErrorMessage(i.payment, " | |
128 | + | let payment = valueOrErrorMessage(i.payment, "Where is payment?") | |
118 | 129 | if ((0 >= payment.amount)) | |
119 | - | then throw(" | |
130 | + | then throw("Amount must be positive") | |
120 | 131 | else { | |
121 | 132 | let amountAsset = match payment.assetId { | |
122 | 133 | case p: ByteVector => | |
123 | 134 | toBase58String(p) | |
124 | 135 | case _ => | |
125 | 136 | "WAVES" | |
126 | 137 | } | |
127 | 138 | let assets = valueOrErrorMessage(getString(this, "assets"), "There are not available assets") | |
128 | 139 | if (if (!(isDefined(indexOf(assets, priceAsset)))) | |
129 | 140 | then true | |
130 | 141 | else !(isDefined(indexOf(assets, amountAsset)))) | |
131 | 142 | then throw("Asset are not available for trading") | |
132 | 143 | else { | |
133 | 144 | let address = toBase58String(i.caller.bytes) | |
134 | 145 | if (if (!(checkStatus(address))) | |
135 | 146 | then if (all) | |
136 | 147 | then true | |
137 | 148 | else (password != "") | |
138 | 149 | else false) | |
139 | 150 | then throw("You must have pro status to use these features") | |
140 | 151 | else { | |
141 | 152 | let orderId = toBase58String(i.transactionId) | |
142 | 153 | let orders = match getString(this, "orders") { | |
143 | 154 | case s: String => | |
144 | 155 | s | |
145 | 156 | case _: Unit => | |
146 | 157 | "" | |
147 | 158 | case _ => | |
148 | 159 | throw() | |
149 | 160 | } | |
150 | 161 | let passwordValid = fromBase58String(password) | |
151 | - | let data = ((((((((((((((toString(payment.amount) + "_") + amountAsset) + "_") + toString( | |
162 | + | let data = (((((((((((((((("sell" + "_") + toString(payment.amount)) + "_") + amountAsset) + "_") + toString(priceAssetAmount)) + "_") + priceAsset) + "_") + address) + "_") + toString(all)) + "_") + password) + "_") + toString(0)) | |
152 | 163 | WriteSet([DataEntry("orders", (orders + orderId)), DataEntry(orderId, data)]) | |
153 | 164 | } | |
154 | 165 | } | |
155 | 166 | } | |
156 | 167 | } | |
157 | 168 | ||
158 | 169 | ||
159 | 170 | ||
160 | 171 | @Callable(i) | |
161 | - | func makeBuy (amountAsset, | |
172 | + | func makeBuy (amountAsset,amount,all,password) = if (if ((amountAsset != "WAVES")) | |
162 | 173 | then !(isDefined(assetInfo(fromBase58String(amountAsset)))) | |
163 | 174 | else false) | |
164 | 175 | then throw("There is no asset with specified id") | |
165 | - | else if ((0 >= | |
166 | - | then throw(" | |
176 | + | else if ((0 >= amount)) | |
177 | + | then throw("Amount must be positive") | |
167 | 178 | else { | |
168 | 179 | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
169 | - | if ((0 >= payment.amount)) | |
180 | + | let priceAssetAmount = payment.amount | |
181 | + | if ((0 >= priceAssetAmount)) | |
170 | 182 | then throw("amount must be positive") | |
171 | 183 | else { | |
172 | 184 | let priceAsset = match payment.assetId { | |
173 | 185 | case p: ByteVector => | |
174 | 186 | toBase58String(p) | |
175 | 187 | case _ => | |
176 | 188 | "WAVES" | |
177 | 189 | } | |
178 | 190 | let assets = valueOrErrorMessage(getString(this, "assets"), "There are not available assets") | |
179 | 191 | if (if (!(isDefined(indexOf(assets, priceAsset)))) | |
180 | 192 | then true | |
181 | 193 | else !(isDefined(indexOf(assets, amountAsset)))) | |
182 | 194 | then throw("Asset are not available for trading") | |
183 | 195 | else { | |
184 | 196 | let address = toBase58String(i.caller.bytes) | |
185 | 197 | if (if (!(checkStatus(address))) | |
186 | 198 | then if (all) | |
187 | 199 | then true | |
188 | 200 | else (password != "") | |
189 | 201 | else false) | |
190 | 202 | then throw("You must have pro status to use these features") | |
191 | 203 | else { | |
192 | 204 | let orderId = toBase58String(i.transactionId) | |
193 | 205 | let orders = match getString(this, "orders") { | |
194 | 206 | case s: String => | |
195 | 207 | s | |
196 | 208 | case _: Unit => | |
197 | 209 | "" | |
198 | 210 | case _ => | |
199 | 211 | throw() | |
200 | 212 | } | |
201 | - | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
202 | - | then 8 | |
203 | - | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
204 | - | let buyAmount = ((payment.amount * pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) / price) | |
205 | - | if ((buyAmount == 0)) | |
213 | + | if ((amount == 0)) | |
206 | 214 | then throw("invalid buy amount") | |
207 | 215 | else { | |
208 | - | let data = ((((((((((((((toString( | |
209 | - | WriteSet([DataEntry("orders", (orders + orderId)), DataEntry(orderId, data)]) | |
216 | + | let data = (((((((((((((((("buy" + "_") + toString(amount)) + "_") + amountAsset) + "_") + toString(priceAssetAmount)) + "_") + priceAsset) + "_") + address) + "_") + toString(all)) + "_") + password) + "_") + toString(0)) | |
217 | + | WriteSet([DataEntry("orders", (orders + orderId)), DataEntry(("buy_" + orderId), data)]) | |
210 | 218 | } | |
211 | 219 | } | |
212 | 220 | } | |
213 | 221 | } | |
214 | 222 | } | |
215 | 223 | ||
216 | 224 | ||
217 | 225 | ||
218 | 226 | @Callable(i) | |
219 | 227 | func takeSell (orderId,sig) = { | |
220 | - | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
221 | - | if ((0 >= payment.amount)) | |
222 | - | then throw("amount must be positive") | |
228 | + | let payment = valueOrErrorMessage(i.payment, "Where is payment?") | |
229 | + | let priceAssetAmount = payment.amount | |
230 | + | if ((0 >= priceAssetAmount)) | |
231 | + | then throw("Amount must be positive") | |
223 | 232 | else { | |
224 | - | let | |
233 | + | let priceAsset = match payment.assetId { | |
225 | 234 | case p: ByteVector => | |
226 | 235 | toBase58String(p) | |
227 | 236 | case _ => | |
228 | 237 | "WAVES" | |
229 | 238 | } | |
230 | 239 | let data = valueOrErrorMessage(getString(this, orderId), "Invalid order id") | |
231 | - | let amount = parseIntValue(split(data, "_")[0]) | |
232 | - | let amountAsset = split(data, "_")[1] | |
233 | - | let price = parseIntValue(split(data, "_")[2]) | |
234 | - | let priceAsset = split(data, "_")[3] | |
235 | - | let owner = value(addressFromString(split(data, "_")[4])) | |
236 | - | let all = if ((split(data, "_")[5] == "true")) | |
240 | + | let orderType = split(data, "_")[0] | |
241 | + | let orderAmount = parseIntValue(split(data, "_")[1]) | |
242 | + | let orderAmountAsset = split(data, "_")[2] | |
243 | + | let orderPriceAssetAmount = parseIntValue(split(data, "_")[3]) | |
244 | + | let orderPriceAsset = split(data, "_")[4] | |
245 | + | let orderOwner = value(addressFromString(split(data, "_")[5])) | |
246 | + | let orderAll = if ((split(data, "_")[6] == "true")) | |
237 | 247 | then true | |
238 | 248 | else false | |
239 | - | let password = split(data, "_")[6] | |
240 | - | let spent = parseIntValue(split(data, "_")[7]) | |
241 | - | if ((priceAsset != paymentAsset)) | |
242 | - | then throw(("Payment asset must be " + priceAsset)) | |
243 | - | else { | |
244 | - | let valid = if ((password != "")) | |
245 | - | then sigVerify(i.callerPublicKey, fromBase58String(sig), fromBase58String(password)) | |
246 | - | else true | |
247 | - | if (!(valid)) | |
248 | - | then throw("The order is private") | |
249 | - | else { | |
250 | - | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
251 | - | then 8 | |
252 | - | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
253 | - | let buyAmount = ((payment.amount * pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) / price) | |
254 | - | if ((buyAmount == 0)) | |
255 | - | then throw("Invalid amount") | |
256 | - | else if (if (all) | |
257 | - | then (amount > buyAmount) | |
258 | - | else false) | |
259 | - | then throw("You must take all or none") | |
260 | - | else if ((buyAmount > (amount - spent))) | |
261 | - | then throw("Not enougth asset in order") | |
262 | - | else { | |
263 | - | let orders = match getString(this, "orders") { | |
264 | - | case s: String => | |
265 | - | s | |
266 | - | case _: Unit => | |
267 | - | "" | |
268 | - | case _ => | |
269 | - | throw() | |
270 | - | } | |
271 | - | let newData = (dropRight(data, size(split(data, "_")[7])) + toString((spent + buyAmount))) | |
272 | - | let index = value(indexOf(orders, orderId)) | |
273 | - | let newOrders = if ((amount == (buyAmount + spent))) | |
274 | - | then (take(orders, index) + drop(orders, (index + size(orderId)))) | |
275 | - | else orders | |
276 | - | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, buyAmount, if ((amountAsset == "WAVES")) | |
277 | - | then unit | |
278 | - | else fromBase58String(amountAsset)), ScriptTransfer(owner, payment.amount, if ((priceAsset == "WAVES")) | |
279 | - | then unit | |
280 | - | else fromBase58String(priceAsset))])) | |
281 | - | } | |
282 | - | } | |
283 | - | } | |
249 | + | let orderPassword = split(data, "_")[7] | |
250 | + | let orderSpent = parseIntValue(split(data, "_")[8]) | |
251 | + | if ((orderType != "sell")) | |
252 | + | then throw("Invalid order type") | |
253 | + | else if ((orderPriceAsset != priceAsset)) | |
254 | + | then throw(("Payment asset must be " + orderPriceAsset)) | |
255 | + | else { | |
256 | + | let valid = if ((orderPassword != "")) | |
257 | + | then sigVerify(i.callerPublicKey, fromBase58String(sig), fromBase58String(orderPassword)) | |
258 | + | else true | |
259 | + | if (!(valid)) | |
260 | + | then throw("The order is private") | |
261 | + | else { | |
262 | + | let amount = ((priceAssetAmount * orderAmount) / orderPriceAssetAmount) | |
263 | + | if ((amount == 0)) | |
264 | + | then throw("Invalid amount") | |
265 | + | else if (if (orderAll) | |
266 | + | then (orderAmount > amount) | |
267 | + | else false) | |
268 | + | then throw("You must take all or none") | |
269 | + | else if ((amount > (orderAmount - orderSpent))) | |
270 | + | then throw("Not enougth asset in order") | |
271 | + | else { | |
272 | + | let orders = match getString(this, "orders") { | |
273 | + | case s: String => | |
274 | + | s | |
275 | + | case _: Unit => | |
276 | + | "" | |
277 | + | case _ => | |
278 | + | throw() | |
279 | + | } | |
280 | + | let newData = (dropRight(data, size(split(data, "_")[7])) + toString((orderSpent + amount))) | |
281 | + | let index = value(indexOf(orders, orderId)) | |
282 | + | let newOrders = if ((orderAmount == (amount + orderSpent))) | |
283 | + | then (take(orders, index) + drop(orders, (index + size(orderId)))) | |
284 | + | else orders | |
285 | + | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, amount, if ((orderAmountAsset == "WAVES")) | |
286 | + | then unit | |
287 | + | else fromBase58String(orderAmountAsset)), ScriptTransfer(orderOwner, priceAssetAmount, if ((orderPriceAsset == "WAVES")) | |
288 | + | then unit | |
289 | + | else fromBase58String(orderPriceAsset))])) | |
290 | + | } | |
291 | + | } | |
292 | + | } | |
284 | 293 | } | |
285 | 294 | } | |
286 | 295 | ||
287 | 296 | ||
288 | 297 | ||
289 | 298 | @Callable(i) | |
290 | 299 | func takeBuy (orderId,sig) = { | |
291 | 300 | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
292 | - | if ((0 >= payment.amount)) | |
301 | + | let amount = payment.amount | |
302 | + | if ((0 >= amount)) | |
293 | 303 | then throw("amount must be positive") | |
294 | 304 | else { | |
295 | - | let | |
305 | + | let amountAsset = match payment.assetId { | |
296 | 306 | case p: ByteVector => | |
297 | 307 | toBase58String(p) | |
298 | 308 | case _ => | |
299 | 309 | "WAVES" | |
300 | 310 | } | |
301 | 311 | let data = valueOrErrorMessage(getString(this, orderId), "Invalid order id") | |
302 | - | let amount = parseIntValue(split(data, "_")[0]) | |
303 | - | let amountAsset = split(data, "_")[1] | |
304 | - | let price = parseIntValue(split(data, "_")[2]) | |
305 | - | let priceAsset = split(data, "_")[3] | |
306 | - | let owner = value(addressFromString(split(data, "_")[4])) | |
307 | - | let all = if ((split(data, "_")[5] == "true")) | |
312 | + | let orderType = split(data, "_")[0] | |
313 | + | let orderAmount = parseIntValue(split(data, "_")[1]) | |
314 | + | let orderAmountAsset = split(data, "_")[2] | |
315 | + | let orderPriceAssetAmount = parseIntValue(split(data, "_")[3]) | |
316 | + | let orderPriceAsset = split(data, "_")[4] | |
317 | + | let orderOwner = value(addressFromString(split(data, "_")[5])) | |
318 | + | let orderAll = if ((split(data, "_")[6] == "true")) | |
308 | 319 | then true | |
309 | 320 | else false | |
310 | - | let password = split(data, "_")[6] | |
311 | - | let spent = parseIntValue(split(data, "_")[7]) | |
312 | - | if ((amountAsset != paymentAsset)) | |
313 | - | then throw(("payment asset must be " + amountAsset)) | |
314 | - | else { | |
315 | - | let valid = if ((password != "")) | |
316 | - | then sigVerify(i.callerPublicKey, fromBase58String(sig), fromBase58String(password)) | |
317 | - | else true | |
318 | - | if (!(valid)) | |
319 | - | then throw("The order is private") | |
320 | - | else { | |
321 | - | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
322 | - | then 8 | |
323 | - | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
324 | - | let priceAmount = ((payment.amount * price) / pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) | |
325 | - | if ((priceAmount == 0)) | |
326 | - | then throw("invalid amount") | |
327 | - | else if (if (all) | |
328 | - | then (amount > priceAmount) | |
329 | - | else false) | |
330 | - | then throw("You must take all or none") | |
331 | - | else if ((payment.amount > (amount - spent))) | |
332 | - | then throw("not enougth asset in order") | |
333 | - | else { | |
334 | - | let orders = match getString(this, "orders") { | |
335 | - | case s: String => | |
336 | - | s | |
337 | - | case _: Unit => | |
338 | - | "" | |
339 | - | case _ => | |
340 | - | throw() | |
341 | - | } | |
342 | - | let newData = (dropRight(data, size(split(data, "_")[7])) + toString((spent + payment.amount))) | |
343 | - | let index = value(indexOf(orders, orderId)) | |
344 | - | let newOrders = if ((amount == (payment.amount + spent))) | |
345 | - | then (take(orders, index) + drop(orders, (index + size(orderId)))) | |
346 | - | else orders | |
347 | - | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, priceAmount, if ((priceAsset == "WAVES")) | |
348 | - | then unit | |
349 | - | else fromBase58String(priceAsset)), ScriptTransfer(owner, payment.amount, if ((amountAsset == "WAVES")) | |
350 | - | then unit | |
351 | - | else fromBase58String(amountAsset))])) | |
352 | - | } | |
353 | - | } | |
354 | - | } | |
321 | + | let orderPassword = split(data, "_")[7] | |
322 | + | let orderSpent = parseIntValue(split(data, "_")[8]) | |
323 | + | if ((orderType != "buy")) | |
324 | + | then throw("Invalid order type") | |
325 | + | else if ((orderAmountAsset != amountAsset)) | |
326 | + | then throw(("payment asset must be " + orderAmountAsset)) | |
327 | + | else { | |
328 | + | let valid = if ((orderPassword != "")) | |
329 | + | then sigVerify(i.callerPublicKey, fromBase58String(sig), fromBase58String(orderPassword)) | |
330 | + | else true | |
331 | + | if (!(valid)) | |
332 | + | then throw("The order is private") | |
333 | + | else { | |
334 | + | let priceAssetAmount = ((amount * orderPriceAssetAmount) / orderAmount) | |
335 | + | if ((priceAssetAmount == 0)) | |
336 | + | then throw("Invalid amount") | |
337 | + | else if (if (orderAll) | |
338 | + | then (orderPriceAssetAmount > priceAssetAmount) | |
339 | + | else false) | |
340 | + | then throw("You must take all or none") | |
341 | + | else if ((priceAssetAmount > (orderPriceAssetAmount - orderSpent))) | |
342 | + | then throw("not enougth asset in order") | |
343 | + | else { | |
344 | + | let orders = match getString(this, "orders") { | |
345 | + | case s: String => | |
346 | + | s | |
347 | + | case _: Unit => | |
348 | + | "" | |
349 | + | case _ => | |
350 | + | throw() | |
351 | + | } | |
352 | + | let newData = (dropRight(data, size(split(data, "_")[7])) + toString((orderSpent + priceAssetAmount))) | |
353 | + | let index = value(indexOf(orders, orderId)) | |
354 | + | let newOrders = if ((orderPriceAssetAmount == (priceAssetAmount + orderSpent))) | |
355 | + | then (take(orders, index) + drop(orders, (index + size(orderId)))) | |
356 | + | else orders | |
357 | + | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, priceAssetAmount, if ((orderPriceAsset == "WAVES")) | |
358 | + | then unit | |
359 | + | else fromBase58String(orderPriceAsset)), ScriptTransfer(orderOwner, amount, if ((orderAmountAsset == "WAVES")) | |
360 | + | then unit | |
361 | + | else fromBase58String(orderAmountAsset))])) | |
362 | + | } | |
363 | + | } | |
364 | + | } | |
355 | 365 | } | |
366 | + | } | |
367 | + | ||
368 | + | ||
369 | + | ||
370 | + | @Callable(i) | |
371 | + | func returnSell (orderId) = { | |
372 | + | let data = valueOrErrorMessage(getString(this, ("sell_" + orderId)), "Invalid order id") | |
373 | + | let orderType = split(data, "_")[0] | |
374 | + | let orderAmount = parseIntValue(split(data, "_")[1]) | |
375 | + | let orderAmountAsset = split(data, "_")[2] | |
376 | + | let orderPriceAssetAmount = parseIntValue(split(data, "_")[3]) | |
377 | + | let orderPriceAsset = split(data, "_")[4] | |
378 | + | let orderOwner = value(addressFromString(split(data, "_")[5])) | |
379 | + | let orderAll = if ((split(data, "_")[6] == "true")) | |
380 | + | then true | |
381 | + | else false | |
382 | + | let orderPassword = split(data, "_")[7] | |
383 | + | let orderSpent = parseIntValue(split(data, "_")[8]) | |
384 | + | if ((orderType != "sell")) | |
385 | + | then throw("Invalid order type") | |
386 | + | else if ((orderOwner != i.caller)) | |
387 | + | then throw("return should be called by order owner") | |
388 | + | else { | |
389 | + | let returnAmount = (orderAmount - orderSpent) | |
390 | + | if ((0 >= returnAmount)) | |
391 | + | then throw("nothing to return") | |
392 | + | else { | |
393 | + | let orders = match getString(this, "orders") { | |
394 | + | case s: String => | |
395 | + | s | |
396 | + | case _: Unit => | |
397 | + | "" | |
398 | + | case _ => | |
399 | + | throw() | |
400 | + | } | |
401 | + | let newData = (dropRight(data, size(split(data, "_")[7])) + toString(orderAmount)) | |
402 | + | let index = value(indexOf(orders, orderId)) | |
403 | + | let newOrders = (take(orders, index) + drop(orders, (index + size(orderId)))) | |
404 | + | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, returnAmount, if ((orderAmountAsset == "WAVES")) | |
405 | + | then unit | |
406 | + | else fromBase58String(orderAmountAsset))])) | |
407 | + | } | |
408 | + | } | |
356 | 409 | } | |
357 | 410 | ||
358 | 411 | ||
359 | 412 | ||
360 | 413 | @Callable(i) | |
361 | 414 | func returnBuy (orderId) = { | |
362 | 415 | let data = valueOrErrorMessage(getString(this, orderId), "Invalid order id") | |
363 | - | let amount = parseIntValue(split(data, "_")[0]) | |
364 | - | let amountAsset = split(data, "_")[1] | |
365 | - | let price = parseIntValue(split(data, "_")[2]) | |
366 | - | let priceAsset = split(data, "_")[3] | |
367 | - | let owner = value(addressFromString(split(data, "_")[4])) | |
368 | - | let all = if ((split(data, "_")[5] == "true")) | |
416 | + | let orderType = split(data, "_")[0] | |
417 | + | let orderAmount = parseIntValue(split(data, "_")[1]) | |
418 | + | let orderAmountAsset = split(data, "_")[2] | |
419 | + | let orderPriceAssetAmount = parseIntValue(split(data, "_")[3]) | |
420 | + | let orderPriceAsset = split(data, "_")[4] | |
421 | + | let orderOwner = value(addressFromString(split(data, "_")[5])) | |
422 | + | let orderAll = if ((split(data, "_")[6] == "true")) | |
369 | 423 | then true | |
370 | 424 | else false | |
371 | - | let password = split(data, "_")[6] | |
372 | - | let spent = parseIntValue(split(data, "_")[7]) | |
373 | - | if ((owner != i.caller)) | |
374 | - | then throw("Return should be called by order owner") | |
375 | - | else { | |
376 | - | let amountAssetDecimals = if ((amountAsset == "WAVES")) | |
377 | - | then 8 | |
378 | - | else value(assetInfo(fromBase58String(amountAsset))).decimals | |
379 | - | let returnAmount = (((amount - spent) * price) / pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) | |
380 | - | if ((0 >= returnAmount)) | |
381 | - | then throw("nothing to return") | |
382 | - | else { | |
383 | - | let orders = match getString(this, "orders") { | |
384 | - | case s: String => | |
385 | - | s | |
386 | - | case _: Unit => | |
387 | - | "" | |
388 | - | case _ => | |
389 | - | throw() | |
390 | - | } | |
391 | - | let newData = (dropRight(data, size(split(data, "_")[7])) + toString(amount)) | |
392 | - | let index = value(indexOf(orders, orderId)) | |
393 | - | let newOrders = (take(orders, index) + drop(orders, (index + size(orderId)))) | |
394 | - | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, returnAmount, if ((priceAsset == "WAVES")) | |
395 | - | then unit | |
396 | - | else fromBase58String(priceAsset))])) | |
397 | - | } | |
398 | - | } | |
399 | - | } | |
400 | - | ||
401 | - | ||
402 | - | ||
403 | - | @Callable(i) | |
404 | - | func returnSell (orderId) = { | |
405 | - | let data = valueOrErrorMessage(getString(this, orderId), "Invalid order id") | |
406 | - | let amount = parseIntValue(split(data, "_")[0]) | |
407 | - | let amountAsset = split(data, "_")[1] | |
408 | - | let price = parseIntValue(split(data, "_")[2]) | |
409 | - | let priceAsset = split(data, "_")[3] | |
410 | - | let owner = value(addressFromString(split(data, "_")[4])) | |
411 | - | let all = if ((split(data, "_")[5] == "true")) | |
412 | - | then true | |
413 | - | else false | |
414 | - | let password = split(data, "_")[6] | |
415 | - | let spent = parseIntValue(split(data, "_")[7]) | |
416 | - | if ((owner != i.caller)) | |
417 | - | then throw("return should be called by order owner") | |
418 | - | else { | |
419 | - | let returnAmount = (amount - spent) | |
420 | - | if ((0 >= returnAmount)) | |
421 | - | then throw("nothing to return") | |
422 | - | else { | |
423 | - | let orders = match getString(this, "orders") { | |
424 | - | case s: String => | |
425 | - | s | |
426 | - | case _: Unit => | |
427 | - | "" | |
428 | - | case _ => | |
429 | - | throw() | |
430 | - | } | |
431 | - | let newData = (dropRight(data, size(split(data, "_")[7])) + toString(amount)) | |
432 | - | let index = value(indexOf(orders, orderId)) | |
433 | - | let newOrders = (take(orders, index) + drop(orders, (index + size(orderId)))) | |
434 | - | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, returnAmount, if ((amountAsset == "WAVES")) | |
435 | - | then unit | |
436 | - | else fromBase58String(amountAsset))])) | |
437 | - | } | |
438 | - | } | |
425 | + | let orderPassword = split(data, "_")[7] | |
426 | + | let orderSpent = parseIntValue(split(data, "_")[8]) | |
427 | + | if ((orderType != "buy")) | |
428 | + | then throw("Invalid order type") | |
429 | + | else if ((orderOwner != i.caller)) | |
430 | + | then throw("Return should be called by order owner") | |
431 | + | else { | |
432 | + | let returnAmount = (orderPriceAssetAmount - orderSpent) | |
433 | + | if ((0 >= returnAmount)) | |
434 | + | then throw("nothing to return") | |
435 | + | else { | |
436 | + | let orders = match getString(this, "orders") { | |
437 | + | case s: String => | |
438 | + | s | |
439 | + | case _: Unit => | |
440 | + | "" | |
441 | + | case _ => | |
442 | + | throw() | |
443 | + | } | |
444 | + | let newData = (dropRight(data, size(split(data, "_")[7])) + toString(orderPriceAssetAmount)) | |
445 | + | let index = value(indexOf(orders, orderId)) | |
446 | + | let newOrders = (take(orders, index) + drop(orders, (index + size(orderId)))) | |
447 | + | ScriptResult(WriteSet([DataEntry("orders", newOrders), DataEntry(orderId, newData)]), TransferSet([ScriptTransfer(i.caller, returnAmount, if ((orderPriceAsset == "WAVES")) | |
448 | + | then unit | |
449 | + | else fromBase58String(orderPriceAsset))])) | |
450 | + | } | |
451 | + | } | |
439 | 452 | } | |
440 | 453 | ||
441 | 454 |
github/deemru/w8io/169f3d6 87.97 ms ◑