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