tx · Ce4SBkrUZwbiYwPfeJxvdQUbbU2J3DTeMiCyzrTN75qu 3MuCofTkjmv397dEuRXE3pZxTb4zDWa96uo: -0.06500000 Waves 2022.11.10 12:50 [2310895] smart account 3MuCofTkjmv397dEuRXE3pZxTb4zDWa96uo > SELF 0.00000000 Waves
{ "type": 13, "id": "Ce4SBkrUZwbiYwPfeJxvdQUbbU2J3DTeMiCyzrTN75qu", "fee": 6500000, "feeAssetId": null, "timestamp": 1668073844926, "version": 2, "chainId": 84, "sender": "3MuCofTkjmv397dEuRXE3pZxTb4zDWa96uo", "senderPublicKey": "HGKkqEdKKPVXHMq25FyB6nm1kyvrixu1a8Av6wc9t5CG", "proofs": [ "u2XdpAwtg8kuA36XVdc8S3sTZhA4cWoRbJ1tPYKZyVjMUCfcpKZEhTSYJdzMA6LY9WAQrCeNAoxGD5y5jeRg6t8" ], "script": "base64:BgJ2CAISABIAEgMKAQESAwoBARILCgkBAQEBAQEBAQESEAoOAQEBAQEBAQgICAEBAQESAwoBARIFCgMBAQESBgoEAQEBCBIAEgMKAQESABIDCgEIEgASBAoCCAESAwoBARIAEgMKAQgSAwoBCBIDCgEBEgASAwoBCKEBAAlrX29yYV9rZXkCCWtfb3JhX2tleQAPa19vcmFfYmxvY2tfa2V5Ag9rX29yYV9ibG9ja19rZXkABWtfb3JhAgVrX29yYQAJa19iYWxhbmNlAglrX2JhbGFuY2UADmtfcG9zaXRpb25TaXplAg5rX3Bvc2l0aW9uU2l6ZQAQa19wb3NpdGlvbk1hcmdpbgIQa19wb3NpdGlvbk1hcmdpbgAWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAIWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAAua19wb3NpdGlvbkxhc3RVcGRhdGVkQ3VtdWxhdGl2ZVByZW1pdW1GcmFjdGlvbgISa19wb3NpdGlvbkZyYWN0aW9uABRrX3Bvc2l0aW9uQ2xvc2VkRGF0ZQIUa19wb3NpdGlvbkNsb3NlZERhdGUAD2tfcG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0aW9uBQ91bmRlcmx5aW5nUHJpY2UEDHNob3J0RnVuZGluZwkBBGRpdmQCBRRzaG9ydFByZW1pdW1GcmFjdGlvbgUPdW5kZXJseWluZ1ByaWNlCQACAQkArAICCQCsAgIJAKwCAgkBAXMBBQtsb25nRnVuZGluZwkBAXMBBQxzaG9ydEZ1bmRpbmcJAQFzAQkBEGdldFR3YXBTcG90UHJpY2UACQEBcwEJARJnZXRPcmFjbGVUd2FwUHJpY2UAAWkBGHZpZXdfZ2V0Qm9ycm93ZWRCeVRyYWRlcgEHX3RyYWRlcgQNJHQwNzI4NzA3MjkyNAkBE2dldEJvcnJvd2VkQnlUcmFkZXIBBQdfdHJhZGVyBAhib3Jyb3dlZAgFDSR0MDcyODcwNzI5MjQCXzEEB2Fzc2V0SWQIBQ0kdDA3Mjg3MDcyOTI0Al8yCQACAQkArAICCQEBcwEFCGJvcnJvd2VkBQdhc3NldElkAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAkBDmFkbWluUHVibGljS2V5AMmgpy8=", "height": 2310895, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4MarxRNPpAjvyt2fnpkfkkBtAGFVk72DFqQezVuHpFoC Next: none Diff:
Old | New | Differences | |
---|---|---|---|
18 | 18 | let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction" | |
19 | 19 | ||
20 | 20 | let k_positionClosedDate = "k_positionClosedDate" | |
21 | + | ||
22 | + | let k_positionAsset = "k_positionAsset" | |
21 | 23 | ||
22 | 24 | let k_initialized = "k_initialized" | |
23 | 25 | ||
97 | 99 | ||
98 | 100 | let k_manager_address = "k_manager_address" | |
99 | 101 | ||
102 | + | let k_collateral_address = "k_collateral_address" | |
103 | + | ||
104 | + | let k_exchange_address = "k_exchange_address" | |
105 | + | ||
106 | + | let k_nft_manager_address = "k_nft_manager_address" | |
107 | + | ||
108 | + | let k_trader_market_asset_collateral = "k_trader_market_asset_collateral" | |
109 | + | ||
110 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
111 | + | ||
112 | + | ||
100 | 113 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
101 | 114 | ||
102 | 115 | ||
129 | 142 | ||
130 | 143 | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
131 | 144 | ||
145 | + | ||
146 | + | func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set") | |
147 | + | ||
148 | + | ||
149 | + | func collateralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_collateral_address)), "Collateral Manager not set") | |
150 | + | ||
151 | + | ||
152 | + | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_exchange_address), "No swap address")), "Invalid swap address") | |
153 | + | ||
154 | + | ||
155 | + | let k_whitelist_asset = "k_whitelist_asset" | |
156 | + | ||
157 | + | func isWhitelistAsset (_assetId) = valueOrElse(getBoolean(collateralAddress(), toCompositeKey(k_whitelist_asset, _assetId)), false) | |
158 | + | ||
159 | + | ||
160 | + | let k_token_param = "k_token_param" | |
161 | + | ||
162 | + | let k_token_type = "k_token_type" | |
163 | + | ||
164 | + | let FEE_REDUCTION_TOKEN_TYPE = "fee_reduction" | |
132 | 165 | ||
133 | 166 | let DIR_LONG = 1 | |
134 | 167 | ||
169 | 202 | else _y | |
170 | 203 | ||
171 | 204 | ||
172 | - | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
173 | - | ||
174 | - | ||
175 | 205 | func listToStr (_list) = { | |
176 | 206 | func _join (accumulator,val) = ((accumulator + val) + ",") | |
177 | 207 | ||
206 | 236 | ||
207 | 237 | ||
208 | 238 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
239 | + | ||
240 | + | ||
241 | + | func strA (_address,_key) = { | |
242 | + | let val = valueOrErrorMessage(getString(_address, _key), ("No value for key " + _key)) | |
243 | + | val | |
244 | + | } | |
245 | + | ||
246 | + | ||
247 | + | func intA (_address,_key) = { | |
248 | + | let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key)) | |
249 | + | val | |
250 | + | } | |
209 | 251 | ||
210 | 252 | ||
211 | 253 | func cbalance () = int(k_balance) | |
309 | 351 | } | |
310 | 352 | ||
311 | 353 | ||
354 | + | func getPositionAsset (_trader) = { | |
355 | + | let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader)) | |
356 | + | match positionAssetOpt { | |
357 | + | case positionAsset: String => | |
358 | + | positionAsset | |
359 | + | case _ => | |
360 | + | toBase58String(quoteAsset()) | |
361 | + | } | |
362 | + | } | |
363 | + | ||
364 | + | ||
312 | 365 | func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0)) | |
313 | 366 | then throw("No open position") | |
314 | 367 | else true | |
347 | 400 | let amountBaseAssetBought = if (_isAdd) | |
348 | 401 | then amountBaseAssetBoughtAbs | |
349 | 402 | else -(amountBaseAssetBoughtAbs) | |
350 | - | let $ | |
351 | - | let quoteAssetReserveAfter1 = $ | |
352 | - | let baseAssetReserveAfter1 = $ | |
353 | - | let totalPositionSizeAfter1 = $ | |
354 | - | let cumulativeNotionalAfter1 = $ | |
403 | + | let $t01497415167 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs) | |
404 | + | let quoteAssetReserveAfter1 = $t01497415167._1 | |
405 | + | let baseAssetReserveAfter1 = $t01497415167._2 | |
406 | + | let totalPositionSizeAfter1 = $t01497415167._3 | |
407 | + | let cumulativeNotionalAfter1 = $t01497415167._4 | |
355 | 408 | let priceBefore = divd(_qtAstR, _bsAstR) | |
356 | 409 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
357 | 410 | let priceDiff = abs((priceBefore - marketPrice)) | |
371 | 424 | } | |
372 | 425 | else 0 | |
373 | 426 | let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin) | |
374 | - | let $ | |
427 | + | let $t01665816785 = if ((0 > signedMargin)) | |
375 | 428 | then $Tuple2(0, abs(signedMargin)) | |
376 | 429 | else $Tuple2(abs(signedMargin), 0) | |
377 | - | let remainMargin = $ | |
378 | - | let badDebt = $ | |
430 | + | let remainMargin = $t01665816785._1 | |
431 | + | let badDebt = $t01665816785._2 | |
379 | 432 | $Tuple3(remainMargin, badDebt, fundingPayment) | |
380 | 433 | } | |
381 | 434 | ||
392 | 445 | let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter) | |
393 | 446 | let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve)) | |
394 | 447 | let maxPriceImpactValue = maxPriceImpact() | |
395 | - | let $ | |
396 | - | let quoteAssetReserveAfter1 = $ | |
397 | - | let baseAssetReserveAfter1 = $ | |
398 | - | let totalPositionSizeAfter1 = $ | |
399 | - | let cumulativeNotionalAfter1 = $ | |
448 | + | let $t01776217955 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount) | |
449 | + | let quoteAssetReserveAfter1 = $t01776217955._1 | |
450 | + | let baseAssetReserveAfter1 = $t01776217955._2 | |
451 | + | let totalPositionSizeAfter1 = $t01776217955._3 | |
452 | + | let cumulativeNotionalAfter1 = $t01776217955._4 | |
400 | 453 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
401 | 454 | let priceDiff = abs((priceBefore - marketPrice)) | |
402 | 455 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
455 | 508 | let isShort = (0 > _positionSize) | |
456 | 509 | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
457 | 510 | then { | |
458 | - | let $ | |
459 | - | let outPositionNotional = $ | |
460 | - | let x1 = $ | |
461 | - | let x2 = $ | |
462 | - | let x3 = $ | |
511 | + | let $t02117321344 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve) | |
512 | + | let outPositionNotional = $t02117321344._1 | |
513 | + | let x1 = $t02117321344._2 | |
514 | + | let x2 = $t02117321344._3 | |
515 | + | let x3 = $t02117321344._4 | |
463 | 516 | outPositionNotional | |
464 | 517 | } | |
465 | 518 | else muld(positionSizeAbs, getOracleTwapPrice()) | |
480 | 533 | ||
481 | 534 | ||
482 | 535 | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
483 | - | let $ | |
484 | - | let positionSize = $ | |
485 | - | let positionMargin = $ | |
486 | - | let positionOpenNotional = $ | |
487 | - | let positionLstUpdCPF = $ | |
536 | + | let $t02266122789 = getPosition(_trader) | |
537 | + | let positionSize = $t02266122789._1 | |
538 | + | let positionMargin = $t02266122789._2 | |
539 | + | let positionOpenNotional = $t02266122789._3 | |
540 | + | let positionLstUpdCPF = $t02266122789._4 | |
488 | 541 | getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), bsAstR(), _option) | |
489 | 542 | } | |
490 | 543 | ||
493 | 546 | ||
494 | 547 | ||
495 | 548 | func getMarginRatioByOption (_trader,_option) = { | |
496 | - | let $ | |
497 | - | let positionSize = $ | |
498 | - | let positionMargin = $ | |
499 | - | let pon = $ | |
500 | - | let positionLstUpdCPF = $ | |
501 | - | let $ | |
502 | - | let positionNotional = $ | |
503 | - | let unrealizedPnl = $ | |
504 | - | let $ | |
505 | - | let remainMargin = $ | |
506 | - | let badDebt = $ | |
549 | + | let $t02327023381 = getPosition(_trader) | |
550 | + | let positionSize = $t02327023381._1 | |
551 | + | let positionMargin = $t02327023381._2 | |
552 | + | let pon = $t02327023381._3 | |
553 | + | let positionLstUpdCPF = $t02327023381._4 | |
554 | + | let $t02338723480 = getPositionNotionalAndUnrealizedPnl(_trader, _option) | |
555 | + | let positionNotional = $t02338723480._1 | |
556 | + | let unrealizedPnl = $t02338723480._2 | |
557 | + | let $t02348523651 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
558 | + | let remainMargin = $t02348523651._1 | |
559 | + | let badDebt = $t02348523651._2 | |
507 | 560 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
508 | 561 | } | |
509 | 562 | ||
528 | 581 | ||
529 | 582 | ||
530 | 583 | func internalClosePosition (_trader,_checkMaxPriceImpact) = { | |
531 | - | let $ | |
532 | - | let positionSize = $ | |
533 | - | let positionMargin = $ | |
534 | - | let positionOpenNotional = $ | |
535 | - | let positionLstUpdCPF = $ | |
584 | + | let $t02488425012 = getPosition(_trader) | |
585 | + | let positionSize = $t02488425012._1 | |
586 | + | let positionMargin = $t02488425012._2 | |
587 | + | let positionOpenNotional = $t02488425012._3 | |
588 | + | let positionLstUpdCPF = $t02488425012._4 | |
536 | 589 | let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2 | |
537 | - | let $ | |
538 | - | let remainMargin = $ | |
539 | - | let badDebt = $ | |
590 | + | let $t02510725275 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
591 | + | let remainMargin = $t02510725275._1 | |
592 | + | let badDebt = $t02510725275._2 | |
540 | 593 | let exchangedPositionSize = -(positionSize) | |
541 | 594 | let realizedPnl = unrealizedPnl | |
542 | 595 | let marginToVault = -(remainMargin) | |
543 | - | let $ | |
544 | - | let exchangedQuoteAssetAmount = $ | |
545 | - | let quoteAssetReserveAfter = $ | |
546 | - | let baseAssetReserveAfter = $ | |
547 | - | let totalPositionSizeAfter = $ | |
548 | - | let cumulativeNotionalAfter = $ | |
549 | - | let totalLongAfter = $ | |
550 | - | let totalShortAfter = $ | |
596 | + | let $t02540225713 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact) | |
597 | + | let exchangedQuoteAssetAmount = $t02540225713._1 | |
598 | + | let quoteAssetReserveAfter = $t02540225713._2 | |
599 | + | let baseAssetReserveAfter = $t02540225713._3 | |
600 | + | let totalPositionSizeAfter = $t02540225713._4 | |
601 | + | let cumulativeNotionalAfter = $t02540225713._5 | |
602 | + | let totalLongAfter = $t02540225713._6 | |
603 | + | let totalShortAfter = $t02540225713._7 | |
551 | 604 | let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional) | |
552 | 605 | $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter) | |
553 | 606 | } | |
623 | 676 | } | |
624 | 677 | ||
625 | 678 | ||
679 | + | func getAdjustedFee (i) = { | |
680 | + | let baseFee = fee() | |
681 | + | let $t02937629984 = if ((size(i.payments) > 1)) | |
682 | + | then { | |
683 | + | let artifactId = toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid attached artifact")) | |
684 | + | let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, artifactId)) | |
685 | + | if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE)) | |
686 | + | then { | |
687 | + | let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, artifactId)) | |
688 | + | let adjustedFee = muld(baseFee, reduction) | |
689 | + | $Tuple2(adjustedFee, true) | |
690 | + | } | |
691 | + | else throw("Invalid attached artifact") | |
692 | + | } | |
693 | + | else $Tuple2(baseFee, false) | |
694 | + | let adjustedFee = $t02937629984._1 | |
695 | + | let burnArtifact = $t02937629984._2 | |
696 | + | $Tuple2(adjustedFee, burnArtifact) | |
697 | + | } | |
698 | + | ||
699 | + | ||
626 | 700 | 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)] | |
627 | 701 | ||
628 | 702 | ||
629 | 703 | func updateFunding (_nextFundingBlock,_latestLongCumulativePremiumFraction,_latestShortCumulativePremiumFraction,_longFundingRate,_shortFundingRate) = [IntegerEntry(k_nextFundingBlock, _nextFundingBlock), IntegerEntry(k_latestLongCumulativePremiumFraction, _latestLongCumulativePremiumFraction), IntegerEntry(k_latestShortCumulativePremiumFraction, _latestShortCumulativePremiumFraction), IntegerEntry(k_longFundingRate, _longFundingRate), IntegerEntry(k_shortFundingRate, _shortFundingRate)] | |
704 | + | ||
705 | + | ||
706 | + | func updatePositionAsset (_address,_assetId) = [StringEntry(toCompositeKey(k_positionAsset, _address), _assetId)] | |
630 | 707 | ||
631 | 708 | ||
632 | 709 | 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)] | |
668 | 745 | 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))) | |
669 | 746 | ||
670 | 747 | ||
671 | - | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)] | |
748 | + | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)] | |
672 | 749 | ||
673 | 750 | ||
674 | 751 | func withdraw (_address,_amount) = { | |
685 | 762 | ||
686 | 763 | ||
687 | 764 | func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())] | |
765 | + | ||
766 | + | ||
767 | + | func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact) | |
768 | + | then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)] | |
769 | + | else nil | |
770 | + | ||
771 | + | ||
772 | + | func isSameAssetOrNoPosition (_trader,_assetId) = { | |
773 | + | let oldPositionSize = getPosition(_trader)._1 | |
774 | + | if ((oldPositionSize == 0)) | |
775 | + | then true | |
776 | + | else (getPositionAsset(_trader) == _assetId) | |
777 | + | } | |
778 | + | ||
779 | + | ||
780 | + | func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId) | |
781 | + | ||
782 | + | ||
783 | + | func getBorrowedByTraderInMarketKey (_amm,_assetId,_trader) = ((((((k_trader_market_asset_collateral + "_") + _amm) + "_") + _assetId) + "_") + _trader) | |
784 | + | ||
785 | + | ||
786 | + | func getBorrowedByTrader (_trader) = { | |
787 | + | let positionAsset = getPositionAsset(_trader) | |
788 | + | if ((positionAsset == toBase58String(quoteAsset()))) | |
789 | + | then $Tuple2(0, positionAsset) | |
790 | + | else { | |
791 | + | let key = getBorrowedByTraderInMarketKey(toString(this), positionAsset, _trader) | |
792 | + | let borrow = valueOrElse(getInteger(collateralAddress(), key), 0) | |
793 | + | $Tuple2(borrow, positionAsset) | |
794 | + | } | |
795 | + | } | |
688 | 796 | ||
689 | 797 | ||
690 | 798 | @Callable(i) | |
792 | 900 | else paused()) | |
793 | 901 | then throw("Invalid decreasePosition parameters") | |
794 | 902 | else { | |
795 | - | let $ | |
796 | - | let oldPositionSize = $ | |
797 | - | let oldPositionMargin = $ | |
798 | - | let oldPositionOpenNotional = $ | |
799 | - | let oldPositionLstUpdCPF = $ | |
903 | + | let $t04149241644 = getPosition(toString(i.caller)) | |
904 | + | let oldPositionSize = $t04149241644._1 | |
905 | + | let oldPositionMargin = $t04149241644._2 | |
906 | + | let oldPositionOpenNotional = $t04149241644._3 | |
907 | + | let oldPositionLstUpdCPF = $t04149241644._4 | |
800 | 908 | let _direction = if ((oldPositionSize > 0)) | |
801 | 909 | then DIR_SHORT | |
802 | 910 | else DIR_LONG | |
803 | 911 | let isAdd = (_direction == DIR_LONG) | |
804 | 912 | let openNotional = muld(_amount, _leverage) | |
805 | - | let $ | |
806 | - | let oldPositionNotional = $ | |
807 | - | let unrealizedPnl = $ | |
808 | - | let $ | |
913 | + | let $t04181741933 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
914 | + | let oldPositionNotional = $t04181741933._1 | |
915 | + | let unrealizedPnl = $t04181741933._2 | |
916 | + | let $t04193944488 = if ((oldPositionNotional > openNotional)) | |
809 | 917 | then { | |
810 | - | let $ | |
811 | - | let exchangedPositionSize = $ | |
812 | - | let quoteAssetReserveAfter = $ | |
813 | - | let baseAssetReserveAfter = $ | |
814 | - | let totalPositionSizeAfter = $ | |
815 | - | let cumulativeNotionalAfter = $ | |
918 | + | let $t04231642535 = swapInput(isAdd, openNotional) | |
919 | + | let exchangedPositionSize = $t04231642535._1 | |
920 | + | let quoteAssetReserveAfter = $t04231642535._2 | |
921 | + | let baseAssetReserveAfter = $t04231642535._3 | |
922 | + | let totalPositionSizeAfter = $t04231642535._4 | |
923 | + | let cumulativeNotionalAfter = $t04231642535._5 | |
816 | 924 | let exchangedPositionSizeAbs = abs(exchangedPositionSize) | |
817 | 925 | if (if ((_minBaseAssetAmount != 0)) | |
818 | 926 | then (_minBaseAssetAmount > exchangedPositionSizeAbs) | |
820 | 928 | then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount))) | |
821 | 929 | else { | |
822 | 930 | let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize)) | |
823 | - | let $ | |
824 | - | let remainMargin = $ | |
825 | - | let badDebt = $ | |
826 | - | let fundingPayment = $ | |
931 | + | let $t04297243217 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
932 | + | let remainMargin = $t04297243217._1 | |
933 | + | let badDebt = $t04297243217._2 | |
934 | + | let fundingPayment = $t04297243217._3 | |
827 | 935 | let exchangedQuoteAssetAmount = openNotional | |
828 | 936 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
829 | 937 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
838 | 946 | } | |
839 | 947 | } | |
840 | 948 | else throw("Close position first") | |
841 | - | let newPositionSize = $ | |
842 | - | let newPositionRemainMargin = $ | |
843 | - | let newPositionOpenNotional = $ | |
844 | - | let newPositionLatestCPF = $ | |
845 | - | let baseAssetReserveAfter = $ | |
846 | - | let quoteAssetReserveAfter = $ | |
847 | - | let totalPositionSizeAfter = $ | |
848 | - | let cumulativeNotionalAfter = $ | |
849 | - | let openInterestNotionalAfter = $ | |
850 | - | let totalLongAfter = $ | |
851 | - | let totalShortAfter = $ | |
949 | + | let newPositionSize = $t04193944488._1 | |
950 | + | let newPositionRemainMargin = $t04193944488._2 | |
951 | + | let newPositionOpenNotional = $t04193944488._3 | |
952 | + | let newPositionLatestCPF = $t04193944488._4 | |
953 | + | let baseAssetReserveAfter = $t04193944488._5 | |
954 | + | let quoteAssetReserveAfter = $t04193944488._6 | |
955 | + | let totalPositionSizeAfter = $t04193944488._7 | |
956 | + | let cumulativeNotionalAfter = $t04193944488._8 | |
957 | + | let openInterestNotionalAfter = $t04193944488._9 | |
958 | + | let totalLongAfter = $t04193944488._10 | |
959 | + | let totalShortAfter = $t04193944488._11 | |
852 | 960 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
853 | 961 | if ((notifyNotional == notifyNotional)) | |
854 | 962 | then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
859 | 967 | ||
860 | 968 | @Callable(i) | |
861 | 969 | func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = { | |
970 | + | let _trader = toString(i.caller) | |
862 | 971 | let _rawAmount = i.payments[0].amount | |
863 | - | if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
972 | + | let _assetId = i.payments[0].assetId | |
973 | + | let _assetIdStr = toBase58String(value(_assetId)) | |
974 | + | let isQuoteAsset = (_assetId == quoteAsset()) | |
975 | + | let isCollateralAsset = isWhitelistAsset(_assetIdStr) | |
976 | + | if (if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
864 | 977 | then (_direction != DIR_SHORT) | |
865 | 978 | else false) | |
866 | 979 | then true | |
868 | 981 | then true | |
869 | 982 | else !(initialized())) | |
870 | 983 | then true | |
871 | - | else (i.payments[0].assetId != quoteAsset())) | |
984 | + | else if (!(isQuoteAsset)) | |
985 | + | then !(isCollateralAsset) | |
986 | + | else false) | |
987 | + | then true | |
988 | + | else !(isSameAssetOrNoPosition(_trader, _assetIdStr))) | |
872 | 989 | then true | |
873 | 990 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
874 | 991 | then true | |
875 | 992 | else paused()) | |
876 | 993 | then throw("Invalid increasePosition parameters") | |
877 | 994 | else { | |
878 | - | let _trader = toString(i.caller) | |
879 | - | let rawFeeAmount = muld(_rawAmount, fee()) | |
880 | - | let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), rawFeeAmount)]) | |
881 | - | if ((referrerFeeAny == referrerFeeAny)) | |
995 | + | let baseFee = fee() | |
996 | + | let $t04585045901 = getAdjustedFee(i) | |
997 | + | let adjustedFee = $t04585045901._1 | |
998 | + | let burnArtifact = $t04585045901._2 | |
999 | + | let rawFeeAmount = muld(_rawAmount, adjustedFee) | |
1000 | + | let _amount = (_rawAmount - rawFeeAmount) | |
1001 | + | let distributeFeeAmount = if (isCollateralAsset) | |
882 | 1002 | then { | |
883 | - | let referrerFee = match referrerFeeAny { | |
884 | - | case x: Int => | |
885 | - | x | |
886 | - | case _ => | |
887 | - | throw("Invalid referrerFee") | |
1003 | + | let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)]) | |
1004 | + | if ((doBorrow == doBorrow)) | |
1005 | + | then { | |
1006 | + | let balanceBefore = assetBalance(this, quoteAsset()) | |
1007 | + | if ((balanceBefore == balanceBefore)) | |
1008 | + | then { | |
1009 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)]) | |
1010 | + | if ((doSwap == doSwap)) | |
1011 | + | then { | |
1012 | + | let balanceAfter = assetBalance(this, quoteAsset()) | |
1013 | + | if ((balanceAfter == balanceAfter)) | |
1014 | + | then { | |
1015 | + | let exchangedAmount = (balanceAfter - balanceBefore) | |
1016 | + | if ((exchangedAmount == exchangedAmount)) | |
1017 | + | then exchangedAmount | |
1018 | + | else throw("Strict value is not equal to itself.") | |
1019 | + | } | |
1020 | + | else throw("Strict value is not equal to itself.") | |
1021 | + | } | |
1022 | + | else throw("Strict value is not equal to itself.") | |
1023 | + | } | |
1024 | + | else throw("Strict value is not equal to itself.") | |
1025 | + | } | |
1026 | + | else throw("Strict value is not equal to itself.") | |
888 | 1027 | } | |
889 | - | let _amount = (_rawAmount - rawFeeAmount) | |
890 | - | let feeAmount = (rawFeeAmount - referrerFee) | |
891 | - | let $t04205942199 = getPosition(_trader) | |
892 | - | let oldPositionSize = $t04205942199._1 | |
893 | - | let oldPositionMargin = $t04205942199._2 | |
894 | - | let oldPositionOpenNotional = $t04205942199._3 | |
895 | - | let oldPositionLstUpdCPF = $t04205942199._4 | |
896 | - | let isNewPosition = (oldPositionSize == 0) | |
897 | - | let isSameDirection = if ((oldPositionSize > 0)) | |
898 | - | then (_direction == DIR_LONG) | |
899 | - | else (_direction == DIR_SHORT) | |
900 | - | let expandExisting = if (!(isNewPosition)) | |
901 | - | then isSameDirection | |
902 | - | else false | |
903 | - | let isAdd = (_direction == DIR_LONG) | |
904 | - | let $t04248845056 = if (if (isNewPosition) | |
905 | - | then true | |
906 | - | else expandExisting) | |
1028 | + | else rawFeeAmount | |
1029 | + | if ((distributeFeeAmount == distributeFeeAmount)) | |
1030 | + | then { | |
1031 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1032 | + | if ((referrerFeeAny == referrerFeeAny)) | |
907 | 1033 | then { | |
908 | - | let openNotional = muld(_amount, _leverage) | |
909 | - | let $t04291243118 = swapInput(isAdd, openNotional) | |
910 | - | let amountBaseAssetBought = $t04291243118._1 | |
911 | - | let quoteAssetReserveAfter = $t04291243118._2 | |
912 | - | let baseAssetReserveAfter = $t04291243118._3 | |
913 | - | let totalPositionSizeAfter = $t04291243118._4 | |
914 | - | let cumulativeNotionalAfter = $t04291243118._5 | |
915 | - | if (if ((_minBaseAssetAmount != 0)) | |
916 | - | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
917 | - | else false) | |
918 | - | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1034 | + | let referrerFee = match referrerFeeAny { | |
1035 | + | case x: Int => | |
1036 | + | x | |
1037 | + | case _ => | |
1038 | + | throw("Invalid referrerFee") | |
1039 | + | } | |
1040 | + | let feeAmount = (distributeFeeAmount - referrerFee) | |
1041 | + | let $t04721747357 = getPosition(_trader) | |
1042 | + | let oldPositionSize = $t04721747357._1 | |
1043 | + | let oldPositionMargin = $t04721747357._2 | |
1044 | + | let oldPositionOpenNotional = $t04721747357._3 | |
1045 | + | let oldPositionLstUpdCPF = $t04721747357._4 | |
1046 | + | let isNewPosition = (oldPositionSize == 0) | |
1047 | + | let isSameDirection = if ((oldPositionSize > 0)) | |
1048 | + | then (_direction == DIR_LONG) | |
1049 | + | else (_direction == DIR_SHORT) | |
1050 | + | let expandExisting = if (!(isNewPosition)) | |
1051 | + | then isSameDirection | |
1052 | + | else false | |
1053 | + | let isAdd = (_direction == DIR_LONG) | |
1054 | + | let $t04764650231 = if (if (isNewPosition) | |
1055 | + | then true | |
1056 | + | else expandExisting) | |
1057 | + | then { | |
1058 | + | let openNotional = muld(_amount, _leverage) | |
1059 | + | let $t04807048276 = swapInput(isAdd, openNotional) | |
1060 | + | let amountBaseAssetBought = $t04807048276._1 | |
1061 | + | let quoteAssetReserveAfter = $t04807048276._2 | |
1062 | + | let baseAssetReserveAfter = $t04807048276._3 | |
1063 | + | let totalPositionSizeAfter = $t04807048276._4 | |
1064 | + | let cumulativeNotionalAfter = $t04807048276._5 | |
1065 | + | if (if ((_minBaseAssetAmount != 0)) | |
1066 | + | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
1067 | + | else false) | |
1068 | + | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1069 | + | else { | |
1070 | + | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
1071 | + | let increaseMarginRequirement = divd(openNotional, _leverage) | |
1072 | + | let $t04865748896 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
1073 | + | let remainMargin = $t04865748896._1 | |
1074 | + | let x1 = $t04865748896._2 | |
1075 | + | let x2 = $t04865748896._3 | |
1076 | + | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
1077 | + | then throw("Over max spread limit") | |
1078 | + | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
1079 | + | then abs(amountBaseAssetBought) | |
1080 | + | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
1081 | + | then abs(amountBaseAssetBought) | |
1082 | + | else 0))) | |
1083 | + | } | |
1084 | + | } | |
919 | 1085 | else { | |
920 | - | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
921 | - | let increaseMarginRequirement = divd(openNotional, _leverage) | |
922 | - | let $t04349943738 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
923 | - | let remainMargin = $t04349943738._1 | |
924 | - | let x1 = $t04349943738._2 | |
925 | - | let x2 = $t04349943738._3 | |
926 | - | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
927 | - | then throw("Over max spread limit") | |
928 | - | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
929 | - | then abs(amountBaseAssetBought) | |
930 | - | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
931 | - | then abs(amountBaseAssetBought) | |
932 | - | else 0))) | |
1086 | + | let openNotional = muld(_amount, _leverage) | |
1087 | + | let $t04992450040 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
1088 | + | let oldPositionNotional = $t04992450040._1 | |
1089 | + | let unrealizedPnl = $t04992450040._2 | |
1090 | + | if ((oldPositionNotional > openNotional)) | |
1091 | + | then throw("Use decreasePosition to decrease position size") | |
1092 | + | else throw("Close position first") | |
933 | 1093 | } | |
934 | - | } | |
935 | - | else { | |
936 | - | let openNotional = muld(_amount, _leverage) | |
937 | - | let $t04474944865 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
938 | - | let oldPositionNotional = $t04474944865._1 | |
939 | - | let unrealizedPnl = $t04474944865._2 | |
940 | - | if ((oldPositionNotional > openNotional)) | |
941 | - | then throw("Use decreasePosition to decrease position size") | |
942 | - | else throw("Close position first") | |
943 | - | } | |
944 | - | let newPositionSize = $t04248845056._1 | |
945 | - | let newPositionRemainMargin = $t04248845056._2 | |
946 | - | let newPositionOpenNotional = $t04248845056._3 | |
947 | - | let newPositionLatestCPF = $t04248845056._4 | |
948 | - | let baseAssetReserveAfter = $t04248845056._5 | |
949 | - | let quoteAssetReserveAfter = $t04248845056._6 | |
950 | - | let totalPositionSizeAfter = $t04248845056._7 | |
951 | - | let cumulativeNotionalAfter = $t04248845056._8 | |
952 | - | let openInterestNotionalAfter = $t04248845056._9 | |
953 | - | let totalLongAfter = $t04248845056._10 | |
954 | - | let totalShortAfter = $t04248845056._11 | |
955 | - | let feeToStakers = (feeAmount / 2) | |
956 | - | let feeToInsurance = (feeAmount - feeToStakers) | |
957 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
958 | - | if ((stake == stake)) | |
959 | - | then { | |
960 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
961 | - | if ((depositInsurance == depositInsurance)) | |
1094 | + | let newPositionSize = $t04764650231._1 | |
1095 | + | let newPositionRemainMargin = $t04764650231._2 | |
1096 | + | let newPositionOpenNotional = $t04764650231._3 | |
1097 | + | let newPositionLatestCPF = $t04764650231._4 | |
1098 | + | let baseAssetReserveAfter = $t04764650231._5 | |
1099 | + | let quoteAssetReserveAfter = $t04764650231._6 | |
1100 | + | let totalPositionSizeAfter = $t04764650231._7 | |
1101 | + | let cumulativeNotionalAfter = $t04764650231._8 | |
1102 | + | let openInterestNotionalAfter = $t04764650231._9 | |
1103 | + | let totalLongAfter = $t04764650231._10 | |
1104 | + | let totalShortAfter = $t04764650231._11 | |
1105 | + | let feeToStakers = (feeAmount / 2) | |
1106 | + | let feeToInsurance = (feeAmount - feeToStakers) | |
1107 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1108 | + | if ((stake == stake)) | |
962 | 1109 | then { | |
963 | - | let | |
964 | - | if (( | |
1110 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1111 | + | if ((depositInsurance == depositInsurance)) | |
965 | 1112 | then { | |
966 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
967 | - | if ((notifyNotional == notifyNotional)) | |
968 | - | then (((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
1113 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1114 | + | if ((notifyFee == notifyFee)) | |
1115 | + | then { | |
1116 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1117 | + | if ((notifyNotional == notifyNotional)) | |
1118 | + | then (((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1119 | + | else throw("Strict value is not equal to itself.") | |
1120 | + | } | |
969 | 1121 | else throw("Strict value is not equal to itself.") | |
970 | 1122 | } | |
971 | 1123 | else throw("Strict value is not equal to itself.") | |
982 | 1134 | ||
983 | 1135 | @Callable(i) | |
984 | 1136 | func addMargin () = { | |
1137 | + | let _trader = toString(i.caller) | |
985 | 1138 | let _rawAmount = i.payments[0].amount | |
986 | - | if (if (if (if ((i.payments[0].assetId != quoteAsset())) | |
1139 | + | let _assetId = i.payments[0].assetId | |
1140 | + | let _assetIdStr = toBase58String(value(_assetId)) | |
1141 | + | let isQuoteAsset = (_assetId == quoteAsset()) | |
1142 | + | let isCollateralAsset = isWhitelistAsset(_assetIdStr) | |
1143 | + | if (if (if (if (if (if (!(isQuoteAsset)) | |
1144 | + | then !(isCollateralAsset) | |
1145 | + | else false) | |
987 | 1146 | then true | |
988 | 1147 | else !(requireOpenPosition(toString(i.caller)))) | |
1148 | + | then true | |
1149 | + | else !(isSameAsset(_trader, _assetIdStr))) | |
989 | 1150 | then true | |
990 | 1151 | else !(initialized())) | |
991 | 1152 | then true | |
992 | 1153 | else paused()) | |
993 | 1154 | then throw("Invalid addMargin parameters") | |
994 | 1155 | else { | |
995 | - | let _trader = toString(i.caller) | |
996 | - | let rawFeeAmount = muld(_rawAmount, fee()) | |
997 | - | let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), rawFeeAmount)]) | |
998 | - | if ((referrerFeeAny == referrerFeeAny)) | |
1156 | + | let $t05198752038 = getAdjustedFee(i) | |
1157 | + | let adjustedFee = $t05198752038._1 | |
1158 | + | let burnArtifact = $t05198752038._2 | |
1159 | + | let rawFeeAmount = muld(_rawAmount, adjustedFee) | |
1160 | + | let _amount = (_rawAmount - rawFeeAmount) | |
1161 | + | let distributeFeeAmount = if (isCollateralAsset) | |
999 | 1162 | then { | |
1000 | - | let referrerFee = match referrerFeeAny { | |
1001 | - | case x: Int => | |
1002 | - | x | |
1003 | - | case _ => | |
1004 | - | throw("Invalid referrerFee") | |
1163 | + | let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)]) | |
1164 | + | if ((doBorrow == doBorrow)) | |
1165 | + | then { | |
1166 | + | let balanceBefore = assetBalance(this, quoteAsset()) | |
1167 | + | if ((balanceBefore == balanceBefore)) | |
1168 | + | then { | |
1169 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)]) | |
1170 | + | if ((doSwap == doSwap)) | |
1171 | + | then { | |
1172 | + | let balanceAfter = assetBalance(this, quoteAsset()) | |
1173 | + | if ((balanceAfter == balanceAfter)) | |
1174 | + | then { | |
1175 | + | let exchangedAmount = (balanceAfter - balanceBefore) | |
1176 | + | if ((exchangedAmount == exchangedAmount)) | |
1177 | + | then exchangedAmount | |
1178 | + | else throw("Strict value is not equal to itself.") | |
1179 | + | } | |
1180 | + | else throw("Strict value is not equal to itself.") | |
1181 | + | } | |
1182 | + | else throw("Strict value is not equal to itself.") | |
1183 | + | } | |
1184 | + | else throw("Strict value is not equal to itself.") | |
1185 | + | } | |
1186 | + | else throw("Strict value is not equal to itself.") | |
1005 | 1187 | } | |
1006 | - | let feeAmount = (rawFeeAmount - referrerFee) | |
1007 | - | let _amount = (_rawAmount - rawFeeAmount) | |
1008 | - | let $t04690247042 = getPosition(_trader) | |
1009 | - | let oldPositionSize = $t04690247042._1 | |
1010 | - | let oldPositionMargin = $t04690247042._2 | |
1011 | - | let oldPositionOpenNotional = $t04690247042._3 | |
1012 | - | let oldPositionLstUpdCPF = $t04690247042._4 | |
1013 | - | let feeToStakers = (feeAmount / 2) | |
1014 | - | let feeToInsurance = (feeAmount - feeToStakers) | |
1015 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1016 | - | if ((stake == stake)) | |
1188 | + | else rawFeeAmount | |
1189 | + | if ((distributeFeeAmount == distributeFeeAmount)) | |
1190 | + | then { | |
1191 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1192 | + | if ((referrerFeeAny == referrerFeeAny)) | |
1017 | 1193 | then { | |
1018 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1019 | - | if ((depositInsurance == depositInsurance)) | |
1194 | + | let referrerFee = match referrerFeeAny { | |
1195 | + | case x: Int => | |
1196 | + | x | |
1197 | + | case _ => | |
1198 | + | throw("Invalid referrerFee") | |
1199 | + | } | |
1200 | + | let feeAmount = (distributeFeeAmount - referrerFee) | |
1201 | + | let $t05333753477 = getPosition(_trader) | |
1202 | + | let oldPositionSize = $t05333753477._1 | |
1203 | + | let oldPositionMargin = $t05333753477._2 | |
1204 | + | let oldPositionOpenNotional = $t05333753477._3 | |
1205 | + | let oldPositionLstUpdCPF = $t05333753477._4 | |
1206 | + | let feeToStakers = (feeAmount / 2) | |
1207 | + | let feeToInsurance = (feeAmount - feeToStakers) | |
1208 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1209 | + | if ((stake == stake)) | |
1020 | 1210 | then { | |
1021 | - | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1022 | - | if ((notifyFee == notifyFee)) | |
1023 | - | then ((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
1211 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1212 | + | if ((depositInsurance == depositInsurance)) | |
1213 | + | then { | |
1214 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1215 | + | if ((notifyFee == notifyFee)) | |
1216 | + | then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1217 | + | else throw("Strict value is not equal to itself.") | |
1218 | + | } | |
1024 | 1219 | else throw("Strict value is not equal to itself.") | |
1025 | 1220 | } | |
1026 | 1221 | else throw("Strict value is not equal to itself.") | |
1034 | 1229 | ||
1035 | 1230 | ||
1036 | 1231 | @Callable(i) | |
1037 | - | func removeMargin (_amount) = if (if (if (if ((0 >= _amount)) | |
1038 | - | then true | |
1039 | - | else !(requireOpenPosition(toString(i.caller)))) | |
1040 | - | then true | |
1041 | - | else !(initialized())) | |
1042 | - | then true | |
1043 | - | else paused()) | |
1044 | - | then throw("Invalid removeMargin parameters") | |
1045 | - | else { | |
1046 | - | let $t04801848170 = getPosition(toString(i.caller)) | |
1047 | - | let oldPositionSize = $t04801848170._1 | |
1048 | - | let oldPositionMargin = $t04801848170._2 | |
1049 | - | let oldPositionOpenNotional = $t04801848170._3 | |
1050 | - | let oldPositionLstUpdCPF = $t04801848170._4 | |
1051 | - | let marginDelta = -(_amount) | |
1052 | - | let $t04820748386 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
1053 | - | let remainMargin = $t04820748386._1 | |
1054 | - | let badDebt = $t04820748386._2 | |
1055 | - | if ((badDebt != 0)) | |
1056 | - | then throw("Invalid removed margin amount") | |
1057 | - | else { | |
1058 | - | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1059 | - | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1060 | - | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1061 | - | else { | |
1062 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil) | |
1063 | - | if ((unstake == unstake)) | |
1064 | - | then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount))) | |
1065 | - | else throw("Strict value is not equal to itself.") | |
1066 | - | } | |
1067 | - | } | |
1068 | - | } | |
1232 | + | func removeMargin (_amount) = { | |
1233 | + | let _trader = toString(i.caller) | |
1234 | + | if (if (if (if ((0 >= _amount)) | |
1235 | + | then true | |
1236 | + | else !(requireOpenPosition(_trader))) | |
1237 | + | then true | |
1238 | + | else !(initialized())) | |
1239 | + | then true | |
1240 | + | else paused()) | |
1241 | + | then throw("Invalid removeMargin parameters") | |
1242 | + | else { | |
1243 | + | let $t05452054660 = getPosition(_trader) | |
1244 | + | let oldPositionSize = $t05452054660._1 | |
1245 | + | let oldPositionMargin = $t05452054660._2 | |
1246 | + | let oldPositionOpenNotional = $t05452054660._3 | |
1247 | + | let oldPositionLstUpdCPF = $t05452054660._4 | |
1248 | + | let marginDelta = -(_amount) | |
1249 | + | let $t05469754876 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
1250 | + | let remainMargin = $t05469754876._1 | |
1251 | + | let badDebt = $t05469754876._2 | |
1252 | + | if ((badDebt != 0)) | |
1253 | + | then throw("Invalid removed margin amount") | |
1254 | + | else { | |
1255 | + | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1256 | + | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1257 | + | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1258 | + | else { | |
1259 | + | let quoteAssetStr = toBase58String(quoteAsset()) | |
1260 | + | let $t05532055374 = getBorrowedByTrader(_trader) | |
1261 | + | let borrowed = $t05532055374._1 | |
1262 | + | let assetId = $t05532055374._2 | |
1263 | + | let toRepay = if ((_amount > borrowed)) | |
1264 | + | then borrowed | |
1265 | + | else _amount | |
1266 | + | let toWithdraw = if ((borrowed > _amount)) | |
1267 | + | then 0 | |
1268 | + | else (_amount - borrowed) | |
1269 | + | let finalBorrow = (borrowed - toRepay) | |
1270 | + | let switchPositionToQuote = if ((finalBorrow > 0)) | |
1271 | + | then nil | |
1272 | + | else updatePositionAsset(_trader, quoteAssetStr) | |
1273 | + | let doSanityCheck = if (((toRepay + toWithdraw) != _amount)) | |
1274 | + | then throw(((((("toRepay=" + toString(toRepay)) + " + toWithdraw=") + toString(toWithdraw)) + " != ") + toString(_amount))) | |
1275 | + | else nil | |
1276 | + | if ((doSanityCheck == doSanityCheck)) | |
1277 | + | then { | |
1278 | + | let doUnstake = invoke(managerAddress(), "withdraw", [quoteAssetStr, _amount], nil) | |
1279 | + | if ((doUnstake == doUnstake)) | |
1280 | + | then { | |
1281 | + | let returnCollateralAction = if ((toRepay > 0)) | |
1282 | + | then { | |
1283 | + | let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), toRepay)]) | |
1284 | + | if ((doRepay == doRepay)) | |
1285 | + | then [ScriptTransfer(i.caller, toRepay, fromBase58String(assetId))] | |
1286 | + | else throw("Strict value is not equal to itself.") | |
1287 | + | } | |
1288 | + | else nil | |
1289 | + | if ((returnCollateralAction == returnCollateralAction)) | |
1290 | + | then (updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ (if ((toWithdraw > 0)) | |
1291 | + | then withdraw(i.caller, toWithdraw) | |
1292 | + | else (((nil ++ updateBalance((cbalance() - _amount))) ++ switchPositionToQuote) ++ returnCollateralAction))) | |
1293 | + | else throw("Strict value is not equal to itself.") | |
1294 | + | } | |
1295 | + | else throw("Strict value is not equal to itself.") | |
1296 | + | } | |
1297 | + | else throw("Strict value is not equal to itself.") | |
1298 | + | } | |
1299 | + | } | |
1300 | + | } | |
1301 | + | } | |
1069 | 1302 | ||
1070 | 1303 | ||
1071 | 1304 | ||
1072 | 1305 | @Callable(i) | |
1073 | 1306 | func closePosition () = { | |
1074 | - | let | |
1075 | - | let | |
1076 | - | if (if (if (!(requireOpenPosition( | |
1307 | + | let _trader = getActualCaller(i) | |
1308 | + | let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller") | |
1309 | + | if (if (if (!(requireOpenPosition(_trader))) | |
1077 | 1310 | then true | |
1078 | 1311 | else !(initialized())) | |
1079 | 1312 | then true | |
1080 | 1313 | else paused()) | |
1081 | 1314 | then throw("Invalid closePosition parameters") | |
1082 | 1315 | else { | |
1083 | - | let $ | |
1084 | - | let x1 = $ | |
1085 | - | let positionBadDebt = $ | |
1086 | - | let realizedPnl = $ | |
1087 | - | let marginToVault = $ | |
1088 | - | let quoteAssetReserveAfter = $ | |
1089 | - | let baseAssetReserveAfter = $ | |
1090 | - | let totalPositionSizeAfter = $ | |
1091 | - | let cumulativeNotionalAfter = $ | |
1092 | - | let openInterestNotionalAfter = $ | |
1093 | - | let x2 = $ | |
1094 | - | let totalLongAfter = $ | |
1095 | - | let totalShortAfter = $ | |
1316 | + | let $t05756657944 = internalClosePosition(_trader, true) | |
1317 | + | let x1 = $t05756657944._1 | |
1318 | + | let positionBadDebt = $t05756657944._2 | |
1319 | + | let realizedPnl = $t05756657944._3 | |
1320 | + | let marginToVault = $t05756657944._4 | |
1321 | + | let quoteAssetReserveAfter = $t05756657944._5 | |
1322 | + | let baseAssetReserveAfter = $t05756657944._6 | |
1323 | + | let totalPositionSizeAfter = $t05756657944._7 | |
1324 | + | let cumulativeNotionalAfter = $t05756657944._8 | |
1325 | + | let openInterestNotionalAfter = $t05756657944._9 | |
1326 | + | let x2 = $t05756657944._10 | |
1327 | + | let totalLongAfter = $t05756657944._11 | |
1328 | + | let totalShortAfter = $t05756657944._12 | |
1096 | 1329 | if ((positionBadDebt > 0)) | |
1097 | 1330 | then throw("Unable to close position with bad debt") | |
1098 | 1331 | else { | |
1099 | 1332 | let withdrawAmount = abs(marginToVault) | |
1100 | 1333 | let ammBalance = (cbalance() - withdrawAmount) | |
1101 | - | let $ | |
1334 | + | let $t05815358295 = if ((0 > ammBalance)) | |
1102 | 1335 | then $Tuple2(0, abs(ammBalance)) | |
1103 | 1336 | else $Tuple2(ammBalance, 0) | |
1104 | - | let ammNewBalance = $ | |
1105 | - | let getFromInsurance = $ | |
1337 | + | let ammNewBalance = $t05815358295._1 | |
1338 | + | let getFromInsurance = $t05815358295._2 | |
1106 | 1339 | let x = if ((getFromInsurance > 0)) | |
1107 | 1340 | then { | |
1108 | 1341 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil) | |
1116 | 1349 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (withdrawAmount - getFromInsurance)], nil) | |
1117 | 1350 | if ((unstake == unstake)) | |
1118 | 1351 | then { | |
1119 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [caller, 0], nil) | |
1120 | - | if ((notifyNotional == notifyNotional)) | |
1121 | - | then (((deletePosition(caller) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(callerAddress, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
1352 | + | let $t05879758851 = getBorrowedByTrader(_trader) | |
1353 | + | let borrowed = $t05879758851._1 | |
1354 | + | let assetId = $t05879758851._2 | |
1355 | + | let $t05886659783 = if ((borrowed > 0)) | |
1356 | + | then if ((withdrawAmount >= borrowed)) | |
1357 | + | then { | |
1358 | + | let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), borrowed)]) | |
1359 | + | if ((doRepay == doRepay)) | |
1360 | + | then $Tuple2([ScriptTransfer(_traderAddress, borrowed, fromBase58String(assetId))], (withdrawAmount - borrowed)) | |
1361 | + | else throw("Strict value is not equal to itself.") | |
1362 | + | } | |
1363 | + | else { | |
1364 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], [AttachedPayment(quoteAsset(), withdrawAmount)]) | |
1365 | + | if ((realizeAndClose == realizeAndClose)) | |
1366 | + | then $Tuple2([ScriptTransfer(_traderAddress, withdrawAmount, fromBase58String(assetId))], 0) | |
1367 | + | else throw("Strict value is not equal to itself.") | |
1368 | + | } | |
1369 | + | else $Tuple2(nil, withdrawAmount) | |
1370 | + | if (($t05886659783 == $t05886659783)) | |
1371 | + | then { | |
1372 | + | let quoteWithdrawAmount = $t05886659783._2 | |
1373 | + | let sendCollateralAction = $t05886659783._1 | |
1374 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1375 | + | if ((notifyNotional == notifyNotional)) | |
1376 | + | then ((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ (if ((quoteWithdrawAmount > 0)) | |
1377 | + | then withdraw(_traderAddress, quoteWithdrawAmount) | |
1378 | + | else ((nil ++ updateBalance(ammNewBalance)) ++ sendCollateralAction))) | |
1379 | + | else throw("Strict value is not equal to itself.") | |
1380 | + | } | |
1122 | 1381 | else throw("Strict value is not equal to itself.") | |
1123 | 1382 | } | |
1124 | 1383 | else throw("Strict value is not equal to itself.") | |
1153 | 1412 | then (DECIMAL_UNIT > partialLiquidationRatio()) | |
1154 | 1413 | else false) | |
1155 | 1414 | then { | |
1156 | - | let $ | |
1157 | - | let oldPositionSize = $ | |
1158 | - | let oldPositionMargin = $ | |
1159 | - | let oldPositionOpenNotional = $ | |
1160 | - | let oldPositionLstUpdCPF = $ | |
1415 | + | let $t06148361633 = getPosition(_trader) | |
1416 | + | let oldPositionSize = $t06148361633._1 | |
1417 | + | let oldPositionMargin = $t06148361633._2 | |
1418 | + | let oldPositionOpenNotional = $t06148361633._3 | |
1419 | + | let oldPositionLstUpdCPF = $t06148361633._4 | |
1161 | 1420 | let _direction = if ((oldPositionSize > 0)) | |
1162 | 1421 | then DIR_SHORT | |
1163 | 1422 | else DIR_LONG | |
1164 | 1423 | let isAdd = (_direction == DIR_LONG) | |
1165 | 1424 | let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize) | |
1166 | - | let $t05275452858 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1167 | - | let oldPositionNotional = $t05275452858._1 | |
1168 | - | let unrealizedPnl = $t05275452858._2 | |
1169 | - | let $t05286653156 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1170 | - | let exchangedPositionSize = $t05286653156._1 | |
1171 | - | let quoteAssetReserveAfter = $t05286653156._2 | |
1172 | - | let baseAssetReserveAfter = $t05286653156._3 | |
1173 | - | let totalPositionSizeAfter = $t05286653156._4 | |
1174 | - | let cumulativeNotionalAfter = $t05286653156._5 | |
1175 | - | let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize)) | |
1176 | - | let $t05326353496 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1177 | - | let remainMargin = $t05326353496._1 | |
1178 | - | let badDebt = $t05326353496._2 | |
1179 | - | let fundingPayment = $t05326353496._3 | |
1425 | + | let $t06185861962 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1426 | + | let oldPositionNotional = $t06185861962._1 | |
1427 | + | let unrealizedPnl = $t06185861962._2 | |
1428 | + | let $t06197062202 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1429 | + | let exchangedPositionSize = $t06197062202._1 | |
1430 | + | let quoteAssetReserveAfter = $t06197062202._2 | |
1431 | + | let baseAssetReserveAfter = $t06197062202._3 | |
1432 | + | let totalPositionSizeAfter = $t06197062202._4 | |
1433 | + | let cumulativeNotionalAfter = $t06197062202._5 | |
1434 | + | let liquidationRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize)) | |
1435 | + | let realizedPnl = muld(unrealizedPnl, liquidationRatio) | |
1436 | + | let $t06241362646 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1437 | + | let remainMargin = $t06241362646._1 | |
1438 | + | let badDebt = $t06241362646._2 | |
1439 | + | let fundingPayment = $t06241362646._3 | |
1180 | 1440 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
1181 | 1441 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
1182 | 1442 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
1190 | 1450 | let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize) | |
1191 | 1451 | let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount) | |
1192 | 1452 | let ammBalance = (cbalance() - liquidationPenalty) | |
1193 | - | let $ | |
1453 | + | let $t06381963962 = if ((0 > ammBalance)) | |
1194 | 1454 | then $Tuple2(0, abs(ammBalance)) | |
1195 | 1455 | else $Tuple2(ammBalance, 0) | |
1196 | - | let newAmmBalance = $t05466954812._1 | |
1197 | - | let takeFromInsurance = $t05466954812._2 | |
1198 | - | let x = if ((takeFromInsurance > 0)) | |
1456 | + | let newAmmBalance = $t06381963962._1 | |
1457 | + | let takeFromInsurance = $t06381963962._2 | |
1458 | + | let $t06397064024 = getBorrowedByTrader(_trader) | |
1459 | + | let borrowed = $t06397064024._1 | |
1460 | + | let assetId = $t06397064024._2 | |
1461 | + | let doLiquidateCollateral = if ((borrowed > 0)) | |
1199 | 1462 | then { | |
1200 | - | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1201 | - | if ((withdrawInsurance == withdrawInsurance)) | |
1463 | + | let collateralToSell = muld(borrowed, liquidationRatio) | |
1464 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartially", [_trader, assetId, collateralToSell], nil) | |
1465 | + | if ((realizeAndClose == realizeAndClose)) | |
1202 | 1466 | then nil | |
1203 | 1467 | else throw("Strict value is not equal to itself.") | |
1204 | 1468 | } | |
1205 | 1469 | else nil | |
1206 | - | if (( | |
1470 | + | if ((doLiquidateCollateral == doLiquidateCollateral)) | |
1207 | 1471 | then { | |
1208 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1209 | - | if ((unstake == unstake)) | |
1472 | + | let x = if ((takeFromInsurance > 0)) | |
1210 | 1473 | then { | |
1211 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1212 | - | if ((depositInsurance == depositInsurance)) | |
1474 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1475 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1476 | + | then nil | |
1477 | + | else throw("Strict value is not equal to itself.") | |
1478 | + | } | |
1479 | + | else nil | |
1480 | + | if ((x == x)) | |
1481 | + | then { | |
1482 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1483 | + | if ((unstake == unstake)) | |
1213 | 1484 | then { | |
1214 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1215 | - | if ((notifyNotional == notifyNotional)) | |
1216 | - | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1217 | - | then abs(exchangedPositionSize) | |
1218 | - | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1219 | - | then abs(exchangedPositionSize) | |
1220 | - | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1485 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1486 | + | if ((depositInsurance == depositInsurance)) | |
1487 | + | then { | |
1488 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1489 | + | if ((notifyNotional == notifyNotional)) | |
1490 | + | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1491 | + | then abs(exchangedPositionSize) | |
1492 | + | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1493 | + | then abs(exchangedPositionSize) | |
1494 | + | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1495 | + | else throw("Strict value is not equal to itself.") | |
1496 | + | } | |
1221 | 1497 | else throw("Strict value is not equal to itself.") | |
1222 | 1498 | } | |
1223 | 1499 | else throw("Strict value is not equal to itself.") | |
1227 | 1503 | else throw("Strict value is not equal to itself.") | |
1228 | 1504 | } | |
1229 | 1505 | else { | |
1230 | - | let $ | |
1231 | - | let x1 = $ | |
1232 | - | let badDebt = $ | |
1233 | - | let x2 = $ | |
1234 | - | let x3 = $ | |
1235 | - | let quoteAssetReserveAfter = $ | |
1236 | - | let baseAssetReserveAfter = $ | |
1237 | - | let totalPositionSizeAfter = $ | |
1238 | - | let cumulativeNotionalAfter = $ | |
1239 | - | let openInterestNotionalAfter = $ | |
1240 | - | let exchangedQuoteAssetAmount = $ | |
1241 | - | let totalLongAfter = $ | |
1242 | - | let totalShortAfter = $ | |
1506 | + | let $t06586666321 = internalClosePosition(_trader, false) | |
1507 | + | let x1 = $t06586666321._1 | |
1508 | + | let badDebt = $t06586666321._2 | |
1509 | + | let x2 = $t06586666321._3 | |
1510 | + | let x3 = $t06586666321._4 | |
1511 | + | let quoteAssetReserveAfter = $t06586666321._5 | |
1512 | + | let baseAssetReserveAfter = $t06586666321._6 | |
1513 | + | let totalPositionSizeAfter = $t06586666321._7 | |
1514 | + | let cumulativeNotionalAfter = $t06586666321._8 | |
1515 | + | let openInterestNotionalAfter = $t06586666321._9 | |
1516 | + | let exchangedQuoteAssetAmount = $t06586666321._10 | |
1517 | + | let totalLongAfter = $t06586666321._11 | |
1518 | + | let totalShortAfter = $t06586666321._12 | |
1243 | 1519 | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1244 | 1520 | let feeToLiquidator = (liquidationPenalty / 2) | |
1245 | 1521 | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1246 | 1522 | let ammBalance = (cbalance() - liquidationPenalty) | |
1247 | - | let $ | |
1523 | + | let $t06673366876 = if ((0 > ammBalance)) | |
1248 | 1524 | then $Tuple2(0, abs(ammBalance)) | |
1249 | 1525 | else $Tuple2(ammBalance, 0) | |
1250 | - | let newAmmBalance = $t05712657269._1 | |
1251 | - | let takeFromInsurance = $t05712657269._2 | |
1252 | - | let x = if ((takeFromInsurance > 0)) | |
1526 | + | let newAmmBalance = $t06673366876._1 | |
1527 | + | let takeFromInsurance = $t06673366876._2 | |
1528 | + | let $t06688466938 = getBorrowedByTrader(_trader) | |
1529 | + | let borrowed = $t06688466938._1 | |
1530 | + | let assetId = $t06688466938._2 | |
1531 | + | let doLiquidateCollateral = if ((borrowed > 0)) | |
1253 | 1532 | then { | |
1254 | - | let | |
1255 | - | if (( | |
1533 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], nil) | |
1534 | + | if ((realizeAndClose == realizeAndClose)) | |
1256 | 1535 | then nil | |
1257 | 1536 | else throw("Strict value is not equal to itself.") | |
1258 | 1537 | } | |
1259 | 1538 | else nil | |
1260 | - | if (( | |
1539 | + | if ((doLiquidateCollateral == doLiquidateCollateral)) | |
1261 | 1540 | then { | |
1262 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1263 | - | if ((unstake == unstake)) | |
1541 | + | let x = if ((takeFromInsurance > 0)) | |
1264 | 1542 | then { | |
1265 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1266 | - | if ((depositInsurance == depositInsurance)) | |
1543 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1544 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1545 | + | then nil | |
1546 | + | else throw("Strict value is not equal to itself.") | |
1547 | + | } | |
1548 | + | else nil | |
1549 | + | if ((x == x)) | |
1550 | + | then { | |
1551 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1552 | + | if ((unstake == unstake)) | |
1267 | 1553 | then { | |
1268 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1269 | - | if ((notifyNotional == notifyNotional)) | |
1270 | - | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1554 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1555 | + | if ((depositInsurance == depositInsurance)) | |
1556 | + | then { | |
1557 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1558 | + | if ((notifyNotional == notifyNotional)) | |
1559 | + | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1560 | + | else throw("Strict value is not equal to itself.") | |
1561 | + | } | |
1271 | 1562 | else throw("Strict value is not equal to itself.") | |
1272 | 1563 | } | |
1273 | 1564 | else throw("Strict value is not equal to itself.") | |
1291 | 1582 | then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp))) | |
1292 | 1583 | else { | |
1293 | 1584 | let underlyingPrice = getOracleTwapPrice() | |
1294 | - | let $ | |
1295 | - | let shortPremiumFraction = $ | |
1296 | - | let longPremiumFraction = $ | |
1585 | + | let $t06873668798 = getFunding() | |
1586 | + | let shortPremiumFraction = $t06873668798._1 | |
1587 | + | let longPremiumFraction = $t06873668798._2 | |
1297 | 1588 | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1298 | 1589 | } | |
1299 | 1590 | } | |
1320 | 1611 | else (0 > _price)) | |
1321 | 1612 | then throw("Invalid adjustPeg parameters") | |
1322 | 1613 | else { | |
1323 | - | let $ | |
1324 | - | let newQuoteAssetReserve = $ | |
1325 | - | let pegChangeCost = $ | |
1614 | + | let $t06978969875 = getPegAdjustCost(_price) | |
1615 | + | let newQuoteAssetReserve = $t06978969875._1 | |
1616 | + | let pegChangeCost = $t06978969875._2 | |
1326 | 1617 | if ((pegChangeCost == 0)) | |
1327 | 1618 | then throw("Nothing to adjust") | |
1328 | 1619 | else if ((pegChangeCost > 0)) | |
1345 | 1636 | @Callable(i) | |
1346 | 1637 | func migrateLiquidity () = { | |
1347 | 1638 | let amount = cbalance() | |
1348 | - | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil) | |
1349 | - | if ((unstake == unstake)) | |
1639 | + | if ((amount > 0)) | |
1350 | 1640 | then { | |
1351 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
1352 | - | if ((stake == stake)) | |
1353 | - | then nil | |
1641 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil) | |
1642 | + | if ((unstake == unstake)) | |
1643 | + | then { | |
1644 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
1645 | + | if ((stake == stake)) | |
1646 | + | then nil | |
1647 | + | else throw("Strict value is not equal to itself.") | |
1648 | + | } | |
1354 | 1649 | else throw("Strict value is not equal to itself.") | |
1355 | 1650 | } | |
1356 | - | else | |
1651 | + | else nil | |
1357 | 1652 | } | |
1358 | 1653 | ||
1359 | 1654 | ||
1360 | 1655 | ||
1361 | 1656 | @Callable(i) | |
1362 | 1657 | func v_get (_trader) = { | |
1363 | - | let $ | |
1364 | - | let x1 = $ | |
1365 | - | let x2 = $ | |
1366 | - | let x3 = $ | |
1367 | - | let x4 = $ | |
1658 | + | let $t07151671576 = internalClosePosition(_trader, false) | |
1659 | + | let x1 = $t07151671576._1 | |
1660 | + | let x2 = $t07151671576._2 | |
1661 | + | let x3 = $t07151671576._3 | |
1662 | + | let x4 = $t07151671576._4 | |
1368 | 1663 | throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader)))) | |
1369 | 1664 | } | |
1370 | 1665 | ||
1372 | 1667 | ||
1373 | 1668 | @Callable(i) | |
1374 | 1669 | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1375 | - | let $ | |
1376 | - | let positionSize = $ | |
1377 | - | let positionMargin = $ | |
1378 | - | let pon = $ | |
1379 | - | let positionLstUpdCPF = $ | |
1380 | - | let $ | |
1381 | - | let positionNotional = $ | |
1382 | - | let unrealizedPnl = $ | |
1383 | - | let $ | |
1384 | - | let remainMargin = $ | |
1385 | - | let badDebt = $ | |
1386 | - | let fundingPayment = $ | |
1670 | + | let $t07172371834 = getPosition(_trader) | |
1671 | + | let positionSize = $t07172371834._1 | |
1672 | + | let positionMargin = $t07172371834._2 | |
1673 | + | let pon = $t07172371834._3 | |
1674 | + | let positionLstUpdCPF = $t07172371834._4 | |
1675 | + | let $t07183971940 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1676 | + | let positionNotional = $t07183971940._1 | |
1677 | + | let unrealizedPnl = $t07183971940._2 | |
1678 | + | let $t07194572127 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
1679 | + | let remainMargin = $t07194572127._1 | |
1680 | + | let badDebt = $t07194572127._2 | |
1681 | + | let fundingPayment = $t07194572127._3 | |
1387 | 1682 | throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional))) | |
1388 | 1683 | } | |
1389 | 1684 | ||
1400 | 1695 | @Callable(i) | |
1401 | 1696 | func view_getFunding () = { | |
1402 | 1697 | let underlyingPrice = getOracleTwapPrice() | |
1403 | - | let $ | |
1404 | - | let shortPremiumFraction = $ | |
1405 | - | let longPremiumFraction = $ | |
1698 | + | let $t07251872580 = getFunding() | |
1699 | + | let shortPremiumFraction = $t07251872580._1 | |
1700 | + | let longPremiumFraction = $t07251872580._2 | |
1406 | 1701 | let longFunding = divd(longPremiumFraction, underlyingPrice) | |
1407 | 1702 | let shortFunding = divd(shortPremiumFraction, underlyingPrice) | |
1408 | 1703 | throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOracleTwapPrice()))) | |
1704 | + | } | |
1705 | + | ||
1706 | + | ||
1707 | + | ||
1708 | + | @Callable(i) | |
1709 | + | func view_getBorrowedByTrader (_trader) = { | |
1710 | + | let $t07287072924 = getBorrowedByTrader(_trader) | |
1711 | + | let borrowed = $t07287072924._1 | |
1712 | + | let assetId = $t07287072924._2 | |
1713 | + | throw((s(borrowed) + assetId)) | |
1409 | 1714 | } | |
1410 | 1715 | ||
1411 | 1716 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_ora_key = "k_ora_key" | |
5 | 5 | ||
6 | 6 | let k_ora_block_key = "k_ora_block_key" | |
7 | 7 | ||
8 | 8 | let k_ora = "k_ora" | |
9 | 9 | ||
10 | 10 | let k_balance = "k_balance" | |
11 | 11 | ||
12 | 12 | let k_positionSize = "k_positionSize" | |
13 | 13 | ||
14 | 14 | let k_positionMargin = "k_positionMargin" | |
15 | 15 | ||
16 | 16 | let k_positionOpenNotional = "k_positionOpenNotional" | |
17 | 17 | ||
18 | 18 | let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction" | |
19 | 19 | ||
20 | 20 | let k_positionClosedDate = "k_positionClosedDate" | |
21 | + | ||
22 | + | let k_positionAsset = "k_positionAsset" | |
21 | 23 | ||
22 | 24 | let k_initialized = "k_initialized" | |
23 | 25 | ||
24 | 26 | let k_paused = "k_paused" | |
25 | 27 | ||
26 | 28 | let k_fee = "k_fee" | |
27 | 29 | ||
28 | 30 | let k_fundingPeriod = "k_fundingPeriod" | |
29 | 31 | ||
30 | 32 | let k_initMarginRatio = "k_initMarginRatio" | |
31 | 33 | ||
32 | 34 | let k_maintenanceMarginRatio = "k_mmr" | |
33 | 35 | ||
34 | 36 | let k_liquidationFeeRatio = "k_liquidationFeeRatio" | |
35 | 37 | ||
36 | 38 | let k_partialLiquidationRatio = "k_partLiquidationRatio" | |
37 | 39 | ||
38 | 40 | let k_spreadLimit = "k_spreadLimit" | |
39 | 41 | ||
40 | 42 | let k_maxPriceImpact = "k_maxPriceImpact" | |
41 | 43 | ||
42 | 44 | let k_maxPriceSpread = "k_maxPriceSpread" | |
43 | 45 | ||
44 | 46 | let k_lastDataStr = "k_lastDataStr" | |
45 | 47 | ||
46 | 48 | let k_lastMinuteId = "k_lastMinuteId" | |
47 | 49 | ||
48 | 50 | let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice" | |
49 | 51 | ||
50 | 52 | let k_twapDataLastPrice = "k_twapDataLastPrice" | |
51 | 53 | ||
52 | 54 | let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId" | |
53 | 55 | ||
54 | 56 | let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction" | |
55 | 57 | ||
56 | 58 | let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction" | |
57 | 59 | ||
58 | 60 | let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp" | |
59 | 61 | ||
60 | 62 | let k_longFundingRate = "k_longFundingRate" | |
61 | 63 | ||
62 | 64 | let k_shortFundingRate = "k_shortFundingRate" | |
63 | 65 | ||
64 | 66 | let k_quoteAssetReserve = "k_qtAstR" | |
65 | 67 | ||
66 | 68 | let k_baseAssetReserve = "k_bsAstR" | |
67 | 69 | ||
68 | 70 | let k_totalPositionSize = "k_totalPositionSize" | |
69 | 71 | ||
70 | 72 | let k_totalLongPositionSize = "k_totalLongPositionSize" | |
71 | 73 | ||
72 | 74 | let k_totalShortPositionSize = "k_totalShortPositionSize" | |
73 | 75 | ||
74 | 76 | let k_cumulativeNotional = "k_cumulativeNotional" | |
75 | 77 | ||
76 | 78 | let k_openInterestNotional = "k_openInterestNotional" | |
77 | 79 | ||
78 | 80 | let k_coordinatorAddress = "k_coordinatorAddress" | |
79 | 81 | ||
80 | 82 | let k_insurance_address = "k_insurance_address" | |
81 | 83 | ||
82 | 84 | let k_admin_address = "k_admin_address" | |
83 | 85 | ||
84 | 86 | let k_admin_public_key = "k_admin_public_key" | |
85 | 87 | ||
86 | 88 | let k_quote_asset = "k_quote_asset" | |
87 | 89 | ||
88 | 90 | let k_quote_staking = "k_quote_staking" | |
89 | 91 | ||
90 | 92 | let k_staking_address = "k_staking_address" | |
91 | 93 | ||
92 | 94 | let k_miner_address = "k_miner_address" | |
93 | 95 | ||
94 | 96 | let k_orders_address = "k_orders_address" | |
95 | 97 | ||
96 | 98 | let k_referral_address = "k_referral_address" | |
97 | 99 | ||
98 | 100 | let k_manager_address = "k_manager_address" | |
99 | 101 | ||
102 | + | let k_collateral_address = "k_collateral_address" | |
103 | + | ||
104 | + | let k_exchange_address = "k_exchange_address" | |
105 | + | ||
106 | + | let k_nft_manager_address = "k_nft_manager_address" | |
107 | + | ||
108 | + | let k_trader_market_asset_collateral = "k_trader_market_asset_collateral" | |
109 | + | ||
110 | + | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
111 | + | ||
112 | + | ||
100 | 113 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
101 | 114 | ||
102 | 115 | ||
103 | 116 | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
104 | 117 | ||
105 | 118 | ||
106 | 119 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
107 | 120 | ||
108 | 121 | ||
109 | 122 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
110 | 123 | ||
111 | 124 | ||
112 | 125 | func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set") | |
113 | 126 | ||
114 | 127 | ||
115 | 128 | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Staking not set") | |
116 | 129 | ||
117 | 130 | ||
118 | 131 | func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set") | |
119 | 132 | ||
120 | 133 | ||
121 | 134 | func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Miner not set") | |
122 | 135 | ||
123 | 136 | ||
124 | 137 | func ordersAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_orders_address)), "Orders not set") | |
125 | 138 | ||
126 | 139 | ||
127 | 140 | func referralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_referral_address)), "Referral not set") | |
128 | 141 | ||
129 | 142 | ||
130 | 143 | func managerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_manager_address)), "Manager not set") | |
131 | 144 | ||
145 | + | ||
146 | + | func nftManagerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_nft_manager_address)), "NFT Manager not set") | |
147 | + | ||
148 | + | ||
149 | + | func collateralAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_collateral_address)), "Collateral Manager not set") | |
150 | + | ||
151 | + | ||
152 | + | func swapAddress () = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(coordinator(), k_exchange_address), "No swap address")), "Invalid swap address") | |
153 | + | ||
154 | + | ||
155 | + | let k_whitelist_asset = "k_whitelist_asset" | |
156 | + | ||
157 | + | func isWhitelistAsset (_assetId) = valueOrElse(getBoolean(collateralAddress(), toCompositeKey(k_whitelist_asset, _assetId)), false) | |
158 | + | ||
159 | + | ||
160 | + | let k_token_param = "k_token_param" | |
161 | + | ||
162 | + | let k_token_type = "k_token_type" | |
163 | + | ||
164 | + | let FEE_REDUCTION_TOKEN_TYPE = "fee_reduction" | |
132 | 165 | ||
133 | 166 | let DIR_LONG = 1 | |
134 | 167 | ||
135 | 168 | let DIR_SHORT = 2 | |
136 | 169 | ||
137 | 170 | let TWAP_INTERVAL = 15 | |
138 | 171 | ||
139 | 172 | let ORACLE_INTERVAL = 15 | |
140 | 173 | ||
141 | 174 | let SECONDS = 1000 | |
142 | 175 | ||
143 | 176 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
144 | 177 | ||
145 | 178 | let ONE_DAY = (86400 * DECIMAL_UNIT) | |
146 | 179 | ||
147 | 180 | let ALL_FEES = 100 | |
148 | 181 | ||
149 | 182 | let PNL_OPTION_SPOT = 1 | |
150 | 183 | ||
151 | 184 | let PNL_OPTION_ORACLE = 2 | |
152 | 185 | ||
153 | 186 | func s (_x) = (toString(_x) + ",") | |
154 | 187 | ||
155 | 188 | ||
156 | 189 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
157 | 190 | ||
158 | 191 | ||
159 | 192 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
160 | 193 | ||
161 | 194 | ||
162 | 195 | func abs (_x) = if ((_x > 0)) | |
163 | 196 | then _x | |
164 | 197 | else -(_x) | |
165 | 198 | ||
166 | 199 | ||
167 | 200 | func vmax (_x,_y) = if ((_x >= _y)) | |
168 | 201 | then _x | |
169 | 202 | else _y | |
170 | 203 | ||
171 | 204 | ||
172 | - | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
173 | - | ||
174 | - | ||
175 | 205 | func listToStr (_list) = { | |
176 | 206 | func _join (accumulator,val) = ((accumulator + val) + ",") | |
177 | 207 | ||
178 | 208 | let newListStr = { | |
179 | 209 | let $l = _list | |
180 | 210 | let $s = size($l) | |
181 | 211 | let $acc0 = "" | |
182 | 212 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
183 | 213 | then $a | |
184 | 214 | else _join($a, $l[$i]) | |
185 | 215 | ||
186 | 216 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
187 | 217 | then $a | |
188 | 218 | else throw("List size exceeds 20") | |
189 | 219 | ||
190 | 220 | $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) | |
191 | 221 | } | |
192 | 222 | let newListStrU = dropRight(newListStr, 1) | |
193 | 223 | let newListStrR = if ((take(newListStrU, 1) == ",")) | |
194 | 224 | then drop(newListStrU, 1) | |
195 | 225 | else newListStrU | |
196 | 226 | newListStrR | |
197 | 227 | } | |
198 | 228 | ||
199 | 229 | ||
200 | 230 | func strToList (_str) = split(_str, ",") | |
201 | 231 | ||
202 | 232 | ||
203 | 233 | func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize)) | |
204 | 234 | then (removeByIndex(_list, 0) :+ _value) | |
205 | 235 | else (_list :+ _value) | |
206 | 236 | ||
207 | 237 | ||
208 | 238 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
239 | + | ||
240 | + | ||
241 | + | func strA (_address,_key) = { | |
242 | + | let val = valueOrErrorMessage(getString(_address, _key), ("No value for key " + _key)) | |
243 | + | val | |
244 | + | } | |
245 | + | ||
246 | + | ||
247 | + | func intA (_address,_key) = { | |
248 | + | let val = valueOrErrorMessage(getInteger(_address, _key), ("No value for key " + _key)) | |
249 | + | val | |
250 | + | } | |
209 | 251 | ||
210 | 252 | ||
211 | 253 | func cbalance () = int(k_balance) | |
212 | 254 | ||
213 | 255 | ||
214 | 256 | func fee () = int(k_fee) | |
215 | 257 | ||
216 | 258 | ||
217 | 259 | func initMarginRatio () = int(k_initMarginRatio) | |
218 | 260 | ||
219 | 261 | ||
220 | 262 | func qtAstR () = int(k_quoteAssetReserve) | |
221 | 263 | ||
222 | 264 | ||
223 | 265 | func bsAstR () = int(k_baseAssetReserve) | |
224 | 266 | ||
225 | 267 | ||
226 | 268 | func totalPositionSize () = int(k_totalPositionSize) | |
227 | 269 | ||
228 | 270 | ||
229 | 271 | func cumulativeNotional () = int(k_cumulativeNotional) | |
230 | 272 | ||
231 | 273 | ||
232 | 274 | func openInterestNotional () = int(k_openInterestNotional) | |
233 | 275 | ||
234 | 276 | ||
235 | 277 | func nextFundingBlockTimestamp () = int(k_nextFundingBlock) | |
236 | 278 | ||
237 | 279 | ||
238 | 280 | func fundingPeriodRaw () = int(k_fundingPeriod) | |
239 | 281 | ||
240 | 282 | ||
241 | 283 | func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT) | |
242 | 284 | ||
243 | 285 | ||
244 | 286 | func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS) | |
245 | 287 | ||
246 | 288 | ||
247 | 289 | func maintenanceMarginRatio () = int(k_maintenanceMarginRatio) | |
248 | 290 | ||
249 | 291 | ||
250 | 292 | func liquidationFeeRatio () = int(k_liquidationFeeRatio) | |
251 | 293 | ||
252 | 294 | ||
253 | 295 | func partialLiquidationRatio () = int(k_partialLiquidationRatio) | |
254 | 296 | ||
255 | 297 | ||
256 | 298 | func spreadLimit () = int(k_spreadLimit) | |
257 | 299 | ||
258 | 300 | ||
259 | 301 | func maxPriceImpact () = int(k_maxPriceImpact) | |
260 | 302 | ||
261 | 303 | ||
262 | 304 | func maxPriceSpread () = int(k_maxPriceSpread) | |
263 | 305 | ||
264 | 306 | ||
265 | 307 | func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction) | |
266 | 308 | ||
267 | 309 | ||
268 | 310 | func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction) | |
269 | 311 | ||
270 | 312 | ||
271 | 313 | func totalShortPositionSize () = int(k_totalShortPositionSize) | |
272 | 314 | ||
273 | 315 | ||
274 | 316 | func totalLongPositionSize () = int(k_totalLongPositionSize) | |
275 | 317 | ||
276 | 318 | ||
277 | 319 | func getActualCaller (i) = valueOrElse(getString(ordersAddress(), "k_sender"), toString(i.caller)) | |
278 | 320 | ||
279 | 321 | ||
280 | 322 | func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = { | |
281 | 323 | let remainingMarginRatio = (_marginRatio - _baseMarginRatio) | |
282 | 324 | if (if (_largerThanOrEqualTo) | |
283 | 325 | then (0 > remainingMarginRatio) | |
284 | 326 | else false) | |
285 | 327 | then throw("Invalid margin") | |
286 | 328 | else if (if (!(_largerThanOrEqualTo)) | |
287 | 329 | then (remainingMarginRatio >= 0) | |
288 | 330 | else false) | |
289 | 331 | then throw("Invalid margin") | |
290 | 332 | else true | |
291 | 333 | } | |
292 | 334 | ||
293 | 335 | ||
294 | 336 | func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0)) | |
295 | 337 | then throw("Should not be called with _positionSize == 0") | |
296 | 338 | else if ((_positionSize > 0)) | |
297 | 339 | then latestLongCumulativePremiumFraction() | |
298 | 340 | else latestShortCumulativePremiumFraction() | |
299 | 341 | ||
300 | 342 | ||
301 | 343 | func getPosition (_trader) = { | |
302 | 344 | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader)) | |
303 | 345 | match positionSizeOpt { | |
304 | 346 | case positionSize: Int => | |
305 | 347 | $Tuple4(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader))) | |
306 | 348 | case _ => | |
307 | 349 | $Tuple4(0, 0, 0, 0) | |
308 | 350 | } | |
309 | 351 | } | |
310 | 352 | ||
311 | 353 | ||
354 | + | func getPositionAsset (_trader) = { | |
355 | + | let positionAssetOpt = getString(this, toCompositeKey(k_positionAsset, _trader)) | |
356 | + | match positionAssetOpt { | |
357 | + | case positionAsset: String => | |
358 | + | positionAsset | |
359 | + | case _ => | |
360 | + | toBase58String(quoteAsset()) | |
361 | + | } | |
362 | + | } | |
363 | + | ||
364 | + | ||
312 | 365 | func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0)) | |
313 | 366 | then throw("No open position") | |
314 | 367 | else true | |
315 | 368 | ||
316 | 369 | ||
317 | 370 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
318 | 371 | ||
319 | 372 | ||
320 | 373 | func paused () = valueOrElse(getBoolean(this, k_paused), false) | |
321 | 374 | ||
322 | 375 | ||
323 | 376 | func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd) | |
324 | 377 | then { | |
325 | 378 | let newBase = (bsAstR() - _baseAssetAmount) | |
326 | 379 | if ((0 >= newBase)) | |
327 | 380 | then throw("Tx lead to base asset reserve <= 0, revert") | |
328 | 381 | else $Tuple4((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount), (cumulativeNotional() + _quoteAssetAmount)) | |
329 | 382 | } | |
330 | 383 | else { | |
331 | 384 | let newQuote = (qtAstR() - _quoteAssetAmount) | |
332 | 385 | if ((0 >= newQuote)) | |
333 | 386 | then throw("Tx lead to base quote reserve <= 0, revert") | |
334 | 387 | else $Tuple4(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount), (cumulativeNotional() - _quoteAssetAmount)) | |
335 | 388 | } | |
336 | 389 | ||
337 | 390 | ||
338 | 391 | func swapInput (_isAdd,_quoteAssetAmount) = { | |
339 | 392 | let _qtAstR = qtAstR() | |
340 | 393 | let _bsAstR = bsAstR() | |
341 | 394 | let k = muld(_qtAstR, _bsAstR) | |
342 | 395 | let quoteAssetReserveAfter = if (_isAdd) | |
343 | 396 | then (_qtAstR + _quoteAssetAmount) | |
344 | 397 | else (_qtAstR - _quoteAssetAmount) | |
345 | 398 | let baseAssetReserveAfter = divd(k, quoteAssetReserveAfter) | |
346 | 399 | let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR)) | |
347 | 400 | let amountBaseAssetBought = if (_isAdd) | |
348 | 401 | then amountBaseAssetBoughtAbs | |
349 | 402 | else -(amountBaseAssetBoughtAbs) | |
350 | - | let $ | |
351 | - | let quoteAssetReserveAfter1 = $ | |
352 | - | let baseAssetReserveAfter1 = $ | |
353 | - | let totalPositionSizeAfter1 = $ | |
354 | - | let cumulativeNotionalAfter1 = $ | |
403 | + | let $t01497415167 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs) | |
404 | + | let quoteAssetReserveAfter1 = $t01497415167._1 | |
405 | + | let baseAssetReserveAfter1 = $t01497415167._2 | |
406 | + | let totalPositionSizeAfter1 = $t01497415167._3 | |
407 | + | let cumulativeNotionalAfter1 = $t01497415167._4 | |
355 | 408 | let priceBefore = divd(_qtAstR, _bsAstR) | |
356 | 409 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
357 | 410 | let priceDiff = abs((priceBefore - marketPrice)) | |
358 | 411 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
359 | 412 | let maxPriceImpactValue = maxPriceImpact() | |
360 | 413 | if ((priceImpact > maxPriceImpactValue)) | |
361 | 414 | 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))) | |
362 | 415 | else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1) | |
363 | 416 | } | |
364 | 417 | ||
365 | 418 | ||
366 | 419 | func calcRemainMarginWithFundingPayment (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_marginDelta) = { | |
367 | 420 | let fundingPayment = if ((_oldPositionSize != 0)) | |
368 | 421 | then { | |
369 | 422 | let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize) | |
370 | 423 | muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize) | |
371 | 424 | } | |
372 | 425 | else 0 | |
373 | 426 | let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin) | |
374 | - | let $ | |
427 | + | let $t01665816785 = if ((0 > signedMargin)) | |
375 | 428 | then $Tuple2(0, abs(signedMargin)) | |
376 | 429 | else $Tuple2(abs(signedMargin), 0) | |
377 | - | let remainMargin = $ | |
378 | - | let badDebt = $ | |
430 | + | let remainMargin = $t01665816785._1 | |
431 | + | let badDebt = $t01665816785._2 | |
379 | 432 | $Tuple3(remainMargin, badDebt, fundingPayment) | |
380 | 433 | } | |
381 | 434 | ||
382 | 435 | ||
383 | 436 | func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_baseAssetReserve) = { | |
384 | 437 | let priceBefore = divd(_quoteAssetReserve, _baseAssetReserve) | |
385 | 438 | if ((_baseAssetAmount == 0)) | |
386 | 439 | then throw("Invalid base asset amount") | |
387 | 440 | else { | |
388 | 441 | let k = muld(_quoteAssetReserve, _baseAssetReserve) | |
389 | 442 | let baseAssetPoolAmountAfter = if (_isAdd) | |
390 | 443 | then (_baseAssetReserve + _baseAssetAmount) | |
391 | 444 | else (_baseAssetReserve - _baseAssetAmount) | |
392 | 445 | let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter) | |
393 | 446 | let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve)) | |
394 | 447 | let maxPriceImpactValue = maxPriceImpact() | |
395 | - | let $ | |
396 | - | let quoteAssetReserveAfter1 = $ | |
397 | - | let baseAssetReserveAfter1 = $ | |
398 | - | let totalPositionSizeAfter1 = $ | |
399 | - | let cumulativeNotionalAfter1 = $ | |
448 | + | let $t01776217955 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount) | |
449 | + | let quoteAssetReserveAfter1 = $t01776217955._1 | |
450 | + | let baseAssetReserveAfter1 = $t01776217955._2 | |
451 | + | let totalPositionSizeAfter1 = $t01776217955._3 | |
452 | + | let cumulativeNotionalAfter1 = $t01776217955._4 | |
400 | 453 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
401 | 454 | let priceDiff = abs((priceBefore - marketPrice)) | |
402 | 455 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
403 | 456 | if (if ((priceImpact > maxPriceImpactValue)) | |
404 | 457 | then _checkMaxPriceImpact | |
405 | 458 | else false) | |
406 | 459 | 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))) | |
407 | 460 | else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd) | |
408 | 461 | then abs(_baseAssetAmount) | |
409 | 462 | else 0)), (totalShortPositionSize() - (if (!(_isAdd)) | |
410 | 463 | then abs(_baseAssetAmount) | |
411 | 464 | else 0)), priceImpact) | |
412 | 465 | } | |
413 | 466 | } | |
414 | 467 | ||
415 | 468 | ||
416 | 469 | func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), bsAstR()) | |
417 | 470 | ||
418 | 471 | ||
419 | 472 | func getOracleTwapPrice () = { | |
420 | 473 | let oracle = valueOrErrorMessage(addressFromString(getStringValue(this, k_ora)), "") | |
421 | 474 | let priceKey = getStringValue(this, k_ora_key) | |
422 | 475 | let blockKey = getStringValue(this, k_ora_block_key) | |
423 | 476 | let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey)) | |
424 | 477 | lastValue | |
425 | 478 | } | |
426 | 479 | ||
427 | 480 | ||
428 | 481 | func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = { | |
429 | 482 | let oraclePrice = getOracleTwapPrice() | |
430 | 483 | let priceAfter = divd(_quoteAssetReserve, _baseAssetReserve) | |
431 | 484 | let averagePrice = divd((oraclePrice + priceAfter), (2 * DECIMAL_UNIT)) | |
432 | 485 | let absPriceDiff = divd(abs((oraclePrice - priceAfter)), averagePrice) | |
433 | 486 | if ((absPriceDiff > maxPriceSpread())) | |
434 | 487 | then throw(((("Price spread " + toString(absPriceDiff)) + " > max price spread ") + toString(maxPriceSpread()))) | |
435 | 488 | else true | |
436 | 489 | } | |
437 | 490 | ||
438 | 491 | ||
439 | 492 | func getSpotPrice () = { | |
440 | 493 | let _quoteAssetReserve = qtAstR() | |
441 | 494 | let _baseAssetReserve = bsAstR() | |
442 | 495 | divd(_quoteAssetReserve, _baseAssetReserve) | |
443 | 496 | } | |
444 | 497 | ||
445 | 498 | ||
446 | 499 | func isOverFluctuationLimit () = { | |
447 | 500 | let oraclePrice = getOracleTwapPrice() | |
448 | 501 | let currentPrice = getSpotPrice() | |
449 | 502 | (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit()) | |
450 | 503 | } | |
451 | 504 | ||
452 | 505 | ||
453 | 506 | func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_baseAssetReserve) = { | |
454 | 507 | let positionSizeAbs = abs(_positionSize) | |
455 | 508 | let isShort = (0 > _positionSize) | |
456 | 509 | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
457 | 510 | then { | |
458 | - | let $ | |
459 | - | let outPositionNotional = $ | |
460 | - | let x1 = $ | |
461 | - | let x2 = $ | |
462 | - | let x3 = $ | |
511 | + | let $t02117321344 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve) | |
512 | + | let outPositionNotional = $t02117321344._1 | |
513 | + | let x1 = $t02117321344._2 | |
514 | + | let x2 = $t02117321344._3 | |
515 | + | let x3 = $t02117321344._4 | |
463 | 516 | outPositionNotional | |
464 | 517 | } | |
465 | 518 | else muld(positionSizeAbs, getOracleTwapPrice()) | |
466 | 519 | positionNotional | |
467 | 520 | } | |
468 | 521 | ||
469 | 522 | ||
470 | 523 | func getPositionNotionalAndUnrealizedPnlByValues (_positionSize,_positionOpenNotional,_quoteAssetReserve,_baseAssetReserve,_option) = if ((_positionSize == 0)) | |
471 | 524 | then throw("Invalid position size") | |
472 | 525 | else { | |
473 | 526 | let isShort = (0 > _positionSize) | |
474 | 527 | let positionNotional = getPositionAdjustedOpenNotional(_positionSize, _option, _quoteAssetReserve, _baseAssetReserve) | |
475 | 528 | let unrealizedPnl = if (isShort) | |
476 | 529 | then (_positionOpenNotional - positionNotional) | |
477 | 530 | else (positionNotional - _positionOpenNotional) | |
478 | 531 | $Tuple2(positionNotional, unrealizedPnl) | |
479 | 532 | } | |
480 | 533 | ||
481 | 534 | ||
482 | 535 | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
483 | - | let $ | |
484 | - | let positionSize = $ | |
485 | - | let positionMargin = $ | |
486 | - | let positionOpenNotional = $ | |
487 | - | let positionLstUpdCPF = $ | |
536 | + | let $t02266122789 = getPosition(_trader) | |
537 | + | let positionSize = $t02266122789._1 | |
538 | + | let positionMargin = $t02266122789._2 | |
539 | + | let positionOpenNotional = $t02266122789._3 | |
540 | + | let positionLstUpdCPF = $t02266122789._4 | |
488 | 541 | getPositionNotionalAndUnrealizedPnlByValues(positionSize, positionOpenNotional, qtAstR(), bsAstR(), _option) | |
489 | 542 | } | |
490 | 543 | ||
491 | 544 | ||
492 | 545 | func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional) | |
493 | 546 | ||
494 | 547 | ||
495 | 548 | func getMarginRatioByOption (_trader,_option) = { | |
496 | - | let $ | |
497 | - | let positionSize = $ | |
498 | - | let positionMargin = $ | |
499 | - | let pon = $ | |
500 | - | let positionLstUpdCPF = $ | |
501 | - | let $ | |
502 | - | let positionNotional = $ | |
503 | - | let unrealizedPnl = $ | |
504 | - | let $ | |
505 | - | let remainMargin = $ | |
506 | - | let badDebt = $ | |
549 | + | let $t02327023381 = getPosition(_trader) | |
550 | + | let positionSize = $t02327023381._1 | |
551 | + | let positionMargin = $t02327023381._2 | |
552 | + | let pon = $t02327023381._3 | |
553 | + | let positionLstUpdCPF = $t02327023381._4 | |
554 | + | let $t02338723480 = getPositionNotionalAndUnrealizedPnl(_trader, _option) | |
555 | + | let positionNotional = $t02338723480._1 | |
556 | + | let unrealizedPnl = $t02338723480._2 | |
557 | + | let $t02348523651 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
558 | + | let remainMargin = $t02348523651._1 | |
559 | + | let badDebt = $t02348523651._2 | |
507 | 560 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
508 | 561 | } | |
509 | 562 | ||
510 | 563 | ||
511 | 564 | func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
512 | 565 | ||
513 | 566 | ||
514 | 567 | func getPartialLiquidationAmount (_trader,_positionSize) = { | |
515 | 568 | let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio()))) | |
516 | 569 | let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio) | |
517 | 570 | let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false) | |
518 | 571 | let maxExchangedQuoteAssetAmount = swapResult._1 | |
519 | 572 | let priceImpact = swapResult._8 | |
520 | 573 | if ((maxPriceImpact() > priceImpact)) | |
521 | 574 | then maxExchangedQuoteAssetAmount | |
522 | 575 | else { | |
523 | 576 | let exchangedPositionSize = muld(abs(_positionSize), partialLiquidationRatio()) | |
524 | 577 | let exchangedQuoteAssetAmount = swapOutput((_positionSize > 0), exchangedPositionSize, false)._1 | |
525 | 578 | exchangedQuoteAssetAmount | |
526 | 579 | } | |
527 | 580 | } | |
528 | 581 | ||
529 | 582 | ||
530 | 583 | func internalClosePosition (_trader,_checkMaxPriceImpact) = { | |
531 | - | let $ | |
532 | - | let positionSize = $ | |
533 | - | let positionMargin = $ | |
534 | - | let positionOpenNotional = $ | |
535 | - | let positionLstUpdCPF = $ | |
584 | + | let $t02488425012 = getPosition(_trader) | |
585 | + | let positionSize = $t02488425012._1 | |
586 | + | let positionMargin = $t02488425012._2 | |
587 | + | let positionOpenNotional = $t02488425012._3 | |
588 | + | let positionLstUpdCPF = $t02488425012._4 | |
536 | 589 | let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2 | |
537 | - | let $ | |
538 | - | let remainMargin = $ | |
539 | - | let badDebt = $ | |
590 | + | let $t02510725275 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
591 | + | let remainMargin = $t02510725275._1 | |
592 | + | let badDebt = $t02510725275._2 | |
540 | 593 | let exchangedPositionSize = -(positionSize) | |
541 | 594 | let realizedPnl = unrealizedPnl | |
542 | 595 | let marginToVault = -(remainMargin) | |
543 | - | let $ | |
544 | - | let exchangedQuoteAssetAmount = $ | |
545 | - | let quoteAssetReserveAfter = $ | |
546 | - | let baseAssetReserveAfter = $ | |
547 | - | let totalPositionSizeAfter = $ | |
548 | - | let cumulativeNotionalAfter = $ | |
549 | - | let totalLongAfter = $ | |
550 | - | let totalShortAfter = $ | |
596 | + | let $t02540225713 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact) | |
597 | + | let exchangedQuoteAssetAmount = $t02540225713._1 | |
598 | + | let quoteAssetReserveAfter = $t02540225713._2 | |
599 | + | let baseAssetReserveAfter = $t02540225713._3 | |
600 | + | let totalPositionSizeAfter = $t02540225713._4 | |
601 | + | let cumulativeNotionalAfter = $t02540225713._5 | |
602 | + | let totalLongAfter = $t02540225713._6 | |
603 | + | let totalShortAfter = $t02540225713._7 | |
551 | 604 | let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional) | |
552 | 605 | $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter) | |
553 | 606 | } | |
554 | 607 | ||
555 | 608 | ||
556 | 609 | func getTwapSpotPrice () = { | |
557 | 610 | let minuteId = ((lastBlock.timestamp / 1000) / 60) | |
558 | 611 | let startMinuteId = (minuteId - TWAP_INTERVAL) | |
559 | 612 | let listStr = valueOrElse(getString(this, k_lastDataStr), "") | |
560 | 613 | let list = split(listStr, ",") | |
561 | 614 | func filterFn (accumulator,next) = if ((startMinuteId >= parseIntValue(next))) | |
562 | 615 | then (accumulator :+ parseIntValue(next)) | |
563 | 616 | else accumulator | |
564 | 617 | ||
565 | 618 | let listF = { | |
566 | 619 | let $l = list | |
567 | 620 | let $s = size($l) | |
568 | 621 | let $acc0 = nil | |
569 | 622 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
570 | 623 | then $a | |
571 | 624 | else filterFn($a, $l[$i]) | |
572 | 625 | ||
573 | 626 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
574 | 627 | then $a | |
575 | 628 | else throw("List size exceeds 20") | |
576 | 629 | ||
577 | 630 | $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) | |
578 | 631 | } | |
579 | 632 | let maxIndex = if ((size(listF) > 0)) | |
580 | 633 | then max(listF) | |
581 | 634 | else parseIntValue(list[0]) | |
582 | 635 | let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
583 | 636 | let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0) | |
584 | 637 | let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0) | |
585 | 638 | let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice)) | |
586 | 639 | let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0) | |
587 | 640 | let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0) | |
588 | 641 | let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice)) | |
589 | 642 | ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL) | |
590 | 643 | } | |
591 | 644 | ||
592 | 645 | ||
593 | 646 | func getPegAdjustCost (_price) = { | |
594 | 647 | let _positionSize = totalPositionSize() | |
595 | 648 | let direction = (_positionSize > 0) | |
596 | 649 | let currentNetMarketValue = swapOutput(direction, abs(_positionSize), false)._1 | |
597 | 650 | let baseAssetReserve = bsAstR() | |
598 | 651 | let newQuoteAssetReserve = muld(baseAssetReserve, _price) | |
599 | 652 | let cost = getPositionNotionalAndUnrealizedPnlByValues(_positionSize, currentNetMarketValue, newQuoteAssetReserve, baseAssetReserve, PNL_OPTION_SPOT)._2 | |
600 | 653 | $Tuple2(newQuoteAssetReserve, cost) | |
601 | 654 | } | |
602 | 655 | ||
603 | 656 | ||
604 | 657 | func getFunding () = { | |
605 | 658 | let underlyingPrice = getOracleTwapPrice() | |
606 | 659 | let spotTwapPrice = getTwapSpotPrice() | |
607 | 660 | let premium = (spotTwapPrice - underlyingPrice) | |
608 | 661 | if (if ((totalShortPositionSize() == 0)) | |
609 | 662 | then true | |
610 | 663 | else (totalLongPositionSize() == 0)) | |
611 | 664 | then $Tuple2(0, 0) | |
612 | 665 | else if ((0 > premium)) | |
613 | 666 | then { | |
614 | 667 | let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
615 | 668 | let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize()) | |
616 | 669 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
617 | 670 | } | |
618 | 671 | else { | |
619 | 672 | let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
620 | 673 | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
621 | 674 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
622 | 675 | } | |
623 | 676 | } | |
624 | 677 | ||
625 | 678 | ||
679 | + | func getAdjustedFee (i) = { | |
680 | + | let baseFee = fee() | |
681 | + | let $t02937629984 = if ((size(i.payments) > 1)) | |
682 | + | then { | |
683 | + | let artifactId = toBase58String(valueOrErrorMessage(i.payments[1].assetId, "Invalid attached artifact")) | |
684 | + | let artifactKind = strA(nftManagerAddress(), toCompositeKey(k_token_type, artifactId)) | |
685 | + | if ((artifactKind == FEE_REDUCTION_TOKEN_TYPE)) | |
686 | + | then { | |
687 | + | let reduction = intA(nftManagerAddress(), toCompositeKey(k_token_param, artifactId)) | |
688 | + | let adjustedFee = muld(baseFee, reduction) | |
689 | + | $Tuple2(adjustedFee, true) | |
690 | + | } | |
691 | + | else throw("Invalid attached artifact") | |
692 | + | } | |
693 | + | else $Tuple2(baseFee, false) | |
694 | + | let adjustedFee = $t02937629984._1 | |
695 | + | let burnArtifact = $t02937629984._2 | |
696 | + | $Tuple2(adjustedFee, burnArtifact) | |
697 | + | } | |
698 | + | ||
699 | + | ||
626 | 700 | 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)] | |
627 | 701 | ||
628 | 702 | ||
629 | 703 | func updateFunding (_nextFundingBlock,_latestLongCumulativePremiumFraction,_latestShortCumulativePremiumFraction,_longFundingRate,_shortFundingRate) = [IntegerEntry(k_nextFundingBlock, _nextFundingBlock), IntegerEntry(k_latestLongCumulativePremiumFraction, _latestLongCumulativePremiumFraction), IntegerEntry(k_latestShortCumulativePremiumFraction, _latestShortCumulativePremiumFraction), IntegerEntry(k_longFundingRate, _longFundingRate), IntegerEntry(k_shortFundingRate, _shortFundingRate)] | |
704 | + | ||
705 | + | ||
706 | + | func updatePositionAsset (_address,_assetId) = [StringEntry(toCompositeKey(k_positionAsset, _address), _assetId)] | |
630 | 707 | ||
631 | 708 | ||
632 | 709 | 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)] | |
633 | 710 | ||
634 | 711 | ||
635 | 712 | func appendTwap (price) = { | |
636 | 713 | let minuteId = ((lastBlock.timestamp / 1000) / 60) | |
637 | 714 | let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
638 | 715 | if ((previousMinuteId > minuteId)) | |
639 | 716 | then throw("TWAP out-of-order") | |
640 | 717 | else { | |
641 | 718 | let lastMinuteId = if ((previousMinuteId == 0)) | |
642 | 719 | then minuteId | |
643 | 720 | else previousMinuteId | |
644 | 721 | if ((minuteId > previousMinuteId)) | |
645 | 722 | then { | |
646 | 723 | let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0) | |
647 | 724 | let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), price) | |
648 | 725 | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice)) | |
649 | 726 | let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId)) | |
650 | 727 | [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))] | |
651 | 728 | } | |
652 | 729 | else { | |
653 | 730 | let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0) | |
654 | 731 | let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0) | |
655 | 732 | let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), price) | |
656 | 733 | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice)) | |
657 | 734 | [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), price)] | |
658 | 735 | } | |
659 | 736 | } | |
660 | 737 | } | |
661 | 738 | ||
662 | 739 | ||
663 | 740 | func updateAmmReserves (_qtAstR,_bsAstR) = [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)] | |
664 | 741 | ||
665 | 742 | ||
666 | 743 | func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_cumulativeNotionalAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize) = if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter)) | |
667 | 744 | then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter))) | |
668 | 745 | 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))) | |
669 | 746 | ||
670 | 747 | ||
671 | - | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)] | |
748 | + | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address)), DeleteEntry(toCompositeKey(k_positionAsset, _address)), IntegerEntry(toCompositeKey(k_positionClosedDate, _address), lastBlock.timestamp)] | |
672 | 749 | ||
673 | 750 | ||
674 | 751 | func withdraw (_address,_amount) = { | |
675 | 752 | let balance = assetBalance(this, quoteAsset()) | |
676 | 753 | if ((_amount > balance)) | |
677 | 754 | then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance))) | |
678 | 755 | else [ScriptTransfer(_address, _amount, quoteAsset())] | |
679 | 756 | } | |
680 | 757 | ||
681 | 758 | ||
682 | 759 | func updateBalance (i) = if ((0 > i)) | |
683 | 760 | then throw("Balance") | |
684 | 761 | else [IntegerEntry(k_balance, i)] | |
685 | 762 | ||
686 | 763 | ||
687 | 764 | func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())] | |
765 | + | ||
766 | + | ||
767 | + | func doBurnArtifact (_burnArtifact,i) = if (_burnArtifact) | |
768 | + | then [Burn(valueOrErrorMessage(i.payments[1].assetId, "Invalid artifact"), 1)] | |
769 | + | else nil | |
770 | + | ||
771 | + | ||
772 | + | func isSameAssetOrNoPosition (_trader,_assetId) = { | |
773 | + | let oldPositionSize = getPosition(_trader)._1 | |
774 | + | if ((oldPositionSize == 0)) | |
775 | + | then true | |
776 | + | else (getPositionAsset(_trader) == _assetId) | |
777 | + | } | |
778 | + | ||
779 | + | ||
780 | + | func isSameAsset (_trader,_assetId) = (getPositionAsset(_trader) == _assetId) | |
781 | + | ||
782 | + | ||
783 | + | func getBorrowedByTraderInMarketKey (_amm,_assetId,_trader) = ((((((k_trader_market_asset_collateral + "_") + _amm) + "_") + _assetId) + "_") + _trader) | |
784 | + | ||
785 | + | ||
786 | + | func getBorrowedByTrader (_trader) = { | |
787 | + | let positionAsset = getPositionAsset(_trader) | |
788 | + | if ((positionAsset == toBase58String(quoteAsset()))) | |
789 | + | then $Tuple2(0, positionAsset) | |
790 | + | else { | |
791 | + | let key = getBorrowedByTraderInMarketKey(toString(this), positionAsset, _trader) | |
792 | + | let borrow = valueOrElse(getInteger(collateralAddress(), key), 0) | |
793 | + | $Tuple2(borrow, positionAsset) | |
794 | + | } | |
795 | + | } | |
688 | 796 | ||
689 | 797 | ||
690 | 798 | @Callable(i) | |
691 | 799 | func pause () = if ((i.caller != adminAddress())) | |
692 | 800 | then throw("Invalid togglePause params") | |
693 | 801 | else [BooleanEntry(k_paused, true)] | |
694 | 802 | ||
695 | 803 | ||
696 | 804 | ||
697 | 805 | @Callable(i) | |
698 | 806 | func unpause () = if ((i.caller != adminAddress())) | |
699 | 807 | then throw("Invalid togglePause params") | |
700 | 808 | else [BooleanEntry(k_paused, false)] | |
701 | 809 | ||
702 | 810 | ||
703 | 811 | ||
704 | 812 | @Callable(i) | |
705 | 813 | func addLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress())) | |
706 | 814 | then true | |
707 | 815 | else (0 >= _quoteAssetAmount)) | |
708 | 816 | then throw("Invalid addLiquidity params") | |
709 | 817 | else { | |
710 | 818 | let _qtAstR = qtAstR() | |
711 | 819 | let _bsAstR = bsAstR() | |
712 | 820 | let price = divd(_qtAstR, _bsAstR) | |
713 | 821 | let baseAssetAmountToAdd = divd(_quoteAssetAmount, price) | |
714 | 822 | let qtAstRAfter = (_qtAstR + _quoteAssetAmount) | |
715 | 823 | let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd) | |
716 | 824 | updateAmmReserves(qtAstRAfter, bsAstRAfter) | |
717 | 825 | } | |
718 | 826 | ||
719 | 827 | ||
720 | 828 | ||
721 | 829 | @Callable(i) | |
722 | 830 | func removeLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress())) | |
723 | 831 | then true | |
724 | 832 | else (0 >= _quoteAssetAmount)) | |
725 | 833 | then throw("Invalid removeLiquidity params") | |
726 | 834 | else { | |
727 | 835 | let _qtAstR = qtAstR() | |
728 | 836 | let _bsAstR = bsAstR() | |
729 | 837 | let price = divd(_qtAstR, _bsAstR) | |
730 | 838 | let baseAssetAmountToRemove = divd(_quoteAssetAmount, price) | |
731 | 839 | let qtAstRAfter = (_qtAstR - _quoteAssetAmount) | |
732 | 840 | let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove) | |
733 | 841 | updateAmmReserves(qtAstRAfter, bsAstRAfter) | |
734 | 842 | } | |
735 | 843 | ||
736 | 844 | ||
737 | 845 | ||
738 | 846 | @Callable(i) | |
739 | 847 | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress())) | |
740 | 848 | then throw("Invalid changeSettings params") | |
741 | 849 | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread) | |
742 | 850 | ||
743 | 851 | ||
744 | 852 | ||
745 | 853 | @Callable(i) | |
746 | 854 | 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)) | |
747 | 855 | then true | |
748 | 856 | else (0 >= _bsAstR)) | |
749 | 857 | then true | |
750 | 858 | else (0 >= _fundingPeriod)) | |
751 | 859 | then true | |
752 | 860 | else (0 >= _initMarginRatio)) | |
753 | 861 | then true | |
754 | 862 | else (0 >= _mmr)) | |
755 | 863 | then true | |
756 | 864 | else (0 >= _liquidationFeeRatio)) | |
757 | 865 | then true | |
758 | 866 | else (0 >= _fee)) | |
759 | 867 | then true | |
760 | 868 | else (0 >= _spreadLimit)) | |
761 | 869 | then true | |
762 | 870 | else (0 >= _maxPriceImpact)) | |
763 | 871 | then true | |
764 | 872 | else (0 >= _partialLiquidationRatio)) | |
765 | 873 | then true | |
766 | 874 | else (0 >= _maxPriceSpread)) | |
767 | 875 | then true | |
768 | 876 | else initialized()) | |
769 | 877 | then throw("Invalid initialize parameters") | |
770 | 878 | 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)]) | |
771 | 879 | ||
772 | 880 | ||
773 | 881 | ||
774 | 882 | @Callable(i) | |
775 | 883 | func setInitMarginRatio (_initMarginRatio) = if (if ((0 >= _initMarginRatio)) | |
776 | 884 | then true | |
777 | 885 | else !(initialized())) | |
778 | 886 | then throw("Invalid setInitMarginRatio parameters") | |
779 | 887 | else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread()) | |
780 | 888 | ||
781 | 889 | ||
782 | 890 | ||
783 | 891 | @Callable(i) | |
784 | 892 | func decreasePosition (_amount,_leverage,_minBaseAssetAmount) = if (if (if (if (if ((0 >= _amount)) | |
785 | 893 | then true | |
786 | 894 | else !(initialized())) | |
787 | 895 | then true | |
788 | 896 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
789 | 897 | then true | |
790 | 898 | else !(requireOpenPosition(toString(i.caller)))) | |
791 | 899 | then true | |
792 | 900 | else paused()) | |
793 | 901 | then throw("Invalid decreasePosition parameters") | |
794 | 902 | else { | |
795 | - | let $ | |
796 | - | let oldPositionSize = $ | |
797 | - | let oldPositionMargin = $ | |
798 | - | let oldPositionOpenNotional = $ | |
799 | - | let oldPositionLstUpdCPF = $ | |
903 | + | let $t04149241644 = getPosition(toString(i.caller)) | |
904 | + | let oldPositionSize = $t04149241644._1 | |
905 | + | let oldPositionMargin = $t04149241644._2 | |
906 | + | let oldPositionOpenNotional = $t04149241644._3 | |
907 | + | let oldPositionLstUpdCPF = $t04149241644._4 | |
800 | 908 | let _direction = if ((oldPositionSize > 0)) | |
801 | 909 | then DIR_SHORT | |
802 | 910 | else DIR_LONG | |
803 | 911 | let isAdd = (_direction == DIR_LONG) | |
804 | 912 | let openNotional = muld(_amount, _leverage) | |
805 | - | let $ | |
806 | - | let oldPositionNotional = $ | |
807 | - | let unrealizedPnl = $ | |
808 | - | let $ | |
913 | + | let $t04181741933 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
914 | + | let oldPositionNotional = $t04181741933._1 | |
915 | + | let unrealizedPnl = $t04181741933._2 | |
916 | + | let $t04193944488 = if ((oldPositionNotional > openNotional)) | |
809 | 917 | then { | |
810 | - | let $ | |
811 | - | let exchangedPositionSize = $ | |
812 | - | let quoteAssetReserveAfter = $ | |
813 | - | let baseAssetReserveAfter = $ | |
814 | - | let totalPositionSizeAfter = $ | |
815 | - | let cumulativeNotionalAfter = $ | |
918 | + | let $t04231642535 = swapInput(isAdd, openNotional) | |
919 | + | let exchangedPositionSize = $t04231642535._1 | |
920 | + | let quoteAssetReserveAfter = $t04231642535._2 | |
921 | + | let baseAssetReserveAfter = $t04231642535._3 | |
922 | + | let totalPositionSizeAfter = $t04231642535._4 | |
923 | + | let cumulativeNotionalAfter = $t04231642535._5 | |
816 | 924 | let exchangedPositionSizeAbs = abs(exchangedPositionSize) | |
817 | 925 | if (if ((_minBaseAssetAmount != 0)) | |
818 | 926 | then (_minBaseAssetAmount > exchangedPositionSizeAbs) | |
819 | 927 | else false) | |
820 | 928 | then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount))) | |
821 | 929 | else { | |
822 | 930 | let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize)) | |
823 | - | let $ | |
824 | - | let remainMargin = $ | |
825 | - | let badDebt = $ | |
826 | - | let fundingPayment = $ | |
931 | + | let $t04297243217 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
932 | + | let remainMargin = $t04297243217._1 | |
933 | + | let badDebt = $t04297243217._2 | |
934 | + | let fundingPayment = $t04297243217._3 | |
827 | 935 | let exchangedQuoteAssetAmount = openNotional | |
828 | 936 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
829 | 937 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
830 | 938 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
831 | 939 | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
832 | 940 | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
833 | 941 | $Tuple11(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
834 | 942 | then abs(exchangedPositionSize) | |
835 | 943 | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
836 | 944 | then abs(exchangedPositionSize) | |
837 | 945 | else 0))) | |
838 | 946 | } | |
839 | 947 | } | |
840 | 948 | else throw("Close position first") | |
841 | - | let newPositionSize = $ | |
842 | - | let newPositionRemainMargin = $ | |
843 | - | let newPositionOpenNotional = $ | |
844 | - | let newPositionLatestCPF = $ | |
845 | - | let baseAssetReserveAfter = $ | |
846 | - | let quoteAssetReserveAfter = $ | |
847 | - | let totalPositionSizeAfter = $ | |
848 | - | let cumulativeNotionalAfter = $ | |
849 | - | let openInterestNotionalAfter = $ | |
850 | - | let totalLongAfter = $ | |
851 | - | let totalShortAfter = $ | |
949 | + | let newPositionSize = $t04193944488._1 | |
950 | + | let newPositionRemainMargin = $t04193944488._2 | |
951 | + | let newPositionOpenNotional = $t04193944488._3 | |
952 | + | let newPositionLatestCPF = $t04193944488._4 | |
953 | + | let baseAssetReserveAfter = $t04193944488._5 | |
954 | + | let quoteAssetReserveAfter = $t04193944488._6 | |
955 | + | let totalPositionSizeAfter = $t04193944488._7 | |
956 | + | let cumulativeNotionalAfter = $t04193944488._8 | |
957 | + | let openInterestNotionalAfter = $t04193944488._9 | |
958 | + | let totalLongAfter = $t04193944488._10 | |
959 | + | let totalShortAfter = $t04193944488._11 | |
852 | 960 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
853 | 961 | if ((notifyNotional == notifyNotional)) | |
854 | 962 | then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
855 | 963 | else throw("Strict value is not equal to itself.") | |
856 | 964 | } | |
857 | 965 | ||
858 | 966 | ||
859 | 967 | ||
860 | 968 | @Callable(i) | |
861 | 969 | func increasePosition (_direction,_leverage,_minBaseAssetAmount,_refLink) = { | |
970 | + | let _trader = toString(i.caller) | |
862 | 971 | let _rawAmount = i.payments[0].amount | |
863 | - | if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
972 | + | let _assetId = i.payments[0].assetId | |
973 | + | let _assetIdStr = toBase58String(value(_assetId)) | |
974 | + | let isQuoteAsset = (_assetId == quoteAsset()) | |
975 | + | let isCollateralAsset = isWhitelistAsset(_assetIdStr) | |
976 | + | if (if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
864 | 977 | then (_direction != DIR_SHORT) | |
865 | 978 | else false) | |
866 | 979 | then true | |
867 | 980 | else (0 >= _rawAmount)) | |
868 | 981 | then true | |
869 | 982 | else !(initialized())) | |
870 | 983 | then true | |
871 | - | else (i.payments[0].assetId != quoteAsset())) | |
984 | + | else if (!(isQuoteAsset)) | |
985 | + | then !(isCollateralAsset) | |
986 | + | else false) | |
987 | + | then true | |
988 | + | else !(isSameAssetOrNoPosition(_trader, _assetIdStr))) | |
872 | 989 | then true | |
873 | 990 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
874 | 991 | then true | |
875 | 992 | else paused()) | |
876 | 993 | then throw("Invalid increasePosition parameters") | |
877 | 994 | else { | |
878 | - | let _trader = toString(i.caller) | |
879 | - | let rawFeeAmount = muld(_rawAmount, fee()) | |
880 | - | let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), rawFeeAmount)]) | |
881 | - | if ((referrerFeeAny == referrerFeeAny)) | |
995 | + | let baseFee = fee() | |
996 | + | let $t04585045901 = getAdjustedFee(i) | |
997 | + | let adjustedFee = $t04585045901._1 | |
998 | + | let burnArtifact = $t04585045901._2 | |
999 | + | let rawFeeAmount = muld(_rawAmount, adjustedFee) | |
1000 | + | let _amount = (_rawAmount - rawFeeAmount) | |
1001 | + | let distributeFeeAmount = if (isCollateralAsset) | |
882 | 1002 | then { | |
883 | - | let referrerFee = match referrerFeeAny { | |
884 | - | case x: Int => | |
885 | - | x | |
886 | - | case _ => | |
887 | - | throw("Invalid referrerFee") | |
1003 | + | let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)]) | |
1004 | + | if ((doBorrow == doBorrow)) | |
1005 | + | then { | |
1006 | + | let balanceBefore = assetBalance(this, quoteAsset()) | |
1007 | + | if ((balanceBefore == balanceBefore)) | |
1008 | + | then { | |
1009 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)]) | |
1010 | + | if ((doSwap == doSwap)) | |
1011 | + | then { | |
1012 | + | let balanceAfter = assetBalance(this, quoteAsset()) | |
1013 | + | if ((balanceAfter == balanceAfter)) | |
1014 | + | then { | |
1015 | + | let exchangedAmount = (balanceAfter - balanceBefore) | |
1016 | + | if ((exchangedAmount == exchangedAmount)) | |
1017 | + | then exchangedAmount | |
1018 | + | else throw("Strict value is not equal to itself.") | |
1019 | + | } | |
1020 | + | else throw("Strict value is not equal to itself.") | |
1021 | + | } | |
1022 | + | else throw("Strict value is not equal to itself.") | |
1023 | + | } | |
1024 | + | else throw("Strict value is not equal to itself.") | |
1025 | + | } | |
1026 | + | else throw("Strict value is not equal to itself.") | |
888 | 1027 | } | |
889 | - | let _amount = (_rawAmount - rawFeeAmount) | |
890 | - | let feeAmount = (rawFeeAmount - referrerFee) | |
891 | - | let $t04205942199 = getPosition(_trader) | |
892 | - | let oldPositionSize = $t04205942199._1 | |
893 | - | let oldPositionMargin = $t04205942199._2 | |
894 | - | let oldPositionOpenNotional = $t04205942199._3 | |
895 | - | let oldPositionLstUpdCPF = $t04205942199._4 | |
896 | - | let isNewPosition = (oldPositionSize == 0) | |
897 | - | let isSameDirection = if ((oldPositionSize > 0)) | |
898 | - | then (_direction == DIR_LONG) | |
899 | - | else (_direction == DIR_SHORT) | |
900 | - | let expandExisting = if (!(isNewPosition)) | |
901 | - | then isSameDirection | |
902 | - | else false | |
903 | - | let isAdd = (_direction == DIR_LONG) | |
904 | - | let $t04248845056 = if (if (isNewPosition) | |
905 | - | then true | |
906 | - | else expandExisting) | |
1028 | + | else rawFeeAmount | |
1029 | + | if ((distributeFeeAmount == distributeFeeAmount)) | |
1030 | + | then { | |
1031 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPaymentWithLink", [_trader, _refLink], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1032 | + | if ((referrerFeeAny == referrerFeeAny)) | |
907 | 1033 | then { | |
908 | - | let openNotional = muld(_amount, _leverage) | |
909 | - | let $t04291243118 = swapInput(isAdd, openNotional) | |
910 | - | let amountBaseAssetBought = $t04291243118._1 | |
911 | - | let quoteAssetReserveAfter = $t04291243118._2 | |
912 | - | let baseAssetReserveAfter = $t04291243118._3 | |
913 | - | let totalPositionSizeAfter = $t04291243118._4 | |
914 | - | let cumulativeNotionalAfter = $t04291243118._5 | |
915 | - | if (if ((_minBaseAssetAmount != 0)) | |
916 | - | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
917 | - | else false) | |
918 | - | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1034 | + | let referrerFee = match referrerFeeAny { | |
1035 | + | case x: Int => | |
1036 | + | x | |
1037 | + | case _ => | |
1038 | + | throw("Invalid referrerFee") | |
1039 | + | } | |
1040 | + | let feeAmount = (distributeFeeAmount - referrerFee) | |
1041 | + | let $t04721747357 = getPosition(_trader) | |
1042 | + | let oldPositionSize = $t04721747357._1 | |
1043 | + | let oldPositionMargin = $t04721747357._2 | |
1044 | + | let oldPositionOpenNotional = $t04721747357._3 | |
1045 | + | let oldPositionLstUpdCPF = $t04721747357._4 | |
1046 | + | let isNewPosition = (oldPositionSize == 0) | |
1047 | + | let isSameDirection = if ((oldPositionSize > 0)) | |
1048 | + | then (_direction == DIR_LONG) | |
1049 | + | else (_direction == DIR_SHORT) | |
1050 | + | let expandExisting = if (!(isNewPosition)) | |
1051 | + | then isSameDirection | |
1052 | + | else false | |
1053 | + | let isAdd = (_direction == DIR_LONG) | |
1054 | + | let $t04764650231 = if (if (isNewPosition) | |
1055 | + | then true | |
1056 | + | else expandExisting) | |
1057 | + | then { | |
1058 | + | let openNotional = muld(_amount, _leverage) | |
1059 | + | let $t04807048276 = swapInput(isAdd, openNotional) | |
1060 | + | let amountBaseAssetBought = $t04807048276._1 | |
1061 | + | let quoteAssetReserveAfter = $t04807048276._2 | |
1062 | + | let baseAssetReserveAfter = $t04807048276._3 | |
1063 | + | let totalPositionSizeAfter = $t04807048276._4 | |
1064 | + | let cumulativeNotionalAfter = $t04807048276._5 | |
1065 | + | if (if ((_minBaseAssetAmount != 0)) | |
1066 | + | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
1067 | + | else false) | |
1068 | + | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
1069 | + | else { | |
1070 | + | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
1071 | + | let increaseMarginRequirement = divd(openNotional, _leverage) | |
1072 | + | let $t04865748896 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
1073 | + | let remainMargin = $t04865748896._1 | |
1074 | + | let x1 = $t04865748896._2 | |
1075 | + | let x2 = $t04865748896._3 | |
1076 | + | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
1077 | + | then throw("Over max spread limit") | |
1078 | + | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
1079 | + | then abs(amountBaseAssetBought) | |
1080 | + | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
1081 | + | then abs(amountBaseAssetBought) | |
1082 | + | else 0))) | |
1083 | + | } | |
1084 | + | } | |
919 | 1085 | else { | |
920 | - | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
921 | - | let increaseMarginRequirement = divd(openNotional, _leverage) | |
922 | - | let $t04349943738 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
923 | - | let remainMargin = $t04349943738._1 | |
924 | - | let x1 = $t04349943738._2 | |
925 | - | let x2 = $t04349943738._3 | |
926 | - | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
927 | - | then throw("Over max spread limit") | |
928 | - | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
929 | - | then abs(amountBaseAssetBought) | |
930 | - | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
931 | - | then abs(amountBaseAssetBought) | |
932 | - | else 0))) | |
1086 | + | let openNotional = muld(_amount, _leverage) | |
1087 | + | let $t04992450040 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
1088 | + | let oldPositionNotional = $t04992450040._1 | |
1089 | + | let unrealizedPnl = $t04992450040._2 | |
1090 | + | if ((oldPositionNotional > openNotional)) | |
1091 | + | then throw("Use decreasePosition to decrease position size") | |
1092 | + | else throw("Close position first") | |
933 | 1093 | } | |
934 | - | } | |
935 | - | else { | |
936 | - | let openNotional = muld(_amount, _leverage) | |
937 | - | let $t04474944865 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
938 | - | let oldPositionNotional = $t04474944865._1 | |
939 | - | let unrealizedPnl = $t04474944865._2 | |
940 | - | if ((oldPositionNotional > openNotional)) | |
941 | - | then throw("Use decreasePosition to decrease position size") | |
942 | - | else throw("Close position first") | |
943 | - | } | |
944 | - | let newPositionSize = $t04248845056._1 | |
945 | - | let newPositionRemainMargin = $t04248845056._2 | |
946 | - | let newPositionOpenNotional = $t04248845056._3 | |
947 | - | let newPositionLatestCPF = $t04248845056._4 | |
948 | - | let baseAssetReserveAfter = $t04248845056._5 | |
949 | - | let quoteAssetReserveAfter = $t04248845056._6 | |
950 | - | let totalPositionSizeAfter = $t04248845056._7 | |
951 | - | let cumulativeNotionalAfter = $t04248845056._8 | |
952 | - | let openInterestNotionalAfter = $t04248845056._9 | |
953 | - | let totalLongAfter = $t04248845056._10 | |
954 | - | let totalShortAfter = $t04248845056._11 | |
955 | - | let feeToStakers = (feeAmount / 2) | |
956 | - | let feeToInsurance = (feeAmount - feeToStakers) | |
957 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
958 | - | if ((stake == stake)) | |
959 | - | then { | |
960 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
961 | - | if ((depositInsurance == depositInsurance)) | |
1094 | + | let newPositionSize = $t04764650231._1 | |
1095 | + | let newPositionRemainMargin = $t04764650231._2 | |
1096 | + | let newPositionOpenNotional = $t04764650231._3 | |
1097 | + | let newPositionLatestCPF = $t04764650231._4 | |
1098 | + | let baseAssetReserveAfter = $t04764650231._5 | |
1099 | + | let quoteAssetReserveAfter = $t04764650231._6 | |
1100 | + | let totalPositionSizeAfter = $t04764650231._7 | |
1101 | + | let cumulativeNotionalAfter = $t04764650231._8 | |
1102 | + | let openInterestNotionalAfter = $t04764650231._9 | |
1103 | + | let totalLongAfter = $t04764650231._10 | |
1104 | + | let totalShortAfter = $t04764650231._11 | |
1105 | + | let feeToStakers = (feeAmount / 2) | |
1106 | + | let feeToInsurance = (feeAmount - feeToStakers) | |
1107 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1108 | + | if ((stake == stake)) | |
962 | 1109 | then { | |
963 | - | let | |
964 | - | if (( | |
1110 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1111 | + | if ((depositInsurance == depositInsurance)) | |
965 | 1112 | then { | |
966 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
967 | - | if ((notifyNotional == notifyNotional)) | |
968 | - | then (((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
1113 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1114 | + | if ((notifyFee == notifyFee)) | |
1115 | + | then { | |
1116 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1117 | + | if ((notifyNotional == notifyNotional)) | |
1118 | + | then (((((updatePosition(_trader, newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updatePositionAsset(_trader, _assetIdStr)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1119 | + | else throw("Strict value is not equal to itself.") | |
1120 | + | } | |
969 | 1121 | else throw("Strict value is not equal to itself.") | |
970 | 1122 | } | |
971 | 1123 | else throw("Strict value is not equal to itself.") | |
972 | 1124 | } | |
973 | 1125 | else throw("Strict value is not equal to itself.") | |
974 | 1126 | } | |
975 | 1127 | else throw("Strict value is not equal to itself.") | |
976 | 1128 | } | |
977 | 1129 | else throw("Strict value is not equal to itself.") | |
978 | 1130 | } | |
979 | 1131 | } | |
980 | 1132 | ||
981 | 1133 | ||
982 | 1134 | ||
983 | 1135 | @Callable(i) | |
984 | 1136 | func addMargin () = { | |
1137 | + | let _trader = toString(i.caller) | |
985 | 1138 | let _rawAmount = i.payments[0].amount | |
986 | - | if (if (if (if ((i.payments[0].assetId != quoteAsset())) | |
1139 | + | let _assetId = i.payments[0].assetId | |
1140 | + | let _assetIdStr = toBase58String(value(_assetId)) | |
1141 | + | let isQuoteAsset = (_assetId == quoteAsset()) | |
1142 | + | let isCollateralAsset = isWhitelistAsset(_assetIdStr) | |
1143 | + | if (if (if (if (if (if (!(isQuoteAsset)) | |
1144 | + | then !(isCollateralAsset) | |
1145 | + | else false) | |
987 | 1146 | then true | |
988 | 1147 | else !(requireOpenPosition(toString(i.caller)))) | |
1148 | + | then true | |
1149 | + | else !(isSameAsset(_trader, _assetIdStr))) | |
989 | 1150 | then true | |
990 | 1151 | else !(initialized())) | |
991 | 1152 | then true | |
992 | 1153 | else paused()) | |
993 | 1154 | then throw("Invalid addMargin parameters") | |
994 | 1155 | else { | |
995 | - | let _trader = toString(i.caller) | |
996 | - | let rawFeeAmount = muld(_rawAmount, fee()) | |
997 | - | let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), rawFeeAmount)]) | |
998 | - | if ((referrerFeeAny == referrerFeeAny)) | |
1156 | + | let $t05198752038 = getAdjustedFee(i) | |
1157 | + | let adjustedFee = $t05198752038._1 | |
1158 | + | let burnArtifact = $t05198752038._2 | |
1159 | + | let rawFeeAmount = muld(_rawAmount, adjustedFee) | |
1160 | + | let _amount = (_rawAmount - rawFeeAmount) | |
1161 | + | let distributeFeeAmount = if (isCollateralAsset) | |
999 | 1162 | then { | |
1000 | - | let referrerFee = match referrerFeeAny { | |
1001 | - | case x: Int => | |
1002 | - | x | |
1003 | - | case _ => | |
1004 | - | throw("Invalid referrerFee") | |
1163 | + | let doBorrow = invoke(collateralAddress(), "borrow", [_trader], [AttachedPayment(_assetId, _amount)]) | |
1164 | + | if ((doBorrow == doBorrow)) | |
1165 | + | then { | |
1166 | + | let balanceBefore = assetBalance(this, quoteAsset()) | |
1167 | + | if ((balanceBefore == balanceBefore)) | |
1168 | + | then { | |
1169 | + | let doSwap = invoke(swapAddress(), "swap", [toBase58String(quoteAsset()), 0], [AttachedPayment(_assetId, rawFeeAmount)]) | |
1170 | + | if ((doSwap == doSwap)) | |
1171 | + | then { | |
1172 | + | let balanceAfter = assetBalance(this, quoteAsset()) | |
1173 | + | if ((balanceAfter == balanceAfter)) | |
1174 | + | then { | |
1175 | + | let exchangedAmount = (balanceAfter - balanceBefore) | |
1176 | + | if ((exchangedAmount == exchangedAmount)) | |
1177 | + | then exchangedAmount | |
1178 | + | else throw("Strict value is not equal to itself.") | |
1179 | + | } | |
1180 | + | else throw("Strict value is not equal to itself.") | |
1181 | + | } | |
1182 | + | else throw("Strict value is not equal to itself.") | |
1183 | + | } | |
1184 | + | else throw("Strict value is not equal to itself.") | |
1185 | + | } | |
1186 | + | else throw("Strict value is not equal to itself.") | |
1005 | 1187 | } | |
1006 | - | let feeAmount = (rawFeeAmount - referrerFee) | |
1007 | - | let _amount = (_rawAmount - rawFeeAmount) | |
1008 | - | let $t04690247042 = getPosition(_trader) | |
1009 | - | let oldPositionSize = $t04690247042._1 | |
1010 | - | let oldPositionMargin = $t04690247042._2 | |
1011 | - | let oldPositionOpenNotional = $t04690247042._3 | |
1012 | - | let oldPositionLstUpdCPF = $t04690247042._4 | |
1013 | - | let feeToStakers = (feeAmount / 2) | |
1014 | - | let feeToInsurance = (feeAmount - feeToStakers) | |
1015 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1016 | - | if ((stake == stake)) | |
1188 | + | else rawFeeAmount | |
1189 | + | if ((distributeFeeAmount == distributeFeeAmount)) | |
1190 | + | then { | |
1191 | + | let referrerFeeAny = invoke(referralAddress(), "acceptPayment", [_trader], [AttachedPayment(quoteAsset(), distributeFeeAmount)]) | |
1192 | + | if ((referrerFeeAny == referrerFeeAny)) | |
1017 | 1193 | then { | |
1018 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1019 | - | if ((depositInsurance == depositInsurance)) | |
1194 | + | let referrerFee = match referrerFeeAny { | |
1195 | + | case x: Int => | |
1196 | + | x | |
1197 | + | case _ => | |
1198 | + | throw("Invalid referrerFee") | |
1199 | + | } | |
1200 | + | let feeAmount = (distributeFeeAmount - referrerFee) | |
1201 | + | let $t05333753477 = getPosition(_trader) | |
1202 | + | let oldPositionSize = $t05333753477._1 | |
1203 | + | let oldPositionMargin = $t05333753477._2 | |
1204 | + | let oldPositionOpenNotional = $t05333753477._3 | |
1205 | + | let oldPositionLstUpdCPF = $t05333753477._4 | |
1206 | + | let feeToStakers = (feeAmount / 2) | |
1207 | + | let feeToInsurance = (feeAmount - feeToStakers) | |
1208 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), _amount)]) | |
1209 | + | if ((stake == stake)) | |
1020 | 1210 | then { | |
1021 | - | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1022 | - | if ((notifyFee == notifyFee)) | |
1023 | - | then ((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
1211 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1212 | + | if ((depositInsurance == depositInsurance)) | |
1213 | + | then { | |
1214 | + | let notifyFee = invoke(minerAddress(), "notifyFees", [_trader, feeAmount], nil) | |
1215 | + | if ((notifyFee == notifyFee)) | |
1216 | + | then (((updatePosition(_trader, oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) ++ doBurnArtifact(burnArtifact, i)) | |
1217 | + | else throw("Strict value is not equal to itself.") | |
1218 | + | } | |
1024 | 1219 | else throw("Strict value is not equal to itself.") | |
1025 | 1220 | } | |
1026 | 1221 | else throw("Strict value is not equal to itself.") | |
1027 | 1222 | } | |
1028 | 1223 | else throw("Strict value is not equal to itself.") | |
1029 | 1224 | } | |
1030 | 1225 | else throw("Strict value is not equal to itself.") | |
1031 | 1226 | } | |
1032 | 1227 | } | |
1033 | 1228 | ||
1034 | 1229 | ||
1035 | 1230 | ||
1036 | 1231 | @Callable(i) | |
1037 | - | func removeMargin (_amount) = if (if (if (if ((0 >= _amount)) | |
1038 | - | then true | |
1039 | - | else !(requireOpenPosition(toString(i.caller)))) | |
1040 | - | then true | |
1041 | - | else !(initialized())) | |
1042 | - | then true | |
1043 | - | else paused()) | |
1044 | - | then throw("Invalid removeMargin parameters") | |
1045 | - | else { | |
1046 | - | let $t04801848170 = getPosition(toString(i.caller)) | |
1047 | - | let oldPositionSize = $t04801848170._1 | |
1048 | - | let oldPositionMargin = $t04801848170._2 | |
1049 | - | let oldPositionOpenNotional = $t04801848170._3 | |
1050 | - | let oldPositionLstUpdCPF = $t04801848170._4 | |
1051 | - | let marginDelta = -(_amount) | |
1052 | - | let $t04820748386 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
1053 | - | let remainMargin = $t04820748386._1 | |
1054 | - | let badDebt = $t04820748386._2 | |
1055 | - | if ((badDebt != 0)) | |
1056 | - | then throw("Invalid removed margin amount") | |
1057 | - | else { | |
1058 | - | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1059 | - | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1060 | - | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1061 | - | else { | |
1062 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil) | |
1063 | - | if ((unstake == unstake)) | |
1064 | - | then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount))) | |
1065 | - | else throw("Strict value is not equal to itself.") | |
1066 | - | } | |
1067 | - | } | |
1068 | - | } | |
1232 | + | func removeMargin (_amount) = { | |
1233 | + | let _trader = toString(i.caller) | |
1234 | + | if (if (if (if ((0 >= _amount)) | |
1235 | + | then true | |
1236 | + | else !(requireOpenPosition(_trader))) | |
1237 | + | then true | |
1238 | + | else !(initialized())) | |
1239 | + | then true | |
1240 | + | else paused()) | |
1241 | + | then throw("Invalid removeMargin parameters") | |
1242 | + | else { | |
1243 | + | let $t05452054660 = getPosition(_trader) | |
1244 | + | let oldPositionSize = $t05452054660._1 | |
1245 | + | let oldPositionMargin = $t05452054660._2 | |
1246 | + | let oldPositionOpenNotional = $t05452054660._3 | |
1247 | + | let oldPositionLstUpdCPF = $t05452054660._4 | |
1248 | + | let marginDelta = -(_amount) | |
1249 | + | let $t05469754876 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
1250 | + | let remainMargin = $t05469754876._1 | |
1251 | + | let badDebt = $t05469754876._2 | |
1252 | + | if ((badDebt != 0)) | |
1253 | + | then throw("Invalid removed margin amount") | |
1254 | + | else { | |
1255 | + | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
1256 | + | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
1257 | + | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
1258 | + | else { | |
1259 | + | let quoteAssetStr = toBase58String(quoteAsset()) | |
1260 | + | let $t05532055374 = getBorrowedByTrader(_trader) | |
1261 | + | let borrowed = $t05532055374._1 | |
1262 | + | let assetId = $t05532055374._2 | |
1263 | + | let toRepay = if ((_amount > borrowed)) | |
1264 | + | then borrowed | |
1265 | + | else _amount | |
1266 | + | let toWithdraw = if ((borrowed > _amount)) | |
1267 | + | then 0 | |
1268 | + | else (_amount - borrowed) | |
1269 | + | let finalBorrow = (borrowed - toRepay) | |
1270 | + | let switchPositionToQuote = if ((finalBorrow > 0)) | |
1271 | + | then nil | |
1272 | + | else updatePositionAsset(_trader, quoteAssetStr) | |
1273 | + | let doSanityCheck = if (((toRepay + toWithdraw) != _amount)) | |
1274 | + | then throw(((((("toRepay=" + toString(toRepay)) + " + toWithdraw=") + toString(toWithdraw)) + " != ") + toString(_amount))) | |
1275 | + | else nil | |
1276 | + | if ((doSanityCheck == doSanityCheck)) | |
1277 | + | then { | |
1278 | + | let doUnstake = invoke(managerAddress(), "withdraw", [quoteAssetStr, _amount], nil) | |
1279 | + | if ((doUnstake == doUnstake)) | |
1280 | + | then { | |
1281 | + | let returnCollateralAction = if ((toRepay > 0)) | |
1282 | + | then { | |
1283 | + | let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), toRepay)]) | |
1284 | + | if ((doRepay == doRepay)) | |
1285 | + | then [ScriptTransfer(i.caller, toRepay, fromBase58String(assetId))] | |
1286 | + | else throw("Strict value is not equal to itself.") | |
1287 | + | } | |
1288 | + | else nil | |
1289 | + | if ((returnCollateralAction == returnCollateralAction)) | |
1290 | + | then (updatePosition(_trader, oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ (if ((toWithdraw > 0)) | |
1291 | + | then withdraw(i.caller, toWithdraw) | |
1292 | + | else (((nil ++ updateBalance((cbalance() - _amount))) ++ switchPositionToQuote) ++ returnCollateralAction))) | |
1293 | + | else throw("Strict value is not equal to itself.") | |
1294 | + | } | |
1295 | + | else throw("Strict value is not equal to itself.") | |
1296 | + | } | |
1297 | + | else throw("Strict value is not equal to itself.") | |
1298 | + | } | |
1299 | + | } | |
1300 | + | } | |
1301 | + | } | |
1069 | 1302 | ||
1070 | 1303 | ||
1071 | 1304 | ||
1072 | 1305 | @Callable(i) | |
1073 | 1306 | func closePosition () = { | |
1074 | - | let | |
1075 | - | let | |
1076 | - | if (if (if (!(requireOpenPosition( | |
1307 | + | let _trader = getActualCaller(i) | |
1308 | + | let _traderAddress = valueOrErrorMessage(addressFromString(_trader), "Invalid caller") | |
1309 | + | if (if (if (!(requireOpenPosition(_trader))) | |
1077 | 1310 | then true | |
1078 | 1311 | else !(initialized())) | |
1079 | 1312 | then true | |
1080 | 1313 | else paused()) | |
1081 | 1314 | then throw("Invalid closePosition parameters") | |
1082 | 1315 | else { | |
1083 | - | let $ | |
1084 | - | let x1 = $ | |
1085 | - | let positionBadDebt = $ | |
1086 | - | let realizedPnl = $ | |
1087 | - | let marginToVault = $ | |
1088 | - | let quoteAssetReserveAfter = $ | |
1089 | - | let baseAssetReserveAfter = $ | |
1090 | - | let totalPositionSizeAfter = $ | |
1091 | - | let cumulativeNotionalAfter = $ | |
1092 | - | let openInterestNotionalAfter = $ | |
1093 | - | let x2 = $ | |
1094 | - | let totalLongAfter = $ | |
1095 | - | let totalShortAfter = $ | |
1316 | + | let $t05756657944 = internalClosePosition(_trader, true) | |
1317 | + | let x1 = $t05756657944._1 | |
1318 | + | let positionBadDebt = $t05756657944._2 | |
1319 | + | let realizedPnl = $t05756657944._3 | |
1320 | + | let marginToVault = $t05756657944._4 | |
1321 | + | let quoteAssetReserveAfter = $t05756657944._5 | |
1322 | + | let baseAssetReserveAfter = $t05756657944._6 | |
1323 | + | let totalPositionSizeAfter = $t05756657944._7 | |
1324 | + | let cumulativeNotionalAfter = $t05756657944._8 | |
1325 | + | let openInterestNotionalAfter = $t05756657944._9 | |
1326 | + | let x2 = $t05756657944._10 | |
1327 | + | let totalLongAfter = $t05756657944._11 | |
1328 | + | let totalShortAfter = $t05756657944._12 | |
1096 | 1329 | if ((positionBadDebt > 0)) | |
1097 | 1330 | then throw("Unable to close position with bad debt") | |
1098 | 1331 | else { | |
1099 | 1332 | let withdrawAmount = abs(marginToVault) | |
1100 | 1333 | let ammBalance = (cbalance() - withdrawAmount) | |
1101 | - | let $ | |
1334 | + | let $t05815358295 = if ((0 > ammBalance)) | |
1102 | 1335 | then $Tuple2(0, abs(ammBalance)) | |
1103 | 1336 | else $Tuple2(ammBalance, 0) | |
1104 | - | let ammNewBalance = $ | |
1105 | - | let getFromInsurance = $ | |
1337 | + | let ammNewBalance = $t05815358295._1 | |
1338 | + | let getFromInsurance = $t05815358295._2 | |
1106 | 1339 | let x = if ((getFromInsurance > 0)) | |
1107 | 1340 | then { | |
1108 | 1341 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil) | |
1109 | 1342 | if ((withdrawInsurance == withdrawInsurance)) | |
1110 | 1343 | then nil | |
1111 | 1344 | else throw("Strict value is not equal to itself.") | |
1112 | 1345 | } | |
1113 | 1346 | else nil | |
1114 | 1347 | if ((x == x)) | |
1115 | 1348 | then { | |
1116 | 1349 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (withdrawAmount - getFromInsurance)], nil) | |
1117 | 1350 | if ((unstake == unstake)) | |
1118 | 1351 | then { | |
1119 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [caller, 0], nil) | |
1120 | - | if ((notifyNotional == notifyNotional)) | |
1121 | - | then (((deletePosition(caller) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(callerAddress, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
1352 | + | let $t05879758851 = getBorrowedByTrader(_trader) | |
1353 | + | let borrowed = $t05879758851._1 | |
1354 | + | let assetId = $t05879758851._2 | |
1355 | + | let $t05886659783 = if ((borrowed > 0)) | |
1356 | + | then if ((withdrawAmount >= borrowed)) | |
1357 | + | then { | |
1358 | + | let doRepay = invoke(collateralAddress(), "repay", [_trader, assetId], [AttachedPayment(quoteAsset(), borrowed)]) | |
1359 | + | if ((doRepay == doRepay)) | |
1360 | + | then $Tuple2([ScriptTransfer(_traderAddress, borrowed, fromBase58String(assetId))], (withdrawAmount - borrowed)) | |
1361 | + | else throw("Strict value is not equal to itself.") | |
1362 | + | } | |
1363 | + | else { | |
1364 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], [AttachedPayment(quoteAsset(), withdrawAmount)]) | |
1365 | + | if ((realizeAndClose == realizeAndClose)) | |
1366 | + | then $Tuple2([ScriptTransfer(_traderAddress, withdrawAmount, fromBase58String(assetId))], 0) | |
1367 | + | else throw("Strict value is not equal to itself.") | |
1368 | + | } | |
1369 | + | else $Tuple2(nil, withdrawAmount) | |
1370 | + | if (($t05886659783 == $t05886659783)) | |
1371 | + | then { | |
1372 | + | let quoteWithdrawAmount = $t05886659783._2 | |
1373 | + | let sendCollateralAction = $t05886659783._1 | |
1374 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1375 | + | if ((notifyNotional == notifyNotional)) | |
1376 | + | then ((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ (if ((quoteWithdrawAmount > 0)) | |
1377 | + | then withdraw(_traderAddress, quoteWithdrawAmount) | |
1378 | + | else ((nil ++ updateBalance(ammNewBalance)) ++ sendCollateralAction))) | |
1379 | + | else throw("Strict value is not equal to itself.") | |
1380 | + | } | |
1122 | 1381 | else throw("Strict value is not equal to itself.") | |
1123 | 1382 | } | |
1124 | 1383 | else throw("Strict value is not equal to itself.") | |
1125 | 1384 | } | |
1126 | 1385 | else throw("Strict value is not equal to itself.") | |
1127 | 1386 | } | |
1128 | 1387 | } | |
1129 | 1388 | } | |
1130 | 1389 | ||
1131 | 1390 | ||
1132 | 1391 | ||
1133 | 1392 | @Callable(i) | |
1134 | 1393 | func liquidate (_trader) = { | |
1135 | 1394 | let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
1136 | 1395 | let marginRatio = if (isOverFluctuationLimit()) | |
1137 | 1396 | then { | |
1138 | 1397 | let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE) | |
1139 | 1398 | vmax(spotMarginRatio, oracleMarginRatio) | |
1140 | 1399 | } | |
1141 | 1400 | else spotMarginRatio | |
1142 | 1401 | if (if (if (if (!(requireMoreMarginRatio(marginRatio, maintenanceMarginRatio(), false))) | |
1143 | 1402 | then true | |
1144 | 1403 | else !(requireOpenPosition(_trader))) | |
1145 | 1404 | then true | |
1146 | 1405 | else !(initialized())) | |
1147 | 1406 | then true | |
1148 | 1407 | else paused()) | |
1149 | 1408 | then throw("Unable to liquidate") | |
1150 | 1409 | else if (if (if ((spotMarginRatio > liquidationFeeRatio())) | |
1151 | 1410 | then (partialLiquidationRatio() > 0) | |
1152 | 1411 | else false) | |
1153 | 1412 | then (DECIMAL_UNIT > partialLiquidationRatio()) | |
1154 | 1413 | else false) | |
1155 | 1414 | then { | |
1156 | - | let $ | |
1157 | - | let oldPositionSize = $ | |
1158 | - | let oldPositionMargin = $ | |
1159 | - | let oldPositionOpenNotional = $ | |
1160 | - | let oldPositionLstUpdCPF = $ | |
1415 | + | let $t06148361633 = getPosition(_trader) | |
1416 | + | let oldPositionSize = $t06148361633._1 | |
1417 | + | let oldPositionMargin = $t06148361633._2 | |
1418 | + | let oldPositionOpenNotional = $t06148361633._3 | |
1419 | + | let oldPositionLstUpdCPF = $t06148361633._4 | |
1161 | 1420 | let _direction = if ((oldPositionSize > 0)) | |
1162 | 1421 | then DIR_SHORT | |
1163 | 1422 | else DIR_LONG | |
1164 | 1423 | let isAdd = (_direction == DIR_LONG) | |
1165 | 1424 | let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize) | |
1166 | - | let $t05275452858 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1167 | - | let oldPositionNotional = $t05275452858._1 | |
1168 | - | let unrealizedPnl = $t05275452858._2 | |
1169 | - | let $t05286653156 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1170 | - | let exchangedPositionSize = $t05286653156._1 | |
1171 | - | let quoteAssetReserveAfter = $t05286653156._2 | |
1172 | - | let baseAssetReserveAfter = $t05286653156._3 | |
1173 | - | let totalPositionSizeAfter = $t05286653156._4 | |
1174 | - | let cumulativeNotionalAfter = $t05286653156._5 | |
1175 | - | let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize)) | |
1176 | - | let $t05326353496 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1177 | - | let remainMargin = $t05326353496._1 | |
1178 | - | let badDebt = $t05326353496._2 | |
1179 | - | let fundingPayment = $t05326353496._3 | |
1425 | + | let $t06185861962 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1426 | + | let oldPositionNotional = $t06185861962._1 | |
1427 | + | let unrealizedPnl = $t06185861962._2 | |
1428 | + | let $t06197062202 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1429 | + | let exchangedPositionSize = $t06197062202._1 | |
1430 | + | let quoteAssetReserveAfter = $t06197062202._2 | |
1431 | + | let baseAssetReserveAfter = $t06197062202._3 | |
1432 | + | let totalPositionSizeAfter = $t06197062202._4 | |
1433 | + | let cumulativeNotionalAfter = $t06197062202._5 | |
1434 | + | let liquidationRatio = divd(abs(exchangedPositionSize), abs(oldPositionSize)) | |
1435 | + | let realizedPnl = muld(unrealizedPnl, liquidationRatio) | |
1436 | + | let $t06241362646 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1437 | + | let remainMargin = $t06241362646._1 | |
1438 | + | let badDebt = $t06241362646._2 | |
1439 | + | let fundingPayment = $t06241362646._3 | |
1180 | 1440 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
1181 | 1441 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
1182 | 1442 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
1183 | 1443 | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
1184 | 1444 | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1185 | 1445 | let feeToLiquidator = (liquidationPenalty / 2) | |
1186 | 1446 | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1187 | 1447 | let newPositionMargin = (remainMargin - liquidationPenalty) | |
1188 | 1448 | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
1189 | 1449 | let newPositionOpenNotional = abs(remainOpenNotional) | |
1190 | 1450 | let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize) | |
1191 | 1451 | let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount) | |
1192 | 1452 | let ammBalance = (cbalance() - liquidationPenalty) | |
1193 | - | let $ | |
1453 | + | let $t06381963962 = if ((0 > ammBalance)) | |
1194 | 1454 | then $Tuple2(0, abs(ammBalance)) | |
1195 | 1455 | else $Tuple2(ammBalance, 0) | |
1196 | - | let newAmmBalance = $t05466954812._1 | |
1197 | - | let takeFromInsurance = $t05466954812._2 | |
1198 | - | let x = if ((takeFromInsurance > 0)) | |
1456 | + | let newAmmBalance = $t06381963962._1 | |
1457 | + | let takeFromInsurance = $t06381963962._2 | |
1458 | + | let $t06397064024 = getBorrowedByTrader(_trader) | |
1459 | + | let borrowed = $t06397064024._1 | |
1460 | + | let assetId = $t06397064024._2 | |
1461 | + | let doLiquidateCollateral = if ((borrowed > 0)) | |
1199 | 1462 | then { | |
1200 | - | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1201 | - | if ((withdrawInsurance == withdrawInsurance)) | |
1463 | + | let collateralToSell = muld(borrowed, liquidationRatio) | |
1464 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartially", [_trader, assetId, collateralToSell], nil) | |
1465 | + | if ((realizeAndClose == realizeAndClose)) | |
1202 | 1466 | then nil | |
1203 | 1467 | else throw("Strict value is not equal to itself.") | |
1204 | 1468 | } | |
1205 | 1469 | else nil | |
1206 | - | if (( | |
1470 | + | if ((doLiquidateCollateral == doLiquidateCollateral)) | |
1207 | 1471 | then { | |
1208 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1209 | - | if ((unstake == unstake)) | |
1472 | + | let x = if ((takeFromInsurance > 0)) | |
1210 | 1473 | then { | |
1211 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1212 | - | if ((depositInsurance == depositInsurance)) | |
1474 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1475 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1476 | + | then nil | |
1477 | + | else throw("Strict value is not equal to itself.") | |
1478 | + | } | |
1479 | + | else nil | |
1480 | + | if ((x == x)) | |
1481 | + | then { | |
1482 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1483 | + | if ((unstake == unstake)) | |
1213 | 1484 | then { | |
1214 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1215 | - | if ((notifyNotional == notifyNotional)) | |
1216 | - | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1217 | - | then abs(exchangedPositionSize) | |
1218 | - | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1219 | - | then abs(exchangedPositionSize) | |
1220 | - | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1485 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1486 | + | if ((depositInsurance == depositInsurance)) | |
1487 | + | then { | |
1488 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1489 | + | if ((notifyNotional == notifyNotional)) | |
1490 | + | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1491 | + | then abs(exchangedPositionSize) | |
1492 | + | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1493 | + | then abs(exchangedPositionSize) | |
1494 | + | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1495 | + | else throw("Strict value is not equal to itself.") | |
1496 | + | } | |
1221 | 1497 | else throw("Strict value is not equal to itself.") | |
1222 | 1498 | } | |
1223 | 1499 | else throw("Strict value is not equal to itself.") | |
1224 | 1500 | } | |
1225 | 1501 | else throw("Strict value is not equal to itself.") | |
1226 | 1502 | } | |
1227 | 1503 | else throw("Strict value is not equal to itself.") | |
1228 | 1504 | } | |
1229 | 1505 | else { | |
1230 | - | let $ | |
1231 | - | let x1 = $ | |
1232 | - | let badDebt = $ | |
1233 | - | let x2 = $ | |
1234 | - | let x3 = $ | |
1235 | - | let quoteAssetReserveAfter = $ | |
1236 | - | let baseAssetReserveAfter = $ | |
1237 | - | let totalPositionSizeAfter = $ | |
1238 | - | let cumulativeNotionalAfter = $ | |
1239 | - | let openInterestNotionalAfter = $ | |
1240 | - | let exchangedQuoteAssetAmount = $ | |
1241 | - | let totalLongAfter = $ | |
1242 | - | let totalShortAfter = $ | |
1506 | + | let $t06586666321 = internalClosePosition(_trader, false) | |
1507 | + | let x1 = $t06586666321._1 | |
1508 | + | let badDebt = $t06586666321._2 | |
1509 | + | let x2 = $t06586666321._3 | |
1510 | + | let x3 = $t06586666321._4 | |
1511 | + | let quoteAssetReserveAfter = $t06586666321._5 | |
1512 | + | let baseAssetReserveAfter = $t06586666321._6 | |
1513 | + | let totalPositionSizeAfter = $t06586666321._7 | |
1514 | + | let cumulativeNotionalAfter = $t06586666321._8 | |
1515 | + | let openInterestNotionalAfter = $t06586666321._9 | |
1516 | + | let exchangedQuoteAssetAmount = $t06586666321._10 | |
1517 | + | let totalLongAfter = $t06586666321._11 | |
1518 | + | let totalShortAfter = $t06586666321._12 | |
1243 | 1519 | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1244 | 1520 | let feeToLiquidator = (liquidationPenalty / 2) | |
1245 | 1521 | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1246 | 1522 | let ammBalance = (cbalance() - liquidationPenalty) | |
1247 | - | let $ | |
1523 | + | let $t06673366876 = if ((0 > ammBalance)) | |
1248 | 1524 | then $Tuple2(0, abs(ammBalance)) | |
1249 | 1525 | else $Tuple2(ammBalance, 0) | |
1250 | - | let newAmmBalance = $t05712657269._1 | |
1251 | - | let takeFromInsurance = $t05712657269._2 | |
1252 | - | let x = if ((takeFromInsurance > 0)) | |
1526 | + | let newAmmBalance = $t06673366876._1 | |
1527 | + | let takeFromInsurance = $t06673366876._2 | |
1528 | + | let $t06688466938 = getBorrowedByTrader(_trader) | |
1529 | + | let borrowed = $t06688466938._1 | |
1530 | + | let assetId = $t06688466938._2 | |
1531 | + | let doLiquidateCollateral = if ((borrowed > 0)) | |
1253 | 1532 | then { | |
1254 | - | let | |
1255 | - | if (( | |
1533 | + | let realizeAndClose = invoke(collateralAddress(), "realizePartiallyAndClose", [_trader, assetId], nil) | |
1534 | + | if ((realizeAndClose == realizeAndClose)) | |
1256 | 1535 | then nil | |
1257 | 1536 | else throw("Strict value is not equal to itself.") | |
1258 | 1537 | } | |
1259 | 1538 | else nil | |
1260 | - | if (( | |
1539 | + | if ((doLiquidateCollateral == doLiquidateCollateral)) | |
1261 | 1540 | then { | |
1262 | - | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1263 | - | if ((unstake == unstake)) | |
1541 | + | let x = if ((takeFromInsurance > 0)) | |
1264 | 1542 | then { | |
1265 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1266 | - | if ((depositInsurance == depositInsurance)) | |
1543 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1544 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1545 | + | then nil | |
1546 | + | else throw("Strict value is not equal to itself.") | |
1547 | + | } | |
1548 | + | else nil | |
1549 | + | if ((x == x)) | |
1550 | + | then { | |
1551 | + | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), (liquidationPenalty - takeFromInsurance)], nil) | |
1552 | + | if ((unstake == unstake)) | |
1267 | 1553 | then { | |
1268 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1269 | - | if ((notifyNotional == notifyNotional)) | |
1270 | - | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1554 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1555 | + | if ((depositInsurance == depositInsurance)) | |
1556 | + | then { | |
1557 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1558 | + | if ((notifyNotional == notifyNotional)) | |
1559 | + | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1560 | + | else throw("Strict value is not equal to itself.") | |
1561 | + | } | |
1271 | 1562 | else throw("Strict value is not equal to itself.") | |
1272 | 1563 | } | |
1273 | 1564 | else throw("Strict value is not equal to itself.") | |
1274 | 1565 | } | |
1275 | 1566 | else throw("Strict value is not equal to itself.") | |
1276 | 1567 | } | |
1277 | 1568 | else throw("Strict value is not equal to itself.") | |
1278 | 1569 | } | |
1279 | 1570 | } | |
1280 | 1571 | ||
1281 | 1572 | ||
1282 | 1573 | ||
1283 | 1574 | @Callable(i) | |
1284 | 1575 | func payFunding () = { | |
1285 | 1576 | let fundingBlockTimestamp = nextFundingBlockTimestamp() | |
1286 | 1577 | if (if (if ((fundingBlockTimestamp > lastBlock.timestamp)) | |
1287 | 1578 | then true | |
1288 | 1579 | else !(initialized())) | |
1289 | 1580 | then true | |
1290 | 1581 | else paused()) | |
1291 | 1582 | then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp))) | |
1292 | 1583 | else { | |
1293 | 1584 | let underlyingPrice = getOracleTwapPrice() | |
1294 | - | let $ | |
1295 | - | let shortPremiumFraction = $ | |
1296 | - | let longPremiumFraction = $ | |
1585 | + | let $t06873668798 = getFunding() | |
1586 | + | let shortPremiumFraction = $t06873668798._1 | |
1587 | + | let longPremiumFraction = $t06873668798._2 | |
1297 | 1588 | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1298 | 1589 | } | |
1299 | 1590 | } | |
1300 | 1591 | ||
1301 | 1592 | ||
1302 | 1593 | ||
1303 | 1594 | @Callable(i) | |
1304 | 1595 | func forceMoveAsset (_trader,_amount) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller)) | |
1305 | 1596 | then true | |
1306 | 1597 | else (0 > _amount)) | |
1307 | 1598 | then throw("Invalid forceMoveAsset parameters") | |
1308 | 1599 | else { | |
1309 | 1600 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), _amount], nil) | |
1310 | 1601 | if ((unstake == unstake)) | |
1311 | 1602 | then (withdraw(addressFromStringValue(_trader), _amount) ++ updateBalance((cbalance() - _amount))) | |
1312 | 1603 | else throw("Strict value is not equal to itself.") | |
1313 | 1604 | } | |
1314 | 1605 | ||
1315 | 1606 | ||
1316 | 1607 | ||
1317 | 1608 | @Callable(i) | |
1318 | 1609 | func adjustPeg (_price) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller)) | |
1319 | 1610 | then true | |
1320 | 1611 | else (0 > _price)) | |
1321 | 1612 | then throw("Invalid adjustPeg parameters") | |
1322 | 1613 | else { | |
1323 | - | let $ | |
1324 | - | let newQuoteAssetReserve = $ | |
1325 | - | let pegChangeCost = $ | |
1614 | + | let $t06978969875 = getPegAdjustCost(_price) | |
1615 | + | let newQuoteAssetReserve = $t06978969875._1 | |
1616 | + | let pegChangeCost = $t06978969875._2 | |
1326 | 1617 | if ((pegChangeCost == 0)) | |
1327 | 1618 | then throw("Nothing to adjust") | |
1328 | 1619 | else if ((pegChangeCost > 0)) | |
1329 | 1620 | then updateAmmReserves(newQuoteAssetReserve, bsAstR()) | |
1330 | 1621 | else { | |
1331 | 1622 | let unstake = invoke(managerAddress(), "withdraw", [toBase58String(quoteAsset()), abs(pegChangeCost)], nil) | |
1332 | 1623 | if ((unstake == unstake)) | |
1333 | 1624 | then { | |
1334 | 1625 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), abs(pegChangeCost))]) | |
1335 | 1626 | if ((depositInsurance == depositInsurance)) | |
1336 | 1627 | then (updateBalance((cbalance() - abs(pegChangeCost))) ++ updateAmmReserves(newQuoteAssetReserve, bsAstR())) | |
1337 | 1628 | else throw("Strict value is not equal to itself.") | |
1338 | 1629 | } | |
1339 | 1630 | else throw("Strict value is not equal to itself.") | |
1340 | 1631 | } | |
1341 | 1632 | } | |
1342 | 1633 | ||
1343 | 1634 | ||
1344 | 1635 | ||
1345 | 1636 | @Callable(i) | |
1346 | 1637 | func migrateLiquidity () = { | |
1347 | 1638 | let amount = cbalance() | |
1348 | - | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil) | |
1349 | - | if ((unstake == unstake)) | |
1639 | + | if ((amount > 0)) | |
1350 | 1640 | then { | |
1351 | - | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
1352 | - | if ((stake == stake)) | |
1353 | - | then nil | |
1641 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [amount, toBase58String(quoteAsset())], nil) | |
1642 | + | if ((unstake == unstake)) | |
1643 | + | then { | |
1644 | + | let stake = invoke(managerAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), amount)]) | |
1645 | + | if ((stake == stake)) | |
1646 | + | then nil | |
1647 | + | else throw("Strict value is not equal to itself.") | |
1648 | + | } | |
1354 | 1649 | else throw("Strict value is not equal to itself.") | |
1355 | 1650 | } | |
1356 | - | else | |
1651 | + | else nil | |
1357 | 1652 | } | |
1358 | 1653 | ||
1359 | 1654 | ||
1360 | 1655 | ||
1361 | 1656 | @Callable(i) | |
1362 | 1657 | func v_get (_trader) = { | |
1363 | - | let $ | |
1364 | - | let x1 = $ | |
1365 | - | let x2 = $ | |
1366 | - | let x3 = $ | |
1367 | - | let x4 = $ | |
1658 | + | let $t07151671576 = internalClosePosition(_trader, false) | |
1659 | + | let x1 = $t07151671576._1 | |
1660 | + | let x2 = $t07151671576._2 | |
1661 | + | let x3 = $t07151671576._3 | |
1662 | + | let x4 = $t07151671576._4 | |
1368 | 1663 | throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader)))) | |
1369 | 1664 | } | |
1370 | 1665 | ||
1371 | 1666 | ||
1372 | 1667 | ||
1373 | 1668 | @Callable(i) | |
1374 | 1669 | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1375 | - | let $ | |
1376 | - | let positionSize = $ | |
1377 | - | let positionMargin = $ | |
1378 | - | let pon = $ | |
1379 | - | let positionLstUpdCPF = $ | |
1380 | - | let $ | |
1381 | - | let positionNotional = $ | |
1382 | - | let unrealizedPnl = $ | |
1383 | - | let $ | |
1384 | - | let remainMargin = $ | |
1385 | - | let badDebt = $ | |
1386 | - | let fundingPayment = $ | |
1670 | + | let $t07172371834 = getPosition(_trader) | |
1671 | + | let positionSize = $t07172371834._1 | |
1672 | + | let positionMargin = $t07172371834._2 | |
1673 | + | let pon = $t07172371834._3 | |
1674 | + | let positionLstUpdCPF = $t07172371834._4 | |
1675 | + | let $t07183971940 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1676 | + | let positionNotional = $t07183971940._1 | |
1677 | + | let unrealizedPnl = $t07183971940._2 | |
1678 | + | let $t07194572127 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
1679 | + | let remainMargin = $t07194572127._1 | |
1680 | + | let badDebt = $t07194572127._2 | |
1681 | + | let fundingPayment = $t07194572127._3 | |
1387 | 1682 | throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional))) | |
1388 | 1683 | } | |
1389 | 1684 | ||
1390 | 1685 | ||
1391 | 1686 | ||
1392 | 1687 | @Callable(i) | |
1393 | 1688 | func view_getPegAdjustCost (_price) = { | |
1394 | 1689 | let cost = getPegAdjustCost(_price) | |
1395 | 1690 | throw(toString(cost._2)) | |
1396 | 1691 | } | |
1397 | 1692 | ||
1398 | 1693 | ||
1399 | 1694 | ||
1400 | 1695 | @Callable(i) | |
1401 | 1696 | func view_getFunding () = { | |
1402 | 1697 | let underlyingPrice = getOracleTwapPrice() | |
1403 | - | let $ | |
1404 | - | let shortPremiumFraction = $ | |
1405 | - | let longPremiumFraction = $ | |
1698 | + | let $t07251872580 = getFunding() | |
1699 | + | let shortPremiumFraction = $t07251872580._1 | |
1700 | + | let longPremiumFraction = $t07251872580._2 | |
1406 | 1701 | let longFunding = divd(longPremiumFraction, underlyingPrice) | |
1407 | 1702 | let shortFunding = divd(shortPremiumFraction, underlyingPrice) | |
1408 | 1703 | throw((((s(longFunding) + s(shortFunding)) + s(getTwapSpotPrice())) + s(getOracleTwapPrice()))) | |
1704 | + | } | |
1705 | + | ||
1706 | + | ||
1707 | + | ||
1708 | + | @Callable(i) | |
1709 | + | func view_getBorrowedByTrader (_trader) = { | |
1710 | + | let $t07287072924 = getBorrowedByTrader(_trader) | |
1711 | + | let borrowed = $t07287072924._1 | |
1712 | + | let assetId = $t07287072924._2 | |
1713 | + | throw((s(borrowed) + assetId)) | |
1409 | 1714 | } | |
1410 | 1715 | ||
1411 | 1716 | ||
1412 | 1717 | @Verifier(tx) | |
1413 | 1718 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
1414 | 1719 |
github/deemru/w8io/169f3d6 257.62 ms ◑