tx · Ds8AKnKzvELv1CDkJdSiB3h5ayuwMLje1nN26Vw3mvgv

3MtMZPVohRyxckRk11RZM4geun6itShmcXy:  -0.07000000 Waves

2022.12.08 11:41 [2351139] smart account 3MtMZPVohRyxckRk11RZM4geun6itShmcXy > SELF 0.00000000 Waves

{ "type": 13, "id": "Ds8AKnKzvELv1CDkJdSiB3h5ayuwMLje1nN26Vw3mvgv", "fee": 7000000, "feeAssetId": null, "timestamp": 1670488897403, "version": 2, "chainId": 84, "sender": "3MtMZPVohRyxckRk11RZM4geun6itShmcXy", "senderPublicKey": "AcX4fkfjTbNodAULoBzLJcZwKsACkfzdq78cpEww7RP8", "proofs": [ "27UEh9jYk1M9cZtRRg3usqcJ9vKaLbEi9FkZ2PSf21mw8cHKiBTCzC3mFnisV59hixEGrunGEdnzQDmHTfMG2ECW" ], "script": "base64:BgJ1CAISABIAEgASABIDCgEBEgMKAQESDAoKAQEBAQEBAQEBARIRCg8BAQEBAQEBCAgIAQEBAQESBQoDAQEBEgYKBAEBAQgSABIDCgEBEgQKAgEBEgMKAQgSABIAEgMKAQgSAwoBARIAEgASAwoBCBIAEgQKAggIuwEACWtfb3JhX2tleQIJa19vcmFfa2V5AA9rX29yYV9ibG9ja19rZXkCD2tfb3JhX2Jsb2NrX2tleQAFa19vcmECBWtfb3JhAAlrX2JhbGFuY2UCCWtfYmFsYW5jZQAKa19zZXF1ZW5jZQIKa19zZXF1ZW5jZQAOa19wb3NpdGlvblNpemUCDmtfcG9zaXRpb25TaXplABBrX3Bvc2l0aW9uTWFyZ2luAhBrX3Bvc2l0aW9uTWFyZ2luABZrX3Bvc2l0aW9uT3Blbk5vdGlvbmFsAhZrX3Bvc2l0aW9uT3Blbk5vdGlvbmFsAC5rX3Bvc2l0aW9uTGFzdFVwZGF0ZWRDdW11bGF0aXZlUHJlbWl1bUZyYWN0aW9uAhJrX3Bvc2l0aW9uRnJhY3Rpb24AEmtfcG9zaXRpb25TZXF1ZW5jZQISa19wb3NpdGlvblNl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JARJnZXRPcmFjbGVUd2FwUHJpY2UAAWkBGHZpZXdfZ2V0Qm9ycm93ZWRCeVRyYWRlcgEHX3RyYWRlcgQNJHQwODE4ODE4MTkzNQkBE2dldEJvcnJvd2VkQnlUcmFkZXIBBQdfdHJhZGVyBAhib3Jyb3dlZAgFDSR0MDgxODgxODE5MzUCXzEEB2Fzc2V0SWQIBQ0kdDA4MTg4MTgxOTM1Al8yCQACAQkArAICCQEBcwEFCGJvcnJvd2VkBQdhc3NldElkAWkBEGNvbXB1dGVTcG90UHJpY2UABAZyZXN1bHQJAQxnZXRTcG90UHJpY2UACQCUCgIFA25pbAUGcmVzdWx0AWkBH2NvbXB1dGVGZWVGb3JUcmFkZXJXaXRoQXJ0aWZhY3QCB190cmFkZXILX2FydGlmYWN0SWQEBnJlc3VsdAkBGGdldEZvclRyYWRlcldpdGhBcnRpZmFjdAIFB190cmFkZXIFC19hcnRpZmFjdElkCQCUCgIFA25pbAUGcmVzdWx0AQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAkBDmFkbWluUHVibGljS2V5AEfFPW0=", "height": 2351139, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: J7uKdaq1NavAeqpr1qshcZMfEx9sZ3mPT65fzBXvvu8G Next: CVVdN1UcYtFKS75ePZGXD4MRHN38aJXK1fvoxk15EJLD Diff:
OldNewDifferences
99
1010 let k_balance = "k_balance"
1111
12+let k_sequence = "k_sequence"
13+
1214 let k_positionSize = "k_positionSize"
1315
1416 let k_positionMargin = "k_positionMargin"
1719
1820 let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction"
1921
20-let k_positionClosedDate = "k_positionClosedDate"
22+let k_positionSequence = "k_positionSequence"
2123
2224 let k_positionAsset = "k_positionAsset"
2325
2426 let k_initialized = "k_initialized"
2527
2628 let k_paused = "k_paused"
29+
30+let k_closeOnly = "k_closeOnly"
2731
2832 let k_fee = "k_fee"
2933
4246 let k_maxPriceImpact = "k_maxPriceImpact"
4347
4448 let k_maxPriceSpread = "k_maxPriceSpread"
49+
50+let k_maxOpenNotional = "k_maxOpenNotional"
4551
4652 let k_lastDataStr = "k_lastDataStr"
4753
7783
7884 let k_totalShortPositionSize = "k_totalShortPositionSize"
7985
80-let k_cumulativeNotional = "k_cumulativeNotional"
86+let k_openInterestNotional = "k_openInterestNotional"
8187
82-let k_openInterestNotional = "k_openInterestNotional"
88+let k_openInterestShort = "k_openInterestShort"
89+
90+let k_openInterestLong = "k_openInterestLong"
8391
8492 let k_coordinatorAddress = "k_coordinatorAddress"
8593
100108 let k_orders_address = "k_orders_address"
101109
102110 let k_referral_address = "k_referral_address"
103-
104-let k_manager_address = "k_manager_address"
105111
106112 let k_collateral_address = "k_collateral_address"
107113
298304 func totalPositionSize () = int(k_totalPositionSize)
299305
300306
301-func cumulativeNotional () = int(k_cumulativeNotional)
307+func openInterestNotional () = int(k_openInterestNotional)
302308
303309
304-func openInterestNotional () = int(k_openInterestNotional)
310+func openInterestShort () = int(k_openInterestShort)
311+
312+
313+func openInterestLong () = int(k_openInterestLong)
305314
306315
307316 func nextFundingBlockTimestamp () = int(k_nextFundingBlock)
334343 func maxPriceSpread () = int(k_maxPriceSpread)
335344
336345
346+func maxOpenNotional () = int(k_maxOpenNotional)
347+
348+
337349 func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction)
338350
339351
344356
345357
346358 func totalLongPositionSize () = int(k_totalLongPositionSize)
359+
360+
361+func lastSequence () = intOr(k_sequence, 0)
347362
348363
349364 func getActualCaller (i) = valueOrElse(getString(ordersAddress(), "k_sender"), toString(i.caller))
403418 func paused () = valueOrElse(getBoolean(this, k_paused), false)
404419
405420
421+func closeOnly () = valueOrElse(getBoolean(this, k_closeOnly), false)
422+
423+
406424 func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd)
407425 then {
408426 let newBase = (bsAstR() - _baseAssetAmount)
409427 if ((0 >= newBase))
410428 then throw("Tx lead to base asset reserve <= 0, revert")
411- else $Tuple4((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount), (cumulativeNotional() + _quoteAssetAmount))
429+ else $Tuple3((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount))
412430 }
413431 else {
414432 let newQuote = (qtAstR() - _quoteAssetAmount)
415433 if ((0 >= newQuote))
416434 then throw("Tx lead to base quote reserve <= 0, revert")
417- else $Tuple4(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount), (cumulativeNotional() - _quoteAssetAmount))
435+ else $Tuple3(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount))
418436 }
419437
420438
421-func calcInvariant (_qtAstR,_qtAstW,_bsAstR,_bsAstW) = muld(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
439+func calcInvariant (_qtAstR,_qtAstW,_bsAstR,_bsAstW) = {
440+ let bqtAstR = toBigInt(_qtAstR)
441+ let bqtAstW = toBigInt(_qtAstW)
442+ let bbsAstR = toBigInt(_bsAstR)
443+ let bbsAstW = toBigInt(_bsAstW)
444+ bmuld(bmuld(bqtAstR, bqtAstW), bmuld(bbsAstR, bbsAstW))
445+ }
422446
423447
424448 func swapInput (_isAdd,_quoteAssetAmount) = {
430454 let quoteAssetReserveAfter = if (_isAdd)
431455 then (_qtAstR + _quoteAssetAmount)
432456 else (_qtAstR - _quoteAssetAmount)
433- let baseAssetReserveAfter = divd(k, muld(quoteAssetReserveAfter, _qtAstW))
457+ let baseAssetReserveAfter = toInt(bdivd(k, toBigInt(muld(quoteAssetReserveAfter, _qtAstW))))
434458 let amountBaseAssetBoughtAbs = divd(abs((baseAssetReserveAfter - _bsAstR)), _qtAstW)
435459 let amountBaseAssetBought = if (_isAdd)
436460 then amountBaseAssetBoughtAbs
437461 else -(amountBaseAssetBoughtAbs)
438- let $t01633316526 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
439- let quoteAssetReserveAfter1 = $t01633316526._1
440- let baseAssetReserveAfter1 = $t01633316526._2
441- let totalPositionSizeAfter1 = $t01633316526._3
442- let cumulativeNotionalAfter1 = $t01633316526._4
462+ let $t01665516818 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
463+ let quoteAssetReserveAfter1 = $t01665516818._1
464+ let baseAssetReserveAfter1 = $t01665516818._2
465+ let totalPositionSizeAfter1 = $t01665516818._3
443466 let priceBefore = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
444467 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
445468 let priceDiff = abs((priceBefore - marketPrice))
447470 let maxPriceImpactValue = maxPriceImpact()
448471 if ((priceImpact > maxPriceImpactValue))
449472 then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_qtAstR)) + " before base asset: ") + toString(_bsAstR)) + " quote asset amount to exchange: ") + toString(_quoteAssetAmount)) + " price before: ") + toString(priceBefore)) + " marketPrice: ") + toString(marketPrice)))
450- else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1)
473+ else $Tuple4(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1)
451474 }
452475
453476
459482 }
460483 else 0
461484 let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin)
462- let $t01804518172 = if ((0 > signedMargin))
485+ let $t01830518432 = if ((0 > signedMargin))
463486 then $Tuple2(0, abs(signedMargin))
464487 else $Tuple2(abs(signedMargin), 0)
465- let remainMargin = $t01804518172._1
466- let badDebt = $t01804518172._2
488+ let remainMargin = $t01830518432._1
489+ let badDebt = $t01830518432._2
467490 $Tuple3(remainMargin, badDebt, fundingPayment)
468491 }
469492
477500 let baseAssetPoolAmountAfter = if (_isAdd)
478501 then (_baseAssetReserve + _baseAssetAmount)
479502 else (_baseAssetReserve - _baseAssetAmount)
480- let quoteAssetAfter = divd(k, muld(baseAssetPoolAmountAfter, _baseAssetWeight))
503+ let quoteAssetAfter = toInt(bdivd(k, toBigInt(muld(baseAssetPoolAmountAfter, _baseAssetWeight))))
481504 let quoteAssetSold = abs((quoteAssetAfter - muld(_quoteAssetReserve, _quoteAssetWeight)))
482505 let maxPriceImpactValue = maxPriceImpact()
483- let $t01934019533 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
484- let quoteAssetReserveAfter1 = $t01934019533._1
485- let baseAssetReserveAfter1 = $t01934019533._2
486- let totalPositionSizeAfter1 = $t01934019533._3
487- let cumulativeNotionalAfter1 = $t01934019533._4
506+ let $t01962019781 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
507+ let quoteAssetReserveAfter1 = $t01962019781._1
508+ let baseAssetReserveAfter1 = $t01962019781._2
509+ let totalPositionSizeAfter1 = $t01962019781._3
488510 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
489511 let priceDiff = abs((priceBefore - marketPrice))
490512 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
492514 then _checkMaxPriceImpact
493515 else false)
494516 then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_quoteAssetReserve)) + " before base asset: ") + toString(_baseAssetReserve)) + " base asset amount to exchange: ") + toString(_baseAssetAmount)) + " price before: ") + toString(priceBefore)) + " market price: ") + toString(marketPrice)))
495- else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd)
517+ else $Tuple7(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, (totalLongPositionSize() - (if (_isAdd)
496518 then abs(_baseAssetAmount)
497519 else 0)), (totalShortPositionSize() - (if (!(_isAdd))
498520 then abs(_baseAssetAmount)
524546 }
525547
526548
549+func requireNotOverMaxOpenNotional (_longOpenNotional,_shortOpenNotional) = {
550+ let _maxOpenNotional = maxOpenNotional()
551+ if ((_longOpenNotional > _maxOpenNotional))
552+ then throw(((("Long open notional " + toString(_longOpenNotional)) + " > max open notional ") + toString(_maxOpenNotional)))
553+ else if ((_shortOpenNotional > _maxOpenNotional))
554+ then throw(((("Short open notional " + toString(_shortOpenNotional)) + " > max open notional ") + toString(_maxOpenNotional)))
555+ else true
556+ }
557+
558+
527559 func getSpotPrice () = {
528560 let _quoteAssetReserve = qtAstR()
529561 let _baseAssetReserve = bsAstR()
545577 let isShort = (0 > _positionSize)
546578 let positionNotional = if ((_option == PNL_OPTION_SPOT))
547579 then {
548- let $t02290823128 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)
549- let outPositionNotional = $t02290823128._1
550- let x1 = $t02290823128._2
551- let x2 = $t02290823128._3
552- let x3 = $t02290823128._4
580+ let $t02365523875 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)
581+ let outPositionNotional = $t02365523875._1
582+ let x1 = $t02365523875._2
583+ let x2 = $t02365523875._3
584+ let x3 = $t02365523875._4
553585 outPositionNotional
554586 }
555587 else muld(positionSizeAbs, getOracleTwapPrice())
570602
571603
572604 func getPositionNotionalAndUnrealizedPnl (_trader,_option) = {
573- let $t02455324681 = getPosition(_trader)
574- let positionSize = $t02455324681._1
575- let positionMargin = $t02455324681._2
576- let positionOpenNotional = $t02455324681._3
577- let positionLstUpdCPF = $t02455324681._4
605+ let $t02530025428 = getPosition(_trader)
606+ let positionSize = $t02530025428._1
607+ let positionMargin = $t02530025428._2
608+ let positionOpenNotional = $t02530025428._3
609+ let positionLstUpdCPF = $t02530025428._4
578610 getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), qtAstW(), bsAstR(), bsAstW(), _option)
579611 }
580612
583615
584616
585617 func getMarginRatioByOption (_trader,_option) = {
586- let $t02519425305 = getPosition(_trader)
587- let positionSize = $t02519425305._1
588- let positionMargin = $t02519425305._2
589- let pon = $t02519425305._3
590- let positionLstUpdCPF = $t02519425305._4
591- let $t02531125404 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
592- let positionNotional = $t02531125404._1
593- let unrealizedPnl = $t02531125404._2
594- let $t02540925575 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
595- let remainMargin = $t02540925575._1
596- let badDebt = $t02540925575._2
618+ let $t02594126052 = getPosition(_trader)
619+ let positionSize = $t02594126052._1
620+ let positionMargin = $t02594126052._2
621+ let pon = $t02594126052._3
622+ let positionLstUpdCPF = $t02594126052._4
623+ let $t02605826151 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
624+ let positionNotional = $t02605826151._1
625+ let unrealizedPnl = $t02605826151._2
626+ let $t02615626322 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
627+ let remainMargin = $t02615626322._1
628+ let badDebt = $t02615626322._2
597629 calcMarginRatio(remainMargin, badDebt, positionNotional)
598630 }
599631
606638 let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio)
607639 let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false)
608640 let maxExchangedQuoteAssetAmount = swapResult._1
609- let priceImpact = swapResult._8
641+ let priceImpact = swapResult._7
610642 if ((maxPriceImpact() > priceImpact))
611643 then maxExchangedQuoteAssetAmount
612644 else {
618650
619651
620652 func internalClosePosition (_trader,_checkMaxPriceImpact) = {
621- let $t02680826936 = getPosition(_trader)
622- let positionSize = $t02680826936._1
623- let positionMargin = $t02680826936._2
624- let positionOpenNotional = $t02680826936._3
625- let positionLstUpdCPF = $t02680826936._4
653+ let $t02756227690 = getPosition(_trader)
654+ let positionSize = $t02756227690._1
655+ let positionMargin = $t02756227690._2
656+ let positionOpenNotional = $t02756227690._3
657+ let positionLstUpdCPF = $t02756227690._4
626658 let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2
627- let $t02703127199 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
628- let remainMargin = $t02703127199._1
629- let badDebt = $t02703127199._2
659+ let $t02778527953 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
660+ let remainMargin = $t02778527953._1
661+ let badDebt = $t02778527953._2
630662 let exchangedPositionSize = -(positionSize)
631663 let realizedPnl = unrealizedPnl
632664 let marginToVault = -(remainMargin)
633- let $t02732627631 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
634- let exchangedQuoteAssetAmount = $t02732627631._1
635- let quoteAssetReserveAfter = $t02732627631._2
636- let baseAssetReserveAfter = $t02732627631._3
637- let totalPositionSizeAfter = $t02732627631._4
638- let cumulativeNotionalAfter = $t02732627631._5
639- let totalLongAfter = $t02732627631._6
640- let totalShortAfter = $t02732627631._7
665+ let $t02808028354 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
666+ let exchangedQuoteAssetAmount = $t02808028354._1
667+ let quoteAssetReserveAfter = $t02808028354._2
668+ let baseAssetReserveAfter = $t02808028354._3
669+ let totalPositionSizeAfter = $t02808028354._4
670+ let totalLongAfter = $t02808028354._5
671+ let totalShortAfter = $t02808028354._6
641672 let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional)
642- $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter)
673+ $Tuple13(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter, (openInterestLong() - (if ((positionSize > 0))
674+ then positionOpenNotional
675+ else 0)), (openInterestShort() - (if ((0 > positionSize))
676+ then positionOpenNotional
677+ else 0)))
643678 }
644679
645680
686721 then $Tuple2(qtAstR(), bsAstR())
687722 else {
688723 let direction = (_positionSize > 0)
689- let $t02961829797 = swapOutput(direction, abs(_positionSize), false)
690- let currentNetMarketValue = $t02961829797._1
691- let terminalQuoteAssetReserve = $t02961829797._2
692- let terminalBaseAssetReserve = $t02961829797._3
724+ let $t03047730656 = swapOutput(direction, abs(_positionSize), false)
725+ let currentNetMarketValue = $t03047730656._1
726+ let terminalQuoteAssetReserve = $t03047730656._2
727+ let terminalBaseAssetReserve = $t03047730656._3
693728 $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve)
694729 }
695730 }
757792 }
758793
759794
760-func getAdjustedFee (i,_baseFeeDiscount) = {
795+func getAdjustedFee (_artifactId,_baseFeeDiscount) = {
761796 let baseFeeRaw = fee()
762797 let baseFee = muld(baseFeeRaw, _baseFeeDiscount)
763- let $t03289033498 = if ((size(i.payments) > 1))
798+ let $t03375534250 = if ((_artifactId != ""))
764799 then {
765- let artifactId = toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid attached artifact"))
766- let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, artifactId))
800+ let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, _artifactId))
767801 if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE))
768802 then {
769- let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, artifactId))
803+ let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, _artifactId))
770804 let adjustedFee = muld(baseFee, reduction)
771805 $Tuple2(adjustedFee, true)
772806 }
773807 else throw("Invalid attached artifact")
774808 }
775809 else $Tuple2(baseFee, false)
776- let adjustedFee = $t03289033498._1
777- let burnArtifact = $t03289033498._2
810+ let adjustedFee = $t03375534250._1
811+ let burnArtifact = $t03375534250._2
778812 $Tuple2(adjustedFee, burnArtifact)
779813 }
780814
781815
782-func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread)]
816+func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional)]
783817
784818
785819 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)]
786820
787821
788822 func updatePositionAsset (_address,_assetId) = [StringEntry(toCompositeKey(k_positionAsset, _address), _assetId)]
823+
824+
825+func incrementPositionSequenceNumber (isNewPosition,_address) = if (isNewPosition)
826+ then {
827+ let currentSequence = lastSequence()
828+[IntegerEntry(toCompositeKey(k_positionSequence, _address), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))]
829+ }
830+ else nil
789831
790832
791833 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)]
825867 func updateAmmWeights (_qtAstW,_bsAstW) = [IntegerEntry(k_quoteAssetWeight, _qtAstW), IntegerEntry(k_baseAssetWeight, _bsAstW)]
826868
827869
828-func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_cumulativeNotionalAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize) = {
870+func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize,_totalLongOpenNotional,_totalShortOpenNotional) = {
829871 let _qtAstW = qtAstW()
830872 let _bsAstW = bsAstW()
831873 if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter))
832874 then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter)))
833- else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_cumulativeNotional, _cumulativeNotionalAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize)]) ++ appendTwap(divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))))
875+ else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize), IntegerEntry(k_openInterestLong, _totalLongOpenNotional), IntegerEntry(k_openInterestShort, _totalShortOpenNotional)]) ++ appendTwap(divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))))
834876 }
835877
836878
837-func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)]
879+func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address))]
838880
839881
840882 func withdraw (_address,_amount) = {
884926 }
885927
886928
929+func getForTraderWithArtifact (_trader,_artifactId) = {
930+ let doGetFeeDiscount = invoke(minerAddress(), "computeFeeDiscount", [_trader], nil)
931+ if ((doGetFeeDiscount == doGetFeeDiscount))
932+ then {
933+ let feeDiscount = match doGetFeeDiscount {
934+ case x: Int =>
935+ x
936+ case _ =>
937+ throw("Invalid computeFeeDiscount result")
938+ }
939+ let $t04258342657 = getAdjustedFee(_artifactId, feeDiscount)
940+ let adjustedFee = $t04258342657._1
941+ let burnArtifact = $t04258342657._2
942+ $Tuple2(adjustedFee, burnArtifact)
943+ }
944+ else throw("Strict value is not equal to itself.")
945+ }
946+
947+
948+func getArtifactId (i) = {
949+ let artifactId = if ((size(i.payments) > 1))
950+ then toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifactId"))
951+ else ""
952+ artifactId
953+ }
954+
955+
887956 @Callable(i)
888957 func pause () = if ((i.caller != adminAddress()))
889- then throw("Invalid togglePause params")
958+ then throw("Invalid pause params")
890959 else [BooleanEntry(k_paused, true)]
891960
892961
893962
894963 @Callable(i)
895964 func unpause () = if ((i.caller != adminAddress()))
896- then throw("Invalid togglePause params")
965+ then throw("Invalid unpause params")
897966 else [BooleanEntry(k_paused, false)]
967+
968+
969+
970+@Callable(i)
971+func setCloseOnly () = if ((i.caller != adminAddress()))
972+ then throw("Invalid setCloseOnly params")
973+ else [BooleanEntry(k_closeOnly, true)]
974+
975+
976+
977+@Callable(i)
978+func unsetCloseOnly () = if ((i.caller != adminAddress()))
979+ then throw("Invalid unsetCloseOnly params")
980+ else [BooleanEntry(k_closeOnly, false)]
898981
899982
900983
9371020
9381021
9391022 @Callable(i)
940-func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress()))
1023+func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional) = if ((i.caller != adminAddress()))
9411024 then throw("Invalid changeSettings params")
942- else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)
1025+ else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional)
9431026
9441027
9451028
9461029 @Callable(i)
947-func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
1030+func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional) = if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
9481031 then true
9491032 else (0 >= _bsAstR))
9501033 then true
9661049 then true
9671050 else (0 >= _maxPriceSpread))
9681051 then true
1052+ else (0 >= _maxOpenNotional))
1053+ then true
9691054 else initialized())
9701055 then throw("Invalid initialize parameters")
971- else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)])
972-
973-
974-
975-@Callable(i)
976-func setInitMarginRatio (_initMarginRatio) = if (if ((0 >= _initMarginRatio))
977- then true
978- else !(initialized()))
979- then throw("Invalid setInitMarginRatio parameters")
980- else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread())
1056+ else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)])
9811057
9821058
9831059
9851061 func decreasePosition (_amount,_leverage,_minBaseAssetAmount) = {
9861062 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
9871063 if ((sync == sync))
988- then if (if (if (if (if ((0 >= _amount))
989- then true
990- else !(initialized()))
991- then true
992- else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
993- then true
994- else !(requireOpenPosition(toString(i.caller))))
995- then true
996- else paused())
997- then throw("Invalid decreasePosition parameters")
998- else {
999- let $t04547845630 = getPosition(toString(i.caller))
1000- let oldPositionSize = $t04547845630._1
1001- let oldPositionMargin = $t04547845630._2
1002- let oldPositionOpenNotional = $t04547845630._3
1003- let oldPositionLstUpdCPF = $t04547845630._4
1004- let _direction = if ((oldPositionSize > 0))
1005- then DIR_SHORT
1006- else DIR_LONG
1007- let isAdd = (_direction == DIR_LONG)
1008- let openNotional = muld(_amount, _leverage)
1009- let $t04580345919 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1010- let oldPositionNotional = $t04580345919._1
1011- let unrealizedPnl = $t04580345919._2
1012- let $t04592548474 = if ((oldPositionNotional > openNotional))
1013- then {
1014- let $t04630246521 = swapInput(isAdd, openNotional)
1015- let exchangedPositionSize = $t04630246521._1
1016- let quoteAssetReserveAfter = $t04630246521._2
1017- let baseAssetReserveAfter = $t04630246521._3
1018- let totalPositionSizeAfter = $t04630246521._4
1019- let cumulativeNotionalAfter = $t04630246521._5
1020- let exchangedPositionSizeAbs = abs(exchangedPositionSize)
1021- if (if ((_minBaseAssetAmount != 0))
1022- then (_minBaseAssetAmount > exchangedPositionSizeAbs)
1023- else false)
1024- then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount)))
1025- else {
1026- let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize))
1027- let $t04695847203 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1028- let remainMargin = $t04695847203._1
1029- let badDebt = $t04695847203._2
1030- let fundingPayment = $t04695847203._3
1031- let exchangedQuoteAssetAmount = openNotional
1032- let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
1033- let remainOpenNotional = if ((oldPositionSize > 0))
1034- then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
1035- else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
1036- let newPositionSize = (oldPositionSize + exchangedPositionSize)
1037- $Tuple11(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0))
1038- then abs(exchangedPositionSize)
1039- else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1040- then abs(exchangedPositionSize)
1041- else 0)))
1042- }
1043- }
1044- else throw("Close position first")
1045- let newPositionSize = $t04592548474._1
1046- let newPositionRemainMargin = $t04592548474._2
1047- let newPositionOpenNotional = $t04592548474._3
1048- let newPositionLatestCPF = $t04592548474._4
1049- let baseAssetReserveAfter = $t04592548474._5
1050- let quoteAssetReserveAfter = $t04592548474._6
1051- let totalPositionSizeAfter = $t04592548474._7
1052- let cumulativeNotionalAfter = $t04592548474._8
1053- let openInterestNotionalAfter = $t04592548474._9
1054- let totalLongAfter = $t04592548474._10
1055- let totalShortAfter = $t04592548474._11
1056- let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil)
1057- if ((notifyNotional == notifyNotional))
1058- then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter))
1059- else throw("Strict value is not equal to itself.")
1060- }
1064+ then {
1065+ let _trader = getActualCaller(i)
1066+ if (if (if (if (if ((0 >= _amount))
1067+ then true
1068+ else !(initialized()))
1069+ then true
1070+ else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
1071+ then true
1072+ else !(requireOpenPosition(_trader)))
1073+ then true
1074+ else paused())
1075+ then throw("Invalid decreasePosition parameters")
1076+ else {
1077+ let $t04734747487 = getPosition(_trader)
1078+ let oldPositionSize = $t04734747487._1
1079+ let oldPositionMargin = $t04734747487._2
1080+ let oldPositionOpenNotional = $t04734747487._3
1081+ let oldPositionLstUpdCPF = $t04734747487._4
1082+ let _direction = if ((oldPositionSize > 0))
1083+ then DIR_SHORT
1084+ else DIR_LONG
1085+ let isAdd = (_direction == DIR_LONG)
1086+ let openNotional = muld(_amount, _leverage)
1087+ let $t04766047764 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1088+ let oldPositionNotional = $t04766047764._1
1089+ let unrealizedPnl = $t04766047764._2
1090+ let $t04777050428 = if ((oldPositionNotional > openNotional))
1091+ then {
1092+ let $t04818548369 = swapInput(isAdd, openNotional)
1093+ let exchangedPositionSize = $t04818548369._1
1094+ let quoteAssetReserveAfter = $t04818548369._2
1095+ let baseAssetReserveAfter = $t04818548369._3
1096+ let totalPositionSizeAfter = $t04818548369._4
1097+ let exchangedPositionSizeAbs = abs(exchangedPositionSize)
1098+ if (if ((_minBaseAssetAmount != 0))
1099+ then (_minBaseAssetAmount > exchangedPositionSizeAbs)
1100+ else false)
1101+ then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount)))
1102+ else {
1103+ let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize))
1104+ let $t04880649051 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1105+ let remainMargin = $t04880649051._1
1106+ let badDebt = $t04880649051._2
1107+ let fundingPayment = $t04880649051._3
1108+ let exchangedQuoteAssetAmount = openNotional
1109+ let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
1110+ let remainOpenNotional = if ((oldPositionSize > 0))
1111+ then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
1112+ else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
1113+ let newPositionSize = (oldPositionSize + exchangedPositionSize)
1114+ $Tuple12(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0))
1115+ then abs(exchangedPositionSize)
1116+ else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1117+ then abs(exchangedPositionSize)
1118+ else 0)), (openInterestLong() - (if ((newPositionSize > 0))
1119+ then openNotional
1120+ else 0)), (openInterestShort() - (if ((0 > newPositionSize))
1121+ then openNotional
1122+ else 0)))
1123+ }
1124+ }
1125+ else throw("Close position first")
1126+ let newPositionSize = $t04777050428._1
1127+ let newPositionRemainMargin = $t04777050428._2
1128+ let newPositionOpenNotional = $t04777050428._3
1129+ let newPositionLatestCPF = $t04777050428._4
1130+ let baseAssetReserveAfter = $t04777050428._5
1131+ let quoteAssetReserveAfter = $t04777050428._6
1132+ let totalPositionSizeAfter = $t04777050428._7
1133+ let openInterestNotionalAfter = $t04777050428._8
1134+ let totalLongAfter = $t04777050428._9
1135+ let totalShortAfter = $t04777050428._10
1136+ let totalLongOpenInterestAfter = $t04777050428._11
1137+ let totalShortOpenInterestAfter = $t04777050428._12
1138+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1139+ if ((notifyNotional == notifyNotional))
1140+ then (updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter))
1141+ else throw("Strict value is not equal to itself.")
1142+ }
1143+ }
10611144 else throw("Strict value is not equal to itself.")
10621145 }
10631146
10681151 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
10691152 if ((sync == sync))
10701153 then {
1071- let _trader = toString(i.caller)
1154+ let _trader = getActualCaller(i)
10721155 let _rawAmount = i.payments[0].amount
10731156 let _assetId = i.payments[0].assetId
10741157 let _assetIdStr = toBase58String(value(_assetId))
10751158 let isQuoteAsset = (_assetId == quoteAsset())
10761159 let isCollateralAsset = isWhitelistAsset(_assetIdStr)
1077- if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
1160+ if (if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
10781161 then (_direction != DIR_SHORT)
10791162 else false)
10801163 then true
10911174 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
10921175 then true
10931176 else paused())
1177+ then true
1178+ else closeOnly())
10941179 then throw("Invalid increasePosition parameters")
10951180 else {
1096- let doGetFeeDiscount = invoke(minerAddress(), "computeFeeDiscount", [_trader], nil)
1097- if ((doGetFeeDiscount == doGetFeeDiscount))
1181+ let $t05186651951 = getForTraderWithArtifact(_trader, getArtifactId(i))
1182+ let adjustedFee = $t05186651951._1
1183+ let burnArtifact = $t05186651951._2
1184+ let rawFeeAmount = muld(_rawAmount, adjustedFee)
1185+ let _amount = (_rawAmount - rawFeeAmount)
1186+ let distributeFeeAmount = if (isCollateralAsset)
10981187 then {
1099- let feeDiscount = match doGetFeeDiscount {
1100- case x: Int =>
1101- x
1102- case _ =>
1103- throw("Invalid computeFeeDiscount result")
1104- }
1105- let $t05013750201 = getAdjustedFee(i, feeDiscount)
1106- let adjustedFee = $t05013750201._1
1107- let burnArtifact = $t05013750201._2
1108- let rawFeeAmount = muld(_rawAmount, adjustedFee)
1109- let _amount = (_rawAmount - rawFeeAmount)
1110- let distributeFeeAmount = if (isCollateralAsset)
1188+ let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1189+ if ((doBorrow == doBorrow))
11111190 then {
1112- let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1113- if ((doBorrow == doBorrow))
1191+ let balanceBefore = assetBalance(this, quoteAsset())
1192+ if ((balanceBefore == balanceBefore))
11141193 then {
1115- let balanceBefore = assetBalance(this, quoteAsset())
1116- if ((balanceBefore == balanceBefore))
1194+ let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1195+ if ((doSwap == doSwap))
11171196 then {
1118- let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1119- if ((doSwap == doSwap))
1197+ let balanceAfter = assetBalance(this, quoteAsset())
1198+ if ((balanceAfter == balanceAfter))
11201199 then {
1121- let balanceAfter = assetBalance(this, quoteAsset())
1122- if ((balanceAfter == balanceAfter))
1123- then {
1124- let exchangedAmount = (balanceAfter - balanceBefore)
1125- if ((exchangedAmount == exchangedAmount))
1126- then exchangedAmount
1127- else throw("Strict value is not equal to itself.")
1128- }
1200+ let exchangedAmount = (balanceAfter - balanceBefore)
1201+ if ((exchangedAmount == exchangedAmount))
1202+ then exchangedAmount
11291203 else throw("Strict value is not equal to itself.")
11301204 }
11311205 else throw("Strict value is not equal to itself.")
11341208 }
11351209 else throw("Strict value is not equal to itself.")
11361210 }
1137- else rawFeeAmount
1138- if ((distributeFeeAmount == distributeFeeAmount))
1211+ else throw("Strict value is not equal to itself.")
1212+ }
1213+ else rawFeeAmount
1214+ if ((distributeFeeAmount == distributeFeeAmount))
1215+ then {
1216+ let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1217+ if ((referrerFeeAny == referrerFeeAny))
11391218 then {
1140- let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1141- if ((referrerFeeAny == referrerFeeAny))
1219+ let referrerFee = match referrerFeeAny {
1220+ case x: Int =>
1221+ x
1222+ case _ =>
1223+ throw("Invalid referrerFee")
1224+ }
1225+ let feeAmount = (distributeFeeAmount - referrerFee)
1226+ let $t05326753407 = getPosition(_trader)
1227+ let oldPositionSize = $t05326753407._1
1228+ let oldPositionMargin = $t05326753407._2
1229+ let oldPositionOpenNotional = $t05326753407._3
1230+ let oldPositionLstUpdCPF = $t05326753407._4
1231+ let isNewPosition = (oldPositionSize == 0)
1232+ let isSameDirection = if ((oldPositionSize > 0))
1233+ then (_direction == DIR_LONG)
1234+ else (_direction == DIR_SHORT)
1235+ let expandExisting = if (!(isNewPosition))
1236+ then isSameDirection
1237+ else false
1238+ let isAdd = (_direction == DIR_LONG)
1239+ let $t05369656737 = if (if (isNewPosition)
1240+ then true
1241+ else expandExisting)
11421242 then {
1143- let referrerFee = match referrerFeeAny {
1144- case x: Int =>
1145- x
1146- case _ =>
1147- throw("Invalid referrerFee")
1243+ let openNotional = muld(_amount, _leverage)
1244+ let $t05415854331 = swapInput(isAdd, openNotional)
1245+ let amountBaseAssetBought = $t05415854331._1
1246+ let quoteAssetReserveAfter = $t05415854331._2
1247+ let baseAssetReserveAfter = $t05415854331._3
1248+ let totalPositionSizeAfter = $t05415854331._4
1249+ if (if ((_minBaseAssetAmount != 0))
1250+ then (_minBaseAssetAmount > abs(amountBaseAssetBought))
1251+ else false)
1252+ then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
1253+ else {
1254+ let newPositionSize = (oldPositionSize + amountBaseAssetBought)
1255+ let totalLongOpenInterestAfter = (openInterestLong() + (if ((newPositionSize > 0))
1256+ then openNotional
1257+ else 0))
1258+ let totalShortOpenInterestAfter = (openInterestShort() + (if ((0 > newPositionSize))
1259+ then openNotional
1260+ else 0))
1261+ let increaseMarginRequirement = divd(openNotional, _leverage)
1262+ let $t05493955178 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
1263+ let remainMargin = $t05493955178._1
1264+ let x1 = $t05493955178._2
1265+ let x2 = $t05493955178._3
1266+ if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
1267+ then throw("Over max spread limit")
1268+ else if (!(requireNotOverMaxOpenNotional(totalLongOpenInterestAfter, totalShortOpenInterestAfter)))
1269+ then throw("Over max open notional")
1270+ else $Tuple12(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
1271+ then abs(amountBaseAssetBought)
1272+ else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
1273+ then abs(amountBaseAssetBought)
1274+ else 0)), totalLongOpenInterestAfter, totalShortOpenInterestAfter)
1275+ }
11481276 }
1149- let feeAmount = (distributeFeeAmount - referrerFee)
1150- let $t05151751657 = getPosition(_trader)
1151- let oldPositionSize = $t05151751657._1
1152- let oldPositionMargin = $t05151751657._2
1153- let oldPositionOpenNotional = $t05151751657._3
1154- let oldPositionLstUpdCPF = $t05151751657._4
1155- let isNewPosition = (oldPositionSize == 0)
1156- let isSameDirection = if ((oldPositionSize > 0))
1157- then (_direction == DIR_LONG)
1158- else (_direction == DIR_SHORT)
1159- let expandExisting = if (!(isNewPosition))
1160- then isSameDirection
1161- else false
1162- let isAdd = (_direction == DIR_LONG)
1163- let $t05194654531 = if (if (isNewPosition)
1164- then true
1165- else expandExisting)
1277+ else {
1278+ let openNotional = muld(_amount, _leverage)
1279+ let $t05643756553 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1280+ let oldPositionNotional = $t05643756553._1
1281+ let unrealizedPnl = $t05643756553._2
1282+ if ((oldPositionNotional > openNotional))
1283+ then throw("Use decreasePosition to decrease position size")
1284+ else throw("Close position first")
1285+ }
1286+ let newPositionSize = $t05369656737._1
1287+ let newPositionRemainMargin = $t05369656737._2
1288+ let newPositionOpenNotional = $t05369656737._3
1289+ let newPositionLatestCPF = $t05369656737._4
1290+ let baseAssetReserveAfter = $t05369656737._5
1291+ let quoteAssetReserveAfter = $t05369656737._6
1292+ let totalPositionSizeAfter = $t05369656737._7
1293+ let openInterestNotionalAfter = $t05369656737._8
1294+ let totalLongAfter = $t05369656737._9
1295+ let totalShortAfter = $t05369656737._10
1296+ let totalLongOpenInterestAfter = $t05369656737._11
1297+ let totalShortOpenInterestAfter = $t05369656737._12
1298+ let feeToStakers = (feeAmount / 2)
1299+ let feeToInsurance = (feeAmount - feeToStakers)
1300+ let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
1301+ if ((stake == stake))
1302+ then {
1303+ let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1304+ if ((depositInsurance == depositInsurance))
11661305 then {
1167- let openNotional = muld(_amount, _leverage)
1168- let $t05237052576 = swapInput(isAdd, openNotional)
1169- let amountBaseAssetBought = $t05237052576._1
1170- let quoteAssetReserveAfter = $t05237052576._2
1171- let baseAssetReserveAfter = $t05237052576._3
1172- let totalPositionSizeAfter = $t05237052576._4
1173- let cumulativeNotionalAfter = $t05237052576._5
1174- if (if ((_minBaseAssetAmount != 0))
1175- then (_minBaseAssetAmount > abs(amountBaseAssetBought))
1176- else false)
1177- then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
1178- else {
1179- let newPositionSize = (oldPositionSize + amountBaseAssetBought)
1180- let increaseMarginRequirement = divd(openNotional, _leverage)
1181- let $t05295753196 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
1182- let remainMargin = $t05295753196._1
1183- let x1 = $t05295753196._2
1184- let x2 = $t05295753196._3
1185- if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
1186- then throw("Over max spread limit")
1187- else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
1188- then abs(amountBaseAssetBought)
1189- else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
1190- then abs(amountBaseAssetBought)
1191- else 0)))
1192- }
1193- }
1194- else {
1195- let openNotional = muld(_amount, _leverage)
1196- let $t05422454340 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1197- let oldPositionNotional = $t05422454340._1
1198- let unrealizedPnl = $t05422454340._2
1199- if ((oldPositionNotional > openNotional))
1200- then throw("Use decreasePosition to decrease position size")
1201- else throw("Close position first")
1202- }
1203- let newPositionSize = $t05194654531._1
1204- let newPositionRemainMargin = $t05194654531._2
1205- let newPositionOpenNotional = $t05194654531._3
1206- let newPositionLatestCPF = $t05194654531._4
1207- let baseAssetReserveAfter = $t05194654531._5
1208- let quoteAssetReserveAfter = $t05194654531._6
1209- let totalPositionSizeAfter = $t05194654531._7
1210- let cumulativeNotionalAfter = $t05194654531._8
1211- let openInterestNotionalAfter = $t05194654531._9
1212- let totalLongAfter = $t05194654531._10
1213- let totalShortAfter = $t05194654531._11
1214- let feeToStakers = (feeAmount / 2)
1215- let feeToInsurance = (feeAmount - feeToStakers)
1216- let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
1217- if ((stake == stake))
1218- then {
1219- let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1220- if ((depositInsurance == depositInsurance))
1306+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1307+ if ((notifyFee == notifyFee))
12211308 then {
1222- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1223- if ((notifyFee == notifyFee))
1224- then {
1225- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1226- if ((notifyNotional == notifyNotional))
1227- then (((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
1228- else throw("Strict value is not equal to itself.")
1229- }
1309+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1310+ if ((notifyNotional == notifyNotional))
1311+ then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ incrementPositionSequenceNumber(isNewPosition, _trader)) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
12301312 else throw("Strict value is not equal to itself.")
12311313 }
12321314 else throw("Strict value is not equal to itself.")
12561338 let _assetIdStr = toBase58String(value(_assetId))
12571339 let isQuoteAsset = (_assetId == quoteAsset())
12581340 let isCollateralAsset = isWhitelistAsset(_assetIdStr)
1259- if (if (if (if (if (if (!(isQuoteAsset))
1341+ if (if (if (if (if (if (if (!(isQuoteAsset))
12601342 then !(isCollateralAsset)
12611343 else false)
12621344 then true
12671349 else !(initialized()))
12681350 then true
12691351 else paused())
1352+ then true
1353+ else closeOnly())
12701354 then throw("Invalid addMargin parameters")
12711355 else {
1272- let doGetFeeDiscount = invoke(minerAddress(), "computeFeeDiscount", [_trader], nil)
1273- if ((doGetFeeDiscount == doGetFeeDiscount))
1356+ let $t05867958764 = getForTraderWithArtifact(_trader, getArtifactId(i))
1357+ let adjustedFee = $t05867958764._1
1358+ let burnArtifact = $t05867958764._2
1359+ let rawFeeAmount = muld(_rawAmount, adjustedFee)
1360+ let _amount = (_rawAmount - rawFeeAmount)
1361+ let distributeFeeAmount = if (isCollateralAsset)
12741362 then {
1275- let feeDiscount = match doGetFeeDiscount {
1276- case x: Int =>
1277- x
1278- case _ =>
1279- throw("Invalid computeFeeDiscount result")
1280- }
1281- let $t05660856672 = getAdjustedFee(i, feeDiscount)
1282- let adjustedFee = $t05660856672._1
1283- let burnArtifact = $t05660856672._2
1284- let rawFeeAmount = muld(_rawAmount, adjustedFee)
1285- let _amount = (_rawAmount - rawFeeAmount)
1286- let distributeFeeAmount = if (isCollateralAsset)
1363+ let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1364+ if ((doBorrow == doBorrow))
12871365 then {
1288- let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1289- if ((doBorrow == doBorrow))
1366+ let balanceBefore = assetBalance(this, quoteAsset())
1367+ if ((balanceBefore == balanceBefore))
12901368 then {
1291- let balanceBefore = assetBalance(this, quoteAsset())
1292- if ((balanceBefore == balanceBefore))
1369+ let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1370+ if ((doSwap == doSwap))
12931371 then {
1294- let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1295- if ((doSwap == doSwap))
1372+ let balanceAfter = assetBalance(this, quoteAsset())
1373+ if ((balanceAfter == balanceAfter))
12961374 then {
1297- let balanceAfter = assetBalance(this, quoteAsset())
1298- if ((balanceAfter == balanceAfter))
1299- then {
1300- let exchangedAmount = (balanceAfter - balanceBefore)
1301- if ((exchangedAmount == exchangedAmount))
1302- then exchangedAmount
1303- else throw("Strict value is not equal to itself.")
1304- }
1375+ let exchangedAmount = (balanceAfter - balanceBefore)
1376+ if ((exchangedAmount == exchangedAmount))
1377+ then exchangedAmount
13051378 else throw("Strict value is not equal to itself.")
13061379 }
13071380 else throw("Strict value is not equal to itself.")
13101383 }
13111384 else throw("Strict value is not equal to itself.")
13121385 }
1313- else rawFeeAmount
1314- if ((distributeFeeAmount == distributeFeeAmount))
1386+ else throw("Strict value is not equal to itself.")
1387+ }
1388+ else rawFeeAmount
1389+ if ((distributeFeeAmount == distributeFeeAmount))
1390+ then {
1391+ let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1392+ if ((referrerFeeAny == referrerFeeAny))
13151393 then {
1316- let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1317- if ((referrerFeeAny == referrerFeeAny))
1394+ let referrerFee = match referrerFeeAny {
1395+ case x: Int =>
1396+ x
1397+ case _ =>
1398+ throw("Invalid referrerFee")
1399+ }
1400+ let feeAmount = (distributeFeeAmount - referrerFee)
1401+ let $t06006360203 = getPosition(_trader)
1402+ let oldPositionSize = $t06006360203._1
1403+ let oldPositionMargin = $t06006360203._2
1404+ let oldPositionOpenNotional = $t06006360203._3
1405+ let oldPositionLstUpdCPF = $t06006360203._4
1406+ let feeToStakers = (feeAmount / 2)
1407+ let feeToInsurance = (feeAmount - feeToStakers)
1408+ let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
1409+ if ((stake == stake))
13181410 then {
1319- let referrerFee = match referrerFeeAny {
1320- case x: Int =>
1321- x
1322- case _ =>
1323- throw("Invalid referrerFee")
1324- }
1325- let feeAmount = (distributeFeeAmount - referrerFee)
1326- let $t05797158111 = getPosition(_trader)
1327- let oldPositionSize = $t05797158111._1
1328- let oldPositionMargin = $t05797158111._2
1329- let oldPositionOpenNotional = $t05797158111._3
1330- let oldPositionLstUpdCPF = $t05797158111._4
1331- let feeToStakers = (feeAmount / 2)
1332- let feeToInsurance = (feeAmount - feeToStakers)
1333- let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
1334- if ((stake == stake))
1411+ let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1412+ if ((depositInsurance == depositInsurance))
13351413 then {
1336- let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1337- if ((depositInsurance == depositInsurance))
1338- then {
1339- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1340- if ((notifyFee == notifyFee))
1341- then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
1342- else throw("Strict value is not equal to itself.")
1343- }
1414+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1415+ if ((notifyFee == notifyFee))
1416+ then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
13441417 else throw("Strict value is not equal to itself.")
13451418 }
13461419 else throw("Strict value is not equal to itself.")
13721445 else paused())
13731446 then throw("Invalid removeMargin parameters")
13741447 else {
1375- let $t05921759357 = getPosition(_trader)
1376- let oldPositionSize = $t05921759357._1
1377- let oldPositionMargin = $t05921759357._2
1378- let oldPositionOpenNotional = $t05921759357._3
1379- let oldPositionLstUpdCPF = $t05921759357._4
1448+ let $t06130961449 = getPosition(_trader)
1449+ let oldPositionSize = $t06130961449._1
1450+ let oldPositionMargin = $t06130961449._2
1451+ let oldPositionOpenNotional = $t06130961449._3
1452+ let oldPositionLstUpdCPF = $t06130961449._4
13801453 let marginDelta = -(_amount)
1381- let $t05939459573 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
1382- let remainMargin = $t05939459573._1
1383- let badDebt = $t05939459573._2
1454+ let $t06148661665 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
1455+ let remainMargin = $t06148661665._1
1456+ let badDebt = $t06148661665._2
13841457 if ((badDebt != 0))
13851458 then throw("Invalid removed margin amount")
13861459 else {
13891462 then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
13901463 else {
13911464 let quoteAssetStr = toBase58String(quoteAsset())
1392- let $t06001760071 = getBorrowedByTrader(_trader)
1393- let borrowed = $t06001760071._1
1394- let assetId = $t06001760071._2
1465+ let $t06210962163 = getBorrowedByTrader(_trader)
1466+ let borrowed = $t06210962163._1
1467+ let assetId = $t06210962163._2
13951468 let toRepay = if ((_amount > borrowed))
13961469 then borrowed
13971470 else _amount
14371510
14381511
14391512 @Callable(i)
1440-func closePosition () = {
1513+func closePosition (_size,_minQuoteAssetAmount) = {
14411514 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
14421515 if ((sync == sync))
14431516 then {
14441517 let _trader = getActualCaller(i)
14451518 let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller")
1446- if (if (if (!(requireOpenPosition(_trader)))
1519+ if (if (if (if (if (!(requireOpenPosition(_trader)))
14471520 then true
14481521 else !(initialized()))
14491522 then true
14501523 else paused())
1524+ then true
1525+ else (0 >= _size))
1526+ then true
1527+ else (0 > _minQuoteAssetAmount))
14511528 then throw("Invalid closePosition parameters")
14521529 else {
1453- let $t06232162699 = internalClosePosition(_trader, true)
1454- let x1 = $t06232162699._1
1455- let positionBadDebt = $t06232162699._2
1456- let realizedPnl = $t06232162699._3
1457- let marginToVault = $t06232162699._4
1458- let quoteAssetReserveAfter = $t06232162699._5
1459- let baseAssetReserveAfter = $t06232162699._6
1460- let totalPositionSizeAfter = $t06232162699._7
1461- let cumulativeNotionalAfter = $t06232162699._8
1462- let openInterestNotionalAfter = $t06232162699._9
1463- let x2 = $t06232162699._10
1464- let totalLongAfter = $t06232162699._11
1465- let totalShortAfter = $t06232162699._12
1530+ let $t06429364433 = getPosition(_trader)
1531+ let oldPositionSize = $t06429364433._1
1532+ let oldPositionMargin = $t06429364433._2
1533+ let oldPositionOpenNotional = $t06429364433._3
1534+ let oldPositionLstUpdCPF = $t06429364433._4
1535+ let $t06443968811 = if ((abs(oldPositionSize) > _size))
1536+ then {
1537+ let _direction = if ((oldPositionSize > 0))
1538+ then DIR_SHORT
1539+ else DIR_LONG
1540+ let isAdd = (_direction == DIR_LONG)
1541+ let $t06503065252 = swapOutput((oldPositionSize > 0), _size, true)
1542+ let exchangedQuoteAssetAmount = $t06503065252._1
1543+ let quoteAssetReserveAfter = $t06503065252._2
1544+ let baseAssetReserveAfter = $t06503065252._3
1545+ let totalPositionSizeAfter = $t06503065252._4
1546+ let exchangedPositionSize = if ((oldPositionSize > 0))
1547+ then -(_size)
1548+ else _size
1549+ let $t06534365497 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1550+ let oldPositionNotional = $t06534365497._1
1551+ let unrealizedPnl = $t06534365497._2
1552+ let realizedRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize))
1553+ let realizedPnl = muld(unrealizedPnl, realizedRatio)
1554+ let $t06571165949 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1555+ let remainMargin = $t06571165949._1
1556+ let positionBadDebt = $t06571165949._2
1557+ let fundingPayment = $t06571165949._3
1558+ let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
1559+ let remainOpenNotional = if ((oldPositionSize > 0))
1560+ then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
1561+ else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
1562+ let newPositionMargin = muld(remainMargin, realizedRatio)
1563+ let newPositionSize = (oldPositionSize + exchangedPositionSize)
1564+ let newPositionOpenNotional = abs(remainOpenNotional)
1565+ let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize)
1566+ let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount)
1567+ if (if ((_minQuoteAssetAmount != 0))
1568+ then (_minQuoteAssetAmount > exchangedQuoteAssetAmount)
1569+ else false)
1570+ then throw(((("Limit error: " + toString(exchangedQuoteAssetAmount)) + " < ") + toString(_minQuoteAssetAmount)))
1571+ else $Tuple15(newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, positionBadDebt, realizedPnl, (abs((remainMargin - newPositionMargin)) + realizedPnl), quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1572+ then abs(exchangedPositionSize)
1573+ else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1574+ then abs(exchangedPositionSize)
1575+ else 0)), (openInterestLong() - (if ((newPositionSize > 0))
1576+ then exchangedQuoteAssetAmount
1577+ else 0)), (openInterestShort() - (if ((0 > newPositionSize))
1578+ then exchangedQuoteAssetAmount
1579+ else 0)))
1580+ }
1581+ else if ((_size > abs(oldPositionSize)))
1582+ then throw("Invalid closePosition parameters")
1583+ else {
1584+ let $t06775268171 = internalClosePosition(_trader, true)
1585+ let exchangedQuoteAssetAmount = $t06775268171._1
1586+ let positionBadDebt = $t06775268171._2
1587+ let realizedPnl = $t06775268171._3
1588+ let marginToVault = $t06775268171._4
1589+ let quoteAssetReserveAfter = $t06775268171._5
1590+ let baseAssetReserveAfter = $t06775268171._6
1591+ let totalPositionSizeAfter = $t06775268171._7
1592+ let openInterestNotionalAfter = $t06775268171._8
1593+ let x2 = $t06775268171._9
1594+ let totalLongAfter = $t06775268171._10
1595+ let totalShortAfter = $t06775268171._11
1596+ let totalLongOpenInterestAfter = $t06775268171._12
1597+ let totalShortOpenInterestAfter = $t06775268171._13
1598+ if (if ((_minQuoteAssetAmount != 0))
1599+ then (_minQuoteAssetAmount > exchangedQuoteAssetAmount)
1600+ else false)
1601+ then throw(((("Limit error: " + toString(exchangedQuoteAssetAmount)) + " < ") + toString(_minQuoteAssetAmount)))
1602+ else $Tuple15(0, 0, 0, 0, positionBadDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)
1603+ }
1604+ let newPositionSize = $t06443968811._1
1605+ let newPositionMargin = $t06443968811._2
1606+ let newPositionOpenNotional = $t06443968811._3
1607+ let newPositionLstUpdCPF = $t06443968811._4
1608+ let positionBadDebt = $t06443968811._5
1609+ let realizedPnl = $t06443968811._6
1610+ let marginToVault = $t06443968811._7
1611+ let quoteAssetReserveAfter = $t06443968811._8
1612+ let baseAssetReserveAfter = $t06443968811._9
1613+ let totalPositionSizeAfter = $t06443968811._10
1614+ let openInterestNotionalAfter = $t06443968811._11
1615+ let totalLongAfter = $t06443968811._12
1616+ let totalShortAfter = $t06443968811._13
1617+ let totalLongOpenInterestAfter = $t06443968811._14
1618+ let totalShortOpenInterestAfter = $t06443968811._15
14661619 if ((positionBadDebt > 0))
14671620 then throw("Unable to close position with bad debt")
14681621 else {
14691622 let withdrawAmount = abs(marginToVault)
14701623 let ammBalance = (cbalance() - withdrawAmount)
1471- let $t06302363538 = if ((0 > ammBalance))
1624+ let $t06902069149 = if ((0 > ammBalance))
14721625 then $Tuple2(0, abs(ammBalance))
14731626 else $Tuple2(ammBalance, 0)
1474- let ammNewBalance = $t06302363538._1
1475- let x11 = $t06302363538._2
1627+ let ammNewBalance = $t06902069149._1
1628+ let x11 = $t06902069149._2
14761629 let unstake = invoke(vaultAddress(), "withdrawLocked", [withdrawAmount], nil)
14771630 if ((unstake == unstake))
14781631 then {
1479- let $t06375063804 = getBorrowedByTrader(_trader)
1480- let borrowed = $t06375063804._1
1481- let assetId = $t06375063804._2
1482- let $t06381964736 = if ((borrowed > 0))
1632+ let $t06936169415 = getBorrowedByTrader(_trader)
1633+ let borrowed = $t06936169415._1
1634+ let assetId = $t06936169415._2
1635+ let $t06943070347 = if ((borrowed > 0))
14831636 then if ((withdrawAmount >= borrowed))
14841637 then {
14851638 let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), borrowed)])
14941647 else throw("Strict value is not equal to itself.")
14951648 }
14961649 else $Tuple2(nil, withdrawAmount)
1497- if (($t06381964736 == $t06381964736))
1650+ if (($t06943070347 == $t06943070347))
14981651 then {
1499- let quoteWithdrawAmount = $t06381964736._2
1500- let sendCollateralAction = $t06381964736._1
1652+ let quoteWithdrawAmount = $t06943070347._2
1653+ let sendCollateralAction = $t06943070347._1
15011654 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
15021655 if ((notifyNotional == notifyNotional))
1503- then ((((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ (if ((quoteWithdrawAmount > 0))
1656+ then (((((if ((newPositionSize == 0))
1657+ then deletePosition(_trader)
1658+ else updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((quoteWithdrawAmount > 0))
15041659 then withdraw(_traderAddress, quoteWithdrawAmount)
15051660 else nil)) ++ updateBalance(ammNewBalance)) ++ sendCollateralAction)
15061661 else throw("Strict value is not equal to itself.")
15421697 then (DECIMAL_UNIT > partialLiquidationRatio())
15431698 else false)
15441699 then {
1545- let $t06650466654 = getPosition(_trader)
1546- let oldPositionSize = $t06650466654._1
1547- let oldPositionMargin = $t06650466654._2
1548- let oldPositionOpenNotional = $t06650466654._3
1549- let oldPositionLstUpdCPF = $t06650466654._4
1700+ let $t07239672546 = getPosition(_trader)
1701+ let oldPositionSize = $t07239672546._1
1702+ let oldPositionMargin = $t07239672546._2
1703+ let oldPositionOpenNotional = $t07239672546._3
1704+ let oldPositionLstUpdCPF = $t07239672546._4
15501705 let _direction = if ((oldPositionSize > 0))
15511706 then DIR_SHORT
15521707 else DIR_LONG
15531708 let isAdd = (_direction == DIR_LONG)
15541709 let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize)
1555- let $t06687966983 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1556- let oldPositionNotional = $t06687966983._1
1557- let unrealizedPnl = $t06687966983._2
1558- let $t06699167223 = swapInput(isAdd, exchangedQuoteAssetAmount)
1559- let exchangedPositionSize = $t06699167223._1
1560- let quoteAssetReserveAfter = $t06699167223._2
1561- let baseAssetReserveAfter = $t06699167223._3
1562- let totalPositionSizeAfter = $t06699167223._4
1563- let cumulativeNotionalAfter = $t06699167223._5
1710+ let $t07277172875 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1711+ let oldPositionNotional = $t07277172875._1
1712+ let unrealizedPnl = $t07277172875._2
1713+ let $t07288373070 = swapInput(isAdd, exchangedQuoteAssetAmount)
1714+ let exchangedPositionSize = $t07288373070._1
1715+ let quoteAssetReserveAfter = $t07288373070._2
1716+ let baseAssetReserveAfter = $t07288373070._3
1717+ let totalPositionSizeAfter = $t07288373070._4
15641718 let liquidationRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize))
15651719 let realizedPnl = muld(unrealizedPnl, liquidationRatio)
1566- let $t06751267745 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1567- let remainMargin = $t06751267745._1
1568- let badDebt = $t06751267745._2
1569- let fundingPayment = $t06751267745._3
1720+ let $t07335973592 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1721+ let remainMargin = $t07335973592._1
1722+ let badDebt = $t07335973592._2
1723+ let fundingPayment = $t07335973592._3
15701724 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
15711725 let remainOpenNotional = if ((oldPositionSize > 0))
15721726 then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
15801734 let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize)
15811735 let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount)
15821736 let ammBalance = (cbalance() - liquidationPenalty)
1583- let $t06891869047 = if ((0 > ammBalance))
1737+ let $t07476574894 = if ((0 > ammBalance))
15841738 then $Tuple2(0, abs(ammBalance))
15851739 else $Tuple2(ammBalance, 0)
1586- let newAmmBalance = $t06891869047._1
1587- let x11 = $t06891869047._2
1588- let $t06905569109 = getBorrowedByTrader(_trader)
1589- let borrowed = $t06905569109._1
1590- let assetId = $t06905569109._2
1740+ let newAmmBalance = $t07476574894._1
1741+ let x11 = $t07476574894._2
1742+ let $t07490274956 = getBorrowedByTrader(_trader)
1743+ let borrowed = $t07490274956._1
1744+ let assetId = $t07490274956._2
15911745 let doLiquidateCollateral = if ((borrowed > 0))
15921746 then {
15931747 let collateralToSell = muld(borrowed, liquidationRatio)
16071761 then {
16081762 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
16091763 if ((notifyNotional == notifyNotional))
1610- then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1764+ then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
16111765 then abs(exchangedPositionSize)
16121766 else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
16131767 then abs(exchangedPositionSize)
1768+ else 0)), (openInterestLong() - (if ((newPositionSize > 0))
1769+ then exchangedQuoteAssetAmount
1770+ else 0)), (openInterestShort() - (if ((0 > newPositionSize))
1771+ then exchangedQuoteAssetAmount
16141772 else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
16151773 else throw("Strict value is not equal to itself.")
16161774 }
16211779 else throw("Strict value is not equal to itself.")
16221780 }
16231781 else {
1624- let $t07091471369 = internalClosePosition(_trader, false)
1625- let x1 = $t07091471369._1
1626- let badDebt = $t07091471369._2
1627- let x2 = $t07091471369._3
1628- let x3 = $t07091471369._4
1629- let quoteAssetReserveAfter = $t07091471369._5
1630- let baseAssetReserveAfter = $t07091471369._6
1631- let totalPositionSizeAfter = $t07091471369._7
1632- let cumulativeNotionalAfter = $t07091471369._8
1633- let openInterestNotionalAfter = $t07091471369._9
1634- let exchangedQuoteAssetAmount = $t07091471369._10
1635- let totalLongAfter = $t07091471369._11
1636- let totalShortAfter = $t07091471369._12
1782+ let $t07665577150 = internalClosePosition(_trader, false)
1783+ let x1 = $t07665577150._1
1784+ let badDebt = $t07665577150._2
1785+ let x2 = $t07665577150._3
1786+ let x3 = $t07665577150._4
1787+ let quoteAssetReserveAfter = $t07665577150._5
1788+ let baseAssetReserveAfter = $t07665577150._6
1789+ let totalPositionSizeAfter = $t07665577150._7
1790+ let openInterestNotionalAfter = $t07665577150._8
1791+ let exchangedQuoteAssetAmount = $t07665577150._9
1792+ let totalLongAfter = $t07665577150._10
1793+ let totalShortAfter = $t07665577150._11
1794+ let totalLongOpenInterestAfter = $t07665577150._12
1795+ let totalShortOpenInterestAfter = $t07665577150._13
16371796 let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
16381797 let feeToLiquidator = (liquidationPenalty / 2)
16391798 let feeToInsurance = (liquidationPenalty - feeToLiquidator)
16401799 let ammBalance = (cbalance() - liquidationPenalty)
1641- let $t07178171910 = if ((0 > ammBalance))
1800+ let $t07756277691 = if ((0 > ammBalance))
16421801 then $Tuple2(0, abs(ammBalance))
16431802 else $Tuple2(ammBalance, 0)
1644- let newAmmBalance = $t07178171910._1
1645- let x11 = $t07178171910._2
1646- let $t07191871972 = getBorrowedByTrader(_trader)
1647- let borrowed = $t07191871972._1
1648- let assetId = $t07191871972._2
1803+ let newAmmBalance = $t07756277691._1
1804+ let x11 = $t07756277691._2
1805+ let $t07769977753 = getBorrowedByTrader(_trader)
1806+ let borrowed = $t07769977753._1
1807+ let assetId = $t07769977753._2
16491808 let doLiquidateCollateral = if ((borrowed > 0))
16501809 then {
16511810 let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], nil)
16741833 then {
16751834 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
16761835 if ((notifyNotional == notifyNotional))
1677- then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1836+ then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
16781837 else throw("Strict value is not equal to itself.")
16791838 }
16801839 else throw("Strict value is not equal to itself.")
17021861 then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp)))
17031862 else {
17041863 let underlyingPrice = getOracleTwapPrice()
1705- let $t07399974061 = getFunding()
1706- let shortPremiumFraction = $t07399974061._1
1707- let longPremiumFraction = $t07399974061._2
1864+ let $t07956079622 = getFunding()
1865+ let shortPremiumFraction = $t07956079622._1
1866+ let longPremiumFraction = $t07956079622._2
17081867 updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
17091868 }
17101869 }
17131872
17141873 @Callable(i)
17151874 func syncTerminalPriceToOracle () = {
1716- let $t07444374564 = getSyncTerminalPrice(getOracleTwapPrice())
1717- let newQuoteAssetWeight = $t07444374564._1
1718- let newBaseAssetWeight = $t07444374564._2
1719- let marginToVault = $t07444374564._3
1720- updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)
1721- }
1722-
1723-
1724-
1725-@Callable(i)
1726-func v_get (_trader) = {
1727- let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
1728- if ((sync == sync))
1729- then {
1730- let $t07474274802 = internalClosePosition(_trader, false)
1731- let x1 = $t07474274802._1
1732- let x2 = $t07474274802._2
1733- let x3 = $t07474274802._3
1734- let x4 = $t07474274802._4
1735- throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader))))
1736- }
1875+ let $t08000480125 = getSyncTerminalPrice(getOracleTwapPrice())
1876+ let newQuoteAssetWeight = $t08000480125._1
1877+ let newBaseAssetWeight = $t08000480125._2
1878+ let marginToVault = $t08000480125._3
1879+ let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil)
1880+ if ((lockBadDebt == lockBadDebt))
1881+ then updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)
17371882 else throw("Strict value is not equal to itself.")
17381883 }
17391884
17441889 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
17451890 if ((sync == sync))
17461891 then {
1747- let $t07501375114 = getPosition(_trader)
1748- let positionSize = $t07501375114._1
1749- let positionMargin = $t07501375114._2
1750- let pon = $t07501375114._3
1751- let positionLstUpdCPF = $t07501375114._4
1752- let $t07511775218 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1753- let positionNotional = $t07511775218._1
1754- let unrealizedPnl = $t07511775218._2
1755- let $t07522175393 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1756- let remainMargin = $t07522175393._1
1757- let badDebt = $t07522175393._2
1758- let fundingPayment = $t07522175393._3
1892+ let $t08050280603 = getPosition(_trader)
1893+ let positionSize = $t08050280603._1
1894+ let positionMargin = $t08050280603._2
1895+ let pon = $t08050280603._3
1896+ let positionLstUpdCPF = $t08050280603._4
1897+ let $t08060680707 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1898+ let positionNotional = $t08060680707._1
1899+ let unrealizedPnl = $t08060680707._2
1900+ let $t08071080882 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1901+ let remainMargin = $t08071080882._1
1902+ let badDebt = $t08071080882._2
1903+ let fundingPayment = $t08071080882._3
17591904 throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)))
17601905 }
17611906 else throw("Strict value is not equal to itself.")
17731918
17741919 @Callable(i)
17751920 func view_getTerminalAmmPrice () = {
1776- let $t07574075821 = getTerminalAmmState()
1777- let terminalQuoteAssetReserve = $t07574075821._1
1778- let terminalBaseAssetReserve = $t07574075821._2
1921+ let $t08122981310 = getTerminalAmmState()
1922+ let terminalQuoteAssetReserve = $t08122981310._1
1923+ let terminalBaseAssetReserve = $t08122981310._2
17791924 let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
17801925 throw(toString(price))
17811926 }
17851930 @Callable(i)
17861931 func view_getFunding () = {
17871932 let underlyingPrice = getOracleTwapPrice()
1788- let $t07604076102 = getFunding()
1789- let shortPremiumFraction = $t07604076102._1
1790- let longPremiumFraction = $t07604076102._2
1933+ let $t08152981591 = getFunding()
1934+ let shortPremiumFraction = $t08152981591._1
1935+ let longPremiumFraction = $t08152981591._2
17911936 let longFunding = divd(longPremiumFraction, underlyingPrice)
17921937 let shortFunding = divd(shortPremiumFraction, underlyingPrice)
17931938 throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOracleTwapPrice())))
17971942
17981943 @Callable(i)
17991944 func view_getBorrowedByTrader (_trader) = {
1800- let $t07639276446 = getBorrowedByTrader(_trader)
1801- let borrowed = $t07639276446._1
1802- let assetId = $t07639276446._2
1945+ let $t08188181935 = getBorrowedByTrader(_trader)
1946+ let borrowed = $t08188181935._1
1947+ let assetId = $t08188181935._2
18031948 throw((s(borrowed) + assetId))
1949+ }
1950+
1951+
1952+
1953+@Callable(i)
1954+func computeSpotPrice () = {
1955+ let result = getSpotPrice()
1956+ $Tuple2(nil, result)
1957+ }
1958+
1959+
1960+
1961+@Callable(i)
1962+func computeFeeForTraderWithArtifact (_trader,_artifactId) = {
1963+ let result = getForTraderWithArtifact(_trader, _artifactId)
1964+ $Tuple2(nil, result)
18041965 }
18051966
18061967
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_ora_key = "k_ora_key"
55
66 let k_ora_block_key = "k_ora_block_key"
77
88 let k_ora = "k_ora"
99
1010 let k_balance = "k_balance"
1111
12+let k_sequence = "k_sequence"
13+
1214 let k_positionSize = "k_positionSize"
1315
1416 let k_positionMargin = "k_positionMargin"
1517
1618 let k_positionOpenNotional = "k_positionOpenNotional"
1719
1820 let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction"
1921
20-let k_positionClosedDate = "k_positionClosedDate"
22+let k_positionSequence = "k_positionSequence"
2123
2224 let k_positionAsset = "k_positionAsset"
2325
2426 let k_initialized = "k_initialized"
2527
2628 let k_paused = "k_paused"
29+
30+let k_closeOnly = "k_closeOnly"
2731
2832 let k_fee = "k_fee"
2933
3034 let k_fundingPeriod = "k_fundingPeriod"
3135
3236 let k_initMarginRatio = "k_initMarginRatio"
3337
3438 let k_maintenanceMarginRatio = "k_mmr"
3539
3640 let k_liquidationFeeRatio = "k_liquidationFeeRatio"
3741
3842 let k_partialLiquidationRatio = "k_partLiquidationRatio"
3943
4044 let k_spreadLimit = "k_spreadLimit"
4145
4246 let k_maxPriceImpact = "k_maxPriceImpact"
4347
4448 let k_maxPriceSpread = "k_maxPriceSpread"
49+
50+let k_maxOpenNotional = "k_maxOpenNotional"
4551
4652 let k_lastDataStr = "k_lastDataStr"
4753
4854 let k_lastMinuteId = "k_lastMinuteId"
4955
5056 let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice"
5157
5258 let k_twapDataLastPrice = "k_twapDataLastPrice"
5359
5460 let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId"
5561
5662 let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction"
5763
5864 let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction"
5965
6066 let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp"
6167
6268 let k_longFundingRate = "k_longFundingRate"
6369
6470 let k_shortFundingRate = "k_shortFundingRate"
6571
6672 let k_quoteAssetReserve = "k_qtAstR"
6773
6874 let k_baseAssetReserve = "k_bsAstR"
6975
7076 let k_quoteAssetWeight = "k_qtAstW"
7177
7278 let k_baseAssetWeight = "k_bsAstW"
7379
7480 let k_totalPositionSize = "k_totalPositionSize"
7581
7682 let k_totalLongPositionSize = "k_totalLongPositionSize"
7783
7884 let k_totalShortPositionSize = "k_totalShortPositionSize"
7985
80-let k_cumulativeNotional = "k_cumulativeNotional"
86+let k_openInterestNotional = "k_openInterestNotional"
8187
82-let k_openInterestNotional = "k_openInterestNotional"
88+let k_openInterestShort = "k_openInterestShort"
89+
90+let k_openInterestLong = "k_openInterestLong"
8391
8492 let k_coordinatorAddress = "k_coordinatorAddress"
8593
8694 let k_vault_address = "k_vault_address"
8795
8896 let k_admin_address = "k_admin_address"
8997
9098 let k_admin_public_key = "k_admin_public_key"
9199
92100 let k_quote_asset = "k_quote_asset"
93101
94102 let k_quote_staking = "k_quote_staking"
95103
96104 let k_staking_address = "k_staking_address"
97105
98106 let k_miner_address = "k_miner_address"
99107
100108 let k_orders_address = "k_orders_address"
101109
102110 let k_referral_address = "k_referral_address"
103-
104-let k_manager_address = "k_manager_address"
105111
106112 let k_collateral_address = "k_collateral_address"
107113
108114 let k_exchange_address = "k_exchange_address"
109115
110116 let k_nft_manager_address = "k_nft_manager_address"
111117
112118 let k_trader_market_asset_collateral = "k_trader_market_asset_collateral"
113119
114120 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
115121
116122
117123 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
118124
119125
120126 func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
121127
122128
123129 func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
124130
125131
126132 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
127133
128134
129135 func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set")
130136
131137
132138 func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set")
133139
134140
135141 func vaultAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_vault_address)), "Vault not set")
136142
137143
138144 func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Miner not set")
139145
140146
141147 func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set")
142148
143149
144150 func referralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_referral_address)), "Referral not set")
145151
146152
147153 func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set")
148154
149155
150156 func collateralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_collateral_address)), "Collateral Manager not set")
151157
152158
153159 func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_exchange_address), "No swap address")), "Invalid swap address")
154160
155161
156162 let k_whitelist_asset = "k_whitelist_asset"
157163
158164 func isWhitelistAsset (_assetId) = valueOrElse(getBoolean(collateralAddress(), toCompositeKey(k_whitelist_asset, _assetId)), false)
159165
160166
161167 let k_token_param = "k_token_param"
162168
163169 let k_token_type = "k_token_type"
164170
165171 let FEE_REDUCTION_TOKEN_TYPE = "fee_reduction"
166172
167173 let DIR_LONG = 1
168174
169175 let DIR_SHORT = 2
170176
171177 let TWAP_INTERVAL = 15
172178
173179 let ORACLE_INTERVAL = 15
174180
175181 let SECONDS = 1000
176182
177183 let DECIMAL_NUMBERS = 6
178184
179185 let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10))
180186
181187 let ONE_DAY = (86400 * DECIMAL_UNIT)
182188
183189 let ALL_FEES = 100
184190
185191 let PNL_OPTION_SPOT = 1
186192
187193 let PNL_OPTION_ORACLE = 2
188194
189195 func s (_x) = (toString(_x) + ",")
190196
191197
192198 func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
193199
194200
195201 func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
196202
197203
198204 func sqrtd (_x) = sqrt(_x, DECIMAL_NUMBERS, DECIMAL_NUMBERS, HALFEVEN)
199205
200206
201207 func powd (_x,_y) = pow(_x, DECIMAL_NUMBERS, _y, DECIMAL_NUMBERS, DECIMAL_NUMBERS, HALFEVEN)
202208
203209
204210 func bdivd (_x,_y) = fraction(_x, toBigInt(DECIMAL_UNIT), _y, HALFEVEN)
205211
206212
207213 func bmuld (_x,_y) = fraction(_x, _y, toBigInt(DECIMAL_UNIT), HALFEVEN)
208214
209215
210216 func bsqrtd (_x) = sqrtBigInt(_x, DECIMAL_NUMBERS, DECIMAL_NUMBERS, HALFEVEN)
211217
212218
213219 func bpowd (_x,_y) = pow(_x, DECIMAL_NUMBERS, _y, DECIMAL_NUMBERS, DECIMAL_NUMBERS, HALFEVEN)
214220
215221
216222 func abs (_x) = if ((_x > 0))
217223 then _x
218224 else -(_x)
219225
220226
221227 func vmax (_x,_y) = if ((_x >= _y))
222228 then _x
223229 else _y
224230
225231
226232 func listToStr (_list) = {
227233 func _join (accumulator,val) = ((accumulator + val) + ",")
228234
229235 let newListStr = {
230236 let $l = _list
231237 let $s = size($l)
232238 let $acc0 = ""
233239 func $f0_1 ($a,$i) = if (($i >= $s))
234240 then $a
235241 else _join($a, $l[$i])
236242
237243 func $f0_2 ($a,$i) = if (($i >= $s))
238244 then $a
239245 else throw("List size exceeds 20")
240246
241247 $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)
242248 }
243249 let newListStrU = dropRight(newListStr, 1)
244250 let newListStrR = if ((take(newListStrU, 1) == ","))
245251 then drop(newListStrU, 1)
246252 else newListStrU
247253 newListStrR
248254 }
249255
250256
251257 func strToList (_str) = split(_str, ",")
252258
253259
254260 func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize))
255261 then (removeByIndex(_list, 0) :+ _value)
256262 else (_list :+ _value)
257263
258264
259265 func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
260266
261267
262268 func intOr (k,def) = valueOrElse(getInteger(this, k), def)
263269
264270
265271 func strA (_address,_key) = {
266272 let val = valueOrErrorMessage(getString(_address, _key), ("No value for key " + _key))
267273 val
268274 }
269275
270276
271277 func intA (_address,_key) = {
272278 let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key))
273279 val
274280 }
275281
276282
277283 func cbalance () = int(k_balance)
278284
279285
280286 func fee () = int(k_fee)
281287
282288
283289 func initMarginRatio () = int(k_initMarginRatio)
284290
285291
286292 func qtAstR () = int(k_quoteAssetReserve)
287293
288294
289295 func bsAstR () = int(k_baseAssetReserve)
290296
291297
292298 func qtAstW () = intOr(k_quoteAssetWeight, DECIMAL_UNIT)
293299
294300
295301 func bsAstW () = intOr(k_baseAssetWeight, DECIMAL_UNIT)
296302
297303
298304 func totalPositionSize () = int(k_totalPositionSize)
299305
300306
301-func cumulativeNotional () = int(k_cumulativeNotional)
307+func openInterestNotional () = int(k_openInterestNotional)
302308
303309
304-func openInterestNotional () = int(k_openInterestNotional)
310+func openInterestShort () = int(k_openInterestShort)
311+
312+
313+func openInterestLong () = int(k_openInterestLong)
305314
306315
307316 func nextFundingBlockTimestamp () = int(k_nextFundingBlock)
308317
309318
310319 func fundingPeriodRaw () = int(k_fundingPeriod)
311320
312321
313322 func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT)
314323
315324
316325 func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS)
317326
318327
319328 func maintenanceMarginRatio () = int(k_maintenanceMarginRatio)
320329
321330
322331 func liquidationFeeRatio () = int(k_liquidationFeeRatio)
323332
324333
325334 func partialLiquidationRatio () = int(k_partialLiquidationRatio)
326335
327336
328337 func spreadLimit () = int(k_spreadLimit)
329338
330339
331340 func maxPriceImpact () = int(k_maxPriceImpact)
332341
333342
334343 func maxPriceSpread () = int(k_maxPriceSpread)
335344
336345
346+func maxOpenNotional () = int(k_maxOpenNotional)
347+
348+
337349 func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction)
338350
339351
340352 func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction)
341353
342354
343355 func totalShortPositionSize () = int(k_totalShortPositionSize)
344356
345357
346358 func totalLongPositionSize () = int(k_totalLongPositionSize)
359+
360+
361+func lastSequence () = intOr(k_sequence, 0)
347362
348363
349364 func getActualCaller (i) = valueOrElse(getString(ordersAddress(), "k_sender"), toString(i.caller))
350365
351366
352367 func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = {
353368 let remainingMarginRatio = (_marginRatio - _baseMarginRatio)
354369 if (if (_largerThanOrEqualTo)
355370 then (0 > remainingMarginRatio)
356371 else false)
357372 then throw("Invalid margin")
358373 else if (if (!(_largerThanOrEqualTo))
359374 then (remainingMarginRatio >= 0)
360375 else false)
361376 then throw("Invalid margin")
362377 else true
363378 }
364379
365380
366381 func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0))
367382 then throw("Should not be called with _positionSize == 0")
368383 else if ((_positionSize > 0))
369384 then latestLongCumulativePremiumFraction()
370385 else latestShortCumulativePremiumFraction()
371386
372387
373388 func getPosition (_trader) = {
374389 let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader))
375390 match positionSizeOpt {
376391 case positionSize: Int =>
377392 $Tuple4(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)))
378393 case _ =>
379394 $Tuple4(0, 0, 0, 0)
380395 }
381396 }
382397
383398
384399 func getPositionAsset (_trader) = {
385400 let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader))
386401 match positionAssetOpt {
387402 case positionAsset: String =>
388403 positionAsset
389404 case _ =>
390405 toBase58String(quoteAsset())
391406 }
392407 }
393408
394409
395410 func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0))
396411 then throw("No open position")
397412 else true
398413
399414
400415 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
401416
402417
403418 func paused () = valueOrElse(getBoolean(this, k_paused), false)
404419
405420
421+func closeOnly () = valueOrElse(getBoolean(this, k_closeOnly), false)
422+
423+
406424 func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd)
407425 then {
408426 let newBase = (bsAstR() - _baseAssetAmount)
409427 if ((0 >= newBase))
410428 then throw("Tx lead to base asset reserve <= 0, revert")
411- else $Tuple4((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount), (cumulativeNotional() + _quoteAssetAmount))
429+ else $Tuple3((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount))
412430 }
413431 else {
414432 let newQuote = (qtAstR() - _quoteAssetAmount)
415433 if ((0 >= newQuote))
416434 then throw("Tx lead to base quote reserve <= 0, revert")
417- else $Tuple4(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount), (cumulativeNotional() - _quoteAssetAmount))
435+ else $Tuple3(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount))
418436 }
419437
420438
421-func calcInvariant (_qtAstR,_qtAstW,_bsAstR,_bsAstW) = muld(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
439+func calcInvariant (_qtAstR,_qtAstW,_bsAstR,_bsAstW) = {
440+ let bqtAstR = toBigInt(_qtAstR)
441+ let bqtAstW = toBigInt(_qtAstW)
442+ let bbsAstR = toBigInt(_bsAstR)
443+ let bbsAstW = toBigInt(_bsAstW)
444+ bmuld(bmuld(bqtAstR, bqtAstW), bmuld(bbsAstR, bbsAstW))
445+ }
422446
423447
424448 func swapInput (_isAdd,_quoteAssetAmount) = {
425449 let _qtAstR = qtAstR()
426450 let _bsAstR = bsAstR()
427451 let _qtAstW = qtAstW()
428452 let _bsAstW = bsAstW()
429453 let k = calcInvariant(_qtAstR, _qtAstW, _bsAstR, _bsAstW)
430454 let quoteAssetReserveAfter = if (_isAdd)
431455 then (_qtAstR + _quoteAssetAmount)
432456 else (_qtAstR - _quoteAssetAmount)
433- let baseAssetReserveAfter = divd(k, muld(quoteAssetReserveAfter, _qtAstW))
457+ let baseAssetReserveAfter = toInt(bdivd(k, toBigInt(muld(quoteAssetReserveAfter, _qtAstW))))
434458 let amountBaseAssetBoughtAbs = divd(abs((baseAssetReserveAfter - _bsAstR)), _qtAstW)
435459 let amountBaseAssetBought = if (_isAdd)
436460 then amountBaseAssetBoughtAbs
437461 else -(amountBaseAssetBoughtAbs)
438- let $t01633316526 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
439- let quoteAssetReserveAfter1 = $t01633316526._1
440- let baseAssetReserveAfter1 = $t01633316526._2
441- let totalPositionSizeAfter1 = $t01633316526._3
442- let cumulativeNotionalAfter1 = $t01633316526._4
462+ let $t01665516818 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
463+ let quoteAssetReserveAfter1 = $t01665516818._1
464+ let baseAssetReserveAfter1 = $t01665516818._2
465+ let totalPositionSizeAfter1 = $t01665516818._3
443466 let priceBefore = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
444467 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
445468 let priceDiff = abs((priceBefore - marketPrice))
446469 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
447470 let maxPriceImpactValue = maxPriceImpact()
448471 if ((priceImpact > maxPriceImpactValue))
449472 then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_qtAstR)) + " before base asset: ") + toString(_bsAstR)) + " quote asset amount to exchange: ") + toString(_quoteAssetAmount)) + " price before: ") + toString(priceBefore)) + " marketPrice: ") + toString(marketPrice)))
450- else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1)
473+ else $Tuple4(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1)
451474 }
452475
453476
454477 func calcRemainMarginWithFundingPayment (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_marginDelta) = {
455478 let fundingPayment = if ((_oldPositionSize != 0))
456479 then {
457480 let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize)
458481 muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize)
459482 }
460483 else 0
461484 let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin)
462- let $t01804518172 = if ((0 > signedMargin))
485+ let $t01830518432 = if ((0 > signedMargin))
463486 then $Tuple2(0, abs(signedMargin))
464487 else $Tuple2(abs(signedMargin), 0)
465- let remainMargin = $t01804518172._1
466- let badDebt = $t01804518172._2
488+ let remainMargin = $t01830518432._1
489+ let badDebt = $t01830518432._2
467490 $Tuple3(remainMargin, badDebt, fundingPayment)
468491 }
469492
470493
471494 func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight) = {
472495 let priceBefore = divd(muld(_quoteAssetReserve, _quoteAssetWeight), muld(_baseAssetReserve, _baseAssetWeight))
473496 if ((_baseAssetAmount == 0))
474497 then throw("Invalid base asset amount")
475498 else {
476499 let k = calcInvariant(_quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)
477500 let baseAssetPoolAmountAfter = if (_isAdd)
478501 then (_baseAssetReserve + _baseAssetAmount)
479502 else (_baseAssetReserve - _baseAssetAmount)
480- let quoteAssetAfter = divd(k, muld(baseAssetPoolAmountAfter, _baseAssetWeight))
503+ let quoteAssetAfter = toInt(bdivd(k, toBigInt(muld(baseAssetPoolAmountAfter, _baseAssetWeight))))
481504 let quoteAssetSold = abs((quoteAssetAfter - muld(_quoteAssetReserve, _quoteAssetWeight)))
482505 let maxPriceImpactValue = maxPriceImpact()
483- let $t01934019533 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
484- let quoteAssetReserveAfter1 = $t01934019533._1
485- let baseAssetReserveAfter1 = $t01934019533._2
486- let totalPositionSizeAfter1 = $t01934019533._3
487- let cumulativeNotionalAfter1 = $t01934019533._4
506+ let $t01962019781 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
507+ let quoteAssetReserveAfter1 = $t01962019781._1
508+ let baseAssetReserveAfter1 = $t01962019781._2
509+ let totalPositionSizeAfter1 = $t01962019781._3
488510 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
489511 let priceDiff = abs((priceBefore - marketPrice))
490512 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
491513 if (if ((priceImpact > maxPriceImpactValue))
492514 then _checkMaxPriceImpact
493515 else false)
494516 then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_quoteAssetReserve)) + " before base asset: ") + toString(_baseAssetReserve)) + " base asset amount to exchange: ") + toString(_baseAssetAmount)) + " price before: ") + toString(priceBefore)) + " market price: ") + toString(marketPrice)))
495- else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd)
517+ else $Tuple7(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, (totalLongPositionSize() - (if (_isAdd)
496518 then abs(_baseAssetAmount)
497519 else 0)), (totalShortPositionSize() - (if (!(_isAdd))
498520 then abs(_baseAssetAmount)
499521 else 0)), priceImpact)
500522 }
501523 }
502524
503525
504526 func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), qtAstW(), bsAstR(), bsAstW())
505527
506528
507529 func getOracleTwapPrice () = {
508530 let oracle = valueOrErrorMessage(addressFromString(getStringValue(this, k_ora)), "")
509531 let priceKey = getStringValue(this, k_ora_key)
510532 let blockKey = getStringValue(this, k_ora_block_key)
511533 let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey))
512534 lastValue
513535 }
514536
515537
516538 func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = {
517539 let oraclePrice = getOracleTwapPrice()
518540 let priceAfter = divd(_quoteAssetReserve, _baseAssetReserve)
519541 let averagePrice = divd((oraclePrice + priceAfter), (2 * DECIMAL_UNIT))
520542 let absPriceDiff = divd(abs((oraclePrice - priceAfter)), averagePrice)
521543 if ((absPriceDiff > maxPriceSpread()))
522544 then throw(((("Price spread " + toString(absPriceDiff)) + " > max price spread ") + toString(maxPriceSpread())))
523545 else true
524546 }
525547
526548
549+func requireNotOverMaxOpenNotional (_longOpenNotional,_shortOpenNotional) = {
550+ let _maxOpenNotional = maxOpenNotional()
551+ if ((_longOpenNotional > _maxOpenNotional))
552+ then throw(((("Long open notional " + toString(_longOpenNotional)) + " > max open notional ") + toString(_maxOpenNotional)))
553+ else if ((_shortOpenNotional > _maxOpenNotional))
554+ then throw(((("Short open notional " + toString(_shortOpenNotional)) + " > max open notional ") + toString(_maxOpenNotional)))
555+ else true
556+ }
557+
558+
527559 func getSpotPrice () = {
528560 let _quoteAssetReserve = qtAstR()
529561 let _baseAssetReserve = bsAstR()
530562 let _qtAstW = qtAstW()
531563 let _bsAstW = bsAstW()
532564 divd(muld(_quoteAssetReserve, _qtAstW), muld(_baseAssetReserve, _bsAstW))
533565 }
534566
535567
536568 func isOverFluctuationLimit () = {
537569 let oraclePrice = getOracleTwapPrice()
538570 let currentPrice = getSpotPrice()
539571 (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit())
540572 }
541573
542574
543575 func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight) = {
544576 let positionSizeAbs = abs(_positionSize)
545577 let isShort = (0 > _positionSize)
546578 let positionNotional = if ((_option == PNL_OPTION_SPOT))
547579 then {
548- let $t02290823128 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)
549- let outPositionNotional = $t02290823128._1
550- let x1 = $t02290823128._2
551- let x2 = $t02290823128._3
552- let x3 = $t02290823128._4
580+ let $t02365523875 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)
581+ let outPositionNotional = $t02365523875._1
582+ let x1 = $t02365523875._2
583+ let x2 = $t02365523875._3
584+ let x3 = $t02365523875._4
553585 outPositionNotional
554586 }
555587 else muld(positionSizeAbs, getOracleTwapPrice())
556588 positionNotional
557589 }
558590
559591
560592 func getPositionNotionalAndUnrealizedPnlByValues (_positionSize,_positionOpenNotional,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight,_option) = if ((_positionSize == 0))
561593 then throw("Invalid position size")
562594 else {
563595 let isShort = (0 > _positionSize)
564596 let positionNotional = getPositionAdjustedOpenNotional(_positionSize, _option, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)
565597 let unrealizedPnl = if (isShort)
566598 then (_positionOpenNotional - positionNotional)
567599 else (positionNotional - _positionOpenNotional)
568600 $Tuple2(positionNotional, unrealizedPnl)
569601 }
570602
571603
572604 func getPositionNotionalAndUnrealizedPnl (_trader,_option) = {
573- let $t02455324681 = getPosition(_trader)
574- let positionSize = $t02455324681._1
575- let positionMargin = $t02455324681._2
576- let positionOpenNotional = $t02455324681._3
577- let positionLstUpdCPF = $t02455324681._4
605+ let $t02530025428 = getPosition(_trader)
606+ let positionSize = $t02530025428._1
607+ let positionMargin = $t02530025428._2
608+ let positionOpenNotional = $t02530025428._3
609+ let positionLstUpdCPF = $t02530025428._4
578610 getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), qtAstW(), bsAstR(), bsAstW(), _option)
579611 }
580612
581613
582614 func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional)
583615
584616
585617 func getMarginRatioByOption (_trader,_option) = {
586- let $t02519425305 = getPosition(_trader)
587- let positionSize = $t02519425305._1
588- let positionMargin = $t02519425305._2
589- let pon = $t02519425305._3
590- let positionLstUpdCPF = $t02519425305._4
591- let $t02531125404 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
592- let positionNotional = $t02531125404._1
593- let unrealizedPnl = $t02531125404._2
594- let $t02540925575 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
595- let remainMargin = $t02540925575._1
596- let badDebt = $t02540925575._2
618+ let $t02594126052 = getPosition(_trader)
619+ let positionSize = $t02594126052._1
620+ let positionMargin = $t02594126052._2
621+ let pon = $t02594126052._3
622+ let positionLstUpdCPF = $t02594126052._4
623+ let $t02605826151 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
624+ let positionNotional = $t02605826151._1
625+ let unrealizedPnl = $t02605826151._2
626+ let $t02615626322 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
627+ let remainMargin = $t02615626322._1
628+ let badDebt = $t02615626322._2
597629 calcMarginRatio(remainMargin, badDebt, positionNotional)
598630 }
599631
600632
601633 func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
602634
603635
604636 func getPartialLiquidationAmount (_trader,_positionSize) = {
605637 let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio())))
606638 let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio)
607639 let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false)
608640 let maxExchangedQuoteAssetAmount = swapResult._1
609- let priceImpact = swapResult._8
641+ let priceImpact = swapResult._7
610642 if ((maxPriceImpact() > priceImpact))
611643 then maxExchangedQuoteAssetAmount
612644 else {
613645 let exchangedPositionSize = muld(abs(_positionSize), partialLiquidationRatio())
614646 let exchangedQuoteAssetAmount = swapOutput((_positionSize > 0), exchangedPositionSize, false)._1
615647 exchangedQuoteAssetAmount
616648 }
617649 }
618650
619651
620652 func internalClosePosition (_trader,_checkMaxPriceImpact) = {
621- let $t02680826936 = getPosition(_trader)
622- let positionSize = $t02680826936._1
623- let positionMargin = $t02680826936._2
624- let positionOpenNotional = $t02680826936._3
625- let positionLstUpdCPF = $t02680826936._4
653+ let $t02756227690 = getPosition(_trader)
654+ let positionSize = $t02756227690._1
655+ let positionMargin = $t02756227690._2
656+ let positionOpenNotional = $t02756227690._3
657+ let positionLstUpdCPF = $t02756227690._4
626658 let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2
627- let $t02703127199 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
628- let remainMargin = $t02703127199._1
629- let badDebt = $t02703127199._2
659+ let $t02778527953 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
660+ let remainMargin = $t02778527953._1
661+ let badDebt = $t02778527953._2
630662 let exchangedPositionSize = -(positionSize)
631663 let realizedPnl = unrealizedPnl
632664 let marginToVault = -(remainMargin)
633- let $t02732627631 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
634- let exchangedQuoteAssetAmount = $t02732627631._1
635- let quoteAssetReserveAfter = $t02732627631._2
636- let baseAssetReserveAfter = $t02732627631._3
637- let totalPositionSizeAfter = $t02732627631._4
638- let cumulativeNotionalAfter = $t02732627631._5
639- let totalLongAfter = $t02732627631._6
640- let totalShortAfter = $t02732627631._7
665+ let $t02808028354 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
666+ let exchangedQuoteAssetAmount = $t02808028354._1
667+ let quoteAssetReserveAfter = $t02808028354._2
668+ let baseAssetReserveAfter = $t02808028354._3
669+ let totalPositionSizeAfter = $t02808028354._4
670+ let totalLongAfter = $t02808028354._5
671+ let totalShortAfter = $t02808028354._6
641672 let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional)
642- $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter)
673+ $Tuple13(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter, (openInterestLong() - (if ((positionSize > 0))
674+ then positionOpenNotional
675+ else 0)), (openInterestShort() - (if ((0 > positionSize))
676+ then positionOpenNotional
677+ else 0)))
643678 }
644679
645680
646681 func getTwapSpotPrice () = {
647682 let minuteId = ((lastBlock.timestamp / 1000) / 60)
648683 let startMinuteId = (minuteId - TWAP_INTERVAL)
649684 let listStr = valueOrElse(getString(this, k_lastDataStr), "")
650685 let list = split(listStr, ",")
651686 func filterFn (accumulator,next) = if ((startMinuteId >= parseIntValue(next)))
652687 then (accumulator :+ parseIntValue(next))
653688 else accumulator
654689
655690 let listF = {
656691 let $l = list
657692 let $s = size($l)
658693 let $acc0 = nil
659694 func $f0_1 ($a,$i) = if (($i >= $s))
660695 then $a
661696 else filterFn($a, $l[$i])
662697
663698 func $f0_2 ($a,$i) = if (($i >= $s))
664699 then $a
665700 else throw("List size exceeds 20")
666701
667702 $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)
668703 }
669704 let maxIndex = if ((size(listF) > 0))
670705 then max(listF)
671706 else parseIntValue(list[0])
672707 let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
673708 let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0)
674709 let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0)
675710 let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice))
676711 let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0)
677712 let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0)
678713 let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice))
679714 ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL)
680715 }
681716
682717
683718 func getTerminalAmmState () = {
684719 let _positionSize = totalPositionSize()
685720 if ((_positionSize == 0))
686721 then $Tuple2(qtAstR(), bsAstR())
687722 else {
688723 let direction = (_positionSize > 0)
689- let $t02961829797 = swapOutput(direction, abs(_positionSize), false)
690- let currentNetMarketValue = $t02961829797._1
691- let terminalQuoteAssetReserve = $t02961829797._2
692- let terminalBaseAssetReserve = $t02961829797._3
724+ let $t03047730656 = swapOutput(direction, abs(_positionSize), false)
725+ let currentNetMarketValue = $t03047730656._1
726+ let terminalQuoteAssetReserve = $t03047730656._2
727+ let terminalBaseAssetReserve = $t03047730656._3
693728 $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve)
694729 }
695730 }
696731
697732
698733 func getQuoteAssetWeight (baseAssetReserve,totalPositionSize,quoteAssetReserve,targetPrice) = {
699734 let b = toBigInt(baseAssetReserve)
700735 let sz = toBigInt(totalPositionSize)
701736 let q = toBigInt(quoteAssetReserve)
702737 let p = toBigInt(targetPrice)
703738 let bs2 = bpowd((b + sz), toBigInt((2 * DECIMAL_UNIT)))
704739 let qbs2 = bmuld(q, bs2)
705740 let ps4 = (toBigInt(4) * bmuld(p, sz))
706741 let sqr = bsqrtd(bmuld(qbs2, (q - ps4)))
707742 let bq = bmuld(b, q)
708743 let qs = bmuld(q, sz)
709744 let top = ((-(sqr) + bq) + qs)
710745 let bot = (toBigInt(2) * bmuld(q, sz))
711746 let result = bdivd(top, bot)
712747 toInt(result)
713748 }
714749
715750
716751 func getSyncTerminalPrice (_terminalPrice) = {
717752 let _positionSize = totalPositionSize()
718753 if ((_positionSize == 0))
719754 then {
720755 let _qtAstR = qtAstR()
721756 let _bsAstR = bsAstR()
722757 let newQtAstW = divd(muld(_terminalPrice, _bsAstR), _qtAstR)
723758 $Tuple3(newQtAstW, DECIMAL_UNIT, 0)
724759 }
725760 else {
726761 let direction = (_positionSize > 0)
727762 let currentNetMarketValue = swapOutput(direction, abs(_positionSize), false)._1
728763 let _qtAstR = qtAstR()
729764 let _bsAstR = bsAstR()
730765 let newQtAstW = getQuoteAssetWeight(_bsAstR, _positionSize, _qtAstR, _terminalPrice)
731766 let newBsAstW = DECIMAL_UNIT
732767 let marginToVault = getPositionNotionalAndUnrealizedPnlByValues(_positionSize, currentNetMarketValue, _qtAstR, newQtAstW, _bsAstR, newBsAstW, PNL_OPTION_SPOT)._2
733768 $Tuple3(newQtAstW, newBsAstW, marginToVault)
734769 }
735770 }
736771
737772
738773 func getFunding () = {
739774 let underlyingPrice = getOracleTwapPrice()
740775 let spotTwapPrice = getTwapSpotPrice()
741776 let premium = (spotTwapPrice - underlyingPrice)
742777 if (if ((totalShortPositionSize() == 0))
743778 then true
744779 else (totalLongPositionSize() == 0))
745780 then $Tuple2(0, 0)
746781 else if ((0 > premium))
747782 then {
748783 let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
749784 let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize())
750785 $Tuple2(shortPremiumFraction, longPremiumFraction)
751786 }
752787 else {
753788 let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
754789 let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize())
755790 $Tuple2(shortPremiumFraction, longPremiumFraction)
756791 }
757792 }
758793
759794
760-func getAdjustedFee (i,_baseFeeDiscount) = {
795+func getAdjustedFee (_artifactId,_baseFeeDiscount) = {
761796 let baseFeeRaw = fee()
762797 let baseFee = muld(baseFeeRaw, _baseFeeDiscount)
763- let $t03289033498 = if ((size(i.payments) > 1))
798+ let $t03375534250 = if ((_artifactId != ""))
764799 then {
765- let artifactId = toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid attached artifact"))
766- let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, artifactId))
800+ let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, _artifactId))
767801 if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE))
768802 then {
769- let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, artifactId))
803+ let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, _artifactId))
770804 let adjustedFee = muld(baseFee, reduction)
771805 $Tuple2(adjustedFee, true)
772806 }
773807 else throw("Invalid attached artifact")
774808 }
775809 else $Tuple2(baseFee, false)
776- let adjustedFee = $t03289033498._1
777- let burnArtifact = $t03289033498._2
810+ let adjustedFee = $t03375534250._1
811+ let burnArtifact = $t03375534250._2
778812 $Tuple2(adjustedFee, burnArtifact)
779813 }
780814
781815
782-func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread)]
816+func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional)]
783817
784818
785819 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)]
786820
787821
788822 func updatePositionAsset (_address,_assetId) = [StringEntry(toCompositeKey(k_positionAsset, _address), _assetId)]
823+
824+
825+func incrementPositionSequenceNumber (isNewPosition,_address) = if (isNewPosition)
826+ then {
827+ let currentSequence = lastSequence()
828+[IntegerEntry(toCompositeKey(k_positionSequence, _address), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))]
829+ }
830+ else nil
789831
790832
791833 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)]
792834
793835
794836 func appendTwap (price) = {
795837 let minuteId = ((lastBlock.timestamp / 1000) / 60)
796838 let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
797839 if ((previousMinuteId > minuteId))
798840 then throw("TWAP out-of-order")
799841 else {
800842 let lastMinuteId = if ((previousMinuteId == 0))
801843 then minuteId
802844 else previousMinuteId
803845 if ((minuteId > previousMinuteId))
804846 then {
805847 let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0)
806848 let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), price)
807849 let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice))
808850 let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId))
809851 [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))]
810852 }
811853 else {
812854 let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0)
813855 let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0)
814856 let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), price)
815857 let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice))
816858 [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), price)]
817859 }
818860 }
819861 }
820862
821863
822864 func updateAmmReserves (_qtAstR,_bsAstR) = [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)]
823865
824866
825867 func updateAmmWeights (_qtAstW,_bsAstW) = [IntegerEntry(k_quoteAssetWeight, _qtAstW), IntegerEntry(k_baseAssetWeight, _bsAstW)]
826868
827869
828-func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_cumulativeNotionalAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize) = {
870+func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize,_totalLongOpenNotional,_totalShortOpenNotional) = {
829871 let _qtAstW = qtAstW()
830872 let _bsAstW = bsAstW()
831873 if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter))
832874 then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter)))
833- else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_cumulativeNotional, _cumulativeNotionalAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize)]) ++ appendTwap(divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))))
875+ else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize), IntegerEntry(k_openInterestLong, _totalLongOpenNotional), IntegerEntry(k_openInterestShort, _totalShortOpenNotional)]) ++ appendTwap(divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))))
834876 }
835877
836878
837-func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)]
879+func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address))]
838880
839881
840882 func withdraw (_address,_amount) = {
841883 let balance = assetBalance(this, quoteAsset())
842884 if ((_amount > balance))
843885 then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance)))
844886 else [ScriptTransfer(_address, _amount, quoteAsset())]
845887 }
846888
847889
848890 func updateBalance (i) = if ((0 > i))
849891 then throw("Balance")
850892 else [IntegerEntry(k_balance, i)]
851893
852894
853895 func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())]
854896
855897
856898 func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact)
857899 then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)]
858900 else nil
859901
860902
861903 func isSameAssetOrNoPosition (_trader,_assetId) = {
862904 let oldPositionSize = getPosition(_trader)._1
863905 if ((oldPositionSize == 0))
864906 then true
865907 else (getPositionAsset(_trader) == _assetId)
866908 }
867909
868910
869911 func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId)
870912
871913
872914 func getBorrowedByTraderInMarketKey (_amm,_assetId,_trader) = ((((((k_trader_market_asset_collateral + "_") + _amm) + "_") + _assetId) + "_") + _trader)
873915
874916
875917 func getBorrowedByTrader (_trader) = {
876918 let positionAsset = getPositionAsset(_trader)
877919 if ((positionAsset == toBase58String(quoteAsset())))
878920 then $Tuple2(0, positionAsset)
879921 else {
880922 let key = getBorrowedByTraderInMarketKey(toString(this), positionAsset, _trader)
881923 let borrow = valueOrElse(getInteger(collateralAddress(), key), 0)
882924 $Tuple2(borrow, positionAsset)
883925 }
884926 }
885927
886928
929+func getForTraderWithArtifact (_trader,_artifactId) = {
930+ let doGetFeeDiscount = invoke(minerAddress(), "computeFeeDiscount", [_trader], nil)
931+ if ((doGetFeeDiscount == doGetFeeDiscount))
932+ then {
933+ let feeDiscount = match doGetFeeDiscount {
934+ case x: Int =>
935+ x
936+ case _ =>
937+ throw("Invalid computeFeeDiscount result")
938+ }
939+ let $t04258342657 = getAdjustedFee(_artifactId, feeDiscount)
940+ let adjustedFee = $t04258342657._1
941+ let burnArtifact = $t04258342657._2
942+ $Tuple2(adjustedFee, burnArtifact)
943+ }
944+ else throw("Strict value is not equal to itself.")
945+ }
946+
947+
948+func getArtifactId (i) = {
949+ let artifactId = if ((size(i.payments) > 1))
950+ then toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifactId"))
951+ else ""
952+ artifactId
953+ }
954+
955+
887956 @Callable(i)
888957 func pause () = if ((i.caller != adminAddress()))
889- then throw("Invalid togglePause params")
958+ then throw("Invalid pause params")
890959 else [BooleanEntry(k_paused, true)]
891960
892961
893962
894963 @Callable(i)
895964 func unpause () = if ((i.caller != adminAddress()))
896- then throw("Invalid togglePause params")
965+ then throw("Invalid unpause params")
897966 else [BooleanEntry(k_paused, false)]
967+
968+
969+
970+@Callable(i)
971+func setCloseOnly () = if ((i.caller != adminAddress()))
972+ then throw("Invalid setCloseOnly params")
973+ else [BooleanEntry(k_closeOnly, true)]
974+
975+
976+
977+@Callable(i)
978+func unsetCloseOnly () = if ((i.caller != adminAddress()))
979+ then throw("Invalid unsetCloseOnly params")
980+ else [BooleanEntry(k_closeOnly, false)]
898981
899982
900983
901984 @Callable(i)
902985 func addLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress()))
903986 then true
904987 else (0 >= _quoteAssetAmount))
905988 then throw("Invalid addLiquidity params")
906989 else {
907990 let _qtAstR = qtAstR()
908991 let _bsAstR = bsAstR()
909992 let _qtAstW = qtAstW()
910993 let _bsAstW = bsAstW()
911994 let price = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
912995 let baseAssetAmountToAdd = divd(_quoteAssetAmount, price)
913996 let qtAstRAfter = (_qtAstR + _quoteAssetAmount)
914997 let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd)
915998 updateAmmReserves(qtAstRAfter, bsAstRAfter)
916999 }
9171000
9181001
9191002
9201003 @Callable(i)
9211004 func removeLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress()))
9221005 then true
9231006 else (0 >= _quoteAssetAmount))
9241007 then throw("Invalid removeLiquidity params")
9251008 else {
9261009 let _qtAstR = qtAstR()
9271010 let _bsAstR = bsAstR()
9281011 let _qtAstW = qtAstW()
9291012 let _bsAstW = bsAstW()
9301013 let price = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
9311014 let baseAssetAmountToRemove = divd(_quoteAssetAmount, price)
9321015 let qtAstRAfter = (_qtAstR - _quoteAssetAmount)
9331016 let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove)
9341017 updateAmmReserves(qtAstRAfter, bsAstRAfter)
9351018 }
9361019
9371020
9381021
9391022 @Callable(i)
940-func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress()))
1023+func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional) = if ((i.caller != adminAddress()))
9411024 then throw("Invalid changeSettings params")
942- else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)
1025+ else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional)
9431026
9441027
9451028
9461029 @Callable(i)
947-func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
1030+func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional) = if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
9481031 then true
9491032 else (0 >= _bsAstR))
9501033 then true
9511034 else (0 >= _fundingPeriod))
9521035 then true
9531036 else (0 >= _initMarginRatio))
9541037 then true
9551038 else (0 >= _mmr))
9561039 then true
9571040 else (0 >= _liquidationFeeRatio))
9581041 then true
9591042 else (0 >= _fee))
9601043 then true
9611044 else (0 >= _spreadLimit))
9621045 then true
9631046 else (0 >= _maxPriceImpact))
9641047 then true
9651048 else (0 >= _partialLiquidationRatio))
9661049 then true
9671050 else (0 >= _maxPriceSpread))
9681051 then true
1052+ else (0 >= _maxOpenNotional))
1053+ then true
9691054 else initialized())
9701055 then throw("Invalid initialize parameters")
971- else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)])
972-
973-
974-
975-@Callable(i)
976-func setInitMarginRatio (_initMarginRatio) = if (if ((0 >= _initMarginRatio))
977- then true
978- else !(initialized()))
979- then throw("Invalid setInitMarginRatio parameters")
980- else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread())
1056+ else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)])
9811057
9821058
9831059
9841060 @Callable(i)
9851061 func decreasePosition (_amount,_leverage,_minBaseAssetAmount) = {
9861062 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
9871063 if ((sync == sync))
988- then if (if (if (if (if ((0 >= _amount))
989- then true
990- else !(initialized()))
991- then true
992- else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
993- then true
994- else !(requireOpenPosition(toString(i.caller))))
995- then true
996- else paused())
997- then throw("Invalid decreasePosition parameters")
998- else {
999- let $t04547845630 = getPosition(toString(i.caller))
1000- let oldPositionSize = $t04547845630._1
1001- let oldPositionMargin = $t04547845630._2
1002- let oldPositionOpenNotional = $t04547845630._3
1003- let oldPositionLstUpdCPF = $t04547845630._4
1004- let _direction = if ((oldPositionSize > 0))
1005- then DIR_SHORT
1006- else DIR_LONG
1007- let isAdd = (_direction == DIR_LONG)
1008- let openNotional = muld(_amount, _leverage)
1009- let $t04580345919 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1010- let oldPositionNotional = $t04580345919._1
1011- let unrealizedPnl = $t04580345919._2
1012- let $t04592548474 = if ((oldPositionNotional > openNotional))
1013- then {
1014- let $t04630246521 = swapInput(isAdd, openNotional)
1015- let exchangedPositionSize = $t04630246521._1
1016- let quoteAssetReserveAfter = $t04630246521._2
1017- let baseAssetReserveAfter = $t04630246521._3
1018- let totalPositionSizeAfter = $t04630246521._4
1019- let cumulativeNotionalAfter = $t04630246521._5
1020- let exchangedPositionSizeAbs = abs(exchangedPositionSize)
1021- if (if ((_minBaseAssetAmount != 0))
1022- then (_minBaseAssetAmount > exchangedPositionSizeAbs)
1023- else false)
1024- then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount)))
1025- else {
1026- let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize))
1027- let $t04695847203 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1028- let remainMargin = $t04695847203._1
1029- let badDebt = $t04695847203._2
1030- let fundingPayment = $t04695847203._3
1031- let exchangedQuoteAssetAmount = openNotional
1032- let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
1033- let remainOpenNotional = if ((oldPositionSize > 0))
1034- then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
1035- else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
1036- let newPositionSize = (oldPositionSize + exchangedPositionSize)
1037- $Tuple11(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0))
1038- then abs(exchangedPositionSize)
1039- else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1040- then abs(exchangedPositionSize)
1041- else 0)))
1042- }
1043- }
1044- else throw("Close position first")
1045- let newPositionSize = $t04592548474._1
1046- let newPositionRemainMargin = $t04592548474._2
1047- let newPositionOpenNotional = $t04592548474._3
1048- let newPositionLatestCPF = $t04592548474._4
1049- let baseAssetReserveAfter = $t04592548474._5
1050- let quoteAssetReserveAfter = $t04592548474._6
1051- let totalPositionSizeAfter = $t04592548474._7
1052- let cumulativeNotionalAfter = $t04592548474._8
1053- let openInterestNotionalAfter = $t04592548474._9
1054- let totalLongAfter = $t04592548474._10
1055- let totalShortAfter = $t04592548474._11
1056- let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil)
1057- if ((notifyNotional == notifyNotional))
1058- then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter))
1059- else throw("Strict value is not equal to itself.")
1060- }
1064+ then {
1065+ let _trader = getActualCaller(i)
1066+ if (if (if (if (if ((0 >= _amount))
1067+ then true
1068+ else !(initialized()))
1069+ then true
1070+ else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
1071+ then true
1072+ else !(requireOpenPosition(_trader)))
1073+ then true
1074+ else paused())
1075+ then throw("Invalid decreasePosition parameters")
1076+ else {
1077+ let $t04734747487 = getPosition(_trader)
1078+ let oldPositionSize = $t04734747487._1
1079+ let oldPositionMargin = $t04734747487._2
1080+ let oldPositionOpenNotional = $t04734747487._3
1081+ let oldPositionLstUpdCPF = $t04734747487._4
1082+ let _direction = if ((oldPositionSize > 0))
1083+ then DIR_SHORT
1084+ else DIR_LONG
1085+ let isAdd = (_direction == DIR_LONG)
1086+ let openNotional = muld(_amount, _leverage)
1087+ let $t04766047764 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1088+ let oldPositionNotional = $t04766047764._1
1089+ let unrealizedPnl = $t04766047764._2
1090+ let $t04777050428 = if ((oldPositionNotional > openNotional))
1091+ then {
1092+ let $t04818548369 = swapInput(isAdd, openNotional)
1093+ let exchangedPositionSize = $t04818548369._1
1094+ let quoteAssetReserveAfter = $t04818548369._2
1095+ let baseAssetReserveAfter = $t04818548369._3
1096+ let totalPositionSizeAfter = $t04818548369._4
1097+ let exchangedPositionSizeAbs = abs(exchangedPositionSize)
1098+ if (if ((_minBaseAssetAmount != 0))
1099+ then (_minBaseAssetAmount > exchangedPositionSizeAbs)
1100+ else false)
1101+ then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount)))
1102+ else {
1103+ let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize))
1104+ let $t04880649051 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1105+ let remainMargin = $t04880649051._1
1106+ let badDebt = $t04880649051._2
1107+ let fundingPayment = $t04880649051._3
1108+ let exchangedQuoteAssetAmount = openNotional
1109+ let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
1110+ let remainOpenNotional = if ((oldPositionSize > 0))
1111+ then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
1112+ else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
1113+ let newPositionSize = (oldPositionSize + exchangedPositionSize)
1114+ $Tuple12(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0))
1115+ then abs(exchangedPositionSize)
1116+ else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1117+ then abs(exchangedPositionSize)
1118+ else 0)), (openInterestLong() - (if ((newPositionSize > 0))
1119+ then openNotional
1120+ else 0)), (openInterestShort() - (if ((0 > newPositionSize))
1121+ then openNotional
1122+ else 0)))
1123+ }
1124+ }
1125+ else throw("Close position first")
1126+ let newPositionSize = $t04777050428._1
1127+ let newPositionRemainMargin = $t04777050428._2
1128+ let newPositionOpenNotional = $t04777050428._3
1129+ let newPositionLatestCPF = $t04777050428._4
1130+ let baseAssetReserveAfter = $t04777050428._5
1131+ let quoteAssetReserveAfter = $t04777050428._6
1132+ let totalPositionSizeAfter = $t04777050428._7
1133+ let openInterestNotionalAfter = $t04777050428._8
1134+ let totalLongAfter = $t04777050428._9
1135+ let totalShortAfter = $t04777050428._10
1136+ let totalLongOpenInterestAfter = $t04777050428._11
1137+ let totalShortOpenInterestAfter = $t04777050428._12
1138+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1139+ if ((notifyNotional == notifyNotional))
1140+ then (updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter))
1141+ else throw("Strict value is not equal to itself.")
1142+ }
1143+ }
10611144 else throw("Strict value is not equal to itself.")
10621145 }
10631146
10641147
10651148
10661149 @Callable(i)
10671150 func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = {
10681151 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
10691152 if ((sync == sync))
10701153 then {
1071- let _trader = toString(i.caller)
1154+ let _trader = getActualCaller(i)
10721155 let _rawAmount = i.payments[0].amount
10731156 let _assetId = i.payments[0].assetId
10741157 let _assetIdStr = toBase58String(value(_assetId))
10751158 let isQuoteAsset = (_assetId == quoteAsset())
10761159 let isCollateralAsset = isWhitelistAsset(_assetIdStr)
1077- if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
1160+ if (if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
10781161 then (_direction != DIR_SHORT)
10791162 else false)
10801163 then true
10811164 else (0 >= _rawAmount))
10821165 then true
10831166 else !(initialized()))
10841167 then true
10851168 else if (!(isQuoteAsset))
10861169 then !(isCollateralAsset)
10871170 else false)
10881171 then true
10891172 else !(isSameAssetOrNoPosition(_trader, _assetIdStr)))
10901173 then true
10911174 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
10921175 then true
10931176 else paused())
1177+ then true
1178+ else closeOnly())
10941179 then throw("Invalid increasePosition parameters")
10951180 else {
1096- let doGetFeeDiscount = invoke(minerAddress(), "computeFeeDiscount", [_trader], nil)
1097- if ((doGetFeeDiscount == doGetFeeDiscount))
1181+ let $t05186651951 = getForTraderWithArtifact(_trader, getArtifactId(i))
1182+ let adjustedFee = $t05186651951._1
1183+ let burnArtifact = $t05186651951._2
1184+ let rawFeeAmount = muld(_rawAmount, adjustedFee)
1185+ let _amount = (_rawAmount - rawFeeAmount)
1186+ let distributeFeeAmount = if (isCollateralAsset)
10981187 then {
1099- let feeDiscount = match doGetFeeDiscount {
1100- case x: Int =>
1101- x
1102- case _ =>
1103- throw("Invalid computeFeeDiscount result")
1104- }
1105- let $t05013750201 = getAdjustedFee(i, feeDiscount)
1106- let adjustedFee = $t05013750201._1
1107- let burnArtifact = $t05013750201._2
1108- let rawFeeAmount = muld(_rawAmount, adjustedFee)
1109- let _amount = (_rawAmount - rawFeeAmount)
1110- let distributeFeeAmount = if (isCollateralAsset)
1188+ let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1189+ if ((doBorrow == doBorrow))
11111190 then {
1112- let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1113- if ((doBorrow == doBorrow))
1191+ let balanceBefore = assetBalance(this, quoteAsset())
1192+ if ((balanceBefore == balanceBefore))
11141193 then {
1115- let balanceBefore = assetBalance(this, quoteAsset())
1116- if ((balanceBefore == balanceBefore))
1194+ let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1195+ if ((doSwap == doSwap))
11171196 then {
1118- let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1119- if ((doSwap == doSwap))
1197+ let balanceAfter = assetBalance(this, quoteAsset())
1198+ if ((balanceAfter == balanceAfter))
11201199 then {
1121- let balanceAfter = assetBalance(this, quoteAsset())
1122- if ((balanceAfter == balanceAfter))
1123- then {
1124- let exchangedAmount = (balanceAfter - balanceBefore)
1125- if ((exchangedAmount == exchangedAmount))
1126- then exchangedAmount
1127- else throw("Strict value is not equal to itself.")
1128- }
1200+ let exchangedAmount = (balanceAfter - balanceBefore)
1201+ if ((exchangedAmount == exchangedAmount))
1202+ then exchangedAmount
11291203 else throw("Strict value is not equal to itself.")
11301204 }
11311205 else throw("Strict value is not equal to itself.")
11321206 }
11331207 else throw("Strict value is not equal to itself.")
11341208 }
11351209 else throw("Strict value is not equal to itself.")
11361210 }
1137- else rawFeeAmount
1138- if ((distributeFeeAmount == distributeFeeAmount))
1211+ else throw("Strict value is not equal to itself.")
1212+ }
1213+ else rawFeeAmount
1214+ if ((distributeFeeAmount == distributeFeeAmount))
1215+ then {
1216+ let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1217+ if ((referrerFeeAny == referrerFeeAny))
11391218 then {
1140- let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1141- if ((referrerFeeAny == referrerFeeAny))
1219+ let referrerFee = match referrerFeeAny {
1220+ case x: Int =>
1221+ x
1222+ case _ =>
1223+ throw("Invalid referrerFee")
1224+ }
1225+ let feeAmount = (distributeFeeAmount - referrerFee)
1226+ let $t05326753407 = getPosition(_trader)
1227+ let oldPositionSize = $t05326753407._1
1228+ let oldPositionMargin = $t05326753407._2
1229+ let oldPositionOpenNotional = $t05326753407._3
1230+ let oldPositionLstUpdCPF = $t05326753407._4
1231+ let isNewPosition = (oldPositionSize == 0)
1232+ let isSameDirection = if ((oldPositionSize > 0))
1233+ then (_direction == DIR_LONG)
1234+ else (_direction == DIR_SHORT)
1235+ let expandExisting = if (!(isNewPosition))
1236+ then isSameDirection
1237+ else false
1238+ let isAdd = (_direction == DIR_LONG)
1239+ let $t05369656737 = if (if (isNewPosition)
1240+ then true
1241+ else expandExisting)
11421242 then {
1143- let referrerFee = match referrerFeeAny {
1144- case x: Int =>
1145- x
1146- case _ =>
1147- throw("Invalid referrerFee")
1243+ let openNotional = muld(_amount, _leverage)
1244+ let $t05415854331 = swapInput(isAdd, openNotional)
1245+ let amountBaseAssetBought = $t05415854331._1
1246+ let quoteAssetReserveAfter = $t05415854331._2
1247+ let baseAssetReserveAfter = $t05415854331._3
1248+ let totalPositionSizeAfter = $t05415854331._4
1249+ if (if ((_minBaseAssetAmount != 0))
1250+ then (_minBaseAssetAmount > abs(amountBaseAssetBought))
1251+ else false)
1252+ then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
1253+ else {
1254+ let newPositionSize = (oldPositionSize + amountBaseAssetBought)
1255+ let totalLongOpenInterestAfter = (openInterestLong() + (if ((newPositionSize > 0))
1256+ then openNotional
1257+ else 0))
1258+ let totalShortOpenInterestAfter = (openInterestShort() + (if ((0 > newPositionSize))
1259+ then openNotional
1260+ else 0))
1261+ let increaseMarginRequirement = divd(openNotional, _leverage)
1262+ let $t05493955178 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
1263+ let remainMargin = $t05493955178._1
1264+ let x1 = $t05493955178._2
1265+ let x2 = $t05493955178._3
1266+ if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
1267+ then throw("Over max spread limit")
1268+ else if (!(requireNotOverMaxOpenNotional(totalLongOpenInterestAfter, totalShortOpenInterestAfter)))
1269+ then throw("Over max open notional")
1270+ else $Tuple12(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
1271+ then abs(amountBaseAssetBought)
1272+ else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
1273+ then abs(amountBaseAssetBought)
1274+ else 0)), totalLongOpenInterestAfter, totalShortOpenInterestAfter)
1275+ }
11481276 }
1149- let feeAmount = (distributeFeeAmount - referrerFee)
1150- let $t05151751657 = getPosition(_trader)
1151- let oldPositionSize = $t05151751657._1
1152- let oldPositionMargin = $t05151751657._2
1153- let oldPositionOpenNotional = $t05151751657._3
1154- let oldPositionLstUpdCPF = $t05151751657._4
1155- let isNewPosition = (oldPositionSize == 0)
1156- let isSameDirection = if ((oldPositionSize > 0))
1157- then (_direction == DIR_LONG)
1158- else (_direction == DIR_SHORT)
1159- let expandExisting = if (!(isNewPosition))
1160- then isSameDirection
1161- else false
1162- let isAdd = (_direction == DIR_LONG)
1163- let $t05194654531 = if (if (isNewPosition)
1164- then true
1165- else expandExisting)
1277+ else {
1278+ let openNotional = muld(_amount, _leverage)
1279+ let $t05643756553 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1280+ let oldPositionNotional = $t05643756553._1
1281+ let unrealizedPnl = $t05643756553._2
1282+ if ((oldPositionNotional > openNotional))
1283+ then throw("Use decreasePosition to decrease position size")
1284+ else throw("Close position first")
1285+ }
1286+ let newPositionSize = $t05369656737._1
1287+ let newPositionRemainMargin = $t05369656737._2
1288+ let newPositionOpenNotional = $t05369656737._3
1289+ let newPositionLatestCPF = $t05369656737._4
1290+ let baseAssetReserveAfter = $t05369656737._5
1291+ let quoteAssetReserveAfter = $t05369656737._6
1292+ let totalPositionSizeAfter = $t05369656737._7
1293+ let openInterestNotionalAfter = $t05369656737._8
1294+ let totalLongAfter = $t05369656737._9
1295+ let totalShortAfter = $t05369656737._10
1296+ let totalLongOpenInterestAfter = $t05369656737._11
1297+ let totalShortOpenInterestAfter = $t05369656737._12
1298+ let feeToStakers = (feeAmount / 2)
1299+ let feeToInsurance = (feeAmount - feeToStakers)
1300+ let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
1301+ if ((stake == stake))
1302+ then {
1303+ let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1304+ if ((depositInsurance == depositInsurance))
11661305 then {
1167- let openNotional = muld(_amount, _leverage)
1168- let $t05237052576 = swapInput(isAdd, openNotional)
1169- let amountBaseAssetBought = $t05237052576._1
1170- let quoteAssetReserveAfter = $t05237052576._2
1171- let baseAssetReserveAfter = $t05237052576._3
1172- let totalPositionSizeAfter = $t05237052576._4
1173- let cumulativeNotionalAfter = $t05237052576._5
1174- if (if ((_minBaseAssetAmount != 0))
1175- then (_minBaseAssetAmount > abs(amountBaseAssetBought))
1176- else false)
1177- then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
1178- else {
1179- let newPositionSize = (oldPositionSize + amountBaseAssetBought)
1180- let increaseMarginRequirement = divd(openNotional, _leverage)
1181- let $t05295753196 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
1182- let remainMargin = $t05295753196._1
1183- let x1 = $t05295753196._2
1184- let x2 = $t05295753196._3
1185- if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
1186- then throw("Over max spread limit")
1187- else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
1188- then abs(amountBaseAssetBought)
1189- else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
1190- then abs(amountBaseAssetBought)
1191- else 0)))
1192- }
1193- }
1194- else {
1195- let openNotional = muld(_amount, _leverage)
1196- let $t05422454340 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1197- let oldPositionNotional = $t05422454340._1
1198- let unrealizedPnl = $t05422454340._2
1199- if ((oldPositionNotional > openNotional))
1200- then throw("Use decreasePosition to decrease position size")
1201- else throw("Close position first")
1202- }
1203- let newPositionSize = $t05194654531._1
1204- let newPositionRemainMargin = $t05194654531._2
1205- let newPositionOpenNotional = $t05194654531._3
1206- let newPositionLatestCPF = $t05194654531._4
1207- let baseAssetReserveAfter = $t05194654531._5
1208- let quoteAssetReserveAfter = $t05194654531._6
1209- let totalPositionSizeAfter = $t05194654531._7
1210- let cumulativeNotionalAfter = $t05194654531._8
1211- let openInterestNotionalAfter = $t05194654531._9
1212- let totalLongAfter = $t05194654531._10
1213- let totalShortAfter = $t05194654531._11
1214- let feeToStakers = (feeAmount / 2)
1215- let feeToInsurance = (feeAmount - feeToStakers)
1216- let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
1217- if ((stake == stake))
1218- then {
1219- let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1220- if ((depositInsurance == depositInsurance))
1306+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1307+ if ((notifyFee == notifyFee))
12211308 then {
1222- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1223- if ((notifyFee == notifyFee))
1224- then {
1225- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1226- if ((notifyNotional == notifyNotional))
1227- then (((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
1228- else throw("Strict value is not equal to itself.")
1229- }
1309+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1310+ if ((notifyNotional == notifyNotional))
1311+ then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ incrementPositionSequenceNumber(isNewPosition, _trader)) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
12301312 else throw("Strict value is not equal to itself.")
12311313 }
12321314 else throw("Strict value is not equal to itself.")
12331315 }
12341316 else throw("Strict value is not equal to itself.")
12351317 }
12361318 else throw("Strict value is not equal to itself.")
12371319 }
12381320 else throw("Strict value is not equal to itself.")
12391321 }
12401322 else throw("Strict value is not equal to itself.")
12411323 }
12421324 }
12431325 else throw("Strict value is not equal to itself.")
12441326 }
12451327
12461328
12471329
12481330 @Callable(i)
12491331 func addMargin () = {
12501332 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
12511333 if ((sync == sync))
12521334 then {
12531335 let _trader = toString(i.caller)
12541336 let _rawAmount = i.payments[0].amount
12551337 let _assetId = i.payments[0].assetId
12561338 let _assetIdStr = toBase58String(value(_assetId))
12571339 let isQuoteAsset = (_assetId == quoteAsset())
12581340 let isCollateralAsset = isWhitelistAsset(_assetIdStr)
1259- if (if (if (if (if (if (!(isQuoteAsset))
1341+ if (if (if (if (if (if (if (!(isQuoteAsset))
12601342 then !(isCollateralAsset)
12611343 else false)
12621344 then true
12631345 else !(requireOpenPosition(toString(i.caller))))
12641346 then true
12651347 else !(isSameAsset(_trader, _assetIdStr)))
12661348 then true
12671349 else !(initialized()))
12681350 then true
12691351 else paused())
1352+ then true
1353+ else closeOnly())
12701354 then throw("Invalid addMargin parameters")
12711355 else {
1272- let doGetFeeDiscount = invoke(minerAddress(), "computeFeeDiscount", [_trader], nil)
1273- if ((doGetFeeDiscount == doGetFeeDiscount))
1356+ let $t05867958764 = getForTraderWithArtifact(_trader, getArtifactId(i))
1357+ let adjustedFee = $t05867958764._1
1358+ let burnArtifact = $t05867958764._2
1359+ let rawFeeAmount = muld(_rawAmount, adjustedFee)
1360+ let _amount = (_rawAmount - rawFeeAmount)
1361+ let distributeFeeAmount = if (isCollateralAsset)
12741362 then {
1275- let feeDiscount = match doGetFeeDiscount {
1276- case x: Int =>
1277- x
1278- case _ =>
1279- throw("Invalid computeFeeDiscount result")
1280- }
1281- let $t05660856672 = getAdjustedFee(i, feeDiscount)
1282- let adjustedFee = $t05660856672._1
1283- let burnArtifact = $t05660856672._2
1284- let rawFeeAmount = muld(_rawAmount, adjustedFee)
1285- let _amount = (_rawAmount - rawFeeAmount)
1286- let distributeFeeAmount = if (isCollateralAsset)
1363+ let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1364+ if ((doBorrow == doBorrow))
12871365 then {
1288- let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1289- if ((doBorrow == doBorrow))
1366+ let balanceBefore = assetBalance(this, quoteAsset())
1367+ if ((balanceBefore == balanceBefore))
12901368 then {
1291- let balanceBefore = assetBalance(this, quoteAsset())
1292- if ((balanceBefore == balanceBefore))
1369+ let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1370+ if ((doSwap == doSwap))
12931371 then {
1294- let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1295- if ((doSwap == doSwap))
1372+ let balanceAfter = assetBalance(this, quoteAsset())
1373+ if ((balanceAfter == balanceAfter))
12961374 then {
1297- let balanceAfter = assetBalance(this, quoteAsset())
1298- if ((balanceAfter == balanceAfter))
1299- then {
1300- let exchangedAmount = (balanceAfter - balanceBefore)
1301- if ((exchangedAmount == exchangedAmount))
1302- then exchangedAmount
1303- else throw("Strict value is not equal to itself.")
1304- }
1375+ let exchangedAmount = (balanceAfter - balanceBefore)
1376+ if ((exchangedAmount == exchangedAmount))
1377+ then exchangedAmount
13051378 else throw("Strict value is not equal to itself.")
13061379 }
13071380 else throw("Strict value is not equal to itself.")
13081381 }
13091382 else throw("Strict value is not equal to itself.")
13101383 }
13111384 else throw("Strict value is not equal to itself.")
13121385 }
1313- else rawFeeAmount
1314- if ((distributeFeeAmount == distributeFeeAmount))
1386+ else throw("Strict value is not equal to itself.")
1387+ }
1388+ else rawFeeAmount
1389+ if ((distributeFeeAmount == distributeFeeAmount))
1390+ then {
1391+ let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1392+ if ((referrerFeeAny == referrerFeeAny))
13151393 then {
1316- let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1317- if ((referrerFeeAny == referrerFeeAny))
1394+ let referrerFee = match referrerFeeAny {
1395+ case x: Int =>
1396+ x
1397+ case _ =>
1398+ throw("Invalid referrerFee")
1399+ }
1400+ let feeAmount = (distributeFeeAmount - referrerFee)
1401+ let $t06006360203 = getPosition(_trader)
1402+ let oldPositionSize = $t06006360203._1
1403+ let oldPositionMargin = $t06006360203._2
1404+ let oldPositionOpenNotional = $t06006360203._3
1405+ let oldPositionLstUpdCPF = $t06006360203._4
1406+ let feeToStakers = (feeAmount / 2)
1407+ let feeToInsurance = (feeAmount - feeToStakers)
1408+ let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
1409+ if ((stake == stake))
13181410 then {
1319- let referrerFee = match referrerFeeAny {
1320- case x: Int =>
1321- x
1322- case _ =>
1323- throw("Invalid referrerFee")
1324- }
1325- let feeAmount = (distributeFeeAmount - referrerFee)
1326- let $t05797158111 = getPosition(_trader)
1327- let oldPositionSize = $t05797158111._1
1328- let oldPositionMargin = $t05797158111._2
1329- let oldPositionOpenNotional = $t05797158111._3
1330- let oldPositionLstUpdCPF = $t05797158111._4
1331- let feeToStakers = (feeAmount / 2)
1332- let feeToInsurance = (feeAmount - feeToStakers)
1333- let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
1334- if ((stake == stake))
1411+ let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1412+ if ((depositInsurance == depositInsurance))
13351413 then {
1336- let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1337- if ((depositInsurance == depositInsurance))
1338- then {
1339- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1340- if ((notifyFee == notifyFee))
1341- then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
1342- else throw("Strict value is not equal to itself.")
1343- }
1414+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1415+ if ((notifyFee == notifyFee))
1416+ then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
13441417 else throw("Strict value is not equal to itself.")
13451418 }
13461419 else throw("Strict value is not equal to itself.")
13471420 }
13481421 else throw("Strict value is not equal to itself.")
13491422 }
13501423 else throw("Strict value is not equal to itself.")
13511424 }
13521425 else throw("Strict value is not equal to itself.")
13531426 }
13541427 }
13551428 else throw("Strict value is not equal to itself.")
13561429 }
13571430
13581431
13591432
13601433 @Callable(i)
13611434 func removeMargin (_amount) = {
13621435 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
13631436 if ((sync == sync))
13641437 then {
13651438 let _trader = toString(i.caller)
13661439 if (if (if (if ((0 >= _amount))
13671440 then true
13681441 else !(requireOpenPosition(_trader)))
13691442 then true
13701443 else !(initialized()))
13711444 then true
13721445 else paused())
13731446 then throw("Invalid removeMargin parameters")
13741447 else {
1375- let $t05921759357 = getPosition(_trader)
1376- let oldPositionSize = $t05921759357._1
1377- let oldPositionMargin = $t05921759357._2
1378- let oldPositionOpenNotional = $t05921759357._3
1379- let oldPositionLstUpdCPF = $t05921759357._4
1448+ let $t06130961449 = getPosition(_trader)
1449+ let oldPositionSize = $t06130961449._1
1450+ let oldPositionMargin = $t06130961449._2
1451+ let oldPositionOpenNotional = $t06130961449._3
1452+ let oldPositionLstUpdCPF = $t06130961449._4
13801453 let marginDelta = -(_amount)
1381- let $t05939459573 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
1382- let remainMargin = $t05939459573._1
1383- let badDebt = $t05939459573._2
1454+ let $t06148661665 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
1455+ let remainMargin = $t06148661665._1
1456+ let badDebt = $t06148661665._2
13841457 if ((badDebt != 0))
13851458 then throw("Invalid removed margin amount")
13861459 else {
13871460 let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional)
13881461 if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true)))
13891462 then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
13901463 else {
13911464 let quoteAssetStr = toBase58String(quoteAsset())
1392- let $t06001760071 = getBorrowedByTrader(_trader)
1393- let borrowed = $t06001760071._1
1394- let assetId = $t06001760071._2
1465+ let $t06210962163 = getBorrowedByTrader(_trader)
1466+ let borrowed = $t06210962163._1
1467+ let assetId = $t06210962163._2
13951468 let toRepay = if ((_amount > borrowed))
13961469 then borrowed
13971470 else _amount
13981471 let toWithdraw = if ((borrowed > _amount))
13991472 then 0
14001473 else (_amount - borrowed)
14011474 let finalBorrow = (borrowed - toRepay)
14021475 let switchPositionToQuote = if ((finalBorrow > 0))
14031476 then nil
14041477 else updatePositionAsset(_trader, quoteAssetStr)
14051478 let doSanityCheck = if (((toRepay + toWithdraw) != _amount))
14061479 then throw(((((("toRepay=" + toString(toRepay)) + " + toWithdraw=") + toString(toWithdraw)) + " != ") + toString(_amount)))
14071480 else nil
14081481 if ((doSanityCheck == doSanityCheck))
14091482 then {
14101483 let doUnstake = invoke(vaultAddress(), "withdrawLocked", [_amount], nil)
14111484 if ((doUnstake == doUnstake))
14121485 then {
14131486 let returnCollateralAction = if ((toRepay > 0))
14141487 then {
14151488 let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), toRepay)])
14161489 if ((doRepay == doRepay))
14171490 then [ScriptTransfer(i.caller, toRepay, fromBase58String(assetId))]
14181491 else throw("Strict value is not equal to itself.")
14191492 }
14201493 else nil
14211494 if ((returnCollateralAction == returnCollateralAction))
14221495 then ((((updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ (if ((toWithdraw > 0))
14231496 then withdraw(i.caller, toWithdraw)
14241497 else nil)) ++ updateBalance((cbalance() - _amount))) ++ switchPositionToQuote) ++ returnCollateralAction)
14251498 else throw("Strict value is not equal to itself.")
14261499 }
14271500 else throw("Strict value is not equal to itself.")
14281501 }
14291502 else throw("Strict value is not equal to itself.")
14301503 }
14311504 }
14321505 }
14331506 }
14341507 else throw("Strict value is not equal to itself.")
14351508 }
14361509
14371510
14381511
14391512 @Callable(i)
1440-func closePosition () = {
1513+func closePosition (_size,_minQuoteAssetAmount) = {
14411514 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
14421515 if ((sync == sync))
14431516 then {
14441517 let _trader = getActualCaller(i)
14451518 let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller")
1446- if (if (if (!(requireOpenPosition(_trader)))
1519+ if (if (if (if (if (!(requireOpenPosition(_trader)))
14471520 then true
14481521 else !(initialized()))
14491522 then true
14501523 else paused())
1524+ then true
1525+ else (0 >= _size))
1526+ then true
1527+ else (0 > _minQuoteAssetAmount))
14511528 then throw("Invalid closePosition parameters")
14521529 else {
1453- let $t06232162699 = internalClosePosition(_trader, true)
1454- let x1 = $t06232162699._1
1455- let positionBadDebt = $t06232162699._2
1456- let realizedPnl = $t06232162699._3
1457- let marginToVault = $t06232162699._4
1458- let quoteAssetReserveAfter = $t06232162699._5
1459- let baseAssetReserveAfter = $t06232162699._6
1460- let totalPositionSizeAfter = $t06232162699._7
1461- let cumulativeNotionalAfter = $t06232162699._8
1462- let openInterestNotionalAfter = $t06232162699._9
1463- let x2 = $t06232162699._10
1464- let totalLongAfter = $t06232162699._11
1465- let totalShortAfter = $t06232162699._12
1530+ let $t06429364433 = getPosition(_trader)
1531+ let oldPositionSize = $t06429364433._1
1532+ let oldPositionMargin = $t06429364433._2
1533+ let oldPositionOpenNotional = $t06429364433._3
1534+ let oldPositionLstUpdCPF = $t06429364433._4
1535+ let $t06443968811 = if ((abs(oldPositionSize) > _size))
1536+ then {
1537+ let _direction = if ((oldPositionSize > 0))
1538+ then DIR_SHORT
1539+ else DIR_LONG
1540+ let isAdd = (_direction == DIR_LONG)
1541+ let $t06503065252 = swapOutput((oldPositionSize > 0), _size, true)
1542+ let exchangedQuoteAssetAmount = $t06503065252._1
1543+ let quoteAssetReserveAfter = $t06503065252._2
1544+ let baseAssetReserveAfter = $t06503065252._3
1545+ let totalPositionSizeAfter = $t06503065252._4
1546+ let exchangedPositionSize = if ((oldPositionSize > 0))
1547+ then -(_size)
1548+ else _size
1549+ let $t06534365497 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1550+ let oldPositionNotional = $t06534365497._1
1551+ let unrealizedPnl = $t06534365497._2
1552+ let realizedRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize))
1553+ let realizedPnl = muld(unrealizedPnl, realizedRatio)
1554+ let $t06571165949 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1555+ let remainMargin = $t06571165949._1
1556+ let positionBadDebt = $t06571165949._2
1557+ let fundingPayment = $t06571165949._3
1558+ let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
1559+ let remainOpenNotional = if ((oldPositionSize > 0))
1560+ then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
1561+ else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
1562+ let newPositionMargin = muld(remainMargin, realizedRatio)
1563+ let newPositionSize = (oldPositionSize + exchangedPositionSize)
1564+ let newPositionOpenNotional = abs(remainOpenNotional)
1565+ let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize)
1566+ let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount)
1567+ if (if ((_minQuoteAssetAmount != 0))
1568+ then (_minQuoteAssetAmount > exchangedQuoteAssetAmount)
1569+ else false)
1570+ then throw(((("Limit error: " + toString(exchangedQuoteAssetAmount)) + " < ") + toString(_minQuoteAssetAmount)))
1571+ else $Tuple15(newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, positionBadDebt, realizedPnl, (abs((remainMargin - newPositionMargin)) + realizedPnl), quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1572+ then abs(exchangedPositionSize)
1573+ else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1574+ then abs(exchangedPositionSize)
1575+ else 0)), (openInterestLong() - (if ((newPositionSize > 0))
1576+ then exchangedQuoteAssetAmount
1577+ else 0)), (openInterestShort() - (if ((0 > newPositionSize))
1578+ then exchangedQuoteAssetAmount
1579+ else 0)))
1580+ }
1581+ else if ((_size > abs(oldPositionSize)))
1582+ then throw("Invalid closePosition parameters")
1583+ else {
1584+ let $t06775268171 = internalClosePosition(_trader, true)
1585+ let exchangedQuoteAssetAmount = $t06775268171._1
1586+ let positionBadDebt = $t06775268171._2
1587+ let realizedPnl = $t06775268171._3
1588+ let marginToVault = $t06775268171._4
1589+ let quoteAssetReserveAfter = $t06775268171._5
1590+ let baseAssetReserveAfter = $t06775268171._6
1591+ let totalPositionSizeAfter = $t06775268171._7
1592+ let openInterestNotionalAfter = $t06775268171._8
1593+ let x2 = $t06775268171._9
1594+ let totalLongAfter = $t06775268171._10
1595+ let totalShortAfter = $t06775268171._11
1596+ let totalLongOpenInterestAfter = $t06775268171._12
1597+ let totalShortOpenInterestAfter = $t06775268171._13
1598+ if (if ((_minQuoteAssetAmount != 0))
1599+ then (_minQuoteAssetAmount > exchangedQuoteAssetAmount)
1600+ else false)
1601+ then throw(((("Limit error: " + toString(exchangedQuoteAssetAmount)) + " < ") + toString(_minQuoteAssetAmount)))
1602+ else $Tuple15(0, 0, 0, 0, positionBadDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)
1603+ }
1604+ let newPositionSize = $t06443968811._1
1605+ let newPositionMargin = $t06443968811._2
1606+ let newPositionOpenNotional = $t06443968811._3
1607+ let newPositionLstUpdCPF = $t06443968811._4
1608+ let positionBadDebt = $t06443968811._5
1609+ let realizedPnl = $t06443968811._6
1610+ let marginToVault = $t06443968811._7
1611+ let quoteAssetReserveAfter = $t06443968811._8
1612+ let baseAssetReserveAfter = $t06443968811._9
1613+ let totalPositionSizeAfter = $t06443968811._10
1614+ let openInterestNotionalAfter = $t06443968811._11
1615+ let totalLongAfter = $t06443968811._12
1616+ let totalShortAfter = $t06443968811._13
1617+ let totalLongOpenInterestAfter = $t06443968811._14
1618+ let totalShortOpenInterestAfter = $t06443968811._15
14661619 if ((positionBadDebt > 0))
14671620 then throw("Unable to close position with bad debt")
14681621 else {
14691622 let withdrawAmount = abs(marginToVault)
14701623 let ammBalance = (cbalance() - withdrawAmount)
1471- let $t06302363538 = if ((0 > ammBalance))
1624+ let $t06902069149 = if ((0 > ammBalance))
14721625 then $Tuple2(0, abs(ammBalance))
14731626 else $Tuple2(ammBalance, 0)
1474- let ammNewBalance = $t06302363538._1
1475- let x11 = $t06302363538._2
1627+ let ammNewBalance = $t06902069149._1
1628+ let x11 = $t06902069149._2
14761629 let unstake = invoke(vaultAddress(), "withdrawLocked", [withdrawAmount], nil)
14771630 if ((unstake == unstake))
14781631 then {
1479- let $t06375063804 = getBorrowedByTrader(_trader)
1480- let borrowed = $t06375063804._1
1481- let assetId = $t06375063804._2
1482- let $t06381964736 = if ((borrowed > 0))
1632+ let $t06936169415 = getBorrowedByTrader(_trader)
1633+ let borrowed = $t06936169415._1
1634+ let assetId = $t06936169415._2
1635+ let $t06943070347 = if ((borrowed > 0))
14831636 then if ((withdrawAmount >= borrowed))
14841637 then {
14851638 let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), borrowed)])
14861639 if ((doRepay == doRepay))
14871640 then $Tuple2([ScriptTransfer(_traderAddress, borrowed, fromBase58String(assetId))], (withdrawAmount - borrowed))
14881641 else throw("Strict value is not equal to itself.")
14891642 }
14901643 else {
14911644 let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], [AttachedPayment(quoteAsset(), withdrawAmount)])
14921645 if ((realizeAndClose == realizeAndClose))
14931646 then $Tuple2([ScriptTransfer(_traderAddress, withdrawAmount, fromBase58String(assetId))], 0)
14941647 else throw("Strict value is not equal to itself.")
14951648 }
14961649 else $Tuple2(nil, withdrawAmount)
1497- if (($t06381964736 == $t06381964736))
1650+ if (($t06943070347 == $t06943070347))
14981651 then {
1499- let quoteWithdrawAmount = $t06381964736._2
1500- let sendCollateralAction = $t06381964736._1
1652+ let quoteWithdrawAmount = $t06943070347._2
1653+ let sendCollateralAction = $t06943070347._1
15011654 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
15021655 if ((notifyNotional == notifyNotional))
1503- then ((((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ (if ((quoteWithdrawAmount > 0))
1656+ then (((((if ((newPositionSize == 0))
1657+ then deletePosition(_trader)
1658+ else updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((quoteWithdrawAmount > 0))
15041659 then withdraw(_traderAddress, quoteWithdrawAmount)
15051660 else nil)) ++ updateBalance(ammNewBalance)) ++ sendCollateralAction)
15061661 else throw("Strict value is not equal to itself.")
15071662 }
15081663 else throw("Strict value is not equal to itself.")
15091664 }
15101665 else throw("Strict value is not equal to itself.")
15111666 }
15121667 }
15131668 }
15141669 else throw("Strict value is not equal to itself.")
15151670 }
15161671
15171672
15181673
15191674 @Callable(i)
15201675 func liquidate (_trader) = {
15211676 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
15221677 if ((sync == sync))
15231678 then {
15241679 let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
15251680 let marginRatio = if (isOverFluctuationLimit())
15261681 then {
15271682 let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE)
15281683 vmax(spotMarginRatio, oracleMarginRatio)
15291684 }
15301685 else spotMarginRatio
15311686 if (if (if (if (!(requireMoreMarginRatio(marginRatio, maintenanceMarginRatio(), false)))
15321687 then true
15331688 else !(requireOpenPosition(_trader)))
15341689 then true
15351690 else !(initialized()))
15361691 then true
15371692 else paused())
15381693 then throw("Unable to liquidate")
15391694 else if (if (if ((spotMarginRatio > liquidationFeeRatio()))
15401695 then (partialLiquidationRatio() > 0)
15411696 else false)
15421697 then (DECIMAL_UNIT > partialLiquidationRatio())
15431698 else false)
15441699 then {
1545- let $t06650466654 = getPosition(_trader)
1546- let oldPositionSize = $t06650466654._1
1547- let oldPositionMargin = $t06650466654._2
1548- let oldPositionOpenNotional = $t06650466654._3
1549- let oldPositionLstUpdCPF = $t06650466654._4
1700+ let $t07239672546 = getPosition(_trader)
1701+ let oldPositionSize = $t07239672546._1
1702+ let oldPositionMargin = $t07239672546._2
1703+ let oldPositionOpenNotional = $t07239672546._3
1704+ let oldPositionLstUpdCPF = $t07239672546._4
15501705 let _direction = if ((oldPositionSize > 0))
15511706 then DIR_SHORT
15521707 else DIR_LONG
15531708 let isAdd = (_direction == DIR_LONG)
15541709 let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize)
1555- let $t06687966983 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1556- let oldPositionNotional = $t06687966983._1
1557- let unrealizedPnl = $t06687966983._2
1558- let $t06699167223 = swapInput(isAdd, exchangedQuoteAssetAmount)
1559- let exchangedPositionSize = $t06699167223._1
1560- let quoteAssetReserveAfter = $t06699167223._2
1561- let baseAssetReserveAfter = $t06699167223._3
1562- let totalPositionSizeAfter = $t06699167223._4
1563- let cumulativeNotionalAfter = $t06699167223._5
1710+ let $t07277172875 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1711+ let oldPositionNotional = $t07277172875._1
1712+ let unrealizedPnl = $t07277172875._2
1713+ let $t07288373070 = swapInput(isAdd, exchangedQuoteAssetAmount)
1714+ let exchangedPositionSize = $t07288373070._1
1715+ let quoteAssetReserveAfter = $t07288373070._2
1716+ let baseAssetReserveAfter = $t07288373070._3
1717+ let totalPositionSizeAfter = $t07288373070._4
15641718 let liquidationRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize))
15651719 let realizedPnl = muld(unrealizedPnl, liquidationRatio)
1566- let $t06751267745 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1567- let remainMargin = $t06751267745._1
1568- let badDebt = $t06751267745._2
1569- let fundingPayment = $t06751267745._3
1720+ let $t07335973592 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1721+ let remainMargin = $t07335973592._1
1722+ let badDebt = $t07335973592._2
1723+ let fundingPayment = $t07335973592._3
15701724 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
15711725 let remainOpenNotional = if ((oldPositionSize > 0))
15721726 then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
15731727 else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
15741728 let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
15751729 let feeToLiquidator = (liquidationPenalty / 2)
15761730 let feeToInsurance = (liquidationPenalty - feeToLiquidator)
15771731 let newPositionMargin = (remainMargin - liquidationPenalty)
15781732 let newPositionSize = (oldPositionSize + exchangedPositionSize)
15791733 let newPositionOpenNotional = abs(remainOpenNotional)
15801734 let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize)
15811735 let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount)
15821736 let ammBalance = (cbalance() - liquidationPenalty)
1583- let $t06891869047 = if ((0 > ammBalance))
1737+ let $t07476574894 = if ((0 > ammBalance))
15841738 then $Tuple2(0, abs(ammBalance))
15851739 else $Tuple2(ammBalance, 0)
1586- let newAmmBalance = $t06891869047._1
1587- let x11 = $t06891869047._2
1588- let $t06905569109 = getBorrowedByTrader(_trader)
1589- let borrowed = $t06905569109._1
1590- let assetId = $t06905569109._2
1740+ let newAmmBalance = $t07476574894._1
1741+ let x11 = $t07476574894._2
1742+ let $t07490274956 = getBorrowedByTrader(_trader)
1743+ let borrowed = $t07490274956._1
1744+ let assetId = $t07490274956._2
15911745 let doLiquidateCollateral = if ((borrowed > 0))
15921746 then {
15931747 let collateralToSell = muld(borrowed, liquidationRatio)
15941748 let realizeAndClose = invoke(collateralAddress(), "realizePartially", [_trader, assetId, collateralToSell], nil)
15951749 if ((realizeAndClose == realizeAndClose))
15961750 then nil
15971751 else throw("Strict value is not equal to itself.")
15981752 }
15991753 else nil
16001754 if ((doLiquidateCollateral == doLiquidateCollateral))
16011755 then {
16021756 let unstake = invoke(vaultAddress(), "withdrawLocked", [liquidationPenalty], nil)
16031757 if ((unstake == unstake))
16041758 then {
16051759 let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
16061760 if ((depositInsurance == depositInsurance))
16071761 then {
16081762 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
16091763 if ((notifyNotional == notifyNotional))
1610- then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1764+ then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
16111765 then abs(exchangedPositionSize)
16121766 else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
16131767 then abs(exchangedPositionSize)
1768+ else 0)), (openInterestLong() - (if ((newPositionSize > 0))
1769+ then exchangedQuoteAssetAmount
1770+ else 0)), (openInterestShort() - (if ((0 > newPositionSize))
1771+ then exchangedQuoteAssetAmount
16141772 else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
16151773 else throw("Strict value is not equal to itself.")
16161774 }
16171775 else throw("Strict value is not equal to itself.")
16181776 }
16191777 else throw("Strict value is not equal to itself.")
16201778 }
16211779 else throw("Strict value is not equal to itself.")
16221780 }
16231781 else {
1624- let $t07091471369 = internalClosePosition(_trader, false)
1625- let x1 = $t07091471369._1
1626- let badDebt = $t07091471369._2
1627- let x2 = $t07091471369._3
1628- let x3 = $t07091471369._4
1629- let quoteAssetReserveAfter = $t07091471369._5
1630- let baseAssetReserveAfter = $t07091471369._6
1631- let totalPositionSizeAfter = $t07091471369._7
1632- let cumulativeNotionalAfter = $t07091471369._8
1633- let openInterestNotionalAfter = $t07091471369._9
1634- let exchangedQuoteAssetAmount = $t07091471369._10
1635- let totalLongAfter = $t07091471369._11
1636- let totalShortAfter = $t07091471369._12
1782+ let $t07665577150 = internalClosePosition(_trader, false)
1783+ let x1 = $t07665577150._1
1784+ let badDebt = $t07665577150._2
1785+ let x2 = $t07665577150._3
1786+ let x3 = $t07665577150._4
1787+ let quoteAssetReserveAfter = $t07665577150._5
1788+ let baseAssetReserveAfter = $t07665577150._6
1789+ let totalPositionSizeAfter = $t07665577150._7
1790+ let openInterestNotionalAfter = $t07665577150._8
1791+ let exchangedQuoteAssetAmount = $t07665577150._9
1792+ let totalLongAfter = $t07665577150._10
1793+ let totalShortAfter = $t07665577150._11
1794+ let totalLongOpenInterestAfter = $t07665577150._12
1795+ let totalShortOpenInterestAfter = $t07665577150._13
16371796 let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
16381797 let feeToLiquidator = (liquidationPenalty / 2)
16391798 let feeToInsurance = (liquidationPenalty - feeToLiquidator)
16401799 let ammBalance = (cbalance() - liquidationPenalty)
1641- let $t07178171910 = if ((0 > ammBalance))
1800+ let $t07756277691 = if ((0 > ammBalance))
16421801 then $Tuple2(0, abs(ammBalance))
16431802 else $Tuple2(ammBalance, 0)
1644- let newAmmBalance = $t07178171910._1
1645- let x11 = $t07178171910._2
1646- let $t07191871972 = getBorrowedByTrader(_trader)
1647- let borrowed = $t07191871972._1
1648- let assetId = $t07191871972._2
1803+ let newAmmBalance = $t07756277691._1
1804+ let x11 = $t07756277691._2
1805+ let $t07769977753 = getBorrowedByTrader(_trader)
1806+ let borrowed = $t07769977753._1
1807+ let assetId = $t07769977753._2
16491808 let doLiquidateCollateral = if ((borrowed > 0))
16501809 then {
16511810 let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], nil)
16521811 if ((realizeAndClose == realizeAndClose))
16531812 then nil
16541813 else throw("Strict value is not equal to itself.")
16551814 }
16561815 else nil
16571816 if ((doLiquidateCollateral == doLiquidateCollateral))
16581817 then {
16591818 let x = if ((badDebt > 0))
16601819 then {
16611820 let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [badDebt], nil)
16621821 if ((lockBadDebt == lockBadDebt))
16631822 then nil
16641823 else throw("Strict value is not equal to itself.")
16651824 }
16661825 else nil
16671826 if ((x == x))
16681827 then {
16691828 let unstake = invoke(vaultAddress(), "withdrawLocked", [liquidationPenalty], nil)
16701829 if ((unstake == unstake))
16711830 then {
16721831 let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
16731832 if ((depositInsurance == depositInsurance))
16741833 then {
16751834 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
16761835 if ((notifyNotional == notifyNotional))
1677- then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1836+ then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
16781837 else throw("Strict value is not equal to itself.")
16791838 }
16801839 else throw("Strict value is not equal to itself.")
16811840 }
16821841 else throw("Strict value is not equal to itself.")
16831842 }
16841843 else throw("Strict value is not equal to itself.")
16851844 }
16861845 else throw("Strict value is not equal to itself.")
16871846 }
16881847 }
16891848 else throw("Strict value is not equal to itself.")
16901849 }
16911850
16921851
16931852
16941853 @Callable(i)
16951854 func payFunding () = {
16961855 let fundingBlockTimestamp = nextFundingBlockTimestamp()
16971856 if (if (if ((fundingBlockTimestamp > lastBlock.timestamp))
16981857 then true
16991858 else !(initialized()))
17001859 then true
17011860 else paused())
17021861 then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp)))
17031862 else {
17041863 let underlyingPrice = getOracleTwapPrice()
1705- let $t07399974061 = getFunding()
1706- let shortPremiumFraction = $t07399974061._1
1707- let longPremiumFraction = $t07399974061._2
1864+ let $t07956079622 = getFunding()
1865+ let shortPremiumFraction = $t07956079622._1
1866+ let longPremiumFraction = $t07956079622._2
17081867 updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
17091868 }
17101869 }
17111870
17121871
17131872
17141873 @Callable(i)
17151874 func syncTerminalPriceToOracle () = {
1716- let $t07444374564 = getSyncTerminalPrice(getOracleTwapPrice())
1717- let newQuoteAssetWeight = $t07444374564._1
1718- let newBaseAssetWeight = $t07444374564._2
1719- let marginToVault = $t07444374564._3
1720- updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)
1721- }
1722-
1723-
1724-
1725-@Callable(i)
1726-func v_get (_trader) = {
1727- let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
1728- if ((sync == sync))
1729- then {
1730- let $t07474274802 = internalClosePosition(_trader, false)
1731- let x1 = $t07474274802._1
1732- let x2 = $t07474274802._2
1733- let x3 = $t07474274802._3
1734- let x4 = $t07474274802._4
1735- throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader))))
1736- }
1875+ let $t08000480125 = getSyncTerminalPrice(getOracleTwapPrice())
1876+ let newQuoteAssetWeight = $t08000480125._1
1877+ let newBaseAssetWeight = $t08000480125._2
1878+ let marginToVault = $t08000480125._3
1879+ let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil)
1880+ if ((lockBadDebt == lockBadDebt))
1881+ then updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)
17371882 else throw("Strict value is not equal to itself.")
17381883 }
17391884
17401885
17411886
17421887 @Callable(i)
17431888 func view_calcRemainMarginWithFundingPayment (_trader) = {
17441889 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
17451890 if ((sync == sync))
17461891 then {
1747- let $t07501375114 = getPosition(_trader)
1748- let positionSize = $t07501375114._1
1749- let positionMargin = $t07501375114._2
1750- let pon = $t07501375114._3
1751- let positionLstUpdCPF = $t07501375114._4
1752- let $t07511775218 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1753- let positionNotional = $t07511775218._1
1754- let unrealizedPnl = $t07511775218._2
1755- let $t07522175393 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1756- let remainMargin = $t07522175393._1
1757- let badDebt = $t07522175393._2
1758- let fundingPayment = $t07522175393._3
1892+ let $t08050280603 = getPosition(_trader)
1893+ let positionSize = $t08050280603._1
1894+ let positionMargin = $t08050280603._2
1895+ let pon = $t08050280603._3
1896+ let positionLstUpdCPF = $t08050280603._4
1897+ let $t08060680707 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1898+ let positionNotional = $t08060680707._1
1899+ let unrealizedPnl = $t08060680707._2
1900+ let $t08071080882 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1901+ let remainMargin = $t08071080882._1
1902+ let badDebt = $t08071080882._2
1903+ let fundingPayment = $t08071080882._3
17591904 throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)))
17601905 }
17611906 else throw("Strict value is not equal to itself.")
17621907 }
17631908
17641909
17651910
17661911 @Callable(i)
17671912 func view_getPegAdjustCost (_price) = {
17681913 let result = getSyncTerminalPrice(_price)
17691914 throw(toString(result._3))
17701915 }
17711916
17721917
17731918
17741919 @Callable(i)
17751920 func view_getTerminalAmmPrice () = {
1776- let $t07574075821 = getTerminalAmmState()
1777- let terminalQuoteAssetReserve = $t07574075821._1
1778- let terminalBaseAssetReserve = $t07574075821._2
1921+ let $t08122981310 = getTerminalAmmState()
1922+ let terminalQuoteAssetReserve = $t08122981310._1
1923+ let terminalBaseAssetReserve = $t08122981310._2
17791924 let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
17801925 throw(toString(price))
17811926 }
17821927
17831928
17841929
17851930 @Callable(i)
17861931 func view_getFunding () = {
17871932 let underlyingPrice = getOracleTwapPrice()
1788- let $t07604076102 = getFunding()
1789- let shortPremiumFraction = $t07604076102._1
1790- let longPremiumFraction = $t07604076102._2
1933+ let $t08152981591 = getFunding()
1934+ let shortPremiumFraction = $t08152981591._1
1935+ let longPremiumFraction = $t08152981591._2
17911936 let longFunding = divd(longPremiumFraction, underlyingPrice)
17921937 let shortFunding = divd(shortPremiumFraction, underlyingPrice)
17931938 throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOracleTwapPrice())))
17941939 }
17951940
17961941
17971942
17981943 @Callable(i)
17991944 func view_getBorrowedByTrader (_trader) = {
1800- let $t07639276446 = getBorrowedByTrader(_trader)
1801- let borrowed = $t07639276446._1
1802- let assetId = $t07639276446._2
1945+ let $t08188181935 = getBorrowedByTrader(_trader)
1946+ let borrowed = $t08188181935._1
1947+ let assetId = $t08188181935._2
18031948 throw((s(borrowed) + assetId))
1949+ }
1950+
1951+
1952+
1953+@Callable(i)
1954+func computeSpotPrice () = {
1955+ let result = getSpotPrice()
1956+ $Tuple2(nil, result)
1957+ }
1958+
1959+
1960+
1961+@Callable(i)
1962+func computeFeeForTraderWithArtifact (_trader,_artifactId) = {
1963+ let result = getForTraderWithArtifact(_trader, _artifactId)
1964+ $Tuple2(nil, result)
18041965 }
18051966
18061967
18071968 @Verifier(tx)
18081969 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
18091970

github/deemru/w8io/169f3d6 
297.20 ms