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