tx · 7ib7q42TFXW558nKYQh6sBRzhboEFcXwPij2wocAhD61 3MxbR7b3gHF4XdQKNTT5aQMRiazHvrVWC8N: -0.02000000 Waves 2021.01.22 19:16 [1364903] smart account 3MxbR7b3gHF4XdQKNTT5aQMRiazHvrVWC8N > SELF 0.00000000 Waves
{ "type": 13, "id": "7ib7q42TFXW558nKYQh6sBRzhboEFcXwPij2wocAhD61", "fee": 2000000, "feeAssetId": null, "timestamp": 1611332173954, "version": 1, "sender": "3MxbR7b3gHF4XdQKNTT5aQMRiazHvrVWC8N", "senderPublicKey": "4bj7YXaphTC4Ldx7DqqMmrTjNshRtw1yNsej2XXZcAzS", "proofs": [ "37nsoknN6BqYbVdFTjQmDKrfmJifCswGWjMzNY9uY5sZSkxHAaRRdLqxLdhtEE63YVsHSo6gQMbr4HjjmMmywvYP", "2T2hmJfih59hX8jevUrxJHjDNL3ZT5ingZLhDqLTNM7QjYvEDYF1DjF2jv1sA6WK2aMTDW9chY7xd8LAqQ7nXSef", "5EznK9R5BtUspQwx3Vmco31Ti9u7qUcU2R3djEDoef6NeJz2Dqkm5UQmUPcmkG3MGGu11V4sCWv6maNsr8Yt3vDv" ], "script": "base64:AAIEAAAAAAAAAAkIAhIAEgMKAQgAAABKAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5CQEAAAALdmFsdWVPckVsc2UAAAACCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQAAAAAAAAAAAAEAAAAOZ2V0U3RyaW5nQnlLZXkAAAABAAAAA2tleQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkCAAAAAAEAAAAWZ2V0Qm9vbEJ5QWRkcmVzc0FuZEtleQAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQbAAAAAgUAAAAHYWRkcmVzcwUAAAADa2V5BwEAAAAYZ2V0U3RyaW5nQnlBZGRyZXNzQW5kS2V5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UJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAIJAAJZAAAAAQkAAZEAAAACBQAAABBwdWJLZXlBZG1pbnNMaXN0AAAAAAAAAAACAAAAAAAAAAABAAAAAAAAAAAAAwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAMJAAJZAAAAAQkAAZEAAAACBQAAABBwdWJLZXlBZG1pbnNMaXN0AAAAAAAAAAADAAAAAAAAAAACAAAAAAAAAAAACQAAZwAAAAIFAAAABWNvdW50AAAAAAAAAAAD2/UC0g==", "chainId": 84, "height": 1364903, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Er48URK6xZ8SZK2657Gw37FNVN1WN4Ptgk2up7Jk7HNa Next: none Diff:
Old | New | Differences | |
---|---|---|---|
40 | 40 | ||
41 | 41 | let PriceKey = "price" | |
42 | 42 | ||
43 | - | let | |
43 | + | let NsbtAssetIdKey = "bond_asset_id" | |
44 | 44 | ||
45 | 45 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
46 | 46 | ||
99 | 99 | ||
100 | 100 | let neutrinoAssetId = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
101 | 101 | ||
102 | - | let | |
102 | + | let nsbtAssetId = base58'BGhPYquXSK6UYjnPLEn94gFhetp4Jvf7toekEY4x1VDH' | |
103 | 103 | ||
104 | 104 | let isBlocked = getBoolByAddressAndKey(controlContract, "is_blocked") | |
105 | 105 | ||
121 | 121 | ||
122 | 122 | let firstOrder = getStringByKey(FirstOrderKey) | |
123 | 123 | ||
124 | - | let | |
124 | + | let nsbtSupplyMAX = value(assetInfo(nsbtAssetId)).quantity | |
125 | 125 | ||
126 | - | let nsbtMax = ((2850 * 1000) * PAULI) | |
127 | - | ||
128 | - | let nsbtCurrent = (((1850 * 1000) * PAULI) + issuedNsbt) | |
126 | + | let nsbtSupply = (nsbtSupplyMAX - assetBalance(this, nsbtAssetId)) | |
129 | 127 | ||
130 | 128 | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
131 | 129 | ||
158 | 156 | ||
159 | 157 | ||
160 | 158 | func orderData (orderId,totalWavelets,filledWavelets,owner,status,roi,price) = [IntegerEntry(getOrderPriceKey(orderId), price), IntegerEntry(getOrderTotalKey(orderId), totalWavelets), IntegerEntry(getOrderFilledTotalKey(orderId), filledWavelets), StringEntry(getOrderOwnerKey(orderId), owner), IntegerEntry(getOrderHeightKey(orderId), height), StringEntry(getOrderStatusKey(orderId), status), IntegerEntry(("debug_order_currentPrice_" + orderId), currentPrice), IntegerEntry(getRoiByOrderIdKey(orderId), roi)] | |
161 | - | ||
162 | - | ||
163 | - | func internalSellBond (pFirstOrder,pNextOrder,pFilledTotal,pRoi,pPrice,pPaymentWavelets,orderOwnerAddress,instantOrder) = { | |
164 | - | let priceWavesByBondCents = getPriceForRoi(pRoi) | |
165 | - | let remainedTotal = (pPaymentWavelets - pFilledTotal) | |
166 | - | let fillableOrderAmount = convertWavesToBond(remainedTotal, priceWavesByBondCents) | |
167 | - | let totalOrderWaveletesRequired = convertBondToWaves(fillableOrderAmount, priceWavesByBondCents) | |
168 | - | let nbTokensSellCondition = (currentMaxRoi >= pRoi) | |
169 | - | if (!(nbTokensSellCondition)) | |
170 | - | then throw(("innapropriate roi: " + toString(pRoi))) | |
171 | - | else if ((totalOrderWaveletesRequired == 0)) | |
172 | - | then throw("cannot fill order at the moment") | |
173 | - | else { | |
174 | - | let changeWavelets = (remainedTotal - totalOrderWaveletesRequired) | |
175 | - | let writeSetData = if (instantOrder) | |
176 | - | then orderData(pFirstOrder, pPaymentWavelets, (pFilledTotal + totalOrderWaveletesRequired), toBase58String(orderOwnerAddress.bytes), FILLED, pRoi, currentPrice) | |
177 | - | else [IntegerEntry(getOrderFilledTotalKey(pFirstOrder), (pFilledTotal + totalOrderWaveletesRequired)), StringEntry(getOrderStatusKey(pFirstOrder), FILLED), StringEntry(getPrevOrderKey(pNextOrder), ""), StringEntry(FirstOrderKey, pNextOrder)] | |
178 | - | (writeSetData ++ [ScriptTransfer(orderOwnerAddress, fillableOrderAmount, bondAssetId), ScriptTransfer(neutrinoContract, totalOrderWaveletesRequired, unit), ScriptTransfer(orderOwnerAddress, changeWavelets, unit)]) | |
179 | - | } | |
180 | - | } | |
181 | - | ||
182 | - | ||
183 | - | func internalAddBuyBondOrder (roi,price,prevOrder,inv,instantOrder) = { | |
184 | - | let pmt = value(inv.payments[0]) | |
185 | - | let newOrderId = toBase58String(inv.transactionId) | |
186 | - | if (isBlocked) | |
187 | - | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
188 | - | else if ((MINORDERTOTAL > pmt.amount)) | |
189 | - | then throw(("min order total equals " + toString(MINORDERTOTAL))) | |
190 | - | else if ((roi > MAXROI)) | |
191 | - | then throw("max setOrder ROI is 95%") | |
192 | - | else if ((0 > roi)) | |
193 | - | then throw("can't place order with negative roi") | |
194 | - | else if ((roi == 0)) | |
195 | - | then throw("roi should not be equal to 0") | |
196 | - | else if (isDefined(pmt.assetId)) | |
197 | - | then throw("can use waves only") | |
198 | - | else if ((getOrderOwner(newOrderId) != "")) | |
199 | - | then throw("order exists") | |
200 | - | else if (if ((prevOrder != "")) | |
201 | - | then (getOrderStatus(prevOrder) != NEW) | |
202 | - | else false) | |
203 | - | then throw("prev order status is not new") | |
204 | - | else { | |
205 | - | let isNewOrderAtFirstPosition = (prevOrder == "") | |
206 | - | let owner = toString(inv.caller) | |
207 | - | let nextOrder = if (isNewOrderAtFirstPosition) | |
208 | - | then firstOrder | |
209 | - | else getNextOrder(prevOrder) | |
210 | - | let nextOrderRoi = getNumberByKey(getRoiByOrderIdKey(nextOrder)) | |
211 | - | let isNextOrderError = if (if ((nextOrder != "")) | |
212 | - | then (roi >= nextOrderRoi) | |
213 | - | else false) | |
214 | - | then true | |
215 | - | else false | |
216 | - | let prevOrderRoi = getNumberByKey(getRoiByOrderIdKey(prevOrder)) | |
217 | - | let isPrevOrderError = if (if ((prevOrder != "")) | |
218 | - | then (prevOrderRoi > roi) | |
219 | - | else false) | |
220 | - | then true | |
221 | - | else false | |
222 | - | if (if (isNextOrderError) | |
223 | - | then true | |
224 | - | else isPrevOrderError) | |
225 | - | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
226 | - | else if (if (isNewOrderAtFirstPosition) | |
227 | - | then (currentMaxRoi >= roi) | |
228 | - | else false) | |
229 | - | then internalSellBond(newOrderId, nextOrder, 0, roi, price, pmt.amount, inv.caller, true) | |
230 | - | else if (instantOrder) | |
231 | - | then throw("Instant order couldn't be added into waiting queue") | |
232 | - | else ([StringEntry(getPrevOrderKey(newOrderId), prevOrder), StringEntry(getNextOrderKey(newOrderId), nextOrder), StringEntry(getNextOrderKey(prevOrder), if ((prevOrder == "")) | |
233 | - | then "" | |
234 | - | else newOrderId), StringEntry(getPrevOrderKey(nextOrder), if ((nextOrder == "")) | |
235 | - | then "" | |
236 | - | else newOrderId), StringEntry(FirstOrderKey, if (if ((firstOrder == "")) | |
237 | - | then true | |
238 | - | else (firstOrder == nextOrder)) | |
239 | - | then newOrderId | |
240 | - | else firstOrder)] ++ orderData(newOrderId, pmt.amount, 0, owner, NEW, roi, price)) | |
241 | - | } | |
242 | - | } | |
243 | 159 | ||
244 | 160 | ||
245 | 161 | let IdxA = 0 | |
286 | 202 | func toStr (name,curveResult) = (((((((((((((((((((((((((((((((((((((((name + "[nsbtAmountRaw=") + toString(curveResult[0])) + " usdnPayment=") + toString(curveResult[1])) + " wRaw=") + toString(curveResult[2])) + " uRaw=") + toString(curveResult[3])) + " mRaw=") + toString(curveResult[4])) + " sRaw=") + toString(curveResult[5])) + " nsbtCurveParam_a=") + toString(curveResult[6])) + " nsbtCurveParam_b=") + toString(curveResult[7])) + " wReservesInUsdn=") + toString(curveResult[8])) + " price=") + toString(curveResult[9])) + " multBR=") + toString(curveResult[10])) + " multPower=") + toString(curveResult[11])) + " multExpInPower=") + toString(curveResult[12])) + " multK=") + toString(curveResult[13])) + " multStepM1=") + toString(curveResult[14])) + " multStep2=") + toString(curveResult[15])) + " multStepM3=") + toString(curveResult[16])) + " multStep4=") + toString(curveResult[17])) + " stepM5=") + toString(curveResult[18])) + "]") | |
287 | 203 | ||
288 | 204 | ||
289 | - | func bigComplexity (i) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (!(isDefined(transferTransactionById(fromBase58String("PdLw5JK5ppfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k"))))) | |
290 | - | then !(isDefined(transferTransactionById(fromBase58String("adLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
291 | - | else false) | |
292 | - | then !(isDefined(transferTransactionById(fromBase58String("sdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
293 | - | else false) | |
294 | - | then !(isDefined(transferTransactionById(fromBase58String("ddLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
295 | - | else false) | |
296 | - | then !(isDefined(transferTransactionById(fromBase58String("fdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
297 | - | else false) | |
298 | - | then !(isDefined(transferTransactionById(fromBase58String("gdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
299 | - | else false) | |
300 | - | then !(isDefined(transferTransactionById(fromBase58String("hdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
301 | - | else false) | |
302 | - | then !(isDefined(transferTransactionById(fromBase58String("jdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
303 | - | else false) | |
304 | - | then !(isDefined(transferTransactionById(fromBase58String("kdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
305 | - | else false) | |
306 | - | then !(isDefined(transferTransactionById(fromBase58String("rdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
307 | - | else false) | |
308 | - | then !(isDefined(transferTransactionById(fromBase58String("tdLq5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
309 | - | else false) | |
310 | - | then !(isDefined(transferTransactionById(fromBase58String("tdLy5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
311 | - | else false) | |
312 | - | then !(isDefined(transferTransactionById(fromBase58String("tdLu5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
313 | - | else false) | |
314 | - | then !(isDefined(transferTransactionById(fromBase58String("tdLh5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
315 | - | else false) | |
316 | - | then !(isDefined(transferTransactionById(fromBase58String("1dL4JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
317 | - | else false) | |
318 | - | then !(isDefined(transferTransactionById(fromBase58String("2dL25JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
319 | - | else false) | |
320 | - | then !(isDefined(transferTransactionById(fromBase58String("3dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
321 | - | else false) | |
322 | - | then !(isDefined(transferTransactionById(fromBase58String("4dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
323 | - | else false) | |
324 | - | then !(isDefined(transferTransactionById(fromBase58String("5dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
325 | - | else false) | |
326 | - | then !(isDefined(transferTransactionById(fromBase58String("6dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
327 | - | else false) | |
328 | - | then !(isDefined(transferTransactionById(fromBase58String("7dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
329 | - | else false) | |
330 | - | then !(isDefined(transferTransactionById(fromBase58String("8dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
331 | - | else false) | |
332 | - | then !(isDefined(transferTransactionById(fromBase58String("91L95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
333 | - | else false) | |
334 | - | then !(isDefined(transferTransactionById(fromBase58String("92L95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
335 | - | else false) | |
336 | - | then !(isDefined(transferTransactionById(fromBase58String("93L95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
337 | - | else false) | |
338 | - | then !(isDefined(transferTransactionById(fromBase58String("94L95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
339 | - | else false | |
340 | - | ||
341 | - | ||
342 | - | func privateNsbtPriceREST () = { | |
343 | - | let kCalcArray = calculateK(reserve, neutrinoSupply, currentPrice, nsbtMax, nsbtCurrent) | |
344 | - | let multK = kCalcArray[IdxMultK] | |
345 | - | let multStep1 = fraction(nsbtMax, MULT, (nsbtMax - nsbtCurrent)) | |
346 | - | let multStep2 = fraction(multStep1, multStep1, MULT) | |
347 | - | let multNsbt2usdnPrice = fraction(multK, multStep2, MULT) | |
348 | - | let nsbt2usdnPrice = fraction(multNsbt2usdnPrice, PAULI, MULT) | |
349 | - | let nsbt2wavesPrice = fraction(nsbt2usdnPrice, PAULI, currentPrice) | |
350 | - | $Tuple2(IntegerEntry("nsbt2usdnPrice", nsbt2usdnPrice), IntegerEntry("nsbt2wavesPrice", nsbt2wavesPrice)) | |
351 | - | } | |
352 | - | ||
353 | - | ||
354 | - | @Callable(i) | |
355 | - | func nsbtPriceREST () = { | |
356 | - | let nsbtPriceTuple = privateNsbtPriceREST() | |
357 | - | let nsbt2usdnPrice = nsbtPriceTuple._1.value | |
358 | - | let nsbt2wavesPrice = nsbtPriceTuple._2.value | |
359 | - | let restData = makeString(["startNsbtPriceREST", toString(nsbt2usdnPrice), toString(nsbt2wavesPrice), "endNsbtPriceREST"], "__") | |
360 | - | throw(restData) | |
361 | - | } | |
362 | - | ||
363 | - | ||
364 | - | ||
365 | 205 | @Callable(i) | |
366 | 206 | func buyNsbt () = { | |
367 | 207 | let pmt = value(i.payments[0]) | |
375 | 215 | else if (((10 * WAVELET) > pmtAmount)) | |
376 | 216 | then throw("min 10 waves expected") | |
377 | 217 | else { | |
378 | - | let curveResult = curveFunction(reserve, neutrinoSupply, currentPrice, | |
218 | + | let curveResult = curveFunction(reserve, neutrinoSupply, currentPrice, nsbtSupplyMAX, nsbtSupply, wavesPay) | |
379 | 219 | let nsbtAmount = curveResult[0] | |
380 | - | let nsbt2WavesPriceRaw = calcNsbt2WavesPriceRaw(wavesPay, nsbtAmount) | |
381 | - | let roi = (fraction(getReversePrice(nsbt2WavesPriceRaw), 100, currentPrice) - 100) | |
382 | - | (orderData(toBase58String(i.transactionId), pmtAmount, pmtAmount, toString(ownerAddress), FILLED, roi, nsbt2WavesPriceRaw) ++ [ScriptTransfer(ownerAddress, nsbtAmount, bondAssetId), ScriptTransfer(neutrinoContract, wavesPay, unit), StringEntry("debug_curveResult", toStr("curveResult", curveResult)), IntegerEntry("tmp_issuedNsbt_2", (issuedNsbt + nsbtAmount))]) | |
220 | + | if ((0 >= nsbtAmount)) | |
221 | + | then throw("nsbtAmount <= 0") | |
222 | + | else { | |
223 | + | let nsbt2WavesPriceRaw = calcNsbt2WavesPriceRaw(wavesPay, nsbtAmount) | |
224 | + | let roi = 0 | |
225 | + | (orderData(toBase58String(i.transactionId), pmtAmount, pmtAmount, toString(ownerAddress), FILLED, roi, nsbt2WavesPriceRaw) ++ [ScriptTransfer(ownerAddress, nsbtAmount, nsbtAssetId), ScriptTransfer(neutrinoContract, wavesPay, unit), StringEntry("debug_curveResult", toStr("curveResult", curveResult))]) | |
226 | + | } | |
383 | 227 | } | |
384 | - | } | |
385 | - | ||
386 | - | ||
387 | - | ||
388 | - | @Callable(i) | |
389 | - | func instantBuyNsbtOrFail (noLessThenRoi) = { | |
390 | - | let pmt = value(i.payments[0]) | |
391 | - | let roi = currentMaxRoi | |
392 | - | if ((noLessThenRoi > roi)) | |
393 | - | then throw(((("Current maxRoi=" + toString(roi)) + " is less then passed parameter noLessThenRoi=") + toString(noLessThenRoi))) | |
394 | - | else { | |
395 | - | let priceWavesByBondCents = getPriceForRoi(roi) | |
396 | - | internalAddBuyBondOrder(roi, getReversePrice(priceWavesByBondCents), "", i, true) | |
397 | - | } | |
398 | - | } | |
399 | - | ||
400 | - | ||
401 | - | ||
402 | - | @Callable(i) | |
403 | - | func addBuyBondOrder (price,prevOrder) = { | |
404 | - | let pmt = value(i.payments[0]) | |
405 | - | let priceWavesByBondCents = getReversePrice(price) | |
406 | - | if ((0 >= price)) | |
407 | - | then throw("price less zero") | |
408 | - | else internalAddBuyBondOrder(fraction((priceWavesByBondCents - currentPrice), 100, currentPrice), price, prevOrder, i, false) | |
409 | 228 | } | |
410 | 229 | ||
411 | 230 | ||
417 | 236 | let caller = toString(i.caller) | |
418 | 237 | let nextOrder = getNextOrder(orderId) | |
419 | 238 | let prevOrder = getPrevOrder(orderId) | |
420 | - | if (isBlocked) | |
421 | - | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
422 | - | else if ((owner != caller)) | |
423 | - | then throw("permission denied") | |
424 | - | else if ((getOrderStatus(orderId) != NEW)) | |
425 | - | then throw("invalid order status") | |
426 | - | else [StringEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
427 | - | then nextOrder | |
428 | - | else firstOrder), StringEntry(getNextOrderKey(prevOrder), nextOrder), StringEntry(getPrevOrderKey(nextOrder), prevOrder), StringEntry(getOrderStatusKey(orderId), CANCELED), ScriptTransfer(i.caller, amount, unit)] | |
239 | + | if ((getOrderStatus(orderId) != NEW)) | |
240 | + | then throw("invalid order status") | |
241 | + | else [StringEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
242 | + | then nextOrder | |
243 | + | else firstOrder), StringEntry(getNextOrderKey(prevOrder), nextOrder), StringEntry(getPrevOrderKey(nextOrder), prevOrder), StringEntry(getOrderStatusKey(orderId), CANCELED), ScriptTransfer(i.caller, amount, unit)] | |
429 | 244 | } | |
430 | - | ||
431 | - | ||
432 | - | ||
433 | - | @Callable(i) | |
434 | - | func sellBond () = if (isBlocked) | |
435 | - | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
436 | - | else if ((firstOrder == "")) | |
437 | - | then throw("empty orderbook") | |
438 | - | else { | |
439 | - | let nextOrder = getNextOrder(firstOrder) | |
440 | - | let filledTotal = getOrderFilledTotal(firstOrder) | |
441 | - | let orderPrice = getOrderPrice(firstOrder) | |
442 | - | let roi = getNumberByKey(getRoiByOrderIdKey(firstOrder)) | |
443 | - | let paymentWavelets = getOrderTotal(firstOrder) | |
444 | - | let orderOwnerAddress = Address(fromBase58String(getOrderOwner(firstOrder))) | |
445 | - | internalSellBond(firstOrder, nextOrder, filledTotal, roi, orderPrice, paymentWavelets, orderOwnerAddress, false) | |
446 | - | } | |
447 | 245 | ||
448 | 246 | ||
449 | 247 | @Verifier(tx) | |
450 | 248 | func verify () = { | |
451 | - | let pubKeyAdminsList = [" | |
249 | + | let pubKeyAdminsList = ["GJdLSaLiv5K7xuejac8mcRcHoyo3dPrESrvktG3a6MAR", "3xumx4hrPpeeoo79HLGbZCgfz95L39ZFdxxwWeSUC2Pu", "D4CqtK5fBsnzRo33ZMhrM7niLseDH2uRoK6weBq2JQ3A", "5WRXFSjwcTbNfKcJs8ZqXmSSWYsSVJUtMvMqZj5hH4Nc"] | |
452 | 250 | let count = ((((if (sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(pubKeyAdminsList[0]))) | |
453 | 251 | then 1 | |
454 | 252 | else 0) + (if (sigVerify(tx.bodyBytes, tx.proofs[1], fromBase58String(pubKeyAdminsList[1]))) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func getBoolByAddressAndKey (address,key) = valueOrElse(getBoolean(address, key), false) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func getStringByAddressAndKey (address,key) = valueOrElse(getString(address, key), "") | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(address, key), 0) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | let WAVELET = 100000000 | |
20 | 20 | ||
21 | 21 | let PAULI = 1000000 | |
22 | 22 | ||
23 | 23 | let PAULISCALE = 6 | |
24 | 24 | ||
25 | 25 | let PRICELET = 1000000 | |
26 | 26 | ||
27 | 27 | let MULT = 100000000 | |
28 | 28 | ||
29 | 29 | let MULTSCALE = 8 | |
30 | 30 | ||
31 | 31 | let MINORDERTOTAL = (10 * WAVELET) | |
32 | 32 | ||
33 | 33 | let MAXROI = 95 | |
34 | 34 | ||
35 | 35 | let CANCELED = "canceled" | |
36 | 36 | ||
37 | 37 | let NEW = "new" | |
38 | 38 | ||
39 | 39 | let FILLED = "filled" | |
40 | 40 | ||
41 | 41 | let PriceKey = "price" | |
42 | 42 | ||
43 | - | let | |
43 | + | let NsbtAssetIdKey = "bond_asset_id" | |
44 | 44 | ||
45 | 45 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
46 | 46 | ||
47 | 47 | let BalanceLockedkKey = "balance_lock_" | |
48 | 48 | ||
49 | 49 | let WavesLockedBalanceKey = (BalanceLockedkKey + "waves") | |
50 | 50 | ||
51 | 51 | let NeutrinoLockedBalanceKey = (BalanceLockedkKey + "neutrino") | |
52 | 52 | ||
53 | 53 | let FirstOrderKey = "order_first" | |
54 | 54 | ||
55 | 55 | func getRoiByOrderIdKey (orderId) = ("debug_order_roi_" + orderId) | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func getOrderPriceKey (orderId) = ("order_price_" + orderId) | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func getOrderTotalKey (orderId) = ("order_total_" + orderId) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func getOrderOwnerKey (orderId) = ("order_owner_" + orderId) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func getOrderHeightKey (orderId) = ("order_height_" + orderId) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func getOrderStatusKey (orderId) = ("order_status_" + orderId) | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func getOrderFilledTotalKey (orderId) = ("order_filled_total_" + orderId) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func getPrevOrderKey (orderId) = ("order_prev_" + orderId) | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | func getNextOrderKey (orderId) = ("order_next_" + orderId) | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, PRICELET, price), WAVELET, PAULI) | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, PRICELET), PAULI, WAVELET) | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price) | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | func convertBondToWaves (amount,price) = convertNeutrinoToWaves(amount, price) | |
92 | 92 | ||
93 | 93 | ||
94 | 94 | let neutrinoContract = Address(base58'3Mzbx34Ex5rRbn39vUHx9kiwh3nneF8S5we') | |
95 | 95 | ||
96 | 96 | let controlContract = Address(base58'3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx') | |
97 | 97 | ||
98 | 98 | let liquidationContract = Address(base58'3N5nmMvMH8o3RPEyCKCaoWahBTYTexnZy62') | |
99 | 99 | ||
100 | 100 | let neutrinoAssetId = base58'25FEqEjRkqK6yCkiT7Lz6SAYz7gUFCtxfCChnrVFD5AT' | |
101 | 101 | ||
102 | - | let | |
102 | + | let nsbtAssetId = base58'BGhPYquXSK6UYjnPLEn94gFhetp4Jvf7toekEY4x1VDH' | |
103 | 103 | ||
104 | 104 | let isBlocked = getBoolByAddressAndKey(controlContract, "is_blocked") | |
105 | 105 | ||
106 | 106 | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
107 | 107 | ||
108 | 108 | let neutrinoLockedBalance = getNumberByAddressAndKey(neutrinoContract, NeutrinoLockedBalanceKey) | |
109 | 109 | ||
110 | 110 | let reserve = (wavesBalance(neutrinoContract).regular - getNumberByAddressAndKey(neutrinoContract, WavesLockedBalanceKey)) | |
111 | 111 | ||
112 | 112 | let reservesInUsdn = convertWavesToNeutrino(reserve, currentPrice) | |
113 | 113 | ||
114 | 114 | let neutrinoSupply = (((neutrinoLockedBalance + value(assetInfo(neutrinoAssetId)).quantity) - assetBalance(neutrinoContract, neutrinoAssetId)) - assetBalance(liquidationContract, neutrinoAssetId)) | |
115 | 115 | ||
116 | 116 | let deficit = (neutrinoSupply - reservesInUsdn) | |
117 | 117 | ||
118 | 118 | let currentMaxRoi = fraction(deficit, 100, neutrinoSupply) | |
119 | 119 | ||
120 | 120 | let currentBrMult = fraction(reservesInUsdn, MULT, neutrinoSupply) | |
121 | 121 | ||
122 | 122 | let firstOrder = getStringByKey(FirstOrderKey) | |
123 | 123 | ||
124 | - | let | |
124 | + | let nsbtSupplyMAX = value(assetInfo(nsbtAssetId)).quantity | |
125 | 125 | ||
126 | - | let nsbtMax = ((2850 * 1000) * PAULI) | |
127 | - | ||
128 | - | let nsbtCurrent = (((1850 * 1000) * PAULI) + issuedNsbt) | |
126 | + | let nsbtSupply = (nsbtSupplyMAX - assetBalance(this, nsbtAssetId)) | |
129 | 127 | ||
130 | 128 | func getOrderPrice (id) = getNumberByKey(getOrderPriceKey(id)) | |
131 | 129 | ||
132 | 130 | ||
133 | 131 | func getOrderTotal (id) = getNumberByKey(getOrderTotalKey(id)) | |
134 | 132 | ||
135 | 133 | ||
136 | 134 | func getOrderOwner (id) = getStringByKey(getOrderOwnerKey(id)) | |
137 | 135 | ||
138 | 136 | ||
139 | 137 | func getOrderStatus (id) = getStringByKey(getOrderStatusKey(id)) | |
140 | 138 | ||
141 | 139 | ||
142 | 140 | func getOrderFilledTotal (id) = getNumberByKey(getOrderFilledTotalKey(id)) | |
143 | 141 | ||
144 | 142 | ||
145 | 143 | func getPrevOrder (id) = getStringByKey(getPrevOrderKey(id)) | |
146 | 144 | ||
147 | 145 | ||
148 | 146 | func getNextOrder (id) = getStringByKey(getNextOrderKey(id)) | |
149 | 147 | ||
150 | 148 | ||
151 | 149 | func getPriceForRoi (roiPercents) = fraction((100 + roiPercents), currentPrice, 100) | |
152 | 150 | ||
153 | 151 | ||
154 | 152 | func getReversePrice (price) = ((PRICELET * PRICELET) / price) | |
155 | 153 | ||
156 | 154 | ||
157 | 155 | func calcNsbt2WavesPriceRaw (spentWavesRaw,receivedNsbtRaw) = fraction(spentWavesRaw, (PAULI * PRICELET), receivedNsbtRaw) | |
158 | 156 | ||
159 | 157 | ||
160 | 158 | func orderData (orderId,totalWavelets,filledWavelets,owner,status,roi,price) = [IntegerEntry(getOrderPriceKey(orderId), price), IntegerEntry(getOrderTotalKey(orderId), totalWavelets), IntegerEntry(getOrderFilledTotalKey(orderId), filledWavelets), StringEntry(getOrderOwnerKey(orderId), owner), IntegerEntry(getOrderHeightKey(orderId), height), StringEntry(getOrderStatusKey(orderId), status), IntegerEntry(("debug_order_currentPrice_" + orderId), currentPrice), IntegerEntry(getRoiByOrderIdKey(orderId), roi)] | |
161 | - | ||
162 | - | ||
163 | - | func internalSellBond (pFirstOrder,pNextOrder,pFilledTotal,pRoi,pPrice,pPaymentWavelets,orderOwnerAddress,instantOrder) = { | |
164 | - | let priceWavesByBondCents = getPriceForRoi(pRoi) | |
165 | - | let remainedTotal = (pPaymentWavelets - pFilledTotal) | |
166 | - | let fillableOrderAmount = convertWavesToBond(remainedTotal, priceWavesByBondCents) | |
167 | - | let totalOrderWaveletesRequired = convertBondToWaves(fillableOrderAmount, priceWavesByBondCents) | |
168 | - | let nbTokensSellCondition = (currentMaxRoi >= pRoi) | |
169 | - | if (!(nbTokensSellCondition)) | |
170 | - | then throw(("innapropriate roi: " + toString(pRoi))) | |
171 | - | else if ((totalOrderWaveletesRequired == 0)) | |
172 | - | then throw("cannot fill order at the moment") | |
173 | - | else { | |
174 | - | let changeWavelets = (remainedTotal - totalOrderWaveletesRequired) | |
175 | - | let writeSetData = if (instantOrder) | |
176 | - | then orderData(pFirstOrder, pPaymentWavelets, (pFilledTotal + totalOrderWaveletesRequired), toBase58String(orderOwnerAddress.bytes), FILLED, pRoi, currentPrice) | |
177 | - | else [IntegerEntry(getOrderFilledTotalKey(pFirstOrder), (pFilledTotal + totalOrderWaveletesRequired)), StringEntry(getOrderStatusKey(pFirstOrder), FILLED), StringEntry(getPrevOrderKey(pNextOrder), ""), StringEntry(FirstOrderKey, pNextOrder)] | |
178 | - | (writeSetData ++ [ScriptTransfer(orderOwnerAddress, fillableOrderAmount, bondAssetId), ScriptTransfer(neutrinoContract, totalOrderWaveletesRequired, unit), ScriptTransfer(orderOwnerAddress, changeWavelets, unit)]) | |
179 | - | } | |
180 | - | } | |
181 | - | ||
182 | - | ||
183 | - | func internalAddBuyBondOrder (roi,price,prevOrder,inv,instantOrder) = { | |
184 | - | let pmt = value(inv.payments[0]) | |
185 | - | let newOrderId = toBase58String(inv.transactionId) | |
186 | - | if (isBlocked) | |
187 | - | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
188 | - | else if ((MINORDERTOTAL > pmt.amount)) | |
189 | - | then throw(("min order total equals " + toString(MINORDERTOTAL))) | |
190 | - | else if ((roi > MAXROI)) | |
191 | - | then throw("max setOrder ROI is 95%") | |
192 | - | else if ((0 > roi)) | |
193 | - | then throw("can't place order with negative roi") | |
194 | - | else if ((roi == 0)) | |
195 | - | then throw("roi should not be equal to 0") | |
196 | - | else if (isDefined(pmt.assetId)) | |
197 | - | then throw("can use waves only") | |
198 | - | else if ((getOrderOwner(newOrderId) != "")) | |
199 | - | then throw("order exists") | |
200 | - | else if (if ((prevOrder != "")) | |
201 | - | then (getOrderStatus(prevOrder) != NEW) | |
202 | - | else false) | |
203 | - | then throw("prev order status is not new") | |
204 | - | else { | |
205 | - | let isNewOrderAtFirstPosition = (prevOrder == "") | |
206 | - | let owner = toString(inv.caller) | |
207 | - | let nextOrder = if (isNewOrderAtFirstPosition) | |
208 | - | then firstOrder | |
209 | - | else getNextOrder(prevOrder) | |
210 | - | let nextOrderRoi = getNumberByKey(getRoiByOrderIdKey(nextOrder)) | |
211 | - | let isNextOrderError = if (if ((nextOrder != "")) | |
212 | - | then (roi >= nextOrderRoi) | |
213 | - | else false) | |
214 | - | then true | |
215 | - | else false | |
216 | - | let prevOrderRoi = getNumberByKey(getRoiByOrderIdKey(prevOrder)) | |
217 | - | let isPrevOrderError = if (if ((prevOrder != "")) | |
218 | - | then (prevOrderRoi > roi) | |
219 | - | else false) | |
220 | - | then true | |
221 | - | else false | |
222 | - | if (if (isNextOrderError) | |
223 | - | then true | |
224 | - | else isPrevOrderError) | |
225 | - | then throw(((("invalid order isPrevOrderError:" + toString(isPrevOrderError)) + " isNextOrderError:") + toString(isNextOrderError))) | |
226 | - | else if (if (isNewOrderAtFirstPosition) | |
227 | - | then (currentMaxRoi >= roi) | |
228 | - | else false) | |
229 | - | then internalSellBond(newOrderId, nextOrder, 0, roi, price, pmt.amount, inv.caller, true) | |
230 | - | else if (instantOrder) | |
231 | - | then throw("Instant order couldn't be added into waiting queue") | |
232 | - | else ([StringEntry(getPrevOrderKey(newOrderId), prevOrder), StringEntry(getNextOrderKey(newOrderId), nextOrder), StringEntry(getNextOrderKey(prevOrder), if ((prevOrder == "")) | |
233 | - | then "" | |
234 | - | else newOrderId), StringEntry(getPrevOrderKey(nextOrder), if ((nextOrder == "")) | |
235 | - | then "" | |
236 | - | else newOrderId), StringEntry(FirstOrderKey, if (if ((firstOrder == "")) | |
237 | - | then true | |
238 | - | else (firstOrder == nextOrder)) | |
239 | - | then newOrderId | |
240 | - | else firstOrder)] ++ orderData(newOrderId, pmt.amount, 0, owner, NEW, roi, price)) | |
241 | - | } | |
242 | - | } | |
243 | 159 | ||
244 | 160 | ||
245 | 161 | let IdxA = 0 | |
246 | 162 | ||
247 | 163 | let IdxPaulB = 1 | |
248 | 164 | ||
249 | 165 | let IdxWResAsUsdn = 2 | |
250 | 166 | ||
251 | 167 | let IdxMultBR = 3 | |
252 | 168 | ||
253 | 169 | let IdxMultPower = 4 | |
254 | 170 | ||
255 | 171 | let IdxMultExpInPower = 5 | |
256 | 172 | ||
257 | 173 | let IdxMultK = 6 | |
258 | 174 | ||
259 | 175 | func calculateK (wRaw,uRaw,price,mRaw,sRaw) = { | |
260 | 176 | let EXP = 271828100 | |
261 | 177 | let a = valueOrElse(getInteger(this, "nsbtCurveParam_a"), 3) | |
262 | 178 | let paulB = valueOrElse(getInteger(this, "nsbtCurveParam_b"), ((3 * PAULI) / 10)) | |
263 | 179 | let wReservesInUsdn = convertWavesToNeutrino(wRaw, price) | |
264 | 180 | let multBR = fraction(wReservesInUsdn, MULT, uRaw) | |
265 | 181 | let multPower = (a * (multBR - (1 * MULT))) | |
266 | 182 | let multExpInPower = pow(EXP, MULTSCALE, multPower, MULTSCALE, MULTSCALE, DOWN) | |
267 | 183 | let multK = fraction(paulB, multExpInPower, PAULI) | |
268 | 184 | [a, paulB, wReservesInUsdn, multBR, multPower, multExpInPower, multK] | |
269 | 185 | } | |
270 | 186 | ||
271 | 187 | ||
272 | 188 | func curveFunction (wRaw,uRaw,price,mRaw,sRaw,wavesPayRaw) = { | |
273 | 189 | let kCalcArray = calculateK(wRaw, uRaw, price, mRaw, sRaw) | |
274 | 190 | let multK = kCalcArray[IdxMultK] | |
275 | 191 | let usdnPay = convertWavesToNeutrino(wavesPayRaw, price) | |
276 | 192 | let multStepM1 = fraction(multK, mRaw, PAULI) | |
277 | 193 | let multStep2 = fraction(multStepM1, PAULI, (mRaw - sRaw)) | |
278 | 194 | let multStepM3 = (fraction(usdnPay, MULT, PAULI) + fraction(multStep2, mRaw, PAULI)) | |
279 | 195 | let multStep4 = fraction(multStepM1, MULT, multStepM3) | |
280 | 196 | let stepM5 = fraction(multStep4, mRaw, MULT) | |
281 | 197 | let nsbtAmountRaw = ((mRaw - sRaw) - stepM5) | |
282 | 198 | [nsbtAmountRaw, usdnPay, wRaw, uRaw, mRaw, sRaw, kCalcArray[IdxA], kCalcArray[IdxPaulB], kCalcArray[IdxWResAsUsdn], price, kCalcArray[IdxMultBR], kCalcArray[IdxMultPower], kCalcArray[IdxMultExpInPower], multK, multStepM1, multStep2, multStepM3, multStep4, stepM5] | |
283 | 199 | } | |
284 | 200 | ||
285 | 201 | ||
286 | 202 | func toStr (name,curveResult) = (((((((((((((((((((((((((((((((((((((((name + "[nsbtAmountRaw=") + toString(curveResult[0])) + " usdnPayment=") + toString(curveResult[1])) + " wRaw=") + toString(curveResult[2])) + " uRaw=") + toString(curveResult[3])) + " mRaw=") + toString(curveResult[4])) + " sRaw=") + toString(curveResult[5])) + " nsbtCurveParam_a=") + toString(curveResult[6])) + " nsbtCurveParam_b=") + toString(curveResult[7])) + " wReservesInUsdn=") + toString(curveResult[8])) + " price=") + toString(curveResult[9])) + " multBR=") + toString(curveResult[10])) + " multPower=") + toString(curveResult[11])) + " multExpInPower=") + toString(curveResult[12])) + " multK=") + toString(curveResult[13])) + " multStepM1=") + toString(curveResult[14])) + " multStep2=") + toString(curveResult[15])) + " multStepM3=") + toString(curveResult[16])) + " multStep4=") + toString(curveResult[17])) + " stepM5=") + toString(curveResult[18])) + "]") | |
287 | 203 | ||
288 | 204 | ||
289 | - | func bigComplexity (i) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (!(isDefined(transferTransactionById(fromBase58String("PdLw5JK5ppfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k"))))) | |
290 | - | then !(isDefined(transferTransactionById(fromBase58String("adLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
291 | - | else false) | |
292 | - | then !(isDefined(transferTransactionById(fromBase58String("sdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
293 | - | else false) | |
294 | - | then !(isDefined(transferTransactionById(fromBase58String("ddLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
295 | - | else false) | |
296 | - | then !(isDefined(transferTransactionById(fromBase58String("fdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
297 | - | else false) | |
298 | - | then !(isDefined(transferTransactionById(fromBase58String("gdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
299 | - | else false) | |
300 | - | then !(isDefined(transferTransactionById(fromBase58String("hdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
301 | - | else false) | |
302 | - | then !(isDefined(transferTransactionById(fromBase58String("jdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
303 | - | else false) | |
304 | - | then !(isDefined(transferTransactionById(fromBase58String("kdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
305 | - | else false) | |
306 | - | then !(isDefined(transferTransactionById(fromBase58String("rdLw5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
307 | - | else false) | |
308 | - | then !(isDefined(transferTransactionById(fromBase58String("tdLq5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
309 | - | else false) | |
310 | - | then !(isDefined(transferTransactionById(fromBase58String("tdLy5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
311 | - | else false) | |
312 | - | then !(isDefined(transferTransactionById(fromBase58String("tdLu5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
313 | - | else false) | |
314 | - | then !(isDefined(transferTransactionById(fromBase58String("tdLh5JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
315 | - | else false) | |
316 | - | then !(isDefined(transferTransactionById(fromBase58String("1dL4JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
317 | - | else false) | |
318 | - | then !(isDefined(transferTransactionById(fromBase58String("2dL25JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
319 | - | else false) | |
320 | - | then !(isDefined(transferTransactionById(fromBase58String("3dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
321 | - | else false) | |
322 | - | then !(isDefined(transferTransactionById(fromBase58String("4dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
323 | - | else false) | |
324 | - | then !(isDefined(transferTransactionById(fromBase58String("5dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
325 | - | else false) | |
326 | - | then !(isDefined(transferTransactionById(fromBase58String("6dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
327 | - | else false) | |
328 | - | then !(isDefined(transferTransactionById(fromBase58String("7dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
329 | - | else false) | |
330 | - | then !(isDefined(transferTransactionById(fromBase58String("8dL95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
331 | - | else false) | |
332 | - | then !(isDefined(transferTransactionById(fromBase58String("91L95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
333 | - | else false) | |
334 | - | then !(isDefined(transferTransactionById(fromBase58String("92L95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
335 | - | else false) | |
336 | - | then !(isDefined(transferTransactionById(fromBase58String("93L95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
337 | - | else false) | |
338 | - | then !(isDefined(transferTransactionById(fromBase58String("94L95JKdpqfSEqvmFJvchejorAkzd4BrWLvoFwvMGu5k")))) | |
339 | - | else false | |
340 | - | ||
341 | - | ||
342 | - | func privateNsbtPriceREST () = { | |
343 | - | let kCalcArray = calculateK(reserve, neutrinoSupply, currentPrice, nsbtMax, nsbtCurrent) | |
344 | - | let multK = kCalcArray[IdxMultK] | |
345 | - | let multStep1 = fraction(nsbtMax, MULT, (nsbtMax - nsbtCurrent)) | |
346 | - | let multStep2 = fraction(multStep1, multStep1, MULT) | |
347 | - | let multNsbt2usdnPrice = fraction(multK, multStep2, MULT) | |
348 | - | let nsbt2usdnPrice = fraction(multNsbt2usdnPrice, PAULI, MULT) | |
349 | - | let nsbt2wavesPrice = fraction(nsbt2usdnPrice, PAULI, currentPrice) | |
350 | - | $Tuple2(IntegerEntry("nsbt2usdnPrice", nsbt2usdnPrice), IntegerEntry("nsbt2wavesPrice", nsbt2wavesPrice)) | |
351 | - | } | |
352 | - | ||
353 | - | ||
354 | - | @Callable(i) | |
355 | - | func nsbtPriceREST () = { | |
356 | - | let nsbtPriceTuple = privateNsbtPriceREST() | |
357 | - | let nsbt2usdnPrice = nsbtPriceTuple._1.value | |
358 | - | let nsbt2wavesPrice = nsbtPriceTuple._2.value | |
359 | - | let restData = makeString(["startNsbtPriceREST", toString(nsbt2usdnPrice), toString(nsbt2wavesPrice), "endNsbtPriceREST"], "__") | |
360 | - | throw(restData) | |
361 | - | } | |
362 | - | ||
363 | - | ||
364 | - | ||
365 | 205 | @Callable(i) | |
366 | 206 | func buyNsbt () = { | |
367 | 207 | let pmt = value(i.payments[0]) | |
368 | 208 | let pmtAmount = pmt.amount | |
369 | 209 | let wavesPay = pmtAmount | |
370 | 210 | let ownerAddress = i.caller | |
371 | 211 | if (isBlocked) | |
372 | 212 | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
373 | 213 | else if (isDefined(pmt.assetId)) | |
374 | 214 | then throw("can use waves only") | |
375 | 215 | else if (((10 * WAVELET) > pmtAmount)) | |
376 | 216 | then throw("min 10 waves expected") | |
377 | 217 | else { | |
378 | - | let curveResult = curveFunction(reserve, neutrinoSupply, currentPrice, | |
218 | + | let curveResult = curveFunction(reserve, neutrinoSupply, currentPrice, nsbtSupplyMAX, nsbtSupply, wavesPay) | |
379 | 219 | let nsbtAmount = curveResult[0] | |
380 | - | let nsbt2WavesPriceRaw = calcNsbt2WavesPriceRaw(wavesPay, nsbtAmount) | |
381 | - | let roi = (fraction(getReversePrice(nsbt2WavesPriceRaw), 100, currentPrice) - 100) | |
382 | - | (orderData(toBase58String(i.transactionId), pmtAmount, pmtAmount, toString(ownerAddress), FILLED, roi, nsbt2WavesPriceRaw) ++ [ScriptTransfer(ownerAddress, nsbtAmount, bondAssetId), ScriptTransfer(neutrinoContract, wavesPay, unit), StringEntry("debug_curveResult", toStr("curveResult", curveResult)), IntegerEntry("tmp_issuedNsbt_2", (issuedNsbt + nsbtAmount))]) | |
220 | + | if ((0 >= nsbtAmount)) | |
221 | + | then throw("nsbtAmount <= 0") | |
222 | + | else { | |
223 | + | let nsbt2WavesPriceRaw = calcNsbt2WavesPriceRaw(wavesPay, nsbtAmount) | |
224 | + | let roi = 0 | |
225 | + | (orderData(toBase58String(i.transactionId), pmtAmount, pmtAmount, toString(ownerAddress), FILLED, roi, nsbt2WavesPriceRaw) ++ [ScriptTransfer(ownerAddress, nsbtAmount, nsbtAssetId), ScriptTransfer(neutrinoContract, wavesPay, unit), StringEntry("debug_curveResult", toStr("curveResult", curveResult))]) | |
226 | + | } | |
383 | 227 | } | |
384 | - | } | |
385 | - | ||
386 | - | ||
387 | - | ||
388 | - | @Callable(i) | |
389 | - | func instantBuyNsbtOrFail (noLessThenRoi) = { | |
390 | - | let pmt = value(i.payments[0]) | |
391 | - | let roi = currentMaxRoi | |
392 | - | if ((noLessThenRoi > roi)) | |
393 | - | then throw(((("Current maxRoi=" + toString(roi)) + " is less then passed parameter noLessThenRoi=") + toString(noLessThenRoi))) | |
394 | - | else { | |
395 | - | let priceWavesByBondCents = getPriceForRoi(roi) | |
396 | - | internalAddBuyBondOrder(roi, getReversePrice(priceWavesByBondCents), "", i, true) | |
397 | - | } | |
398 | - | } | |
399 | - | ||
400 | - | ||
401 | - | ||
402 | - | @Callable(i) | |
403 | - | func addBuyBondOrder (price,prevOrder) = { | |
404 | - | let pmt = value(i.payments[0]) | |
405 | - | let priceWavesByBondCents = getReversePrice(price) | |
406 | - | if ((0 >= price)) | |
407 | - | then throw("price less zero") | |
408 | - | else internalAddBuyBondOrder(fraction((priceWavesByBondCents - currentPrice), 100, currentPrice), price, prevOrder, i, false) | |
409 | 228 | } | |
410 | 229 | ||
411 | 230 | ||
412 | 231 | ||
413 | 232 | @Callable(i) | |
414 | 233 | func cancelOrder (orderId) = { | |
415 | 234 | let owner = getOrderOwner(orderId) | |
416 | 235 | let amount = (getOrderTotal(orderId) - getOrderFilledTotal(orderId)) | |
417 | 236 | let caller = toString(i.caller) | |
418 | 237 | let nextOrder = getNextOrder(orderId) | |
419 | 238 | let prevOrder = getPrevOrder(orderId) | |
420 | - | if (isBlocked) | |
421 | - | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
422 | - | else if ((owner != caller)) | |
423 | - | then throw("permission denied") | |
424 | - | else if ((getOrderStatus(orderId) != NEW)) | |
425 | - | then throw("invalid order status") | |
426 | - | else [StringEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
427 | - | then nextOrder | |
428 | - | else firstOrder), StringEntry(getNextOrderKey(prevOrder), nextOrder), StringEntry(getPrevOrderKey(nextOrder), prevOrder), StringEntry(getOrderStatusKey(orderId), CANCELED), ScriptTransfer(i.caller, amount, unit)] | |
239 | + | if ((getOrderStatus(orderId) != NEW)) | |
240 | + | then throw("invalid order status") | |
241 | + | else [StringEntry(FirstOrderKey, if ((firstOrder == orderId)) | |
242 | + | then nextOrder | |
243 | + | else firstOrder), StringEntry(getNextOrderKey(prevOrder), nextOrder), StringEntry(getPrevOrderKey(nextOrder), prevOrder), StringEntry(getOrderStatusKey(orderId), CANCELED), ScriptTransfer(i.caller, amount, unit)] | |
429 | 244 | } | |
430 | - | ||
431 | - | ||
432 | - | ||
433 | - | @Callable(i) | |
434 | - | func sellBond () = if (isBlocked) | |
435 | - | then throw("contract is blocked by EMERGENCY SHUTDOWN actions until reactivation by emergency oracles") | |
436 | - | else if ((firstOrder == "")) | |
437 | - | then throw("empty orderbook") | |
438 | - | else { | |
439 | - | let nextOrder = getNextOrder(firstOrder) | |
440 | - | let filledTotal = getOrderFilledTotal(firstOrder) | |
441 | - | let orderPrice = getOrderPrice(firstOrder) | |
442 | - | let roi = getNumberByKey(getRoiByOrderIdKey(firstOrder)) | |
443 | - | let paymentWavelets = getOrderTotal(firstOrder) | |
444 | - | let orderOwnerAddress = Address(fromBase58String(getOrderOwner(firstOrder))) | |
445 | - | internalSellBond(firstOrder, nextOrder, filledTotal, roi, orderPrice, paymentWavelets, orderOwnerAddress, false) | |
446 | - | } | |
447 | 245 | ||
448 | 246 | ||
449 | 247 | @Verifier(tx) | |
450 | 248 | func verify () = { | |
451 | - | let pubKeyAdminsList = [" | |
249 | + | let pubKeyAdminsList = ["GJdLSaLiv5K7xuejac8mcRcHoyo3dPrESrvktG3a6MAR", "3xumx4hrPpeeoo79HLGbZCgfz95L39ZFdxxwWeSUC2Pu", "D4CqtK5fBsnzRo33ZMhrM7niLseDH2uRoK6weBq2JQ3A", "5WRXFSjwcTbNfKcJs8ZqXmSSWYsSVJUtMvMqZj5hH4Nc"] | |
452 | 250 | let count = ((((if (sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(pubKeyAdminsList[0]))) | |
453 | 251 | then 1 | |
454 | 252 | else 0) + (if (sigVerify(tx.bodyBytes, tx.proofs[1], fromBase58String(pubKeyAdminsList[1]))) | |
455 | 253 | then 1 | |
456 | 254 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[2], fromBase58String(pubKeyAdminsList[2]))) | |
457 | 255 | then 1 | |
458 | 256 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[3], fromBase58String(pubKeyAdminsList[3]))) | |
459 | 257 | then 2 | |
460 | 258 | else 0)) | |
461 | 259 | (count >= 3) | |
462 | 260 | } | |
463 | 261 |
github/deemru/w8io/169f3d6 77.61 ms ◑