tx · Ce4SBkrUZwbiYwPfeJxvdQUbbU2J3DTeMiCyzrTN75qu

3MuCofTkjmv397dEuRXE3pZxTb4zDWa96uo:  -0.06500000 Waves

2022.11.10 12:50 [2310895] smart account 3MuCofTkjmv397dEuRXE3pZxTb4zDWa96uo > SELF 0.00000000 Waves

{ "type": 13, "id": "Ce4SBkrUZwbiYwPfeJxvdQUbbU2J3DTeMiCyzrTN75qu", "fee": 6500000, "feeAssetId": null, "timestamp": 1668073844926, "version": 2, "chainId": 84, "sender": "3MuCofTkjmv397dEuRXE3pZxTb4zDWa96uo", "senderPublicKey": "HGKkqEdKKPVXHMq25FyB6nm1kyvrixu1a8Av6wc9t5CG", "proofs": [ "u2XdpAwtg8kuA36XVdc8S3sTZhA4cWoRbJ1tPYKZyVjMUCfcpKZEhTSYJdzMA6LY9WAQrCeNAoxGD5y5jeRg6t8" ], "script": "base64:BgJ2CAISABIAEgMKAQESAwoBARILCgkBAQEBAQEBAQESEAoOAQEBAQEBAQgICAEBAQESAwoBARIFCgMBAQESBgoEAQEBCBIAEgMKAQESABIDCgEIEgASBAoCCAESAwoBARIAEgMKAQgSAwoBCBIDCgEBEgASAwoBCKEBAAlrX29yYV9rZXkCCWtfb3JhX2tleQAPa19vcmFfYmxvY2tfa2V5Ag9rX29yYV9ibG9ja19rZXkABWtfb3JhAgVrX29yYQAJa19iYWxhbmNlAglrX2JhbGFuY2UADmtfcG9zaXRpb25TaXplAg5rX3Bvc2l0aW9uU2l6ZQAQa19wb3NpdGlvbk1hcmdpbgIQa19wb3NpdGlvbk1hcmdpbgAWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAIWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAAua19wb3NpdGlvbkxhc3RVcGRhdGVkQ3VtdWxhdGl2ZVByZW1pdW1GcmFjdGlvbgISa19wb3NpdGlvbkZyYWN0aW9uABRrX3Bvc2l0aW9uQ2xvc2VkRGF0ZQIUa19wb3NpdGlvbkNsb3NlZERhdGUAD2tfc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N0aW9uBQ91bmRlcmx5aW5nUHJpY2UEDHNob3J0RnVuZGluZwkBBGRpdmQCBRRzaG9ydFByZW1pdW1GcmFjdGlvbgUPdW5kZXJseWluZ1ByaWNlCQACAQkArAICCQCsAgIJAKwCAgkBAXMBBQtsb25nRnVuZGluZwkBAXMBBQxzaG9ydEZ1bmRpbmcJAQFzAQkBEGdldFR3YXBTcG90UHJpY2UACQEBcwEJARJnZXRPcmFjbGVUd2FwUHJpY2UAAWkBGHZpZXdfZ2V0Qm9ycm93ZWRCeVRyYWRlcgEHX3RyYWRlcgQNJHQwNzI4NzA3MjkyNAkBE2dldEJvcnJvd2VkQnlUcmFkZXIBBQdfdHJhZGVyBAhib3Jyb3dlZAgFDSR0MDcyODcwNzI5MjQCXzEEB2Fzc2V0SWQIBQ0kdDA3Mjg3MDcyOTI0Al8yCQACAQkArAICCQEBcwEFCGJvcnJvd2VkBQdhc3NldElkAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAkBDmFkbWluUHVibGljS2V5AMmgpy8=", "height": 2310895, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4MarxRNPpAjvyt2fnpkfkkBtAGFVk72DFqQezVuHpFoC Next: none Diff:
OldNewDifferences
1818 let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction"
1919
2020 let k_positionClosedDate = "k_positionClosedDate"
21+
22+let k_positionAsset = "k_positionAsset"
2123
2224 let k_initialized = "k_initialized"
2325
9799
98100 let k_manager_address = "k_manager_address"
99101
102+let k_collateral_address = "k_collateral_address"
103+
104+let k_exchange_address = "k_exchange_address"
105+
106+let k_nft_manager_address = "k_nft_manager_address"
107+
108+let k_trader_market_asset_collateral = "k_trader_market_asset_collateral"
109+
110+func toCompositeKey (_key,_address) = ((_key + "_") + _address)
111+
112+
100113 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
101114
102115
129142
130143 func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set")
131144
145+
146+func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set")
147+
148+
149+func collateralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_collateral_address)), "Collateral Manager not set")
150+
151+
152+func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_exchange_address), "No swap address")), "Invalid swap address")
153+
154+
155+let k_whitelist_asset = "k_whitelist_asset"
156+
157+func isWhitelistAsset (_assetId) = valueOrElse(getBoolean(collateralAddress(), toCompositeKey(k_whitelist_asset, _assetId)), false)
158+
159+
160+let k_token_param = "k_token_param"
161+
162+let k_token_type = "k_token_type"
163+
164+let FEE_REDUCTION_TOKEN_TYPE = "fee_reduction"
132165
133166 let DIR_LONG = 1
134167
169202 else _y
170203
171204
172-func toCompositeKey (_key,_address) = ((_key + "_") + _address)
173-
174-
175205 func listToStr (_list) = {
176206 func _join (accumulator,val) = ((accumulator + val) + ",")
177207
206236
207237
208238 func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
239+
240+
241+func strA (_address,_key) = {
242+ let val = valueOrErrorMessage(getString(_address, _key), ("No value for key " + _key))
243+ val
244+ }
245+
246+
247+func intA (_address,_key) = {
248+ let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key))
249+ val
250+ }
209251
210252
211253 func cbalance () = int(k_balance)
309351 }
310352
311353
354+func getPositionAsset (_trader) = {
355+ let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader))
356+ match positionAssetOpt {
357+ case positionAsset: String =>
358+ positionAsset
359+ case _ =>
360+ toBase58String(quoteAsset())
361+ }
362+ }
363+
364+
312365 func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0))
313366 then throw("No open position")
314367 else true
347400 let amountBaseAssetBought = if (_isAdd)
348401 then amountBaseAssetBoughtAbs
349402 else -(amountBaseAssetBoughtAbs)
350- let $t01301913212 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
351- let quoteAssetReserveAfter1 = $t01301913212._1
352- let baseAssetReserveAfter1 = $t01301913212._2
353- let totalPositionSizeAfter1 = $t01301913212._3
354- let cumulativeNotionalAfter1 = $t01301913212._4
403+ let $t01497415167 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
404+ let quoteAssetReserveAfter1 = $t01497415167._1
405+ let baseAssetReserveAfter1 = $t01497415167._2
406+ let totalPositionSizeAfter1 = $t01497415167._3
407+ let cumulativeNotionalAfter1 = $t01497415167._4
355408 let priceBefore = divd(_qtAstR, _bsAstR)
356409 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
357410 let priceDiff = abs((priceBefore - marketPrice))
371424 }
372425 else 0
373426 let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin)
374- let $t01470314830 = if ((0 > signedMargin))
427+ let $t01665816785 = if ((0 > signedMargin))
375428 then $Tuple2(0, abs(signedMargin))
376429 else $Tuple2(abs(signedMargin), 0)
377- let remainMargin = $t01470314830._1
378- let badDebt = $t01470314830._2
430+ let remainMargin = $t01665816785._1
431+ let badDebt = $t01665816785._2
379432 $Tuple3(remainMargin, badDebt, fundingPayment)
380433 }
381434
392445 let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter)
393446 let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve))
394447 let maxPriceImpactValue = maxPriceImpact()
395- let $t01580716000 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
396- let quoteAssetReserveAfter1 = $t01580716000._1
397- let baseAssetReserveAfter1 = $t01580716000._2
398- let totalPositionSizeAfter1 = $t01580716000._3
399- let cumulativeNotionalAfter1 = $t01580716000._4
448+ let $t01776217955 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
449+ let quoteAssetReserveAfter1 = $t01776217955._1
450+ let baseAssetReserveAfter1 = $t01776217955._2
451+ let totalPositionSizeAfter1 = $t01776217955._3
452+ let cumulativeNotionalAfter1 = $t01776217955._4
400453 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
401454 let priceDiff = abs((priceBefore - marketPrice))
402455 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
455508 let isShort = (0 > _positionSize)
456509 let positionNotional = if ((_option == PNL_OPTION_SPOT))
457510 then {
458- let $t01921819389 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve)
459- let outPositionNotional = $t01921819389._1
460- let x1 = $t01921819389._2
461- let x2 = $t01921819389._3
462- let x3 = $t01921819389._4
511+ let $t02117321344 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve)
512+ let outPositionNotional = $t02117321344._1
513+ let x1 = $t02117321344._2
514+ let x2 = $t02117321344._3
515+ let x3 = $t02117321344._4
463516 outPositionNotional
464517 }
465518 else muld(positionSizeAbs, getOracleTwapPrice())
480533
481534
482535 func getPositionNotionalAndUnrealizedPnl (_trader,_option) = {
483- let $t02070620834 = getPosition(_trader)
484- let positionSize = $t02070620834._1
485- let positionMargin = $t02070620834._2
486- let positionOpenNotional = $t02070620834._3
487- let positionLstUpdCPF = $t02070620834._4
536+ let $t02266122789 = getPosition(_trader)
537+ let positionSize = $t02266122789._1
538+ let positionMargin = $t02266122789._2
539+ let positionOpenNotional = $t02266122789._3
540+ let positionLstUpdCPF = $t02266122789._4
488541 getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), bsAstR(), _option)
489542 }
490543
493546
494547
495548 func getMarginRatioByOption (_trader,_option) = {
496- let $t02131521426 = getPosition(_trader)
497- let positionSize = $t02131521426._1
498- let positionMargin = $t02131521426._2
499- let pon = $t02131521426._3
500- let positionLstUpdCPF = $t02131521426._4
501- let $t02143221525 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
502- let positionNotional = $t02143221525._1
503- let unrealizedPnl = $t02143221525._2
504- let $t02153021696 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
505- let remainMargin = $t02153021696._1
506- let badDebt = $t02153021696._2
549+ let $t02327023381 = getPosition(_trader)
550+ let positionSize = $t02327023381._1
551+ let positionMargin = $t02327023381._2
552+ let pon = $t02327023381._3
553+ let positionLstUpdCPF = $t02327023381._4
554+ let $t02338723480 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
555+ let positionNotional = $t02338723480._1
556+ let unrealizedPnl = $t02338723480._2
557+ let $t02348523651 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
558+ let remainMargin = $t02348523651._1
559+ let badDebt = $t02348523651._2
507560 calcMarginRatio(remainMargin, badDebt, positionNotional)
508561 }
509562
528581
529582
530583 func internalClosePosition (_trader,_checkMaxPriceImpact) = {
531- let $t02292923057 = getPosition(_trader)
532- let positionSize = $t02292923057._1
533- let positionMargin = $t02292923057._2
534- let positionOpenNotional = $t02292923057._3
535- let positionLstUpdCPF = $t02292923057._4
584+ let $t02488425012 = getPosition(_trader)
585+ let positionSize = $t02488425012._1
586+ let positionMargin = $t02488425012._2
587+ let positionOpenNotional = $t02488425012._3
588+ let positionLstUpdCPF = $t02488425012._4
536589 let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2
537- let $t02315223320 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
538- let remainMargin = $t02315223320._1
539- let badDebt = $t02315223320._2
590+ let $t02510725275 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
591+ let remainMargin = $t02510725275._1
592+ let badDebt = $t02510725275._2
540593 let exchangedPositionSize = -(positionSize)
541594 let realizedPnl = unrealizedPnl
542595 let marginToVault = -(remainMargin)
543- let $t02344723758 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
544- let exchangedQuoteAssetAmount = $t02344723758._1
545- let quoteAssetReserveAfter = $t02344723758._2
546- let baseAssetReserveAfter = $t02344723758._3
547- let totalPositionSizeAfter = $t02344723758._4
548- let cumulativeNotionalAfter = $t02344723758._5
549- let totalLongAfter = $t02344723758._6
550- let totalShortAfter = $t02344723758._7
596+ let $t02540225713 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
597+ let exchangedQuoteAssetAmount = $t02540225713._1
598+ let quoteAssetReserveAfter = $t02540225713._2
599+ let baseAssetReserveAfter = $t02540225713._3
600+ let totalPositionSizeAfter = $t02540225713._4
601+ let cumulativeNotionalAfter = $t02540225713._5
602+ let totalLongAfter = $t02540225713._6
603+ let totalShortAfter = $t02540225713._7
551604 let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional)
552605 $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter)
553606 }
623676 }
624677
625678
679+func getAdjustedFee (i) = {
680+ let baseFee = fee()
681+ let $t02937629984 = if ((size(i.payments) > 1))
682+ then {
683+ let artifactId = toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid attached artifact"))
684+ let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, artifactId))
685+ if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE))
686+ then {
687+ let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, artifactId))
688+ let adjustedFee = muld(baseFee, reduction)
689+ $Tuple2(adjustedFee, true)
690+ }
691+ else throw("Invalid attached artifact")
692+ }
693+ else $Tuple2(baseFee, false)
694+ let adjustedFee = $t02937629984._1
695+ let burnArtifact = $t02937629984._2
696+ $Tuple2(adjustedFee, burnArtifact)
697+ }
698+
699+
626700 func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread)]
627701
628702
629703 func updateFunding (_nextFundingBlock,_latestLongCumulativePremiumFraction,_latestShortCumulativePremiumFraction,_longFundingRate,_shortFundingRate) = [IntegerEntry(k_nextFundingBlock, _nextFundingBlock), IntegerEntry(k_latestLongCumulativePremiumFraction, _latestLongCumulativePremiumFraction), IntegerEntry(k_latestShortCumulativePremiumFraction, _latestShortCumulativePremiumFraction), IntegerEntry(k_longFundingRate, _longFundingRate), IntegerEntry(k_shortFundingRate, _shortFundingRate)]
704+
705+
706+func updatePositionAsset (_address,_assetId) = [StringEntry(toCompositeKey(k_positionAsset, _address), _assetId)]
630707
631708
632709 func updatePosition (_address,_size,_margin,_openNotional,_latestCumulativePremiumFraction) = [IntegerEntry(toCompositeKey(k_positionSize, _address), _size), IntegerEntry(toCompositeKey(k_positionMargin, _address), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, _address), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address), _latestCumulativePremiumFraction)]
668745 else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_cumulativeNotional, _cumulativeNotionalAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize)]) ++ appendTwap(divd(_qtAstR, _bsAstR)))
669746
670747
671-func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)]
748+func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)]
672749
673750
674751 func withdraw (_address,_amount) = {
685762
686763
687764 func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())]
765+
766+
767+func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact)
768+ then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)]
769+ else nil
770+
771+
772+func isSameAssetOrNoPosition (_trader,_assetId) = {
773+ let oldPositionSize = getPosition(_trader)._1
774+ if ((oldPositionSize == 0))
775+ then true
776+ else (getPositionAsset(_trader) == _assetId)
777+ }
778+
779+
780+func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId)
781+
782+
783+func getBorrowedByTraderInMarketKey (_amm,_assetId,_trader) = ((((((k_trader_market_asset_collateral + "_") + _amm) + "_") + _assetId) + "_") + _trader)
784+
785+
786+func getBorrowedByTrader (_trader) = {
787+ let positionAsset = getPositionAsset(_trader)
788+ if ((positionAsset == toBase58String(quoteAsset())))
789+ then $Tuple2(0, positionAsset)
790+ else {
791+ let key = getBorrowedByTraderInMarketKey(toString(this), positionAsset, _trader)
792+ let borrow = valueOrElse(getInteger(collateralAddress(), key), 0)
793+ $Tuple2(borrow, positionAsset)
794+ }
795+ }
688796
689797
690798 @Callable(i)
792900 else paused())
793901 then throw("Invalid decreasePosition parameters")
794902 else {
795- let $t03753437686 = getPosition(toString(i.caller))
796- let oldPositionSize = $t03753437686._1
797- let oldPositionMargin = $t03753437686._2
798- let oldPositionOpenNotional = $t03753437686._3
799- let oldPositionLstUpdCPF = $t03753437686._4
903+ let $t04149241644 = getPosition(toString(i.caller))
904+ let oldPositionSize = $t04149241644._1
905+ let oldPositionMargin = $t04149241644._2
906+ let oldPositionOpenNotional = $t04149241644._3
907+ let oldPositionLstUpdCPF = $t04149241644._4
800908 let _direction = if ((oldPositionSize > 0))
801909 then DIR_SHORT
802910 else DIR_LONG
803911 let isAdd = (_direction == DIR_LONG)
804912 let openNotional = muld(_amount, _leverage)
805- let $t03785937975 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
806- let oldPositionNotional = $t03785937975._1
807- let unrealizedPnl = $t03785937975._2
808- let $t03798140530 = if ((oldPositionNotional > openNotional))
913+ let $t04181741933 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
914+ let oldPositionNotional = $t04181741933._1
915+ let unrealizedPnl = $t04181741933._2
916+ let $t04193944488 = if ((oldPositionNotional > openNotional))
809917 then {
810- let $t03835838577 = swapInput(isAdd, openNotional)
811- let exchangedPositionSize = $t03835838577._1
812- let quoteAssetReserveAfter = $t03835838577._2
813- let baseAssetReserveAfter = $t03835838577._3
814- let totalPositionSizeAfter = $t03835838577._4
815- let cumulativeNotionalAfter = $t03835838577._5
918+ let $t04231642535 = swapInput(isAdd, openNotional)
919+ let exchangedPositionSize = $t04231642535._1
920+ let quoteAssetReserveAfter = $t04231642535._2
921+ let baseAssetReserveAfter = $t04231642535._3
922+ let totalPositionSizeAfter = $t04231642535._4
923+ let cumulativeNotionalAfter = $t04231642535._5
816924 let exchangedPositionSizeAbs = abs(exchangedPositionSize)
817925 if (if ((_minBaseAssetAmount != 0))
818926 then (_minBaseAssetAmount > exchangedPositionSizeAbs)
820928 then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount)))
821929 else {
822930 let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize))
823- let $t03901439259 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
824- let remainMargin = $t03901439259._1
825- let badDebt = $t03901439259._2
826- let fundingPayment = $t03901439259._3
931+ let $t04297243217 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
932+ let remainMargin = $t04297243217._1
933+ let badDebt = $t04297243217._2
934+ let fundingPayment = $t04297243217._3
827935 let exchangedQuoteAssetAmount = openNotional
828936 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
829937 let remainOpenNotional = if ((oldPositionSize > 0))
838946 }
839947 }
840948 else throw("Close position first")
841- let newPositionSize = $t03798140530._1
842- let newPositionRemainMargin = $t03798140530._2
843- let newPositionOpenNotional = $t03798140530._3
844- let newPositionLatestCPF = $t03798140530._4
845- let baseAssetReserveAfter = $t03798140530._5
846- let quoteAssetReserveAfter = $t03798140530._6
847- let totalPositionSizeAfter = $t03798140530._7
848- let cumulativeNotionalAfter = $t03798140530._8
849- let openInterestNotionalAfter = $t03798140530._9
850- let totalLongAfter = $t03798140530._10
851- let totalShortAfter = $t03798140530._11
949+ let newPositionSize = $t04193944488._1
950+ let newPositionRemainMargin = $t04193944488._2
951+ let newPositionOpenNotional = $t04193944488._3
952+ let newPositionLatestCPF = $t04193944488._4
953+ let baseAssetReserveAfter = $t04193944488._5
954+ let quoteAssetReserveAfter = $t04193944488._6
955+ let totalPositionSizeAfter = $t04193944488._7
956+ let cumulativeNotionalAfter = $t04193944488._8
957+ let openInterestNotionalAfter = $t04193944488._9
958+ let totalLongAfter = $t04193944488._10
959+ let totalShortAfter = $t04193944488._11
852960 let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil)
853961 if ((notifyNotional == notifyNotional))
854962 then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter))
859967
860968 @Callable(i)
861969 func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = {
970+ let _trader = toString(i.caller)
862971 let _rawAmount = i.payments[0].amount
863- if (if (if (if (if (if (if ((_direction != DIR_LONG))
972+ let _assetId = i.payments[0].assetId
973+ let _assetIdStr = toBase58String(value(_assetId))
974+ let isQuoteAsset = (_assetId == quoteAsset())
975+ let isCollateralAsset = isWhitelistAsset(_assetIdStr)
976+ if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
864977 then (_direction != DIR_SHORT)
865978 else false)
866979 then true
868981 then true
869982 else !(initialized()))
870983 then true
871- else (i.payments[0].assetId != quoteAsset()))
984+ else if (!(isQuoteAsset))
985+ then !(isCollateralAsset)
986+ else false)
987+ then true
988+ else !(isSameAssetOrNoPosition(_trader, _assetIdStr)))
872989 then true
873990 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
874991 then true
875992 else paused())
876993 then throw("Invalid increasePosition parameters")
877994 else {
878- let _trader = toString(i.caller)
879- let rawFeeAmount = muld(_rawAmount, fee())
880- let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), rawFeeAmount)])
881- if ((referrerFeeAny == referrerFeeAny))
995+ let baseFee = fee()
996+ let $t04585045901 = getAdjustedFee(i)
997+ let adjustedFee = $t04585045901._1
998+ let burnArtifact = $t04585045901._2
999+ let rawFeeAmount = muld(_rawAmount, adjustedFee)
1000+ let _amount = (_rawAmount - rawFeeAmount)
1001+ let distributeFeeAmount = if (isCollateralAsset)
8821002 then {
883- let referrerFee = match referrerFeeAny {
884- case x: Int =>
885- x
886- case _ =>
887- throw("Invalid referrerFee")
1003+ let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1004+ if ((doBorrow == doBorrow))
1005+ then {
1006+ let balanceBefore = assetBalance(this, quoteAsset())
1007+ if ((balanceBefore == balanceBefore))
1008+ then {
1009+ let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1010+ if ((doSwap == doSwap))
1011+ then {
1012+ let balanceAfter = assetBalance(this, quoteAsset())
1013+ if ((balanceAfter == balanceAfter))
1014+ then {
1015+ let exchangedAmount = (balanceAfter - balanceBefore)
1016+ if ((exchangedAmount == exchangedAmount))
1017+ then exchangedAmount
1018+ else throw("Strict value is not equal to itself.")
1019+ }
1020+ else throw("Strict value is not equal to itself.")
1021+ }
1022+ else throw("Strict value is not equal to itself.")
1023+ }
1024+ else throw("Strict value is not equal to itself.")
1025+ }
1026+ else throw("Strict value is not equal to itself.")
8881027 }
889- let _amount = (_rawAmount - rawFeeAmount)
890- let feeAmount = (rawFeeAmount - referrerFee)
891- let $t04205942199 = getPosition(_trader)
892- let oldPositionSize = $t04205942199._1
893- let oldPositionMargin = $t04205942199._2
894- let oldPositionOpenNotional = $t04205942199._3
895- let oldPositionLstUpdCPF = $t04205942199._4
896- let isNewPosition = (oldPositionSize == 0)
897- let isSameDirection = if ((oldPositionSize > 0))
898- then (_direction == DIR_LONG)
899- else (_direction == DIR_SHORT)
900- let expandExisting = if (!(isNewPosition))
901- then isSameDirection
902- else false
903- let isAdd = (_direction == DIR_LONG)
904- let $t04248845056 = if (if (isNewPosition)
905- then true
906- else expandExisting)
1028+ else rawFeeAmount
1029+ if ((distributeFeeAmount == distributeFeeAmount))
1030+ then {
1031+ let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1032+ if ((referrerFeeAny == referrerFeeAny))
9071033 then {
908- let openNotional = muld(_amount, _leverage)
909- let $t04291243118 = swapInput(isAdd, openNotional)
910- let amountBaseAssetBought = $t04291243118._1
911- let quoteAssetReserveAfter = $t04291243118._2
912- let baseAssetReserveAfter = $t04291243118._3
913- let totalPositionSizeAfter = $t04291243118._4
914- let cumulativeNotionalAfter = $t04291243118._5
915- if (if ((_minBaseAssetAmount != 0))
916- then (_minBaseAssetAmount > abs(amountBaseAssetBought))
917- else false)
918- then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
1034+ let referrerFee = match referrerFeeAny {
1035+ case x: Int =>
1036+ x
1037+ case _ =>
1038+ throw("Invalid referrerFee")
1039+ }
1040+ let feeAmount = (distributeFeeAmount - referrerFee)
1041+ let $t04721747357 = getPosition(_trader)
1042+ let oldPositionSize = $t04721747357._1
1043+ let oldPositionMargin = $t04721747357._2
1044+ let oldPositionOpenNotional = $t04721747357._3
1045+ let oldPositionLstUpdCPF = $t04721747357._4
1046+ let isNewPosition = (oldPositionSize == 0)
1047+ let isSameDirection = if ((oldPositionSize > 0))
1048+ then (_direction == DIR_LONG)
1049+ else (_direction == DIR_SHORT)
1050+ let expandExisting = if (!(isNewPosition))
1051+ then isSameDirection
1052+ else false
1053+ let isAdd = (_direction == DIR_LONG)
1054+ let $t04764650231 = if (if (isNewPosition)
1055+ then true
1056+ else expandExisting)
1057+ then {
1058+ let openNotional = muld(_amount, _leverage)
1059+ let $t04807048276 = swapInput(isAdd, openNotional)
1060+ let amountBaseAssetBought = $t04807048276._1
1061+ let quoteAssetReserveAfter = $t04807048276._2
1062+ let baseAssetReserveAfter = $t04807048276._3
1063+ let totalPositionSizeAfter = $t04807048276._4
1064+ let cumulativeNotionalAfter = $t04807048276._5
1065+ if (if ((_minBaseAssetAmount != 0))
1066+ then (_minBaseAssetAmount > abs(amountBaseAssetBought))
1067+ else false)
1068+ then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
1069+ else {
1070+ let newPositionSize = (oldPositionSize + amountBaseAssetBought)
1071+ let increaseMarginRequirement = divd(openNotional, _leverage)
1072+ let $t04865748896 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
1073+ let remainMargin = $t04865748896._1
1074+ let x1 = $t04865748896._2
1075+ let x2 = $t04865748896._3
1076+ if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
1077+ then throw("Over max spread limit")
1078+ else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
1079+ then abs(amountBaseAssetBought)
1080+ else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
1081+ then abs(amountBaseAssetBought)
1082+ else 0)))
1083+ }
1084+ }
9191085 else {
920- let newPositionSize = (oldPositionSize + amountBaseAssetBought)
921- let increaseMarginRequirement = divd(openNotional, _leverage)
922- let $t04349943738 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
923- let remainMargin = $t04349943738._1
924- let x1 = $t04349943738._2
925- let x2 = $t04349943738._3
926- if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
927- then throw("Over max spread limit")
928- else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
929- then abs(amountBaseAssetBought)
930- else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
931- then abs(amountBaseAssetBought)
932- else 0)))
1086+ let openNotional = muld(_amount, _leverage)
1087+ let $t04992450040 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1088+ let oldPositionNotional = $t04992450040._1
1089+ let unrealizedPnl = $t04992450040._2
1090+ if ((oldPositionNotional > openNotional))
1091+ then throw("Use decreasePosition to decrease position size")
1092+ else throw("Close position first")
9331093 }
934- }
935- else {
936- let openNotional = muld(_amount, _leverage)
937- let $t04474944865 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
938- let oldPositionNotional = $t04474944865._1
939- let unrealizedPnl = $t04474944865._2
940- if ((oldPositionNotional > openNotional))
941- then throw("Use decreasePosition to decrease position size")
942- else throw("Close position first")
943- }
944- let newPositionSize = $t04248845056._1
945- let newPositionRemainMargin = $t04248845056._2
946- let newPositionOpenNotional = $t04248845056._3
947- let newPositionLatestCPF = $t04248845056._4
948- let baseAssetReserveAfter = $t04248845056._5
949- let quoteAssetReserveAfter = $t04248845056._6
950- let totalPositionSizeAfter = $t04248845056._7
951- let cumulativeNotionalAfter = $t04248845056._8
952- let openInterestNotionalAfter = $t04248845056._9
953- let totalLongAfter = $t04248845056._10
954- let totalShortAfter = $t04248845056._11
955- let feeToStakers = (feeAmount / 2)
956- let feeToInsurance = (feeAmount - feeToStakers)
957- let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
958- if ((stake == stake))
959- then {
960- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
961- if ((depositInsurance == depositInsurance))
1094+ let newPositionSize = $t04764650231._1
1095+ let newPositionRemainMargin = $t04764650231._2
1096+ let newPositionOpenNotional = $t04764650231._3
1097+ let newPositionLatestCPF = $t04764650231._4
1098+ let baseAssetReserveAfter = $t04764650231._5
1099+ let quoteAssetReserveAfter = $t04764650231._6
1100+ let totalPositionSizeAfter = $t04764650231._7
1101+ let cumulativeNotionalAfter = $t04764650231._8
1102+ let openInterestNotionalAfter = $t04764650231._9
1103+ let totalLongAfter = $t04764650231._10
1104+ let totalShortAfter = $t04764650231._11
1105+ let feeToStakers = (feeAmount / 2)
1106+ let feeToInsurance = (feeAmount - feeToStakers)
1107+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
1108+ if ((stake == stake))
9621109 then {
963- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
964- if ((notifyFee == notifyFee))
1110+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1111+ if ((depositInsurance == depositInsurance))
9651112 then {
966- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
967- if ((notifyNotional == notifyNotional))
968- then (((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount)))
1113+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1114+ if ((notifyFee == notifyFee))
1115+ then {
1116+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1117+ if ((notifyNotional == notifyNotional))
1118+ then (((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
1119+ else throw("Strict value is not equal to itself.")
1120+ }
9691121 else throw("Strict value is not equal to itself.")
9701122 }
9711123 else throw("Strict value is not equal to itself.")
9821134
9831135 @Callable(i)
9841136 func addMargin () = {
1137+ let _trader = toString(i.caller)
9851138 let _rawAmount = i.payments[0].amount
986- if (if (if (if ((i.payments[0].assetId != quoteAsset()))
1139+ let _assetId = i.payments[0].assetId
1140+ let _assetIdStr = toBase58String(value(_assetId))
1141+ let isQuoteAsset = (_assetId == quoteAsset())
1142+ let isCollateralAsset = isWhitelistAsset(_assetIdStr)
1143+ if (if (if (if (if (if (!(isQuoteAsset))
1144+ then !(isCollateralAsset)
1145+ else false)
9871146 then true
9881147 else !(requireOpenPosition(toString(i.caller))))
1148+ then true
1149+ else !(isSameAsset(_trader, _assetIdStr)))
9891150 then true
9901151 else !(initialized()))
9911152 then true
9921153 else paused())
9931154 then throw("Invalid addMargin parameters")
9941155 else {
995- let _trader = toString(i.caller)
996- let rawFeeAmount = muld(_rawAmount, fee())
997- let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), rawFeeAmount)])
998- if ((referrerFeeAny == referrerFeeAny))
1156+ let $t05198752038 = getAdjustedFee(i)
1157+ let adjustedFee = $t05198752038._1
1158+ let burnArtifact = $t05198752038._2
1159+ let rawFeeAmount = muld(_rawAmount, adjustedFee)
1160+ let _amount = (_rawAmount - rawFeeAmount)
1161+ let distributeFeeAmount = if (isCollateralAsset)
9991162 then {
1000- let referrerFee = match referrerFeeAny {
1001- case x: Int =>
1002- x
1003- case _ =>
1004- throw("Invalid referrerFee")
1163+ let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1164+ if ((doBorrow == doBorrow))
1165+ then {
1166+ let balanceBefore = assetBalance(this, quoteAsset())
1167+ if ((balanceBefore == balanceBefore))
1168+ then {
1169+ let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1170+ if ((doSwap == doSwap))
1171+ then {
1172+ let balanceAfter = assetBalance(this, quoteAsset())
1173+ if ((balanceAfter == balanceAfter))
1174+ then {
1175+ let exchangedAmount = (balanceAfter - balanceBefore)
1176+ if ((exchangedAmount == exchangedAmount))
1177+ then exchangedAmount
1178+ else throw("Strict value is not equal to itself.")
1179+ }
1180+ else throw("Strict value is not equal to itself.")
1181+ }
1182+ else throw("Strict value is not equal to itself.")
1183+ }
1184+ else throw("Strict value is not equal to itself.")
1185+ }
1186+ else throw("Strict value is not equal to itself.")
10051187 }
1006- let feeAmount = (rawFeeAmount - referrerFee)
1007- let _amount = (_rawAmount - rawFeeAmount)
1008- let $t04690247042 = getPosition(_trader)
1009- let oldPositionSize = $t04690247042._1
1010- let oldPositionMargin = $t04690247042._2
1011- let oldPositionOpenNotional = $t04690247042._3
1012- let oldPositionLstUpdCPF = $t04690247042._4
1013- let feeToStakers = (feeAmount / 2)
1014- let feeToInsurance = (feeAmount - feeToStakers)
1015- let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
1016- if ((stake == stake))
1188+ else rawFeeAmount
1189+ if ((distributeFeeAmount == distributeFeeAmount))
1190+ then {
1191+ let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1192+ if ((referrerFeeAny == referrerFeeAny))
10171193 then {
1018- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1019- if ((depositInsurance == depositInsurance))
1194+ let referrerFee = match referrerFeeAny {
1195+ case x: Int =>
1196+ x
1197+ case _ =>
1198+ throw("Invalid referrerFee")
1199+ }
1200+ let feeAmount = (distributeFeeAmount - referrerFee)
1201+ let $t05333753477 = getPosition(_trader)
1202+ let oldPositionSize = $t05333753477._1
1203+ let oldPositionMargin = $t05333753477._2
1204+ let oldPositionOpenNotional = $t05333753477._3
1205+ let oldPositionLstUpdCPF = $t05333753477._4
1206+ let feeToStakers = (feeAmount / 2)
1207+ let feeToInsurance = (feeAmount - feeToStakers)
1208+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
1209+ if ((stake == stake))
10201210 then {
1021- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1022- if ((notifyFee == notifyFee))
1023- then ((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount)))
1211+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1212+ if ((depositInsurance == depositInsurance))
1213+ then {
1214+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1215+ if ((notifyFee == notifyFee))
1216+ then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
1217+ else throw("Strict value is not equal to itself.")
1218+ }
10241219 else throw("Strict value is not equal to itself.")
10251220 }
10261221 else throw("Strict value is not equal to itself.")
10341229
10351230
10361231 @Callable(i)
1037-func removeMargin (_amount) = if (if (if (if ((0 >= _amount))
1038- then true
1039- else !(requireOpenPosition(toString(i.caller))))
1040- then true
1041- else !(initialized()))
1042- then true
1043- else paused())
1044- then throw("Invalid removeMargin parameters")
1045- else {
1046- let $t04801848170 = getPosition(toString(i.caller))
1047- let oldPositionSize = $t04801848170._1
1048- let oldPositionMargin = $t04801848170._2
1049- let oldPositionOpenNotional = $t04801848170._3
1050- let oldPositionLstUpdCPF = $t04801848170._4
1051- let marginDelta = -(_amount)
1052- let $t04820748386 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
1053- let remainMargin = $t04820748386._1
1054- let badDebt = $t04820748386._2
1055- if ((badDebt != 0))
1056- then throw("Invalid removed margin amount")
1057- else {
1058- let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional)
1059- if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true)))
1060- then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
1061- else {
1062- let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil)
1063- if ((unstake == unstake))
1064- then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount)))
1065- else throw("Strict value is not equal to itself.")
1066- }
1067- }
1068- }
1232+func removeMargin (_amount) = {
1233+ let _trader = toString(i.caller)
1234+ if (if (if (if ((0 >= _amount))
1235+ then true
1236+ else !(requireOpenPosition(_trader)))
1237+ then true
1238+ else !(initialized()))
1239+ then true
1240+ else paused())
1241+ then throw("Invalid removeMargin parameters")
1242+ else {
1243+ let $t05452054660 = getPosition(_trader)
1244+ let oldPositionSize = $t05452054660._1
1245+ let oldPositionMargin = $t05452054660._2
1246+ let oldPositionOpenNotional = $t05452054660._3
1247+ let oldPositionLstUpdCPF = $t05452054660._4
1248+ let marginDelta = -(_amount)
1249+ let $t05469754876 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
1250+ let remainMargin = $t05469754876._1
1251+ let badDebt = $t05469754876._2
1252+ if ((badDebt != 0))
1253+ then throw("Invalid removed margin amount")
1254+ else {
1255+ let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional)
1256+ if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true)))
1257+ then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
1258+ else {
1259+ let quoteAssetStr = toBase58String(quoteAsset())
1260+ let $t05532055374 = getBorrowedByTrader(_trader)
1261+ let borrowed = $t05532055374._1
1262+ let assetId = $t05532055374._2
1263+ let toRepay = if ((_amount > borrowed))
1264+ then borrowed
1265+ else _amount
1266+ let toWithdraw = if ((borrowed > _amount))
1267+ then 0
1268+ else (_amount - borrowed)
1269+ let finalBorrow = (borrowed - toRepay)
1270+ let switchPositionToQuote = if ((finalBorrow > 0))
1271+ then nil
1272+ else updatePositionAsset(_trader, quoteAssetStr)
1273+ let doSanityCheck = if (((toRepay + toWithdraw) != _amount))
1274+ then throw(((((("toRepay=" + toString(toRepay)) + " + toWithdraw=") + toString(toWithdraw)) + " != ") + toString(_amount)))
1275+ else nil
1276+ if ((doSanityCheck == doSanityCheck))
1277+ then {
1278+ let doUnstake = invoke(managerAddress(), "withdraw", [quoteAssetStr, _amount], nil)
1279+ if ((doUnstake == doUnstake))
1280+ then {
1281+ let returnCollateralAction = if ((toRepay > 0))
1282+ then {
1283+ let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), toRepay)])
1284+ if ((doRepay == doRepay))
1285+ then [ScriptTransfer(i.caller, toRepay, fromBase58String(assetId))]
1286+ else throw("Strict value is not equal to itself.")
1287+ }
1288+ else nil
1289+ if ((returnCollateralAction == returnCollateralAction))
1290+ then (updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ (if ((toWithdraw > 0))
1291+ then withdraw(i.caller, toWithdraw)
1292+ else (((nil ++ updateBalance((cbalance() - _amount))) ++ switchPositionToQuote) ++ returnCollateralAction)))
1293+ else throw("Strict value is not equal to itself.")
1294+ }
1295+ else throw("Strict value is not equal to itself.")
1296+ }
1297+ else throw("Strict value is not equal to itself.")
1298+ }
1299+ }
1300+ }
1301+ }
10691302
10701303
10711304
10721305 @Callable(i)
10731306 func closePosition () = {
1074- let caller = getActualCaller(i)
1075- let callerAddress = valueOrErrorMessage(addressFromString(caller), "Invalid caller")
1076- if (if (if (!(requireOpenPosition(caller)))
1307+ let _trader = getActualCaller(i)
1308+ let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller")
1309+ if (if (if (!(requireOpenPosition(_trader)))
10771310 then true
10781311 else !(initialized()))
10791312 then true
10801313 else paused())
10811314 then throw("Invalid closePosition parameters")
10821315 else {
1083- let $t04958049957 = internalClosePosition(caller, true)
1084- let x1 = $t04958049957._1
1085- let positionBadDebt = $t04958049957._2
1086- let realizedPnl = $t04958049957._3
1087- let marginToVault = $t04958049957._4
1088- let quoteAssetReserveAfter = $t04958049957._5
1089- let baseAssetReserveAfter = $t04958049957._6
1090- let totalPositionSizeAfter = $t04958049957._7
1091- let cumulativeNotionalAfter = $t04958049957._8
1092- let openInterestNotionalAfter = $t04958049957._9
1093- let x2 = $t04958049957._10
1094- let totalLongAfter = $t04958049957._11
1095- let totalShortAfter = $t04958049957._12
1316+ let $t05756657944 = internalClosePosition(_trader, true)
1317+ let x1 = $t05756657944._1
1318+ let positionBadDebt = $t05756657944._2
1319+ let realizedPnl = $t05756657944._3
1320+ let marginToVault = $t05756657944._4
1321+ let quoteAssetReserveAfter = $t05756657944._5
1322+ let baseAssetReserveAfter = $t05756657944._6
1323+ let totalPositionSizeAfter = $t05756657944._7
1324+ let cumulativeNotionalAfter = $t05756657944._8
1325+ let openInterestNotionalAfter = $t05756657944._9
1326+ let x2 = $t05756657944._10
1327+ let totalLongAfter = $t05756657944._11
1328+ let totalShortAfter = $t05756657944._12
10961329 if ((positionBadDebt > 0))
10971330 then throw("Unable to close position with bad debt")
10981331 else {
10991332 let withdrawAmount = abs(marginToVault)
11001333 let ammBalance = (cbalance() - withdrawAmount)
1101- let $t05016650308 = if ((0 > ammBalance))
1334+ let $t05815358295 = if ((0 > ammBalance))
11021335 then $Tuple2(0, abs(ammBalance))
11031336 else $Tuple2(ammBalance, 0)
1104- let ammNewBalance = $t05016650308._1
1105- let getFromInsurance = $t05016650308._2
1337+ let ammNewBalance = $t05815358295._1
1338+ let getFromInsurance = $t05815358295._2
11061339 let x = if ((getFromInsurance > 0))
11071340 then {
11081341 let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil)
11161349 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (withdrawAmount - getFromInsurance)], nil)
11171350 if ((unstake == unstake))
11181351 then {
1119- let notifyNotional = invoke(minerAddress(), "notifyNotional", [caller, 0], nil)
1120- if ((notifyNotional == notifyNotional))
1121- then (((deletePosition(caller) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(callerAddress, withdrawAmount)) ++ updateBalance(ammNewBalance))
1352+ let $t05879758851 = getBorrowedByTrader(_trader)
1353+ let borrowed = $t05879758851._1
1354+ let assetId = $t05879758851._2
1355+ let $t05886659783 = if ((borrowed > 0))
1356+ then if ((withdrawAmount >= borrowed))
1357+ then {
1358+ let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), borrowed)])
1359+ if ((doRepay == doRepay))
1360+ then $Tuple2([ScriptTransfer(_traderAddress, borrowed, fromBase58String(assetId))], (withdrawAmount - borrowed))
1361+ else throw("Strict value is not equal to itself.")
1362+ }
1363+ else {
1364+ let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], [AttachedPayment(quoteAsset(), withdrawAmount)])
1365+ if ((realizeAndClose == realizeAndClose))
1366+ then $Tuple2([ScriptTransfer(_traderAddress, withdrawAmount, fromBase58String(assetId))], 0)
1367+ else throw("Strict value is not equal to itself.")
1368+ }
1369+ else $Tuple2(nil, withdrawAmount)
1370+ if (($t05886659783 == $t05886659783))
1371+ then {
1372+ let quoteWithdrawAmount = $t05886659783._2
1373+ let sendCollateralAction = $t05886659783._1
1374+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1375+ if ((notifyNotional == notifyNotional))
1376+ then ((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ (if ((quoteWithdrawAmount > 0))
1377+ then withdraw(_traderAddress, quoteWithdrawAmount)
1378+ else ((nil ++ updateBalance(ammNewBalance)) ++ sendCollateralAction)))
1379+ else throw("Strict value is not equal to itself.")
1380+ }
11221381 else throw("Strict value is not equal to itself.")
11231382 }
11241383 else throw("Strict value is not equal to itself.")
11531412 then (DECIMAL_UNIT > partialLiquidationRatio())
11541413 else false)
11551414 then {
1156- let $t05237952529 = getPosition(_trader)
1157- let oldPositionSize = $t05237952529._1
1158- let oldPositionMargin = $t05237952529._2
1159- let oldPositionOpenNotional = $t05237952529._3
1160- let oldPositionLstUpdCPF = $t05237952529._4
1415+ let $t06148361633 = getPosition(_trader)
1416+ let oldPositionSize = $t06148361633._1
1417+ let oldPositionMargin = $t06148361633._2
1418+ let oldPositionOpenNotional = $t06148361633._3
1419+ let oldPositionLstUpdCPF = $t06148361633._4
11611420 let _direction = if ((oldPositionSize > 0))
11621421 then DIR_SHORT
11631422 else DIR_LONG
11641423 let isAdd = (_direction == DIR_LONG)
11651424 let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize)
1166- let $t05275452858 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1167- let oldPositionNotional = $t05275452858._1
1168- let unrealizedPnl = $t05275452858._2
1169- let $t05286653156 = swapInput(isAdd, exchangedQuoteAssetAmount)
1170- let exchangedPositionSize = $t05286653156._1
1171- let quoteAssetReserveAfter = $t05286653156._2
1172- let baseAssetReserveAfter = $t05286653156._3
1173- let totalPositionSizeAfter = $t05286653156._4
1174- let cumulativeNotionalAfter = $t05286653156._5
1175- let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize))
1176- let $t05326353496 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1177- let remainMargin = $t05326353496._1
1178- let badDebt = $t05326353496._2
1179- let fundingPayment = $t05326353496._3
1425+ let $t06185861962 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1426+ let oldPositionNotional = $t06185861962._1
1427+ let unrealizedPnl = $t06185861962._2
1428+ let $t06197062202 = swapInput(isAdd, exchangedQuoteAssetAmount)
1429+ let exchangedPositionSize = $t06197062202._1
1430+ let quoteAssetReserveAfter = $t06197062202._2
1431+ let baseAssetReserveAfter = $t06197062202._3
1432+ let totalPositionSizeAfter = $t06197062202._4
1433+ let cumulativeNotionalAfter = $t06197062202._5
1434+ let liquidationRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize))
1435+ let realizedPnl = muld(unrealizedPnl, liquidationRatio)
1436+ let $t06241362646 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1437+ let remainMargin = $t06241362646._1
1438+ let badDebt = $t06241362646._2
1439+ let fundingPayment = $t06241362646._3
11801440 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
11811441 let remainOpenNotional = if ((oldPositionSize > 0))
11821442 then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
11901450 let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize)
11911451 let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount)
11921452 let ammBalance = (cbalance() - liquidationPenalty)
1193- let $t05466954812 = if ((0 > ammBalance))
1453+ let $t06381963962 = if ((0 > ammBalance))
11941454 then $Tuple2(0, abs(ammBalance))
11951455 else $Tuple2(ammBalance, 0)
1196- let newAmmBalance = $t05466954812._1
1197- let takeFromInsurance = $t05466954812._2
1198- let x = if ((takeFromInsurance > 0))
1456+ let newAmmBalance = $t06381963962._1
1457+ let takeFromInsurance = $t06381963962._2
1458+ let $t06397064024 = getBorrowedByTrader(_trader)
1459+ let borrowed = $t06397064024._1
1460+ let assetId = $t06397064024._2
1461+ let doLiquidateCollateral = if ((borrowed > 0))
11991462 then {
1200- let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1201- if ((withdrawInsurance == withdrawInsurance))
1463+ let collateralToSell = muld(borrowed, liquidationRatio)
1464+ let realizeAndClose = invoke(collateralAddress(), "realizePartially", [_trader, assetId, collateralToSell], nil)
1465+ if ((realizeAndClose == realizeAndClose))
12021466 then nil
12031467 else throw("Strict value is not equal to itself.")
12041468 }
12051469 else nil
1206- if ((x == x))
1470+ if ((doLiquidateCollateral == doLiquidateCollateral))
12071471 then {
1208- let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil)
1209- if ((unstake == unstake))
1472+ let x = if ((takeFromInsurance > 0))
12101473 then {
1211- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1212- if ((depositInsurance == depositInsurance))
1474+ let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1475+ if ((withdrawInsurance == withdrawInsurance))
1476+ then nil
1477+ else throw("Strict value is not equal to itself.")
1478+ }
1479+ else nil
1480+ if ((x == x))
1481+ then {
1482+ let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil)
1483+ if ((unstake == unstake))
12131484 then {
1214- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1215- if ((notifyNotional == notifyNotional))
1216- then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1217- then abs(exchangedPositionSize)
1218- else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1219- then abs(exchangedPositionSize)
1220- else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1485+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1486+ if ((depositInsurance == depositInsurance))
1487+ then {
1488+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1489+ if ((notifyNotional == notifyNotional))
1490+ then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1491+ then abs(exchangedPositionSize)
1492+ else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1493+ then abs(exchangedPositionSize)
1494+ else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1495+ else throw("Strict value is not equal to itself.")
1496+ }
12211497 else throw("Strict value is not equal to itself.")
12221498 }
12231499 else throw("Strict value is not equal to itself.")
12271503 else throw("Strict value is not equal to itself.")
12281504 }
12291505 else {
1230- let $t05625956714 = internalClosePosition(_trader, false)
1231- let x1 = $t05625956714._1
1232- let badDebt = $t05625956714._2
1233- let x2 = $t05625956714._3
1234- let x3 = $t05625956714._4
1235- let quoteAssetReserveAfter = $t05625956714._5
1236- let baseAssetReserveAfter = $t05625956714._6
1237- let totalPositionSizeAfter = $t05625956714._7
1238- let cumulativeNotionalAfter = $t05625956714._8
1239- let openInterestNotionalAfter = $t05625956714._9
1240- let exchangedQuoteAssetAmount = $t05625956714._10
1241- let totalLongAfter = $t05625956714._11
1242- let totalShortAfter = $t05625956714._12
1506+ let $t06586666321 = internalClosePosition(_trader, false)
1507+ let x1 = $t06586666321._1
1508+ let badDebt = $t06586666321._2
1509+ let x2 = $t06586666321._3
1510+ let x3 = $t06586666321._4
1511+ let quoteAssetReserveAfter = $t06586666321._5
1512+ let baseAssetReserveAfter = $t06586666321._6
1513+ let totalPositionSizeAfter = $t06586666321._7
1514+ let cumulativeNotionalAfter = $t06586666321._8
1515+ let openInterestNotionalAfter = $t06586666321._9
1516+ let exchangedQuoteAssetAmount = $t06586666321._10
1517+ let totalLongAfter = $t06586666321._11
1518+ let totalShortAfter = $t06586666321._12
12431519 let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
12441520 let feeToLiquidator = (liquidationPenalty / 2)
12451521 let feeToInsurance = (liquidationPenalty - feeToLiquidator)
12461522 let ammBalance = (cbalance() - liquidationPenalty)
1247- let $t05712657269 = if ((0 > ammBalance))
1523+ let $t06673366876 = if ((0 > ammBalance))
12481524 then $Tuple2(0, abs(ammBalance))
12491525 else $Tuple2(ammBalance, 0)
1250- let newAmmBalance = $t05712657269._1
1251- let takeFromInsurance = $t05712657269._2
1252- let x = if ((takeFromInsurance > 0))
1526+ let newAmmBalance = $t06673366876._1
1527+ let takeFromInsurance = $t06673366876._2
1528+ let $t06688466938 = getBorrowedByTrader(_trader)
1529+ let borrowed = $t06688466938._1
1530+ let assetId = $t06688466938._2
1531+ let doLiquidateCollateral = if ((borrowed > 0))
12531532 then {
1254- let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1255- if ((withdrawInsurance == withdrawInsurance))
1533+ let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], nil)
1534+ if ((realizeAndClose == realizeAndClose))
12561535 then nil
12571536 else throw("Strict value is not equal to itself.")
12581537 }
12591538 else nil
1260- if ((x == x))
1539+ if ((doLiquidateCollateral == doLiquidateCollateral))
12611540 then {
1262- let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil)
1263- if ((unstake == unstake))
1541+ let x = if ((takeFromInsurance > 0))
12641542 then {
1265- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1266- if ((depositInsurance == depositInsurance))
1543+ let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1544+ if ((withdrawInsurance == withdrawInsurance))
1545+ then nil
1546+ else throw("Strict value is not equal to itself.")
1547+ }
1548+ else nil
1549+ if ((x == x))
1550+ then {
1551+ let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil)
1552+ if ((unstake == unstake))
12671553 then {
1268- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1269- if ((notifyNotional == notifyNotional))
1270- then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1554+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1555+ if ((depositInsurance == depositInsurance))
1556+ then {
1557+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1558+ if ((notifyNotional == notifyNotional))
1559+ then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1560+ else throw("Strict value is not equal to itself.")
1561+ }
12711562 else throw("Strict value is not equal to itself.")
12721563 }
12731564 else throw("Strict value is not equal to itself.")
12911582 then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp)))
12921583 else {
12931584 let underlyingPrice = getOracleTwapPrice()
1294- let $t05875558817 = getFunding()
1295- let shortPremiumFraction = $t05875558817._1
1296- let longPremiumFraction = $t05875558817._2
1585+ let $t06873668798 = getFunding()
1586+ let shortPremiumFraction = $t06873668798._1
1587+ let longPremiumFraction = $t06873668798._2
12971588 updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
12981589 }
12991590 }
13201611 else (0 > _price))
13211612 then throw("Invalid adjustPeg parameters")
13221613 else {
1323- let $t05980859894 = getPegAdjustCost(_price)
1324- let newQuoteAssetReserve = $t05980859894._1
1325- let pegChangeCost = $t05980859894._2
1614+ let $t06978969875 = getPegAdjustCost(_price)
1615+ let newQuoteAssetReserve = $t06978969875._1
1616+ let pegChangeCost = $t06978969875._2
13261617 if ((pegChangeCost == 0))
13271618 then throw("Nothing to adjust")
13281619 else if ((pegChangeCost > 0))
13451636 @Callable(i)
13461637 func migrateLiquidity () = {
13471638 let amount = cbalance()
1348- let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil)
1349- if ((unstake == unstake))
1639+ if ((amount > 0))
13501640 then {
1351- let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)])
1352- if ((stake == stake))
1353- then nil
1641+ let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil)
1642+ if ((unstake == unstake))
1643+ then {
1644+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)])
1645+ if ((stake == stake))
1646+ then nil
1647+ else throw("Strict value is not equal to itself.")
1648+ }
13541649 else throw("Strict value is not equal to itself.")
13551650 }
1356- else throw("Strict value is not equal to itself.")
1651+ else nil
13571652 }
13581653
13591654
13601655
13611656 @Callable(i)
13621657 func v_get (_trader) = {
1363- let $t06146361523 = internalClosePosition(_trader, false)
1364- let x1 = $t06146361523._1
1365- let x2 = $t06146361523._2
1366- let x3 = $t06146361523._3
1367- let x4 = $t06146361523._4
1658+ let $t07151671576 = internalClosePosition(_trader, false)
1659+ let x1 = $t07151671576._1
1660+ let x2 = $t07151671576._2
1661+ let x3 = $t07151671576._3
1662+ let x4 = $t07151671576._4
13681663 throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader))))
13691664 }
13701665
13721667
13731668 @Callable(i)
13741669 func view_calcRemainMarginWithFundingPayment (_trader) = {
1375- let $t06167061781 = getPosition(_trader)
1376- let positionSize = $t06167061781._1
1377- let positionMargin = $t06167061781._2
1378- let pon = $t06167061781._3
1379- let positionLstUpdCPF = $t06167061781._4
1380- let $t06178661887 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1381- let positionNotional = $t06178661887._1
1382- let unrealizedPnl = $t06178661887._2
1383- let $t06189262074 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1384- let remainMargin = $t06189262074._1
1385- let badDebt = $t06189262074._2
1386- let fundingPayment = $t06189262074._3
1670+ let $t07172371834 = getPosition(_trader)
1671+ let positionSize = $t07172371834._1
1672+ let positionMargin = $t07172371834._2
1673+ let pon = $t07172371834._3
1674+ let positionLstUpdCPF = $t07172371834._4
1675+ let $t07183971940 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1676+ let positionNotional = $t07183971940._1
1677+ let unrealizedPnl = $t07183971940._2
1678+ let $t07194572127 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1679+ let remainMargin = $t07194572127._1
1680+ let badDebt = $t07194572127._2
1681+ let fundingPayment = $t07194572127._3
13871682 throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)))
13881683 }
13891684
14001695 @Callable(i)
14011696 func view_getFunding () = {
14021697 let underlyingPrice = getOracleTwapPrice()
1403- let $t06246562527 = getFunding()
1404- let shortPremiumFraction = $t06246562527._1
1405- let longPremiumFraction = $t06246562527._2
1698+ let $t07251872580 = getFunding()
1699+ let shortPremiumFraction = $t07251872580._1
1700+ let longPremiumFraction = $t07251872580._2
14061701 let longFunding = divd(longPremiumFraction, underlyingPrice)
14071702 let shortFunding = divd(shortPremiumFraction, underlyingPrice)
14081703 throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOracleTwapPrice())))
1704+ }
1705+
1706+
1707+
1708+@Callable(i)
1709+func view_getBorrowedByTrader (_trader) = {
1710+ let $t07287072924 = getBorrowedByTrader(_trader)
1711+ let borrowed = $t07287072924._1
1712+ let assetId = $t07287072924._2
1713+ throw((s(borrowed) + assetId))
14091714 }
14101715
14111716
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let k_ora_key = "k_ora_key"
55
66 let k_ora_block_key = "k_ora_block_key"
77
88 let k_ora = "k_ora"
99
1010 let k_balance = "k_balance"
1111
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_positionClosedDate = "k_positionClosedDate"
21+
22+let k_positionAsset = "k_positionAsset"
2123
2224 let k_initialized = "k_initialized"
2325
2426 let k_paused = "k_paused"
2527
2628 let k_fee = "k_fee"
2729
2830 let k_fundingPeriod = "k_fundingPeriod"
2931
3032 let k_initMarginRatio = "k_initMarginRatio"
3133
3234 let k_maintenanceMarginRatio = "k_mmr"
3335
3436 let k_liquidationFeeRatio = "k_liquidationFeeRatio"
3537
3638 let k_partialLiquidationRatio = "k_partLiquidationRatio"
3739
3840 let k_spreadLimit = "k_spreadLimit"
3941
4042 let k_maxPriceImpact = "k_maxPriceImpact"
4143
4244 let k_maxPriceSpread = "k_maxPriceSpread"
4345
4446 let k_lastDataStr = "k_lastDataStr"
4547
4648 let k_lastMinuteId = "k_lastMinuteId"
4749
4850 let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice"
4951
5052 let k_twapDataLastPrice = "k_twapDataLastPrice"
5153
5254 let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId"
5355
5456 let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction"
5557
5658 let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction"
5759
5860 let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp"
5961
6062 let k_longFundingRate = "k_longFundingRate"
6163
6264 let k_shortFundingRate = "k_shortFundingRate"
6365
6466 let k_quoteAssetReserve = "k_qtAstR"
6567
6668 let k_baseAssetReserve = "k_bsAstR"
6769
6870 let k_totalPositionSize = "k_totalPositionSize"
6971
7072 let k_totalLongPositionSize = "k_totalLongPositionSize"
7173
7274 let k_totalShortPositionSize = "k_totalShortPositionSize"
7375
7476 let k_cumulativeNotional = "k_cumulativeNotional"
7577
7678 let k_openInterestNotional = "k_openInterestNotional"
7779
7880 let k_coordinatorAddress = "k_coordinatorAddress"
7981
8082 let k_insurance_address = "k_insurance_address"
8183
8284 let k_admin_address = "k_admin_address"
8385
8486 let k_admin_public_key = "k_admin_public_key"
8587
8688 let k_quote_asset = "k_quote_asset"
8789
8890 let k_quote_staking = "k_quote_staking"
8991
9092 let k_staking_address = "k_staking_address"
9193
9294 let k_miner_address = "k_miner_address"
9395
9496 let k_orders_address = "k_orders_address"
9597
9698 let k_referral_address = "k_referral_address"
9799
98100 let k_manager_address = "k_manager_address"
99101
102+let k_collateral_address = "k_collateral_address"
103+
104+let k_exchange_address = "k_exchange_address"
105+
106+let k_nft_manager_address = "k_nft_manager_address"
107+
108+let k_trader_market_asset_collateral = "k_trader_market_asset_collateral"
109+
110+func toCompositeKey (_key,_address) = ((_key + "_") + _address)
111+
112+
100113 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
101114
102115
103116 func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
104117
105118
106119 func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
107120
108121
109122 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
110123
111124
112125 func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set")
113126
114127
115128 func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set")
116129
117130
118131 func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set")
119132
120133
121134 func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Miner not set")
122135
123136
124137 func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set")
125138
126139
127140 func referralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_referral_address)), "Referral not set")
128141
129142
130143 func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set")
131144
145+
146+func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set")
147+
148+
149+func collateralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_collateral_address)), "Collateral Manager not set")
150+
151+
152+func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_exchange_address), "No swap address")), "Invalid swap address")
153+
154+
155+let k_whitelist_asset = "k_whitelist_asset"
156+
157+func isWhitelistAsset (_assetId) = valueOrElse(getBoolean(collateralAddress(), toCompositeKey(k_whitelist_asset, _assetId)), false)
158+
159+
160+let k_token_param = "k_token_param"
161+
162+let k_token_type = "k_token_type"
163+
164+let FEE_REDUCTION_TOKEN_TYPE = "fee_reduction"
132165
133166 let DIR_LONG = 1
134167
135168 let DIR_SHORT = 2
136169
137170 let TWAP_INTERVAL = 15
138171
139172 let ORACLE_INTERVAL = 15
140173
141174 let SECONDS = 1000
142175
143176 let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10))
144177
145178 let ONE_DAY = (86400 * DECIMAL_UNIT)
146179
147180 let ALL_FEES = 100
148181
149182 let PNL_OPTION_SPOT = 1
150183
151184 let PNL_OPTION_ORACLE = 2
152185
153186 func s (_x) = (toString(_x) + ",")
154187
155188
156189 func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
157190
158191
159192 func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
160193
161194
162195 func abs (_x) = if ((_x > 0))
163196 then _x
164197 else -(_x)
165198
166199
167200 func vmax (_x,_y) = if ((_x >= _y))
168201 then _x
169202 else _y
170203
171204
172-func toCompositeKey (_key,_address) = ((_key + "_") + _address)
173-
174-
175205 func listToStr (_list) = {
176206 func _join (accumulator,val) = ((accumulator + val) + ",")
177207
178208 let newListStr = {
179209 let $l = _list
180210 let $s = size($l)
181211 let $acc0 = ""
182212 func $f0_1 ($a,$i) = if (($i >= $s))
183213 then $a
184214 else _join($a, $l[$i])
185215
186216 func $f0_2 ($a,$i) = if (($i >= $s))
187217 then $a
188218 else throw("List size exceeds 20")
189219
190220 $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)
191221 }
192222 let newListStrU = dropRight(newListStr, 1)
193223 let newListStrR = if ((take(newListStrU, 1) == ","))
194224 then drop(newListStrU, 1)
195225 else newListStrU
196226 newListStrR
197227 }
198228
199229
200230 func strToList (_str) = split(_str, ",")
201231
202232
203233 func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize))
204234 then (removeByIndex(_list, 0) :+ _value)
205235 else (_list :+ _value)
206236
207237
208238 func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
239+
240+
241+func strA (_address,_key) = {
242+ let val = valueOrErrorMessage(getString(_address, _key), ("No value for key " + _key))
243+ val
244+ }
245+
246+
247+func intA (_address,_key) = {
248+ let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key))
249+ val
250+ }
209251
210252
211253 func cbalance () = int(k_balance)
212254
213255
214256 func fee () = int(k_fee)
215257
216258
217259 func initMarginRatio () = int(k_initMarginRatio)
218260
219261
220262 func qtAstR () = int(k_quoteAssetReserve)
221263
222264
223265 func bsAstR () = int(k_baseAssetReserve)
224266
225267
226268 func totalPositionSize () = int(k_totalPositionSize)
227269
228270
229271 func cumulativeNotional () = int(k_cumulativeNotional)
230272
231273
232274 func openInterestNotional () = int(k_openInterestNotional)
233275
234276
235277 func nextFundingBlockTimestamp () = int(k_nextFundingBlock)
236278
237279
238280 func fundingPeriodRaw () = int(k_fundingPeriod)
239281
240282
241283 func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT)
242284
243285
244286 func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS)
245287
246288
247289 func maintenanceMarginRatio () = int(k_maintenanceMarginRatio)
248290
249291
250292 func liquidationFeeRatio () = int(k_liquidationFeeRatio)
251293
252294
253295 func partialLiquidationRatio () = int(k_partialLiquidationRatio)
254296
255297
256298 func spreadLimit () = int(k_spreadLimit)
257299
258300
259301 func maxPriceImpact () = int(k_maxPriceImpact)
260302
261303
262304 func maxPriceSpread () = int(k_maxPriceSpread)
263305
264306
265307 func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction)
266308
267309
268310 func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction)
269311
270312
271313 func totalShortPositionSize () = int(k_totalShortPositionSize)
272314
273315
274316 func totalLongPositionSize () = int(k_totalLongPositionSize)
275317
276318
277319 func getActualCaller (i) = valueOrElse(getString(ordersAddress(), "k_sender"), toString(i.caller))
278320
279321
280322 func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = {
281323 let remainingMarginRatio = (_marginRatio - _baseMarginRatio)
282324 if (if (_largerThanOrEqualTo)
283325 then (0 > remainingMarginRatio)
284326 else false)
285327 then throw("Invalid margin")
286328 else if (if (!(_largerThanOrEqualTo))
287329 then (remainingMarginRatio >= 0)
288330 else false)
289331 then throw("Invalid margin")
290332 else true
291333 }
292334
293335
294336 func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0))
295337 then throw("Should not be called with _positionSize == 0")
296338 else if ((_positionSize > 0))
297339 then latestLongCumulativePremiumFraction()
298340 else latestShortCumulativePremiumFraction()
299341
300342
301343 func getPosition (_trader) = {
302344 let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader))
303345 match positionSizeOpt {
304346 case positionSize: Int =>
305347 $Tuple4(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)))
306348 case _ =>
307349 $Tuple4(0, 0, 0, 0)
308350 }
309351 }
310352
311353
354+func getPositionAsset (_trader) = {
355+ let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader))
356+ match positionAssetOpt {
357+ case positionAsset: String =>
358+ positionAsset
359+ case _ =>
360+ toBase58String(quoteAsset())
361+ }
362+ }
363+
364+
312365 func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0))
313366 then throw("No open position")
314367 else true
315368
316369
317370 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
318371
319372
320373 func paused () = valueOrElse(getBoolean(this, k_paused), false)
321374
322375
323376 func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd)
324377 then {
325378 let newBase = (bsAstR() - _baseAssetAmount)
326379 if ((0 >= newBase))
327380 then throw("Tx lead to base asset reserve <= 0, revert")
328381 else $Tuple4((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount), (cumulativeNotional() + _quoteAssetAmount))
329382 }
330383 else {
331384 let newQuote = (qtAstR() - _quoteAssetAmount)
332385 if ((0 >= newQuote))
333386 then throw("Tx lead to base quote reserve <= 0, revert")
334387 else $Tuple4(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount), (cumulativeNotional() - _quoteAssetAmount))
335388 }
336389
337390
338391 func swapInput (_isAdd,_quoteAssetAmount) = {
339392 let _qtAstR = qtAstR()
340393 let _bsAstR = bsAstR()
341394 let k = muld(_qtAstR, _bsAstR)
342395 let quoteAssetReserveAfter = if (_isAdd)
343396 then (_qtAstR + _quoteAssetAmount)
344397 else (_qtAstR - _quoteAssetAmount)
345398 let baseAssetReserveAfter = divd(k, quoteAssetReserveAfter)
346399 let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR))
347400 let amountBaseAssetBought = if (_isAdd)
348401 then amountBaseAssetBoughtAbs
349402 else -(amountBaseAssetBoughtAbs)
350- let $t01301913212 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
351- let quoteAssetReserveAfter1 = $t01301913212._1
352- let baseAssetReserveAfter1 = $t01301913212._2
353- let totalPositionSizeAfter1 = $t01301913212._3
354- let cumulativeNotionalAfter1 = $t01301913212._4
403+ let $t01497415167 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
404+ let quoteAssetReserveAfter1 = $t01497415167._1
405+ let baseAssetReserveAfter1 = $t01497415167._2
406+ let totalPositionSizeAfter1 = $t01497415167._3
407+ let cumulativeNotionalAfter1 = $t01497415167._4
355408 let priceBefore = divd(_qtAstR, _bsAstR)
356409 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
357410 let priceDiff = abs((priceBefore - marketPrice))
358411 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
359412 let maxPriceImpactValue = maxPriceImpact()
360413 if ((priceImpact > maxPriceImpactValue))
361414 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)))
362415 else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1)
363416 }
364417
365418
366419 func calcRemainMarginWithFundingPayment (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_marginDelta) = {
367420 let fundingPayment = if ((_oldPositionSize != 0))
368421 then {
369422 let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize)
370423 muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize)
371424 }
372425 else 0
373426 let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin)
374- let $t01470314830 = if ((0 > signedMargin))
427+ let $t01665816785 = if ((0 > signedMargin))
375428 then $Tuple2(0, abs(signedMargin))
376429 else $Tuple2(abs(signedMargin), 0)
377- let remainMargin = $t01470314830._1
378- let badDebt = $t01470314830._2
430+ let remainMargin = $t01665816785._1
431+ let badDebt = $t01665816785._2
379432 $Tuple3(remainMargin, badDebt, fundingPayment)
380433 }
381434
382435
383436 func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_baseAssetReserve) = {
384437 let priceBefore = divd(_quoteAssetReserve, _baseAssetReserve)
385438 if ((_baseAssetAmount == 0))
386439 then throw("Invalid base asset amount")
387440 else {
388441 let k = muld(_quoteAssetReserve, _baseAssetReserve)
389442 let baseAssetPoolAmountAfter = if (_isAdd)
390443 then (_baseAssetReserve + _baseAssetAmount)
391444 else (_baseAssetReserve - _baseAssetAmount)
392445 let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter)
393446 let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve))
394447 let maxPriceImpactValue = maxPriceImpact()
395- let $t01580716000 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
396- let quoteAssetReserveAfter1 = $t01580716000._1
397- let baseAssetReserveAfter1 = $t01580716000._2
398- let totalPositionSizeAfter1 = $t01580716000._3
399- let cumulativeNotionalAfter1 = $t01580716000._4
448+ let $t01776217955 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
449+ let quoteAssetReserveAfter1 = $t01776217955._1
450+ let baseAssetReserveAfter1 = $t01776217955._2
451+ let totalPositionSizeAfter1 = $t01776217955._3
452+ let cumulativeNotionalAfter1 = $t01776217955._4
400453 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
401454 let priceDiff = abs((priceBefore - marketPrice))
402455 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
403456 if (if ((priceImpact > maxPriceImpactValue))
404457 then _checkMaxPriceImpact
405458 else false)
406459 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)))
407460 else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd)
408461 then abs(_baseAssetAmount)
409462 else 0)), (totalShortPositionSize() - (if (!(_isAdd))
410463 then abs(_baseAssetAmount)
411464 else 0)), priceImpact)
412465 }
413466 }
414467
415468
416469 func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), bsAstR())
417470
418471
419472 func getOracleTwapPrice () = {
420473 let oracle = valueOrErrorMessage(addressFromString(getStringValue(this, k_ora)), "")
421474 let priceKey = getStringValue(this, k_ora_key)
422475 let blockKey = getStringValue(this, k_ora_block_key)
423476 let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey))
424477 lastValue
425478 }
426479
427480
428481 func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = {
429482 let oraclePrice = getOracleTwapPrice()
430483 let priceAfter = divd(_quoteAssetReserve, _baseAssetReserve)
431484 let averagePrice = divd((oraclePrice + priceAfter), (2 * DECIMAL_UNIT))
432485 let absPriceDiff = divd(abs((oraclePrice - priceAfter)), averagePrice)
433486 if ((absPriceDiff > maxPriceSpread()))
434487 then throw(((("Price spread " + toString(absPriceDiff)) + " > max price spread ") + toString(maxPriceSpread())))
435488 else true
436489 }
437490
438491
439492 func getSpotPrice () = {
440493 let _quoteAssetReserve = qtAstR()
441494 let _baseAssetReserve = bsAstR()
442495 divd(_quoteAssetReserve, _baseAssetReserve)
443496 }
444497
445498
446499 func isOverFluctuationLimit () = {
447500 let oraclePrice = getOracleTwapPrice()
448501 let currentPrice = getSpotPrice()
449502 (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit())
450503 }
451504
452505
453506 func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_baseAssetReserve) = {
454507 let positionSizeAbs = abs(_positionSize)
455508 let isShort = (0 > _positionSize)
456509 let positionNotional = if ((_option == PNL_OPTION_SPOT))
457510 then {
458- let $t01921819389 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve)
459- let outPositionNotional = $t01921819389._1
460- let x1 = $t01921819389._2
461- let x2 = $t01921819389._3
462- let x3 = $t01921819389._4
511+ let $t02117321344 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve)
512+ let outPositionNotional = $t02117321344._1
513+ let x1 = $t02117321344._2
514+ let x2 = $t02117321344._3
515+ let x3 = $t02117321344._4
463516 outPositionNotional
464517 }
465518 else muld(positionSizeAbs, getOracleTwapPrice())
466519 positionNotional
467520 }
468521
469522
470523 func getPositionNotionalAndUnrealizedPnlByValues (_positionSize,_positionOpenNotional,_quoteAssetReserve,_baseAssetReserve,_option) = if ((_positionSize == 0))
471524 then throw("Invalid position size")
472525 else {
473526 let isShort = (0 > _positionSize)
474527 let positionNotional = getPositionAdjustedOpenNotional(_positionSize, _option, _quoteAssetReserve, _baseAssetReserve)
475528 let unrealizedPnl = if (isShort)
476529 then (_positionOpenNotional - positionNotional)
477530 else (positionNotional - _positionOpenNotional)
478531 $Tuple2(positionNotional, unrealizedPnl)
479532 }
480533
481534
482535 func getPositionNotionalAndUnrealizedPnl (_trader,_option) = {
483- let $t02070620834 = getPosition(_trader)
484- let positionSize = $t02070620834._1
485- let positionMargin = $t02070620834._2
486- let positionOpenNotional = $t02070620834._3
487- let positionLstUpdCPF = $t02070620834._4
536+ let $t02266122789 = getPosition(_trader)
537+ let positionSize = $t02266122789._1
538+ let positionMargin = $t02266122789._2
539+ let positionOpenNotional = $t02266122789._3
540+ let positionLstUpdCPF = $t02266122789._4
488541 getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), bsAstR(), _option)
489542 }
490543
491544
492545 func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional)
493546
494547
495548 func getMarginRatioByOption (_trader,_option) = {
496- let $t02131521426 = getPosition(_trader)
497- let positionSize = $t02131521426._1
498- let positionMargin = $t02131521426._2
499- let pon = $t02131521426._3
500- let positionLstUpdCPF = $t02131521426._4
501- let $t02143221525 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
502- let positionNotional = $t02143221525._1
503- let unrealizedPnl = $t02143221525._2
504- let $t02153021696 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
505- let remainMargin = $t02153021696._1
506- let badDebt = $t02153021696._2
549+ let $t02327023381 = getPosition(_trader)
550+ let positionSize = $t02327023381._1
551+ let positionMargin = $t02327023381._2
552+ let pon = $t02327023381._3
553+ let positionLstUpdCPF = $t02327023381._4
554+ let $t02338723480 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
555+ let positionNotional = $t02338723480._1
556+ let unrealizedPnl = $t02338723480._2
557+ let $t02348523651 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
558+ let remainMargin = $t02348523651._1
559+ let badDebt = $t02348523651._2
507560 calcMarginRatio(remainMargin, badDebt, positionNotional)
508561 }
509562
510563
511564 func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
512565
513566
514567 func getPartialLiquidationAmount (_trader,_positionSize) = {
515568 let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio())))
516569 let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio)
517570 let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false)
518571 let maxExchangedQuoteAssetAmount = swapResult._1
519572 let priceImpact = swapResult._8
520573 if ((maxPriceImpact() > priceImpact))
521574 then maxExchangedQuoteAssetAmount
522575 else {
523576 let exchangedPositionSize = muld(abs(_positionSize), partialLiquidationRatio())
524577 let exchangedQuoteAssetAmount = swapOutput((_positionSize > 0), exchangedPositionSize, false)._1
525578 exchangedQuoteAssetAmount
526579 }
527580 }
528581
529582
530583 func internalClosePosition (_trader,_checkMaxPriceImpact) = {
531- let $t02292923057 = getPosition(_trader)
532- let positionSize = $t02292923057._1
533- let positionMargin = $t02292923057._2
534- let positionOpenNotional = $t02292923057._3
535- let positionLstUpdCPF = $t02292923057._4
584+ let $t02488425012 = getPosition(_trader)
585+ let positionSize = $t02488425012._1
586+ let positionMargin = $t02488425012._2
587+ let positionOpenNotional = $t02488425012._3
588+ let positionLstUpdCPF = $t02488425012._4
536589 let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2
537- let $t02315223320 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
538- let remainMargin = $t02315223320._1
539- let badDebt = $t02315223320._2
590+ let $t02510725275 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
591+ let remainMargin = $t02510725275._1
592+ let badDebt = $t02510725275._2
540593 let exchangedPositionSize = -(positionSize)
541594 let realizedPnl = unrealizedPnl
542595 let marginToVault = -(remainMargin)
543- let $t02344723758 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
544- let exchangedQuoteAssetAmount = $t02344723758._1
545- let quoteAssetReserveAfter = $t02344723758._2
546- let baseAssetReserveAfter = $t02344723758._3
547- let totalPositionSizeAfter = $t02344723758._4
548- let cumulativeNotionalAfter = $t02344723758._5
549- let totalLongAfter = $t02344723758._6
550- let totalShortAfter = $t02344723758._7
596+ let $t02540225713 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
597+ let exchangedQuoteAssetAmount = $t02540225713._1
598+ let quoteAssetReserveAfter = $t02540225713._2
599+ let baseAssetReserveAfter = $t02540225713._3
600+ let totalPositionSizeAfter = $t02540225713._4
601+ let cumulativeNotionalAfter = $t02540225713._5
602+ let totalLongAfter = $t02540225713._6
603+ let totalShortAfter = $t02540225713._7
551604 let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional)
552605 $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter)
553606 }
554607
555608
556609 func getTwapSpotPrice () = {
557610 let minuteId = ((lastBlock.timestamp / 1000) / 60)
558611 let startMinuteId = (minuteId - TWAP_INTERVAL)
559612 let listStr = valueOrElse(getString(this, k_lastDataStr), "")
560613 let list = split(listStr, ",")
561614 func filterFn (accumulator,next) = if ((startMinuteId >= parseIntValue(next)))
562615 then (accumulator :+ parseIntValue(next))
563616 else accumulator
564617
565618 let listF = {
566619 let $l = list
567620 let $s = size($l)
568621 let $acc0 = nil
569622 func $f0_1 ($a,$i) = if (($i >= $s))
570623 then $a
571624 else filterFn($a, $l[$i])
572625
573626 func $f0_2 ($a,$i) = if (($i >= $s))
574627 then $a
575628 else throw("List size exceeds 20")
576629
577630 $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)
578631 }
579632 let maxIndex = if ((size(listF) > 0))
580633 then max(listF)
581634 else parseIntValue(list[0])
582635 let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
583636 let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0)
584637 let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0)
585638 let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice))
586639 let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0)
587640 let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0)
588641 let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice))
589642 ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL)
590643 }
591644
592645
593646 func getPegAdjustCost (_price) = {
594647 let _positionSize = totalPositionSize()
595648 let direction = (_positionSize > 0)
596649 let currentNetMarketValue = swapOutput(direction, abs(_positionSize), false)._1
597650 let baseAssetReserve = bsAstR()
598651 let newQuoteAssetReserve = muld(baseAssetReserve, _price)
599652 let cost = getPositionNotionalAndUnrealizedPnlByValues(_positionSize, currentNetMarketValue, newQuoteAssetReserve, baseAssetReserve, PNL_OPTION_SPOT)._2
600653 $Tuple2(newQuoteAssetReserve, cost)
601654 }
602655
603656
604657 func getFunding () = {
605658 let underlyingPrice = getOracleTwapPrice()
606659 let spotTwapPrice = getTwapSpotPrice()
607660 let premium = (spotTwapPrice - underlyingPrice)
608661 if (if ((totalShortPositionSize() == 0))
609662 then true
610663 else (totalLongPositionSize() == 0))
611664 then $Tuple2(0, 0)
612665 else if ((0 > premium))
613666 then {
614667 let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
615668 let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize())
616669 $Tuple2(shortPremiumFraction, longPremiumFraction)
617670 }
618671 else {
619672 let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
620673 let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize())
621674 $Tuple2(shortPremiumFraction, longPremiumFraction)
622675 }
623676 }
624677
625678
679+func getAdjustedFee (i) = {
680+ let baseFee = fee()
681+ let $t02937629984 = if ((size(i.payments) > 1))
682+ then {
683+ let artifactId = toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid attached artifact"))
684+ let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, artifactId))
685+ if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE))
686+ then {
687+ let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, artifactId))
688+ let adjustedFee = muld(baseFee, reduction)
689+ $Tuple2(adjustedFee, true)
690+ }
691+ else throw("Invalid attached artifact")
692+ }
693+ else $Tuple2(baseFee, false)
694+ let adjustedFee = $t02937629984._1
695+ let burnArtifact = $t02937629984._2
696+ $Tuple2(adjustedFee, burnArtifact)
697+ }
698+
699+
626700 func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread)]
627701
628702
629703 func updateFunding (_nextFundingBlock,_latestLongCumulativePremiumFraction,_latestShortCumulativePremiumFraction,_longFundingRate,_shortFundingRate) = [IntegerEntry(k_nextFundingBlock, _nextFundingBlock), IntegerEntry(k_latestLongCumulativePremiumFraction, _latestLongCumulativePremiumFraction), IntegerEntry(k_latestShortCumulativePremiumFraction, _latestShortCumulativePremiumFraction), IntegerEntry(k_longFundingRate, _longFundingRate), IntegerEntry(k_shortFundingRate, _shortFundingRate)]
704+
705+
706+func updatePositionAsset (_address,_assetId) = [StringEntry(toCompositeKey(k_positionAsset, _address), _assetId)]
630707
631708
632709 func updatePosition (_address,_size,_margin,_openNotional,_latestCumulativePremiumFraction) = [IntegerEntry(toCompositeKey(k_positionSize, _address), _size), IntegerEntry(toCompositeKey(k_positionMargin, _address), _margin), IntegerEntry(toCompositeKey(k_positionOpenNotional, _address), _openNotional), IntegerEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address), _latestCumulativePremiumFraction)]
633710
634711
635712 func appendTwap (price) = {
636713 let minuteId = ((lastBlock.timestamp / 1000) / 60)
637714 let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
638715 if ((previousMinuteId > minuteId))
639716 then throw("TWAP out-of-order")
640717 else {
641718 let lastMinuteId = if ((previousMinuteId == 0))
642719 then minuteId
643720 else previousMinuteId
644721 if ((minuteId > previousMinuteId))
645722 then {
646723 let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0)
647724 let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), price)
648725 let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice))
649726 let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId))
650727 [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))]
651728 }
652729 else {
653730 let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0)
654731 let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0)
655732 let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), price)
656733 let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice))
657734 [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), price)]
658735 }
659736 }
660737 }
661738
662739
663740 func updateAmmReserves (_qtAstR,_bsAstR) = [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)]
664741
665742
666743 func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_cumulativeNotionalAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize) = if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter))
667744 then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter)))
668745 else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_cumulativeNotional, _cumulativeNotionalAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize)]) ++ appendTwap(divd(_qtAstR, _bsAstR)))
669746
670747
671-func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)]
748+func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)]
672749
673750
674751 func withdraw (_address,_amount) = {
675752 let balance = assetBalance(this, quoteAsset())
676753 if ((_amount > balance))
677754 then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance)))
678755 else [ScriptTransfer(_address, _amount, quoteAsset())]
679756 }
680757
681758
682759 func updateBalance (i) = if ((0 > i))
683760 then throw("Balance")
684761 else [IntegerEntry(k_balance, i)]
685762
686763
687764 func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())]
765+
766+
767+func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact)
768+ then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)]
769+ else nil
770+
771+
772+func isSameAssetOrNoPosition (_trader,_assetId) = {
773+ let oldPositionSize = getPosition(_trader)._1
774+ if ((oldPositionSize == 0))
775+ then true
776+ else (getPositionAsset(_trader) == _assetId)
777+ }
778+
779+
780+func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId)
781+
782+
783+func getBorrowedByTraderInMarketKey (_amm,_assetId,_trader) = ((((((k_trader_market_asset_collateral + "_") + _amm) + "_") + _assetId) + "_") + _trader)
784+
785+
786+func getBorrowedByTrader (_trader) = {
787+ let positionAsset = getPositionAsset(_trader)
788+ if ((positionAsset == toBase58String(quoteAsset())))
789+ then $Tuple2(0, positionAsset)
790+ else {
791+ let key = getBorrowedByTraderInMarketKey(toString(this), positionAsset, _trader)
792+ let borrow = valueOrElse(getInteger(collateralAddress(), key), 0)
793+ $Tuple2(borrow, positionAsset)
794+ }
795+ }
688796
689797
690798 @Callable(i)
691799 func pause () = if ((i.caller != adminAddress()))
692800 then throw("Invalid togglePause params")
693801 else [BooleanEntry(k_paused, true)]
694802
695803
696804
697805 @Callable(i)
698806 func unpause () = if ((i.caller != adminAddress()))
699807 then throw("Invalid togglePause params")
700808 else [BooleanEntry(k_paused, false)]
701809
702810
703811
704812 @Callable(i)
705813 func addLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress()))
706814 then true
707815 else (0 >= _quoteAssetAmount))
708816 then throw("Invalid addLiquidity params")
709817 else {
710818 let _qtAstR = qtAstR()
711819 let _bsAstR = bsAstR()
712820 let price = divd(_qtAstR, _bsAstR)
713821 let baseAssetAmountToAdd = divd(_quoteAssetAmount, price)
714822 let qtAstRAfter = (_qtAstR + _quoteAssetAmount)
715823 let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd)
716824 updateAmmReserves(qtAstRAfter, bsAstRAfter)
717825 }
718826
719827
720828
721829 @Callable(i)
722830 func removeLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress()))
723831 then true
724832 else (0 >= _quoteAssetAmount))
725833 then throw("Invalid removeLiquidity params")
726834 else {
727835 let _qtAstR = qtAstR()
728836 let _bsAstR = bsAstR()
729837 let price = divd(_qtAstR, _bsAstR)
730838 let baseAssetAmountToRemove = divd(_quoteAssetAmount, price)
731839 let qtAstRAfter = (_qtAstR - _quoteAssetAmount)
732840 let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove)
733841 updateAmmReserves(qtAstRAfter, bsAstRAfter)
734842 }
735843
736844
737845
738846 @Callable(i)
739847 func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress()))
740848 then throw("Invalid changeSettings params")
741849 else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)
742850
743851
744852
745853 @Callable(i)
746854 func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
747855 then true
748856 else (0 >= _bsAstR))
749857 then true
750858 else (0 >= _fundingPeriod))
751859 then true
752860 else (0 >= _initMarginRatio))
753861 then true
754862 else (0 >= _mmr))
755863 then true
756864 else (0 >= _liquidationFeeRatio))
757865 then true
758866 else (0 >= _fee))
759867 then true
760868 else (0 >= _spreadLimit))
761869 then true
762870 else (0 >= _maxPriceImpact))
763871 then true
764872 else (0 >= _partialLiquidationRatio))
765873 then true
766874 else (0 >= _maxPriceSpread))
767875 then true
768876 else initialized())
769877 then throw("Invalid initialize parameters")
770878 else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)])
771879
772880
773881
774882 @Callable(i)
775883 func setInitMarginRatio (_initMarginRatio) = if (if ((0 >= _initMarginRatio))
776884 then true
777885 else !(initialized()))
778886 then throw("Invalid setInitMarginRatio parameters")
779887 else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread())
780888
781889
782890
783891 @Callable(i)
784892 func decreasePosition (_amount,_leverage,_minBaseAssetAmount) = if (if (if (if (if ((0 >= _amount))
785893 then true
786894 else !(initialized()))
787895 then true
788896 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
789897 then true
790898 else !(requireOpenPosition(toString(i.caller))))
791899 then true
792900 else paused())
793901 then throw("Invalid decreasePosition parameters")
794902 else {
795- let $t03753437686 = getPosition(toString(i.caller))
796- let oldPositionSize = $t03753437686._1
797- let oldPositionMargin = $t03753437686._2
798- let oldPositionOpenNotional = $t03753437686._3
799- let oldPositionLstUpdCPF = $t03753437686._4
903+ let $t04149241644 = getPosition(toString(i.caller))
904+ let oldPositionSize = $t04149241644._1
905+ let oldPositionMargin = $t04149241644._2
906+ let oldPositionOpenNotional = $t04149241644._3
907+ let oldPositionLstUpdCPF = $t04149241644._4
800908 let _direction = if ((oldPositionSize > 0))
801909 then DIR_SHORT
802910 else DIR_LONG
803911 let isAdd = (_direction == DIR_LONG)
804912 let openNotional = muld(_amount, _leverage)
805- let $t03785937975 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
806- let oldPositionNotional = $t03785937975._1
807- let unrealizedPnl = $t03785937975._2
808- let $t03798140530 = if ((oldPositionNotional > openNotional))
913+ let $t04181741933 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
914+ let oldPositionNotional = $t04181741933._1
915+ let unrealizedPnl = $t04181741933._2
916+ let $t04193944488 = if ((oldPositionNotional > openNotional))
809917 then {
810- let $t03835838577 = swapInput(isAdd, openNotional)
811- let exchangedPositionSize = $t03835838577._1
812- let quoteAssetReserveAfter = $t03835838577._2
813- let baseAssetReserveAfter = $t03835838577._3
814- let totalPositionSizeAfter = $t03835838577._4
815- let cumulativeNotionalAfter = $t03835838577._5
918+ let $t04231642535 = swapInput(isAdd, openNotional)
919+ let exchangedPositionSize = $t04231642535._1
920+ let quoteAssetReserveAfter = $t04231642535._2
921+ let baseAssetReserveAfter = $t04231642535._3
922+ let totalPositionSizeAfter = $t04231642535._4
923+ let cumulativeNotionalAfter = $t04231642535._5
816924 let exchangedPositionSizeAbs = abs(exchangedPositionSize)
817925 if (if ((_minBaseAssetAmount != 0))
818926 then (_minBaseAssetAmount > exchangedPositionSizeAbs)
819927 else false)
820928 then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount)))
821929 else {
822930 let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize))
823- let $t03901439259 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
824- let remainMargin = $t03901439259._1
825- let badDebt = $t03901439259._2
826- let fundingPayment = $t03901439259._3
931+ let $t04297243217 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
932+ let remainMargin = $t04297243217._1
933+ let badDebt = $t04297243217._2
934+ let fundingPayment = $t04297243217._3
827935 let exchangedQuoteAssetAmount = openNotional
828936 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
829937 let remainOpenNotional = if ((oldPositionSize > 0))
830938 then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
831939 else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
832940 let newPositionSize = (oldPositionSize + exchangedPositionSize)
833941 $Tuple11(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0))
834942 then abs(exchangedPositionSize)
835943 else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
836944 then abs(exchangedPositionSize)
837945 else 0)))
838946 }
839947 }
840948 else throw("Close position first")
841- let newPositionSize = $t03798140530._1
842- let newPositionRemainMargin = $t03798140530._2
843- let newPositionOpenNotional = $t03798140530._3
844- let newPositionLatestCPF = $t03798140530._4
845- let baseAssetReserveAfter = $t03798140530._5
846- let quoteAssetReserveAfter = $t03798140530._6
847- let totalPositionSizeAfter = $t03798140530._7
848- let cumulativeNotionalAfter = $t03798140530._8
849- let openInterestNotionalAfter = $t03798140530._9
850- let totalLongAfter = $t03798140530._10
851- let totalShortAfter = $t03798140530._11
949+ let newPositionSize = $t04193944488._1
950+ let newPositionRemainMargin = $t04193944488._2
951+ let newPositionOpenNotional = $t04193944488._3
952+ let newPositionLatestCPF = $t04193944488._4
953+ let baseAssetReserveAfter = $t04193944488._5
954+ let quoteAssetReserveAfter = $t04193944488._6
955+ let totalPositionSizeAfter = $t04193944488._7
956+ let cumulativeNotionalAfter = $t04193944488._8
957+ let openInterestNotionalAfter = $t04193944488._9
958+ let totalLongAfter = $t04193944488._10
959+ let totalShortAfter = $t04193944488._11
852960 let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil)
853961 if ((notifyNotional == notifyNotional))
854962 then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter))
855963 else throw("Strict value is not equal to itself.")
856964 }
857965
858966
859967
860968 @Callable(i)
861969 func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = {
970+ let _trader = toString(i.caller)
862971 let _rawAmount = i.payments[0].amount
863- if (if (if (if (if (if (if ((_direction != DIR_LONG))
972+ let _assetId = i.payments[0].assetId
973+ let _assetIdStr = toBase58String(value(_assetId))
974+ let isQuoteAsset = (_assetId == quoteAsset())
975+ let isCollateralAsset = isWhitelistAsset(_assetIdStr)
976+ if (if (if (if (if (if (if (if ((_direction != DIR_LONG))
864977 then (_direction != DIR_SHORT)
865978 else false)
866979 then true
867980 else (0 >= _rawAmount))
868981 then true
869982 else !(initialized()))
870983 then true
871- else (i.payments[0].assetId != quoteAsset()))
984+ else if (!(isQuoteAsset))
985+ then !(isCollateralAsset)
986+ else false)
987+ then true
988+ else !(isSameAssetOrNoPosition(_trader, _assetIdStr)))
872989 then true
873990 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
874991 then true
875992 else paused())
876993 then throw("Invalid increasePosition parameters")
877994 else {
878- let _trader = toString(i.caller)
879- let rawFeeAmount = muld(_rawAmount, fee())
880- let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), rawFeeAmount)])
881- if ((referrerFeeAny == referrerFeeAny))
995+ let baseFee = fee()
996+ let $t04585045901 = getAdjustedFee(i)
997+ let adjustedFee = $t04585045901._1
998+ let burnArtifact = $t04585045901._2
999+ let rawFeeAmount = muld(_rawAmount, adjustedFee)
1000+ let _amount = (_rawAmount - rawFeeAmount)
1001+ let distributeFeeAmount = if (isCollateralAsset)
8821002 then {
883- let referrerFee = match referrerFeeAny {
884- case x: Int =>
885- x
886- case _ =>
887- throw("Invalid referrerFee")
1003+ let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1004+ if ((doBorrow == doBorrow))
1005+ then {
1006+ let balanceBefore = assetBalance(this, quoteAsset())
1007+ if ((balanceBefore == balanceBefore))
1008+ then {
1009+ let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1010+ if ((doSwap == doSwap))
1011+ then {
1012+ let balanceAfter = assetBalance(this, quoteAsset())
1013+ if ((balanceAfter == balanceAfter))
1014+ then {
1015+ let exchangedAmount = (balanceAfter - balanceBefore)
1016+ if ((exchangedAmount == exchangedAmount))
1017+ then exchangedAmount
1018+ else throw("Strict value is not equal to itself.")
1019+ }
1020+ else throw("Strict value is not equal to itself.")
1021+ }
1022+ else throw("Strict value is not equal to itself.")
1023+ }
1024+ else throw("Strict value is not equal to itself.")
1025+ }
1026+ else throw("Strict value is not equal to itself.")
8881027 }
889- let _amount = (_rawAmount - rawFeeAmount)
890- let feeAmount = (rawFeeAmount - referrerFee)
891- let $t04205942199 = getPosition(_trader)
892- let oldPositionSize = $t04205942199._1
893- let oldPositionMargin = $t04205942199._2
894- let oldPositionOpenNotional = $t04205942199._3
895- let oldPositionLstUpdCPF = $t04205942199._4
896- let isNewPosition = (oldPositionSize == 0)
897- let isSameDirection = if ((oldPositionSize > 0))
898- then (_direction == DIR_LONG)
899- else (_direction == DIR_SHORT)
900- let expandExisting = if (!(isNewPosition))
901- then isSameDirection
902- else false
903- let isAdd = (_direction == DIR_LONG)
904- let $t04248845056 = if (if (isNewPosition)
905- then true
906- else expandExisting)
1028+ else rawFeeAmount
1029+ if ((distributeFeeAmount == distributeFeeAmount))
1030+ then {
1031+ let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1032+ if ((referrerFeeAny == referrerFeeAny))
9071033 then {
908- let openNotional = muld(_amount, _leverage)
909- let $t04291243118 = swapInput(isAdd, openNotional)
910- let amountBaseAssetBought = $t04291243118._1
911- let quoteAssetReserveAfter = $t04291243118._2
912- let baseAssetReserveAfter = $t04291243118._3
913- let totalPositionSizeAfter = $t04291243118._4
914- let cumulativeNotionalAfter = $t04291243118._5
915- if (if ((_minBaseAssetAmount != 0))
916- then (_minBaseAssetAmount > abs(amountBaseAssetBought))
917- else false)
918- then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
1034+ let referrerFee = match referrerFeeAny {
1035+ case x: Int =>
1036+ x
1037+ case _ =>
1038+ throw("Invalid referrerFee")
1039+ }
1040+ let feeAmount = (distributeFeeAmount - referrerFee)
1041+ let $t04721747357 = getPosition(_trader)
1042+ let oldPositionSize = $t04721747357._1
1043+ let oldPositionMargin = $t04721747357._2
1044+ let oldPositionOpenNotional = $t04721747357._3
1045+ let oldPositionLstUpdCPF = $t04721747357._4
1046+ let isNewPosition = (oldPositionSize == 0)
1047+ let isSameDirection = if ((oldPositionSize > 0))
1048+ then (_direction == DIR_LONG)
1049+ else (_direction == DIR_SHORT)
1050+ let expandExisting = if (!(isNewPosition))
1051+ then isSameDirection
1052+ else false
1053+ let isAdd = (_direction == DIR_LONG)
1054+ let $t04764650231 = if (if (isNewPosition)
1055+ then true
1056+ else expandExisting)
1057+ then {
1058+ let openNotional = muld(_amount, _leverage)
1059+ let $t04807048276 = swapInput(isAdd, openNotional)
1060+ let amountBaseAssetBought = $t04807048276._1
1061+ let quoteAssetReserveAfter = $t04807048276._2
1062+ let baseAssetReserveAfter = $t04807048276._3
1063+ let totalPositionSizeAfter = $t04807048276._4
1064+ let cumulativeNotionalAfter = $t04807048276._5
1065+ if (if ((_minBaseAssetAmount != 0))
1066+ then (_minBaseAssetAmount > abs(amountBaseAssetBought))
1067+ else false)
1068+ then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
1069+ else {
1070+ let newPositionSize = (oldPositionSize + amountBaseAssetBought)
1071+ let increaseMarginRequirement = divd(openNotional, _leverage)
1072+ let $t04865748896 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
1073+ let remainMargin = $t04865748896._1
1074+ let x1 = $t04865748896._2
1075+ let x2 = $t04865748896._3
1076+ if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
1077+ then throw("Over max spread limit")
1078+ else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
1079+ then abs(amountBaseAssetBought)
1080+ else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
1081+ then abs(amountBaseAssetBought)
1082+ else 0)))
1083+ }
1084+ }
9191085 else {
920- let newPositionSize = (oldPositionSize + amountBaseAssetBought)
921- let increaseMarginRequirement = divd(openNotional, _leverage)
922- let $t04349943738 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
923- let remainMargin = $t04349943738._1
924- let x1 = $t04349943738._2
925- let x2 = $t04349943738._3
926- if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
927- then throw("Over max spread limit")
928- else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
929- then abs(amountBaseAssetBought)
930- else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
931- then abs(amountBaseAssetBought)
932- else 0)))
1086+ let openNotional = muld(_amount, _leverage)
1087+ let $t04992450040 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
1088+ let oldPositionNotional = $t04992450040._1
1089+ let unrealizedPnl = $t04992450040._2
1090+ if ((oldPositionNotional > openNotional))
1091+ then throw("Use decreasePosition to decrease position size")
1092+ else throw("Close position first")
9331093 }
934- }
935- else {
936- let openNotional = muld(_amount, _leverage)
937- let $t04474944865 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
938- let oldPositionNotional = $t04474944865._1
939- let unrealizedPnl = $t04474944865._2
940- if ((oldPositionNotional > openNotional))
941- then throw("Use decreasePosition to decrease position size")
942- else throw("Close position first")
943- }
944- let newPositionSize = $t04248845056._1
945- let newPositionRemainMargin = $t04248845056._2
946- let newPositionOpenNotional = $t04248845056._3
947- let newPositionLatestCPF = $t04248845056._4
948- let baseAssetReserveAfter = $t04248845056._5
949- let quoteAssetReserveAfter = $t04248845056._6
950- let totalPositionSizeAfter = $t04248845056._7
951- let cumulativeNotionalAfter = $t04248845056._8
952- let openInterestNotionalAfter = $t04248845056._9
953- let totalLongAfter = $t04248845056._10
954- let totalShortAfter = $t04248845056._11
955- let feeToStakers = (feeAmount / 2)
956- let feeToInsurance = (feeAmount - feeToStakers)
957- let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
958- if ((stake == stake))
959- then {
960- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
961- if ((depositInsurance == depositInsurance))
1094+ let newPositionSize = $t04764650231._1
1095+ let newPositionRemainMargin = $t04764650231._2
1096+ let newPositionOpenNotional = $t04764650231._3
1097+ let newPositionLatestCPF = $t04764650231._4
1098+ let baseAssetReserveAfter = $t04764650231._5
1099+ let quoteAssetReserveAfter = $t04764650231._6
1100+ let totalPositionSizeAfter = $t04764650231._7
1101+ let cumulativeNotionalAfter = $t04764650231._8
1102+ let openInterestNotionalAfter = $t04764650231._9
1103+ let totalLongAfter = $t04764650231._10
1104+ let totalShortAfter = $t04764650231._11
1105+ let feeToStakers = (feeAmount / 2)
1106+ let feeToInsurance = (feeAmount - feeToStakers)
1107+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
1108+ if ((stake == stake))
9621109 then {
963- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
964- if ((notifyFee == notifyFee))
1110+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1111+ if ((depositInsurance == depositInsurance))
9651112 then {
966- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
967- if ((notifyNotional == notifyNotional))
968- then (((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount)))
1113+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1114+ if ((notifyFee == notifyFee))
1115+ then {
1116+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1117+ if ((notifyNotional == notifyNotional))
1118+ then (((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
1119+ else throw("Strict value is not equal to itself.")
1120+ }
9691121 else throw("Strict value is not equal to itself.")
9701122 }
9711123 else throw("Strict value is not equal to itself.")
9721124 }
9731125 else throw("Strict value is not equal to itself.")
9741126 }
9751127 else throw("Strict value is not equal to itself.")
9761128 }
9771129 else throw("Strict value is not equal to itself.")
9781130 }
9791131 }
9801132
9811133
9821134
9831135 @Callable(i)
9841136 func addMargin () = {
1137+ let _trader = toString(i.caller)
9851138 let _rawAmount = i.payments[0].amount
986- if (if (if (if ((i.payments[0].assetId != quoteAsset()))
1139+ let _assetId = i.payments[0].assetId
1140+ let _assetIdStr = toBase58String(value(_assetId))
1141+ let isQuoteAsset = (_assetId == quoteAsset())
1142+ let isCollateralAsset = isWhitelistAsset(_assetIdStr)
1143+ if (if (if (if (if (if (!(isQuoteAsset))
1144+ then !(isCollateralAsset)
1145+ else false)
9871146 then true
9881147 else !(requireOpenPosition(toString(i.caller))))
1148+ then true
1149+ else !(isSameAsset(_trader, _assetIdStr)))
9891150 then true
9901151 else !(initialized()))
9911152 then true
9921153 else paused())
9931154 then throw("Invalid addMargin parameters")
9941155 else {
995- let _trader = toString(i.caller)
996- let rawFeeAmount = muld(_rawAmount, fee())
997- let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), rawFeeAmount)])
998- if ((referrerFeeAny == referrerFeeAny))
1156+ let $t05198752038 = getAdjustedFee(i)
1157+ let adjustedFee = $t05198752038._1
1158+ let burnArtifact = $t05198752038._2
1159+ let rawFeeAmount = muld(_rawAmount, adjustedFee)
1160+ let _amount = (_rawAmount - rawFeeAmount)
1161+ let distributeFeeAmount = if (isCollateralAsset)
9991162 then {
1000- let referrerFee = match referrerFeeAny {
1001- case x: Int =>
1002- x
1003- case _ =>
1004- throw("Invalid referrerFee")
1163+ let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)])
1164+ if ((doBorrow == doBorrow))
1165+ then {
1166+ let balanceBefore = assetBalance(this, quoteAsset())
1167+ if ((balanceBefore == balanceBefore))
1168+ then {
1169+ let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)])
1170+ if ((doSwap == doSwap))
1171+ then {
1172+ let balanceAfter = assetBalance(this, quoteAsset())
1173+ if ((balanceAfter == balanceAfter))
1174+ then {
1175+ let exchangedAmount = (balanceAfter - balanceBefore)
1176+ if ((exchangedAmount == exchangedAmount))
1177+ then exchangedAmount
1178+ else throw("Strict value is not equal to itself.")
1179+ }
1180+ else throw("Strict value is not equal to itself.")
1181+ }
1182+ else throw("Strict value is not equal to itself.")
1183+ }
1184+ else throw("Strict value is not equal to itself.")
1185+ }
1186+ else throw("Strict value is not equal to itself.")
10051187 }
1006- let feeAmount = (rawFeeAmount - referrerFee)
1007- let _amount = (_rawAmount - rawFeeAmount)
1008- let $t04690247042 = getPosition(_trader)
1009- let oldPositionSize = $t04690247042._1
1010- let oldPositionMargin = $t04690247042._2
1011- let oldPositionOpenNotional = $t04690247042._3
1012- let oldPositionLstUpdCPF = $t04690247042._4
1013- let feeToStakers = (feeAmount / 2)
1014- let feeToInsurance = (feeAmount - feeToStakers)
1015- let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
1016- if ((stake == stake))
1188+ else rawFeeAmount
1189+ if ((distributeFeeAmount == distributeFeeAmount))
1190+ then {
1191+ let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)])
1192+ if ((referrerFeeAny == referrerFeeAny))
10171193 then {
1018- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1019- if ((depositInsurance == depositInsurance))
1194+ let referrerFee = match referrerFeeAny {
1195+ case x: Int =>
1196+ x
1197+ case _ =>
1198+ throw("Invalid referrerFee")
1199+ }
1200+ let feeAmount = (distributeFeeAmount - referrerFee)
1201+ let $t05333753477 = getPosition(_trader)
1202+ let oldPositionSize = $t05333753477._1
1203+ let oldPositionMargin = $t05333753477._2
1204+ let oldPositionOpenNotional = $t05333753477._3
1205+ let oldPositionLstUpdCPF = $t05333753477._4
1206+ let feeToStakers = (feeAmount / 2)
1207+ let feeToInsurance = (feeAmount - feeToStakers)
1208+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)])
1209+ if ((stake == stake))
10201210 then {
1021- let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1022- if ((notifyFee == notifyFee))
1023- then ((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount)))
1211+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1212+ if ((depositInsurance == depositInsurance))
1213+ then {
1214+ let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil)
1215+ if ((notifyFee == notifyFee))
1216+ then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i))
1217+ else throw("Strict value is not equal to itself.")
1218+ }
10241219 else throw("Strict value is not equal to itself.")
10251220 }
10261221 else throw("Strict value is not equal to itself.")
10271222 }
10281223 else throw("Strict value is not equal to itself.")
10291224 }
10301225 else throw("Strict value is not equal to itself.")
10311226 }
10321227 }
10331228
10341229
10351230
10361231 @Callable(i)
1037-func removeMargin (_amount) = if (if (if (if ((0 >= _amount))
1038- then true
1039- else !(requireOpenPosition(toString(i.caller))))
1040- then true
1041- else !(initialized()))
1042- then true
1043- else paused())
1044- then throw("Invalid removeMargin parameters")
1045- else {
1046- let $t04801848170 = getPosition(toString(i.caller))
1047- let oldPositionSize = $t04801848170._1
1048- let oldPositionMargin = $t04801848170._2
1049- let oldPositionOpenNotional = $t04801848170._3
1050- let oldPositionLstUpdCPF = $t04801848170._4
1051- let marginDelta = -(_amount)
1052- let $t04820748386 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
1053- let remainMargin = $t04820748386._1
1054- let badDebt = $t04820748386._2
1055- if ((badDebt != 0))
1056- then throw("Invalid removed margin amount")
1057- else {
1058- let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional)
1059- if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true)))
1060- then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
1061- else {
1062- let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil)
1063- if ((unstake == unstake))
1064- then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount)))
1065- else throw("Strict value is not equal to itself.")
1066- }
1067- }
1068- }
1232+func removeMargin (_amount) = {
1233+ let _trader = toString(i.caller)
1234+ if (if (if (if ((0 >= _amount))
1235+ then true
1236+ else !(requireOpenPosition(_trader)))
1237+ then true
1238+ else !(initialized()))
1239+ then true
1240+ else paused())
1241+ then throw("Invalid removeMargin parameters")
1242+ else {
1243+ let $t05452054660 = getPosition(_trader)
1244+ let oldPositionSize = $t05452054660._1
1245+ let oldPositionMargin = $t05452054660._2
1246+ let oldPositionOpenNotional = $t05452054660._3
1247+ let oldPositionLstUpdCPF = $t05452054660._4
1248+ let marginDelta = -(_amount)
1249+ let $t05469754876 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
1250+ let remainMargin = $t05469754876._1
1251+ let badDebt = $t05469754876._2
1252+ if ((badDebt != 0))
1253+ then throw("Invalid removed margin amount")
1254+ else {
1255+ let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional)
1256+ if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true)))
1257+ then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
1258+ else {
1259+ let quoteAssetStr = toBase58String(quoteAsset())
1260+ let $t05532055374 = getBorrowedByTrader(_trader)
1261+ let borrowed = $t05532055374._1
1262+ let assetId = $t05532055374._2
1263+ let toRepay = if ((_amount > borrowed))
1264+ then borrowed
1265+ else _amount
1266+ let toWithdraw = if ((borrowed > _amount))
1267+ then 0
1268+ else (_amount - borrowed)
1269+ let finalBorrow = (borrowed - toRepay)
1270+ let switchPositionToQuote = if ((finalBorrow > 0))
1271+ then nil
1272+ else updatePositionAsset(_trader, quoteAssetStr)
1273+ let doSanityCheck = if (((toRepay + toWithdraw) != _amount))
1274+ then throw(((((("toRepay=" + toString(toRepay)) + " + toWithdraw=") + toString(toWithdraw)) + " != ") + toString(_amount)))
1275+ else nil
1276+ if ((doSanityCheck == doSanityCheck))
1277+ then {
1278+ let doUnstake = invoke(managerAddress(), "withdraw", [quoteAssetStr, _amount], nil)
1279+ if ((doUnstake == doUnstake))
1280+ then {
1281+ let returnCollateralAction = if ((toRepay > 0))
1282+ then {
1283+ let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), toRepay)])
1284+ if ((doRepay == doRepay))
1285+ then [ScriptTransfer(i.caller, toRepay, fromBase58String(assetId))]
1286+ else throw("Strict value is not equal to itself.")
1287+ }
1288+ else nil
1289+ if ((returnCollateralAction == returnCollateralAction))
1290+ then (updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ (if ((toWithdraw > 0))
1291+ then withdraw(i.caller, toWithdraw)
1292+ else (((nil ++ updateBalance((cbalance() - _amount))) ++ switchPositionToQuote) ++ returnCollateralAction)))
1293+ else throw("Strict value is not equal to itself.")
1294+ }
1295+ else throw("Strict value is not equal to itself.")
1296+ }
1297+ else throw("Strict value is not equal to itself.")
1298+ }
1299+ }
1300+ }
1301+ }
10691302
10701303
10711304
10721305 @Callable(i)
10731306 func closePosition () = {
1074- let caller = getActualCaller(i)
1075- let callerAddress = valueOrErrorMessage(addressFromString(caller), "Invalid caller")
1076- if (if (if (!(requireOpenPosition(caller)))
1307+ let _trader = getActualCaller(i)
1308+ let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller")
1309+ if (if (if (!(requireOpenPosition(_trader)))
10771310 then true
10781311 else !(initialized()))
10791312 then true
10801313 else paused())
10811314 then throw("Invalid closePosition parameters")
10821315 else {
1083- let $t04958049957 = internalClosePosition(caller, true)
1084- let x1 = $t04958049957._1
1085- let positionBadDebt = $t04958049957._2
1086- let realizedPnl = $t04958049957._3
1087- let marginToVault = $t04958049957._4
1088- let quoteAssetReserveAfter = $t04958049957._5
1089- let baseAssetReserveAfter = $t04958049957._6
1090- let totalPositionSizeAfter = $t04958049957._7
1091- let cumulativeNotionalAfter = $t04958049957._8
1092- let openInterestNotionalAfter = $t04958049957._9
1093- let x2 = $t04958049957._10
1094- let totalLongAfter = $t04958049957._11
1095- let totalShortAfter = $t04958049957._12
1316+ let $t05756657944 = internalClosePosition(_trader, true)
1317+ let x1 = $t05756657944._1
1318+ let positionBadDebt = $t05756657944._2
1319+ let realizedPnl = $t05756657944._3
1320+ let marginToVault = $t05756657944._4
1321+ let quoteAssetReserveAfter = $t05756657944._5
1322+ let baseAssetReserveAfter = $t05756657944._6
1323+ let totalPositionSizeAfter = $t05756657944._7
1324+ let cumulativeNotionalAfter = $t05756657944._8
1325+ let openInterestNotionalAfter = $t05756657944._9
1326+ let x2 = $t05756657944._10
1327+ let totalLongAfter = $t05756657944._11
1328+ let totalShortAfter = $t05756657944._12
10961329 if ((positionBadDebt > 0))
10971330 then throw("Unable to close position with bad debt")
10981331 else {
10991332 let withdrawAmount = abs(marginToVault)
11001333 let ammBalance = (cbalance() - withdrawAmount)
1101- let $t05016650308 = if ((0 > ammBalance))
1334+ let $t05815358295 = if ((0 > ammBalance))
11021335 then $Tuple2(0, abs(ammBalance))
11031336 else $Tuple2(ammBalance, 0)
1104- let ammNewBalance = $t05016650308._1
1105- let getFromInsurance = $t05016650308._2
1337+ let ammNewBalance = $t05815358295._1
1338+ let getFromInsurance = $t05815358295._2
11061339 let x = if ((getFromInsurance > 0))
11071340 then {
11081341 let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil)
11091342 if ((withdrawInsurance == withdrawInsurance))
11101343 then nil
11111344 else throw("Strict value is not equal to itself.")
11121345 }
11131346 else nil
11141347 if ((x == x))
11151348 then {
11161349 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (withdrawAmount - getFromInsurance)], nil)
11171350 if ((unstake == unstake))
11181351 then {
1119- let notifyNotional = invoke(minerAddress(), "notifyNotional", [caller, 0], nil)
1120- if ((notifyNotional == notifyNotional))
1121- then (((deletePosition(caller) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(callerAddress, withdrawAmount)) ++ updateBalance(ammNewBalance))
1352+ let $t05879758851 = getBorrowedByTrader(_trader)
1353+ let borrowed = $t05879758851._1
1354+ let assetId = $t05879758851._2
1355+ let $t05886659783 = if ((borrowed > 0))
1356+ then if ((withdrawAmount >= borrowed))
1357+ then {
1358+ let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), borrowed)])
1359+ if ((doRepay == doRepay))
1360+ then $Tuple2([ScriptTransfer(_traderAddress, borrowed, fromBase58String(assetId))], (withdrawAmount - borrowed))
1361+ else throw("Strict value is not equal to itself.")
1362+ }
1363+ else {
1364+ let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], [AttachedPayment(quoteAsset(), withdrawAmount)])
1365+ if ((realizeAndClose == realizeAndClose))
1366+ then $Tuple2([ScriptTransfer(_traderAddress, withdrawAmount, fromBase58String(assetId))], 0)
1367+ else throw("Strict value is not equal to itself.")
1368+ }
1369+ else $Tuple2(nil, withdrawAmount)
1370+ if (($t05886659783 == $t05886659783))
1371+ then {
1372+ let quoteWithdrawAmount = $t05886659783._2
1373+ let sendCollateralAction = $t05886659783._1
1374+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1375+ if ((notifyNotional == notifyNotional))
1376+ then ((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ (if ((quoteWithdrawAmount > 0))
1377+ then withdraw(_traderAddress, quoteWithdrawAmount)
1378+ else ((nil ++ updateBalance(ammNewBalance)) ++ sendCollateralAction)))
1379+ else throw("Strict value is not equal to itself.")
1380+ }
11221381 else throw("Strict value is not equal to itself.")
11231382 }
11241383 else throw("Strict value is not equal to itself.")
11251384 }
11261385 else throw("Strict value is not equal to itself.")
11271386 }
11281387 }
11291388 }
11301389
11311390
11321391
11331392 @Callable(i)
11341393 func liquidate (_trader) = {
11351394 let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
11361395 let marginRatio = if (isOverFluctuationLimit())
11371396 then {
11381397 let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE)
11391398 vmax(spotMarginRatio, oracleMarginRatio)
11401399 }
11411400 else spotMarginRatio
11421401 if (if (if (if (!(requireMoreMarginRatio(marginRatio, maintenanceMarginRatio(), false)))
11431402 then true
11441403 else !(requireOpenPosition(_trader)))
11451404 then true
11461405 else !(initialized()))
11471406 then true
11481407 else paused())
11491408 then throw("Unable to liquidate")
11501409 else if (if (if ((spotMarginRatio > liquidationFeeRatio()))
11511410 then (partialLiquidationRatio() > 0)
11521411 else false)
11531412 then (DECIMAL_UNIT > partialLiquidationRatio())
11541413 else false)
11551414 then {
1156- let $t05237952529 = getPosition(_trader)
1157- let oldPositionSize = $t05237952529._1
1158- let oldPositionMargin = $t05237952529._2
1159- let oldPositionOpenNotional = $t05237952529._3
1160- let oldPositionLstUpdCPF = $t05237952529._4
1415+ let $t06148361633 = getPosition(_trader)
1416+ let oldPositionSize = $t06148361633._1
1417+ let oldPositionMargin = $t06148361633._2
1418+ let oldPositionOpenNotional = $t06148361633._3
1419+ let oldPositionLstUpdCPF = $t06148361633._4
11611420 let _direction = if ((oldPositionSize > 0))
11621421 then DIR_SHORT
11631422 else DIR_LONG
11641423 let isAdd = (_direction == DIR_LONG)
11651424 let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize)
1166- let $t05275452858 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1167- let oldPositionNotional = $t05275452858._1
1168- let unrealizedPnl = $t05275452858._2
1169- let $t05286653156 = swapInput(isAdd, exchangedQuoteAssetAmount)
1170- let exchangedPositionSize = $t05286653156._1
1171- let quoteAssetReserveAfter = $t05286653156._2
1172- let baseAssetReserveAfter = $t05286653156._3
1173- let totalPositionSizeAfter = $t05286653156._4
1174- let cumulativeNotionalAfter = $t05286653156._5
1175- let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize))
1176- let $t05326353496 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1177- let remainMargin = $t05326353496._1
1178- let badDebt = $t05326353496._2
1179- let fundingPayment = $t05326353496._3
1425+ let $t06185861962 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1426+ let oldPositionNotional = $t06185861962._1
1427+ let unrealizedPnl = $t06185861962._2
1428+ let $t06197062202 = swapInput(isAdd, exchangedQuoteAssetAmount)
1429+ let exchangedPositionSize = $t06197062202._1
1430+ let quoteAssetReserveAfter = $t06197062202._2
1431+ let baseAssetReserveAfter = $t06197062202._3
1432+ let totalPositionSizeAfter = $t06197062202._4
1433+ let cumulativeNotionalAfter = $t06197062202._5
1434+ let liquidationRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize))
1435+ let realizedPnl = muld(unrealizedPnl, liquidationRatio)
1436+ let $t06241362646 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1437+ let remainMargin = $t06241362646._1
1438+ let badDebt = $t06241362646._2
1439+ let fundingPayment = $t06241362646._3
11801440 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
11811441 let remainOpenNotional = if ((oldPositionSize > 0))
11821442 then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
11831443 else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
11841444 let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
11851445 let feeToLiquidator = (liquidationPenalty / 2)
11861446 let feeToInsurance = (liquidationPenalty - feeToLiquidator)
11871447 let newPositionMargin = (remainMargin - liquidationPenalty)
11881448 let newPositionSize = (oldPositionSize + exchangedPositionSize)
11891449 let newPositionOpenNotional = abs(remainOpenNotional)
11901450 let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize)
11911451 let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount)
11921452 let ammBalance = (cbalance() - liquidationPenalty)
1193- let $t05466954812 = if ((0 > ammBalance))
1453+ let $t06381963962 = if ((0 > ammBalance))
11941454 then $Tuple2(0, abs(ammBalance))
11951455 else $Tuple2(ammBalance, 0)
1196- let newAmmBalance = $t05466954812._1
1197- let takeFromInsurance = $t05466954812._2
1198- let x = if ((takeFromInsurance > 0))
1456+ let newAmmBalance = $t06381963962._1
1457+ let takeFromInsurance = $t06381963962._2
1458+ let $t06397064024 = getBorrowedByTrader(_trader)
1459+ let borrowed = $t06397064024._1
1460+ let assetId = $t06397064024._2
1461+ let doLiquidateCollateral = if ((borrowed > 0))
11991462 then {
1200- let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1201- if ((withdrawInsurance == withdrawInsurance))
1463+ let collateralToSell = muld(borrowed, liquidationRatio)
1464+ let realizeAndClose = invoke(collateralAddress(), "realizePartially", [_trader, assetId, collateralToSell], nil)
1465+ if ((realizeAndClose == realizeAndClose))
12021466 then nil
12031467 else throw("Strict value is not equal to itself.")
12041468 }
12051469 else nil
1206- if ((x == x))
1470+ if ((doLiquidateCollateral == doLiquidateCollateral))
12071471 then {
1208- let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil)
1209- if ((unstake == unstake))
1472+ let x = if ((takeFromInsurance > 0))
12101473 then {
1211- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1212- if ((depositInsurance == depositInsurance))
1474+ let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1475+ if ((withdrawInsurance == withdrawInsurance))
1476+ then nil
1477+ else throw("Strict value is not equal to itself.")
1478+ }
1479+ else nil
1480+ if ((x == x))
1481+ then {
1482+ let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil)
1483+ if ((unstake == unstake))
12131484 then {
1214- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1215- if ((notifyNotional == notifyNotional))
1216- then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1217- then abs(exchangedPositionSize)
1218- else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1219- then abs(exchangedPositionSize)
1220- else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1485+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1486+ if ((depositInsurance == depositInsurance))
1487+ then {
1488+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1489+ if ((notifyNotional == notifyNotional))
1490+ then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1491+ then abs(exchangedPositionSize)
1492+ else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1493+ then abs(exchangedPositionSize)
1494+ else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1495+ else throw("Strict value is not equal to itself.")
1496+ }
12211497 else throw("Strict value is not equal to itself.")
12221498 }
12231499 else throw("Strict value is not equal to itself.")
12241500 }
12251501 else throw("Strict value is not equal to itself.")
12261502 }
12271503 else throw("Strict value is not equal to itself.")
12281504 }
12291505 else {
1230- let $t05625956714 = internalClosePosition(_trader, false)
1231- let x1 = $t05625956714._1
1232- let badDebt = $t05625956714._2
1233- let x2 = $t05625956714._3
1234- let x3 = $t05625956714._4
1235- let quoteAssetReserveAfter = $t05625956714._5
1236- let baseAssetReserveAfter = $t05625956714._6
1237- let totalPositionSizeAfter = $t05625956714._7
1238- let cumulativeNotionalAfter = $t05625956714._8
1239- let openInterestNotionalAfter = $t05625956714._9
1240- let exchangedQuoteAssetAmount = $t05625956714._10
1241- let totalLongAfter = $t05625956714._11
1242- let totalShortAfter = $t05625956714._12
1506+ let $t06586666321 = internalClosePosition(_trader, false)
1507+ let x1 = $t06586666321._1
1508+ let badDebt = $t06586666321._2
1509+ let x2 = $t06586666321._3
1510+ let x3 = $t06586666321._4
1511+ let quoteAssetReserveAfter = $t06586666321._5
1512+ let baseAssetReserveAfter = $t06586666321._6
1513+ let totalPositionSizeAfter = $t06586666321._7
1514+ let cumulativeNotionalAfter = $t06586666321._8
1515+ let openInterestNotionalAfter = $t06586666321._9
1516+ let exchangedQuoteAssetAmount = $t06586666321._10
1517+ let totalLongAfter = $t06586666321._11
1518+ let totalShortAfter = $t06586666321._12
12431519 let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
12441520 let feeToLiquidator = (liquidationPenalty / 2)
12451521 let feeToInsurance = (liquidationPenalty - feeToLiquidator)
12461522 let ammBalance = (cbalance() - liquidationPenalty)
1247- let $t05712657269 = if ((0 > ammBalance))
1523+ let $t06673366876 = if ((0 > ammBalance))
12481524 then $Tuple2(0, abs(ammBalance))
12491525 else $Tuple2(ammBalance, 0)
1250- let newAmmBalance = $t05712657269._1
1251- let takeFromInsurance = $t05712657269._2
1252- let x = if ((takeFromInsurance > 0))
1526+ let newAmmBalance = $t06673366876._1
1527+ let takeFromInsurance = $t06673366876._2
1528+ let $t06688466938 = getBorrowedByTrader(_trader)
1529+ let borrowed = $t06688466938._1
1530+ let assetId = $t06688466938._2
1531+ let doLiquidateCollateral = if ((borrowed > 0))
12531532 then {
1254- let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1255- if ((withdrawInsurance == withdrawInsurance))
1533+ let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], nil)
1534+ if ((realizeAndClose == realizeAndClose))
12561535 then nil
12571536 else throw("Strict value is not equal to itself.")
12581537 }
12591538 else nil
1260- if ((x == x))
1539+ if ((doLiquidateCollateral == doLiquidateCollateral))
12611540 then {
1262- let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil)
1263- if ((unstake == unstake))
1541+ let x = if ((takeFromInsurance > 0))
12641542 then {
1265- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1266- if ((depositInsurance == depositInsurance))
1543+ let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1544+ if ((withdrawInsurance == withdrawInsurance))
1545+ then nil
1546+ else throw("Strict value is not equal to itself.")
1547+ }
1548+ else nil
1549+ if ((x == x))
1550+ then {
1551+ let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil)
1552+ if ((unstake == unstake))
12671553 then {
1268- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1269- if ((notifyNotional == notifyNotional))
1270- then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1554+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1555+ if ((depositInsurance == depositInsurance))
1556+ then {
1557+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1558+ if ((notifyNotional == notifyNotional))
1559+ then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1560+ else throw("Strict value is not equal to itself.")
1561+ }
12711562 else throw("Strict value is not equal to itself.")
12721563 }
12731564 else throw("Strict value is not equal to itself.")
12741565 }
12751566 else throw("Strict value is not equal to itself.")
12761567 }
12771568 else throw("Strict value is not equal to itself.")
12781569 }
12791570 }
12801571
12811572
12821573
12831574 @Callable(i)
12841575 func payFunding () = {
12851576 let fundingBlockTimestamp = nextFundingBlockTimestamp()
12861577 if (if (if ((fundingBlockTimestamp > lastBlock.timestamp))
12871578 then true
12881579 else !(initialized()))
12891580 then true
12901581 else paused())
12911582 then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp)))
12921583 else {
12931584 let underlyingPrice = getOracleTwapPrice()
1294- let $t05875558817 = getFunding()
1295- let shortPremiumFraction = $t05875558817._1
1296- let longPremiumFraction = $t05875558817._2
1585+ let $t06873668798 = getFunding()
1586+ let shortPremiumFraction = $t06873668798._1
1587+ let longPremiumFraction = $t06873668798._2
12971588 updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
12981589 }
12991590 }
13001591
13011592
13021593
13031594 @Callable(i)
13041595 func forceMoveAsset (_trader,_amount) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller))
13051596 then true
13061597 else (0 > _amount))
13071598 then throw("Invalid forceMoveAsset parameters")
13081599 else {
13091600 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil)
13101601 if ((unstake == unstake))
13111602 then (withdraw(addressFromStringValue(_trader), _amount) ++ updateBalance((cbalance() - _amount)))
13121603 else throw("Strict value is not equal to itself.")
13131604 }
13141605
13151606
13161607
13171608 @Callable(i)
13181609 func adjustPeg (_price) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller))
13191610 then true
13201611 else (0 > _price))
13211612 then throw("Invalid adjustPeg parameters")
13221613 else {
1323- let $t05980859894 = getPegAdjustCost(_price)
1324- let newQuoteAssetReserve = $t05980859894._1
1325- let pegChangeCost = $t05980859894._2
1614+ let $t06978969875 = getPegAdjustCost(_price)
1615+ let newQuoteAssetReserve = $t06978969875._1
1616+ let pegChangeCost = $t06978969875._2
13261617 if ((pegChangeCost == 0))
13271618 then throw("Nothing to adjust")
13281619 else if ((pegChangeCost > 0))
13291620 then updateAmmReserves(newQuoteAssetReserve, bsAstR())
13301621 else {
13311622 let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), abs(pegChangeCost)], nil)
13321623 if ((unstake == unstake))
13331624 then {
13341625 let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), abs(pegChangeCost))])
13351626 if ((depositInsurance == depositInsurance))
13361627 then (updateBalance((cbalance() - abs(pegChangeCost))) ++ updateAmmReserves(newQuoteAssetReserve, bsAstR()))
13371628 else throw("Strict value is not equal to itself.")
13381629 }
13391630 else throw("Strict value is not equal to itself.")
13401631 }
13411632 }
13421633
13431634
13441635
13451636 @Callable(i)
13461637 func migrateLiquidity () = {
13471638 let amount = cbalance()
1348- let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil)
1349- if ((unstake == unstake))
1639+ if ((amount > 0))
13501640 then {
1351- let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)])
1352- if ((stake == stake))
1353- then nil
1641+ let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil)
1642+ if ((unstake == unstake))
1643+ then {
1644+ let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)])
1645+ if ((stake == stake))
1646+ then nil
1647+ else throw("Strict value is not equal to itself.")
1648+ }
13541649 else throw("Strict value is not equal to itself.")
13551650 }
1356- else throw("Strict value is not equal to itself.")
1651+ else nil
13571652 }
13581653
13591654
13601655
13611656 @Callable(i)
13621657 func v_get (_trader) = {
1363- let $t06146361523 = internalClosePosition(_trader, false)
1364- let x1 = $t06146361523._1
1365- let x2 = $t06146361523._2
1366- let x3 = $t06146361523._3
1367- let x4 = $t06146361523._4
1658+ let $t07151671576 = internalClosePosition(_trader, false)
1659+ let x1 = $t07151671576._1
1660+ let x2 = $t07151671576._2
1661+ let x3 = $t07151671576._3
1662+ let x4 = $t07151671576._4
13681663 throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader))))
13691664 }
13701665
13711666
13721667
13731668 @Callable(i)
13741669 func view_calcRemainMarginWithFundingPayment (_trader) = {
1375- let $t06167061781 = getPosition(_trader)
1376- let positionSize = $t06167061781._1
1377- let positionMargin = $t06167061781._2
1378- let pon = $t06167061781._3
1379- let positionLstUpdCPF = $t06167061781._4
1380- let $t06178661887 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1381- let positionNotional = $t06178661887._1
1382- let unrealizedPnl = $t06178661887._2
1383- let $t06189262074 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1384- let remainMargin = $t06189262074._1
1385- let badDebt = $t06189262074._2
1386- let fundingPayment = $t06189262074._3
1670+ let $t07172371834 = getPosition(_trader)
1671+ let positionSize = $t07172371834._1
1672+ let positionMargin = $t07172371834._2
1673+ let pon = $t07172371834._3
1674+ let positionLstUpdCPF = $t07172371834._4
1675+ let $t07183971940 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1676+ let positionNotional = $t07183971940._1
1677+ let unrealizedPnl = $t07183971940._2
1678+ let $t07194572127 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1679+ let remainMargin = $t07194572127._1
1680+ let badDebt = $t07194572127._2
1681+ let fundingPayment = $t07194572127._3
13871682 throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)))
13881683 }
13891684
13901685
13911686
13921687 @Callable(i)
13931688 func view_getPegAdjustCost (_price) = {
13941689 let cost = getPegAdjustCost(_price)
13951690 throw(toString(cost._2))
13961691 }
13971692
13981693
13991694
14001695 @Callable(i)
14011696 func view_getFunding () = {
14021697 let underlyingPrice = getOracleTwapPrice()
1403- let $t06246562527 = getFunding()
1404- let shortPremiumFraction = $t06246562527._1
1405- let longPremiumFraction = $t06246562527._2
1698+ let $t07251872580 = getFunding()
1699+ let shortPremiumFraction = $t07251872580._1
1700+ let longPremiumFraction = $t07251872580._2
14061701 let longFunding = divd(longPremiumFraction, underlyingPrice)
14071702 let shortFunding = divd(shortPremiumFraction, underlyingPrice)
14081703 throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOracleTwapPrice())))
1704+ }
1705+
1706+
1707+
1708+@Callable(i)
1709+func view_getBorrowedByTrader (_trader) = {
1710+ let $t07287072924 = getBorrowedByTrader(_trader)
1711+ let borrowed = $t07287072924._1
1712+ let assetId = $t07287072924._2
1713+ throw((s(borrowed) + assetId))
14091714 }
14101715
14111716
14121717 @Verifier(tx)
14131718 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
14141719

github/deemru/w8io/169f3d6 
257.62 ms