tx · 1Mh8dJKr6Hedyb3EnSz3RA5LaLFGZjK8NcsfJyA4Pb2 3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv: -0.01400000 Waves 2019.09.11 00:42 [670576] smart account 3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv > SELF 0.00000000 Waves
{ "type": 13, "id": "1Mh8dJKr6Hedyb3EnSz3RA5LaLFGZjK8NcsfJyA4Pb2", "fee": 1400000, "feeAssetId": null, "timestamp": 1568151763987, "version": 1, "sender": "3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv", "senderPublicKey": "BxHnTcjvN9ZtnKfdKYp6aKRdkMB4ZHxHnTDr5dWx5Vz2", "proofs": [ "5xNUR7Fdzvcx8iLQRoho13AG6NYVrGAU67pJ62vgpSRMHCL61TZo5w7t1tbXQHUgPuZxWTmMqnTX1YQvWro1odk8" ], "script": "base64:AAIDAAAAAAAAAAAAAAAAAAAAAwAAAAFpAQAAAAhtYWtlU2VsbAAAAAIAAAAKcHJpY2VBc3NldAAAAAVwcmljZQMDCQEAAAACIT0AAAACBQAAAApwcmljZUFzc2V0AgAAAAVXQVZFUwkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQkAA+wAAAABCQACWQAAAAEFAAAACnByaWNlQXNzZXQHCQAAAgAAAAECAAAAI1RoZXJlIGlzIG5vIGFzc2V0IHdpdGggc3BlY2lmaWVkIGlkAwkAAGcAAAACAAAAAAAAAAAABQAAAAVwcmljZQkAAAIAAAABAgAAABZwcmljZSBtdXN0IGJlIHBvc2l0aXZlBAAAAAdwYXltZW50CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIIBQAAAAFpAAAAB3BheW1lbnQCAAAAEXdoZXJlIGlzIHBheW1lbnQ/AwkAAGcAAAACAAAAAAAAAAAACAUAAAAHcGF5bWVudAAAAAZhbW91bnQJAAACAAAAAQIAAAAXYW1vdW50IG11c3QgYmUgcG9zaXRpdmUEAAAAB29yZGVySWQJAAEs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ALYW1vdW50QXNzZXQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAFb3duZXIIBQAAAAdwYXltZW50AAAABmFtb3VudAMJAAAAAAAAAgUAAAAKcHJpY2VBc3NldAIAAAAFV0FWRVMFAAAABHVuaXQJAAJZAAAAAQUAAAAKcHJpY2VBc3NldAUAAAADbmlsAAAAAACebR4=", "chainId": 84, "height": 670576, "spentComplexity": 0 } View: original | compacted Prev: cgaJd6ZDpxK2rVq1ugUFMwwfz5ypyQ1k7q8MQ47KAu5 Next: FfyAK5oJ4T7L8KFXMAK4MrU3gJ6NykijhpygHAE7dmiW Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | - | func makeSell (priceAsset,price | |
7 | + | func makeSell (priceAsset,price) = if (if ((priceAsset != "WAVES")) | |
8 | 8 | then !(isDefined(assetInfo(fromBase58String(priceAsset)))) | |
9 | 9 | else false) | |
10 | 10 | then throw("There is no asset with specified id") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | @Callable(i) | |
32 | - | func makeBuy (amountAsset,price | |
32 | + | func makeBuy (amountAsset,price) = if (if ((amountAsset != "WAVES")) | |
33 | 33 | then !(isDefined(assetInfo(fromBase58String(amountAsset)))) | |
34 | 34 | else false) | |
35 | 35 | then throw("There is no asset with specified id") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | ||
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | - | func makeSell (priceAsset,price | |
7 | + | func makeSell (priceAsset,price) = if (if ((priceAsset != "WAVES")) | |
8 | 8 | then !(isDefined(assetInfo(fromBase58String(priceAsset)))) | |
9 | 9 | else false) | |
10 | 10 | then throw("There is no asset with specified id") | |
11 | 11 | else if ((0 >= price)) | |
12 | 12 | then throw("price must be positive") | |
13 | 13 | else { | |
14 | 14 | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
15 | 15 | if ((0 >= payment.amount)) | |
16 | 16 | then throw("amount must be positive") | |
17 | 17 | else { | |
18 | 18 | let orderId = ("sell_" + toBase58String(i.transactionId)) | |
19 | 19 | let amountAsset = match payment.assetId { | |
20 | 20 | case p: ByteVector => | |
21 | 21 | toBase58String(p) | |
22 | 22 | case _ => | |
23 | 23 | "WAVES" | |
24 | 24 | } | |
25 | 25 | WriteSet([DataEntry((orderId + "_amount"), payment.amount), DataEntry((orderId + "_amount_asset"), amountAsset), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_price_asset"), priceAsset), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
26 | 26 | } | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | ||
31 | 31 | @Callable(i) | |
32 | - | func makeBuy (amountAsset,price | |
32 | + | func makeBuy (amountAsset,price) = if (if ((amountAsset != "WAVES")) | |
33 | 33 | then !(isDefined(assetInfo(fromBase58String(amountAsset)))) | |
34 | 34 | else false) | |
35 | 35 | then throw("There is no asset with specified id") | |
36 | 36 | else if ((0 >= price)) | |
37 | 37 | then throw("price must be positive") | |
38 | 38 | else { | |
39 | 39 | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
40 | 40 | if ((0 >= payment.amount)) | |
41 | 41 | then throw("amount must be positive") | |
42 | 42 | else { | |
43 | 43 | let orderId = ("buy_" + toBase58String(i.transactionId)) | |
44 | 44 | let priceAsset = match payment.assetId { | |
45 | 45 | case p: ByteVector => | |
46 | 46 | toBase58String(p) | |
47 | 47 | case _ => | |
48 | 48 | "WAVES" | |
49 | 49 | } | |
50 | 50 | WriteSet([DataEntry((orderId + "_amount"), (payment.amount / price)), DataEntry((orderId + "_amount_asset"), amountAsset), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_price_asset"), priceAsset), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)]) | |
51 | 51 | } | |
52 | 52 | } | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | ||
56 | 56 | @Callable(i) | |
57 | 57 | func takeSell (id) = { | |
58 | 58 | let payment = valueOrErrorMessage(i.payment, "where is payment?") | |
59 | 59 | if ((0 >= payment.amount)) | |
60 | 60 | then throw("amount must be positive") | |
61 | 61 | else { | |
62 | 62 | let orderId = ("sell_" + id) | |
63 | 63 | let paymentAsset = match payment.assetId { | |
64 | 64 | case p: ByteVector => | |
65 | 65 | toBase58String(p) | |
66 | 66 | case _ => | |
67 | 67 | "WAVES" | |
68 | 68 | } | |
69 | 69 | let priceAsset = valueOrErrorMessage(getString(this, (orderId + "_price_asset")), "there is no order with specified id") | |
70 | 70 | if ((priceAsset != paymentAsset)) | |
71 | 71 | then throw(("payment asset must be " + priceAsset)) | |
72 | 72 | else { | |
73 | 73 | let price = getIntegerValue(this, (orderId + "_price")) | |
74 | 74 | let amount = getIntegerValue(this, (orderId + "_amount")) | |
75 | 75 | let buyAmount = (payment.amount / price) | |
76 | 76 | let owner = value(addressFromString(getStringValue(this, (orderId + "_owner")))) | |
77 | 77 | let amountAsset = getStringValue(this, (orderId + "_amount_asset")) | |
78 | 78 | let spent = getIntegerValue(this, (orderId + "_spent")) | |
79 | 79 | if ((buyAmount > (amount - spent))) | |
80 | 80 | then throw("not enougth asset in order") | |
81 | 81 | else ScriptResult(WriteSet([DataEntry((orderId + "_spent"), (spent + buyAmount))]), TransferSet([ScriptTransfer(i.caller, buyAmount, if ((amountAsset == "WAVES")) | |
82 | 82 | then unit | |
83 | 83 | else fromBase58String(amountAsset)), ScriptTransfer(owner, payment.amount, if ((priceAsset == "WAVES")) | |
84 | 84 | then unit | |
85 | 85 | else fromBase58String(priceAsset))])) | |
86 | 86 | } | |
87 | 87 | } | |
88 | 88 | } | |
89 | 89 | ||
90 | 90 |
github/deemru/w8io/169f3d6 26.37 ms ◑