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