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:BgJFCAISAwoBCBIAEgMKAQgSCgoICAEBAQEBAQgSCwoJCAEBAQgBAQEBEg0KCwgIAQEBAQEBCAgBEgMKAQESAwoBARIDCgEBNwAUa19jb29yZGluYXRvckFkZHJlc3MCFGtfY29vcmRpbmF0b3JBZGRyZXNzABJrX2FkbWluX3B1YmxpY19rZXkCEmtfYWRtaW5fcHVibGljX2tleQANa19xdW90ZV9hc3NldAINa19xdW90ZV9hc3NldAAFa19hbW0CBWtfYW1tABFrX21hbmFnZXJfYWRkcmVzcwIRa19tYW5hZ2VyX2FkZHJlc3MAEmtfcG9zaXRpb25TZXF1ZW5jZQISa19wb3NpdGlvblNlcXVlbmNlAA5rX3Bvc2l0aW9uU2l6ZQIOa19wb3NpdGlvblNpemUABWtfZmVlAgVrX2ZlZQAQa19leGVjdXRlZE9yZGVycwIQa19leGVjdXRlZE9yZGVycwAQa19jYW5jZWxlZE9yZGVycwIQa19jYW5jZWxlZE9yZGVycwAHa19vcmRlcgIHa19vcmRlcgANa19sYXN0T3JkZXJJZAINa19sYXN0T3JkZXJJZAAQa190cmFkZXJPcmRlckNudA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b1NldENvbnRleHQED2RvQ2xvc2VQb3NpdGlvbgkA/AcECQERQGV4dHJOYXRpdmUoMTA2MikBBQRfYW1tBQZtZXRob2QFBGFyZ3MFCHBheW1lbnRzAwkAAAIFD2RvQ2xvc2VQb3NpdGlvbgUPZG9DbG9zZVBvc2l0aW9uBA5kb1Jlc2V0Q29udGV4dAkA/AcEBQR0aGlzAgxyZXNldENvbnRleHQFA25pbAUDbmlsAwkAAAIFDmRvUmVzZXRDb250ZXh0BQ5kb1Jlc2V0Q29udGV4dAkBEG1hcmtFeGVjdXRlT3JkZXIBBQhfb3JkZXJJZAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpARR2aWV3X2NhbkV4ZWN1dGVPcmRlcgEIX29yZGVySWQEAXMJAPwHBAUEdGhpcwIMZXhlY3V0ZU9yZGVyCQDMCAIFCF9vcmRlcklkBQNuaWwFA25pbAMJAAACBQFzBQFzCQACAQIHU3VjY2VzcwkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAJAQ5hZG1pblB1YmxpY0tleQDHKKTM", "height": 2361278, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 25o3gzaMe49eZgUyoMEdqps81Pfptxej6NQZU6mHLDJc Next: Fj8LyeAxMh3HyxXSCJcfdzuxbkP34QExpoCxpuGYvYrU Diff:
Old | New | Differences | |
---|---|---|---|
242 | 242 | ||
243 | 243 | ||
244 | 244 | @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) | |
245 | 310 | func internalCreateOrder (_trader,_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_paymentAssetId,_paymentAmount) = if (if (if (if (if (if (if (if (if (!(initialized())) | |
246 | 311 | then true | |
247 | 312 | else !(isWhitelist(_amm))) | |
317 | 382 | ||
318 | 383 | @Callable(i) | |
319 | 384 | func cancelOrder (_orderId) = { | |
320 | - | let $ | |
321 | - | let _amm = $ | |
322 | - | let _trader = $ | |
323 | - | let _amountIn = $ | |
324 | - | let _leverage = $ | |
325 | - | let _type = $ | |
326 | - | let _triggerPrice = $ | |
327 | - | let _amountUsdn = $ | |
328 | - | let _side = $ | |
329 | - | let _refLink = $ | |
330 | - | let _positionId = $ | |
331 | - | let _limitPrice = $ | |
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 | |
332 | 397 | if (if (if (!(initialized())) | |
333 | 398 | then true | |
334 | 399 | else !(isValid(_orderId))) | |
357 | 422 | ||
358 | 423 | @Callable(i) | |
359 | 424 | func executeOrder (_orderId) = { | |
360 | - | let $ | |
361 | - | let _amm = $ | |
362 | - | let _trader = $ | |
363 | - | let _amountIn = $ | |
364 | - | let _leverage = $ | |
365 | - | let _type = $ | |
366 | - | let _triggerPrice = $ | |
367 | - | let _amountUsdn = $ | |
368 | - | let _side = $ | |
369 | - | let _refLink = $ | |
370 | - | let _positionId = $ | |
371 | - | let _limitPrice = $ | |
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 | |
372 | 437 | if (if (!(initialized())) | |
373 | 438 | then true | |
374 | 439 | else !(isValid(_orderId))) | |
378 | 443 | let currentPositionId = if ((positionSize != 0)) | |
379 | 444 | then getPositionId(_amm, _trader) | |
380 | 445 | else 0 | |
381 | - | let $ | |
446 | + | let $t01510518926 = if ((_type == STOP)) | |
382 | 447 | then { | |
383 | 448 | let _positionDirection = if ((positionSize > 0)) | |
384 | 449 | then LONG | |
449 | 514 | else throw("Can not execute LIMIT order: triggerPrice mismatch") | |
450 | 515 | } | |
451 | 516 | else throw(("Invalid order type: " + toString(_type))) | |
452 | - | let method = $ | |
453 | - | let args = $ | |
454 | - | let payments = $ | |
517 | + | let method = $t01510518926._1 | |
518 | + | let args = $t01510518926._2 | |
519 | + | let payments = $t01510518926._3 | |
455 | 520 | let withdraw = if ((size(payments) == 1)) | |
456 | 521 | then { | |
457 | 522 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), payments[0].amount], nil) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_coordinatorAddress = "k_coordinatorAddress" | |
5 | 5 | ||
6 | 6 | let k_admin_public_key = "k_admin_public_key" | |
7 | 7 | ||
8 | 8 | let k_quote_asset = "k_quote_asset" | |
9 | 9 | ||
10 | 10 | let k_amm = "k_amm" | |
11 | 11 | ||
12 | 12 | let k_manager_address = "k_manager_address" | |
13 | 13 | ||
14 | 14 | let k_positionSequence = "k_positionSequence" | |
15 | 15 | ||
16 | 16 | let k_positionSize = "k_positionSize" | |
17 | 17 | ||
18 | 18 | let k_fee = "k_fee" | |
19 | 19 | ||
20 | 20 | let k_executedOrders = "k_executedOrders" | |
21 | 21 | ||
22 | 22 | let k_canceledOrders = "k_canceledOrders" | |
23 | 23 | ||
24 | 24 | let k_order = "k_order" | |
25 | 25 | ||
26 | 26 | let k_lastOrderId = "k_lastOrderId" | |
27 | 27 | ||
28 | 28 | let k_traderOrderCnt = "k_traderOrderCnt" | |
29 | 29 | ||
30 | 30 | let k_sender = "k_sender" | |
31 | 31 | ||
32 | 32 | let k_initialized = "k_initialized" | |
33 | 33 | ||
34 | 34 | let STOP = 1 | |
35 | 35 | ||
36 | 36 | let TAKE = 2 | |
37 | 37 | ||
38 | 38 | let LIMIT = 3 | |
39 | 39 | ||
40 | 40 | let LONG = 1 | |
41 | 41 | ||
42 | 42 | let SHORT = 2 | |
43 | 43 | ||
44 | 44 | let INCREASE = 1 | |
45 | 45 | ||
46 | 46 | let DECREASE = 2 | |
47 | 47 | ||
48 | 48 | let MAX_TRADER_ORDERS_PER_AMM = 5 | |
49 | 49 | ||
50 | 50 | let TIME = lastBlock.timestamp | |
51 | 51 | ||
52 | 52 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
53 | 53 | ||
54 | 54 | let SPREAD_LIMIT = (DECIMAL_UNIT / 200) | |
55 | 55 | ||
56 | 56 | func abs (_x) = if ((_x > 0)) | |
57 | 57 | then _x | |
58 | 58 | else -(_x) | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func minv (_x,_y) = if ((_x > _y)) | |
68 | 68 | then _y | |
69 | 69 | else _x | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func executedOrderKey (_orderId) = ((k_executedOrders + "_") + toString(_orderId)) | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func canceledOrderKey (_orderId) = ((k_canceledOrders + "_") + toString(_orderId)) | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func orderKey (_orderId) = toCompositeKey(k_order, toString(_orderId)) | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func traderOrderCountKey (_amm,_trader) = ((((k_traderOrderCnt + "_") + _amm) + "_") + _trader) | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func isWhitelist (_address) = valueOrElse(getBoolean(coordinator(), toCompositeKey(k_amm, _address)), false) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func isValid (_orderId) = if (valueOrElse(getBoolean(this, executedOrderKey(_orderId)), false)) | |
106 | 106 | then throw(("Order already executed: " + toString(_orderId))) | |
107 | 107 | else if (valueOrElse(getBoolean(this, canceledOrderKey(_orderId)), false)) | |
108 | 108 | then throw(("Order already cancelled: " + toString(_orderId))) | |
109 | 109 | else true | |
110 | 110 | ||
111 | 111 | ||
112 | 112 | func currentOrderId () = valueOrElse(getInteger(this, k_lastOrderId), 0) | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | func getTraderOrderCount (_amm,_trader) = { | |
116 | 116 | let key = traderOrderCountKey(_amm, _trader) | |
117 | 117 | valueOrElse(getInteger(this, key), 0) | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func getOrder (_orderId) = { | |
122 | 122 | let orderStr = valueOrErrorMessage(getString(this, orderKey(_orderId)), ("Invalid order id: " + toString(_orderId))) | |
123 | 123 | let orderPartList = split(orderStr, ",") | |
124 | 124 | let amm = orderPartList[0] | |
125 | 125 | let trader = orderPartList[1] | |
126 | 126 | let amountIn = valueOrErrorMessage(parseInt(orderPartList[2]), "Invalid amountIn") | |
127 | 127 | let leverage = valueOrErrorMessage(parseInt(orderPartList[3]), "Invalid leverage") | |
128 | 128 | let type = valueOrErrorMessage(parseInt(orderPartList[4]), "Invalid type") | |
129 | 129 | let triggerPrice = valueOrErrorMessage(parseInt(orderPartList[5]), "Invalid triggerPrice") | |
130 | 130 | let paymentUsdn = valueOrErrorMessage(parseInt(orderPartList[6]), "Invalid paymentUsdn") | |
131 | 131 | let side = valueOrErrorMessage(parseInt(orderPartList[7]), "Invalid side") | |
132 | 132 | let refLink = orderPartList[8] | |
133 | 133 | let positionId = valueOrErrorMessage(parseInt(orderPartList[9]), "Invalid positionId") | |
134 | 134 | let limitPrice = valueOrErrorMessage(parseInt(orderPartList[10]), "Invalid limitPrice") | |
135 | 135 | $Tuple11(amm, trader, amountIn, leverage, type, triggerPrice, paymentUsdn, side, refLink, positionId, limitPrice) | |
136 | 136 | } | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func getMarketPrice (_amm) = { | |
140 | 140 | let s = invoke(addressFromStringValue(_amm), "computeSpotPrice", nil, nil) | |
141 | 141 | if ((s == s)) | |
142 | 142 | then { | |
143 | 143 | let res = match s { | |
144 | 144 | case t: Int => | |
145 | 145 | t | |
146 | 146 | case _ => | |
147 | 147 | throw("Invalid computeSpotPrice result") | |
148 | 148 | } | |
149 | 149 | value(res) | |
150 | 150 | } | |
151 | 151 | else throw("Strict value is not equal to itself.") | |
152 | 152 | } | |
153 | 153 | ||
154 | 154 | ||
155 | 155 | func getFee (_amm,_trader) = { | |
156 | 156 | let s = invoke(addressFromStringValue(_amm), "computeFeeForTraderWithArtifact", [_trader, ""], nil) | |
157 | 157 | if ((s == s)) | |
158 | 158 | then { | |
159 | 159 | let res = match s { | |
160 | 160 | case t: (Int, Boolean) => | |
161 | 161 | t._1 | |
162 | 162 | case _ => | |
163 | 163 | throw("Invalid computeFeeForTraderWithArtifact result") | |
164 | 164 | } | |
165 | 165 | value(res) | |
166 | 166 | } | |
167 | 167 | else throw("Strict value is not equal to itself.") | |
168 | 168 | } | |
169 | 169 | ||
170 | 170 | ||
171 | 171 | func getPositionSize (_amm,_trader) = { | |
172 | 172 | let amm = addressFromStringValue(_amm) | |
173 | 173 | let sizeKey = toCompositeKey(k_positionSize, _trader) | |
174 | 174 | valueOrElse(getInteger(amm, sizeKey), 0) | |
175 | 175 | } | |
176 | 176 | ||
177 | 177 | ||
178 | 178 | func getPositionId (_amm,_trader) = { | |
179 | 179 | let amm = addressFromStringValue(_amm) | |
180 | 180 | let seqKey = toCompositeKey(k_positionSequence, _trader) | |
181 | 181 | valueOrElse(getInteger(amm, seqKey), 0) | |
182 | 182 | } | |
183 | 183 | ||
184 | 184 | ||
185 | 185 | func getSpread (_price) = muld(_price, SPREAD_LIMIT) | |
186 | 186 | ||
187 | 187 | ||
188 | 188 | func saveOrder (_orderId,_amm,_trader,_amountIn,_leverage,_type,_triggerPrice,_paymentUsdn,_side,_refLink,_positionId,_limitPrice) = { | |
189 | 189 | let orderStr = makeString([_amm, _trader, toString(_amountIn), toString(_leverage), toString(_type), toString(_triggerPrice), toString(_paymentUsdn), toString(_side), _refLink, toString(_positionId), toString(_limitPrice)], ",") | |
190 | 190 | [StringEntry(orderKey(_orderId), orderStr)] | |
191 | 191 | } | |
192 | 192 | ||
193 | 193 | ||
194 | 194 | func updateTraderOrderCount (_amm,_trader,_count) = [IntegerEntry(traderOrderCountKey(_amm, _trader), _count)] | |
195 | 195 | ||
196 | 196 | ||
197 | 197 | func updateLastOrderId (_lastOrderId) = [IntegerEntry(k_lastOrderId, _lastOrderId)] | |
198 | 198 | ||
199 | 199 | ||
200 | 200 | func markExecuteOrder (_orderId) = [BooleanEntry(toCompositeKey(k_executedOrders, toString(_orderId)), true)] | |
201 | 201 | ||
202 | 202 | ||
203 | 203 | func markCancelOrder (_orderId) = [BooleanEntry(toCompositeKey(k_canceledOrders, toString(_orderId)), true)] | |
204 | 204 | ||
205 | 205 | ||
206 | 206 | @Callable(i) | |
207 | 207 | func setContext (_sender) = if ((i.caller != this)) | |
208 | 208 | then throw("Only self-call") | |
209 | 209 | else [StringEntry(k_sender, _sender)] | |
210 | 210 | ||
211 | 211 | ||
212 | 212 | ||
213 | 213 | @Callable(i) | |
214 | 214 | func resetContext () = if ((i.caller != this)) | |
215 | 215 | then throw("Only self-call") | |
216 | 216 | else [DeleteEntry(k_sender)] | |
217 | 217 | ||
218 | 218 | ||
219 | 219 | ||
220 | 220 | @Callable(i) | |
221 | 221 | func initialize (_coordinator) = if (initialized()) | |
222 | 222 | then throw("Already initialized") | |
223 | 223 | else [StringEntry(k_coordinatorAddress, _coordinator), BooleanEntry(k_initialized, true)] | |
224 | 224 | ||
225 | 225 | ||
226 | 226 | ||
227 | 227 | @Callable(i) | |
228 | 228 | func createOrder (_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink) = if ((size(i.payments) > 1)) | |
229 | 229 | then throw("Invalid createOrder parameters: invalid payment count") | |
230 | 230 | else { | |
231 | 231 | let $t080238275 = if ((size(i.payments) == 1)) | |
232 | 232 | then $Tuple2(toBase58String(valueOrErrorMessage(i.payments[0].assetId, "Invalid asset id")), i.payments[0].amount) | |
233 | 233 | else $Tuple2("", 0) | |
234 | 234 | let paymentAssetId = $t080238275._1 | |
235 | 235 | let paymentAmount = $t080238275._2 | |
236 | 236 | let doCall = invoke(this, "internalCreateOrder", [toString(i.caller), _amm, _type, _triggerPrice, _limitPrice, _amountIn, _leverage, _side, _refLink, paymentAssetId, paymentAmount], nil) | |
237 | 237 | if ((doCall == doCall)) | |
238 | 238 | then nil | |
239 | 239 | else throw("Strict value is not equal to itself.") | |
240 | 240 | } | |
241 | 241 | ||
242 | 242 | ||
243 | 243 | ||
244 | 244 | @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) | |
245 | 310 | func internalCreateOrder (_trader,_amm,_type,_triggerPrice,_limitPrice,_amountIn,_leverage,_side,_refLink,_paymentAssetId,_paymentAmount) = if (if (if (if (if (if (if (if (if (!(initialized())) | |
246 | 311 | then true | |
247 | 312 | else !(isWhitelist(_amm))) | |
248 | 313 | then true | |
249 | 314 | else (0 >= _triggerPrice)) | |
250 | 315 | then true | |
251 | 316 | else (0 > _limitPrice)) | |
252 | 317 | then true | |
253 | 318 | else (0 >= _amountIn)) | |
254 | 319 | then true | |
255 | 320 | else (0 > _leverage)) | |
256 | 321 | then true | |
257 | 322 | else !(if ((_side == LONG)) | |
258 | 323 | then true | |
259 | 324 | else (_side == SHORT))) | |
260 | 325 | then true | |
261 | 326 | else !(if (if ((_type == STOP)) | |
262 | 327 | then true | |
263 | 328 | else (_type == TAKE)) | |
264 | 329 | then true | |
265 | 330 | else (_type == LIMIT))) | |
266 | 331 | then true | |
267 | 332 | else !((i.caller == this))) | |
268 | 333 | then throw("Invalid createOrder parameters") | |
269 | 334 | else { | |
270 | 335 | let orderId = (currentOrderId() + 1) | |
271 | 336 | let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) + 1) | |
272 | 337 | let positionSize = getPositionSize(_amm, _trader) | |
273 | 338 | let _direction = if (if (if ((positionSize == 0)) | |
274 | 339 | then true | |
275 | 340 | else if ((positionSize > 0)) | |
276 | 341 | then (_side == LONG) | |
277 | 342 | else false) | |
278 | 343 | then true | |
279 | 344 | else if ((0 > positionSize)) | |
280 | 345 | then (_side == SHORT) | |
281 | 346 | else false) | |
282 | 347 | then INCREASE | |
283 | 348 | else DECREASE | |
284 | 349 | if (if ((positionSize == 0)) | |
285 | 350 | then if ((_type == STOP)) | |
286 | 351 | then true | |
287 | 352 | else (_type == TAKE) | |
288 | 353 | else false) | |
289 | 354 | then throw("Can not create STOP/TAKE order: no position") | |
290 | 355 | else { | |
291 | 356 | let usdnPayment = if ((_direction == INCREASE)) | |
292 | 357 | then if (if ((_paymentAssetId != toBase58String(quoteAsset()))) | |
293 | 358 | then true | |
294 | 359 | else (_paymentAmount != _amountIn)) | |
295 | 360 | then throw("Invalid createLimitOrder parameters: invalid payment") | |
296 | 361 | else { | |
297 | 362 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _paymentAmount)]) | |
298 | 363 | if ((stake == stake)) | |
299 | 364 | then _paymentAmount | |
300 | 365 | else throw("Strict value is not equal to itself.") | |
301 | 366 | } | |
302 | 367 | else 0 | |
303 | 368 | if ((usdnPayment == usdnPayment)) | |
304 | 369 | then { | |
305 | 370 | let positionId = if ((positionSize != 0)) | |
306 | 371 | then getPositionId(_amm, _trader) | |
307 | 372 | else 0 | |
308 | 373 | if ((newTraderOrderCount > MAX_TRADER_ORDERS_PER_AMM)) | |
309 | 374 | then throw("Invalid createLimitOrder parameters: order count") | |
310 | 375 | else ((saveOrder(orderId, _amm, _trader, _amountIn, _leverage, _type, _triggerPrice, usdnPayment, _side, _refLink, positionId, _limitPrice) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ updateLastOrderId(orderId)) | |
311 | 376 | } | |
312 | 377 | else throw("Strict value is not equal to itself.") | |
313 | 378 | } | |
314 | 379 | } | |
315 | 380 | ||
316 | 381 | ||
317 | 382 | ||
318 | 383 | @Callable(i) | |
319 | 384 | func cancelOrder (_orderId) = { | |
320 | - | let $ | |
321 | - | let _amm = $ | |
322 | - | let _trader = $ | |
323 | - | let _amountIn = $ | |
324 | - | let _leverage = $ | |
325 | - | let _type = $ | |
326 | - | let _triggerPrice = $ | |
327 | - | let _amountUsdn = $ | |
328 | - | let _side = $ | |
329 | - | let _refLink = $ | |
330 | - | let _positionId = $ | |
331 | - | let _limitPrice = $ | |
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 | |
332 | 397 | if (if (if (!(initialized())) | |
333 | 398 | then true | |
334 | 399 | else !(isValid(_orderId))) | |
335 | 400 | then true | |
336 | 401 | else !((toString(i.caller) == _trader))) | |
337 | 402 | then throw("Invalid cancelOrder parameters") | |
338 | 403 | else { | |
339 | 404 | let newTraderOrderCount = (getTraderOrderCount(_amm, _trader) - 1) | |
340 | 405 | let withdraw = if ((_amountUsdn > 0)) | |
341 | 406 | then { | |
342 | 407 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amountUsdn], nil) | |
343 | 408 | if ((unstake == unstake)) | |
344 | 409 | then nil | |
345 | 410 | else throw("Strict value is not equal to itself.") | |
346 | 411 | } | |
347 | 412 | else nil | |
348 | 413 | if ((withdraw == withdraw)) | |
349 | 414 | then ((markCancelOrder(_orderId) ++ updateTraderOrderCount(_amm, _trader, newTraderOrderCount)) ++ (if ((_amountUsdn > 0)) | |
350 | 415 | then [ScriptTransfer(i.caller, _amountUsdn, quoteAsset())] | |
351 | 416 | else nil)) | |
352 | 417 | else throw("Strict value is not equal to itself.") | |
353 | 418 | } | |
354 | 419 | } | |
355 | 420 | ||
356 | 421 | ||
357 | 422 | ||
358 | 423 | @Callable(i) | |
359 | 424 | func executeOrder (_orderId) = { | |
360 | - | let $ | |
361 | - | let _amm = $ | |
362 | - | let _trader = $ | |
363 | - | let _amountIn = $ | |
364 | - | let _leverage = $ | |
365 | - | let _type = $ | |
366 | - | let _triggerPrice = $ | |
367 | - | let _amountUsdn = $ | |
368 | - | let _side = $ | |
369 | - | let _refLink = $ | |
370 | - | let _positionId = $ | |
371 | - | let _limitPrice = $ | |
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 | |
372 | 437 | if (if (!(initialized())) | |
373 | 438 | then true | |
374 | 439 | else !(isValid(_orderId))) | |
375 | 440 | then throw("Invalid executeOrder parameters") | |
376 | 441 | else { | |
377 | 442 | let positionSize = getPositionSize(_amm, _trader) | |
378 | 443 | let currentPositionId = if ((positionSize != 0)) | |
379 | 444 | then getPositionId(_amm, _trader) | |
380 | 445 | else 0 | |
381 | - | let $ | |
446 | + | let $t01510518926 = if ((_type == STOP)) | |
382 | 447 | then { | |
383 | 448 | let _positionDirection = if ((positionSize > 0)) | |
384 | 449 | then LONG | |
385 | 450 | else if ((0 > positionSize)) | |
386 | 451 | then SHORT | |
387 | 452 | else throw("Can not execute STOP order: no open position") | |
388 | 453 | let marketPrice = getMarketPrice(_amm) | |
389 | 454 | let isExecutable = if ((_side == _positionDirection)) | |
390 | 455 | then throw("Can not execute STOP order: reduce only") | |
391 | 456 | else if ((currentPositionId != _positionId)) | |
392 | 457 | then throw("Can not execute STOP order: position closed") | |
393 | 458 | else if ((_positionDirection == LONG)) | |
394 | 459 | then (_triggerPrice >= marketPrice) | |
395 | 460 | else (marketPrice >= _triggerPrice) | |
396 | 461 | if (isExecutable) | |
397 | 462 | then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), muld(_limitPrice, abs(positionSize))], nil) | |
398 | 463 | else throw("Can not execute STOP order: triggerPrice mismatch") | |
399 | 464 | } | |
400 | 465 | else if ((_type == TAKE)) | |
401 | 466 | then { | |
402 | 467 | let _positionDirection = if ((positionSize > 0)) | |
403 | 468 | then LONG | |
404 | 469 | else if ((0 > positionSize)) | |
405 | 470 | then SHORT | |
406 | 471 | else throw("Can not execute STOP order: no open position") | |
407 | 472 | let marketPrice = getMarketPrice(_amm) | |
408 | 473 | let isExecutable = if ((_side == _positionDirection)) | |
409 | 474 | then throw("Can not execute TAKE order: reduce only") | |
410 | 475 | else if ((currentPositionId != _positionId)) | |
411 | 476 | then throw(((("Can not execute TAKE order: position closed " + toString(currentPositionId)) + "!=") + toString(_positionId))) | |
412 | 477 | else if ((_positionDirection == LONG)) | |
413 | 478 | then (marketPrice >= _triggerPrice) | |
414 | 479 | else (_triggerPrice >= marketPrice) | |
415 | 480 | if (isExecutable) | |
416 | 481 | then $Tuple3("closePosition", [minv(_amountIn, abs(positionSize)), muld(_limitPrice, abs(positionSize))], nil) | |
417 | 482 | else throw("Can not execute TAKE order: triggerPrice mismatch") | |
418 | 483 | } | |
419 | 484 | else if ((_type == LIMIT)) | |
420 | 485 | then { | |
421 | 486 | let marketPrice = getMarketPrice(_amm) | |
422 | 487 | let spread = if ((_limitPrice == 0)) | |
423 | 488 | then getSpread(_triggerPrice) | |
424 | 489 | else abs((_triggerPrice - _limitPrice)) | |
425 | 490 | let isExecutable = if ((marketPrice >= (_triggerPrice - spread))) | |
426 | 491 | then ((_triggerPrice + spread) >= marketPrice) | |
427 | 492 | else false | |
428 | 493 | if (isExecutable) | |
429 | 494 | then { | |
430 | 495 | let _positionDirection = if ((positionSize > 0)) | |
431 | 496 | then LONG | |
432 | 497 | else if ((0 > positionSize)) | |
433 | 498 | then SHORT | |
434 | 499 | else -1 | |
435 | 500 | let direction = if ((positionSize == 0)) | |
436 | 501 | then INCREASE | |
437 | 502 | else if ((_positionDirection == _side)) | |
438 | 503 | then INCREASE | |
439 | 504 | else DECREASE | |
440 | 505 | if ((direction == INCREASE)) | |
441 | 506 | then { | |
442 | 507 | let amountInWithFee = (_amountUsdn - muld(_amountUsdn, getFee(_amm, _trader))) | |
443 | 508 | $Tuple3("increasePosition", [_side, _leverage, if ((_limitPrice == 0)) | |
444 | 509 | then 0 | |
445 | 510 | else divd(amountInWithFee, _limitPrice), _refLink], [AttachedPayment(quoteAsset(), _amountUsdn)]) | |
446 | 511 | } | |
447 | 512 | else $Tuple3("closePosition", [_amountIn, muld(_amountIn, _limitPrice)], nil) | |
448 | 513 | } | |
449 | 514 | else throw("Can not execute LIMIT order: triggerPrice mismatch") | |
450 | 515 | } | |
451 | 516 | else throw(("Invalid order type: " + toString(_type))) | |
452 | - | let method = $ | |
453 | - | let args = $ | |
454 | - | let payments = $ | |
517 | + | let method = $t01510518926._1 | |
518 | + | let args = $t01510518926._2 | |
519 | + | let payments = $t01510518926._3 | |
455 | 520 | let withdraw = if ((size(payments) == 1)) | |
456 | 521 | then { | |
457 | 522 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), payments[0].amount], nil) | |
458 | 523 | if ((unstake == unstake)) | |
459 | 524 | then nil | |
460 | 525 | else throw("Strict value is not equal to itself.") | |
461 | 526 | } | |
462 | 527 | else nil | |
463 | 528 | if ((withdraw == withdraw)) | |
464 | 529 | then { | |
465 | 530 | let doSetContext = invoke(this, "setContext", [_trader], nil) | |
466 | 531 | if ((doSetContext == doSetContext)) | |
467 | 532 | then { | |
468 | 533 | let doClosePosition = invoke(addressFromStringValue(_amm), method, args, payments) | |
469 | 534 | if ((doClosePosition == doClosePosition)) | |
470 | 535 | then { | |
471 | 536 | let doResetContext = invoke(this, "resetContext", nil, nil) | |
472 | 537 | if ((doResetContext == doResetContext)) | |
473 | 538 | then markExecuteOrder(_orderId) | |
474 | 539 | else throw("Strict value is not equal to itself.") | |
475 | 540 | } | |
476 | 541 | else throw("Strict value is not equal to itself.") | |
477 | 542 | } | |
478 | 543 | else throw("Strict value is not equal to itself.") | |
479 | 544 | } | |
480 | 545 | else throw("Strict value is not equal to itself.") | |
481 | 546 | } | |
482 | 547 | } | |
483 | 548 | ||
484 | 549 | ||
485 | 550 | ||
486 | 551 | @Callable(i) | |
487 | 552 | func view_canExecuteOrder (_orderId) = { | |
488 | 553 | let s = invoke(this, "executeOrder", [_orderId], nil) | |
489 | 554 | if ((s == s)) | |
490 | 555 | then throw("Success") | |
491 | 556 | else throw("Strict value is not equal to itself.") | |
492 | 557 | } | |
493 | 558 | ||
494 | 559 | ||
495 | 560 | @Verifier(tx) | |
496 | 561 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
497 | 562 |
github/deemru/w8io/026f985 58.48 ms ◑