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