tx · 4aR2GSKzTzxqfPHnUvYtoPuU9cSyhEh3SFAUYoXUNys6 3MuTR6FqVriefgvXkJtNxj8CNh3nBbuqidJ: -0.01400000 Waves 2019.09.18 18:50 [681913] smart account 3MuTR6FqVriefgvXkJtNxj8CNh3nBbuqidJ > SELF 0.00000000 Waves
{ "type": 13, "id": "4aR2GSKzTzxqfPHnUvYtoPuU9cSyhEh3SFAUYoXUNys6", "fee": 1400000, "feeAssetId": null, "timestamp": 1568821847981, "version": 1, "sender": "3MuTR6FqVriefgvXkJtNxj8CNh3nBbuqidJ", "senderPublicKey": "7Egc9nr6FA2hbNNbo8H21n8htzQ5nYzsLc6eku6JU5pn", "proofs": [ "3DPJqXq1Ueg7DcuZzLynJSHdZqn264Bh9qTFGyxYqeHYiWTfX6WgwcpU5RoH6Uap8GYn1Md6etVmP1MaaPV8J3Ya" ], "script": "base64:AAIDAAAAAAAAAAAAAAAhAAAAAAROT05FAgAAAAABAAAAGGdldE51bWJlckJ5QWRkcmVzc0FuZEtleQAAAAIAAAAHYWRkcmVzcwAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAAdhZGRyZXNzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAEAAAAOZ2V0U3RyaW5nQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAA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xAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQUAAAAQbmV1dHJpbm9Db250cmFjdAUAAAAMcmV0dXJuQW1vdW50BQAAAAtCb25kQXNzZXRJZAUAAAADbmlsAAAAAJ90Jvs=", "chainId": 84, "height": 681913, "spentComplexity": 0 } View: original | compacted Prev: none Next: AsNFd69NnkoKX7UCP1WttdkZHEEyPL5mxPdfpfSLzQP9 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let NONE = "" | |
5 | + | ||
6 | + | func getNumberByAddressAndKey (address,key) = match getInteger(addressFromStringValue(address), key) { | |
7 | + | case a: Int => | |
8 | + | a | |
9 | + | case _ => | |
10 | + | 0 | |
11 | + | } | |
12 | + | ||
13 | + | ||
14 | + | func getNumberByKey (key) = match getInteger(this, key) { | |
15 | + | case a: Int => | |
16 | + | a | |
17 | + | case _ => | |
18 | + | 0 | |
19 | + | } | |
20 | + | ||
21 | + | ||
22 | + | func getStringByKey (key) = match getString(this, key) { | |
23 | + | case a: String => | |
24 | + | a | |
25 | + | case _ => | |
26 | + | NONE | |
27 | + | } | |
28 | + | ||
29 | + | ||
30 | + | let OrderBookKey = "orderbook" | |
31 | + | ||
32 | + | let OrderPriceKey = "order_price_" | |
33 | + | ||
34 | + | let OrderTotalKey = "order_total_" | |
35 | + | ||
36 | + | let OrderFilledTotalKey = "order_filled_total_" | |
37 | + | ||
38 | + | let OrderOwnerKey = "order_owner_" | |
39 | + | ||
40 | + | let OrderHeightKey = "order_height_" | |
41 | + | ||
42 | + | let OrderStatusKey = "order_status_" | |
43 | + | ||
44 | + | let PriceKey = "price" | |
45 | + | ||
46 | + | let BondAssetIdKey = "bond_asset_id" | |
47 | + | ||
48 | + | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
49 | + | ||
50 | + | let NeutrinoContractKey = "neutrino_contract" | |
51 | + | ||
52 | + | let orderbook = getStringByKey(OrderBookKey) | |
53 | + | ||
54 | + | func getOrderPrice (id) = getNumberByKey((OrderPriceKey + id)) | |
55 | + | ||
56 | + | ||
57 | + | func getOrderTotal (id) = getNumberByKey((OrderTotalKey + id)) | |
58 | + | ||
59 | + | ||
60 | + | func getOrderOwner (id) = getStringByKey((OrderOwnerKey + id)) | |
61 | + | ||
62 | + | ||
63 | + | func getOrderStatus (id) = getStringByKey((OrderStatusKey + id)) | |
64 | + | ||
65 | + | ||
66 | + | func getOrderFilledTotal (id) = getNumberByKey((OrderFilledTotalKey + id)) | |
67 | + | ||
68 | + | ||
69 | + | let neutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey)) | |
70 | + | ||
71 | + | let neutrinoContract = getStringByKey(NeutrinoContractKey) | |
72 | + | ||
73 | + | let reserve = wavesBalance(addressFromStringValue(neutrinoContract)) | |
74 | + | ||
75 | + | let neutrinoSupply = { | |
76 | + | let info = extract(assetInfo(neutrinoAssetId)) | |
77 | + | (info.quantity - assetBalance(addressFromStringValue(neutrinoContract), neutrinoAssetId)) | |
78 | + | } | |
79 | + | ||
80 | + | let price = getNumberByAddressAndKey(neutrinoContract, PriceKey) | |
81 | + | ||
82 | + | let OrderSplitSymbol = "_" | |
83 | + | ||
84 | + | let BondAssetId = fromBase58String(getStringByKey(BondAssetIdKey)) | |
85 | + | ||
86 | + | let Wavelet = 100000000 | |
87 | + | ||
88 | + | let CANCELED = "canceled" | |
89 | + | ||
90 | + | let NEW = "new" | |
91 | + | ||
92 | + | let FILLED = "filled" | |
93 | + | ||
94 | + | func calculateOrderbook (orderId,position) = { | |
95 | + | let orders = split(orderbook, OrderSplitSymbol) | |
96 | + | let newOrder = (orderId + OrderSplitSymbol) | |
97 | + | if ((position == 0)) | |
98 | + | then (newOrder + orderbook) | |
99 | + | else if ((position >= (size(orders) - 1))) | |
100 | + | then (orderbook + newOrder) | |
101 | + | else { | |
102 | + | let parts = split(orderbook, (orders[position] + OrderSplitSymbol)) | |
103 | + | (((parts[0] + newOrder) + (orders[position] + OrderSplitSymbol)) + parts[1]) | |
104 | + | } | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | @Callable(i) | |
109 | + | func setOrder (price,position) = { | |
110 | + | let pmt = extract(i.payment) | |
111 | + | let newOrderId = toBase58String(keccak256((((toBytes(price) + toBytes(pmt.amount)) + i.caller.bytes) + toBytes(height)))) | |
112 | + | if ((pmt.assetId != neutrinoAssetId)) | |
113 | + | then throw("can use neutrino only") | |
114 | + | else if ((0 >= price)) | |
115 | + | then throw("price less zero") | |
116 | + | else if ((getOrderOwner(newOrderId) != NONE)) | |
117 | + | then throw("order exists") | |
118 | + | else { | |
119 | + | let orders = split(orderbook, OrderSplitSymbol) | |
120 | + | let nextOrderId = if ((position == 0)) | |
121 | + | then "" | |
122 | + | else orders[(position - 1)] | |
123 | + | let nextOrderPrice = getOrderPrice(nextOrderId) | |
124 | + | let isNextOrderError = if (if ((nextOrderId != "")) | |
125 | + | then (price > nextOrderPrice) | |
126 | + | else false) | |
127 | + | then true | |
128 | + | else false | |
129 | + | let prevOrderId = orders[position] | |
130 | + | let prevOrderPrice = getOrderPrice(prevOrderId) | |
131 | + | let isPrevOrderError = if ((prevOrderPrice >= price)) | |
132 | + | then true | |
133 | + | else false | |
134 | + | if (if (isNextOrderError) | |
135 | + | then true | |
136 | + | else isPrevOrderError) | |
137 | + | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
138 | + | 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)]) | |
139 | + | } | |
140 | + | } | |
141 | + | ||
142 | + | ||
143 | + | ||
144 | + | @Callable(i) | |
145 | + | func cancelOrder (orderId) = { | |
146 | + | let owner = getOrderOwner(orderId) | |
147 | + | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
148 | + | if ((owner != toString(i.caller))) | |
149 | + | then throw("permission denied") | |
150 | + | else { | |
151 | + | let parts = split(orderbook, (orderId + OrderSplitSymbol)) | |
152 | + | ScriptResult(WriteSet([DataEntry(OrderBookKey, (parts[0] + parts[1])), DataEntry((OrderStatusKey + orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, neutrinoAssetId)])) | |
153 | + | } | |
154 | + | } | |
155 | + | ||
156 | + | ||
157 | + | ||
158 | + | @Callable(i) | |
159 | + | func executeOrder () = { | |
160 | + | let bondBalance = assetBalance(this, BondAssetId) | |
161 | + | let deficit = ((neutrinoSupply - ((reserve * price) / 100)) / Wavelet) | |
162 | + | let deficitPositive = if ((0 >= deficit)) | |
163 | + | then 0 | |
164 | + | else deficit | |
165 | + | let bondAmount = if ((deficitPositive >= bondBalance)) | |
166 | + | then bondBalance | |
167 | + | else deficitPositive | |
168 | + | let returnAmount = if ((deficitPositive >= bondBalance)) | |
169 | + | then 0 | |
170 | + | else (bondBalance - deficitPositive) | |
171 | + | if ((bondAmount == 0)) | |
172 | + | then TransferSet([ScriptTransfer(addressFromStringValue(neutrinoContract), returnAmount, BondAssetId)]) | |
173 | + | else { | |
174 | + | let orderId = split(orderbook, OrderSplitSymbol)[0] | |
175 | + | let filledTotal = getOrderFilledTotal(orderId) | |
176 | + | let orderTotal = getOrderTotal(orderId) | |
177 | + | let orderPrice = getOrderPrice(orderId) | |
178 | + | let orderOwner = getOrderOwner(orderId) | |
179 | + | let amount = ((((orderTotal - filledTotal) * 100) / orderPrice) / Wavelet) | |
180 | + | let newOrderbook = if ((bondAmount >= amount)) | |
181 | + | then split(orderbook, (orderId + OrderSplitSymbol))[1] | |
182 | + | else orderbook | |
183 | + | let filledAmount = if ((bondAmount >= amount)) | |
184 | + | then amount | |
185 | + | else bondAmount | |
186 | + | let total = (((filledAmount * orderPrice) / 100) * Wavelet) | |
187 | + | let status = if ((bondAmount >= amount)) | |
188 | + | then FILLED | |
189 | + | else NEW | |
190 | + | ScriptResult(WriteSet([DataEntry(OrderBookKey, newOrderbook), DataEntry((OrderFilledTotalKey + orderId), (filledTotal + total)), DataEntry((OrderStatusKey + orderId), status)]), TransferSet([ScriptTransfer(addressFromStringValue(orderOwner), filledAmount, BondAssetId), ScriptTransfer(addressFromStringValue(neutrinoContract), total, neutrinoAssetId), ScriptTransfer(addressFromStringValue(neutrinoContract), returnAmount, BondAssetId)])) | |
191 | + | } | |
192 | + | } | |
193 | + | ||
194 | + |
github/deemru/w8io/026f985 31.25 ms ◑