tx · 4GQDLn3cqjDQdPnmxAgefpTZtysBmz9vGVUCv99MyqAk

3N9kbR6BQEQV7pwBfDFzprJtNofgi6fSJ6Y:  -0.03700000 Waves

2023.04.17 20:26 [2538862] smart account 3N9kbR6BQEQV7pwBfDFzprJtNofgi6fSJ6Y > SELF 0.00000000 Waves

{ "type": 13, "id": "4GQDLn3cqjDQdPnmxAgefpTZtysBmz9vGVUCv99MyqAk", "fee": 3700000, "feeAssetId": null, "timestamp": 1681752390213, "version": 2, "chainId": 84, "sender": "3N9kbR6BQEQV7pwBfDFzprJtNofgi6fSJ6Y", "senderPublicKey": "EajGg1J8duApPELWPw9gVkPwAKFC9hujhvCcne4FunUa", "proofs": [ "64aUjno3wvqiAUcxyqGE9nG5sjBfHt6s4KE8dPuYDofN1hJq5cnC8nrzFC9SBK5UGBmbs8tmgA7pU8ZqLoNk4Cjk" ], "script": "base64:BgJgCAISBAoCCAgSAwoBCBIAEgMKAQgSDgoMCAEBAQEBAQgBAQEBEgsKCQgBAQEIAQEBARIFCgMICAESCAoGCAgBAQEBEg0KCwgIAQEBAQEBCAgBEgMKAQESAwoBARIDCgEBQgAUa19jb29yZGluYXRvckFkZHJlc3MCFGtfY29vcmRpbmF0b3JBZGRyZXNzAA9rX2FkbWluX2FkZHJlc3MCD2tfYWRtaW5fYWRkcmVzcwANa19xdW90ZV9hc3NldAINa19xdW90ZV9hc3NldAAFa19hbW0CBWtfYW1tABFrX21hbmFnZXJfYWRkcmVzcwIRa19tYW5hZ2VyX2FkZHJlc3MAEmtfcG9zaXRpb25TZXF1ZW5jZQISa19wb3NpdGlvblNlcXVlbmNlAA5rX3Bvc2l0aW9uU2l6ZQIOa19wb3NpdGlvblNpemUAEGtfZXhlY3V0ZWRPcmRlcnMCEGtfZXhlY3V0ZWRPcmRlcnMAEGtfY2FuY2VsZWRPcmRlcnMCEGtfY2FuY2VsZWRPcmRlcnMAB2tfb3JkZXICB2tfb3JkZXIADmtfb3JkZXJSZXF1ZXN0AgprX29y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CQACAQIHU3VjY2VzcwkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAEDmNvb3JkaW5hdG9yU3RyCQCdCAIFBHRoaXMFFGtfY29vcmRpbmF0b3JBZGRyZXNzAwkBCWlzRGVmaW5lZAEFDmNvb3JkaW5hdG9yU3RyBAVhZG1pbgkAnQgCCQERQGV4dHJOYXRpdmUoMTA2MikBCQEFdmFsdWUBBQ5jb29yZGluYXRvclN0cgUPa19hZG1pbl9hZGRyZXNzAwkBCWlzRGVmaW5lZAEFBWFkbWluCQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEJAQV2YWx1ZQEFBWFkbWluCQCsAgIJAKwCAgkArAICAgdzdGF0dXNfCQClCAEFBHRoaXMCAV8JANgEAQgFAnR4AmlkBwkAAgECLnVuYWJsZSB0byB2ZXJpZnk6IGFkbWluIG5vdCBzZXQgaW4gY29vcmRpbmF0b3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXk4/OYT", "height": 2538862, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Etj6dUa2n6myFoCEbpYbRn5tSEgTQfA1DFDKs8ejWgs Next: HR2Q5DwnggXfAGj8yBJQd9cMbup894NUTJy5nXqSmv1W Diff:
OldNewDifferences
33 {-# CONTENT_TYPE DAPP #-}
44 let k_coordinatorAddress = "k_coordinatorAddress"
55
6-let k_admin_public_key = "k_admin_public_key"
6+let k_admin_address = "k_admin_address"
77
88 let k_quote_asset = "k_quote_asset"
99
1515
1616 let k_positionSize = "k_positionSize"
1717
18-let k_fee = "k_fee"
19-
2018 let k_executedOrders = "k_executedOrders"
2119
2220 let k_canceledOrders = "k_canceledOrders"
2321
2422 let k_order = "k_order"
23+
24+let k_orderRequest = "k_orderReq"
2525
2626 let k_lastOrderId = "k_lastOrderId"
2727
4747
4848 let DECREASE = 2
4949
50-let MAX_TRADER_ORDERS_PER_AMM = 5
50+let MAX_TRADER_ORDERS_PER_AMM = 10
5151
5252 let TIME = lastBlock.timestamp
5353
8383 func orderKey (_orderId) = toCompositeKey(k_order, toString(_orderId))
8484
8585
86+func orderRequestKey (_orderId,_type) = ((((k_orderRequest + "_") + toString(_orderId)) + "_") + toString(_type))
87+
88+
8689 func traderOrderCountKey (_amm,_trader) = ((((k_traderOrderCnt + "_") + _amm) + "_") + _trader)
8790
8891
99102
100103
101104 func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
102-
103-
104-func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
105105
106106
107107 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
129129 if ((val == ""))
130130 then nil
131131 else split(val, ",")
132+ }
133+
134+
135+func haveOrderRequest (_orderId,_type) = {
136+ let key = orderRequestKey(_orderId, _type)
137+ isDefined(getString(this, key))
138+ }
139+
140+
141+func getOrderRequest (_orderId,_type) = {
142+ let key = orderRequestKey(_orderId, _type)
143+ let orderRequestStr = valueOrErrorMessage(getString(this, key), ("Not order request for key: " + key))
144+ let orderRequestPartList = split(orderRequestStr, ",")
145+ let orderId = valueOrErrorMessage(parseInt(orderRequestPartList[0]), "Invalid orderId")
146+ let amm = orderRequestPartList[1]
147+ let trader = orderRequestPartList[2]
148+ let type = valueOrErrorMessage(parseInt(orderRequestPartList[3]), "Invalid type")
149+ let triggerPrice = valueOrErrorMessage(parseInt(orderRequestPartList[4]), "Invalid triggerPrice")
150+ let limitPrice = valueOrErrorMessage(parseInt(orderRequestPartList[5]), "Invalid limitPrice")
151+ $Tuple6(orderId, amm, trader, type, triggerPrice, limitPrice)
132152 }
133153
134154
182202 }
183203
184204
185-func getPositionSize (_amm,_trader) = {
205+func getPositionDirection (_orderSide,_orderType) = if (if ((_orderType == TAKE))
206+ then true
207+ else (_orderType == STOP))
208+ then if ((_orderSide == LONG))
209+ then SHORT
210+ else LONG
211+ else _orderSide
212+
213+
214+func getPositionSize (_amm,_trader,_direction) = {
186215 let amm = addressFromStringValue(_amm)
187- let sizeKey = toCompositeKey(k_positionSize, _trader)
216+ let positionKey = ((_trader + "_") + toString(_direction))
217+ let sizeKey = toCompositeKey(k_positionSize, positionKey)
188218 valueOrElse(getInteger(amm, sizeKey), 0)
189219 }
190220
191221
192-func getPositionId (_amm,_trader) = {
222+func getPositionId (_amm,_trader,_direction) = {
193223 let amm = addressFromStringValue(_amm)
194- let seqKey = toCompositeKey(k_positionSequence, _trader)
224+ let positionKey = ((_trader + "_") + toString(_direction))
225+ let seqKey = toCompositeKey(k_positionSequence, positionKey)
195226 valueOrElse(getInteger(amm, seqKey), 0)
196227 }
197228
205236 }
206237
207238
208-func addRemoveOrderId (_orderId,_amm,_trader,_add) = {
209- let orderIds = traderAmmOrdersIds(_amm, _trader)
210- let orderIdsNew = if (_add)
211- then (orderIds :+ toString(_orderId))
212- else removeByIndex(orderIds, valueOrErrorMessage(indexOf(orderIds, toString(_orderId)), ("No order with id: " + toString(_orderId))))
213- let orderIdsNewStr = makeString(orderIdsNew, ",")
214-[StringEntry(traderOrderIdsKey(_amm, _trader), orderIdsNewStr)]
239+func saveOrderRequest (_orderId,_amm,_trader,_type,_triggerPrice,_limitPrice) = {
240+ let orderReqStr = makeString([toString(_orderId), _amm, _trader, toString(_type), toString(_triggerPrice), toString(_limitPrice)], ",")
241+[StringEntry(orderRequestKey(_orderId, _type), orderReqStr)]
215242 }
216243
217244
218-func updateTraderOrderCount (_amm,_trader,_count) = [IntegerEntry(traderOrderCountKey(_amm, _trader), _count)]
245+func updateOrderIdStr (_orderIdsNewStr,_amm,_trader) = [StringEntry(traderOrderIdsKey(_amm, _trader), _orderIdsNewStr)]
246+
247+
248+func addRemoveOrderIdList (_orderIds,_orderId,_amm,_trader,_add) = {
249+ let orderIdsNew = if (_add)
250+ then (_orderIds :+ toString(_orderId))
251+ else removeByIndex(_orderIds, valueOrErrorMessage(indexOf(_orderIds, toString(_orderId)), ("No order with id: " + toString(_orderId))))
252+ orderIdsNew
253+ }
254+
255+
256+func addRemoveOrderId (_orderId,_amm,_trader,_add) = {
257+ let orderIds = traderAmmOrdersIds(_amm, _trader)
258+ let orderIdsNew = addRemoveOrderIdList(orderIds, _orderId, _amm, _trader, _add)
259+ let orderIdsNewStr = makeString(orderIdsNew, ",")
260+ updateOrderIdStr(orderIdsNewStr, _amm, _trader)
261+ }
262+
263+
264+func updateTraderOrderCount (_amm,_trader,_count) = if ((0 > _count))
265+ then throw(("Invalid order count: " + toString(_count)))
266+ else [IntegerEntry(traderOrderCountKey(_amm, _trader), _count)]
219267
220268
221269 func updateLastOrderId (_lastOrderId) = [IntegerEntry(k_lastOrderId, _lastOrderId)]
227275 func markCancelOrder (_orderId) = [BooleanEntry(toCompositeKey(k_canceledOrders, toString(_orderId)), true)]
228276
229277
278+func getPositionIds (_amm,_trader) = {
279+ let longPositionSize = getPositionSize(_amm, _trader, LONG)
280+ let currentLongPositionId = if ((longPositionSize != 0))
281+ then getPositionId(_amm, _trader, LONG)
282+ else 0
283+ let shortPositionSize = getPositionSize(_amm, _trader, SHORT)
284+ let currentShortPositionId = if ((shortPositionSize != 0))
285+ then getPositionId(_amm, _trader, SHORT)
286+ else 0
287+[currentLongPositionId, currentShortPositionId]
288+ }
289+
290+
230291 @Callable(i)
231292 func cleanUpStaleOrders (_amm,_trader) = {
232293 let orders = traderAmmOrdersIds(_amm, _trader)
233- let orderCount = getTraderOrderCount(_amm, _trader)
294+ let positionIds = getPositionIds(_amm, _trader)
234295 func cleanUpOne (_acc,_orderId) = {
235296 let orderIdInt = valueOrErrorMessage(parseInt(_orderId), "Invalid order id")
236- let $t083838578 = getOrder(orderIdInt)
237- let _x1 = $t083838578._1
238- let _x2 = $t083838578._2
239- let _x3 = $t083838578._3
240- let _x4 = $t083838578._4
241- let _type = $t083838578._5
242- let _x5 = $t083838578._6
243- let _x6 = $t083838578._7
244- let _x7 = $t083838578._8
245- let _x8 = $t083838578._9
246- let _positionId = $t083838578._10
247- let _x9 = $t083838578._11
248- let positionSize = getPositionSize(_amm, _trader)
249- let currentPositionId = if ((positionSize != 0))
250- then getPositionId(_amm, _trader)
251- else 0
252- if (if (if ((_type == STOP))
297+ let $t01115611351 = getOrder(orderIdInt)
298+ let _x1 = $t01115611351._1
299+ let _x2 = $t01115611351._2
300+ let _x3 = $t01115611351._3
301+ let _x4 = $t01115611351._4
302+ let _type = $t01115611351._5
303+ let _x5 = $t01115611351._6
304+ let _x6 = $t01115611351._7
305+ let _x7 = $t01115611351._8
306+ let _x8 = $t01115611351._9
307+ let _positionId = $t01115611351._10
308+ let _x9 = $t01115611351._11
309+ if (if (if (if ((_type == STOP))
253310 then true
254311 else (_type == TAKE))
255- then (currentPositionId != _positionId)
312+ then (positionIds[0] != _positionId)
313+ else false)
314+ then (positionIds[1] != _positionId)
256315 else false)
257316 then {
258- let change = (markCancelOrder(orderIdInt) ++ addRemoveOrderId(orderIdInt, _amm, _trader, false))
259- $Tuple2((_acc._1 + 1), (_acc._2 ++ change))
317+ let change = markCancelOrder(orderIdInt)
318+ let newOrderList = addRemoveOrderIdList(_acc._1, orderIdInt, _amm, _trader, false)
319+ $Tuple2(newOrderList, (_acc._2 ++ change))
260320 }
261321 else _acc
262322 }
263323
264- let result = {
324+ let $t01170411779 = {
265325 let $l = orders
266326 let $s = size($l)
267- let $acc0 = $Tuple2(0, nil)
327+ let $acc0 = $Tuple2(orders, nil)
268328 func $f0_1 ($a,$i) = if (($i >= $s))
269329 then $a
270330 else cleanUpOne($a, $l[$i])
271331
272332 func $f0_2 ($a,$i) = if (($i >= $s))
273333 then $a
274- else throw("List size exceeds 5")
334+ else throw("List size exceeds 10")
275335
276- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
336+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
277337 }
278- (result._2 ++ updateTraderOrderCount(_amm, _trader, (orderCount - result._1)))
338+ let newOrders = $t01170411779._1
339+ let cancelActions = $t01170411779._2
340+ ((cancelActions ++ updateTraderOrderCount(_amm, _trader, size(newOrders))) ++ updateOrderIdStr(makeString(newOrders, ","), _amm, _trader))
279341 }
280342
281343
295357
296358
297359 @Callable(i)
298-func initialize (_coordinator) = if (initialized())
299- then throw("Already initialized")
300- else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)]
360+func initialize (_coordinator) = if (if (initialized())
361+ then true
362+ else (i.caller != this))
363+ then throw("Unable to initialize")
364+ else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), BooleanEntry(k_initialized, true)]
301365
302366
303367
304368 @Callable(i)
305-func createOrder (_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink) = {
369+func createOrder (_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_stopTriggerPrice,_stopLimitPrice,_takeTriggerPrice,_takeLimitPrice) = {
306370 let _trader = toString(i.caller)
307371 let cleanUp = invoke(this, "cleanUpStaleOrders", [_amm, _trader], nil)
308372 if ((cleanUp == cleanUp))
309373 then if ((size(i.payments) > 1))
310374 then throw("Invalid createOrder parameters: invalid payment count")
311375 else {
312- let $t01028710539 = if ((size(i.payments) == 1))
376+ let $t01427514527 = if ((size(i.payments) == 1))
313377 then $Tuple2(toBase58String(valueOrErrorMessage(i.payments[0].assetId, "Invalid asset id")), i.payments[0].amount)
314378 else $Tuple2("", 0)
315- let paymentAssetId = $t01028710539._1
316- let paymentAmount = $t01028710539._2
379+ let paymentAssetId = $t01427514527._1
380+ let paymentAmount = $t01427514527._2
317381 let doCall = invoke(this, "internalCreateOrder", [_trader, _amm, _type, _triggerPrice, _limitPrice, _amountIn, _leverage, _side, _refLink, paymentAssetId, paymentAmount], nil)
318382 if ((doCall == doCall))
319- then nil
383+ then {
384+ let orderId = match doCall {
385+ case t: Int =>
386+ t
387+ case _ =>
388+ throw("Invalid ID of created order")
389+ }
390+ if ((_type == LIMIT))
391+ then {
392+ let makeStop = if ((_stopTriggerPrice > 0))
393+ then {
394+ let doMakeStop = invoke(this, "internalCreateOrderRequest", [_trader, _amm, orderId, STOP, _stopTriggerPrice, _stopLimitPrice], nil)
395+ if ((doMakeStop == doMakeStop))
396+ then nil
397+ else throw("Strict value is not equal to itself.")
398+ }
399+ else nil
400+ let makeTake = if ((_takeTriggerPrice > 0))
401+ then {
402+ let doMakeTake = invoke(this, "internalCreateOrderRequest", [_trader, _amm, orderId, TAKE, _takeTriggerPrice, _takeLimitPrice], nil)
403+ if ((doMakeTake == doMakeTake))
404+ then nil
405+ else throw("Strict value is not equal to itself.")
406+ }
407+ else nil
408+ (makeStop ++ makeTake)
409+ }
410+ else nil
411+ }
320412 else throw("Strict value is not equal to itself.")
321413 }
322414 else throw("Strict value is not equal to itself.")
334426 else !(isWhitelist(_amm)))
335427 then throw("Invalid increasePositionWithStopLoss parameters")
336428 else {
337- let positionSize = getPositionSize(_amm, _trader)
429+ let positionSize = getPositionSize(_amm, _trader, _direction)
338430 if ((positionSize != 0))
339431 then throw("Invalid increasePositionWithStopLoss parameters: only new position")
340432 else {
347439 let doResetContext = invoke(this, "resetContext", nil, nil)
348440 if ((doResetContext == doResetContext))
349441 then {
350- let openedPositionSize = getPositionSize(_amm, _trader)
442+ let openedPositionSize = getPositionSize(_amm, _trader, _direction)
351443 if ((openedPositionSize == openedPositionSize))
352444 then {
353445 let amountIn = abs(openedPositionSize)
393485
394486
395487 @Callable(i)
396-func internalCreateOrder (_trader,_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_paymentAssetId,_paymentAmount) = if (if (if (if (if (if (if (if (if (!(initialized()))
488+func internalMarkOrderExecuted (_amm,_trader,_orderId) = if (if (if (!(initialized()))
489+ then true
490+ else !(isWhitelist(_amm)))
491+ then true
492+ else !((i.caller == this)))
493+ then throw("Invalid internalMarkOrderExecuted parameters")
494+ else {
495+ let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) - 1)
496+ ((updateTraderOrderCount(_amm, _trader, newTraderOrderCount) ++ addRemoveOrderId(_orderId, _amm, _trader, false)) ++ markExecuteOrder(_orderId))
497+ }
498+
499+
500+
501+@Callable(i)
502+func internalCreateOrderRequest (_trader,_amm,_orderId,_type,_triggerPrice,_limitPrice) = if (if (if (if (if (!(initialized()))
397503 then true
398504 else !(isWhitelist(_amm)))
399505 then true
401507 then true
402508 else (0 > _limitPrice))
403509 then true
404- else (0 >= _amountIn))
405- then true
406- else (0 > _leverage))
407- then true
408- else !(if ((_side == LONG))
510+ else !((i.caller == this)))
511+ then throw("Invalid internalCreateOrderRequest parameters")
512+ else saveOrderRequest(_orderId, _amm, _trader, _type, _triggerPrice, _limitPrice)
513+
514+
515+
516+@Callable(i)
517+func internalCreateOrder (_trader,_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_paymentAssetId,_paymentAmount) = {
518+ let x1 = toString(!(initialized()))
519+ let x2 = toString(!(isWhitelist(_amm)))
520+ let x3 = toString((0 >= _triggerPrice))
521+ let x4 = toString((0 > _limitPrice))
522+ let x5 = toString((0 >= _amountIn))
523+ let x6 = toString((0 > _leverage))
524+ let x7 = toString(!(if ((_side == LONG))
409525 then true
410526 else (_side == SHORT)))
411- then true
412- else !(if (if ((_type == STOP))
527+ let x8 = toString(!(if (if ((_type == STOP))
413528 then true
414529 else (_type == TAKE))
415530 then true
416531 else (_type == LIMIT)))
417- then true
418- else !((i.caller == this)))
419- then throw("Invalid createOrder parameters")
420- else {
421- let orderId = (currentOrderId() + 1)
422- let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) + 1)
423- let positionSize = getPositionSize(_amm, _trader)
424- let _direction = if (if (if ((positionSize == 0))
532+ let x9 = toString(!((i.caller == this)))
533+ let all = makeString([x1, x2, x3, x4, x5, x6, x7, x8, x9], ",")
534+ if (if (if (if (if (if (if (if (if (!(initialized()))
535+ then true
536+ else !(isWhitelist(_amm)))
537+ then true
538+ else (0 >= _triggerPrice))
539+ then true
540+ else (0 > _limitPrice))
541+ then true
542+ else (0 >= _amountIn))
543+ then true
544+ else (0 > _leverage))
545+ then true
546+ else !(if ((_side == LONG))
425547 then true
426- else if ((positionSize > 0))
427- then (_side == LONG)
548+ else (_side == SHORT)))
549+ then true
550+ else !(if (if ((_type == STOP))
551+ then true
552+ else (_type == TAKE))
553+ then true
554+ else (_type == LIMIT)))
555+ then true
556+ else !((i.caller == this)))
557+ then throw(("Invalid internalCreateOrder parameters " + all))
558+ else {
559+ let orderId = (currentOrderId() + 1)
560+ let positionDirection = getPositionDirection(_side, _type)
561+ let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) + 1)
562+ let positionSize = getPositionSize(_amm, _trader, positionDirection)
563+ let _direction = if (if (if ((positionSize == 0))
564+ then true
565+ else if ((positionSize > 0))
566+ then (_side == LONG)
567+ else false)
568+ then true
569+ else if ((0 > positionSize))
570+ then (_side == SHORT)
571+ else false)
572+ then INCREASE
573+ else DECREASE
574+ if (if ((positionSize == 0))
575+ then if ((_type == STOP))
576+ then true
577+ else (_type == TAKE)
428578 else false)
429- then true
430- else if ((0 > positionSize))
431- then (_side == SHORT)
432- else false)
433- then INCREASE
434- else DECREASE
435- if (if ((positionSize == 0))
436- then if ((_type == STOP))
437- then true
438- else (_type == TAKE)
439- else false)
440- then throw("Can not create STOP/TAKE order: no position")
441- else {
442- let usdnPayment = if ((_direction == INCREASE))
443- then if (if ((_paymentAssetId != toBase58String(quoteAsset())))
444- then true
445- else (_paymentAmount != _amountIn))
446- then throw("Invalid createLimitOrder parameters: invalid payment")
447- else {
448- let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _paymentAmount)])
449- if ((stake == stake))
450- then _paymentAmount
451- else throw("Strict value is not equal to itself.")
579+ then throw("Can not create STOP/TAKE order: no position")
580+ else {
581+ let usdnPayment = if ((_direction == INCREASE))
582+ then if (if ((_paymentAssetId != toBase58String(quoteAsset())))
583+ then true
584+ else (_paymentAmount != _amountIn))
585+ then throw("Invalid createLimitOrder parameters: invalid payment")
586+ else {
587+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _paymentAmount)])
588+ if ((stake == stake))
589+ then _paymentAmount
590+ else throw("Strict value is not equal to itself.")
591+ }
592+ else 0
593+ if ((usdnPayment == usdnPayment))
594+ then {
595+ let positionId = if ((positionSize != 0))
596+ then getPositionId(_amm, _trader, positionDirection)
597+ else 0
598+ if (if (if ((_type == STOP))
599+ then true
600+ else (_type == TAKE))
601+ then (positionId == 0)
602+ else false)
603+ then throw("STOP and TAKE order should be assigned to position with id != 0")
604+ else if ((newTraderOrderCount > MAX_TRADER_ORDERS_PER_AMM))
605+ then throw("Invalid createLimitOrder parameters: order count")
606+ else {
607+ let changeSet = (((saveOrder(orderId, _amm, _trader, _amountIn, _leverage, _type, _triggerPrice, usdnPayment, _side, _refLink, positionId, _limitPrice) ++ addRemoveOrderId(orderId, _amm, _trader, true)) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ updateLastOrderId(orderId))
608+ $Tuple2(changeSet, orderId)
609+ }
452610 }
453- else 0
454- if ((usdnPayment == usdnPayment))
455- then {
456- let positionId = if ((positionSize != 0))
457- then getPositionId(_amm, _trader)
458- else 0
459- if ((newTraderOrderCount > MAX_TRADER_ORDERS_PER_AMM))
460- then throw("Invalid createLimitOrder parameters: order count")
461- else (((saveOrder(orderId, _amm, _trader, _amountIn, _leverage, _type, _triggerPrice, usdnPayment, _side, _refLink, positionId, _limitPrice) ++ addRemoveOrderId(orderId, _amm, _trader, true)) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ updateLastOrderId(orderId))
462- }
463- else throw("Strict value is not equal to itself.")
464- }
465- }
611+ else throw("Strict value is not equal to itself.")
612+ }
613+ }
614+ }
466615
467616
468617
469618 @Callable(i)
470619 func cancelOrder (_orderId) = {
471- let $t01590816127 = getOrder(_orderId)
472- let _amm = $t01590816127._1
473- let _trader = $t01590816127._2
474- let _amountIn = $t01590816127._3
475- let _leverage = $t01590816127._4
476- let _type = $t01590816127._5
477- let _triggerPrice = $t01590816127._6
478- let _amountUsdn = $t01590816127._7
479- let _side = $t01590816127._8
480- let _refLink = $t01590816127._9
481- let _positionId = $t01590816127._10
482- let _limitPrice = $t01590816127._11
620+ let $t02378624005 = getOrder(_orderId)
621+ let _amm = $t02378624005._1
622+ let _trader = $t02378624005._2
623+ let _amountIn = $t02378624005._3
624+ let _leverage = $t02378624005._4
625+ let _type = $t02378624005._5
626+ let _triggerPrice = $t02378624005._6
627+ let _amountUsdn = $t02378624005._7
628+ let _side = $t02378624005._8
629+ let _refLink = $t02378624005._9
630+ let _positionId = $t02378624005._10
631+ let _limitPrice = $t02378624005._11
483632 if (if (if (!(initialized()))
484633 then true
485634 else !(isValid(_orderId)))
513662
514663 @Callable(i)
515664 func executeOrder (_orderId) = {
516- let $t01709817317 = getOrder(_orderId)
517- let _amm = $t01709817317._1
518- let _trader = $t01709817317._2
519- let _amountIn = $t01709817317._3
520- let _leverage = $t01709817317._4
521- let _type = $t01709817317._5
522- let _triggerPrice = $t01709817317._6
523- let _amountUsdn = $t01709817317._7
524- let _side = $t01709817317._8
525- let _refLink = $t01709817317._9
526- let _positionId = $t01709817317._10
527- let _limitPrice = $t01709817317._11
665+ let $t02520325422 = getOrder(_orderId)
666+ let _amm = $t02520325422._1
667+ let _trader = $t02520325422._2
668+ let _amountIn = $t02520325422._3
669+ let _leverage = $t02520325422._4
670+ let _type = $t02520325422._5
671+ let _triggerPrice = $t02520325422._6
672+ let _amountUsdn = $t02520325422._7
673+ let _side = $t02520325422._8
674+ let _refLink = $t02520325422._9
675+ let _positionId = $t02520325422._10
676+ let _limitPrice = $t02520325422._11
528677 let cleanUp = invoke(this, "cleanUpStaleOrders", [_amm, _trader], nil)
529678 if ((cleanUp == cleanUp))
530- then if (if (!(initialized()))
531- then true
532- else !(isValid(_orderId)))
533- then throw("Invalid executeOrder parameters")
534- else {
535- let positionSize = getPositionSize(_amm, _trader)
536- let currentPositionId = if ((positionSize != 0))
537- then getPositionId(_amm, _trader)
538- else 0
539- let $t01772121563 = if ((_type == STOP))
540- then {
541- let _positionDirection = if ((positionSize > 0))
542- then LONG
543- else if ((0 > positionSize))
544- then SHORT
545- else throw("Can not execute STOP order: no open position")
546- let marketPrice = getMarketPrice(_amm)
547- let isExecutable = if ((_side == _positionDirection))
548- then throw("Can not execute STOP order: reduce only")
549- else if ((currentPositionId != _positionId))
550- then throw("Can not execute STOP order: position closed")
551- else if ((_positionDirection == LONG))
552- then (_triggerPrice >= marketPrice)
553- else (marketPrice >= _triggerPrice)
554- if (isExecutable)
555- then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), muld(_limitPrice, abs(positionSize)), false], nil)
556- else throw("Can not execute STOP order: triggerPrice mismatch")
557- }
558- else if ((_type == TAKE))
679+ then {
680+ let positionDirection = getPositionDirection(_side, _type)
681+ if (if (!(initialized()))
682+ then true
683+ else !(isValid(_orderId)))
684+ then throw("Invalid executeOrder parameters")
685+ else {
686+ let positionSize = getPositionSize(_amm, _trader, positionDirection)
687+ if ((positionSize == positionSize))
559688 then {
560- let _positionDirection = if ((positionSize > 0))
561- then LONG
562- else if ((0 > positionSize))
563- then SHORT
564- else throw("Can not execute STOP order: no open position")
565- let marketPrice = getMarketPrice(_amm)
566- let isExecutable = if ((_side == _positionDirection))
567- then throw("Can not execute TAKE order: reduce only")
568- else if ((currentPositionId != _positionId))
569- then throw(((("Can not execute TAKE order: position closed " + toString(currentPositionId)) + "!=") + toString(_positionId)))
570- else if ((_positionDirection == LONG))
571- then (marketPrice >= _triggerPrice)
572- else (_triggerPrice >= marketPrice)
573- if (isExecutable)
574- then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), muld(_limitPrice, abs(positionSize)), false], nil)
575- else throw("Can not execute TAKE order: triggerPrice mismatch")
576- }
577- else if ((_type == LIMIT))
578- then {
579- let marketPrice = getMarketPrice(_amm)
580- let spread = if ((_limitPrice == 0))
581- then getSpread(_triggerPrice)
582- else abs((_triggerPrice - _limitPrice))
583- let isExecutable = if ((marketPrice >= (_triggerPrice - spread)))
584- then ((_triggerPrice + spread) >= marketPrice)
585- else false
586- if (isExecutable)
689+ let currentPositionId = if ((positionSize != 0))
690+ then getPositionId(_amm, _trader, positionDirection)
691+ else 0
692+ let $t02592929307 = if ((_type == STOP))
693+ then {
694+ let _positionDirection = if ((positionSize > 0))
695+ then LONG
696+ else if ((0 > positionSize))
697+ then SHORT
698+ else throw("Can not execute STOP order: no open position")
699+ let marketPrice = getMarketPrice(_amm)
700+ let isExecutable = if ((_side == _positionDirection))
701+ then throw("Can not execute STOP order: reduce only")
702+ else if ((currentPositionId != _positionId))
703+ then throw("Can not execute STOP order: position closed")
704+ else if ((_positionDirection == LONG))
705+ then (_triggerPrice >= marketPrice)
706+ else (marketPrice >= _triggerPrice)
707+ if (isExecutable)
708+ then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), positionDirection, muld(_limitPrice, abs(positionSize)), false], nil)
709+ else throw("Can not execute STOP order: triggerPrice mismatch")
710+ }
711+ else if ((_type == TAKE))
587712 then {
588713 let _positionDirection = if ((positionSize > 0))
589714 then LONG
590715 else if ((0 > positionSize))
591716 then SHORT
592- else -1
593- let direction = if ((positionSize == 0))
594- then INCREASE
595- else if ((_positionDirection == _side))
596- then INCREASE
597- else DECREASE
598- if ((direction == INCREASE))
599- then {
600- let amountInWithFee = (_amountUsdn - muld(_amountUsdn, getFee(_amm, _trader)))
601- $Tuple3("increasePosition", [_side, _leverage, if ((_limitPrice == 0))
602- then 0
603- else divd(amountInWithFee, _limitPrice), _refLink], [AttachedPayment(quoteAsset(), _amountUsdn)])
604- }
605- else $Tuple3("closePosition", [_amountIn, muld(_amountIn, _limitPrice), false], nil)
717+ else throw("Can not execute STOP order: no open position")
718+ let marketPrice = getMarketPrice(_amm)
719+ let isExecutable = if ((_side == _positionDirection))
720+ then throw("Can not execute TAKE order: reduce only")
721+ else if ((currentPositionId != _positionId))
722+ then throw(((("Can not execute TAKE order: position closed " + toString(currentPositionId)) + "!=") + toString(_positionId)))
723+ else if ((_positionDirection == LONG))
724+ then (marketPrice >= _triggerPrice)
725+ else (_triggerPrice >= marketPrice)
726+ if (isExecutable)
727+ then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), positionDirection, muld(_limitPrice, abs(positionSize)), false], nil)
728+ else throw("Can not execute TAKE order: triggerPrice mismatch")
606729 }
607- else throw("Can not execute LIMIT order: triggerPrice mismatch")
608- }
609- else throw(("Invalid order type: " + toString(_type)))
610- let method = $t01772121563._1
611- let args = $t01772121563._2
612- let payments = $t01772121563._3
613- let withdraw = if ((size(payments) == 1))
614- then {
615- let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), payments[0].amount], nil)
616- if ((unstake == unstake))
617- then nil
618- else throw("Strict value is not equal to itself.")
619- }
620- else nil
621- if ((withdraw == withdraw))
622- then {
623- let doSetContext = invoke(this, "setContext", [_trader], nil)
624- if ((doSetContext == doSetContext))
625- then {
626- let doClosePosition = invoke(addressFromStringValue(_amm), method, args, payments)
627- if ((doClosePosition == doClosePosition))
628- then {
629- let doResetContext = invoke(this, "resetContext", nil, nil)
630- if ((doResetContext == doResetContext))
631- then {
632- let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) - 1)
633- ((updateTraderOrderCount(_amm, _trader, newTraderOrderCount) ++ addRemoveOrderId(_orderId, _amm, _trader, false)) ++ markExecuteOrder(_orderId))
634- }
635- else throw("Strict value is not equal to itself.")
636- }
637- else throw("Strict value is not equal to itself.")
638- }
639- else throw("Strict value is not equal to itself.")
640- }
641- else throw("Strict value is not equal to itself.")
642- }
730+ else if ((_type == LIMIT))
731+ then {
732+ let marketPrice = getMarketPrice(_amm)
733+ let spread = if ((_limitPrice == 0))
734+ then getSpread(_triggerPrice)
735+ else abs((_triggerPrice - _limitPrice))
736+ let isExecutable = if ((marketPrice >= (_triggerPrice - spread)))
737+ then ((_triggerPrice + spread) >= marketPrice)
738+ else false
739+ if (isExecutable)
740+ then {
741+ let amountInWithFee = (_amountUsdn - muld(_amountUsdn, getFee(_amm, _trader)))
742+ $Tuple3("increasePosition", [_side, _leverage, if ((_limitPrice == 0))
743+ then 0
744+ else divd(amountInWithFee, _limitPrice), _refLink], [AttachedPayment(quoteAsset(), _amountUsdn)])
745+ }
746+ else throw("Can not execute LIMIT order: triggerPrice mismatch")
747+ }
748+ else throw(("Invalid order type: " + toString(_type)))
749+ let method = $t02592929307._1
750+ let args = $t02592929307._2
751+ let payments = $t02592929307._3
752+ let withdraw = if ((size(payments) == 1))
753+ then {
754+ let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), payments[0].amount], nil)
755+ if ((unstake == unstake))
756+ then nil
757+ else throw("Strict value is not equal to itself.")
758+ }
759+ else nil
760+ if ((withdraw == withdraw))
761+ then {
762+ let doSetContext = invoke(this, "setContext", [_trader], nil)
763+ if ((doSetContext == doSetContext))
764+ then {
765+ let doClosePosition = invoke(addressFromStringValue(_amm), method, args, payments)
766+ if ((doClosePosition == doClosePosition))
767+ then {
768+ let doResetContext = invoke(this, "resetContext", nil, nil)
769+ if ((doResetContext == doResetContext))
770+ then {
771+ let executeOrderRequest = if ((_type == LIMIT))
772+ then {
773+ let newPositionSize = getPositionSize(_amm, _trader, positionDirection)
774+ if ((newPositionSize == newPositionSize))
775+ then {
776+ let newPositionId = getPositionId(_amm, _trader, positionDirection)
777+ if ((newPositionId == newPositionId))
778+ then {
779+ let positionSizeDelta = (newPositionSize - positionSize)
780+ let closeOrderSide = if ((newPositionSize > 0))
781+ then SHORT
782+ else LONG
783+ let makeTakeOrder = if (haveOrderRequest(_orderId, TAKE))
784+ then {
785+ let $t03026930468 = getOrderRequest(_orderId, TAKE)
786+ let newOrderId = $t03026930468._1
787+ let newAmm = $t03026930468._2
788+ let newTrader = $t03026930468._3
789+ let newType = $t03026930468._4
790+ let newTriggerPrice = $t03026930468._5
791+ let newLimitPrice = $t03026930468._6
792+ let doCall = invoke(this, "internalCreateOrder", [newTrader, newAmm, newType, newTriggerPrice, newLimitPrice, positionSizeDelta, 0, closeOrderSide, "", "", 0], nil)
793+ if ((doCall == doCall))
794+ then nil
795+ else throw("Strict value is not equal to itself.")
796+ }
797+ else nil
798+ if ((makeTakeOrder == makeTakeOrder))
799+ then {
800+ let makeStopOrder = if (haveOrderRequest(_orderId, STOP))
801+ then {
802+ let $t03102431223 = getOrderRequest(_orderId, STOP)
803+ let newOrderId = $t03102431223._1
804+ let newAmm = $t03102431223._2
805+ let newTrader = $t03102431223._3
806+ let newType = $t03102431223._4
807+ let newTriggerPrice = $t03102431223._5
808+ let newLimitPrice = $t03102431223._6
809+ let doCall = invoke(this, "internalCreateOrder", [newTrader, newAmm, newType, newTriggerPrice, newLimitPrice, positionSizeDelta, 0, closeOrderSide, "", "", 0], nil)
810+ if ((doCall == doCall))
811+ then nil
812+ else throw("Strict value is not equal to itself.")
813+ }
814+ else nil
815+ if ((makeStopOrder == makeStopOrder))
816+ then (makeTakeOrder ++ makeStopOrder)
817+ else throw("Strict value is not equal to itself.")
818+ }
819+ else throw("Strict value is not equal to itself.")
820+ }
821+ else throw("Strict value is not equal to itself.")
822+ }
823+ else throw("Strict value is not equal to itself.")
824+ }
825+ else nil
826+ if ((executeOrderRequest == executeOrderRequest))
827+ then {
828+ let doMarkOrderExecuted = invoke(this, "internalMarkOrderExecuted", [_amm, _trader, _orderId], nil)
829+ if ((doMarkOrderExecuted == doMarkOrderExecuted))
830+ then nil
831+ else throw("Strict value is not equal to itself.")
832+ }
833+ else throw("Strict value is not equal to itself.")
834+ }
835+ else throw("Strict value is not equal to itself.")
836+ }
837+ else throw("Strict value is not equal to itself.")
838+ }
839+ else throw("Strict value is not equal to itself.")
840+ }
841+ else throw("Strict value is not equal to itself.")
842+ }
843+ else throw("Strict value is not equal to itself.")
844+ }
845+ }
643846 else throw("Strict value is not equal to itself.")
644847 }
645848
655858
656859
657860 @Verifier(tx)
658-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
861+func verify () = {
862+ let coordinatorStr = getString(this, k_coordinatorAddress)
863+ if (isDefined(coordinatorStr))
864+ then {
865+ let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
866+ if (isDefined(admin))
867+ then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
868+ else throw("unable to verify: admin not set in coordinator")
869+ }
870+ else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
871+ }
659872
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_coordinatorAddress = "k_coordinatorAddress"
55
6-let k_admin_public_key = "k_admin_public_key"
6+let k_admin_address = "k_admin_address"
77
88 let k_quote_asset = "k_quote_asset"
99
1010 let k_amm = "k_amm"
1111
1212 let k_manager_address = "k_manager_address"
1313
1414 let k_positionSequence = "k_positionSequence"
1515
1616 let k_positionSize = "k_positionSize"
1717
18-let k_fee = "k_fee"
19-
2018 let k_executedOrders = "k_executedOrders"
2119
2220 let k_canceledOrders = "k_canceledOrders"
2321
2422 let k_order = "k_order"
23+
24+let k_orderRequest = "k_orderReq"
2525
2626 let k_lastOrderId = "k_lastOrderId"
2727
2828 let k_traderOrderCnt = "k_traderOrderCnt"
2929
3030 let k_traderOrderIds = "k_traderOrderIds"
3131
3232 let k_sender = "k_sender"
3333
3434 let k_initialized = "k_initialized"
3535
3636 let STOP = 1
3737
3838 let TAKE = 2
3939
4040 let LIMIT = 3
4141
4242 let LONG = 1
4343
4444 let SHORT = 2
4545
4646 let INCREASE = 1
4747
4848 let DECREASE = 2
4949
50-let MAX_TRADER_ORDERS_PER_AMM = 5
50+let MAX_TRADER_ORDERS_PER_AMM = 10
5151
5252 let TIME = lastBlock.timestamp
5353
5454 let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10))
5555
5656 let SPREAD_LIMIT = (DECIMAL_UNIT / 200)
5757
5858 func abs (_x) = if ((_x > 0))
5959 then _x
6060 else -(_x)
6161
6262
6363 func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
6464
6565
6666 func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
6767
6868
6969 func minv (_x,_y) = if ((_x > _y))
7070 then _y
7171 else _x
7272
7373
7474 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
7575
7676
7777 func executedOrderKey (_orderId) = ((k_executedOrders + "_") + toString(_orderId))
7878
7979
8080 func canceledOrderKey (_orderId) = ((k_canceledOrders + "_") + toString(_orderId))
8181
8282
8383 func orderKey (_orderId) = toCompositeKey(k_order, toString(_orderId))
8484
8585
86+func orderRequestKey (_orderId,_type) = ((((k_orderRequest + "_") + toString(_orderId)) + "_") + toString(_type))
87+
88+
8689 func traderOrderCountKey (_amm,_trader) = ((((k_traderOrderCnt + "_") + _amm) + "_") + _trader)
8790
8891
8992 func traderOrderIdsKey (_amm,_trader) = ((((k_traderOrderIds + "_") + _amm) + "_") + _trader)
9093
9194
9295 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
9396
9497
9598 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
9699
97100
98101 func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set")
99102
100103
101104 func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
102-
103-
104-func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
105105
106106
107107 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
108108
109109
110110 func isValid (_orderId) = if (valueOrElse(getBoolean(this, executedOrderKey(_orderId)), false))
111111 then throw(("Order already executed: " + toString(_orderId)))
112112 else if (valueOrElse(getBoolean(this, canceledOrderKey(_orderId)), false))
113113 then throw(("Order already cancelled: " + toString(_orderId)))
114114 else true
115115
116116
117117 func currentOrderId () = valueOrElse(getInteger(this, k_lastOrderId), 0)
118118
119119
120120 func getTraderOrderCount (_amm,_trader) = {
121121 let key = traderOrderCountKey(_amm, _trader)
122122 valueOrElse(getInteger(this, key), 0)
123123 }
124124
125125
126126 func traderAmmOrdersIds (_amm,_trader) = {
127127 let key = traderOrderIdsKey(_amm, _trader)
128128 let val = valueOrElse(getString(this, key), "")
129129 if ((val == ""))
130130 then nil
131131 else split(val, ",")
132+ }
133+
134+
135+func haveOrderRequest (_orderId,_type) = {
136+ let key = orderRequestKey(_orderId, _type)
137+ isDefined(getString(this, key))
138+ }
139+
140+
141+func getOrderRequest (_orderId,_type) = {
142+ let key = orderRequestKey(_orderId, _type)
143+ let orderRequestStr = valueOrErrorMessage(getString(this, key), ("Not order request for key: " + key))
144+ let orderRequestPartList = split(orderRequestStr, ",")
145+ let orderId = valueOrErrorMessage(parseInt(orderRequestPartList[0]), "Invalid orderId")
146+ let amm = orderRequestPartList[1]
147+ let trader = orderRequestPartList[2]
148+ let type = valueOrErrorMessage(parseInt(orderRequestPartList[3]), "Invalid type")
149+ let triggerPrice = valueOrErrorMessage(parseInt(orderRequestPartList[4]), "Invalid triggerPrice")
150+ let limitPrice = valueOrErrorMessage(parseInt(orderRequestPartList[5]), "Invalid limitPrice")
151+ $Tuple6(orderId, amm, trader, type, triggerPrice, limitPrice)
132152 }
133153
134154
135155 func getOrder (_orderId) = {
136156 let orderStr = valueOrErrorMessage(getString(this, orderKey(_orderId)), ("Invalid order id: " + toString(_orderId)))
137157 let orderPartList = split(orderStr, ",")
138158 let amm = orderPartList[0]
139159 let trader = orderPartList[1]
140160 let amountIn = valueOrErrorMessage(parseInt(orderPartList[2]), "Invalid amountIn")
141161 let leverage = valueOrErrorMessage(parseInt(orderPartList[3]), "Invalid leverage")
142162 let type = valueOrErrorMessage(parseInt(orderPartList[4]), "Invalid type")
143163 let triggerPrice = valueOrErrorMessage(parseInt(orderPartList[5]), "Invalid triggerPrice")
144164 let paymentUsdn = valueOrErrorMessage(parseInt(orderPartList[6]), "Invalid paymentUsdn")
145165 let side = valueOrErrorMessage(parseInt(orderPartList[7]), "Invalid side")
146166 let refLink = orderPartList[8]
147167 let positionId = valueOrErrorMessage(parseInt(orderPartList[9]), "Invalid positionId")
148168 let limitPrice = valueOrErrorMessage(parseInt(orderPartList[10]), "Invalid limitPrice")
149169 $Tuple11(amm, trader, amountIn, leverage, type, triggerPrice, paymentUsdn, side, refLink, positionId, limitPrice)
150170 }
151171
152172
153173 func getMarketPrice (_amm) = {
154174 let s = invoke(addressFromStringValue(_amm), "computeSpotPrice", nil, nil)
155175 if ((s == s))
156176 then {
157177 let res = match s {
158178 case t: Int =>
159179 t
160180 case _ =>
161181 throw("Invalid computeSpotPrice result")
162182 }
163183 value(res)
164184 }
165185 else throw("Strict value is not equal to itself.")
166186 }
167187
168188
169189 func getFee (_amm,_trader) = {
170190 let s = invoke(addressFromStringValue(_amm), "computeFeeForTraderWithArtifact", [_trader, ""], nil)
171191 if ((s == s))
172192 then {
173193 let res = match s {
174194 case t: (Int, Boolean) =>
175195 t._1
176196 case _ =>
177197 throw("Invalid computeFeeForTraderWithArtifact result")
178198 }
179199 value(res)
180200 }
181201 else throw("Strict value is not equal to itself.")
182202 }
183203
184204
185-func getPositionSize (_amm,_trader) = {
205+func getPositionDirection (_orderSide,_orderType) = if (if ((_orderType == TAKE))
206+ then true
207+ else (_orderType == STOP))
208+ then if ((_orderSide == LONG))
209+ then SHORT
210+ else LONG
211+ else _orderSide
212+
213+
214+func getPositionSize (_amm,_trader,_direction) = {
186215 let amm = addressFromStringValue(_amm)
187- let sizeKey = toCompositeKey(k_positionSize, _trader)
216+ let positionKey = ((_trader + "_") + toString(_direction))
217+ let sizeKey = toCompositeKey(k_positionSize, positionKey)
188218 valueOrElse(getInteger(amm, sizeKey), 0)
189219 }
190220
191221
192-func getPositionId (_amm,_trader) = {
222+func getPositionId (_amm,_trader,_direction) = {
193223 let amm = addressFromStringValue(_amm)
194- let seqKey = toCompositeKey(k_positionSequence, _trader)
224+ let positionKey = ((_trader + "_") + toString(_direction))
225+ let seqKey = toCompositeKey(k_positionSequence, positionKey)
195226 valueOrElse(getInteger(amm, seqKey), 0)
196227 }
197228
198229
199230 func getSpread (_price) = muld(_price, SPREAD_LIMIT)
200231
201232
202233 func saveOrder (_orderId,_amm,_trader,_amountIn,_leverage,_type,_triggerPrice,_paymentUsdn,_side,_refLink,_positionId,_limitPrice) = {
203234 let orderStr = makeString([_amm, _trader, toString(_amountIn), toString(_leverage), toString(_type), toString(_triggerPrice), toString(_paymentUsdn), toString(_side), _refLink, toString(_positionId), toString(_limitPrice)], ",")
204235 [StringEntry(orderKey(_orderId), orderStr)]
205236 }
206237
207238
208-func addRemoveOrderId (_orderId,_amm,_trader,_add) = {
209- let orderIds = traderAmmOrdersIds(_amm, _trader)
210- let orderIdsNew = if (_add)
211- then (orderIds :+ toString(_orderId))
212- else removeByIndex(orderIds, valueOrErrorMessage(indexOf(orderIds, toString(_orderId)), ("No order with id: " + toString(_orderId))))
213- let orderIdsNewStr = makeString(orderIdsNew, ",")
214-[StringEntry(traderOrderIdsKey(_amm, _trader), orderIdsNewStr)]
239+func saveOrderRequest (_orderId,_amm,_trader,_type,_triggerPrice,_limitPrice) = {
240+ let orderReqStr = makeString([toString(_orderId), _amm, _trader, toString(_type), toString(_triggerPrice), toString(_limitPrice)], ",")
241+[StringEntry(orderRequestKey(_orderId, _type), orderReqStr)]
215242 }
216243
217244
218-func updateTraderOrderCount (_amm,_trader,_count) = [IntegerEntry(traderOrderCountKey(_amm, _trader), _count)]
245+func updateOrderIdStr (_orderIdsNewStr,_amm,_trader) = [StringEntry(traderOrderIdsKey(_amm, _trader), _orderIdsNewStr)]
246+
247+
248+func addRemoveOrderIdList (_orderIds,_orderId,_amm,_trader,_add) = {
249+ let orderIdsNew = if (_add)
250+ then (_orderIds :+ toString(_orderId))
251+ else removeByIndex(_orderIds, valueOrErrorMessage(indexOf(_orderIds, toString(_orderId)), ("No order with id: " + toString(_orderId))))
252+ orderIdsNew
253+ }
254+
255+
256+func addRemoveOrderId (_orderId,_amm,_trader,_add) = {
257+ let orderIds = traderAmmOrdersIds(_amm, _trader)
258+ let orderIdsNew = addRemoveOrderIdList(orderIds, _orderId, _amm, _trader, _add)
259+ let orderIdsNewStr = makeString(orderIdsNew, ",")
260+ updateOrderIdStr(orderIdsNewStr, _amm, _trader)
261+ }
262+
263+
264+func updateTraderOrderCount (_amm,_trader,_count) = if ((0 > _count))
265+ then throw(("Invalid order count: " + toString(_count)))
266+ else [IntegerEntry(traderOrderCountKey(_amm, _trader), _count)]
219267
220268
221269 func updateLastOrderId (_lastOrderId) = [IntegerEntry(k_lastOrderId, _lastOrderId)]
222270
223271
224272 func markExecuteOrder (_orderId) = [BooleanEntry(toCompositeKey(k_executedOrders, toString(_orderId)), true)]
225273
226274
227275 func markCancelOrder (_orderId) = [BooleanEntry(toCompositeKey(k_canceledOrders, toString(_orderId)), true)]
228276
229277
278+func getPositionIds (_amm,_trader) = {
279+ let longPositionSize = getPositionSize(_amm, _trader, LONG)
280+ let currentLongPositionId = if ((longPositionSize != 0))
281+ then getPositionId(_amm, _trader, LONG)
282+ else 0
283+ let shortPositionSize = getPositionSize(_amm, _trader, SHORT)
284+ let currentShortPositionId = if ((shortPositionSize != 0))
285+ then getPositionId(_amm, _trader, SHORT)
286+ else 0
287+[currentLongPositionId, currentShortPositionId]
288+ }
289+
290+
230291 @Callable(i)
231292 func cleanUpStaleOrders (_amm,_trader) = {
232293 let orders = traderAmmOrdersIds(_amm, _trader)
233- let orderCount = getTraderOrderCount(_amm, _trader)
294+ let positionIds = getPositionIds(_amm, _trader)
234295 func cleanUpOne (_acc,_orderId) = {
235296 let orderIdInt = valueOrErrorMessage(parseInt(_orderId), "Invalid order id")
236- let $t083838578 = getOrder(orderIdInt)
237- let _x1 = $t083838578._1
238- let _x2 = $t083838578._2
239- let _x3 = $t083838578._3
240- let _x4 = $t083838578._4
241- let _type = $t083838578._5
242- let _x5 = $t083838578._6
243- let _x6 = $t083838578._7
244- let _x7 = $t083838578._8
245- let _x8 = $t083838578._9
246- let _positionId = $t083838578._10
247- let _x9 = $t083838578._11
248- let positionSize = getPositionSize(_amm, _trader)
249- let currentPositionId = if ((positionSize != 0))
250- then getPositionId(_amm, _trader)
251- else 0
252- if (if (if ((_type == STOP))
297+ let $t01115611351 = getOrder(orderIdInt)
298+ let _x1 = $t01115611351._1
299+ let _x2 = $t01115611351._2
300+ let _x3 = $t01115611351._3
301+ let _x4 = $t01115611351._4
302+ let _type = $t01115611351._5
303+ let _x5 = $t01115611351._6
304+ let _x6 = $t01115611351._7
305+ let _x7 = $t01115611351._8
306+ let _x8 = $t01115611351._9
307+ let _positionId = $t01115611351._10
308+ let _x9 = $t01115611351._11
309+ if (if (if (if ((_type == STOP))
253310 then true
254311 else (_type == TAKE))
255- then (currentPositionId != _positionId)
312+ then (positionIds[0] != _positionId)
313+ else false)
314+ then (positionIds[1] != _positionId)
256315 else false)
257316 then {
258- let change = (markCancelOrder(orderIdInt) ++ addRemoveOrderId(orderIdInt, _amm, _trader, false))
259- $Tuple2((_acc._1 + 1), (_acc._2 ++ change))
317+ let change = markCancelOrder(orderIdInt)
318+ let newOrderList = addRemoveOrderIdList(_acc._1, orderIdInt, _amm, _trader, false)
319+ $Tuple2(newOrderList, (_acc._2 ++ change))
260320 }
261321 else _acc
262322 }
263323
264- let result = {
324+ let $t01170411779 = {
265325 let $l = orders
266326 let $s = size($l)
267- let $acc0 = $Tuple2(0, nil)
327+ let $acc0 = $Tuple2(orders, nil)
268328 func $f0_1 ($a,$i) = if (($i >= $s))
269329 then $a
270330 else cleanUpOne($a, $l[$i])
271331
272332 func $f0_2 ($a,$i) = if (($i >= $s))
273333 then $a
274- else throw("List size exceeds 5")
334+ else throw("List size exceeds 10")
275335
276- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
336+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10)
277337 }
278- (result._2 ++ updateTraderOrderCount(_amm, _trader, (orderCount - result._1)))
338+ let newOrders = $t01170411779._1
339+ let cancelActions = $t01170411779._2
340+ ((cancelActions ++ updateTraderOrderCount(_amm, _trader, size(newOrders))) ++ updateOrderIdStr(makeString(newOrders, ","), _amm, _trader))
279341 }
280342
281343
282344
283345 @Callable(i)
284346 func setContext (_sender) = if ((i.caller != this))
285347 then throw("Only self-call")
286348 else [StringEntry(k_sender, _sender)]
287349
288350
289351
290352 @Callable(i)
291353 func resetContext () = if ((i.caller != this))
292354 then throw("Only self-call")
293355 else [DeleteEntry(k_sender)]
294356
295357
296358
297359 @Callable(i)
298-func initialize (_coordinator) = if (initialized())
299- then throw("Already initialized")
300- else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)]
360+func initialize (_coordinator) = if (if (initialized())
361+ then true
362+ else (i.caller != this))
363+ then throw("Unable to initialize")
364+ else [StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator))), BooleanEntry(k_initialized, true)]
301365
302366
303367
304368 @Callable(i)
305-func createOrder (_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink) = {
369+func createOrder (_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_stopTriggerPrice,_stopLimitPrice,_takeTriggerPrice,_takeLimitPrice) = {
306370 let _trader = toString(i.caller)
307371 let cleanUp = invoke(this, "cleanUpStaleOrders", [_amm, _trader], nil)
308372 if ((cleanUp == cleanUp))
309373 then if ((size(i.payments) > 1))
310374 then throw("Invalid createOrder parameters: invalid payment count")
311375 else {
312- let $t01028710539 = if ((size(i.payments) == 1))
376+ let $t01427514527 = if ((size(i.payments) == 1))
313377 then $Tuple2(toBase58String(valueOrErrorMessage(i.payments[0].assetId, "Invalid asset id")), i.payments[0].amount)
314378 else $Tuple2("", 0)
315- let paymentAssetId = $t01028710539._1
316- let paymentAmount = $t01028710539._2
379+ let paymentAssetId = $t01427514527._1
380+ let paymentAmount = $t01427514527._2
317381 let doCall = invoke(this, "internalCreateOrder", [_trader, _amm, _type, _triggerPrice, _limitPrice, _amountIn, _leverage, _side, _refLink, paymentAssetId, paymentAmount], nil)
318382 if ((doCall == doCall))
319- then nil
383+ then {
384+ let orderId = match doCall {
385+ case t: Int =>
386+ t
387+ case _ =>
388+ throw("Invalid ID of created order")
389+ }
390+ if ((_type == LIMIT))
391+ then {
392+ let makeStop = if ((_stopTriggerPrice > 0))
393+ then {
394+ let doMakeStop = invoke(this, "internalCreateOrderRequest", [_trader, _amm, orderId, STOP, _stopTriggerPrice, _stopLimitPrice], nil)
395+ if ((doMakeStop == doMakeStop))
396+ then nil
397+ else throw("Strict value is not equal to itself.")
398+ }
399+ else nil
400+ let makeTake = if ((_takeTriggerPrice > 0))
401+ then {
402+ let doMakeTake = invoke(this, "internalCreateOrderRequest", [_trader, _amm, orderId, TAKE, _takeTriggerPrice, _takeLimitPrice], nil)
403+ if ((doMakeTake == doMakeTake))
404+ then nil
405+ else throw("Strict value is not equal to itself.")
406+ }
407+ else nil
408+ (makeStop ++ makeTake)
409+ }
410+ else nil
411+ }
320412 else throw("Strict value is not equal to itself.")
321413 }
322414 else throw("Strict value is not equal to itself.")
323415 }
324416
325417
326418
327419 @Callable(i)
328420 func increasePositionWithStopLoss (_amm,_direction,_leverage,_minBaseAssetAmount,_refLink,_stopTriggerPrice,_stopLimitPrice,_takeTriggerPrice,_takeLimitPrice) = {
329421 let _trader = toString(i.caller)
330422 let cleanUp = invoke(this, "cleanUpStaleOrders", [_amm, _trader], nil)
331423 if ((cleanUp == cleanUp))
332424 then if (if (!(initialized()))
333425 then true
334426 else !(isWhitelist(_amm)))
335427 then throw("Invalid increasePositionWithStopLoss parameters")
336428 else {
337- let positionSize = getPositionSize(_amm, _trader)
429+ let positionSize = getPositionSize(_amm, _trader, _direction)
338430 if ((positionSize != 0))
339431 then throw("Invalid increasePositionWithStopLoss parameters: only new position")
340432 else {
341433 let doSetContext = invoke(this, "setContext", [_trader], nil)
342434 if ((doSetContext == doSetContext))
343435 then {
344436 let doClosePosition = invoke(addressFromStringValue(_amm), "increasePosition", [_direction, _leverage, _minBaseAssetAmount, _refLink], i.payments)
345437 if ((doClosePosition == doClosePosition))
346438 then {
347439 let doResetContext = invoke(this, "resetContext", nil, nil)
348440 if ((doResetContext == doResetContext))
349441 then {
350- let openedPositionSize = getPositionSize(_amm, _trader)
442+ let openedPositionSize = getPositionSize(_amm, _trader, _direction)
351443 if ((openedPositionSize == openedPositionSize))
352444 then {
353445 let amountIn = abs(openedPositionSize)
354446 let stopLossSide = if ((0 > openedPositionSize))
355447 then LONG
356448 else SHORT
357449 let doCreateStopOrder = if ((_stopTriggerPrice > 0))
358450 then {
359451 let doCreateStopOrder = invoke(this, "internalCreateOrder", [_trader, _amm, STOP, _stopTriggerPrice, _stopLimitPrice, amountIn, 0, stopLossSide, _refLink, "", 0], nil)
360452 if ((doCreateStopOrder == doCreateStopOrder))
361453 then nil
362454 else throw("Strict value is not equal to itself.")
363455 }
364456 else nil
365457 if ((doCreateStopOrder == doCreateStopOrder))
366458 then {
367459 let doCreateTakeOrder = if ((_takeTriggerPrice > 0))
368460 then {
369461 let doCreateTakeOrder = invoke(this, "internalCreateOrder", [_trader, _amm, TAKE, _takeTriggerPrice, _takeLimitPrice, amountIn, 0, stopLossSide, _refLink, "", 0], nil)
370462 if ((doCreateTakeOrder == doCreateTakeOrder))
371463 then nil
372464 else throw("Strict value is not equal to itself.")
373465 }
374466 else nil
375467 if ((doCreateTakeOrder == doCreateTakeOrder))
376468 then nil
377469 else throw("Strict value is not equal to itself.")
378470 }
379471 else throw("Strict value is not equal to itself.")
380472 }
381473 else throw("Strict value is not equal to itself.")
382474 }
383475 else throw("Strict value is not equal to itself.")
384476 }
385477 else throw("Strict value is not equal to itself.")
386478 }
387479 else throw("Strict value is not equal to itself.")
388480 }
389481 }
390482 else throw("Strict value is not equal to itself.")
391483 }
392484
393485
394486
395487 @Callable(i)
396-func internalCreateOrder (_trader,_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_paymentAssetId,_paymentAmount) = if (if (if (if (if (if (if (if (if (!(initialized()))
488+func internalMarkOrderExecuted (_amm,_trader,_orderId) = if (if (if (!(initialized()))
489+ then true
490+ else !(isWhitelist(_amm)))
491+ then true
492+ else !((i.caller == this)))
493+ then throw("Invalid internalMarkOrderExecuted parameters")
494+ else {
495+ let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) - 1)
496+ ((updateTraderOrderCount(_amm, _trader, newTraderOrderCount) ++ addRemoveOrderId(_orderId, _amm, _trader, false)) ++ markExecuteOrder(_orderId))
497+ }
498+
499+
500+
501+@Callable(i)
502+func internalCreateOrderRequest (_trader,_amm,_orderId,_type,_triggerPrice,_limitPrice) = if (if (if (if (if (!(initialized()))
397503 then true
398504 else !(isWhitelist(_amm)))
399505 then true
400506 else (0 >= _triggerPrice))
401507 then true
402508 else (0 > _limitPrice))
403509 then true
404- else (0 >= _amountIn))
405- then true
406- else (0 > _leverage))
407- then true
408- else !(if ((_side == LONG))
510+ else !((i.caller == this)))
511+ then throw("Invalid internalCreateOrderRequest parameters")
512+ else saveOrderRequest(_orderId, _amm, _trader, _type, _triggerPrice, _limitPrice)
513+
514+
515+
516+@Callable(i)
517+func internalCreateOrder (_trader,_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_paymentAssetId,_paymentAmount) = {
518+ let x1 = toString(!(initialized()))
519+ let x2 = toString(!(isWhitelist(_amm)))
520+ let x3 = toString((0 >= _triggerPrice))
521+ let x4 = toString((0 > _limitPrice))
522+ let x5 = toString((0 >= _amountIn))
523+ let x6 = toString((0 > _leverage))
524+ let x7 = toString(!(if ((_side == LONG))
409525 then true
410526 else (_side == SHORT)))
411- then true
412- else !(if (if ((_type == STOP))
527+ let x8 = toString(!(if (if ((_type == STOP))
413528 then true
414529 else (_type == TAKE))
415530 then true
416531 else (_type == LIMIT)))
417- then true
418- else !((i.caller == this)))
419- then throw("Invalid createOrder parameters")
420- else {
421- let orderId = (currentOrderId() + 1)
422- let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) + 1)
423- let positionSize = getPositionSize(_amm, _trader)
424- let _direction = if (if (if ((positionSize == 0))
532+ let x9 = toString(!((i.caller == this)))
533+ let all = makeString([x1, x2, x3, x4, x5, x6, x7, x8, x9], ",")
534+ if (if (if (if (if (if (if (if (if (!(initialized()))
535+ then true
536+ else !(isWhitelist(_amm)))
537+ then true
538+ else (0 >= _triggerPrice))
539+ then true
540+ else (0 > _limitPrice))
541+ then true
542+ else (0 >= _amountIn))
543+ then true
544+ else (0 > _leverage))
545+ then true
546+ else !(if ((_side == LONG))
425547 then true
426- else if ((positionSize > 0))
427- then (_side == LONG)
548+ else (_side == SHORT)))
549+ then true
550+ else !(if (if ((_type == STOP))
551+ then true
552+ else (_type == TAKE))
553+ then true
554+ else (_type == LIMIT)))
555+ then true
556+ else !((i.caller == this)))
557+ then throw(("Invalid internalCreateOrder parameters " + all))
558+ else {
559+ let orderId = (currentOrderId() + 1)
560+ let positionDirection = getPositionDirection(_side, _type)
561+ let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) + 1)
562+ let positionSize = getPositionSize(_amm, _trader, positionDirection)
563+ let _direction = if (if (if ((positionSize == 0))
564+ then true
565+ else if ((positionSize > 0))
566+ then (_side == LONG)
567+ else false)
568+ then true
569+ else if ((0 > positionSize))
570+ then (_side == SHORT)
571+ else false)
572+ then INCREASE
573+ else DECREASE
574+ if (if ((positionSize == 0))
575+ then if ((_type == STOP))
576+ then true
577+ else (_type == TAKE)
428578 else false)
429- then true
430- else if ((0 > positionSize))
431- then (_side == SHORT)
432- else false)
433- then INCREASE
434- else DECREASE
435- if (if ((positionSize == 0))
436- then if ((_type == STOP))
437- then true
438- else (_type == TAKE)
439- else false)
440- then throw("Can not create STOP/TAKE order: no position")
441- else {
442- let usdnPayment = if ((_direction == INCREASE))
443- then if (if ((_paymentAssetId != toBase58String(quoteAsset())))
444- then true
445- else (_paymentAmount != _amountIn))
446- then throw("Invalid createLimitOrder parameters: invalid payment")
447- else {
448- let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _paymentAmount)])
449- if ((stake == stake))
450- then _paymentAmount
451- else throw("Strict value is not equal to itself.")
579+ then throw("Can not create STOP/TAKE order: no position")
580+ else {
581+ let usdnPayment = if ((_direction == INCREASE))
582+ then if (if ((_paymentAssetId != toBase58String(quoteAsset())))
583+ then true
584+ else (_paymentAmount != _amountIn))
585+ then throw("Invalid createLimitOrder parameters: invalid payment")
586+ else {
587+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _paymentAmount)])
588+ if ((stake == stake))
589+ then _paymentAmount
590+ else throw("Strict value is not equal to itself.")
591+ }
592+ else 0
593+ if ((usdnPayment == usdnPayment))
594+ then {
595+ let positionId = if ((positionSize != 0))
596+ then getPositionId(_amm, _trader, positionDirection)
597+ else 0
598+ if (if (if ((_type == STOP))
599+ then true
600+ else (_type == TAKE))
601+ then (positionId == 0)
602+ else false)
603+ then throw("STOP and TAKE order should be assigned to position with id != 0")
604+ else if ((newTraderOrderCount > MAX_TRADER_ORDERS_PER_AMM))
605+ then throw("Invalid createLimitOrder parameters: order count")
606+ else {
607+ let changeSet = (((saveOrder(orderId, _amm, _trader, _amountIn, _leverage, _type, _triggerPrice, usdnPayment, _side, _refLink, positionId, _limitPrice) ++ addRemoveOrderId(orderId, _amm, _trader, true)) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ updateLastOrderId(orderId))
608+ $Tuple2(changeSet, orderId)
609+ }
452610 }
453- else 0
454- if ((usdnPayment == usdnPayment))
455- then {
456- let positionId = if ((positionSize != 0))
457- then getPositionId(_amm, _trader)
458- else 0
459- if ((newTraderOrderCount > MAX_TRADER_ORDERS_PER_AMM))
460- then throw("Invalid createLimitOrder parameters: order count")
461- else (((saveOrder(orderId, _amm, _trader, _amountIn, _leverage, _type, _triggerPrice, usdnPayment, _side, _refLink, positionId, _limitPrice) ++ addRemoveOrderId(orderId, _amm, _trader, true)) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ updateLastOrderId(orderId))
462- }
463- else throw("Strict value is not equal to itself.")
464- }
465- }
611+ else throw("Strict value is not equal to itself.")
612+ }
613+ }
614+ }
466615
467616
468617
469618 @Callable(i)
470619 func cancelOrder (_orderId) = {
471- let $t01590816127 = getOrder(_orderId)
472- let _amm = $t01590816127._1
473- let _trader = $t01590816127._2
474- let _amountIn = $t01590816127._3
475- let _leverage = $t01590816127._4
476- let _type = $t01590816127._5
477- let _triggerPrice = $t01590816127._6
478- let _amountUsdn = $t01590816127._7
479- let _side = $t01590816127._8
480- let _refLink = $t01590816127._9
481- let _positionId = $t01590816127._10
482- let _limitPrice = $t01590816127._11
620+ let $t02378624005 = getOrder(_orderId)
621+ let _amm = $t02378624005._1
622+ let _trader = $t02378624005._2
623+ let _amountIn = $t02378624005._3
624+ let _leverage = $t02378624005._4
625+ let _type = $t02378624005._5
626+ let _triggerPrice = $t02378624005._6
627+ let _amountUsdn = $t02378624005._7
628+ let _side = $t02378624005._8
629+ let _refLink = $t02378624005._9
630+ let _positionId = $t02378624005._10
631+ let _limitPrice = $t02378624005._11
483632 if (if (if (!(initialized()))
484633 then true
485634 else !(isValid(_orderId)))
486635 then true
487636 else !((toString(i.caller) == _trader)))
488637 then throw("Invalid cancelOrder parameters")
489638 else {
490639 let cleanUp = invoke(this, "cleanUpStaleOrders", [_amm, _trader], nil)
491640 if ((cleanUp == cleanUp))
492641 then {
493642 let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) - 1)
494643 let withdraw = if ((_amountUsdn > 0))
495644 then {
496645 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amountUsdn], nil)
497646 if ((unstake == unstake))
498647 then nil
499648 else throw("Strict value is not equal to itself.")
500649 }
501650 else nil
502651 if ((withdraw == withdraw))
503652 then (((markCancelOrder(_orderId) ++ addRemoveOrderId(_orderId, _amm, _trader, false)) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ (if ((_amountUsdn > 0))
504653 then [ScriptTransfer(i.caller, _amountUsdn, quoteAsset())]
505654 else nil))
506655 else throw("Strict value is not equal to itself.")
507656 }
508657 else throw("Strict value is not equal to itself.")
509658 }
510659 }
511660
512661
513662
514663 @Callable(i)
515664 func executeOrder (_orderId) = {
516- let $t01709817317 = getOrder(_orderId)
517- let _amm = $t01709817317._1
518- let _trader = $t01709817317._2
519- let _amountIn = $t01709817317._3
520- let _leverage = $t01709817317._4
521- let _type = $t01709817317._5
522- let _triggerPrice = $t01709817317._6
523- let _amountUsdn = $t01709817317._7
524- let _side = $t01709817317._8
525- let _refLink = $t01709817317._9
526- let _positionId = $t01709817317._10
527- let _limitPrice = $t01709817317._11
665+ let $t02520325422 = getOrder(_orderId)
666+ let _amm = $t02520325422._1
667+ let _trader = $t02520325422._2
668+ let _amountIn = $t02520325422._3
669+ let _leverage = $t02520325422._4
670+ let _type = $t02520325422._5
671+ let _triggerPrice = $t02520325422._6
672+ let _amountUsdn = $t02520325422._7
673+ let _side = $t02520325422._8
674+ let _refLink = $t02520325422._9
675+ let _positionId = $t02520325422._10
676+ let _limitPrice = $t02520325422._11
528677 let cleanUp = invoke(this, "cleanUpStaleOrders", [_amm, _trader], nil)
529678 if ((cleanUp == cleanUp))
530- then if (if (!(initialized()))
531- then true
532- else !(isValid(_orderId)))
533- then throw("Invalid executeOrder parameters")
534- else {
535- let positionSize = getPositionSize(_amm, _trader)
536- let currentPositionId = if ((positionSize != 0))
537- then getPositionId(_amm, _trader)
538- else 0
539- let $t01772121563 = if ((_type == STOP))
540- then {
541- let _positionDirection = if ((positionSize > 0))
542- then LONG
543- else if ((0 > positionSize))
544- then SHORT
545- else throw("Can not execute STOP order: no open position")
546- let marketPrice = getMarketPrice(_amm)
547- let isExecutable = if ((_side == _positionDirection))
548- then throw("Can not execute STOP order: reduce only")
549- else if ((currentPositionId != _positionId))
550- then throw("Can not execute STOP order: position closed")
551- else if ((_positionDirection == LONG))
552- then (_triggerPrice >= marketPrice)
553- else (marketPrice >= _triggerPrice)
554- if (isExecutable)
555- then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), muld(_limitPrice, abs(positionSize)), false], nil)
556- else throw("Can not execute STOP order: triggerPrice mismatch")
557- }
558- else if ((_type == TAKE))
679+ then {
680+ let positionDirection = getPositionDirection(_side, _type)
681+ if (if (!(initialized()))
682+ then true
683+ else !(isValid(_orderId)))
684+ then throw("Invalid executeOrder parameters")
685+ else {
686+ let positionSize = getPositionSize(_amm, _trader, positionDirection)
687+ if ((positionSize == positionSize))
559688 then {
560- let _positionDirection = if ((positionSize > 0))
561- then LONG
562- else if ((0 > positionSize))
563- then SHORT
564- else throw("Can not execute STOP order: no open position")
565- let marketPrice = getMarketPrice(_amm)
566- let isExecutable = if ((_side == _positionDirection))
567- then throw("Can not execute TAKE order: reduce only")
568- else if ((currentPositionId != _positionId))
569- then throw(((("Can not execute TAKE order: position closed " + toString(currentPositionId)) + "!=") + toString(_positionId)))
570- else if ((_positionDirection == LONG))
571- then (marketPrice >= _triggerPrice)
572- else (_triggerPrice >= marketPrice)
573- if (isExecutable)
574- then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), muld(_limitPrice, abs(positionSize)), false], nil)
575- else throw("Can not execute TAKE order: triggerPrice mismatch")
576- }
577- else if ((_type == LIMIT))
578- then {
579- let marketPrice = getMarketPrice(_amm)
580- let spread = if ((_limitPrice == 0))
581- then getSpread(_triggerPrice)
582- else abs((_triggerPrice - _limitPrice))
583- let isExecutable = if ((marketPrice >= (_triggerPrice - spread)))
584- then ((_triggerPrice + spread) >= marketPrice)
585- else false
586- if (isExecutable)
689+ let currentPositionId = if ((positionSize != 0))
690+ then getPositionId(_amm, _trader, positionDirection)
691+ else 0
692+ let $t02592929307 = if ((_type == STOP))
693+ then {
694+ let _positionDirection = if ((positionSize > 0))
695+ then LONG
696+ else if ((0 > positionSize))
697+ then SHORT
698+ else throw("Can not execute STOP order: no open position")
699+ let marketPrice = getMarketPrice(_amm)
700+ let isExecutable = if ((_side == _positionDirection))
701+ then throw("Can not execute STOP order: reduce only")
702+ else if ((currentPositionId != _positionId))
703+ then throw("Can not execute STOP order: position closed")
704+ else if ((_positionDirection == LONG))
705+ then (_triggerPrice >= marketPrice)
706+ else (marketPrice >= _triggerPrice)
707+ if (isExecutable)
708+ then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), positionDirection, muld(_limitPrice, abs(positionSize)), false], nil)
709+ else throw("Can not execute STOP order: triggerPrice mismatch")
710+ }
711+ else if ((_type == TAKE))
587712 then {
588713 let _positionDirection = if ((positionSize > 0))
589714 then LONG
590715 else if ((0 > positionSize))
591716 then SHORT
592- else -1
593- let direction = if ((positionSize == 0))
594- then INCREASE
595- else if ((_positionDirection == _side))
596- then INCREASE
597- else DECREASE
598- if ((direction == INCREASE))
599- then {
600- let amountInWithFee = (_amountUsdn - muld(_amountUsdn, getFee(_amm, _trader)))
601- $Tuple3("increasePosition", [_side, _leverage, if ((_limitPrice == 0))
602- then 0
603- else divd(amountInWithFee, _limitPrice), _refLink], [AttachedPayment(quoteAsset(), _amountUsdn)])
604- }
605- else $Tuple3("closePosition", [_amountIn, muld(_amountIn, _limitPrice), false], nil)
717+ else throw("Can not execute STOP order: no open position")
718+ let marketPrice = getMarketPrice(_amm)
719+ let isExecutable = if ((_side == _positionDirection))
720+ then throw("Can not execute TAKE order: reduce only")
721+ else if ((currentPositionId != _positionId))
722+ then throw(((("Can not execute TAKE order: position closed " + toString(currentPositionId)) + "!=") + toString(_positionId)))
723+ else if ((_positionDirection == LONG))
724+ then (marketPrice >= _triggerPrice)
725+ else (_triggerPrice >= marketPrice)
726+ if (isExecutable)
727+ then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), positionDirection, muld(_limitPrice, abs(positionSize)), false], nil)
728+ else throw("Can not execute TAKE order: triggerPrice mismatch")
606729 }
607- else throw("Can not execute LIMIT order: triggerPrice mismatch")
608- }
609- else throw(("Invalid order type: " + toString(_type)))
610- let method = $t01772121563._1
611- let args = $t01772121563._2
612- let payments = $t01772121563._3
613- let withdraw = if ((size(payments) == 1))
614- then {
615- let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), payments[0].amount], nil)
616- if ((unstake == unstake))
617- then nil
618- else throw("Strict value is not equal to itself.")
619- }
620- else nil
621- if ((withdraw == withdraw))
622- then {
623- let doSetContext = invoke(this, "setContext", [_trader], nil)
624- if ((doSetContext == doSetContext))
625- then {
626- let doClosePosition = invoke(addressFromStringValue(_amm), method, args, payments)
627- if ((doClosePosition == doClosePosition))
628- then {
629- let doResetContext = invoke(this, "resetContext", nil, nil)
630- if ((doResetContext == doResetContext))
631- then {
632- let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) - 1)
633- ((updateTraderOrderCount(_amm, _trader, newTraderOrderCount) ++ addRemoveOrderId(_orderId, _amm, _trader, false)) ++ markExecuteOrder(_orderId))
634- }
635- else throw("Strict value is not equal to itself.")
636- }
637- else throw("Strict value is not equal to itself.")
638- }
639- else throw("Strict value is not equal to itself.")
640- }
641- else throw("Strict value is not equal to itself.")
642- }
730+ else if ((_type == LIMIT))
731+ then {
732+ let marketPrice = getMarketPrice(_amm)
733+ let spread = if ((_limitPrice == 0))
734+ then getSpread(_triggerPrice)
735+ else abs((_triggerPrice - _limitPrice))
736+ let isExecutable = if ((marketPrice >= (_triggerPrice - spread)))
737+ then ((_triggerPrice + spread) >= marketPrice)
738+ else false
739+ if (isExecutable)
740+ then {
741+ let amountInWithFee = (_amountUsdn - muld(_amountUsdn, getFee(_amm, _trader)))
742+ $Tuple3("increasePosition", [_side, _leverage, if ((_limitPrice == 0))
743+ then 0
744+ else divd(amountInWithFee, _limitPrice), _refLink], [AttachedPayment(quoteAsset(), _amountUsdn)])
745+ }
746+ else throw("Can not execute LIMIT order: triggerPrice mismatch")
747+ }
748+ else throw(("Invalid order type: " + toString(_type)))
749+ let method = $t02592929307._1
750+ let args = $t02592929307._2
751+ let payments = $t02592929307._3
752+ let withdraw = if ((size(payments) == 1))
753+ then {
754+ let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), payments[0].amount], nil)
755+ if ((unstake == unstake))
756+ then nil
757+ else throw("Strict value is not equal to itself.")
758+ }
759+ else nil
760+ if ((withdraw == withdraw))
761+ then {
762+ let doSetContext = invoke(this, "setContext", [_trader], nil)
763+ if ((doSetContext == doSetContext))
764+ then {
765+ let doClosePosition = invoke(addressFromStringValue(_amm), method, args, payments)
766+ if ((doClosePosition == doClosePosition))
767+ then {
768+ let doResetContext = invoke(this, "resetContext", nil, nil)
769+ if ((doResetContext == doResetContext))
770+ then {
771+ let executeOrderRequest = if ((_type == LIMIT))
772+ then {
773+ let newPositionSize = getPositionSize(_amm, _trader, positionDirection)
774+ if ((newPositionSize == newPositionSize))
775+ then {
776+ let newPositionId = getPositionId(_amm, _trader, positionDirection)
777+ if ((newPositionId == newPositionId))
778+ then {
779+ let positionSizeDelta = (newPositionSize - positionSize)
780+ let closeOrderSide = if ((newPositionSize > 0))
781+ then SHORT
782+ else LONG
783+ let makeTakeOrder = if (haveOrderRequest(_orderId, TAKE))
784+ then {
785+ let $t03026930468 = getOrderRequest(_orderId, TAKE)
786+ let newOrderId = $t03026930468._1
787+ let newAmm = $t03026930468._2
788+ let newTrader = $t03026930468._3
789+ let newType = $t03026930468._4
790+ let newTriggerPrice = $t03026930468._5
791+ let newLimitPrice = $t03026930468._6
792+ let doCall = invoke(this, "internalCreateOrder", [newTrader, newAmm, newType, newTriggerPrice, newLimitPrice, positionSizeDelta, 0, closeOrderSide, "", "", 0], nil)
793+ if ((doCall == doCall))
794+ then nil
795+ else throw("Strict value is not equal to itself.")
796+ }
797+ else nil
798+ if ((makeTakeOrder == makeTakeOrder))
799+ then {
800+ let makeStopOrder = if (haveOrderRequest(_orderId, STOP))
801+ then {
802+ let $t03102431223 = getOrderRequest(_orderId, STOP)
803+ let newOrderId = $t03102431223._1
804+ let newAmm = $t03102431223._2
805+ let newTrader = $t03102431223._3
806+ let newType = $t03102431223._4
807+ let newTriggerPrice = $t03102431223._5
808+ let newLimitPrice = $t03102431223._6
809+ let doCall = invoke(this, "internalCreateOrder", [newTrader, newAmm, newType, newTriggerPrice, newLimitPrice, positionSizeDelta, 0, closeOrderSide, "", "", 0], nil)
810+ if ((doCall == doCall))
811+ then nil
812+ else throw("Strict value is not equal to itself.")
813+ }
814+ else nil
815+ if ((makeStopOrder == makeStopOrder))
816+ then (makeTakeOrder ++ makeStopOrder)
817+ else throw("Strict value is not equal to itself.")
818+ }
819+ else throw("Strict value is not equal to itself.")
820+ }
821+ else throw("Strict value is not equal to itself.")
822+ }
823+ else throw("Strict value is not equal to itself.")
824+ }
825+ else nil
826+ if ((executeOrderRequest == executeOrderRequest))
827+ then {
828+ let doMarkOrderExecuted = invoke(this, "internalMarkOrderExecuted", [_amm, _trader, _orderId], nil)
829+ if ((doMarkOrderExecuted == doMarkOrderExecuted))
830+ then nil
831+ else throw("Strict value is not equal to itself.")
832+ }
833+ else throw("Strict value is not equal to itself.")
834+ }
835+ else throw("Strict value is not equal to itself.")
836+ }
837+ else throw("Strict value is not equal to itself.")
838+ }
839+ else throw("Strict value is not equal to itself.")
840+ }
841+ else throw("Strict value is not equal to itself.")
842+ }
843+ else throw("Strict value is not equal to itself.")
844+ }
845+ }
643846 else throw("Strict value is not equal to itself.")
644847 }
645848
646849
647850
648851 @Callable(i)
649852 func view_canExecuteOrder (_orderId) = {
650853 let s = invoke(this, "executeOrder", [_orderId], nil)
651854 if ((s == s))
652855 then throw("Success")
653856 else throw("Strict value is not equal to itself.")
654857 }
655858
656859
657860 @Verifier(tx)
658-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
861+func verify () = {
862+ let coordinatorStr = getString(this, k_coordinatorAddress)
863+ if (isDefined(coordinatorStr))
864+ then {
865+ let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
866+ if (isDefined(admin))
867+ then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
868+ else throw("unable to verify: admin not set in coordinator")
869+ }
870+ else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
871+ }
659872

github/deemru/w8io/026f985 
141.51 ms