tx · 4iq91r5FH6FxZgkbyctTRDgh7cbhSa9Mc8Yn4Lezjg52 3N7xypnjMJoEB7gGQP8kaiRsLAgKLpMZc69: -0.01000000 Waves 2019.06.22 13:26 [553114] smart account 3N7xypnjMJoEB7gGQP8kaiRsLAgKLpMZc69 > SELF 0.00000000 Waves
{ "type": 13, "id": "4iq91r5FH6FxZgkbyctTRDgh7cbhSa9Mc8Yn4Lezjg52", "fee": 1000000, "feeAssetId": null, "timestamp": 1561199206711, "version": 1, "sender": "3N7xypnjMJoEB7gGQP8kaiRsLAgKLpMZc69", "senderPublicKey": "6DTQHSDi4mm7GvT75uZaxDcGvPdRqjXxMsisMk1sVmXR", "proofs": [ "2wEJfirDoPYntNbAnFNR4z8FhaeGkJow5h7YynAEkMjXaAPhuzxCxkSfHg6engBjz3BwkgxTWiCBPYCtvqdeGUof" ], "script": "base64:AAIDAAAAAAAAAAAAAAAPAAAAAAhJZHhQcmljZQAAAAAAAAAAAAAAAAAJSWR4QW1vdW50AAAAAAAAAAABAAAAAAxJZHhUcmFkZVBhaXIAAAAAAAAAAAIAAAAADElkeE9yZGVyVHlwZQAAAAAAAAAAAwAAAAAJSWR4U2VuZGVyAAAAAAAAAAAEAAAAAApJZHhBc3NldElkAAAAAAAAAAAFAAAAAANCVVkCAAAAA0JVWQAAAAAEU0VMTAIAAAAEU0VMTAEAAAAZUmVtb3ZlVW5kZXJzY29yZUlmUHJlc2VudAAAAAEAAAAJcmVtYWluaW5nAwkAAGYAAAACCQABMQAAAAEFAAAACXJlbWFpbmluZwAAAAAAAAAAAAkAATAAAAACBQAAAAlyZW1haW5pbmcAAAAAAAAAAAEFAAAACXJlbWFpbmluZwEAAAAPRm9ybWF0RGF0YVBhcmFtAAAAAQAAAAFwBAAAAAFzCQABMQAAAAEFAAAAAXADCQAAAAAAAAIFAAAAAXMAAAAAAAAAAAAJAAACAAAAAQIAAAAlUGFyYW1ldGVyIHNpemUgbXVzdCBiZSBncmVhdGVyIHRoZW4gMAMJAABm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AEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAZhc3NldDECAAAAAS8FAAAACnByaWNlQXNzZXQFAAAACXRyYWlkUGFpcgUAAAADbmlsAAAAAJHJjS8=", "chainId": 84, "height": 553114, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let IdxPrice = 0 | |
5 | + | ||
6 | + | let IdxAmount = 1 | |
7 | + | ||
8 | + | let IdxTradePair = 2 | |
9 | + | ||
10 | + | let IdxOrderType = 3 | |
11 | + | ||
12 | + | let IdxSender = 4 | |
13 | + | ||
14 | + | let IdxAssetId = 5 | |
15 | + | ||
16 | + | let BUY = "BUY" | |
17 | + | ||
18 | + | let SELL = "SELL" | |
19 | + | ||
20 | + | func RemoveUnderscoreIfPresent (remaining) = if ((size(remaining) > 0)) | |
21 | + | then drop(remaining, 1) | |
22 | + | else remaining | |
23 | + | ||
24 | + | ||
25 | + | func FormatDataParam (p) = { | |
26 | + | let s = size(p) | |
27 | + | if ((s == 0)) | |
28 | + | then throw("Parameter size must be greater then 0") | |
29 | + | else if ((s > 99)) | |
30 | + | then throw("Parameter size must be less then 100") | |
31 | + | else if ((10 > s)) | |
32 | + | then (("0" + toString(s)) + p) | |
33 | + | else (toString(s) + p) | |
34 | + | } | |
35 | + | ||
36 | + | ||
37 | + | func ParseNextAttribute (remaining) = { | |
38 | + | let s = size(remaining) | |
39 | + | if ((s > 0)) | |
40 | + | then { | |
41 | + | let nn = parseIntValue(take(remaining, 2)) | |
42 | + | let v = take(drop(remaining, 2), nn) | |
43 | + | let tmpRemaining = drop(remaining, (nn + 2)) | |
44 | + | let remainingState = RemoveUnderscoreIfPresent(tmpRemaining) | |
45 | + | [v, remainingState] | |
46 | + | } | |
47 | + | else throw("Empty string was passed into parseNextAttribute func") | |
48 | + | } | |
49 | + | ||
50 | + | ||
51 | + | func FormatOrderDataStr (traidPair,sender,orderType,price,amount,assetId) = { | |
52 | + | let fullStateStr = ((((((((((FormatDataParam(traidPair) + "_") + FormatDataParam(sender)) + "_") + FormatDataParam(orderType)) + "_") + FormatDataParam(toString(price))) + "_") + FormatDataParam(toString(amount))) + "_") + FormatDataParam(assetId)) | |
53 | + | fullStateStr | |
54 | + | } | |
55 | + | ||
56 | + | ||
57 | + | func ParseOrderRawDataStr (rawStateStr) = { | |
58 | + | let tradePair = ParseNextAttribute(rawStateStr) | |
59 | + | let sender = ParseNextAttribute(tradePair[1]) | |
60 | + | let orderType = ParseNextAttribute(sender[1]) | |
61 | + | let price = ParseNextAttribute(orderType[1]) | |
62 | + | let amount = ParseNextAttribute(price[1]) | |
63 | + | let assetId = ParseNextAttribute(amount[1]) | |
64 | + | [price[0], amount[0], tradePair[0], orderType[0], sender[0], assetId[0]] | |
65 | + | } | |
66 | + | ||
67 | + | ||
68 | + | func pow10 (exp) = if ((exp == 0)) | |
69 | + | then 1 | |
70 | + | else if ((exp == 1)) | |
71 | + | then 10 | |
72 | + | else if ((exp == 2)) | |
73 | + | then 100 | |
74 | + | else if ((exp == 3)) | |
75 | + | then 1000 | |
76 | + | else if ((exp == 4)) | |
77 | + | then 10000 | |
78 | + | else if ((exp == 5)) | |
79 | + | then 100000 | |
80 | + | else if ((exp == 6)) | |
81 | + | then 1000000 | |
82 | + | else if ((exp == 7)) | |
83 | + | then 10000000 | |
84 | + | else if ((exp == 8)) | |
85 | + | then 100000000 | |
86 | + | else if ((exp == 9)) | |
87 | + | then 1000000000 | |
88 | + | else if ((exp == 10)) | |
89 | + | then 10000000000 | |
90 | + | else if ((exp == 11)) | |
91 | + | then 100000000000 | |
92 | + | else if ((exp == 12)) | |
93 | + | then 1000000000000 | |
94 | + | else throw("Pow10 more then 12 is not supported") | |
95 | + | ||
96 | + | ||
97 | + | func assetIdFromString (assetId) = if (if ((assetId == "WAVES")) | |
98 | + | then true | |
99 | + | else (assetId == "")) | |
100 | + | then unit | |
101 | + | else fromBase58String(assetId) | |
102 | + | ||
103 | + | ||
104 | + | @Callable(i) | |
105 | + | func order (assetId,price) = { | |
106 | + | let pmt = extract(i.payment) | |
107 | + | let pmtAssetIdStr = if (isDefined(pmt.assetId)) | |
108 | + | then toBase58String(value(pmt.assetId)) | |
109 | + | else "WAVES" | |
110 | + | let possibleTraidPair1 = getString(this, ((assetId + "/") + pmtAssetIdStr)) | |
111 | + | let possibleTraidPair2 = getString(this, ((pmtAssetIdStr + "/") + assetId)) | |
112 | + | let traidPair = if (isDefined(possibleTraidPair1)) | |
113 | + | then value(possibleTraidPair1) | |
114 | + | else if (isDefined(possibleTraidPair2)) | |
115 | + | then value(possibleTraidPair2) | |
116 | + | else throw("Traiding for that assets is not supported") | |
117 | + | let orderType = if (isDefined(possibleTraidPair1)) | |
118 | + | then BUY | |
119 | + | else SELL | |
120 | + | let orderStr = FormatOrderDataStr(traidPair, toBase58String(i.caller.bytes), orderType, price, pmt.amount, assetId) | |
121 | + | WriteSet([DataEntry(toBase58String(i.transactionId), orderStr)]) | |
122 | + | } | |
123 | + | ||
124 | + | ||
125 | + | ||
126 | + | @Callable(i) | |
127 | + | func matchOrders (order1Id,order2Id) = { | |
128 | + | let order1 = ParseOrderRawDataStr(getStringValue(this, order1Id)) | |
129 | + | let order2 = ParseOrderRawDataStr(getStringValue(this, order2Id)) | |
130 | + | if ((order1[IdxTradePair] != order2[IdxTradePair])) | |
131 | + | then throw("Trying to match orders from different trading pairs") | |
132 | + | else if ((order1[IdxOrderType] == order2[IdxOrderType])) | |
133 | + | then throw("Trying to match orders of the same type") | |
134 | + | else { | |
135 | + | let order1isSell = (order1[IdxOrderType] == SELL) | |
136 | + | let sellOrder = if (order1isSell) | |
137 | + | then order1 | |
138 | + | else order2 | |
139 | + | let buyOrder = if (!(order1isSell)) | |
140 | + | then order1 | |
141 | + | else order2 | |
142 | + | let sellPrice = parseIntValue(sellOrder[IdxPrice]) | |
143 | + | let buyPrice = parseIntValue(buyOrder[IdxPrice]) | |
144 | + | let sellOrderAmount = parseIntValue(sellOrder[IdxAmount]) | |
145 | + | let buyOrderAmount = parseIntValue(buyOrder[IdxAmount]) | |
146 | + | if ((sellPrice > buyPrice)) | |
147 | + | then throw("Orders are not match by price") | |
148 | + | else { | |
149 | + | let exchangePrice = sellPrice | |
150 | + | let amountAssetDecimals = if ((buyOrder[IdxAssetId] == "WAVES")) | |
151 | + | then 8 | |
152 | + | else value(assetInfo(value(assetIdFromString(buyOrder[IdxAssetId])))).decimals | |
153 | + | let priceAssetDecimals = if ((sellOrder[IdxAssetId] == "WAVES")) | |
154 | + | then 8 | |
155 | + | else value(assetInfo(value(assetIdFromString(sellOrder[IdxAssetId])))).decimals | |
156 | + | let buyAmount = ((buyOrderAmount * pow10(amountAssetDecimals)) / exchangePrice) | |
157 | + | let sellAmount = sellOrderAmount | |
158 | + | let amountAssetAmount = if ((buyAmount >= sellAmount)) | |
159 | + | then sellAmount | |
160 | + | else buyAmount | |
161 | + | let priceAssetAmount = ((amountAssetAmount * exchangePrice) / pow10(amountAssetDecimals)) | |
162 | + | let updatedBuyStr = FormatOrderDataStr(buyOrder[IdxTradePair], buyOrder[IdxSender], buyOrder[IdxOrderType], buyPrice, (buyOrderAmount - priceAssetAmount), buyOrder[IdxAssetId]) | |
163 | + | let updatedSellStr = FormatOrderDataStr(sellOrder[IdxTradePair], sellOrder[IdxSender], sellOrder[IdxOrderType], sellPrice, (sellOrderAmount - amountAssetAmount), sellOrder[IdxAssetId]) | |
164 | + | ScriptResult(WriteSet([DataEntry(if (!(order1isSell)) | |
165 | + | then order1Id | |
166 | + | else order2Id, updatedBuyStr), DataEntry(if (order1isSell) | |
167 | + | then order1Id | |
168 | + | else order2Id, updatedSellStr)]), TransferSet([ScriptTransfer(addressFromStringValue(buyOrder[IdxSender]), amountAssetAmount, assetIdFromString(buyOrder[IdxAssetId])), ScriptTransfer(addressFromStringValue(sellOrder[IdxSender]), priceAssetAmount, assetIdFromString(sellOrder[IdxAssetId]))])) | |
169 | + | } | |
170 | + | } | |
171 | + | } | |
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | @Callable(i) | |
176 | + | func registerTraidPair (asset1,priceAsset,traidPair) = WriteSet([DataEntry(((asset1 + "/") + priceAsset), traidPair)]) | |
177 | + | ||
178 | + |
github/deemru/w8io/026f985 31.55 ms ◑