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