tx · 9Vyfi5f9oSfnL6MaJMhccRtq1JAoR5noz64AddKGmSiL

3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH:  -0.04900000 Waves

2022.08.29 22:18 [2206149] smart account 3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH > SELF 0.00000000 Waves

{ "type": 13, "id": "9Vyfi5f9oSfnL6MaJMhccRtq1JAoR5noz64AddKGmSiL", "fee": 4900000, "feeAssetId": null, "timestamp": 1661800731187, "version": 2, "chainId": 84, "sender": "3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH", "senderPublicKey": "Hj6oyH6As5UWo8fZ1K4hPsEY7nxH3MvhBqDD6axiwjXs", "proofs": [ "gmRbFpPrUpkkdbDRkTEaX1UgGGcydQmJXisx6K8qUoE6RsxEuq2g5wUXV4S6RWf4C3AwEZoXgpnFKtF2m5DZBiT" ], "script": "base64:BgJiCAISABIAEgMKAQESAwoBARILCgkBAQEBAQEBAQESEAoOAQEBAQEBAQgICAEBAQESAwoBARIFCgMBAQESBQoDAQEBEgASAwoBARIAEgMKAQgSABIDCgEIEgMKAQgSBAoCCAF/AAlrX29yYV9rZXkCCWtfb3JhX2tleQAPa19vcmFfYmxvY2tfa2V5Ag9rX29yYV9ibG9ja19rZXkABWtfb3JhAgVrX29yYQAJa19iYWxhbmNlAglrX2JhbGFuY2UADmtfcG9zaXRpb25TaXplAg5rX3Bvc2l0aW9uU2l6ZQAQa19wb3NpdGlvbk1hcmdpbgIQa19wb3NpdGlvbk1hcmdpbgAWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAIWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAAua19wb3NpdGlvbkxhc3RVcGRhdGVkQ3VtdWxhdGl2ZVByZW1pdW1GcmFjdGlvbgISa19wb3NpdGlvbkZyYWN0aW9uAA1rX2luaXRpYWxpemVkAg1rX2luaXRpYWxpemVkAAhrX3BhdXNlZAIIa19wYXVzZWQABWtfZmVlAgVrX2ZlZQAPa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vuc3Rha2UJAPwHBAkBEXF1b3RlQXNzZXRTdGFraW5nAAIOdW5sb2NrTmV1dHJpbm8JAMwIAgUHX2Ftb3VudAkAzAgCCQDYBAEJAQpxdW90ZUFzc2V0AAUDbmlsBQNuaWwDCQAAAgUHdW5zdGFrZQUHdW5zdGFrZQkAzggCCQEId2l0aGRyYXcCCQERQGV4dHJOYXRpdmUoMTA2MikBBQdfdHJhZGVyBQdfYW1vdW50CQENdXBkYXRlQmFsYW5jZQEJAGUCCQEIY2JhbGFuY2UABQdfYW1vdW50CQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAkBDmFkbWluUHVibGljS2V5AMe2r1k=", "height": 2206149, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H8RBFe1rwD7zdhDn48UVL2PmY4pEYjR1cyfXDKhwhJVJ Next: 6Znb8ZnUjQjNn75JbKbhqcFT1cCLEiTyMKVrWkqAPpcE Diff:
OldNewDifferences
3131
3232 let k_liquidationFeeRatio = "k_liquidationFeeRatio"
3333
34+let k_partialLiquidationRatio = "k_partLiquidationRatio"
35+
3436 let k_spreadLimit = "k_spreadLimit"
3537
3638 let k_maxPriceImpact = "k_maxPriceImpact"
39+
40+let k_maxPriceSpread = "k_maxPriceSpread"
3741
3842 let k_lastDataStr = "k_lastDataStr"
3943
229233 func liquidationFeeRatio () = int(k_liquidationFeeRatio)
230234
231235
236+func partialLiquidationRatio () = int(k_partialLiquidationRatio)
237+
238+
232239 func spreadLimit () = int(k_spreadLimit)
233240
234241
235242 func maxPriceImpact () = int(k_maxPriceImpact)
243+
244+
245+func maxPriceSpread () = int(k_maxPriceSpread)
236246
237247
238248 func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction)
317327 let amountBaseAssetBought = if (_isAdd)
318328 then amountBaseAssetBoughtAbs
319329 else -(amountBaseAssetBoughtAbs)
320- let $t01183712030 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
321- let quoteAssetReserveAfter1 = $t01183712030._1
322- let baseAssetReserveAfter1 = $t01183712030._2
323- let totalPositionSizeAfter1 = $t01183712030._3
324- let cumulativeNotionalAfter1 = $t01183712030._4
330+ let $t01217712370 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
331+ let quoteAssetReserveAfter1 = $t01217712370._1
332+ let baseAssetReserveAfter1 = $t01217712370._2
333+ let totalPositionSizeAfter1 = $t01217712370._3
334+ let cumulativeNotionalAfter1 = $t01217712370._4
325335 let priceBefore = divd(_qtAstR, _bsAstR)
326336 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
327337 let priceDiff = abs((priceBefore - marketPrice))
341351 }
342352 else 0
343353 let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin)
344- let $t01352113648 = if ((0 > signedMargin))
354+ let $t01386113988 = if ((0 > signedMargin))
345355 then $Tuple2(0, abs(signedMargin))
346356 else $Tuple2(abs(signedMargin), 0)
347- let remainMargin = $t01352113648._1
348- let badDebt = $t01352113648._2
357+ let remainMargin = $t01386113988._1
358+ let badDebt = $t01386113988._2
349359 $Tuple3(remainMargin, badDebt, fundingPayment)
350360 }
351361
352362
353-func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = {
354- let _quoteAssetReserve = qtAstR()
355- let _baseAssetReserve = bsAstR()
363+func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_baseAssetReserve) = {
356364 let priceBefore = divd(_quoteAssetReserve, _baseAssetReserve)
357365 if ((_baseAssetAmount == 0))
358366 then throw("Invalid base asset amount")
364372 let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter)
365373 let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve))
366374 let maxPriceImpactValue = maxPriceImpact()
367- let $t01463214825 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
368- let quoteAssetReserveAfter1 = $t01463214825._1
369- let baseAssetReserveAfter1 = $t01463214825._2
370- let totalPositionSizeAfter1 = $t01463214825._3
371- let cumulativeNotionalAfter1 = $t01463214825._4
375+ let $t01496515158 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
376+ let quoteAssetReserveAfter1 = $t01496515158._1
377+ let baseAssetReserveAfter1 = $t01496515158._2
378+ let totalPositionSizeAfter1 = $t01496515158._3
379+ let cumulativeNotionalAfter1 = $t01496515158._4
372380 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
373381 let priceDiff = abs((priceBefore - marketPrice))
374382 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
376384 then _checkMaxPriceImpact
377385 else false)
378386 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)))
379- else $Tuple7(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd)
387+ else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd)
380388 then abs(_baseAssetAmount)
381389 else 0)), (totalShortPositionSize() - (if (!(_isAdd))
382390 then abs(_baseAssetAmount)
383- else 0)))
391+ else 0)), priceImpact)
384392 }
385393 }
394+
395+
396+func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), bsAstR())
386397
387398
388399 func getOracleTwapPrice () = {
391402 let blockKey = getStringValue(this, k_ora_block_key)
392403 let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey))
393404 lastValue
405+ }
406+
407+
408+func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = {
409+ let oraclePrice = getOracleTwapPrice()
410+ let priceAfter = divd(_quoteAssetReserve, _baseAssetReserve)
411+ let averagePrice = divd((oraclePrice + priceAfter), (2 * DECIMAL_UNIT))
412+ let absPriceDiff = divd(abs((oraclePrice - priceAfter)), averagePrice)
413+ if ((absPriceDiff > maxPriceSpread()))
414+ then throw(((("Price spread " + toString(absPriceDiff)) + " > max price spread ") + toString(maxPriceSpread())))
415+ else true
394416 }
395417
396418
408430 }
409431
410432
433+func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_baseAssetReserve) = {
434+ let positionSizeAbs = abs(_positionSize)
435+ let isShort = (0 > _positionSize)
436+ let positionNotional = if ((_option == PNL_OPTION_SPOT))
437+ then {
438+ let $t01837618547 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve)
439+ let outPositionNotional = $t01837618547._1
440+ let x1 = $t01837618547._2
441+ let x2 = $t01837618547._3
442+ let x3 = $t01837618547._4
443+ outPositionNotional
444+ }
445+ else muld(positionSizeAbs, getOracleTwapPrice())
446+ positionNotional
447+ }
448+
449+
411450 func getPositionNotionalAndUnrealizedPnl (_trader,_option) = {
412- let $t01729317421 = getPosition(_trader)
413- let positionSize = $t01729317421._1
414- let positionMargin = $t01729317421._2
415- let positionOpenNotional = $t01729317421._3
416- let positionLstUpdCPF = $t01729317421._4
417- let positionSizeAbs = abs(positionSize)
418- if ((positionSizeAbs == 0))
451+ let $t01894119069 = getPosition(_trader)
452+ let positionSize = $t01894119069._1
453+ let positionMargin = $t01894119069._2
454+ let positionOpenNotional = $t01894119069._3
455+ let positionLstUpdCPF = $t01894119069._4
456+ if ((positionSize == 0))
419457 then throw("Invalid position size")
420458 else {
421459 let isShort = (0 > positionSize)
422- let positionNotional = if ((_option == PNL_OPTION_SPOT))
423- then {
424- let $t01766817792 = swapOutput(!(isShort), positionSizeAbs, false)
425- let outPositionNotional = $t01766817792._1
426- let x1 = $t01766817792._2
427- let x2 = $t01766817792._3
428- let x3 = $t01766817792._4
429- outPositionNotional
430- }
431- else muld(positionSizeAbs, getOracleTwapPrice())
460+ let positionNotional = getPositionAdjustedOpenNotional(positionSize, _option, qtAstR(), bsAstR())
432461 let unrealizedPnl = if (isShort)
433462 then (positionOpenNotional - positionNotional)
434463 else (positionNotional - positionOpenNotional)
441470
442471
443472 func getMarginRatioByOption (_trader,_option) = {
444- let $t01846218573 = getPosition(_trader)
445- let positionSize = $t01846218573._1
446- let positionMargin = $t01846218573._2
447- let pon = $t01846218573._3
448- let positionLstUpdCPF = $t01846218573._4
449- let $t01857918672 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
450- let positionNotional = $t01857918672._1
451- let unrealizedPnl = $t01857918672._2
452- let $t01867718843 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
453- let remainMargin = $t01867718843._1
454- let badDebt = $t01867718843._2
473+ let $t01990220013 = getPosition(_trader)
474+ let positionSize = $t01990220013._1
475+ let positionMargin = $t01990220013._2
476+ let pon = $t01990220013._3
477+ let positionLstUpdCPF = $t01990220013._4
478+ let $t02001920112 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
479+ let positionNotional = $t02001920112._1
480+ let unrealizedPnl = $t02001920112._2
481+ let $t02011720283 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
482+ let remainMargin = $t02011720283._1
483+ let badDebt = $t02011720283._2
455484 calcMarginRatio(remainMargin, badDebt, positionNotional)
456485 }
457486
459488 func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
460489
461490
491+func getPartialLiquidationAmount (_trader,_positionSize) = {
492+ let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio())))
493+ let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio)
494+ let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false)
495+ let maxExchangedQuoteAssetAmount = swapResult._1
496+ let priceImpact = swapResult._8
497+ if ((maxPriceImpact() > priceImpact))
498+ then maxExchangedQuoteAssetAmount
499+ else {
500+ let exchangedPositionSize = muld(abs(_positionSize), partialLiquidationRatio())
501+ let exchangedQuoteAssetAmount = swapOutput((_positionSize > 0), exchangedPositionSize, false)._1
502+ exchangedQuoteAssetAmount
503+ }
504+ }
505+
506+
462507 func internalClosePosition (_trader,_checkMaxPriceImpact) = {
463- let $t01919019318 = getPosition(_trader)
464- let positionSize = $t01919019318._1
465- let positionMargin = $t01919019318._2
466- let positionOpenNotional = $t01919019318._3
467- let positionLstUpdCPF = $t01919019318._4
468- let $t01932419411 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
469- let x1 = $t01932419411._1
470- let unrealizedPnl = $t01932419411._2
471- let $t01941619584 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
472- let remainMargin = $t01941619584._1
473- let badDebt = $t01941619584._2
508+ let $t02146521593 = getPosition(_trader)
509+ let positionSize = $t02146521593._1
510+ let positionMargin = $t02146521593._2
511+ let positionOpenNotional = $t02146521593._3
512+ let positionLstUpdCPF = $t02146521593._4
513+ let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2
514+ let $t02168821856 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
515+ let remainMargin = $t02168821856._1
516+ let badDebt = $t02168821856._2
474517 let exchangedPositionSize = -(positionSize)
475518 let realizedPnl = unrealizedPnl
476519 let marginToVault = -(remainMargin)
477- let $t01971120022 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
478- let exchangedQuoteAssetAmount = $t01971120022._1
479- let quoteAssetReserveAfter = $t01971120022._2
480- let baseAssetReserveAfter = $t01971120022._3
481- let totalPositionSizeAfter = $t01971120022._4
482- let cumulativeNotionalAfter = $t01971120022._5
483- let totalLongAfter = $t01971120022._6
484- let totalShortAfter = $t01971120022._7
520+ let $t02198322294 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
521+ let exchangedQuoteAssetAmount = $t02198322294._1
522+ let quoteAssetReserveAfter = $t02198322294._2
523+ let baseAssetReserveAfter = $t02198322294._3
524+ let totalPositionSizeAfter = $t02198322294._4
525+ let cumulativeNotionalAfter = $t02198322294._5
526+ let totalLongAfter = $t02198322294._6
527+ let totalShortAfter = $t02198322294._7
485528 let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional)
486529 $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter)
487530 }
524567 }
525568
526569
527-func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact)]
570+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)]
528571
529572
530573 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)]
637680
638681
639682 @Callable(i)
640-func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = if ((i.caller != adminAddress()))
683+func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress()))
641684 then throw("Invalid changeSettings params")
642- else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact)
685+ else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)
643686
644687
645688
646689 @Callable(i)
647-func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact) = if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
690+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))
648691 then true
649692 else (0 >= _bsAstR))
650693 then true
662705 then true
663706 else (0 >= _maxPriceImpact))
664707 then true
708+ else (0 >= _partialLiquidationRatio))
709+ then true
710+ else (0 >= _maxPriceSpread))
711+ then true
665712 else initialized())
666713 then throw("Invalid initialize parameters")
667- else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)])
668-
669-
670-
671-@Callable(i)
672-func setMaxPriceImpact (_maxPriceImpact) = if (if ((0 >= _maxPriceImpact))
673- then true
674- else !(initialized()))
675- then throw("Invalid _maxPriceImpact parameters")
676- else updateSettings(initMarginRatio(), maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), _maxPriceImpact)
714+ 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)])
677715
678716
679717
682720 then true
683721 else !(initialized()))
684722 then throw("Invalid setInitMarginRatio parameters")
685- else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact())
723+ else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread())
686724
687725
688726
698736 else paused())
699737 then throw("Invalid decreasePosition parameters")
700738 else {
701- let $t03173131883 = getPosition(toString(i.caller))
702- let oldPositionSize = $t03173131883._1
703- let oldPositionMargin = $t03173131883._2
704- let oldPositionOpenNotional = $t03173131883._3
705- let oldPositionLstUpdCPF = $t03173131883._4
739+ let $t03418734339 = getPosition(toString(i.caller))
740+ let oldPositionSize = $t03418734339._1
741+ let oldPositionMargin = $t03418734339._2
742+ let oldPositionOpenNotional = $t03418734339._3
743+ let oldPositionLstUpdCPF = $t03418734339._4
706744 let _direction = if ((oldPositionSize > 0))
707745 then DIR_SHORT
708746 else DIR_LONG
709747 let isAdd = (_direction == DIR_LONG)
710748 let openNotional = muld(_amount, _leverage)
711- let $t03205632172 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
712- let oldPositionNotional = $t03205632172._1
713- let unrealizedPnl = $t03205632172._2
714- let $t03217834727 = if ((oldPositionNotional > openNotional))
749+ let $t03451234628 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
750+ let oldPositionNotional = $t03451234628._1
751+ let unrealizedPnl = $t03451234628._2
752+ let $t03463437183 = if ((oldPositionNotional > openNotional))
715753 then {
716- let $t03255532774 = swapInput(isAdd, openNotional)
717- let exchangedPositionSize = $t03255532774._1
718- let quoteAssetReserveAfter = $t03255532774._2
719- let baseAssetReserveAfter = $t03255532774._3
720- let totalPositionSizeAfter = $t03255532774._4
721- let cumulativeNotionalAfter = $t03255532774._5
754+ let $t03501135230 = swapInput(isAdd, openNotional)
755+ let exchangedPositionSize = $t03501135230._1
756+ let quoteAssetReserveAfter = $t03501135230._2
757+ let baseAssetReserveAfter = $t03501135230._3
758+ let totalPositionSizeAfter = $t03501135230._4
759+ let cumulativeNotionalAfter = $t03501135230._5
722760 let exchangedPositionSizeAbs = abs(exchangedPositionSize)
723761 if (if ((_minBaseAssetAmount != 0))
724762 then (_minBaseAssetAmount > exchangedPositionSizeAbs)
726764 then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount)))
727765 else {
728766 let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize))
729- let $t03321133456 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
730- let remainMargin = $t03321133456._1
731- let badDebt = $t03321133456._2
732- let fundingPayment = $t03321133456._3
767+ let $t03566735912 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
768+ let remainMargin = $t03566735912._1
769+ let badDebt = $t03566735912._2
770+ let fundingPayment = $t03566735912._3
733771 let exchangedQuoteAssetAmount = openNotional
734772 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
735773 let remainOpenNotional = if ((oldPositionSize > 0))
744782 }
745783 }
746784 else throw("Close position first")
747- let newPositionSize = $t03217834727._1
748- let newPositionRemainMargin = $t03217834727._2
749- let newPositionOpenNotional = $t03217834727._3
750- let newPositionLatestCPF = $t03217834727._4
751- let baseAssetReserveAfter = $t03217834727._5
752- let quoteAssetReserveAfter = $t03217834727._6
753- let totalPositionSizeAfter = $t03217834727._7
754- let cumulativeNotionalAfter = $t03217834727._8
755- let openInterestNotionalAfter = $t03217834727._9
756- let totalLongAfter = $t03217834727._10
757- let totalShortAfter = $t03217834727._11
785+ let newPositionSize = $t03463437183._1
786+ let newPositionRemainMargin = $t03463437183._2
787+ let newPositionOpenNotional = $t03463437183._3
788+ let newPositionLatestCPF = $t03463437183._4
789+ let baseAssetReserveAfter = $t03463437183._5
790+ let quoteAssetReserveAfter = $t03463437183._6
791+ let totalPositionSizeAfter = $t03463437183._7
792+ let cumulativeNotionalAfter = $t03463437183._8
793+ let openInterestNotionalAfter = $t03463437183._9
794+ let totalLongAfter = $t03463437183._10
795+ let totalShortAfter = $t03463437183._11
758796 let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil)
759797 if ((notifyNotional == notifyNotional))
760798 then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter))
783821 else {
784822 let feeAmount = muld(_rawAmount, fee())
785823 let _amount = (_rawAmount - feeAmount)
786- let $t03584535997 = getPosition(toString(i.caller))
787- let oldPositionSize = $t03584535997._1
788- let oldPositionMargin = $t03584535997._2
789- let oldPositionOpenNotional = $t03584535997._3
790- let oldPositionLstUpdCPF = $t03584535997._4
824+ let $t03830138453 = getPosition(toString(i.caller))
825+ let oldPositionSize = $t03830138453._1
826+ let oldPositionMargin = $t03830138453._2
827+ let oldPositionOpenNotional = $t03830138453._3
828+ let oldPositionLstUpdCPF = $t03830138453._4
791829 let isNewPosition = (oldPositionSize == 0)
792830 let isSameDirection = if ((oldPositionSize > 0))
793831 then (_direction == DIR_LONG)
796834 then isSameDirection
797835 else false
798836 let isAdd = (_direction == DIR_LONG)
799- let $t03628638675 = if (if (isNewPosition)
837+ let $t03874241310 = if (if (isNewPosition)
800838 then true
801839 else expandExisting)
802840 then {
803841 let openNotional = muld(_amount, _leverage)
804- let $t03671036916 = swapInput(isAdd, openNotional)
805- let amountBaseAssetBought = $t03671036916._1
806- let quoteAssetReserveAfter = $t03671036916._2
807- let baseAssetReserveAfter = $t03671036916._3
808- let totalPositionSizeAfter = $t03671036916._4
809- let cumulativeNotionalAfter = $t03671036916._5
842+ let $t03916639372 = swapInput(isAdd, openNotional)
843+ let amountBaseAssetBought = $t03916639372._1
844+ let quoteAssetReserveAfter = $t03916639372._2
845+ let baseAssetReserveAfter = $t03916639372._3
846+ let totalPositionSizeAfter = $t03916639372._4
847+ let cumulativeNotionalAfter = $t03916639372._5
810848 if (if ((_minBaseAssetAmount != 0))
811849 then (_minBaseAssetAmount > abs(amountBaseAssetBought))
812850 else false)
814852 else {
815853 let newPositionSize = (oldPositionSize + amountBaseAssetBought)
816854 let increaseMarginRequirement = divd(openNotional, _leverage)
817- let $t03729737536 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
818- let remainMargin = $t03729737536._1
819- let x1 = $t03729737536._2
820- let x2 = $t03729737536._3
821- $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
822- then abs(amountBaseAssetBought)
823- else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
824- then abs(amountBaseAssetBought)
825- else 0)))
855+ let $t03975339992 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
856+ let remainMargin = $t03975339992._1
857+ let x1 = $t03975339992._2
858+ let x2 = $t03975339992._3
859+ if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
860+ then throw("Over max spread limit")
861+ else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
862+ then abs(amountBaseAssetBought)
863+ else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
864+ then abs(amountBaseAssetBought)
865+ else 0)))
826866 }
827867 }
828868 else {
829869 let openNotional = muld(_amount, _leverage)
830- let $t03836838484 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
831- let oldPositionNotional = $t03836838484._1
832- let unrealizedPnl = $t03836838484._2
870+ let $t04100341119 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
871+ let oldPositionNotional = $t04100341119._1
872+ let unrealizedPnl = $t04100341119._2
833873 if ((oldPositionNotional > openNotional))
834874 then throw("Use decreasePosition to decrease position size")
835875 else throw("Close position first")
836876 }
837- let newPositionSize = $t03628638675._1
838- let newPositionRemainMargin = $t03628638675._2
839- let newPositionOpenNotional = $t03628638675._3
840- let newPositionLatestCPF = $t03628638675._4
841- let baseAssetReserveAfter = $t03628638675._5
842- let quoteAssetReserveAfter = $t03628638675._6
843- let totalPositionSizeAfter = $t03628638675._7
844- let cumulativeNotionalAfter = $t03628638675._8
845- let openInterestNotionalAfter = $t03628638675._9
846- let totalLongAfter = $t03628638675._10
847- let totalShortAfter = $t03628638675._11
877+ let newPositionSize = $t03874241310._1
878+ let newPositionRemainMargin = $t03874241310._2
879+ let newPositionOpenNotional = $t03874241310._3
880+ let newPositionLatestCPF = $t03874241310._4
881+ let baseAssetReserveAfter = $t03874241310._5
882+ let quoteAssetReserveAfter = $t03874241310._6
883+ let totalPositionSizeAfter = $t03874241310._7
884+ let cumulativeNotionalAfter = $t03874241310._8
885+ let openInterestNotionalAfter = $t03874241310._9
886+ let totalLongAfter = $t03874241310._10
887+ let totalShortAfter = $t03874241310._11
848888 let feeToStakers = (feeAmount / 2)
849889 let feeToInsurance = (feeAmount - feeToStakers)
850890 let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)])
885925 else {
886926 let feeAmount = muld(_rawAmount, fee())
887927 let _amount = (_rawAmount - feeAmount)
888- let $t04023140383 = getPosition(toString(i.caller))
889- let oldPositionSize = $t04023140383._1
890- let oldPositionMargin = $t04023140383._2
891- let oldPositionOpenNotional = $t04023140383._3
892- let oldPositionLstUpdCPF = $t04023140383._4
928+ let $t04286643018 = getPosition(toString(i.caller))
929+ let oldPositionSize = $t04286643018._1
930+ let oldPositionMargin = $t04286643018._2
931+ let oldPositionOpenNotional = $t04286643018._3
932+ let oldPositionLstUpdCPF = $t04286643018._4
893933 let feeToStakers = (feeAmount / 2)
894934 let feeToInsurance = (feeAmount - feeToStakers)
895935 let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)])
921961 else paused())
922962 then throw("Invalid removeMargin parameters")
923963 else {
924- let $t04143241584 = getPosition(toString(i.caller))
925- let oldPositionSize = $t04143241584._1
926- let oldPositionMargin = $t04143241584._2
927- let oldPositionOpenNotional = $t04143241584._3
928- let oldPositionLstUpdCPF = $t04143241584._4
964+ let $t04406744219 = getPosition(toString(i.caller))
965+ let oldPositionSize = $t04406744219._1
966+ let oldPositionMargin = $t04406744219._2
967+ let oldPositionOpenNotional = $t04406744219._3
968+ let oldPositionLstUpdCPF = $t04406744219._4
929969 let marginDelta = -(_amount)
930- let $t04162141800 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
931- let remainMargin = $t04162141800._1
932- let badDebt = $t04162141800._2
970+ let $t04425644435 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
971+ let remainMargin = $t04425644435._1
972+ let badDebt = $t04425644435._2
933973 if ((badDebt != 0))
934974 then throw("Invalid removed margin amount")
935975 else {
955995 else paused())
956996 then throw("Invalid closePosition parameters")
957997 else {
958- let $t04289643286 = internalClosePosition(toString(i.caller), true)
959- let x1 = $t04289643286._1
960- let positionBadDebt = $t04289643286._2
961- let realizedPnl = $t04289643286._3
962- let marginToVault = $t04289643286._4
963- let quoteAssetReserveAfter = $t04289643286._5
964- let baseAssetReserveAfter = $t04289643286._6
965- let totalPositionSizeAfter = $t04289643286._7
966- let cumulativeNotionalAfter = $t04289643286._8
967- let openInterestNotionalAfter = $t04289643286._9
968- let x2 = $t04289643286._10
969- let totalLongAfter = $t04289643286._11
970- let totalShortAfter = $t04289643286._12
998+ let $t04553145921 = internalClosePosition(toString(i.caller), true)
999+ let x1 = $t04553145921._1
1000+ let positionBadDebt = $t04553145921._2
1001+ let realizedPnl = $t04553145921._3
1002+ let marginToVault = $t04553145921._4
1003+ let quoteAssetReserveAfter = $t04553145921._5
1004+ let baseAssetReserveAfter = $t04553145921._6
1005+ let totalPositionSizeAfter = $t04553145921._7
1006+ let cumulativeNotionalAfter = $t04553145921._8
1007+ let openInterestNotionalAfter = $t04553145921._9
1008+ let x2 = $t04553145921._10
1009+ let totalLongAfter = $t04553145921._11
1010+ let totalShortAfter = $t04553145921._12
9711011 if ((positionBadDebt > 0))
9721012 then throw("Unable to close position with bad debt")
9731013 else {
9741014 let withdrawAmount = abs(marginToVault)
9751015 let ammBalance = (cbalance() - withdrawAmount)
976- let $t04349543637 = if ((0 > ammBalance))
1016+ let $t04613046272 = if ((0 > ammBalance))
9771017 then $Tuple2(0, abs(ammBalance))
9781018 else $Tuple2(ammBalance, 0)
979- let ammNewBalance = $t04349543637._1
980- let getFromInsurance = $t04349543637._2
1019+ let ammNewBalance = $t04613046272._1
1020+ let getFromInsurance = $t04613046272._2
9811021 let x = if ((getFromInsurance > 0))
9821022 then {
9831023 let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil)
10211061 then true
10221062 else paused())
10231063 then throw("Unable to liquidate")
1024- else {
1025- let $t04532745750 = internalClosePosition(_trader, false)
1026- let x1 = $t04532745750._1
1027- let badDebt = $t04532745750._2
1028- let x2 = $t04532745750._3
1029- let x3 = $t04532745750._4
1030- let quoteAssetReserveAfter = $t04532745750._5
1031- let baseAssetReserveAfter = $t04532745750._6
1032- let totalPositionSizeAfter = $t04532745750._7
1033- let cumulativeNotionalAfter = $t04532745750._8
1034- let openInterestNotionalAfter = $t04532745750._9
1035- let exchangedQuoteAssetAmount = $t04532745750._10
1036- let totalLongAfter = $t04532745750._11
1037- let totalShortAfter = $t04532745750._12
1038- let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
1039- let feeToLiquidator = (liquidationPenalty / 2)
1040- let feeToInsurance = (liquidationPenalty - feeToLiquidator)
1041- let ammBalance = (cbalance() - liquidationPenalty)
1042- let $t04614846283 = if ((0 > ammBalance))
1043- then $Tuple2(0, abs(ammBalance))
1044- else $Tuple2(ammBalance, 0)
1045- let newAmmBalance = $t04614846283._1
1046- let takeFromInsurance = $t04614846283._2
1047- let x = if ((takeFromInsurance > 0))
1048- then {
1049- let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1050- if ((withdrawInsurance == withdrawInsurance))
1051- then nil
1052- else throw("Strict value is not equal to itself.")
1053- }
1054- else nil
1055- if ((x == x))
1056- then {
1057- let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil)
1058- if ((unstake == unstake))
1059- then {
1060- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1061- if ((depositInsurance == depositInsurance))
1062- then {
1063- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1064- if ((notifyNotional == notifyNotional))
1065- then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1066- else throw("Strict value is not equal to itself.")
1067- }
1068- else throw("Strict value is not equal to itself.")
1069- }
1070- else throw("Strict value is not equal to itself.")
1071- }
1072- else throw("Strict value is not equal to itself.")
1073- }
1064+ else if (if (if ((spotMarginRatio > liquidationFeeRatio()))
1065+ then (partialLiquidationRatio() > 0)
1066+ else false)
1067+ then (DECIMAL_UNIT > partialLiquidationRatio())
1068+ else false)
1069+ then {
1070+ let $t04837348523 = getPosition(_trader)
1071+ let oldPositionSize = $t04837348523._1
1072+ let oldPositionMargin = $t04837348523._2
1073+ let oldPositionOpenNotional = $t04837348523._3
1074+ let oldPositionLstUpdCPF = $t04837348523._4
1075+ let _direction = if ((oldPositionSize > 0))
1076+ then DIR_SHORT
1077+ else DIR_LONG
1078+ let isAdd = (_direction == DIR_LONG)
1079+ let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize)
1080+ let $t04874848852 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1081+ let oldPositionNotional = $t04874848852._1
1082+ let unrealizedPnl = $t04874848852._2
1083+ let $t04886049150 = swapInput(isAdd, exchangedQuoteAssetAmount)
1084+ let exchangedPositionSize = $t04886049150._1
1085+ let quoteAssetReserveAfter = $t04886049150._2
1086+ let baseAssetReserveAfter = $t04886049150._3
1087+ let totalPositionSizeAfter = $t04886049150._4
1088+ let cumulativeNotionalAfter = $t04886049150._5
1089+ let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize))
1090+ let $t04925749490 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1091+ let remainMargin = $t04925749490._1
1092+ let badDebt = $t04925749490._2
1093+ let fundingPayment = $t04925749490._3
1094+ let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
1095+ let remainOpenNotional = if ((oldPositionSize > 0))
1096+ then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
1097+ else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
1098+ let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
1099+ let feeToLiquidator = (liquidationPenalty / 2)
1100+ let feeToInsurance = (liquidationPenalty - feeToLiquidator)
1101+ let newPositionMargin = (remainMargin - liquidationPenalty)
1102+ let newPositionSize = (oldPositionSize + exchangedPositionSize)
1103+ let newPositionOpenNotional = abs(remainOpenNotional)
1104+ let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize)
1105+ let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount)
1106+ let ammBalance = (cbalance() - liquidationPenalty)
1107+ let $t05066350806 = if ((0 > ammBalance))
1108+ then $Tuple2(0, abs(ammBalance))
1109+ else $Tuple2(ammBalance, 0)
1110+ let newAmmBalance = $t05066350806._1
1111+ let takeFromInsurance = $t05066350806._2
1112+ let x = if ((takeFromInsurance > 0))
1113+ then {
1114+ let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1115+ if ((withdrawInsurance == withdrawInsurance))
1116+ then nil
1117+ else throw("Strict value is not equal to itself.")
1118+ }
1119+ else nil
1120+ if ((x == x))
1121+ then {
1122+ let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil)
1123+ if ((unstake == unstake))
1124+ then {
1125+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1126+ if ((depositInsurance == depositInsurance))
1127+ then {
1128+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1129+ if ((notifyNotional == notifyNotional))
1130+ then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1131+ then abs(exchangedPositionSize)
1132+ else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1133+ then abs(exchangedPositionSize)
1134+ else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1135+ else throw("Strict value is not equal to itself.")
1136+ }
1137+ else throw("Strict value is not equal to itself.")
1138+ }
1139+ else throw("Strict value is not equal to itself.")
1140+ }
1141+ else throw("Strict value is not equal to itself.")
1142+ }
1143+ else {
1144+ let $t05226252717 = internalClosePosition(_trader, false)
1145+ let x1 = $t05226252717._1
1146+ let badDebt = $t05226252717._2
1147+ let x2 = $t05226252717._3
1148+ let x3 = $t05226252717._4
1149+ let quoteAssetReserveAfter = $t05226252717._5
1150+ let baseAssetReserveAfter = $t05226252717._6
1151+ let totalPositionSizeAfter = $t05226252717._7
1152+ let cumulativeNotionalAfter = $t05226252717._8
1153+ let openInterestNotionalAfter = $t05226252717._9
1154+ let exchangedQuoteAssetAmount = $t05226252717._10
1155+ let totalLongAfter = $t05226252717._11
1156+ let totalShortAfter = $t05226252717._12
1157+ let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
1158+ let feeToLiquidator = (liquidationPenalty / 2)
1159+ let feeToInsurance = (liquidationPenalty - feeToLiquidator)
1160+ let ammBalance = (cbalance() - liquidationPenalty)
1161+ let $t05312953272 = if ((0 > ammBalance))
1162+ then $Tuple2(0, abs(ammBalance))
1163+ else $Tuple2(ammBalance, 0)
1164+ let newAmmBalance = $t05312953272._1
1165+ let takeFromInsurance = $t05312953272._2
1166+ let x = if ((takeFromInsurance > 0))
1167+ then {
1168+ let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1169+ if ((withdrawInsurance == withdrawInsurance))
1170+ then nil
1171+ else throw("Strict value is not equal to itself.")
1172+ }
1173+ else nil
1174+ if ((x == x))
1175+ then {
1176+ let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil)
1177+ if ((unstake == unstake))
1178+ then {
1179+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1180+ if ((depositInsurance == depositInsurance))
1181+ then {
1182+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1183+ if ((notifyNotional == notifyNotional))
1184+ then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1185+ else throw("Strict value is not equal to itself.")
1186+ }
1187+ else throw("Strict value is not equal to itself.")
1188+ }
1189+ else throw("Strict value is not equal to itself.")
1190+ }
1191+ else throw("Strict value is not equal to itself.")
1192+ }
10741193 }
10751194
10761195
10881207 let underlyingPrice = getOracleTwapPrice()
10891208 let spotTwapPrice = getTwapSpotPrice()
10901209 let premium = (spotTwapPrice - underlyingPrice)
1091- let $t04777749112 = if (if ((totalShortPositionSize() == 0))
1210+ let $t05486056195 = if (if ((totalShortPositionSize() == 0))
10921211 then true
10931212 else (totalLongPositionSize() == 0))
10941213 then $Tuple2(0, 0)
11031222 let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize())
11041223 $Tuple2(shortPremiumFraction, longPremiumFraction)
11051224 }
1106- let shortPremiumFraction = $t04777749112._1
1107- let longPremiumFraction = $t04777749112._2
1225+ let shortPremiumFraction = $t05486056195._1
1226+ let longPremiumFraction = $t05486056195._2
11081227 updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
11091228 }
11101229 }
11131232
11141233 @Callable(i)
11151234 func v_get (_trader) = {
1116- let $t04948749547 = internalClosePosition(_trader, false)
1117- let x1 = $t04948749547._1
1118- let x2 = $t04948749547._2
1119- let x3 = $t04948749547._3
1120- let x4 = $t04948749547._4
1235+ let $t05657056630 = internalClosePosition(_trader, false)
1236+ let x1 = $t05657056630._1
1237+ let x2 = $t05657056630._2
1238+ let x3 = $t05657056630._3
1239+ let x4 = $t05657056630._4
11211240 throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader))))
11221241 }
11231242
11251244
11261245 @Callable(i)
11271246 func view_calcRemainMarginWithFundingPayment (_trader) = {
1128- let $t04969449805 = getPosition(_trader)
1129- let positionSize = $t04969449805._1
1130- let positionMargin = $t04969449805._2
1131- let pon = $t04969449805._3
1132- let positionLstUpdCPF = $t04969449805._4
1133- let $t04981049911 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1134- let positionNotional = $t04981049911._1
1135- let unrealizedPnl = $t04981049911._2
1136- let $t04991650098 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1137- let remainMargin = $t04991650098._1
1138- let badDebt = $t04991650098._2
1139- let fundingPayment = $t04991650098._3
1140- throw(((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)))
1247+ let $t05677756888 = getPosition(_trader)
1248+ let positionSize = $t05677756888._1
1249+ let positionMargin = $t05677756888._2
1250+ let pon = $t05677756888._3
1251+ let positionLstUpdCPF = $t05677756888._4
1252+ let $t05689356994 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1253+ let positionNotional = $t05689356994._1
1254+ let unrealizedPnl = $t05689356994._2
1255+ let $t05699957181 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1256+ let remainMargin = $t05699957181._1
1257+ let badDebt = $t05699957181._2
1258+ let fundingPayment = $t05699957181._3
1259+ throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)))
11411260 }
11421261
11431262
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_initialized = "k_initialized"
2121
2222 let k_paused = "k_paused"
2323
2424 let k_fee = "k_fee"
2525
2626 let k_fundingPeriod = "k_fundingPeriod"
2727
2828 let k_initMarginRatio = "k_initMarginRatio"
2929
3030 let k_maintenanceMarginRatio = "k_mmr"
3131
3232 let k_liquidationFeeRatio = "k_liquidationFeeRatio"
3333
34+let k_partialLiquidationRatio = "k_partLiquidationRatio"
35+
3436 let k_spreadLimit = "k_spreadLimit"
3537
3638 let k_maxPriceImpact = "k_maxPriceImpact"
39+
40+let k_maxPriceSpread = "k_maxPriceSpread"
3741
3842 let k_lastDataStr = "k_lastDataStr"
3943
4044 let k_lastMinuteId = "k_lastMinuteId"
4145
4246 let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice"
4347
4448 let k_twapDataLastPrice = "k_twapDataLastPrice"
4549
4650 let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId"
4751
4852 let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction"
4953
5054 let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction"
5155
5256 let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp"
5357
5458 let k_longFundingRate = "k_longFundingRate"
5559
5660 let k_shortFundingRate = "k_shortFundingRate"
5761
5862 let k_quoteAssetReserve = "k_qtAstR"
5963
6064 let k_baseAssetReserve = "k_bsAstR"
6165
6266 let k_totalPositionSize = "k_totalPositionSize"
6367
6468 let k_totalLongPositionSize = "k_totalLongPositionSize"
6569
6670 let k_totalShortPositionSize = "k_totalShortPositionSize"
6771
6872 let k_cumulativeNotional = "k_cumulativeNotional"
6973
7074 let k_openInterestNotional = "k_openInterestNotional"
7175
7276 let k_coordinatorAddress = "k_coordinatorAddress"
7377
7478 let k_insurance_address = "k_insurance_address"
7579
7680 let k_admin_address = "k_admin_address"
7781
7882 let k_admin_public_key = "k_admin_public_key"
7983
8084 let k_quote_asset = "k_quote_asset"
8185
8286 let k_quote_staking = "k_quote_staking"
8387
8488 let k_staking_address = "k_staking_address"
8589
8690 let k_miner_address = "k_miner_address"
8791
8892 func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set")
8993
9094
9195 func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address))
9296
9397
9498 func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key))
9599
96100
97101 func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset))
98102
99103
100104 func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set")
101105
102106
103107 func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Insurance not set")
104108
105109
106110 func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set")
107111
108112
109113 func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Insurance not set")
110114
111115
112116 let DIR_LONG = 1
113117
114118 let DIR_SHORT = 2
115119
116120 let TWAP_INTERVAL = 15
117121
118122 let ORACLE_INTERVAL = 15
119123
120124 let SECONDS = 1000
121125
122126 let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10))
123127
124128 let ONE_DAY = (86400 * DECIMAL_UNIT)
125129
126130 let ALL_FEES = 100
127131
128132 let PNL_OPTION_SPOT = 1
129133
130134 let PNL_OPTION_ORACLE = 2
131135
132136 func s (_x) = (toString(_x) + ",")
133137
134138
135139 func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN)
136140
137141
138142 func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN)
139143
140144
141145 func abs (_x) = if ((_x > 0))
142146 then _x
143147 else -(_x)
144148
145149
146150 func vmax (_x,_y) = if ((_x >= _y))
147151 then _x
148152 else _y
149153
150154
151155 func toCompositeKey (_key,_address) = ((_key + "_") + _address)
152156
153157
154158 func listToStr (_list) = {
155159 func _join (accumulator,val) = ((accumulator + val) + ",")
156160
157161 let newListStr = {
158162 let $l = _list
159163 let $s = size($l)
160164 let $acc0 = ""
161165 func $f0_1 ($a,$i) = if (($i >= $s))
162166 then $a
163167 else _join($a, $l[$i])
164168
165169 func $f0_2 ($a,$i) = if (($i >= $s))
166170 then $a
167171 else throw("List size exceeds 20")
168172
169173 $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)
170174 }
171175 let newListStrU = dropRight(newListStr, 1)
172176 let newListStrR = if ((take(newListStrU, 1) == ","))
173177 then drop(newListStrU, 1)
174178 else newListStrU
175179 newListStrR
176180 }
177181
178182
179183 func strToList (_str) = split(_str, ",")
180184
181185
182186 func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize))
183187 then (removeByIndex(_list, 0) :+ _value)
184188 else (_list :+ _value)
185189
186190
187191 func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k))
188192
189193
190194 func cbalance () = int(k_balance)
191195
192196
193197 func fee () = int(k_fee)
194198
195199
196200 func initMarginRatio () = int(k_initMarginRatio)
197201
198202
199203 func qtAstR () = int(k_quoteAssetReserve)
200204
201205
202206 func bsAstR () = int(k_baseAssetReserve)
203207
204208
205209 func totalPositionSize () = int(k_totalPositionSize)
206210
207211
208212 func cumulativeNotional () = int(k_cumulativeNotional)
209213
210214
211215 func openInterestNotional () = int(k_openInterestNotional)
212216
213217
214218 func nextFundingBlockTimestamp () = int(k_nextFundingBlock)
215219
216220
217221 func fundingPeriodRaw () = int(k_fundingPeriod)
218222
219223
220224 func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT)
221225
222226
223227 func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS)
224228
225229
226230 func maintenanceMarginRatio () = int(k_maintenanceMarginRatio)
227231
228232
229233 func liquidationFeeRatio () = int(k_liquidationFeeRatio)
230234
231235
236+func partialLiquidationRatio () = int(k_partialLiquidationRatio)
237+
238+
232239 func spreadLimit () = int(k_spreadLimit)
233240
234241
235242 func maxPriceImpact () = int(k_maxPriceImpact)
243+
244+
245+func maxPriceSpread () = int(k_maxPriceSpread)
236246
237247
238248 func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction)
239249
240250
241251 func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction)
242252
243253
244254 func totalShortPositionSize () = int(k_totalShortPositionSize)
245255
246256
247257 func totalLongPositionSize () = int(k_totalLongPositionSize)
248258
249259
250260 func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = {
251261 let remainingMarginRatio = (_marginRatio - _baseMarginRatio)
252262 if (if (_largerThanOrEqualTo)
253263 then (0 > remainingMarginRatio)
254264 else false)
255265 then throw("Invalid margin")
256266 else if (if (!(_largerThanOrEqualTo))
257267 then (remainingMarginRatio >= 0)
258268 else false)
259269 then throw("Invalid margin")
260270 else true
261271 }
262272
263273
264274 func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0))
265275 then throw("Should not be called with _positionSize == 0")
266276 else if ((_positionSize > 0))
267277 then latestLongCumulativePremiumFraction()
268278 else latestShortCumulativePremiumFraction()
269279
270280
271281 func getPosition (_trader) = {
272282 let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader))
273283 match positionSizeOpt {
274284 case positionSize: Int =>
275285 $Tuple4(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader)))
276286 case _ =>
277287 $Tuple4(0, 0, 0, 0)
278288 }
279289 }
280290
281291
282292 func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0))
283293 then throw("No open position")
284294 else true
285295
286296
287297 func initialized () = valueOrElse(getBoolean(this, k_initialized), false)
288298
289299
290300 func paused () = valueOrElse(getBoolean(this, k_paused), false)
291301
292302
293303 func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd)
294304 then {
295305 let newBase = (bsAstR() - _baseAssetAmount)
296306 if ((0 >= newBase))
297307 then throw("Tx lead to base asset reserve <= 0, revert")
298308 else $Tuple4((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount), (cumulativeNotional() + _quoteAssetAmount))
299309 }
300310 else {
301311 let newQuote = (qtAstR() - _quoteAssetAmount)
302312 if ((0 >= newQuote))
303313 then throw("Tx lead to base quote reserve <= 0, revert")
304314 else $Tuple4(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount), (cumulativeNotional() - _quoteAssetAmount))
305315 }
306316
307317
308318 func swapInput (_isAdd,_quoteAssetAmount) = {
309319 let _qtAstR = qtAstR()
310320 let _bsAstR = bsAstR()
311321 let k = muld(_qtAstR, _bsAstR)
312322 let quoteAssetReserveAfter = if (_isAdd)
313323 then (_qtAstR + _quoteAssetAmount)
314324 else (_qtAstR - _quoteAssetAmount)
315325 let baseAssetReserveAfter = divd(k, quoteAssetReserveAfter)
316326 let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR))
317327 let amountBaseAssetBought = if (_isAdd)
318328 then amountBaseAssetBoughtAbs
319329 else -(amountBaseAssetBoughtAbs)
320- let $t01183712030 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
321- let quoteAssetReserveAfter1 = $t01183712030._1
322- let baseAssetReserveAfter1 = $t01183712030._2
323- let totalPositionSizeAfter1 = $t01183712030._3
324- let cumulativeNotionalAfter1 = $t01183712030._4
330+ let $t01217712370 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs)
331+ let quoteAssetReserveAfter1 = $t01217712370._1
332+ let baseAssetReserveAfter1 = $t01217712370._2
333+ let totalPositionSizeAfter1 = $t01217712370._3
334+ let cumulativeNotionalAfter1 = $t01217712370._4
325335 let priceBefore = divd(_qtAstR, _bsAstR)
326336 let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs)
327337 let priceDiff = abs((priceBefore - marketPrice))
328338 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
329339 let maxPriceImpactValue = maxPriceImpact()
330340 if ((priceImpact > maxPriceImpactValue))
331341 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)))
332342 else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1)
333343 }
334344
335345
336346 func calcRemainMarginWithFundingPayment (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_marginDelta) = {
337347 let fundingPayment = if ((_oldPositionSize != 0))
338348 then {
339349 let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize)
340350 muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize)
341351 }
342352 else 0
343353 let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin)
344- let $t01352113648 = if ((0 > signedMargin))
354+ let $t01386113988 = if ((0 > signedMargin))
345355 then $Tuple2(0, abs(signedMargin))
346356 else $Tuple2(abs(signedMargin), 0)
347- let remainMargin = $t01352113648._1
348- let badDebt = $t01352113648._2
357+ let remainMargin = $t01386113988._1
358+ let badDebt = $t01386113988._2
349359 $Tuple3(remainMargin, badDebt, fundingPayment)
350360 }
351361
352362
353-func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = {
354- let _quoteAssetReserve = qtAstR()
355- let _baseAssetReserve = bsAstR()
363+func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_baseAssetReserve) = {
356364 let priceBefore = divd(_quoteAssetReserve, _baseAssetReserve)
357365 if ((_baseAssetAmount == 0))
358366 then throw("Invalid base asset amount")
359367 else {
360368 let k = muld(_quoteAssetReserve, _baseAssetReserve)
361369 let baseAssetPoolAmountAfter = if (_isAdd)
362370 then (_baseAssetReserve + _baseAssetAmount)
363371 else (_baseAssetReserve - _baseAssetAmount)
364372 let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter)
365373 let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve))
366374 let maxPriceImpactValue = maxPriceImpact()
367- let $t01463214825 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
368- let quoteAssetReserveAfter1 = $t01463214825._1
369- let baseAssetReserveAfter1 = $t01463214825._2
370- let totalPositionSizeAfter1 = $t01463214825._3
371- let cumulativeNotionalAfter1 = $t01463214825._4
375+ let $t01496515158 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount)
376+ let quoteAssetReserveAfter1 = $t01496515158._1
377+ let baseAssetReserveAfter1 = $t01496515158._2
378+ let totalPositionSizeAfter1 = $t01496515158._3
379+ let cumulativeNotionalAfter1 = $t01496515158._4
372380 let marketPrice = divd(quoteAssetSold, _baseAssetAmount)
373381 let priceDiff = abs((priceBefore - marketPrice))
374382 let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff)))
375383 if (if ((priceImpact > maxPriceImpactValue))
376384 then _checkMaxPriceImpact
377385 else false)
378386 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)))
379- else $Tuple7(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd)
387+ else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd)
380388 then abs(_baseAssetAmount)
381389 else 0)), (totalShortPositionSize() - (if (!(_isAdd))
382390 then abs(_baseAssetAmount)
383- else 0)))
391+ else 0)), priceImpact)
384392 }
385393 }
394+
395+
396+func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), bsAstR())
386397
387398
388399 func getOracleTwapPrice () = {
389400 let oracle = valueOrErrorMessage(addressFromString(getStringValue(this, k_ora)), "")
390401 let priceKey = getStringValue(this, k_ora_key)
391402 let blockKey = getStringValue(this, k_ora_block_key)
392403 let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey))
393404 lastValue
405+ }
406+
407+
408+func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = {
409+ let oraclePrice = getOracleTwapPrice()
410+ let priceAfter = divd(_quoteAssetReserve, _baseAssetReserve)
411+ let averagePrice = divd((oraclePrice + priceAfter), (2 * DECIMAL_UNIT))
412+ let absPriceDiff = divd(abs((oraclePrice - priceAfter)), averagePrice)
413+ if ((absPriceDiff > maxPriceSpread()))
414+ then throw(((("Price spread " + toString(absPriceDiff)) + " > max price spread ") + toString(maxPriceSpread())))
415+ else true
394416 }
395417
396418
397419 func getSpotPrice () = {
398420 let _quoteAssetReserve = qtAstR()
399421 let _baseAssetReserve = bsAstR()
400422 divd(_quoteAssetReserve, _baseAssetReserve)
401423 }
402424
403425
404426 func isOverFluctuationLimit () = {
405427 let oraclePrice = getOracleTwapPrice()
406428 let currentPrice = getSpotPrice()
407429 (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit())
408430 }
409431
410432
433+func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_baseAssetReserve) = {
434+ let positionSizeAbs = abs(_positionSize)
435+ let isShort = (0 > _positionSize)
436+ let positionNotional = if ((_option == PNL_OPTION_SPOT))
437+ then {
438+ let $t01837618547 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve)
439+ let outPositionNotional = $t01837618547._1
440+ let x1 = $t01837618547._2
441+ let x2 = $t01837618547._3
442+ let x3 = $t01837618547._4
443+ outPositionNotional
444+ }
445+ else muld(positionSizeAbs, getOracleTwapPrice())
446+ positionNotional
447+ }
448+
449+
411450 func getPositionNotionalAndUnrealizedPnl (_trader,_option) = {
412- let $t01729317421 = getPosition(_trader)
413- let positionSize = $t01729317421._1
414- let positionMargin = $t01729317421._2
415- let positionOpenNotional = $t01729317421._3
416- let positionLstUpdCPF = $t01729317421._4
417- let positionSizeAbs = abs(positionSize)
418- if ((positionSizeAbs == 0))
451+ let $t01894119069 = getPosition(_trader)
452+ let positionSize = $t01894119069._1
453+ let positionMargin = $t01894119069._2
454+ let positionOpenNotional = $t01894119069._3
455+ let positionLstUpdCPF = $t01894119069._4
456+ if ((positionSize == 0))
419457 then throw("Invalid position size")
420458 else {
421459 let isShort = (0 > positionSize)
422- let positionNotional = if ((_option == PNL_OPTION_SPOT))
423- then {
424- let $t01766817792 = swapOutput(!(isShort), positionSizeAbs, false)
425- let outPositionNotional = $t01766817792._1
426- let x1 = $t01766817792._2
427- let x2 = $t01766817792._3
428- let x3 = $t01766817792._4
429- outPositionNotional
430- }
431- else muld(positionSizeAbs, getOracleTwapPrice())
460+ let positionNotional = getPositionAdjustedOpenNotional(positionSize, _option, qtAstR(), bsAstR())
432461 let unrealizedPnl = if (isShort)
433462 then (positionOpenNotional - positionNotional)
434463 else (positionNotional - positionOpenNotional)
435464 $Tuple2(positionNotional, unrealizedPnl)
436465 }
437466 }
438467
439468
440469 func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional)
441470
442471
443472 func getMarginRatioByOption (_trader,_option) = {
444- let $t01846218573 = getPosition(_trader)
445- let positionSize = $t01846218573._1
446- let positionMargin = $t01846218573._2
447- let pon = $t01846218573._3
448- let positionLstUpdCPF = $t01846218573._4
449- let $t01857918672 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
450- let positionNotional = $t01857918672._1
451- let unrealizedPnl = $t01857918672._2
452- let $t01867718843 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
453- let remainMargin = $t01867718843._1
454- let badDebt = $t01867718843._2
473+ let $t01990220013 = getPosition(_trader)
474+ let positionSize = $t01990220013._1
475+ let positionMargin = $t01990220013._2
476+ let pon = $t01990220013._3
477+ let positionLstUpdCPF = $t01990220013._4
478+ let $t02001920112 = getPositionNotionalAndUnrealizedPnl(_trader, _option)
479+ let positionNotional = $t02001920112._1
480+ let unrealizedPnl = $t02001920112._2
481+ let $t02011720283 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
482+ let remainMargin = $t02011720283._1
483+ let badDebt = $t02011720283._2
455484 calcMarginRatio(remainMargin, badDebt, positionNotional)
456485 }
457486
458487
459488 func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
460489
461490
491+func getPartialLiquidationAmount (_trader,_positionSize) = {
492+ let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio())))
493+ let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio)
494+ let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false)
495+ let maxExchangedQuoteAssetAmount = swapResult._1
496+ let priceImpact = swapResult._8
497+ if ((maxPriceImpact() > priceImpact))
498+ then maxExchangedQuoteAssetAmount
499+ else {
500+ let exchangedPositionSize = muld(abs(_positionSize), partialLiquidationRatio())
501+ let exchangedQuoteAssetAmount = swapOutput((_positionSize > 0), exchangedPositionSize, false)._1
502+ exchangedQuoteAssetAmount
503+ }
504+ }
505+
506+
462507 func internalClosePosition (_trader,_checkMaxPriceImpact) = {
463- let $t01919019318 = getPosition(_trader)
464- let positionSize = $t01919019318._1
465- let positionMargin = $t01919019318._2
466- let positionOpenNotional = $t01919019318._3
467- let positionLstUpdCPF = $t01919019318._4
468- let $t01932419411 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
469- let x1 = $t01932419411._1
470- let unrealizedPnl = $t01932419411._2
471- let $t01941619584 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
472- let remainMargin = $t01941619584._1
473- let badDebt = $t01941619584._2
508+ let $t02146521593 = getPosition(_trader)
509+ let positionSize = $t02146521593._1
510+ let positionMargin = $t02146521593._2
511+ let positionOpenNotional = $t02146521593._3
512+ let positionLstUpdCPF = $t02146521593._4
513+ let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2
514+ let $t02168821856 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
515+ let remainMargin = $t02168821856._1
516+ let badDebt = $t02168821856._2
474517 let exchangedPositionSize = -(positionSize)
475518 let realizedPnl = unrealizedPnl
476519 let marginToVault = -(remainMargin)
477- let $t01971120022 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
478- let exchangedQuoteAssetAmount = $t01971120022._1
479- let quoteAssetReserveAfter = $t01971120022._2
480- let baseAssetReserveAfter = $t01971120022._3
481- let totalPositionSizeAfter = $t01971120022._4
482- let cumulativeNotionalAfter = $t01971120022._5
483- let totalLongAfter = $t01971120022._6
484- let totalShortAfter = $t01971120022._7
520+ let $t02198322294 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact)
521+ let exchangedQuoteAssetAmount = $t02198322294._1
522+ let quoteAssetReserveAfter = $t02198322294._2
523+ let baseAssetReserveAfter = $t02198322294._3
524+ let totalPositionSizeAfter = $t02198322294._4
525+ let cumulativeNotionalAfter = $t02198322294._5
526+ let totalLongAfter = $t02198322294._6
527+ let totalShortAfter = $t02198322294._7
485528 let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional)
486529 $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter)
487530 }
488531
489532
490533 func getTwapSpotPrice () = {
491534 let minuteId = ((lastBlock.timestamp / 1000) / 60)
492535 let startMinuteId = (minuteId - TWAP_INTERVAL)
493536 let listStr = valueOrElse(getString(this, k_lastDataStr), "")
494537 let list = split(listStr, ",")
495538 func filterFn (accumulator,next) = if ((startMinuteId >= parseIntValue(next)))
496539 then (accumulator :+ parseIntValue(next))
497540 else accumulator
498541
499542 let listF = {
500543 let $l = list
501544 let $s = size($l)
502545 let $acc0 = nil
503546 func $f0_1 ($a,$i) = if (($i >= $s))
504547 then $a
505548 else filterFn($a, $l[$i])
506549
507550 func $f0_2 ($a,$i) = if (($i >= $s))
508551 then $a
509552 else throw("List size exceeds 20")
510553
511554 $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)
512555 }
513556 let maxIndex = if ((size(listF) > 0))
514557 then max(listF)
515558 else parseIntValue(list[0])
516559 let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
517560 let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0)
518561 let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0)
519562 let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice))
520563 let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0)
521564 let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0)
522565 let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice))
523566 ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL)
524567 }
525568
526569
527-func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact)]
570+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)]
528571
529572
530573 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)]
531574
532575
533576 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)]
534577
535578
536579 func appendTwap (price) = {
537580 let minuteId = ((lastBlock.timestamp / 1000) / 60)
538581 let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0)
539582 if ((previousMinuteId > minuteId))
540583 then throw("TWAP out-of-order")
541584 else {
542585 let lastMinuteId = if ((previousMinuteId == 0))
543586 then minuteId
544587 else previousMinuteId
545588 if ((minuteId > previousMinuteId))
546589 then {
547590 let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0)
548591 let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), price)
549592 let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice))
550593 let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId))
551594 [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))]
552595 }
553596 else {
554597 let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0)
555598 let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0)
556599 let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), price)
557600 let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice))
558601 [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), price)]
559602 }
560603 }
561604 }
562605
563606
564607 func updateAmmReserves (_qtAstR,_bsAstR) = [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)]
565608
566609
567610 func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_cumulativeNotionalAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize) = if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter))
568611 then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter)))
569612 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)))
570613
571614
572615 func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address))]
573616
574617
575618 func withdraw (_address,_amount) = {
576619 let balance = assetBalance(this, quoteAsset())
577620 if ((_amount > balance))
578621 then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance)))
579622 else [ScriptTransfer(_address, _amount, quoteAsset())]
580623 }
581624
582625
583626 func updateBalance (i) = if ((0 > i))
584627 then throw("Balance")
585628 else [IntegerEntry(k_balance, i)]
586629
587630
588631 func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())]
589632
590633
591634 @Callable(i)
592635 func pause () = if ((i.caller != adminAddress()))
593636 then throw("Invalid togglePause params")
594637 else [BooleanEntry(k_paused, true)]
595638
596639
597640
598641 @Callable(i)
599642 func unpause () = if ((i.caller != adminAddress()))
600643 then throw("Invalid togglePause params")
601644 else [BooleanEntry(k_paused, false)]
602645
603646
604647
605648 @Callable(i)
606649 func addLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress()))
607650 then true
608651 else (0 >= _quoteAssetAmount))
609652 then throw("Invalid addLiquidity params")
610653 else {
611654 let _qtAstR = qtAstR()
612655 let _bsAstR = bsAstR()
613656 let price = divd(_qtAstR, _bsAstR)
614657 let baseAssetAmountToAdd = divd(_quoteAssetAmount, price)
615658 let qtAstRAfter = (_qtAstR + _quoteAssetAmount)
616659 let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd)
617660 updateAmmReserves(qtAstRAfter, bsAstRAfter)
618661 }
619662
620663
621664
622665 @Callable(i)
623666 func removeLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress()))
624667 then true
625668 else (0 >= _quoteAssetAmount))
626669 then throw("Invalid removeLiquidity params")
627670 else {
628671 let _qtAstR = qtAstR()
629672 let _bsAstR = bsAstR()
630673 let price = divd(_qtAstR, _bsAstR)
631674 let baseAssetAmountToRemove = divd(_quoteAssetAmount, price)
632675 let qtAstRAfter = (_qtAstR - _quoteAssetAmount)
633676 let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove)
634677 updateAmmReserves(qtAstRAfter, bsAstRAfter)
635678 }
636679
637680
638681
639682 @Callable(i)
640-func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = if ((i.caller != adminAddress()))
683+func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress()))
641684 then throw("Invalid changeSettings params")
642- else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact)
685+ else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)
643686
644687
645688
646689 @Callable(i)
647-func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact) = if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR))
690+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))
648691 then true
649692 else (0 >= _bsAstR))
650693 then true
651694 else (0 >= _fundingPeriod))
652695 then true
653696 else (0 >= _initMarginRatio))
654697 then true
655698 else (0 >= _mmr))
656699 then true
657700 else (0 >= _liquidationFeeRatio))
658701 then true
659702 else (0 >= _fee))
660703 then true
661704 else (0 >= _spreadLimit))
662705 then true
663706 else (0 >= _maxPriceImpact))
664707 then true
708+ else (0 >= _partialLiquidationRatio))
709+ then true
710+ else (0 >= _maxPriceSpread))
711+ then true
665712 else initialized())
666713 then throw("Invalid initialize parameters")
667- else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)])
668-
669-
670-
671-@Callable(i)
672-func setMaxPriceImpact (_maxPriceImpact) = if (if ((0 >= _maxPriceImpact))
673- then true
674- else !(initialized()))
675- then throw("Invalid _maxPriceImpact parameters")
676- else updateSettings(initMarginRatio(), maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), _maxPriceImpact)
714+ 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)])
677715
678716
679717
680718 @Callable(i)
681719 func setInitMarginRatio (_initMarginRatio) = if (if ((0 >= _initMarginRatio))
682720 then true
683721 else !(initialized()))
684722 then throw("Invalid setInitMarginRatio parameters")
685- else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact())
723+ else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread())
686724
687725
688726
689727 @Callable(i)
690728 func decreasePosition (_amount,_leverage,_minBaseAssetAmount) = if (if (if (if (if ((0 >= _amount))
691729 then true
692730 else !(initialized()))
693731 then true
694732 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
695733 then true
696734 else !(requireOpenPosition(toString(i.caller))))
697735 then true
698736 else paused())
699737 then throw("Invalid decreasePosition parameters")
700738 else {
701- let $t03173131883 = getPosition(toString(i.caller))
702- let oldPositionSize = $t03173131883._1
703- let oldPositionMargin = $t03173131883._2
704- let oldPositionOpenNotional = $t03173131883._3
705- let oldPositionLstUpdCPF = $t03173131883._4
739+ let $t03418734339 = getPosition(toString(i.caller))
740+ let oldPositionSize = $t03418734339._1
741+ let oldPositionMargin = $t03418734339._2
742+ let oldPositionOpenNotional = $t03418734339._3
743+ let oldPositionLstUpdCPF = $t03418734339._4
706744 let _direction = if ((oldPositionSize > 0))
707745 then DIR_SHORT
708746 else DIR_LONG
709747 let isAdd = (_direction == DIR_LONG)
710748 let openNotional = muld(_amount, _leverage)
711- let $t03205632172 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
712- let oldPositionNotional = $t03205632172._1
713- let unrealizedPnl = $t03205632172._2
714- let $t03217834727 = if ((oldPositionNotional > openNotional))
749+ let $t03451234628 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
750+ let oldPositionNotional = $t03451234628._1
751+ let unrealizedPnl = $t03451234628._2
752+ let $t03463437183 = if ((oldPositionNotional > openNotional))
715753 then {
716- let $t03255532774 = swapInput(isAdd, openNotional)
717- let exchangedPositionSize = $t03255532774._1
718- let quoteAssetReserveAfter = $t03255532774._2
719- let baseAssetReserveAfter = $t03255532774._3
720- let totalPositionSizeAfter = $t03255532774._4
721- let cumulativeNotionalAfter = $t03255532774._5
754+ let $t03501135230 = swapInput(isAdd, openNotional)
755+ let exchangedPositionSize = $t03501135230._1
756+ let quoteAssetReserveAfter = $t03501135230._2
757+ let baseAssetReserveAfter = $t03501135230._3
758+ let totalPositionSizeAfter = $t03501135230._4
759+ let cumulativeNotionalAfter = $t03501135230._5
722760 let exchangedPositionSizeAbs = abs(exchangedPositionSize)
723761 if (if ((_minBaseAssetAmount != 0))
724762 then (_minBaseAssetAmount > exchangedPositionSizeAbs)
725763 else false)
726764 then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount)))
727765 else {
728766 let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize))
729- let $t03321133456 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
730- let remainMargin = $t03321133456._1
731- let badDebt = $t03321133456._2
732- let fundingPayment = $t03321133456._3
767+ let $t03566735912 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
768+ let remainMargin = $t03566735912._1
769+ let badDebt = $t03566735912._2
770+ let fundingPayment = $t03566735912._3
733771 let exchangedQuoteAssetAmount = openNotional
734772 let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
735773 let remainOpenNotional = if ((oldPositionSize > 0))
736774 then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
737775 else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
738776 let newPositionSize = (oldPositionSize + exchangedPositionSize)
739777 $Tuple11(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0))
740778 then abs(exchangedPositionSize)
741779 else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
742780 then abs(exchangedPositionSize)
743781 else 0)))
744782 }
745783 }
746784 else throw("Close position first")
747- let newPositionSize = $t03217834727._1
748- let newPositionRemainMargin = $t03217834727._2
749- let newPositionOpenNotional = $t03217834727._3
750- let newPositionLatestCPF = $t03217834727._4
751- let baseAssetReserveAfter = $t03217834727._5
752- let quoteAssetReserveAfter = $t03217834727._6
753- let totalPositionSizeAfter = $t03217834727._7
754- let cumulativeNotionalAfter = $t03217834727._8
755- let openInterestNotionalAfter = $t03217834727._9
756- let totalLongAfter = $t03217834727._10
757- let totalShortAfter = $t03217834727._11
785+ let newPositionSize = $t03463437183._1
786+ let newPositionRemainMargin = $t03463437183._2
787+ let newPositionOpenNotional = $t03463437183._3
788+ let newPositionLatestCPF = $t03463437183._4
789+ let baseAssetReserveAfter = $t03463437183._5
790+ let quoteAssetReserveAfter = $t03463437183._6
791+ let totalPositionSizeAfter = $t03463437183._7
792+ let cumulativeNotionalAfter = $t03463437183._8
793+ let openInterestNotionalAfter = $t03463437183._9
794+ let totalLongAfter = $t03463437183._10
795+ let totalShortAfter = $t03463437183._11
758796 let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil)
759797 if ((notifyNotional == notifyNotional))
760798 then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter))
761799 else throw("Strict value is not equal to itself.")
762800 }
763801
764802
765803
766804 @Callable(i)
767805 func increasePosition (_direction,_leverage,_minBaseAssetAmount) = {
768806 let _rawAmount = i.payments[0].amount
769807 if (if (if (if (if (if (if ((_direction != DIR_LONG))
770808 then (_direction != DIR_SHORT)
771809 else false)
772810 then true
773811 else (0 >= _rawAmount))
774812 then true
775813 else !(initialized()))
776814 then true
777815 else (i.payments[0].assetId != quoteAsset()))
778816 then true
779817 else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true)))
780818 then true
781819 else paused())
782820 then throw("Invalid increasePosition parameters")
783821 else {
784822 let feeAmount = muld(_rawAmount, fee())
785823 let _amount = (_rawAmount - feeAmount)
786- let $t03584535997 = getPosition(toString(i.caller))
787- let oldPositionSize = $t03584535997._1
788- let oldPositionMargin = $t03584535997._2
789- let oldPositionOpenNotional = $t03584535997._3
790- let oldPositionLstUpdCPF = $t03584535997._4
824+ let $t03830138453 = getPosition(toString(i.caller))
825+ let oldPositionSize = $t03830138453._1
826+ let oldPositionMargin = $t03830138453._2
827+ let oldPositionOpenNotional = $t03830138453._3
828+ let oldPositionLstUpdCPF = $t03830138453._4
791829 let isNewPosition = (oldPositionSize == 0)
792830 let isSameDirection = if ((oldPositionSize > 0))
793831 then (_direction == DIR_LONG)
794832 else (_direction == DIR_SHORT)
795833 let expandExisting = if (!(isNewPosition))
796834 then isSameDirection
797835 else false
798836 let isAdd = (_direction == DIR_LONG)
799- let $t03628638675 = if (if (isNewPosition)
837+ let $t03874241310 = if (if (isNewPosition)
800838 then true
801839 else expandExisting)
802840 then {
803841 let openNotional = muld(_amount, _leverage)
804- let $t03671036916 = swapInput(isAdd, openNotional)
805- let amountBaseAssetBought = $t03671036916._1
806- let quoteAssetReserveAfter = $t03671036916._2
807- let baseAssetReserveAfter = $t03671036916._3
808- let totalPositionSizeAfter = $t03671036916._4
809- let cumulativeNotionalAfter = $t03671036916._5
842+ let $t03916639372 = swapInput(isAdd, openNotional)
843+ let amountBaseAssetBought = $t03916639372._1
844+ let quoteAssetReserveAfter = $t03916639372._2
845+ let baseAssetReserveAfter = $t03916639372._3
846+ let totalPositionSizeAfter = $t03916639372._4
847+ let cumulativeNotionalAfter = $t03916639372._5
810848 if (if ((_minBaseAssetAmount != 0))
811849 then (_minBaseAssetAmount > abs(amountBaseAssetBought))
812850 else false)
813851 then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount)))
814852 else {
815853 let newPositionSize = (oldPositionSize + amountBaseAssetBought)
816854 let increaseMarginRequirement = divd(openNotional, _leverage)
817- let $t03729737536 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
818- let remainMargin = $t03729737536._1
819- let x1 = $t03729737536._2
820- let x2 = $t03729737536._3
821- $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
822- then abs(amountBaseAssetBought)
823- else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
824- then abs(amountBaseAssetBought)
825- else 0)))
855+ let $t03975339992 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement)
856+ let remainMargin = $t03975339992._1
857+ let x1 = $t03975339992._2
858+ let x2 = $t03975339992._3
859+ if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter)))
860+ then throw("Over max spread limit")
861+ else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0))
862+ then abs(amountBaseAssetBought)
863+ else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize))
864+ then abs(amountBaseAssetBought)
865+ else 0)))
826866 }
827867 }
828868 else {
829869 let openNotional = muld(_amount, _leverage)
830- let $t03836838484 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
831- let oldPositionNotional = $t03836838484._1
832- let unrealizedPnl = $t03836838484._2
870+ let $t04100341119 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT)
871+ let oldPositionNotional = $t04100341119._1
872+ let unrealizedPnl = $t04100341119._2
833873 if ((oldPositionNotional > openNotional))
834874 then throw("Use decreasePosition to decrease position size")
835875 else throw("Close position first")
836876 }
837- let newPositionSize = $t03628638675._1
838- let newPositionRemainMargin = $t03628638675._2
839- let newPositionOpenNotional = $t03628638675._3
840- let newPositionLatestCPF = $t03628638675._4
841- let baseAssetReserveAfter = $t03628638675._5
842- let quoteAssetReserveAfter = $t03628638675._6
843- let totalPositionSizeAfter = $t03628638675._7
844- let cumulativeNotionalAfter = $t03628638675._8
845- let openInterestNotionalAfter = $t03628638675._9
846- let totalLongAfter = $t03628638675._10
847- let totalShortAfter = $t03628638675._11
877+ let newPositionSize = $t03874241310._1
878+ let newPositionRemainMargin = $t03874241310._2
879+ let newPositionOpenNotional = $t03874241310._3
880+ let newPositionLatestCPF = $t03874241310._4
881+ let baseAssetReserveAfter = $t03874241310._5
882+ let quoteAssetReserveAfter = $t03874241310._6
883+ let totalPositionSizeAfter = $t03874241310._7
884+ let cumulativeNotionalAfter = $t03874241310._8
885+ let openInterestNotionalAfter = $t03874241310._9
886+ let totalLongAfter = $t03874241310._10
887+ let totalShortAfter = $t03874241310._11
848888 let feeToStakers = (feeAmount / 2)
849889 let feeToInsurance = (feeAmount - feeToStakers)
850890 let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)])
851891 if ((stake == stake))
852892 then {
853893 let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
854894 if ((depositInsurance == depositInsurance))
855895 then {
856896 let notifyFee = invoke(minerAddress(), "notifyFees", [toString(i.caller), feeAmount], nil)
857897 if ((notifyFee == notifyFee))
858898 then {
859899 let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil)
860900 if ((notifyNotional == notifyNotional))
861901 then (((updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount)))
862902 else throw("Strict value is not equal to itself.")
863903 }
864904 else throw("Strict value is not equal to itself.")
865905 }
866906 else throw("Strict value is not equal to itself.")
867907 }
868908 else throw("Strict value is not equal to itself.")
869909 }
870910 }
871911
872912
873913
874914 @Callable(i)
875915 func addMargin () = {
876916 let _rawAmount = i.payments[0].amount
877917 if (if (if (if ((i.payments[0].assetId != quoteAsset()))
878918 then true
879919 else !(requireOpenPosition(toString(i.caller))))
880920 then true
881921 else !(initialized()))
882922 then true
883923 else paused())
884924 then throw("Invalid addMargin parameters")
885925 else {
886926 let feeAmount = muld(_rawAmount, fee())
887927 let _amount = (_rawAmount - feeAmount)
888- let $t04023140383 = getPosition(toString(i.caller))
889- let oldPositionSize = $t04023140383._1
890- let oldPositionMargin = $t04023140383._2
891- let oldPositionOpenNotional = $t04023140383._3
892- let oldPositionLstUpdCPF = $t04023140383._4
928+ let $t04286643018 = getPosition(toString(i.caller))
929+ let oldPositionSize = $t04286643018._1
930+ let oldPositionMargin = $t04286643018._2
931+ let oldPositionOpenNotional = $t04286643018._3
932+ let oldPositionLstUpdCPF = $t04286643018._4
893933 let feeToStakers = (feeAmount / 2)
894934 let feeToInsurance = (feeAmount - feeToStakers)
895935 let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)])
896936 if ((stake == stake))
897937 then {
898938 let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
899939 if ((depositInsurance == depositInsurance))
900940 then {
901941 let notifyFee = invoke(minerAddress(), "notifyFees", [toString(i.caller), feeAmount], nil)
902942 if ((notifyFee == notifyFee))
903943 then ((updatePosition(toString(i.caller), oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount)))
904944 else throw("Strict value is not equal to itself.")
905945 }
906946 else throw("Strict value is not equal to itself.")
907947 }
908948 else throw("Strict value is not equal to itself.")
909949 }
910950 }
911951
912952
913953
914954 @Callable(i)
915955 func removeMargin (_amount) = if (if (if (if ((0 >= _amount))
916956 then true
917957 else !(requireOpenPosition(toString(i.caller))))
918958 then true
919959 else !(initialized()))
920960 then true
921961 else paused())
922962 then throw("Invalid removeMargin parameters")
923963 else {
924- let $t04143241584 = getPosition(toString(i.caller))
925- let oldPositionSize = $t04143241584._1
926- let oldPositionMargin = $t04143241584._2
927- let oldPositionOpenNotional = $t04143241584._3
928- let oldPositionLstUpdCPF = $t04143241584._4
964+ let $t04406744219 = getPosition(toString(i.caller))
965+ let oldPositionSize = $t04406744219._1
966+ let oldPositionMargin = $t04406744219._2
967+ let oldPositionOpenNotional = $t04406744219._3
968+ let oldPositionLstUpdCPF = $t04406744219._4
929969 let marginDelta = -(_amount)
930- let $t04162141800 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
931- let remainMargin = $t04162141800._1
932- let badDebt = $t04162141800._2
970+ let $t04425644435 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta)
971+ let remainMargin = $t04425644435._1
972+ let badDebt = $t04425644435._2
933973 if ((badDebt != 0))
934974 then throw("Invalid removed margin amount")
935975 else {
936976 let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional)
937977 if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true)))
938978 then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio())))
939979 else {
940980 let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [_amount, toBase58String(quoteAsset())], nil)
941981 if ((unstake == unstake))
942982 then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount)))
943983 else throw("Strict value is not equal to itself.")
944984 }
945985 }
946986 }
947987
948988
949989
950990 @Callable(i)
951991 func closePosition () = if (if (if (!(requireOpenPosition(toString(i.caller))))
952992 then true
953993 else !(initialized()))
954994 then true
955995 else paused())
956996 then throw("Invalid closePosition parameters")
957997 else {
958- let $t04289643286 = internalClosePosition(toString(i.caller), true)
959- let x1 = $t04289643286._1
960- let positionBadDebt = $t04289643286._2
961- let realizedPnl = $t04289643286._3
962- let marginToVault = $t04289643286._4
963- let quoteAssetReserveAfter = $t04289643286._5
964- let baseAssetReserveAfter = $t04289643286._6
965- let totalPositionSizeAfter = $t04289643286._7
966- let cumulativeNotionalAfter = $t04289643286._8
967- let openInterestNotionalAfter = $t04289643286._9
968- let x2 = $t04289643286._10
969- let totalLongAfter = $t04289643286._11
970- let totalShortAfter = $t04289643286._12
998+ let $t04553145921 = internalClosePosition(toString(i.caller), true)
999+ let x1 = $t04553145921._1
1000+ let positionBadDebt = $t04553145921._2
1001+ let realizedPnl = $t04553145921._3
1002+ let marginToVault = $t04553145921._4
1003+ let quoteAssetReserveAfter = $t04553145921._5
1004+ let baseAssetReserveAfter = $t04553145921._6
1005+ let totalPositionSizeAfter = $t04553145921._7
1006+ let cumulativeNotionalAfter = $t04553145921._8
1007+ let openInterestNotionalAfter = $t04553145921._9
1008+ let x2 = $t04553145921._10
1009+ let totalLongAfter = $t04553145921._11
1010+ let totalShortAfter = $t04553145921._12
9711011 if ((positionBadDebt > 0))
9721012 then throw("Unable to close position with bad debt")
9731013 else {
9741014 let withdrawAmount = abs(marginToVault)
9751015 let ammBalance = (cbalance() - withdrawAmount)
976- let $t04349543637 = if ((0 > ammBalance))
1016+ let $t04613046272 = if ((0 > ammBalance))
9771017 then $Tuple2(0, abs(ammBalance))
9781018 else $Tuple2(ammBalance, 0)
979- let ammNewBalance = $t04349543637._1
980- let getFromInsurance = $t04349543637._2
1019+ let ammNewBalance = $t04613046272._1
1020+ let getFromInsurance = $t04613046272._2
9811021 let x = if ((getFromInsurance > 0))
9821022 then {
9831023 let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil)
9841024 if ((withdrawInsurance == withdrawInsurance))
9851025 then nil
9861026 else throw("Strict value is not equal to itself.")
9871027 }
9881028 else nil
9891029 if ((x == x))
9901030 then {
9911031 let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(withdrawAmount - getFromInsurance), toBase58String(quoteAsset())], nil)
9921032 if ((unstake == unstake))
9931033 then {
9941034 let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), 0], nil)
9951035 if ((notifyNotional == notifyNotional))
9961036 then (((deletePosition(toString(i.caller)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, withdrawAmount)) ++ updateBalance(ammNewBalance))
9971037 else throw("Strict value is not equal to itself.")
9981038 }
9991039 else throw("Strict value is not equal to itself.")
10001040 }
10011041 else throw("Strict value is not equal to itself.")
10021042 }
10031043 }
10041044
10051045
10061046
10071047 @Callable(i)
10081048 func liquidate (_trader) = {
10091049 let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT)
10101050 let marginRatio = if (isOverFluctuationLimit())
10111051 then {
10121052 let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE)
10131053 vmax(spotMarginRatio, oracleMarginRatio)
10141054 }
10151055 else spotMarginRatio
10161056 if (if (if (if (!(requireMoreMarginRatio(marginRatio, maintenanceMarginRatio(), false)))
10171057 then true
10181058 else !(requireOpenPosition(_trader)))
10191059 then true
10201060 else !(initialized()))
10211061 then true
10221062 else paused())
10231063 then throw("Unable to liquidate")
1024- else {
1025- let $t04532745750 = internalClosePosition(_trader, false)
1026- let x1 = $t04532745750._1
1027- let badDebt = $t04532745750._2
1028- let x2 = $t04532745750._3
1029- let x3 = $t04532745750._4
1030- let quoteAssetReserveAfter = $t04532745750._5
1031- let baseAssetReserveAfter = $t04532745750._6
1032- let totalPositionSizeAfter = $t04532745750._7
1033- let cumulativeNotionalAfter = $t04532745750._8
1034- let openInterestNotionalAfter = $t04532745750._9
1035- let exchangedQuoteAssetAmount = $t04532745750._10
1036- let totalLongAfter = $t04532745750._11
1037- let totalShortAfter = $t04532745750._12
1038- let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
1039- let feeToLiquidator = (liquidationPenalty / 2)
1040- let feeToInsurance = (liquidationPenalty - feeToLiquidator)
1041- let ammBalance = (cbalance() - liquidationPenalty)
1042- let $t04614846283 = if ((0 > ammBalance))
1043- then $Tuple2(0, abs(ammBalance))
1044- else $Tuple2(ammBalance, 0)
1045- let newAmmBalance = $t04614846283._1
1046- let takeFromInsurance = $t04614846283._2
1047- let x = if ((takeFromInsurance > 0))
1048- then {
1049- let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1050- if ((withdrawInsurance == withdrawInsurance))
1051- then nil
1052- else throw("Strict value is not equal to itself.")
1053- }
1054- else nil
1055- if ((x == x))
1056- then {
1057- let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil)
1058- if ((unstake == unstake))
1059- then {
1060- let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1061- if ((depositInsurance == depositInsurance))
1062- then {
1063- let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1064- if ((notifyNotional == notifyNotional))
1065- then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1066- else throw("Strict value is not equal to itself.")
1067- }
1068- else throw("Strict value is not equal to itself.")
1069- }
1070- else throw("Strict value is not equal to itself.")
1071- }
1072- else throw("Strict value is not equal to itself.")
1073- }
1064+ else if (if (if ((spotMarginRatio > liquidationFeeRatio()))
1065+ then (partialLiquidationRatio() > 0)
1066+ else false)
1067+ then (DECIMAL_UNIT > partialLiquidationRatio())
1068+ else false)
1069+ then {
1070+ let $t04837348523 = getPosition(_trader)
1071+ let oldPositionSize = $t04837348523._1
1072+ let oldPositionMargin = $t04837348523._2
1073+ let oldPositionOpenNotional = $t04837348523._3
1074+ let oldPositionLstUpdCPF = $t04837348523._4
1075+ let _direction = if ((oldPositionSize > 0))
1076+ then DIR_SHORT
1077+ else DIR_LONG
1078+ let isAdd = (_direction == DIR_LONG)
1079+ let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize)
1080+ let $t04874848852 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1081+ let oldPositionNotional = $t04874848852._1
1082+ let unrealizedPnl = $t04874848852._2
1083+ let $t04886049150 = swapInput(isAdd, exchangedQuoteAssetAmount)
1084+ let exchangedPositionSize = $t04886049150._1
1085+ let quoteAssetReserveAfter = $t04886049150._2
1086+ let baseAssetReserveAfter = $t04886049150._3
1087+ let totalPositionSizeAfter = $t04886049150._4
1088+ let cumulativeNotionalAfter = $t04886049150._5
1089+ let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize))
1090+ let $t04925749490 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl)
1091+ let remainMargin = $t04925749490._1
1092+ let badDebt = $t04925749490._2
1093+ let fundingPayment = $t04925749490._3
1094+ let unrealizedPnlAfter = (unrealizedPnl - realizedPnl)
1095+ let remainOpenNotional = if ((oldPositionSize > 0))
1096+ then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter)
1097+ else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount)
1098+ let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
1099+ let feeToLiquidator = (liquidationPenalty / 2)
1100+ let feeToInsurance = (liquidationPenalty - feeToLiquidator)
1101+ let newPositionMargin = (remainMargin - liquidationPenalty)
1102+ let newPositionSize = (oldPositionSize + exchangedPositionSize)
1103+ let newPositionOpenNotional = abs(remainOpenNotional)
1104+ let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize)
1105+ let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount)
1106+ let ammBalance = (cbalance() - liquidationPenalty)
1107+ let $t05066350806 = if ((0 > ammBalance))
1108+ then $Tuple2(0, abs(ammBalance))
1109+ else $Tuple2(ammBalance, 0)
1110+ let newAmmBalance = $t05066350806._1
1111+ let takeFromInsurance = $t05066350806._2
1112+ let x = if ((takeFromInsurance > 0))
1113+ then {
1114+ let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1115+ if ((withdrawInsurance == withdrawInsurance))
1116+ then nil
1117+ else throw("Strict value is not equal to itself.")
1118+ }
1119+ else nil
1120+ if ((x == x))
1121+ then {
1122+ let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil)
1123+ if ((unstake == unstake))
1124+ then {
1125+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1126+ if ((depositInsurance == depositInsurance))
1127+ then {
1128+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil)
1129+ if ((notifyNotional == notifyNotional))
1130+ then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0))
1131+ then abs(exchangedPositionSize)
1132+ else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize))
1133+ then abs(exchangedPositionSize)
1134+ else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1135+ else throw("Strict value is not equal to itself.")
1136+ }
1137+ else throw("Strict value is not equal to itself.")
1138+ }
1139+ else throw("Strict value is not equal to itself.")
1140+ }
1141+ else throw("Strict value is not equal to itself.")
1142+ }
1143+ else {
1144+ let $t05226252717 = internalClosePosition(_trader, false)
1145+ let x1 = $t05226252717._1
1146+ let badDebt = $t05226252717._2
1147+ let x2 = $t05226252717._3
1148+ let x3 = $t05226252717._4
1149+ let quoteAssetReserveAfter = $t05226252717._5
1150+ let baseAssetReserveAfter = $t05226252717._6
1151+ let totalPositionSizeAfter = $t05226252717._7
1152+ let cumulativeNotionalAfter = $t05226252717._8
1153+ let openInterestNotionalAfter = $t05226252717._9
1154+ let exchangedQuoteAssetAmount = $t05226252717._10
1155+ let totalLongAfter = $t05226252717._11
1156+ let totalShortAfter = $t05226252717._12
1157+ let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio())
1158+ let feeToLiquidator = (liquidationPenalty / 2)
1159+ let feeToInsurance = (liquidationPenalty - feeToLiquidator)
1160+ let ammBalance = (cbalance() - liquidationPenalty)
1161+ let $t05312953272 = if ((0 > ammBalance))
1162+ then $Tuple2(0, abs(ammBalance))
1163+ else $Tuple2(ammBalance, 0)
1164+ let newAmmBalance = $t05312953272._1
1165+ let takeFromInsurance = $t05312953272._2
1166+ let x = if ((takeFromInsurance > 0))
1167+ then {
1168+ let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil)
1169+ if ((withdrawInsurance == withdrawInsurance))
1170+ then nil
1171+ else throw("Strict value is not equal to itself.")
1172+ }
1173+ else nil
1174+ if ((x == x))
1175+ then {
1176+ let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil)
1177+ if ((unstake == unstake))
1178+ then {
1179+ let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)])
1180+ if ((depositInsurance == depositInsurance))
1181+ then {
1182+ let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil)
1183+ if ((notifyNotional == notifyNotional))
1184+ then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance))
1185+ else throw("Strict value is not equal to itself.")
1186+ }
1187+ else throw("Strict value is not equal to itself.")
1188+ }
1189+ else throw("Strict value is not equal to itself.")
1190+ }
1191+ else throw("Strict value is not equal to itself.")
1192+ }
10741193 }
10751194
10761195
10771196
10781197 @Callable(i)
10791198 func payFunding () = {
10801199 let fundingBlockTimestamp = nextFundingBlockTimestamp()
10811200 if (if (if ((fundingBlockTimestamp > lastBlock.timestamp))
10821201 then true
10831202 else !(initialized()))
10841203 then true
10851204 else paused())
10861205 then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp)))
10871206 else {
10881207 let underlyingPrice = getOracleTwapPrice()
10891208 let spotTwapPrice = getTwapSpotPrice()
10901209 let premium = (spotTwapPrice - underlyingPrice)
1091- let $t04777749112 = if (if ((totalShortPositionSize() == 0))
1210+ let $t05486056195 = if (if ((totalShortPositionSize() == 0))
10921211 then true
10931212 else (totalLongPositionSize() == 0))
10941213 then $Tuple2(0, 0)
10951214 else if ((0 > premium))
10961215 then {
10971216 let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
10981217 let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize())
10991218 $Tuple2(shortPremiumFraction, longPremiumFraction)
11001219 }
11011220 else {
11021221 let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY)
11031222 let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize())
11041223 $Tuple2(shortPremiumFraction, longPremiumFraction)
11051224 }
1106- let shortPremiumFraction = $t04777749112._1
1107- let longPremiumFraction = $t04777749112._2
1225+ let shortPremiumFraction = $t05486056195._1
1226+ let longPremiumFraction = $t05486056195._2
11081227 updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice))
11091228 }
11101229 }
11111230
11121231
11131232
11141233 @Callable(i)
11151234 func v_get (_trader) = {
1116- let $t04948749547 = internalClosePosition(_trader, false)
1117- let x1 = $t04948749547._1
1118- let x2 = $t04948749547._2
1119- let x3 = $t04948749547._3
1120- let x4 = $t04948749547._4
1235+ let $t05657056630 = internalClosePosition(_trader, false)
1236+ let x1 = $t05657056630._1
1237+ let x2 = $t05657056630._2
1238+ let x3 = $t05657056630._3
1239+ let x4 = $t05657056630._4
11211240 throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader))))
11221241 }
11231242
11241243
11251244
11261245 @Callable(i)
11271246 func view_calcRemainMarginWithFundingPayment (_trader) = {
1128- let $t04969449805 = getPosition(_trader)
1129- let positionSize = $t04969449805._1
1130- let positionMargin = $t04969449805._2
1131- let pon = $t04969449805._3
1132- let positionLstUpdCPF = $t04969449805._4
1133- let $t04981049911 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1134- let positionNotional = $t04981049911._1
1135- let unrealizedPnl = $t04981049911._2
1136- let $t04991650098 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1137- let remainMargin = $t04991650098._1
1138- let badDebt = $t04991650098._2
1139- let fundingPayment = $t04991650098._3
1140- throw(((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)))
1247+ let $t05677756888 = getPosition(_trader)
1248+ let positionSize = $t05677756888._1
1249+ let positionMargin = $t05677756888._2
1250+ let pon = $t05677756888._3
1251+ let positionLstUpdCPF = $t05677756888._4
1252+ let $t05689356994 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)
1253+ let positionNotional = $t05689356994._1
1254+ let unrealizedPnl = $t05689356994._2
1255+ let $t05699957181 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl)
1256+ let remainMargin = $t05699957181._1
1257+ let badDebt = $t05699957181._2
1258+ let fundingPayment = $t05699957181._3
1259+ throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional)))
11411260 }
11421261
11431262
11441263
11451264 @Callable(i)
11461265 func forceMoveAsset (_trader,_amount) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller))
11471266 then true
11481267 else (0 > _amount))
11491268 then throw("Invalid forceMoveAsset parameters")
11501269 else {
11511270 let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [_amount, toBase58String(quoteAsset())], nil)
11521271 if ((unstake == unstake))
11531272 then (withdraw(addressFromStringValue(_trader), _amount) ++ updateBalance((cbalance() - _amount)))
11541273 else throw("Strict value is not equal to itself.")
11551274 }
11561275
11571276
11581277 @Verifier(tx)
11591278 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey())
11601279

github/deemru/w8io/026f985 
167.54 ms