tx · 3R9r48JHBCAkN9WKfTCWHboKR3Ci9G4fkv4kv7dG4Joo

3Msgz3mHrTkvdJwoWq6mKF7rPmYa1sUYDKo:  -0.01000000 Waves

2019.06.22 00:17 [552311] smart account 3Msgz3mHrTkvdJwoWq6mKF7rPmYa1sUYDKo > SELF 0.00000000 Waves

{ "type": 13, "id": "3R9r48JHBCAkN9WKfTCWHboKR3Ci9G4fkv4kv7dG4Joo", "fee": 1000000, "feeAssetId": null, "timestamp": 1561151821232, "version": 1, "sender": "3Msgz3mHrTkvdJwoWq6mKF7rPmYa1sUYDKo", "senderPublicKey": "6t99UGJdB6CX4oSDnw2K6LeZSrsfQs6prKfMiH8Lzi8X", "proofs": [ "onFkatwvQPUNfD2s82aTu7zdTJJTVRwaxXUXJAHGZ4iwdLmSKv3n71tKzxMLejVSaq2N3x1oxTvGPinamydqkFG" ], "script": "base64:AAIDAAAAAAAAAAAAAAAOAAAAAAhJZHhQcmljZQAAAAAAAAAAAAAAAAAJSWR4QW1vdW50AAAAAAAAAAABAAAAAAxJZHhUcmFkZVBhaXIAAAAAAAAAAAIAAAAADElkeE9yZGVyVHlwZQAAAAAAAAAAAwAAAAAJSWR4U2VuZGVyAAAAAAAAAAAEAAAAAApJZHhBc3NldElkAAAAAAAAAAAFAAAAAANCVVkCAAAAA0JVWQAAAAAEU0VMTAIAAAAEU0VMTAEAAAAZUmVtb3ZlVW5kZXJzY29yZUlmUHJlc2VudAAAAAEAAAAJcmVtYWluaW5nAwkAAGYAAAACCQABMQAAAAEFAAAACXJlbWFpbmluZwAAAAAAAAAAAAkAATAAAAACBQAAAAlyZW1haW5pbmcAAAAAAAAAAAEFAAAACXJlbWFpbmluZwEAAAAPRm9ybWF0RGF0YVBhcmFtAAAAAQAAAAFwBAAAAAFzCQABMQAAAAEFAAAAAXADCQAAAAAAAAIFAAAAAXMAAAAAAAAAAAAJAAACAAAAAQIAAAAlUGFyYW1ldGVyIHNpemUgbXVzdCBiZSBncmVhdGVyIHRoZW4gM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AgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAZhc3NldDECAAAAAS8FAAAACnByaWNlQXNzZXQFAAAACXRyYWlkUGFpcgUAAAADbmlsAAAAAGVt++M=", "chainId": 84, "height": 552311, "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 o1 = getStringValue(this, order1Id)
100+ let o2 = getStringValue(this, order2Id)
101+ let order1 = ParseOrderRawDataStr(o1)
102+ let order2 = ParseOrderRawDataStr(o2)
103+ if ((order1[IdxTradePair] != order2[IdxTradePair]))
104+ then throw("Trying to match orders from different trading pairs")
105+ else if ((order1[IdxOrderType] == order2[IdxOrderType]))
106+ then throw("Trying to match orders of the same type")
107+ else {
108+ let order1isSell = (order1[IdxOrderType] == SELL)
109+ let sellOrder = if (order1isSell)
110+ then order1
111+ else order2
112+ let buyOrder = if (!(order1isSell))
113+ then order1
114+ else order2
115+ let sellPrice = parseIntValue(sellOrder[IdxPrice])
116+ let buyPrice = parseIntValue(buyOrder[IdxPrice])
117+ let sellOrderAmount = parseIntValue(sellOrder[IdxAmount])
118+ let buyOrderAmount = parseIntValue(buyOrder[IdxAmount])
119+ if ((sellPrice > buyPrice))
120+ then throw("Orders are not match by price")
121+ else {
122+ let exchangePrice = sellPrice
123+ let amountAssetDecimals = value(assetInfo(value(assetIdFromString(buyOrder[IdxAssetId])))).decimals
124+ let buyAmount = ((buyOrderAmount * amountAssetDecimals) / exchangePrice)
125+ let sellAmount = sellOrderAmount
126+ let amountAssetAmount = if ((buyAmount >= sellAmount))
127+ then sellAmount
128+ else buyAmount
129+ let priceAssetAmount = (amountAssetAmount * exchangePrice)
130+ let updatedBuyStr = FormatOrderDataStr(buyOrder[IdxTradePair], buyOrder[IdxSender], buyOrder[IdxOrderType], buyPrice, (buyOrderAmount - priceAssetAmount), buyOrder[IdxAssetId])
131+ let updatedSellStr = FormatOrderDataStr(sellOrder[IdxTradePair], sellOrder[IdxSender], sellOrder[IdxOrderType], sellPrice, (sellOrderAmount - amountAssetAmount), sellOrder[IdxAssetId])
132+ ScriptResult(WriteSet([DataEntry(if (!(order1isSell))
133+ then order1Id
134+ else order2Id, updatedBuyStr), DataEntry(if (order1isSell)
135+ then order1Id
136+ else order2Id, updatedSellStr)]), TransferSet([ScriptTransfer(addressFromStringValue(buyOrder[IdxSender]), amountAssetAmount, assetIdFromString(buyOrder[IdxAssetId])), ScriptTransfer(addressFromStringValue(sellOrder[IdxSender]), priceAssetAmount, assetIdFromString(sellOrder[IdxAssetId]))]))
137+ }
138+ }
139+ }
140+
141+
142+
143+@Callable(i)
144+func registerTraidPair (asset1,priceAsset,traidPair) = WriteSet([DataEntry(((asset1 + "/") + priceAsset), traidPair)])
145+
146+

github/deemru/w8io/026f985 
23.62 ms