tx · G3pWKUsKi4HMLycVUgtJQCNLSMb6rtuPhnfEozDKaR7c

3N84iXumu9z2CKUP7hDejL7H1KykfPHHV1A:  -0.01000000 Waves

2019.06.22 12:59 [553083] smart account 3N84iXumu9z2CKUP7hDejL7H1KykfPHHV1A > SELF 0.00000000 Waves

{ "type": 13, "id": "G3pWKUsKi4HMLycVUgtJQCNLSMb6rtuPhnfEozDKaR7c", "fee": 1000000, "feeAssetId": null, "timestamp": 1561197605705, "version": 1, "sender": "3N84iXumu9z2CKUP7hDejL7H1KykfPHHV1A", "senderPublicKey": "eNNbbeyyLwB9g2YriXZ3PriBwa5Td2BnabpMn5aY8Cz", "proofs": [ "59VDbGfFCBZqkuMu75bWENh4h7v29QSDgVUVtrVcsiNK4GZ3zkpn2AKMZsVWGcDh7ufg3RjZV6eXBa3S12aXmNib" ], "script": "base64:AAIDAAAAAAAAAAAAAAAOAAAAAAhJZHhQcmljZQAAAAAAAAAAAAAAAAAJSWR4QW1vdW50AAAAAAAAAAABAAAAAAxJZHhUcmFkZVBhaXIAAAAAAAAAAAIAAAAADElkeE9yZGVyVHlwZQAAAAAAAAAAAwAAAAAJSWR4U2VuZGVyAAAAAAAAAAAEAAAAAApJZHhBc3NldElkAAAAAAAAAAAFAAAAAANCVVkCAAAAA0JVWQAAAAAEU0VMTAIAAAAEU0VMTAEAAAAZUmVtb3ZlVW5kZXJzY29yZUlmUHJlc2VudAAAAAEAAAAJcmVtYWluaW5nAwkAAGYAAAACCQABMQAAAAEFAAAACXJlbWFpbmluZwAAAAAAAAAAAAkAATAAAAACBQAAAAlyZW1haW5pbmcAAAAAAAAAAAEFAAAACXJlbWFpbmluZwEAAAAPRm9ybWF0RGF0YVBhcmFtAAAAAQAAAAFwBAAAAAFzCQABMQAAAAEFAAAAAXADCQAAAAAAAAIFAAAAAXMAAAAAAAAAAAAJAAACAAAAAQIAAAAlUGFyYW1ldGVyIHNpemUgbXVzdCBiZSBncmVhdGVyIHRoZW4gMAMJAABmAAAAAgU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AAAAAQkAAZEAAAACBQAAAAlzZWxsT3JkZXIFAAAACUlkeFNlbmRlcgUAAAAQcHJpY2VBc3NldEFtb3VudAkBAAAAEWFzc2V0SWRGcm9tU3RyaW5nAAAAAQkAAZEAAAACBQAAAAlzZWxsT3JkZXIFAAAACklkeEFzc2V0SWQFAAAAA25pbAAAAAFpAQAAABFyZWdpc3RlclRyYWlkUGFpcgAAAAMAAAAGYXNzZXQxAAAACnByaWNlQXNzZXQAAAAJdHJhaWRQYWlyCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgUAAAAGYXNzZXQxAgAAAAEvBQAAAApwcmljZUFzc2V0BQAAAAl0cmFpZFBhaXIFAAAAA25pbAAAAAA0xPfB", "chainId": 84, "height": 553083, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
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 assetIdFromString (assetId) = if (if ((assetId == "WAVES"))
69+ then true
70+ else (assetId == ""))
71+ then unit
72+ else fromBase58String(assetId)
73+
74+
75+@Callable(i)
76+func order (assetId,price) = {
77+ let pmt = extract(i.payment)
78+ let pmtAssetIdStr = if (isDefined(pmt.assetId))
79+ then toBase58String(value(pmt.assetId))
80+ else "WAVES"
81+ let possibleTraidPair1 = getString(this, ((assetId + "/") + pmtAssetIdStr))
82+ let possibleTraidPair2 = getString(this, ((pmtAssetIdStr + "/") + assetId))
83+ let traidPair = if (isDefined(possibleTraidPair1))
84+ then value(possibleTraidPair1)
85+ else if (isDefined(possibleTraidPair2))
86+ then value(possibleTraidPair2)
87+ else throw("Traiding for that assets is not supported")
88+ let orderType = if (isDefined(possibleTraidPair1))
89+ then BUY
90+ else SELL
91+ let orderStr = FormatOrderDataStr(traidPair, toBase58String(i.caller.bytes), orderType, price, pmt.amount, assetId)
92+ WriteSet([DataEntry(toBase58String(i.transactionId), orderStr)])
93+ }
94+
95+
96+
97+@Callable(i)
98+func matchOrders (order1Id,order2Id) = {
99+ let order1 = ParseOrderRawDataStr(getStringValue(this, order1Id))
100+ let order2 = ParseOrderRawDataStr(getStringValue(this, order2Id))
101+ if ((order1[IdxTradePair] != order2[IdxTradePair]))
102+ then throw("Trying to match orders from different trading pairs")
103+ else if ((order1[IdxOrderType] == order2[IdxOrderType]))
104+ then throw("Trying to match orders of the same type")
105+ else {
106+ let order1isSell = (order1[IdxOrderType] == SELL)
107+ let sellOrder = if (order1isSell)
108+ then order1
109+ else order2
110+ let buyOrder = if (!(order1isSell))
111+ then order1
112+ else order2
113+ let sellPrice = parseIntValue(sellOrder[IdxPrice])
114+ let buyPrice = parseIntValue(buyOrder[IdxPrice])
115+ let sellOrderAmount = parseIntValue(sellOrder[IdxAmount])
116+ let buyOrderAmount = parseIntValue(buyOrder[IdxAmount])
117+ if ((sellPrice > buyPrice))
118+ then throw("Orders are not match by price")
119+ else {
120+ let exchangePrice = sellPrice
121+ let amountAssetDecimals = if ((buyOrder[IdxAssetId] == "WAVES"))
122+ then 8
123+ else value(assetInfo(value(assetIdFromString(buyOrder[IdxAssetId])))).decimals
124+ let priceAssetDecimals = if ((sellOrder[IdxAssetId] == "WAVES"))
125+ then 8
126+ else value(assetInfo(value(assetIdFromString(sellOrder[IdxAssetId])))).decimals
127+ let buyAmount = ((buyOrderAmount * 100000000) / exchangePrice)
128+ let sellAmount = sellOrderAmount
129+ let amountAssetAmount = if ((buyAmount >= sellAmount))
130+ then sellAmount
131+ else buyAmount
132+ let priceAssetAmount = ((amountAssetAmount * exchangePrice) / 100000000)
133+ let updatedBuyStr = FormatOrderDataStr(buyOrder[IdxTradePair], buyOrder[IdxSender], buyOrder[IdxOrderType], buyPrice, (buyOrderAmount - priceAssetAmount), buyOrder[IdxAssetId])
134+ let updatedSellStr = FormatOrderDataStr(sellOrder[IdxTradePair], sellOrder[IdxSender], sellOrder[IdxOrderType], sellPrice, (sellOrderAmount - amountAssetAmount), sellOrder[IdxAssetId])
135+ ScriptResult(WriteSet([DataEntry(if (!(order1isSell))
136+ then order1Id
137+ else order2Id, updatedBuyStr), DataEntry(if (order1isSell)
138+ then order1Id
139+ else order2Id, updatedSellStr)]), TransferSet([ScriptTransfer(addressFromStringValue(buyOrder[IdxSender]), amountAssetAmount, assetIdFromString(buyOrder[IdxAssetId])), ScriptTransfer(addressFromStringValue(sellOrder[IdxSender]), priceAssetAmount, assetIdFromString(sellOrder[IdxAssetId]))]))
140+ }
141+ }
142+ }
143+
144+
145+
146+@Callable(i)
147+func registerTraidPair (asset1,priceAsset,traidPair) = WriteSet([DataEntry(((asset1 + "/") + priceAsset), traidPair)])
148+
149+

github/deemru/w8io/169f3d6 
20.98 ms