tx · 4J4TzApuukBCCo4YSPXpTxmFLDWAFGu2vYfR6MFjJMFC 3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH: -0.05100000 Waves 2022.08.02 16:54 [2166952] smart account 3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH > SELF 0.00000000 Waves
{ "type": 13, "id": "4J4TzApuukBCCo4YSPXpTxmFLDWAFGu2vYfR6MFjJMFC", "fee": 5100000, "feeAssetId": null, "timestamp": 1659448464653, "version": 2, "chainId": 84, "sender": "3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH", "senderPublicKey": "Hj6oyH6As5UWo8fZ1K4hPsEY7nxH3MvhBqDD6axiwjXs", "proofs": [ "4NXWue515yKY4ENEj5kLMSniWygiMvpbsToxzxyfCm4xUX388D2EsnAdzQQDP7Bv5e41NCMw7d7VJRN19GLRnQKC" ], "script": "base64:BgJPCAISABIAEgkKBwEBAQEBAQESDgoMAQEBAQEBAQgICAEBEgUKAwEBARIFCgMBAQESABIDCgEBEgASAwoBCBIAEgMKAQgSAwoBCBIECgIIAXgACWtfb3JhX2tleQIJa19vcmFfa2V5AA9rX29yYV9ibG9ja19rZXkCD2tfb3JhX2Jsb2NrX2tleQAFa19vcmECBWtfb3JhAAlrX2JhbGFuY2UCCWtfYmFsYW5jZQAOa19wb3NpdGlvblNpemUCDmtfcG9zaXRpb25TaXplABBrX3Bvc2l0aW9uTWFyZ2luAhBrX3Bvc2l0aW9uTWFyZ2luABZrX3Bvc2l0aW9uT3Blbk5vdGlvbmFsAhZrX3Bvc2l0aW9uT3Blbk5vdGlvbmFsAC5rX3Bvc2l0aW9uTGFzdFVwZGF0ZWRDdW11bGF0aXZlUHJlbWl1bUZyYWN0aW9uAhJrX3Bvc2l0aW9uRnJhY3Rpb24ADWtfaW5pdGlhbGl6ZWQCDWtfaW5pdGlhbGl6ZWQACGtfcGF1c2VkAghrX3BhdXNlZAAFa19mZWUCBWtfZmVlAA9rX2Z1bmRpbmdQZXJ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91bnQJAMwIAgkA2AQBCQEKcXVvdGVBc3NldAAFA25pbAUDbmlsAwkAAAIFB3Vuc3Rha2UFB3Vuc3Rha2UJAM4IAgkBCHdpdGhkcmF3AgkBEUBleHRyTmF0aXZlKDEwNjIpAQUHX3RyYWRlcgUHX2Ftb3VudAkBDXVwZGF0ZUJhbGFuY2UBCQBlAgkBCGNiYWxhbmNlAAUHX2Ftb3VudAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAJAQ5hZG1pblB1YmxpY0tleQCD1+UI", "height": 2166952, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 91v8xQ5aRYVhg5gC1PqePck5ZM6JcGbw5ELvRK9AJ639 Next: Ei9tbgMjGRJbCZMHUkWYzyzJTiQ9XsvKgd1TTUVrLTvn Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_ora_key = "k_ora_key" | |
83 | 83 | ||
84 | 84 | let k_staking_address = "k_staking_address" | |
85 | 85 | ||
86 | + | let k_miner_address = "k_miner_address" | |
87 | + | ||
86 | 88 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
87 | 89 | ||
88 | 90 | ||
102 | 104 | ||
103 | 105 | ||
104 | 106 | func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set") | |
107 | + | ||
108 | + | ||
109 | + | func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Insurance not set") | |
105 | 110 | ||
106 | 111 | ||
107 | 112 | let DIR_LONG = 1 | |
323 | 328 | if ((priceImpact > maxPriceImpactValue)) | |
324 | 329 | then throw(((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue))) | |
325 | 330 | else { | |
326 | - | let $ | |
327 | - | let quoteAssetReserveAfter1 = $ | |
328 | - | let baseAssetReserveAfter1 = $ | |
329 | - | let totalPositionSizeAfter1 = $ | |
330 | - | let cumulativeNotionalAfter1 = $ | |
331 | + | let $t01236812571 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs) | |
332 | + | let quoteAssetReserveAfter1 = $t01236812571._1 | |
333 | + | let baseAssetReserveAfter1 = $t01236812571._2 | |
334 | + | let totalPositionSizeAfter1 = $t01236812571._3 | |
335 | + | let cumulativeNotionalAfter1 = $t01236812571._4 | |
331 | 336 | $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1) | |
332 | 337 | } | |
333 | 338 | } | |
341 | 346 | } | |
342 | 347 | else 0 | |
343 | 348 | let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin) | |
344 | - | let $ | |
349 | + | let $t01331813445 = if ((0 > signedMargin)) | |
345 | 350 | then $Tuple2(0, abs(signedMargin)) | |
346 | 351 | else $Tuple2(abs(signedMargin), 0) | |
347 | - | let remainMargin = $ | |
348 | - | let badDebt = $ | |
352 | + | let remainMargin = $t01331813445._1 | |
353 | + | let badDebt = $t01331813445._2 | |
349 | 354 | $Tuple3(remainMargin, badDebt, fundingPayment) | |
350 | 355 | } | |
351 | 356 | ||
362 | 367 | else (_baseAssetReserve - _baseAssetAmount) | |
363 | 368 | let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter) | |
364 | 369 | let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve)) | |
365 | - | let $ | |
366 | - | let quoteAssetReserveAfter1 = $ | |
367 | - | let baseAssetReserveAfter1 = $ | |
368 | - | let totalPositionSizeAfter1 = $ | |
369 | - | let cumulativeNotionalAfter1 = $ | |
370 | + | let $t01428314476 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount) | |
371 | + | let quoteAssetReserveAfter1 = $t01428314476._1 | |
372 | + | let baseAssetReserveAfter1 = $t01428314476._2 | |
373 | + | let totalPositionSizeAfter1 = $t01428314476._3 | |
374 | + | let cumulativeNotionalAfter1 = $t01428314476._4 | |
370 | 375 | $Tuple7(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd) | |
371 | 376 | then abs(_baseAssetAmount) | |
372 | 377 | else 0)), (totalShortPositionSize() - (if (!(_isAdd)) | |
400 | 405 | ||
401 | 406 | ||
402 | 407 | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
403 | - | let $ | |
404 | - | let positionSize = $ | |
405 | - | let positionMargin = $ | |
406 | - | let positionOpenNotional = $ | |
407 | - | let positionLstUpdCPF = $ | |
408 | + | let $t01610816236 = getPosition(_trader) | |
409 | + | let positionSize = $t01610816236._1 | |
410 | + | let positionMargin = $t01610816236._2 | |
411 | + | let positionOpenNotional = $t01610816236._3 | |
412 | + | let positionLstUpdCPF = $t01610816236._4 | |
408 | 413 | let positionSizeAbs = abs(positionSize) | |
409 | 414 | if ((positionSizeAbs == 0)) | |
410 | 415 | then throw("Invalid position size") | |
412 | 417 | let isShort = (0 > positionSize) | |
413 | 418 | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
414 | 419 | then { | |
415 | - | let $ | |
416 | - | let outPositionNotional = $ | |
417 | - | let x1 = $ | |
418 | - | let x2 = $ | |
419 | - | let x3 = $ | |
420 | + | let $t01648316590 = swapOutput(!(isShort), positionSizeAbs) | |
421 | + | let outPositionNotional = $t01648316590._1 | |
422 | + | let x1 = $t01648316590._2 | |
423 | + | let x2 = $t01648316590._3 | |
424 | + | let x3 = $t01648316590._4 | |
420 | 425 | outPositionNotional | |
421 | 426 | } | |
422 | 427 | else muld(positionSizeAbs, getOracleTwapPrice()) | |
432 | 437 | ||
433 | 438 | ||
434 | 439 | func getMarginRatioByOption (_trader,_option) = { | |
435 | - | let $ | |
436 | - | let positionSize = $ | |
437 | - | let positionMargin = $ | |
438 | - | let pon = $ | |
439 | - | let positionLstUpdCPF = $ | |
440 | - | let $ | |
441 | - | let positionNotional = $ | |
442 | - | let unrealizedPnl = $ | |
443 | - | let $ | |
444 | - | let remainMargin = $ | |
445 | - | let badDebt = $ | |
440 | + | let $t01726017371 = getPosition(_trader) | |
441 | + | let positionSize = $t01726017371._1 | |
442 | + | let positionMargin = $t01726017371._2 | |
443 | + | let pon = $t01726017371._3 | |
444 | + | let positionLstUpdCPF = $t01726017371._4 | |
445 | + | let $t01737717470 = getPositionNotionalAndUnrealizedPnl(_trader, _option) | |
446 | + | let positionNotional = $t01737717470._1 | |
447 | + | let unrealizedPnl = $t01737717470._2 | |
448 | + | let $t01747517641 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
449 | + | let remainMargin = $t01747517641._1 | |
450 | + | let badDebt = $t01747517641._2 | |
446 | 451 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
447 | 452 | } | |
448 | 453 | ||
451 | 456 | ||
452 | 457 | ||
453 | 458 | func internalClosePosition (_trader) = { | |
454 | - | let $ | |
455 | - | let positionSize = $ | |
456 | - | let positionMargin = $ | |
457 | - | let positionOpenNotional = $ | |
458 | - | let positionLstUpdCPF = $ | |
459 | - | let $ | |
460 | - | let x1 = $ | |
461 | - | let unrealizedPnl = $ | |
462 | - | let $ | |
463 | - | let remainMargin = $ | |
464 | - | let badDebt = $ | |
459 | + | let $t01795718085 = getPosition(_trader) | |
460 | + | let positionSize = $t01795718085._1 | |
461 | + | let positionMargin = $t01795718085._2 | |
462 | + | let positionOpenNotional = $t01795718085._3 | |
463 | + | let positionLstUpdCPF = $t01795718085._4 | |
464 | + | let $t01809118178 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
465 | + | let x1 = $t01809118178._1 | |
466 | + | let unrealizedPnl = $t01809118178._2 | |
467 | + | let $t01818318351 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
468 | + | let remainMargin = $t01818318351._1 | |
469 | + | let badDebt = $t01818318351._2 | |
465 | 470 | let exchangedPositionSize = -(positionSize) | |
466 | 471 | let realizedPnl = unrealizedPnl | |
467 | 472 | let marginToVault = -(remainMargin) | |
468 | - | let $ | |
469 | - | let exchangedQuoteAssetAmount = $ | |
470 | - | let quoteAssetReserveAfter = $ | |
471 | - | let baseAssetReserveAfter = $ | |
472 | - | let totalPositionSizeAfter = $ | |
473 | - | let cumulativeNotionalAfter = $ | |
474 | - | let totalLongAfter = $ | |
475 | - | let totalShortAfter = $ | |
473 | + | let $t01847818759 = swapOutput((positionSize > 0), abs(positionSize)) | |
474 | + | let exchangedQuoteAssetAmount = $t01847818759._1 | |
475 | + | let quoteAssetReserveAfter = $t01847818759._2 | |
476 | + | let baseAssetReserveAfter = $t01847818759._3 | |
477 | + | let totalPositionSizeAfter = $t01847818759._4 | |
478 | + | let cumulativeNotionalAfter = $t01847818759._5 | |
479 | + | let totalLongAfter = $t01847818759._6 | |
480 | + | let totalShortAfter = $t01847818759._7 | |
476 | 481 | let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional) | |
477 | 482 | $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter) | |
478 | 483 | } | |
638 | 643 | else paused()) | |
639 | 644 | then throw("Invalid decreasePosition parameters") | |
640 | 645 | else { | |
641 | - | let $ | |
642 | - | let oldPositionSize = $ | |
643 | - | let oldPositionMargin = $ | |
644 | - | let oldPositionOpenNotional = $ | |
645 | - | let oldPositionLstUpdCPF = $ | |
646 | + | let $t02860028752 = getPosition(toString(i.caller)) | |
647 | + | let oldPositionSize = $t02860028752._1 | |
648 | + | let oldPositionMargin = $t02860028752._2 | |
649 | + | let oldPositionOpenNotional = $t02860028752._3 | |
650 | + | let oldPositionLstUpdCPF = $t02860028752._4 | |
646 | 651 | let _direction = if ((oldPositionSize > 0)) | |
647 | 652 | then DIR_SHORT | |
648 | 653 | else DIR_LONG | |
649 | 654 | let isAdd = (_direction == DIR_LONG) | |
650 | 655 | let openNotional = muld(_amount, _leverage) | |
651 | - | let $ | |
652 | - | let oldPositionNotional = $ | |
653 | - | let unrealizedPnl = $ | |
654 | - | let $ | |
656 | + | let $t02892529041 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
657 | + | let oldPositionNotional = $t02892529041._1 | |
658 | + | let unrealizedPnl = $t02892529041._2 | |
659 | + | let $t02904731596 = if ((oldPositionNotional > openNotional)) | |
655 | 660 | then { | |
656 | - | let $ | |
657 | - | let exchangedPositionSize = $ | |
658 | - | let quoteAssetReserveAfter = $ | |
659 | - | let baseAssetReserveAfter = $ | |
660 | - | let totalPositionSizeAfter = $ | |
661 | - | let cumulativeNotionalAfter = $ | |
661 | + | let $t02942429643 = swapInput(isAdd, openNotional) | |
662 | + | let exchangedPositionSize = $t02942429643._1 | |
663 | + | let quoteAssetReserveAfter = $t02942429643._2 | |
664 | + | let baseAssetReserveAfter = $t02942429643._3 | |
665 | + | let totalPositionSizeAfter = $t02942429643._4 | |
666 | + | let cumulativeNotionalAfter = $t02942429643._5 | |
662 | 667 | let exchangedPositionSizeAbs = abs(exchangedPositionSize) | |
663 | 668 | if (if ((_minBaseAssetAmount != 0)) | |
664 | 669 | then (_minBaseAssetAmount > exchangedPositionSizeAbs) | |
666 | 671 | then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount))) | |
667 | 672 | else { | |
668 | 673 | let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize)) | |
669 | - | let $ | |
670 | - | let remainMargin = $ | |
671 | - | let badDebt = $ | |
672 | - | let fundingPayment = $ | |
674 | + | let $t03008030325 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
675 | + | let remainMargin = $t03008030325._1 | |
676 | + | let badDebt = $t03008030325._2 | |
677 | + | let fundingPayment = $t03008030325._3 | |
673 | 678 | let exchangedQuoteAssetAmount = openNotional | |
674 | 679 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
675 | 680 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
684 | 689 | } | |
685 | 690 | } | |
686 | 691 | else throw("Close position first") | |
687 | - | let newPositionSize = $t02883331382._1 | |
688 | - | let newPositionRemainMargin = $t02883331382._2 | |
689 | - | let newPositionOpenNotional = $t02883331382._3 | |
690 | - | let newPositionLatestCPF = $t02883331382._4 | |
691 | - | let baseAssetReserveAfter = $t02883331382._5 | |
692 | - | let quoteAssetReserveAfter = $t02883331382._6 | |
693 | - | let totalPositionSizeAfter = $t02883331382._7 | |
694 | - | let cumulativeNotionalAfter = $t02883331382._8 | |
695 | - | let openInterestNotionalAfter = $t02883331382._9 | |
696 | - | let totalLongAfter = $t02883331382._10 | |
697 | - | let totalShortAfter = $t02883331382._11 | |
698 | - | (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
692 | + | let newPositionSize = $t02904731596._1 | |
693 | + | let newPositionRemainMargin = $t02904731596._2 | |
694 | + | let newPositionOpenNotional = $t02904731596._3 | |
695 | + | let newPositionLatestCPF = $t02904731596._4 | |
696 | + | let baseAssetReserveAfter = $t02904731596._5 | |
697 | + | let quoteAssetReserveAfter = $t02904731596._6 | |
698 | + | let totalPositionSizeAfter = $t02904731596._7 | |
699 | + | let cumulativeNotionalAfter = $t02904731596._8 | |
700 | + | let openInterestNotionalAfter = $t02904731596._9 | |
701 | + | let totalLongAfter = $t02904731596._10 | |
702 | + | let totalShortAfter = $t02904731596._11 | |
703 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
704 | + | if ((notifyNotional == notifyNotional)) | |
705 | + | then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
706 | + | else throw("Strict value is not equal to itself.") | |
699 | 707 | } | |
700 | 708 | ||
701 | 709 | ||
724 | 732 | else { | |
725 | 733 | let feeAmount = muld(_rawAmount, fee()) | |
726 | 734 | let _amount = (_rawAmount - feeAmount) | |
727 | - | let $ | |
728 | - | let oldPositionSize = $ | |
729 | - | let oldPositionMargin = $ | |
730 | - | let oldPositionOpenNotional = $ | |
731 | - | let oldPositionLstUpdCPF = $ | |
735 | + | let $t03278432936 = getPosition(toString(i.caller)) | |
736 | + | let oldPositionSize = $t03278432936._1 | |
737 | + | let oldPositionMargin = $t03278432936._2 | |
738 | + | let oldPositionOpenNotional = $t03278432936._3 | |
739 | + | let oldPositionLstUpdCPF = $t03278432936._4 | |
732 | 740 | let isNewPosition = (oldPositionSize == 0) | |
733 | 741 | let isSameDirection = if ((oldPositionSize > 0)) | |
734 | 742 | then (_direction == DIR_LONG) | |
737 | 745 | then isSameDirection | |
738 | 746 | else false | |
739 | 747 | let isAdd = (_direction == DIR_LONG) | |
740 | - | let $ | |
748 | + | let $t03322535614 = if (if (isNewPosition) | |
741 | 749 | then true | |
742 | 750 | else expandExisting) | |
743 | 751 | then { | |
744 | 752 | let openNotional = muld(_amount, _leverage) | |
745 | - | let $ | |
746 | - | let amountBaseAssetBought = $ | |
747 | - | let quoteAssetReserveAfter = $ | |
748 | - | let baseAssetReserveAfter = $ | |
749 | - | let totalPositionSizeAfter = $ | |
750 | - | let cumulativeNotionalAfter = $ | |
753 | + | let $t03364933855 = swapInput(isAdd, openNotional) | |
754 | + | let amountBaseAssetBought = $t03364933855._1 | |
755 | + | let quoteAssetReserveAfter = $t03364933855._2 | |
756 | + | let baseAssetReserveAfter = $t03364933855._3 | |
757 | + | let totalPositionSizeAfter = $t03364933855._4 | |
758 | + | let cumulativeNotionalAfter = $t03364933855._5 | |
751 | 759 | if (if ((_minBaseAssetAmount != 0)) | |
752 | 760 | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
753 | 761 | else false) | |
755 | 763 | else { | |
756 | 764 | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
757 | 765 | let increaseMarginRequirement = divd(openNotional, _leverage) | |
758 | - | let $ | |
759 | - | let remainMargin = $ | |
760 | - | let x1 = $ | |
761 | - | let x2 = $ | |
766 | + | let $t03423634475 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
767 | + | let remainMargin = $t03423634475._1 | |
768 | + | let x1 = $t03423634475._2 | |
769 | + | let x2 = $t03423634475._3 | |
762 | 770 | $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
763 | 771 | then abs(amountBaseAssetBought) | |
764 | 772 | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
768 | 776 | } | |
769 | 777 | else { | |
770 | 778 | let openNotional = muld(_amount, _leverage) | |
771 | - | let $ | |
772 | - | let oldPositionNotional = $ | |
773 | - | let unrealizedPnl = $ | |
779 | + | let $t03530735423 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
780 | + | let oldPositionNotional = $t03530735423._1 | |
781 | + | let unrealizedPnl = $t03530735423._2 | |
774 | 782 | if ((oldPositionNotional > openNotional)) | |
775 | 783 | then throw("Use decreasePosition to decrease position size") | |
776 | 784 | else throw("Close position first") | |
777 | 785 | } | |
778 | - | let newPositionSize = $ | |
779 | - | let newPositionRemainMargin = $ | |
780 | - | let newPositionOpenNotional = $ | |
781 | - | let newPositionLatestCPF = $ | |
782 | - | let baseAssetReserveAfter = $ | |
783 | - | let quoteAssetReserveAfter = $ | |
784 | - | let totalPositionSizeAfter = $ | |
785 | - | let cumulativeNotionalAfter = $ | |
786 | - | let openInterestNotionalAfter = $ | |
787 | - | let totalLongAfter = $ | |
788 | - | let totalShortAfter = $ | |
786 | + | let newPositionSize = $t03322535614._1 | |
787 | + | let newPositionRemainMargin = $t03322535614._2 | |
788 | + | let newPositionOpenNotional = $t03322535614._3 | |
789 | + | let newPositionLatestCPF = $t03322535614._4 | |
790 | + | let baseAssetReserveAfter = $t03322535614._5 | |
791 | + | let quoteAssetReserveAfter = $t03322535614._6 | |
792 | + | let totalPositionSizeAfter = $t03322535614._7 | |
793 | + | let cumulativeNotionalAfter = $t03322535614._8 | |
794 | + | let openInterestNotionalAfter = $t03322535614._9 | |
795 | + | let totalLongAfter = $t03322535614._10 | |
796 | + | let totalShortAfter = $t03322535614._11 | |
789 | 797 | let feeToStakers = (feeAmount / 2) | |
790 | 798 | let feeToInsurance = (feeAmount - feeToStakers) | |
791 | 799 | let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)]) | |
793 | 801 | then { | |
794 | 802 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
795 | 803 | if ((depositInsurance == depositInsurance)) | |
796 | - | then (((updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
804 | + | then { | |
805 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [toString(i.caller), feeAmount], nil) | |
806 | + | if ((notifyFee == notifyFee)) | |
807 | + | then { | |
808 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
809 | + | if ((notifyNotional == notifyNotional)) | |
810 | + | then (((updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
811 | + | else throw("Strict value is not equal to itself.") | |
812 | + | } | |
813 | + | else throw("Strict value is not equal to itself.") | |
814 | + | } | |
797 | 815 | else throw("Strict value is not equal to itself.") | |
798 | 816 | } | |
799 | 817 | else throw("Strict value is not equal to itself.") | |
816 | 834 | else { | |
817 | 835 | let feeAmount = muld(_rawAmount, fee()) | |
818 | 836 | let _amount = (_rawAmount - feeAmount) | |
819 | - | let $ | |
820 | - | let oldPositionSize = $ | |
821 | - | let oldPositionMargin = $ | |
822 | - | let oldPositionOpenNotional = $ | |
823 | - | let oldPositionLstUpdCPF = $ | |
837 | + | let $t03717037322 = getPosition(toString(i.caller)) | |
838 | + | let oldPositionSize = $t03717037322._1 | |
839 | + | let oldPositionMargin = $t03717037322._2 | |
840 | + | let oldPositionOpenNotional = $t03717037322._3 | |
841 | + | let oldPositionLstUpdCPF = $t03717037322._4 | |
824 | 842 | let feeToStakers = (feeAmount / 2) | |
825 | 843 | let feeToInsurance = (feeAmount - feeToStakers) | |
826 | 844 | let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)]) | |
828 | 846 | then { | |
829 | 847 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
830 | 848 | if ((depositInsurance == depositInsurance)) | |
831 | - | then ((updatePosition(toString(i.caller), oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
849 | + | then { | |
850 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [toString(i.caller), feeAmount], nil) | |
851 | + | if ((notifyFee == notifyFee)) | |
852 | + | then ((updatePosition(toString(i.caller), oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
853 | + | else throw("Strict value is not equal to itself.") | |
854 | + | } | |
832 | 855 | else throw("Strict value is not equal to itself.") | |
833 | 856 | } | |
834 | 857 | else throw("Strict value is not equal to itself.") | |
847 | 870 | else paused()) | |
848 | 871 | then throw("Invalid removeMargin parameters") | |
849 | 872 | else { | |
850 | - | let $ | |
851 | - | let oldPositionSize = $ | |
852 | - | let oldPositionMargin = $ | |
853 | - | let oldPositionOpenNotional = $ | |
854 | - | let oldPositionLstUpdCPF = $ | |
873 | + | let $t03837138523 = getPosition(toString(i.caller)) | |
874 | + | let oldPositionSize = $t03837138523._1 | |
875 | + | let oldPositionMargin = $t03837138523._2 | |
876 | + | let oldPositionOpenNotional = $t03837138523._3 | |
877 | + | let oldPositionLstUpdCPF = $t03837138523._4 | |
855 | 878 | let marginDelta = -(_amount) | |
856 | - | let $ | |
857 | - | let remainMargin = $ | |
858 | - | let badDebt = $ | |
879 | + | let $t03856038739 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
880 | + | let remainMargin = $t03856038739._1 | |
881 | + | let badDebt = $t03856038739._2 | |
859 | 882 | if ((badDebt != 0)) | |
860 | 883 | then throw("Invalid removed margin amount") | |
861 | 884 | else { | |
881 | 904 | else paused()) | |
882 | 905 | then throw("Invalid closePosition parameters") | |
883 | 906 | else { | |
884 | - | let $ | |
885 | - | let x1 = $ | |
886 | - | let positionBadDebt = $ | |
887 | - | let realizedPnl = $ | |
888 | - | let marginToVault = $ | |
889 | - | let quoteAssetReserveAfter = $ | |
890 | - | let baseAssetReserveAfter = $ | |
891 | - | let totalPositionSizeAfter = $ | |
892 | - | let cumulativeNotionalAfter = $ | |
893 | - | let openInterestNotionalAfter = $ | |
894 | - | let x2 = $ | |
895 | - | let totalLongAfter = $ | |
896 | - | let totalShortAfter = $ | |
907 | + | let $t03983540219 = internalClosePosition(toString(i.caller)) | |
908 | + | let x1 = $t03983540219._1 | |
909 | + | let positionBadDebt = $t03983540219._2 | |
910 | + | let realizedPnl = $t03983540219._3 | |
911 | + | let marginToVault = $t03983540219._4 | |
912 | + | let quoteAssetReserveAfter = $t03983540219._5 | |
913 | + | let baseAssetReserveAfter = $t03983540219._6 | |
914 | + | let totalPositionSizeAfter = $t03983540219._7 | |
915 | + | let cumulativeNotionalAfter = $t03983540219._8 | |
916 | + | let openInterestNotionalAfter = $t03983540219._9 | |
917 | + | let x2 = $t03983540219._10 | |
918 | + | let totalLongAfter = $t03983540219._11 | |
919 | + | let totalShortAfter = $t03983540219._12 | |
897 | 920 | if ((positionBadDebt > 0)) | |
898 | 921 | then throw("Unable to close position with bad debt") | |
899 | 922 | else { | |
900 | 923 | let withdrawAmount = abs(marginToVault) | |
901 | 924 | let ammBalance = (cbalance() - withdrawAmount) | |
902 | - | let $ | |
925 | + | let $t04042840570 = if ((0 > ammBalance)) | |
903 | 926 | then $Tuple2(0, abs(ammBalance)) | |
904 | 927 | else $Tuple2(ammBalance, 0) | |
905 | - | let ammNewBalance = $ | |
906 | - | let getFromInsurance = $ | |
928 | + | let ammNewBalance = $t04042840570._1 | |
929 | + | let getFromInsurance = $t04042840570._2 | |
907 | 930 | let x = if ((getFromInsurance > 0)) | |
908 | 931 | then { | |
909 | 932 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil) | |
916 | 939 | then { | |
917 | 940 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(withdrawAmount - getFromInsurance), toBase58String(quoteAsset())], nil) | |
918 | 941 | if ((unstake == unstake)) | |
919 | - | then (((deletePosition(toString(i.caller)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
942 | + | then { | |
943 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), 0], nil) | |
944 | + | if ((notifyNotional == notifyNotional)) | |
945 | + | then (((deletePosition(toString(i.caller)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
946 | + | else throw("Strict value is not equal to itself.") | |
947 | + | } | |
920 | 948 | else throw("Strict value is not equal to itself.") | |
921 | 949 | } | |
922 | 950 | else throw("Strict value is not equal to itself.") | |
943 | 971 | else paused()) | |
944 | 972 | then throw("Unable to liquidate") | |
945 | 973 | else { | |
946 | - | let $ | |
947 | - | let x1 = $ | |
948 | - | let badDebt = $ | |
949 | - | let x2 = $ | |
950 | - | let x3 = $ | |
951 | - | let quoteAssetReserveAfter = $ | |
952 | - | let baseAssetReserveAfter = $ | |
953 | - | let totalPositionSizeAfter = $ | |
954 | - | let cumulativeNotionalAfter = $ | |
955 | - | let openInterestNotionalAfter = $ | |
956 | - | let exchangedQuoteAssetAmount = $ | |
957 | - | let totalLongAfter = $ | |
958 | - | let totalShortAfter = $ | |
974 | + | let $t04226042676 = internalClosePosition(_trader) | |
975 | + | let x1 = $t04226042676._1 | |
976 | + | let badDebt = $t04226042676._2 | |
977 | + | let x2 = $t04226042676._3 | |
978 | + | let x3 = $t04226042676._4 | |
979 | + | let quoteAssetReserveAfter = $t04226042676._5 | |
980 | + | let baseAssetReserveAfter = $t04226042676._6 | |
981 | + | let totalPositionSizeAfter = $t04226042676._7 | |
982 | + | let cumulativeNotionalAfter = $t04226042676._8 | |
983 | + | let openInterestNotionalAfter = $t04226042676._9 | |
984 | + | let exchangedQuoteAssetAmount = $t04226042676._10 | |
985 | + | let totalLongAfter = $t04226042676._11 | |
986 | + | let totalShortAfter = $t04226042676._12 | |
959 | 987 | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
960 | 988 | let feeToLiquidator = (liquidationPenalty / 2) | |
961 | 989 | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
962 | 990 | let ammBalance = (cbalance() - liquidationPenalty) | |
963 | - | let $ | |
991 | + | let $t04307443209 = if ((0 > ammBalance)) | |
964 | 992 | then $Tuple2(0, abs(ammBalance)) | |
965 | 993 | else $Tuple2(ammBalance, 0) | |
966 | - | let newAmmBalance = $ | |
967 | - | let takeFromInsurance = $ | |
994 | + | let newAmmBalance = $t04307443209._1 | |
995 | + | let takeFromInsurance = $t04307443209._2 | |
968 | 996 | let x = if ((takeFromInsurance > 0)) | |
969 | 997 | then { | |
970 | 998 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
980 | 1008 | then { | |
981 | 1009 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
982 | 1010 | if ((depositInsurance == depositInsurance)) | |
983 | - | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1011 | + | then { | |
1012 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1013 | + | if ((notifyNotional == notifyNotional)) | |
1014 | + | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1015 | + | else throw("Strict value is not equal to itself.") | |
1016 | + | } | |
984 | 1017 | else throw("Strict value is not equal to itself.") | |
985 | 1018 | } | |
986 | 1019 | else throw("Strict value is not equal to itself.") | |
1004 | 1037 | let underlyingPrice = getOracleTwapPrice() | |
1005 | 1038 | let spotTwapPrice = getTwapSpotPrice() | |
1006 | 1039 | let premium = (spotTwapPrice - underlyingPrice) | |
1007 | - | let $ | |
1040 | + | let $t04470346038 = if (if ((totalShortPositionSize() == 0)) | |
1008 | 1041 | then true | |
1009 | 1042 | else (totalLongPositionSize() == 0)) | |
1010 | 1043 | then $Tuple2(0, 0) | |
1019 | 1052 | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
1020 | 1053 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
1021 | 1054 | } | |
1022 | - | let shortPremiumFraction = $ | |
1023 | - | let longPremiumFraction = $ | |
1055 | + | let shortPremiumFraction = $t04470346038._1 | |
1056 | + | let longPremiumFraction = $t04470346038._2 | |
1024 | 1057 | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1025 | 1058 | } | |
1026 | 1059 | } | |
1029 | 1062 | ||
1030 | 1063 | @Callable(i) | |
1031 | 1064 | func v_get (_trader) = { | |
1032 | - | let $ | |
1033 | - | let x1 = $ | |
1034 | - | let x2 = $ | |
1035 | - | let x3 = $ | |
1036 | - | let x4 = $ | |
1065 | + | let $t04641346466 = internalClosePosition(_trader) | |
1066 | + | let x1 = $t04641346466._1 | |
1067 | + | let x2 = $t04641346466._2 | |
1068 | + | let x3 = $t04641346466._3 | |
1069 | + | let x4 = $t04641346466._4 | |
1037 | 1070 | throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader)))) | |
1038 | 1071 | } | |
1039 | 1072 | ||
1041 | 1074 | ||
1042 | 1075 | @Callable(i) | |
1043 | 1076 | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1044 | - | let $ | |
1045 | - | let positionSize = $ | |
1046 | - | let positionMargin = $ | |
1047 | - | let pon = $ | |
1048 | - | let positionLstUpdCPF = $ | |
1049 | - | let $ | |
1050 | - | let positionNotional = $ | |
1051 | - | let unrealizedPnl = $ | |
1052 | - | let $ | |
1053 | - | let remainMargin = $ | |
1054 | - | let badDebt = $ | |
1055 | - | let fundingPayment = $ | |
1077 | + | let $t04661346724 = getPosition(_trader) | |
1078 | + | let positionSize = $t04661346724._1 | |
1079 | + | let positionMargin = $t04661346724._2 | |
1080 | + | let pon = $t04661346724._3 | |
1081 | + | let positionLstUpdCPF = $t04661346724._4 | |
1082 | + | let $t04672946830 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1083 | + | let positionNotional = $t04672946830._1 | |
1084 | + | let unrealizedPnl = $t04672946830._2 | |
1085 | + | let $t04683547017 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
1086 | + | let remainMargin = $t04683547017._1 | |
1087 | + | let badDebt = $t04683547017._2 | |
1088 | + | let fundingPayment = $t04683547017._3 | |
1056 | 1089 | throw(((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader)))) | |
1057 | 1090 | } | |
1091 | + | ||
1092 | + | ||
1093 | + | ||
1094 | + | @Callable(i) | |
1095 | + | func forceMoveAsset (_trader,_amount) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller)) | |
1096 | + | then true | |
1097 | + | else (0 > _amount)) | |
1098 | + | then throw("Invalid forceMoveAsset parameters") | |
1099 | + | else { | |
1100 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [_amount, toBase58String(quoteAsset())], nil) | |
1101 | + | if ((unstake == unstake)) | |
1102 | + | then (withdraw(addressFromStringValue(_trader), _amount) ++ updateBalance((cbalance() - _amount))) | |
1103 | + | else throw("Strict value is not equal to itself.") | |
1104 | + | } | |
1058 | 1105 | ||
1059 | 1106 | ||
1060 | 1107 | @Verifier(tx) |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
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_initialized = "k_initialized" | |
21 | 21 | ||
22 | 22 | let k_paused = "k_paused" | |
23 | 23 | ||
24 | 24 | let k_fee = "k_fee" | |
25 | 25 | ||
26 | 26 | let k_fundingPeriod = "k_fundingPeriod" | |
27 | 27 | ||
28 | 28 | let k_initMarginRatio = "k_initMarginRatio" | |
29 | 29 | ||
30 | 30 | let k_maintenanceMarginRatio = "k_mmr" | |
31 | 31 | ||
32 | 32 | let k_liquidationFeeRatio = "k_liquidationFeeRatio" | |
33 | 33 | ||
34 | 34 | let k_spreadLimit = "k_spreadLimit" | |
35 | 35 | ||
36 | 36 | let k_maxPriceImpact = "k_maxPriceImpact" | |
37 | 37 | ||
38 | 38 | let k_lastDataStr = "k_lastDataStr" | |
39 | 39 | ||
40 | 40 | let k_lastMinuteId = "k_lastMinuteId" | |
41 | 41 | ||
42 | 42 | let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice" | |
43 | 43 | ||
44 | 44 | let k_twapDataLastPrice = "k_twapDataLastPrice" | |
45 | 45 | ||
46 | 46 | let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId" | |
47 | 47 | ||
48 | 48 | let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction" | |
49 | 49 | ||
50 | 50 | let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction" | |
51 | 51 | ||
52 | 52 | let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp" | |
53 | 53 | ||
54 | 54 | let k_longFundingRate = "k_longFundingRate" | |
55 | 55 | ||
56 | 56 | let k_shortFundingRate = "k_shortFundingRate" | |
57 | 57 | ||
58 | 58 | let k_quoteAssetReserve = "k_qtAstR" | |
59 | 59 | ||
60 | 60 | let k_baseAssetReserve = "k_bsAstR" | |
61 | 61 | ||
62 | 62 | let k_totalPositionSize = "k_totalPositionSize" | |
63 | 63 | ||
64 | 64 | let k_totalLongPositionSize = "k_totalLongPositionSize" | |
65 | 65 | ||
66 | 66 | let k_totalShortPositionSize = "k_totalShortPositionSize" | |
67 | 67 | ||
68 | 68 | let k_cumulativeNotional = "k_cumulativeNotional" | |
69 | 69 | ||
70 | 70 | let k_openInterestNotional = "k_openInterestNotional" | |
71 | 71 | ||
72 | 72 | let k_coordinatorAddress = "k_coordinatorAddress" | |
73 | 73 | ||
74 | 74 | let k_insurance_address = "k_insurance_address" | |
75 | 75 | ||
76 | 76 | let k_admin_address = "k_admin_address" | |
77 | 77 | ||
78 | 78 | let k_admin_public_key = "k_admin_public_key" | |
79 | 79 | ||
80 | 80 | let k_quote_asset = "k_quote_asset" | |
81 | 81 | ||
82 | 82 | let k_quote_staking = "k_quote_staking" | |
83 | 83 | ||
84 | 84 | let k_staking_address = "k_staking_address" | |
85 | 85 | ||
86 | + | let k_miner_address = "k_miner_address" | |
87 | + | ||
86 | 88 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
87 | 89 | ||
88 | 90 | ||
89 | 91 | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
90 | 92 | ||
91 | 93 | ||
92 | 94 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
93 | 95 | ||
94 | 96 | ||
95 | 97 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
96 | 98 | ||
97 | 99 | ||
98 | 100 | func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set") | |
99 | 101 | ||
100 | 102 | ||
101 | 103 | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Insurance not set") | |
102 | 104 | ||
103 | 105 | ||
104 | 106 | func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set") | |
107 | + | ||
108 | + | ||
109 | + | func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Insurance not set") | |
105 | 110 | ||
106 | 111 | ||
107 | 112 | let DIR_LONG = 1 | |
108 | 113 | ||
109 | 114 | let DIR_SHORT = 2 | |
110 | 115 | ||
111 | 116 | let FUNDING_BLOCK_INTERVAL = 60 | |
112 | 117 | ||
113 | 118 | let TWAP_INTERVAL = 15 | |
114 | 119 | ||
115 | 120 | let ORACLE_INTERVAL = 15 | |
116 | 121 | ||
117 | 122 | let SECONDS = 1000 | |
118 | 123 | ||
119 | 124 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
120 | 125 | ||
121 | 126 | let HUNDRED_PERCENT = (100 * DECIMAL_UNIT) | |
122 | 127 | ||
123 | 128 | let ONE_DAY = (86400 * DECIMAL_UNIT) | |
124 | 129 | ||
125 | 130 | let ALL_FEES = 100 | |
126 | 131 | ||
127 | 132 | let PNL_OPTION_SPOT = 1 | |
128 | 133 | ||
129 | 134 | let PNL_OPTION_ORACLE = 2 | |
130 | 135 | ||
131 | 136 | func s (_x) = (toString(_x) + ",") | |
132 | 137 | ||
133 | 138 | ||
134 | 139 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
135 | 140 | ||
136 | 141 | ||
137 | 142 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
138 | 143 | ||
139 | 144 | ||
140 | 145 | func abs (_x) = if ((_x > 0)) | |
141 | 146 | then _x | |
142 | 147 | else -(_x) | |
143 | 148 | ||
144 | 149 | ||
145 | 150 | func vmax (_x,_y) = if ((_x >= _y)) | |
146 | 151 | then _x | |
147 | 152 | else _y | |
148 | 153 | ||
149 | 154 | ||
150 | 155 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
151 | 156 | ||
152 | 157 | ||
153 | 158 | func listToStr (_list) = { | |
154 | 159 | func _join (accumulator,val) = ((accumulator + val) + ",") | |
155 | 160 | ||
156 | 161 | let newListStr = { | |
157 | 162 | let $l = _list | |
158 | 163 | let $s = size($l) | |
159 | 164 | let $acc0 = "" | |
160 | 165 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
161 | 166 | then $a | |
162 | 167 | else _join($a, $l[$i]) | |
163 | 168 | ||
164 | 169 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
165 | 170 | then $a | |
166 | 171 | else throw("List size exceeds 20") | |
167 | 172 | ||
168 | 173 | $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) | |
169 | 174 | } | |
170 | 175 | let newListStrU = dropRight(newListStr, 1) | |
171 | 176 | let newListStrR = if ((take(newListStrU, 1) == ",")) | |
172 | 177 | then drop(newListStrU, 1) | |
173 | 178 | else newListStrU | |
174 | 179 | newListStrR | |
175 | 180 | } | |
176 | 181 | ||
177 | 182 | ||
178 | 183 | func strToList (_str) = split(_str, ",") | |
179 | 184 | ||
180 | 185 | ||
181 | 186 | func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize)) | |
182 | 187 | then (removeByIndex(_list, 0) :+ _value) | |
183 | 188 | else (_list :+ _value) | |
184 | 189 | ||
185 | 190 | ||
186 | 191 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
187 | 192 | ||
188 | 193 | ||
189 | 194 | func cbalance () = int(k_balance) | |
190 | 195 | ||
191 | 196 | ||
192 | 197 | func fee () = int(k_fee) | |
193 | 198 | ||
194 | 199 | ||
195 | 200 | func initMarginRatio () = int(k_initMarginRatio) | |
196 | 201 | ||
197 | 202 | ||
198 | 203 | func qtAstR () = int(k_quoteAssetReserve) | |
199 | 204 | ||
200 | 205 | ||
201 | 206 | func bsAstR () = int(k_baseAssetReserve) | |
202 | 207 | ||
203 | 208 | ||
204 | 209 | func totalPositionSize () = int(k_totalPositionSize) | |
205 | 210 | ||
206 | 211 | ||
207 | 212 | func cumulativeNotional () = int(k_cumulativeNotional) | |
208 | 213 | ||
209 | 214 | ||
210 | 215 | func openInterestNotional () = int(k_openInterestNotional) | |
211 | 216 | ||
212 | 217 | ||
213 | 218 | func nextFundingBlockTimestamp () = int(k_nextFundingBlock) | |
214 | 219 | ||
215 | 220 | ||
216 | 221 | func fundingPeriodRaw () = int(k_fundingPeriod) | |
217 | 222 | ||
218 | 223 | ||
219 | 224 | func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT) | |
220 | 225 | ||
221 | 226 | ||
222 | 227 | func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS) | |
223 | 228 | ||
224 | 229 | ||
225 | 230 | func maintenanceMarginRatio () = int(k_maintenanceMarginRatio) | |
226 | 231 | ||
227 | 232 | ||
228 | 233 | func liquidationFeeRatio () = int(k_liquidationFeeRatio) | |
229 | 234 | ||
230 | 235 | ||
231 | 236 | func spreadLimit () = int(k_spreadLimit) | |
232 | 237 | ||
233 | 238 | ||
234 | 239 | func maxPriceImpact () = int(k_maxPriceImpact) | |
235 | 240 | ||
236 | 241 | ||
237 | 242 | func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction) | |
238 | 243 | ||
239 | 244 | ||
240 | 245 | func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction) | |
241 | 246 | ||
242 | 247 | ||
243 | 248 | func totalShortPositionSize () = int(k_totalShortPositionSize) | |
244 | 249 | ||
245 | 250 | ||
246 | 251 | func totalLongPositionSize () = int(k_totalLongPositionSize) | |
247 | 252 | ||
248 | 253 | ||
249 | 254 | func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = { | |
250 | 255 | let remainingMarginRatio = (_marginRatio - _baseMarginRatio) | |
251 | 256 | if (if (_largerThanOrEqualTo) | |
252 | 257 | then (0 > remainingMarginRatio) | |
253 | 258 | else false) | |
254 | 259 | then throw("Invalid margin") | |
255 | 260 | else if (if (!(_largerThanOrEqualTo)) | |
256 | 261 | then (remainingMarginRatio >= 0) | |
257 | 262 | else false) | |
258 | 263 | then throw("Invalid margin") | |
259 | 264 | else true | |
260 | 265 | } | |
261 | 266 | ||
262 | 267 | ||
263 | 268 | func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0)) | |
264 | 269 | then throw("Should not be called with _positionSize == 0") | |
265 | 270 | else if ((_positionSize > 0)) | |
266 | 271 | then latestLongCumulativePremiumFraction() | |
267 | 272 | else latestShortCumulativePremiumFraction() | |
268 | 273 | ||
269 | 274 | ||
270 | 275 | func getPosition (_trader) = { | |
271 | 276 | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader)) | |
272 | 277 | match positionSizeOpt { | |
273 | 278 | case positionSize: Int => | |
274 | 279 | $Tuple4(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader))) | |
275 | 280 | case _ => | |
276 | 281 | $Tuple4(0, 0, 0, 0) | |
277 | 282 | } | |
278 | 283 | } | |
279 | 284 | ||
280 | 285 | ||
281 | 286 | func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0)) | |
282 | 287 | then throw("No open position") | |
283 | 288 | else true | |
284 | 289 | ||
285 | 290 | ||
286 | 291 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
287 | 292 | ||
288 | 293 | ||
289 | 294 | func paused () = valueOrElse(getBoolean(this, k_paused), false) | |
290 | 295 | ||
291 | 296 | ||
292 | 297 | func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd) | |
293 | 298 | then { | |
294 | 299 | let newBase = (bsAstR() - _baseAssetAmount) | |
295 | 300 | if ((0 >= newBase)) | |
296 | 301 | then throw("Tx lead to base asset reserve <= 0, revert") | |
297 | 302 | else $Tuple4((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount), (cumulativeNotional() + _quoteAssetAmount)) | |
298 | 303 | } | |
299 | 304 | else { | |
300 | 305 | let newQuote = (qtAstR() - _quoteAssetAmount) | |
301 | 306 | if ((0 >= newQuote)) | |
302 | 307 | then throw("Tx lead to base quote reserve <= 0, revert") | |
303 | 308 | else $Tuple4(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount), (cumulativeNotional() - _quoteAssetAmount)) | |
304 | 309 | } | |
305 | 310 | ||
306 | 311 | ||
307 | 312 | func swapInput (_isAdd,_quoteAssetAmount) = { | |
308 | 313 | let _qtAstR = qtAstR() | |
309 | 314 | let _bsAstR = bsAstR() | |
310 | 315 | let priceBefore = divd(_qtAstR, _bsAstR) | |
311 | 316 | let amountBaseAssetBoughtWithoutPriceImpact = muld(_quoteAssetAmount, priceBefore) | |
312 | 317 | let k = muld(_qtAstR, _bsAstR) | |
313 | 318 | let quoteAssetReserveAfter = if (_isAdd) | |
314 | 319 | then (_qtAstR + _quoteAssetAmount) | |
315 | 320 | else (_qtAstR - _quoteAssetAmount) | |
316 | 321 | let baseAssetReserveAfter = divd(k, quoteAssetReserveAfter) | |
317 | 322 | let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR)) | |
318 | 323 | let amountBaseAssetBought = if (_isAdd) | |
319 | 324 | then amountBaseAssetBoughtAbs | |
320 | 325 | else -(amountBaseAssetBoughtAbs) | |
321 | 326 | let priceImpact = ((amountBaseAssetBoughtWithoutPriceImpact - amountBaseAssetBoughtAbs) / amountBaseAssetBoughtWithoutPriceImpact) | |
322 | 327 | let maxPriceImpactValue = maxPriceImpact() | |
323 | 328 | if ((priceImpact > maxPriceImpactValue)) | |
324 | 329 | then throw(((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue))) | |
325 | 330 | else { | |
326 | - | let $ | |
327 | - | let quoteAssetReserveAfter1 = $ | |
328 | - | let baseAssetReserveAfter1 = $ | |
329 | - | let totalPositionSizeAfter1 = $ | |
330 | - | let cumulativeNotionalAfter1 = $ | |
331 | + | let $t01236812571 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs) | |
332 | + | let quoteAssetReserveAfter1 = $t01236812571._1 | |
333 | + | let baseAssetReserveAfter1 = $t01236812571._2 | |
334 | + | let totalPositionSizeAfter1 = $t01236812571._3 | |
335 | + | let cumulativeNotionalAfter1 = $t01236812571._4 | |
331 | 336 | $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1) | |
332 | 337 | } | |
333 | 338 | } | |
334 | 339 | ||
335 | 340 | ||
336 | 341 | func calcRemainMarginWithFundingPayment (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_marginDelta) = { | |
337 | 342 | let fundingPayment = if ((_oldPositionSize != 0)) | |
338 | 343 | then { | |
339 | 344 | let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize) | |
340 | 345 | muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize) | |
341 | 346 | } | |
342 | 347 | else 0 | |
343 | 348 | let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin) | |
344 | - | let $ | |
349 | + | let $t01331813445 = if ((0 > signedMargin)) | |
345 | 350 | then $Tuple2(0, abs(signedMargin)) | |
346 | 351 | else $Tuple2(abs(signedMargin), 0) | |
347 | - | let remainMargin = $ | |
348 | - | let badDebt = $ | |
352 | + | let remainMargin = $t01331813445._1 | |
353 | + | let badDebt = $t01331813445._2 | |
349 | 354 | $Tuple3(remainMargin, badDebt, fundingPayment) | |
350 | 355 | } | |
351 | 356 | ||
352 | 357 | ||
353 | 358 | func swapOutput (_isAdd,_baseAssetAmount) = { | |
354 | 359 | let _quoteAssetReserve = qtAstR() | |
355 | 360 | let _baseAssetReserve = bsAstR() | |
356 | 361 | if ((_baseAssetAmount == 0)) | |
357 | 362 | then throw("Invalid base asset amount") | |
358 | 363 | else { | |
359 | 364 | let k = muld(_quoteAssetReserve, _baseAssetReserve) | |
360 | 365 | let baseAssetPoolAmountAfter = if (_isAdd) | |
361 | 366 | then (_baseAssetReserve + _baseAssetAmount) | |
362 | 367 | else (_baseAssetReserve - _baseAssetAmount) | |
363 | 368 | let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter) | |
364 | 369 | let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve)) | |
365 | - | let $ | |
366 | - | let quoteAssetReserveAfter1 = $ | |
367 | - | let baseAssetReserveAfter1 = $ | |
368 | - | let totalPositionSizeAfter1 = $ | |
369 | - | let cumulativeNotionalAfter1 = $ | |
370 | + | let $t01428314476 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount) | |
371 | + | let quoteAssetReserveAfter1 = $t01428314476._1 | |
372 | + | let baseAssetReserveAfter1 = $t01428314476._2 | |
373 | + | let totalPositionSizeAfter1 = $t01428314476._3 | |
374 | + | let cumulativeNotionalAfter1 = $t01428314476._4 | |
370 | 375 | $Tuple7(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd) | |
371 | 376 | then abs(_baseAssetAmount) | |
372 | 377 | else 0)), (totalShortPositionSize() - (if (!(_isAdd)) | |
373 | 378 | then abs(_baseAssetAmount) | |
374 | 379 | else 0))) | |
375 | 380 | } | |
376 | 381 | } | |
377 | 382 | ||
378 | 383 | ||
379 | 384 | func getOracleTwapPrice () = { | |
380 | 385 | let oracle = valueOrErrorMessage(addressFromString(getStringValue(this, k_ora)), "") | |
381 | 386 | let priceKey = getStringValue(this, k_ora_key) | |
382 | 387 | let blockKey = getStringValue(this, k_ora_block_key) | |
383 | 388 | let lastValue = getIntegerValue(oracle, priceKey) | |
384 | 389 | lastValue | |
385 | 390 | } | |
386 | 391 | ||
387 | 392 | ||
388 | 393 | func getSpotPrice () = { | |
389 | 394 | let _quoteAssetReserve = qtAstR() | |
390 | 395 | let _baseAssetReserve = bsAstR() | |
391 | 396 | divd(_quoteAssetReserve, _baseAssetReserve) | |
392 | 397 | } | |
393 | 398 | ||
394 | 399 | ||
395 | 400 | func isOverFluctuationLimit () = { | |
396 | 401 | let oraclePrice = getOracleTwapPrice() | |
397 | 402 | let currentPrice = getSpotPrice() | |
398 | 403 | (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit()) | |
399 | 404 | } | |
400 | 405 | ||
401 | 406 | ||
402 | 407 | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
403 | - | let $ | |
404 | - | let positionSize = $ | |
405 | - | let positionMargin = $ | |
406 | - | let positionOpenNotional = $ | |
407 | - | let positionLstUpdCPF = $ | |
408 | + | let $t01610816236 = getPosition(_trader) | |
409 | + | let positionSize = $t01610816236._1 | |
410 | + | let positionMargin = $t01610816236._2 | |
411 | + | let positionOpenNotional = $t01610816236._3 | |
412 | + | let positionLstUpdCPF = $t01610816236._4 | |
408 | 413 | let positionSizeAbs = abs(positionSize) | |
409 | 414 | if ((positionSizeAbs == 0)) | |
410 | 415 | then throw("Invalid position size") | |
411 | 416 | else { | |
412 | 417 | let isShort = (0 > positionSize) | |
413 | 418 | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
414 | 419 | then { | |
415 | - | let $ | |
416 | - | let outPositionNotional = $ | |
417 | - | let x1 = $ | |
418 | - | let x2 = $ | |
419 | - | let x3 = $ | |
420 | + | let $t01648316590 = swapOutput(!(isShort), positionSizeAbs) | |
421 | + | let outPositionNotional = $t01648316590._1 | |
422 | + | let x1 = $t01648316590._2 | |
423 | + | let x2 = $t01648316590._3 | |
424 | + | let x3 = $t01648316590._4 | |
420 | 425 | outPositionNotional | |
421 | 426 | } | |
422 | 427 | else muld(positionSizeAbs, getOracleTwapPrice()) | |
423 | 428 | let unrealizedPnl = if (isShort) | |
424 | 429 | then (positionOpenNotional - positionNotional) | |
425 | 430 | else (positionNotional - positionOpenNotional) | |
426 | 431 | $Tuple2(positionNotional, unrealizedPnl) | |
427 | 432 | } | |
428 | 433 | } | |
429 | 434 | ||
430 | 435 | ||
431 | 436 | func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional) | |
432 | 437 | ||
433 | 438 | ||
434 | 439 | func getMarginRatioByOption (_trader,_option) = { | |
435 | - | let $ | |
436 | - | let positionSize = $ | |
437 | - | let positionMargin = $ | |
438 | - | let pon = $ | |
439 | - | let positionLstUpdCPF = $ | |
440 | - | let $ | |
441 | - | let positionNotional = $ | |
442 | - | let unrealizedPnl = $ | |
443 | - | let $ | |
444 | - | let remainMargin = $ | |
445 | - | let badDebt = $ | |
440 | + | let $t01726017371 = getPosition(_trader) | |
441 | + | let positionSize = $t01726017371._1 | |
442 | + | let positionMargin = $t01726017371._2 | |
443 | + | let pon = $t01726017371._3 | |
444 | + | let positionLstUpdCPF = $t01726017371._4 | |
445 | + | let $t01737717470 = getPositionNotionalAndUnrealizedPnl(_trader, _option) | |
446 | + | let positionNotional = $t01737717470._1 | |
447 | + | let unrealizedPnl = $t01737717470._2 | |
448 | + | let $t01747517641 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
449 | + | let remainMargin = $t01747517641._1 | |
450 | + | let badDebt = $t01747517641._2 | |
446 | 451 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
447 | 452 | } | |
448 | 453 | ||
449 | 454 | ||
450 | 455 | func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
451 | 456 | ||
452 | 457 | ||
453 | 458 | func internalClosePosition (_trader) = { | |
454 | - | let $ | |
455 | - | let positionSize = $ | |
456 | - | let positionMargin = $ | |
457 | - | let positionOpenNotional = $ | |
458 | - | let positionLstUpdCPF = $ | |
459 | - | let $ | |
460 | - | let x1 = $ | |
461 | - | let unrealizedPnl = $ | |
462 | - | let $ | |
463 | - | let remainMargin = $ | |
464 | - | let badDebt = $ | |
459 | + | let $t01795718085 = getPosition(_trader) | |
460 | + | let positionSize = $t01795718085._1 | |
461 | + | let positionMargin = $t01795718085._2 | |
462 | + | let positionOpenNotional = $t01795718085._3 | |
463 | + | let positionLstUpdCPF = $t01795718085._4 | |
464 | + | let $t01809118178 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
465 | + | let x1 = $t01809118178._1 | |
466 | + | let unrealizedPnl = $t01809118178._2 | |
467 | + | let $t01818318351 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
468 | + | let remainMargin = $t01818318351._1 | |
469 | + | let badDebt = $t01818318351._2 | |
465 | 470 | let exchangedPositionSize = -(positionSize) | |
466 | 471 | let realizedPnl = unrealizedPnl | |
467 | 472 | let marginToVault = -(remainMargin) | |
468 | - | let $ | |
469 | - | let exchangedQuoteAssetAmount = $ | |
470 | - | let quoteAssetReserveAfter = $ | |
471 | - | let baseAssetReserveAfter = $ | |
472 | - | let totalPositionSizeAfter = $ | |
473 | - | let cumulativeNotionalAfter = $ | |
474 | - | let totalLongAfter = $ | |
475 | - | let totalShortAfter = $ | |
473 | + | let $t01847818759 = swapOutput((positionSize > 0), abs(positionSize)) | |
474 | + | let exchangedQuoteAssetAmount = $t01847818759._1 | |
475 | + | let quoteAssetReserveAfter = $t01847818759._2 | |
476 | + | let baseAssetReserveAfter = $t01847818759._3 | |
477 | + | let totalPositionSizeAfter = $t01847818759._4 | |
478 | + | let cumulativeNotionalAfter = $t01847818759._5 | |
479 | + | let totalLongAfter = $t01847818759._6 | |
480 | + | let totalShortAfter = $t01847818759._7 | |
476 | 481 | let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional) | |
477 | 482 | $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter) | |
478 | 483 | } | |
479 | 484 | ||
480 | 485 | ||
481 | 486 | func getTwapSpotPrice () = { | |
482 | 487 | let minuteId = ((lastBlock.timestamp / 1000) / 60) | |
483 | 488 | let startMinuteId = (minuteId - TWAP_INTERVAL) | |
484 | 489 | let listStr = valueOrElse(getString(this, k_lastDataStr), "") | |
485 | 490 | let list = split(listStr, ",") | |
486 | 491 | func filterFn (accumulator,next) = if ((startMinuteId >= parseIntValue(next))) | |
487 | 492 | then (accumulator :+ parseIntValue(next)) | |
488 | 493 | else accumulator | |
489 | 494 | ||
490 | 495 | let listF = { | |
491 | 496 | let $l = list | |
492 | 497 | let $s = size($l) | |
493 | 498 | let $acc0 = nil | |
494 | 499 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
495 | 500 | then $a | |
496 | 501 | else filterFn($a, $l[$i]) | |
497 | 502 | ||
498 | 503 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
499 | 504 | then $a | |
500 | 505 | else throw("List size exceeds 20") | |
501 | 506 | ||
502 | 507 | $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) | |
503 | 508 | } | |
504 | 509 | let maxIndex = if ((size(listF) > 0)) | |
505 | 510 | then max(listF) | |
506 | 511 | else parseIntValue(list[0]) | |
507 | 512 | let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
508 | 513 | let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0) | |
509 | 514 | let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0) | |
510 | 515 | let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice)) | |
511 | 516 | let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0) | |
512 | 517 | let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0) | |
513 | 518 | let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice)) | |
514 | 519 | ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL) | |
515 | 520 | } | |
516 | 521 | ||
517 | 522 | ||
518 | 523 | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = [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)] | |
519 | 524 | ||
520 | 525 | ||
521 | 526 | 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)] | |
522 | 527 | ||
523 | 528 | ||
524 | 529 | 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)] | |
525 | 530 | ||
526 | 531 | ||
527 | 532 | func appendTwap (price) = { | |
528 | 533 | let minuteId = ((lastBlock.timestamp / 1000) / 60) | |
529 | 534 | let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
530 | 535 | if ((previousMinuteId > minuteId)) | |
531 | 536 | then throw("TWAP out-of-order") | |
532 | 537 | else { | |
533 | 538 | let lastMinuteId = if ((previousMinuteId == 0)) | |
534 | 539 | then minuteId | |
535 | 540 | else previousMinuteId | |
536 | 541 | if ((minuteId > previousMinuteId)) | |
537 | 542 | then { | |
538 | 543 | let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0) | |
539 | 544 | let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), price) | |
540 | 545 | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice)) | |
541 | 546 | let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId)) | |
542 | 547 | [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))] | |
543 | 548 | } | |
544 | 549 | else { | |
545 | 550 | let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0) | |
546 | 551 | let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0) | |
547 | 552 | let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), price) | |
548 | 553 | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice)) | |
549 | 554 | [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), price)] | |
550 | 555 | } | |
551 | 556 | } | |
552 | 557 | } | |
553 | 558 | ||
554 | 559 | ||
555 | 560 | func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_cumulativeNotionalAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize) = if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter)) | |
556 | 561 | then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter))) | |
557 | 562 | else ([IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _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))) | |
558 | 563 | ||
559 | 564 | ||
560 | 565 | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address))] | |
561 | 566 | ||
562 | 567 | ||
563 | 568 | func withdraw (_address,_amount) = { | |
564 | 569 | let balance = assetBalance(this, quoteAsset()) | |
565 | 570 | if ((_amount > balance)) | |
566 | 571 | then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance))) | |
567 | 572 | else [ScriptTransfer(_address, _amount, quoteAsset())] | |
568 | 573 | } | |
569 | 574 | ||
570 | 575 | ||
571 | 576 | func updateBalance (i) = if ((0 > i)) | |
572 | 577 | then throw("Balance") | |
573 | 578 | else [IntegerEntry(k_balance, i)] | |
574 | 579 | ||
575 | 580 | ||
576 | 581 | func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())] | |
577 | 582 | ||
578 | 583 | ||
579 | 584 | @Callable(i) | |
580 | 585 | func pause () = if ((i.caller != adminAddress())) | |
581 | 586 | then throw("Invalid togglePause params") | |
582 | 587 | else [BooleanEntry(k_paused, true)] | |
583 | 588 | ||
584 | 589 | ||
585 | 590 | ||
586 | 591 | @Callable(i) | |
587 | 592 | func unpause () = if ((i.caller != adminAddress())) | |
588 | 593 | then throw("Invalid togglePause params") | |
589 | 594 | else [BooleanEntry(k_paused, false)] | |
590 | 595 | ||
591 | 596 | ||
592 | 597 | ||
593 | 598 | @Callable(i) | |
594 | 599 | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = if ((i.caller != adminAddress())) | |
595 | 600 | then throw("Invalid changeSettings params") | |
596 | 601 | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact) | |
597 | 602 | ||
598 | 603 | ||
599 | 604 | ||
600 | 605 | @Callable(i) | |
601 | 606 | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact) = if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
602 | 607 | then true | |
603 | 608 | else (0 >= _bsAstR)) | |
604 | 609 | then true | |
605 | 610 | else (0 >= _fundingPeriod)) | |
606 | 611 | then true | |
607 | 612 | else (0 >= _initMarginRatio)) | |
608 | 613 | then true | |
609 | 614 | else (0 >= _mmr)) | |
610 | 615 | then true | |
611 | 616 | else (0 >= _liquidationFeeRatio)) | |
612 | 617 | then true | |
613 | 618 | else (0 >= _fee)) | |
614 | 619 | then true | |
615 | 620 | else (0 >= _spreadLimit)) | |
616 | 621 | then true | |
617 | 622 | else (0 >= _maxPriceImpact)) | |
618 | 623 | then true | |
619 | 624 | else initialized()) | |
620 | 625 | then throw("Invalid initialize parameters") | |
621 | 626 | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact)) ++ 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)]) | |
622 | 627 | ||
623 | 628 | ||
624 | 629 | ||
625 | 630 | @Callable(i) | |
626 | 631 | func decreasePosition (_amount,_leverage,_minBaseAssetAmount) = if (if (if (if (if (if ((0 >= _amount)) | |
627 | 632 | then true | |
628 | 633 | else if (((1 * DECIMAL_UNIT) > _leverage)) | |
629 | 634 | then true | |
630 | 635 | else (_leverage > (3 * DECIMAL_UNIT))) | |
631 | 636 | then true | |
632 | 637 | else !(initialized())) | |
633 | 638 | then true | |
634 | 639 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
635 | 640 | then true | |
636 | 641 | else !(requireOpenPosition(toString(i.caller)))) | |
637 | 642 | then true | |
638 | 643 | else paused()) | |
639 | 644 | then throw("Invalid decreasePosition parameters") | |
640 | 645 | else { | |
641 | - | let $ | |
642 | - | let oldPositionSize = $ | |
643 | - | let oldPositionMargin = $ | |
644 | - | let oldPositionOpenNotional = $ | |
645 | - | let oldPositionLstUpdCPF = $ | |
646 | + | let $t02860028752 = getPosition(toString(i.caller)) | |
647 | + | let oldPositionSize = $t02860028752._1 | |
648 | + | let oldPositionMargin = $t02860028752._2 | |
649 | + | let oldPositionOpenNotional = $t02860028752._3 | |
650 | + | let oldPositionLstUpdCPF = $t02860028752._4 | |
646 | 651 | let _direction = if ((oldPositionSize > 0)) | |
647 | 652 | then DIR_SHORT | |
648 | 653 | else DIR_LONG | |
649 | 654 | let isAdd = (_direction == DIR_LONG) | |
650 | 655 | let openNotional = muld(_amount, _leverage) | |
651 | - | let $ | |
652 | - | let oldPositionNotional = $ | |
653 | - | let unrealizedPnl = $ | |
654 | - | let $ | |
656 | + | let $t02892529041 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
657 | + | let oldPositionNotional = $t02892529041._1 | |
658 | + | let unrealizedPnl = $t02892529041._2 | |
659 | + | let $t02904731596 = if ((oldPositionNotional > openNotional)) | |
655 | 660 | then { | |
656 | - | let $ | |
657 | - | let exchangedPositionSize = $ | |
658 | - | let quoteAssetReserveAfter = $ | |
659 | - | let baseAssetReserveAfter = $ | |
660 | - | let totalPositionSizeAfter = $ | |
661 | - | let cumulativeNotionalAfter = $ | |
661 | + | let $t02942429643 = swapInput(isAdd, openNotional) | |
662 | + | let exchangedPositionSize = $t02942429643._1 | |
663 | + | let quoteAssetReserveAfter = $t02942429643._2 | |
664 | + | let baseAssetReserveAfter = $t02942429643._3 | |
665 | + | let totalPositionSizeAfter = $t02942429643._4 | |
666 | + | let cumulativeNotionalAfter = $t02942429643._5 | |
662 | 667 | let exchangedPositionSizeAbs = abs(exchangedPositionSize) | |
663 | 668 | if (if ((_minBaseAssetAmount != 0)) | |
664 | 669 | then (_minBaseAssetAmount > exchangedPositionSizeAbs) | |
665 | 670 | else false) | |
666 | 671 | then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount))) | |
667 | 672 | else { | |
668 | 673 | let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize)) | |
669 | - | let $ | |
670 | - | let remainMargin = $ | |
671 | - | let badDebt = $ | |
672 | - | let fundingPayment = $ | |
674 | + | let $t03008030325 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
675 | + | let remainMargin = $t03008030325._1 | |
676 | + | let badDebt = $t03008030325._2 | |
677 | + | let fundingPayment = $t03008030325._3 | |
673 | 678 | let exchangedQuoteAssetAmount = openNotional | |
674 | 679 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
675 | 680 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
676 | 681 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
677 | 682 | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
678 | 683 | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
679 | 684 | $Tuple11(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
680 | 685 | then abs(exchangedPositionSize) | |
681 | 686 | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
682 | 687 | then abs(exchangedPositionSize) | |
683 | 688 | else 0))) | |
684 | 689 | } | |
685 | 690 | } | |
686 | 691 | else throw("Close position first") | |
687 | - | let newPositionSize = $t02883331382._1 | |
688 | - | let newPositionRemainMargin = $t02883331382._2 | |
689 | - | let newPositionOpenNotional = $t02883331382._3 | |
690 | - | let newPositionLatestCPF = $t02883331382._4 | |
691 | - | let baseAssetReserveAfter = $t02883331382._5 | |
692 | - | let quoteAssetReserveAfter = $t02883331382._6 | |
693 | - | let totalPositionSizeAfter = $t02883331382._7 | |
694 | - | let cumulativeNotionalAfter = $t02883331382._8 | |
695 | - | let openInterestNotionalAfter = $t02883331382._9 | |
696 | - | let totalLongAfter = $t02883331382._10 | |
697 | - | let totalShortAfter = $t02883331382._11 | |
698 | - | (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
692 | + | let newPositionSize = $t02904731596._1 | |
693 | + | let newPositionRemainMargin = $t02904731596._2 | |
694 | + | let newPositionOpenNotional = $t02904731596._3 | |
695 | + | let newPositionLatestCPF = $t02904731596._4 | |
696 | + | let baseAssetReserveAfter = $t02904731596._5 | |
697 | + | let quoteAssetReserveAfter = $t02904731596._6 | |
698 | + | let totalPositionSizeAfter = $t02904731596._7 | |
699 | + | let cumulativeNotionalAfter = $t02904731596._8 | |
700 | + | let openInterestNotionalAfter = $t02904731596._9 | |
701 | + | let totalLongAfter = $t02904731596._10 | |
702 | + | let totalShortAfter = $t02904731596._11 | |
703 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
704 | + | if ((notifyNotional == notifyNotional)) | |
705 | + | then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
706 | + | else throw("Strict value is not equal to itself.") | |
699 | 707 | } | |
700 | 708 | ||
701 | 709 | ||
702 | 710 | ||
703 | 711 | @Callable(i) | |
704 | 712 | func increasePosition (_direction,_leverage,_minBaseAssetAmount) = { | |
705 | 713 | let _rawAmount = i.payments[0].amount | |
706 | 714 | if (if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
707 | 715 | then (_direction != DIR_SHORT) | |
708 | 716 | else false) | |
709 | 717 | then true | |
710 | 718 | else (0 >= _rawAmount)) | |
711 | 719 | then true | |
712 | 720 | else if (((1 * DECIMAL_UNIT) > _leverage)) | |
713 | 721 | then true | |
714 | 722 | else (_leverage > (3 * DECIMAL_UNIT))) | |
715 | 723 | then true | |
716 | 724 | else !(initialized())) | |
717 | 725 | then true | |
718 | 726 | else (i.payments[0].assetId != quoteAsset())) | |
719 | 727 | then true | |
720 | 728 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
721 | 729 | then true | |
722 | 730 | else paused()) | |
723 | 731 | then throw("Invalid increasePosition parameters") | |
724 | 732 | else { | |
725 | 733 | let feeAmount = muld(_rawAmount, fee()) | |
726 | 734 | let _amount = (_rawAmount - feeAmount) | |
727 | - | let $ | |
728 | - | let oldPositionSize = $ | |
729 | - | let oldPositionMargin = $ | |
730 | - | let oldPositionOpenNotional = $ | |
731 | - | let oldPositionLstUpdCPF = $ | |
735 | + | let $t03278432936 = getPosition(toString(i.caller)) | |
736 | + | let oldPositionSize = $t03278432936._1 | |
737 | + | let oldPositionMargin = $t03278432936._2 | |
738 | + | let oldPositionOpenNotional = $t03278432936._3 | |
739 | + | let oldPositionLstUpdCPF = $t03278432936._4 | |
732 | 740 | let isNewPosition = (oldPositionSize == 0) | |
733 | 741 | let isSameDirection = if ((oldPositionSize > 0)) | |
734 | 742 | then (_direction == DIR_LONG) | |
735 | 743 | else (_direction == DIR_SHORT) | |
736 | 744 | let expandExisting = if (!(isNewPosition)) | |
737 | 745 | then isSameDirection | |
738 | 746 | else false | |
739 | 747 | let isAdd = (_direction == DIR_LONG) | |
740 | - | let $ | |
748 | + | let $t03322535614 = if (if (isNewPosition) | |
741 | 749 | then true | |
742 | 750 | else expandExisting) | |
743 | 751 | then { | |
744 | 752 | let openNotional = muld(_amount, _leverage) | |
745 | - | let $ | |
746 | - | let amountBaseAssetBought = $ | |
747 | - | let quoteAssetReserveAfter = $ | |
748 | - | let baseAssetReserveAfter = $ | |
749 | - | let totalPositionSizeAfter = $ | |
750 | - | let cumulativeNotionalAfter = $ | |
753 | + | let $t03364933855 = swapInput(isAdd, openNotional) | |
754 | + | let amountBaseAssetBought = $t03364933855._1 | |
755 | + | let quoteAssetReserveAfter = $t03364933855._2 | |
756 | + | let baseAssetReserveAfter = $t03364933855._3 | |
757 | + | let totalPositionSizeAfter = $t03364933855._4 | |
758 | + | let cumulativeNotionalAfter = $t03364933855._5 | |
751 | 759 | if (if ((_minBaseAssetAmount != 0)) | |
752 | 760 | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
753 | 761 | else false) | |
754 | 762 | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
755 | 763 | else { | |
756 | 764 | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
757 | 765 | let increaseMarginRequirement = divd(openNotional, _leverage) | |
758 | - | let $ | |
759 | - | let remainMargin = $ | |
760 | - | let x1 = $ | |
761 | - | let x2 = $ | |
766 | + | let $t03423634475 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
767 | + | let remainMargin = $t03423634475._1 | |
768 | + | let x1 = $t03423634475._2 | |
769 | + | let x2 = $t03423634475._3 | |
762 | 770 | $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
763 | 771 | then abs(amountBaseAssetBought) | |
764 | 772 | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
765 | 773 | then abs(amountBaseAssetBought) | |
766 | 774 | else 0))) | |
767 | 775 | } | |
768 | 776 | } | |
769 | 777 | else { | |
770 | 778 | let openNotional = muld(_amount, _leverage) | |
771 | - | let $ | |
772 | - | let oldPositionNotional = $ | |
773 | - | let unrealizedPnl = $ | |
779 | + | let $t03530735423 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
780 | + | let oldPositionNotional = $t03530735423._1 | |
781 | + | let unrealizedPnl = $t03530735423._2 | |
774 | 782 | if ((oldPositionNotional > openNotional)) | |
775 | 783 | then throw("Use decreasePosition to decrease position size") | |
776 | 784 | else throw("Close position first") | |
777 | 785 | } | |
778 | - | let newPositionSize = $ | |
779 | - | let newPositionRemainMargin = $ | |
780 | - | let newPositionOpenNotional = $ | |
781 | - | let newPositionLatestCPF = $ | |
782 | - | let baseAssetReserveAfter = $ | |
783 | - | let quoteAssetReserveAfter = $ | |
784 | - | let totalPositionSizeAfter = $ | |
785 | - | let cumulativeNotionalAfter = $ | |
786 | - | let openInterestNotionalAfter = $ | |
787 | - | let totalLongAfter = $ | |
788 | - | let totalShortAfter = $ | |
786 | + | let newPositionSize = $t03322535614._1 | |
787 | + | let newPositionRemainMargin = $t03322535614._2 | |
788 | + | let newPositionOpenNotional = $t03322535614._3 | |
789 | + | let newPositionLatestCPF = $t03322535614._4 | |
790 | + | let baseAssetReserveAfter = $t03322535614._5 | |
791 | + | let quoteAssetReserveAfter = $t03322535614._6 | |
792 | + | let totalPositionSizeAfter = $t03322535614._7 | |
793 | + | let cumulativeNotionalAfter = $t03322535614._8 | |
794 | + | let openInterestNotionalAfter = $t03322535614._9 | |
795 | + | let totalLongAfter = $t03322535614._10 | |
796 | + | let totalShortAfter = $t03322535614._11 | |
789 | 797 | let feeToStakers = (feeAmount / 2) | |
790 | 798 | let feeToInsurance = (feeAmount - feeToStakers) | |
791 | 799 | let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)]) | |
792 | 800 | if ((stake == stake)) | |
793 | 801 | then { | |
794 | 802 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
795 | 803 | if ((depositInsurance == depositInsurance)) | |
796 | - | then (((updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
804 | + | then { | |
805 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [toString(i.caller), feeAmount], nil) | |
806 | + | if ((notifyFee == notifyFee)) | |
807 | + | then { | |
808 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
809 | + | if ((notifyNotional == notifyNotional)) | |
810 | + | then (((updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
811 | + | else throw("Strict value is not equal to itself.") | |
812 | + | } | |
813 | + | else throw("Strict value is not equal to itself.") | |
814 | + | } | |
797 | 815 | else throw("Strict value is not equal to itself.") | |
798 | 816 | } | |
799 | 817 | else throw("Strict value is not equal to itself.") | |
800 | 818 | } | |
801 | 819 | } | |
802 | 820 | ||
803 | 821 | ||
804 | 822 | ||
805 | 823 | @Callable(i) | |
806 | 824 | func addMargin () = { | |
807 | 825 | let _rawAmount = i.payments[0].amount | |
808 | 826 | if (if (if (if ((i.payments[0].assetId != quoteAsset())) | |
809 | 827 | then true | |
810 | 828 | else !(requireOpenPosition(toString(i.caller)))) | |
811 | 829 | then true | |
812 | 830 | else !(initialized())) | |
813 | 831 | then true | |
814 | 832 | else paused()) | |
815 | 833 | then throw("Invalid addMargin parameters") | |
816 | 834 | else { | |
817 | 835 | let feeAmount = muld(_rawAmount, fee()) | |
818 | 836 | let _amount = (_rawAmount - feeAmount) | |
819 | - | let $ | |
820 | - | let oldPositionSize = $ | |
821 | - | let oldPositionMargin = $ | |
822 | - | let oldPositionOpenNotional = $ | |
823 | - | let oldPositionLstUpdCPF = $ | |
837 | + | let $t03717037322 = getPosition(toString(i.caller)) | |
838 | + | let oldPositionSize = $t03717037322._1 | |
839 | + | let oldPositionMargin = $t03717037322._2 | |
840 | + | let oldPositionOpenNotional = $t03717037322._3 | |
841 | + | let oldPositionLstUpdCPF = $t03717037322._4 | |
824 | 842 | let feeToStakers = (feeAmount / 2) | |
825 | 843 | let feeToInsurance = (feeAmount - feeToStakers) | |
826 | 844 | let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)]) | |
827 | 845 | if ((stake == stake)) | |
828 | 846 | then { | |
829 | 847 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
830 | 848 | if ((depositInsurance == depositInsurance)) | |
831 | - | then ((updatePosition(toString(i.caller), oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
849 | + | then { | |
850 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [toString(i.caller), feeAmount], nil) | |
851 | + | if ((notifyFee == notifyFee)) | |
852 | + | then ((updatePosition(toString(i.caller), oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
853 | + | else throw("Strict value is not equal to itself.") | |
854 | + | } | |
832 | 855 | else throw("Strict value is not equal to itself.") | |
833 | 856 | } | |
834 | 857 | else throw("Strict value is not equal to itself.") | |
835 | 858 | } | |
836 | 859 | } | |
837 | 860 | ||
838 | 861 | ||
839 | 862 | ||
840 | 863 | @Callable(i) | |
841 | 864 | func removeMargin (_amount) = if (if (if (if ((0 >= _amount)) | |
842 | 865 | then true | |
843 | 866 | else !(requireOpenPosition(toString(i.caller)))) | |
844 | 867 | then true | |
845 | 868 | else !(initialized())) | |
846 | 869 | then true | |
847 | 870 | else paused()) | |
848 | 871 | then throw("Invalid removeMargin parameters") | |
849 | 872 | else { | |
850 | - | let $ | |
851 | - | let oldPositionSize = $ | |
852 | - | let oldPositionMargin = $ | |
853 | - | let oldPositionOpenNotional = $ | |
854 | - | let oldPositionLstUpdCPF = $ | |
873 | + | let $t03837138523 = getPosition(toString(i.caller)) | |
874 | + | let oldPositionSize = $t03837138523._1 | |
875 | + | let oldPositionMargin = $t03837138523._2 | |
876 | + | let oldPositionOpenNotional = $t03837138523._3 | |
877 | + | let oldPositionLstUpdCPF = $t03837138523._4 | |
855 | 878 | let marginDelta = -(_amount) | |
856 | - | let $ | |
857 | - | let remainMargin = $ | |
858 | - | let badDebt = $ | |
879 | + | let $t03856038739 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
880 | + | let remainMargin = $t03856038739._1 | |
881 | + | let badDebt = $t03856038739._2 | |
859 | 882 | if ((badDebt != 0)) | |
860 | 883 | then throw("Invalid removed margin amount") | |
861 | 884 | else { | |
862 | 885 | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
863 | 886 | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
864 | 887 | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
865 | 888 | else { | |
866 | 889 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [_amount, toBase58String(quoteAsset())], nil) | |
867 | 890 | if ((unstake == unstake)) | |
868 | 891 | then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount))) | |
869 | 892 | else throw("Strict value is not equal to itself.") | |
870 | 893 | } | |
871 | 894 | } | |
872 | 895 | } | |
873 | 896 | ||
874 | 897 | ||
875 | 898 | ||
876 | 899 | @Callable(i) | |
877 | 900 | func closePosition () = if (if (if (!(requireOpenPosition(toString(i.caller)))) | |
878 | 901 | then true | |
879 | 902 | else !(initialized())) | |
880 | 903 | then true | |
881 | 904 | else paused()) | |
882 | 905 | then throw("Invalid closePosition parameters") | |
883 | 906 | else { | |
884 | - | let $ | |
885 | - | let x1 = $ | |
886 | - | let positionBadDebt = $ | |
887 | - | let realizedPnl = $ | |
888 | - | let marginToVault = $ | |
889 | - | let quoteAssetReserveAfter = $ | |
890 | - | let baseAssetReserveAfter = $ | |
891 | - | let totalPositionSizeAfter = $ | |
892 | - | let cumulativeNotionalAfter = $ | |
893 | - | let openInterestNotionalAfter = $ | |
894 | - | let x2 = $ | |
895 | - | let totalLongAfter = $ | |
896 | - | let totalShortAfter = $ | |
907 | + | let $t03983540219 = internalClosePosition(toString(i.caller)) | |
908 | + | let x1 = $t03983540219._1 | |
909 | + | let positionBadDebt = $t03983540219._2 | |
910 | + | let realizedPnl = $t03983540219._3 | |
911 | + | let marginToVault = $t03983540219._4 | |
912 | + | let quoteAssetReserveAfter = $t03983540219._5 | |
913 | + | let baseAssetReserveAfter = $t03983540219._6 | |
914 | + | let totalPositionSizeAfter = $t03983540219._7 | |
915 | + | let cumulativeNotionalAfter = $t03983540219._8 | |
916 | + | let openInterestNotionalAfter = $t03983540219._9 | |
917 | + | let x2 = $t03983540219._10 | |
918 | + | let totalLongAfter = $t03983540219._11 | |
919 | + | let totalShortAfter = $t03983540219._12 | |
897 | 920 | if ((positionBadDebt > 0)) | |
898 | 921 | then throw("Unable to close position with bad debt") | |
899 | 922 | else { | |
900 | 923 | let withdrawAmount = abs(marginToVault) | |
901 | 924 | let ammBalance = (cbalance() - withdrawAmount) | |
902 | - | let $ | |
925 | + | let $t04042840570 = if ((0 > ammBalance)) | |
903 | 926 | then $Tuple2(0, abs(ammBalance)) | |
904 | 927 | else $Tuple2(ammBalance, 0) | |
905 | - | let ammNewBalance = $ | |
906 | - | let getFromInsurance = $ | |
928 | + | let ammNewBalance = $t04042840570._1 | |
929 | + | let getFromInsurance = $t04042840570._2 | |
907 | 930 | let x = if ((getFromInsurance > 0)) | |
908 | 931 | then { | |
909 | 932 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil) | |
910 | 933 | if ((withdrawInsurance == withdrawInsurance)) | |
911 | 934 | then nil | |
912 | 935 | else throw("Strict value is not equal to itself.") | |
913 | 936 | } | |
914 | 937 | else nil | |
915 | 938 | if ((x == x)) | |
916 | 939 | then { | |
917 | 940 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(withdrawAmount - getFromInsurance), toBase58String(quoteAsset())], nil) | |
918 | 941 | if ((unstake == unstake)) | |
919 | - | then (((deletePosition(toString(i.caller)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
942 | + | then { | |
943 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), 0], nil) | |
944 | + | if ((notifyNotional == notifyNotional)) | |
945 | + | then (((deletePosition(toString(i.caller)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
946 | + | else throw("Strict value is not equal to itself.") | |
947 | + | } | |
920 | 948 | else throw("Strict value is not equal to itself.") | |
921 | 949 | } | |
922 | 950 | else throw("Strict value is not equal to itself.") | |
923 | 951 | } | |
924 | 952 | } | |
925 | 953 | ||
926 | 954 | ||
927 | 955 | ||
928 | 956 | @Callable(i) | |
929 | 957 | func liquidate (_trader) = { | |
930 | 958 | let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
931 | 959 | let marginRatio = if (isOverFluctuationLimit()) | |
932 | 960 | then { | |
933 | 961 | let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE) | |
934 | 962 | vmax(spotMarginRatio, oracleMarginRatio) | |
935 | 963 | } | |
936 | 964 | else spotMarginRatio | |
937 | 965 | if (if (if (if (!(requireMoreMarginRatio(marginRatio, maintenanceMarginRatio(), false))) | |
938 | 966 | then true | |
939 | 967 | else !(requireOpenPosition(_trader))) | |
940 | 968 | then true | |
941 | 969 | else !(initialized())) | |
942 | 970 | then true | |
943 | 971 | else paused()) | |
944 | 972 | then throw("Unable to liquidate") | |
945 | 973 | else { | |
946 | - | let $ | |
947 | - | let x1 = $ | |
948 | - | let badDebt = $ | |
949 | - | let x2 = $ | |
950 | - | let x3 = $ | |
951 | - | let quoteAssetReserveAfter = $ | |
952 | - | let baseAssetReserveAfter = $ | |
953 | - | let totalPositionSizeAfter = $ | |
954 | - | let cumulativeNotionalAfter = $ | |
955 | - | let openInterestNotionalAfter = $ | |
956 | - | let exchangedQuoteAssetAmount = $ | |
957 | - | let totalLongAfter = $ | |
958 | - | let totalShortAfter = $ | |
974 | + | let $t04226042676 = internalClosePosition(_trader) | |
975 | + | let x1 = $t04226042676._1 | |
976 | + | let badDebt = $t04226042676._2 | |
977 | + | let x2 = $t04226042676._3 | |
978 | + | let x3 = $t04226042676._4 | |
979 | + | let quoteAssetReserveAfter = $t04226042676._5 | |
980 | + | let baseAssetReserveAfter = $t04226042676._6 | |
981 | + | let totalPositionSizeAfter = $t04226042676._7 | |
982 | + | let cumulativeNotionalAfter = $t04226042676._8 | |
983 | + | let openInterestNotionalAfter = $t04226042676._9 | |
984 | + | let exchangedQuoteAssetAmount = $t04226042676._10 | |
985 | + | let totalLongAfter = $t04226042676._11 | |
986 | + | let totalShortAfter = $t04226042676._12 | |
959 | 987 | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
960 | 988 | let feeToLiquidator = (liquidationPenalty / 2) | |
961 | 989 | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
962 | 990 | let ammBalance = (cbalance() - liquidationPenalty) | |
963 | - | let $ | |
991 | + | let $t04307443209 = if ((0 > ammBalance)) | |
964 | 992 | then $Tuple2(0, abs(ammBalance)) | |
965 | 993 | else $Tuple2(ammBalance, 0) | |
966 | - | let newAmmBalance = $ | |
967 | - | let takeFromInsurance = $ | |
994 | + | let newAmmBalance = $t04307443209._1 | |
995 | + | let takeFromInsurance = $t04307443209._2 | |
968 | 996 | let x = if ((takeFromInsurance > 0)) | |
969 | 997 | then { | |
970 | 998 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
971 | 999 | if ((withdrawInsurance == withdrawInsurance)) | |
972 | 1000 | then nil | |
973 | 1001 | else throw("Strict value is not equal to itself.") | |
974 | 1002 | } | |
975 | 1003 | else nil | |
976 | 1004 | if ((x == x)) | |
977 | 1005 | then { | |
978 | 1006 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil) | |
979 | 1007 | if ((unstake == unstake)) | |
980 | 1008 | then { | |
981 | 1009 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
982 | 1010 | if ((depositInsurance == depositInsurance)) | |
983 | - | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1011 | + | then { | |
1012 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1013 | + | if ((notifyNotional == notifyNotional)) | |
1014 | + | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1015 | + | else throw("Strict value is not equal to itself.") | |
1016 | + | } | |
984 | 1017 | else throw("Strict value is not equal to itself.") | |
985 | 1018 | } | |
986 | 1019 | else throw("Strict value is not equal to itself.") | |
987 | 1020 | } | |
988 | 1021 | else throw("Strict value is not equal to itself.") | |
989 | 1022 | } | |
990 | 1023 | } | |
991 | 1024 | ||
992 | 1025 | ||
993 | 1026 | ||
994 | 1027 | @Callable(i) | |
995 | 1028 | func payFunding () = { | |
996 | 1029 | let fundingBlockTimestamp = nextFundingBlockTimestamp() | |
997 | 1030 | if (if (if ((fundingBlockTimestamp > lastBlock.timestamp)) | |
998 | 1031 | then true | |
999 | 1032 | else !(initialized())) | |
1000 | 1033 | then true | |
1001 | 1034 | else paused()) | |
1002 | 1035 | then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp))) | |
1003 | 1036 | else { | |
1004 | 1037 | let underlyingPrice = getOracleTwapPrice() | |
1005 | 1038 | let spotTwapPrice = getTwapSpotPrice() | |
1006 | 1039 | let premium = (spotTwapPrice - underlyingPrice) | |
1007 | - | let $ | |
1040 | + | let $t04470346038 = if (if ((totalShortPositionSize() == 0)) | |
1008 | 1041 | then true | |
1009 | 1042 | else (totalLongPositionSize() == 0)) | |
1010 | 1043 | then $Tuple2(0, 0) | |
1011 | 1044 | else if ((0 > premium)) | |
1012 | 1045 | then { | |
1013 | 1046 | let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
1014 | 1047 | let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize()) | |
1015 | 1048 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
1016 | 1049 | } | |
1017 | 1050 | else { | |
1018 | 1051 | let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
1019 | 1052 | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
1020 | 1053 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
1021 | 1054 | } | |
1022 | - | let shortPremiumFraction = $ | |
1023 | - | let longPremiumFraction = $ | |
1055 | + | let shortPremiumFraction = $t04470346038._1 | |
1056 | + | let longPremiumFraction = $t04470346038._2 | |
1024 | 1057 | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1025 | 1058 | } | |
1026 | 1059 | } | |
1027 | 1060 | ||
1028 | 1061 | ||
1029 | 1062 | ||
1030 | 1063 | @Callable(i) | |
1031 | 1064 | func v_get (_trader) = { | |
1032 | - | let $ | |
1033 | - | let x1 = $ | |
1034 | - | let x2 = $ | |
1035 | - | let x3 = $ | |
1036 | - | let x4 = $ | |
1065 | + | let $t04641346466 = internalClosePosition(_trader) | |
1066 | + | let x1 = $t04641346466._1 | |
1067 | + | let x2 = $t04641346466._2 | |
1068 | + | let x3 = $t04641346466._3 | |
1069 | + | let x4 = $t04641346466._4 | |
1037 | 1070 | throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader)))) | |
1038 | 1071 | } | |
1039 | 1072 | ||
1040 | 1073 | ||
1041 | 1074 | ||
1042 | 1075 | @Callable(i) | |
1043 | 1076 | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1044 | - | let $ | |
1045 | - | let positionSize = $ | |
1046 | - | let positionMargin = $ | |
1047 | - | let pon = $ | |
1048 | - | let positionLstUpdCPF = $ | |
1049 | - | let $ | |
1050 | - | let positionNotional = $ | |
1051 | - | let unrealizedPnl = $ | |
1052 | - | let $ | |
1053 | - | let remainMargin = $ | |
1054 | - | let badDebt = $ | |
1055 | - | let fundingPayment = $ | |
1077 | + | let $t04661346724 = getPosition(_trader) | |
1078 | + | let positionSize = $t04661346724._1 | |
1079 | + | let positionMargin = $t04661346724._2 | |
1080 | + | let pon = $t04661346724._3 | |
1081 | + | let positionLstUpdCPF = $t04661346724._4 | |
1082 | + | let $t04672946830 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1083 | + | let positionNotional = $t04672946830._1 | |
1084 | + | let unrealizedPnl = $t04672946830._2 | |
1085 | + | let $t04683547017 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
1086 | + | let remainMargin = $t04683547017._1 | |
1087 | + | let badDebt = $t04683547017._2 | |
1088 | + | let fundingPayment = $t04683547017._3 | |
1056 | 1089 | throw(((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader)))) | |
1057 | 1090 | } | |
1091 | + | ||
1092 | + | ||
1093 | + | ||
1094 | + | @Callable(i) | |
1095 | + | func forceMoveAsset (_trader,_amount) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller)) | |
1096 | + | then true | |
1097 | + | else (0 > _amount)) | |
1098 | + | then throw("Invalid forceMoveAsset parameters") | |
1099 | + | else { | |
1100 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [_amount, toBase58String(quoteAsset())], nil) | |
1101 | + | if ((unstake == unstake)) | |
1102 | + | then (withdraw(addressFromStringValue(_trader), _amount) ++ updateBalance((cbalance() - _amount))) | |
1103 | + | else throw("Strict value is not equal to itself.") | |
1104 | + | } | |
1058 | 1105 | ||
1059 | 1106 | ||
1060 | 1107 | @Verifier(tx) | |
1061 | 1108 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
1062 | 1109 |
github/deemru/w8io/169f3d6 201.55 ms ◑