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