tx · Nb3WLdAAc8RKfQbSMgv9L4PvonrX6DqZRYWqfuoa4Za

3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb:  -0.01400000 Waves

2019.09.17 19:22 [680479] smart account 3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb > SELF 0.00000000 Waves

{ "type": 13, "id": "Nb3WLdAAc8RKfQbSMgv9L4PvonrX6DqZRYWqfuoa4Za", "fee": 1400000, "feeAssetId": null, "timestamp": 1568737409438, "version": 1, "sender": "3NC8pQxcnDTtDkhzv5Eje8qqW4qoFawLnAb", "senderPublicKey": "5vyi92HdgdTabKCQzDHGrgQ4ASjtoT3XrCUXr459sWuc", "proofs": [ "2PWRTZJzpoavWbW78YewpuNpPmS2znidKDLS7Q28Fu1sFmx56pvF6KnRr2T3CeToZmVdTEhiZpW4xJkoCPSmPQZy" ], "script": "base64:AAIDAAAAAAAAAAAAAAAhAAAAAAROT05FAgAAAAABAAAAGGdldE51bWJlckJ5QWRkcmVzc0FuZEtleQAAAAIAAAAHYWRkcmVzcwAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAAdhZGRyZXNzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAEAAAAOZ2V0U3RyaW5nQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJ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dmVsZXQEAAAABnN0YXR1cwMJAABnAAAAAgUAAAAKYm9uZEFtb3VudAUAAAAGYW1vdW50BQAAAAZGSUxMRUQFAAAAA05FVwkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAADE9yZGVyQm9va0tleQUAAAAMbmV3T3JkZXJib29rCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAAE09yZGVyRmlsbGVkVG90YWxLZXkFAAAAB29yZGVySWQJAABkAAAAAgUAAAALZmlsbGVkVG90YWwFAAAABXRvdGFsCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAADk9yZGVyU3RhdHVzS2V5BQAAAAdvcmRlcklkBQAAAAZzdGF0dXMFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAADGZpbGxlZEFtb3VudAUAAAALQm9uZEFzc2V0SWQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAABBOZXV0cmlub0NvbnRyYWN0BQAAAAV0b3RhbAUAAAAPTmV1dHJpbm9Bc3NldElkCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAQTmV1dHJpbm9Db250cmFjdAUAAAAMcmV0dXJuQW1vdW50BQAAAAtCb25kQXNzZXRJZAUAAAADbmlsAAAAAHBy8Lo=", "chainId": 84, "height": 680479, "spentComplexity": 0 } View: original | compacted Prev: DQxUA9jm9ei3KYFpc27xxhf914MdFvspmiSPiXYQxcA9 Next: 9p8rK9fSo8KhiUtqrKBd1YovogPPdebqgUthqcqjwjrS Diff:
OldNewDifferences
4949
5050 let NeutrinoContractKey = "neutrino_contract"
5151
52-let NeutrinoSupplyKey = "neutrino_supply"
53-
54-let WavesReserveKey = "waves_reserve"
55-
5652 let orderbook = getStringByKey(OrderBookKey)
5753
5854 func getOrderPrice (id) = getNumberByKey((OrderPriceKey + id))
7066 func getOrderFilledTotal (id) = getNumberByKey((OrderFilledTotalKey + id))
7167
7268
69+let NeutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey))
70+
7371 let NeutrinoContract = getStringByKey(NeutrinoContractKey)
7472
75-let reserve = getNumberByAddressAndKey(NeutrinoContract, WavesReserveKey)
73+let reserve = wavesBalance(addressFromStringValue(NeutrinoContract))
7674
77-let neutrinoSupply = getNumberByAddressAndKey(NeutrinoContract, NeutrinoSupplyKey)
75+let neutrinoSupply = {
76+ let info = extract(assetInfo(NeutrinoAssetId))
77+ (info.quantity - assetBalance(addressFromStringValue(NeutrinoContract), NeutrinoAssetId))
78+ }
7879
7980 let price = getNumberByAddressAndKey(NeutrinoContract, PriceKey)
8081
8182 let OrderSplitSymbol = "_"
8283
8384 let BondAssetId = fromBase58String(getStringByKey(BondAssetIdKey))
84-
85-let NeutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey))
8685
8786 let Wavelet = 100000000
8887
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let NONE = ""
55
66 func getNumberByAddressAndKey (address,key) = match getInteger(addressFromStringValue(address), key) {
77 case a: Int =>
88 a
99 case _ =>
1010 0
1111 }
1212
1313
1414 func getNumberByKey (key) = match getInteger(this, key) {
1515 case a: Int =>
1616 a
1717 case _ =>
1818 0
1919 }
2020
2121
2222 func getStringByKey (key) = match getString(this, key) {
2323 case a: String =>
2424 a
2525 case _ =>
2626 NONE
2727 }
2828
2929
3030 let OrderBookKey = "orderbook"
3131
3232 let OrderPriceKey = "order_price_"
3333
3434 let OrderTotalKey = "order_total_"
3535
3636 let OrderFilledTotalKey = "order_filled_total_"
3737
3838 let OrderOwnerKey = "order_owner_"
3939
4040 let OrderHeightKey = "order_height_"
4141
4242 let OrderStatusKey = "order_status_"
4343
4444 let PriceKey = "price"
4545
4646 let BondAssetIdKey = "bond_asset_id"
4747
4848 let NeutrinoAssetIdKey = "neutrino_asset_id"
4949
5050 let NeutrinoContractKey = "neutrino_contract"
5151
52-let NeutrinoSupplyKey = "neutrino_supply"
53-
54-let WavesReserveKey = "waves_reserve"
55-
5652 let orderbook = getStringByKey(OrderBookKey)
5753
5854 func getOrderPrice (id) = getNumberByKey((OrderPriceKey + id))
5955
6056
6157 func getOrderTotal (id) = getNumberByKey((OrderTotalKey + id))
6258
6359
6460 func getOrderOwner (id) = getStringByKey((OrderOwnerKey + id))
6561
6662
6763 func getOrderStatus (id) = getStringByKey((OrderStatusKey + id))
6864
6965
7066 func getOrderFilledTotal (id) = getNumberByKey((OrderFilledTotalKey + id))
7167
7268
69+let NeutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey))
70+
7371 let NeutrinoContract = getStringByKey(NeutrinoContractKey)
7472
75-let reserve = getNumberByAddressAndKey(NeutrinoContract, WavesReserveKey)
73+let reserve = wavesBalance(addressFromStringValue(NeutrinoContract))
7674
77-let neutrinoSupply = getNumberByAddressAndKey(NeutrinoContract, NeutrinoSupplyKey)
75+let neutrinoSupply = {
76+ let info = extract(assetInfo(NeutrinoAssetId))
77+ (info.quantity - assetBalance(addressFromStringValue(NeutrinoContract), NeutrinoAssetId))
78+ }
7879
7980 let price = getNumberByAddressAndKey(NeutrinoContract, PriceKey)
8081
8182 let OrderSplitSymbol = "_"
8283
8384 let BondAssetId = fromBase58String(getStringByKey(BondAssetIdKey))
84-
85-let NeutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey))
8685
8786 let Wavelet = 100000000
8887
8988 let CANCELED = "canceled"
9089
9190 let NEW = "new"
9291
9392 let FILLED = "filled"
9493
9594 func calculateOrderbook (orderId,position) = {
9695 let orders = split(orderbook, OrderSplitSymbol)
9796 let newOrder = (orderId + OrderSplitSymbol)
9897 if ((position == 0))
9998 then (newOrder + orderbook)
10099 else if ((position >= (size(orders) - 1)))
101100 then (orderbook + newOrder)
102101 else {
103102 let parts = split(orderbook, (orders[position] + OrderSplitSymbol))
104103 (((parts[0] + newOrder) + (orders[position] + OrderSplitSymbol)) + parts[1])
105104 }
106105 }
107106
108107
109108 @Callable(i)
110109 func setOrder (price,position) = {
111110 let pmt = extract(i.payment)
112111 let newOrderId = toBase58String(keccak256((((toBytes(price) + toBytes(pmt.amount)) + i.caller.bytes) + toBytes(height))))
113112 if ((pmt.assetId != NeutrinoAssetId))
114113 then throw("can use neutrino only")
115114 else if ((0 >= price))
116115 then throw("price less zero")
117116 else if ((getOrderOwner(newOrderId) != NONE))
118117 then throw("order exists")
119118 else {
120119 let orders = split(orderbook, OrderSplitSymbol)
121120 let nextOrderId = if ((position == 0))
122121 then ""
123122 else orders[(position - 1)]
124123 let nextOrderPrice = getOrderPrice(nextOrderId)
125124 let isNextOrderError = if (if ((nextOrderId != ""))
126125 then (price > nextOrderPrice)
127126 else false)
128127 then true
129128 else false
130129 let prevOrderId = orders[position]
131130 let prevOrderPrice = getOrderPrice(prevOrderId)
132131 let isPrevOrderError = if ((prevOrderPrice >= price))
133132 then true
134133 else false
135134 if (if (isNextOrderError)
136135 then true
137136 else isPrevOrderError)
138137 then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError)))
139138 else WriteSet([DataEntry(OrderBookKey, calculateOrderbook(newOrderId, position)), DataEntry((OrderPriceKey + newOrderId), price), DataEntry((OrderTotalKey + newOrderId), pmt.amount), DataEntry((OrderOwnerKey + newOrderId), toString(i.caller)), DataEntry((OrderHeightKey + newOrderId), height), DataEntry((OrderStatusKey + newOrderId), NEW)])
140139 }
141140 }
142141
143142
144143
145144 @Callable(i)
146145 func cancelOrder (orderId) = {
147146 let owner = getOrderOwner(orderId)
148147 let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId))
149148 if ((owner != toString(i.caller)))
150149 then throw("permission denied")
151150 else {
152151 let parts = split(orderbook, (orderId + OrderSplitSymbol))
153152 ScriptResult(WriteSet([DataEntry(OrderBookKey, (parts[0] + parts[1])), DataEntry((OrderStatusKey + orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, NeutrinoAssetId)]))
154153 }
155154 }
156155
157156
158157
159158 @Callable(i)
160159 func executeOrder () = {
161160 let bondBalance = assetBalance(this, BondAssetId)
162161 let deficit = ((neutrinoSupply - ((reserve * price) / 100)) / Wavelet)
163162 let bondAmount = if ((deficit >= bondBalance))
164163 then bondBalance
165164 else deficit
166165 let returnAmount = if ((deficit >= bondBalance))
167166 then 0
168167 else (bondBalance - deficit)
169168 if ((bondAmount == 0))
170169 then TransferSet([ScriptTransfer(addressFromStringValue(NeutrinoContract), returnAmount, BondAssetId)])
171170 else {
172171 let orderId = split(orderbook, OrderSplitSymbol)[0]
173172 let filledTotal = getOrderFilledTotal(orderId)
174173 let orderTotal = getOrderTotal(orderId)
175174 let orderPrice = getOrderPrice(orderId)
176175 let amount = ((((orderTotal - filledTotal) * 100) / orderPrice) / Wavelet)
177176 let newOrderbook = if ((bondAmount >= amount))
178177 then split(orderbook, (orderId + OrderSplitSymbol))[1]
179178 else orderbook
180179 let filledAmount = if ((bondAmount >= amount))
181180 then amount
182181 else bondAmount
183182 let total = (((filledAmount * orderPrice) / 100) * Wavelet)
184183 let status = if ((bondAmount >= amount))
185184 then FILLED
186185 else NEW
187186 ScriptResult(WriteSet([DataEntry(OrderBookKey, newOrderbook), DataEntry((OrderFilledTotalKey + orderId), (filledTotal + total)), DataEntry((OrderStatusKey + orderId), status)]), TransferSet([ScriptTransfer(i.caller, filledAmount, BondAssetId), ScriptTransfer(addressFromStringValue(NeutrinoContract), total, NeutrinoAssetId), ScriptTransfer(addressFromStringValue(NeutrinoContract), returnAmount, BondAssetId)]))
188187 }
189188 }
190189
191190

github/deemru/w8io/169f3d6 
88.19 ms