tx · C6UTAtzNVPR5uJnJyj1MchNwbnGPonUbF9UWjY9AcrJa 3N3KGW7Gbu5krHUEpi51GTFvTTEVyYvt1vM: -0.10000000 Waves 2020.04.01 09:10 [934694] smart account 3N3KGW7Gbu5krHUEpi51GTFvTTEVyYvt1vM > SELF 0.00000000 Waves
{ "type": 13, "id": "C6UTAtzNVPR5uJnJyj1MchNwbnGPonUbF9UWjY9AcrJa", "fee": 10000000, "feeAssetId": null, "timestamp": 1585721508465, "version": 1, "sender": "3N3KGW7Gbu5krHUEpi51GTFvTTEVyYvt1vM", "senderPublicKey": "BSLyTW7cVFUAbFbgLdob7BDLUP4VSSnB3guBg4Gss9yM", "proofs": [ "3qr1CZewXVuVbASP72cr8JYHxG5VTkqjXqhBgr4SvXZaaotKYSvrYAsQCTQzSAbtJfiHpVds8zPwMMLYQV5XB32R" ], "script": "base64:AAIDAAAAAAAAAA8IARIECgIBCBIDCgEIEgAAAAA3AQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAgAAAAABAAAAFmdldEJvb2xCeUFkZHJlc3NBbmRLZXkAAAACAAAAB2FkZHJlc3MAAAADa2V5BAAAAAckbWF0Y2gwCQAEGwAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAHQm9vbGVhbgQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQcBAAAAGGdldFN0cmluZ0J5QW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AKZmlyc3RPcmRlcgkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAANRmlyc3RPcmRlcktleQMJAAAAAAAAAgUAAAAJbmV3U3RhdHVzBQAAAAZGSUxMRUQFAAAACW5leHRPcmRlcgUAAAAKZmlyc3RPcmRlcgkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAFmdldE9yZGVyRmlsbGVkVG90YWxLZXkAAAABBQAAAApmaXJzdE9yZGVyCQAAZAAAAAIFAAAAC2ZpbGxlZFRvdGFsBQAAABt0b3RhbE9yZGVyV2F2ZWxldGVzUmVxdWlyZWQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABFnZXRPcmRlclN0YXR1c0tleQAAAAEFAAAACmZpcnN0T3JkZXIFAAAACW5ld1N0YXR1cwUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQkBAAAADWdldE9yZGVyT3duZXIAAAABBQAAAApmaXJzdE9yZGVyBQAAABNmaWxsYWJsZU9yZGVyQW1vdW50BQAAAAtib25kQXNzZXRJZAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAABBuZXV0cmlub0NvbnRyYWN0BQAAABt0b3RhbE9yZGVyV2F2ZWxldGVzUmVxdWlyZWQFAAAABHVuaXQFAAAAA25pbAAAAADEo8U3", "chainId": 84, "height": 934694, "spentComplexity": 0 } View: original | compacted Prev: CJQyypAkXbbjcH5jVGjqRpjqdBitA8aZ193Jpwbn9frM Next: none Diff:
Old | New | Differences | |
---|---|---|---|
47 | 47 | ||
48 | 48 | let PERCENTACCURACY = 1000 | |
49 | 49 | ||
50 | - | let MINORDERTOTAL = ( | |
50 | + | let MINORDERTOTAL = (1 * WAVELET) | |
51 | 51 | ||
52 | 52 | let MAXROI = 100 | |
53 | 53 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getNumberByKey (key) = match getInteger(this, key) { | |
5 | 5 | case a: Int => | |
6 | 6 | a | |
7 | 7 | case _ => | |
8 | 8 | 0 | |
9 | 9 | } | |
10 | 10 | ||
11 | 11 | ||
12 | 12 | func getStringByKey (key) = match getString(this, key) { | |
13 | 13 | case a: String => | |
14 | 14 | a | |
15 | 15 | case _ => | |
16 | 16 | "" | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getBoolByAddressAndKey (address,key) = match getBoolean(address, key) { | |
21 | 21 | case a: Boolean => | |
22 | 22 | a | |
23 | 23 | case _ => | |
24 | 24 | false | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getStringByAddressAndKey (address,key) = match getString(address, key) { | |
29 | 29 | case a: String => | |
30 | 30 | a | |
31 | 31 | case _ => | |
32 | 32 | "" | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getNumberByAddressAndKey (address,key) = match getInteger(address, key) { | |
37 | 37 | case a: Int => | |
38 | 38 | a | |
39 | 39 | case _ => | |
40 | 40 | 0 | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | let WAVELET = 100000000 | |
45 | 45 | ||
46 | 46 | let PAULI = 1000000 | |
47 | 47 | ||
48 | 48 | let PERCENTACCURACY = 1000 | |
49 | 49 | ||
50 | - | let MINORDERTOTAL = ( | |
50 | + | let MINORDERTOTAL = (1 * WAVELET) | |
51 | 51 | ||
52 | 52 | let MAXROI = 100 | |
53 | 53 | ||
54 | 54 | let CANCELED = "canceled" | |
55 | 55 | ||
56 | 56 | let NEW = "new" | |
57 | 57 | ||
58 | 58 | let FILLED = "filled" | |
59 | 59 | ||
60 | 60 | let NeutrinoContractKey = "neutrino_contract" | |
61 | 61 | ||
62 | 62 | let PriceKey = "price" | |
63 | 63 | ||
64 | 64 | let BondAssetIdKey = "bond_asset_id" | |
65 | 65 | ||
66 | 66 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
67 | 67 | ||
68 | 68 | let ControlContractKey = "control_contract" | |
69 | 69 | ||
70 | 70 | let BalanceLockedkKey = "balance_lock_" | |
71 | 71 | ||
72 | 72 | let WavesLockedBalanceKey = (BalanceLockedkKey + "waves") | |
73 | 73 | ||
74 | 74 | let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino") | |
75 | 75 | ||
76 | 76 | let LiquidationContractKey = "liquidation_contract" | |
77 | 77 | ||
78 | 78 | let FirstOrderKey = "order_first" | |
79 | 79 | ||
80 | 80 | func getRoiByOrderIdKey (orderId) = ("debug_order_roi_" + orderId) | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | func getOrderPriceKey (orderId) = ("order_price_" + orderId) | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | func getOrderTotalKey (orderId) = ("order_total_" + orderId) | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | func getOrderOwnerKey (orderId) = ("order_owner_" + orderId) | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | func getOrderHeightKey (orderId) = ("order_height_" + orderId) | |
93 | 93 | ||
94 | 94 | ||
95 | 95 | func getOrderStatusKey (orderId) = ("order_status_" + orderId) | |
96 | 96 | ||
97 | 97 | ||
98 | 98 | func getOrderFilledTotalKey (orderId) = ("order_filled_total_" + orderId) | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | func getPrevOrderKey (orderId) = ("order_prev_" + orderId) | |
102 | 102 | ||
103 | 103 | ||
104 | 104 | func getNextOrderKey (orderId) = ("order_next_" + orderId) | |
105 | 105 | ||
106 | 106 | ||
107 | 107 | func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, 100, price), WAVELET, PAULI) | |
108 | 108 | ||
109 | 109 | ||
110 | 110 | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, 100), PAULI, WAVELET) | |
111 | 111 | ||
112 | 112 | ||
113 | 113 | func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price) | |
114 | 114 | ||
115 | 115 | ||
116 | 116 | func convertBondToWaves (amount,price) = convertNeutrinoToWaves(amount, price) | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | let neutrinoContract = addressFromStringValue("3MydqRdWHFcvU4ZogmgkGNHt8fqYiCRazbn") | |
120 | 120 | ||
121 | 121 | let controlContract = addressFromStringValue("3MqY3tM5bgwds1ugNQGJziL8VJVvjTiNccH") | |
122 | 122 | ||
123 | 123 | let liquidationContract = addressFromStringValue("3MyiJb9yZnpyXJADhdEoNk3MT3FHKmbYRJX") | |
124 | 124 | ||
125 | 125 | let neutrinoAssetId = fromBase58String("4EUBRLwFstXZhMHWJPk9ZnyhHT4VVFCSZb6p6K5hySjd") | |
126 | 126 | ||
127 | 127 | let bondAssetId = fromBase58String("Qh28HvUAcFboD1GsAcyURQjNW6mdpuGvXVgFS9e3CzC") | |
128 | 128 | ||
129 | 129 | let isBlocked = getBoolByAddressAndKey(controlContract, "is_blocked") | |
130 | 130 | ||
131 | 131 | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
132 | 132 | ||
133 | 133 | let neutrinoLockedBalance = getNumberByAddressAndKey(neutrinoContract, NeutrinoLockedBalanceKey) | |
134 | 134 | ||
135 | 135 | let reserve = (wavesBalance(neutrinoContract) - getNumberByAddressAndKey(neutrinoContract, WavesLockedBalanceKey)) | |
136 | 136 | ||
137 | 137 | let neutrinoSupply = (((neutrinoLockedBalance + extract(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(liquidationContract, neutrinoAssetId)) | |
138 | 138 | ||
139 | 139 | let deficit = (neutrinoSupply - convertWavesToNeutrino(reserve, currentPrice)) | |
140 | 140 | ||
141 | 141 | let firstOrder = getStringByKey(FirstOrderKey) | |
142 | 142 | ||
143 | 143 | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
147 | 147 | ||
148 | 148 | ||
149 | 149 | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | func getOrderStatus (id) = getStringByKey(getOrderStatusKey(id)) | |
153 | 153 | ||
154 | 154 | ||
155 | 155 | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
156 | 156 | ||
157 | 157 | ||
158 | 158 | func getPrevOrder (id) = getStringByKey(getPrevOrderKey(id)) | |
159 | 159 | ||
160 | 160 | ||
161 | 161 | func getNextOrder (id) = getStringByKey(getNextOrderKey(id)) | |
162 | 162 | ||
163 | 163 | ||
164 | 164 | @Callable(i) | |
165 | 165 | func addBuyBondOrder (price,prevOrder) = { | |
166 | 166 | let pmt = extract(i.payment) | |
167 | 167 | let orderId = toBase58String(keccak256(((((toBytes(price) + toBytes(pmt.amount)) + i.caller.bytes) + toBytes(height)) + i.transactionId))) | |
168 | 168 | let priceWavesByBondCents = fraction(100, 100, price) | |
169 | 169 | let roi = fraction((priceWavesByBondCents - currentPrice), 100, currentPrice) | |
170 | 170 | if (isBlocked) | |
171 | 171 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
172 | 172 | else if ((0 >= deficit)) | |
173 | 173 | then throw("there is no ability to add order during proficit") | |
174 | 174 | else if ((MINORDERTOTAL > pmt.amount)) | |
175 | 175 | then throw(("min order total equals " + toString(MINORDERTOTAL))) | |
176 | 176 | else if ((roi > MAXROI)) | |
177 | 177 | then throw("max setOrder ROI is 100%") | |
178 | 178 | else if ((0 >= roi)) | |
179 | 179 | then throw("min setOrder ROI is more than 0%") | |
180 | 180 | else if (isDefined(pmt.assetId)) | |
181 | 181 | then throw("can use waves only") | |
182 | 182 | else if ((0 >= price)) | |
183 | 183 | then throw("price less zero") | |
184 | 184 | else if ((getOrderOwner(orderId) != "")) | |
185 | 185 | then throw("order exists") | |
186 | 186 | else if (if ((prevOrder != "")) | |
187 | 187 | then (getOrderStatus(prevOrder) != NEW) | |
188 | 188 | else false) | |
189 | 189 | then throw("prev order status is not new") | |
190 | 190 | else { | |
191 | 191 | let owner = toString(i.caller) | |
192 | 192 | let nextOrder = if ((prevOrder == "")) | |
193 | 193 | then firstOrder | |
194 | 194 | else getNextOrder(prevOrder) | |
195 | 195 | let nextOrderRoi = getNumberByKey(getRoiByOrderIdKey(nextOrder)) | |
196 | 196 | let isNextOrderError = if (if ((nextOrder != "")) | |
197 | 197 | then (roi >= nextOrderRoi) | |
198 | 198 | else false) | |
199 | 199 | then true | |
200 | 200 | else false | |
201 | 201 | let prevOrderRoi = getNumberByKey(getRoiByOrderIdKey(prevOrder)) | |
202 | 202 | let isPrevOrderError = if (if ((prevOrder != "")) | |
203 | 203 | then (prevOrderRoi > roi) | |
204 | 204 | else false) | |
205 | 205 | then true | |
206 | 206 | else false | |
207 | 207 | if (if (isNextOrderError) | |
208 | 208 | then true | |
209 | 209 | else isPrevOrderError) | |
210 | 210 | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
211 | 211 | else WriteSet([DataEntry(getPrevOrderKey(orderId), prevOrder), DataEntry(getNextOrderKey(orderId), nextOrder), DataEntry(getNextOrderKey(prevOrder), if ((prevOrder == "")) | |
212 | 212 | then "" | |
213 | 213 | else orderId), DataEntry(getPrevOrderKey(nextOrder), if ((nextOrder == "")) | |
214 | 214 | then "" | |
215 | 215 | else orderId), DataEntry(FirstOrderKey, if (if ((firstOrder == "")) | |
216 | 216 | then true | |
217 | 217 | else (firstOrder == nextOrder)) | |
218 | 218 | then orderId | |
219 | 219 | else firstOrder), DataEntry(getOrderPriceKey(orderId), price), DataEntry(getOrderTotalKey(orderId), pmt.amount), DataEntry(getOrderOwnerKey(orderId), owner), DataEntry(getOrderHeightKey(orderId), height), DataEntry(getOrderStatusKey(orderId), NEW), DataEntry(("debug_order_currentPrice_" + orderId), currentPrice), DataEntry(getRoiByOrderIdKey(orderId), roi)]) | |
220 | 220 | } | |
221 | 221 | } | |
222 | 222 | ||
223 | 223 | ||
224 | 224 | ||
225 | 225 | @Callable(i) | |
226 | 226 | func cancelOrder (orderId) = { | |
227 | 227 | let owner = getOrderOwner(orderId) | |
228 | 228 | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
229 | 229 | let caller = toString(i.caller) | |
230 | 230 | let nextOrder = getNextOrder(orderId) | |
231 | 231 | let prevOrder = getPrevOrder(orderId) | |
232 | 232 | if (isBlocked) | |
233 | 233 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
234 | 234 | else if ((owner != caller)) | |
235 | 235 | then throw("permission denied") | |
236 | 236 | else if ((getOrderStatus(orderId) != NEW)) | |
237 | 237 | then throw("invalid order status") | |
238 | 238 | else ScriptResult(WriteSet([DataEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
239 | 239 | then nextOrder | |
240 | 240 | else firstOrder), DataEntry(getNextOrderKey(prevOrder), nextOrder), DataEntry(getPrevOrderKey(nextOrder), prevOrder), DataEntry(getOrderStatusKey(orderId), CANCELED)]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
241 | 241 | } | |
242 | 242 | ||
243 | 243 | ||
244 | 244 | ||
245 | 245 | @Callable(i) | |
246 | 246 | func sellBond () = { | |
247 | 247 | let bondBalance = assetBalance(this, bondAssetId) | |
248 | 248 | let deficitPositive = if ((0 >= deficit)) | |
249 | 249 | then 0 | |
250 | 250 | else deficit | |
251 | 251 | let bondAmount = if ((deficitPositive >= bondBalance)) | |
252 | 252 | then bondBalance | |
253 | 253 | else deficitPositive | |
254 | 254 | let returnAmount = if ((deficitPositive >= bondBalance)) | |
255 | 255 | then 0 | |
256 | 256 | else (bondBalance - deficitPositive) | |
257 | 257 | if (if ((deficitPositive == 0)) | |
258 | 258 | then (bondBalance == 0) | |
259 | 259 | else false) | |
260 | 260 | then throw("without deficit") | |
261 | 261 | else if ((bondBalance == 0)) | |
262 | 262 | then throw("without bonds to sell") | |
263 | 263 | else if ((returnAmount > 0)) | |
264 | 264 | then TransferSet([ScriptTransfer(neutrinoContract, returnAmount, bondAssetId)]) | |
265 | 265 | else if ((firstOrder == "")) | |
266 | 266 | then throw("empty orderbook") | |
267 | 267 | else { | |
268 | 268 | let nextOrder = getNextOrder(firstOrder) | |
269 | 269 | let filledTotal = getOrderFilledTotal(firstOrder) | |
270 | 270 | let orderPrice = getOrderPrice(firstOrder) | |
271 | 271 | let priceWavesByBondCents = fraction(100, 100, orderPrice) | |
272 | 272 | let roi = getNumberByKey(getRoiByOrderIdKey(firstOrder)) | |
273 | 273 | let remainedTotal = (getOrderTotal(firstOrder) - filledTotal) | |
274 | 274 | let amountToExecuteOrder = convertWavesToBond(remainedTotal, priceWavesByBondCents) | |
275 | 275 | let fillOrderCondition = (bondAmount >= amountToExecuteOrder) | |
276 | 276 | let fillableOrderAmount = if (fillOrderCondition) | |
277 | 277 | then amountToExecuteOrder | |
278 | 278 | else bondAmount | |
279 | 279 | let totalOrderWaveletesRequired = convertBondToWaves(fillableOrderAmount, priceWavesByBondCents) | |
280 | 280 | if (if ((roi > fraction(deficit, 100, neutrinoSupply))) | |
281 | 281 | then true | |
282 | 282 | else (0 >= deficitPositive)) | |
283 | 283 | then throw(("deficit should be higther or equal than roi: " + toString(roi))) | |
284 | 284 | else if ((amountToExecuteOrder == 0)) | |
285 | 285 | then ScriptResult(WriteSet([DataEntry(FirstOrderKey, nextOrder), DataEntry(getPrevOrderKey(nextOrder), ""), DataEntry(FirstOrderKey, nextOrder), DataEntry(getOrderStatusKey(firstOrder), FILLED)]), TransferSet([ScriptTransfer(addressFromStringValue(getOrderOwner(firstOrder)), remainedTotal, unit)])) | |
286 | 286 | else if ((totalOrderWaveletesRequired == 0)) | |
287 | 287 | then throw("cannot fill order at the moment") | |
288 | 288 | else { | |
289 | 289 | let newStatus = if (if (fillOrderCondition) | |
290 | 290 | then (remainedTotal == 0) | |
291 | 291 | else false) | |
292 | 292 | then FILLED | |
293 | 293 | else NEW | |
294 | 294 | ScriptResult(WriteSet([DataEntry(getPrevOrderKey(nextOrder), if ((newStatus == FILLED)) | |
295 | 295 | then "" | |
296 | 296 | else firstOrder), DataEntry(FirstOrderKey, if ((newStatus == FILLED)) | |
297 | 297 | then nextOrder | |
298 | 298 | else firstOrder), DataEntry(getOrderFilledTotalKey(firstOrder), (filledTotal + totalOrderWaveletesRequired)), DataEntry(getOrderStatusKey(firstOrder), newStatus)]), TransferSet([ScriptTransfer(addressFromStringValue(getOrderOwner(firstOrder)), fillableOrderAmount, bondAssetId), ScriptTransfer(neutrinoContract, totalOrderWaveletesRequired, unit)])) | |
299 | 299 | } | |
300 | 300 | } | |
301 | 301 | } | |
302 | 302 | ||
303 | 303 |
github/deemru/w8io/169f3d6 55.03 ms ◑