tx · BB2Z4Az4uRK4EFCVCa9h2khTeDRJWNZVHqdqgFDnYgVv 3Mp3uUKsY4LnTo3j4N7dJAfqRfMJ6Rgr35Q: -0.07500000 Waves 2023.04.17 19:50 [2538824] smart account 3Mp3uUKsY4LnTo3j4N7dJAfqRfMJ6Rgr35Q > SELF 0.00000000 Waves
{ "type": 13, "id": "BB2Z4Az4uRK4EFCVCa9h2khTeDRJWNZVHqdqgFDnYgVv", "fee": 7500000, "feeAssetId": null, "timestamp": 1681750253768, "version": 2, "chainId": 84, "sender": "3Mp3uUKsY4LnTo3j4N7dJAfqRfMJ6Rgr35Q", "senderPublicKey": "EiYReiiFX6CXEuz35wibBnvZ8LjJHZrgFwR73fomjgzy", "proofs": [ "PwGAaFumWe3kmZufKckU3oh6L7jLTstNVkGrWjiENPwEvUJemESMBpfta4f27y1ax5ZxVGYkS3v1aPSCoZBh4Kn" ], "script": "base64:BgKAAQgCEgASABIAEgASAwoBARIDCgEBEhAKDgEBAQEBAQEBAQEBAQEBEhUKEwEBAQEBAQEICAgBAQEBAQEBAQESBgoEAQEBCBIDCgEBEgQKAgEBEgYKBAEBAQQSBAoCCAESABIAEgASAwoBCBIECgIIARIDCgEBEgASABIAEgQKAggIrwEADGtfYmFzZU9yYWNsZQIMa19iYXNlT3JhY2xlAA1rX3F1b3RlT3JhY2xlAg1rX3F1b3RlT3JhY2xlAAlrX2JhbGFuY2UCCWtfYmFsYW5jZQAKa19zZXF1ZW5jZQIKa19zZXF1ZW5jZQAOa19wb3NpdGlvblNpemUCDmtfcG9zaXRpb25TaXplABBrX3Bvc2l0aW9uTWFyZ2luAhBrX3Bvc2l0aW9uTWFyZ2luABZrX3Bvc2l0aW9uT3Blbk5vdGlvbmFsAhZrX3Bvc2l0aW9uT3Blbk5vdGlvbmFsAC5rX3Bvc2l0aW9uTGFzdFVwZGF0ZWRDdW11bGF0aXZlUHJlbWl1bUZyYWN0aW9uAhJrX3Bvc2l0aW9uRnJhY3Rpb24AEmtfcG9zaX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zRGVmaW5lZAEFDmNvb3JkaW5hdG9yU3RyBAVhZG1pbgkAnQgCCQERQGV4dHJOYXRpdmUoMTA2MikBCQEFdmFsdWUBBQ5jb29yZGluYXRvclN0cgUPa19hZG1pbl9hZGRyZXNzAwkBCWlzRGVmaW5lZAEFBWFkbWluCQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEJAQV2YWx1ZQEFBWFkbWluCQCsAgIJAKwCAgkArAICAgdzdGF0dXNfCQClCAEFBHRoaXMCAV8JANgEAQgFAnR4AmlkBwkAAgECLnVuYWJsZSB0byB2ZXJpZnk6IGFkbWluIG5vdCBzZXQgaW4gY29vcmRpbmF0b3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXmT5mUn", "height": 2538824, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 858z2JZZsF7GEpGKxhSwRxoJhjU3XzsbQmve6h1bZXd4 Next: EPCxh1RUM4iQk14ZNQ4Zu4JLWuqhrCp89N26M7ShosaL Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction" | |
19 | 19 | ||
20 | 20 | let k_positionSequence = "k_positionSequence" | |
21 | - | ||
22 | - | let k_positionAsset = "k_positionAsset" | |
23 | 21 | ||
24 | 22 | let k_positionFee = "k_positionFee" | |
25 | 23 | ||
57 | 55 | ||
58 | 56 | let k_maxOracleDelay = "k_maxOracleDelay" | |
59 | 57 | ||
60 | - | let k_lastDataStr = "k_lastDataStr" | |
61 | - | ||
62 | - | let k_lastMinuteId = "k_lastMinuteId" | |
63 | - | ||
64 | - | let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice" | |
65 | - | ||
66 | - | let k_twapDataLastPrice = "k_twapDataLastPrice" | |
67 | - | ||
68 | - | let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId" | |
58 | + | let k_fundingMode = "k_fundingMode" | |
69 | 59 | ||
70 | 60 | let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction" | |
71 | 61 | ||
107 | 97 | ||
108 | 98 | let k_quote_asset = "k_quote_asset" | |
109 | 99 | ||
110 | - | let k_quote_staking = "k_quote_staking" | |
111 | - | ||
112 | 100 | let k_staking_address = "k_staking_address" | |
113 | 101 | ||
114 | 102 | let k_miner_address = "k_miner_address" | |
116 | 104 | let k_orders_address = "k_orders_address" | |
117 | 105 | ||
118 | 106 | let k_referral_address = "k_referral_address" | |
119 | - | ||
120 | - | let k_exchange_address = "k_exchange_address" | |
121 | 107 | ||
122 | 108 | let k_nft_manager_address = "k_nft_manager_address" | |
123 | 109 | ||
131 | 117 | ||
132 | 118 | ||
133 | 119 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
134 | - | ||
135 | - | ||
136 | - | func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set") | |
137 | 120 | ||
138 | 121 | ||
139 | 122 | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set") | |
164 | 147 | ||
165 | 148 | let DIR_SHORT = 2 | |
166 | 149 | ||
167 | - | let TWAP_INTERVAL = 15 | |
168 | - | ||
169 | 150 | let SECONDS = 1000 | |
170 | 151 | ||
171 | 152 | let DECIMAL_NUMBERS = 6 | |
179 | 160 | let PNL_OPTION_SPOT = 1 | |
180 | 161 | ||
181 | 162 | let PNL_OPTION_ORACLE = 2 | |
163 | + | ||
164 | + | let FUNDING_ASYMMETRIC = 1 | |
165 | + | ||
166 | + | let FUNDING_SYMMETRIC = 2 | |
182 | 167 | ||
183 | 168 | func s (_x) = (toString(_x) + ",") | |
184 | 169 | ||
203 | 188 | func vmax (_x,_y) = if ((_x >= _y)) | |
204 | 189 | then _x | |
205 | 190 | else _y | |
206 | - | ||
207 | - | ||
208 | - | func listToStr (_list) = if ((size(_list) == 0)) | |
209 | - | then "" | |
210 | - | else makeString(_list, ",") | |
211 | - | ||
212 | - | ||
213 | - | func strToList (_str) = if ((_str == "")) | |
214 | - | then nil | |
215 | - | else split(_str, ",") | |
216 | - | ||
217 | - | ||
218 | - | func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize)) | |
219 | - | then (removeByIndex(_list, 0) :+ _value) | |
220 | - | else (_list :+ _value) | |
221 | 191 | ||
222 | 192 | ||
223 | 193 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
328 | 298 | func maxOracleDelay () = int(k_maxOracleDelay) | |
329 | 299 | ||
330 | 300 | ||
301 | + | func fundingMode () = intOr(k_fundingMode, FUNDING_ASYMMETRIC) | |
302 | + | ||
303 | + | ||
331 | 304 | func lastTimestamp () = lastBlock.timestamp | |
332 | 305 | ||
333 | 306 | ||
355 | 328 | else latestShortCumulativePremiumFraction() | |
356 | 329 | ||
357 | 330 | ||
358 | - | func getPosition (_trader) = { | |
359 | - | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader)) | |
331 | + | func getPosition (_trader,_direction) = { | |
332 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
333 | + | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, positionKey)) | |
360 | 334 | match positionSizeOpt { | |
361 | 335 | case positionSize: Int => | |
362 | - | $Tuple5(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, | |
336 | + | $Tuple5(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, positionKey)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, positionKey)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedTimestamp, positionKey))) | |
363 | 337 | case _ => | |
364 | 338 | $Tuple5(0, 0, 0, 0, 0) | |
365 | 339 | } | |
366 | 340 | } | |
367 | 341 | ||
368 | 342 | ||
369 | - | func getPositionAsset (_trader) = { | |
370 | - | let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader)) | |
371 | - | match positionAssetOpt { | |
372 | - | case positionAsset: String => | |
373 | - | positionAsset | |
374 | - | case _ => | |
375 | - | toBase58String(quoteAsset()) | |
376 | - | } | |
377 | - | } | |
343 | + | func getDirection (_positionSize) = if ((0 > _positionSize)) | |
344 | + | then DIR_SHORT | |
345 | + | else DIR_LONG | |
378 | 346 | ||
379 | 347 | ||
380 | - | func getPositionFee (_trader) = { | |
381 | - | let positionFeeOpt = getInteger(this, toCompositeKey(k_positionFee, _trader)) | |
348 | + | func getPositionFee (_trader,_direction) = { | |
349 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
350 | + | let positionFeeOpt = getInteger(this, toCompositeKey(k_positionFee, positionKey)) | |
382 | 351 | match positionFeeOpt { | |
383 | 352 | case positionFee: Int => | |
384 | 353 | positionFee | |
388 | 357 | } | |
389 | 358 | ||
390 | 359 | ||
391 | - | func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0)) | |
360 | + | func requireOpenPosition (_trader,_direction) = if ((getPosition(_trader, _direction)._1 == 0)) | |
392 | 361 | then throw("No open position") | |
393 | 362 | else true | |
394 | 363 | ||
456 | 425 | let amountBaseAssetBought = if (_isAdd) | |
457 | 426 | then amountBaseAssetBoughtAbs | |
458 | 427 | else -(amountBaseAssetBoughtAbs) | |
459 | - | let $ | |
460 | - | let quoteAssetReserveAfter1 = $ | |
461 | - | let baseAssetReserveAfter1 = $ | |
462 | - | let totalPositionSizeAfter1 = $ | |
428 | + | let $t01558415754 = updateReserve(_isAdd, quoteAssetAmountAdjusted, amountBaseAssetBoughtAbs) | |
429 | + | let quoteAssetReserveAfter1 = $t01558415754._1 | |
430 | + | let baseAssetReserveAfter1 = $t01558415754._2 | |
431 | + | let totalPositionSizeAfter1 = $t01558415754._3 | |
463 | 432 | let priceBefore = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW)) | |
464 | 433 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
465 | 434 | let priceDiff = abs((priceBefore - marketPrice)) | |
487 | 456 | else 0 | |
488 | 457 | let rolloverFee = calcRolloverFee(_oldPositionMargin, _oldPositionLastUpdatedTimestamp) | |
489 | 458 | let signedMargin = (((_marginDelta - rolloverFee) - fundingPayment) + _oldPositionMargin) | |
490 | - | let $ | |
459 | + | let $t01842118548 = if ((0 > signedMargin)) | |
491 | 460 | then $Tuple2(0, abs(signedMargin)) | |
492 | 461 | else $Tuple2(abs(signedMargin), 0) | |
493 | - | let remainMargin = $ | |
494 | - | let badDebt = $ | |
462 | + | let remainMargin = $t01842118548._1 | |
463 | + | let badDebt = $t01842118548._2 | |
495 | 464 | $Tuple4(remainMargin, badDebt, fundingPayment, rolloverFee) | |
496 | 465 | } | |
497 | 466 | ||
509 | 478 | let quoteAssetDelta = abs((quoteAssetAfter - _quoteAssetReserve)) | |
510 | 479 | let quoteAssetSold = muld(quoteAssetDelta, _quoteAssetWeight) | |
511 | 480 | let maxPriceImpactValue = maxPriceImpact() | |
512 | - | let $ | |
513 | - | let quoteAssetReserveAfter1 = $ | |
514 | - | let baseAssetReserveAfter1 = $ | |
515 | - | let totalPositionSizeAfter1 = $ | |
481 | + | let $t01981019972 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount) | |
482 | + | let quoteAssetReserveAfter1 = $t01981019972._1 | |
483 | + | let baseAssetReserveAfter1 = $t01981019972._2 | |
484 | + | let totalPositionSizeAfter1 = $t01981019972._3 | |
516 | 485 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
517 | 486 | let priceDiff = abs((priceBefore - marketPrice)) | |
518 | 487 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
646 | 615 | } | |
647 | 616 | ||
648 | 617 | ||
649 | - | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
650 | - | let $ | |
651 | - | let positionSize = $ | |
652 | - | let positionMargin = $ | |
653 | - | let positionOpenNotional = $ | |
654 | - | let positionLstUpdCPF = $ | |
618 | + | func getPositionNotionalAndUnrealizedPnl (_trader,_direction,_option) = { | |
619 | + | let $t02786728007 = getPosition(_trader, _direction) | |
620 | + | let positionSize = $t02786728007._1 | |
621 | + | let positionMargin = $t02786728007._2 | |
622 | + | let positionOpenNotional = $t02786728007._3 | |
623 | + | let positionLstUpdCPF = $t02786728007._4 | |
655 | 624 | getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), qtAstW(), bsAstR(), bsAstW(), _option) | |
656 | 625 | } | |
657 | 626 | ||
659 | 628 | func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional) | |
660 | 629 | ||
661 | 630 | ||
662 | - | func getMarginRatioByOption (_trader,_option) = { | |
663 | - | let $ | |
664 | - | let positionSize = $ | |
665 | - | let positionMargin = $ | |
666 | - | let pon = $ | |
667 | - | let positionLastUpdatedCPF = $ | |
668 | - | let positionTimestamp = $ | |
669 | - | let $ | |
670 | - | let positionNotional = $ | |
671 | - | let unrealizedPnl = $ | |
672 | - | let $ | |
673 | - | let remainMargin = $ | |
674 | - | let badDebt = $ | |
631 | + | func getMarginRatioByOption (_trader,_direction,_option) = { | |
632 | + | let $t02853928692 = getPosition(_trader, _direction) | |
633 | + | let positionSize = $t02853928692._1 | |
634 | + | let positionMargin = $t02853928692._2 | |
635 | + | let pon = $t02853928692._3 | |
636 | + | let positionLastUpdatedCPF = $t02853928692._4 | |
637 | + | let positionTimestamp = $t02853928692._5 | |
638 | + | let $t02869828803 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, _option) | |
639 | + | let positionNotional = $t02869828803._1 | |
640 | + | let unrealizedPnl = $t02869828803._2 | |
641 | + | let $t02880829020 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLastUpdatedCPF, positionTimestamp, unrealizedPnl) | |
642 | + | let remainMargin = $t02880829020._1 | |
643 | + | let badDebt = $t02880829020._2 | |
675 | 644 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
676 | 645 | } | |
677 | 646 | ||
678 | 647 | ||
679 | - | func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
648 | + | func getMarginRatio (_trader,_direction) = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT) | |
680 | 649 | ||
681 | 650 | ||
682 | 651 | func getPartialLiquidationAmount (_trader,_positionSize) = { | |
683 | - | let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio()))) | |
652 | + | let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader, getDirection(_positionSize)), maintenanceMarginRatio()))) | |
684 | 653 | let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio) | |
685 | 654 | let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false) | |
686 | 655 | let maxExchangedQuoteAssetAmount = swapResult._1 | |
691 | 660 | } | |
692 | 661 | ||
693 | 662 | ||
694 | - | func internalClosePosition (_trader,_size,_fee,_minQuoteAssetAmount,_addToMargin,_checkMaxPriceImpact,_liquidate) = { | |
695 | - | let $ | |
696 | - | let oldPositionSize = $ | |
697 | - | let oldPositionMargin = $ | |
698 | - | let oldPositionOpenNotional = $ | |
699 | - | let oldPositionLstUpdCPF = $ | |
700 | - | let oldPositionTimestamp = $ | |
663 | + | func internalClosePosition (_trader,_direction,_size,_fee,_minQuoteAssetAmount,_addToMargin,_checkMaxPriceImpact,_liquidate) = { | |
664 | + | let $t03018330351 = getPosition(_trader, _direction) | |
665 | + | let oldPositionSize = $t03018330351._1 | |
666 | + | let oldPositionMargin = $t03018330351._2 | |
667 | + | let oldPositionOpenNotional = $t03018330351._3 | |
668 | + | let oldPositionLstUpdCPF = $t03018330351._4 | |
669 | + | let oldPositionTimestamp = $t03018330351._5 | |
701 | 670 | let isLongPosition = (oldPositionSize > 0) | |
702 | 671 | let absOldPositionSize = abs(oldPositionSize) | |
703 | 672 | if (if ((absOldPositionSize >= _size)) | |
705 | 674 | else false) | |
706 | 675 | then { | |
707 | 676 | let isPartialClose = (absOldPositionSize > _size) | |
708 | - | let $ | |
709 | - | let exchangedQuoteAssetAmount = $ | |
710 | - | let quoteAssetReserveAfter = $ | |
711 | - | let baseAssetReserveAfter = $ | |
712 | - | let totalPositionSizeAfter = $ | |
677 | + | let $t03064331094 = swapOutput((oldPositionSize > 0), _size, _checkMaxPriceImpact) | |
678 | + | let exchangedQuoteAssetAmount = $t03064331094._1 | |
679 | + | let quoteAssetReserveAfter = $t03064331094._2 | |
680 | + | let baseAssetReserveAfter = $t03064331094._3 | |
681 | + | let totalPositionSizeAfter = $t03064331094._4 | |
713 | 682 | let exchangedPositionSize = if ((oldPositionSize > 0)) | |
714 | 683 | then -(_size) | |
715 | 684 | else _size | |
716 | - | let $ | |
717 | - | let oldPositionNotional = $ | |
718 | - | let unrealizedPnl = $ | |
685 | + | let $t03130931533 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, PNL_OPTION_SPOT) | |
686 | + | let oldPositionNotional = $t03130931533._1 | |
687 | + | let unrealizedPnl = $t03130931533._2 | |
719 | 688 | let realizedRatio = divd(abs(exchangedPositionSize), absOldPositionSize) | |
720 | 689 | let realizedPnl = muld(unrealizedPnl, realizedRatio) | |
721 | - | let $ | |
722 | - | let remainMarginBefore = $ | |
723 | - | let x1 = $ | |
724 | - | let x2 = $ | |
725 | - | let rolloverFee = $ | |
690 | + | let $t03187432120 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, unrealizedPnl) | |
691 | + | let remainMarginBefore = $t03187432120._1 | |
692 | + | let x1 = $t03187432120._2 | |
693 | + | let x2 = $t03187432120._3 | |
694 | + | let rolloverFee = $t03187432120._4 | |
726 | 695 | let positionBadDebt = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, realizedPnl)._2 | |
727 | 696 | let realizedCloseFee = muld(muld(oldPositionNotional, realizedRatio), _fee) | |
728 | 697 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
730 | 699 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
731 | 700 | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
732 | 701 | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
733 | - | let $ | |
702 | + | let $t03352633912 = if ((newPositionSize == 0)) | |
734 | 703 | then $Tuple2(0, 0) | |
735 | 704 | else $Tuple2(abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize)) | |
736 | - | let newPositionOpenNotional = $ | |
737 | - | let newPositionLstUpdCPF = $ | |
705 | + | let newPositionOpenNotional = $t03352633912._1 | |
706 | + | let newPositionLstUpdCPF = $t03352633912._2 | |
738 | 707 | let openNotionalDelta = (oldPositionOpenNotional - newPositionOpenNotional) | |
739 | - | let marginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
708 | + | let marginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT) | |
740 | 709 | let newPositionMarginWithSameRatio = if ((oldPositionSize > 0)) | |
741 | 710 | then (muld((newPositionOpenNotional + unrealizedPnlAfter), marginRatio) - unrealizedPnlAfter) | |
742 | 711 | else (muld((newPositionOpenNotional - unrealizedPnlAfter), marginRatio) - unrealizedPnlAfter) | |
771 | 740 | } | |
772 | 741 | ||
773 | 742 | ||
774 | - | func getTwapSpotPrice () = { | |
775 | - | let minuteId = ((lastTimestamp() / 1000) / 60) | |
776 | - | let startMinuteId = (minuteId - TWAP_INTERVAL) | |
777 | - | let listStr = valueOrElse(getString(this, k_lastDataStr), "") | |
778 | - | let list = split(listStr, ",") | |
779 | - | func filterFn (accumulator,next) = if ((startMinuteId >= valueOrErrorMessage(parseInt(next), ("getTwapSpotPrice: invalid int: " + listStr)))) | |
780 | - | then (accumulator :+ parseIntValue(next)) | |
781 | - | else accumulator | |
782 | - | ||
783 | - | let listF = { | |
784 | - | let $l = list | |
785 | - | let $s = size($l) | |
786 | - | let $acc0 = nil | |
787 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
788 | - | then $a | |
789 | - | else filterFn($a, $l[$i]) | |
790 | - | ||
791 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
792 | - | then $a | |
793 | - | else throw("List size exceeds 20") | |
794 | - | ||
795 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) | |
796 | - | } | |
797 | - | let maxIndex = if ((size(listF) > 0)) | |
798 | - | then max(listF) | |
799 | - | else valueOrErrorMessage(parseInt(list[0]), ("getTwapSpotPrice: invalid int: " + listStr)) | |
800 | - | let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
801 | - | let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0) | |
802 | - | let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0) | |
803 | - | let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice)) | |
804 | - | let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0) | |
805 | - | let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0) | |
806 | - | let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice)) | |
807 | - | ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL) | |
808 | - | } | |
809 | - | ||
810 | - | ||
811 | 743 | func getTerminalAmmState () = { | |
812 | 744 | let _positionSize = totalPositionSize() | |
813 | 745 | if ((_positionSize == 0)) | |
814 | 746 | then $Tuple2(qtAstR(), bsAstR()) | |
815 | 747 | else { | |
816 | 748 | let direction = (_positionSize > 0) | |
817 | - | let $ | |
818 | - | let currentNetMarketValue = $ | |
819 | - | let terminalQuoteAssetReserve = $ | |
820 | - | let terminalBaseAssetReserve = $ | |
749 | + | let $t03715937338 = swapOutput(direction, abs(_positionSize), false) | |
750 | + | let currentNetMarketValue = $t03715937338._1 | |
751 | + | let terminalQuoteAssetReserve = $t03715937338._2 | |
752 | + | let terminalBaseAssetReserve = $t03715937338._3 | |
821 | 753 | $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve) | |
822 | 754 | } | |
823 | 755 | } | |
857 | 789 | ||
858 | 790 | func getFunding () = { | |
859 | 791 | let underlyingPrice = getOraclePrice() | |
860 | - | let | |
861 | - | let premium = ( | |
792 | + | let spotPrice = getSpotPrice() | |
793 | + | let premium = (spotPrice - underlyingPrice) | |
862 | 794 | if (if (if ((totalShortPositionSize() == 0)) | |
863 | 795 | then true | |
864 | 796 | else (totalLongPositionSize() == 0)) | |
865 | 797 | then true | |
866 | 798 | else isMarketClosed()) | |
867 | - | then $ | |
799 | + | then $Tuple3(0, 0, 0) | |
868 | 800 | else if ((0 > premium)) | |
869 | 801 | then { | |
870 | 802 | let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
871 | - | let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize()) | |
872 | - | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
803 | + | if ((fundingMode() == FUNDING_ASYMMETRIC)) | |
804 | + | then { | |
805 | + | let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize()) | |
806 | + | $Tuple3(shortPremiumFraction, longPremiumFraction, 0) | |
807 | + | } | |
808 | + | else { | |
809 | + | let shortTotalPremiumFraction = abs(muld(shortPremiumFraction, totalShortPositionSize())) | |
810 | + | let longTotalPremiumFraction = abs(muld(shortPremiumFraction, totalLongPositionSize())) | |
811 | + | let premiumToVault = (shortTotalPremiumFraction - longTotalPremiumFraction) | |
812 | + | $Tuple3(shortPremiumFraction, shortPremiumFraction, premiumToVault) | |
813 | + | } | |
873 | 814 | } | |
874 | 815 | else { | |
875 | 816 | let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
876 | - | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
877 | - | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
817 | + | if ((fundingMode() == FUNDING_ASYMMETRIC)) | |
818 | + | then { | |
819 | + | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
820 | + | $Tuple3(shortPremiumFraction, longPremiumFraction, 0) | |
821 | + | } | |
822 | + | else { | |
823 | + | let longTotalPremiumFraction = abs(muld(longPremiumFraction, totalLongPositionSize())) | |
824 | + | let shortTotalPremiumFraction = abs(muld(longPremiumFraction, totalShortPositionSize())) | |
825 | + | let premiumToVault = (longTotalPremiumFraction - shortTotalPremiumFraction) | |
826 | + | $Tuple3(longPremiumFraction, longPremiumFraction, premiumToVault) | |
827 | + | } | |
878 | 828 | } | |
879 | 829 | } | |
880 | 830 | ||
882 | 832 | func getAdjustedFee (_artifactId,_baseFeeDiscount) = { | |
883 | 833 | let baseFeeRaw = fee() | |
884 | 834 | let baseFee = muld(baseFeeRaw, _baseFeeDiscount) | |
885 | - | let $ | |
835 | + | let $t04191342408 = if ((_artifactId != "")) | |
886 | 836 | then { | |
887 | 837 | let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, _artifactId)) | |
888 | 838 | if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE)) | |
894 | 844 | else throw("Invalid attached artifact") | |
895 | 845 | } | |
896 | 846 | else $Tuple2(baseFee, false) | |
897 | - | let adjustedFee = $ | |
898 | - | let burnArtifact = $ | |
847 | + | let adjustedFee = $t04191342408._1 | |
848 | + | let burnArtifact = $t04191342408._2 | |
899 | 849 | $Tuple2(adjustedFee, burnArtifact) | |
900 | 850 | } | |
901 | - | ||
902 | - | ||
903 | - | func isSameAssetOrNoPosition (_trader,_assetId) = { | |
904 | - | let oldPositionSize = getPosition(_trader)._1 | |
905 | - | if ((oldPositionSize == 0)) | |
906 | - | then true | |
907 | - | else (getPositionAsset(_trader) == _assetId) | |
908 | - | } | |
909 | - | ||
910 | - | ||
911 | - | func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId) | |
912 | 851 | ||
913 | 852 | ||
914 | 853 | func getForTraderWithArtifact (_trader,_artifactId) = { | |
921 | 860 | case _ => | |
922 | 861 | throw("Invalid computeFeeDiscount result") | |
923 | 862 | } | |
924 | - | let $ | |
925 | - | let adjustedFee = $ | |
926 | - | let burnArtifact = $ | |
863 | + | let $t04275442828 = getAdjustedFee(_artifactId, feeDiscount) | |
864 | + | let adjustedFee = $t04275442828._1 | |
865 | + | let burnArtifact = $t04275442828._2 | |
927 | 866 | $Tuple2(adjustedFee, burnArtifact) | |
928 | 867 | } | |
929 | 868 | else throw("Strict value is not equal to itself.") | |
945 | 884 | } | |
946 | 885 | ||
947 | 886 | ||
948 | - | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional), IntegerEntry(k_feeToStakersPercent, _feeToStakersPercent), IntegerEntry(k_maxOracleDelay, _feeToStakersPercent), IntegerEntry(k_rolloverFee, _rolloverFee)] | |
887 | + | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional), IntegerEntry(k_feeToStakersPercent, _feeToStakersPercent), IntegerEntry(k_maxOracleDelay, _feeToStakersPercent), IntegerEntry(k_rolloverFee, _rolloverFee), IntegerEntry(k_fundingMode, _fundingMode)] | |
949 | 888 | ||
950 | 889 | ||
951 | 890 | func updateFunding (_nextFundingBlock,_latestLongCumulativePremiumFraction,_latestShortCumulativePremiumFraction,_longFundingRate,_shortFundingRate) = [IntegerEntry(k_nextFundingBlock, _nextFundingBlock), IntegerEntry(k_latestLongCumulativePremiumFraction, _latestLongCumulativePremiumFraction), IntegerEntry(k_latestShortCumulativePremiumFraction, _latestShortCumulativePremiumFraction), IntegerEntry(k_longFundingRate, _longFundingRate), IntegerEntry(k_shortFundingRate, _shortFundingRate)] | |
952 | 891 | ||
953 | 892 | ||
954 | - | func incrementPositionSequenceNumber (_isNewPosition,_address) = if (_isNewPosition) | |
955 | - | then { | |
956 | - | let currentSequence = lastSequence() | |
957 | - | [IntegerEntry(toCompositeKey(k_positionSequence, _address), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))] | |
958 | - | } | |
959 | - | else nil | |
893 | + | func incrementPositionSequenceNumber (_isNewPosition,_trader,_direction) = { | |
894 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
895 | + | if (_isNewPosition) | |
896 | + | then { | |
897 | + | let currentSequence = lastSequence() | |
898 | + | [IntegerEntry(toCompositeKey(k_positionSequence, positionKey), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))] | |
899 | + | } | |
900 | + | else nil | |
901 | + | } | |
960 | 902 | ||
961 | 903 | ||
962 | - | func updatePositionFee (_isNewPosition,_address,_fee) = if (_isNewPosition) | |
963 | - | then [IntegerEntry(toCompositeKey(k_positionFee, _address), _fee)] | |
964 | - | else nil | |
904 | + | func updatePositionFee (_isNewPosition,_trader,_direction,_fee) = { | |
905 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
906 | + | if (_isNewPosition) | |
907 | + | then [IntegerEntry(toCompositeKey(k_positionFee, positionKey), _fee)] | |
908 | + | else nil | |
909 | + | } | |
965 | 910 | ||
966 | 911 | ||
967 | - | func updatePosition (_address,_size,_margin,_openNotional,_latestCumulativePremiumFraction,_latestTimestamp) = [IntegerEntry(toCompositeKey(k_positionSize, _address), _size), IntegerEntry(toCompositeKey(k_positionMargin, _address), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, _address), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address), _latestCumulativePremiumFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _address), _latestTimestamp)] | |
968 | - | ||
969 | - | ||
970 | - | func appendTwap (_price) = { | |
971 | - | let minuteId = ((lastTimestamp() / 1000) / 60) | |
972 | - | let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
973 | - | if ((previousMinuteId > minuteId)) | |
974 | - | then throw("TWAP out-of-order") | |
975 | - | else { | |
976 | - | let lastMinuteId = if ((previousMinuteId == 0)) | |
977 | - | then minuteId | |
978 | - | else previousMinuteId | |
979 | - | if ((minuteId > previousMinuteId)) | |
980 | - | then { | |
981 | - | let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0) | |
982 | - | let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), _price) | |
983 | - | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice)) | |
984 | - | let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId)) | |
985 | - | [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), _price), IntegerEntry(toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId)), previousMinuteId), IntegerEntry(k_lastMinuteId, minuteId), StringEntry(k_lastDataStr, listToStr(list))] | |
986 | - | } | |
987 | - | else { | |
988 | - | let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0) | |
989 | - | let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0) | |
990 | - | let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), _price) | |
991 | - | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice)) | |
992 | - | [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), _price)] | |
993 | - | } | |
994 | - | } | |
912 | + | func updatePosition (_trader,_size,_margin,_openNotional,_latestCumulativePremiumFraction,_latestTimestamp) = { | |
913 | + | let direction = getDirection(_size) | |
914 | + | let positionKey = ((_trader + "_") + toString(direction)) | |
915 | + | [IntegerEntry(toCompositeKey(k_positionSize, positionKey), _size), IntegerEntry(toCompositeKey(k_positionMargin, positionKey), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, positionKey), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey), _latestCumulativePremiumFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey), _latestTimestamp)] | |
995 | 916 | } | |
996 | 917 | ||
997 | 918 | ||
1006 | 927 | let _bsAstW = bsAstW() | |
1007 | 928 | if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter)) | |
1008 | 929 | then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter))) | |
1009 | - | else | |
930 | + | else (updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize), IntegerEntry(k_openInterestLong, _totalLongOpenNotional), IntegerEntry(k_openInterestShort, _totalShortOpenNotional)]) | |
1010 | 931 | } | |
1011 | 932 | ||
1012 | 933 | ||
1013 | - | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address)), DeleteEntry(toCompositeKey(k_positionFee, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _address))] | |
934 | + | func deletePosition (_trader,_direction) = { | |
935 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
936 | + | [DeleteEntry(toCompositeKey(k_positionSize, positionKey)), DeleteEntry(toCompositeKey(k_positionMargin, positionKey)), DeleteEntry(toCompositeKey(k_positionOpenNotional, positionKey)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey)), DeleteEntry(toCompositeKey(k_positionFee, positionKey)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey))] | |
937 | + | } | |
1014 | 938 | ||
1015 | 939 | ||
1016 | 940 | func withdraw (_address,_amount) = { | |
1076 | 1000 | let qtAstRAfter = (_qtAstR + _quoteAssetAmount) | |
1077 | 1001 | let baseAssetAmountToAdd = (divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR) | |
1078 | 1002 | let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd) | |
1079 | - | let $ | |
1080 | - | let newQuoteAssetWeight = $ | |
1081 | - | let newBaseAssetWeight = $ | |
1082 | - | let marginToVault = $ | |
1003 | + | let $t05108351234 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter) | |
1004 | + | let newQuoteAssetWeight = $t05108351234._1 | |
1005 | + | let newBaseAssetWeight = $t05108351234._2 | |
1006 | + | let marginToVault = $t05108351234._3 | |
1083 | 1007 | let doExchangePnL = if ((marginToVault != 0)) | |
1084 | 1008 | then { | |
1085 | 1009 | let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil) | |
1109 | 1033 | let qtAstRAfter = (_qtAstR - _quoteAssetAmount) | |
1110 | 1034 | let baseAssetAmountToRemove = abs((divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR)) | |
1111 | 1035 | let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove) | |
1112 | - | let $ | |
1113 | - | let newQuoteAssetWeight = $ | |
1114 | - | let newBaseAssetWeight = $ | |
1115 | - | let marginToVault = $ | |
1036 | + | let $t05233052481 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter) | |
1037 | + | let newQuoteAssetWeight = $t05233052481._1 | |
1038 | + | let newBaseAssetWeight = $t05233052481._2 | |
1039 | + | let marginToVault = $t05233052481._3 | |
1116 | 1040 | let doExchangePnL = if ((marginToVault != 0)) | |
1117 | 1041 | then { | |
1118 | 1042 | let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil) | |
1129 | 1053 | ||
1130 | 1054 | ||
1131 | 1055 | @Callable(i) | |
1132 | - | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = if ((i.caller != adminAddress())) | |
1056 | + | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _fundingPeriod)) | |
1057 | + | then true | |
1058 | + | else (0 >= _initMarginRatio)) | |
1059 | + | then true | |
1060 | + | else (0 >= _mmr)) | |
1061 | + | then true | |
1062 | + | else (0 >= _liquidationFeeRatio)) | |
1063 | + | then true | |
1064 | + | else (0 >= _fee)) | |
1065 | + | then true | |
1066 | + | else (0 >= _spreadLimit)) | |
1067 | + | then true | |
1068 | + | else (0 >= _maxPriceImpact)) | |
1069 | + | then true | |
1070 | + | else (0 >= _partialLiquidationRatio)) | |
1071 | + | then true | |
1072 | + | else (0 >= _maxPriceSpread)) | |
1073 | + | then true | |
1074 | + | else (0 >= _maxOpenNotional)) | |
1075 | + | then true | |
1076 | + | else (0 >= _feeToStakersPercent)) | |
1077 | + | then true | |
1078 | + | else (_feeToStakersPercent > DECIMAL_UNIT)) | |
1079 | + | then true | |
1080 | + | else (0 >= _maxOracleDelay)) | |
1081 | + | then true | |
1082 | + | else (0 >= _rolloverFee)) | |
1083 | + | then true | |
1084 | + | else if ((_fundingMode != FUNDING_SYMMETRIC)) | |
1085 | + | then (_fundingMode != FUNDING_ASYMMETRIC) | |
1086 | + | else false) | |
1087 | + | then true | |
1088 | + | else !(initialized())) | |
1089 | + | then true | |
1090 | + | else (i.caller != adminAddress())) | |
1133 | 1091 | then throw("Invalid changeSettings params") | |
1134 | - | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee) | |
1092 | + | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee, _fundingMode) | |
1135 | 1093 | ||
1136 | 1094 | ||
1137 | 1095 | ||
1138 | 1096 | @Callable(i) | |
1139 | - | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_baseOracleData,_quoteOracleData,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
1097 | + | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_baseOracleData,_quoteOracleData,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
1140 | 1098 | then true | |
1141 | 1099 | else (0 >= _bsAstR)) | |
1142 | 1100 | then true | |
1168 | 1126 | then true | |
1169 | 1127 | else (0 >= _rolloverFee)) | |
1170 | 1128 | then true | |
1129 | + | else if ((_fundingMode != FUNDING_SYMMETRIC)) | |
1130 | + | then (_fundingMode != FUNDING_ASYMMETRIC) | |
1131 | + | else false) | |
1132 | + | then true | |
1171 | 1133 | else initialized()) | |
1172 | 1134 | then true | |
1173 | 1135 | else (i.caller != this)) | |
1174 | 1136 | then throw("Invalid initialize parameters") | |
1175 | - | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee)) ++ updateFunding((lastTimestamp() + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_quoteOracle, _quoteOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))]) | |
1137 | + | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee, _fundingMode)) ++ updateFunding((lastTimestamp() + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_quoteOracle, _quoteOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))]) | |
1176 | 1138 | ||
1177 | 1139 | ||
1178 | 1140 | ||
1189 | 1151 | let _assetId = i.payments[0].assetId | |
1190 | 1152 | let _assetIdStr = toBase58String(value(_assetId)) | |
1191 | 1153 | let isQuoteAsset = (_assetId == quoteAsset()) | |
1192 | - | if (if (if (if (if (if (if (if (if ( | |
1154 | + | if (if (if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
1193 | 1155 | then (_direction != DIR_SHORT) | |
1194 | 1156 | else false) | |
1195 | 1157 | then true | |
1198 | 1160 | else !(initialized())) | |
1199 | 1161 | then true | |
1200 | 1162 | else !(isQuoteAsset)) | |
1201 | - | then true | |
1202 | - | else !(isSameAssetOrNoPosition(_trader, _assetIdStr))) | |
1203 | 1163 | then true | |
1204 | 1164 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
1205 | 1165 | then true | |
1210 | 1170 | else isMarketClosed()) | |
1211 | 1171 | then throw("Invalid increasePosition parameters") | |
1212 | 1172 | else { | |
1213 | - | let $ | |
1214 | - | let adjustedFee = $ | |
1215 | - | let burnArtifact = $ | |
1173 | + | let $t05855158700 = getForTraderWithArtifact(_trader, getArtifactId(i)) | |
1174 | + | let adjustedFee = $t05855158700._1 | |
1175 | + | let burnArtifact = $t05855158700._2 | |
1216 | 1176 | let _amount = divd(_rawAmount, (muld(adjustedFee, _leverage) + DECIMAL_UNIT)) | |
1217 | 1177 | let distributeFeeAmount = (_rawAmount - _amount) | |
1218 | 1178 | let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1225 | 1185 | throw("Invalid referrerFee") | |
1226 | 1186 | } | |
1227 | 1187 | let feeAmount = (distributeFeeAmount - referrerFee) | |
1228 | - | let $ | |
1229 | - | let oldPositionSize = $ | |
1230 | - | let oldPositionMargin = $ | |
1231 | - | let oldPositionOpenNotional = $ | |
1232 | - | let oldPositionLstUpdCPF = $ | |
1233 | - | let oldPositionTimestamp = $ | |
1188 | + | let $t05919659376 = getPosition(_trader, _direction) | |
1189 | + | let oldPositionSize = $t05919659376._1 | |
1190 | + | let oldPositionMargin = $t05919659376._2 | |
1191 | + | let oldPositionOpenNotional = $t05919659376._3 | |
1192 | + | let oldPositionLstUpdCPF = $t05919659376._4 | |
1193 | + | let oldPositionTimestamp = $t05919659376._5 | |
1234 | 1194 | let isNewPosition = (oldPositionSize == 0) | |
1235 | 1195 | let isSameDirection = if ((oldPositionSize > 0)) | |
1236 | 1196 | then (_direction == DIR_LONG) | |
1239 | 1199 | then isSameDirection | |
1240 | 1200 | else false | |
1241 | 1201 | let isAdd = (_direction == DIR_LONG) | |
1242 | - | let $ | |
1202 | + | let $t05966562798 = if (if (isNewPosition) | |
1243 | 1203 | then true | |
1244 | 1204 | else expandExisting) | |
1245 | 1205 | then { | |
1246 | 1206 | let openNotional = muld(_amount, _leverage) | |
1247 | - | let $ | |
1248 | - | let amountBaseAssetBought = $ | |
1249 | - | let quoteAssetReserveAfter = $ | |
1250 | - | let baseAssetReserveAfter = $ | |
1251 | - | let totalPositionSizeAfter = $ | |
1207 | + | let $t06017460347 = swapInput(isAdd, openNotional) | |
1208 | + | let amountBaseAssetBought = $t06017460347._1 | |
1209 | + | let quoteAssetReserveAfter = $t06017460347._2 | |
1210 | + | let baseAssetReserveAfter = $t06017460347._3 | |
1211 | + | let totalPositionSizeAfter = $t06017460347._4 | |
1252 | 1212 | if (if ((_minBaseAssetAmount != 0)) | |
1253 | 1213 | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
1254 | 1214 | else false) | |
1261 | 1221 | let totalShortOpenInterestAfter = (openInterestShort() + (if ((0 > newPositionSize)) | |
1262 | 1222 | then openNotional | |
1263 | 1223 | else 0)) | |
1264 | - | let $ | |
1265 | - | let remainMargin = $ | |
1266 | - | let x1 = $ | |
1267 | - | let x2 = $ | |
1268 | - | let rolloverFee = $ | |
1224 | + | let $t06089361168 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, _amount) | |
1225 | + | let remainMargin = $t06089361168._1 | |
1226 | + | let x1 = $t06089361168._2 | |
1227 | + | let x2 = $t06089361168._3 | |
1228 | + | let rolloverFee = $t06089361168._4 | |
1269 | 1229 | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
1270 | 1230 | then throw("Over max spread limit") | |
1271 | 1231 | else if (!(requireNotOverMaxOpenNotional(totalLongOpenInterestAfter, totalShortOpenInterestAfter))) | |
1279 | 1239 | } | |
1280 | 1240 | else { | |
1281 | 1241 | let openNotional = muld(_amount, _leverage) | |
1282 | - | let $ | |
1283 | - | let oldPositionNotional = $ | |
1284 | - | let unrealizedPnl = $ | |
1242 | + | let $t06248662614 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), _direction, PNL_OPTION_SPOT) | |
1243 | + | let oldPositionNotional = $t06248662614._1 | |
1244 | + | let unrealizedPnl = $t06248662614._2 | |
1285 | 1245 | if ((oldPositionNotional > openNotional)) | |
1286 | 1246 | then throw("Use decreasePosition to decrease position size") | |
1287 | 1247 | else throw("Close position first") | |
1288 | 1248 | } | |
1289 | - | let newPositionSize = $ | |
1290 | - | let newPositionRemainMargin = $ | |
1291 | - | let newPositionOpenNotional = $ | |
1292 | - | let newPositionLatestCPF = $ | |
1293 | - | let newPositionTimestamp = $ | |
1294 | - | let baseAssetReserveAfter = $ | |
1295 | - | let quoteAssetReserveAfter = $ | |
1296 | - | let totalPositionSizeAfter = $ | |
1297 | - | let openInterestNotionalAfter = $ | |
1298 | - | let totalLongAfter = $ | |
1299 | - | let totalShortAfter = $ | |
1300 | - | let totalLongOpenInterestAfter = $ | |
1301 | - | let totalShortOpenInterestAfter = $ | |
1302 | - | let rolloverFee = $ | |
1303 | - | let $ | |
1304 | - | let feeToStakers = $ | |
1305 | - | let feeToVault = $ | |
1249 | + | let newPositionSize = $t05966562798._1 | |
1250 | + | let newPositionRemainMargin = $t05966562798._2 | |
1251 | + | let newPositionOpenNotional = $t05966562798._3 | |
1252 | + | let newPositionLatestCPF = $t05966562798._4 | |
1253 | + | let newPositionTimestamp = $t05966562798._5 | |
1254 | + | let baseAssetReserveAfter = $t05966562798._6 | |
1255 | + | let quoteAssetReserveAfter = $t05966562798._7 | |
1256 | + | let totalPositionSizeAfter = $t05966562798._8 | |
1257 | + | let openInterestNotionalAfter = $t05966562798._9 | |
1258 | + | let totalLongAfter = $t05966562798._10 | |
1259 | + | let totalShortAfter = $t05966562798._11 | |
1260 | + | let totalLongOpenInterestAfter = $t05966562798._12 | |
1261 | + | let totalShortOpenInterestAfter = $t05966562798._13 | |
1262 | + | let rolloverFee = $t05966562798._14 | |
1263 | + | let $t06280462875 = distributeFee((feeAmount + rolloverFee)) | |
1264 | + | let feeToStakers = $t06280462875._1 | |
1265 | + | let feeToVault = $t06280462875._2 | |
1306 | 1266 | let stake = if ((_amount >= rolloverFee)) | |
1307 | 1267 | then invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), (_amount - rolloverFee))]) | |
1308 | 1268 | else invoke(vaultAddress(), "withdrawLocked", [(rolloverFee - _amount)], nil) | |
1316 | 1276 | then { | |
1317 | 1277 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1318 | 1278 | if ((notifyNotional == notifyNotional)) | |
1319 | - | then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF, newPositionTimestamp) ++ incrementPositionSequenceNumber(isNewPosition, _trader)) ++ updatePositionFee(isNewPosition, _trader, adjustedFee)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doBurnArtifact(burnArtifact, i)) | |
1279 | + | then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF, newPositionTimestamp) ++ incrementPositionSequenceNumber(isNewPosition, _trader, _direction)) ++ updatePositionFee(isNewPosition, _trader, _direction, adjustedFee)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doBurnArtifact(burnArtifact, i)) | |
1320 | 1280 | else throw("Strict value is not equal to itself.") | |
1321 | 1281 | } | |
1322 | 1282 | else throw("Strict value is not equal to itself.") | |
1336 | 1296 | ||
1337 | 1297 | ||
1338 | 1298 | @Callable(i) | |
1339 | - | func addMargin () = { | |
1299 | + | func addMargin (_direction) = { | |
1340 | 1300 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1341 | 1301 | if ((sync == sync)) | |
1342 | 1302 | then { | |
1348 | 1308 | let _assetId = i.payments[0].assetId | |
1349 | 1309 | let _assetIdStr = toBase58String(value(_assetId)) | |
1350 | 1310 | let isQuoteAsset = (_assetId == quoteAsset()) | |
1351 | - | if (if (if (if (if ( | |
1311 | + | if (if (if (if (if (!(isQuoteAsset)) | |
1352 | 1312 | then true | |
1353 | - | else !(requireOpenPosition(toString(i.caller)))) | |
1354 | - | then true | |
1355 | - | else !(isSameAsset(_trader, _assetIdStr))) | |
1313 | + | else !(requireOpenPosition(toString(i.caller), _direction))) | |
1356 | 1314 | then true | |
1357 | 1315 | else !(initialized())) | |
1358 | 1316 | then true | |
1359 | 1317 | else paused()) | |
1360 | 1318 | then true | |
1361 | - | else closeOnly()) | |
1362 | - | then true | |
1363 | 1319 | else isMarketClosed()) | |
1364 | 1320 | then throw("Invalid addMargin parameters") | |
1365 | 1321 | else { | |
1366 | - | let $ | |
1367 | - | let oldPositionSize = $ | |
1368 | - | let oldPositionMargin = $ | |
1369 | - | let oldPositionOpenNotional = $ | |
1370 | - | let oldPositionLstUpdCPF = $ | |
1371 | - | let oldPositionTimestamp = $ | |
1322 | + | let $t06512265302 = getPosition(_trader, _direction) | |
1323 | + | let oldPositionSize = $t06512265302._1 | |
1324 | + | let oldPositionMargin = $t06512265302._2 | |
1325 | + | let oldPositionOpenNotional = $t06512265302._3 | |
1326 | + | let oldPositionLstUpdCPF = $t06512265302._4 | |
1327 | + | let oldPositionTimestamp = $t06512265302._5 | |
1372 | 1328 | let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1373 | 1329 | if ((stake == stake)) | |
1374 | 1330 | then { | |
1375 | 1331 | let rolloverFee = calcRolloverFee(oldPositionMargin, oldPositionTimestamp) | |
1376 | 1332 | let doTransferFeeToStakers = if ((rolloverFee > 0)) | |
1377 | 1333 | then { | |
1378 | - | let $ | |
1379 | - | let feeToStakers = $ | |
1380 | - | let feeToVault = $ | |
1334 | + | let $t06558765646 = distributeFee(rolloverFee) | |
1335 | + | let feeToStakers = $t06558765646._1 | |
1336 | + | let feeToVault = $t06558765646._2 | |
1381 | 1337 | let unstake = invoke(vaultAddress(), "withdrawLocked", [feeToStakers], nil) | |
1382 | 1338 | if ((unstake == unstake)) | |
1383 | 1339 | then { | |
1404 | 1360 | ||
1405 | 1361 | ||
1406 | 1362 | @Callable(i) | |
1407 | - | func removeMargin (_amount) = { | |
1363 | + | func removeMargin (_amount,_direction) = { | |
1408 | 1364 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1409 | 1365 | if ((sync == sync)) | |
1410 | 1366 | then { | |
1414 | 1370 | let _trader = toString(i.caller) | |
1415 | 1371 | if (if (if (if (if ((0 >= _amount)) | |
1416 | 1372 | then true | |
1417 | - | else !(requireOpenPosition(_trader))) | |
1373 | + | else !(requireOpenPosition(_trader, _direction))) | |
1418 | 1374 | then true | |
1419 | 1375 | else !(initialized())) | |
1420 | 1376 | then true | |
1423 | 1379 | else isMarketClosed()) | |
1424 | 1380 | then throw("Invalid removeMargin parameters") | |
1425 | 1381 | else { | |
1426 | - | let $ | |
1427 | - | let oldPositionSize = $ | |
1428 | - | let oldPositionMargin = $ | |
1429 | - | let oldPositionOpenNotional = $ | |
1430 | - | let oldPositionLstUpdCPF = $ | |
1431 | - | let oldPositionTimestamp = $ | |
1432 | - | let $ | |
1433 | - | let remainMargin = $ | |
1434 | - | let badDebt = $ | |
1435 | - | let fundingPayment = $ | |
1436 | - | let rolloverFee = $ | |
1382 | + | let $t06705067230 = getPosition(_trader, _direction) | |
1383 | + | let oldPositionSize = $t06705067230._1 | |
1384 | + | let oldPositionMargin = $t06705067230._2 | |
1385 | + | let oldPositionOpenNotional = $t06705067230._3 | |
1386 | + | let oldPositionLstUpdCPF = $t06705067230._4 | |
1387 | + | let oldPositionTimestamp = $t06705067230._5 | |
1388 | + | let $t06723667485 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, -(_amount)) | |
1389 | + | let remainMargin = $t06723667485._1 | |
1390 | + | let badDebt = $t06723667485._2 | |
1391 | + | let fundingPayment = $t06723667485._3 | |
1392 | + | let rolloverFee = $t06723667485._4 | |
1437 | 1393 | if ((badDebt != 0)) | |
1438 | 1394 | then throw("Invalid removed margin amount") | |
1439 | 1395 | else { | |
1441 | 1397 | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1442 | 1398 | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1443 | 1399 | else { | |
1444 | - | let $ | |
1445 | - | let feeToStakers = $ | |
1446 | - | let feeToVault = $ | |
1400 | + | let $t06787167930 = distributeFee(rolloverFee) | |
1401 | + | let feeToStakers = $t06787167930._1 | |
1402 | + | let feeToVault = $t06787167930._2 | |
1447 | 1403 | let doTransferFeeToStakers = if ((rolloverFee > 0)) | |
1448 | 1404 | then { | |
1449 | 1405 | let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(feeToVault)], nil) | |
1472 | 1428 | ||
1473 | 1429 | ||
1474 | 1430 | @Callable(i) | |
1475 | - | func closePosition (_size,_minQuoteAssetAmount,_addToMargin) = { | |
1431 | + | func closePosition (_size,_direction,_minQuoteAssetAmount,_addToMargin) = { | |
1476 | 1432 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1477 | 1433 | if ((sync == sync)) | |
1478 | 1434 | then { | |
1481 | 1437 | then { | |
1482 | 1438 | let _trader = getActualCaller(i) | |
1483 | 1439 | let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller") | |
1484 | - | let positionFee = getPositionFee(_trader) | |
1485 | - | if (if (if (if (if (if (!(requireOpenPosition(_trader))) | |
1440 | + | let positionFee = getPositionFee(_trader, _direction) | |
1441 | + | if (if (if (if (if (if (!(requireOpenPosition(_trader, _direction))) | |
1486 | 1442 | then true | |
1487 | 1443 | else !(initialized())) | |
1488 | 1444 | then true | |
1495 | 1451 | else isMarketClosed()) | |
1496 | 1452 | then throw("Invalid closePosition parameters") | |
1497 | 1453 | else { | |
1498 | - | let oldPositionTimestamp = getPosition(_trader)._5 | |
1499 | - | let $ | |
1500 | - | let newPositionSize = $ | |
1501 | - | let newPositionMargin = $ | |
1502 | - | let newPositionOpenNotional = $ | |
1503 | - | let newPositionLstUpdCPF = $ | |
1504 | - | let positionBadDebt = $ | |
1505 | - | let realizedPnl = $ | |
1506 | - | let marginToTrader = $ | |
1507 | - | let quoteAssetReserveAfter = $ | |
1508 | - | let baseAssetReserveAfter = $ | |
1509 | - | let totalPositionSizeAfter = $ | |
1510 | - | let openInterestNotionalAfter = $ | |
1511 | - | let totalLongAfter = $ | |
1512 | - | let totalShortAfter = $ | |
1513 | - | let totalLongOpenInterestAfter = $ | |
1514 | - | let totalShortOpenInterestAfter = $ | |
1515 | - | let realizedFee = $ | |
1454 | + | let oldPositionTimestamp = getPosition(_trader, _direction)._5 | |
1455 | + | let $t07015870761 = internalClosePosition(_trader, _direction, _size, positionFee, _minQuoteAssetAmount, _addToMargin, true, true) | |
1456 | + | let newPositionSize = $t07015870761._1 | |
1457 | + | let newPositionMargin = $t07015870761._2 | |
1458 | + | let newPositionOpenNotional = $t07015870761._3 | |
1459 | + | let newPositionLstUpdCPF = $t07015870761._4 | |
1460 | + | let positionBadDebt = $t07015870761._5 | |
1461 | + | let realizedPnl = $t07015870761._6 | |
1462 | + | let marginToTrader = $t07015870761._7 | |
1463 | + | let quoteAssetReserveAfter = $t07015870761._8 | |
1464 | + | let baseAssetReserveAfter = $t07015870761._9 | |
1465 | + | let totalPositionSizeAfter = $t07015870761._10 | |
1466 | + | let openInterestNotionalAfter = $t07015870761._11 | |
1467 | + | let totalLongAfter = $t07015870761._12 | |
1468 | + | let totalShortAfter = $t07015870761._13 | |
1469 | + | let totalLongOpenInterestAfter = $t07015870761._14 | |
1470 | + | let totalShortOpenInterestAfter = $t07015870761._15 | |
1471 | + | let realizedFee = $t07015870761._16 | |
1516 | 1472 | if ((positionBadDebt > 0)) | |
1517 | 1473 | then throw("Invalid closePosition parameters: bad debt") | |
1518 | 1474 | else if ((oldPositionTimestamp >= lastTimestamp())) | |
1527 | 1483 | let unstake = invoke(vaultAddress(), "withdrawLocked", [withdrawAmount], nil) | |
1528 | 1484 | if ((unstake == unstake)) | |
1529 | 1485 | then { | |
1530 | - | let $t06970569764 = distributeFee(realizedFee) | |
1531 | - | let feeToStakers = $t06970569764._1 | |
1532 | - | let feeToVault = $t06970569764._2 | |
1533 | - | let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)]) | |
1534 | - | if ((depositVault == depositVault)) | |
1486 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), realizedFee)]) | |
1487 | + | if ((referrerFeeAny == referrerFeeAny)) | |
1535 | 1488 | then { | |
1536 | - | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, realizedFee], nil) | |
1537 | - | if ((notifyFee == notifyFee)) | |
1489 | + | let referrerFee = match referrerFeeAny { | |
1490 | + | case x: Int => | |
1491 | + | x | |
1492 | + | case _ => | |
1493 | + | throw("Invalid referrerFee") | |
1494 | + | } | |
1495 | + | let $t07173371806 = distributeFee((realizedFee - referrerFee)) | |
1496 | + | let feeToStakers = $t07173371806._1 | |
1497 | + | let feeToVault = $t07173371806._2 | |
1498 | + | let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)]) | |
1499 | + | if ((depositVault == depositVault)) | |
1538 | 1500 | then { | |
1539 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1540 | - | if ((notifyNotional == notifyNotional)) | |
1541 | - | then (((((if (isPartialClose) | |
1542 | - | then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp()) | |
1543 | - | else deletePosition(_trader)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((marginToTrader > 0)) | |
1544 | - | then withdraw(_traderAddress, marginToTrader) | |
1545 | - | else nil)) ++ updateBalance(ammNewBalance)) ++ transferFee(feeToStakers)) | |
1501 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, realizedFee], nil) | |
1502 | + | if ((notifyFee == notifyFee)) | |
1503 | + | then { | |
1504 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1505 | + | if ((notifyNotional == notifyNotional)) | |
1506 | + | then (((((if (isPartialClose) | |
1507 | + | then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp()) | |
1508 | + | else deletePosition(_trader, _direction)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((marginToTrader > 0)) | |
1509 | + | then withdraw(_traderAddress, marginToTrader) | |
1510 | + | else nil)) ++ updateBalance(ammNewBalance)) ++ transferFee(feeToStakers)) | |
1511 | + | else throw("Strict value is not equal to itself.") | |
1512 | + | } | |
1546 | 1513 | else throw("Strict value is not equal to itself.") | |
1547 | 1514 | } | |
1548 | 1515 | else throw("Strict value is not equal to itself.") | |
1561 | 1528 | ||
1562 | 1529 | ||
1563 | 1530 | @Callable(i) | |
1564 | - | func liquidate (_trader) = { | |
1531 | + | func liquidate (_trader,_direction) = { | |
1565 | 1532 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1566 | 1533 | if ((sync == sync)) | |
1567 | 1534 | then { | |
1568 | - | let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
1535 | + | let spotMarginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT) | |
1569 | 1536 | let liquidationMarginRatio = if (isOverFluctuationLimit()) | |
1570 | 1537 | then { | |
1571 | - | let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE) | |
1538 | + | let oracleMarginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_ORACLE) | |
1572 | 1539 | vmax(spotMarginRatio, oracleMarginRatio) | |
1573 | 1540 | } | |
1574 | 1541 | else spotMarginRatio | |
1575 | 1542 | if (if (if (if (if (!(requireMoreMarginRatio(liquidationMarginRatio, maintenanceMarginRatio(), false))) | |
1576 | 1543 | then true | |
1577 | - | else !(requireOpenPosition(_trader))) | |
1544 | + | else !(requireOpenPosition(_trader, _direction))) | |
1578 | 1545 | then true | |
1579 | 1546 | else !(initialized())) | |
1580 | 1547 | then true | |
1588 | 1555 | else false) | |
1589 | 1556 | then (DECIMAL_UNIT > partialLiquidationRatio()) | |
1590 | 1557 | else false | |
1591 | - | let oldPositionSize = getPosition(_trader)._1 | |
1558 | + | let oldPositionSize = getPosition(_trader, _direction)._1 | |
1592 | 1559 | let positionSizeAbs = abs(oldPositionSize) | |
1593 | - | let $ | |
1560 | + | let $t07430474627 = if (isPartialLiquidation) | |
1594 | 1561 | then { | |
1595 | 1562 | let liquidationSize = getPartialLiquidationAmount(_trader, oldPositionSize) | |
1596 | 1563 | let liquidationRatio = divd(abs(liquidationSize), positionSizeAbs) | |
1597 | 1564 | $Tuple2(liquidationRatio, abs(liquidationSize)) | |
1598 | 1565 | } | |
1599 | 1566 | else $Tuple2(0, positionSizeAbs) | |
1600 | - | let liquidationRatio = $ | |
1601 | - | let liquidationSize = $ | |
1602 | - | let $ | |
1567 | + | let liquidationRatio = $t07430474627._1 | |
1568 | + | let liquidationSize = $t07430474627._2 | |
1569 | + | let $t07463375289 = internalClosePosition(_trader, _direction, if (isPartialLiquidation) | |
1603 | 1570 | then liquidationSize | |
1604 | 1571 | else positionSizeAbs, liquidationFeeRatio(), 0, true, false, true) | |
1605 | - | let newPositionSize = $ | |
1606 | - | let newPositionMargin = $ | |
1607 | - | let newPositionOpenNotional = $ | |
1608 | - | let newPositionLstUpdCPF = $ | |
1609 | - | let positionBadDebt = $ | |
1610 | - | let realizedPnl = $ | |
1611 | - | let marginToTrader = $ | |
1612 | - | let quoteAssetReserveAfter = $ | |
1613 | - | let baseAssetReserveAfter = $ | |
1614 | - | let totalPositionSizeAfter = $ | |
1615 | - | let openInterestNotionalAfter = $ | |
1616 | - | let totalLongAfter = $ | |
1617 | - | let totalShortAfter = $ | |
1618 | - | let totalLongOpenInterestAfter = $ | |
1619 | - | let totalShortOpenInterestAfter = $ | |
1620 | - | let liquidationPenalty = $ | |
1572 | + | let newPositionSize = $t07463375289._1 | |
1573 | + | let newPositionMargin = $t07463375289._2 | |
1574 | + | let newPositionOpenNotional = $t07463375289._3 | |
1575 | + | let newPositionLstUpdCPF = $t07463375289._4 | |
1576 | + | let positionBadDebt = $t07463375289._5 | |
1577 | + | let realizedPnl = $t07463375289._6 | |
1578 | + | let marginToTrader = $t07463375289._7 | |
1579 | + | let quoteAssetReserveAfter = $t07463375289._8 | |
1580 | + | let baseAssetReserveAfter = $t07463375289._9 | |
1581 | + | let totalPositionSizeAfter = $t07463375289._10 | |
1582 | + | let openInterestNotionalAfter = $t07463375289._11 | |
1583 | + | let totalLongAfter = $t07463375289._12 | |
1584 | + | let totalShortAfter = $t07463375289._13 | |
1585 | + | let totalLongOpenInterestAfter = $t07463375289._14 | |
1586 | + | let totalShortOpenInterestAfter = $t07463375289._15 | |
1587 | + | let liquidationPenalty = $t07463375289._16 | |
1621 | 1588 | let feeToLiquidator = (liquidationPenalty / 2) | |
1622 | 1589 | let feeToVault = (liquidationPenalty - feeToLiquidator) | |
1623 | 1590 | let ammBalance = (cbalance() - liquidationPenalty) | |
1644 | 1611 | if ((notifyNotional == notifyNotional)) | |
1645 | 1612 | then ((((if (isPartialLiquidation) | |
1646 | 1613 | then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp()) | |
1647 | - | else deletePosition(_trader)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1614 | + | else deletePosition(_trader, _direction)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1648 | 1615 | else throw("Strict value is not equal to itself.") | |
1649 | 1616 | } | |
1650 | 1617 | else throw("Strict value is not equal to itself.") | |
1673 | 1640 | then throw(((("Invalid funding block timestamp: " + toString(lastTimestamp())) + " < ") + toString(fundingBlockTimestamp))) | |
1674 | 1641 | else { | |
1675 | 1642 | let underlyingPrice = getOraclePrice() | |
1676 | - | let $t07503175093 = getFunding() | |
1677 | - | let shortPremiumFraction = $t07503175093._1 | |
1678 | - | let longPremiumFraction = $t07503175093._2 | |
1679 | - | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1643 | + | let $t07741477492 = getFunding() | |
1644 | + | let shortPremiumFraction = $t07741477492._1 | |
1645 | + | let longPremiumFraction = $t07741477492._2 | |
1646 | + | let premiumToVault = $t07741477492._3 | |
1647 | + | let doPayFundingToVault = if ((premiumToVault > 0)) | |
1648 | + | then { | |
1649 | + | let doPayFundingToVault = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(premiumToVault)], nil) | |
1650 | + | if ((doPayFundingToVault == doPayFundingToVault)) | |
1651 | + | then nil | |
1652 | + | else throw("Strict value is not equal to itself.") | |
1653 | + | } | |
1654 | + | else nil | |
1655 | + | if ((doPayFundingToVault == doPayFundingToVault)) | |
1656 | + | then updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1657 | + | else throw("Strict value is not equal to itself.") | |
1680 | 1658 | } | |
1681 | 1659 | } | |
1682 | 1660 | else throw("Strict value is not equal to itself.") | |
1688 | 1666 | func syncTerminalPriceToOracle () = { | |
1689 | 1667 | let _qtAstR = qtAstR() | |
1690 | 1668 | let _bsAstR = bsAstR() | |
1691 | - | let $ | |
1692 | - | let newQuoteAssetWeight = $ | |
1693 | - | let newBaseAssetWeight = $ | |
1694 | - | let marginToVault = $ | |
1669 | + | let $t07854578911 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR) | |
1670 | + | let newQuoteAssetWeight = $t07854578911._1 | |
1671 | + | let newBaseAssetWeight = $t07854578911._2 | |
1672 | + | let marginToVault = $t07854578911._3 | |
1695 | 1673 | let marginToVaultAdj = if (if ((0 > marginToVault)) | |
1696 | 1674 | then (abs(marginToVault) > cbalance()) | |
1697 | 1675 | else false) | |
1706 | 1684 | } | |
1707 | 1685 | else nil | |
1708 | 1686 | if ((doExchangePnL == doExchangePnL)) | |
1709 | - | then | |
1687 | + | then (updateBalance((cbalance() + marginToVaultAdj)) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)) | |
1710 | 1688 | else throw("Strict value is not equal to itself.") | |
1711 | 1689 | } | |
1712 | 1690 | ||
1716 | 1694 | func ensureCalledOnce () = if ((i.caller != this)) | |
1717 | 1695 | then throw("Invalid saveCurrentTxId parameters") | |
1718 | 1696 | else { | |
1697 | + | let txId = toBase58String(i.transactionId) | |
1719 | 1698 | let lastTx = valueOrElse(getString(this, k_lastTx), "") | |
1720 | - | if ((lastTx != | |
1721 | - | then [StringEntry(k_lastTx, | |
1699 | + | if ((lastTx != txId)) | |
1700 | + | then [StringEntry(k_lastTx, txId)] | |
1722 | 1701 | else throw("Can not call vAMM methods twice in one tx") | |
1723 | 1702 | } | |
1724 | 1703 | ||
1725 | 1704 | ||
1726 | 1705 | ||
1727 | 1706 | @Callable(i) | |
1728 | - | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1707 | + | func migratePosition (_trader) = { | |
1708 | + | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader)) | |
1709 | + | if (if (isDefined(positionSizeOpt)) | |
1710 | + | then isDefined(addressFromString(_trader)) | |
1711 | + | else false) | |
1712 | + | then { | |
1713 | + | let pSize = getIntegerValue(this, toCompositeKey(k_positionSize, _trader)) | |
1714 | + | let pMargin = getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)) | |
1715 | + | let pNotional = getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)) | |
1716 | + | let pFraction = getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)) | |
1717 | + | let pTimestamp = valueOrElse(getInteger(this, toCompositeKey(k_positionLastUpdatedTimestamp, _trader)), lastBlock.timestamp) | |
1718 | + | let pFee = valueOrElse(getInteger(this, toCompositeKey(k_positionFee, _trader)), fee()) | |
1719 | + | let pSequence = getIntegerValue(this, toCompositeKey(k_positionSequence, _trader)) | |
1720 | + | let pDirection = getDirection(pSize) | |
1721 | + | let positionKey = ((_trader + "_") + toString(pDirection)) | |
1722 | + | [DeleteEntry(toCompositeKey(k_positionSize, _trader)), DeleteEntry(toCompositeKey(k_positionMargin, _trader)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _trader)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _trader)), DeleteEntry(toCompositeKey(k_positionFee, _trader)), DeleteEntry(toCompositeKey(k_positionSequence, _trader)), IntegerEntry(toCompositeKey(k_positionSize, positionKey), pSize), IntegerEntry(toCompositeKey(k_positionMargin, positionKey), pMargin), IntegerEntry(toCompositeKey(k_positionOpenNotional, positionKey), pNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey), pFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey), pTimestamp), IntegerEntry(toCompositeKey(k_positionFee, positionKey), pFee), IntegerEntry(toCompositeKey(k_positionSequence, positionKey), pSequence)] | |
1723 | + | } | |
1724 | + | else throw(("Nothing to migrate for " + _trader)) | |
1725 | + | } | |
1726 | + | ||
1727 | + | ||
1728 | + | ||
1729 | + | @Callable(i) | |
1730 | + | func view_calcRemainMarginWithFundingPayment (_trader,_direction) = { | |
1729 | 1731 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1730 | 1732 | if ((sync == sync)) | |
1731 | 1733 | then { | |
1732 | - | let $ | |
1733 | - | let positionSize = $ | |
1734 | - | let positionMargin = $ | |
1735 | - | let pon = $ | |
1736 | - | let positionLstUpdCPF = $ | |
1737 | - | let positionTimestamp = $ | |
1738 | - | let $ | |
1739 | - | let positionNotional = $ | |
1740 | - | let unrealizedPnl = $ | |
1741 | - | let $ | |
1742 | - | let remainMargin = $ | |
1743 | - | let badDebt = $ | |
1744 | - | let fundingPayment = $ | |
1745 | - | let rolloverFee = $ | |
1746 | - | throw(((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)) + s(rolloverFee))) | |
1734 | + | let $t08260282738 = getPosition(_trader, _direction) | |
1735 | + | let positionSize = $t08260282738._1 | |
1736 | + | let positionMargin = $t08260282738._2 | |
1737 | + | let pon = $t08260282738._3 | |
1738 | + | let positionLstUpdCPF = $t08260282738._4 | |
1739 | + | let positionTimestamp = $t08260282738._5 | |
1740 | + | let $t08274182854 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, PNL_OPTION_SPOT) | |
1741 | + | let positionNotional = $t08274182854._1 | |
1742 | + | let unrealizedPnl = $t08274182854._2 | |
1743 | + | let $t08285783081 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLstUpdCPF, positionTimestamp, unrealizedPnl) | |
1744 | + | let remainMargin = $t08285783081._1 | |
1745 | + | let badDebt = $t08285783081._2 | |
1746 | + | let fundingPayment = $t08285783081._3 | |
1747 | + | let rolloverFee = $t08285783081._4 | |
1748 | + | throw(((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader, _direction))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)) + s(rolloverFee))) | |
1747 | 1749 | } | |
1748 | 1750 | else throw("Strict value is not equal to itself.") | |
1749 | 1751 | } | |
1762 | 1764 | ||
1763 | 1765 | @Callable(i) | |
1764 | 1766 | func view_getTerminalAmmPrice () = { | |
1765 | - | let $ | |
1766 | - | let terminalQuoteAssetReserve = $ | |
1767 | - | let terminalBaseAssetReserve = $ | |
1767 | + | let $t08381683897 = getTerminalAmmState() | |
1768 | + | let terminalQuoteAssetReserve = $t08381683897._1 | |
1769 | + | let terminalBaseAssetReserve = $t08381683897._2 | |
1768 | 1770 | let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW())) | |
1769 | 1771 | throw(toString(price)) | |
1770 | 1772 | } | |
1773 | 1775 | ||
1774 | 1776 | @Callable(i) | |
1775 | 1777 | func view_getFunding () = { | |
1776 | - | let underlyingPrice = getOraclePrice() | |
1777 | - | let $t07823778299 = getFunding() | |
1778 | - | let shortPremiumFraction = $t07823778299._1 | |
1779 | - | let longPremiumFraction = $t07823778299._2 | |
1780 | - | let longFunding = divd(longPremiumFraction, underlyingPrice) | |
1781 | - | let shortFunding = divd(shortPremiumFraction, underlyingPrice) | |
1782 | - | throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOraclePrice()))) | |
1778 | + | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1779 | + | if ((sync == sync)) | |
1780 | + | then { | |
1781 | + | let underlyingPrice = getOraclePrice() | |
1782 | + | let $t08445684534 = getFunding() | |
1783 | + | let shortPremiumFraction = $t08445684534._1 | |
1784 | + | let longPremiumFraction = $t08445684534._2 | |
1785 | + | let premiumToVault = $t08445684534._3 | |
1786 | + | let longFunding = divd(longPremiumFraction, underlyingPrice) | |
1787 | + | let shortFunding = divd(shortPremiumFraction, underlyingPrice) | |
1788 | + | throw(((((s(longFunding) + s(shortFunding)) + s(getSpotPrice())) + s(getOraclePrice())) + s(premiumToVault))) | |
1789 | + | } | |
1790 | + | else throw("Strict value is not equal to itself.") | |
1783 | 1791 | } | |
1784 | 1792 | ||
1785 | 1793 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_baseOracle = "k_baseOracle" | |
5 | 5 | ||
6 | 6 | let k_quoteOracle = "k_quoteOracle" | |
7 | 7 | ||
8 | 8 | let k_balance = "k_balance" | |
9 | 9 | ||
10 | 10 | let k_sequence = "k_sequence" | |
11 | 11 | ||
12 | 12 | let k_positionSize = "k_positionSize" | |
13 | 13 | ||
14 | 14 | let k_positionMargin = "k_positionMargin" | |
15 | 15 | ||
16 | 16 | let k_positionOpenNotional = "k_positionOpenNotional" | |
17 | 17 | ||
18 | 18 | let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction" | |
19 | 19 | ||
20 | 20 | let k_positionSequence = "k_positionSequence" | |
21 | - | ||
22 | - | let k_positionAsset = "k_positionAsset" | |
23 | 21 | ||
24 | 22 | let k_positionFee = "k_positionFee" | |
25 | 23 | ||
26 | 24 | let k_positionLastUpdatedTimestamp = "k_positionTimestamp" | |
27 | 25 | ||
28 | 26 | let k_initialized = "k_initialized" | |
29 | 27 | ||
30 | 28 | let k_paused = "k_paused" | |
31 | 29 | ||
32 | 30 | let k_closeOnly = "k_closeOnly" | |
33 | 31 | ||
34 | 32 | let k_fee = "k_fee" | |
35 | 33 | ||
36 | 34 | let k_rolloverFee = "k_rollover_fee" | |
37 | 35 | ||
38 | 36 | let k_fundingPeriod = "k_fundingPeriod" | |
39 | 37 | ||
40 | 38 | let k_initMarginRatio = "k_initMarginRatio" | |
41 | 39 | ||
42 | 40 | let k_maintenanceMarginRatio = "k_mmr" | |
43 | 41 | ||
44 | 42 | let k_liquidationFeeRatio = "k_liquidationFeeRatio" | |
45 | 43 | ||
46 | 44 | let k_partialLiquidationRatio = "k_partLiquidationRatio" | |
47 | 45 | ||
48 | 46 | let k_spreadLimit = "k_spreadLimit" | |
49 | 47 | ||
50 | 48 | let k_maxPriceImpact = "k_maxPriceImpact" | |
51 | 49 | ||
52 | 50 | let k_maxPriceSpread = "k_maxPriceSpread" | |
53 | 51 | ||
54 | 52 | let k_maxOpenNotional = "k_maxOpenNotional" | |
55 | 53 | ||
56 | 54 | let k_feeToStakersPercent = "k_feeToStakersPercent" | |
57 | 55 | ||
58 | 56 | let k_maxOracleDelay = "k_maxOracleDelay" | |
59 | 57 | ||
60 | - | let k_lastDataStr = "k_lastDataStr" | |
61 | - | ||
62 | - | let k_lastMinuteId = "k_lastMinuteId" | |
63 | - | ||
64 | - | let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice" | |
65 | - | ||
66 | - | let k_twapDataLastPrice = "k_twapDataLastPrice" | |
67 | - | ||
68 | - | let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId" | |
58 | + | let k_fundingMode = "k_fundingMode" | |
69 | 59 | ||
70 | 60 | let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction" | |
71 | 61 | ||
72 | 62 | let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction" | |
73 | 63 | ||
74 | 64 | let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp" | |
75 | 65 | ||
76 | 66 | let k_longFundingRate = "k_longFundingRate" | |
77 | 67 | ||
78 | 68 | let k_shortFundingRate = "k_shortFundingRate" | |
79 | 69 | ||
80 | 70 | let k_quoteAssetReserve = "k_qtAstR" | |
81 | 71 | ||
82 | 72 | let k_baseAssetReserve = "k_bsAstR" | |
83 | 73 | ||
84 | 74 | let k_quoteAssetWeight = "k_qtAstW" | |
85 | 75 | ||
86 | 76 | let k_baseAssetWeight = "k_bsAstW" | |
87 | 77 | ||
88 | 78 | let k_totalPositionSize = "k_totalPositionSize" | |
89 | 79 | ||
90 | 80 | let k_totalLongPositionSize = "k_totalLongPositionSize" | |
91 | 81 | ||
92 | 82 | let k_totalShortPositionSize = "k_totalShortPositionSize" | |
93 | 83 | ||
94 | 84 | let k_openInterestNotional = "k_openInterestNotional" | |
95 | 85 | ||
96 | 86 | let k_openInterestShort = "k_openInterestShort" | |
97 | 87 | ||
98 | 88 | let k_openInterestLong = "k_openInterestLong" | |
99 | 89 | ||
100 | 90 | let k_lastTx = "k_lastTx" | |
101 | 91 | ||
102 | 92 | let k_coordinatorAddress = "k_coordinatorAddress" | |
103 | 93 | ||
104 | 94 | let k_vault_address = "k_vault_address" | |
105 | 95 | ||
106 | 96 | let k_admin_address = "k_admin_address" | |
107 | 97 | ||
108 | 98 | let k_quote_asset = "k_quote_asset" | |
109 | 99 | ||
110 | - | let k_quote_staking = "k_quote_staking" | |
111 | - | ||
112 | 100 | let k_staking_address = "k_staking_address" | |
113 | 101 | ||
114 | 102 | let k_miner_address = "k_miner_address" | |
115 | 103 | ||
116 | 104 | let k_orders_address = "k_orders_address" | |
117 | 105 | ||
118 | 106 | let k_referral_address = "k_referral_address" | |
119 | - | ||
120 | - | let k_exchange_address = "k_exchange_address" | |
121 | 107 | ||
122 | 108 | let k_nft_manager_address = "k_nft_manager_address" | |
123 | 109 | ||
124 | 110 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
125 | 111 | ||
126 | 112 | ||
127 | 113 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
128 | 114 | ||
129 | 115 | ||
130 | 116 | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
131 | 117 | ||
132 | 118 | ||
133 | 119 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
134 | - | ||
135 | - | ||
136 | - | func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set") | |
137 | 120 | ||
138 | 121 | ||
139 | 122 | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set") | |
140 | 123 | ||
141 | 124 | ||
142 | 125 | func vaultAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_vault_address)), "Vault not set") | |
143 | 126 | ||
144 | 127 | ||
145 | 128 | func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Miner not set") | |
146 | 129 | ||
147 | 130 | ||
148 | 131 | func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set") | |
149 | 132 | ||
150 | 133 | ||
151 | 134 | func referralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_referral_address)), "Referral not set") | |
152 | 135 | ||
153 | 136 | ||
154 | 137 | func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set") | |
155 | 138 | ||
156 | 139 | ||
157 | 140 | let k_token_param = "k_token_param" | |
158 | 141 | ||
159 | 142 | let k_token_type = "k_token_type" | |
160 | 143 | ||
161 | 144 | let FEE_REDUCTION_TOKEN_TYPE = "fee_reduction" | |
162 | 145 | ||
163 | 146 | let DIR_LONG = 1 | |
164 | 147 | ||
165 | 148 | let DIR_SHORT = 2 | |
166 | 149 | ||
167 | - | let TWAP_INTERVAL = 15 | |
168 | - | ||
169 | 150 | let SECONDS = 1000 | |
170 | 151 | ||
171 | 152 | let DECIMAL_NUMBERS = 6 | |
172 | 153 | ||
173 | 154 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
174 | 155 | ||
175 | 156 | let MINUTES_IN_YEAR = (525600 * DECIMAL_UNIT) | |
176 | 157 | ||
177 | 158 | let ONE_DAY = (86400 * DECIMAL_UNIT) | |
178 | 159 | ||
179 | 160 | let PNL_OPTION_SPOT = 1 | |
180 | 161 | ||
181 | 162 | let PNL_OPTION_ORACLE = 2 | |
163 | + | ||
164 | + | let FUNDING_ASYMMETRIC = 1 | |
165 | + | ||
166 | + | let FUNDING_SYMMETRIC = 2 | |
182 | 167 | ||
183 | 168 | func s (_x) = (toString(_x) + ",") | |
184 | 169 | ||
185 | 170 | ||
186 | 171 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
187 | 172 | ||
188 | 173 | ||
189 | 174 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
190 | 175 | ||
191 | 176 | ||
192 | 177 | func bdivd (_x,_y) = fraction(_x, toBigInt(DECIMAL_UNIT), _y, HALFEVEN) | |
193 | 178 | ||
194 | 179 | ||
195 | 180 | func bmuld (_x,_y) = fraction(_x, _y, toBigInt(DECIMAL_UNIT), HALFEVEN) | |
196 | 181 | ||
197 | 182 | ||
198 | 183 | func abs (_x) = if ((_x > 0)) | |
199 | 184 | then _x | |
200 | 185 | else -(_x) | |
201 | 186 | ||
202 | 187 | ||
203 | 188 | func vmax (_x,_y) = if ((_x >= _y)) | |
204 | 189 | then _x | |
205 | 190 | else _y | |
206 | - | ||
207 | - | ||
208 | - | func listToStr (_list) = if ((size(_list) == 0)) | |
209 | - | then "" | |
210 | - | else makeString(_list, ",") | |
211 | - | ||
212 | - | ||
213 | - | func strToList (_str) = if ((_str == "")) | |
214 | - | then nil | |
215 | - | else split(_str, ",") | |
216 | - | ||
217 | - | ||
218 | - | func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize)) | |
219 | - | then (removeByIndex(_list, 0) :+ _value) | |
220 | - | else (_list :+ _value) | |
221 | 191 | ||
222 | 192 | ||
223 | 193 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
224 | 194 | ||
225 | 195 | ||
226 | 196 | func intOr (k,def) = valueOrElse(getInteger(this, k), def) | |
227 | 197 | ||
228 | 198 | ||
229 | 199 | func strA (_address,_key) = { | |
230 | 200 | let val = valueOrErrorMessage(getString(_address, _key), ("No value for key " + _key)) | |
231 | 201 | val | |
232 | 202 | } | |
233 | 203 | ||
234 | 204 | ||
235 | 205 | func intA (_address,_key) = { | |
236 | 206 | let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key)) | |
237 | 207 | val | |
238 | 208 | } | |
239 | 209 | ||
240 | 210 | ||
241 | 211 | func cbalance () = int(k_balance) | |
242 | 212 | ||
243 | 213 | ||
244 | 214 | func fee () = int(k_fee) | |
245 | 215 | ||
246 | 216 | ||
247 | 217 | func rolloverFeeRate () = int(k_rolloverFee) | |
248 | 218 | ||
249 | 219 | ||
250 | 220 | func initMarginRatio () = int(k_initMarginRatio) | |
251 | 221 | ||
252 | 222 | ||
253 | 223 | func qtAstR () = int(k_quoteAssetReserve) | |
254 | 224 | ||
255 | 225 | ||
256 | 226 | func bsAstR () = int(k_baseAssetReserve) | |
257 | 227 | ||
258 | 228 | ||
259 | 229 | func qtAstW () = intOr(k_quoteAssetWeight, DECIMAL_UNIT) | |
260 | 230 | ||
261 | 231 | ||
262 | 232 | func bsAstW () = intOr(k_baseAssetWeight, DECIMAL_UNIT) | |
263 | 233 | ||
264 | 234 | ||
265 | 235 | func totalPositionSize () = int(k_totalPositionSize) | |
266 | 236 | ||
267 | 237 | ||
268 | 238 | func openInterestNotional () = int(k_openInterestNotional) | |
269 | 239 | ||
270 | 240 | ||
271 | 241 | func openInterestShort () = int(k_openInterestShort) | |
272 | 242 | ||
273 | 243 | ||
274 | 244 | func openInterestLong () = int(k_openInterestLong) | |
275 | 245 | ||
276 | 246 | ||
277 | 247 | func nextFundingBlockTimestamp () = int(k_nextFundingBlock) | |
278 | 248 | ||
279 | 249 | ||
280 | 250 | func fundingPeriodRaw () = int(k_fundingPeriod) | |
281 | 251 | ||
282 | 252 | ||
283 | 253 | func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT) | |
284 | 254 | ||
285 | 255 | ||
286 | 256 | func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS) | |
287 | 257 | ||
288 | 258 | ||
289 | 259 | func maintenanceMarginRatio () = int(k_maintenanceMarginRatio) | |
290 | 260 | ||
291 | 261 | ||
292 | 262 | func liquidationFeeRatio () = int(k_liquidationFeeRatio) | |
293 | 263 | ||
294 | 264 | ||
295 | 265 | func partialLiquidationRatio () = int(k_partialLiquidationRatio) | |
296 | 266 | ||
297 | 267 | ||
298 | 268 | func spreadLimit () = int(k_spreadLimit) | |
299 | 269 | ||
300 | 270 | ||
301 | 271 | func maxPriceImpact () = int(k_maxPriceImpact) | |
302 | 272 | ||
303 | 273 | ||
304 | 274 | func maxPriceSpread () = int(k_maxPriceSpread) | |
305 | 275 | ||
306 | 276 | ||
307 | 277 | func maxOpenNotional () = int(k_maxOpenNotional) | |
308 | 278 | ||
309 | 279 | ||
310 | 280 | func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction) | |
311 | 281 | ||
312 | 282 | ||
313 | 283 | func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction) | |
314 | 284 | ||
315 | 285 | ||
316 | 286 | func totalShortPositionSize () = int(k_totalShortPositionSize) | |
317 | 287 | ||
318 | 288 | ||
319 | 289 | func totalLongPositionSize () = int(k_totalLongPositionSize) | |
320 | 290 | ||
321 | 291 | ||
322 | 292 | func lastSequence () = intOr(k_sequence, 0) | |
323 | 293 | ||
324 | 294 | ||
325 | 295 | func feeToStakersPercent () = int(k_feeToStakersPercent) | |
326 | 296 | ||
327 | 297 | ||
328 | 298 | func maxOracleDelay () = int(k_maxOracleDelay) | |
329 | 299 | ||
330 | 300 | ||
301 | + | func fundingMode () = intOr(k_fundingMode, FUNDING_ASYMMETRIC) | |
302 | + | ||
303 | + | ||
331 | 304 | func lastTimestamp () = lastBlock.timestamp | |
332 | 305 | ||
333 | 306 | ||
334 | 307 | func getActualCaller (i) = valueOrElse(getString(ordersAddress(), "k_sender"), toString(i.caller)) | |
335 | 308 | ||
336 | 309 | ||
337 | 310 | func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = { | |
338 | 311 | let remainingMarginRatio = (_marginRatio - _baseMarginRatio) | |
339 | 312 | if (if (_largerThanOrEqualTo) | |
340 | 313 | then (0 > remainingMarginRatio) | |
341 | 314 | else false) | |
342 | 315 | then throw(((("Invalid margin: " + toString(_marginRatio)) + " < ") + toString(_baseMarginRatio))) | |
343 | 316 | else if (if (!(_largerThanOrEqualTo)) | |
344 | 317 | then (remainingMarginRatio >= 0) | |
345 | 318 | else false) | |
346 | 319 | then throw(((("Invalid margin: " + toString(_marginRatio)) + " > ") + toString(_baseMarginRatio))) | |
347 | 320 | else true | |
348 | 321 | } | |
349 | 322 | ||
350 | 323 | ||
351 | 324 | func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0)) | |
352 | 325 | then throw("Should not be called with _positionSize == 0") | |
353 | 326 | else if ((_positionSize > 0)) | |
354 | 327 | then latestLongCumulativePremiumFraction() | |
355 | 328 | else latestShortCumulativePremiumFraction() | |
356 | 329 | ||
357 | 330 | ||
358 | - | func getPosition (_trader) = { | |
359 | - | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader)) | |
331 | + | func getPosition (_trader,_direction) = { | |
332 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
333 | + | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, positionKey)) | |
360 | 334 | match positionSizeOpt { | |
361 | 335 | case positionSize: Int => | |
362 | - | $Tuple5(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, | |
336 | + | $Tuple5(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, positionKey)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, positionKey)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedTimestamp, positionKey))) | |
363 | 337 | case _ => | |
364 | 338 | $Tuple5(0, 0, 0, 0, 0) | |
365 | 339 | } | |
366 | 340 | } | |
367 | 341 | ||
368 | 342 | ||
369 | - | func getPositionAsset (_trader) = { | |
370 | - | let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader)) | |
371 | - | match positionAssetOpt { | |
372 | - | case positionAsset: String => | |
373 | - | positionAsset | |
374 | - | case _ => | |
375 | - | toBase58String(quoteAsset()) | |
376 | - | } | |
377 | - | } | |
343 | + | func getDirection (_positionSize) = if ((0 > _positionSize)) | |
344 | + | then DIR_SHORT | |
345 | + | else DIR_LONG | |
378 | 346 | ||
379 | 347 | ||
380 | - | func getPositionFee (_trader) = { | |
381 | - | let positionFeeOpt = getInteger(this, toCompositeKey(k_positionFee, _trader)) | |
348 | + | func getPositionFee (_trader,_direction) = { | |
349 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
350 | + | let positionFeeOpt = getInteger(this, toCompositeKey(k_positionFee, positionKey)) | |
382 | 351 | match positionFeeOpt { | |
383 | 352 | case positionFee: Int => | |
384 | 353 | positionFee | |
385 | 354 | case _ => | |
386 | 355 | fee() | |
387 | 356 | } | |
388 | 357 | } | |
389 | 358 | ||
390 | 359 | ||
391 | - | func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0)) | |
360 | + | func requireOpenPosition (_trader,_direction) = if ((getPosition(_trader, _direction)._1 == 0)) | |
392 | 361 | then throw("No open position") | |
393 | 362 | else true | |
394 | 363 | ||
395 | 364 | ||
396 | 365 | func getOracleData (key) = { | |
397 | 366 | let oracleDataStr = getString(this, key) | |
398 | 367 | if (if (isDefined(oracleDataStr)) | |
399 | 368 | then (value(oracleDataStr) != "") | |
400 | 369 | else false) | |
401 | 370 | then { | |
402 | 371 | let oracleData = split(value(oracleDataStr), ",") | |
403 | 372 | let oracleAddress = valueOrErrorMessage(addressFromString(oracleData[0]), ("Invalid oracle address in: " + value(oracleDataStr))) | |
404 | 373 | let priceKey = oracleData[1] | |
405 | 374 | let blockKey = oracleData[2] | |
406 | 375 | let openKey = oracleData[3] | |
407 | 376 | $Tuple4(oracleAddress, priceKey, blockKey, openKey) | |
408 | 377 | } | |
409 | 378 | else unit | |
410 | 379 | } | |
411 | 380 | ||
412 | 381 | ||
413 | 382 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
414 | 383 | ||
415 | 384 | ||
416 | 385 | func paused () = valueOrElse(getBoolean(this, k_paused), false) | |
417 | 386 | ||
418 | 387 | ||
419 | 388 | func closeOnly () = valueOrElse(getBoolean(this, k_closeOnly), false) | |
420 | 389 | ||
421 | 390 | ||
422 | 391 | func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd) | |
423 | 392 | then { | |
424 | 393 | let newBase = (bsAstR() - _baseAssetAmount) | |
425 | 394 | if ((0 >= newBase)) | |
426 | 395 | then throw("Tx lead to base asset reserve <= 0, revert") | |
427 | 396 | else $Tuple3((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount)) | |
428 | 397 | } | |
429 | 398 | else { | |
430 | 399 | let newQuote = (qtAstR() - _quoteAssetAmount) | |
431 | 400 | if ((0 >= newQuote)) | |
432 | 401 | then throw("Tx lead to base quote reserve <= 0, revert") | |
433 | 402 | else $Tuple3(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount)) | |
434 | 403 | } | |
435 | 404 | ||
436 | 405 | ||
437 | 406 | func calcInvariant (_qtAstR,_bsAstR) = { | |
438 | 407 | let bqtAstR = toBigInt(_qtAstR) | |
439 | 408 | let bbsAstR = toBigInt(_bsAstR) | |
440 | 409 | bmuld(bqtAstR, bbsAstR) | |
441 | 410 | } | |
442 | 411 | ||
443 | 412 | ||
444 | 413 | func swapInput (_isAdd,_quoteAssetAmount) = { | |
445 | 414 | let _qtAstR = qtAstR() | |
446 | 415 | let _bsAstR = bsAstR() | |
447 | 416 | let _qtAstW = qtAstW() | |
448 | 417 | let _bsAstW = bsAstW() | |
449 | 418 | let quoteAssetAmountAdjusted = divd(_quoteAssetAmount, _qtAstW) | |
450 | 419 | let k = calcInvariant(_qtAstR, _bsAstR) | |
451 | 420 | let quoteAssetReserveAfter = if (_isAdd) | |
452 | 421 | then (_qtAstR + quoteAssetAmountAdjusted) | |
453 | 422 | else (_qtAstR - quoteAssetAmountAdjusted) | |
454 | 423 | let baseAssetReserveAfter = toInt(bdivd(k, toBigInt(quoteAssetReserveAfter))) | |
455 | 424 | let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR)) | |
456 | 425 | let amountBaseAssetBought = if (_isAdd) | |
457 | 426 | then amountBaseAssetBoughtAbs | |
458 | 427 | else -(amountBaseAssetBoughtAbs) | |
459 | - | let $ | |
460 | - | let quoteAssetReserveAfter1 = $ | |
461 | - | let baseAssetReserveAfter1 = $ | |
462 | - | let totalPositionSizeAfter1 = $ | |
428 | + | let $t01558415754 = updateReserve(_isAdd, quoteAssetAmountAdjusted, amountBaseAssetBoughtAbs) | |
429 | + | let quoteAssetReserveAfter1 = $t01558415754._1 | |
430 | + | let baseAssetReserveAfter1 = $t01558415754._2 | |
431 | + | let totalPositionSizeAfter1 = $t01558415754._3 | |
463 | 432 | let priceBefore = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW)) | |
464 | 433 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
465 | 434 | let priceDiff = abs((priceBefore - marketPrice)) | |
466 | 435 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
467 | 436 | let maxPriceImpactValue = maxPriceImpact() | |
468 | 437 | if ((priceImpact > maxPriceImpactValue)) | |
469 | 438 | then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_qtAstR)) + " before base asset: ") + toString(_bsAstR)) + " quote asset amount to exchange: ") + toString(_quoteAssetAmount)) + " price before: ") + toString(priceBefore)) + " marketPrice: ") + toString(marketPrice))) | |
470 | 439 | else $Tuple4(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1) | |
471 | 440 | } | |
472 | 441 | ||
473 | 442 | ||
474 | 443 | func calcRolloverFee (_oldPositionMargin,_oldPositionLastUpdatedTimestamp) = { | |
475 | 444 | let positionMinutes = ((((lastTimestamp() - _oldPositionLastUpdatedTimestamp) / 1000) / 60) * DECIMAL_UNIT) | |
476 | 445 | let rolloverFee = divd(muld(muld(_oldPositionMargin, positionMinutes), rolloverFeeRate()), MINUTES_IN_YEAR) | |
477 | 446 | rolloverFee | |
478 | 447 | } | |
479 | 448 | ||
480 | 449 | ||
481 | 450 | func calcRemainMarginWithFundingPaymentAndRolloverFee (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_oldPositionLastUpdatedTimestamp,_marginDelta) = { | |
482 | 451 | let fundingPayment = if ((_oldPositionSize != 0)) | |
483 | 452 | then { | |
484 | 453 | let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize) | |
485 | 454 | muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize) | |
486 | 455 | } | |
487 | 456 | else 0 | |
488 | 457 | let rolloverFee = calcRolloverFee(_oldPositionMargin, _oldPositionLastUpdatedTimestamp) | |
489 | 458 | let signedMargin = (((_marginDelta - rolloverFee) - fundingPayment) + _oldPositionMargin) | |
490 | - | let $ | |
459 | + | let $t01842118548 = if ((0 > signedMargin)) | |
491 | 460 | then $Tuple2(0, abs(signedMargin)) | |
492 | 461 | else $Tuple2(abs(signedMargin), 0) | |
493 | - | let remainMargin = $ | |
494 | - | let badDebt = $ | |
462 | + | let remainMargin = $t01842118548._1 | |
463 | + | let badDebt = $t01842118548._2 | |
495 | 464 | $Tuple4(remainMargin, badDebt, fundingPayment, rolloverFee) | |
496 | 465 | } | |
497 | 466 | ||
498 | 467 | ||
499 | 468 | func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight) = { | |
500 | 469 | let priceBefore = divd(muld(_quoteAssetReserve, _quoteAssetWeight), muld(_baseAssetReserve, _baseAssetWeight)) | |
501 | 470 | if ((_baseAssetAmount == 0)) | |
502 | 471 | then throw("Invalid base asset amount") | |
503 | 472 | else { | |
504 | 473 | let k = calcInvariant(_quoteAssetReserve, _baseAssetReserve) | |
505 | 474 | let baseAssetPoolAmountAfter = if (_isAdd) | |
506 | 475 | then (_baseAssetReserve + _baseAssetAmount) | |
507 | 476 | else (_baseAssetReserve - _baseAssetAmount) | |
508 | 477 | let quoteAssetAfter = toInt(bdivd(k, toBigInt(baseAssetPoolAmountAfter))) | |
509 | 478 | let quoteAssetDelta = abs((quoteAssetAfter - _quoteAssetReserve)) | |
510 | 479 | let quoteAssetSold = muld(quoteAssetDelta, _quoteAssetWeight) | |
511 | 480 | let maxPriceImpactValue = maxPriceImpact() | |
512 | - | let $ | |
513 | - | let quoteAssetReserveAfter1 = $ | |
514 | - | let baseAssetReserveAfter1 = $ | |
515 | - | let totalPositionSizeAfter1 = $ | |
481 | + | let $t01981019972 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount) | |
482 | + | let quoteAssetReserveAfter1 = $t01981019972._1 | |
483 | + | let baseAssetReserveAfter1 = $t01981019972._2 | |
484 | + | let totalPositionSizeAfter1 = $t01981019972._3 | |
516 | 485 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
517 | 486 | let priceDiff = abs((priceBefore - marketPrice)) | |
518 | 487 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
519 | 488 | if (if ((priceImpact > maxPriceImpactValue)) | |
520 | 489 | then _checkMaxPriceImpact | |
521 | 490 | else false) | |
522 | 491 | then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_quoteAssetReserve)) + " before base asset: ") + toString(_baseAssetReserve)) + " base asset amount to exchange: ") + toString(_baseAssetAmount)) + " price before: ") + toString(priceBefore)) + " market price: ") + toString(marketPrice))) | |
523 | 492 | else $Tuple7(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, (totalLongPositionSize() - (if (_isAdd) | |
524 | 493 | then abs(_baseAssetAmount) | |
525 | 494 | else 0)), (totalShortPositionSize() - (if (!(_isAdd)) | |
526 | 495 | then abs(_baseAssetAmount) | |
527 | 496 | else 0)), priceImpact) | |
528 | 497 | } | |
529 | 498 | } | |
530 | 499 | ||
531 | 500 | ||
532 | 501 | func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), qtAstW(), bsAstR(), bsAstW()) | |
533 | 502 | ||
534 | 503 | ||
535 | 504 | func getOraclePriceValue (oracle,priceKey,blockKey) = { | |
536 | 505 | let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey)) | |
537 | 506 | if ((blockKey != "")) | |
538 | 507 | then { | |
539 | 508 | let currentBlock = lastBlock.height | |
540 | 509 | let lastOracleBlock = valueOrErrorMessage(getInteger(oracle, blockKey), ((("Can not get oracle block. Oracle: " + toString(oracle)) + " key: ") + blockKey)) | |
541 | 510 | if (((currentBlock - lastOracleBlock) > maxOracleDelay())) | |
542 | 511 | then throw(((("Oracle stale data. Last oracle block: " + toString(lastOracleBlock)) + " current block: ") + toString(currentBlock))) | |
543 | 512 | else lastValue | |
544 | 513 | } | |
545 | 514 | else lastValue | |
546 | 515 | } | |
547 | 516 | ||
548 | 517 | ||
549 | 518 | func getOraclePrice () = { | |
550 | 519 | let baseOracle = valueOrErrorMessage(getOracleData(k_baseOracle), "No base asset oracle data") | |
551 | 520 | let baseOraclePrice = getOraclePriceValue(baseOracle._1, baseOracle._2, baseOracle._3) | |
552 | 521 | let quoteOracle = getOracleData(k_quoteOracle) | |
553 | 522 | let quoteOraclePrice = if (isDefined(quoteOracle)) | |
554 | 523 | then { | |
555 | 524 | let quoteOracleV = value(quoteOracle) | |
556 | 525 | getOraclePriceValue(quoteOracleV._1, quoteOracleV._2, quoteOracleV._3) | |
557 | 526 | } | |
558 | 527 | else DECIMAL_UNIT | |
559 | 528 | divd(baseOraclePrice, quoteOraclePrice) | |
560 | 529 | } | |
561 | 530 | ||
562 | 531 | ||
563 | 532 | func isMarketClosed () = { | |
564 | 533 | let baseOracle = valueOrErrorMessage(getOracleData(k_baseOracle), "No base asset oracle data") | |
565 | 534 | let oracle = baseOracle._1 | |
566 | 535 | let openKey = baseOracle._4 | |
567 | 536 | if ((openKey != "")) | |
568 | 537 | then { | |
569 | 538 | let isOpen = valueOrErrorMessage(getBoolean(oracle, openKey), ((("Can not get oracle is open/closed. Oracle: " + toString(oracle)) + " key: ") + openKey)) | |
570 | 539 | !(isOpen) | |
571 | 540 | } | |
572 | 541 | else false | |
573 | 542 | } | |
574 | 543 | ||
575 | 544 | ||
576 | 545 | func absPriceDiff (_oraclePrice,_quoteAssetReserve,_baseAssetReserve,_qtAstW,_bsAstW) = { | |
577 | 546 | let priceAfter = divd(muld(_quoteAssetReserve, _qtAstW), muld(_baseAssetReserve, _bsAstW)) | |
578 | 547 | let averagePrice = divd((_oraclePrice + priceAfter), (2 * DECIMAL_UNIT)) | |
579 | 548 | let absPriceDiff = divd(abs((_oraclePrice - priceAfter)), averagePrice) | |
580 | 549 | absPriceDiff | |
581 | 550 | } | |
582 | 551 | ||
583 | 552 | ||
584 | 553 | func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = { | |
585 | 554 | let oraclePrice = getOraclePrice() | |
586 | 555 | let _qtAstW = qtAstW() | |
587 | 556 | let _bsAstW = bsAstW() | |
588 | 557 | let absPriceDiffBefore = absPriceDiff(oraclePrice, qtAstR(), bsAstR(), _qtAstW, _bsAstW) | |
589 | 558 | let absPriceDiffAfter = absPriceDiff(oraclePrice, _quoteAssetReserve, _baseAssetReserve, _qtAstW, _bsAstW) | |
590 | 559 | if (if ((absPriceDiffAfter > maxPriceSpread())) | |
591 | 560 | then (absPriceDiffAfter > absPriceDiffBefore) | |
592 | 561 | else false) | |
593 | 562 | then throw(((("Price spread " + toString(absPriceDiffAfter)) + " > max price spread ") + toString(maxPriceSpread()))) | |
594 | 563 | else true | |
595 | 564 | } | |
596 | 565 | ||
597 | 566 | ||
598 | 567 | func requireNotOverMaxOpenNotional (_longOpenNotional,_shortOpenNotional) = { | |
599 | 568 | let _maxOpenNotional = maxOpenNotional() | |
600 | 569 | if ((_longOpenNotional > _maxOpenNotional)) | |
601 | 570 | then throw(((("Long open notional " + toString(_longOpenNotional)) + " > max open notional ") + toString(_maxOpenNotional))) | |
602 | 571 | else if ((_shortOpenNotional > _maxOpenNotional)) | |
603 | 572 | then throw(((("Short open notional " + toString(_shortOpenNotional)) + " > max open notional ") + toString(_maxOpenNotional))) | |
604 | 573 | else true | |
605 | 574 | } | |
606 | 575 | ||
607 | 576 | ||
608 | 577 | func getSpotPrice () = { | |
609 | 578 | let _quoteAssetReserve = qtAstR() | |
610 | 579 | let _baseAssetReserve = bsAstR() | |
611 | 580 | let _qtAstW = qtAstW() | |
612 | 581 | let _bsAstW = bsAstW() | |
613 | 582 | divd(muld(_quoteAssetReserve, _qtAstW), muld(_baseAssetReserve, _bsAstW)) | |
614 | 583 | } | |
615 | 584 | ||
616 | 585 | ||
617 | 586 | func isOverFluctuationLimit () = { | |
618 | 587 | let oraclePrice = getOraclePrice() | |
619 | 588 | let currentPrice = getSpotPrice() | |
620 | 589 | (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit()) | |
621 | 590 | } | |
622 | 591 | ||
623 | 592 | ||
624 | 593 | func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight) = { | |
625 | 594 | let positionSizeAbs = abs(_positionSize) | |
626 | 595 | let isShort = (0 > _positionSize) | |
627 | 596 | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
628 | 597 | then { | |
629 | 598 | let outPositionNotional = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)._1 | |
630 | 599 | outPositionNotional | |
631 | 600 | } | |
632 | 601 | else muld(positionSizeAbs, getOraclePrice()) | |
633 | 602 | positionNotional | |
634 | 603 | } | |
635 | 604 | ||
636 | 605 | ||
637 | 606 | func getPositionNotionalAndUnrealizedPnlByValues (_positionSize,_positionOpenNotional,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight,_option) = if ((_positionSize == 0)) | |
638 | 607 | then throw("Invalid position size") | |
639 | 608 | else { | |
640 | 609 | let isShort = (0 > _positionSize) | |
641 | 610 | let positionNotional = getPositionAdjustedOpenNotional(_positionSize, _option, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight) | |
642 | 611 | let unrealizedPnl = if (isShort) | |
643 | 612 | then (_positionOpenNotional - positionNotional) | |
644 | 613 | else (positionNotional - _positionOpenNotional) | |
645 | 614 | $Tuple2(positionNotional, unrealizedPnl) | |
646 | 615 | } | |
647 | 616 | ||
648 | 617 | ||
649 | - | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
650 | - | let $ | |
651 | - | let positionSize = $ | |
652 | - | let positionMargin = $ | |
653 | - | let positionOpenNotional = $ | |
654 | - | let positionLstUpdCPF = $ | |
618 | + | func getPositionNotionalAndUnrealizedPnl (_trader,_direction,_option) = { | |
619 | + | let $t02786728007 = getPosition(_trader, _direction) | |
620 | + | let positionSize = $t02786728007._1 | |
621 | + | let positionMargin = $t02786728007._2 | |
622 | + | let positionOpenNotional = $t02786728007._3 | |
623 | + | let positionLstUpdCPF = $t02786728007._4 | |
655 | 624 | getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), qtAstW(), bsAstR(), bsAstW(), _option) | |
656 | 625 | } | |
657 | 626 | ||
658 | 627 | ||
659 | 628 | func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional) | |
660 | 629 | ||
661 | 630 | ||
662 | - | func getMarginRatioByOption (_trader,_option) = { | |
663 | - | let $ | |
664 | - | let positionSize = $ | |
665 | - | let positionMargin = $ | |
666 | - | let pon = $ | |
667 | - | let positionLastUpdatedCPF = $ | |
668 | - | let positionTimestamp = $ | |
669 | - | let $ | |
670 | - | let positionNotional = $ | |
671 | - | let unrealizedPnl = $ | |
672 | - | let $ | |
673 | - | let remainMargin = $ | |
674 | - | let badDebt = $ | |
631 | + | func getMarginRatioByOption (_trader,_direction,_option) = { | |
632 | + | let $t02853928692 = getPosition(_trader, _direction) | |
633 | + | let positionSize = $t02853928692._1 | |
634 | + | let positionMargin = $t02853928692._2 | |
635 | + | let pon = $t02853928692._3 | |
636 | + | let positionLastUpdatedCPF = $t02853928692._4 | |
637 | + | let positionTimestamp = $t02853928692._5 | |
638 | + | let $t02869828803 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, _option) | |
639 | + | let positionNotional = $t02869828803._1 | |
640 | + | let unrealizedPnl = $t02869828803._2 | |
641 | + | let $t02880829020 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLastUpdatedCPF, positionTimestamp, unrealizedPnl) | |
642 | + | let remainMargin = $t02880829020._1 | |
643 | + | let badDebt = $t02880829020._2 | |
675 | 644 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
676 | 645 | } | |
677 | 646 | ||
678 | 647 | ||
679 | - | func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
648 | + | func getMarginRatio (_trader,_direction) = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT) | |
680 | 649 | ||
681 | 650 | ||
682 | 651 | func getPartialLiquidationAmount (_trader,_positionSize) = { | |
683 | - | let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio()))) | |
652 | + | let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader, getDirection(_positionSize)), maintenanceMarginRatio()))) | |
684 | 653 | let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio) | |
685 | 654 | let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false) | |
686 | 655 | let maxExchangedQuoteAssetAmount = swapResult._1 | |
687 | 656 | let priceImpact = swapResult._7 | |
688 | 657 | if ((maxPriceImpact() > priceImpact)) | |
689 | 658 | then maxExchangedPositionSize | |
690 | 659 | else muld(abs(_positionSize), partialLiquidationRatio()) | |
691 | 660 | } | |
692 | 661 | ||
693 | 662 | ||
694 | - | func internalClosePosition (_trader,_size,_fee,_minQuoteAssetAmount,_addToMargin,_checkMaxPriceImpact,_liquidate) = { | |
695 | - | let $ | |
696 | - | let oldPositionSize = $ | |
697 | - | let oldPositionMargin = $ | |
698 | - | let oldPositionOpenNotional = $ | |
699 | - | let oldPositionLstUpdCPF = $ | |
700 | - | let oldPositionTimestamp = $ | |
663 | + | func internalClosePosition (_trader,_direction,_size,_fee,_minQuoteAssetAmount,_addToMargin,_checkMaxPriceImpact,_liquidate) = { | |
664 | + | let $t03018330351 = getPosition(_trader, _direction) | |
665 | + | let oldPositionSize = $t03018330351._1 | |
666 | + | let oldPositionMargin = $t03018330351._2 | |
667 | + | let oldPositionOpenNotional = $t03018330351._3 | |
668 | + | let oldPositionLstUpdCPF = $t03018330351._4 | |
669 | + | let oldPositionTimestamp = $t03018330351._5 | |
701 | 670 | let isLongPosition = (oldPositionSize > 0) | |
702 | 671 | let absOldPositionSize = abs(oldPositionSize) | |
703 | 672 | if (if ((absOldPositionSize >= _size)) | |
704 | 673 | then (_size > 0) | |
705 | 674 | else false) | |
706 | 675 | then { | |
707 | 676 | let isPartialClose = (absOldPositionSize > _size) | |
708 | - | let $ | |
709 | - | let exchangedQuoteAssetAmount = $ | |
710 | - | let quoteAssetReserveAfter = $ | |
711 | - | let baseAssetReserveAfter = $ | |
712 | - | let totalPositionSizeAfter = $ | |
677 | + | let $t03064331094 = swapOutput((oldPositionSize > 0), _size, _checkMaxPriceImpact) | |
678 | + | let exchangedQuoteAssetAmount = $t03064331094._1 | |
679 | + | let quoteAssetReserveAfter = $t03064331094._2 | |
680 | + | let baseAssetReserveAfter = $t03064331094._3 | |
681 | + | let totalPositionSizeAfter = $t03064331094._4 | |
713 | 682 | let exchangedPositionSize = if ((oldPositionSize > 0)) | |
714 | 683 | then -(_size) | |
715 | 684 | else _size | |
716 | - | let $ | |
717 | - | let oldPositionNotional = $ | |
718 | - | let unrealizedPnl = $ | |
685 | + | let $t03130931533 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, PNL_OPTION_SPOT) | |
686 | + | let oldPositionNotional = $t03130931533._1 | |
687 | + | let unrealizedPnl = $t03130931533._2 | |
719 | 688 | let realizedRatio = divd(abs(exchangedPositionSize), absOldPositionSize) | |
720 | 689 | let realizedPnl = muld(unrealizedPnl, realizedRatio) | |
721 | - | let $ | |
722 | - | let remainMarginBefore = $ | |
723 | - | let x1 = $ | |
724 | - | let x2 = $ | |
725 | - | let rolloverFee = $ | |
690 | + | let $t03187432120 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, unrealizedPnl) | |
691 | + | let remainMarginBefore = $t03187432120._1 | |
692 | + | let x1 = $t03187432120._2 | |
693 | + | let x2 = $t03187432120._3 | |
694 | + | let rolloverFee = $t03187432120._4 | |
726 | 695 | let positionBadDebt = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, realizedPnl)._2 | |
727 | 696 | let realizedCloseFee = muld(muld(oldPositionNotional, realizedRatio), _fee) | |
728 | 697 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
729 | 698 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
730 | 699 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
731 | 700 | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
732 | 701 | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
733 | - | let $ | |
702 | + | let $t03352633912 = if ((newPositionSize == 0)) | |
734 | 703 | then $Tuple2(0, 0) | |
735 | 704 | else $Tuple2(abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize)) | |
736 | - | let newPositionOpenNotional = $ | |
737 | - | let newPositionLstUpdCPF = $ | |
705 | + | let newPositionOpenNotional = $t03352633912._1 | |
706 | + | let newPositionLstUpdCPF = $t03352633912._2 | |
738 | 707 | let openNotionalDelta = (oldPositionOpenNotional - newPositionOpenNotional) | |
739 | - | let marginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
708 | + | let marginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT) | |
740 | 709 | let newPositionMarginWithSameRatio = if ((oldPositionSize > 0)) | |
741 | 710 | then (muld((newPositionOpenNotional + unrealizedPnlAfter), marginRatio) - unrealizedPnlAfter) | |
742 | 711 | else (muld((newPositionOpenNotional - unrealizedPnlAfter), marginRatio) - unrealizedPnlAfter) | |
743 | 712 | let marginToTraderRaw = ((remainMarginBefore - (newPositionMarginWithSameRatio + unrealizedPnlAfter)) - realizedCloseFee) | |
744 | 713 | let marginToTrader = if ((0 > marginToTraderRaw)) | |
745 | 714 | then if (_liquidate) | |
746 | 715 | then 0 | |
747 | 716 | else throw("Invalid internalClosePosition params: unable to pay fee") | |
748 | 717 | else marginToTraderRaw | |
749 | 718 | let newPositionMargin = if (_addToMargin) | |
750 | 719 | then (newPositionMarginWithSameRatio + marginToTrader) | |
751 | 720 | else newPositionMarginWithSameRatio | |
752 | 721 | if (if ((_minQuoteAssetAmount != 0)) | |
753 | 722 | then (_minQuoteAssetAmount > exchangedQuoteAssetAmount) | |
754 | 723 | else false) | |
755 | 724 | then throw(((("Limit error: " + toString(exchangedQuoteAssetAmount)) + " < ") + toString(_minQuoteAssetAmount))) | |
756 | 725 | else $Tuple17(newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, positionBadDebt, realizedPnl, if (if (_addToMargin) | |
757 | 726 | then isPartialClose | |
758 | 727 | else false) | |
759 | 728 | then 0 | |
760 | 729 | else marginToTrader, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, (openInterestNotional() - openNotionalDelta), (totalLongPositionSize() - (if (isLongPosition) | |
761 | 730 | then abs(exchangedPositionSize) | |
762 | 731 | else 0)), (totalShortPositionSize() - (if (!(isLongPosition)) | |
763 | 732 | then abs(exchangedPositionSize) | |
764 | 733 | else 0)), (openInterestLong() - (if (isLongPosition) | |
765 | 734 | then openNotionalDelta | |
766 | 735 | else 0)), (openInterestShort() - (if (!(isLongPosition)) | |
767 | 736 | then openNotionalDelta | |
768 | 737 | else 0)), (realizedCloseFee + rolloverFee), exchangedQuoteAssetAmount) | |
769 | 738 | } | |
770 | 739 | else throw(((("Invalid internalClosePosition params: invalid position size: " + toString(_size)) + " max: ") + toString(absOldPositionSize))) | |
771 | 740 | } | |
772 | 741 | ||
773 | 742 | ||
774 | - | func getTwapSpotPrice () = { | |
775 | - | let minuteId = ((lastTimestamp() / 1000) / 60) | |
776 | - | let startMinuteId = (minuteId - TWAP_INTERVAL) | |
777 | - | let listStr = valueOrElse(getString(this, k_lastDataStr), "") | |
778 | - | let list = split(listStr, ",") | |
779 | - | func filterFn (accumulator,next) = if ((startMinuteId >= valueOrErrorMessage(parseInt(next), ("getTwapSpotPrice: invalid int: " + listStr)))) | |
780 | - | then (accumulator :+ parseIntValue(next)) | |
781 | - | else accumulator | |
782 | - | ||
783 | - | let listF = { | |
784 | - | let $l = list | |
785 | - | let $s = size($l) | |
786 | - | let $acc0 = nil | |
787 | - | func $f0_1 ($a,$i) = if (($i >= $s)) | |
788 | - | then $a | |
789 | - | else filterFn($a, $l[$i]) | |
790 | - | ||
791 | - | func $f0_2 ($a,$i) = if (($i >= $s)) | |
792 | - | then $a | |
793 | - | else throw("List size exceeds 20") | |
794 | - | ||
795 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($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), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20) | |
796 | - | } | |
797 | - | let maxIndex = if ((size(listF) > 0)) | |
798 | - | then max(listF) | |
799 | - | else valueOrErrorMessage(parseInt(list[0]), ("getTwapSpotPrice: invalid int: " + listStr)) | |
800 | - | let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
801 | - | let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0) | |
802 | - | let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0) | |
803 | - | let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice)) | |
804 | - | let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0) | |
805 | - | let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0) | |
806 | - | let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice)) | |
807 | - | ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL) | |
808 | - | } | |
809 | - | ||
810 | - | ||
811 | 743 | func getTerminalAmmState () = { | |
812 | 744 | let _positionSize = totalPositionSize() | |
813 | 745 | if ((_positionSize == 0)) | |
814 | 746 | then $Tuple2(qtAstR(), bsAstR()) | |
815 | 747 | else { | |
816 | 748 | let direction = (_positionSize > 0) | |
817 | - | let $ | |
818 | - | let currentNetMarketValue = $ | |
819 | - | let terminalQuoteAssetReserve = $ | |
820 | - | let terminalBaseAssetReserve = $ | |
749 | + | let $t03715937338 = swapOutput(direction, abs(_positionSize), false) | |
750 | + | let currentNetMarketValue = $t03715937338._1 | |
751 | + | let terminalQuoteAssetReserve = $t03715937338._2 | |
752 | + | let terminalBaseAssetReserve = $t03715937338._3 | |
821 | 753 | $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve) | |
822 | 754 | } | |
823 | 755 | } | |
824 | 756 | ||
825 | 757 | ||
826 | 758 | func getQuoteAssetWeight (baseAssetReserve,totalPositionSize,quoteAssetReserve,targetPrice) = { | |
827 | 759 | let b = toBigInt(baseAssetReserve) | |
828 | 760 | let sz = toBigInt(totalPositionSize) | |
829 | 761 | let q = toBigInt(quoteAssetReserve) | |
830 | 762 | let p = toBigInt(targetPrice) | |
831 | 763 | let k = bmuld(q, b) | |
832 | 764 | let newB = (b + sz) | |
833 | 765 | let newQ = bdivd(k, newB) | |
834 | 766 | let z = bdivd(newQ, newB) | |
835 | 767 | let result = bdivd(p, z) | |
836 | 768 | toInt(result) | |
837 | 769 | } | |
838 | 770 | ||
839 | 771 | ||
840 | 772 | func getSyncTerminalPrice (_terminalPrice,_qtAstR,_bsAstR) = { | |
841 | 773 | let _positionSize = totalPositionSize() | |
842 | 774 | if ((_positionSize == 0)) | |
843 | 775 | then { | |
844 | 776 | let newQtAstW = divd(muld(_terminalPrice, _bsAstR), _qtAstR) | |
845 | 777 | $Tuple3(newQtAstW, DECIMAL_UNIT, 0) | |
846 | 778 | } | |
847 | 779 | else { | |
848 | 780 | let direction = (_positionSize > 0) | |
849 | 781 | let currentNetMarketValue = swapOutput(direction, abs(_positionSize), false)._1 | |
850 | 782 | let newQtAstW = getQuoteAssetWeight(_bsAstR, _positionSize, _qtAstR, _terminalPrice) | |
851 | 783 | let newBsAstW = DECIMAL_UNIT | |
852 | 784 | let marginToVault = getPositionNotionalAndUnrealizedPnlByValues(_positionSize, currentNetMarketValue, _qtAstR, newQtAstW, _bsAstR, newBsAstW, PNL_OPTION_SPOT)._2 | |
853 | 785 | $Tuple3(newQtAstW, newBsAstW, marginToVault) | |
854 | 786 | } | |
855 | 787 | } | |
856 | 788 | ||
857 | 789 | ||
858 | 790 | func getFunding () = { | |
859 | 791 | let underlyingPrice = getOraclePrice() | |
860 | - | let | |
861 | - | let premium = ( | |
792 | + | let spotPrice = getSpotPrice() | |
793 | + | let premium = (spotPrice - underlyingPrice) | |
862 | 794 | if (if (if ((totalShortPositionSize() == 0)) | |
863 | 795 | then true | |
864 | 796 | else (totalLongPositionSize() == 0)) | |
865 | 797 | then true | |
866 | 798 | else isMarketClosed()) | |
867 | - | then $ | |
799 | + | then $Tuple3(0, 0, 0) | |
868 | 800 | else if ((0 > premium)) | |
869 | 801 | then { | |
870 | 802 | let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
871 | - | let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize()) | |
872 | - | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
803 | + | if ((fundingMode() == FUNDING_ASYMMETRIC)) | |
804 | + | then { | |
805 | + | let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize()) | |
806 | + | $Tuple3(shortPremiumFraction, longPremiumFraction, 0) | |
807 | + | } | |
808 | + | else { | |
809 | + | let shortTotalPremiumFraction = abs(muld(shortPremiumFraction, totalShortPositionSize())) | |
810 | + | let longTotalPremiumFraction = abs(muld(shortPremiumFraction, totalLongPositionSize())) | |
811 | + | let premiumToVault = (shortTotalPremiumFraction - longTotalPremiumFraction) | |
812 | + | $Tuple3(shortPremiumFraction, shortPremiumFraction, premiumToVault) | |
813 | + | } | |
873 | 814 | } | |
874 | 815 | else { | |
875 | 816 | let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
876 | - | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
877 | - | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
817 | + | if ((fundingMode() == FUNDING_ASYMMETRIC)) | |
818 | + | then { | |
819 | + | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
820 | + | $Tuple3(shortPremiumFraction, longPremiumFraction, 0) | |
821 | + | } | |
822 | + | else { | |
823 | + | let longTotalPremiumFraction = abs(muld(longPremiumFraction, totalLongPositionSize())) | |
824 | + | let shortTotalPremiumFraction = abs(muld(longPremiumFraction, totalShortPositionSize())) | |
825 | + | let premiumToVault = (longTotalPremiumFraction - shortTotalPremiumFraction) | |
826 | + | $Tuple3(longPremiumFraction, longPremiumFraction, premiumToVault) | |
827 | + | } | |
878 | 828 | } | |
879 | 829 | } | |
880 | 830 | ||
881 | 831 | ||
882 | 832 | func getAdjustedFee (_artifactId,_baseFeeDiscount) = { | |
883 | 833 | let baseFeeRaw = fee() | |
884 | 834 | let baseFee = muld(baseFeeRaw, _baseFeeDiscount) | |
885 | - | let $ | |
835 | + | let $t04191342408 = if ((_artifactId != "")) | |
886 | 836 | then { | |
887 | 837 | let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, _artifactId)) | |
888 | 838 | if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE)) | |
889 | 839 | then { | |
890 | 840 | let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, _artifactId)) | |
891 | 841 | let adjustedFee = muld(baseFee, reduction) | |
892 | 842 | $Tuple2(adjustedFee, true) | |
893 | 843 | } | |
894 | 844 | else throw("Invalid attached artifact") | |
895 | 845 | } | |
896 | 846 | else $Tuple2(baseFee, false) | |
897 | - | let adjustedFee = $ | |
898 | - | let burnArtifact = $ | |
847 | + | let adjustedFee = $t04191342408._1 | |
848 | + | let burnArtifact = $t04191342408._2 | |
899 | 849 | $Tuple2(adjustedFee, burnArtifact) | |
900 | 850 | } | |
901 | - | ||
902 | - | ||
903 | - | func isSameAssetOrNoPosition (_trader,_assetId) = { | |
904 | - | let oldPositionSize = getPosition(_trader)._1 | |
905 | - | if ((oldPositionSize == 0)) | |
906 | - | then true | |
907 | - | else (getPositionAsset(_trader) == _assetId) | |
908 | - | } | |
909 | - | ||
910 | - | ||
911 | - | func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId) | |
912 | 851 | ||
913 | 852 | ||
914 | 853 | func getForTraderWithArtifact (_trader,_artifactId) = { | |
915 | 854 | let doGetFeeDiscount = invoke(minerAddress(), "computeFeeDiscount", [_trader], nil) | |
916 | 855 | if ((doGetFeeDiscount == doGetFeeDiscount)) | |
917 | 856 | then { | |
918 | 857 | let feeDiscount = match doGetFeeDiscount { | |
919 | 858 | case x: Int => | |
920 | 859 | x | |
921 | 860 | case _ => | |
922 | 861 | throw("Invalid computeFeeDiscount result") | |
923 | 862 | } | |
924 | - | let $ | |
925 | - | let adjustedFee = $ | |
926 | - | let burnArtifact = $ | |
863 | + | let $t04275442828 = getAdjustedFee(_artifactId, feeDiscount) | |
864 | + | let adjustedFee = $t04275442828._1 | |
865 | + | let burnArtifact = $t04275442828._2 | |
927 | 866 | $Tuple2(adjustedFee, burnArtifact) | |
928 | 867 | } | |
929 | 868 | else throw("Strict value is not equal to itself.") | |
930 | 869 | } | |
931 | 870 | ||
932 | 871 | ||
933 | 872 | func getArtifactId (i) = { | |
934 | 873 | let artifactId = if ((size(i.payments) > 1)) | |
935 | 874 | then toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifactId")) | |
936 | 875 | else "" | |
937 | 876 | artifactId | |
938 | 877 | } | |
939 | 878 | ||
940 | 879 | ||
941 | 880 | func distributeFee (_feeAmount) = { | |
942 | 881 | let feeToStakers = muld(_feeAmount, feeToStakersPercent()) | |
943 | 882 | let feeToVault = (_feeAmount - feeToStakers) | |
944 | 883 | $Tuple2(feeToStakers, feeToVault) | |
945 | 884 | } | |
946 | 885 | ||
947 | 886 | ||
948 | - | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional), IntegerEntry(k_feeToStakersPercent, _feeToStakersPercent), IntegerEntry(k_maxOracleDelay, _feeToStakersPercent), IntegerEntry(k_rolloverFee, _rolloverFee)] | |
887 | + | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional), IntegerEntry(k_feeToStakersPercent, _feeToStakersPercent), IntegerEntry(k_maxOracleDelay, _feeToStakersPercent), IntegerEntry(k_rolloverFee, _rolloverFee), IntegerEntry(k_fundingMode, _fundingMode)] | |
949 | 888 | ||
950 | 889 | ||
951 | 890 | func updateFunding (_nextFundingBlock,_latestLongCumulativePremiumFraction,_latestShortCumulativePremiumFraction,_longFundingRate,_shortFundingRate) = [IntegerEntry(k_nextFundingBlock, _nextFundingBlock), IntegerEntry(k_latestLongCumulativePremiumFraction, _latestLongCumulativePremiumFraction), IntegerEntry(k_latestShortCumulativePremiumFraction, _latestShortCumulativePremiumFraction), IntegerEntry(k_longFundingRate, _longFundingRate), IntegerEntry(k_shortFundingRate, _shortFundingRate)] | |
952 | 891 | ||
953 | 892 | ||
954 | - | func incrementPositionSequenceNumber (_isNewPosition,_address) = if (_isNewPosition) | |
955 | - | then { | |
956 | - | let currentSequence = lastSequence() | |
957 | - | [IntegerEntry(toCompositeKey(k_positionSequence, _address), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))] | |
958 | - | } | |
959 | - | else nil | |
893 | + | func incrementPositionSequenceNumber (_isNewPosition,_trader,_direction) = { | |
894 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
895 | + | if (_isNewPosition) | |
896 | + | then { | |
897 | + | let currentSequence = lastSequence() | |
898 | + | [IntegerEntry(toCompositeKey(k_positionSequence, positionKey), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))] | |
899 | + | } | |
900 | + | else nil | |
901 | + | } | |
960 | 902 | ||
961 | 903 | ||
962 | - | func updatePositionFee (_isNewPosition,_address,_fee) = if (_isNewPosition) | |
963 | - | then [IntegerEntry(toCompositeKey(k_positionFee, _address), _fee)] | |
964 | - | else nil | |
904 | + | func updatePositionFee (_isNewPosition,_trader,_direction,_fee) = { | |
905 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
906 | + | if (_isNewPosition) | |
907 | + | then [IntegerEntry(toCompositeKey(k_positionFee, positionKey), _fee)] | |
908 | + | else nil | |
909 | + | } | |
965 | 910 | ||
966 | 911 | ||
967 | - | func updatePosition (_address,_size,_margin,_openNotional,_latestCumulativePremiumFraction,_latestTimestamp) = [IntegerEntry(toCompositeKey(k_positionSize, _address), _size), IntegerEntry(toCompositeKey(k_positionMargin, _address), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, _address), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address), _latestCumulativePremiumFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _address), _latestTimestamp)] | |
968 | - | ||
969 | - | ||
970 | - | func appendTwap (_price) = { | |
971 | - | let minuteId = ((lastTimestamp() / 1000) / 60) | |
972 | - | let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
973 | - | if ((previousMinuteId > minuteId)) | |
974 | - | then throw("TWAP out-of-order") | |
975 | - | else { | |
976 | - | let lastMinuteId = if ((previousMinuteId == 0)) | |
977 | - | then minuteId | |
978 | - | else previousMinuteId | |
979 | - | if ((minuteId > previousMinuteId)) | |
980 | - | then { | |
981 | - | let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0) | |
982 | - | let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), _price) | |
983 | - | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice)) | |
984 | - | let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId)) | |
985 | - | [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), _price), IntegerEntry(toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId)), previousMinuteId), IntegerEntry(k_lastMinuteId, minuteId), StringEntry(k_lastDataStr, listToStr(list))] | |
986 | - | } | |
987 | - | else { | |
988 | - | let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0) | |
989 | - | let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0) | |
990 | - | let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), _price) | |
991 | - | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice)) | |
992 | - | [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), _price)] | |
993 | - | } | |
994 | - | } | |
912 | + | func updatePosition (_trader,_size,_margin,_openNotional,_latestCumulativePremiumFraction,_latestTimestamp) = { | |
913 | + | let direction = getDirection(_size) | |
914 | + | let positionKey = ((_trader + "_") + toString(direction)) | |
915 | + | [IntegerEntry(toCompositeKey(k_positionSize, positionKey), _size), IntegerEntry(toCompositeKey(k_positionMargin, positionKey), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, positionKey), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey), _latestCumulativePremiumFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey), _latestTimestamp)] | |
995 | 916 | } | |
996 | 917 | ||
997 | 918 | ||
998 | 919 | func updateAmmReserves (_qtAstR,_bsAstR) = [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)] | |
999 | 920 | ||
1000 | 921 | ||
1001 | 922 | func updateAmmWeights (_qtAstW,_bsAstW) = [IntegerEntry(k_quoteAssetWeight, _qtAstW), IntegerEntry(k_baseAssetWeight, _bsAstW)] | |
1002 | 923 | ||
1003 | 924 | ||
1004 | 925 | func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize,_totalLongOpenNotional,_totalShortOpenNotional) = { | |
1005 | 926 | let _qtAstW = qtAstW() | |
1006 | 927 | let _bsAstW = bsAstW() | |
1007 | 928 | if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter)) | |
1008 | 929 | then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter))) | |
1009 | - | else | |
930 | + | else (updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize), IntegerEntry(k_openInterestLong, _totalLongOpenNotional), IntegerEntry(k_openInterestShort, _totalShortOpenNotional)]) | |
1010 | 931 | } | |
1011 | 932 | ||
1012 | 933 | ||
1013 | - | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address)), DeleteEntry(toCompositeKey(k_positionFee, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _address))] | |
934 | + | func deletePosition (_trader,_direction) = { | |
935 | + | let positionKey = ((_trader + "_") + toString(_direction)) | |
936 | + | [DeleteEntry(toCompositeKey(k_positionSize, positionKey)), DeleteEntry(toCompositeKey(k_positionMargin, positionKey)), DeleteEntry(toCompositeKey(k_positionOpenNotional, positionKey)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey)), DeleteEntry(toCompositeKey(k_positionFee, positionKey)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey))] | |
937 | + | } | |
1014 | 938 | ||
1015 | 939 | ||
1016 | 940 | func withdraw (_address,_amount) = { | |
1017 | 941 | let balance = assetBalance(this, quoteAsset()) | |
1018 | 942 | if ((_amount > balance)) | |
1019 | 943 | then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance))) | |
1020 | 944 | else [ScriptTransfer(_address, _amount, quoteAsset())] | |
1021 | 945 | } | |
1022 | 946 | ||
1023 | 947 | ||
1024 | 948 | func updateBalance (i) = if ((0 > i)) | |
1025 | 949 | then throw("Balance") | |
1026 | 950 | else [IntegerEntry(k_balance, i)] | |
1027 | 951 | ||
1028 | 952 | ||
1029 | 953 | func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())] | |
1030 | 954 | ||
1031 | 955 | ||
1032 | 956 | func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact) | |
1033 | 957 | then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)] | |
1034 | 958 | else nil | |
1035 | 959 | ||
1036 | 960 | ||
1037 | 961 | @Callable(i) | |
1038 | 962 | func pause () = if ((i.caller != adminAddress())) | |
1039 | 963 | then throw("Invalid pause params") | |
1040 | 964 | else [BooleanEntry(k_paused, true)] | |
1041 | 965 | ||
1042 | 966 | ||
1043 | 967 | ||
1044 | 968 | @Callable(i) | |
1045 | 969 | func unpause () = if ((i.caller != adminAddress())) | |
1046 | 970 | then throw("Invalid unpause params") | |
1047 | 971 | else [BooleanEntry(k_paused, false)] | |
1048 | 972 | ||
1049 | 973 | ||
1050 | 974 | ||
1051 | 975 | @Callable(i) | |
1052 | 976 | func setCloseOnly () = if ((i.caller != adminAddress())) | |
1053 | 977 | then throw("Invalid setCloseOnly params") | |
1054 | 978 | else [BooleanEntry(k_closeOnly, true)] | |
1055 | 979 | ||
1056 | 980 | ||
1057 | 981 | ||
1058 | 982 | @Callable(i) | |
1059 | 983 | func unsetCloseOnly () = if ((i.caller != adminAddress())) | |
1060 | 984 | then throw("Invalid unsetCloseOnly params") | |
1061 | 985 | else [BooleanEntry(k_closeOnly, false)] | |
1062 | 986 | ||
1063 | 987 | ||
1064 | 988 | ||
1065 | 989 | @Callable(i) | |
1066 | 990 | func addLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress())) | |
1067 | 991 | then true | |
1068 | 992 | else (0 >= _quoteAssetAmount)) | |
1069 | 993 | then throw("Invalid addLiquidity params") | |
1070 | 994 | else { | |
1071 | 995 | let _qtAstR = qtAstR() | |
1072 | 996 | let _bsAstR = bsAstR() | |
1073 | 997 | let _qtAstW = qtAstW() | |
1074 | 998 | let _bsAstW = bsAstW() | |
1075 | 999 | let price = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW)) | |
1076 | 1000 | let qtAstRAfter = (_qtAstR + _quoteAssetAmount) | |
1077 | 1001 | let baseAssetAmountToAdd = (divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR) | |
1078 | 1002 | let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd) | |
1079 | - | let $ | |
1080 | - | let newQuoteAssetWeight = $ | |
1081 | - | let newBaseAssetWeight = $ | |
1082 | - | let marginToVault = $ | |
1003 | + | let $t05108351234 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter) | |
1004 | + | let newQuoteAssetWeight = $t05108351234._1 | |
1005 | + | let newBaseAssetWeight = $t05108351234._2 | |
1006 | + | let marginToVault = $t05108351234._3 | |
1083 | 1007 | let doExchangePnL = if ((marginToVault != 0)) | |
1084 | 1008 | then { | |
1085 | 1009 | let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil) | |
1086 | 1010 | if ((doExchangePnL == doExchangePnL)) | |
1087 | 1011 | then nil | |
1088 | 1012 | else throw("Strict value is not equal to itself.") | |
1089 | 1013 | } | |
1090 | 1014 | else nil | |
1091 | 1015 | if ((doExchangePnL == doExchangePnL)) | |
1092 | 1016 | then (updateAmmReserves(qtAstRAfter, bsAstRAfter) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)) | |
1093 | 1017 | else throw("Strict value is not equal to itself.") | |
1094 | 1018 | } | |
1095 | 1019 | ||
1096 | 1020 | ||
1097 | 1021 | ||
1098 | 1022 | @Callable(i) | |
1099 | 1023 | func removeLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress())) | |
1100 | 1024 | then true | |
1101 | 1025 | else (_quoteAssetAmount >= 0)) | |
1102 | 1026 | then throw("Invalid removeLiquidity params") | |
1103 | 1027 | else { | |
1104 | 1028 | let _qtAstR = qtAstR() | |
1105 | 1029 | let _bsAstR = bsAstR() | |
1106 | 1030 | let _qtAstW = qtAstW() | |
1107 | 1031 | let _bsAstW = bsAstW() | |
1108 | 1032 | let price = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW)) | |
1109 | 1033 | let qtAstRAfter = (_qtAstR - _quoteAssetAmount) | |
1110 | 1034 | let baseAssetAmountToRemove = abs((divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR)) | |
1111 | 1035 | let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove) | |
1112 | - | let $ | |
1113 | - | let newQuoteAssetWeight = $ | |
1114 | - | let newBaseAssetWeight = $ | |
1115 | - | let marginToVault = $ | |
1036 | + | let $t05233052481 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter) | |
1037 | + | let newQuoteAssetWeight = $t05233052481._1 | |
1038 | + | let newBaseAssetWeight = $t05233052481._2 | |
1039 | + | let marginToVault = $t05233052481._3 | |
1116 | 1040 | let doExchangePnL = if ((marginToVault != 0)) | |
1117 | 1041 | then { | |
1118 | 1042 | let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil) | |
1119 | 1043 | if ((doExchangePnL == doExchangePnL)) | |
1120 | 1044 | then nil | |
1121 | 1045 | else throw("Strict value is not equal to itself.") | |
1122 | 1046 | } | |
1123 | 1047 | else nil | |
1124 | 1048 | if ((doExchangePnL == doExchangePnL)) | |
1125 | 1049 | then (updateAmmReserves(qtAstRAfter, bsAstRAfter) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)) | |
1126 | 1050 | else throw("Strict value is not equal to itself.") | |
1127 | 1051 | } | |
1128 | 1052 | ||
1129 | 1053 | ||
1130 | 1054 | ||
1131 | 1055 | @Callable(i) | |
1132 | - | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = if ((i.caller != adminAddress())) | |
1056 | + | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _fundingPeriod)) | |
1057 | + | then true | |
1058 | + | else (0 >= _initMarginRatio)) | |
1059 | + | then true | |
1060 | + | else (0 >= _mmr)) | |
1061 | + | then true | |
1062 | + | else (0 >= _liquidationFeeRatio)) | |
1063 | + | then true | |
1064 | + | else (0 >= _fee)) | |
1065 | + | then true | |
1066 | + | else (0 >= _spreadLimit)) | |
1067 | + | then true | |
1068 | + | else (0 >= _maxPriceImpact)) | |
1069 | + | then true | |
1070 | + | else (0 >= _partialLiquidationRatio)) | |
1071 | + | then true | |
1072 | + | else (0 >= _maxPriceSpread)) | |
1073 | + | then true | |
1074 | + | else (0 >= _maxOpenNotional)) | |
1075 | + | then true | |
1076 | + | else (0 >= _feeToStakersPercent)) | |
1077 | + | then true | |
1078 | + | else (_feeToStakersPercent > DECIMAL_UNIT)) | |
1079 | + | then true | |
1080 | + | else (0 >= _maxOracleDelay)) | |
1081 | + | then true | |
1082 | + | else (0 >= _rolloverFee)) | |
1083 | + | then true | |
1084 | + | else if ((_fundingMode != FUNDING_SYMMETRIC)) | |
1085 | + | then (_fundingMode != FUNDING_ASYMMETRIC) | |
1086 | + | else false) | |
1087 | + | then true | |
1088 | + | else !(initialized())) | |
1089 | + | then true | |
1090 | + | else (i.caller != adminAddress())) | |
1133 | 1091 | then throw("Invalid changeSettings params") | |
1134 | - | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee) | |
1092 | + | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee, _fundingMode) | |
1135 | 1093 | ||
1136 | 1094 | ||
1137 | 1095 | ||
1138 | 1096 | @Callable(i) | |
1139 | - | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_baseOracleData,_quoteOracleData,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
1097 | + | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_baseOracleData,_quoteOracleData,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
1140 | 1098 | then true | |
1141 | 1099 | else (0 >= _bsAstR)) | |
1142 | 1100 | then true | |
1143 | 1101 | else (0 >= _fundingPeriod)) | |
1144 | 1102 | then true | |
1145 | 1103 | else (0 >= _initMarginRatio)) | |
1146 | 1104 | then true | |
1147 | 1105 | else (0 >= _mmr)) | |
1148 | 1106 | then true | |
1149 | 1107 | else (0 >= _liquidationFeeRatio)) | |
1150 | 1108 | then true | |
1151 | 1109 | else (0 >= _fee)) | |
1152 | 1110 | then true | |
1153 | 1111 | else (0 >= _spreadLimit)) | |
1154 | 1112 | then true | |
1155 | 1113 | else (0 >= _maxPriceImpact)) | |
1156 | 1114 | then true | |
1157 | 1115 | else (0 >= _partialLiquidationRatio)) | |
1158 | 1116 | then true | |
1159 | 1117 | else (0 >= _maxPriceSpread)) | |
1160 | 1118 | then true | |
1161 | 1119 | else (0 >= _maxOpenNotional)) | |
1162 | 1120 | then true | |
1163 | 1121 | else (0 >= _feeToStakersPercent)) | |
1164 | 1122 | then true | |
1165 | 1123 | else (_feeToStakersPercent > DECIMAL_UNIT)) | |
1166 | 1124 | then true | |
1167 | 1125 | else (0 >= _maxOracleDelay)) | |
1168 | 1126 | then true | |
1169 | 1127 | else (0 >= _rolloverFee)) | |
1170 | 1128 | then true | |
1129 | + | else if ((_fundingMode != FUNDING_SYMMETRIC)) | |
1130 | + | then (_fundingMode != FUNDING_ASYMMETRIC) | |
1131 | + | else false) | |
1132 | + | then true | |
1171 | 1133 | else initialized()) | |
1172 | 1134 | then true | |
1173 | 1135 | else (i.caller != this)) | |
1174 | 1136 | then throw("Invalid initialize parameters") | |
1175 | - | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee)) ++ updateFunding((lastTimestamp() + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_quoteOracle, _quoteOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))]) | |
1137 | + | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee, _fundingMode)) ++ updateFunding((lastTimestamp() + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_quoteOracle, _quoteOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))]) | |
1176 | 1138 | ||
1177 | 1139 | ||
1178 | 1140 | ||
1179 | 1141 | @Callable(i) | |
1180 | 1142 | func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = { | |
1181 | 1143 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1182 | 1144 | if ((sync == sync)) | |
1183 | 1145 | then { | |
1184 | 1146 | let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil) | |
1185 | 1147 | if ((ensureCalledOnce == ensureCalledOnce)) | |
1186 | 1148 | then { | |
1187 | 1149 | let _trader = getActualCaller(i) | |
1188 | 1150 | let _rawAmount = i.payments[0].amount | |
1189 | 1151 | let _assetId = i.payments[0].assetId | |
1190 | 1152 | let _assetIdStr = toBase58String(value(_assetId)) | |
1191 | 1153 | let isQuoteAsset = (_assetId == quoteAsset()) | |
1192 | - | if (if (if (if (if (if (if (if (if ( | |
1154 | + | if (if (if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
1193 | 1155 | then (_direction != DIR_SHORT) | |
1194 | 1156 | else false) | |
1195 | 1157 | then true | |
1196 | 1158 | else (0 >= _rawAmount)) | |
1197 | 1159 | then true | |
1198 | 1160 | else !(initialized())) | |
1199 | 1161 | then true | |
1200 | 1162 | else !(isQuoteAsset)) | |
1201 | - | then true | |
1202 | - | else !(isSameAssetOrNoPosition(_trader, _assetIdStr))) | |
1203 | 1163 | then true | |
1204 | 1164 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
1205 | 1165 | then true | |
1206 | 1166 | else paused()) | |
1207 | 1167 | then true | |
1208 | 1168 | else closeOnly()) | |
1209 | 1169 | then true | |
1210 | 1170 | else isMarketClosed()) | |
1211 | 1171 | then throw("Invalid increasePosition parameters") | |
1212 | 1172 | else { | |
1213 | - | let $ | |
1214 | - | let adjustedFee = $ | |
1215 | - | let burnArtifact = $ | |
1173 | + | let $t05855158700 = getForTraderWithArtifact(_trader, getArtifactId(i)) | |
1174 | + | let adjustedFee = $t05855158700._1 | |
1175 | + | let burnArtifact = $t05855158700._2 | |
1216 | 1176 | let _amount = divd(_rawAmount, (muld(adjustedFee, _leverage) + DECIMAL_UNIT)) | |
1217 | 1177 | let distributeFeeAmount = (_rawAmount - _amount) | |
1218 | 1178 | let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1219 | 1179 | if ((referrerFeeAny == referrerFeeAny)) | |
1220 | 1180 | then { | |
1221 | 1181 | let referrerFee = match referrerFeeAny { | |
1222 | 1182 | case x: Int => | |
1223 | 1183 | x | |
1224 | 1184 | case _ => | |
1225 | 1185 | throw("Invalid referrerFee") | |
1226 | 1186 | } | |
1227 | 1187 | let feeAmount = (distributeFeeAmount - referrerFee) | |
1228 | - | let $ | |
1229 | - | let oldPositionSize = $ | |
1230 | - | let oldPositionMargin = $ | |
1231 | - | let oldPositionOpenNotional = $ | |
1232 | - | let oldPositionLstUpdCPF = $ | |
1233 | - | let oldPositionTimestamp = $ | |
1188 | + | let $t05919659376 = getPosition(_trader, _direction) | |
1189 | + | let oldPositionSize = $t05919659376._1 | |
1190 | + | let oldPositionMargin = $t05919659376._2 | |
1191 | + | let oldPositionOpenNotional = $t05919659376._3 | |
1192 | + | let oldPositionLstUpdCPF = $t05919659376._4 | |
1193 | + | let oldPositionTimestamp = $t05919659376._5 | |
1234 | 1194 | let isNewPosition = (oldPositionSize == 0) | |
1235 | 1195 | let isSameDirection = if ((oldPositionSize > 0)) | |
1236 | 1196 | then (_direction == DIR_LONG) | |
1237 | 1197 | else (_direction == DIR_SHORT) | |
1238 | 1198 | let expandExisting = if (!(isNewPosition)) | |
1239 | 1199 | then isSameDirection | |
1240 | 1200 | else false | |
1241 | 1201 | let isAdd = (_direction == DIR_LONG) | |
1242 | - | let $ | |
1202 | + | let $t05966562798 = if (if (isNewPosition) | |
1243 | 1203 | then true | |
1244 | 1204 | else expandExisting) | |
1245 | 1205 | then { | |
1246 | 1206 | let openNotional = muld(_amount, _leverage) | |
1247 | - | let $ | |
1248 | - | let amountBaseAssetBought = $ | |
1249 | - | let quoteAssetReserveAfter = $ | |
1250 | - | let baseAssetReserveAfter = $ | |
1251 | - | let totalPositionSizeAfter = $ | |
1207 | + | let $t06017460347 = swapInput(isAdd, openNotional) | |
1208 | + | let amountBaseAssetBought = $t06017460347._1 | |
1209 | + | let quoteAssetReserveAfter = $t06017460347._2 | |
1210 | + | let baseAssetReserveAfter = $t06017460347._3 | |
1211 | + | let totalPositionSizeAfter = $t06017460347._4 | |
1252 | 1212 | if (if ((_minBaseAssetAmount != 0)) | |
1253 | 1213 | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
1254 | 1214 | else false) | |
1255 | 1215 | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1256 | 1216 | else { | |
1257 | 1217 | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
1258 | 1218 | let totalLongOpenInterestAfter = (openInterestLong() + (if ((newPositionSize > 0)) | |
1259 | 1219 | then openNotional | |
1260 | 1220 | else 0)) | |
1261 | 1221 | let totalShortOpenInterestAfter = (openInterestShort() + (if ((0 > newPositionSize)) | |
1262 | 1222 | then openNotional | |
1263 | 1223 | else 0)) | |
1264 | - | let $ | |
1265 | - | let remainMargin = $ | |
1266 | - | let x1 = $ | |
1267 | - | let x2 = $ | |
1268 | - | let rolloverFee = $ | |
1224 | + | let $t06089361168 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, _amount) | |
1225 | + | let remainMargin = $t06089361168._1 | |
1226 | + | let x1 = $t06089361168._2 | |
1227 | + | let x2 = $t06089361168._3 | |
1228 | + | let rolloverFee = $t06089361168._4 | |
1269 | 1229 | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
1270 | 1230 | then throw("Over max spread limit") | |
1271 | 1231 | else if (!(requireNotOverMaxOpenNotional(totalLongOpenInterestAfter, totalShortOpenInterestAfter))) | |
1272 | 1232 | then throw("Over max open notional") | |
1273 | 1233 | else $Tuple14(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), lastTimestamp(), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
1274 | 1234 | then abs(amountBaseAssetBought) | |
1275 | 1235 | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
1276 | 1236 | then abs(amountBaseAssetBought) | |
1277 | 1237 | else 0)), totalLongOpenInterestAfter, totalShortOpenInterestAfter, rolloverFee) | |
1278 | 1238 | } | |
1279 | 1239 | } | |
1280 | 1240 | else { | |
1281 | 1241 | let openNotional = muld(_amount, _leverage) | |
1282 | - | let $ | |
1283 | - | let oldPositionNotional = $ | |
1284 | - | let unrealizedPnl = $ | |
1242 | + | let $t06248662614 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), _direction, PNL_OPTION_SPOT) | |
1243 | + | let oldPositionNotional = $t06248662614._1 | |
1244 | + | let unrealizedPnl = $t06248662614._2 | |
1285 | 1245 | if ((oldPositionNotional > openNotional)) | |
1286 | 1246 | then throw("Use decreasePosition to decrease position size") | |
1287 | 1247 | else throw("Close position first") | |
1288 | 1248 | } | |
1289 | - | let newPositionSize = $ | |
1290 | - | let newPositionRemainMargin = $ | |
1291 | - | let newPositionOpenNotional = $ | |
1292 | - | let newPositionLatestCPF = $ | |
1293 | - | let newPositionTimestamp = $ | |
1294 | - | let baseAssetReserveAfter = $ | |
1295 | - | let quoteAssetReserveAfter = $ | |
1296 | - | let totalPositionSizeAfter = $ | |
1297 | - | let openInterestNotionalAfter = $ | |
1298 | - | let totalLongAfter = $ | |
1299 | - | let totalShortAfter = $ | |
1300 | - | let totalLongOpenInterestAfter = $ | |
1301 | - | let totalShortOpenInterestAfter = $ | |
1302 | - | let rolloverFee = $ | |
1303 | - | let $ | |
1304 | - | let feeToStakers = $ | |
1305 | - | let feeToVault = $ | |
1249 | + | let newPositionSize = $t05966562798._1 | |
1250 | + | let newPositionRemainMargin = $t05966562798._2 | |
1251 | + | let newPositionOpenNotional = $t05966562798._3 | |
1252 | + | let newPositionLatestCPF = $t05966562798._4 | |
1253 | + | let newPositionTimestamp = $t05966562798._5 | |
1254 | + | let baseAssetReserveAfter = $t05966562798._6 | |
1255 | + | let quoteAssetReserveAfter = $t05966562798._7 | |
1256 | + | let totalPositionSizeAfter = $t05966562798._8 | |
1257 | + | let openInterestNotionalAfter = $t05966562798._9 | |
1258 | + | let totalLongAfter = $t05966562798._10 | |
1259 | + | let totalShortAfter = $t05966562798._11 | |
1260 | + | let totalLongOpenInterestAfter = $t05966562798._12 | |
1261 | + | let totalShortOpenInterestAfter = $t05966562798._13 | |
1262 | + | let rolloverFee = $t05966562798._14 | |
1263 | + | let $t06280462875 = distributeFee((feeAmount + rolloverFee)) | |
1264 | + | let feeToStakers = $t06280462875._1 | |
1265 | + | let feeToVault = $t06280462875._2 | |
1306 | 1266 | let stake = if ((_amount >= rolloverFee)) | |
1307 | 1267 | then invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), (_amount - rolloverFee))]) | |
1308 | 1268 | else invoke(vaultAddress(), "withdrawLocked", [(rolloverFee - _amount)], nil) | |
1309 | 1269 | if ((stake == stake)) | |
1310 | 1270 | then { | |
1311 | 1271 | let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)]) | |
1312 | 1272 | if ((depositVault == depositVault)) | |
1313 | 1273 | then { | |
1314 | 1274 | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1315 | 1275 | if ((notifyFee == notifyFee)) | |
1316 | 1276 | then { | |
1317 | 1277 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1318 | 1278 | if ((notifyNotional == notifyNotional)) | |
1319 | - | then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF, newPositionTimestamp) ++ incrementPositionSequenceNumber(isNewPosition, _trader)) ++ updatePositionFee(isNewPosition, _trader, adjustedFee)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doBurnArtifact(burnArtifact, i)) | |
1279 | + | then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF, newPositionTimestamp) ++ incrementPositionSequenceNumber(isNewPosition, _trader, _direction)) ++ updatePositionFee(isNewPosition, _trader, _direction, adjustedFee)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doBurnArtifact(burnArtifact, i)) | |
1320 | 1280 | else throw("Strict value is not equal to itself.") | |
1321 | 1281 | } | |
1322 | 1282 | else throw("Strict value is not equal to itself.") | |
1323 | 1283 | } | |
1324 | 1284 | else throw("Strict value is not equal to itself.") | |
1325 | 1285 | } | |
1326 | 1286 | else throw("Strict value is not equal to itself.") | |
1327 | 1287 | } | |
1328 | 1288 | else throw("Strict value is not equal to itself.") | |
1329 | 1289 | } | |
1330 | 1290 | } | |
1331 | 1291 | else throw("Strict value is not equal to itself.") | |
1332 | 1292 | } | |
1333 | 1293 | else throw("Strict value is not equal to itself.") | |
1334 | 1294 | } | |
1335 | 1295 | ||
1336 | 1296 | ||
1337 | 1297 | ||
1338 | 1298 | @Callable(i) | |
1339 | - | func addMargin () = { | |
1299 | + | func addMargin (_direction) = { | |
1340 | 1300 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1341 | 1301 | if ((sync == sync)) | |
1342 | 1302 | then { | |
1343 | 1303 | let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil) | |
1344 | 1304 | if ((ensureCalledOnce == ensureCalledOnce)) | |
1345 | 1305 | then { | |
1346 | 1306 | let _trader = toString(i.caller) | |
1347 | 1307 | let _amount = i.payments[0].amount | |
1348 | 1308 | let _assetId = i.payments[0].assetId | |
1349 | 1309 | let _assetIdStr = toBase58String(value(_assetId)) | |
1350 | 1310 | let isQuoteAsset = (_assetId == quoteAsset()) | |
1351 | - | if (if (if (if (if ( | |
1311 | + | if (if (if (if (if (!(isQuoteAsset)) | |
1352 | 1312 | then true | |
1353 | - | else !(requireOpenPosition(toString(i.caller)))) | |
1354 | - | then true | |
1355 | - | else !(isSameAsset(_trader, _assetIdStr))) | |
1313 | + | else !(requireOpenPosition(toString(i.caller), _direction))) | |
1356 | 1314 | then true | |
1357 | 1315 | else !(initialized())) | |
1358 | 1316 | then true | |
1359 | 1317 | else paused()) | |
1360 | 1318 | then true | |
1361 | - | else closeOnly()) | |
1362 | - | then true | |
1363 | 1319 | else isMarketClosed()) | |
1364 | 1320 | then throw("Invalid addMargin parameters") | |
1365 | 1321 | else { | |
1366 | - | let $ | |
1367 | - | let oldPositionSize = $ | |
1368 | - | let oldPositionMargin = $ | |
1369 | - | let oldPositionOpenNotional = $ | |
1370 | - | let oldPositionLstUpdCPF = $ | |
1371 | - | let oldPositionTimestamp = $ | |
1322 | + | let $t06512265302 = getPosition(_trader, _direction) | |
1323 | + | let oldPositionSize = $t06512265302._1 | |
1324 | + | let oldPositionMargin = $t06512265302._2 | |
1325 | + | let oldPositionOpenNotional = $t06512265302._3 | |
1326 | + | let oldPositionLstUpdCPF = $t06512265302._4 | |
1327 | + | let oldPositionTimestamp = $t06512265302._5 | |
1372 | 1328 | let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1373 | 1329 | if ((stake == stake)) | |
1374 | 1330 | then { | |
1375 | 1331 | let rolloverFee = calcRolloverFee(oldPositionMargin, oldPositionTimestamp) | |
1376 | 1332 | let doTransferFeeToStakers = if ((rolloverFee > 0)) | |
1377 | 1333 | then { | |
1378 | - | let $ | |
1379 | - | let feeToStakers = $ | |
1380 | - | let feeToVault = $ | |
1334 | + | let $t06558765646 = distributeFee(rolloverFee) | |
1335 | + | let feeToStakers = $t06558765646._1 | |
1336 | + | let feeToVault = $t06558765646._2 | |
1381 | 1337 | let unstake = invoke(vaultAddress(), "withdrawLocked", [feeToStakers], nil) | |
1382 | 1338 | if ((unstake == unstake)) | |
1383 | 1339 | then { | |
1384 | 1340 | let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(feeToVault)], nil) | |
1385 | 1341 | if ((lockBadDebt == lockBadDebt)) | |
1386 | 1342 | then transferFee(feeToStakers) | |
1387 | 1343 | else throw("Strict value is not equal to itself.") | |
1388 | 1344 | } | |
1389 | 1345 | else throw("Strict value is not equal to itself.") | |
1390 | 1346 | } | |
1391 | 1347 | else nil | |
1392 | 1348 | if ((doTransferFeeToStakers == doTransferFeeToStakers)) | |
1393 | 1349 | then ((updatePosition(_trader, oldPositionSize, ((oldPositionMargin - rolloverFee) + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF, lastTimestamp()) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doTransferFeeToStakers) | |
1394 | 1350 | else throw("Strict value is not equal to itself.") | |
1395 | 1351 | } | |
1396 | 1352 | else throw("Strict value is not equal to itself.") | |
1397 | 1353 | } | |
1398 | 1354 | } | |
1399 | 1355 | else throw("Strict value is not equal to itself.") | |
1400 | 1356 | } | |
1401 | 1357 | else throw("Strict value is not equal to itself.") | |
1402 | 1358 | } | |
1403 | 1359 | ||
1404 | 1360 | ||
1405 | 1361 | ||
1406 | 1362 | @Callable(i) | |
1407 | - | func removeMargin (_amount) = { | |
1363 | + | func removeMargin (_amount,_direction) = { | |
1408 | 1364 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1409 | 1365 | if ((sync == sync)) | |
1410 | 1366 | then { | |
1411 | 1367 | let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil) | |
1412 | 1368 | if ((ensureCalledOnce == ensureCalledOnce)) | |
1413 | 1369 | then { | |
1414 | 1370 | let _trader = toString(i.caller) | |
1415 | 1371 | if (if (if (if (if ((0 >= _amount)) | |
1416 | 1372 | then true | |
1417 | - | else !(requireOpenPosition(_trader))) | |
1373 | + | else !(requireOpenPosition(_trader, _direction))) | |
1418 | 1374 | then true | |
1419 | 1375 | else !(initialized())) | |
1420 | 1376 | then true | |
1421 | 1377 | else paused()) | |
1422 | 1378 | then true | |
1423 | 1379 | else isMarketClosed()) | |
1424 | 1380 | then throw("Invalid removeMargin parameters") | |
1425 | 1381 | else { | |
1426 | - | let $ | |
1427 | - | let oldPositionSize = $ | |
1428 | - | let oldPositionMargin = $ | |
1429 | - | let oldPositionOpenNotional = $ | |
1430 | - | let oldPositionLstUpdCPF = $ | |
1431 | - | let oldPositionTimestamp = $ | |
1432 | - | let $ | |
1433 | - | let remainMargin = $ | |
1434 | - | let badDebt = $ | |
1435 | - | let fundingPayment = $ | |
1436 | - | let rolloverFee = $ | |
1382 | + | let $t06705067230 = getPosition(_trader, _direction) | |
1383 | + | let oldPositionSize = $t06705067230._1 | |
1384 | + | let oldPositionMargin = $t06705067230._2 | |
1385 | + | let oldPositionOpenNotional = $t06705067230._3 | |
1386 | + | let oldPositionLstUpdCPF = $t06705067230._4 | |
1387 | + | let oldPositionTimestamp = $t06705067230._5 | |
1388 | + | let $t06723667485 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, -(_amount)) | |
1389 | + | let remainMargin = $t06723667485._1 | |
1390 | + | let badDebt = $t06723667485._2 | |
1391 | + | let fundingPayment = $t06723667485._3 | |
1392 | + | let rolloverFee = $t06723667485._4 | |
1437 | 1393 | if ((badDebt != 0)) | |
1438 | 1394 | then throw("Invalid removed margin amount") | |
1439 | 1395 | else { | |
1440 | 1396 | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1441 | 1397 | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1442 | 1398 | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1443 | 1399 | else { | |
1444 | - | let $ | |
1445 | - | let feeToStakers = $ | |
1446 | - | let feeToVault = $ | |
1400 | + | let $t06787167930 = distributeFee(rolloverFee) | |
1401 | + | let feeToStakers = $t06787167930._1 | |
1402 | + | let feeToVault = $t06787167930._2 | |
1447 | 1403 | let doTransferFeeToStakers = if ((rolloverFee > 0)) | |
1448 | 1404 | then { | |
1449 | 1405 | let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(feeToVault)], nil) | |
1450 | 1406 | if ((lockBadDebt == lockBadDebt)) | |
1451 | 1407 | then transferFee(feeToStakers) | |
1452 | 1408 | else throw("Strict value is not equal to itself.") | |
1453 | 1409 | } | |
1454 | 1410 | else nil | |
1455 | 1411 | if ((doTransferFeeToStakers == doTransferFeeToStakers)) | |
1456 | 1412 | then { | |
1457 | 1413 | let unstake = invoke(vaultAddress(), "withdrawLocked", [(_amount + feeToStakers)], nil) | |
1458 | 1414 | if ((unstake == unstake)) | |
1459 | 1415 | then (((updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize), lastTimestamp()) ++ withdraw(i.caller, _amount)) ++ updateBalance(((cbalance() - _amount) - rolloverFee))) ++ doTransferFeeToStakers) | |
1460 | 1416 | else throw("Strict value is not equal to itself.") | |
1461 | 1417 | } | |
1462 | 1418 | else throw("Strict value is not equal to itself.") | |
1463 | 1419 | } | |
1464 | 1420 | } | |
1465 | 1421 | } | |
1466 | 1422 | } | |
1467 | 1423 | else throw("Strict value is not equal to itself.") | |
1468 | 1424 | } | |
1469 | 1425 | else throw("Strict value is not equal to itself.") | |
1470 | 1426 | } | |
1471 | 1427 | ||
1472 | 1428 | ||
1473 | 1429 | ||
1474 | 1430 | @Callable(i) | |
1475 | - | func closePosition (_size,_minQuoteAssetAmount,_addToMargin) = { | |
1431 | + | func closePosition (_size,_direction,_minQuoteAssetAmount,_addToMargin) = { | |
1476 | 1432 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1477 | 1433 | if ((sync == sync)) | |
1478 | 1434 | then { | |
1479 | 1435 | let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil) | |
1480 | 1436 | if ((ensureCalledOnce == ensureCalledOnce)) | |
1481 | 1437 | then { | |
1482 | 1438 | let _trader = getActualCaller(i) | |
1483 | 1439 | let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller") | |
1484 | - | let positionFee = getPositionFee(_trader) | |
1485 | - | if (if (if (if (if (if (!(requireOpenPosition(_trader))) | |
1440 | + | let positionFee = getPositionFee(_trader, _direction) | |
1441 | + | if (if (if (if (if (if (!(requireOpenPosition(_trader, _direction))) | |
1486 | 1442 | then true | |
1487 | 1443 | else !(initialized())) | |
1488 | 1444 | then true | |
1489 | 1445 | else paused()) | |
1490 | 1446 | then true | |
1491 | 1447 | else (0 >= _size)) | |
1492 | 1448 | then true | |
1493 | 1449 | else (0 > _minQuoteAssetAmount)) | |
1494 | 1450 | then true | |
1495 | 1451 | else isMarketClosed()) | |
1496 | 1452 | then throw("Invalid closePosition parameters") | |
1497 | 1453 | else { | |
1498 | - | let oldPositionTimestamp = getPosition(_trader)._5 | |
1499 | - | let $ | |
1500 | - | let newPositionSize = $ | |
1501 | - | let newPositionMargin = $ | |
1502 | - | let newPositionOpenNotional = $ | |
1503 | - | let newPositionLstUpdCPF = $ | |
1504 | - | let positionBadDebt = $ | |
1505 | - | let realizedPnl = $ | |
1506 | - | let marginToTrader = $ | |
1507 | - | let quoteAssetReserveAfter = $ | |
1508 | - | let baseAssetReserveAfter = $ | |
1509 | - | let totalPositionSizeAfter = $ | |
1510 | - | let openInterestNotionalAfter = $ | |
1511 | - | let totalLongAfter = $ | |
1512 | - | let totalShortAfter = $ | |
1513 | - | let totalLongOpenInterestAfter = $ | |
1514 | - | let totalShortOpenInterestAfter = $ | |
1515 | - | let realizedFee = $ | |
1454 | + | let oldPositionTimestamp = getPosition(_trader, _direction)._5 | |
1455 | + | let $t07015870761 = internalClosePosition(_trader, _direction, _size, positionFee, _minQuoteAssetAmount, _addToMargin, true, true) | |
1456 | + | let newPositionSize = $t07015870761._1 | |
1457 | + | let newPositionMargin = $t07015870761._2 | |
1458 | + | let newPositionOpenNotional = $t07015870761._3 | |
1459 | + | let newPositionLstUpdCPF = $t07015870761._4 | |
1460 | + | let positionBadDebt = $t07015870761._5 | |
1461 | + | let realizedPnl = $t07015870761._6 | |
1462 | + | let marginToTrader = $t07015870761._7 | |
1463 | + | let quoteAssetReserveAfter = $t07015870761._8 | |
1464 | + | let baseAssetReserveAfter = $t07015870761._9 | |
1465 | + | let totalPositionSizeAfter = $t07015870761._10 | |
1466 | + | let openInterestNotionalAfter = $t07015870761._11 | |
1467 | + | let totalLongAfter = $t07015870761._12 | |
1468 | + | let totalShortAfter = $t07015870761._13 | |
1469 | + | let totalLongOpenInterestAfter = $t07015870761._14 | |
1470 | + | let totalShortOpenInterestAfter = $t07015870761._15 | |
1471 | + | let realizedFee = $t07015870761._16 | |
1516 | 1472 | if ((positionBadDebt > 0)) | |
1517 | 1473 | then throw("Invalid closePosition parameters: bad debt") | |
1518 | 1474 | else if ((oldPositionTimestamp >= lastTimestamp())) | |
1519 | 1475 | then throw("Invalid closePosition parameters: wait at least 1 block before closing the position") | |
1520 | 1476 | else { | |
1521 | 1477 | let isPartialClose = (newPositionSize != 0) | |
1522 | 1478 | let withdrawAmount = (marginToTrader + realizedFee) | |
1523 | 1479 | let ammBalance = (cbalance() - withdrawAmount) | |
1524 | 1480 | let ammNewBalance = if ((0 > ammBalance)) | |
1525 | 1481 | then 0 | |
1526 | 1482 | else ammBalance | |
1527 | 1483 | let unstake = invoke(vaultAddress(), "withdrawLocked", [withdrawAmount], nil) | |
1528 | 1484 | if ((unstake == unstake)) | |
1529 | 1485 | then { | |
1530 | - | let $t06970569764 = distributeFee(realizedFee) | |
1531 | - | let feeToStakers = $t06970569764._1 | |
1532 | - | let feeToVault = $t06970569764._2 | |
1533 | - | let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)]) | |
1534 | - | if ((depositVault == depositVault)) | |
1486 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), realizedFee)]) | |
1487 | + | if ((referrerFeeAny == referrerFeeAny)) | |
1535 | 1488 | then { | |
1536 | - | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, realizedFee], nil) | |
1537 | - | if ((notifyFee == notifyFee)) | |
1489 | + | let referrerFee = match referrerFeeAny { | |
1490 | + | case x: Int => | |
1491 | + | x | |
1492 | + | case _ => | |
1493 | + | throw("Invalid referrerFee") | |
1494 | + | } | |
1495 | + | let $t07173371806 = distributeFee((realizedFee - referrerFee)) | |
1496 | + | let feeToStakers = $t07173371806._1 | |
1497 | + | let feeToVault = $t07173371806._2 | |
1498 | + | let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)]) | |
1499 | + | if ((depositVault == depositVault)) | |
1538 | 1500 | then { | |
1539 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1540 | - | if ((notifyNotional == notifyNotional)) | |
1541 | - | then (((((if (isPartialClose) | |
1542 | - | then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp()) | |
1543 | - | else deletePosition(_trader)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((marginToTrader > 0)) | |
1544 | - | then withdraw(_traderAddress, marginToTrader) | |
1545 | - | else nil)) ++ updateBalance(ammNewBalance)) ++ transferFee(feeToStakers)) | |
1501 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, realizedFee], nil) | |
1502 | + | if ((notifyFee == notifyFee)) | |
1503 | + | then { | |
1504 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1505 | + | if ((notifyNotional == notifyNotional)) | |
1506 | + | then (((((if (isPartialClose) | |
1507 | + | then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp()) | |
1508 | + | else deletePosition(_trader, _direction)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((marginToTrader > 0)) | |
1509 | + | then withdraw(_traderAddress, marginToTrader) | |
1510 | + | else nil)) ++ updateBalance(ammNewBalance)) ++ transferFee(feeToStakers)) | |
1511 | + | else throw("Strict value is not equal to itself.") | |
1512 | + | } | |
1546 | 1513 | else throw("Strict value is not equal to itself.") | |
1547 | 1514 | } | |
1548 | 1515 | else throw("Strict value is not equal to itself.") | |
1549 | 1516 | } | |
1550 | 1517 | else throw("Strict value is not equal to itself.") | |
1551 | 1518 | } | |
1552 | 1519 | else throw("Strict value is not equal to itself.") | |
1553 | 1520 | } | |
1554 | 1521 | } | |
1555 | 1522 | } | |
1556 | 1523 | else throw("Strict value is not equal to itself.") | |
1557 | 1524 | } | |
1558 | 1525 | else throw("Strict value is not equal to itself.") | |
1559 | 1526 | } | |
1560 | 1527 | ||
1561 | 1528 | ||
1562 | 1529 | ||
1563 | 1530 | @Callable(i) | |
1564 | - | func liquidate (_trader) = { | |
1531 | + | func liquidate (_trader,_direction) = { | |
1565 | 1532 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1566 | 1533 | if ((sync == sync)) | |
1567 | 1534 | then { | |
1568 | - | let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
1535 | + | let spotMarginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT) | |
1569 | 1536 | let liquidationMarginRatio = if (isOverFluctuationLimit()) | |
1570 | 1537 | then { | |
1571 | - | let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE) | |
1538 | + | let oracleMarginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_ORACLE) | |
1572 | 1539 | vmax(spotMarginRatio, oracleMarginRatio) | |
1573 | 1540 | } | |
1574 | 1541 | else spotMarginRatio | |
1575 | 1542 | if (if (if (if (if (!(requireMoreMarginRatio(liquidationMarginRatio, maintenanceMarginRatio(), false))) | |
1576 | 1543 | then true | |
1577 | - | else !(requireOpenPosition(_trader))) | |
1544 | + | else !(requireOpenPosition(_trader, _direction))) | |
1578 | 1545 | then true | |
1579 | 1546 | else !(initialized())) | |
1580 | 1547 | then true | |
1581 | 1548 | else paused()) | |
1582 | 1549 | then true | |
1583 | 1550 | else isMarketClosed()) | |
1584 | 1551 | then throw("Unable to liquidate") | |
1585 | 1552 | else { | |
1586 | 1553 | let isPartialLiquidation = if (if ((spotMarginRatio > liquidationFeeRatio())) | |
1587 | 1554 | then (partialLiquidationRatio() > 0) | |
1588 | 1555 | else false) | |
1589 | 1556 | then (DECIMAL_UNIT > partialLiquidationRatio()) | |
1590 | 1557 | else false | |
1591 | - | let oldPositionSize = getPosition(_trader)._1 | |
1558 | + | let oldPositionSize = getPosition(_trader, _direction)._1 | |
1592 | 1559 | let positionSizeAbs = abs(oldPositionSize) | |
1593 | - | let $ | |
1560 | + | let $t07430474627 = if (isPartialLiquidation) | |
1594 | 1561 | then { | |
1595 | 1562 | let liquidationSize = getPartialLiquidationAmount(_trader, oldPositionSize) | |
1596 | 1563 | let liquidationRatio = divd(abs(liquidationSize), positionSizeAbs) | |
1597 | 1564 | $Tuple2(liquidationRatio, abs(liquidationSize)) | |
1598 | 1565 | } | |
1599 | 1566 | else $Tuple2(0, positionSizeAbs) | |
1600 | - | let liquidationRatio = $ | |
1601 | - | let liquidationSize = $ | |
1602 | - | let $ | |
1567 | + | let liquidationRatio = $t07430474627._1 | |
1568 | + | let liquidationSize = $t07430474627._2 | |
1569 | + | let $t07463375289 = internalClosePosition(_trader, _direction, if (isPartialLiquidation) | |
1603 | 1570 | then liquidationSize | |
1604 | 1571 | else positionSizeAbs, liquidationFeeRatio(), 0, true, false, true) | |
1605 | - | let newPositionSize = $ | |
1606 | - | let newPositionMargin = $ | |
1607 | - | let newPositionOpenNotional = $ | |
1608 | - | let newPositionLstUpdCPF = $ | |
1609 | - | let positionBadDebt = $ | |
1610 | - | let realizedPnl = $ | |
1611 | - | let marginToTrader = $ | |
1612 | - | let quoteAssetReserveAfter = $ | |
1613 | - | let baseAssetReserveAfter = $ | |
1614 | - | let totalPositionSizeAfter = $ | |
1615 | - | let openInterestNotionalAfter = $ | |
1616 | - | let totalLongAfter = $ | |
1617 | - | let totalShortAfter = $ | |
1618 | - | let totalLongOpenInterestAfter = $ | |
1619 | - | let totalShortOpenInterestAfter = $ | |
1620 | - | let liquidationPenalty = $ | |
1572 | + | let newPositionSize = $t07463375289._1 | |
1573 | + | let newPositionMargin = $t07463375289._2 | |
1574 | + | let newPositionOpenNotional = $t07463375289._3 | |
1575 | + | let newPositionLstUpdCPF = $t07463375289._4 | |
1576 | + | let positionBadDebt = $t07463375289._5 | |
1577 | + | let realizedPnl = $t07463375289._6 | |
1578 | + | let marginToTrader = $t07463375289._7 | |
1579 | + | let quoteAssetReserveAfter = $t07463375289._8 | |
1580 | + | let baseAssetReserveAfter = $t07463375289._9 | |
1581 | + | let totalPositionSizeAfter = $t07463375289._10 | |
1582 | + | let openInterestNotionalAfter = $t07463375289._11 | |
1583 | + | let totalLongAfter = $t07463375289._12 | |
1584 | + | let totalShortAfter = $t07463375289._13 | |
1585 | + | let totalLongOpenInterestAfter = $t07463375289._14 | |
1586 | + | let totalShortOpenInterestAfter = $t07463375289._15 | |
1587 | + | let liquidationPenalty = $t07463375289._16 | |
1621 | 1588 | let feeToLiquidator = (liquidationPenalty / 2) | |
1622 | 1589 | let feeToVault = (liquidationPenalty - feeToLiquidator) | |
1623 | 1590 | let ammBalance = (cbalance() - liquidationPenalty) | |
1624 | 1591 | let newAmmBalance = if ((0 > ammBalance)) | |
1625 | 1592 | then 0 | |
1626 | 1593 | else ammBalance | |
1627 | 1594 | let lockBadDebt = if ((positionBadDebt > 0)) | |
1628 | 1595 | then { | |
1629 | 1596 | let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [(positionBadDebt + liquidationPenalty)], nil) | |
1630 | 1597 | if ((lockBadDebt == lockBadDebt)) | |
1631 | 1598 | then nil | |
1632 | 1599 | else throw("Strict value is not equal to itself.") | |
1633 | 1600 | } | |
1634 | 1601 | else nil | |
1635 | 1602 | if ((lockBadDebt == lockBadDebt)) | |
1636 | 1603 | then { | |
1637 | 1604 | let unstake = invoke(vaultAddress(), "withdrawLocked", [liquidationPenalty], nil) | |
1638 | 1605 | if ((unstake == unstake)) | |
1639 | 1606 | then { | |
1640 | 1607 | let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)]) | |
1641 | 1608 | if ((depositInsurance == depositInsurance)) | |
1642 | 1609 | then { | |
1643 | 1610 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1644 | 1611 | if ((notifyNotional == notifyNotional)) | |
1645 | 1612 | then ((((if (isPartialLiquidation) | |
1646 | 1613 | then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp()) | |
1647 | - | else deletePosition(_trader)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1614 | + | else deletePosition(_trader, _direction)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1648 | 1615 | else throw("Strict value is not equal to itself.") | |
1649 | 1616 | } | |
1650 | 1617 | else throw("Strict value is not equal to itself.") | |
1651 | 1618 | } | |
1652 | 1619 | else throw("Strict value is not equal to itself.") | |
1653 | 1620 | } | |
1654 | 1621 | else throw("Strict value is not equal to itself.") | |
1655 | 1622 | } | |
1656 | 1623 | } | |
1657 | 1624 | else throw("Strict value is not equal to itself.") | |
1658 | 1625 | } | |
1659 | 1626 | ||
1660 | 1627 | ||
1661 | 1628 | ||
1662 | 1629 | @Callable(i) | |
1663 | 1630 | func payFunding () = { | |
1664 | 1631 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1665 | 1632 | if ((sync == sync)) | |
1666 | 1633 | then { | |
1667 | 1634 | let fundingBlockTimestamp = nextFundingBlockTimestamp() | |
1668 | 1635 | if (if (if ((fundingBlockTimestamp > lastTimestamp())) | |
1669 | 1636 | then true | |
1670 | 1637 | else !(initialized())) | |
1671 | 1638 | then true | |
1672 | 1639 | else paused()) | |
1673 | 1640 | then throw(((("Invalid funding block timestamp: " + toString(lastTimestamp())) + " < ") + toString(fundingBlockTimestamp))) | |
1674 | 1641 | else { | |
1675 | 1642 | let underlyingPrice = getOraclePrice() | |
1676 | - | let $t07503175093 = getFunding() | |
1677 | - | let shortPremiumFraction = $t07503175093._1 | |
1678 | - | let longPremiumFraction = $t07503175093._2 | |
1679 | - | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1643 | + | let $t07741477492 = getFunding() | |
1644 | + | let shortPremiumFraction = $t07741477492._1 | |
1645 | + | let longPremiumFraction = $t07741477492._2 | |
1646 | + | let premiumToVault = $t07741477492._3 | |
1647 | + | let doPayFundingToVault = if ((premiumToVault > 0)) | |
1648 | + | then { | |
1649 | + | let doPayFundingToVault = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(premiumToVault)], nil) | |
1650 | + | if ((doPayFundingToVault == doPayFundingToVault)) | |
1651 | + | then nil | |
1652 | + | else throw("Strict value is not equal to itself.") | |
1653 | + | } | |
1654 | + | else nil | |
1655 | + | if ((doPayFundingToVault == doPayFundingToVault)) | |
1656 | + | then updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1657 | + | else throw("Strict value is not equal to itself.") | |
1680 | 1658 | } | |
1681 | 1659 | } | |
1682 | 1660 | else throw("Strict value is not equal to itself.") | |
1683 | 1661 | } | |
1684 | 1662 | ||
1685 | 1663 | ||
1686 | 1664 | ||
1687 | 1665 | @Callable(i) | |
1688 | 1666 | func syncTerminalPriceToOracle () = { | |
1689 | 1667 | let _qtAstR = qtAstR() | |
1690 | 1668 | let _bsAstR = bsAstR() | |
1691 | - | let $ | |
1692 | - | let newQuoteAssetWeight = $ | |
1693 | - | let newBaseAssetWeight = $ | |
1694 | - | let marginToVault = $ | |
1669 | + | let $t07854578911 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR) | |
1670 | + | let newQuoteAssetWeight = $t07854578911._1 | |
1671 | + | let newBaseAssetWeight = $t07854578911._2 | |
1672 | + | let marginToVault = $t07854578911._3 | |
1695 | 1673 | let marginToVaultAdj = if (if ((0 > marginToVault)) | |
1696 | 1674 | then (abs(marginToVault) > cbalance()) | |
1697 | 1675 | else false) | |
1698 | 1676 | then -(cbalance()) | |
1699 | 1677 | else marginToVault | |
1700 | 1678 | let doExchangePnL = if ((marginToVaultAdj != 0)) | |
1701 | 1679 | then { | |
1702 | 1680 | let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVaultAdj], nil) | |
1703 | 1681 | if ((doExchangePnL == doExchangePnL)) | |
1704 | 1682 | then nil | |
1705 | 1683 | else throw("Strict value is not equal to itself.") | |
1706 | 1684 | } | |
1707 | 1685 | else nil | |
1708 | 1686 | if ((doExchangePnL == doExchangePnL)) | |
1709 | - | then | |
1687 | + | then (updateBalance((cbalance() + marginToVaultAdj)) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)) | |
1710 | 1688 | else throw("Strict value is not equal to itself.") | |
1711 | 1689 | } | |
1712 | 1690 | ||
1713 | 1691 | ||
1714 | 1692 | ||
1715 | 1693 | @Callable(i) | |
1716 | 1694 | func ensureCalledOnce () = if ((i.caller != this)) | |
1717 | 1695 | then throw("Invalid saveCurrentTxId parameters") | |
1718 | 1696 | else { | |
1697 | + | let txId = toBase58String(i.transactionId) | |
1719 | 1698 | let lastTx = valueOrElse(getString(this, k_lastTx), "") | |
1720 | - | if ((lastTx != | |
1721 | - | then [StringEntry(k_lastTx, | |
1699 | + | if ((lastTx != txId)) | |
1700 | + | then [StringEntry(k_lastTx, txId)] | |
1722 | 1701 | else throw("Can not call vAMM methods twice in one tx") | |
1723 | 1702 | } | |
1724 | 1703 | ||
1725 | 1704 | ||
1726 | 1705 | ||
1727 | 1706 | @Callable(i) | |
1728 | - | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1707 | + | func migratePosition (_trader) = { | |
1708 | + | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader)) | |
1709 | + | if (if (isDefined(positionSizeOpt)) | |
1710 | + | then isDefined(addressFromString(_trader)) | |
1711 | + | else false) | |
1712 | + | then { | |
1713 | + | let pSize = getIntegerValue(this, toCompositeKey(k_positionSize, _trader)) | |
1714 | + | let pMargin = getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)) | |
1715 | + | let pNotional = getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)) | |
1716 | + | let pFraction = getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)) | |
1717 | + | let pTimestamp = valueOrElse(getInteger(this, toCompositeKey(k_positionLastUpdatedTimestamp, _trader)), lastBlock.timestamp) | |
1718 | + | let pFee = valueOrElse(getInteger(this, toCompositeKey(k_positionFee, _trader)), fee()) | |
1719 | + | let pSequence = getIntegerValue(this, toCompositeKey(k_positionSequence, _trader)) | |
1720 | + | let pDirection = getDirection(pSize) | |
1721 | + | let positionKey = ((_trader + "_") + toString(pDirection)) | |
1722 | + | [DeleteEntry(toCompositeKey(k_positionSize, _trader)), DeleteEntry(toCompositeKey(k_positionMargin, _trader)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _trader)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _trader)), DeleteEntry(toCompositeKey(k_positionFee, _trader)), DeleteEntry(toCompositeKey(k_positionSequence, _trader)), IntegerEntry(toCompositeKey(k_positionSize, positionKey), pSize), IntegerEntry(toCompositeKey(k_positionMargin, positionKey), pMargin), IntegerEntry(toCompositeKey(k_positionOpenNotional, positionKey), pNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey), pFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey), pTimestamp), IntegerEntry(toCompositeKey(k_positionFee, positionKey), pFee), IntegerEntry(toCompositeKey(k_positionSequence, positionKey), pSequence)] | |
1723 | + | } | |
1724 | + | else throw(("Nothing to migrate for " + _trader)) | |
1725 | + | } | |
1726 | + | ||
1727 | + | ||
1728 | + | ||
1729 | + | @Callable(i) | |
1730 | + | func view_calcRemainMarginWithFundingPayment (_trader,_direction) = { | |
1729 | 1731 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1730 | 1732 | if ((sync == sync)) | |
1731 | 1733 | then { | |
1732 | - | let $ | |
1733 | - | let positionSize = $ | |
1734 | - | let positionMargin = $ | |
1735 | - | let pon = $ | |
1736 | - | let positionLstUpdCPF = $ | |
1737 | - | let positionTimestamp = $ | |
1738 | - | let $ | |
1739 | - | let positionNotional = $ | |
1740 | - | let unrealizedPnl = $ | |
1741 | - | let $ | |
1742 | - | let remainMargin = $ | |
1743 | - | let badDebt = $ | |
1744 | - | let fundingPayment = $ | |
1745 | - | let rolloverFee = $ | |
1746 | - | throw(((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)) + s(rolloverFee))) | |
1734 | + | let $t08260282738 = getPosition(_trader, _direction) | |
1735 | + | let positionSize = $t08260282738._1 | |
1736 | + | let positionMargin = $t08260282738._2 | |
1737 | + | let pon = $t08260282738._3 | |
1738 | + | let positionLstUpdCPF = $t08260282738._4 | |
1739 | + | let positionTimestamp = $t08260282738._5 | |
1740 | + | let $t08274182854 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, PNL_OPTION_SPOT) | |
1741 | + | let positionNotional = $t08274182854._1 | |
1742 | + | let unrealizedPnl = $t08274182854._2 | |
1743 | + | let $t08285783081 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLstUpdCPF, positionTimestamp, unrealizedPnl) | |
1744 | + | let remainMargin = $t08285783081._1 | |
1745 | + | let badDebt = $t08285783081._2 | |
1746 | + | let fundingPayment = $t08285783081._3 | |
1747 | + | let rolloverFee = $t08285783081._4 | |
1748 | + | throw(((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader, _direction))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)) + s(rolloverFee))) | |
1747 | 1749 | } | |
1748 | 1750 | else throw("Strict value is not equal to itself.") | |
1749 | 1751 | } | |
1750 | 1752 | ||
1751 | 1753 | ||
1752 | 1754 | ||
1753 | 1755 | @Callable(i) | |
1754 | 1756 | func view_getPegAdjustCost (_price) = { | |
1755 | 1757 | let _qtAstR = qtAstR() | |
1756 | 1758 | let _bsAstR = bsAstR() | |
1757 | 1759 | let result = getSyncTerminalPrice(_price, _qtAstR, _bsAstR) | |
1758 | 1760 | throw(toString(result._3)) | |
1759 | 1761 | } | |
1760 | 1762 | ||
1761 | 1763 | ||
1762 | 1764 | ||
1763 | 1765 | @Callable(i) | |
1764 | 1766 | func view_getTerminalAmmPrice () = { | |
1765 | - | let $ | |
1766 | - | let terminalQuoteAssetReserve = $ | |
1767 | - | let terminalBaseAssetReserve = $ | |
1767 | + | let $t08381683897 = getTerminalAmmState() | |
1768 | + | let terminalQuoteAssetReserve = $t08381683897._1 | |
1769 | + | let terminalBaseAssetReserve = $t08381683897._2 | |
1768 | 1770 | let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW())) | |
1769 | 1771 | throw(toString(price)) | |
1770 | 1772 | } | |
1771 | 1773 | ||
1772 | 1774 | ||
1773 | 1775 | ||
1774 | 1776 | @Callable(i) | |
1775 | 1777 | func view_getFunding () = { | |
1776 | - | let underlyingPrice = getOraclePrice() | |
1777 | - | let $t07823778299 = getFunding() | |
1778 | - | let shortPremiumFraction = $t07823778299._1 | |
1779 | - | let longPremiumFraction = $t07823778299._2 | |
1780 | - | let longFunding = divd(longPremiumFraction, underlyingPrice) | |
1781 | - | let shortFunding = divd(shortPremiumFraction, underlyingPrice) | |
1782 | - | throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOraclePrice()))) | |
1778 | + | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1779 | + | if ((sync == sync)) | |
1780 | + | then { | |
1781 | + | let underlyingPrice = getOraclePrice() | |
1782 | + | let $t08445684534 = getFunding() | |
1783 | + | let shortPremiumFraction = $t08445684534._1 | |
1784 | + | let longPremiumFraction = $t08445684534._2 | |
1785 | + | let premiumToVault = $t08445684534._3 | |
1786 | + | let longFunding = divd(longPremiumFraction, underlyingPrice) | |
1787 | + | let shortFunding = divd(shortPremiumFraction, underlyingPrice) | |
1788 | + | throw(((((s(longFunding) + s(shortFunding)) + s(getSpotPrice())) + s(getOraclePrice())) + s(premiumToVault))) | |
1789 | + | } | |
1790 | + | else throw("Strict value is not equal to itself.") | |
1783 | 1791 | } | |
1784 | 1792 | ||
1785 | 1793 | ||
1786 | 1794 | ||
1787 | 1795 | @Callable(i) | |
1788 | 1796 | func computeSpotPrice () = { | |
1789 | 1797 | let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil) | |
1790 | 1798 | if ((sync == sync)) | |
1791 | 1799 | then { | |
1792 | 1800 | let result = getSpotPrice() | |
1793 | 1801 | $Tuple2(nil, result) | |
1794 | 1802 | } | |
1795 | 1803 | else throw("Strict value is not equal to itself.") | |
1796 | 1804 | } | |
1797 | 1805 | ||
1798 | 1806 | ||
1799 | 1807 | ||
1800 | 1808 | @Callable(i) | |
1801 | 1809 | func computeFeeForTraderWithArtifact (_trader,_artifactId) = { | |
1802 | 1810 | let result = getForTraderWithArtifact(_trader, _artifactId) | |
1803 | 1811 | $Tuple2(nil, result) | |
1804 | 1812 | } | |
1805 | 1813 | ||
1806 | 1814 | ||
1807 | 1815 | @Verifier(tx) | |
1808 | 1816 | func verify () = { | |
1809 | 1817 | let coordinatorStr = getString(this, k_coordinatorAddress) | |
1810 | 1818 | if (isDefined(coordinatorStr)) | |
1811 | 1819 | then { | |
1812 | 1820 | let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address) | |
1813 | 1821 | if (isDefined(admin)) | |
1814 | 1822 | then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false) | |
1815 | 1823 | else throw("unable to verify: admin not set in coordinator") | |
1816 | 1824 | } | |
1817 | 1825 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
1818 | 1826 | } | |
1819 | 1827 |
github/deemru/w8io/026f985 305.29 ms ◑