tx · 9HEMv6NzTacEfbxV2S5MSzaPbbvk6qzzx3MmD4UrEe71

3N9kbR6BQEQV7pwBfDFzprJtNofgi6fSJ6Y:  -0.03700000 Waves

2022.12.15 13:01 [2361278] smart account 3N9kbR6BQEQV7pwBfDFzprJtNofgi6fSJ6Y > SELF 0.00000000 Waves

{ "type": 13, "id": "9HEMv6NzTacEfbxV2S5MSzaPbbvk6qzzx3MmD4UrEe71", "fee": 3700000, "feeAssetId": null, "timestamp": 1671098527415, "version": 2, "chainId": 84, "sender": "3N9kbR6BQEQV7pwBfDFzprJtNofgi6fSJ6Y", "senderPublicKey": "EajGg1J8duApPELWPw9gVkPwAKFC9hujhvCcne4FunUa", "proofs": [ "4woavukbViTpzU8PK6tW6MT5mNQv1UkoQAzd8dzpEBcYn7n93YXf7B67W5Vf3mU1EK6F53QUhHxfdwU7tHmYCWHp" ], "script": "base64:BgJFCAISAwoBCBIAEgMKAQgSCgoICAEBAQEBAQgSCwoJCAEBAQgBAQEBEg0KCwgIAQEBAQEBCAgBEgMKAQESAwoBARIDCgEBNwAUa19jb29yZGluYXRvckFkZHJlc3MCFGtfY29vcmRpbmF0b3JBZGRyZXNzABJrX2FkbWluX3B1YmxpY19rZXkCEmtfYWRtaW5fcHVibGljX2tleQANa19xdW90ZV9hc3NldAINa19xdW90ZV9hc3NldAAFa19hbW0CBWtfYW1tABFrX21hbmFnZXJfYWRkcmVzcwIRa19tYW5hZ2VyX2FkZHJlc3MAEmtfcG9zaXRpb25TZXF1ZW5jZQISa19wb3NpdGlvblNlcXVlbmNlAA5rX3Bvc2l0aW9uU2l6ZQIOa19wb3NpdGlvblNpemUABWtfZmVlAgVrX2ZlZQAQa19leGVjdXRlZE9yZGVycwIQa19leGVjdXRlZE9yZGVycwAQa19jYW5jZWxlZE9yZGVycwIQa19jYW5jZWxlZE9yZGVycwAHa19vcmRlcgIHa19vcmRlcgANa19sYXN0T3JkZXJJZAINa19sYXN0T3JkZXJJZAAQa190cmFkZXJPcmRlckNud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kb1NldENvbnRleHQED2RvQ2xvc2VQb3NpdGlvbgkA/AcECQERQGV4dHJOYXRpdmUoMTA2MikBBQRfYW1tBQZtZXRob2QFBGFyZ3MFCHBheW1lbnRzAwkAAAIFD2RvQ2xvc2VQb3NpdGlvbgUPZG9DbG9zZVBvc2l0aW9uBA5kb1Jlc2V0Q29udGV4dAkA/AcEBQR0aGlzAgxyZXNldENvbnRleHQFA25pbAUDbmlsAwkAAAIFDmRvUmVzZXRDb250ZXh0BQ5kb1Jlc2V0Q29udGV4dAkBEG1hcmtFeGVjdXRlT3JkZXIBBQhfb3JkZXJJZAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpARR2aWV3X2NhbkV4ZWN1dGVPcmRlcgEIX29yZGVySWQEAXMJAPwHBAUEdGhpcwIMZXhlY3V0ZU9yZGVyCQDMCAIFCF9vcmRlcklkBQNuaWwFA25pbAMJAAACBQFzBQFzCQACAQIHU3VjY2VzcwkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAJAQ5hZG1pblB1YmxpY0tleQDHKKTM", "height": 2361278, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 25o3gzaMe49eZgUyoMEdqps81Pfptxej6NQZU6mHLDJc Next: Fj8LyeAxMh3HyxXSCJcfdzuxbkP34QExpoCxpuGYvYrU Diff:
OldNewDifferences
242242
243243
244244 @Callable(i)
245+func increasePositionWithStopLoss (_amm,_direction,_leverage,_minBaseAssetAmount,_refLink,_stopTriggerPrice,_stopLimitPrice,_takeTriggerPrice,_takeLimitPrice) = {
246+ let _trader = toString(i.caller)
247+ if (if (!(initialized()))
248+ then true
249+ else !(isWhitelist(_amm)))
250+ then throw("Invalid increasePositionWithStopLoss parameters")
251+ else {
252+ let positionSize = getPositionSize(_amm, _trader)
253+ if ((positionSize != 0))
254+ then throw("Invalid increasePositionWithStopLoss parameters: only new position")
255+ else {
256+ let doSetContext = invoke(this, "setContext", [_trader], nil)
257+ if ((doSetContext == doSetContext))
258+ then {
259+ let doClosePosition = invoke(addressFromStringValue(_amm), "increasePosition", [_direction, _leverage, _minBaseAssetAmount, _refLink], i.payments)
260+ if ((doClosePosition == doClosePosition))
261+ then {
262+ let doResetContext = invoke(this, "resetContext", nil, nil)
263+ if ((doResetContext == doResetContext))
264+ then {
265+ let openedPositionSize = getPositionSize(_amm, _trader)
266+ if ((openedPositionSize == openedPositionSize))
267+ then {
268+ let amountIn = abs(openedPositionSize)
269+ let stopLossSide = if ((0 > openedPositionSize))
270+ then LONG
271+ else SHORT
272+ let doCreateStopOrder = if ((_stopTriggerPrice > 0))
273+ then {
274+ let doCreateStopOrder = invoke(this, "internalCreateOrder", [_trader, _amm, STOP, _stopTriggerPrice, _stopLimitPrice, amountIn, 0, stopLossSide, _refLink, "", 0], nil)
275+ if ((doCreateStopOrder == doCreateStopOrder))
276+ then nil
277+ else throw("Strict value is not equal to itself.")
278+ }
279+ else nil
280+ if ((doCreateStopOrder == doCreateStopOrder))
281+ then {
282+ let doCreateTakeOrder = if ((_takeTriggerPrice > 0))
283+ then {
284+ let doCreateTakeOrder = invoke(this, "internalCreateOrder", [_trader, _amm, TAKE, _takeTriggerPrice, _takeLimitPrice, amountIn, 0, stopLossSide, _refLink, "", 0], nil)
285+ if ((doCreateTakeOrder == doCreateTakeOrder))
286+ then nil
287+ else throw("Strict value is not equal to itself.")
288+ }
289+ else nil
290+ if ((doCreateTakeOrder == doCreateTakeOrder))
291+ then nil
292+ else throw("Strict value is not equal to itself.")
293+ }
294+ else throw("Strict value is not equal to itself.")
295+ }
296+ else throw("Strict value is not equal to itself.")
297+ }
298+ else throw("Strict value is not equal to itself.")
299+ }
300+ else throw("Strict value is not equal to itself.")
301+ }
302+ else throw("Strict value is not equal to itself.")
303+ }
304+ }
305+ }
306+
307+
308+
309+@Callable(i)
245310 func internalCreateOrder (_trader,_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_paymentAssetId,_paymentAmount) = if (if (if (if (if (if (if (if (if (!(initialized()))
246311 then true
247312 else !(isWhitelist(_amm)))
317382
318383 @Callable(i)
319384 func cancelOrder (_orderId) = {
320- let $t01120511424 = getOrder(_orderId)
321- let _amm = $t01120511424._1
322- let _trader = $t01120511424._2
323- let _amountIn = $t01120511424._3
324- let _leverage = $t01120511424._4
325- let _type = $t01120511424._5
326- let _triggerPrice = $t01120511424._6
327- let _amountUsdn = $t01120511424._7
328- let _side = $t01120511424._8
329- let _refLink = $t01120511424._9
330- let _positionId = $t01120511424._10
331- let _limitPrice = $t01120511424._11
385+ let $t01350813727 = getOrder(_orderId)
386+ let _amm = $t01350813727._1
387+ let _trader = $t01350813727._2
388+ let _amountIn = $t01350813727._3
389+ let _leverage = $t01350813727._4
390+ let _type = $t01350813727._5
391+ let _triggerPrice = $t01350813727._6
392+ let _amountUsdn = $t01350813727._7
393+ let _side = $t01350813727._8
394+ let _refLink = $t01350813727._9
395+ let _positionId = $t01350813727._10
396+ let _limitPrice = $t01350813727._11
332397 if (if (if (!(initialized()))
333398 then true
334399 else !(isValid(_orderId)))
357422
358423 @Callable(i)
359424 func executeOrder (_orderId) = {
360- let $t01225712476 = getOrder(_orderId)
361- let _amm = $t01225712476._1
362- let _trader = $t01225712476._2
363- let _amountIn = $t01225712476._3
364- let _leverage = $t01225712476._4
365- let _type = $t01225712476._5
366- let _triggerPrice = $t01225712476._6
367- let _amountUsdn = $t01225712476._7
368- let _side = $t01225712476._8
369- let _refLink = $t01225712476._9
370- let _positionId = $t01225712476._10
371- let _limitPrice = $t01225712476._11
425+ let $t01456014779 = getOrder(_orderId)
426+ let _amm = $t01456014779._1
427+ let _trader = $t01456014779._2
428+ let _amountIn = $t01456014779._3
429+ let _leverage = $t01456014779._4
430+ let _type = $t01456014779._5
431+ let _triggerPrice = $t01456014779._6
432+ let _amountUsdn = $t01456014779._7
433+ let _side = $t01456014779._8
434+ let _refLink = $t01456014779._9
435+ let _positionId = $t01456014779._10
436+ let _limitPrice = $t01456014779._11
372437 if (if (!(initialized()))
373438 then true
374439 else !(isValid(_orderId)))
378443 let currentPositionId = if ((positionSize != 0))
379444 then getPositionId(_amm, _trader)
380445 else 0
381- let $t01280216623 = if ((_type == STOP))
446+ let $t01510518926 = if ((_type == STOP))
382447 then {
383448 let _positionDirection = if ((positionSize > 0))
384449 then LONG
449514 else throw("Can not execute LIMIT order: triggerPrice mismatch")
450515 }
451516 else throw(("Invalid order type: " + toString(_type)))
452- let method = $t01280216623._1
453- let args = $t01280216623._2
454- let payments = $t01280216623._3
517+ let method = $t01510518926._1
518+ let args = $t01510518926._2
519+ let payments = $t01510518926._3
455520 let withdraw = if ((size(payments) == 1))
456521 then {
457522 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), payments[0].amount], nil)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_coordinatorAddress = "k_coordinatorAddress"
55
66 let k_admin_public_key = "k_admin_public_key"
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
1818 let k_fee = "k_fee"
1919
2020 let k_executedOrders = "k_executedOrders"
2121
2222 let k_canceledOrders = "k_canceledOrders"
2323
2424 let k_order = "k_order"
2525
2626 let k_lastOrderId = "k_lastOrderId"
2727
2828 let k_traderOrderCnt = "k_traderOrderCnt"
2929
3030 let k_sender = "k_sender"
3131
3232 let k_initialized = "k_initialized"
3333
3434 let STOP = 1
3535
3636 let TAKE = 2
3737
3838 let LIMIT = 3
3939
4040 let LONG = 1
4141
4242 let SHORT = 2
4343
4444 let INCREASE = 1
4545
4646 let DECREASE = 2
4747
4848 let MAX_TRADER_ORDERS_PER_AMM = 5
4949
5050 let TIME = lastBlock.timestamp
5151
5252 let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10))
5353
5454 let SPREAD_LIMIT = (DECIMAL_UNIT / 200)
5555
5656 func abs (_x) = if ((_x > 0))
5757 then _x
5858 else -(_x)
5959
6060
6161 func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
6262
6363
6464 func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
6565
6666
6767 func minv (_x,_y) = if ((_x > _y))
6868 then _y
6969 else _x
7070
7171
7272 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
7373
7474
7575 func executedOrderKey (_orderId) = ((k_executedOrders + "_") + toString(_orderId))
7676
7777
7878 func canceledOrderKey (_orderId) = ((k_canceledOrders + "_") + toString(_orderId))
7979
8080
8181 func orderKey (_orderId) = toCompositeKey(k_order, toString(_orderId))
8282
8383
8484 func traderOrderCountKey (_amm,_trader) = ((((k_traderOrderCnt + "_") + _amm) + "_") + _trader)
8585
8686
8787 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
8888
8989
9090 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
9191
9292
9393 func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set")
9494
9595
9696 func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false)
9797
9898
9999 func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
100100
101101
102102 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
103103
104104
105105 func isValid (_orderId) = if (valueOrElse(getBoolean(this, executedOrderKey(_orderId)), false))
106106 then throw(("Order already executed: " + toString(_orderId)))
107107 else if (valueOrElse(getBoolean(this, canceledOrderKey(_orderId)), false))
108108 then throw(("Order already cancelled: " + toString(_orderId)))
109109 else true
110110
111111
112112 func currentOrderId () = valueOrElse(getInteger(this, k_lastOrderId), 0)
113113
114114
115115 func getTraderOrderCount (_amm,_trader) = {
116116 let key = traderOrderCountKey(_amm, _trader)
117117 valueOrElse(getInteger(this, key), 0)
118118 }
119119
120120
121121 func getOrder (_orderId) = {
122122 let orderStr = valueOrErrorMessage(getString(this, orderKey(_orderId)), ("Invalid order id: " + toString(_orderId)))
123123 let orderPartList = split(orderStr, ",")
124124 let amm = orderPartList[0]
125125 let trader = orderPartList[1]
126126 let amountIn = valueOrErrorMessage(parseInt(orderPartList[2]), "Invalid amountIn")
127127 let leverage = valueOrErrorMessage(parseInt(orderPartList[3]), "Invalid leverage")
128128 let type = valueOrErrorMessage(parseInt(orderPartList[4]), "Invalid type")
129129 let triggerPrice = valueOrErrorMessage(parseInt(orderPartList[5]), "Invalid triggerPrice")
130130 let paymentUsdn = valueOrErrorMessage(parseInt(orderPartList[6]), "Invalid paymentUsdn")
131131 let side = valueOrErrorMessage(parseInt(orderPartList[7]), "Invalid side")
132132 let refLink = orderPartList[8]
133133 let positionId = valueOrErrorMessage(parseInt(orderPartList[9]), "Invalid positionId")
134134 let limitPrice = valueOrErrorMessage(parseInt(orderPartList[10]), "Invalid limitPrice")
135135 $Tuple11(amm, trader, amountIn, leverage, type, triggerPrice, paymentUsdn, side, refLink, positionId, limitPrice)
136136 }
137137
138138
139139 func getMarketPrice (_amm) = {
140140 let s = invoke(addressFromStringValue(_amm), "computeSpotPrice", nil, nil)
141141 if ((s == s))
142142 then {
143143 let res = match s {
144144 case t: Int =>
145145 t
146146 case _ =>
147147 throw("Invalid computeSpotPrice result")
148148 }
149149 value(res)
150150 }
151151 else throw("Strict value is not equal to itself.")
152152 }
153153
154154
155155 func getFee (_amm,_trader) = {
156156 let s = invoke(addressFromStringValue(_amm), "computeFeeForTraderWithArtifact", [_trader, ""], nil)
157157 if ((s == s))
158158 then {
159159 let res = match s {
160160 case t: (Int, Boolean) =>
161161 t._1
162162 case _ =>
163163 throw("Invalid computeFeeForTraderWithArtifact result")
164164 }
165165 value(res)
166166 }
167167 else throw("Strict value is not equal to itself.")
168168 }
169169
170170
171171 func getPositionSize (_amm,_trader) = {
172172 let amm = addressFromStringValue(_amm)
173173 let sizeKey = toCompositeKey(k_positionSize, _trader)
174174 valueOrElse(getInteger(amm, sizeKey), 0)
175175 }
176176
177177
178178 func getPositionId (_amm,_trader) = {
179179 let amm = addressFromStringValue(_amm)
180180 let seqKey = toCompositeKey(k_positionSequence, _trader)
181181 valueOrElse(getInteger(amm, seqKey), 0)
182182 }
183183
184184
185185 func getSpread (_price) = muld(_price, SPREAD_LIMIT)
186186
187187
188188 func saveOrder (_orderId,_amm,_trader,_amountIn,_leverage,_type,_triggerPrice,_paymentUsdn,_side,_refLink,_positionId,_limitPrice) = {
189189 let orderStr = makeString([_amm, _trader, toString(_amountIn), toString(_leverage), toString(_type), toString(_triggerPrice), toString(_paymentUsdn), toString(_side), _refLink, toString(_positionId), toString(_limitPrice)], ",")
190190 [StringEntry(orderKey(_orderId), orderStr)]
191191 }
192192
193193
194194 func updateTraderOrderCount (_amm,_trader,_count) = [IntegerEntry(traderOrderCountKey(_amm, _trader), _count)]
195195
196196
197197 func updateLastOrderId (_lastOrderId) = [IntegerEntry(k_lastOrderId, _lastOrderId)]
198198
199199
200200 func markExecuteOrder (_orderId) = [BooleanEntry(toCompositeKey(k_executedOrders, toString(_orderId)), true)]
201201
202202
203203 func markCancelOrder (_orderId) = [BooleanEntry(toCompositeKey(k_canceledOrders, toString(_orderId)), true)]
204204
205205
206206 @Callable(i)
207207 func setContext (_sender) = if ((i.caller != this))
208208 then throw("Only self-call")
209209 else [StringEntry(k_sender, _sender)]
210210
211211
212212
213213 @Callable(i)
214214 func resetContext () = if ((i.caller != this))
215215 then throw("Only self-call")
216216 else [DeleteEntry(k_sender)]
217217
218218
219219
220220 @Callable(i)
221221 func initialize (_coordinator) = if (initialized())
222222 then throw("Already initialized")
223223 else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)]
224224
225225
226226
227227 @Callable(i)
228228 func createOrder (_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink) = if ((size(i.payments) > 1))
229229 then throw("Invalid createOrder parameters: invalid payment count")
230230 else {
231231 let $t080238275 = if ((size(i.payments) == 1))
232232 then $Tuple2(toBase58String(valueOrErrorMessage(i.payments[0].assetId, "Invalid asset id")), i.payments[0].amount)
233233 else $Tuple2("", 0)
234234 let paymentAssetId = $t080238275._1
235235 let paymentAmount = $t080238275._2
236236 let doCall = invoke(this, "internalCreateOrder", [toString(i.caller), _amm, _type, _triggerPrice, _limitPrice, _amountIn, _leverage, _side, _refLink, paymentAssetId, paymentAmount], nil)
237237 if ((doCall == doCall))
238238 then nil
239239 else throw("Strict value is not equal to itself.")
240240 }
241241
242242
243243
244244 @Callable(i)
245+func increasePositionWithStopLoss (_amm,_direction,_leverage,_minBaseAssetAmount,_refLink,_stopTriggerPrice,_stopLimitPrice,_takeTriggerPrice,_takeLimitPrice) = {
246+ let _trader = toString(i.caller)
247+ if (if (!(initialized()))
248+ then true
249+ else !(isWhitelist(_amm)))
250+ then throw("Invalid increasePositionWithStopLoss parameters")
251+ else {
252+ let positionSize = getPositionSize(_amm, _trader)
253+ if ((positionSize != 0))
254+ then throw("Invalid increasePositionWithStopLoss parameters: only new position")
255+ else {
256+ let doSetContext = invoke(this, "setContext", [_trader], nil)
257+ if ((doSetContext == doSetContext))
258+ then {
259+ let doClosePosition = invoke(addressFromStringValue(_amm), "increasePosition", [_direction, _leverage, _minBaseAssetAmount, _refLink], i.payments)
260+ if ((doClosePosition == doClosePosition))
261+ then {
262+ let doResetContext = invoke(this, "resetContext", nil, nil)
263+ if ((doResetContext == doResetContext))
264+ then {
265+ let openedPositionSize = getPositionSize(_amm, _trader)
266+ if ((openedPositionSize == openedPositionSize))
267+ then {
268+ let amountIn = abs(openedPositionSize)
269+ let stopLossSide = if ((0 > openedPositionSize))
270+ then LONG
271+ else SHORT
272+ let doCreateStopOrder = if ((_stopTriggerPrice > 0))
273+ then {
274+ let doCreateStopOrder = invoke(this, "internalCreateOrder", [_trader, _amm, STOP, _stopTriggerPrice, _stopLimitPrice, amountIn, 0, stopLossSide, _refLink, "", 0], nil)
275+ if ((doCreateStopOrder == doCreateStopOrder))
276+ then nil
277+ else throw("Strict value is not equal to itself.")
278+ }
279+ else nil
280+ if ((doCreateStopOrder == doCreateStopOrder))
281+ then {
282+ let doCreateTakeOrder = if ((_takeTriggerPrice > 0))
283+ then {
284+ let doCreateTakeOrder = invoke(this, "internalCreateOrder", [_trader, _amm, TAKE, _takeTriggerPrice, _takeLimitPrice, amountIn, 0, stopLossSide, _refLink, "", 0], nil)
285+ if ((doCreateTakeOrder == doCreateTakeOrder))
286+ then nil
287+ else throw("Strict value is not equal to itself.")
288+ }
289+ else nil
290+ if ((doCreateTakeOrder == doCreateTakeOrder))
291+ then nil
292+ else throw("Strict value is not equal to itself.")
293+ }
294+ else throw("Strict value is not equal to itself.")
295+ }
296+ else throw("Strict value is not equal to itself.")
297+ }
298+ else throw("Strict value is not equal to itself.")
299+ }
300+ else throw("Strict value is not equal to itself.")
301+ }
302+ else throw("Strict value is not equal to itself.")
303+ }
304+ }
305+ }
306+
307+
308+
309+@Callable(i)
245310 func internalCreateOrder (_trader,_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_paymentAssetId,_paymentAmount) = if (if (if (if (if (if (if (if (if (!(initialized()))
246311 then true
247312 else !(isWhitelist(_amm)))
248313 then true
249314 else (0 >= _triggerPrice))
250315 then true
251316 else (0 > _limitPrice))
252317 then true
253318 else (0 >= _amountIn))
254319 then true
255320 else (0 > _leverage))
256321 then true
257322 else !(if ((_side == LONG))
258323 then true
259324 else (_side == SHORT)))
260325 then true
261326 else !(if (if ((_type == STOP))
262327 then true
263328 else (_type == TAKE))
264329 then true
265330 else (_type == LIMIT)))
266331 then true
267332 else !((i.caller == this)))
268333 then throw("Invalid createOrder parameters")
269334 else {
270335 let orderId = (currentOrderId() + 1)
271336 let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) + 1)
272337 let positionSize = getPositionSize(_amm, _trader)
273338 let _direction = if (if (if ((positionSize == 0))
274339 then true
275340 else if ((positionSize > 0))
276341 then (_side == LONG)
277342 else false)
278343 then true
279344 else if ((0 > positionSize))
280345 then (_side == SHORT)
281346 else false)
282347 then INCREASE
283348 else DECREASE
284349 if (if ((positionSize == 0))
285350 then if ((_type == STOP))
286351 then true
287352 else (_type == TAKE)
288353 else false)
289354 then throw("Can not create STOP/TAKE order: no position")
290355 else {
291356 let usdnPayment = if ((_direction == INCREASE))
292357 then if (if ((_paymentAssetId != toBase58String(quoteAsset())))
293358 then true
294359 else (_paymentAmount != _amountIn))
295360 then throw("Invalid createLimitOrder parameters: invalid payment")
296361 else {
297362 let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _paymentAmount)])
298363 if ((stake == stake))
299364 then _paymentAmount
300365 else throw("Strict value is not equal to itself.")
301366 }
302367 else 0
303368 if ((usdnPayment == usdnPayment))
304369 then {
305370 let positionId = if ((positionSize != 0))
306371 then getPositionId(_amm, _trader)
307372 else 0
308373 if ((newTraderOrderCount > MAX_TRADER_ORDERS_PER_AMM))
309374 then throw("Invalid createLimitOrder parameters: order count")
310375 else ((saveOrder(orderId, _amm, _trader, _amountIn, _leverage, _type, _triggerPrice, usdnPayment, _side, _refLink, positionId, _limitPrice) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ updateLastOrderId(orderId))
311376 }
312377 else throw("Strict value is not equal to itself.")
313378 }
314379 }
315380
316381
317382
318383 @Callable(i)
319384 func cancelOrder (_orderId) = {
320- let $t01120511424 = getOrder(_orderId)
321- let _amm = $t01120511424._1
322- let _trader = $t01120511424._2
323- let _amountIn = $t01120511424._3
324- let _leverage = $t01120511424._4
325- let _type = $t01120511424._5
326- let _triggerPrice = $t01120511424._6
327- let _amountUsdn = $t01120511424._7
328- let _side = $t01120511424._8
329- let _refLink = $t01120511424._9
330- let _positionId = $t01120511424._10
331- let _limitPrice = $t01120511424._11
385+ let $t01350813727 = getOrder(_orderId)
386+ let _amm = $t01350813727._1
387+ let _trader = $t01350813727._2
388+ let _amountIn = $t01350813727._3
389+ let _leverage = $t01350813727._4
390+ let _type = $t01350813727._5
391+ let _triggerPrice = $t01350813727._6
392+ let _amountUsdn = $t01350813727._7
393+ let _side = $t01350813727._8
394+ let _refLink = $t01350813727._9
395+ let _positionId = $t01350813727._10
396+ let _limitPrice = $t01350813727._11
332397 if (if (if (!(initialized()))
333398 then true
334399 else !(isValid(_orderId)))
335400 then true
336401 else !((toString(i.caller) == _trader)))
337402 then throw("Invalid cancelOrder parameters")
338403 else {
339404 let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) - 1)
340405 let withdraw = if ((_amountUsdn > 0))
341406 then {
342407 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amountUsdn], nil)
343408 if ((unstake == unstake))
344409 then nil
345410 else throw("Strict value is not equal to itself.")
346411 }
347412 else nil
348413 if ((withdraw == withdraw))
349414 then ((markCancelOrder(_orderId) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ (if ((_amountUsdn > 0))
350415 then [ScriptTransfer(i.caller, _amountUsdn, quoteAsset())]
351416 else nil))
352417 else throw("Strict value is not equal to itself.")
353418 }
354419 }
355420
356421
357422
358423 @Callable(i)
359424 func executeOrder (_orderId) = {
360- let $t01225712476 = getOrder(_orderId)
361- let _amm = $t01225712476._1
362- let _trader = $t01225712476._2
363- let _amountIn = $t01225712476._3
364- let _leverage = $t01225712476._4
365- let _type = $t01225712476._5
366- let _triggerPrice = $t01225712476._6
367- let _amountUsdn = $t01225712476._7
368- let _side = $t01225712476._8
369- let _refLink = $t01225712476._9
370- let _positionId = $t01225712476._10
371- let _limitPrice = $t01225712476._11
425+ let $t01456014779 = getOrder(_orderId)
426+ let _amm = $t01456014779._1
427+ let _trader = $t01456014779._2
428+ let _amountIn = $t01456014779._3
429+ let _leverage = $t01456014779._4
430+ let _type = $t01456014779._5
431+ let _triggerPrice = $t01456014779._6
432+ let _amountUsdn = $t01456014779._7
433+ let _side = $t01456014779._8
434+ let _refLink = $t01456014779._9
435+ let _positionId = $t01456014779._10
436+ let _limitPrice = $t01456014779._11
372437 if (if (!(initialized()))
373438 then true
374439 else !(isValid(_orderId)))
375440 then throw("Invalid executeOrder parameters")
376441 else {
377442 let positionSize = getPositionSize(_amm, _trader)
378443 let currentPositionId = if ((positionSize != 0))
379444 then getPositionId(_amm, _trader)
380445 else 0
381- let $t01280216623 = if ((_type == STOP))
446+ let $t01510518926 = if ((_type == STOP))
382447 then {
383448 let _positionDirection = if ((positionSize > 0))
384449 then LONG
385450 else if ((0 > positionSize))
386451 then SHORT
387452 else throw("Can not execute STOP order: no open position")
388453 let marketPrice = getMarketPrice(_amm)
389454 let isExecutable = if ((_side == _positionDirection))
390455 then throw("Can not execute STOP order: reduce only")
391456 else if ((currentPositionId != _positionId))
392457 then throw("Can not execute STOP order: position closed")
393458 else if ((_positionDirection == LONG))
394459 then (_triggerPrice >= marketPrice)
395460 else (marketPrice >= _triggerPrice)
396461 if (isExecutable)
397462 then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), muld(_limitPrice, abs(positionSize))], nil)
398463 else throw("Can not execute STOP order: triggerPrice mismatch")
399464 }
400465 else if ((_type == TAKE))
401466 then {
402467 let _positionDirection = if ((positionSize > 0))
403468 then LONG
404469 else if ((0 > positionSize))
405470 then SHORT
406471 else throw("Can not execute STOP order: no open position")
407472 let marketPrice = getMarketPrice(_amm)
408473 let isExecutable = if ((_side == _positionDirection))
409474 then throw("Can not execute TAKE order: reduce only")
410475 else if ((currentPositionId != _positionId))
411476 then throw(((("Can not execute TAKE order: position closed " + toString(currentPositionId)) + "!=") + toString(_positionId)))
412477 else if ((_positionDirection == LONG))
413478 then (marketPrice >= _triggerPrice)
414479 else (_triggerPrice >= marketPrice)
415480 if (isExecutable)
416481 then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), muld(_limitPrice, abs(positionSize))], nil)
417482 else throw("Can not execute TAKE order: triggerPrice mismatch")
418483 }
419484 else if ((_type == LIMIT))
420485 then {
421486 let marketPrice = getMarketPrice(_amm)
422487 let spread = if ((_limitPrice == 0))
423488 then getSpread(_triggerPrice)
424489 else abs((_triggerPrice - _limitPrice))
425490 let isExecutable = if ((marketPrice >= (_triggerPrice - spread)))
426491 then ((_triggerPrice + spread) >= marketPrice)
427492 else false
428493 if (isExecutable)
429494 then {
430495 let _positionDirection = if ((positionSize > 0))
431496 then LONG
432497 else if ((0 > positionSize))
433498 then SHORT
434499 else -1
435500 let direction = if ((positionSize == 0))
436501 then INCREASE
437502 else if ((_positionDirection == _side))
438503 then INCREASE
439504 else DECREASE
440505 if ((direction == INCREASE))
441506 then {
442507 let amountInWithFee = (_amountUsdn - muld(_amountUsdn, getFee(_amm, _trader)))
443508 $Tuple3("increasePosition", [_side, _leverage, if ((_limitPrice == 0))
444509 then 0
445510 else divd(amountInWithFee, _limitPrice), _refLink], [AttachedPayment(quoteAsset(), _amountUsdn)])
446511 }
447512 else $Tuple3("closePosition", [_amountIn, muld(_amountIn, _limitPrice)], nil)
448513 }
449514 else throw("Can not execute LIMIT order: triggerPrice mismatch")
450515 }
451516 else throw(("Invalid order type: " + toString(_type)))
452- let method = $t01280216623._1
453- let args = $t01280216623._2
454- let payments = $t01280216623._3
517+ let method = $t01510518926._1
518+ let args = $t01510518926._2
519+ let payments = $t01510518926._3
455520 let withdraw = if ((size(payments) == 1))
456521 then {
457522 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), payments[0].amount], nil)
458523 if ((unstake == unstake))
459524 then nil
460525 else throw("Strict value is not equal to itself.")
461526 }
462527 else nil
463528 if ((withdraw == withdraw))
464529 then {
465530 let doSetContext = invoke(this, "setContext", [_trader], nil)
466531 if ((doSetContext == doSetContext))
467532 then {
468533 let doClosePosition = invoke(addressFromStringValue(_amm), method, args, payments)
469534 if ((doClosePosition == doClosePosition))
470535 then {
471536 let doResetContext = invoke(this, "resetContext", nil, nil)
472537 if ((doResetContext == doResetContext))
473538 then markExecuteOrder(_orderId)
474539 else throw("Strict value is not equal to itself.")
475540 }
476541 else throw("Strict value is not equal to itself.")
477542 }
478543 else throw("Strict value is not equal to itself.")
479544 }
480545 else throw("Strict value is not equal to itself.")
481546 }
482547 }
483548
484549
485550
486551 @Callable(i)
487552 func view_canExecuteOrder (_orderId) = {
488553 let s = invoke(this, "executeOrder", [_orderId], nil)
489554 if ((s == s))
490555 then throw("Success")
491556 else throw("Strict value is not equal to itself.")
492557 }
493558
494559
495560 @Verifier(tx)
496561 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
497562

github/deemru/w8io/026f985 
58.48 ms