tx · BB2Z4Az4uRK4EFCVCa9h2khTeDRJWNZVHqdqgFDnYgVv

3Mp3uUKsY4LnTo3j4N7dJAfqRfMJ6Rgr35Q:  -0.07500000 Waves

2023.04.17 19:50 [2538824] smart account 3Mp3uUKsY4LnTo3j4N7dJAfqRfMJ6Rgr35Q > SELF 0.00000000 Waves

{ "type": 13, "id": "BB2Z4Az4uRK4EFCVCa9h2khTeDRJWNZVHqdqgFDnYgVv", "fee": 7500000, "feeAssetId": null, "timestamp": 1681750253768, "version": 2, "chainId": 84, "sender": "3Mp3uUKsY4LnTo3j4N7dJAfqRfMJ6Rgr35Q", "senderPublicKey": "EiYReiiFX6CXEuz35wibBnvZ8LjJHZrgFwR73fomjgzy", "proofs": [ "PwGAaFumWe3kmZufKckU3oh6L7jLTstNVkGrWjiENPwEvUJemESMBpfta4f27y1ax5ZxVGYkS3v1aPSCoZBh4Kn" ], "script": "base64:BgKAAQgCEgASABIAEgASAwoBARIDCgEBEhAKDgEBAQEBAQEBAQEBAQEBEhUKEwEBAQEBAQEICAgBAQEBAQEBAQESBgoEAQEBCBIDCgEBEgQKAgEBEgYKBAEBAQQSBAoCCAESABIAEgASAwoBCBIECgIIARIDCgEBEgASABIAEgQKAggIrwEADGtfYmFzZU9yYWNsZQIMa19iYXNlT3JhY2xlAA1rX3F1b3RlT3JhY2xlAg1rX3F1b3RlT3JhY2xlAAlrX2JhbGFuY2UCCWtfYmFsYW5jZQAKa19zZXF1ZW5jZQIKa19zZXF1ZW5jZQAOa19wb3NpdGlvblNpemUCDmtfcG9zaXRpb25TaXplABBrX3Bvc2l0aW9uTWFyZ2luAhBrX3Bvc2l0aW9uTWFyZ2luABZrX3Bvc2l0aW9uT3Blbk5vdGlvbmFsAhZrX3Bvc2l0aW9uT3Blbk5vdGlvbmFsAC5rX3Bvc2l0aW9uTGFzdFVwZGF0ZWRDdW11bGF0aXZlUHJlbWl1bUZyYWN0aW9uAhJrX3Bvc2l0aW9uRnJhY3Rpb24AEmtfcG9za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lzRGVmaW5lZAEFDmNvb3JkaW5hdG9yU3RyBAVhZG1pbgkAnQgCCQERQGV4dHJOYXRpdmUoMTA2MikBCQEFdmFsdWUBBQ5jb29yZGluYXRvclN0cgUPa19hZG1pbl9hZGRyZXNzAwkBCWlzRGVmaW5lZAEFBWFkbWluCQELdmFsdWVPckVsc2UCCQCbCAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEJAQV2YWx1ZQEFBWFkbWluCQCsAgIJAKwCAgkArAICAgdzdGF0dXNfCQClCAEFBHRoaXMCAV8JANgEAQgFAnR4AmlkBwkAAgECLnVuYWJsZSB0byB2ZXJpZnk6IGFkbWluIG5vdCBzZXQgaW4gY29vcmRpbmF0b3IJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXmT5mUn", "height": 2538824, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 858z2JZZsF7GEpGKxhSwRxoJhjU3XzsbQmve6h1bZXd4 Next: EPCxh1RUM4iQk14ZNQ4Zu4JLWuqhrCp89N26M7ShosaL Diff:
OldNewDifferences
1818 let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction"
1919
2020 let k_positionSequence = "k_positionSequence"
21-
22-let k_positionAsset = "k_positionAsset"
2321
2422 let k_positionFee = "k_positionFee"
2523
5755
5856 let k_maxOracleDelay = "k_maxOracleDelay"
5957
60-let k_lastDataStr = "k_lastDataStr"
61-
62-let k_lastMinuteId = "k_lastMinuteId"
63-
64-let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice"
65-
66-let k_twapDataLastPrice = "k_twapDataLastPrice"
67-
68-let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId"
58+let k_fundingMode = "k_fundingMode"
6959
7060 let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction"
7161
10797
10898 let k_quote_asset = "k_quote_asset"
10999
110-let k_quote_staking = "k_quote_staking"
111-
112100 let k_staking_address = "k_staking_address"
113101
114102 let k_miner_address = "k_miner_address"
116104 let k_orders_address = "k_orders_address"
117105
118106 let k_referral_address = "k_referral_address"
119-
120-let k_exchange_address = "k_exchange_address"
121107
122108 let k_nft_manager_address = "k_nft_manager_address"
123109
131117
132118
133119 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
134-
135-
136-func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set")
137120
138121
139122 func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set")
164147
165148 let DIR_SHORT = 2
166149
167-let TWAP_INTERVAL = 15
168-
169150 let SECONDS = 1000
170151
171152 let DECIMAL_NUMBERS = 6
179160 let PNL_OPTION_SPOT = 1
180161
181162 let PNL_OPTION_ORACLE = 2
163+
164+let FUNDING_ASYMMETRIC = 1
165+
166+let FUNDING_SYMMETRIC = 2
182167
183168 func s (_x) = (toString(_x) + ",")
184169
203188 func vmax (_x,_y) = if ((_x >= _y))
204189 then _x
205190 else _y
206-
207-
208-func listToStr (_list) = if ((size(_list) == 0))
209- then ""
210- else makeString(_list, ",")
211-
212-
213-func strToList (_str) = if ((_str == ""))
214- then nil
215- else split(_str, ",")
216-
217-
218-func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize))
219- then (removeByIndex(_list, 0) :+ _value)
220- else (_list :+ _value)
221191
222192
223193 func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
328298 func maxOracleDelay () = int(k_maxOracleDelay)
329299
330300
301+func fundingMode () = intOr(k_fundingMode, FUNDING_ASYMMETRIC)
302+
303+
331304 func lastTimestamp () = lastBlock.timestamp
332305
333306
355328 else latestShortCumulativePremiumFraction()
356329
357330
358-func getPosition (_trader) = {
359- let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader))
331+func getPosition (_trader,_direction) = {
332+ let positionKey = ((_trader + "_") + toString(_direction))
333+ let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, positionKey))
360334 match positionSizeOpt {
361335 case positionSize: Int =>
362- $Tuple5(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedTimestamp, _trader)))
336+ $Tuple5(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, positionKey)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, positionKey)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedTimestamp, positionKey)))
363337 case _ =>
364338 $Tuple5(0, 0, 0, 0, 0)
365339 }
366340 }
367341
368342
369-func getPositionAsset (_trader) = {
370- let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader))
371- match positionAssetOpt {
372- case positionAsset: String =>
373- positionAsset
374- case _ =>
375- toBase58String(quoteAsset())
376- }
377- }
343+func getDirection (_positionSize) = if ((0 > _positionSize))
344+ then DIR_SHORT
345+ else DIR_LONG
378346
379347
380-func getPositionFee (_trader) = {
381- let positionFeeOpt = getInteger(this, toCompositeKey(k_positionFee, _trader))
348+func getPositionFee (_trader,_direction) = {
349+ let positionKey = ((_trader + "_") + toString(_direction))
350+ let positionFeeOpt = getInteger(this, toCompositeKey(k_positionFee, positionKey))
382351 match positionFeeOpt {
383352 case positionFee: Int =>
384353 positionFee
388357 }
389358
390359
391-func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0))
360+func requireOpenPosition (_trader,_direction) = if ((getPosition(_trader, _direction)._1 == 0))
392361 then throw("No open position")
393362 else true
394363
456425 let amountBaseAssetBought = if (_isAdd)
457426 then amountBaseAssetBoughtAbs
458427 else -(amountBaseAssetBoughtAbs)
459- let $t01672216892 = updateReserve(_isAdd, quoteAssetAmountAdjusted, amountBaseAssetBoughtAbs)
460- let quoteAssetReserveAfter1 = $t01672216892._1
461- let baseAssetReserveAfter1 = $t01672216892._2
462- let totalPositionSizeAfter1 = $t01672216892._3
428+ let $t01558415754 = updateReserve(_isAdd, quoteAssetAmountAdjusted, amountBaseAssetBoughtAbs)
429+ let quoteAssetReserveAfter1 = $t01558415754._1
430+ let baseAssetReserveAfter1 = $t01558415754._2
431+ let totalPositionSizeAfter1 = $t01558415754._3
463432 let priceBefore = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
464433 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
465434 let priceDiff = abs((priceBefore - marketPrice))
487456 else 0
488457 let rolloverFee = calcRolloverFee(_oldPositionMargin, _oldPositionLastUpdatedTimestamp)
489458 let signedMargin = (((_marginDelta - rolloverFee) - fundingPayment) + _oldPositionMargin)
490- let $t01914719274 = if ((0 > signedMargin))
459+ let $t01842118548 = if ((0 > signedMargin))
491460 then $Tuple2(0, abs(signedMargin))
492461 else $Tuple2(abs(signedMargin), 0)
493- let remainMargin = $t01914719274._1
494- let badDebt = $t01914719274._2
462+ let remainMargin = $t01842118548._1
463+ let badDebt = $t01842118548._2
495464 $Tuple4(remainMargin, badDebt, fundingPayment, rolloverFee)
496465 }
497466
509478 let quoteAssetDelta = abs((quoteAssetAfter - _quoteAssetReserve))
510479 let quoteAssetSold = muld(quoteAssetDelta, _quoteAssetWeight)
511480 let maxPriceImpactValue = maxPriceImpact()
512- let $t02053620698 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount)
513- let quoteAssetReserveAfter1 = $t02053620698._1
514- let baseAssetReserveAfter1 = $t02053620698._2
515- let totalPositionSizeAfter1 = $t02053620698._3
481+ let $t01981019972 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount)
482+ let quoteAssetReserveAfter1 = $t01981019972._1
483+ let baseAssetReserveAfter1 = $t01981019972._2
484+ let totalPositionSizeAfter1 = $t01981019972._3
516485 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
517486 let priceDiff = abs((priceBefore - marketPrice))
518487 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
646615 }
647616
648617
649-func getPositionNotionalAndUnrealizedPnl (_trader,_option) = {
650- let $t02857628704 = getPosition(_trader)
651- let positionSize = $t02857628704._1
652- let positionMargin = $t02857628704._2
653- let positionOpenNotional = $t02857628704._3
654- let positionLstUpdCPF = $t02857628704._4
618+func getPositionNotionalAndUnrealizedPnl (_trader,_direction,_option) = {
619+ let $t02786728007 = getPosition(_trader, _direction)
620+ let positionSize = $t02786728007._1
621+ let positionMargin = $t02786728007._2
622+ let positionOpenNotional = $t02786728007._3
623+ let positionLstUpdCPF = $t02786728007._4
655624 getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), qtAstW(), bsAstR(), bsAstW(), _option)
656625 }
657626
659628 func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional)
660629
661630
662-func getMarginRatioByOption (_trader,_option) = {
663- let $t02921929360 = getPosition(_trader)
664- let positionSize = $t02921929360._1
665- let positionMargin = $t02921929360._2
666- let pon = $t02921929360._3
667- let positionLastUpdatedCPF = $t02921929360._4
668- let positionTimestamp = $t02921929360._5
669- let $t02936629459 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
670- let positionNotional = $t02936629459._1
671- let unrealizedPnl = $t02936629459._2
672- let $t02946429676 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLastUpdatedCPF, positionTimestamp, unrealizedPnl)
673- let remainMargin = $t02946429676._1
674- let badDebt = $t02946429676._2
631+func getMarginRatioByOption (_trader,_direction,_option) = {
632+ let $t02853928692 = getPosition(_trader, _direction)
633+ let positionSize = $t02853928692._1
634+ let positionMargin = $t02853928692._2
635+ let pon = $t02853928692._3
636+ let positionLastUpdatedCPF = $t02853928692._4
637+ let positionTimestamp = $t02853928692._5
638+ let $t02869828803 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, _option)
639+ let positionNotional = $t02869828803._1
640+ let unrealizedPnl = $t02869828803._2
641+ let $t02880829020 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLastUpdatedCPF, positionTimestamp, unrealizedPnl)
642+ let remainMargin = $t02880829020._1
643+ let badDebt = $t02880829020._2
675644 calcMarginRatio(remainMargin, badDebt, positionNotional)
676645 }
677646
678647
679-func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
648+func getMarginRatio (_trader,_direction) = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT)
680649
681650
682651 func getPartialLiquidationAmount (_trader,_positionSize) = {
683- let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio())))
652+ let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader, getDirection(_positionSize)), maintenanceMarginRatio())))
684653 let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio)
685654 let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false)
686655 let maxExchangedQuoteAssetAmount = swapResult._1
691660 }
692661
693662
694-func internalClosePosition (_trader,_size,_fee,_minQuoteAssetAmount,_addToMargin,_checkMaxPriceImpact,_liquidate) = {
695- let $t03074330899 = getPosition(_trader)
696- let oldPositionSize = $t03074330899._1
697- let oldPositionMargin = $t03074330899._2
698- let oldPositionOpenNotional = $t03074330899._3
699- let oldPositionLstUpdCPF = $t03074330899._4
700- let oldPositionTimestamp = $t03074330899._5
663+func internalClosePosition (_trader,_direction,_size,_fee,_minQuoteAssetAmount,_addToMargin,_checkMaxPriceImpact,_liquidate) = {
664+ let $t03018330351 = getPosition(_trader, _direction)
665+ let oldPositionSize = $t03018330351._1
666+ let oldPositionMargin = $t03018330351._2
667+ let oldPositionOpenNotional = $t03018330351._3
668+ let oldPositionLstUpdCPF = $t03018330351._4
669+ let oldPositionTimestamp = $t03018330351._5
701670 let isLongPosition = (oldPositionSize > 0)
702671 let absOldPositionSize = abs(oldPositionSize)
703672 if (if ((absOldPositionSize >= _size))
705674 else false)
706675 then {
707676 let isPartialClose = (absOldPositionSize > _size)
708- let $t03119131642 = swapOutput((oldPositionSize > 0), _size, _checkMaxPriceImpact)
709- let exchangedQuoteAssetAmount = $t03119131642._1
710- let quoteAssetReserveAfter = $t03119131642._2
711- let baseAssetReserveAfter = $t03119131642._3
712- let totalPositionSizeAfter = $t03119131642._4
677+ let $t03064331094 = swapOutput((oldPositionSize > 0), _size, _checkMaxPriceImpact)
678+ let exchangedQuoteAssetAmount = $t03064331094._1
679+ let quoteAssetReserveAfter = $t03064331094._2
680+ let baseAssetReserveAfter = $t03064331094._3
681+ let totalPositionSizeAfter = $t03064331094._4
713682 let exchangedPositionSize = if ((oldPositionSize > 0))
714683 then -(_size)
715684 else _size
716- let $t03185732064 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
717- let oldPositionNotional = $t03185732064._1
718- let unrealizedPnl = $t03185732064._2
685+ let $t03130931533 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, PNL_OPTION_SPOT)
686+ let oldPositionNotional = $t03130931533._1
687+ let unrealizedPnl = $t03130931533._2
719688 let realizedRatio = divd(abs(exchangedPositionSize), absOldPositionSize)
720689 let realizedPnl = muld(unrealizedPnl, realizedRatio)
721- let $t03240532651 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, unrealizedPnl)
722- let remainMarginBefore = $t03240532651._1
723- let x1 = $t03240532651._2
724- let x2 = $t03240532651._3
725- let rolloverFee = $t03240532651._4
690+ let $t03187432120 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, unrealizedPnl)
691+ let remainMarginBefore = $t03187432120._1
692+ let x1 = $t03187432120._2
693+ let x2 = $t03187432120._3
694+ let rolloverFee = $t03187432120._4
726695 let positionBadDebt = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, realizedPnl)._2
727696 let realizedCloseFee = muld(muld(oldPositionNotional, realizedRatio), _fee)
728697 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
730699 then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
731700 else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
732701 let newPositionSize = (oldPositionSize + exchangedPositionSize)
733- let $t03405734443 = if ((newPositionSize == 0))
702+ let $t03352633912 = if ((newPositionSize == 0))
734703 then $Tuple2(0, 0)
735704 else $Tuple2(abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize))
736- let newPositionOpenNotional = $t03405734443._1
737- let newPositionLstUpdCPF = $t03405734443._2
705+ let newPositionOpenNotional = $t03352633912._1
706+ let newPositionLstUpdCPF = $t03352633912._2
738707 let openNotionalDelta = (oldPositionOpenNotional - newPositionOpenNotional)
739- let marginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
708+ let marginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT)
740709 let newPositionMarginWithSameRatio = if ((oldPositionSize > 0))
741710 then (muld((newPositionOpenNotional + unrealizedPnlAfter), marginRatio) - unrealizedPnlAfter)
742711 else (muld((newPositionOpenNotional - unrealizedPnlAfter), marginRatio) - unrealizedPnlAfter)
771740 }
772741
773742
774-func getTwapSpotPrice () = {
775- let minuteId = ((lastTimestamp() / 1000) / 60)
776- let startMinuteId = (minuteId - TWAP_INTERVAL)
777- let listStr = valueOrElse(getString(this, k_lastDataStr), "")
778- let list = split(listStr, ",")
779- func filterFn (accumulator,next) = if ((startMinuteId >= valueOrErrorMessage(parseInt(next), ("getTwapSpotPrice: invalid int: " + listStr))))
780- then (accumulator :+ parseIntValue(next))
781- else accumulator
782-
783- let listF = {
784- let $l = list
785- let $s = size($l)
786- let $acc0 = nil
787- func $f0_1 ($a,$i) = if (($i >= $s))
788- then $a
789- else filterFn($a, $l[$i])
790-
791- func $f0_2 ($a,$i) = if (($i >= $s))
792- then $a
793- else throw("List size exceeds 20")
794-
795- $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)
796- }
797- let maxIndex = if ((size(listF) > 0))
798- then max(listF)
799- else valueOrErrorMessage(parseInt(list[0]), ("getTwapSpotPrice: invalid int: " + listStr))
800- let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
801- let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0)
802- let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0)
803- let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice))
804- let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0)
805- let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0)
806- let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice))
807- ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL)
808- }
809-
810-
811743 func getTerminalAmmState () = {
812744 let _positionSize = totalPositionSize()
813745 if ((_positionSize == 0))
814746 then $Tuple2(qtAstR(), bsAstR())
815747 else {
816748 let direction = (_positionSize > 0)
817- let $t03918039359 = swapOutput(direction, abs(_positionSize), false)
818- let currentNetMarketValue = $t03918039359._1
819- let terminalQuoteAssetReserve = $t03918039359._2
820- let terminalBaseAssetReserve = $t03918039359._3
749+ let $t03715937338 = swapOutput(direction, abs(_positionSize), false)
750+ let currentNetMarketValue = $t03715937338._1
751+ let terminalQuoteAssetReserve = $t03715937338._2
752+ let terminalBaseAssetReserve = $t03715937338._3
821753 $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve)
822754 }
823755 }
857789
858790 func getFunding () = {
859791 let underlyingPrice = getOraclePrice()
860- let spotTwapPrice = getTwapSpotPrice()
861- let premium = (spotTwapPrice - underlyingPrice)
792+ let spotPrice = getSpotPrice()
793+ let premium = (spotPrice - underlyingPrice)
862794 if (if (if ((totalShortPositionSize() == 0))
863795 then true
864796 else (totalLongPositionSize() == 0))
865797 then true
866798 else isMarketClosed())
867- then $Tuple2(0, 0)
799+ then $Tuple3(0, 0, 0)
868800 else if ((0 > premium))
869801 then {
870802 let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
871- let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize())
872- $Tuple2(shortPremiumFraction, longPremiumFraction)
803+ if ((fundingMode() == FUNDING_ASYMMETRIC))
804+ then {
805+ let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize())
806+ $Tuple3(shortPremiumFraction, longPremiumFraction, 0)
807+ }
808+ else {
809+ let shortTotalPremiumFraction = abs(muld(shortPremiumFraction, totalShortPositionSize()))
810+ let longTotalPremiumFraction = abs(muld(shortPremiumFraction, totalLongPositionSize()))
811+ let premiumToVault = (shortTotalPremiumFraction - longTotalPremiumFraction)
812+ $Tuple3(shortPremiumFraction, shortPremiumFraction, premiumToVault)
813+ }
873814 }
874815 else {
875816 let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
876- let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize())
877- $Tuple2(shortPremiumFraction, longPremiumFraction)
817+ if ((fundingMode() == FUNDING_ASYMMETRIC))
818+ then {
819+ let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize())
820+ $Tuple3(shortPremiumFraction, longPremiumFraction, 0)
821+ }
822+ else {
823+ let longTotalPremiumFraction = abs(muld(longPremiumFraction, totalLongPositionSize()))
824+ let shortTotalPremiumFraction = abs(muld(longPremiumFraction, totalShortPositionSize()))
825+ let premiumToVault = (longTotalPremiumFraction - shortTotalPremiumFraction)
826+ $Tuple3(longPremiumFraction, longPremiumFraction, premiumToVault)
827+ }
878828 }
879829 }
880830
882832 func getAdjustedFee (_artifactId,_baseFeeDiscount) = {
883833 let baseFeeRaw = fee()
884834 let baseFee = muld(baseFeeRaw, _baseFeeDiscount)
885- let $t04222042715 = if ((_artifactId != ""))
835+ let $t04191342408 = if ((_artifactId != ""))
886836 then {
887837 let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, _artifactId))
888838 if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE))
894844 else throw("Invalid attached artifact")
895845 }
896846 else $Tuple2(baseFee, false)
897- let adjustedFee = $t04222042715._1
898- let burnArtifact = $t04222042715._2
847+ let adjustedFee = $t04191342408._1
848+ let burnArtifact = $t04191342408._2
899849 $Tuple2(adjustedFee, burnArtifact)
900850 }
901-
902-
903-func isSameAssetOrNoPosition (_trader,_assetId) = {
904- let oldPositionSize = getPosition(_trader)._1
905- if ((oldPositionSize == 0))
906- then true
907- else (getPositionAsset(_trader) == _assetId)
908- }
909-
910-
911-func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId)
912851
913852
914853 func getForTraderWithArtifact (_trader,_artifactId) = {
921860 case _ =>
922861 throw("Invalid computeFeeDiscount result")
923862 }
924- let $t04339543469 = getAdjustedFee(_artifactId, feeDiscount)
925- let adjustedFee = $t04339543469._1
926- let burnArtifact = $t04339543469._2
863+ let $t04275442828 = getAdjustedFee(_artifactId, feeDiscount)
864+ let adjustedFee = $t04275442828._1
865+ let burnArtifact = $t04275442828._2
927866 $Tuple2(adjustedFee, burnArtifact)
928867 }
929868 else throw("Strict value is not equal to itself.")
945884 }
946885
947886
948-func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional), IntegerEntry(k_feeToStakersPercent, _feeToStakersPercent), IntegerEntry(k_maxOracleDelay, _feeToStakersPercent), IntegerEntry(k_rolloverFee, _rolloverFee)]
887+func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional), IntegerEntry(k_feeToStakersPercent, _feeToStakersPercent), IntegerEntry(k_maxOracleDelay, _feeToStakersPercent), IntegerEntry(k_rolloverFee, _rolloverFee), IntegerEntry(k_fundingMode, _fundingMode)]
949888
950889
951890 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)]
952891
953892
954-func incrementPositionSequenceNumber (_isNewPosition,_address) = if (_isNewPosition)
955- then {
956- let currentSequence = lastSequence()
957-[IntegerEntry(toCompositeKey(k_positionSequence, _address), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))]
958- }
959- else nil
893+func incrementPositionSequenceNumber (_isNewPosition,_trader,_direction) = {
894+ let positionKey = ((_trader + "_") + toString(_direction))
895+ if (_isNewPosition)
896+ then {
897+ let currentSequence = lastSequence()
898+[IntegerEntry(toCompositeKey(k_positionSequence, positionKey), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))]
899+ }
900+ else nil
901+ }
960902
961903
962-func updatePositionFee (_isNewPosition,_address,_fee) = if (_isNewPosition)
963- then [IntegerEntry(toCompositeKey(k_positionFee, _address), _fee)]
964- else nil
904+func updatePositionFee (_isNewPosition,_trader,_direction,_fee) = {
905+ let positionKey = ((_trader + "_") + toString(_direction))
906+ if (_isNewPosition)
907+ then [IntegerEntry(toCompositeKey(k_positionFee, positionKey), _fee)]
908+ else nil
909+ }
965910
966911
967-func updatePosition (_address,_size,_margin,_openNotional,_latestCumulativePremiumFraction,_latestTimestamp) = [IntegerEntry(toCompositeKey(k_positionSize, _address), _size), IntegerEntry(toCompositeKey(k_positionMargin, _address), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, _address), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address), _latestCumulativePremiumFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _address), _latestTimestamp)]
968-
969-
970-func appendTwap (_price) = {
971- let minuteId = ((lastTimestamp() / 1000) / 60)
972- let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
973- if ((previousMinuteId > minuteId))
974- then throw("TWAP out-of-order")
975- else {
976- let lastMinuteId = if ((previousMinuteId == 0))
977- then minuteId
978- else previousMinuteId
979- if ((minuteId > previousMinuteId))
980- then {
981- let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0)
982- let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), _price)
983- let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice))
984- let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId))
985-[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))]
986- }
987- else {
988- let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0)
989- let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0)
990- let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), _price)
991- let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice))
992-[IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), _price)]
993- }
994- }
912+func updatePosition (_trader,_size,_margin,_openNotional,_latestCumulativePremiumFraction,_latestTimestamp) = {
913+ let direction = getDirection(_size)
914+ let positionKey = ((_trader + "_") + toString(direction))
915+[IntegerEntry(toCompositeKey(k_positionSize, positionKey), _size), IntegerEntry(toCompositeKey(k_positionMargin, positionKey), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, positionKey), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey), _latestCumulativePremiumFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey), _latestTimestamp)]
995916 }
996917
997918
1006927 let _bsAstW = bsAstW()
1007928 if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter))
1008929 then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter)))
1009- 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))))
930+ 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)])
1010931 }
1011932
1012933
1013-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)), DeleteEntry(toCompositeKey(k_positionFee, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _address))]
934+func deletePosition (_trader,_direction) = {
935+ let positionKey = ((_trader + "_") + toString(_direction))
936+[DeleteEntry(toCompositeKey(k_positionSize, positionKey)), DeleteEntry(toCompositeKey(k_positionMargin, positionKey)), DeleteEntry(toCompositeKey(k_positionOpenNotional, positionKey)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey)), DeleteEntry(toCompositeKey(k_positionFee, positionKey)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey))]
937+ }
1014938
1015939
1016940 func withdraw (_address,_amount) = {
10761000 let qtAstRAfter = (_qtAstR + _quoteAssetAmount)
10771001 let baseAssetAmountToAdd = (divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR)
10781002 let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd)
1079- let $t05287653027 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
1080- let newQuoteAssetWeight = $t05287653027._1
1081- let newBaseAssetWeight = $t05287653027._2
1082- let marginToVault = $t05287653027._3
1003+ let $t05108351234 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
1004+ let newQuoteAssetWeight = $t05108351234._1
1005+ let newBaseAssetWeight = $t05108351234._2
1006+ let marginToVault = $t05108351234._3
10831007 let doExchangePnL = if ((marginToVault != 0))
10841008 then {
10851009 let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil)
11091033 let qtAstRAfter = (_qtAstR - _quoteAssetAmount)
11101034 let baseAssetAmountToRemove = abs((divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR))
11111035 let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove)
1112- let $t05395954110 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
1113- let newQuoteAssetWeight = $t05395954110._1
1114- let newBaseAssetWeight = $t05395954110._2
1115- let marginToVault = $t05395954110._3
1036+ let $t05233052481 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
1037+ let newQuoteAssetWeight = $t05233052481._1
1038+ let newBaseAssetWeight = $t05233052481._2
1039+ let marginToVault = $t05233052481._3
11161040 let doExchangePnL = if ((marginToVault != 0))
11171041 then {
11181042 let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil)
11291053
11301054
11311055 @Callable(i)
1132-func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = if ((i.caller != adminAddress()))
1056+func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _fundingPeriod))
1057+ then true
1058+ else (0 >= _initMarginRatio))
1059+ then true
1060+ else (0 >= _mmr))
1061+ then true
1062+ else (0 >= _liquidationFeeRatio))
1063+ then true
1064+ else (0 >= _fee))
1065+ then true
1066+ else (0 >= _spreadLimit))
1067+ then true
1068+ else (0 >= _maxPriceImpact))
1069+ then true
1070+ else (0 >= _partialLiquidationRatio))
1071+ then true
1072+ else (0 >= _maxPriceSpread))
1073+ then true
1074+ else (0 >= _maxOpenNotional))
1075+ then true
1076+ else (0 >= _feeToStakersPercent))
1077+ then true
1078+ else (_feeToStakersPercent > DECIMAL_UNIT))
1079+ then true
1080+ else (0 >= _maxOracleDelay))
1081+ then true
1082+ else (0 >= _rolloverFee))
1083+ then true
1084+ else if ((_fundingMode != FUNDING_SYMMETRIC))
1085+ then (_fundingMode != FUNDING_ASYMMETRIC)
1086+ else false)
1087+ then true
1088+ else !(initialized()))
1089+ then true
1090+ else (i.caller != adminAddress()))
11331091 then throw("Invalid changeSettings params")
1134- else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee)
1092+ else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee, _fundingMode)
11351093
11361094
11371095
11381096 @Callable(i)
1139-func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_baseOracleData,_quoteOracleData,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
1097+func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_baseOracleData,_quoteOracleData,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
11401098 then true
11411099 else (0 >= _bsAstR))
11421100 then true
11681126 then true
11691127 else (0 >= _rolloverFee))
11701128 then true
1129+ else if ((_fundingMode != FUNDING_SYMMETRIC))
1130+ then (_fundingMode != FUNDING_ASYMMETRIC)
1131+ else false)
1132+ then true
11711133 else initialized())
11721134 then true
11731135 else (i.caller != this))
11741136 then throw("Invalid initialize parameters")
1175- else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee)) ++ updateFunding((lastTimestamp() + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_quoteOracle, _quoteOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))])
1137+ else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee, _fundingMode)) ++ updateFunding((lastTimestamp() + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_quoteOracle, _quoteOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))])
11761138
11771139
11781140
11891151 let _assetId = i.payments[0].assetId
11901152 let _assetIdStr = toBase58String(value(_assetId))
11911153 let isQuoteAsset = (_assetId == quoteAsset())
1192- if (if (if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
1154+ if (if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
11931155 then (_direction != DIR_SHORT)
11941156 else false)
11951157 then true
11981160 else !(initialized()))
11991161 then true
12001162 else !(isQuoteAsset))
1201- then true
1202- else !(isSameAssetOrNoPosition(_trader, _assetIdStr)))
12031163 then true
12041164 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
12051165 then true
12101170 else isMarketClosed())
12111171 then throw("Invalid increasePosition parameters")
12121172 else {
1213- let $t05788858037 = getForTraderWithArtifact(_trader, getArtifactId(i))
1214- let adjustedFee = $t05788858037._1
1215- let burnArtifact = $t05788858037._2
1173+ let $t05855158700 = getForTraderWithArtifact(_trader, getArtifactId(i))
1174+ let adjustedFee = $t05855158700._1
1175+ let burnArtifact = $t05855158700._2
12161176 let _amount = divd(_rawAmount, (muld(adjustedFee, _leverage) + DECIMAL_UNIT))
12171177 let distributeFeeAmount = (_rawAmount - _amount)
12181178 let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
12251185 throw("Invalid referrerFee")
12261186 }
12271187 let feeAmount = (distributeFeeAmount - referrerFee)
1228- let $t05853358701 = getPosition(_trader)
1229- let oldPositionSize = $t05853358701._1
1230- let oldPositionMargin = $t05853358701._2
1231- let oldPositionOpenNotional = $t05853358701._3
1232- let oldPositionLstUpdCPF = $t05853358701._4
1233- let oldPositionTimestamp = $t05853358701._5
1188+ let $t05919659376 = getPosition(_trader, _direction)
1189+ let oldPositionSize = $t05919659376._1
1190+ let oldPositionMargin = $t05919659376._2
1191+ let oldPositionOpenNotional = $t05919659376._3
1192+ let oldPositionLstUpdCPF = $t05919659376._4
1193+ let oldPositionTimestamp = $t05919659376._5
12341194 let isNewPosition = (oldPositionSize == 0)
12351195 let isSameDirection = if ((oldPositionSize > 0))
12361196 then (_direction == DIR_LONG)
12391199 then isSameDirection
12401200 else false
12411201 let isAdd = (_direction == DIR_LONG)
1242- let $t05899062111 = if (if (isNewPosition)
1202+ let $t05966562798 = if (if (isNewPosition)
12431203 then true
12441204 else expandExisting)
12451205 then {
12461206 let openNotional = muld(_amount, _leverage)
1247- let $t05949959672 = swapInput(isAdd, openNotional)
1248- let amountBaseAssetBought = $t05949959672._1
1249- let quoteAssetReserveAfter = $t05949959672._2
1250- let baseAssetReserveAfter = $t05949959672._3
1251- let totalPositionSizeAfter = $t05949959672._4
1207+ let $t06017460347 = swapInput(isAdd, openNotional)
1208+ let amountBaseAssetBought = $t06017460347._1
1209+ let quoteAssetReserveAfter = $t06017460347._2
1210+ let baseAssetReserveAfter = $t06017460347._3
1211+ let totalPositionSizeAfter = $t06017460347._4
12521212 if (if ((_minBaseAssetAmount != 0))
12531213 then (_minBaseAssetAmount > abs(amountBaseAssetBought))
12541214 else false)
12611221 let totalShortOpenInterestAfter = (openInterestShort() + (if ((0 > newPositionSize))
12621222 then openNotional
12631223 else 0))
1264- let $t06021860493 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, _amount)
1265- let remainMargin = $t06021860493._1
1266- let x1 = $t06021860493._2
1267- let x2 = $t06021860493._3
1268- let rolloverFee = $t06021860493._4
1224+ let $t06089361168 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, _amount)
1225+ let remainMargin = $t06089361168._1
1226+ let x1 = $t06089361168._2
1227+ let x2 = $t06089361168._3
1228+ let rolloverFee = $t06089361168._4
12691229 if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
12701230 then throw("Over max spread limit")
12711231 else if (!(requireNotOverMaxOpenNotional(totalLongOpenInterestAfter, totalShortOpenInterestAfter)))
12791239 }
12801240 else {
12811241 let openNotional = muld(_amount, _leverage)
1282- let $t06181161927 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1283- let oldPositionNotional = $t06181161927._1
1284- let unrealizedPnl = $t06181161927._2
1242+ let $t06248662614 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), _direction, PNL_OPTION_SPOT)
1243+ let oldPositionNotional = $t06248662614._1
1244+ let unrealizedPnl = $t06248662614._2
12851245 if ((oldPositionNotional > openNotional))
12861246 then throw("Use decreasePosition to decrease position size")
12871247 else throw("Close position first")
12881248 }
1289- let newPositionSize = $t05899062111._1
1290- let newPositionRemainMargin = $t05899062111._2
1291- let newPositionOpenNotional = $t05899062111._3
1292- let newPositionLatestCPF = $t05899062111._4
1293- let newPositionTimestamp = $t05899062111._5
1294- let baseAssetReserveAfter = $t05899062111._6
1295- let quoteAssetReserveAfter = $t05899062111._7
1296- let totalPositionSizeAfter = $t05899062111._8
1297- let openInterestNotionalAfter = $t05899062111._9
1298- let totalLongAfter = $t05899062111._10
1299- let totalShortAfter = $t05899062111._11
1300- let totalLongOpenInterestAfter = $t05899062111._12
1301- let totalShortOpenInterestAfter = $t05899062111._13
1302- let rolloverFee = $t05899062111._14
1303- let $t06211762188 = distributeFee((feeAmount + rolloverFee))
1304- let feeToStakers = $t06211762188._1
1305- let feeToVault = $t06211762188._2
1249+ let newPositionSize = $t05966562798._1
1250+ let newPositionRemainMargin = $t05966562798._2
1251+ let newPositionOpenNotional = $t05966562798._3
1252+ let newPositionLatestCPF = $t05966562798._4
1253+ let newPositionTimestamp = $t05966562798._5
1254+ let baseAssetReserveAfter = $t05966562798._6
1255+ let quoteAssetReserveAfter = $t05966562798._7
1256+ let totalPositionSizeAfter = $t05966562798._8
1257+ let openInterestNotionalAfter = $t05966562798._9
1258+ let totalLongAfter = $t05966562798._10
1259+ let totalShortAfter = $t05966562798._11
1260+ let totalLongOpenInterestAfter = $t05966562798._12
1261+ let totalShortOpenInterestAfter = $t05966562798._13
1262+ let rolloverFee = $t05966562798._14
1263+ let $t06280462875 = distributeFee((feeAmount + rolloverFee))
1264+ let feeToStakers = $t06280462875._1
1265+ let feeToVault = $t06280462875._2
13061266 let stake = if ((_amount >= rolloverFee))
13071267 then invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), (_amount - rolloverFee))])
13081268 else invoke(vaultAddress(), "withdrawLocked", [(rolloverFee - _amount)], nil)
13161276 then {
13171277 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
13181278 if ((notifyNotional == notifyNotional))
1319- then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF, newPositionTimestamp) ++ incrementPositionSequenceNumber(isNewPosition, _trader)) ++ updatePositionFee(isNewPosition, _trader, adjustedFee)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doBurnArtifact(burnArtifact, i))
1279+ then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF, newPositionTimestamp) ++ incrementPositionSequenceNumber(isNewPosition, _trader, _direction)) ++ updatePositionFee(isNewPosition, _trader, _direction, adjustedFee)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doBurnArtifact(burnArtifact, i))
13201280 else throw("Strict value is not equal to itself.")
13211281 }
13221282 else throw("Strict value is not equal to itself.")
13361296
13371297
13381298 @Callable(i)
1339-func addMargin () = {
1299+func addMargin (_direction) = {
13401300 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
13411301 if ((sync == sync))
13421302 then {
13481308 let _assetId = i.payments[0].assetId
13491309 let _assetIdStr = toBase58String(value(_assetId))
13501310 let isQuoteAsset = (_assetId == quoteAsset())
1351- if (if (if (if (if (if (if (!(isQuoteAsset))
1311+ if (if (if (if (if (!(isQuoteAsset))
13521312 then true
1353- else !(requireOpenPosition(toString(i.caller))))
1354- then true
1355- else !(isSameAsset(_trader, _assetIdStr)))
1313+ else !(requireOpenPosition(toString(i.caller), _direction)))
13561314 then true
13571315 else !(initialized()))
13581316 then true
13591317 else paused())
13601318 then true
1361- else closeOnly())
1362- then true
13631319 else isMarketClosed())
13641320 then throw("Invalid addMargin parameters")
13651321 else {
1366- let $t06429964467 = getPosition(_trader)
1367- let oldPositionSize = $t06429964467._1
1368- let oldPositionMargin = $t06429964467._2
1369- let oldPositionOpenNotional = $t06429964467._3
1370- let oldPositionLstUpdCPF = $t06429964467._4
1371- let oldPositionTimestamp = $t06429964467._5
1322+ let $t06512265302 = getPosition(_trader, _direction)
1323+ let oldPositionSize = $t06512265302._1
1324+ let oldPositionMargin = $t06512265302._2
1325+ let oldPositionOpenNotional = $t06512265302._3
1326+ let oldPositionLstUpdCPF = $t06512265302._4
1327+ let oldPositionTimestamp = $t06512265302._5
13721328 let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
13731329 if ((stake == stake))
13741330 then {
13751331 let rolloverFee = calcRolloverFee(oldPositionMargin, oldPositionTimestamp)
13761332 let doTransferFeeToStakers = if ((rolloverFee > 0))
13771333 then {
1378- let $t06475264811 = distributeFee(rolloverFee)
1379- let feeToStakers = $t06475264811._1
1380- let feeToVault = $t06475264811._2
1334+ let $t06558765646 = distributeFee(rolloverFee)
1335+ let feeToStakers = $t06558765646._1
1336+ let feeToVault = $t06558765646._2
13811337 let unstake = invoke(vaultAddress(), "withdrawLocked", [feeToStakers], nil)
13821338 if ((unstake == unstake))
13831339 then {
14041360
14051361
14061362 @Callable(i)
1407-func removeMargin (_amount) = {
1363+func removeMargin (_amount,_direction) = {
14081364 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
14091365 if ((sync == sync))
14101366 then {
14141370 let _trader = toString(i.caller)
14151371 if (if (if (if (if ((0 >= _amount))
14161372 then true
1417- else !(requireOpenPosition(_trader)))
1373+ else !(requireOpenPosition(_trader, _direction)))
14181374 then true
14191375 else !(initialized()))
14201376 then true
14231379 else isMarketClosed())
14241380 then throw("Invalid removeMargin parameters")
14251381 else {
1426- let $t06592366091 = getPosition(_trader)
1427- let oldPositionSize = $t06592366091._1
1428- let oldPositionMargin = $t06592366091._2
1429- let oldPositionOpenNotional = $t06592366091._3
1430- let oldPositionLstUpdCPF = $t06592366091._4
1431- let oldPositionTimestamp = $t06592366091._5
1432- let $t06609766346 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, -(_amount))
1433- let remainMargin = $t06609766346._1
1434- let badDebt = $t06609766346._2
1435- let fundingPayment = $t06609766346._3
1436- let rolloverFee = $t06609766346._4
1382+ let $t06705067230 = getPosition(_trader, _direction)
1383+ let oldPositionSize = $t06705067230._1
1384+ let oldPositionMargin = $t06705067230._2
1385+ let oldPositionOpenNotional = $t06705067230._3
1386+ let oldPositionLstUpdCPF = $t06705067230._4
1387+ let oldPositionTimestamp = $t06705067230._5
1388+ let $t06723667485 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, -(_amount))
1389+ let remainMargin = $t06723667485._1
1390+ let badDebt = $t06723667485._2
1391+ let fundingPayment = $t06723667485._3
1392+ let rolloverFee = $t06723667485._4
14371393 if ((badDebt != 0))
14381394 then throw("Invalid removed margin amount")
14391395 else {
14411397 if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true)))
14421398 then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
14431399 else {
1444- let $t06673266791 = distributeFee(rolloverFee)
1445- let feeToStakers = $t06673266791._1
1446- let feeToVault = $t06673266791._2
1400+ let $t06787167930 = distributeFee(rolloverFee)
1401+ let feeToStakers = $t06787167930._1
1402+ let feeToVault = $t06787167930._2
14471403 let doTransferFeeToStakers = if ((rolloverFee > 0))
14481404 then {
14491405 let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(feeToVault)], nil)
14721428
14731429
14741430 @Callable(i)
1475-func closePosition (_size,_minQuoteAssetAmount,_addToMargin) = {
1431+func closePosition (_size,_direction,_minQuoteAssetAmount,_addToMargin) = {
14761432 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
14771433 if ((sync == sync))
14781434 then {
14811437 then {
14821438 let _trader = getActualCaller(i)
14831439 let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller")
1484- let positionFee = getPositionFee(_trader)
1485- if (if (if (if (if (if (!(requireOpenPosition(_trader)))
1440+ let positionFee = getPositionFee(_trader, _direction)
1441+ if (if (if (if (if (if (!(requireOpenPosition(_trader, _direction)))
14861442 then true
14871443 else !(initialized()))
14881444 then true
14951451 else isMarketClosed())
14961452 then throw("Invalid closePosition parameters")
14971453 else {
1498- let oldPositionTimestamp = getPosition(_trader)._5
1499- let $t06844869033 = internalClosePosition(_trader, _size, positionFee, _minQuoteAssetAmount, _addToMargin, true, true)
1500- let newPositionSize = $t06844869033._1
1501- let newPositionMargin = $t06844869033._2
1502- let newPositionOpenNotional = $t06844869033._3
1503- let newPositionLstUpdCPF = $t06844869033._4
1504- let positionBadDebt = $t06844869033._5
1505- let realizedPnl = $t06844869033._6
1506- let marginToTrader = $t06844869033._7
1507- let quoteAssetReserveAfter = $t06844869033._8
1508- let baseAssetReserveAfter = $t06844869033._9
1509- let totalPositionSizeAfter = $t06844869033._10
1510- let openInterestNotionalAfter = $t06844869033._11
1511- let totalLongAfter = $t06844869033._12
1512- let totalShortAfter = $t06844869033._13
1513- let totalLongOpenInterestAfter = $t06844869033._14
1514- let totalShortOpenInterestAfter = $t06844869033._15
1515- let realizedFee = $t06844869033._16
1454+ let oldPositionTimestamp = getPosition(_trader, _direction)._5
1455+ let $t07015870761 = internalClosePosition(_trader, _direction, _size, positionFee, _minQuoteAssetAmount, _addToMargin, true, true)
1456+ let newPositionSize = $t07015870761._1
1457+ let newPositionMargin = $t07015870761._2
1458+ let newPositionOpenNotional = $t07015870761._3
1459+ let newPositionLstUpdCPF = $t07015870761._4
1460+ let positionBadDebt = $t07015870761._5
1461+ let realizedPnl = $t07015870761._6
1462+ let marginToTrader = $t07015870761._7
1463+ let quoteAssetReserveAfter = $t07015870761._8
1464+ let baseAssetReserveAfter = $t07015870761._9
1465+ let totalPositionSizeAfter = $t07015870761._10
1466+ let openInterestNotionalAfter = $t07015870761._11
1467+ let totalLongAfter = $t07015870761._12
1468+ let totalShortAfter = $t07015870761._13
1469+ let totalLongOpenInterestAfter = $t07015870761._14
1470+ let totalShortOpenInterestAfter = $t07015870761._15
1471+ let realizedFee = $t07015870761._16
15161472 if ((positionBadDebt > 0))
15171473 then throw("Invalid closePosition parameters: bad debt")
15181474 else if ((oldPositionTimestamp >= lastTimestamp()))
15271483 let unstake = invoke(vaultAddress(), "withdrawLocked", [withdrawAmount], nil)
15281484 if ((unstake == unstake))
15291485 then {
1530- let $t06970569764 = distributeFee(realizedFee)
1531- let feeToStakers = $t06970569764._1
1532- let feeToVault = $t06970569764._2
1533- let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)])
1534- if ((depositVault == depositVault))
1486+ let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), realizedFee)])
1487+ if ((referrerFeeAny == referrerFeeAny))
15351488 then {
1536- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, realizedFee], nil)
1537- if ((notifyFee == notifyFee))
1489+ let referrerFee = match referrerFeeAny {
1490+ case x: Int =>
1491+ x
1492+ case _ =>
1493+ throw("Invalid referrerFee")
1494+ }
1495+ let $t07173371806 = distributeFee((realizedFee - referrerFee))
1496+ let feeToStakers = $t07173371806._1
1497+ let feeToVault = $t07173371806._2
1498+ let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)])
1499+ if ((depositVault == depositVault))
15381500 then {
1539- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1540- if ((notifyNotional == notifyNotional))
1541- then (((((if (isPartialClose)
1542- then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp())
1543- else deletePosition(_trader)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((marginToTrader > 0))
1544- then withdraw(_traderAddress, marginToTrader)
1545- else nil)) ++ updateBalance(ammNewBalance)) ++ transferFee(feeToStakers))
1501+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, realizedFee], nil)
1502+ if ((notifyFee == notifyFee))
1503+ then {
1504+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1505+ if ((notifyNotional == notifyNotional))
1506+ then (((((if (isPartialClose)
1507+ then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp())
1508+ else deletePosition(_trader, _direction)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((marginToTrader > 0))
1509+ then withdraw(_traderAddress, marginToTrader)
1510+ else nil)) ++ updateBalance(ammNewBalance)) ++ transferFee(feeToStakers))
1511+ else throw("Strict value is not equal to itself.")
1512+ }
15461513 else throw("Strict value is not equal to itself.")
15471514 }
15481515 else throw("Strict value is not equal to itself.")
15611528
15621529
15631530 @Callable(i)
1564-func liquidate (_trader) = {
1531+func liquidate (_trader,_direction) = {
15651532 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
15661533 if ((sync == sync))
15671534 then {
1568- let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
1535+ let spotMarginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT)
15691536 let liquidationMarginRatio = if (isOverFluctuationLimit())
15701537 then {
1571- let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE)
1538+ let oracleMarginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_ORACLE)
15721539 vmax(spotMarginRatio, oracleMarginRatio)
15731540 }
15741541 else spotMarginRatio
15751542 if (if (if (if (if (!(requireMoreMarginRatio(liquidationMarginRatio, maintenanceMarginRatio(), false)))
15761543 then true
1577- else !(requireOpenPosition(_trader)))
1544+ else !(requireOpenPosition(_trader, _direction)))
15781545 then true
15791546 else !(initialized()))
15801547 then true
15881555 else false)
15891556 then (DECIMAL_UNIT > partialLiquidationRatio())
15901557 else false
1591- let oldPositionSize = getPosition(_trader)._1
1558+ let oldPositionSize = getPosition(_trader, _direction)._1
15921559 let positionSizeAbs = abs(oldPositionSize)
1593- let $t07207772400 = if (isPartialLiquidation)
1560+ let $t07430474627 = if (isPartialLiquidation)
15941561 then {
15951562 let liquidationSize = getPartialLiquidationAmount(_trader, oldPositionSize)
15961563 let liquidationRatio = divd(abs(liquidationSize), positionSizeAbs)
15971564 $Tuple2(liquidationRatio, abs(liquidationSize))
15981565 }
15991566 else $Tuple2(0, positionSizeAbs)
1600- let liquidationRatio = $t07207772400._1
1601- let liquidationSize = $t07207772400._2
1602- let $t07240673044 = internalClosePosition(_trader, if (isPartialLiquidation)
1567+ let liquidationRatio = $t07430474627._1
1568+ let liquidationSize = $t07430474627._2
1569+ let $t07463375289 = internalClosePosition(_trader, _direction, if (isPartialLiquidation)
16031570 then liquidationSize
16041571 else positionSizeAbs, liquidationFeeRatio(), 0, true, false, true)
1605- let newPositionSize = $t07240673044._1
1606- let newPositionMargin = $t07240673044._2
1607- let newPositionOpenNotional = $t07240673044._3
1608- let newPositionLstUpdCPF = $t07240673044._4
1609- let positionBadDebt = $t07240673044._5
1610- let realizedPnl = $t07240673044._6
1611- let marginToTrader = $t07240673044._7
1612- let quoteAssetReserveAfter = $t07240673044._8
1613- let baseAssetReserveAfter = $t07240673044._9
1614- let totalPositionSizeAfter = $t07240673044._10
1615- let openInterestNotionalAfter = $t07240673044._11
1616- let totalLongAfter = $t07240673044._12
1617- let totalShortAfter = $t07240673044._13
1618- let totalLongOpenInterestAfter = $t07240673044._14
1619- let totalShortOpenInterestAfter = $t07240673044._15
1620- let liquidationPenalty = $t07240673044._16
1572+ let newPositionSize = $t07463375289._1
1573+ let newPositionMargin = $t07463375289._2
1574+ let newPositionOpenNotional = $t07463375289._3
1575+ let newPositionLstUpdCPF = $t07463375289._4
1576+ let positionBadDebt = $t07463375289._5
1577+ let realizedPnl = $t07463375289._6
1578+ let marginToTrader = $t07463375289._7
1579+ let quoteAssetReserveAfter = $t07463375289._8
1580+ let baseAssetReserveAfter = $t07463375289._9
1581+ let totalPositionSizeAfter = $t07463375289._10
1582+ let openInterestNotionalAfter = $t07463375289._11
1583+ let totalLongAfter = $t07463375289._12
1584+ let totalShortAfter = $t07463375289._13
1585+ let totalLongOpenInterestAfter = $t07463375289._14
1586+ let totalShortOpenInterestAfter = $t07463375289._15
1587+ let liquidationPenalty = $t07463375289._16
16211588 let feeToLiquidator = (liquidationPenalty / 2)
16221589 let feeToVault = (liquidationPenalty - feeToLiquidator)
16231590 let ammBalance = (cbalance() - liquidationPenalty)
16441611 if ((notifyNotional == notifyNotional))
16451612 then ((((if (isPartialLiquidation)
16461613 then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp())
1647- else deletePosition(_trader)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1614+ else deletePosition(_trader, _direction)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
16481615 else throw("Strict value is not equal to itself.")
16491616 }
16501617 else throw("Strict value is not equal to itself.")
16731640 then throw(((("Invalid funding block timestamp: " + toString(lastTimestamp())) + " < ") + toString(fundingBlockTimestamp)))
16741641 else {
16751642 let underlyingPrice = getOraclePrice()
1676- let $t07503175093 = getFunding()
1677- let shortPremiumFraction = $t07503175093._1
1678- let longPremiumFraction = $t07503175093._2
1679- updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
1643+ let $t07741477492 = getFunding()
1644+ let shortPremiumFraction = $t07741477492._1
1645+ let longPremiumFraction = $t07741477492._2
1646+ let premiumToVault = $t07741477492._3
1647+ let doPayFundingToVault = if ((premiumToVault > 0))
1648+ then {
1649+ let doPayFundingToVault = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(premiumToVault)], nil)
1650+ if ((doPayFundingToVault == doPayFundingToVault))
1651+ then nil
1652+ else throw("Strict value is not equal to itself.")
1653+ }
1654+ else nil
1655+ if ((doPayFundingToVault == doPayFundingToVault))
1656+ then updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
1657+ else throw("Strict value is not equal to itself.")
16801658 }
16811659 }
16821660 else throw("Strict value is not equal to itself.")
16881666 func syncTerminalPriceToOracle () = {
16891667 let _qtAstR = qtAstR()
16901668 let _bsAstR = bsAstR()
1691- let $t07552575891 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR)
1692- let newQuoteAssetWeight = $t07552575891._1
1693- let newBaseAssetWeight = $t07552575891._2
1694- let marginToVault = $t07552575891._3
1669+ let $t07854578911 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR)
1670+ let newQuoteAssetWeight = $t07854578911._1
1671+ let newBaseAssetWeight = $t07854578911._2
1672+ let marginToVault = $t07854578911._3
16951673 let marginToVaultAdj = if (if ((0 > marginToVault))
16961674 then (abs(marginToVault) > cbalance())
16971675 else false)
17061684 }
17071685 else nil
17081686 if ((doExchangePnL == doExchangePnL))
1709- then ((updateBalance((cbalance() + marginToVaultAdj)) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)) ++ appendTwap(divd(muld(_qtAstR, newQuoteAssetWeight), muld(_bsAstR, newBaseAssetWeight))))
1687+ then (updateBalance((cbalance() + marginToVaultAdj)) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight))
17101688 else throw("Strict value is not equal to itself.")
17111689 }
17121690
17161694 func ensureCalledOnce () = if ((i.caller != this))
17171695 then throw("Invalid saveCurrentTxId parameters")
17181696 else {
1697+ let txId = toBase58String(i.transactionId)
17191698 let lastTx = valueOrElse(getString(this, k_lastTx), "")
1720- if ((lastTx != toBase58String(i.transactionId)))
1721- then [StringEntry(k_lastTx, lastTx)]
1699+ if ((lastTx != txId))
1700+ then [StringEntry(k_lastTx, txId)]
17221701 else throw("Can not call vAMM methods twice in one tx")
17231702 }
17241703
17251704
17261705
17271706 @Callable(i)
1728-func view_calcRemainMarginWithFundingPayment (_trader) = {
1707+func migratePosition (_trader) = {
1708+ let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader))
1709+ if (if (isDefined(positionSizeOpt))
1710+ then isDefined(addressFromString(_trader))
1711+ else false)
1712+ then {
1713+ let pSize = getIntegerValue(this, toCompositeKey(k_positionSize, _trader))
1714+ let pMargin = getIntegerValue(this, toCompositeKey(k_positionMargin, _trader))
1715+ let pNotional = getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader))
1716+ let pFraction = getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader))
1717+ let pTimestamp = valueOrElse(getInteger(this, toCompositeKey(k_positionLastUpdatedTimestamp, _trader)), lastBlock.timestamp)
1718+ let pFee = valueOrElse(getInteger(this, toCompositeKey(k_positionFee, _trader)), fee())
1719+ let pSequence = getIntegerValue(this, toCompositeKey(k_positionSequence, _trader))
1720+ let pDirection = getDirection(pSize)
1721+ let positionKey = ((_trader + "_") + toString(pDirection))
1722+[DeleteEntry(toCompositeKey(k_positionSize, _trader)), DeleteEntry(toCompositeKey(k_positionMargin, _trader)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _trader)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _trader)), DeleteEntry(toCompositeKey(k_positionFee, _trader)), DeleteEntry(toCompositeKey(k_positionSequence, _trader)), IntegerEntry(toCompositeKey(k_positionSize, positionKey), pSize), IntegerEntry(toCompositeKey(k_positionMargin, positionKey), pMargin), IntegerEntry(toCompositeKey(k_positionOpenNotional, positionKey), pNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey), pFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey), pTimestamp), IntegerEntry(toCompositeKey(k_positionFee, positionKey), pFee), IntegerEntry(toCompositeKey(k_positionSequence, positionKey), pSequence)]
1723+ }
1724+ else throw(("Nothing to migrate for " + _trader))
1725+ }
1726+
1727+
1728+
1729+@Callable(i)
1730+func view_calcRemainMarginWithFundingPayment (_trader,_direction) = {
17291731 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
17301732 if ((sync == sync))
17311733 then {
1732- let $t07705077174 = getPosition(_trader)
1733- let positionSize = $t07705077174._1
1734- let positionMargin = $t07705077174._2
1735- let pon = $t07705077174._3
1736- let positionLstUpdCPF = $t07705077174._4
1737- let positionTimestamp = $t07705077174._5
1738- let $t07717777278 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1739- let positionNotional = $t07717777278._1
1740- let unrealizedPnl = $t07717777278._2
1741- let $t07728177505 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLstUpdCPF, positionTimestamp, unrealizedPnl)
1742- let remainMargin = $t07728177505._1
1743- let badDebt = $t07728177505._2
1744- let fundingPayment = $t07728177505._3
1745- let rolloverFee = $t07728177505._4
1746- throw(((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)) + s(rolloverFee)))
1734+ let $t08260282738 = getPosition(_trader, _direction)
1735+ let positionSize = $t08260282738._1
1736+ let positionMargin = $t08260282738._2
1737+ let pon = $t08260282738._3
1738+ let positionLstUpdCPF = $t08260282738._4
1739+ let positionTimestamp = $t08260282738._5
1740+ let $t08274182854 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, PNL_OPTION_SPOT)
1741+ let positionNotional = $t08274182854._1
1742+ let unrealizedPnl = $t08274182854._2
1743+ let $t08285783081 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLstUpdCPF, positionTimestamp, unrealizedPnl)
1744+ let remainMargin = $t08285783081._1
1745+ let badDebt = $t08285783081._2
1746+ let fundingPayment = $t08285783081._3
1747+ let rolloverFee = $t08285783081._4
1748+ throw(((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader, _direction))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)) + s(rolloverFee)))
17471749 }
17481750 else throw("Strict value is not equal to itself.")
17491751 }
17621764
17631765 @Callable(i)
17641766 func view_getTerminalAmmPrice () = {
1765- let $t07794178022 = getTerminalAmmState()
1766- let terminalQuoteAssetReserve = $t07794178022._1
1767- let terminalBaseAssetReserve = $t07794178022._2
1767+ let $t08381683897 = getTerminalAmmState()
1768+ let terminalQuoteAssetReserve = $t08381683897._1
1769+ let terminalBaseAssetReserve = $t08381683897._2
17681770 let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
17691771 throw(toString(price))
17701772 }
17731775
17741776 @Callable(i)
17751777 func view_getFunding () = {
1776- let underlyingPrice = getOraclePrice()
1777- let $t07823778299 = getFunding()
1778- let shortPremiumFraction = $t07823778299._1
1779- let longPremiumFraction = $t07823778299._2
1780- let longFunding = divd(longPremiumFraction, underlyingPrice)
1781- let shortFunding = divd(shortPremiumFraction, underlyingPrice)
1782- throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOraclePrice())))
1778+ let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
1779+ if ((sync == sync))
1780+ then {
1781+ let underlyingPrice = getOraclePrice()
1782+ let $t08445684534 = getFunding()
1783+ let shortPremiumFraction = $t08445684534._1
1784+ let longPremiumFraction = $t08445684534._2
1785+ let premiumToVault = $t08445684534._3
1786+ let longFunding = divd(longPremiumFraction, underlyingPrice)
1787+ let shortFunding = divd(shortPremiumFraction, underlyingPrice)
1788+ throw(((((s(longFunding) + s(shortFunding)) + s(getSpotPrice())) + s(getOraclePrice())) + s(premiumToVault)))
1789+ }
1790+ else throw("Strict value is not equal to itself.")
17831791 }
17841792
17851793
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_baseOracle = "k_baseOracle"
55
66 let k_quoteOracle = "k_quoteOracle"
77
88 let k_balance = "k_balance"
99
1010 let k_sequence = "k_sequence"
1111
1212 let k_positionSize = "k_positionSize"
1313
1414 let k_positionMargin = "k_positionMargin"
1515
1616 let k_positionOpenNotional = "k_positionOpenNotional"
1717
1818 let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction"
1919
2020 let k_positionSequence = "k_positionSequence"
21-
22-let k_positionAsset = "k_positionAsset"
2321
2422 let k_positionFee = "k_positionFee"
2523
2624 let k_positionLastUpdatedTimestamp = "k_positionTimestamp"
2725
2826 let k_initialized = "k_initialized"
2927
3028 let k_paused = "k_paused"
3129
3230 let k_closeOnly = "k_closeOnly"
3331
3432 let k_fee = "k_fee"
3533
3634 let k_rolloverFee = "k_rollover_fee"
3735
3836 let k_fundingPeriod = "k_fundingPeriod"
3937
4038 let k_initMarginRatio = "k_initMarginRatio"
4139
4240 let k_maintenanceMarginRatio = "k_mmr"
4341
4442 let k_liquidationFeeRatio = "k_liquidationFeeRatio"
4543
4644 let k_partialLiquidationRatio = "k_partLiquidationRatio"
4745
4846 let k_spreadLimit = "k_spreadLimit"
4947
5048 let k_maxPriceImpact = "k_maxPriceImpact"
5149
5250 let k_maxPriceSpread = "k_maxPriceSpread"
5351
5452 let k_maxOpenNotional = "k_maxOpenNotional"
5553
5654 let k_feeToStakersPercent = "k_feeToStakersPercent"
5755
5856 let k_maxOracleDelay = "k_maxOracleDelay"
5957
60-let k_lastDataStr = "k_lastDataStr"
61-
62-let k_lastMinuteId = "k_lastMinuteId"
63-
64-let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice"
65-
66-let k_twapDataLastPrice = "k_twapDataLastPrice"
67-
68-let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId"
58+let k_fundingMode = "k_fundingMode"
6959
7060 let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction"
7161
7262 let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction"
7363
7464 let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp"
7565
7666 let k_longFundingRate = "k_longFundingRate"
7767
7868 let k_shortFundingRate = "k_shortFundingRate"
7969
8070 let k_quoteAssetReserve = "k_qtAstR"
8171
8272 let k_baseAssetReserve = "k_bsAstR"
8373
8474 let k_quoteAssetWeight = "k_qtAstW"
8575
8676 let k_baseAssetWeight = "k_bsAstW"
8777
8878 let k_totalPositionSize = "k_totalPositionSize"
8979
9080 let k_totalLongPositionSize = "k_totalLongPositionSize"
9181
9282 let k_totalShortPositionSize = "k_totalShortPositionSize"
9383
9484 let k_openInterestNotional = "k_openInterestNotional"
9585
9686 let k_openInterestShort = "k_openInterestShort"
9787
9888 let k_openInterestLong = "k_openInterestLong"
9989
10090 let k_lastTx = "k_lastTx"
10191
10292 let k_coordinatorAddress = "k_coordinatorAddress"
10393
10494 let k_vault_address = "k_vault_address"
10595
10696 let k_admin_address = "k_admin_address"
10797
10898 let k_quote_asset = "k_quote_asset"
10999
110-let k_quote_staking = "k_quote_staking"
111-
112100 let k_staking_address = "k_staking_address"
113101
114102 let k_miner_address = "k_miner_address"
115103
116104 let k_orders_address = "k_orders_address"
117105
118106 let k_referral_address = "k_referral_address"
119-
120-let k_exchange_address = "k_exchange_address"
121107
122108 let k_nft_manager_address = "k_nft_manager_address"
123109
124110 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
125111
126112
127113 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
128114
129115
130116 func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
131117
132118
133119 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
134-
135-
136-func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set")
137120
138121
139122 func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set")
140123
141124
142125 func vaultAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_vault_address)), "Vault not set")
143126
144127
145128 func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Miner not set")
146129
147130
148131 func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set")
149132
150133
151134 func referralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_referral_address)), "Referral not set")
152135
153136
154137 func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set")
155138
156139
157140 let k_token_param = "k_token_param"
158141
159142 let k_token_type = "k_token_type"
160143
161144 let FEE_REDUCTION_TOKEN_TYPE = "fee_reduction"
162145
163146 let DIR_LONG = 1
164147
165148 let DIR_SHORT = 2
166149
167-let TWAP_INTERVAL = 15
168-
169150 let SECONDS = 1000
170151
171152 let DECIMAL_NUMBERS = 6
172153
173154 let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10))
174155
175156 let MINUTES_IN_YEAR = (525600 * DECIMAL_UNIT)
176157
177158 let ONE_DAY = (86400 * DECIMAL_UNIT)
178159
179160 let PNL_OPTION_SPOT = 1
180161
181162 let PNL_OPTION_ORACLE = 2
163+
164+let FUNDING_ASYMMETRIC = 1
165+
166+let FUNDING_SYMMETRIC = 2
182167
183168 func s (_x) = (toString(_x) + ",")
184169
185170
186171 func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
187172
188173
189174 func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
190175
191176
192177 func bdivd (_x,_y) = fraction(_x, toBigInt(DECIMAL_UNIT), _y, HALFEVEN)
193178
194179
195180 func bmuld (_x,_y) = fraction(_x, _y, toBigInt(DECIMAL_UNIT), HALFEVEN)
196181
197182
198183 func abs (_x) = if ((_x > 0))
199184 then _x
200185 else -(_x)
201186
202187
203188 func vmax (_x,_y) = if ((_x >= _y))
204189 then _x
205190 else _y
206-
207-
208-func listToStr (_list) = if ((size(_list) == 0))
209- then ""
210- else makeString(_list, ",")
211-
212-
213-func strToList (_str) = if ((_str == ""))
214- then nil
215- else split(_str, ",")
216-
217-
218-func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize))
219- then (removeByIndex(_list, 0) :+ _value)
220- else (_list :+ _value)
221191
222192
223193 func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
224194
225195
226196 func intOr (k,def) = valueOrElse(getInteger(this, k), def)
227197
228198
229199 func strA (_address,_key) = {
230200 let val = valueOrErrorMessage(getString(_address, _key), ("No value for key " + _key))
231201 val
232202 }
233203
234204
235205 func intA (_address,_key) = {
236206 let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key))
237207 val
238208 }
239209
240210
241211 func cbalance () = int(k_balance)
242212
243213
244214 func fee () = int(k_fee)
245215
246216
247217 func rolloverFeeRate () = int(k_rolloverFee)
248218
249219
250220 func initMarginRatio () = int(k_initMarginRatio)
251221
252222
253223 func qtAstR () = int(k_quoteAssetReserve)
254224
255225
256226 func bsAstR () = int(k_baseAssetReserve)
257227
258228
259229 func qtAstW () = intOr(k_quoteAssetWeight, DECIMAL_UNIT)
260230
261231
262232 func bsAstW () = intOr(k_baseAssetWeight, DECIMAL_UNIT)
263233
264234
265235 func totalPositionSize () = int(k_totalPositionSize)
266236
267237
268238 func openInterestNotional () = int(k_openInterestNotional)
269239
270240
271241 func openInterestShort () = int(k_openInterestShort)
272242
273243
274244 func openInterestLong () = int(k_openInterestLong)
275245
276246
277247 func nextFundingBlockTimestamp () = int(k_nextFundingBlock)
278248
279249
280250 func fundingPeriodRaw () = int(k_fundingPeriod)
281251
282252
283253 func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT)
284254
285255
286256 func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS)
287257
288258
289259 func maintenanceMarginRatio () = int(k_maintenanceMarginRatio)
290260
291261
292262 func liquidationFeeRatio () = int(k_liquidationFeeRatio)
293263
294264
295265 func partialLiquidationRatio () = int(k_partialLiquidationRatio)
296266
297267
298268 func spreadLimit () = int(k_spreadLimit)
299269
300270
301271 func maxPriceImpact () = int(k_maxPriceImpact)
302272
303273
304274 func maxPriceSpread () = int(k_maxPriceSpread)
305275
306276
307277 func maxOpenNotional () = int(k_maxOpenNotional)
308278
309279
310280 func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction)
311281
312282
313283 func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction)
314284
315285
316286 func totalShortPositionSize () = int(k_totalShortPositionSize)
317287
318288
319289 func totalLongPositionSize () = int(k_totalLongPositionSize)
320290
321291
322292 func lastSequence () = intOr(k_sequence, 0)
323293
324294
325295 func feeToStakersPercent () = int(k_feeToStakersPercent)
326296
327297
328298 func maxOracleDelay () = int(k_maxOracleDelay)
329299
330300
301+func fundingMode () = intOr(k_fundingMode, FUNDING_ASYMMETRIC)
302+
303+
331304 func lastTimestamp () = lastBlock.timestamp
332305
333306
334307 func getActualCaller (i) = valueOrElse(getString(ordersAddress(), "k_sender"), toString(i.caller))
335308
336309
337310 func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = {
338311 let remainingMarginRatio = (_marginRatio - _baseMarginRatio)
339312 if (if (_largerThanOrEqualTo)
340313 then (0 > remainingMarginRatio)
341314 else false)
342315 then throw(((("Invalid margin: " + toString(_marginRatio)) + " < ") + toString(_baseMarginRatio)))
343316 else if (if (!(_largerThanOrEqualTo))
344317 then (remainingMarginRatio >= 0)
345318 else false)
346319 then throw(((("Invalid margin: " + toString(_marginRatio)) + " > ") + toString(_baseMarginRatio)))
347320 else true
348321 }
349322
350323
351324 func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0))
352325 then throw("Should not be called with _positionSize == 0")
353326 else if ((_positionSize > 0))
354327 then latestLongCumulativePremiumFraction()
355328 else latestShortCumulativePremiumFraction()
356329
357330
358-func getPosition (_trader) = {
359- let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader))
331+func getPosition (_trader,_direction) = {
332+ let positionKey = ((_trader + "_") + toString(_direction))
333+ let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, positionKey))
360334 match positionSizeOpt {
361335 case positionSize: Int =>
362- $Tuple5(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedTimestamp, _trader)))
336+ $Tuple5(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, positionKey)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, positionKey)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedTimestamp, positionKey)))
363337 case _ =>
364338 $Tuple5(0, 0, 0, 0, 0)
365339 }
366340 }
367341
368342
369-func getPositionAsset (_trader) = {
370- let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader))
371- match positionAssetOpt {
372- case positionAsset: String =>
373- positionAsset
374- case _ =>
375- toBase58String(quoteAsset())
376- }
377- }
343+func getDirection (_positionSize) = if ((0 > _positionSize))
344+ then DIR_SHORT
345+ else DIR_LONG
378346
379347
380-func getPositionFee (_trader) = {
381- let positionFeeOpt = getInteger(this, toCompositeKey(k_positionFee, _trader))
348+func getPositionFee (_trader,_direction) = {
349+ let positionKey = ((_trader + "_") + toString(_direction))
350+ let positionFeeOpt = getInteger(this, toCompositeKey(k_positionFee, positionKey))
382351 match positionFeeOpt {
383352 case positionFee: Int =>
384353 positionFee
385354 case _ =>
386355 fee()
387356 }
388357 }
389358
390359
391-func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0))
360+func requireOpenPosition (_trader,_direction) = if ((getPosition(_trader, _direction)._1 == 0))
392361 then throw("No open position")
393362 else true
394363
395364
396365 func getOracleData (key) = {
397366 let oracleDataStr = getString(this, key)
398367 if (if (isDefined(oracleDataStr))
399368 then (value(oracleDataStr) != "")
400369 else false)
401370 then {
402371 let oracleData = split(value(oracleDataStr), ",")
403372 let oracleAddress = valueOrErrorMessage(addressFromString(oracleData[0]), ("Invalid oracle address in: " + value(oracleDataStr)))
404373 let priceKey = oracleData[1]
405374 let blockKey = oracleData[2]
406375 let openKey = oracleData[3]
407376 $Tuple4(oracleAddress, priceKey, blockKey, openKey)
408377 }
409378 else unit
410379 }
411380
412381
413382 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
414383
415384
416385 func paused () = valueOrElse(getBoolean(this, k_paused), false)
417386
418387
419388 func closeOnly () = valueOrElse(getBoolean(this, k_closeOnly), false)
420389
421390
422391 func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd)
423392 then {
424393 let newBase = (bsAstR() - _baseAssetAmount)
425394 if ((0 >= newBase))
426395 then throw("Tx lead to base asset reserve <= 0, revert")
427396 else $Tuple3((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount))
428397 }
429398 else {
430399 let newQuote = (qtAstR() - _quoteAssetAmount)
431400 if ((0 >= newQuote))
432401 then throw("Tx lead to base quote reserve <= 0, revert")
433402 else $Tuple3(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount))
434403 }
435404
436405
437406 func calcInvariant (_qtAstR,_bsAstR) = {
438407 let bqtAstR = toBigInt(_qtAstR)
439408 let bbsAstR = toBigInt(_bsAstR)
440409 bmuld(bqtAstR, bbsAstR)
441410 }
442411
443412
444413 func swapInput (_isAdd,_quoteAssetAmount) = {
445414 let _qtAstR = qtAstR()
446415 let _bsAstR = bsAstR()
447416 let _qtAstW = qtAstW()
448417 let _bsAstW = bsAstW()
449418 let quoteAssetAmountAdjusted = divd(_quoteAssetAmount, _qtAstW)
450419 let k = calcInvariant(_qtAstR, _bsAstR)
451420 let quoteAssetReserveAfter = if (_isAdd)
452421 then (_qtAstR + quoteAssetAmountAdjusted)
453422 else (_qtAstR - quoteAssetAmountAdjusted)
454423 let baseAssetReserveAfter = toInt(bdivd(k, toBigInt(quoteAssetReserveAfter)))
455424 let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR))
456425 let amountBaseAssetBought = if (_isAdd)
457426 then amountBaseAssetBoughtAbs
458427 else -(amountBaseAssetBoughtAbs)
459- let $t01672216892 = updateReserve(_isAdd, quoteAssetAmountAdjusted, amountBaseAssetBoughtAbs)
460- let quoteAssetReserveAfter1 = $t01672216892._1
461- let baseAssetReserveAfter1 = $t01672216892._2
462- let totalPositionSizeAfter1 = $t01672216892._3
428+ let $t01558415754 = updateReserve(_isAdd, quoteAssetAmountAdjusted, amountBaseAssetBoughtAbs)
429+ let quoteAssetReserveAfter1 = $t01558415754._1
430+ let baseAssetReserveAfter1 = $t01558415754._2
431+ let totalPositionSizeAfter1 = $t01558415754._3
463432 let priceBefore = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
464433 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
465434 let priceDiff = abs((priceBefore - marketPrice))
466435 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
467436 let maxPriceImpactValue = maxPriceImpact()
468437 if ((priceImpact > maxPriceImpactValue))
469438 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)))
470439 else $Tuple4(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1)
471440 }
472441
473442
474443 func calcRolloverFee (_oldPositionMargin,_oldPositionLastUpdatedTimestamp) = {
475444 let positionMinutes = ((((lastTimestamp() - _oldPositionLastUpdatedTimestamp) / 1000) / 60) * DECIMAL_UNIT)
476445 let rolloverFee = divd(muld(muld(_oldPositionMargin, positionMinutes), rolloverFeeRate()), MINUTES_IN_YEAR)
477446 rolloverFee
478447 }
479448
480449
481450 func calcRemainMarginWithFundingPaymentAndRolloverFee (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_oldPositionLastUpdatedTimestamp,_marginDelta) = {
482451 let fundingPayment = if ((_oldPositionSize != 0))
483452 then {
484453 let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize)
485454 muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize)
486455 }
487456 else 0
488457 let rolloverFee = calcRolloverFee(_oldPositionMargin, _oldPositionLastUpdatedTimestamp)
489458 let signedMargin = (((_marginDelta - rolloverFee) - fundingPayment) + _oldPositionMargin)
490- let $t01914719274 = if ((0 > signedMargin))
459+ let $t01842118548 = if ((0 > signedMargin))
491460 then $Tuple2(0, abs(signedMargin))
492461 else $Tuple2(abs(signedMargin), 0)
493- let remainMargin = $t01914719274._1
494- let badDebt = $t01914719274._2
462+ let remainMargin = $t01842118548._1
463+ let badDebt = $t01842118548._2
495464 $Tuple4(remainMargin, badDebt, fundingPayment, rolloverFee)
496465 }
497466
498467
499468 func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight) = {
500469 let priceBefore = divd(muld(_quoteAssetReserve, _quoteAssetWeight), muld(_baseAssetReserve, _baseAssetWeight))
501470 if ((_baseAssetAmount == 0))
502471 then throw("Invalid base asset amount")
503472 else {
504473 let k = calcInvariant(_quoteAssetReserve, _baseAssetReserve)
505474 let baseAssetPoolAmountAfter = if (_isAdd)
506475 then (_baseAssetReserve + _baseAssetAmount)
507476 else (_baseAssetReserve - _baseAssetAmount)
508477 let quoteAssetAfter = toInt(bdivd(k, toBigInt(baseAssetPoolAmountAfter)))
509478 let quoteAssetDelta = abs((quoteAssetAfter - _quoteAssetReserve))
510479 let quoteAssetSold = muld(quoteAssetDelta, _quoteAssetWeight)
511480 let maxPriceImpactValue = maxPriceImpact()
512- let $t02053620698 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount)
513- let quoteAssetReserveAfter1 = $t02053620698._1
514- let baseAssetReserveAfter1 = $t02053620698._2
515- let totalPositionSizeAfter1 = $t02053620698._3
481+ let $t01981019972 = updateReserve(!(_isAdd), quoteAssetDelta, _baseAssetAmount)
482+ let quoteAssetReserveAfter1 = $t01981019972._1
483+ let baseAssetReserveAfter1 = $t01981019972._2
484+ let totalPositionSizeAfter1 = $t01981019972._3
516485 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
517486 let priceDiff = abs((priceBefore - marketPrice))
518487 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
519488 if (if ((priceImpact > maxPriceImpactValue))
520489 then _checkMaxPriceImpact
521490 else false)
522491 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)))
523492 else $Tuple7(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, (totalLongPositionSize() - (if (_isAdd)
524493 then abs(_baseAssetAmount)
525494 else 0)), (totalShortPositionSize() - (if (!(_isAdd))
526495 then abs(_baseAssetAmount)
527496 else 0)), priceImpact)
528497 }
529498 }
530499
531500
532501 func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), qtAstW(), bsAstR(), bsAstW())
533502
534503
535504 func getOraclePriceValue (oracle,priceKey,blockKey) = {
536505 let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey))
537506 if ((blockKey != ""))
538507 then {
539508 let currentBlock = lastBlock.height
540509 let lastOracleBlock = valueOrErrorMessage(getInteger(oracle, blockKey), ((("Can not get oracle block. Oracle: " + toString(oracle)) + " key: ") + blockKey))
541510 if (((currentBlock - lastOracleBlock) > maxOracleDelay()))
542511 then throw(((("Oracle stale data. Last oracle block: " + toString(lastOracleBlock)) + " current block: ") + toString(currentBlock)))
543512 else lastValue
544513 }
545514 else lastValue
546515 }
547516
548517
549518 func getOraclePrice () = {
550519 let baseOracle = valueOrErrorMessage(getOracleData(k_baseOracle), "No base asset oracle data")
551520 let baseOraclePrice = getOraclePriceValue(baseOracle._1, baseOracle._2, baseOracle._3)
552521 let quoteOracle = getOracleData(k_quoteOracle)
553522 let quoteOraclePrice = if (isDefined(quoteOracle))
554523 then {
555524 let quoteOracleV = value(quoteOracle)
556525 getOraclePriceValue(quoteOracleV._1, quoteOracleV._2, quoteOracleV._3)
557526 }
558527 else DECIMAL_UNIT
559528 divd(baseOraclePrice, quoteOraclePrice)
560529 }
561530
562531
563532 func isMarketClosed () = {
564533 let baseOracle = valueOrErrorMessage(getOracleData(k_baseOracle), "No base asset oracle data")
565534 let oracle = baseOracle._1
566535 let openKey = baseOracle._4
567536 if ((openKey != ""))
568537 then {
569538 let isOpen = valueOrErrorMessage(getBoolean(oracle, openKey), ((("Can not get oracle is open/closed. Oracle: " + toString(oracle)) + " key: ") + openKey))
570539 !(isOpen)
571540 }
572541 else false
573542 }
574543
575544
576545 func absPriceDiff (_oraclePrice,_quoteAssetReserve,_baseAssetReserve,_qtAstW,_bsAstW) = {
577546 let priceAfter = divd(muld(_quoteAssetReserve, _qtAstW), muld(_baseAssetReserve, _bsAstW))
578547 let averagePrice = divd((_oraclePrice + priceAfter), (2 * DECIMAL_UNIT))
579548 let absPriceDiff = divd(abs((_oraclePrice - priceAfter)), averagePrice)
580549 absPriceDiff
581550 }
582551
583552
584553 func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = {
585554 let oraclePrice = getOraclePrice()
586555 let _qtAstW = qtAstW()
587556 let _bsAstW = bsAstW()
588557 let absPriceDiffBefore = absPriceDiff(oraclePrice, qtAstR(), bsAstR(), _qtAstW, _bsAstW)
589558 let absPriceDiffAfter = absPriceDiff(oraclePrice, _quoteAssetReserve, _baseAssetReserve, _qtAstW, _bsAstW)
590559 if (if ((absPriceDiffAfter > maxPriceSpread()))
591560 then (absPriceDiffAfter > absPriceDiffBefore)
592561 else false)
593562 then throw(((("Price spread " + toString(absPriceDiffAfter)) + " > max price spread ") + toString(maxPriceSpread())))
594563 else true
595564 }
596565
597566
598567 func requireNotOverMaxOpenNotional (_longOpenNotional,_shortOpenNotional) = {
599568 let _maxOpenNotional = maxOpenNotional()
600569 if ((_longOpenNotional > _maxOpenNotional))
601570 then throw(((("Long open notional " + toString(_longOpenNotional)) + " > max open notional ") + toString(_maxOpenNotional)))
602571 else if ((_shortOpenNotional > _maxOpenNotional))
603572 then throw(((("Short open notional " + toString(_shortOpenNotional)) + " > max open notional ") + toString(_maxOpenNotional)))
604573 else true
605574 }
606575
607576
608577 func getSpotPrice () = {
609578 let _quoteAssetReserve = qtAstR()
610579 let _baseAssetReserve = bsAstR()
611580 let _qtAstW = qtAstW()
612581 let _bsAstW = bsAstW()
613582 divd(muld(_quoteAssetReserve, _qtAstW), muld(_baseAssetReserve, _bsAstW))
614583 }
615584
616585
617586 func isOverFluctuationLimit () = {
618587 let oraclePrice = getOraclePrice()
619588 let currentPrice = getSpotPrice()
620589 (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit())
621590 }
622591
623592
624593 func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight) = {
625594 let positionSizeAbs = abs(_positionSize)
626595 let isShort = (0 > _positionSize)
627596 let positionNotional = if ((_option == PNL_OPTION_SPOT))
628597 then {
629598 let outPositionNotional = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)._1
630599 outPositionNotional
631600 }
632601 else muld(positionSizeAbs, getOraclePrice())
633602 positionNotional
634603 }
635604
636605
637606 func getPositionNotionalAndUnrealizedPnlByValues (_positionSize,_positionOpenNotional,_quoteAssetReserve,_quoteAssetWeight,_baseAssetReserve,_baseAssetWeight,_option) = if ((_positionSize == 0))
638607 then throw("Invalid position size")
639608 else {
640609 let isShort = (0 > _positionSize)
641610 let positionNotional = getPositionAdjustedOpenNotional(_positionSize, _option, _quoteAssetReserve, _quoteAssetWeight, _baseAssetReserve, _baseAssetWeight)
642611 let unrealizedPnl = if (isShort)
643612 then (_positionOpenNotional - positionNotional)
644613 else (positionNotional - _positionOpenNotional)
645614 $Tuple2(positionNotional, unrealizedPnl)
646615 }
647616
648617
649-func getPositionNotionalAndUnrealizedPnl (_trader,_option) = {
650- let $t02857628704 = getPosition(_trader)
651- let positionSize = $t02857628704._1
652- let positionMargin = $t02857628704._2
653- let positionOpenNotional = $t02857628704._3
654- let positionLstUpdCPF = $t02857628704._4
618+func getPositionNotionalAndUnrealizedPnl (_trader,_direction,_option) = {
619+ let $t02786728007 = getPosition(_trader, _direction)
620+ let positionSize = $t02786728007._1
621+ let positionMargin = $t02786728007._2
622+ let positionOpenNotional = $t02786728007._3
623+ let positionLstUpdCPF = $t02786728007._4
655624 getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), qtAstW(), bsAstR(), bsAstW(), _option)
656625 }
657626
658627
659628 func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional)
660629
661630
662-func getMarginRatioByOption (_trader,_option) = {
663- let $t02921929360 = getPosition(_trader)
664- let positionSize = $t02921929360._1
665- let positionMargin = $t02921929360._2
666- let pon = $t02921929360._3
667- let positionLastUpdatedCPF = $t02921929360._4
668- let positionTimestamp = $t02921929360._5
669- let $t02936629459 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
670- let positionNotional = $t02936629459._1
671- let unrealizedPnl = $t02936629459._2
672- let $t02946429676 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLastUpdatedCPF, positionTimestamp, unrealizedPnl)
673- let remainMargin = $t02946429676._1
674- let badDebt = $t02946429676._2
631+func getMarginRatioByOption (_trader,_direction,_option) = {
632+ let $t02853928692 = getPosition(_trader, _direction)
633+ let positionSize = $t02853928692._1
634+ let positionMargin = $t02853928692._2
635+ let pon = $t02853928692._3
636+ let positionLastUpdatedCPF = $t02853928692._4
637+ let positionTimestamp = $t02853928692._5
638+ let $t02869828803 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, _option)
639+ let positionNotional = $t02869828803._1
640+ let unrealizedPnl = $t02869828803._2
641+ let $t02880829020 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLastUpdatedCPF, positionTimestamp, unrealizedPnl)
642+ let remainMargin = $t02880829020._1
643+ let badDebt = $t02880829020._2
675644 calcMarginRatio(remainMargin, badDebt, positionNotional)
676645 }
677646
678647
679-func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
648+func getMarginRatio (_trader,_direction) = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT)
680649
681650
682651 func getPartialLiquidationAmount (_trader,_positionSize) = {
683- let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio())))
652+ let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader, getDirection(_positionSize)), maintenanceMarginRatio())))
684653 let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio)
685654 let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false)
686655 let maxExchangedQuoteAssetAmount = swapResult._1
687656 let priceImpact = swapResult._7
688657 if ((maxPriceImpact() > priceImpact))
689658 then maxExchangedPositionSize
690659 else muld(abs(_positionSize), partialLiquidationRatio())
691660 }
692661
693662
694-func internalClosePosition (_trader,_size,_fee,_minQuoteAssetAmount,_addToMargin,_checkMaxPriceImpact,_liquidate) = {
695- let $t03074330899 = getPosition(_trader)
696- let oldPositionSize = $t03074330899._1
697- let oldPositionMargin = $t03074330899._2
698- let oldPositionOpenNotional = $t03074330899._3
699- let oldPositionLstUpdCPF = $t03074330899._4
700- let oldPositionTimestamp = $t03074330899._5
663+func internalClosePosition (_trader,_direction,_size,_fee,_minQuoteAssetAmount,_addToMargin,_checkMaxPriceImpact,_liquidate) = {
664+ let $t03018330351 = getPosition(_trader, _direction)
665+ let oldPositionSize = $t03018330351._1
666+ let oldPositionMargin = $t03018330351._2
667+ let oldPositionOpenNotional = $t03018330351._3
668+ let oldPositionLstUpdCPF = $t03018330351._4
669+ let oldPositionTimestamp = $t03018330351._5
701670 let isLongPosition = (oldPositionSize > 0)
702671 let absOldPositionSize = abs(oldPositionSize)
703672 if (if ((absOldPositionSize >= _size))
704673 then (_size > 0)
705674 else false)
706675 then {
707676 let isPartialClose = (absOldPositionSize > _size)
708- let $t03119131642 = swapOutput((oldPositionSize > 0), _size, _checkMaxPriceImpact)
709- let exchangedQuoteAssetAmount = $t03119131642._1
710- let quoteAssetReserveAfter = $t03119131642._2
711- let baseAssetReserveAfter = $t03119131642._3
712- let totalPositionSizeAfter = $t03119131642._4
677+ let $t03064331094 = swapOutput((oldPositionSize > 0), _size, _checkMaxPriceImpact)
678+ let exchangedQuoteAssetAmount = $t03064331094._1
679+ let quoteAssetReserveAfter = $t03064331094._2
680+ let baseAssetReserveAfter = $t03064331094._3
681+ let totalPositionSizeAfter = $t03064331094._4
713682 let exchangedPositionSize = if ((oldPositionSize > 0))
714683 then -(_size)
715684 else _size
716- let $t03185732064 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
717- let oldPositionNotional = $t03185732064._1
718- let unrealizedPnl = $t03185732064._2
685+ let $t03130931533 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, PNL_OPTION_SPOT)
686+ let oldPositionNotional = $t03130931533._1
687+ let unrealizedPnl = $t03130931533._2
719688 let realizedRatio = divd(abs(exchangedPositionSize), absOldPositionSize)
720689 let realizedPnl = muld(unrealizedPnl, realizedRatio)
721- let $t03240532651 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, unrealizedPnl)
722- let remainMarginBefore = $t03240532651._1
723- let x1 = $t03240532651._2
724- let x2 = $t03240532651._3
725- let rolloverFee = $t03240532651._4
690+ let $t03187432120 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, unrealizedPnl)
691+ let remainMarginBefore = $t03187432120._1
692+ let x1 = $t03187432120._2
693+ let x2 = $t03187432120._3
694+ let rolloverFee = $t03187432120._4
726695 let positionBadDebt = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, realizedPnl)._2
727696 let realizedCloseFee = muld(muld(oldPositionNotional, realizedRatio), _fee)
728697 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
729698 let remainOpenNotional = if ((oldPositionSize > 0))
730699 then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
731700 else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
732701 let newPositionSize = (oldPositionSize + exchangedPositionSize)
733- let $t03405734443 = if ((newPositionSize == 0))
702+ let $t03352633912 = if ((newPositionSize == 0))
734703 then $Tuple2(0, 0)
735704 else $Tuple2(abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize))
736- let newPositionOpenNotional = $t03405734443._1
737- let newPositionLstUpdCPF = $t03405734443._2
705+ let newPositionOpenNotional = $t03352633912._1
706+ let newPositionLstUpdCPF = $t03352633912._2
738707 let openNotionalDelta = (oldPositionOpenNotional - newPositionOpenNotional)
739- let marginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
708+ let marginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT)
740709 let newPositionMarginWithSameRatio = if ((oldPositionSize > 0))
741710 then (muld((newPositionOpenNotional + unrealizedPnlAfter), marginRatio) - unrealizedPnlAfter)
742711 else (muld((newPositionOpenNotional - unrealizedPnlAfter), marginRatio) - unrealizedPnlAfter)
743712 let marginToTraderRaw = ((remainMarginBefore - (newPositionMarginWithSameRatio + unrealizedPnlAfter)) - realizedCloseFee)
744713 let marginToTrader = if ((0 > marginToTraderRaw))
745714 then if (_liquidate)
746715 then 0
747716 else throw("Invalid internalClosePosition params: unable to pay fee")
748717 else marginToTraderRaw
749718 let newPositionMargin = if (_addToMargin)
750719 then (newPositionMarginWithSameRatio + marginToTrader)
751720 else newPositionMarginWithSameRatio
752721 if (if ((_minQuoteAssetAmount != 0))
753722 then (_minQuoteAssetAmount > exchangedQuoteAssetAmount)
754723 else false)
755724 then throw(((("Limit error: " + toString(exchangedQuoteAssetAmount)) + " < ") + toString(_minQuoteAssetAmount)))
756725 else $Tuple17(newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, positionBadDebt, realizedPnl, if (if (_addToMargin)
757726 then isPartialClose
758727 else false)
759728 then 0
760729 else marginToTrader, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, (openInterestNotional() - openNotionalDelta), (totalLongPositionSize() - (if (isLongPosition)
761730 then abs(exchangedPositionSize)
762731 else 0)), (totalShortPositionSize() - (if (!(isLongPosition))
763732 then abs(exchangedPositionSize)
764733 else 0)), (openInterestLong() - (if (isLongPosition)
765734 then openNotionalDelta
766735 else 0)), (openInterestShort() - (if (!(isLongPosition))
767736 then openNotionalDelta
768737 else 0)), (realizedCloseFee + rolloverFee), exchangedQuoteAssetAmount)
769738 }
770739 else throw(((("Invalid internalClosePosition params: invalid position size: " + toString(_size)) + " max: ") + toString(absOldPositionSize)))
771740 }
772741
773742
774-func getTwapSpotPrice () = {
775- let minuteId = ((lastTimestamp() / 1000) / 60)
776- let startMinuteId = (minuteId - TWAP_INTERVAL)
777- let listStr = valueOrElse(getString(this, k_lastDataStr), "")
778- let list = split(listStr, ",")
779- func filterFn (accumulator,next) = if ((startMinuteId >= valueOrErrorMessage(parseInt(next), ("getTwapSpotPrice: invalid int: " + listStr))))
780- then (accumulator :+ parseIntValue(next))
781- else accumulator
782-
783- let listF = {
784- let $l = list
785- let $s = size($l)
786- let $acc0 = nil
787- func $f0_1 ($a,$i) = if (($i >= $s))
788- then $a
789- else filterFn($a, $l[$i])
790-
791- func $f0_2 ($a,$i) = if (($i >= $s))
792- then $a
793- else throw("List size exceeds 20")
794-
795- $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)
796- }
797- let maxIndex = if ((size(listF) > 0))
798- then max(listF)
799- else valueOrErrorMessage(parseInt(list[0]), ("getTwapSpotPrice: invalid int: " + listStr))
800- let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
801- let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0)
802- let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0)
803- let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice))
804- let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0)
805- let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0)
806- let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice))
807- ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL)
808- }
809-
810-
811743 func getTerminalAmmState () = {
812744 let _positionSize = totalPositionSize()
813745 if ((_positionSize == 0))
814746 then $Tuple2(qtAstR(), bsAstR())
815747 else {
816748 let direction = (_positionSize > 0)
817- let $t03918039359 = swapOutput(direction, abs(_positionSize), false)
818- let currentNetMarketValue = $t03918039359._1
819- let terminalQuoteAssetReserve = $t03918039359._2
820- let terminalBaseAssetReserve = $t03918039359._3
749+ let $t03715937338 = swapOutput(direction, abs(_positionSize), false)
750+ let currentNetMarketValue = $t03715937338._1
751+ let terminalQuoteAssetReserve = $t03715937338._2
752+ let terminalBaseAssetReserve = $t03715937338._3
821753 $Tuple2(terminalQuoteAssetReserve, terminalBaseAssetReserve)
822754 }
823755 }
824756
825757
826758 func getQuoteAssetWeight (baseAssetReserve,totalPositionSize,quoteAssetReserve,targetPrice) = {
827759 let b = toBigInt(baseAssetReserve)
828760 let sz = toBigInt(totalPositionSize)
829761 let q = toBigInt(quoteAssetReserve)
830762 let p = toBigInt(targetPrice)
831763 let k = bmuld(q, b)
832764 let newB = (b + sz)
833765 let newQ = bdivd(k, newB)
834766 let z = bdivd(newQ, newB)
835767 let result = bdivd(p, z)
836768 toInt(result)
837769 }
838770
839771
840772 func getSyncTerminalPrice (_terminalPrice,_qtAstR,_bsAstR) = {
841773 let _positionSize = totalPositionSize()
842774 if ((_positionSize == 0))
843775 then {
844776 let newQtAstW = divd(muld(_terminalPrice, _bsAstR), _qtAstR)
845777 $Tuple3(newQtAstW, DECIMAL_UNIT, 0)
846778 }
847779 else {
848780 let direction = (_positionSize > 0)
849781 let currentNetMarketValue = swapOutput(direction, abs(_positionSize), false)._1
850782 let newQtAstW = getQuoteAssetWeight(_bsAstR, _positionSize, _qtAstR, _terminalPrice)
851783 let newBsAstW = DECIMAL_UNIT
852784 let marginToVault = getPositionNotionalAndUnrealizedPnlByValues(_positionSize, currentNetMarketValue, _qtAstR, newQtAstW, _bsAstR, newBsAstW, PNL_OPTION_SPOT)._2
853785 $Tuple3(newQtAstW, newBsAstW, marginToVault)
854786 }
855787 }
856788
857789
858790 func getFunding () = {
859791 let underlyingPrice = getOraclePrice()
860- let spotTwapPrice = getTwapSpotPrice()
861- let premium = (spotTwapPrice - underlyingPrice)
792+ let spotPrice = getSpotPrice()
793+ let premium = (spotPrice - underlyingPrice)
862794 if (if (if ((totalShortPositionSize() == 0))
863795 then true
864796 else (totalLongPositionSize() == 0))
865797 then true
866798 else isMarketClosed())
867- then $Tuple2(0, 0)
799+ then $Tuple3(0, 0, 0)
868800 else if ((0 > premium))
869801 then {
870802 let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
871- let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize())
872- $Tuple2(shortPremiumFraction, longPremiumFraction)
803+ if ((fundingMode() == FUNDING_ASYMMETRIC))
804+ then {
805+ let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize())
806+ $Tuple3(shortPremiumFraction, longPremiumFraction, 0)
807+ }
808+ else {
809+ let shortTotalPremiumFraction = abs(muld(shortPremiumFraction, totalShortPositionSize()))
810+ let longTotalPremiumFraction = abs(muld(shortPremiumFraction, totalLongPositionSize()))
811+ let premiumToVault = (shortTotalPremiumFraction - longTotalPremiumFraction)
812+ $Tuple3(shortPremiumFraction, shortPremiumFraction, premiumToVault)
813+ }
873814 }
874815 else {
875816 let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
876- let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize())
877- $Tuple2(shortPremiumFraction, longPremiumFraction)
817+ if ((fundingMode() == FUNDING_ASYMMETRIC))
818+ then {
819+ let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize())
820+ $Tuple3(shortPremiumFraction, longPremiumFraction, 0)
821+ }
822+ else {
823+ let longTotalPremiumFraction = abs(muld(longPremiumFraction, totalLongPositionSize()))
824+ let shortTotalPremiumFraction = abs(muld(longPremiumFraction, totalShortPositionSize()))
825+ let premiumToVault = (longTotalPremiumFraction - shortTotalPremiumFraction)
826+ $Tuple3(longPremiumFraction, longPremiumFraction, premiumToVault)
827+ }
878828 }
879829 }
880830
881831
882832 func getAdjustedFee (_artifactId,_baseFeeDiscount) = {
883833 let baseFeeRaw = fee()
884834 let baseFee = muld(baseFeeRaw, _baseFeeDiscount)
885- let $t04222042715 = if ((_artifactId != ""))
835+ let $t04191342408 = if ((_artifactId != ""))
886836 then {
887837 let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, _artifactId))
888838 if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE))
889839 then {
890840 let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, _artifactId))
891841 let adjustedFee = muld(baseFee, reduction)
892842 $Tuple2(adjustedFee, true)
893843 }
894844 else throw("Invalid attached artifact")
895845 }
896846 else $Tuple2(baseFee, false)
897- let adjustedFee = $t04222042715._1
898- let burnArtifact = $t04222042715._2
847+ let adjustedFee = $t04191342408._1
848+ let burnArtifact = $t04191342408._2
899849 $Tuple2(adjustedFee, burnArtifact)
900850 }
901-
902-
903-func isSameAssetOrNoPosition (_trader,_assetId) = {
904- let oldPositionSize = getPosition(_trader)._1
905- if ((oldPositionSize == 0))
906- then true
907- else (getPositionAsset(_trader) == _assetId)
908- }
909-
910-
911-func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId)
912851
913852
914853 func getForTraderWithArtifact (_trader,_artifactId) = {
915854 let doGetFeeDiscount = invoke(minerAddress(), "computeFeeDiscount", [_trader], nil)
916855 if ((doGetFeeDiscount == doGetFeeDiscount))
917856 then {
918857 let feeDiscount = match doGetFeeDiscount {
919858 case x: Int =>
920859 x
921860 case _ =>
922861 throw("Invalid computeFeeDiscount result")
923862 }
924- let $t04339543469 = getAdjustedFee(_artifactId, feeDiscount)
925- let adjustedFee = $t04339543469._1
926- let burnArtifact = $t04339543469._2
863+ let $t04275442828 = getAdjustedFee(_artifactId, feeDiscount)
864+ let adjustedFee = $t04275442828._1
865+ let burnArtifact = $t04275442828._2
927866 $Tuple2(adjustedFee, burnArtifact)
928867 }
929868 else throw("Strict value is not equal to itself.")
930869 }
931870
932871
933872 func getArtifactId (i) = {
934873 let artifactId = if ((size(i.payments) > 1))
935874 then toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifactId"))
936875 else ""
937876 artifactId
938877 }
939878
940879
941880 func distributeFee (_feeAmount) = {
942881 let feeToStakers = muld(_feeAmount, feeToStakersPercent())
943882 let feeToVault = (_feeAmount - feeToStakers)
944883 $Tuple2(feeToStakers, feeToVault)
945884 }
946885
947886
948-func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional), IntegerEntry(k_feeToStakersPercent, _feeToStakersPercent), IntegerEntry(k_maxOracleDelay, _feeToStakersPercent), IntegerEntry(k_rolloverFee, _rolloverFee)]
887+func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread), IntegerEntry(k_maxOpenNotional, _maxOpenNotional), IntegerEntry(k_feeToStakersPercent, _feeToStakersPercent), IntegerEntry(k_maxOracleDelay, _feeToStakersPercent), IntegerEntry(k_rolloverFee, _rolloverFee), IntegerEntry(k_fundingMode, _fundingMode)]
949888
950889
951890 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)]
952891
953892
954-func incrementPositionSequenceNumber (_isNewPosition,_address) = if (_isNewPosition)
955- then {
956- let currentSequence = lastSequence()
957-[IntegerEntry(toCompositeKey(k_positionSequence, _address), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))]
958- }
959- else nil
893+func incrementPositionSequenceNumber (_isNewPosition,_trader,_direction) = {
894+ let positionKey = ((_trader + "_") + toString(_direction))
895+ if (_isNewPosition)
896+ then {
897+ let currentSequence = lastSequence()
898+[IntegerEntry(toCompositeKey(k_positionSequence, positionKey), (currentSequence + 1)), IntegerEntry(k_sequence, (currentSequence + 1))]
899+ }
900+ else nil
901+ }
960902
961903
962-func updatePositionFee (_isNewPosition,_address,_fee) = if (_isNewPosition)
963- then [IntegerEntry(toCompositeKey(k_positionFee, _address), _fee)]
964- else nil
904+func updatePositionFee (_isNewPosition,_trader,_direction,_fee) = {
905+ let positionKey = ((_trader + "_") + toString(_direction))
906+ if (_isNewPosition)
907+ then [IntegerEntry(toCompositeKey(k_positionFee, positionKey), _fee)]
908+ else nil
909+ }
965910
966911
967-func updatePosition (_address,_size,_margin,_openNotional,_latestCumulativePremiumFraction,_latestTimestamp) = [IntegerEntry(toCompositeKey(k_positionSize, _address), _size), IntegerEntry(toCompositeKey(k_positionMargin, _address), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, _address), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address), _latestCumulativePremiumFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _address), _latestTimestamp)]
968-
969-
970-func appendTwap (_price) = {
971- let minuteId = ((lastTimestamp() / 1000) / 60)
972- let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
973- if ((previousMinuteId > minuteId))
974- then throw("TWAP out-of-order")
975- else {
976- let lastMinuteId = if ((previousMinuteId == 0))
977- then minuteId
978- else previousMinuteId
979- if ((minuteId > previousMinuteId))
980- then {
981- let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0)
982- let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), _price)
983- let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice))
984- let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId))
985-[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))]
986- }
987- else {
988- let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0)
989- let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0)
990- let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), _price)
991- let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice))
992-[IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), _price)]
993- }
994- }
912+func updatePosition (_trader,_size,_margin,_openNotional,_latestCumulativePremiumFraction,_latestTimestamp) = {
913+ let direction = getDirection(_size)
914+ let positionKey = ((_trader + "_") + toString(direction))
915+[IntegerEntry(toCompositeKey(k_positionSize, positionKey), _size), IntegerEntry(toCompositeKey(k_positionMargin, positionKey), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, positionKey), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey), _latestCumulativePremiumFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey), _latestTimestamp)]
995916 }
996917
997918
998919 func updateAmmReserves (_qtAstR,_bsAstR) = [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)]
999920
1000921
1001922 func updateAmmWeights (_qtAstW,_bsAstW) = [IntegerEntry(k_quoteAssetWeight, _qtAstW), IntegerEntry(k_baseAssetWeight, _bsAstW)]
1002923
1003924
1004925 func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize,_totalLongOpenNotional,_totalShortOpenNotional) = {
1005926 let _qtAstW = qtAstW()
1006927 let _bsAstW = bsAstW()
1007928 if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter))
1008929 then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter)))
1009- 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))))
930+ 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)])
1010931 }
1011932
1012933
1013-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)), DeleteEntry(toCompositeKey(k_positionFee, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _address))]
934+func deletePosition (_trader,_direction) = {
935+ let positionKey = ((_trader + "_") + toString(_direction))
936+[DeleteEntry(toCompositeKey(k_positionSize, positionKey)), DeleteEntry(toCompositeKey(k_positionMargin, positionKey)), DeleteEntry(toCompositeKey(k_positionOpenNotional, positionKey)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey)), DeleteEntry(toCompositeKey(k_positionFee, positionKey)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey))]
937+ }
1014938
1015939
1016940 func withdraw (_address,_amount) = {
1017941 let balance = assetBalance(this, quoteAsset())
1018942 if ((_amount > balance))
1019943 then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance)))
1020944 else [ScriptTransfer(_address, _amount, quoteAsset())]
1021945 }
1022946
1023947
1024948 func updateBalance (i) = if ((0 > i))
1025949 then throw("Balance")
1026950 else [IntegerEntry(k_balance, i)]
1027951
1028952
1029953 func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())]
1030954
1031955
1032956 func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact)
1033957 then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)]
1034958 else nil
1035959
1036960
1037961 @Callable(i)
1038962 func pause () = if ((i.caller != adminAddress()))
1039963 then throw("Invalid pause params")
1040964 else [BooleanEntry(k_paused, true)]
1041965
1042966
1043967
1044968 @Callable(i)
1045969 func unpause () = if ((i.caller != adminAddress()))
1046970 then throw("Invalid unpause params")
1047971 else [BooleanEntry(k_paused, false)]
1048972
1049973
1050974
1051975 @Callable(i)
1052976 func setCloseOnly () = if ((i.caller != adminAddress()))
1053977 then throw("Invalid setCloseOnly params")
1054978 else [BooleanEntry(k_closeOnly, true)]
1055979
1056980
1057981
1058982 @Callable(i)
1059983 func unsetCloseOnly () = if ((i.caller != adminAddress()))
1060984 then throw("Invalid unsetCloseOnly params")
1061985 else [BooleanEntry(k_closeOnly, false)]
1062986
1063987
1064988
1065989 @Callable(i)
1066990 func addLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress()))
1067991 then true
1068992 else (0 >= _quoteAssetAmount))
1069993 then throw("Invalid addLiquidity params")
1070994 else {
1071995 let _qtAstR = qtAstR()
1072996 let _bsAstR = bsAstR()
1073997 let _qtAstW = qtAstW()
1074998 let _bsAstW = bsAstW()
1075999 let price = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
10761000 let qtAstRAfter = (_qtAstR + _quoteAssetAmount)
10771001 let baseAssetAmountToAdd = (divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR)
10781002 let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd)
1079- let $t05287653027 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
1080- let newQuoteAssetWeight = $t05287653027._1
1081- let newBaseAssetWeight = $t05287653027._2
1082- let marginToVault = $t05287653027._3
1003+ let $t05108351234 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
1004+ let newQuoteAssetWeight = $t05108351234._1
1005+ let newBaseAssetWeight = $t05108351234._2
1006+ let marginToVault = $t05108351234._3
10831007 let doExchangePnL = if ((marginToVault != 0))
10841008 then {
10851009 let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil)
10861010 if ((doExchangePnL == doExchangePnL))
10871011 then nil
10881012 else throw("Strict value is not equal to itself.")
10891013 }
10901014 else nil
10911015 if ((doExchangePnL == doExchangePnL))
10921016 then (updateAmmReserves(qtAstRAfter, bsAstRAfter) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight))
10931017 else throw("Strict value is not equal to itself.")
10941018 }
10951019
10961020
10971021
10981022 @Callable(i)
10991023 func removeLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress()))
11001024 then true
11011025 else (_quoteAssetAmount >= 0))
11021026 then throw("Invalid removeLiquidity params")
11031027 else {
11041028 let _qtAstR = qtAstR()
11051029 let _bsAstR = bsAstR()
11061030 let _qtAstW = qtAstW()
11071031 let _bsAstW = bsAstW()
11081032 let price = divd(muld(_qtAstR, _qtAstW), muld(_bsAstR, _bsAstW))
11091033 let qtAstRAfter = (_qtAstR - _quoteAssetAmount)
11101034 let baseAssetAmountToRemove = abs((divd(muld(qtAstRAfter, _qtAstW), price) - _bsAstR))
11111035 let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove)
1112- let $t05395954110 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
1113- let newQuoteAssetWeight = $t05395954110._1
1114- let newBaseAssetWeight = $t05395954110._2
1115- let marginToVault = $t05395954110._3
1036+ let $t05233052481 = getSyncTerminalPrice(getOraclePrice(), qtAstRAfter, bsAstRAfter)
1037+ let newQuoteAssetWeight = $t05233052481._1
1038+ let newBaseAssetWeight = $t05233052481._2
1039+ let marginToVault = $t05233052481._3
11161040 let doExchangePnL = if ((marginToVault != 0))
11171041 then {
11181042 let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVault], nil)
11191043 if ((doExchangePnL == doExchangePnL))
11201044 then nil
11211045 else throw("Strict value is not equal to itself.")
11221046 }
11231047 else nil
11241048 if ((doExchangePnL == doExchangePnL))
11251049 then (updateAmmReserves(qtAstRAfter, bsAstRAfter) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight))
11261050 else throw("Strict value is not equal to itself.")
11271051 }
11281052
11291053
11301054
11311055 @Callable(i)
1132-func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = if ((i.caller != adminAddress()))
1056+func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _fundingPeriod))
1057+ then true
1058+ else (0 >= _initMarginRatio))
1059+ then true
1060+ else (0 >= _mmr))
1061+ then true
1062+ else (0 >= _liquidationFeeRatio))
1063+ then true
1064+ else (0 >= _fee))
1065+ then true
1066+ else (0 >= _spreadLimit))
1067+ then true
1068+ else (0 >= _maxPriceImpact))
1069+ then true
1070+ else (0 >= _partialLiquidationRatio))
1071+ then true
1072+ else (0 >= _maxPriceSpread))
1073+ then true
1074+ else (0 >= _maxOpenNotional))
1075+ then true
1076+ else (0 >= _feeToStakersPercent))
1077+ then true
1078+ else (_feeToStakersPercent > DECIMAL_UNIT))
1079+ then true
1080+ else (0 >= _maxOracleDelay))
1081+ then true
1082+ else (0 >= _rolloverFee))
1083+ then true
1084+ else if ((_fundingMode != FUNDING_SYMMETRIC))
1085+ then (_fundingMode != FUNDING_ASYMMETRIC)
1086+ else false)
1087+ then true
1088+ else !(initialized()))
1089+ then true
1090+ else (i.caller != adminAddress()))
11331091 then throw("Invalid changeSettings params")
1134- else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee)
1092+ else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee, _fundingMode)
11351093
11361094
11371095
11381096 @Callable(i)
1139-func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_baseOracleData,_quoteOracleData,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
1097+func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_baseOracleData,_quoteOracleData,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread,_maxOpenNotional,_feeToStakersPercent,_maxOracleDelay,_rolloverFee,_fundingMode) = if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
11401098 then true
11411099 else (0 >= _bsAstR))
11421100 then true
11431101 else (0 >= _fundingPeriod))
11441102 then true
11451103 else (0 >= _initMarginRatio))
11461104 then true
11471105 else (0 >= _mmr))
11481106 then true
11491107 else (0 >= _liquidationFeeRatio))
11501108 then true
11511109 else (0 >= _fee))
11521110 then true
11531111 else (0 >= _spreadLimit))
11541112 then true
11551113 else (0 >= _maxPriceImpact))
11561114 then true
11571115 else (0 >= _partialLiquidationRatio))
11581116 then true
11591117 else (0 >= _maxPriceSpread))
11601118 then true
11611119 else (0 >= _maxOpenNotional))
11621120 then true
11631121 else (0 >= _feeToStakersPercent))
11641122 then true
11651123 else (_feeToStakersPercent > DECIMAL_UNIT))
11661124 then true
11671125 else (0 >= _maxOracleDelay))
11681126 then true
11691127 else (0 >= _rolloverFee))
11701128 then true
1129+ else if ((_fundingMode != FUNDING_SYMMETRIC))
1130+ then (_fundingMode != FUNDING_ASYMMETRIC)
1131+ else false)
1132+ then true
11711133 else initialized())
11721134 then true
11731135 else (i.caller != this))
11741136 then throw("Invalid initialize parameters")
1175- else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee)) ++ updateFunding((lastTimestamp() + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_quoteOracle, _quoteOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))])
1137+ else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread, _maxOpenNotional, _feeToStakersPercent, _maxOracleDelay, _rolloverFee, _fundingMode)) ++ updateFunding((lastTimestamp() + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_baseOracle, _baseOracleData), StringEntry(k_quoteOracle, _quoteOracleData), StringEntry(k_coordinatorAddress, toString(addressFromStringValue(_coordinator)))])
11761138
11771139
11781140
11791141 @Callable(i)
11801142 func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = {
11811143 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
11821144 if ((sync == sync))
11831145 then {
11841146 let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil)
11851147 if ((ensureCalledOnce == ensureCalledOnce))
11861148 then {
11871149 let _trader = getActualCaller(i)
11881150 let _rawAmount = i.payments[0].amount
11891151 let _assetId = i.payments[0].assetId
11901152 let _assetIdStr = toBase58String(value(_assetId))
11911153 let isQuoteAsset = (_assetId == quoteAsset())
1192- if (if (if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
1154+ if (if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
11931155 then (_direction != DIR_SHORT)
11941156 else false)
11951157 then true
11961158 else (0 >= _rawAmount))
11971159 then true
11981160 else !(initialized()))
11991161 then true
12001162 else !(isQuoteAsset))
1201- then true
1202- else !(isSameAssetOrNoPosition(_trader, _assetIdStr)))
12031163 then true
12041164 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
12051165 then true
12061166 else paused())
12071167 then true
12081168 else closeOnly())
12091169 then true
12101170 else isMarketClosed())
12111171 then throw("Invalid increasePosition parameters")
12121172 else {
1213- let $t05788858037 = getForTraderWithArtifact(_trader, getArtifactId(i))
1214- let adjustedFee = $t05788858037._1
1215- let burnArtifact = $t05788858037._2
1173+ let $t05855158700 = getForTraderWithArtifact(_trader, getArtifactId(i))
1174+ let adjustedFee = $t05855158700._1
1175+ let burnArtifact = $t05855158700._2
12161176 let _amount = divd(_rawAmount, (muld(adjustedFee, _leverage) + DECIMAL_UNIT))
12171177 let distributeFeeAmount = (_rawAmount - _amount)
12181178 let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
12191179 if ((referrerFeeAny == referrerFeeAny))
12201180 then {
12211181 let referrerFee = match referrerFeeAny {
12221182 case x: Int =>
12231183 x
12241184 case _ =>
12251185 throw("Invalid referrerFee")
12261186 }
12271187 let feeAmount = (distributeFeeAmount - referrerFee)
1228- let $t05853358701 = getPosition(_trader)
1229- let oldPositionSize = $t05853358701._1
1230- let oldPositionMargin = $t05853358701._2
1231- let oldPositionOpenNotional = $t05853358701._3
1232- let oldPositionLstUpdCPF = $t05853358701._4
1233- let oldPositionTimestamp = $t05853358701._5
1188+ let $t05919659376 = getPosition(_trader, _direction)
1189+ let oldPositionSize = $t05919659376._1
1190+ let oldPositionMargin = $t05919659376._2
1191+ let oldPositionOpenNotional = $t05919659376._3
1192+ let oldPositionLstUpdCPF = $t05919659376._4
1193+ let oldPositionTimestamp = $t05919659376._5
12341194 let isNewPosition = (oldPositionSize == 0)
12351195 let isSameDirection = if ((oldPositionSize > 0))
12361196 then (_direction == DIR_LONG)
12371197 else (_direction == DIR_SHORT)
12381198 let expandExisting = if (!(isNewPosition))
12391199 then isSameDirection
12401200 else false
12411201 let isAdd = (_direction == DIR_LONG)
1242- let $t05899062111 = if (if (isNewPosition)
1202+ let $t05966562798 = if (if (isNewPosition)
12431203 then true
12441204 else expandExisting)
12451205 then {
12461206 let openNotional = muld(_amount, _leverage)
1247- let $t05949959672 = swapInput(isAdd, openNotional)
1248- let amountBaseAssetBought = $t05949959672._1
1249- let quoteAssetReserveAfter = $t05949959672._2
1250- let baseAssetReserveAfter = $t05949959672._3
1251- let totalPositionSizeAfter = $t05949959672._4
1207+ let $t06017460347 = swapInput(isAdd, openNotional)
1208+ let amountBaseAssetBought = $t06017460347._1
1209+ let quoteAssetReserveAfter = $t06017460347._2
1210+ let baseAssetReserveAfter = $t06017460347._3
1211+ let totalPositionSizeAfter = $t06017460347._4
12521212 if (if ((_minBaseAssetAmount != 0))
12531213 then (_minBaseAssetAmount > abs(amountBaseAssetBought))
12541214 else false)
12551215 then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
12561216 else {
12571217 let newPositionSize = (oldPositionSize + amountBaseAssetBought)
12581218 let totalLongOpenInterestAfter = (openInterestLong() + (if ((newPositionSize > 0))
12591219 then openNotional
12601220 else 0))
12611221 let totalShortOpenInterestAfter = (openInterestShort() + (if ((0 > newPositionSize))
12621222 then openNotional
12631223 else 0))
1264- let $t06021860493 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, _amount)
1265- let remainMargin = $t06021860493._1
1266- let x1 = $t06021860493._2
1267- let x2 = $t06021860493._3
1268- let rolloverFee = $t06021860493._4
1224+ let $t06089361168 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, _amount)
1225+ let remainMargin = $t06089361168._1
1226+ let x1 = $t06089361168._2
1227+ let x2 = $t06089361168._3
1228+ let rolloverFee = $t06089361168._4
12691229 if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
12701230 then throw("Over max spread limit")
12711231 else if (!(requireNotOverMaxOpenNotional(totalLongOpenInterestAfter, totalShortOpenInterestAfter)))
12721232 then throw("Over max open notional")
12731233 else $Tuple14(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), lastTimestamp(), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
12741234 then abs(amountBaseAssetBought)
12751235 else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
12761236 then abs(amountBaseAssetBought)
12771237 else 0)), totalLongOpenInterestAfter, totalShortOpenInterestAfter, rolloverFee)
12781238 }
12791239 }
12801240 else {
12811241 let openNotional = muld(_amount, _leverage)
1282- let $t06181161927 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1283- let oldPositionNotional = $t06181161927._1
1284- let unrealizedPnl = $t06181161927._2
1242+ let $t06248662614 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), _direction, PNL_OPTION_SPOT)
1243+ let oldPositionNotional = $t06248662614._1
1244+ let unrealizedPnl = $t06248662614._2
12851245 if ((oldPositionNotional > openNotional))
12861246 then throw("Use decreasePosition to decrease position size")
12871247 else throw("Close position first")
12881248 }
1289- let newPositionSize = $t05899062111._1
1290- let newPositionRemainMargin = $t05899062111._2
1291- let newPositionOpenNotional = $t05899062111._3
1292- let newPositionLatestCPF = $t05899062111._4
1293- let newPositionTimestamp = $t05899062111._5
1294- let baseAssetReserveAfter = $t05899062111._6
1295- let quoteAssetReserveAfter = $t05899062111._7
1296- let totalPositionSizeAfter = $t05899062111._8
1297- let openInterestNotionalAfter = $t05899062111._9
1298- let totalLongAfter = $t05899062111._10
1299- let totalShortAfter = $t05899062111._11
1300- let totalLongOpenInterestAfter = $t05899062111._12
1301- let totalShortOpenInterestAfter = $t05899062111._13
1302- let rolloverFee = $t05899062111._14
1303- let $t06211762188 = distributeFee((feeAmount + rolloverFee))
1304- let feeToStakers = $t06211762188._1
1305- let feeToVault = $t06211762188._2
1249+ let newPositionSize = $t05966562798._1
1250+ let newPositionRemainMargin = $t05966562798._2
1251+ let newPositionOpenNotional = $t05966562798._3
1252+ let newPositionLatestCPF = $t05966562798._4
1253+ let newPositionTimestamp = $t05966562798._5
1254+ let baseAssetReserveAfter = $t05966562798._6
1255+ let quoteAssetReserveAfter = $t05966562798._7
1256+ let totalPositionSizeAfter = $t05966562798._8
1257+ let openInterestNotionalAfter = $t05966562798._9
1258+ let totalLongAfter = $t05966562798._10
1259+ let totalShortAfter = $t05966562798._11
1260+ let totalLongOpenInterestAfter = $t05966562798._12
1261+ let totalShortOpenInterestAfter = $t05966562798._13
1262+ let rolloverFee = $t05966562798._14
1263+ let $t06280462875 = distributeFee((feeAmount + rolloverFee))
1264+ let feeToStakers = $t06280462875._1
1265+ let feeToVault = $t06280462875._2
13061266 let stake = if ((_amount >= rolloverFee))
13071267 then invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), (_amount - rolloverFee))])
13081268 else invoke(vaultAddress(), "withdrawLocked", [(rolloverFee - _amount)], nil)
13091269 if ((stake == stake))
13101270 then {
13111271 let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)])
13121272 if ((depositVault == depositVault))
13131273 then {
13141274 let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
13151275 if ((notifyFee == notifyFee))
13161276 then {
13171277 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
13181278 if ((notifyNotional == notifyNotional))
1319- then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF, newPositionTimestamp) ++ incrementPositionSequenceNumber(isNewPosition, _trader)) ++ updatePositionFee(isNewPosition, _trader, adjustedFee)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doBurnArtifact(burnArtifact, i))
1279+ then ((((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF, newPositionTimestamp) ++ incrementPositionSequenceNumber(isNewPosition, _trader, _direction)) ++ updatePositionFee(isNewPosition, _trader, _direction, adjustedFee)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ transferFee(feeToStakers)) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doBurnArtifact(burnArtifact, i))
13201280 else throw("Strict value is not equal to itself.")
13211281 }
13221282 else throw("Strict value is not equal to itself.")
13231283 }
13241284 else throw("Strict value is not equal to itself.")
13251285 }
13261286 else throw("Strict value is not equal to itself.")
13271287 }
13281288 else throw("Strict value is not equal to itself.")
13291289 }
13301290 }
13311291 else throw("Strict value is not equal to itself.")
13321292 }
13331293 else throw("Strict value is not equal to itself.")
13341294 }
13351295
13361296
13371297
13381298 @Callable(i)
1339-func addMargin () = {
1299+func addMargin (_direction) = {
13401300 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
13411301 if ((sync == sync))
13421302 then {
13431303 let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil)
13441304 if ((ensureCalledOnce == ensureCalledOnce))
13451305 then {
13461306 let _trader = toString(i.caller)
13471307 let _amount = i.payments[0].amount
13481308 let _assetId = i.payments[0].assetId
13491309 let _assetIdStr = toBase58String(value(_assetId))
13501310 let isQuoteAsset = (_assetId == quoteAsset())
1351- if (if (if (if (if (if (if (!(isQuoteAsset))
1311+ if (if (if (if (if (!(isQuoteAsset))
13521312 then true
1353- else !(requireOpenPosition(toString(i.caller))))
1354- then true
1355- else !(isSameAsset(_trader, _assetIdStr)))
1313+ else !(requireOpenPosition(toString(i.caller), _direction)))
13561314 then true
13571315 else !(initialized()))
13581316 then true
13591317 else paused())
13601318 then true
1361- else closeOnly())
1362- then true
13631319 else isMarketClosed())
13641320 then throw("Invalid addMargin parameters")
13651321 else {
1366- let $t06429964467 = getPosition(_trader)
1367- let oldPositionSize = $t06429964467._1
1368- let oldPositionMargin = $t06429964467._2
1369- let oldPositionOpenNotional = $t06429964467._3
1370- let oldPositionLstUpdCPF = $t06429964467._4
1371- let oldPositionTimestamp = $t06429964467._5
1322+ let $t06512265302 = getPosition(_trader, _direction)
1323+ let oldPositionSize = $t06512265302._1
1324+ let oldPositionMargin = $t06512265302._2
1325+ let oldPositionOpenNotional = $t06512265302._3
1326+ let oldPositionLstUpdCPF = $t06512265302._4
1327+ let oldPositionTimestamp = $t06512265302._5
13721328 let stake = invoke(vaultAddress(), "addLocked", nil, [AttachedPayment(quoteAsset(), _amount)])
13731329 if ((stake == stake))
13741330 then {
13751331 let rolloverFee = calcRolloverFee(oldPositionMargin, oldPositionTimestamp)
13761332 let doTransferFeeToStakers = if ((rolloverFee > 0))
13771333 then {
1378- let $t06475264811 = distributeFee(rolloverFee)
1379- let feeToStakers = $t06475264811._1
1380- let feeToVault = $t06475264811._2
1334+ let $t06558765646 = distributeFee(rolloverFee)
1335+ let feeToStakers = $t06558765646._1
1336+ let feeToVault = $t06558765646._2
13811337 let unstake = invoke(vaultAddress(), "withdrawLocked", [feeToStakers], nil)
13821338 if ((unstake == unstake))
13831339 then {
13841340 let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(feeToVault)], nil)
13851341 if ((lockBadDebt == lockBadDebt))
13861342 then transferFee(feeToStakers)
13871343 else throw("Strict value is not equal to itself.")
13881344 }
13891345 else throw("Strict value is not equal to itself.")
13901346 }
13911347 else nil
13921348 if ((doTransferFeeToStakers == doTransferFeeToStakers))
13931349 then ((updatePosition(_trader, oldPositionSize, ((oldPositionMargin - rolloverFee) + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF, lastTimestamp()) ++ updateBalance(((cbalance() + _amount) - rolloverFee))) ++ doTransferFeeToStakers)
13941350 else throw("Strict value is not equal to itself.")
13951351 }
13961352 else throw("Strict value is not equal to itself.")
13971353 }
13981354 }
13991355 else throw("Strict value is not equal to itself.")
14001356 }
14011357 else throw("Strict value is not equal to itself.")
14021358 }
14031359
14041360
14051361
14061362 @Callable(i)
1407-func removeMargin (_amount) = {
1363+func removeMargin (_amount,_direction) = {
14081364 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
14091365 if ((sync == sync))
14101366 then {
14111367 let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil)
14121368 if ((ensureCalledOnce == ensureCalledOnce))
14131369 then {
14141370 let _trader = toString(i.caller)
14151371 if (if (if (if (if ((0 >= _amount))
14161372 then true
1417- else !(requireOpenPosition(_trader)))
1373+ else !(requireOpenPosition(_trader, _direction)))
14181374 then true
14191375 else !(initialized()))
14201376 then true
14211377 else paused())
14221378 then true
14231379 else isMarketClosed())
14241380 then throw("Invalid removeMargin parameters")
14251381 else {
1426- let $t06592366091 = getPosition(_trader)
1427- let oldPositionSize = $t06592366091._1
1428- let oldPositionMargin = $t06592366091._2
1429- let oldPositionOpenNotional = $t06592366091._3
1430- let oldPositionLstUpdCPF = $t06592366091._4
1431- let oldPositionTimestamp = $t06592366091._5
1432- let $t06609766346 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, -(_amount))
1433- let remainMargin = $t06609766346._1
1434- let badDebt = $t06609766346._2
1435- let fundingPayment = $t06609766346._3
1436- let rolloverFee = $t06609766346._4
1382+ let $t06705067230 = getPosition(_trader, _direction)
1383+ let oldPositionSize = $t06705067230._1
1384+ let oldPositionMargin = $t06705067230._2
1385+ let oldPositionOpenNotional = $t06705067230._3
1386+ let oldPositionLstUpdCPF = $t06705067230._4
1387+ let oldPositionTimestamp = $t06705067230._5
1388+ let $t06723667485 = calcRemainMarginWithFundingPaymentAndRolloverFee(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, oldPositionTimestamp, -(_amount))
1389+ let remainMargin = $t06723667485._1
1390+ let badDebt = $t06723667485._2
1391+ let fundingPayment = $t06723667485._3
1392+ let rolloverFee = $t06723667485._4
14371393 if ((badDebt != 0))
14381394 then throw("Invalid removed margin amount")
14391395 else {
14401396 let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional)
14411397 if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true)))
14421398 then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
14431399 else {
1444- let $t06673266791 = distributeFee(rolloverFee)
1445- let feeToStakers = $t06673266791._1
1446- let feeToVault = $t06673266791._2
1400+ let $t06787167930 = distributeFee(rolloverFee)
1401+ let feeToStakers = $t06787167930._1
1402+ let feeToVault = $t06787167930._2
14471403 let doTransferFeeToStakers = if ((rolloverFee > 0))
14481404 then {
14491405 let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(feeToVault)], nil)
14501406 if ((lockBadDebt == lockBadDebt))
14511407 then transferFee(feeToStakers)
14521408 else throw("Strict value is not equal to itself.")
14531409 }
14541410 else nil
14551411 if ((doTransferFeeToStakers == doTransferFeeToStakers))
14561412 then {
14571413 let unstake = invoke(vaultAddress(), "withdrawLocked", [(_amount + feeToStakers)], nil)
14581414 if ((unstake == unstake))
14591415 then (((updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize), lastTimestamp()) ++ withdraw(i.caller, _amount)) ++ updateBalance(((cbalance() - _amount) - rolloverFee))) ++ doTransferFeeToStakers)
14601416 else throw("Strict value is not equal to itself.")
14611417 }
14621418 else throw("Strict value is not equal to itself.")
14631419 }
14641420 }
14651421 }
14661422 }
14671423 else throw("Strict value is not equal to itself.")
14681424 }
14691425 else throw("Strict value is not equal to itself.")
14701426 }
14711427
14721428
14731429
14741430 @Callable(i)
1475-func closePosition (_size,_minQuoteAssetAmount,_addToMargin) = {
1431+func closePosition (_size,_direction,_minQuoteAssetAmount,_addToMargin) = {
14761432 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
14771433 if ((sync == sync))
14781434 then {
14791435 let ensureCalledOnce = invoke(this, "ensureCalledOnce", nil, nil)
14801436 if ((ensureCalledOnce == ensureCalledOnce))
14811437 then {
14821438 let _trader = getActualCaller(i)
14831439 let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller")
1484- let positionFee = getPositionFee(_trader)
1485- if (if (if (if (if (if (!(requireOpenPosition(_trader)))
1440+ let positionFee = getPositionFee(_trader, _direction)
1441+ if (if (if (if (if (if (!(requireOpenPosition(_trader, _direction)))
14861442 then true
14871443 else !(initialized()))
14881444 then true
14891445 else paused())
14901446 then true
14911447 else (0 >= _size))
14921448 then true
14931449 else (0 > _minQuoteAssetAmount))
14941450 then true
14951451 else isMarketClosed())
14961452 then throw("Invalid closePosition parameters")
14971453 else {
1498- let oldPositionTimestamp = getPosition(_trader)._5
1499- let $t06844869033 = internalClosePosition(_trader, _size, positionFee, _minQuoteAssetAmount, _addToMargin, true, true)
1500- let newPositionSize = $t06844869033._1
1501- let newPositionMargin = $t06844869033._2
1502- let newPositionOpenNotional = $t06844869033._3
1503- let newPositionLstUpdCPF = $t06844869033._4
1504- let positionBadDebt = $t06844869033._5
1505- let realizedPnl = $t06844869033._6
1506- let marginToTrader = $t06844869033._7
1507- let quoteAssetReserveAfter = $t06844869033._8
1508- let baseAssetReserveAfter = $t06844869033._9
1509- let totalPositionSizeAfter = $t06844869033._10
1510- let openInterestNotionalAfter = $t06844869033._11
1511- let totalLongAfter = $t06844869033._12
1512- let totalShortAfter = $t06844869033._13
1513- let totalLongOpenInterestAfter = $t06844869033._14
1514- let totalShortOpenInterestAfter = $t06844869033._15
1515- let realizedFee = $t06844869033._16
1454+ let oldPositionTimestamp = getPosition(_trader, _direction)._5
1455+ let $t07015870761 = internalClosePosition(_trader, _direction, _size, positionFee, _minQuoteAssetAmount, _addToMargin, true, true)
1456+ let newPositionSize = $t07015870761._1
1457+ let newPositionMargin = $t07015870761._2
1458+ let newPositionOpenNotional = $t07015870761._3
1459+ let newPositionLstUpdCPF = $t07015870761._4
1460+ let positionBadDebt = $t07015870761._5
1461+ let realizedPnl = $t07015870761._6
1462+ let marginToTrader = $t07015870761._7
1463+ let quoteAssetReserveAfter = $t07015870761._8
1464+ let baseAssetReserveAfter = $t07015870761._9
1465+ let totalPositionSizeAfter = $t07015870761._10
1466+ let openInterestNotionalAfter = $t07015870761._11
1467+ let totalLongAfter = $t07015870761._12
1468+ let totalShortAfter = $t07015870761._13
1469+ let totalLongOpenInterestAfter = $t07015870761._14
1470+ let totalShortOpenInterestAfter = $t07015870761._15
1471+ let realizedFee = $t07015870761._16
15161472 if ((positionBadDebt > 0))
15171473 then throw("Invalid closePosition parameters: bad debt")
15181474 else if ((oldPositionTimestamp >= lastTimestamp()))
15191475 then throw("Invalid closePosition parameters: wait at least 1 block before closing the position")
15201476 else {
15211477 let isPartialClose = (newPositionSize != 0)
15221478 let withdrawAmount = (marginToTrader + realizedFee)
15231479 let ammBalance = (cbalance() - withdrawAmount)
15241480 let ammNewBalance = if ((0 > ammBalance))
15251481 then 0
15261482 else ammBalance
15271483 let unstake = invoke(vaultAddress(), "withdrawLocked", [withdrawAmount], nil)
15281484 if ((unstake == unstake))
15291485 then {
1530- let $t06970569764 = distributeFee(realizedFee)
1531- let feeToStakers = $t06970569764._1
1532- let feeToVault = $t06970569764._2
1533- let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)])
1534- if ((depositVault == depositVault))
1486+ let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), realizedFee)])
1487+ if ((referrerFeeAny == referrerFeeAny))
15351488 then {
1536- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, realizedFee], nil)
1537- if ((notifyFee == notifyFee))
1489+ let referrerFee = match referrerFeeAny {
1490+ case x: Int =>
1491+ x
1492+ case _ =>
1493+ throw("Invalid referrerFee")
1494+ }
1495+ let $t07173371806 = distributeFee((realizedFee - referrerFee))
1496+ let feeToStakers = $t07173371806._1
1497+ let feeToVault = $t07173371806._2
1498+ let depositVault = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)])
1499+ if ((depositVault == depositVault))
15381500 then {
1539- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1540- if ((notifyNotional == notifyNotional))
1541- then (((((if (isPartialClose)
1542- then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp())
1543- else deletePosition(_trader)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((marginToTrader > 0))
1544- then withdraw(_traderAddress, marginToTrader)
1545- else nil)) ++ updateBalance(ammNewBalance)) ++ transferFee(feeToStakers))
1501+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, realizedFee], nil)
1502+ if ((notifyFee == notifyFee))
1503+ then {
1504+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1505+ if ((notifyNotional == notifyNotional))
1506+ then (((((if (isPartialClose)
1507+ then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp())
1508+ else deletePosition(_trader, _direction)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ (if ((marginToTrader > 0))
1509+ then withdraw(_traderAddress, marginToTrader)
1510+ else nil)) ++ updateBalance(ammNewBalance)) ++ transferFee(feeToStakers))
1511+ else throw("Strict value is not equal to itself.")
1512+ }
15461513 else throw("Strict value is not equal to itself.")
15471514 }
15481515 else throw("Strict value is not equal to itself.")
15491516 }
15501517 else throw("Strict value is not equal to itself.")
15511518 }
15521519 else throw("Strict value is not equal to itself.")
15531520 }
15541521 }
15551522 }
15561523 else throw("Strict value is not equal to itself.")
15571524 }
15581525 else throw("Strict value is not equal to itself.")
15591526 }
15601527
15611528
15621529
15631530 @Callable(i)
1564-func liquidate (_trader) = {
1531+func liquidate (_trader,_direction) = {
15651532 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
15661533 if ((sync == sync))
15671534 then {
1568- let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
1535+ let spotMarginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_SPOT)
15691536 let liquidationMarginRatio = if (isOverFluctuationLimit())
15701537 then {
1571- let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE)
1538+ let oracleMarginRatio = getMarginRatioByOption(_trader, _direction, PNL_OPTION_ORACLE)
15721539 vmax(spotMarginRatio, oracleMarginRatio)
15731540 }
15741541 else spotMarginRatio
15751542 if (if (if (if (if (!(requireMoreMarginRatio(liquidationMarginRatio, maintenanceMarginRatio(), false)))
15761543 then true
1577- else !(requireOpenPosition(_trader)))
1544+ else !(requireOpenPosition(_trader, _direction)))
15781545 then true
15791546 else !(initialized()))
15801547 then true
15811548 else paused())
15821549 then true
15831550 else isMarketClosed())
15841551 then throw("Unable to liquidate")
15851552 else {
15861553 let isPartialLiquidation = if (if ((spotMarginRatio > liquidationFeeRatio()))
15871554 then (partialLiquidationRatio() > 0)
15881555 else false)
15891556 then (DECIMAL_UNIT > partialLiquidationRatio())
15901557 else false
1591- let oldPositionSize = getPosition(_trader)._1
1558+ let oldPositionSize = getPosition(_trader, _direction)._1
15921559 let positionSizeAbs = abs(oldPositionSize)
1593- let $t07207772400 = if (isPartialLiquidation)
1560+ let $t07430474627 = if (isPartialLiquidation)
15941561 then {
15951562 let liquidationSize = getPartialLiquidationAmount(_trader, oldPositionSize)
15961563 let liquidationRatio = divd(abs(liquidationSize), positionSizeAbs)
15971564 $Tuple2(liquidationRatio, abs(liquidationSize))
15981565 }
15991566 else $Tuple2(0, positionSizeAbs)
1600- let liquidationRatio = $t07207772400._1
1601- let liquidationSize = $t07207772400._2
1602- let $t07240673044 = internalClosePosition(_trader, if (isPartialLiquidation)
1567+ let liquidationRatio = $t07430474627._1
1568+ let liquidationSize = $t07430474627._2
1569+ let $t07463375289 = internalClosePosition(_trader, _direction, if (isPartialLiquidation)
16031570 then liquidationSize
16041571 else positionSizeAbs, liquidationFeeRatio(), 0, true, false, true)
1605- let newPositionSize = $t07240673044._1
1606- let newPositionMargin = $t07240673044._2
1607- let newPositionOpenNotional = $t07240673044._3
1608- let newPositionLstUpdCPF = $t07240673044._4
1609- let positionBadDebt = $t07240673044._5
1610- let realizedPnl = $t07240673044._6
1611- let marginToTrader = $t07240673044._7
1612- let quoteAssetReserveAfter = $t07240673044._8
1613- let baseAssetReserveAfter = $t07240673044._9
1614- let totalPositionSizeAfter = $t07240673044._10
1615- let openInterestNotionalAfter = $t07240673044._11
1616- let totalLongAfter = $t07240673044._12
1617- let totalShortAfter = $t07240673044._13
1618- let totalLongOpenInterestAfter = $t07240673044._14
1619- let totalShortOpenInterestAfter = $t07240673044._15
1620- let liquidationPenalty = $t07240673044._16
1572+ let newPositionSize = $t07463375289._1
1573+ let newPositionMargin = $t07463375289._2
1574+ let newPositionOpenNotional = $t07463375289._3
1575+ let newPositionLstUpdCPF = $t07463375289._4
1576+ let positionBadDebt = $t07463375289._5
1577+ let realizedPnl = $t07463375289._6
1578+ let marginToTrader = $t07463375289._7
1579+ let quoteAssetReserveAfter = $t07463375289._8
1580+ let baseAssetReserveAfter = $t07463375289._9
1581+ let totalPositionSizeAfter = $t07463375289._10
1582+ let openInterestNotionalAfter = $t07463375289._11
1583+ let totalLongAfter = $t07463375289._12
1584+ let totalShortAfter = $t07463375289._13
1585+ let totalLongOpenInterestAfter = $t07463375289._14
1586+ let totalShortOpenInterestAfter = $t07463375289._15
1587+ let liquidationPenalty = $t07463375289._16
16211588 let feeToLiquidator = (liquidationPenalty / 2)
16221589 let feeToVault = (liquidationPenalty - feeToLiquidator)
16231590 let ammBalance = (cbalance() - liquidationPenalty)
16241591 let newAmmBalance = if ((0 > ammBalance))
16251592 then 0
16261593 else ammBalance
16271594 let lockBadDebt = if ((positionBadDebt > 0))
16281595 then {
16291596 let lockBadDebt = invoke(vaultAddress(), "exchangeFreeAndLocked", [(positionBadDebt + liquidationPenalty)], nil)
16301597 if ((lockBadDebt == lockBadDebt))
16311598 then nil
16321599 else throw("Strict value is not equal to itself.")
16331600 }
16341601 else nil
16351602 if ((lockBadDebt == lockBadDebt))
16361603 then {
16371604 let unstake = invoke(vaultAddress(), "withdrawLocked", [liquidationPenalty], nil)
16381605 if ((unstake == unstake))
16391606 then {
16401607 let depositInsurance = invoke(vaultAddress(), "addFree", nil, [AttachedPayment(quoteAsset(), feeToVault)])
16411608 if ((depositInsurance == depositInsurance))
16421609 then {
16431610 let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
16441611 if ((notifyNotional == notifyNotional))
16451612 then ((((if (isPartialLiquidation)
16461613 then updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF, lastTimestamp())
1647- else deletePosition(_trader)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1614+ else deletePosition(_trader, _direction)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter, totalLongOpenInterestAfter, totalShortOpenInterestAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
16481615 else throw("Strict value is not equal to itself.")
16491616 }
16501617 else throw("Strict value is not equal to itself.")
16511618 }
16521619 else throw("Strict value is not equal to itself.")
16531620 }
16541621 else throw("Strict value is not equal to itself.")
16551622 }
16561623 }
16571624 else throw("Strict value is not equal to itself.")
16581625 }
16591626
16601627
16611628
16621629 @Callable(i)
16631630 func payFunding () = {
16641631 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
16651632 if ((sync == sync))
16661633 then {
16671634 let fundingBlockTimestamp = nextFundingBlockTimestamp()
16681635 if (if (if ((fundingBlockTimestamp > lastTimestamp()))
16691636 then true
16701637 else !(initialized()))
16711638 then true
16721639 else paused())
16731640 then throw(((("Invalid funding block timestamp: " + toString(lastTimestamp())) + " < ") + toString(fundingBlockTimestamp)))
16741641 else {
16751642 let underlyingPrice = getOraclePrice()
1676- let $t07503175093 = getFunding()
1677- let shortPremiumFraction = $t07503175093._1
1678- let longPremiumFraction = $t07503175093._2
1679- updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
1643+ let $t07741477492 = getFunding()
1644+ let shortPremiumFraction = $t07741477492._1
1645+ let longPremiumFraction = $t07741477492._2
1646+ let premiumToVault = $t07741477492._3
1647+ let doPayFundingToVault = if ((premiumToVault > 0))
1648+ then {
1649+ let doPayFundingToVault = invoke(vaultAddress(), "exchangeFreeAndLocked", [-(premiumToVault)], nil)
1650+ if ((doPayFundingToVault == doPayFundingToVault))
1651+ then nil
1652+ else throw("Strict value is not equal to itself.")
1653+ }
1654+ else nil
1655+ if ((doPayFundingToVault == doPayFundingToVault))
1656+ then updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
1657+ else throw("Strict value is not equal to itself.")
16801658 }
16811659 }
16821660 else throw("Strict value is not equal to itself.")
16831661 }
16841662
16851663
16861664
16871665 @Callable(i)
16881666 func syncTerminalPriceToOracle () = {
16891667 let _qtAstR = qtAstR()
16901668 let _bsAstR = bsAstR()
1691- let $t07552575891 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR)
1692- let newQuoteAssetWeight = $t07552575891._1
1693- let newBaseAssetWeight = $t07552575891._2
1694- let marginToVault = $t07552575891._3
1669+ let $t07854578911 = getSyncTerminalPrice(getOraclePrice(), _qtAstR, _bsAstR)
1670+ let newQuoteAssetWeight = $t07854578911._1
1671+ let newBaseAssetWeight = $t07854578911._2
1672+ let marginToVault = $t07854578911._3
16951673 let marginToVaultAdj = if (if ((0 > marginToVault))
16961674 then (abs(marginToVault) > cbalance())
16971675 else false)
16981676 then -(cbalance())
16991677 else marginToVault
17001678 let doExchangePnL = if ((marginToVaultAdj != 0))
17011679 then {
17021680 let doExchangePnL = invoke(vaultAddress(), "exchangeFreeAndLocked", [marginToVaultAdj], nil)
17031681 if ((doExchangePnL == doExchangePnL))
17041682 then nil
17051683 else throw("Strict value is not equal to itself.")
17061684 }
17071685 else nil
17081686 if ((doExchangePnL == doExchangePnL))
1709- then ((updateBalance((cbalance() + marginToVaultAdj)) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight)) ++ appendTwap(divd(muld(_qtAstR, newQuoteAssetWeight), muld(_bsAstR, newBaseAssetWeight))))
1687+ then (updateBalance((cbalance() + marginToVaultAdj)) ++ updateAmmWeights(newQuoteAssetWeight, newBaseAssetWeight))
17101688 else throw("Strict value is not equal to itself.")
17111689 }
17121690
17131691
17141692
17151693 @Callable(i)
17161694 func ensureCalledOnce () = if ((i.caller != this))
17171695 then throw("Invalid saveCurrentTxId parameters")
17181696 else {
1697+ let txId = toBase58String(i.transactionId)
17191698 let lastTx = valueOrElse(getString(this, k_lastTx), "")
1720- if ((lastTx != toBase58String(i.transactionId)))
1721- then [StringEntry(k_lastTx, lastTx)]
1699+ if ((lastTx != txId))
1700+ then [StringEntry(k_lastTx, txId)]
17221701 else throw("Can not call vAMM methods twice in one tx")
17231702 }
17241703
17251704
17261705
17271706 @Callable(i)
1728-func view_calcRemainMarginWithFundingPayment (_trader) = {
1707+func migratePosition (_trader) = {
1708+ let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader))
1709+ if (if (isDefined(positionSizeOpt))
1710+ then isDefined(addressFromString(_trader))
1711+ else false)
1712+ then {
1713+ let pSize = getIntegerValue(this, toCompositeKey(k_positionSize, _trader))
1714+ let pMargin = getIntegerValue(this, toCompositeKey(k_positionMargin, _trader))
1715+ let pNotional = getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader))
1716+ let pFraction = getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader))
1717+ let pTimestamp = valueOrElse(getInteger(this, toCompositeKey(k_positionLastUpdatedTimestamp, _trader)), lastBlock.timestamp)
1718+ let pFee = valueOrElse(getInteger(this, toCompositeKey(k_positionFee, _trader)), fee())
1719+ let pSequence = getIntegerValue(this, toCompositeKey(k_positionSequence, _trader))
1720+ let pDirection = getDirection(pSize)
1721+ let positionKey = ((_trader + "_") + toString(pDirection))
1722+[DeleteEntry(toCompositeKey(k_positionSize, _trader)), DeleteEntry(toCompositeKey(k_positionMargin, _trader)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _trader)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)), DeleteEntry(toCompositeKey(k_positionLastUpdatedTimestamp, _trader)), DeleteEntry(toCompositeKey(k_positionFee, _trader)), DeleteEntry(toCompositeKey(k_positionSequence, _trader)), IntegerEntry(toCompositeKey(k_positionSize, positionKey), pSize), IntegerEntry(toCompositeKey(k_positionMargin, positionKey), pMargin), IntegerEntry(toCompositeKey(k_positionOpenNotional, positionKey), pNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, positionKey), pFraction), IntegerEntry(toCompositeKey(k_positionLastUpdatedTimestamp, positionKey), pTimestamp), IntegerEntry(toCompositeKey(k_positionFee, positionKey), pFee), IntegerEntry(toCompositeKey(k_positionSequence, positionKey), pSequence)]
1723+ }
1724+ else throw(("Nothing to migrate for " + _trader))
1725+ }
1726+
1727+
1728+
1729+@Callable(i)
1730+func view_calcRemainMarginWithFundingPayment (_trader,_direction) = {
17291731 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
17301732 if ((sync == sync))
17311733 then {
1732- let $t07705077174 = getPosition(_trader)
1733- let positionSize = $t07705077174._1
1734- let positionMargin = $t07705077174._2
1735- let pon = $t07705077174._3
1736- let positionLstUpdCPF = $t07705077174._4
1737- let positionTimestamp = $t07705077174._5
1738- let $t07717777278 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1739- let positionNotional = $t07717777278._1
1740- let unrealizedPnl = $t07717777278._2
1741- let $t07728177505 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLstUpdCPF, positionTimestamp, unrealizedPnl)
1742- let remainMargin = $t07728177505._1
1743- let badDebt = $t07728177505._2
1744- let fundingPayment = $t07728177505._3
1745- let rolloverFee = $t07728177505._4
1746- throw(((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)) + s(rolloverFee)))
1734+ let $t08260282738 = getPosition(_trader, _direction)
1735+ let positionSize = $t08260282738._1
1736+ let positionMargin = $t08260282738._2
1737+ let pon = $t08260282738._3
1738+ let positionLstUpdCPF = $t08260282738._4
1739+ let positionTimestamp = $t08260282738._5
1740+ let $t08274182854 = getPositionNotionalAndUnrealizedPnl(_trader, _direction, PNL_OPTION_SPOT)
1741+ let positionNotional = $t08274182854._1
1742+ let unrealizedPnl = $t08274182854._2
1743+ let $t08285783081 = calcRemainMarginWithFundingPaymentAndRolloverFee(positionSize, positionMargin, positionLstUpdCPF, positionTimestamp, unrealizedPnl)
1744+ let remainMargin = $t08285783081._1
1745+ let badDebt = $t08285783081._2
1746+ let fundingPayment = $t08285783081._3
1747+ let rolloverFee = $t08285783081._4
1748+ throw(((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader, _direction))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)) + s(rolloverFee)))
17471749 }
17481750 else throw("Strict value is not equal to itself.")
17491751 }
17501752
17511753
17521754
17531755 @Callable(i)
17541756 func view_getPegAdjustCost (_price) = {
17551757 let _qtAstR = qtAstR()
17561758 let _bsAstR = bsAstR()
17571759 let result = getSyncTerminalPrice(_price, _qtAstR, _bsAstR)
17581760 throw(toString(result._3))
17591761 }
17601762
17611763
17621764
17631765 @Callable(i)
17641766 func view_getTerminalAmmPrice () = {
1765- let $t07794178022 = getTerminalAmmState()
1766- let terminalQuoteAssetReserve = $t07794178022._1
1767- let terminalBaseAssetReserve = $t07794178022._2
1767+ let $t08381683897 = getTerminalAmmState()
1768+ let terminalQuoteAssetReserve = $t08381683897._1
1769+ let terminalBaseAssetReserve = $t08381683897._2
17681770 let price = divd(muld(terminalQuoteAssetReserve, qtAstW()), muld(terminalBaseAssetReserve, bsAstW()))
17691771 throw(toString(price))
17701772 }
17711773
17721774
17731775
17741776 @Callable(i)
17751777 func view_getFunding () = {
1776- let underlyingPrice = getOraclePrice()
1777- let $t07823778299 = getFunding()
1778- let shortPremiumFraction = $t07823778299._1
1779- let longPremiumFraction = $t07823778299._2
1780- let longFunding = divd(longPremiumFraction, underlyingPrice)
1781- let shortFunding = divd(shortPremiumFraction, underlyingPrice)
1782- throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOraclePrice())))
1778+ let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
1779+ if ((sync == sync))
1780+ then {
1781+ let underlyingPrice = getOraclePrice()
1782+ let $t08445684534 = getFunding()
1783+ let shortPremiumFraction = $t08445684534._1
1784+ let longPremiumFraction = $t08445684534._2
1785+ let premiumToVault = $t08445684534._3
1786+ let longFunding = divd(longPremiumFraction, underlyingPrice)
1787+ let shortFunding = divd(shortPremiumFraction, underlyingPrice)
1788+ throw(((((s(longFunding) + s(shortFunding)) + s(getSpotPrice())) + s(getOraclePrice())) + s(premiumToVault)))
1789+ }
1790+ else throw("Strict value is not equal to itself.")
17831791 }
17841792
17851793
17861794
17871795 @Callable(i)
17881796 func computeSpotPrice () = {
17891797 let sync = invoke(this, "syncTerminalPriceToOracle", nil, nil)
17901798 if ((sync == sync))
17911799 then {
17921800 let result = getSpotPrice()
17931801 $Tuple2(nil, result)
17941802 }
17951803 else throw("Strict value is not equal to itself.")
17961804 }
17971805
17981806
17991807
18001808 @Callable(i)
18011809 func computeFeeForTraderWithArtifact (_trader,_artifactId) = {
18021810 let result = getForTraderWithArtifact(_trader, _artifactId)
18031811 $Tuple2(nil, result)
18041812 }
18051813
18061814
18071815 @Verifier(tx)
18081816 func verify () = {
18091817 let coordinatorStr = getString(this, k_coordinatorAddress)
18101818 if (isDefined(coordinatorStr))
18111819 then {
18121820 let admin = getString(addressFromStringValue(value(coordinatorStr)), k_admin_address)
18131821 if (isDefined(admin))
18141822 then valueOrElse(getBoolean(addressFromStringValue(value(admin)), ((("status_" + toString(this)) + "_") + toBase58String(tx.id))), false)
18151823 else throw("unable to verify: admin not set in coordinator")
18161824 }
18171825 else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
18181826 }
18191827

github/deemru/w8io/026f985 
305.29 ms