tx · FVPaHXec7ajAhMnNV7tjE3bu8Wyc79ZRhCTVub361eZt

3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb:  -0.01000000 Waves

2019.08.27 19:39 [649853] smart account 3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb > SELF 0.00000000 Waves

{ "type": 13, "id": "FVPaHXec7ajAhMnNV7tjE3bu8Wyc79ZRhCTVub361eZt", "fee": 1000000, "feeAssetId": null, "timestamp": 1566924021695, "version": 1, "sender": "3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb", "senderPublicKey": "5vyi92HdgdTabKCQzDHGrgQ4ASjtoT3XrCUXr459sWuc", "proofs": [ "4oQ2WEfjpCtJd52Ho4NxrADaREuSpkPVZRvp66ZofMFP7SM2KojRRnxMY17zrvWe8WSV5HKQosq1Kd1yCDj5EpNV" ], "script": "base64:AAIDAAAAAAAAAAAAAAAUAAAAAAROT05FAgAAAAABAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAABAAAADmdldFN0cmluZ0J5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUAAAAADE9yZGVyQm9va0tleQIAAAAJb3JkZXJib29rAAAAAA1PcmRlclByaWNlS2V5AgAAAAxvcmRlcl9wcmljZV8AAAAADk9yZGVyQW1vdW50S2V5AgAAAA1vcmRlcl9hbW91bnRfAAAAAA1PcmRlck93bmVyS2V5AgAAAAxvcmRlcl9vd25lcl8AAAAADk9yZGVySGVpZ2h0S2V5AgAAAA1vcmRlcl9oZW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vdGFsBQAAAAtCb25kQXNzZXRJZAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAEFAAAAEE5ldXRyaW5vQ29udHJhY3QFAAAAC29yZGVyQW1vdW50BQAAAA9OZXV0cmlub0Fzc2V0SWQFAAAAA25pbAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAOT3JkZXJBbW91bnRLZXkFAAAAB29yZGVySWQJAABlAAAAAgUAAAAFdG90YWwFAAAADW5ld0JvbmRBbW91bnQFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAADW5ld0JvbmRBbW91bnQFAAAAC0JvbmRBc3NldElkCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAQTmV1dHJpbm9Db250cmFjdAkAAGkAAAACCQAAaAAAAAIJAABpAAAAAgUAAAANbmV3Qm9uZEFtb3VudAUAAAAKb3JkZXJQcmljZQAAAAAAAAAAZAUAAAAHV2F2ZWxldAUAAAAPTmV1dHJpbm9Bc3NldElkBQAAAANuaWwAAAAAvUIuvw==", "chainId": 84, "height": 649853, "spentComplexity": 0 } View: original | compacted Prev: none Next: 7Lep4Rd7gRnjTvNbfeVPCfRQFc2t6Duy95ey9BfvgdV1 Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 3 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let NONE = ""
5+
6+func getNumberByKey (key) = match getInteger(this, key) {
7+ case a: Int =>
8+ a
9+ case _ =>
10+ 0
11+}
12+
13+
14+func getStringByKey (key) = match getString(this, key) {
15+ case a: String =>
16+ a
17+ case _ =>
18+ NONE
19+}
20+
21+
22+let OrderBookKey = "orderbook"
23+
24+let OrderPriceKey = "order_price_"
25+
26+let OrderAmountKey = "order_amount_"
27+
28+let OrderOwnerKey = "order_owner_"
29+
30+let OrderHeightKey = "order_height_"
31+
32+let BondAssetIdKey = "bond_asset_id"
33+
34+let NeutrinoAssetIdKey = "neutrino_asset_id"
35+
36+let NeutrinoContractKey = "neutrino_contract_address"
37+
38+func getOrderBook () = getStringByKey(OrderBookKey)
39+
40+
41+func getOrderPrice (id) = getNumberByKey((OrderPriceKey + id))
42+
43+
44+func getOrderAmount (id) = getNumberByKey((OrderAmountKey + id))
45+
46+
47+func getOrderOwner (id) = getStringByKey((OrderOwnerKey + id))
48+
49+
50+let OrderSplitSymbol = "_"
51+
52+let BondAssetId = fromBase58String(getStringByKey(BondAssetIdKey))
53+
54+let NeutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey))
55+
56+let NeutrinoContract = getStringByKey(NeutrinoContractKey)
57+
58+let Wavelet = 100000000
59+
60+@Callable(i)
61+func setOrder (price,nextOrderIndex) = {
62+ let orderbook = getOrderBook()
63+ let pmt = extract(i.payment)
64+ let newOrderId = toBase58String(keccak256((((toBytes(price) + toBytes(pmt.amount)) + i.caller.bytes) + toBytes(height))))
65+ if ((pmt.assetId != NeutrinoAssetId))
66+ then throw("can use neutrino only")
67+ else if ((getOrderOwner(newOrderId) != NONE))
68+ then throw("order exists")
69+ else if ((orderbook == NONE))
70+ then WriteSet([DataEntry(OrderBookKey, (OrderSplitSymbol + newOrderId)), DataEntry((OrderPriceKey + newOrderId), price), DataEntry((OrderAmountKey + newOrderId), pmt.amount), DataEntry((OrderOwnerKey + newOrderId), toString(i.caller)), DataEntry((OrderHeightKey + newOrderId), height)])
71+ else if ((nextOrderIndex == 0))
72+ then {
73+ let prevOrderId = split(orderbook, OrderSplitSymbol)[1]
74+ let prevOrderPrice = getOrderPrice(prevOrderId)
75+ if ((price > prevOrderPrice))
76+ then WriteSet([DataEntry(OrderBookKey, ((OrderSplitSymbol + newOrderId) + orderbook)), DataEntry((OrderPriceKey + newOrderId), price), DataEntry((OrderAmountKey + newOrderId), pmt.amount), DataEntry((OrderOwnerKey + newOrderId), toString(i.caller)), DataEntry((OrderHeightKey + newOrderId), height)])
77+ else throw("invalid price prev order")
78+ }
79+ else {
80+ let orders = split(orderbook, OrderSplitSymbol)
81+ let nextOrderId = orders[nextOrderIndex]
82+ let nextOrderPrice = getOrderPrice(nextOrderId)
83+ if ((price > nextOrderPrice))
84+ then throw("invalid price next order")
85+ else if (((nextOrderIndex + 1) >= size(orders)))
86+ then WriteSet([DataEntry(OrderBookKey, ((orderbook + OrderSplitSymbol) + newOrderId)), DataEntry((OrderPriceKey + newOrderId), price), DataEntry((OrderAmountKey + newOrderId), pmt.amount), DataEntry((OrderOwnerKey + newOrderId), toString(i.caller)), DataEntry((OrderHeightKey + newOrderId), height)])
87+ else {
88+ let prevOrderId = orders[(nextOrderIndex + 1)]
89+ let prevOrderPrice = getOrderPrice(prevOrderId)
90+ if ((price > prevOrderPrice))
91+ then {
92+ let newOrderBookOnePart = split(orderbook, nextOrderId)[0]
93+ let newOrderBookTwoPart = split(orderbook, nextOrderId)[1]
94+ WriteSet([DataEntry(OrderBookKey, ((((newOrderBookOnePart + nextOrderId) + OrderSplitSymbol) + newOrderId) + newOrderBookTwoPart)), DataEntry((OrderPriceKey + newOrderId), price), DataEntry((OrderAmountKey + newOrderId), pmt.amount), DataEntry((OrderOwnerKey + newOrderId), toString(i.caller)), DataEntry((OrderHeightKey + newOrderId), height)])
95+ }
96+ else throw("invalid price prev order")
97+ }
98+ }
99+ }
100+
101+
102+
103+@Callable(i)
104+func cancelOrder (orderId) = {
105+ let orderbook = getOrderBook()
106+ let owner = getOrderOwner(orderId)
107+ let amount = getOrderAmount(orderId)
108+ if ((owner != toString(i.caller)))
109+ then throw("permission denied")
110+ else {
111+ let newOrderBookOnePart = split(orderbook, (OrderSplitSymbol + orderId))[0]
112+ let newOrderBookTwoPart = split(orderbook, (OrderSplitSymbol + orderId))[1]
113+ ScriptResult(WriteSet([DataEntry(OrderBookKey, (newOrderBookOnePart + newOrderBookTwoPart)), DataEntry((OrderPriceKey + orderId), 0), DataEntry((OrderAmountKey + orderId), 0)]), TransferSet([ScriptTransfer(i.caller, amount, NeutrinoAssetId)]))
114+ }
115+ }
116+
117+
118+
119+@Callable(i)
120+func execute () = {
121+ let orderbook = getOrderBook()
122+ let orderId = split(orderbook, OrderSplitSymbol)[1]
123+ let orderAmount = getOrderAmount(orderId)
124+ let orderPrice = getOrderPrice(orderId)
125+ let total = (((orderAmount / orderPrice) * 100) / Wavelet)
126+ let newBondAmount = assetBalance(this, BondAssetId)
127+ if ((newBondAmount >= total))
128+ then {
129+ let newOrderBookTwoPart = split(orderbook, (OrderSplitSymbol + orderId))[1]
130+ ScriptResult(WriteSet([DataEntry(OrderBookKey, newOrderBookTwoPart), DataEntry((OrderPriceKey + orderId), 0), DataEntry((OrderAmountKey + orderId), 0)]), TransferSet([ScriptTransfer(i.caller, total, BondAssetId), ScriptTransfer(addressFromStringValue(NeutrinoContract), orderAmount, NeutrinoAssetId)]))
131+ }
132+ else ScriptResult(WriteSet([DataEntry((OrderAmountKey + orderId), (total - newBondAmount))]), TransferSet([ScriptTransfer(i.caller, newBondAmount, BondAssetId), ScriptTransfer(addressFromStringValue(NeutrinoContract), (((newBondAmount / orderPrice) * 100) / Wavelet), NeutrinoAssetId)]))
133+ }
134+
135+

github/deemru/w8io/169f3d6 
23.64 ms