tx · 7fdsf7EVU5bmorExRwuSifrekRHkDh25t9iX9biFML3m 3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH: -0.06500000 Waves 2022.11.10 12:47 [2310891] smart account 3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH > SELF 0.00000000 Waves
{ "type": 13, "id": "7fdsf7EVU5bmorExRwuSifrekRHkDh25t9iX9biFML3m", "fee": 6500000, "feeAssetId": null, "timestamp": 1668073641484, "version": 2, "chainId": 84, "sender": "3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH", "senderPublicKey": "Hj6oyH6As5UWo8fZ1K4hPsEY7nxH3MvhBqDD6axiwjXs", "proofs": [ "5vi5ZyD4dvQKXkYs8Jd4anNRqRbyLGVhfbfP4b1Sd2zyhiKRr7akYDsEhuNUw567J3TBxeT1cL9ZNSUc3VWvhC6h" ], "script": "base64:BgJ2CAISABIAEgMKAQESAwoBARILCgkBAQEBAQEBAQESEAoOAQEBAQEBAQgICAEBAQESAwoBARIFCgMBAQESBgoEAQEBCBIAEgMKAQESABIDCgEIEgASBAoCCAESAwoBARIAEgMKAQgSAwoBCBIDCgEBEgASAwoBCKEBAAlrX29yYV9rZXkCCWtfb3JhX2tleQAPa19vcmFfYmxvY2tfa2V5Ag9rX29yYV9ibG9ja19rZXkABWtfb3JhAgVrX29yYQAJa19iYWxhbmNlAglrX2JhbGFuY2UADmtfcG9zaXRpb25TaXplAg5rX3Bvc2l0aW9uU2l6ZQAQa19wb3NpdGlvbk1hcmdpbgIQa19wb3NpdGlvbk1hcmdpbgAWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAIWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAAua19wb3NpdGlvbkxhc3RVcGRhdGVkQ3VtdWxhdGl2ZVByZW1pdW1GcmFjdGlvbgISa19wb3NpdGlvbkZyYWN0aW9uABRrX3Bvc2l0aW9uQ2xvc2VkRGF0ZQIUa19wb3NpdGlvbkNsb3NlZERhdGUAD2tf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WN0aW9uBQ91bmRlcmx5aW5nUHJpY2UEDHNob3J0RnVuZGluZwkBBGRpdmQCBRRzaG9ydFByZW1pdW1GcmFjdGlvbgUPdW5kZXJseWluZ1ByaWNlCQACAQkArAICCQCsAgIJAKwCAgkBAXMBBQtsb25nRnVuZGluZwkBAXMBBQxzaG9ydEZ1bmRpbmcJAQFzAQkBEGdldFR3YXBTcG90UHJpY2UACQEBcwEJARJnZXRPcmFjbGVUd2FwUHJpY2UAAWkBGHZpZXdfZ2V0Qm9ycm93ZWRCeVRyYWRlcgEHX3RyYWRlcgQNJHQwNzI4NzA3MjkyNAkBE2dldEJvcnJvd2VkQnlUcmFkZXIBBQdfdHJhZGVyBAhib3Jyb3dlZAgFDSR0MDcyODcwNzI5MjQCXzEEB2Fzc2V0SWQIBQ0kdDA3Mjg3MDcyOTI0Al8yCQACAQkArAICCQEBcwEFCGJvcnJvd2VkBQdhc3NldElkAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAkBDmFkbWluUHVibGljS2V5AMmgpy8=", "height": 2310891, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8iqYrrRAKzR2kHBzQx24RtrsoGKdYdqHsf93zjTd5Ajz Next: F3UGMSQFKnv1otcpC9jNZzmhXGnToxQPjEm6beCFwih6 Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction" | |
19 | 19 | ||
20 | 20 | let k_positionClosedDate = "k_positionClosedDate" | |
21 | + | ||
22 | + | let k_positionAsset = "k_positionAsset" | |
21 | 23 | ||
22 | 24 | let k_initialized = "k_initialized" | |
23 | 25 | ||
97 | 99 | ||
98 | 100 | let k_manager_address = "k_manager_address" | |
99 | 101 | ||
102 | + | let k_collateral_address = "k_collateral_address" | |
103 | + | ||
104 | + | let k_exchange_address = "k_exchange_address" | |
105 | + | ||
100 | 106 | let k_nft_manager_address = "k_nft_manager_address" | |
107 | + | ||
108 | + | let k_trader_market_asset_collateral = "k_trader_market_asset_collateral" | |
109 | + | ||
110 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
111 | + | ||
101 | 112 | ||
102 | 113 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
103 | 114 | ||
133 | 144 | ||
134 | 145 | ||
135 | 146 | func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set") | |
147 | + | ||
148 | + | ||
149 | + | func collateralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_collateral_address)), "Collateral Manager not set") | |
150 | + | ||
151 | + | ||
152 | + | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_exchange_address), "No swap address")), "Invalid swap address") | |
153 | + | ||
154 | + | ||
155 | + | let k_whitelist_asset = "k_whitelist_asset" | |
156 | + | ||
157 | + | func isWhitelistAsset (_assetId) = valueOrElse(getBoolean(collateralAddress(), toCompositeKey(k_whitelist_asset, _assetId)), false) | |
136 | 158 | ||
137 | 159 | ||
138 | 160 | let k_token_param = "k_token_param" | |
178 | 200 | func vmax (_x,_y) = if ((_x >= _y)) | |
179 | 201 | then _x | |
180 | 202 | else _y | |
181 | - | ||
182 | - | ||
183 | - | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
184 | 203 | ||
185 | 204 | ||
186 | 205 | func listToStr (_list) = { | |
332 | 351 | } | |
333 | 352 | ||
334 | 353 | ||
354 | + | func getPositionAsset (_trader) = { | |
355 | + | let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader)) | |
356 | + | match positionAssetOpt { | |
357 | + | case positionAsset: String => | |
358 | + | positionAsset | |
359 | + | case _ => | |
360 | + | toBase58String(quoteAsset()) | |
361 | + | } | |
362 | + | } | |
363 | + | ||
364 | + | ||
335 | 365 | func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0)) | |
336 | 366 | then throw("No open position") | |
337 | 367 | else true | |
370 | 400 | let amountBaseAssetBought = if (_isAdd) | |
371 | 401 | then amountBaseAssetBoughtAbs | |
372 | 402 | else -(amountBaseAssetBoughtAbs) | |
373 | - | let $ | |
374 | - | let quoteAssetReserveAfter1 = $ | |
375 | - | let baseAssetReserveAfter1 = $ | |
376 | - | let totalPositionSizeAfter1 = $ | |
377 | - | let cumulativeNotionalAfter1 = $ | |
403 | + | let $t01497415167 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs) | |
404 | + | let quoteAssetReserveAfter1 = $t01497415167._1 | |
405 | + | let baseAssetReserveAfter1 = $t01497415167._2 | |
406 | + | let totalPositionSizeAfter1 = $t01497415167._3 | |
407 | + | let cumulativeNotionalAfter1 = $t01497415167._4 | |
378 | 408 | let priceBefore = divd(_qtAstR, _bsAstR) | |
379 | 409 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
380 | 410 | let priceDiff = abs((priceBefore - marketPrice)) | |
394 | 424 | } | |
395 | 425 | else 0 | |
396 | 426 | let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin) | |
397 | - | let $ | |
427 | + | let $t01665816785 = if ((0 > signedMargin)) | |
398 | 428 | then $Tuple2(0, abs(signedMargin)) | |
399 | 429 | else $Tuple2(abs(signedMargin), 0) | |
400 | - | let remainMargin = $ | |
401 | - | let badDebt = $ | |
430 | + | let remainMargin = $t01665816785._1 | |
431 | + | let badDebt = $t01665816785._2 | |
402 | 432 | $Tuple3(remainMargin, badDebt, fundingPayment) | |
403 | 433 | } | |
404 | 434 | ||
415 | 445 | let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter) | |
416 | 446 | let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve)) | |
417 | 447 | let maxPriceImpactValue = maxPriceImpact() | |
418 | - | let $ | |
419 | - | let quoteAssetReserveAfter1 = $ | |
420 | - | let baseAssetReserveAfter1 = $ | |
421 | - | let totalPositionSizeAfter1 = $ | |
422 | - | let cumulativeNotionalAfter1 = $ | |
448 | + | let $t01776217955 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount) | |
449 | + | let quoteAssetReserveAfter1 = $t01776217955._1 | |
450 | + | let baseAssetReserveAfter1 = $t01776217955._2 | |
451 | + | let totalPositionSizeAfter1 = $t01776217955._3 | |
452 | + | let cumulativeNotionalAfter1 = $t01776217955._4 | |
423 | 453 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
424 | 454 | let priceDiff = abs((priceBefore - marketPrice)) | |
425 | 455 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
478 | 508 | let isShort = (0 > _positionSize) | |
479 | 509 | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
480 | 510 | then { | |
481 | - | let $ | |
482 | - | let outPositionNotional = $ | |
483 | - | let x1 = $ | |
484 | - | let x2 = $ | |
485 | - | let x3 = $ | |
511 | + | let $t02117321344 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve) | |
512 | + | let outPositionNotional = $t02117321344._1 | |
513 | + | let x1 = $t02117321344._2 | |
514 | + | let x2 = $t02117321344._3 | |
515 | + | let x3 = $t02117321344._4 | |
486 | 516 | outPositionNotional | |
487 | 517 | } | |
488 | 518 | else muld(positionSizeAbs, getOracleTwapPrice()) | |
503 | 533 | ||
504 | 534 | ||
505 | 535 | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
506 | - | let $ | |
507 | - | let positionSize = $ | |
508 | - | let positionMargin = $ | |
509 | - | let positionOpenNotional = $ | |
510 | - | let positionLstUpdCPF = $ | |
536 | + | let $t02266122789 = getPosition(_trader) | |
537 | + | let positionSize = $t02266122789._1 | |
538 | + | let positionMargin = $t02266122789._2 | |
539 | + | let positionOpenNotional = $t02266122789._3 | |
540 | + | let positionLstUpdCPF = $t02266122789._4 | |
511 | 541 | getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), bsAstR(), _option) | |
512 | 542 | } | |
513 | 543 | ||
516 | 546 | ||
517 | 547 | ||
518 | 548 | func getMarginRatioByOption (_trader,_option) = { | |
519 | - | let $ | |
520 | - | let positionSize = $ | |
521 | - | let positionMargin = $ | |
522 | - | let pon = $ | |
523 | - | let positionLstUpdCPF = $ | |
524 | - | let $ | |
525 | - | let positionNotional = $ | |
526 | - | let unrealizedPnl = $ | |
527 | - | let $ | |
528 | - | let remainMargin = $ | |
529 | - | let badDebt = $ | |
549 | + | let $t02327023381 = getPosition(_trader) | |
550 | + | let positionSize = $t02327023381._1 | |
551 | + | let positionMargin = $t02327023381._2 | |
552 | + | let pon = $t02327023381._3 | |
553 | + | let positionLstUpdCPF = $t02327023381._4 | |
554 | + | let $t02338723480 = getPositionNotionalAndUnrealizedPnl(_trader, _option) | |
555 | + | let positionNotional = $t02338723480._1 | |
556 | + | let unrealizedPnl = $t02338723480._2 | |
557 | + | let $t02348523651 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
558 | + | let remainMargin = $t02348523651._1 | |
559 | + | let badDebt = $t02348523651._2 | |
530 | 560 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
531 | 561 | } | |
532 | 562 | ||
551 | 581 | ||
552 | 582 | ||
553 | 583 | func internalClosePosition (_trader,_checkMaxPriceImpact) = { | |
554 | - | let $ | |
555 | - | let positionSize = $ | |
556 | - | let positionMargin = $ | |
557 | - | let positionOpenNotional = $ | |
558 | - | let positionLstUpdCPF = $ | |
584 | + | let $t02488425012 = getPosition(_trader) | |
585 | + | let positionSize = $t02488425012._1 | |
586 | + | let positionMargin = $t02488425012._2 | |
587 | + | let positionOpenNotional = $t02488425012._3 | |
588 | + | let positionLstUpdCPF = $t02488425012._4 | |
559 | 589 | let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2 | |
560 | - | let $ | |
561 | - | let remainMargin = $ | |
562 | - | let badDebt = $ | |
590 | + | let $t02510725275 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
591 | + | let remainMargin = $t02510725275._1 | |
592 | + | let badDebt = $t02510725275._2 | |
563 | 593 | let exchangedPositionSize = -(positionSize) | |
564 | 594 | let realizedPnl = unrealizedPnl | |
565 | 595 | let marginToVault = -(remainMargin) | |
566 | - | let $ | |
567 | - | let exchangedQuoteAssetAmount = $ | |
568 | - | let quoteAssetReserveAfter = $ | |
569 | - | let baseAssetReserveAfter = $ | |
570 | - | let totalPositionSizeAfter = $ | |
571 | - | let cumulativeNotionalAfter = $ | |
572 | - | let totalLongAfter = $ | |
573 | - | let totalShortAfter = $ | |
596 | + | let $t02540225713 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact) | |
597 | + | let exchangedQuoteAssetAmount = $t02540225713._1 | |
598 | + | let quoteAssetReserveAfter = $t02540225713._2 | |
599 | + | let baseAssetReserveAfter = $t02540225713._3 | |
600 | + | let totalPositionSizeAfter = $t02540225713._4 | |
601 | + | let cumulativeNotionalAfter = $t02540225713._5 | |
602 | + | let totalLongAfter = $t02540225713._6 | |
603 | + | let totalShortAfter = $t02540225713._7 | |
574 | 604 | let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional) | |
575 | 605 | $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter) | |
576 | 606 | } | |
648 | 678 | ||
649 | 679 | func getAdjustedFee (i) = { | |
650 | 680 | let baseFee = fee() | |
651 | - | let $ | |
681 | + | let $t02937629984 = if ((size(i.payments) > 1)) | |
652 | 682 | then { | |
653 | 683 | let artifactId = toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid attached artifact")) | |
654 | 684 | let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, artifactId)) | |
661 | 691 | else throw("Invalid attached artifact") | |
662 | 692 | } | |
663 | 693 | else $Tuple2(baseFee, false) | |
664 | - | let adjustedFee = $ | |
665 | - | let burnArtifact = $ | |
694 | + | let adjustedFee = $t02937629984._1 | |
695 | + | let burnArtifact = $t02937629984._2 | |
666 | 696 | $Tuple2(adjustedFee, burnArtifact) | |
667 | 697 | } | |
668 | 698 | ||
671 | 701 | ||
672 | 702 | ||
673 | 703 | 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)] | |
704 | + | ||
705 | + | ||
706 | + | func updatePositionAsset (_address,_assetId) = [StringEntry(toCompositeKey(k_positionAsset, _address), _assetId)] | |
674 | 707 | ||
675 | 708 | ||
676 | 709 | 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)] | |
712 | 745 | else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_cumulativeNotional, _cumulativeNotionalAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize)]) ++ appendTwap(divd(_qtAstR, _bsAstR))) | |
713 | 746 | ||
714 | 747 | ||
715 | - | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)] | |
748 | + | 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)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)] | |
716 | 749 | ||
717 | 750 | ||
718 | 751 | func withdraw (_address,_amount) = { | |
734 | 767 | func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact) | |
735 | 768 | then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)] | |
736 | 769 | else nil | |
770 | + | ||
771 | + | ||
772 | + | func isSameAssetOrNoPosition (_trader,_assetId) = { | |
773 | + | let oldPositionSize = getPosition(_trader)._1 | |
774 | + | if ((oldPositionSize == 0)) | |
775 | + | then true | |
776 | + | else (getPositionAsset(_trader) == _assetId) | |
777 | + | } | |
778 | + | ||
779 | + | ||
780 | + | func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId) | |
781 | + | ||
782 | + | ||
783 | + | func getBorrowedByTraderInMarketKey (_amm,_assetId,_trader) = ((((((k_trader_market_asset_collateral + "_") + _amm) + "_") + _assetId) + "_") + _trader) | |
784 | + | ||
785 | + | ||
786 | + | func getBorrowedByTrader (_trader) = { | |
787 | + | let positionAsset = getPositionAsset(_trader) | |
788 | + | if ((positionAsset == toBase58String(quoteAsset()))) | |
789 | + | then $Tuple2(0, positionAsset) | |
790 | + | else { | |
791 | + | let key = getBorrowedByTraderInMarketKey(toString(this), positionAsset, _trader) | |
792 | + | let borrow = valueOrElse(getInteger(collateralAddress(), key), 0) | |
793 | + | $Tuple2(borrow, positionAsset) | |
794 | + | } | |
795 | + | } | |
737 | 796 | ||
738 | 797 | ||
739 | 798 | @Callable(i) | |
841 | 900 | else paused()) | |
842 | 901 | then throw("Invalid decreasePosition parameters") | |
843 | 902 | else { | |
844 | - | let $ | |
845 | - | let oldPositionSize = $ | |
846 | - | let oldPositionMargin = $ | |
847 | - | let oldPositionOpenNotional = $ | |
848 | - | let oldPositionLstUpdCPF = $ | |
903 | + | let $t04149241644 = getPosition(toString(i.caller)) | |
904 | + | let oldPositionSize = $t04149241644._1 | |
905 | + | let oldPositionMargin = $t04149241644._2 | |
906 | + | let oldPositionOpenNotional = $t04149241644._3 | |
907 | + | let oldPositionLstUpdCPF = $t04149241644._4 | |
849 | 908 | let _direction = if ((oldPositionSize > 0)) | |
850 | 909 | then DIR_SHORT | |
851 | 910 | else DIR_LONG | |
852 | 911 | let isAdd = (_direction == DIR_LONG) | |
853 | 912 | let openNotional = muld(_amount, _leverage) | |
854 | - | let $ | |
855 | - | let oldPositionNotional = $ | |
856 | - | let unrealizedPnl = $ | |
857 | - | let $ | |
913 | + | let $t04181741933 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
914 | + | let oldPositionNotional = $t04181741933._1 | |
915 | + | let unrealizedPnl = $t04181741933._2 | |
916 | + | let $t04193944488 = if ((oldPositionNotional > openNotional)) | |
858 | 917 | then { | |
859 | - | let $ | |
860 | - | let exchangedPositionSize = $ | |
861 | - | let quoteAssetReserveAfter = $ | |
862 | - | let baseAssetReserveAfter = $ | |
863 | - | let totalPositionSizeAfter = $ | |
864 | - | let cumulativeNotionalAfter = $ | |
918 | + | let $t04231642535 = swapInput(isAdd, openNotional) | |
919 | + | let exchangedPositionSize = $t04231642535._1 | |
920 | + | let quoteAssetReserveAfter = $t04231642535._2 | |
921 | + | let baseAssetReserveAfter = $t04231642535._3 | |
922 | + | let totalPositionSizeAfter = $t04231642535._4 | |
923 | + | let cumulativeNotionalAfter = $t04231642535._5 | |
865 | 924 | let exchangedPositionSizeAbs = abs(exchangedPositionSize) | |
866 | 925 | if (if ((_minBaseAssetAmount != 0)) | |
867 | 926 | then (_minBaseAssetAmount > exchangedPositionSizeAbs) | |
869 | 928 | then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount))) | |
870 | 929 | else { | |
871 | 930 | let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize)) | |
872 | - | let $ | |
873 | - | let remainMargin = $ | |
874 | - | let badDebt = $ | |
875 | - | let fundingPayment = $ | |
931 | + | let $t04297243217 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
932 | + | let remainMargin = $t04297243217._1 | |
933 | + | let badDebt = $t04297243217._2 | |
934 | + | let fundingPayment = $t04297243217._3 | |
876 | 935 | let exchangedQuoteAssetAmount = openNotional | |
877 | 936 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
878 | 937 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
887 | 946 | } | |
888 | 947 | } | |
889 | 948 | else throw("Close position first") | |
890 | - | let newPositionSize = $ | |
891 | - | let newPositionRemainMargin = $ | |
892 | - | let newPositionOpenNotional = $ | |
893 | - | let newPositionLatestCPF = $ | |
894 | - | let baseAssetReserveAfter = $ | |
895 | - | let quoteAssetReserveAfter = $ | |
896 | - | let totalPositionSizeAfter = $ | |
897 | - | let cumulativeNotionalAfter = $ | |
898 | - | let openInterestNotionalAfter = $ | |
899 | - | let totalLongAfter = $ | |
900 | - | let totalShortAfter = $ | |
949 | + | let newPositionSize = $t04193944488._1 | |
950 | + | let newPositionRemainMargin = $t04193944488._2 | |
951 | + | let newPositionOpenNotional = $t04193944488._3 | |
952 | + | let newPositionLatestCPF = $t04193944488._4 | |
953 | + | let baseAssetReserveAfter = $t04193944488._5 | |
954 | + | let quoteAssetReserveAfter = $t04193944488._6 | |
955 | + | let totalPositionSizeAfter = $t04193944488._7 | |
956 | + | let cumulativeNotionalAfter = $t04193944488._8 | |
957 | + | let openInterestNotionalAfter = $t04193944488._9 | |
958 | + | let totalLongAfter = $t04193944488._10 | |
959 | + | let totalShortAfter = $t04193944488._11 | |
901 | 960 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
902 | 961 | if ((notifyNotional == notifyNotional)) | |
903 | 962 | then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
908 | 967 | ||
909 | 968 | @Callable(i) | |
910 | 969 | func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = { | |
970 | + | let _trader = toString(i.caller) | |
911 | 971 | let _rawAmount = i.payments[0].amount | |
912 | - | if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
972 | + | let _assetId = i.payments[0].assetId | |
973 | + | let _assetIdStr = toBase58String(value(_assetId)) | |
974 | + | let isQuoteAsset = (_assetId == quoteAsset()) | |
975 | + | let isCollateralAsset = isWhitelistAsset(_assetIdStr) | |
976 | + | if (if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
913 | 977 | then (_direction != DIR_SHORT) | |
914 | 978 | else false) | |
915 | 979 | then true | |
917 | 981 | then true | |
918 | 982 | else !(initialized())) | |
919 | 983 | then true | |
920 | - | else (i.payments[0].assetId != quoteAsset())) | |
984 | + | else if (!(isQuoteAsset)) | |
985 | + | then !(isCollateralAsset) | |
986 | + | else false) | |
987 | + | then true | |
988 | + | else !(isSameAssetOrNoPosition(_trader, _assetIdStr))) | |
921 | 989 | then true | |
922 | 990 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
923 | 991 | then true | |
924 | 992 | else paused()) | |
925 | 993 | then throw("Invalid increasePosition parameters") | |
926 | 994 | else { | |
927 | - | let _trader = toString(i.caller) | |
928 | 995 | let baseFee = fee() | |
929 | - | let $ | |
930 | - | let adjustedFee = $ | |
931 | - | let burnArtifact = $ | |
996 | + | let $t04585045901 = getAdjustedFee(i) | |
997 | + | let adjustedFee = $t04585045901._1 | |
998 | + | let burnArtifact = $t04585045901._2 | |
932 | 999 | let rawFeeAmount = muld(_rawAmount, adjustedFee) | |
933 | - | let | |
934 | - | if ( | |
1000 | + | let _amount = (_rawAmount - rawFeeAmount) | |
1001 | + | let distributeFeeAmount = if (isCollateralAsset) | |
935 | 1002 | then { | |
936 | - | let referrerFee = match referrerFeeAny { | |
937 | - | case x: Int => | |
938 | - | x | |
939 | - | case _ => | |
940 | - | throw("Invalid referrerFee") | |
1003 | + | let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)]) | |
1004 | + | if ((doBorrow == doBorrow)) | |
1005 | + | then { | |
1006 | + | let balanceBefore = assetBalance(this, quoteAsset()) | |
1007 | + | if ((balanceBefore == balanceBefore)) | |
1008 | + | then { | |
1009 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)]) | |
1010 | + | if ((doSwap == doSwap)) | |
1011 | + | then { | |
1012 | + | let balanceAfter = assetBalance(this, quoteAsset()) | |
1013 | + | if ((balanceAfter == balanceAfter)) | |
1014 | + | then { | |
1015 | + | let exchangedAmount = (balanceAfter - balanceBefore) | |
1016 | + | if ((exchangedAmount == exchangedAmount)) | |
1017 | + | then exchangedAmount | |
1018 | + | else throw("Strict value is not equal to itself.") | |
1019 | + | } | |
1020 | + | else throw("Strict value is not equal to itself.") | |
1021 | + | } | |
1022 | + | else throw("Strict value is not equal to itself.") | |
1023 | + | } | |
1024 | + | else throw("Strict value is not equal to itself.") | |
1025 | + | } | |
1026 | + | else throw("Strict value is not equal to itself.") | |
941 | 1027 | } | |
942 | - | let _amount = (_rawAmount - rawFeeAmount) | |
943 | - | let feeAmount = (rawFeeAmount - referrerFee) | |
944 | - | let $t04369643836 = getPosition(_trader) | |
945 | - | let oldPositionSize = $t04369643836._1 | |
946 | - | let oldPositionMargin = $t04369643836._2 | |
947 | - | let oldPositionOpenNotional = $t04369643836._3 | |
948 | - | let oldPositionLstUpdCPF = $t04369643836._4 | |
949 | - | let isNewPosition = (oldPositionSize == 0) | |
950 | - | let isSameDirection = if ((oldPositionSize > 0)) | |
951 | - | then (_direction == DIR_LONG) | |
952 | - | else (_direction == DIR_SHORT) | |
953 | - | let expandExisting = if (!(isNewPosition)) | |
954 | - | then isSameDirection | |
955 | - | else false | |
956 | - | let isAdd = (_direction == DIR_LONG) | |
957 | - | let $t04412546710 = if (if (isNewPosition) | |
958 | - | then true | |
959 | - | else expandExisting) | |
1028 | + | else rawFeeAmount | |
1029 | + | if ((distributeFeeAmount == distributeFeeAmount)) | |
1030 | + | then { | |
1031 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1032 | + | if ((referrerFeeAny == referrerFeeAny)) | |
960 | 1033 | then { | |
961 | - | let openNotional = muld(_amount, _leverage) | |
962 | - | let $t04454944755 = swapInput(isAdd, openNotional) | |
963 | - | let amountBaseAssetBought = $t04454944755._1 | |
964 | - | let quoteAssetReserveAfter = $t04454944755._2 | |
965 | - | let baseAssetReserveAfter = $t04454944755._3 | |
966 | - | let totalPositionSizeAfter = $t04454944755._4 | |
967 | - | let cumulativeNotionalAfter = $t04454944755._5 | |
968 | - | if (if ((_minBaseAssetAmount != 0)) | |
969 | - | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
970 | - | else false) | |
971 | - | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1034 | + | let referrerFee = match referrerFeeAny { | |
1035 | + | case x: Int => | |
1036 | + | x | |
1037 | + | case _ => | |
1038 | + | throw("Invalid referrerFee") | |
1039 | + | } | |
1040 | + | let feeAmount = (distributeFeeAmount - referrerFee) | |
1041 | + | let $t04721747357 = getPosition(_trader) | |
1042 | + | let oldPositionSize = $t04721747357._1 | |
1043 | + | let oldPositionMargin = $t04721747357._2 | |
1044 | + | let oldPositionOpenNotional = $t04721747357._3 | |
1045 | + | let oldPositionLstUpdCPF = $t04721747357._4 | |
1046 | + | let isNewPosition = (oldPositionSize == 0) | |
1047 | + | let isSameDirection = if ((oldPositionSize > 0)) | |
1048 | + | then (_direction == DIR_LONG) | |
1049 | + | else (_direction == DIR_SHORT) | |
1050 | + | let expandExisting = if (!(isNewPosition)) | |
1051 | + | then isSameDirection | |
1052 | + | else false | |
1053 | + | let isAdd = (_direction == DIR_LONG) | |
1054 | + | let $t04764650231 = if (if (isNewPosition) | |
1055 | + | then true | |
1056 | + | else expandExisting) | |
1057 | + | then { | |
1058 | + | let openNotional = muld(_amount, _leverage) | |
1059 | + | let $t04807048276 = swapInput(isAdd, openNotional) | |
1060 | + | let amountBaseAssetBought = $t04807048276._1 | |
1061 | + | let quoteAssetReserveAfter = $t04807048276._2 | |
1062 | + | let baseAssetReserveAfter = $t04807048276._3 | |
1063 | + | let totalPositionSizeAfter = $t04807048276._4 | |
1064 | + | let cumulativeNotionalAfter = $t04807048276._5 | |
1065 | + | if (if ((_minBaseAssetAmount != 0)) | |
1066 | + | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
1067 | + | else false) | |
1068 | + | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1069 | + | else { | |
1070 | + | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
1071 | + | let increaseMarginRequirement = divd(openNotional, _leverage) | |
1072 | + | let $t04865748896 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
1073 | + | let remainMargin = $t04865748896._1 | |
1074 | + | let x1 = $t04865748896._2 | |
1075 | + | let x2 = $t04865748896._3 | |
1076 | + | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
1077 | + | then throw("Over max spread limit") | |
1078 | + | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
1079 | + | then abs(amountBaseAssetBought) | |
1080 | + | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
1081 | + | then abs(amountBaseAssetBought) | |
1082 | + | else 0))) | |
1083 | + | } | |
1084 | + | } | |
972 | 1085 | else { | |
973 | - | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
974 | - | let increaseMarginRequirement = divd(openNotional, _leverage) | |
975 | - | let $t04513645375 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
976 | - | let remainMargin = $t04513645375._1 | |
977 | - | let x1 = $t04513645375._2 | |
978 | - | let x2 = $t04513645375._3 | |
979 | - | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
980 | - | then throw("Over max spread limit") | |
981 | - | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
982 | - | then abs(amountBaseAssetBought) | |
983 | - | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
984 | - | then abs(amountBaseAssetBought) | |
985 | - | else 0))) | |
1086 | + | let openNotional = muld(_amount, _leverage) | |
1087 | + | let $t04992450040 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
1088 | + | let oldPositionNotional = $t04992450040._1 | |
1089 | + | let unrealizedPnl = $t04992450040._2 | |
1090 | + | if ((oldPositionNotional > openNotional)) | |
1091 | + | then throw("Use decreasePosition to decrease position size") | |
1092 | + | else throw("Close position first") | |
986 | 1093 | } | |
987 | - | } | |
988 | - | else { | |
989 | - | let openNotional = muld(_amount, _leverage) | |
990 | - | let $t04640346519 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
991 | - | let oldPositionNotional = $t04640346519._1 | |
992 | - | let unrealizedPnl = $t04640346519._2 | |
993 | - | if ((oldPositionNotional > openNotional)) | |
994 | - | then throw("Use decreasePosition to decrease position size") | |
995 | - | else throw("Close position first") | |
996 | - | } | |
997 | - | let newPositionSize = $t04412546710._1 | |
998 | - | let newPositionRemainMargin = $t04412546710._2 | |
999 | - | let newPositionOpenNotional = $t04412546710._3 | |
1000 | - | let newPositionLatestCPF = $t04412546710._4 | |
1001 | - | let baseAssetReserveAfter = $t04412546710._5 | |
1002 | - | let quoteAssetReserveAfter = $t04412546710._6 | |
1003 | - | let totalPositionSizeAfter = $t04412546710._7 | |
1004 | - | let cumulativeNotionalAfter = $t04412546710._8 | |
1005 | - | let openInterestNotionalAfter = $t04412546710._9 | |
1006 | - | let totalLongAfter = $t04412546710._10 | |
1007 | - | let totalShortAfter = $t04412546710._11 | |
1008 | - | let feeToStakers = (feeAmount / 2) | |
1009 | - | let feeToInsurance = (feeAmount - feeToStakers) | |
1010 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1011 | - | if ((stake == stake)) | |
1012 | - | then { | |
1013 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1014 | - | if ((depositInsurance == depositInsurance)) | |
1094 | + | let newPositionSize = $t04764650231._1 | |
1095 | + | let newPositionRemainMargin = $t04764650231._2 | |
1096 | + | let newPositionOpenNotional = $t04764650231._3 | |
1097 | + | let newPositionLatestCPF = $t04764650231._4 | |
1098 | + | let baseAssetReserveAfter = $t04764650231._5 | |
1099 | + | let quoteAssetReserveAfter = $t04764650231._6 | |
1100 | + | let totalPositionSizeAfter = $t04764650231._7 | |
1101 | + | let cumulativeNotionalAfter = $t04764650231._8 | |
1102 | + | let openInterestNotionalAfter = $t04764650231._9 | |
1103 | + | let totalLongAfter = $t04764650231._10 | |
1104 | + | let totalShortAfter = $t04764650231._11 | |
1105 | + | let feeToStakers = (feeAmount / 2) | |
1106 | + | let feeToInsurance = (feeAmount - feeToStakers) | |
1107 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1108 | + | if ((stake == stake)) | |
1015 | 1109 | then { | |
1016 | - | let | |
1017 | - | if (( | |
1110 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1111 | + | if ((depositInsurance == depositInsurance)) | |
1018 | 1112 | then { | |
1019 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1020 | - | if ((notifyNotional == notifyNotional)) | |
1021 | - | then ((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1113 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1114 | + | if ((notifyFee == notifyFee)) | |
1115 | + | then { | |
1116 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1117 | + | if ((notifyNotional == notifyNotional)) | |
1118 | + | then (((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1119 | + | else throw("Strict value is not equal to itself.") | |
1120 | + | } | |
1022 | 1121 | else throw("Strict value is not equal to itself.") | |
1023 | 1122 | } | |
1024 | 1123 | else throw("Strict value is not equal to itself.") | |
1035 | 1134 | ||
1036 | 1135 | @Callable(i) | |
1037 | 1136 | func addMargin () = { | |
1137 | + | let _trader = toString(i.caller) | |
1038 | 1138 | let _rawAmount = i.payments[0].amount | |
1039 | - | if (if (if (if ((i.payments[0].assetId != quoteAsset())) | |
1139 | + | let _assetId = i.payments[0].assetId | |
1140 | + | let _assetIdStr = toBase58String(value(_assetId)) | |
1141 | + | let isQuoteAsset = (_assetId == quoteAsset()) | |
1142 | + | let isCollateralAsset = isWhitelistAsset(_assetIdStr) | |
1143 | + | if (if (if (if (if (if (!(isQuoteAsset)) | |
1144 | + | then !(isCollateralAsset) | |
1145 | + | else false) | |
1040 | 1146 | then true | |
1041 | 1147 | else !(requireOpenPosition(toString(i.caller)))) | |
1148 | + | then true | |
1149 | + | else !(isSameAsset(_trader, _assetIdStr))) | |
1042 | 1150 | then true | |
1043 | 1151 | else !(initialized())) | |
1044 | 1152 | then true | |
1045 | 1153 | else paused()) | |
1046 | 1154 | then throw("Invalid addMargin parameters") | |
1047 | 1155 | else { | |
1048 | - | let _trader = toString(i.caller) | |
1049 | - | let $t04817848229 = getAdjustedFee(i) | |
1050 | - | let adjustedFee = $t04817848229._1 | |
1051 | - | let burnArtifact = $t04817848229._2 | |
1156 | + | let $t05198752038 = getAdjustedFee(i) | |
1157 | + | let adjustedFee = $t05198752038._1 | |
1158 | + | let burnArtifact = $t05198752038._2 | |
1052 | 1159 | let rawFeeAmount = muld(_rawAmount, adjustedFee) | |
1053 | - | let | |
1054 | - | if ( | |
1160 | + | let _amount = (_rawAmount - rawFeeAmount) | |
1161 | + | let distributeFeeAmount = if (isCollateralAsset) | |
1055 | 1162 | then { | |
1056 | - | let referrerFee = match referrerFeeAny { | |
1057 | - | case x: Int => | |
1058 | - | x | |
1059 | - | case _ => | |
1060 | - | throw("Invalid referrerFee") | |
1163 | + | let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)]) | |
1164 | + | if ((doBorrow == doBorrow)) | |
1165 | + | then { | |
1166 | + | let balanceBefore = assetBalance(this, quoteAsset()) | |
1167 | + | if ((balanceBefore == balanceBefore)) | |
1168 | + | then { | |
1169 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)]) | |
1170 | + | if ((doSwap == doSwap)) | |
1171 | + | then { | |
1172 | + | let balanceAfter = assetBalance(this, quoteAsset()) | |
1173 | + | if ((balanceAfter == balanceAfter)) | |
1174 | + | then { | |
1175 | + | let exchangedAmount = (balanceAfter - balanceBefore) | |
1176 | + | if ((exchangedAmount == exchangedAmount)) | |
1177 | + | then exchangedAmount | |
1178 | + | else throw("Strict value is not equal to itself.") | |
1179 | + | } | |
1180 | + | else throw("Strict value is not equal to itself.") | |
1181 | + | } | |
1182 | + | else throw("Strict value is not equal to itself.") | |
1183 | + | } | |
1184 | + | else throw("Strict value is not equal to itself.") | |
1185 | + | } | |
1186 | + | else throw("Strict value is not equal to itself.") | |
1061 | 1187 | } | |
1062 | - | let feeAmount = (rawFeeAmount - referrerFee) | |
1063 | - | let _amount = (_rawAmount - rawFeeAmount) | |
1064 | - | let $t04866148801 = getPosition(_trader) | |
1065 | - | let oldPositionSize = $t04866148801._1 | |
1066 | - | let oldPositionMargin = $t04866148801._2 | |
1067 | - | let oldPositionOpenNotional = $t04866148801._3 | |
1068 | - | let oldPositionLstUpdCPF = $t04866148801._4 | |
1069 | - | let feeToStakers = (feeAmount / 2) | |
1070 | - | let feeToInsurance = (feeAmount - feeToStakers) | |
1071 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1072 | - | if ((stake == stake)) | |
1188 | + | else rawFeeAmount | |
1189 | + | if ((distributeFeeAmount == distributeFeeAmount)) | |
1190 | + | then { | |
1191 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1192 | + | if ((referrerFeeAny == referrerFeeAny)) | |
1073 | 1193 | then { | |
1074 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1075 | - | if ((depositInsurance == depositInsurance)) | |
1194 | + | let referrerFee = match referrerFeeAny { | |
1195 | + | case x: Int => | |
1196 | + | x | |
1197 | + | case _ => | |
1198 | + | throw("Invalid referrerFee") | |
1199 | + | } | |
1200 | + | let feeAmount = (distributeFeeAmount - referrerFee) | |
1201 | + | let $t05333753477 = getPosition(_trader) | |
1202 | + | let oldPositionSize = $t05333753477._1 | |
1203 | + | let oldPositionMargin = $t05333753477._2 | |
1204 | + | let oldPositionOpenNotional = $t05333753477._3 | |
1205 | + | let oldPositionLstUpdCPF = $t05333753477._4 | |
1206 | + | let feeToStakers = (feeAmount / 2) | |
1207 | + | let feeToInsurance = (feeAmount - feeToStakers) | |
1208 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1209 | + | if ((stake == stake)) | |
1076 | 1210 | then { | |
1077 | - | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1078 | - | if ((notifyFee == notifyFee)) | |
1079 | - | then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1211 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1212 | + | if ((depositInsurance == depositInsurance)) | |
1213 | + | then { | |
1214 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1215 | + | if ((notifyFee == notifyFee)) | |
1216 | + | then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1217 | + | else throw("Strict value is not equal to itself.") | |
1218 | + | } | |
1080 | 1219 | else throw("Strict value is not equal to itself.") | |
1081 | 1220 | } | |
1082 | 1221 | else throw("Strict value is not equal to itself.") | |
1090 | 1229 | ||
1091 | 1230 | ||
1092 | 1231 | @Callable(i) | |
1093 | - | func removeMargin (_amount) = if (if (if (if ((0 >= _amount)) | |
1094 | - | then true | |
1095 | - | else !(requireOpenPosition(toString(i.caller)))) | |
1096 | - | then true | |
1097 | - | else !(initialized())) | |
1098 | - | then true | |
1099 | - | else paused()) | |
1100 | - | then throw("Invalid removeMargin parameters") | |
1101 | - | else { | |
1102 | - | let $t04982049972 = getPosition(toString(i.caller)) | |
1103 | - | let oldPositionSize = $t04982049972._1 | |
1104 | - | let oldPositionMargin = $t04982049972._2 | |
1105 | - | let oldPositionOpenNotional = $t04982049972._3 | |
1106 | - | let oldPositionLstUpdCPF = $t04982049972._4 | |
1107 | - | let marginDelta = -(_amount) | |
1108 | - | let $t05000950188 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
1109 | - | let remainMargin = $t05000950188._1 | |
1110 | - | let badDebt = $t05000950188._2 | |
1111 | - | if ((badDebt != 0)) | |
1112 | - | then throw("Invalid removed margin amount") | |
1113 | - | else { | |
1114 | - | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1115 | - | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1116 | - | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1117 | - | else { | |
1118 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil) | |
1119 | - | if ((unstake == unstake)) | |
1120 | - | then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount))) | |
1121 | - | else throw("Strict value is not equal to itself.") | |
1122 | - | } | |
1123 | - | } | |
1124 | - | } | |
1232 | + | func removeMargin (_amount) = { | |
1233 | + | let _trader = toString(i.caller) | |
1234 | + | if (if (if (if ((0 >= _amount)) | |
1235 | + | then true | |
1236 | + | else !(requireOpenPosition(_trader))) | |
1237 | + | then true | |
1238 | + | else !(initialized())) | |
1239 | + | then true | |
1240 | + | else paused()) | |
1241 | + | then throw("Invalid removeMargin parameters") | |
1242 | + | else { | |
1243 | + | let $t05452054660 = getPosition(_trader) | |
1244 | + | let oldPositionSize = $t05452054660._1 | |
1245 | + | let oldPositionMargin = $t05452054660._2 | |
1246 | + | let oldPositionOpenNotional = $t05452054660._3 | |
1247 | + | let oldPositionLstUpdCPF = $t05452054660._4 | |
1248 | + | let marginDelta = -(_amount) | |
1249 | + | let $t05469754876 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
1250 | + | let remainMargin = $t05469754876._1 | |
1251 | + | let badDebt = $t05469754876._2 | |
1252 | + | if ((badDebt != 0)) | |
1253 | + | then throw("Invalid removed margin amount") | |
1254 | + | else { | |
1255 | + | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1256 | + | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1257 | + | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1258 | + | else { | |
1259 | + | let quoteAssetStr = toBase58String(quoteAsset()) | |
1260 | + | let $t05532055374 = getBorrowedByTrader(_trader) | |
1261 | + | let borrowed = $t05532055374._1 | |
1262 | + | let assetId = $t05532055374._2 | |
1263 | + | let toRepay = if ((_amount > borrowed)) | |
1264 | + | then borrowed | |
1265 | + | else _amount | |
1266 | + | let toWithdraw = if ((borrowed > _amount)) | |
1267 | + | then 0 | |
1268 | + | else (_amount - borrowed) | |
1269 | + | let finalBorrow = (borrowed - toRepay) | |
1270 | + | let switchPositionToQuote = if ((finalBorrow > 0)) | |
1271 | + | then nil | |
1272 | + | else updatePositionAsset(_trader, quoteAssetStr) | |
1273 | + | let doSanityCheck = if (((toRepay + toWithdraw) != _amount)) | |
1274 | + | then throw(((((("toRepay=" + toString(toRepay)) + " + toWithdraw=") + toString(toWithdraw)) + " != ") + toString(_amount))) | |
1275 | + | else nil | |
1276 | + | if ((doSanityCheck == doSanityCheck)) | |
1277 | + | then { | |
1278 | + | let doUnstake = invoke(managerAddress(), "withdraw", [quoteAssetStr, _amount], nil) | |
1279 | + | if ((doUnstake == doUnstake)) | |
1280 | + | then { | |
1281 | + | let returnCollateralAction = if ((toRepay > 0)) | |
1282 | + | then { | |
1283 | + | let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), toRepay)]) | |
1284 | + | if ((doRepay == doRepay)) | |
1285 | + | then [ScriptTransfer(i.caller, toRepay, fromBase58String(assetId))] | |
1286 | + | else throw("Strict value is not equal to itself.") | |
1287 | + | } | |
1288 | + | else nil | |
1289 | + | if ((returnCollateralAction == returnCollateralAction)) | |
1290 | + | then (updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ (if ((toWithdraw > 0)) | |
1291 | + | then withdraw(i.caller, toWithdraw) | |
1292 | + | else (((nil ++ updateBalance((cbalance() - _amount))) ++ switchPositionToQuote) ++ returnCollateralAction))) | |
1293 | + | else throw("Strict value is not equal to itself.") | |
1294 | + | } | |
1295 | + | else throw("Strict value is not equal to itself.") | |
1296 | + | } | |
1297 | + | else throw("Strict value is not equal to itself.") | |
1298 | + | } | |
1299 | + | } | |
1300 | + | } | |
1301 | + | } | |
1125 | 1302 | ||
1126 | 1303 | ||
1127 | 1304 | ||
1128 | 1305 | @Callable(i) | |
1129 | 1306 | func closePosition () = { | |
1130 | - | let | |
1131 | - | let | |
1132 | - | if (if (if (!(requireOpenPosition( | |
1307 | + | let _trader = getActualCaller(i) | |
1308 | + | let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller") | |
1309 | + | if (if (if (!(requireOpenPosition(_trader))) | |
1133 | 1310 | then true | |
1134 | 1311 | else !(initialized())) | |
1135 | 1312 | then true | |
1136 | 1313 | else paused()) | |
1137 | 1314 | then throw("Invalid closePosition parameters") | |
1138 | 1315 | else { | |
1139 | - | let $ | |
1140 | - | let x1 = $ | |
1141 | - | let positionBadDebt = $ | |
1142 | - | let realizedPnl = $ | |
1143 | - | let marginToVault = $ | |
1144 | - | let quoteAssetReserveAfter = $ | |
1145 | - | let baseAssetReserveAfter = $ | |
1146 | - | let totalPositionSizeAfter = $ | |
1147 | - | let cumulativeNotionalAfter = $ | |
1148 | - | let openInterestNotionalAfter = $ | |
1149 | - | let x2 = $ | |
1150 | - | let totalLongAfter = $ | |
1151 | - | let totalShortAfter = $ | |
1316 | + | let $t05756657944 = internalClosePosition(_trader, true) | |
1317 | + | let x1 = $t05756657944._1 | |
1318 | + | let positionBadDebt = $t05756657944._2 | |
1319 | + | let realizedPnl = $t05756657944._3 | |
1320 | + | let marginToVault = $t05756657944._4 | |
1321 | + | let quoteAssetReserveAfter = $t05756657944._5 | |
1322 | + | let baseAssetReserveAfter = $t05756657944._6 | |
1323 | + | let totalPositionSizeAfter = $t05756657944._7 | |
1324 | + | let cumulativeNotionalAfter = $t05756657944._8 | |
1325 | + | let openInterestNotionalAfter = $t05756657944._9 | |
1326 | + | let x2 = $t05756657944._10 | |
1327 | + | let totalLongAfter = $t05756657944._11 | |
1328 | + | let totalShortAfter = $t05756657944._12 | |
1152 | 1329 | if ((positionBadDebt > 0)) | |
1153 | 1330 | then throw("Unable to close position with bad debt") | |
1154 | 1331 | else { | |
1155 | 1332 | let withdrawAmount = abs(marginToVault) | |
1156 | 1333 | let ammBalance = (cbalance() - withdrawAmount) | |
1157 | - | let $ | |
1334 | + | let $t05815358295 = if ((0 > ammBalance)) | |
1158 | 1335 | then $Tuple2(0, abs(ammBalance)) | |
1159 | 1336 | else $Tuple2(ammBalance, 0) | |
1160 | - | let ammNewBalance = $ | |
1161 | - | let getFromInsurance = $ | |
1337 | + | let ammNewBalance = $t05815358295._1 | |
1338 | + | let getFromInsurance = $t05815358295._2 | |
1162 | 1339 | let x = if ((getFromInsurance > 0)) | |
1163 | 1340 | then { | |
1164 | 1341 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil) | |
1172 | 1349 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (withdrawAmount - getFromInsurance)], nil) | |
1173 | 1350 | if ((unstake == unstake)) | |
1174 | 1351 | then { | |
1175 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [caller, 0], nil) | |
1176 | - | if ((notifyNotional == notifyNotional)) | |
1177 | - | then (((deletePosition(caller) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(callerAddress, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
1352 | + | let $t05879758851 = getBorrowedByTrader(_trader) | |
1353 | + | let borrowed = $t05879758851._1 | |
1354 | + | let assetId = $t05879758851._2 | |
1355 | + | let $t05886659783 = if ((borrowed > 0)) | |
1356 | + | then if ((withdrawAmount >= borrowed)) | |
1357 | + | then { | |
1358 | + | let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), borrowed)]) | |
1359 | + | if ((doRepay == doRepay)) | |
1360 | + | then $Tuple2([ScriptTransfer(_traderAddress, borrowed, fromBase58String(assetId))], (withdrawAmount - borrowed)) | |
1361 | + | else throw("Strict value is not equal to itself.") | |
1362 | + | } | |
1363 | + | else { | |
1364 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], [AttachedPayment(quoteAsset(), withdrawAmount)]) | |
1365 | + | if ((realizeAndClose == realizeAndClose)) | |
1366 | + | then $Tuple2([ScriptTransfer(_traderAddress, withdrawAmount, fromBase58String(assetId))], 0) | |
1367 | + | else throw("Strict value is not equal to itself.") | |
1368 | + | } | |
1369 | + | else $Tuple2(nil, withdrawAmount) | |
1370 | + | if (($t05886659783 == $t05886659783)) | |
1371 | + | then { | |
1372 | + | let quoteWithdrawAmount = $t05886659783._2 | |
1373 | + | let sendCollateralAction = $t05886659783._1 | |
1374 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1375 | + | if ((notifyNotional == notifyNotional)) | |
1376 | + | then ((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ (if ((quoteWithdrawAmount > 0)) | |
1377 | + | then withdraw(_traderAddress, quoteWithdrawAmount) | |
1378 | + | else ((nil ++ updateBalance(ammNewBalance)) ++ sendCollateralAction))) | |
1379 | + | else throw("Strict value is not equal to itself.") | |
1380 | + | } | |
1178 | 1381 | else throw("Strict value is not equal to itself.") | |
1179 | 1382 | } | |
1180 | 1383 | else throw("Strict value is not equal to itself.") | |
1209 | 1412 | then (DECIMAL_UNIT > partialLiquidationRatio()) | |
1210 | 1413 | else false) | |
1211 | 1414 | then { | |
1212 | - | let $ | |
1213 | - | let oldPositionSize = $ | |
1214 | - | let oldPositionMargin = $ | |
1215 | - | let oldPositionOpenNotional = $ | |
1216 | - | let oldPositionLstUpdCPF = $ | |
1415 | + | let $t06148361633 = getPosition(_trader) | |
1416 | + | let oldPositionSize = $t06148361633._1 | |
1417 | + | let oldPositionMargin = $t06148361633._2 | |
1418 | + | let oldPositionOpenNotional = $t06148361633._3 | |
1419 | + | let oldPositionLstUpdCPF = $t06148361633._4 | |
1217 | 1420 | let _direction = if ((oldPositionSize > 0)) | |
1218 | 1421 | then DIR_SHORT | |
1219 | 1422 | else DIR_LONG | |
1220 | 1423 | let isAdd = (_direction == DIR_LONG) | |
1221 | 1424 | let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize) | |
1222 | - | let $t05455654660 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1223 | - | let oldPositionNotional = $t05455654660._1 | |
1224 | - | let unrealizedPnl = $t05455654660._2 | |
1225 | - | let $t05466854958 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1226 | - | let exchangedPositionSize = $t05466854958._1 | |
1227 | - | let quoteAssetReserveAfter = $t05466854958._2 | |
1228 | - | let baseAssetReserveAfter = $t05466854958._3 | |
1229 | - | let totalPositionSizeAfter = $t05466854958._4 | |
1230 | - | let cumulativeNotionalAfter = $t05466854958._5 | |
1231 | - | let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize)) | |
1232 | - | let $t05506555298 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1233 | - | let remainMargin = $t05506555298._1 | |
1234 | - | let badDebt = $t05506555298._2 | |
1235 | - | let fundingPayment = $t05506555298._3 | |
1425 | + | let $t06185861962 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1426 | + | let oldPositionNotional = $t06185861962._1 | |
1427 | + | let unrealizedPnl = $t06185861962._2 | |
1428 | + | let $t06197062202 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1429 | + | let exchangedPositionSize = $t06197062202._1 | |
1430 | + | let quoteAssetReserveAfter = $t06197062202._2 | |
1431 | + | let baseAssetReserveAfter = $t06197062202._3 | |
1432 | + | let totalPositionSizeAfter = $t06197062202._4 | |
1433 | + | let cumulativeNotionalAfter = $t06197062202._5 | |
1434 | + | let liquidationRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize)) | |
1435 | + | let realizedPnl = muld(unrealizedPnl, liquidationRatio) | |
1436 | + | let $t06241362646 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1437 | + | let remainMargin = $t06241362646._1 | |
1438 | + | let badDebt = $t06241362646._2 | |
1439 | + | let fundingPayment = $t06241362646._3 | |
1236 | 1440 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
1237 | 1441 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
1238 | 1442 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
1246 | 1450 | let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize) | |
1247 | 1451 | let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount) | |
1248 | 1452 | let ammBalance = (cbalance() - liquidationPenalty) | |
1249 | - | let $ | |
1453 | + | let $t06381963962 = if ((0 > ammBalance)) | |
1250 | 1454 | then $Tuple2(0, abs(ammBalance)) | |
1251 | 1455 | else $Tuple2(ammBalance, 0) | |
1252 | - | let newAmmBalance = $t05647156614._1 | |
1253 | - | let takeFromInsurance = $t05647156614._2 | |
1254 | - | let x = if ((takeFromInsurance > 0)) | |
1456 | + | let newAmmBalance = $t06381963962._1 | |
1457 | + | let takeFromInsurance = $t06381963962._2 | |
1458 | + | let $t06397064024 = getBorrowedByTrader(_trader) | |
1459 | + | let borrowed = $t06397064024._1 | |
1460 | + | let assetId = $t06397064024._2 | |
1461 | + | let doLiquidateCollateral = if ((borrowed > 0)) | |
1255 | 1462 | then { | |
1256 | - | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1257 | - | if ((withdrawInsurance == withdrawInsurance)) | |
1463 | + | let collateralToSell = muld(borrowed, liquidationRatio) | |
1464 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartially", [_trader, assetId, collateralToSell], nil) | |
1465 | + | if ((realizeAndClose == realizeAndClose)) | |
1258 | 1466 | then nil | |
1259 | 1467 | else throw("Strict value is not equal to itself.") | |
1260 | 1468 | } | |
1261 | 1469 | else nil | |
1262 | - | if (( | |
1470 | + | if ((doLiquidateCollateral == doLiquidateCollateral)) | |
1263 | 1471 | then { | |
1264 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1265 | - | if ((unstake == unstake)) | |
1472 | + | let x = if ((takeFromInsurance > 0)) | |
1266 | 1473 | then { | |
1267 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1268 | - | if ((depositInsurance == depositInsurance)) | |
1474 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1475 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1476 | + | then nil | |
1477 | + | else throw("Strict value is not equal to itself.") | |
1478 | + | } | |
1479 | + | else nil | |
1480 | + | if ((x == x)) | |
1481 | + | then { | |
1482 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1483 | + | if ((unstake == unstake)) | |
1269 | 1484 | then { | |
1270 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1271 | - | if ((notifyNotional == notifyNotional)) | |
1272 | - | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1273 | - | then abs(exchangedPositionSize) | |
1274 | - | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1275 | - | then abs(exchangedPositionSize) | |
1276 | - | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1485 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1486 | + | if ((depositInsurance == depositInsurance)) | |
1487 | + | then { | |
1488 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1489 | + | if ((notifyNotional == notifyNotional)) | |
1490 | + | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1491 | + | then abs(exchangedPositionSize) | |
1492 | + | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1493 | + | then abs(exchangedPositionSize) | |
1494 | + | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1495 | + | else throw("Strict value is not equal to itself.") | |
1496 | + | } | |
1277 | 1497 | else throw("Strict value is not equal to itself.") | |
1278 | 1498 | } | |
1279 | 1499 | else throw("Strict value is not equal to itself.") | |
1283 | 1503 | else throw("Strict value is not equal to itself.") | |
1284 | 1504 | } | |
1285 | 1505 | else { | |
1286 | - | let $ | |
1287 | - | let x1 = $ | |
1288 | - | let badDebt = $ | |
1289 | - | let x2 = $ | |
1290 | - | let x3 = $ | |
1291 | - | let quoteAssetReserveAfter = $ | |
1292 | - | let baseAssetReserveAfter = $ | |
1293 | - | let totalPositionSizeAfter = $ | |
1294 | - | let cumulativeNotionalAfter = $ | |
1295 | - | let openInterestNotionalAfter = $ | |
1296 | - | let exchangedQuoteAssetAmount = $ | |
1297 | - | let totalLongAfter = $ | |
1298 | - | let totalShortAfter = $ | |
1506 | + | let $t06586666321 = internalClosePosition(_trader, false) | |
1507 | + | let x1 = $t06586666321._1 | |
1508 | + | let badDebt = $t06586666321._2 | |
1509 | + | let x2 = $t06586666321._3 | |
1510 | + | let x3 = $t06586666321._4 | |
1511 | + | let quoteAssetReserveAfter = $t06586666321._5 | |
1512 | + | let baseAssetReserveAfter = $t06586666321._6 | |
1513 | + | let totalPositionSizeAfter = $t06586666321._7 | |
1514 | + | let cumulativeNotionalAfter = $t06586666321._8 | |
1515 | + | let openInterestNotionalAfter = $t06586666321._9 | |
1516 | + | let exchangedQuoteAssetAmount = $t06586666321._10 | |
1517 | + | let totalLongAfter = $t06586666321._11 | |
1518 | + | let totalShortAfter = $t06586666321._12 | |
1299 | 1519 | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1300 | 1520 | let feeToLiquidator = (liquidationPenalty / 2) | |
1301 | 1521 | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1302 | 1522 | let ammBalance = (cbalance() - liquidationPenalty) | |
1303 | - | let $ | |
1523 | + | let $t06673366876 = if ((0 > ammBalance)) | |
1304 | 1524 | then $Tuple2(0, abs(ammBalance)) | |
1305 | 1525 | else $Tuple2(ammBalance, 0) | |
1306 | - | let newAmmBalance = $t05892859071._1 | |
1307 | - | let takeFromInsurance = $t05892859071._2 | |
1308 | - | let x = if ((takeFromInsurance > 0)) | |
1526 | + | let newAmmBalance = $t06673366876._1 | |
1527 | + | let takeFromInsurance = $t06673366876._2 | |
1528 | + | let $t06688466938 = getBorrowedByTrader(_trader) | |
1529 | + | let borrowed = $t06688466938._1 | |
1530 | + | let assetId = $t06688466938._2 | |
1531 | + | let doLiquidateCollateral = if ((borrowed > 0)) | |
1309 | 1532 | then { | |
1310 | - | let | |
1311 | - | if (( | |
1533 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], nil) | |
1534 | + | if ((realizeAndClose == realizeAndClose)) | |
1312 | 1535 | then nil | |
1313 | 1536 | else throw("Strict value is not equal to itself.") | |
1314 | 1537 | } | |
1315 | 1538 | else nil | |
1316 | - | if (( | |
1539 | + | if ((doLiquidateCollateral == doLiquidateCollateral)) | |
1317 | 1540 | then { | |
1318 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1319 | - | if ((unstake == unstake)) | |
1541 | + | let x = if ((takeFromInsurance > 0)) | |
1320 | 1542 | then { | |
1321 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1322 | - | if ((depositInsurance == depositInsurance)) | |
1543 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1544 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1545 | + | then nil | |
1546 | + | else throw("Strict value is not equal to itself.") | |
1547 | + | } | |
1548 | + | else nil | |
1549 | + | if ((x == x)) | |
1550 | + | then { | |
1551 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1552 | + | if ((unstake == unstake)) | |
1323 | 1553 | then { | |
1324 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1325 | - | if ((notifyNotional == notifyNotional)) | |
1326 | - | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1554 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1555 | + | if ((depositInsurance == depositInsurance)) | |
1556 | + | then { | |
1557 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1558 | + | if ((notifyNotional == notifyNotional)) | |
1559 | + | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1560 | + | else throw("Strict value is not equal to itself.") | |
1561 | + | } | |
1327 | 1562 | else throw("Strict value is not equal to itself.") | |
1328 | 1563 | } | |
1329 | 1564 | else throw("Strict value is not equal to itself.") | |
1347 | 1582 | then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp))) | |
1348 | 1583 | else { | |
1349 | 1584 | let underlyingPrice = getOracleTwapPrice() | |
1350 | - | let $ | |
1351 | - | let shortPremiumFraction = $ | |
1352 | - | let longPremiumFraction = $ | |
1585 | + | let $t06873668798 = getFunding() | |
1586 | + | let shortPremiumFraction = $t06873668798._1 | |
1587 | + | let longPremiumFraction = $t06873668798._2 | |
1353 | 1588 | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1354 | 1589 | } | |
1355 | 1590 | } | |
1376 | 1611 | else (0 > _price)) | |
1377 | 1612 | then throw("Invalid adjustPeg parameters") | |
1378 | 1613 | else { | |
1379 | - | let $ | |
1380 | - | let newQuoteAssetReserve = $ | |
1381 | - | let pegChangeCost = $ | |
1614 | + | let $t06978969875 = getPegAdjustCost(_price) | |
1615 | + | let newQuoteAssetReserve = $t06978969875._1 | |
1616 | + | let pegChangeCost = $t06978969875._2 | |
1382 | 1617 | if ((pegChangeCost == 0)) | |
1383 | 1618 | then throw("Nothing to adjust") | |
1384 | 1619 | else if ((pegChangeCost > 0)) | |
1420 | 1655 | ||
1421 | 1656 | @Callable(i) | |
1422 | 1657 | func v_get (_trader) = { | |
1423 | - | let $ | |
1424 | - | let x1 = $ | |
1425 | - | let x2 = $ | |
1426 | - | let x3 = $ | |
1427 | - | let x4 = $ | |
1658 | + | let $t07151671576 = internalClosePosition(_trader, false) | |
1659 | + | let x1 = $t07151671576._1 | |
1660 | + | let x2 = $t07151671576._2 | |
1661 | + | let x3 = $t07151671576._3 | |
1662 | + | let x4 = $t07151671576._4 | |
1428 | 1663 | throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader)))) | |
1429 | 1664 | } | |
1430 | 1665 | ||
1432 | 1667 | ||
1433 | 1668 | @Callable(i) | |
1434 | 1669 | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1435 | - | let $ | |
1436 | - | let positionSize = $ | |
1437 | - | let positionMargin = $ | |
1438 | - | let pon = $ | |
1439 | - | let positionLstUpdCPF = $ | |
1440 | - | let $ | |
1441 | - | let positionNotional = $ | |
1442 | - | let unrealizedPnl = $ | |
1443 | - | let $ | |
1444 | - | let remainMargin = $ | |
1445 | - | let badDebt = $ | |
1446 | - | let fundingPayment = $ | |
1670 | + | let $t07172371834 = getPosition(_trader) | |
1671 | + | let positionSize = $t07172371834._1 | |
1672 | + | let positionMargin = $t07172371834._2 | |
1673 | + | let pon = $t07172371834._3 | |
1674 | + | let positionLstUpdCPF = $t07172371834._4 | |
1675 | + | let $t07183971940 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1676 | + | let positionNotional = $t07183971940._1 | |
1677 | + | let unrealizedPnl = $t07183971940._2 | |
1678 | + | let $t07194572127 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
1679 | + | let remainMargin = $t07194572127._1 | |
1680 | + | let badDebt = $t07194572127._2 | |
1681 | + | let fundingPayment = $t07194572127._3 | |
1447 | 1682 | throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional))) | |
1448 | 1683 | } | |
1449 | 1684 | ||
1460 | 1695 | @Callable(i) | |
1461 | 1696 | func view_getFunding () = { | |
1462 | 1697 | let underlyingPrice = getOracleTwapPrice() | |
1463 | - | let $ | |
1464 | - | let shortPremiumFraction = $ | |
1465 | - | let longPremiumFraction = $ | |
1698 | + | let $t07251872580 = getFunding() | |
1699 | + | let shortPremiumFraction = $t07251872580._1 | |
1700 | + | let longPremiumFraction = $t07251872580._2 | |
1466 | 1701 | let longFunding = divd(longPremiumFraction, underlyingPrice) | |
1467 | 1702 | let shortFunding = divd(shortPremiumFraction, underlyingPrice) | |
1468 | 1703 | throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOracleTwapPrice()))) | |
1704 | + | } | |
1705 | + | ||
1706 | + | ||
1707 | + | ||
1708 | + | @Callable(i) | |
1709 | + | func view_getBorrowedByTrader (_trader) = { | |
1710 | + | let $t07287072924 = getBorrowedByTrader(_trader) | |
1711 | + | let borrowed = $t07287072924._1 | |
1712 | + | let assetId = $t07287072924._2 | |
1713 | + | throw((s(borrowed) + assetId)) | |
1469 | 1714 | } | |
1470 | 1715 | ||
1471 | 1716 |
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_positionSize = "k_positionSize" | |
13 | 13 | ||
14 | 14 | let k_positionMargin = "k_positionMargin" | |
15 | 15 | ||
16 | 16 | let k_positionOpenNotional = "k_positionOpenNotional" | |
17 | 17 | ||
18 | 18 | let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction" | |
19 | 19 | ||
20 | 20 | let k_positionClosedDate = "k_positionClosedDate" | |
21 | + | ||
22 | + | let k_positionAsset = "k_positionAsset" | |
21 | 23 | ||
22 | 24 | let k_initialized = "k_initialized" | |
23 | 25 | ||
24 | 26 | let k_paused = "k_paused" | |
25 | 27 | ||
26 | 28 | let k_fee = "k_fee" | |
27 | 29 | ||
28 | 30 | let k_fundingPeriod = "k_fundingPeriod" | |
29 | 31 | ||
30 | 32 | let k_initMarginRatio = "k_initMarginRatio" | |
31 | 33 | ||
32 | 34 | let k_maintenanceMarginRatio = "k_mmr" | |
33 | 35 | ||
34 | 36 | let k_liquidationFeeRatio = "k_liquidationFeeRatio" | |
35 | 37 | ||
36 | 38 | let k_partialLiquidationRatio = "k_partLiquidationRatio" | |
37 | 39 | ||
38 | 40 | let k_spreadLimit = "k_spreadLimit" | |
39 | 41 | ||
40 | 42 | let k_maxPriceImpact = "k_maxPriceImpact" | |
41 | 43 | ||
42 | 44 | let k_maxPriceSpread = "k_maxPriceSpread" | |
43 | 45 | ||
44 | 46 | let k_lastDataStr = "k_lastDataStr" | |
45 | 47 | ||
46 | 48 | let k_lastMinuteId = "k_lastMinuteId" | |
47 | 49 | ||
48 | 50 | let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice" | |
49 | 51 | ||
50 | 52 | let k_twapDataLastPrice = "k_twapDataLastPrice" | |
51 | 53 | ||
52 | 54 | let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId" | |
53 | 55 | ||
54 | 56 | let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction" | |
55 | 57 | ||
56 | 58 | let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction" | |
57 | 59 | ||
58 | 60 | let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp" | |
59 | 61 | ||
60 | 62 | let k_longFundingRate = "k_longFundingRate" | |
61 | 63 | ||
62 | 64 | let k_shortFundingRate = "k_shortFundingRate" | |
63 | 65 | ||
64 | 66 | let k_quoteAssetReserve = "k_qtAstR" | |
65 | 67 | ||
66 | 68 | let k_baseAssetReserve = "k_bsAstR" | |
67 | 69 | ||
68 | 70 | let k_totalPositionSize = "k_totalPositionSize" | |
69 | 71 | ||
70 | 72 | let k_totalLongPositionSize = "k_totalLongPositionSize" | |
71 | 73 | ||
72 | 74 | let k_totalShortPositionSize = "k_totalShortPositionSize" | |
73 | 75 | ||
74 | 76 | let k_cumulativeNotional = "k_cumulativeNotional" | |
75 | 77 | ||
76 | 78 | let k_openInterestNotional = "k_openInterestNotional" | |
77 | 79 | ||
78 | 80 | let k_coordinatorAddress = "k_coordinatorAddress" | |
79 | 81 | ||
80 | 82 | let k_insurance_address = "k_insurance_address" | |
81 | 83 | ||
82 | 84 | let k_admin_address = "k_admin_address" | |
83 | 85 | ||
84 | 86 | let k_admin_public_key = "k_admin_public_key" | |
85 | 87 | ||
86 | 88 | let k_quote_asset = "k_quote_asset" | |
87 | 89 | ||
88 | 90 | let k_quote_staking = "k_quote_staking" | |
89 | 91 | ||
90 | 92 | let k_staking_address = "k_staking_address" | |
91 | 93 | ||
92 | 94 | let k_miner_address = "k_miner_address" | |
93 | 95 | ||
94 | 96 | let k_orders_address = "k_orders_address" | |
95 | 97 | ||
96 | 98 | let k_referral_address = "k_referral_address" | |
97 | 99 | ||
98 | 100 | let k_manager_address = "k_manager_address" | |
99 | 101 | ||
102 | + | let k_collateral_address = "k_collateral_address" | |
103 | + | ||
104 | + | let k_exchange_address = "k_exchange_address" | |
105 | + | ||
100 | 106 | let k_nft_manager_address = "k_nft_manager_address" | |
107 | + | ||
108 | + | let k_trader_market_asset_collateral = "k_trader_market_asset_collateral" | |
109 | + | ||
110 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
111 | + | ||
101 | 112 | ||
102 | 113 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
103 | 114 | ||
104 | 115 | ||
105 | 116 | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
106 | 117 | ||
107 | 118 | ||
108 | 119 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
109 | 120 | ||
110 | 121 | ||
111 | 122 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
112 | 123 | ||
113 | 124 | ||
114 | 125 | func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set") | |
115 | 126 | ||
116 | 127 | ||
117 | 128 | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set") | |
118 | 129 | ||
119 | 130 | ||
120 | 131 | func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set") | |
121 | 132 | ||
122 | 133 | ||
123 | 134 | func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Miner not set") | |
124 | 135 | ||
125 | 136 | ||
126 | 137 | func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set") | |
127 | 138 | ||
128 | 139 | ||
129 | 140 | func referralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_referral_address)), "Referral not set") | |
130 | 141 | ||
131 | 142 | ||
132 | 143 | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
133 | 144 | ||
134 | 145 | ||
135 | 146 | func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set") | |
147 | + | ||
148 | + | ||
149 | + | func collateralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_collateral_address)), "Collateral Manager not set") | |
150 | + | ||
151 | + | ||
152 | + | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_exchange_address), "No swap address")), "Invalid swap address") | |
153 | + | ||
154 | + | ||
155 | + | let k_whitelist_asset = "k_whitelist_asset" | |
156 | + | ||
157 | + | func isWhitelistAsset (_assetId) = valueOrElse(getBoolean(collateralAddress(), toCompositeKey(k_whitelist_asset, _assetId)), false) | |
136 | 158 | ||
137 | 159 | ||
138 | 160 | let k_token_param = "k_token_param" | |
139 | 161 | ||
140 | 162 | let k_token_type = "k_token_type" | |
141 | 163 | ||
142 | 164 | let FEE_REDUCTION_TOKEN_TYPE = "fee_reduction" | |
143 | 165 | ||
144 | 166 | let DIR_LONG = 1 | |
145 | 167 | ||
146 | 168 | let DIR_SHORT = 2 | |
147 | 169 | ||
148 | 170 | let TWAP_INTERVAL = 15 | |
149 | 171 | ||
150 | 172 | let ORACLE_INTERVAL = 15 | |
151 | 173 | ||
152 | 174 | let SECONDS = 1000 | |
153 | 175 | ||
154 | 176 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
155 | 177 | ||
156 | 178 | let ONE_DAY = (86400 * DECIMAL_UNIT) | |
157 | 179 | ||
158 | 180 | let ALL_FEES = 100 | |
159 | 181 | ||
160 | 182 | let PNL_OPTION_SPOT = 1 | |
161 | 183 | ||
162 | 184 | let PNL_OPTION_ORACLE = 2 | |
163 | 185 | ||
164 | 186 | func s (_x) = (toString(_x) + ",") | |
165 | 187 | ||
166 | 188 | ||
167 | 189 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
168 | 190 | ||
169 | 191 | ||
170 | 192 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
171 | 193 | ||
172 | 194 | ||
173 | 195 | func abs (_x) = if ((_x > 0)) | |
174 | 196 | then _x | |
175 | 197 | else -(_x) | |
176 | 198 | ||
177 | 199 | ||
178 | 200 | func vmax (_x,_y) = if ((_x >= _y)) | |
179 | 201 | then _x | |
180 | 202 | else _y | |
181 | - | ||
182 | - | ||
183 | - | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
184 | 203 | ||
185 | 204 | ||
186 | 205 | func listToStr (_list) = { | |
187 | 206 | func _join (accumulator,val) = ((accumulator + val) + ",") | |
188 | 207 | ||
189 | 208 | let newListStr = { | |
190 | 209 | let $l = _list | |
191 | 210 | let $s = size($l) | |
192 | 211 | let $acc0 = "" | |
193 | 212 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
194 | 213 | then $a | |
195 | 214 | else _join($a, $l[$i]) | |
196 | 215 | ||
197 | 216 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
198 | 217 | then $a | |
199 | 218 | else throw("List size exceeds 20") | |
200 | 219 | ||
201 | 220 | $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) | |
202 | 221 | } | |
203 | 222 | let newListStrU = dropRight(newListStr, 1) | |
204 | 223 | let newListStrR = if ((take(newListStrU, 1) == ",")) | |
205 | 224 | then drop(newListStrU, 1) | |
206 | 225 | else newListStrU | |
207 | 226 | newListStrR | |
208 | 227 | } | |
209 | 228 | ||
210 | 229 | ||
211 | 230 | func strToList (_str) = split(_str, ",") | |
212 | 231 | ||
213 | 232 | ||
214 | 233 | func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize)) | |
215 | 234 | then (removeByIndex(_list, 0) :+ _value) | |
216 | 235 | else (_list :+ _value) | |
217 | 236 | ||
218 | 237 | ||
219 | 238 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
220 | 239 | ||
221 | 240 | ||
222 | 241 | func strA (_address,_key) = { | |
223 | 242 | let val = valueOrErrorMessage(getString(_address, _key), ("No value for key " + _key)) | |
224 | 243 | val | |
225 | 244 | } | |
226 | 245 | ||
227 | 246 | ||
228 | 247 | func intA (_address,_key) = { | |
229 | 248 | let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key)) | |
230 | 249 | val | |
231 | 250 | } | |
232 | 251 | ||
233 | 252 | ||
234 | 253 | func cbalance () = int(k_balance) | |
235 | 254 | ||
236 | 255 | ||
237 | 256 | func fee () = int(k_fee) | |
238 | 257 | ||
239 | 258 | ||
240 | 259 | func initMarginRatio () = int(k_initMarginRatio) | |
241 | 260 | ||
242 | 261 | ||
243 | 262 | func qtAstR () = int(k_quoteAssetReserve) | |
244 | 263 | ||
245 | 264 | ||
246 | 265 | func bsAstR () = int(k_baseAssetReserve) | |
247 | 266 | ||
248 | 267 | ||
249 | 268 | func totalPositionSize () = int(k_totalPositionSize) | |
250 | 269 | ||
251 | 270 | ||
252 | 271 | func cumulativeNotional () = int(k_cumulativeNotional) | |
253 | 272 | ||
254 | 273 | ||
255 | 274 | func openInterestNotional () = int(k_openInterestNotional) | |
256 | 275 | ||
257 | 276 | ||
258 | 277 | func nextFundingBlockTimestamp () = int(k_nextFundingBlock) | |
259 | 278 | ||
260 | 279 | ||
261 | 280 | func fundingPeriodRaw () = int(k_fundingPeriod) | |
262 | 281 | ||
263 | 282 | ||
264 | 283 | func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT) | |
265 | 284 | ||
266 | 285 | ||
267 | 286 | func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS) | |
268 | 287 | ||
269 | 288 | ||
270 | 289 | func maintenanceMarginRatio () = int(k_maintenanceMarginRatio) | |
271 | 290 | ||
272 | 291 | ||
273 | 292 | func liquidationFeeRatio () = int(k_liquidationFeeRatio) | |
274 | 293 | ||
275 | 294 | ||
276 | 295 | func partialLiquidationRatio () = int(k_partialLiquidationRatio) | |
277 | 296 | ||
278 | 297 | ||
279 | 298 | func spreadLimit () = int(k_spreadLimit) | |
280 | 299 | ||
281 | 300 | ||
282 | 301 | func maxPriceImpact () = int(k_maxPriceImpact) | |
283 | 302 | ||
284 | 303 | ||
285 | 304 | func maxPriceSpread () = int(k_maxPriceSpread) | |
286 | 305 | ||
287 | 306 | ||
288 | 307 | func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction) | |
289 | 308 | ||
290 | 309 | ||
291 | 310 | func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction) | |
292 | 311 | ||
293 | 312 | ||
294 | 313 | func totalShortPositionSize () = int(k_totalShortPositionSize) | |
295 | 314 | ||
296 | 315 | ||
297 | 316 | func totalLongPositionSize () = int(k_totalLongPositionSize) | |
298 | 317 | ||
299 | 318 | ||
300 | 319 | func getActualCaller (i) = valueOrElse(getString(ordersAddress(), "k_sender"), toString(i.caller)) | |
301 | 320 | ||
302 | 321 | ||
303 | 322 | func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = { | |
304 | 323 | let remainingMarginRatio = (_marginRatio - _baseMarginRatio) | |
305 | 324 | if (if (_largerThanOrEqualTo) | |
306 | 325 | then (0 > remainingMarginRatio) | |
307 | 326 | else false) | |
308 | 327 | then throw("Invalid margin") | |
309 | 328 | else if (if (!(_largerThanOrEqualTo)) | |
310 | 329 | then (remainingMarginRatio >= 0) | |
311 | 330 | else false) | |
312 | 331 | then throw("Invalid margin") | |
313 | 332 | else true | |
314 | 333 | } | |
315 | 334 | ||
316 | 335 | ||
317 | 336 | func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0)) | |
318 | 337 | then throw("Should not be called with _positionSize == 0") | |
319 | 338 | else if ((_positionSize > 0)) | |
320 | 339 | then latestLongCumulativePremiumFraction() | |
321 | 340 | else latestShortCumulativePremiumFraction() | |
322 | 341 | ||
323 | 342 | ||
324 | 343 | func getPosition (_trader) = { | |
325 | 344 | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader)) | |
326 | 345 | match positionSizeOpt { | |
327 | 346 | case positionSize: Int => | |
328 | 347 | $Tuple4(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader))) | |
329 | 348 | case _ => | |
330 | 349 | $Tuple4(0, 0, 0, 0) | |
331 | 350 | } | |
332 | 351 | } | |
333 | 352 | ||
334 | 353 | ||
354 | + | func getPositionAsset (_trader) = { | |
355 | + | let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader)) | |
356 | + | match positionAssetOpt { | |
357 | + | case positionAsset: String => | |
358 | + | positionAsset | |
359 | + | case _ => | |
360 | + | toBase58String(quoteAsset()) | |
361 | + | } | |
362 | + | } | |
363 | + | ||
364 | + | ||
335 | 365 | func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0)) | |
336 | 366 | then throw("No open position") | |
337 | 367 | else true | |
338 | 368 | ||
339 | 369 | ||
340 | 370 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
341 | 371 | ||
342 | 372 | ||
343 | 373 | func paused () = valueOrElse(getBoolean(this, k_paused), false) | |
344 | 374 | ||
345 | 375 | ||
346 | 376 | func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd) | |
347 | 377 | then { | |
348 | 378 | let newBase = (bsAstR() - _baseAssetAmount) | |
349 | 379 | if ((0 >= newBase)) | |
350 | 380 | then throw("Tx lead to base asset reserve <= 0, revert") | |
351 | 381 | else $Tuple4((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount), (cumulativeNotional() + _quoteAssetAmount)) | |
352 | 382 | } | |
353 | 383 | else { | |
354 | 384 | let newQuote = (qtAstR() - _quoteAssetAmount) | |
355 | 385 | if ((0 >= newQuote)) | |
356 | 386 | then throw("Tx lead to base quote reserve <= 0, revert") | |
357 | 387 | else $Tuple4(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount), (cumulativeNotional() - _quoteAssetAmount)) | |
358 | 388 | } | |
359 | 389 | ||
360 | 390 | ||
361 | 391 | func swapInput (_isAdd,_quoteAssetAmount) = { | |
362 | 392 | let _qtAstR = qtAstR() | |
363 | 393 | let _bsAstR = bsAstR() | |
364 | 394 | let k = muld(_qtAstR, _bsAstR) | |
365 | 395 | let quoteAssetReserveAfter = if (_isAdd) | |
366 | 396 | then (_qtAstR + _quoteAssetAmount) | |
367 | 397 | else (_qtAstR - _quoteAssetAmount) | |
368 | 398 | let baseAssetReserveAfter = divd(k, quoteAssetReserveAfter) | |
369 | 399 | let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR)) | |
370 | 400 | let amountBaseAssetBought = if (_isAdd) | |
371 | 401 | then amountBaseAssetBoughtAbs | |
372 | 402 | else -(amountBaseAssetBoughtAbs) | |
373 | - | let $ | |
374 | - | let quoteAssetReserveAfter1 = $ | |
375 | - | let baseAssetReserveAfter1 = $ | |
376 | - | let totalPositionSizeAfter1 = $ | |
377 | - | let cumulativeNotionalAfter1 = $ | |
403 | + | let $t01497415167 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs) | |
404 | + | let quoteAssetReserveAfter1 = $t01497415167._1 | |
405 | + | let baseAssetReserveAfter1 = $t01497415167._2 | |
406 | + | let totalPositionSizeAfter1 = $t01497415167._3 | |
407 | + | let cumulativeNotionalAfter1 = $t01497415167._4 | |
378 | 408 | let priceBefore = divd(_qtAstR, _bsAstR) | |
379 | 409 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
380 | 410 | let priceDiff = abs((priceBefore - marketPrice)) | |
381 | 411 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
382 | 412 | let maxPriceImpactValue = maxPriceImpact() | |
383 | 413 | if ((priceImpact > maxPriceImpactValue)) | |
384 | 414 | 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))) | |
385 | 415 | else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1) | |
386 | 416 | } | |
387 | 417 | ||
388 | 418 | ||
389 | 419 | func calcRemainMarginWithFundingPayment (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_marginDelta) = { | |
390 | 420 | let fundingPayment = if ((_oldPositionSize != 0)) | |
391 | 421 | then { | |
392 | 422 | let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize) | |
393 | 423 | muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize) | |
394 | 424 | } | |
395 | 425 | else 0 | |
396 | 426 | let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin) | |
397 | - | let $ | |
427 | + | let $t01665816785 = if ((0 > signedMargin)) | |
398 | 428 | then $Tuple2(0, abs(signedMargin)) | |
399 | 429 | else $Tuple2(abs(signedMargin), 0) | |
400 | - | let remainMargin = $ | |
401 | - | let badDebt = $ | |
430 | + | let remainMargin = $t01665816785._1 | |
431 | + | let badDebt = $t01665816785._2 | |
402 | 432 | $Tuple3(remainMargin, badDebt, fundingPayment) | |
403 | 433 | } | |
404 | 434 | ||
405 | 435 | ||
406 | 436 | func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_baseAssetReserve) = { | |
407 | 437 | let priceBefore = divd(_quoteAssetReserve, _baseAssetReserve) | |
408 | 438 | if ((_baseAssetAmount == 0)) | |
409 | 439 | then throw("Invalid base asset amount") | |
410 | 440 | else { | |
411 | 441 | let k = muld(_quoteAssetReserve, _baseAssetReserve) | |
412 | 442 | let baseAssetPoolAmountAfter = if (_isAdd) | |
413 | 443 | then (_baseAssetReserve + _baseAssetAmount) | |
414 | 444 | else (_baseAssetReserve - _baseAssetAmount) | |
415 | 445 | let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter) | |
416 | 446 | let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve)) | |
417 | 447 | let maxPriceImpactValue = maxPriceImpact() | |
418 | - | let $ | |
419 | - | let quoteAssetReserveAfter1 = $ | |
420 | - | let baseAssetReserveAfter1 = $ | |
421 | - | let totalPositionSizeAfter1 = $ | |
422 | - | let cumulativeNotionalAfter1 = $ | |
448 | + | let $t01776217955 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount) | |
449 | + | let quoteAssetReserveAfter1 = $t01776217955._1 | |
450 | + | let baseAssetReserveAfter1 = $t01776217955._2 | |
451 | + | let totalPositionSizeAfter1 = $t01776217955._3 | |
452 | + | let cumulativeNotionalAfter1 = $t01776217955._4 | |
423 | 453 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
424 | 454 | let priceDiff = abs((priceBefore - marketPrice)) | |
425 | 455 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
426 | 456 | if (if ((priceImpact > maxPriceImpactValue)) | |
427 | 457 | then _checkMaxPriceImpact | |
428 | 458 | else false) | |
429 | 459 | 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))) | |
430 | 460 | else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd) | |
431 | 461 | then abs(_baseAssetAmount) | |
432 | 462 | else 0)), (totalShortPositionSize() - (if (!(_isAdd)) | |
433 | 463 | then abs(_baseAssetAmount) | |
434 | 464 | else 0)), priceImpact) | |
435 | 465 | } | |
436 | 466 | } | |
437 | 467 | ||
438 | 468 | ||
439 | 469 | func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), bsAstR()) | |
440 | 470 | ||
441 | 471 | ||
442 | 472 | func getOracleTwapPrice () = { | |
443 | 473 | let oracle = valueOrErrorMessage(addressFromString(getStringValue(this, k_ora)), "") | |
444 | 474 | let priceKey = getStringValue(this, k_ora_key) | |
445 | 475 | let blockKey = getStringValue(this, k_ora_block_key) | |
446 | 476 | let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey)) | |
447 | 477 | lastValue | |
448 | 478 | } | |
449 | 479 | ||
450 | 480 | ||
451 | 481 | func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = { | |
452 | 482 | let oraclePrice = getOracleTwapPrice() | |
453 | 483 | let priceAfter = divd(_quoteAssetReserve, _baseAssetReserve) | |
454 | 484 | let averagePrice = divd((oraclePrice + priceAfter), (2 * DECIMAL_UNIT)) | |
455 | 485 | let absPriceDiff = divd(abs((oraclePrice - priceAfter)), averagePrice) | |
456 | 486 | if ((absPriceDiff > maxPriceSpread())) | |
457 | 487 | then throw(((("Price spread " + toString(absPriceDiff)) + " > max price spread ") + toString(maxPriceSpread()))) | |
458 | 488 | else true | |
459 | 489 | } | |
460 | 490 | ||
461 | 491 | ||
462 | 492 | func getSpotPrice () = { | |
463 | 493 | let _quoteAssetReserve = qtAstR() | |
464 | 494 | let _baseAssetReserve = bsAstR() | |
465 | 495 | divd(_quoteAssetReserve, _baseAssetReserve) | |
466 | 496 | } | |
467 | 497 | ||
468 | 498 | ||
469 | 499 | func isOverFluctuationLimit () = { | |
470 | 500 | let oraclePrice = getOracleTwapPrice() | |
471 | 501 | let currentPrice = getSpotPrice() | |
472 | 502 | (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit()) | |
473 | 503 | } | |
474 | 504 | ||
475 | 505 | ||
476 | 506 | func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_baseAssetReserve) = { | |
477 | 507 | let positionSizeAbs = abs(_positionSize) | |
478 | 508 | let isShort = (0 > _positionSize) | |
479 | 509 | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
480 | 510 | then { | |
481 | - | let $ | |
482 | - | let outPositionNotional = $ | |
483 | - | let x1 = $ | |
484 | - | let x2 = $ | |
485 | - | let x3 = $ | |
511 | + | let $t02117321344 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve) | |
512 | + | let outPositionNotional = $t02117321344._1 | |
513 | + | let x1 = $t02117321344._2 | |
514 | + | let x2 = $t02117321344._3 | |
515 | + | let x3 = $t02117321344._4 | |
486 | 516 | outPositionNotional | |
487 | 517 | } | |
488 | 518 | else muld(positionSizeAbs, getOracleTwapPrice()) | |
489 | 519 | positionNotional | |
490 | 520 | } | |
491 | 521 | ||
492 | 522 | ||
493 | 523 | func getPositionNotionalAndUnrealizedPnlByValues (_positionSize,_positionOpenNotional,_quoteAssetReserve,_baseAssetReserve,_option) = if ((_positionSize == 0)) | |
494 | 524 | then throw("Invalid position size") | |
495 | 525 | else { | |
496 | 526 | let isShort = (0 > _positionSize) | |
497 | 527 | let positionNotional = getPositionAdjustedOpenNotional(_positionSize, _option, _quoteAssetReserve, _baseAssetReserve) | |
498 | 528 | let unrealizedPnl = if (isShort) | |
499 | 529 | then (_positionOpenNotional - positionNotional) | |
500 | 530 | else (positionNotional - _positionOpenNotional) | |
501 | 531 | $Tuple2(positionNotional, unrealizedPnl) | |
502 | 532 | } | |
503 | 533 | ||
504 | 534 | ||
505 | 535 | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
506 | - | let $ | |
507 | - | let positionSize = $ | |
508 | - | let positionMargin = $ | |
509 | - | let positionOpenNotional = $ | |
510 | - | let positionLstUpdCPF = $ | |
536 | + | let $t02266122789 = getPosition(_trader) | |
537 | + | let positionSize = $t02266122789._1 | |
538 | + | let positionMargin = $t02266122789._2 | |
539 | + | let positionOpenNotional = $t02266122789._3 | |
540 | + | let positionLstUpdCPF = $t02266122789._4 | |
511 | 541 | getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), bsAstR(), _option) | |
512 | 542 | } | |
513 | 543 | ||
514 | 544 | ||
515 | 545 | func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional) | |
516 | 546 | ||
517 | 547 | ||
518 | 548 | func getMarginRatioByOption (_trader,_option) = { | |
519 | - | let $ | |
520 | - | let positionSize = $ | |
521 | - | let positionMargin = $ | |
522 | - | let pon = $ | |
523 | - | let positionLstUpdCPF = $ | |
524 | - | let $ | |
525 | - | let positionNotional = $ | |
526 | - | let unrealizedPnl = $ | |
527 | - | let $ | |
528 | - | let remainMargin = $ | |
529 | - | let badDebt = $ | |
549 | + | let $t02327023381 = getPosition(_trader) | |
550 | + | let positionSize = $t02327023381._1 | |
551 | + | let positionMargin = $t02327023381._2 | |
552 | + | let pon = $t02327023381._3 | |
553 | + | let positionLstUpdCPF = $t02327023381._4 | |
554 | + | let $t02338723480 = getPositionNotionalAndUnrealizedPnl(_trader, _option) | |
555 | + | let positionNotional = $t02338723480._1 | |
556 | + | let unrealizedPnl = $t02338723480._2 | |
557 | + | let $t02348523651 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
558 | + | let remainMargin = $t02348523651._1 | |
559 | + | let badDebt = $t02348523651._2 | |
530 | 560 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
531 | 561 | } | |
532 | 562 | ||
533 | 563 | ||
534 | 564 | func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
535 | 565 | ||
536 | 566 | ||
537 | 567 | func getPartialLiquidationAmount (_trader,_positionSize) = { | |
538 | 568 | let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio()))) | |
539 | 569 | let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio) | |
540 | 570 | let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false) | |
541 | 571 | let maxExchangedQuoteAssetAmount = swapResult._1 | |
542 | 572 | let priceImpact = swapResult._8 | |
543 | 573 | if ((maxPriceImpact() > priceImpact)) | |
544 | 574 | then maxExchangedQuoteAssetAmount | |
545 | 575 | else { | |
546 | 576 | let exchangedPositionSize = muld(abs(_positionSize), partialLiquidationRatio()) | |
547 | 577 | let exchangedQuoteAssetAmount = swapOutput((_positionSize > 0), exchangedPositionSize, false)._1 | |
548 | 578 | exchangedQuoteAssetAmount | |
549 | 579 | } | |
550 | 580 | } | |
551 | 581 | ||
552 | 582 | ||
553 | 583 | func internalClosePosition (_trader,_checkMaxPriceImpact) = { | |
554 | - | let $ | |
555 | - | let positionSize = $ | |
556 | - | let positionMargin = $ | |
557 | - | let positionOpenNotional = $ | |
558 | - | let positionLstUpdCPF = $ | |
584 | + | let $t02488425012 = getPosition(_trader) | |
585 | + | let positionSize = $t02488425012._1 | |
586 | + | let positionMargin = $t02488425012._2 | |
587 | + | let positionOpenNotional = $t02488425012._3 | |
588 | + | let positionLstUpdCPF = $t02488425012._4 | |
559 | 589 | let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2 | |
560 | - | let $ | |
561 | - | let remainMargin = $ | |
562 | - | let badDebt = $ | |
590 | + | let $t02510725275 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
591 | + | let remainMargin = $t02510725275._1 | |
592 | + | let badDebt = $t02510725275._2 | |
563 | 593 | let exchangedPositionSize = -(positionSize) | |
564 | 594 | let realizedPnl = unrealizedPnl | |
565 | 595 | let marginToVault = -(remainMargin) | |
566 | - | let $ | |
567 | - | let exchangedQuoteAssetAmount = $ | |
568 | - | let quoteAssetReserveAfter = $ | |
569 | - | let baseAssetReserveAfter = $ | |
570 | - | let totalPositionSizeAfter = $ | |
571 | - | let cumulativeNotionalAfter = $ | |
572 | - | let totalLongAfter = $ | |
573 | - | let totalShortAfter = $ | |
596 | + | let $t02540225713 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact) | |
597 | + | let exchangedQuoteAssetAmount = $t02540225713._1 | |
598 | + | let quoteAssetReserveAfter = $t02540225713._2 | |
599 | + | let baseAssetReserveAfter = $t02540225713._3 | |
600 | + | let totalPositionSizeAfter = $t02540225713._4 | |
601 | + | let cumulativeNotionalAfter = $t02540225713._5 | |
602 | + | let totalLongAfter = $t02540225713._6 | |
603 | + | let totalShortAfter = $t02540225713._7 | |
574 | 604 | let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional) | |
575 | 605 | $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter) | |
576 | 606 | } | |
577 | 607 | ||
578 | 608 | ||
579 | 609 | func getTwapSpotPrice () = { | |
580 | 610 | let minuteId = ((lastBlock.timestamp / 1000) / 60) | |
581 | 611 | let startMinuteId = (minuteId - TWAP_INTERVAL) | |
582 | 612 | let listStr = valueOrElse(getString(this, k_lastDataStr), "") | |
583 | 613 | let list = split(listStr, ",") | |
584 | 614 | func filterFn (accumulator,next) = if ((startMinuteId >= parseIntValue(next))) | |
585 | 615 | then (accumulator :+ parseIntValue(next)) | |
586 | 616 | else accumulator | |
587 | 617 | ||
588 | 618 | let listF = { | |
589 | 619 | let $l = list | |
590 | 620 | let $s = size($l) | |
591 | 621 | let $acc0 = nil | |
592 | 622 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
593 | 623 | then $a | |
594 | 624 | else filterFn($a, $l[$i]) | |
595 | 625 | ||
596 | 626 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
597 | 627 | then $a | |
598 | 628 | else throw("List size exceeds 20") | |
599 | 629 | ||
600 | 630 | $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) | |
601 | 631 | } | |
602 | 632 | let maxIndex = if ((size(listF) > 0)) | |
603 | 633 | then max(listF) | |
604 | 634 | else parseIntValue(list[0]) | |
605 | 635 | let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
606 | 636 | let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0) | |
607 | 637 | let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0) | |
608 | 638 | let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice)) | |
609 | 639 | let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0) | |
610 | 640 | let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0) | |
611 | 641 | let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice)) | |
612 | 642 | ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL) | |
613 | 643 | } | |
614 | 644 | ||
615 | 645 | ||
616 | 646 | func getPegAdjustCost (_price) = { | |
617 | 647 | let _positionSize = totalPositionSize() | |
618 | 648 | let direction = (_positionSize > 0) | |
619 | 649 | let currentNetMarketValue = swapOutput(direction, abs(_positionSize), false)._1 | |
620 | 650 | let baseAssetReserve = bsAstR() | |
621 | 651 | let newQuoteAssetReserve = muld(baseAssetReserve, _price) | |
622 | 652 | let cost = getPositionNotionalAndUnrealizedPnlByValues(_positionSize, currentNetMarketValue, newQuoteAssetReserve, baseAssetReserve, PNL_OPTION_SPOT)._2 | |
623 | 653 | $Tuple2(newQuoteAssetReserve, cost) | |
624 | 654 | } | |
625 | 655 | ||
626 | 656 | ||
627 | 657 | func getFunding () = { | |
628 | 658 | let underlyingPrice = getOracleTwapPrice() | |
629 | 659 | let spotTwapPrice = getTwapSpotPrice() | |
630 | 660 | let premium = (spotTwapPrice - underlyingPrice) | |
631 | 661 | if (if ((totalShortPositionSize() == 0)) | |
632 | 662 | then true | |
633 | 663 | else (totalLongPositionSize() == 0)) | |
634 | 664 | then $Tuple2(0, 0) | |
635 | 665 | else if ((0 > premium)) | |
636 | 666 | then { | |
637 | 667 | let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
638 | 668 | let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize()) | |
639 | 669 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
640 | 670 | } | |
641 | 671 | else { | |
642 | 672 | let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
643 | 673 | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
644 | 674 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
645 | 675 | } | |
646 | 676 | } | |
647 | 677 | ||
648 | 678 | ||
649 | 679 | func getAdjustedFee (i) = { | |
650 | 680 | let baseFee = fee() | |
651 | - | let $ | |
681 | + | let $t02937629984 = if ((size(i.payments) > 1)) | |
652 | 682 | then { | |
653 | 683 | let artifactId = toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid attached artifact")) | |
654 | 684 | let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, artifactId)) | |
655 | 685 | if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE)) | |
656 | 686 | then { | |
657 | 687 | let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, artifactId)) | |
658 | 688 | let adjustedFee = muld(baseFee, reduction) | |
659 | 689 | $Tuple2(adjustedFee, true) | |
660 | 690 | } | |
661 | 691 | else throw("Invalid attached artifact") | |
662 | 692 | } | |
663 | 693 | else $Tuple2(baseFee, false) | |
664 | - | let adjustedFee = $ | |
665 | - | let burnArtifact = $ | |
694 | + | let adjustedFee = $t02937629984._1 | |
695 | + | let burnArtifact = $t02937629984._2 | |
666 | 696 | $Tuple2(adjustedFee, burnArtifact) | |
667 | 697 | } | |
668 | 698 | ||
669 | 699 | ||
670 | 700 | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = [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)] | |
671 | 701 | ||
672 | 702 | ||
673 | 703 | 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)] | |
704 | + | ||
705 | + | ||
706 | + | func updatePositionAsset (_address,_assetId) = [StringEntry(toCompositeKey(k_positionAsset, _address), _assetId)] | |
674 | 707 | ||
675 | 708 | ||
676 | 709 | 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)] | |
677 | 710 | ||
678 | 711 | ||
679 | 712 | func appendTwap (price) = { | |
680 | 713 | let minuteId = ((lastBlock.timestamp / 1000) / 60) | |
681 | 714 | let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
682 | 715 | if ((previousMinuteId > minuteId)) | |
683 | 716 | then throw("TWAP out-of-order") | |
684 | 717 | else { | |
685 | 718 | let lastMinuteId = if ((previousMinuteId == 0)) | |
686 | 719 | then minuteId | |
687 | 720 | else previousMinuteId | |
688 | 721 | if ((minuteId > previousMinuteId)) | |
689 | 722 | then { | |
690 | 723 | let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0) | |
691 | 724 | let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), price) | |
692 | 725 | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice)) | |
693 | 726 | let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId)) | |
694 | 727 | [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))] | |
695 | 728 | } | |
696 | 729 | else { | |
697 | 730 | let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0) | |
698 | 731 | let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0) | |
699 | 732 | let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), price) | |
700 | 733 | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice)) | |
701 | 734 | [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), price)] | |
702 | 735 | } | |
703 | 736 | } | |
704 | 737 | } | |
705 | 738 | ||
706 | 739 | ||
707 | 740 | func updateAmmReserves (_qtAstR,_bsAstR) = [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)] | |
708 | 741 | ||
709 | 742 | ||
710 | 743 | func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_cumulativeNotionalAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize) = if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter)) | |
711 | 744 | then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter))) | |
712 | 745 | else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_cumulativeNotional, _cumulativeNotionalAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize)]) ++ appendTwap(divd(_qtAstR, _bsAstR))) | |
713 | 746 | ||
714 | 747 | ||
715 | - | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)] | |
748 | + | 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)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)] | |
716 | 749 | ||
717 | 750 | ||
718 | 751 | func withdraw (_address,_amount) = { | |
719 | 752 | let balance = assetBalance(this, quoteAsset()) | |
720 | 753 | if ((_amount > balance)) | |
721 | 754 | then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance))) | |
722 | 755 | else [ScriptTransfer(_address, _amount, quoteAsset())] | |
723 | 756 | } | |
724 | 757 | ||
725 | 758 | ||
726 | 759 | func updateBalance (i) = if ((0 > i)) | |
727 | 760 | then throw("Balance") | |
728 | 761 | else [IntegerEntry(k_balance, i)] | |
729 | 762 | ||
730 | 763 | ||
731 | 764 | func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())] | |
732 | 765 | ||
733 | 766 | ||
734 | 767 | func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact) | |
735 | 768 | then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)] | |
736 | 769 | else nil | |
770 | + | ||
771 | + | ||
772 | + | func isSameAssetOrNoPosition (_trader,_assetId) = { | |
773 | + | let oldPositionSize = getPosition(_trader)._1 | |
774 | + | if ((oldPositionSize == 0)) | |
775 | + | then true | |
776 | + | else (getPositionAsset(_trader) == _assetId) | |
777 | + | } | |
778 | + | ||
779 | + | ||
780 | + | func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId) | |
781 | + | ||
782 | + | ||
783 | + | func getBorrowedByTraderInMarketKey (_amm,_assetId,_trader) = ((((((k_trader_market_asset_collateral + "_") + _amm) + "_") + _assetId) + "_") + _trader) | |
784 | + | ||
785 | + | ||
786 | + | func getBorrowedByTrader (_trader) = { | |
787 | + | let positionAsset = getPositionAsset(_trader) | |
788 | + | if ((positionAsset == toBase58String(quoteAsset()))) | |
789 | + | then $Tuple2(0, positionAsset) | |
790 | + | else { | |
791 | + | let key = getBorrowedByTraderInMarketKey(toString(this), positionAsset, _trader) | |
792 | + | let borrow = valueOrElse(getInteger(collateralAddress(), key), 0) | |
793 | + | $Tuple2(borrow, positionAsset) | |
794 | + | } | |
795 | + | } | |
737 | 796 | ||
738 | 797 | ||
739 | 798 | @Callable(i) | |
740 | 799 | func pause () = if ((i.caller != adminAddress())) | |
741 | 800 | then throw("Invalid togglePause params") | |
742 | 801 | else [BooleanEntry(k_paused, true)] | |
743 | 802 | ||
744 | 803 | ||
745 | 804 | ||
746 | 805 | @Callable(i) | |
747 | 806 | func unpause () = if ((i.caller != adminAddress())) | |
748 | 807 | then throw("Invalid togglePause params") | |
749 | 808 | else [BooleanEntry(k_paused, false)] | |
750 | 809 | ||
751 | 810 | ||
752 | 811 | ||
753 | 812 | @Callable(i) | |
754 | 813 | func addLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress())) | |
755 | 814 | then true | |
756 | 815 | else (0 >= _quoteAssetAmount)) | |
757 | 816 | then throw("Invalid addLiquidity params") | |
758 | 817 | else { | |
759 | 818 | let _qtAstR = qtAstR() | |
760 | 819 | let _bsAstR = bsAstR() | |
761 | 820 | let price = divd(_qtAstR, _bsAstR) | |
762 | 821 | let baseAssetAmountToAdd = divd(_quoteAssetAmount, price) | |
763 | 822 | let qtAstRAfter = (_qtAstR + _quoteAssetAmount) | |
764 | 823 | let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd) | |
765 | 824 | updateAmmReserves(qtAstRAfter, bsAstRAfter) | |
766 | 825 | } | |
767 | 826 | ||
768 | 827 | ||
769 | 828 | ||
770 | 829 | @Callable(i) | |
771 | 830 | func removeLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress())) | |
772 | 831 | then true | |
773 | 832 | else (0 >= _quoteAssetAmount)) | |
774 | 833 | then throw("Invalid removeLiquidity params") | |
775 | 834 | else { | |
776 | 835 | let _qtAstR = qtAstR() | |
777 | 836 | let _bsAstR = bsAstR() | |
778 | 837 | let price = divd(_qtAstR, _bsAstR) | |
779 | 838 | let baseAssetAmountToRemove = divd(_quoteAssetAmount, price) | |
780 | 839 | let qtAstRAfter = (_qtAstR - _quoteAssetAmount) | |
781 | 840 | let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove) | |
782 | 841 | updateAmmReserves(qtAstRAfter, bsAstRAfter) | |
783 | 842 | } | |
784 | 843 | ||
785 | 844 | ||
786 | 845 | ||
787 | 846 | @Callable(i) | |
788 | 847 | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress())) | |
789 | 848 | then throw("Invalid changeSettings params") | |
790 | 849 | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread) | |
791 | 850 | ||
792 | 851 | ||
793 | 852 | ||
794 | 853 | @Callable(i) | |
795 | 854 | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
796 | 855 | then true | |
797 | 856 | else (0 >= _bsAstR)) | |
798 | 857 | then true | |
799 | 858 | else (0 >= _fundingPeriod)) | |
800 | 859 | then true | |
801 | 860 | else (0 >= _initMarginRatio)) | |
802 | 861 | then true | |
803 | 862 | else (0 >= _mmr)) | |
804 | 863 | then true | |
805 | 864 | else (0 >= _liquidationFeeRatio)) | |
806 | 865 | then true | |
807 | 866 | else (0 >= _fee)) | |
808 | 867 | then true | |
809 | 868 | else (0 >= _spreadLimit)) | |
810 | 869 | then true | |
811 | 870 | else (0 >= _maxPriceImpact)) | |
812 | 871 | then true | |
813 | 872 | else (0 >= _partialLiquidationRatio)) | |
814 | 873 | then true | |
815 | 874 | else (0 >= _maxPriceSpread)) | |
816 | 875 | then true | |
817 | 876 | else initialized()) | |
818 | 877 | then throw("Invalid initialize parameters") | |
819 | 878 | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)) ++ 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)]) | |
820 | 879 | ||
821 | 880 | ||
822 | 881 | ||
823 | 882 | @Callable(i) | |
824 | 883 | func setInitMarginRatio (_initMarginRatio) = if (if ((0 >= _initMarginRatio)) | |
825 | 884 | then true | |
826 | 885 | else !(initialized())) | |
827 | 886 | then throw("Invalid setInitMarginRatio parameters") | |
828 | 887 | else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread()) | |
829 | 888 | ||
830 | 889 | ||
831 | 890 | ||
832 | 891 | @Callable(i) | |
833 | 892 | func decreasePosition (_amount,_leverage,_minBaseAssetAmount) = if (if (if (if (if ((0 >= _amount)) | |
834 | 893 | then true | |
835 | 894 | else !(initialized())) | |
836 | 895 | then true | |
837 | 896 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
838 | 897 | then true | |
839 | 898 | else !(requireOpenPosition(toString(i.caller)))) | |
840 | 899 | then true | |
841 | 900 | else paused()) | |
842 | 901 | then throw("Invalid decreasePosition parameters") | |
843 | 902 | else { | |
844 | - | let $ | |
845 | - | let oldPositionSize = $ | |
846 | - | let oldPositionMargin = $ | |
847 | - | let oldPositionOpenNotional = $ | |
848 | - | let oldPositionLstUpdCPF = $ | |
903 | + | let $t04149241644 = getPosition(toString(i.caller)) | |
904 | + | let oldPositionSize = $t04149241644._1 | |
905 | + | let oldPositionMargin = $t04149241644._2 | |
906 | + | let oldPositionOpenNotional = $t04149241644._3 | |
907 | + | let oldPositionLstUpdCPF = $t04149241644._4 | |
849 | 908 | let _direction = if ((oldPositionSize > 0)) | |
850 | 909 | then DIR_SHORT | |
851 | 910 | else DIR_LONG | |
852 | 911 | let isAdd = (_direction == DIR_LONG) | |
853 | 912 | let openNotional = muld(_amount, _leverage) | |
854 | - | let $ | |
855 | - | let oldPositionNotional = $ | |
856 | - | let unrealizedPnl = $ | |
857 | - | let $ | |
913 | + | let $t04181741933 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
914 | + | let oldPositionNotional = $t04181741933._1 | |
915 | + | let unrealizedPnl = $t04181741933._2 | |
916 | + | let $t04193944488 = if ((oldPositionNotional > openNotional)) | |
858 | 917 | then { | |
859 | - | let $ | |
860 | - | let exchangedPositionSize = $ | |
861 | - | let quoteAssetReserveAfter = $ | |
862 | - | let baseAssetReserveAfter = $ | |
863 | - | let totalPositionSizeAfter = $ | |
864 | - | let cumulativeNotionalAfter = $ | |
918 | + | let $t04231642535 = swapInput(isAdd, openNotional) | |
919 | + | let exchangedPositionSize = $t04231642535._1 | |
920 | + | let quoteAssetReserveAfter = $t04231642535._2 | |
921 | + | let baseAssetReserveAfter = $t04231642535._3 | |
922 | + | let totalPositionSizeAfter = $t04231642535._4 | |
923 | + | let cumulativeNotionalAfter = $t04231642535._5 | |
865 | 924 | let exchangedPositionSizeAbs = abs(exchangedPositionSize) | |
866 | 925 | if (if ((_minBaseAssetAmount != 0)) | |
867 | 926 | then (_minBaseAssetAmount > exchangedPositionSizeAbs) | |
868 | 927 | else false) | |
869 | 928 | then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount))) | |
870 | 929 | else { | |
871 | 930 | let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize)) | |
872 | - | let $ | |
873 | - | let remainMargin = $ | |
874 | - | let badDebt = $ | |
875 | - | let fundingPayment = $ | |
931 | + | let $t04297243217 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
932 | + | let remainMargin = $t04297243217._1 | |
933 | + | let badDebt = $t04297243217._2 | |
934 | + | let fundingPayment = $t04297243217._3 | |
876 | 935 | let exchangedQuoteAssetAmount = openNotional | |
877 | 936 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
878 | 937 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
879 | 938 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
880 | 939 | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
881 | 940 | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
882 | 941 | $Tuple11(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
883 | 942 | then abs(exchangedPositionSize) | |
884 | 943 | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
885 | 944 | then abs(exchangedPositionSize) | |
886 | 945 | else 0))) | |
887 | 946 | } | |
888 | 947 | } | |
889 | 948 | else throw("Close position first") | |
890 | - | let newPositionSize = $ | |
891 | - | let newPositionRemainMargin = $ | |
892 | - | let newPositionOpenNotional = $ | |
893 | - | let newPositionLatestCPF = $ | |
894 | - | let baseAssetReserveAfter = $ | |
895 | - | let quoteAssetReserveAfter = $ | |
896 | - | let totalPositionSizeAfter = $ | |
897 | - | let cumulativeNotionalAfter = $ | |
898 | - | let openInterestNotionalAfter = $ | |
899 | - | let totalLongAfter = $ | |
900 | - | let totalShortAfter = $ | |
949 | + | let newPositionSize = $t04193944488._1 | |
950 | + | let newPositionRemainMargin = $t04193944488._2 | |
951 | + | let newPositionOpenNotional = $t04193944488._3 | |
952 | + | let newPositionLatestCPF = $t04193944488._4 | |
953 | + | let baseAssetReserveAfter = $t04193944488._5 | |
954 | + | let quoteAssetReserveAfter = $t04193944488._6 | |
955 | + | let totalPositionSizeAfter = $t04193944488._7 | |
956 | + | let cumulativeNotionalAfter = $t04193944488._8 | |
957 | + | let openInterestNotionalAfter = $t04193944488._9 | |
958 | + | let totalLongAfter = $t04193944488._10 | |
959 | + | let totalShortAfter = $t04193944488._11 | |
901 | 960 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
902 | 961 | if ((notifyNotional == notifyNotional)) | |
903 | 962 | then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
904 | 963 | else throw("Strict value is not equal to itself.") | |
905 | 964 | } | |
906 | 965 | ||
907 | 966 | ||
908 | 967 | ||
909 | 968 | @Callable(i) | |
910 | 969 | func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = { | |
970 | + | let _trader = toString(i.caller) | |
911 | 971 | let _rawAmount = i.payments[0].amount | |
912 | - | if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
972 | + | let _assetId = i.payments[0].assetId | |
973 | + | let _assetIdStr = toBase58String(value(_assetId)) | |
974 | + | let isQuoteAsset = (_assetId == quoteAsset()) | |
975 | + | let isCollateralAsset = isWhitelistAsset(_assetIdStr) | |
976 | + | if (if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
913 | 977 | then (_direction != DIR_SHORT) | |
914 | 978 | else false) | |
915 | 979 | then true | |
916 | 980 | else (0 >= _rawAmount)) | |
917 | 981 | then true | |
918 | 982 | else !(initialized())) | |
919 | 983 | then true | |
920 | - | else (i.payments[0].assetId != quoteAsset())) | |
984 | + | else if (!(isQuoteAsset)) | |
985 | + | then !(isCollateralAsset) | |
986 | + | else false) | |
987 | + | then true | |
988 | + | else !(isSameAssetOrNoPosition(_trader, _assetIdStr))) | |
921 | 989 | then true | |
922 | 990 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
923 | 991 | then true | |
924 | 992 | else paused()) | |
925 | 993 | then throw("Invalid increasePosition parameters") | |
926 | 994 | else { | |
927 | - | let _trader = toString(i.caller) | |
928 | 995 | let baseFee = fee() | |
929 | - | let $ | |
930 | - | let adjustedFee = $ | |
931 | - | let burnArtifact = $ | |
996 | + | let $t04585045901 = getAdjustedFee(i) | |
997 | + | let adjustedFee = $t04585045901._1 | |
998 | + | let burnArtifact = $t04585045901._2 | |
932 | 999 | let rawFeeAmount = muld(_rawAmount, adjustedFee) | |
933 | - | let | |
934 | - | if ( | |
1000 | + | let _amount = (_rawAmount - rawFeeAmount) | |
1001 | + | let distributeFeeAmount = if (isCollateralAsset) | |
935 | 1002 | then { | |
936 | - | let referrerFee = match referrerFeeAny { | |
937 | - | case x: Int => | |
938 | - | x | |
939 | - | case _ => | |
940 | - | throw("Invalid referrerFee") | |
1003 | + | let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)]) | |
1004 | + | if ((doBorrow == doBorrow)) | |
1005 | + | then { | |
1006 | + | let balanceBefore = assetBalance(this, quoteAsset()) | |
1007 | + | if ((balanceBefore == balanceBefore)) | |
1008 | + | then { | |
1009 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)]) | |
1010 | + | if ((doSwap == doSwap)) | |
1011 | + | then { | |
1012 | + | let balanceAfter = assetBalance(this, quoteAsset()) | |
1013 | + | if ((balanceAfter == balanceAfter)) | |
1014 | + | then { | |
1015 | + | let exchangedAmount = (balanceAfter - balanceBefore) | |
1016 | + | if ((exchangedAmount == exchangedAmount)) | |
1017 | + | then exchangedAmount | |
1018 | + | else throw("Strict value is not equal to itself.") | |
1019 | + | } | |
1020 | + | else throw("Strict value is not equal to itself.") | |
1021 | + | } | |
1022 | + | else throw("Strict value is not equal to itself.") | |
1023 | + | } | |
1024 | + | else throw("Strict value is not equal to itself.") | |
1025 | + | } | |
1026 | + | else throw("Strict value is not equal to itself.") | |
941 | 1027 | } | |
942 | - | let _amount = (_rawAmount - rawFeeAmount) | |
943 | - | let feeAmount = (rawFeeAmount - referrerFee) | |
944 | - | let $t04369643836 = getPosition(_trader) | |
945 | - | let oldPositionSize = $t04369643836._1 | |
946 | - | let oldPositionMargin = $t04369643836._2 | |
947 | - | let oldPositionOpenNotional = $t04369643836._3 | |
948 | - | let oldPositionLstUpdCPF = $t04369643836._4 | |
949 | - | let isNewPosition = (oldPositionSize == 0) | |
950 | - | let isSameDirection = if ((oldPositionSize > 0)) | |
951 | - | then (_direction == DIR_LONG) | |
952 | - | else (_direction == DIR_SHORT) | |
953 | - | let expandExisting = if (!(isNewPosition)) | |
954 | - | then isSameDirection | |
955 | - | else false | |
956 | - | let isAdd = (_direction == DIR_LONG) | |
957 | - | let $t04412546710 = if (if (isNewPosition) | |
958 | - | then true | |
959 | - | else expandExisting) | |
1028 | + | else rawFeeAmount | |
1029 | + | if ((distributeFeeAmount == distributeFeeAmount)) | |
1030 | + | then { | |
1031 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1032 | + | if ((referrerFeeAny == referrerFeeAny)) | |
960 | 1033 | then { | |
961 | - | let openNotional = muld(_amount, _leverage) | |
962 | - | let $t04454944755 = swapInput(isAdd, openNotional) | |
963 | - | let amountBaseAssetBought = $t04454944755._1 | |
964 | - | let quoteAssetReserveAfter = $t04454944755._2 | |
965 | - | let baseAssetReserveAfter = $t04454944755._3 | |
966 | - | let totalPositionSizeAfter = $t04454944755._4 | |
967 | - | let cumulativeNotionalAfter = $t04454944755._5 | |
968 | - | if (if ((_minBaseAssetAmount != 0)) | |
969 | - | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
970 | - | else false) | |
971 | - | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1034 | + | let referrerFee = match referrerFeeAny { | |
1035 | + | case x: Int => | |
1036 | + | x | |
1037 | + | case _ => | |
1038 | + | throw("Invalid referrerFee") | |
1039 | + | } | |
1040 | + | let feeAmount = (distributeFeeAmount - referrerFee) | |
1041 | + | let $t04721747357 = getPosition(_trader) | |
1042 | + | let oldPositionSize = $t04721747357._1 | |
1043 | + | let oldPositionMargin = $t04721747357._2 | |
1044 | + | let oldPositionOpenNotional = $t04721747357._3 | |
1045 | + | let oldPositionLstUpdCPF = $t04721747357._4 | |
1046 | + | let isNewPosition = (oldPositionSize == 0) | |
1047 | + | let isSameDirection = if ((oldPositionSize > 0)) | |
1048 | + | then (_direction == DIR_LONG) | |
1049 | + | else (_direction == DIR_SHORT) | |
1050 | + | let expandExisting = if (!(isNewPosition)) | |
1051 | + | then isSameDirection | |
1052 | + | else false | |
1053 | + | let isAdd = (_direction == DIR_LONG) | |
1054 | + | let $t04764650231 = if (if (isNewPosition) | |
1055 | + | then true | |
1056 | + | else expandExisting) | |
1057 | + | then { | |
1058 | + | let openNotional = muld(_amount, _leverage) | |
1059 | + | let $t04807048276 = swapInput(isAdd, openNotional) | |
1060 | + | let amountBaseAssetBought = $t04807048276._1 | |
1061 | + | let quoteAssetReserveAfter = $t04807048276._2 | |
1062 | + | let baseAssetReserveAfter = $t04807048276._3 | |
1063 | + | let totalPositionSizeAfter = $t04807048276._4 | |
1064 | + | let cumulativeNotionalAfter = $t04807048276._5 | |
1065 | + | if (if ((_minBaseAssetAmount != 0)) | |
1066 | + | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
1067 | + | else false) | |
1068 | + | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1069 | + | else { | |
1070 | + | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
1071 | + | let increaseMarginRequirement = divd(openNotional, _leverage) | |
1072 | + | let $t04865748896 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
1073 | + | let remainMargin = $t04865748896._1 | |
1074 | + | let x1 = $t04865748896._2 | |
1075 | + | let x2 = $t04865748896._3 | |
1076 | + | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
1077 | + | then throw("Over max spread limit") | |
1078 | + | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
1079 | + | then abs(amountBaseAssetBought) | |
1080 | + | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
1081 | + | then abs(amountBaseAssetBought) | |
1082 | + | else 0))) | |
1083 | + | } | |
1084 | + | } | |
972 | 1085 | else { | |
973 | - | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
974 | - | let increaseMarginRequirement = divd(openNotional, _leverage) | |
975 | - | let $t04513645375 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
976 | - | let remainMargin = $t04513645375._1 | |
977 | - | let x1 = $t04513645375._2 | |
978 | - | let x2 = $t04513645375._3 | |
979 | - | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
980 | - | then throw("Over max spread limit") | |
981 | - | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
982 | - | then abs(amountBaseAssetBought) | |
983 | - | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
984 | - | then abs(amountBaseAssetBought) | |
985 | - | else 0))) | |
1086 | + | let openNotional = muld(_amount, _leverage) | |
1087 | + | let $t04992450040 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
1088 | + | let oldPositionNotional = $t04992450040._1 | |
1089 | + | let unrealizedPnl = $t04992450040._2 | |
1090 | + | if ((oldPositionNotional > openNotional)) | |
1091 | + | then throw("Use decreasePosition to decrease position size") | |
1092 | + | else throw("Close position first") | |
986 | 1093 | } | |
987 | - | } | |
988 | - | else { | |
989 | - | let openNotional = muld(_amount, _leverage) | |
990 | - | let $t04640346519 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
991 | - | let oldPositionNotional = $t04640346519._1 | |
992 | - | let unrealizedPnl = $t04640346519._2 | |
993 | - | if ((oldPositionNotional > openNotional)) | |
994 | - | then throw("Use decreasePosition to decrease position size") | |
995 | - | else throw("Close position first") | |
996 | - | } | |
997 | - | let newPositionSize = $t04412546710._1 | |
998 | - | let newPositionRemainMargin = $t04412546710._2 | |
999 | - | let newPositionOpenNotional = $t04412546710._3 | |
1000 | - | let newPositionLatestCPF = $t04412546710._4 | |
1001 | - | let baseAssetReserveAfter = $t04412546710._5 | |
1002 | - | let quoteAssetReserveAfter = $t04412546710._6 | |
1003 | - | let totalPositionSizeAfter = $t04412546710._7 | |
1004 | - | let cumulativeNotionalAfter = $t04412546710._8 | |
1005 | - | let openInterestNotionalAfter = $t04412546710._9 | |
1006 | - | let totalLongAfter = $t04412546710._10 | |
1007 | - | let totalShortAfter = $t04412546710._11 | |
1008 | - | let feeToStakers = (feeAmount / 2) | |
1009 | - | let feeToInsurance = (feeAmount - feeToStakers) | |
1010 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1011 | - | if ((stake == stake)) | |
1012 | - | then { | |
1013 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1014 | - | if ((depositInsurance == depositInsurance)) | |
1094 | + | let newPositionSize = $t04764650231._1 | |
1095 | + | let newPositionRemainMargin = $t04764650231._2 | |
1096 | + | let newPositionOpenNotional = $t04764650231._3 | |
1097 | + | let newPositionLatestCPF = $t04764650231._4 | |
1098 | + | let baseAssetReserveAfter = $t04764650231._5 | |
1099 | + | let quoteAssetReserveAfter = $t04764650231._6 | |
1100 | + | let totalPositionSizeAfter = $t04764650231._7 | |
1101 | + | let cumulativeNotionalAfter = $t04764650231._8 | |
1102 | + | let openInterestNotionalAfter = $t04764650231._9 | |
1103 | + | let totalLongAfter = $t04764650231._10 | |
1104 | + | let totalShortAfter = $t04764650231._11 | |
1105 | + | let feeToStakers = (feeAmount / 2) | |
1106 | + | let feeToInsurance = (feeAmount - feeToStakers) | |
1107 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1108 | + | if ((stake == stake)) | |
1015 | 1109 | then { | |
1016 | - | let | |
1017 | - | if (( | |
1110 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1111 | + | if ((depositInsurance == depositInsurance)) | |
1018 | 1112 | then { | |
1019 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1020 | - | if ((notifyNotional == notifyNotional)) | |
1021 | - | then ((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1113 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1114 | + | if ((notifyFee == notifyFee)) | |
1115 | + | then { | |
1116 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1117 | + | if ((notifyNotional == notifyNotional)) | |
1118 | + | then (((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1119 | + | else throw("Strict value is not equal to itself.") | |
1120 | + | } | |
1022 | 1121 | else throw("Strict value is not equal to itself.") | |
1023 | 1122 | } | |
1024 | 1123 | else throw("Strict value is not equal to itself.") | |
1025 | 1124 | } | |
1026 | 1125 | else throw("Strict value is not equal to itself.") | |
1027 | 1126 | } | |
1028 | 1127 | else throw("Strict value is not equal to itself.") | |
1029 | 1128 | } | |
1030 | 1129 | else throw("Strict value is not equal to itself.") | |
1031 | 1130 | } | |
1032 | 1131 | } | |
1033 | 1132 | ||
1034 | 1133 | ||
1035 | 1134 | ||
1036 | 1135 | @Callable(i) | |
1037 | 1136 | func addMargin () = { | |
1137 | + | let _trader = toString(i.caller) | |
1038 | 1138 | let _rawAmount = i.payments[0].amount | |
1039 | - | if (if (if (if ((i.payments[0].assetId != quoteAsset())) | |
1139 | + | let _assetId = i.payments[0].assetId | |
1140 | + | let _assetIdStr = toBase58String(value(_assetId)) | |
1141 | + | let isQuoteAsset = (_assetId == quoteAsset()) | |
1142 | + | let isCollateralAsset = isWhitelistAsset(_assetIdStr) | |
1143 | + | if (if (if (if (if (if (!(isQuoteAsset)) | |
1144 | + | then !(isCollateralAsset) | |
1145 | + | else false) | |
1040 | 1146 | then true | |
1041 | 1147 | else !(requireOpenPosition(toString(i.caller)))) | |
1148 | + | then true | |
1149 | + | else !(isSameAsset(_trader, _assetIdStr))) | |
1042 | 1150 | then true | |
1043 | 1151 | else !(initialized())) | |
1044 | 1152 | then true | |
1045 | 1153 | else paused()) | |
1046 | 1154 | then throw("Invalid addMargin parameters") | |
1047 | 1155 | else { | |
1048 | - | let _trader = toString(i.caller) | |
1049 | - | let $t04817848229 = getAdjustedFee(i) | |
1050 | - | let adjustedFee = $t04817848229._1 | |
1051 | - | let burnArtifact = $t04817848229._2 | |
1156 | + | let $t05198752038 = getAdjustedFee(i) | |
1157 | + | let adjustedFee = $t05198752038._1 | |
1158 | + | let burnArtifact = $t05198752038._2 | |
1052 | 1159 | let rawFeeAmount = muld(_rawAmount, adjustedFee) | |
1053 | - | let | |
1054 | - | if ( | |
1160 | + | let _amount = (_rawAmount - rawFeeAmount) | |
1161 | + | let distributeFeeAmount = if (isCollateralAsset) | |
1055 | 1162 | then { | |
1056 | - | let referrerFee = match referrerFeeAny { | |
1057 | - | case x: Int => | |
1058 | - | x | |
1059 | - | case _ => | |
1060 | - | throw("Invalid referrerFee") | |
1163 | + | let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)]) | |
1164 | + | if ((doBorrow == doBorrow)) | |
1165 | + | then { | |
1166 | + | let balanceBefore = assetBalance(this, quoteAsset()) | |
1167 | + | if ((balanceBefore == balanceBefore)) | |
1168 | + | then { | |
1169 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)]) | |
1170 | + | if ((doSwap == doSwap)) | |
1171 | + | then { | |
1172 | + | let balanceAfter = assetBalance(this, quoteAsset()) | |
1173 | + | if ((balanceAfter == balanceAfter)) | |
1174 | + | then { | |
1175 | + | let exchangedAmount = (balanceAfter - balanceBefore) | |
1176 | + | if ((exchangedAmount == exchangedAmount)) | |
1177 | + | then exchangedAmount | |
1178 | + | else throw("Strict value is not equal to itself.") | |
1179 | + | } | |
1180 | + | else throw("Strict value is not equal to itself.") | |
1181 | + | } | |
1182 | + | else throw("Strict value is not equal to itself.") | |
1183 | + | } | |
1184 | + | else throw("Strict value is not equal to itself.") | |
1185 | + | } | |
1186 | + | else throw("Strict value is not equal to itself.") | |
1061 | 1187 | } | |
1062 | - | let feeAmount = (rawFeeAmount - referrerFee) | |
1063 | - | let _amount = (_rawAmount - rawFeeAmount) | |
1064 | - | let $t04866148801 = getPosition(_trader) | |
1065 | - | let oldPositionSize = $t04866148801._1 | |
1066 | - | let oldPositionMargin = $t04866148801._2 | |
1067 | - | let oldPositionOpenNotional = $t04866148801._3 | |
1068 | - | let oldPositionLstUpdCPF = $t04866148801._4 | |
1069 | - | let feeToStakers = (feeAmount / 2) | |
1070 | - | let feeToInsurance = (feeAmount - feeToStakers) | |
1071 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1072 | - | if ((stake == stake)) | |
1188 | + | else rawFeeAmount | |
1189 | + | if ((distributeFeeAmount == distributeFeeAmount)) | |
1190 | + | then { | |
1191 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1192 | + | if ((referrerFeeAny == referrerFeeAny)) | |
1073 | 1193 | then { | |
1074 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1075 | - | if ((depositInsurance == depositInsurance)) | |
1194 | + | let referrerFee = match referrerFeeAny { | |
1195 | + | case x: Int => | |
1196 | + | x | |
1197 | + | case _ => | |
1198 | + | throw("Invalid referrerFee") | |
1199 | + | } | |
1200 | + | let feeAmount = (distributeFeeAmount - referrerFee) | |
1201 | + | let $t05333753477 = getPosition(_trader) | |
1202 | + | let oldPositionSize = $t05333753477._1 | |
1203 | + | let oldPositionMargin = $t05333753477._2 | |
1204 | + | let oldPositionOpenNotional = $t05333753477._3 | |
1205 | + | let oldPositionLstUpdCPF = $t05333753477._4 | |
1206 | + | let feeToStakers = (feeAmount / 2) | |
1207 | + | let feeToInsurance = (feeAmount - feeToStakers) | |
1208 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1209 | + | if ((stake == stake)) | |
1076 | 1210 | then { | |
1077 | - | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1078 | - | if ((notifyFee == notifyFee)) | |
1079 | - | then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1211 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1212 | + | if ((depositInsurance == depositInsurance)) | |
1213 | + | then { | |
1214 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1215 | + | if ((notifyFee == notifyFee)) | |
1216 | + | then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1217 | + | else throw("Strict value is not equal to itself.") | |
1218 | + | } | |
1080 | 1219 | else throw("Strict value is not equal to itself.") | |
1081 | 1220 | } | |
1082 | 1221 | else throw("Strict value is not equal to itself.") | |
1083 | 1222 | } | |
1084 | 1223 | else throw("Strict value is not equal to itself.") | |
1085 | 1224 | } | |
1086 | 1225 | else throw("Strict value is not equal to itself.") | |
1087 | 1226 | } | |
1088 | 1227 | } | |
1089 | 1228 | ||
1090 | 1229 | ||
1091 | 1230 | ||
1092 | 1231 | @Callable(i) | |
1093 | - | func removeMargin (_amount) = if (if (if (if ((0 >= _amount)) | |
1094 | - | then true | |
1095 | - | else !(requireOpenPosition(toString(i.caller)))) | |
1096 | - | then true | |
1097 | - | else !(initialized())) | |
1098 | - | then true | |
1099 | - | else paused()) | |
1100 | - | then throw("Invalid removeMargin parameters") | |
1101 | - | else { | |
1102 | - | let $t04982049972 = getPosition(toString(i.caller)) | |
1103 | - | let oldPositionSize = $t04982049972._1 | |
1104 | - | let oldPositionMargin = $t04982049972._2 | |
1105 | - | let oldPositionOpenNotional = $t04982049972._3 | |
1106 | - | let oldPositionLstUpdCPF = $t04982049972._4 | |
1107 | - | let marginDelta = -(_amount) | |
1108 | - | let $t05000950188 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
1109 | - | let remainMargin = $t05000950188._1 | |
1110 | - | let badDebt = $t05000950188._2 | |
1111 | - | if ((badDebt != 0)) | |
1112 | - | then throw("Invalid removed margin amount") | |
1113 | - | else { | |
1114 | - | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1115 | - | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1116 | - | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1117 | - | else { | |
1118 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil) | |
1119 | - | if ((unstake == unstake)) | |
1120 | - | then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount))) | |
1121 | - | else throw("Strict value is not equal to itself.") | |
1122 | - | } | |
1123 | - | } | |
1124 | - | } | |
1232 | + | func removeMargin (_amount) = { | |
1233 | + | let _trader = toString(i.caller) | |
1234 | + | if (if (if (if ((0 >= _amount)) | |
1235 | + | then true | |
1236 | + | else !(requireOpenPosition(_trader))) | |
1237 | + | then true | |
1238 | + | else !(initialized())) | |
1239 | + | then true | |
1240 | + | else paused()) | |
1241 | + | then throw("Invalid removeMargin parameters") | |
1242 | + | else { | |
1243 | + | let $t05452054660 = getPosition(_trader) | |
1244 | + | let oldPositionSize = $t05452054660._1 | |
1245 | + | let oldPositionMargin = $t05452054660._2 | |
1246 | + | let oldPositionOpenNotional = $t05452054660._3 | |
1247 | + | let oldPositionLstUpdCPF = $t05452054660._4 | |
1248 | + | let marginDelta = -(_amount) | |
1249 | + | let $t05469754876 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
1250 | + | let remainMargin = $t05469754876._1 | |
1251 | + | let badDebt = $t05469754876._2 | |
1252 | + | if ((badDebt != 0)) | |
1253 | + | then throw("Invalid removed margin amount") | |
1254 | + | else { | |
1255 | + | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1256 | + | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1257 | + | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1258 | + | else { | |
1259 | + | let quoteAssetStr = toBase58String(quoteAsset()) | |
1260 | + | let $t05532055374 = getBorrowedByTrader(_trader) | |
1261 | + | let borrowed = $t05532055374._1 | |
1262 | + | let assetId = $t05532055374._2 | |
1263 | + | let toRepay = if ((_amount > borrowed)) | |
1264 | + | then borrowed | |
1265 | + | else _amount | |
1266 | + | let toWithdraw = if ((borrowed > _amount)) | |
1267 | + | then 0 | |
1268 | + | else (_amount - borrowed) | |
1269 | + | let finalBorrow = (borrowed - toRepay) | |
1270 | + | let switchPositionToQuote = if ((finalBorrow > 0)) | |
1271 | + | then nil | |
1272 | + | else updatePositionAsset(_trader, quoteAssetStr) | |
1273 | + | let doSanityCheck = if (((toRepay + toWithdraw) != _amount)) | |
1274 | + | then throw(((((("toRepay=" + toString(toRepay)) + " + toWithdraw=") + toString(toWithdraw)) + " != ") + toString(_amount))) | |
1275 | + | else nil | |
1276 | + | if ((doSanityCheck == doSanityCheck)) | |
1277 | + | then { | |
1278 | + | let doUnstake = invoke(managerAddress(), "withdraw", [quoteAssetStr, _amount], nil) | |
1279 | + | if ((doUnstake == doUnstake)) | |
1280 | + | then { | |
1281 | + | let returnCollateralAction = if ((toRepay > 0)) | |
1282 | + | then { | |
1283 | + | let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), toRepay)]) | |
1284 | + | if ((doRepay == doRepay)) | |
1285 | + | then [ScriptTransfer(i.caller, toRepay, fromBase58String(assetId))] | |
1286 | + | else throw("Strict value is not equal to itself.") | |
1287 | + | } | |
1288 | + | else nil | |
1289 | + | if ((returnCollateralAction == returnCollateralAction)) | |
1290 | + | then (updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ (if ((toWithdraw > 0)) | |
1291 | + | then withdraw(i.caller, toWithdraw) | |
1292 | + | else (((nil ++ updateBalance((cbalance() - _amount))) ++ switchPositionToQuote) ++ returnCollateralAction))) | |
1293 | + | else throw("Strict value is not equal to itself.") | |
1294 | + | } | |
1295 | + | else throw("Strict value is not equal to itself.") | |
1296 | + | } | |
1297 | + | else throw("Strict value is not equal to itself.") | |
1298 | + | } | |
1299 | + | } | |
1300 | + | } | |
1301 | + | } | |
1125 | 1302 | ||
1126 | 1303 | ||
1127 | 1304 | ||
1128 | 1305 | @Callable(i) | |
1129 | 1306 | func closePosition () = { | |
1130 | - | let | |
1131 | - | let | |
1132 | - | if (if (if (!(requireOpenPosition( | |
1307 | + | let _trader = getActualCaller(i) | |
1308 | + | let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller") | |
1309 | + | if (if (if (!(requireOpenPosition(_trader))) | |
1133 | 1310 | then true | |
1134 | 1311 | else !(initialized())) | |
1135 | 1312 | then true | |
1136 | 1313 | else paused()) | |
1137 | 1314 | then throw("Invalid closePosition parameters") | |
1138 | 1315 | else { | |
1139 | - | let $ | |
1140 | - | let x1 = $ | |
1141 | - | let positionBadDebt = $ | |
1142 | - | let realizedPnl = $ | |
1143 | - | let marginToVault = $ | |
1144 | - | let quoteAssetReserveAfter = $ | |
1145 | - | let baseAssetReserveAfter = $ | |
1146 | - | let totalPositionSizeAfter = $ | |
1147 | - | let cumulativeNotionalAfter = $ | |
1148 | - | let openInterestNotionalAfter = $ | |
1149 | - | let x2 = $ | |
1150 | - | let totalLongAfter = $ | |
1151 | - | let totalShortAfter = $ | |
1316 | + | let $t05756657944 = internalClosePosition(_trader, true) | |
1317 | + | let x1 = $t05756657944._1 | |
1318 | + | let positionBadDebt = $t05756657944._2 | |
1319 | + | let realizedPnl = $t05756657944._3 | |
1320 | + | let marginToVault = $t05756657944._4 | |
1321 | + | let quoteAssetReserveAfter = $t05756657944._5 | |
1322 | + | let baseAssetReserveAfter = $t05756657944._6 | |
1323 | + | let totalPositionSizeAfter = $t05756657944._7 | |
1324 | + | let cumulativeNotionalAfter = $t05756657944._8 | |
1325 | + | let openInterestNotionalAfter = $t05756657944._9 | |
1326 | + | let x2 = $t05756657944._10 | |
1327 | + | let totalLongAfter = $t05756657944._11 | |
1328 | + | let totalShortAfter = $t05756657944._12 | |
1152 | 1329 | if ((positionBadDebt > 0)) | |
1153 | 1330 | then throw("Unable to close position with bad debt") | |
1154 | 1331 | else { | |
1155 | 1332 | let withdrawAmount = abs(marginToVault) | |
1156 | 1333 | let ammBalance = (cbalance() - withdrawAmount) | |
1157 | - | let $ | |
1334 | + | let $t05815358295 = if ((0 > ammBalance)) | |
1158 | 1335 | then $Tuple2(0, abs(ammBalance)) | |
1159 | 1336 | else $Tuple2(ammBalance, 0) | |
1160 | - | let ammNewBalance = $ | |
1161 | - | let getFromInsurance = $ | |
1337 | + | let ammNewBalance = $t05815358295._1 | |
1338 | + | let getFromInsurance = $t05815358295._2 | |
1162 | 1339 | let x = if ((getFromInsurance > 0)) | |
1163 | 1340 | then { | |
1164 | 1341 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil) | |
1165 | 1342 | if ((withdrawInsurance == withdrawInsurance)) | |
1166 | 1343 | then nil | |
1167 | 1344 | else throw("Strict value is not equal to itself.") | |
1168 | 1345 | } | |
1169 | 1346 | else nil | |
1170 | 1347 | if ((x == x)) | |
1171 | 1348 | then { | |
1172 | 1349 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (withdrawAmount - getFromInsurance)], nil) | |
1173 | 1350 | if ((unstake == unstake)) | |
1174 | 1351 | then { | |
1175 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [caller, 0], nil) | |
1176 | - | if ((notifyNotional == notifyNotional)) | |
1177 | - | then (((deletePosition(caller) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(callerAddress, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
1352 | + | let $t05879758851 = getBorrowedByTrader(_trader) | |
1353 | + | let borrowed = $t05879758851._1 | |
1354 | + | let assetId = $t05879758851._2 | |
1355 | + | let $t05886659783 = if ((borrowed > 0)) | |
1356 | + | then if ((withdrawAmount >= borrowed)) | |
1357 | + | then { | |
1358 | + | let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), borrowed)]) | |
1359 | + | if ((doRepay == doRepay)) | |
1360 | + | then $Tuple2([ScriptTransfer(_traderAddress, borrowed, fromBase58String(assetId))], (withdrawAmount - borrowed)) | |
1361 | + | else throw("Strict value is not equal to itself.") | |
1362 | + | } | |
1363 | + | else { | |
1364 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], [AttachedPayment(quoteAsset(), withdrawAmount)]) | |
1365 | + | if ((realizeAndClose == realizeAndClose)) | |
1366 | + | then $Tuple2([ScriptTransfer(_traderAddress, withdrawAmount, fromBase58String(assetId))], 0) | |
1367 | + | else throw("Strict value is not equal to itself.") | |
1368 | + | } | |
1369 | + | else $Tuple2(nil, withdrawAmount) | |
1370 | + | if (($t05886659783 == $t05886659783)) | |
1371 | + | then { | |
1372 | + | let quoteWithdrawAmount = $t05886659783._2 | |
1373 | + | let sendCollateralAction = $t05886659783._1 | |
1374 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1375 | + | if ((notifyNotional == notifyNotional)) | |
1376 | + | then ((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ (if ((quoteWithdrawAmount > 0)) | |
1377 | + | then withdraw(_traderAddress, quoteWithdrawAmount) | |
1378 | + | else ((nil ++ updateBalance(ammNewBalance)) ++ sendCollateralAction))) | |
1379 | + | else throw("Strict value is not equal to itself.") | |
1380 | + | } | |
1178 | 1381 | else throw("Strict value is not equal to itself.") | |
1179 | 1382 | } | |
1180 | 1383 | else throw("Strict value is not equal to itself.") | |
1181 | 1384 | } | |
1182 | 1385 | else throw("Strict value is not equal to itself.") | |
1183 | 1386 | } | |
1184 | 1387 | } | |
1185 | 1388 | } | |
1186 | 1389 | ||
1187 | 1390 | ||
1188 | 1391 | ||
1189 | 1392 | @Callable(i) | |
1190 | 1393 | func liquidate (_trader) = { | |
1191 | 1394 | let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
1192 | 1395 | let marginRatio = if (isOverFluctuationLimit()) | |
1193 | 1396 | then { | |
1194 | 1397 | let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE) | |
1195 | 1398 | vmax(spotMarginRatio, oracleMarginRatio) | |
1196 | 1399 | } | |
1197 | 1400 | else spotMarginRatio | |
1198 | 1401 | if (if (if (if (!(requireMoreMarginRatio(marginRatio, maintenanceMarginRatio(), false))) | |
1199 | 1402 | then true | |
1200 | 1403 | else !(requireOpenPosition(_trader))) | |
1201 | 1404 | then true | |
1202 | 1405 | else !(initialized())) | |
1203 | 1406 | then true | |
1204 | 1407 | else paused()) | |
1205 | 1408 | then throw("Unable to liquidate") | |
1206 | 1409 | else if (if (if ((spotMarginRatio > liquidationFeeRatio())) | |
1207 | 1410 | then (partialLiquidationRatio() > 0) | |
1208 | 1411 | else false) | |
1209 | 1412 | then (DECIMAL_UNIT > partialLiquidationRatio()) | |
1210 | 1413 | else false) | |
1211 | 1414 | then { | |
1212 | - | let $ | |
1213 | - | let oldPositionSize = $ | |
1214 | - | let oldPositionMargin = $ | |
1215 | - | let oldPositionOpenNotional = $ | |
1216 | - | let oldPositionLstUpdCPF = $ | |
1415 | + | let $t06148361633 = getPosition(_trader) | |
1416 | + | let oldPositionSize = $t06148361633._1 | |
1417 | + | let oldPositionMargin = $t06148361633._2 | |
1418 | + | let oldPositionOpenNotional = $t06148361633._3 | |
1419 | + | let oldPositionLstUpdCPF = $t06148361633._4 | |
1217 | 1420 | let _direction = if ((oldPositionSize > 0)) | |
1218 | 1421 | then DIR_SHORT | |
1219 | 1422 | else DIR_LONG | |
1220 | 1423 | let isAdd = (_direction == DIR_LONG) | |
1221 | 1424 | let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize) | |
1222 | - | let $t05455654660 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1223 | - | let oldPositionNotional = $t05455654660._1 | |
1224 | - | let unrealizedPnl = $t05455654660._2 | |
1225 | - | let $t05466854958 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1226 | - | let exchangedPositionSize = $t05466854958._1 | |
1227 | - | let quoteAssetReserveAfter = $t05466854958._2 | |
1228 | - | let baseAssetReserveAfter = $t05466854958._3 | |
1229 | - | let totalPositionSizeAfter = $t05466854958._4 | |
1230 | - | let cumulativeNotionalAfter = $t05466854958._5 | |
1231 | - | let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize)) | |
1232 | - | let $t05506555298 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1233 | - | let remainMargin = $t05506555298._1 | |
1234 | - | let badDebt = $t05506555298._2 | |
1235 | - | let fundingPayment = $t05506555298._3 | |
1425 | + | let $t06185861962 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1426 | + | let oldPositionNotional = $t06185861962._1 | |
1427 | + | let unrealizedPnl = $t06185861962._2 | |
1428 | + | let $t06197062202 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1429 | + | let exchangedPositionSize = $t06197062202._1 | |
1430 | + | let quoteAssetReserveAfter = $t06197062202._2 | |
1431 | + | let baseAssetReserveAfter = $t06197062202._3 | |
1432 | + | let totalPositionSizeAfter = $t06197062202._4 | |
1433 | + | let cumulativeNotionalAfter = $t06197062202._5 | |
1434 | + | let liquidationRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize)) | |
1435 | + | let realizedPnl = muld(unrealizedPnl, liquidationRatio) | |
1436 | + | let $t06241362646 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1437 | + | let remainMargin = $t06241362646._1 | |
1438 | + | let badDebt = $t06241362646._2 | |
1439 | + | let fundingPayment = $t06241362646._3 | |
1236 | 1440 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
1237 | 1441 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
1238 | 1442 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
1239 | 1443 | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
1240 | 1444 | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1241 | 1445 | let feeToLiquidator = (liquidationPenalty / 2) | |
1242 | 1446 | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1243 | 1447 | let newPositionMargin = (remainMargin - liquidationPenalty) | |
1244 | 1448 | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
1245 | 1449 | let newPositionOpenNotional = abs(remainOpenNotional) | |
1246 | 1450 | let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize) | |
1247 | 1451 | let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount) | |
1248 | 1452 | let ammBalance = (cbalance() - liquidationPenalty) | |
1249 | - | let $ | |
1453 | + | let $t06381963962 = if ((0 > ammBalance)) | |
1250 | 1454 | then $Tuple2(0, abs(ammBalance)) | |
1251 | 1455 | else $Tuple2(ammBalance, 0) | |
1252 | - | let newAmmBalance = $t05647156614._1 | |
1253 | - | let takeFromInsurance = $t05647156614._2 | |
1254 | - | let x = if ((takeFromInsurance > 0)) | |
1456 | + | let newAmmBalance = $t06381963962._1 | |
1457 | + | let takeFromInsurance = $t06381963962._2 | |
1458 | + | let $t06397064024 = getBorrowedByTrader(_trader) | |
1459 | + | let borrowed = $t06397064024._1 | |
1460 | + | let assetId = $t06397064024._2 | |
1461 | + | let doLiquidateCollateral = if ((borrowed > 0)) | |
1255 | 1462 | then { | |
1256 | - | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1257 | - | if ((withdrawInsurance == withdrawInsurance)) | |
1463 | + | let collateralToSell = muld(borrowed, liquidationRatio) | |
1464 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartially", [_trader, assetId, collateralToSell], nil) | |
1465 | + | if ((realizeAndClose == realizeAndClose)) | |
1258 | 1466 | then nil | |
1259 | 1467 | else throw("Strict value is not equal to itself.") | |
1260 | 1468 | } | |
1261 | 1469 | else nil | |
1262 | - | if (( | |
1470 | + | if ((doLiquidateCollateral == doLiquidateCollateral)) | |
1263 | 1471 | then { | |
1264 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1265 | - | if ((unstake == unstake)) | |
1472 | + | let x = if ((takeFromInsurance > 0)) | |
1266 | 1473 | then { | |
1267 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1268 | - | if ((depositInsurance == depositInsurance)) | |
1474 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1475 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1476 | + | then nil | |
1477 | + | else throw("Strict value is not equal to itself.") | |
1478 | + | } | |
1479 | + | else nil | |
1480 | + | if ((x == x)) | |
1481 | + | then { | |
1482 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1483 | + | if ((unstake == unstake)) | |
1269 | 1484 | then { | |
1270 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1271 | - | if ((notifyNotional == notifyNotional)) | |
1272 | - | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1273 | - | then abs(exchangedPositionSize) | |
1274 | - | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1275 | - | then abs(exchangedPositionSize) | |
1276 | - | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1485 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1486 | + | if ((depositInsurance == depositInsurance)) | |
1487 | + | then { | |
1488 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1489 | + | if ((notifyNotional == notifyNotional)) | |
1490 | + | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1491 | + | then abs(exchangedPositionSize) | |
1492 | + | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1493 | + | then abs(exchangedPositionSize) | |
1494 | + | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1495 | + | else throw("Strict value is not equal to itself.") | |
1496 | + | } | |
1277 | 1497 | else throw("Strict value is not equal to itself.") | |
1278 | 1498 | } | |
1279 | 1499 | else throw("Strict value is not equal to itself.") | |
1280 | 1500 | } | |
1281 | 1501 | else throw("Strict value is not equal to itself.") | |
1282 | 1502 | } | |
1283 | 1503 | else throw("Strict value is not equal to itself.") | |
1284 | 1504 | } | |
1285 | 1505 | else { | |
1286 | - | let $ | |
1287 | - | let x1 = $ | |
1288 | - | let badDebt = $ | |
1289 | - | let x2 = $ | |
1290 | - | let x3 = $ | |
1291 | - | let quoteAssetReserveAfter = $ | |
1292 | - | let baseAssetReserveAfter = $ | |
1293 | - | let totalPositionSizeAfter = $ | |
1294 | - | let cumulativeNotionalAfter = $ | |
1295 | - | let openInterestNotionalAfter = $ | |
1296 | - | let exchangedQuoteAssetAmount = $ | |
1297 | - | let totalLongAfter = $ | |
1298 | - | let totalShortAfter = $ | |
1506 | + | let $t06586666321 = internalClosePosition(_trader, false) | |
1507 | + | let x1 = $t06586666321._1 | |
1508 | + | let badDebt = $t06586666321._2 | |
1509 | + | let x2 = $t06586666321._3 | |
1510 | + | let x3 = $t06586666321._4 | |
1511 | + | let quoteAssetReserveAfter = $t06586666321._5 | |
1512 | + | let baseAssetReserveAfter = $t06586666321._6 | |
1513 | + | let totalPositionSizeAfter = $t06586666321._7 | |
1514 | + | let cumulativeNotionalAfter = $t06586666321._8 | |
1515 | + | let openInterestNotionalAfter = $t06586666321._9 | |
1516 | + | let exchangedQuoteAssetAmount = $t06586666321._10 | |
1517 | + | let totalLongAfter = $t06586666321._11 | |
1518 | + | let totalShortAfter = $t06586666321._12 | |
1299 | 1519 | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1300 | 1520 | let feeToLiquidator = (liquidationPenalty / 2) | |
1301 | 1521 | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1302 | 1522 | let ammBalance = (cbalance() - liquidationPenalty) | |
1303 | - | let $ | |
1523 | + | let $t06673366876 = if ((0 > ammBalance)) | |
1304 | 1524 | then $Tuple2(0, abs(ammBalance)) | |
1305 | 1525 | else $Tuple2(ammBalance, 0) | |
1306 | - | let newAmmBalance = $t05892859071._1 | |
1307 | - | let takeFromInsurance = $t05892859071._2 | |
1308 | - | let x = if ((takeFromInsurance > 0)) | |
1526 | + | let newAmmBalance = $t06673366876._1 | |
1527 | + | let takeFromInsurance = $t06673366876._2 | |
1528 | + | let $t06688466938 = getBorrowedByTrader(_trader) | |
1529 | + | let borrowed = $t06688466938._1 | |
1530 | + | let assetId = $t06688466938._2 | |
1531 | + | let doLiquidateCollateral = if ((borrowed > 0)) | |
1309 | 1532 | then { | |
1310 | - | let | |
1311 | - | if (( | |
1533 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], nil) | |
1534 | + | if ((realizeAndClose == realizeAndClose)) | |
1312 | 1535 | then nil | |
1313 | 1536 | else throw("Strict value is not equal to itself.") | |
1314 | 1537 | } | |
1315 | 1538 | else nil | |
1316 | - | if (( | |
1539 | + | if ((doLiquidateCollateral == doLiquidateCollateral)) | |
1317 | 1540 | then { | |
1318 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1319 | - | if ((unstake == unstake)) | |
1541 | + | let x = if ((takeFromInsurance > 0)) | |
1320 | 1542 | then { | |
1321 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1322 | - | if ((depositInsurance == depositInsurance)) | |
1543 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1544 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1545 | + | then nil | |
1546 | + | else throw("Strict value is not equal to itself.") | |
1547 | + | } | |
1548 | + | else nil | |
1549 | + | if ((x == x)) | |
1550 | + | then { | |
1551 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1552 | + | if ((unstake == unstake)) | |
1323 | 1553 | then { | |
1324 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1325 | - | if ((notifyNotional == notifyNotional)) | |
1326 | - | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1554 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1555 | + | if ((depositInsurance == depositInsurance)) | |
1556 | + | then { | |
1557 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1558 | + | if ((notifyNotional == notifyNotional)) | |
1559 | + | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1560 | + | else throw("Strict value is not equal to itself.") | |
1561 | + | } | |
1327 | 1562 | else throw("Strict value is not equal to itself.") | |
1328 | 1563 | } | |
1329 | 1564 | else throw("Strict value is not equal to itself.") | |
1330 | 1565 | } | |
1331 | 1566 | else throw("Strict value is not equal to itself.") | |
1332 | 1567 | } | |
1333 | 1568 | else throw("Strict value is not equal to itself.") | |
1334 | 1569 | } | |
1335 | 1570 | } | |
1336 | 1571 | ||
1337 | 1572 | ||
1338 | 1573 | ||
1339 | 1574 | @Callable(i) | |
1340 | 1575 | func payFunding () = { | |
1341 | 1576 | let fundingBlockTimestamp = nextFundingBlockTimestamp() | |
1342 | 1577 | if (if (if ((fundingBlockTimestamp > lastBlock.timestamp)) | |
1343 | 1578 | then true | |
1344 | 1579 | else !(initialized())) | |
1345 | 1580 | then true | |
1346 | 1581 | else paused()) | |
1347 | 1582 | then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp))) | |
1348 | 1583 | else { | |
1349 | 1584 | let underlyingPrice = getOracleTwapPrice() | |
1350 | - | let $ | |
1351 | - | let shortPremiumFraction = $ | |
1352 | - | let longPremiumFraction = $ | |
1585 | + | let $t06873668798 = getFunding() | |
1586 | + | let shortPremiumFraction = $t06873668798._1 | |
1587 | + | let longPremiumFraction = $t06873668798._2 | |
1353 | 1588 | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1354 | 1589 | } | |
1355 | 1590 | } | |
1356 | 1591 | ||
1357 | 1592 | ||
1358 | 1593 | ||
1359 | 1594 | @Callable(i) | |
1360 | 1595 | func forceMoveAsset (_trader,_amount) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller)) | |
1361 | 1596 | then true | |
1362 | 1597 | else (0 > _amount)) | |
1363 | 1598 | then throw("Invalid forceMoveAsset parameters") | |
1364 | 1599 | else { | |
1365 | 1600 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil) | |
1366 | 1601 | if ((unstake == unstake)) | |
1367 | 1602 | then (withdraw(addressFromStringValue(_trader), _amount) ++ updateBalance((cbalance() - _amount))) | |
1368 | 1603 | else throw("Strict value is not equal to itself.") | |
1369 | 1604 | } | |
1370 | 1605 | ||
1371 | 1606 | ||
1372 | 1607 | ||
1373 | 1608 | @Callable(i) | |
1374 | 1609 | func adjustPeg (_price) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller)) | |
1375 | 1610 | then true | |
1376 | 1611 | else (0 > _price)) | |
1377 | 1612 | then throw("Invalid adjustPeg parameters") | |
1378 | 1613 | else { | |
1379 | - | let $ | |
1380 | - | let newQuoteAssetReserve = $ | |
1381 | - | let pegChangeCost = $ | |
1614 | + | let $t06978969875 = getPegAdjustCost(_price) | |
1615 | + | let newQuoteAssetReserve = $t06978969875._1 | |
1616 | + | let pegChangeCost = $t06978969875._2 | |
1382 | 1617 | if ((pegChangeCost == 0)) | |
1383 | 1618 | then throw("Nothing to adjust") | |
1384 | 1619 | else if ((pegChangeCost > 0)) | |
1385 | 1620 | then updateAmmReserves(newQuoteAssetReserve, bsAstR()) | |
1386 | 1621 | else { | |
1387 | 1622 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), abs(pegChangeCost)], nil) | |
1388 | 1623 | if ((unstake == unstake)) | |
1389 | 1624 | then { | |
1390 | 1625 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), abs(pegChangeCost))]) | |
1391 | 1626 | if ((depositInsurance == depositInsurance)) | |
1392 | 1627 | then (updateBalance((cbalance() - abs(pegChangeCost))) ++ updateAmmReserves(newQuoteAssetReserve, bsAstR())) | |
1393 | 1628 | else throw("Strict value is not equal to itself.") | |
1394 | 1629 | } | |
1395 | 1630 | else throw("Strict value is not equal to itself.") | |
1396 | 1631 | } | |
1397 | 1632 | } | |
1398 | 1633 | ||
1399 | 1634 | ||
1400 | 1635 | ||
1401 | 1636 | @Callable(i) | |
1402 | 1637 | func migrateLiquidity () = { | |
1403 | 1638 | let amount = cbalance() | |
1404 | 1639 | if ((amount > 0)) | |
1405 | 1640 | then { | |
1406 | 1641 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil) | |
1407 | 1642 | if ((unstake == unstake)) | |
1408 | 1643 | then { | |
1409 | 1644 | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
1410 | 1645 | if ((stake == stake)) | |
1411 | 1646 | then nil | |
1412 | 1647 | else throw("Strict value is not equal to itself.") | |
1413 | 1648 | } | |
1414 | 1649 | else throw("Strict value is not equal to itself.") | |
1415 | 1650 | } | |
1416 | 1651 | else nil | |
1417 | 1652 | } | |
1418 | 1653 | ||
1419 | 1654 | ||
1420 | 1655 | ||
1421 | 1656 | @Callable(i) | |
1422 | 1657 | func v_get (_trader) = { | |
1423 | - | let $ | |
1424 | - | let x1 = $ | |
1425 | - | let x2 = $ | |
1426 | - | let x3 = $ | |
1427 | - | let x4 = $ | |
1658 | + | let $t07151671576 = internalClosePosition(_trader, false) | |
1659 | + | let x1 = $t07151671576._1 | |
1660 | + | let x2 = $t07151671576._2 | |
1661 | + | let x3 = $t07151671576._3 | |
1662 | + | let x4 = $t07151671576._4 | |
1428 | 1663 | throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader)))) | |
1429 | 1664 | } | |
1430 | 1665 | ||
1431 | 1666 | ||
1432 | 1667 | ||
1433 | 1668 | @Callable(i) | |
1434 | 1669 | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1435 | - | let $ | |
1436 | - | let positionSize = $ | |
1437 | - | let positionMargin = $ | |
1438 | - | let pon = $ | |
1439 | - | let positionLstUpdCPF = $ | |
1440 | - | let $ | |
1441 | - | let positionNotional = $ | |
1442 | - | let unrealizedPnl = $ | |
1443 | - | let $ | |
1444 | - | let remainMargin = $ | |
1445 | - | let badDebt = $ | |
1446 | - | let fundingPayment = $ | |
1670 | + | let $t07172371834 = getPosition(_trader) | |
1671 | + | let positionSize = $t07172371834._1 | |
1672 | + | let positionMargin = $t07172371834._2 | |
1673 | + | let pon = $t07172371834._3 | |
1674 | + | let positionLstUpdCPF = $t07172371834._4 | |
1675 | + | let $t07183971940 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1676 | + | let positionNotional = $t07183971940._1 | |
1677 | + | let unrealizedPnl = $t07183971940._2 | |
1678 | + | let $t07194572127 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
1679 | + | let remainMargin = $t07194572127._1 | |
1680 | + | let badDebt = $t07194572127._2 | |
1681 | + | let fundingPayment = $t07194572127._3 | |
1447 | 1682 | throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional))) | |
1448 | 1683 | } | |
1449 | 1684 | ||
1450 | 1685 | ||
1451 | 1686 | ||
1452 | 1687 | @Callable(i) | |
1453 | 1688 | func view_getPegAdjustCost (_price) = { | |
1454 | 1689 | let cost = getPegAdjustCost(_price) | |
1455 | 1690 | throw(toString(cost._2)) | |
1456 | 1691 | } | |
1457 | 1692 | ||
1458 | 1693 | ||
1459 | 1694 | ||
1460 | 1695 | @Callable(i) | |
1461 | 1696 | func view_getFunding () = { | |
1462 | 1697 | let underlyingPrice = getOracleTwapPrice() | |
1463 | - | let $ | |
1464 | - | let shortPremiumFraction = $ | |
1465 | - | let longPremiumFraction = $ | |
1698 | + | let $t07251872580 = getFunding() | |
1699 | + | let shortPremiumFraction = $t07251872580._1 | |
1700 | + | let longPremiumFraction = $t07251872580._2 | |
1466 | 1701 | let longFunding = divd(longPremiumFraction, underlyingPrice) | |
1467 | 1702 | let shortFunding = divd(shortPremiumFraction, underlyingPrice) | |
1468 | 1703 | throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOracleTwapPrice()))) | |
1704 | + | } | |
1705 | + | ||
1706 | + | ||
1707 | + | ||
1708 | + | @Callable(i) | |
1709 | + | func view_getBorrowedByTrader (_trader) = { | |
1710 | + | let $t07287072924 = getBorrowedByTrader(_trader) | |
1711 | + | let borrowed = $t07287072924._1 | |
1712 | + | let assetId = $t07287072924._2 | |
1713 | + | throw((s(borrowed) + assetId)) | |
1469 | 1714 | } | |
1470 | 1715 | ||
1471 | 1716 | ||
1472 | 1717 | @Verifier(tx) | |
1473 | 1718 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
1474 | 1719 |
github/deemru/w8io/026f985 234.57 ms ◑