tx · 9Vyfi5f9oSfnL6MaJMhccRtq1JAoR5noz64AddKGmSiL 3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH: -0.04900000 Waves 2022.08.29 22:18 [2206149] smart account 3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH > SELF 0.00000000 Waves
{ "type": 13, "id": "9Vyfi5f9oSfnL6MaJMhccRtq1JAoR5noz64AddKGmSiL", "fee": 4900000, "feeAssetId": null, "timestamp": 1661800731187, "version": 2, "chainId": 84, "sender": "3N8G95pEaYEhZ4U3m3UrzpEzwBFn5vvXsZH", "senderPublicKey": "Hj6oyH6As5UWo8fZ1K4hPsEY7nxH3MvhBqDD6axiwjXs", "proofs": [ "gmRbFpPrUpkkdbDRkTEaX1UgGGcydQmJXisx6K8qUoE6RsxEuq2g5wUXV4S6RWf4C3AwEZoXgpnFKtF2m5DZBiT" ], "script": "base64:BgJiCAISABIAEgMKAQESAwoBARILCgkBAQEBAQEBAQESEAoOAQEBAQEBAQgICAEBAQESAwoBARIFCgMBAQESBQoDAQEBEgASAwoBARIAEgMKAQgSABIDCgEIEgMKAQgSBAoCCAF/AAlrX29yYV9rZXkCCWtfb3JhX2tleQAPa19vcmFfYmxvY2tfa2V5Ag9rX29yYV9ibG9ja19rZXkABWtfb3JhAgVrX29yYQAJa19iYWxhbmNlAglrX2JhbGFuY2UADmtfcG9zaXRpb25TaXplAg5rX3Bvc2l0aW9uU2l6ZQAQa19wb3NpdGlvbk1hcmdpbgIQa19wb3NpdGlvbk1hcmdpbgAWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAIWa19wb3NpdGlvbk9wZW5Ob3Rpb25hbAAua19wb3NpdGlvbkxhc3RVcGRhdGVkQ3VtdWxhdGl2ZVByZW1pdW1GcmFjdGlvbgISa19wb3NpdGlvbkZyYWN0aW9uAA1rX2luaXRpYWxpemVkAg1rX2luaXRpYWxpemVkAAhrX3BhdXNlZAIIa19wYXVzZWQABWtfZmVlAgVrX2ZlZQAPa19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uc3Rha2UJAPwHBAkBEXF1b3RlQXNzZXRTdGFraW5nAAIOdW5sb2NrTmV1dHJpbm8JAMwIAgUHX2Ftb3VudAkAzAgCCQDYBAEJAQpxdW90ZUFzc2V0AAUDbmlsBQNuaWwDCQAAAgUHdW5zdGFrZQUHdW5zdGFrZQkAzggCCQEId2l0aGRyYXcCCQERQGV4dHJOYXRpdmUoMTA2MikBBQdfdHJhZGVyBQdfYW1vdW50CQENdXBkYXRlQmFsYW5jZQEJAGUCCQEIY2JhbGFuY2UABQdfYW1vdW50CQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAkBDmFkbWluUHVibGljS2V5AMe2r1k=", "height": 2206149, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: H8RBFe1rwD7zdhDn48UVL2PmY4pEYjR1cyfXDKhwhJVJ Next: 6Znb8ZnUjQjNn75JbKbhqcFT1cCLEiTyMKVrWkqAPpcE Diff:
Old | New | Differences | |
---|---|---|---|
31 | 31 | ||
32 | 32 | let k_liquidationFeeRatio = "k_liquidationFeeRatio" | |
33 | 33 | ||
34 | + | let k_partialLiquidationRatio = "k_partLiquidationRatio" | |
35 | + | ||
34 | 36 | let k_spreadLimit = "k_spreadLimit" | |
35 | 37 | ||
36 | 38 | let k_maxPriceImpact = "k_maxPriceImpact" | |
39 | + | ||
40 | + | let k_maxPriceSpread = "k_maxPriceSpread" | |
37 | 41 | ||
38 | 42 | let k_lastDataStr = "k_lastDataStr" | |
39 | 43 | ||
229 | 233 | func liquidationFeeRatio () = int(k_liquidationFeeRatio) | |
230 | 234 | ||
231 | 235 | ||
236 | + | func partialLiquidationRatio () = int(k_partialLiquidationRatio) | |
237 | + | ||
238 | + | ||
232 | 239 | func spreadLimit () = int(k_spreadLimit) | |
233 | 240 | ||
234 | 241 | ||
235 | 242 | func maxPriceImpact () = int(k_maxPriceImpact) | |
243 | + | ||
244 | + | ||
245 | + | func maxPriceSpread () = int(k_maxPriceSpread) | |
236 | 246 | ||
237 | 247 | ||
238 | 248 | func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction) | |
317 | 327 | let amountBaseAssetBought = if (_isAdd) | |
318 | 328 | then amountBaseAssetBoughtAbs | |
319 | 329 | else -(amountBaseAssetBoughtAbs) | |
320 | - | let $ | |
321 | - | let quoteAssetReserveAfter1 = $ | |
322 | - | let baseAssetReserveAfter1 = $ | |
323 | - | let totalPositionSizeAfter1 = $ | |
324 | - | let cumulativeNotionalAfter1 = $ | |
330 | + | let $t01217712370 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs) | |
331 | + | let quoteAssetReserveAfter1 = $t01217712370._1 | |
332 | + | let baseAssetReserveAfter1 = $t01217712370._2 | |
333 | + | let totalPositionSizeAfter1 = $t01217712370._3 | |
334 | + | let cumulativeNotionalAfter1 = $t01217712370._4 | |
325 | 335 | let priceBefore = divd(_qtAstR, _bsAstR) | |
326 | 336 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
327 | 337 | let priceDiff = abs((priceBefore - marketPrice)) | |
341 | 351 | } | |
342 | 352 | else 0 | |
343 | 353 | let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin) | |
344 | - | let $ | |
354 | + | let $t01386113988 = if ((0 > signedMargin)) | |
345 | 355 | then $Tuple2(0, abs(signedMargin)) | |
346 | 356 | else $Tuple2(abs(signedMargin), 0) | |
347 | - | let remainMargin = $ | |
348 | - | let badDebt = $ | |
357 | + | let remainMargin = $t01386113988._1 | |
358 | + | let badDebt = $t01386113988._2 | |
349 | 359 | $Tuple3(remainMargin, badDebt, fundingPayment) | |
350 | 360 | } | |
351 | 361 | ||
352 | 362 | ||
353 | - | func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = { | |
354 | - | let _quoteAssetReserve = qtAstR() | |
355 | - | let _baseAssetReserve = bsAstR() | |
363 | + | func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_baseAssetReserve) = { | |
356 | 364 | let priceBefore = divd(_quoteAssetReserve, _baseAssetReserve) | |
357 | 365 | if ((_baseAssetAmount == 0)) | |
358 | 366 | then throw("Invalid base asset amount") | |
364 | 372 | let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter) | |
365 | 373 | let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve)) | |
366 | 374 | let maxPriceImpactValue = maxPriceImpact() | |
367 | - | let $ | |
368 | - | let quoteAssetReserveAfter1 = $ | |
369 | - | let baseAssetReserveAfter1 = $ | |
370 | - | let totalPositionSizeAfter1 = $ | |
371 | - | let cumulativeNotionalAfter1 = $ | |
375 | + | let $t01496515158 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount) | |
376 | + | let quoteAssetReserveAfter1 = $t01496515158._1 | |
377 | + | let baseAssetReserveAfter1 = $t01496515158._2 | |
378 | + | let totalPositionSizeAfter1 = $t01496515158._3 | |
379 | + | let cumulativeNotionalAfter1 = $t01496515158._4 | |
372 | 380 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
373 | 381 | let priceDiff = abs((priceBefore - marketPrice)) | |
374 | 382 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
376 | 384 | then _checkMaxPriceImpact | |
377 | 385 | else false) | |
378 | 386 | then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_quoteAssetReserve)) + " before base asset: ") + toString(_baseAssetReserve)) + " base asset amount to exchange: ") + toString(_baseAssetAmount)) + " price before: ") + toString(priceBefore)) + " market price: ") + toString(marketPrice))) | |
379 | - | else $ | |
387 | + | else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd) | |
380 | 388 | then abs(_baseAssetAmount) | |
381 | 389 | else 0)), (totalShortPositionSize() - (if (!(_isAdd)) | |
382 | 390 | then abs(_baseAssetAmount) | |
383 | - | else 0))) | |
391 | + | else 0)), priceImpact) | |
384 | 392 | } | |
385 | 393 | } | |
394 | + | ||
395 | + | ||
396 | + | func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), bsAstR()) | |
386 | 397 | ||
387 | 398 | ||
388 | 399 | func getOracleTwapPrice () = { | |
391 | 402 | let blockKey = getStringValue(this, k_ora_block_key) | |
392 | 403 | let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey)) | |
393 | 404 | lastValue | |
405 | + | } | |
406 | + | ||
407 | + | ||
408 | + | func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = { | |
409 | + | let oraclePrice = getOracleTwapPrice() | |
410 | + | let priceAfter = divd(_quoteAssetReserve, _baseAssetReserve) | |
411 | + | let averagePrice = divd((oraclePrice + priceAfter), (2 * DECIMAL_UNIT)) | |
412 | + | let absPriceDiff = divd(abs((oraclePrice - priceAfter)), averagePrice) | |
413 | + | if ((absPriceDiff > maxPriceSpread())) | |
414 | + | then throw(((("Price spread " + toString(absPriceDiff)) + " > max price spread ") + toString(maxPriceSpread()))) | |
415 | + | else true | |
394 | 416 | } | |
395 | 417 | ||
396 | 418 | ||
408 | 430 | } | |
409 | 431 | ||
410 | 432 | ||
433 | + | func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_baseAssetReserve) = { | |
434 | + | let positionSizeAbs = abs(_positionSize) | |
435 | + | let isShort = (0 > _positionSize) | |
436 | + | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
437 | + | then { | |
438 | + | let $t01837618547 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve) | |
439 | + | let outPositionNotional = $t01837618547._1 | |
440 | + | let x1 = $t01837618547._2 | |
441 | + | let x2 = $t01837618547._3 | |
442 | + | let x3 = $t01837618547._4 | |
443 | + | outPositionNotional | |
444 | + | } | |
445 | + | else muld(positionSizeAbs, getOracleTwapPrice()) | |
446 | + | positionNotional | |
447 | + | } | |
448 | + | ||
449 | + | ||
411 | 450 | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
412 | - | let $t01729317421 = getPosition(_trader) | |
413 | - | let positionSize = $t01729317421._1 | |
414 | - | let positionMargin = $t01729317421._2 | |
415 | - | let positionOpenNotional = $t01729317421._3 | |
416 | - | let positionLstUpdCPF = $t01729317421._4 | |
417 | - | let positionSizeAbs = abs(positionSize) | |
418 | - | if ((positionSizeAbs == 0)) | |
451 | + | let $t01894119069 = getPosition(_trader) | |
452 | + | let positionSize = $t01894119069._1 | |
453 | + | let positionMargin = $t01894119069._2 | |
454 | + | let positionOpenNotional = $t01894119069._3 | |
455 | + | let positionLstUpdCPF = $t01894119069._4 | |
456 | + | if ((positionSize == 0)) | |
419 | 457 | then throw("Invalid position size") | |
420 | 458 | else { | |
421 | 459 | let isShort = (0 > positionSize) | |
422 | - | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
423 | - | then { | |
424 | - | let $t01766817792 = swapOutput(!(isShort), positionSizeAbs, false) | |
425 | - | let outPositionNotional = $t01766817792._1 | |
426 | - | let x1 = $t01766817792._2 | |
427 | - | let x2 = $t01766817792._3 | |
428 | - | let x3 = $t01766817792._4 | |
429 | - | outPositionNotional | |
430 | - | } | |
431 | - | else muld(positionSizeAbs, getOracleTwapPrice()) | |
460 | + | let positionNotional = getPositionAdjustedOpenNotional(positionSize, _option, qtAstR(), bsAstR()) | |
432 | 461 | let unrealizedPnl = if (isShort) | |
433 | 462 | then (positionOpenNotional - positionNotional) | |
434 | 463 | else (positionNotional - positionOpenNotional) | |
441 | 470 | ||
442 | 471 | ||
443 | 472 | func getMarginRatioByOption (_trader,_option) = { | |
444 | - | let $ | |
445 | - | let positionSize = $ | |
446 | - | let positionMargin = $ | |
447 | - | let pon = $ | |
448 | - | let positionLstUpdCPF = $ | |
449 | - | let $ | |
450 | - | let positionNotional = $ | |
451 | - | let unrealizedPnl = $ | |
452 | - | let $ | |
453 | - | let remainMargin = $ | |
454 | - | let badDebt = $ | |
473 | + | let $t01990220013 = getPosition(_trader) | |
474 | + | let positionSize = $t01990220013._1 | |
475 | + | let positionMargin = $t01990220013._2 | |
476 | + | let pon = $t01990220013._3 | |
477 | + | let positionLstUpdCPF = $t01990220013._4 | |
478 | + | let $t02001920112 = getPositionNotionalAndUnrealizedPnl(_trader, _option) | |
479 | + | let positionNotional = $t02001920112._1 | |
480 | + | let unrealizedPnl = $t02001920112._2 | |
481 | + | let $t02011720283 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
482 | + | let remainMargin = $t02011720283._1 | |
483 | + | let badDebt = $t02011720283._2 | |
455 | 484 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
456 | 485 | } | |
457 | 486 | ||
459 | 488 | func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
460 | 489 | ||
461 | 490 | ||
491 | + | func getPartialLiquidationAmount (_trader,_positionSize) = { | |
492 | + | let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio()))) | |
493 | + | let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio) | |
494 | + | let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false) | |
495 | + | let maxExchangedQuoteAssetAmount = swapResult._1 | |
496 | + | let priceImpact = swapResult._8 | |
497 | + | if ((maxPriceImpact() > priceImpact)) | |
498 | + | then maxExchangedQuoteAssetAmount | |
499 | + | else { | |
500 | + | let exchangedPositionSize = muld(abs(_positionSize), partialLiquidationRatio()) | |
501 | + | let exchangedQuoteAssetAmount = swapOutput((_positionSize > 0), exchangedPositionSize, false)._1 | |
502 | + | exchangedQuoteAssetAmount | |
503 | + | } | |
504 | + | } | |
505 | + | ||
506 | + | ||
462 | 507 | func internalClosePosition (_trader,_checkMaxPriceImpact) = { | |
463 | - | let $t01919019318 = getPosition(_trader) | |
464 | - | let positionSize = $t01919019318._1 | |
465 | - | let positionMargin = $t01919019318._2 | |
466 | - | let positionOpenNotional = $t01919019318._3 | |
467 | - | let positionLstUpdCPF = $t01919019318._4 | |
468 | - | let $t01932419411 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
469 | - | let x1 = $t01932419411._1 | |
470 | - | let unrealizedPnl = $t01932419411._2 | |
471 | - | let $t01941619584 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
472 | - | let remainMargin = $t01941619584._1 | |
473 | - | let badDebt = $t01941619584._2 | |
508 | + | let $t02146521593 = getPosition(_trader) | |
509 | + | let positionSize = $t02146521593._1 | |
510 | + | let positionMargin = $t02146521593._2 | |
511 | + | let positionOpenNotional = $t02146521593._3 | |
512 | + | let positionLstUpdCPF = $t02146521593._4 | |
513 | + | let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2 | |
514 | + | let $t02168821856 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
515 | + | let remainMargin = $t02168821856._1 | |
516 | + | let badDebt = $t02168821856._2 | |
474 | 517 | let exchangedPositionSize = -(positionSize) | |
475 | 518 | let realizedPnl = unrealizedPnl | |
476 | 519 | let marginToVault = -(remainMargin) | |
477 | - | let $ | |
478 | - | let exchangedQuoteAssetAmount = $ | |
479 | - | let quoteAssetReserveAfter = $ | |
480 | - | let baseAssetReserveAfter = $ | |
481 | - | let totalPositionSizeAfter = $ | |
482 | - | let cumulativeNotionalAfter = $ | |
483 | - | let totalLongAfter = $ | |
484 | - | let totalShortAfter = $ | |
520 | + | let $t02198322294 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact) | |
521 | + | let exchangedQuoteAssetAmount = $t02198322294._1 | |
522 | + | let quoteAssetReserveAfter = $t02198322294._2 | |
523 | + | let baseAssetReserveAfter = $t02198322294._3 | |
524 | + | let totalPositionSizeAfter = $t02198322294._4 | |
525 | + | let cumulativeNotionalAfter = $t02198322294._5 | |
526 | + | let totalLongAfter = $t02198322294._6 | |
527 | + | let totalShortAfter = $t02198322294._7 | |
485 | 528 | let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional) | |
486 | 529 | $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter) | |
487 | 530 | } | |
524 | 567 | } | |
525 | 568 | ||
526 | 569 | ||
527 | - | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact)] | |
570 | + | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread)] | |
528 | 571 | ||
529 | 572 | ||
530 | 573 | 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)] | |
637 | 680 | ||
638 | 681 | ||
639 | 682 | @Callable(i) | |
640 | - | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = if ((i.caller != adminAddress())) | |
683 | + | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress())) | |
641 | 684 | then throw("Invalid changeSettings params") | |
642 | - | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact) | |
685 | + | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread) | |
643 | 686 | ||
644 | 687 | ||
645 | 688 | ||
646 | 689 | @Callable(i) | |
647 | - | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact) = if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
690 | + | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
648 | 691 | then true | |
649 | 692 | else (0 >= _bsAstR)) | |
650 | 693 | then true | |
662 | 705 | then true | |
663 | 706 | else (0 >= _maxPriceImpact)) | |
664 | 707 | then true | |
708 | + | else (0 >= _partialLiquidationRatio)) | |
709 | + | then true | |
710 | + | else (0 >= _maxPriceSpread)) | |
711 | + | then true | |
665 | 712 | else initialized()) | |
666 | 713 | then throw("Invalid initialize parameters") | |
667 | - | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)]) | |
668 | - | ||
669 | - | ||
670 | - | ||
671 | - | @Callable(i) | |
672 | - | func setMaxPriceImpact (_maxPriceImpact) = if (if ((0 >= _maxPriceImpact)) | |
673 | - | then true | |
674 | - | else !(initialized())) | |
675 | - | then throw("Invalid _maxPriceImpact parameters") | |
676 | - | else updateSettings(initMarginRatio(), maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), _maxPriceImpact) | |
714 | + | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)]) | |
677 | 715 | ||
678 | 716 | ||
679 | 717 | ||
682 | 720 | then true | |
683 | 721 | else !(initialized())) | |
684 | 722 | then throw("Invalid setInitMarginRatio parameters") | |
685 | - | else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact()) | |
723 | + | else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread()) | |
686 | 724 | ||
687 | 725 | ||
688 | 726 | ||
698 | 736 | else paused()) | |
699 | 737 | then throw("Invalid decreasePosition parameters") | |
700 | 738 | else { | |
701 | - | let $ | |
702 | - | let oldPositionSize = $ | |
703 | - | let oldPositionMargin = $ | |
704 | - | let oldPositionOpenNotional = $ | |
705 | - | let oldPositionLstUpdCPF = $ | |
739 | + | let $t03418734339 = getPosition(toString(i.caller)) | |
740 | + | let oldPositionSize = $t03418734339._1 | |
741 | + | let oldPositionMargin = $t03418734339._2 | |
742 | + | let oldPositionOpenNotional = $t03418734339._3 | |
743 | + | let oldPositionLstUpdCPF = $t03418734339._4 | |
706 | 744 | let _direction = if ((oldPositionSize > 0)) | |
707 | 745 | then DIR_SHORT | |
708 | 746 | else DIR_LONG | |
709 | 747 | let isAdd = (_direction == DIR_LONG) | |
710 | 748 | let openNotional = muld(_amount, _leverage) | |
711 | - | let $ | |
712 | - | let oldPositionNotional = $ | |
713 | - | let unrealizedPnl = $ | |
714 | - | let $ | |
749 | + | let $t03451234628 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
750 | + | let oldPositionNotional = $t03451234628._1 | |
751 | + | let unrealizedPnl = $t03451234628._2 | |
752 | + | let $t03463437183 = if ((oldPositionNotional > openNotional)) | |
715 | 753 | then { | |
716 | - | let $ | |
717 | - | let exchangedPositionSize = $ | |
718 | - | let quoteAssetReserveAfter = $ | |
719 | - | let baseAssetReserveAfter = $ | |
720 | - | let totalPositionSizeAfter = $ | |
721 | - | let cumulativeNotionalAfter = $ | |
754 | + | let $t03501135230 = swapInput(isAdd, openNotional) | |
755 | + | let exchangedPositionSize = $t03501135230._1 | |
756 | + | let quoteAssetReserveAfter = $t03501135230._2 | |
757 | + | let baseAssetReserveAfter = $t03501135230._3 | |
758 | + | let totalPositionSizeAfter = $t03501135230._4 | |
759 | + | let cumulativeNotionalAfter = $t03501135230._5 | |
722 | 760 | let exchangedPositionSizeAbs = abs(exchangedPositionSize) | |
723 | 761 | if (if ((_minBaseAssetAmount != 0)) | |
724 | 762 | then (_minBaseAssetAmount > exchangedPositionSizeAbs) | |
726 | 764 | then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount))) | |
727 | 765 | else { | |
728 | 766 | let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize)) | |
729 | - | let $ | |
730 | - | let remainMargin = $ | |
731 | - | let badDebt = $ | |
732 | - | let fundingPayment = $ | |
767 | + | let $t03566735912 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
768 | + | let remainMargin = $t03566735912._1 | |
769 | + | let badDebt = $t03566735912._2 | |
770 | + | let fundingPayment = $t03566735912._3 | |
733 | 771 | let exchangedQuoteAssetAmount = openNotional | |
734 | 772 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
735 | 773 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
744 | 782 | } | |
745 | 783 | } | |
746 | 784 | else throw("Close position first") | |
747 | - | let newPositionSize = $ | |
748 | - | let newPositionRemainMargin = $ | |
749 | - | let newPositionOpenNotional = $ | |
750 | - | let newPositionLatestCPF = $ | |
751 | - | let baseAssetReserveAfter = $ | |
752 | - | let quoteAssetReserveAfter = $ | |
753 | - | let totalPositionSizeAfter = $ | |
754 | - | let cumulativeNotionalAfter = $ | |
755 | - | let openInterestNotionalAfter = $ | |
756 | - | let totalLongAfter = $ | |
757 | - | let totalShortAfter = $ | |
785 | + | let newPositionSize = $t03463437183._1 | |
786 | + | let newPositionRemainMargin = $t03463437183._2 | |
787 | + | let newPositionOpenNotional = $t03463437183._3 | |
788 | + | let newPositionLatestCPF = $t03463437183._4 | |
789 | + | let baseAssetReserveAfter = $t03463437183._5 | |
790 | + | let quoteAssetReserveAfter = $t03463437183._6 | |
791 | + | let totalPositionSizeAfter = $t03463437183._7 | |
792 | + | let cumulativeNotionalAfter = $t03463437183._8 | |
793 | + | let openInterestNotionalAfter = $t03463437183._9 | |
794 | + | let totalLongAfter = $t03463437183._10 | |
795 | + | let totalShortAfter = $t03463437183._11 | |
758 | 796 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
759 | 797 | if ((notifyNotional == notifyNotional)) | |
760 | 798 | then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
783 | 821 | else { | |
784 | 822 | let feeAmount = muld(_rawAmount, fee()) | |
785 | 823 | let _amount = (_rawAmount - feeAmount) | |
786 | - | let $ | |
787 | - | let oldPositionSize = $ | |
788 | - | let oldPositionMargin = $ | |
789 | - | let oldPositionOpenNotional = $ | |
790 | - | let oldPositionLstUpdCPF = $ | |
824 | + | let $t03830138453 = getPosition(toString(i.caller)) | |
825 | + | let oldPositionSize = $t03830138453._1 | |
826 | + | let oldPositionMargin = $t03830138453._2 | |
827 | + | let oldPositionOpenNotional = $t03830138453._3 | |
828 | + | let oldPositionLstUpdCPF = $t03830138453._4 | |
791 | 829 | let isNewPosition = (oldPositionSize == 0) | |
792 | 830 | let isSameDirection = if ((oldPositionSize > 0)) | |
793 | 831 | then (_direction == DIR_LONG) | |
796 | 834 | then isSameDirection | |
797 | 835 | else false | |
798 | 836 | let isAdd = (_direction == DIR_LONG) | |
799 | - | let $ | |
837 | + | let $t03874241310 = if (if (isNewPosition) | |
800 | 838 | then true | |
801 | 839 | else expandExisting) | |
802 | 840 | then { | |
803 | 841 | let openNotional = muld(_amount, _leverage) | |
804 | - | let $ | |
805 | - | let amountBaseAssetBought = $ | |
806 | - | let quoteAssetReserveAfter = $ | |
807 | - | let baseAssetReserveAfter = $ | |
808 | - | let totalPositionSizeAfter = $ | |
809 | - | let cumulativeNotionalAfter = $ | |
842 | + | let $t03916639372 = swapInput(isAdd, openNotional) | |
843 | + | let amountBaseAssetBought = $t03916639372._1 | |
844 | + | let quoteAssetReserveAfter = $t03916639372._2 | |
845 | + | let baseAssetReserveAfter = $t03916639372._3 | |
846 | + | let totalPositionSizeAfter = $t03916639372._4 | |
847 | + | let cumulativeNotionalAfter = $t03916639372._5 | |
810 | 848 | if (if ((_minBaseAssetAmount != 0)) | |
811 | 849 | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
812 | 850 | else false) | |
814 | 852 | else { | |
815 | 853 | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
816 | 854 | let increaseMarginRequirement = divd(openNotional, _leverage) | |
817 | - | let $t03729737536 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
818 | - | let remainMargin = $t03729737536._1 | |
819 | - | let x1 = $t03729737536._2 | |
820 | - | let x2 = $t03729737536._3 | |
821 | - | $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
822 | - | then abs(amountBaseAssetBought) | |
823 | - | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
824 | - | then abs(amountBaseAssetBought) | |
825 | - | else 0))) | |
855 | + | let $t03975339992 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
856 | + | let remainMargin = $t03975339992._1 | |
857 | + | let x1 = $t03975339992._2 | |
858 | + | let x2 = $t03975339992._3 | |
859 | + | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
860 | + | then throw("Over max spread limit") | |
861 | + | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
862 | + | then abs(amountBaseAssetBought) | |
863 | + | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
864 | + | then abs(amountBaseAssetBought) | |
865 | + | else 0))) | |
826 | 866 | } | |
827 | 867 | } | |
828 | 868 | else { | |
829 | 869 | let openNotional = muld(_amount, _leverage) | |
830 | - | let $ | |
831 | - | let oldPositionNotional = $ | |
832 | - | let unrealizedPnl = $ | |
870 | + | let $t04100341119 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
871 | + | let oldPositionNotional = $t04100341119._1 | |
872 | + | let unrealizedPnl = $t04100341119._2 | |
833 | 873 | if ((oldPositionNotional > openNotional)) | |
834 | 874 | then throw("Use decreasePosition to decrease position size") | |
835 | 875 | else throw("Close position first") | |
836 | 876 | } | |
837 | - | let newPositionSize = $ | |
838 | - | let newPositionRemainMargin = $ | |
839 | - | let newPositionOpenNotional = $ | |
840 | - | let newPositionLatestCPF = $ | |
841 | - | let baseAssetReserveAfter = $ | |
842 | - | let quoteAssetReserveAfter = $ | |
843 | - | let totalPositionSizeAfter = $ | |
844 | - | let cumulativeNotionalAfter = $ | |
845 | - | let openInterestNotionalAfter = $ | |
846 | - | let totalLongAfter = $ | |
847 | - | let totalShortAfter = $ | |
877 | + | let newPositionSize = $t03874241310._1 | |
878 | + | let newPositionRemainMargin = $t03874241310._2 | |
879 | + | let newPositionOpenNotional = $t03874241310._3 | |
880 | + | let newPositionLatestCPF = $t03874241310._4 | |
881 | + | let baseAssetReserveAfter = $t03874241310._5 | |
882 | + | let quoteAssetReserveAfter = $t03874241310._6 | |
883 | + | let totalPositionSizeAfter = $t03874241310._7 | |
884 | + | let cumulativeNotionalAfter = $t03874241310._8 | |
885 | + | let openInterestNotionalAfter = $t03874241310._9 | |
886 | + | let totalLongAfter = $t03874241310._10 | |
887 | + | let totalShortAfter = $t03874241310._11 | |
848 | 888 | let feeToStakers = (feeAmount / 2) | |
849 | 889 | let feeToInsurance = (feeAmount - feeToStakers) | |
850 | 890 | let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)]) | |
885 | 925 | else { | |
886 | 926 | let feeAmount = muld(_rawAmount, fee()) | |
887 | 927 | let _amount = (_rawAmount - feeAmount) | |
888 | - | let $ | |
889 | - | let oldPositionSize = $ | |
890 | - | let oldPositionMargin = $ | |
891 | - | let oldPositionOpenNotional = $ | |
892 | - | let oldPositionLstUpdCPF = $ | |
928 | + | let $t04286643018 = getPosition(toString(i.caller)) | |
929 | + | let oldPositionSize = $t04286643018._1 | |
930 | + | let oldPositionMargin = $t04286643018._2 | |
931 | + | let oldPositionOpenNotional = $t04286643018._3 | |
932 | + | let oldPositionLstUpdCPF = $t04286643018._4 | |
893 | 933 | let feeToStakers = (feeAmount / 2) | |
894 | 934 | let feeToInsurance = (feeAmount - feeToStakers) | |
895 | 935 | let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)]) | |
921 | 961 | else paused()) | |
922 | 962 | then throw("Invalid removeMargin parameters") | |
923 | 963 | else { | |
924 | - | let $ | |
925 | - | let oldPositionSize = $ | |
926 | - | let oldPositionMargin = $ | |
927 | - | let oldPositionOpenNotional = $ | |
928 | - | let oldPositionLstUpdCPF = $ | |
964 | + | let $t04406744219 = getPosition(toString(i.caller)) | |
965 | + | let oldPositionSize = $t04406744219._1 | |
966 | + | let oldPositionMargin = $t04406744219._2 | |
967 | + | let oldPositionOpenNotional = $t04406744219._3 | |
968 | + | let oldPositionLstUpdCPF = $t04406744219._4 | |
929 | 969 | let marginDelta = -(_amount) | |
930 | - | let $ | |
931 | - | let remainMargin = $ | |
932 | - | let badDebt = $ | |
970 | + | let $t04425644435 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
971 | + | let remainMargin = $t04425644435._1 | |
972 | + | let badDebt = $t04425644435._2 | |
933 | 973 | if ((badDebt != 0)) | |
934 | 974 | then throw("Invalid removed margin amount") | |
935 | 975 | else { | |
955 | 995 | else paused()) | |
956 | 996 | then throw("Invalid closePosition parameters") | |
957 | 997 | else { | |
958 | - | let $ | |
959 | - | let x1 = $ | |
960 | - | let positionBadDebt = $ | |
961 | - | let realizedPnl = $ | |
962 | - | let marginToVault = $ | |
963 | - | let quoteAssetReserveAfter = $ | |
964 | - | let baseAssetReserveAfter = $ | |
965 | - | let totalPositionSizeAfter = $ | |
966 | - | let cumulativeNotionalAfter = $ | |
967 | - | let openInterestNotionalAfter = $ | |
968 | - | let x2 = $ | |
969 | - | let totalLongAfter = $ | |
970 | - | let totalShortAfter = $ | |
998 | + | let $t04553145921 = internalClosePosition(toString(i.caller), true) | |
999 | + | let x1 = $t04553145921._1 | |
1000 | + | let positionBadDebt = $t04553145921._2 | |
1001 | + | let realizedPnl = $t04553145921._3 | |
1002 | + | let marginToVault = $t04553145921._4 | |
1003 | + | let quoteAssetReserveAfter = $t04553145921._5 | |
1004 | + | let baseAssetReserveAfter = $t04553145921._6 | |
1005 | + | let totalPositionSizeAfter = $t04553145921._7 | |
1006 | + | let cumulativeNotionalAfter = $t04553145921._8 | |
1007 | + | let openInterestNotionalAfter = $t04553145921._9 | |
1008 | + | let x2 = $t04553145921._10 | |
1009 | + | let totalLongAfter = $t04553145921._11 | |
1010 | + | let totalShortAfter = $t04553145921._12 | |
971 | 1011 | if ((positionBadDebt > 0)) | |
972 | 1012 | then throw("Unable to close position with bad debt") | |
973 | 1013 | else { | |
974 | 1014 | let withdrawAmount = abs(marginToVault) | |
975 | 1015 | let ammBalance = (cbalance() - withdrawAmount) | |
976 | - | let $ | |
1016 | + | let $t04613046272 = if ((0 > ammBalance)) | |
977 | 1017 | then $Tuple2(0, abs(ammBalance)) | |
978 | 1018 | else $Tuple2(ammBalance, 0) | |
979 | - | let ammNewBalance = $ | |
980 | - | let getFromInsurance = $ | |
1019 | + | let ammNewBalance = $t04613046272._1 | |
1020 | + | let getFromInsurance = $t04613046272._2 | |
981 | 1021 | let x = if ((getFromInsurance > 0)) | |
982 | 1022 | then { | |
983 | 1023 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil) | |
1021 | 1061 | then true | |
1022 | 1062 | else paused()) | |
1023 | 1063 | then throw("Unable to liquidate") | |
1024 | - | else { | |
1025 | - | let $t04532745750 = internalClosePosition(_trader, false) | |
1026 | - | let x1 = $t04532745750._1 | |
1027 | - | let badDebt = $t04532745750._2 | |
1028 | - | let x2 = $t04532745750._3 | |
1029 | - | let x3 = $t04532745750._4 | |
1030 | - | let quoteAssetReserveAfter = $t04532745750._5 | |
1031 | - | let baseAssetReserveAfter = $t04532745750._6 | |
1032 | - | let totalPositionSizeAfter = $t04532745750._7 | |
1033 | - | let cumulativeNotionalAfter = $t04532745750._8 | |
1034 | - | let openInterestNotionalAfter = $t04532745750._9 | |
1035 | - | let exchangedQuoteAssetAmount = $t04532745750._10 | |
1036 | - | let totalLongAfter = $t04532745750._11 | |
1037 | - | let totalShortAfter = $t04532745750._12 | |
1038 | - | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1039 | - | let feeToLiquidator = (liquidationPenalty / 2) | |
1040 | - | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1041 | - | let ammBalance = (cbalance() - liquidationPenalty) | |
1042 | - | let $t04614846283 = if ((0 > ammBalance)) | |
1043 | - | then $Tuple2(0, abs(ammBalance)) | |
1044 | - | else $Tuple2(ammBalance, 0) | |
1045 | - | let newAmmBalance = $t04614846283._1 | |
1046 | - | let takeFromInsurance = $t04614846283._2 | |
1047 | - | let x = if ((takeFromInsurance > 0)) | |
1048 | - | then { | |
1049 | - | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1050 | - | if ((withdrawInsurance == withdrawInsurance)) | |
1051 | - | then nil | |
1052 | - | else throw("Strict value is not equal to itself.") | |
1053 | - | } | |
1054 | - | else nil | |
1055 | - | if ((x == x)) | |
1056 | - | then { | |
1057 | - | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil) | |
1058 | - | if ((unstake == unstake)) | |
1059 | - | then { | |
1060 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1061 | - | if ((depositInsurance == depositInsurance)) | |
1062 | - | then { | |
1063 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1064 | - | if ((notifyNotional == notifyNotional)) | |
1065 | - | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1066 | - | else throw("Strict value is not equal to itself.") | |
1067 | - | } | |
1068 | - | else throw("Strict value is not equal to itself.") | |
1069 | - | } | |
1070 | - | else throw("Strict value is not equal to itself.") | |
1071 | - | } | |
1072 | - | else throw("Strict value is not equal to itself.") | |
1073 | - | } | |
1064 | + | else if (if (if ((spotMarginRatio > liquidationFeeRatio())) | |
1065 | + | then (partialLiquidationRatio() > 0) | |
1066 | + | else false) | |
1067 | + | then (DECIMAL_UNIT > partialLiquidationRatio()) | |
1068 | + | else false) | |
1069 | + | then { | |
1070 | + | let $t04837348523 = getPosition(_trader) | |
1071 | + | let oldPositionSize = $t04837348523._1 | |
1072 | + | let oldPositionMargin = $t04837348523._2 | |
1073 | + | let oldPositionOpenNotional = $t04837348523._3 | |
1074 | + | let oldPositionLstUpdCPF = $t04837348523._4 | |
1075 | + | let _direction = if ((oldPositionSize > 0)) | |
1076 | + | then DIR_SHORT | |
1077 | + | else DIR_LONG | |
1078 | + | let isAdd = (_direction == DIR_LONG) | |
1079 | + | let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize) | |
1080 | + | let $t04874848852 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1081 | + | let oldPositionNotional = $t04874848852._1 | |
1082 | + | let unrealizedPnl = $t04874848852._2 | |
1083 | + | let $t04886049150 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1084 | + | let exchangedPositionSize = $t04886049150._1 | |
1085 | + | let quoteAssetReserveAfter = $t04886049150._2 | |
1086 | + | let baseAssetReserveAfter = $t04886049150._3 | |
1087 | + | let totalPositionSizeAfter = $t04886049150._4 | |
1088 | + | let cumulativeNotionalAfter = $t04886049150._5 | |
1089 | + | let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize)) | |
1090 | + | let $t04925749490 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1091 | + | let remainMargin = $t04925749490._1 | |
1092 | + | let badDebt = $t04925749490._2 | |
1093 | + | let fundingPayment = $t04925749490._3 | |
1094 | + | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
1095 | + | let remainOpenNotional = if ((oldPositionSize > 0)) | |
1096 | + | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
1097 | + | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
1098 | + | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1099 | + | let feeToLiquidator = (liquidationPenalty / 2) | |
1100 | + | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1101 | + | let newPositionMargin = (remainMargin - liquidationPenalty) | |
1102 | + | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
1103 | + | let newPositionOpenNotional = abs(remainOpenNotional) | |
1104 | + | let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize) | |
1105 | + | let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount) | |
1106 | + | let ammBalance = (cbalance() - liquidationPenalty) | |
1107 | + | let $t05066350806 = if ((0 > ammBalance)) | |
1108 | + | then $Tuple2(0, abs(ammBalance)) | |
1109 | + | else $Tuple2(ammBalance, 0) | |
1110 | + | let newAmmBalance = $t05066350806._1 | |
1111 | + | let takeFromInsurance = $t05066350806._2 | |
1112 | + | let x = if ((takeFromInsurance > 0)) | |
1113 | + | then { | |
1114 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1115 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1116 | + | then nil | |
1117 | + | else throw("Strict value is not equal to itself.") | |
1118 | + | } | |
1119 | + | else nil | |
1120 | + | if ((x == x)) | |
1121 | + | then { | |
1122 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil) | |
1123 | + | if ((unstake == unstake)) | |
1124 | + | then { | |
1125 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1126 | + | if ((depositInsurance == depositInsurance)) | |
1127 | + | then { | |
1128 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1129 | + | if ((notifyNotional == notifyNotional)) | |
1130 | + | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1131 | + | then abs(exchangedPositionSize) | |
1132 | + | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1133 | + | then abs(exchangedPositionSize) | |
1134 | + | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1135 | + | else throw("Strict value is not equal to itself.") | |
1136 | + | } | |
1137 | + | else throw("Strict value is not equal to itself.") | |
1138 | + | } | |
1139 | + | else throw("Strict value is not equal to itself.") | |
1140 | + | } | |
1141 | + | else throw("Strict value is not equal to itself.") | |
1142 | + | } | |
1143 | + | else { | |
1144 | + | let $t05226252717 = internalClosePosition(_trader, false) | |
1145 | + | let x1 = $t05226252717._1 | |
1146 | + | let badDebt = $t05226252717._2 | |
1147 | + | let x2 = $t05226252717._3 | |
1148 | + | let x3 = $t05226252717._4 | |
1149 | + | let quoteAssetReserveAfter = $t05226252717._5 | |
1150 | + | let baseAssetReserveAfter = $t05226252717._6 | |
1151 | + | let totalPositionSizeAfter = $t05226252717._7 | |
1152 | + | let cumulativeNotionalAfter = $t05226252717._8 | |
1153 | + | let openInterestNotionalAfter = $t05226252717._9 | |
1154 | + | let exchangedQuoteAssetAmount = $t05226252717._10 | |
1155 | + | let totalLongAfter = $t05226252717._11 | |
1156 | + | let totalShortAfter = $t05226252717._12 | |
1157 | + | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1158 | + | let feeToLiquidator = (liquidationPenalty / 2) | |
1159 | + | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1160 | + | let ammBalance = (cbalance() - liquidationPenalty) | |
1161 | + | let $t05312953272 = if ((0 > ammBalance)) | |
1162 | + | then $Tuple2(0, abs(ammBalance)) | |
1163 | + | else $Tuple2(ammBalance, 0) | |
1164 | + | let newAmmBalance = $t05312953272._1 | |
1165 | + | let takeFromInsurance = $t05312953272._2 | |
1166 | + | let x = if ((takeFromInsurance > 0)) | |
1167 | + | then { | |
1168 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1169 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1170 | + | then nil | |
1171 | + | else throw("Strict value is not equal to itself.") | |
1172 | + | } | |
1173 | + | else nil | |
1174 | + | if ((x == x)) | |
1175 | + | then { | |
1176 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil) | |
1177 | + | if ((unstake == unstake)) | |
1178 | + | then { | |
1179 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1180 | + | if ((depositInsurance == depositInsurance)) | |
1181 | + | then { | |
1182 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1183 | + | if ((notifyNotional == notifyNotional)) | |
1184 | + | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1185 | + | else throw("Strict value is not equal to itself.") | |
1186 | + | } | |
1187 | + | else throw("Strict value is not equal to itself.") | |
1188 | + | } | |
1189 | + | else throw("Strict value is not equal to itself.") | |
1190 | + | } | |
1191 | + | else throw("Strict value is not equal to itself.") | |
1192 | + | } | |
1074 | 1193 | } | |
1075 | 1194 | ||
1076 | 1195 | ||
1088 | 1207 | let underlyingPrice = getOracleTwapPrice() | |
1089 | 1208 | let spotTwapPrice = getTwapSpotPrice() | |
1090 | 1209 | let premium = (spotTwapPrice - underlyingPrice) | |
1091 | - | let $ | |
1210 | + | let $t05486056195 = if (if ((totalShortPositionSize() == 0)) | |
1092 | 1211 | then true | |
1093 | 1212 | else (totalLongPositionSize() == 0)) | |
1094 | 1213 | then $Tuple2(0, 0) | |
1103 | 1222 | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
1104 | 1223 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
1105 | 1224 | } | |
1106 | - | let shortPremiumFraction = $ | |
1107 | - | let longPremiumFraction = $ | |
1225 | + | let shortPremiumFraction = $t05486056195._1 | |
1226 | + | let longPremiumFraction = $t05486056195._2 | |
1108 | 1227 | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1109 | 1228 | } | |
1110 | 1229 | } | |
1113 | 1232 | ||
1114 | 1233 | @Callable(i) | |
1115 | 1234 | func v_get (_trader) = { | |
1116 | - | let $ | |
1117 | - | let x1 = $ | |
1118 | - | let x2 = $ | |
1119 | - | let x3 = $ | |
1120 | - | let x4 = $ | |
1235 | + | let $t05657056630 = internalClosePosition(_trader, false) | |
1236 | + | let x1 = $t05657056630._1 | |
1237 | + | let x2 = $t05657056630._2 | |
1238 | + | let x3 = $t05657056630._3 | |
1239 | + | let x4 = $t05657056630._4 | |
1121 | 1240 | throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader)))) | |
1122 | 1241 | } | |
1123 | 1242 | ||
1125 | 1244 | ||
1126 | 1245 | @Callable(i) | |
1127 | 1246 | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1128 | - | let $ | |
1129 | - | let positionSize = $ | |
1130 | - | let positionMargin = $ | |
1131 | - | let pon = $ | |
1132 | - | let positionLstUpdCPF = $ | |
1133 | - | let $ | |
1134 | - | let positionNotional = $ | |
1135 | - | let unrealizedPnl = $ | |
1136 | - | let $ | |
1137 | - | let remainMargin = $ | |
1138 | - | let badDebt = $ | |
1139 | - | let fundingPayment = $ | |
1140 | - | throw(((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt))) | |
1247 | + | let $t05677756888 = getPosition(_trader) | |
1248 | + | let positionSize = $t05677756888._1 | |
1249 | + | let positionMargin = $t05677756888._2 | |
1250 | + | let pon = $t05677756888._3 | |
1251 | + | let positionLstUpdCPF = $t05677756888._4 | |
1252 | + | let $t05689356994 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1253 | + | let positionNotional = $t05689356994._1 | |
1254 | + | let unrealizedPnl = $t05689356994._2 | |
1255 | + | let $t05699957181 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
1256 | + | let remainMargin = $t05699957181._1 | |
1257 | + | let badDebt = $t05699957181._2 | |
1258 | + | let fundingPayment = $t05699957181._3 | |
1259 | + | throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional))) | |
1141 | 1260 | } | |
1142 | 1261 | ||
1143 | 1262 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let k_ora_key = "k_ora_key" | |
5 | 5 | ||
6 | 6 | let k_ora_block_key = "k_ora_block_key" | |
7 | 7 | ||
8 | 8 | let k_ora = "k_ora" | |
9 | 9 | ||
10 | 10 | let k_balance = "k_balance" | |
11 | 11 | ||
12 | 12 | let k_positionSize = "k_positionSize" | |
13 | 13 | ||
14 | 14 | let k_positionMargin = "k_positionMargin" | |
15 | 15 | ||
16 | 16 | let k_positionOpenNotional = "k_positionOpenNotional" | |
17 | 17 | ||
18 | 18 | let k_positionLastUpdatedCumulativePremiumFraction = "k_positionFraction" | |
19 | 19 | ||
20 | 20 | let k_initialized = "k_initialized" | |
21 | 21 | ||
22 | 22 | let k_paused = "k_paused" | |
23 | 23 | ||
24 | 24 | let k_fee = "k_fee" | |
25 | 25 | ||
26 | 26 | let k_fundingPeriod = "k_fundingPeriod" | |
27 | 27 | ||
28 | 28 | let k_initMarginRatio = "k_initMarginRatio" | |
29 | 29 | ||
30 | 30 | let k_maintenanceMarginRatio = "k_mmr" | |
31 | 31 | ||
32 | 32 | let k_liquidationFeeRatio = "k_liquidationFeeRatio" | |
33 | 33 | ||
34 | + | let k_partialLiquidationRatio = "k_partLiquidationRatio" | |
35 | + | ||
34 | 36 | let k_spreadLimit = "k_spreadLimit" | |
35 | 37 | ||
36 | 38 | let k_maxPriceImpact = "k_maxPriceImpact" | |
39 | + | ||
40 | + | let k_maxPriceSpread = "k_maxPriceSpread" | |
37 | 41 | ||
38 | 42 | let k_lastDataStr = "k_lastDataStr" | |
39 | 43 | ||
40 | 44 | let k_lastMinuteId = "k_lastMinuteId" | |
41 | 45 | ||
42 | 46 | let k_twapDataLastCumulativePrice = "k_twapDataLastCumulativePrice" | |
43 | 47 | ||
44 | 48 | let k_twapDataLastPrice = "k_twapDataLastPrice" | |
45 | 49 | ||
46 | 50 | let k_twapDataPreviousMinuteId = "k_twapDataPreviousMinuteId" | |
47 | 51 | ||
48 | 52 | let k_latestLongCumulativePremiumFraction = "k_latestLongPremiumFraction" | |
49 | 53 | ||
50 | 54 | let k_latestShortCumulativePremiumFraction = "k_latestShortPremiumFraction" | |
51 | 55 | ||
52 | 56 | let k_nextFundingBlock = "k_nextFundingBlockMinTimestamp" | |
53 | 57 | ||
54 | 58 | let k_longFundingRate = "k_longFundingRate" | |
55 | 59 | ||
56 | 60 | let k_shortFundingRate = "k_shortFundingRate" | |
57 | 61 | ||
58 | 62 | let k_quoteAssetReserve = "k_qtAstR" | |
59 | 63 | ||
60 | 64 | let k_baseAssetReserve = "k_bsAstR" | |
61 | 65 | ||
62 | 66 | let k_totalPositionSize = "k_totalPositionSize" | |
63 | 67 | ||
64 | 68 | let k_totalLongPositionSize = "k_totalLongPositionSize" | |
65 | 69 | ||
66 | 70 | let k_totalShortPositionSize = "k_totalShortPositionSize" | |
67 | 71 | ||
68 | 72 | let k_cumulativeNotional = "k_cumulativeNotional" | |
69 | 73 | ||
70 | 74 | let k_openInterestNotional = "k_openInterestNotional" | |
71 | 75 | ||
72 | 76 | let k_coordinatorAddress = "k_coordinatorAddress" | |
73 | 77 | ||
74 | 78 | let k_insurance_address = "k_insurance_address" | |
75 | 79 | ||
76 | 80 | let k_admin_address = "k_admin_address" | |
77 | 81 | ||
78 | 82 | let k_admin_public_key = "k_admin_public_key" | |
79 | 83 | ||
80 | 84 | let k_quote_asset = "k_quote_asset" | |
81 | 85 | ||
82 | 86 | let k_quote_staking = "k_quote_staking" | |
83 | 87 | ||
84 | 88 | let k_staking_address = "k_staking_address" | |
85 | 89 | ||
86 | 90 | let k_miner_address = "k_miner_address" | |
87 | 91 | ||
88 | 92 | func coordinator () = valueOrErrorMessage(addressFromString(getStringValue(this, k_coordinatorAddress)), "Coordinator not set") | |
89 | 93 | ||
90 | 94 | ||
91 | 95 | func adminAddress () = addressFromString(getStringValue(coordinator(), k_admin_address)) | |
92 | 96 | ||
93 | 97 | ||
94 | 98 | func adminPublicKey () = fromBase58String(getStringValue(coordinator(), k_admin_public_key)) | |
95 | 99 | ||
96 | 100 | ||
97 | 101 | func quoteAsset () = fromBase58String(getStringValue(coordinator(), k_quote_asset)) | |
98 | 102 | ||
99 | 103 | ||
100 | 104 | func quoteAssetStaking () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_quote_staking)), "Quote asset staking not set") | |
101 | 105 | ||
102 | 106 | ||
103 | 107 | func stakingAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_staking_address)), "Insurance not set") | |
104 | 108 | ||
105 | 109 | ||
106 | 110 | func insuranceAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_insurance_address)), "Insurance not set") | |
107 | 111 | ||
108 | 112 | ||
109 | 113 | func minerAddress () = valueOrErrorMessage(addressFromString(getStringValue(coordinator(), k_miner_address)), "Insurance not set") | |
110 | 114 | ||
111 | 115 | ||
112 | 116 | let DIR_LONG = 1 | |
113 | 117 | ||
114 | 118 | let DIR_SHORT = 2 | |
115 | 119 | ||
116 | 120 | let TWAP_INTERVAL = 15 | |
117 | 121 | ||
118 | 122 | let ORACLE_INTERVAL = 15 | |
119 | 123 | ||
120 | 124 | let SECONDS = 1000 | |
121 | 125 | ||
122 | 126 | let DECIMAL_UNIT = (1 * (((((10 * 10) * 10) * 10) * 10) * 10)) | |
123 | 127 | ||
124 | 128 | let ONE_DAY = (86400 * DECIMAL_UNIT) | |
125 | 129 | ||
126 | 130 | let ALL_FEES = 100 | |
127 | 131 | ||
128 | 132 | let PNL_OPTION_SPOT = 1 | |
129 | 133 | ||
130 | 134 | let PNL_OPTION_ORACLE = 2 | |
131 | 135 | ||
132 | 136 | func s (_x) = (toString(_x) + ",") | |
133 | 137 | ||
134 | 138 | ||
135 | 139 | func divd (_x,_y) = fraction(_x, DECIMAL_UNIT, _y, HALFEVEN) | |
136 | 140 | ||
137 | 141 | ||
138 | 142 | func muld (_x,_y) = fraction(_x, _y, DECIMAL_UNIT, HALFEVEN) | |
139 | 143 | ||
140 | 144 | ||
141 | 145 | func abs (_x) = if ((_x > 0)) | |
142 | 146 | then _x | |
143 | 147 | else -(_x) | |
144 | 148 | ||
145 | 149 | ||
146 | 150 | func vmax (_x,_y) = if ((_x >= _y)) | |
147 | 151 | then _x | |
148 | 152 | else _y | |
149 | 153 | ||
150 | 154 | ||
151 | 155 | func toCompositeKey (_key,_address) = ((_key + "_") + _address) | |
152 | 156 | ||
153 | 157 | ||
154 | 158 | func listToStr (_list) = { | |
155 | 159 | func _join (accumulator,val) = ((accumulator + val) + ",") | |
156 | 160 | ||
157 | 161 | let newListStr = { | |
158 | 162 | let $l = _list | |
159 | 163 | let $s = size($l) | |
160 | 164 | let $acc0 = "" | |
161 | 165 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
162 | 166 | then $a | |
163 | 167 | else _join($a, $l[$i]) | |
164 | 168 | ||
165 | 169 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
166 | 170 | then $a | |
167 | 171 | else throw("List size exceeds 20") | |
168 | 172 | ||
169 | 173 | $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) | |
170 | 174 | } | |
171 | 175 | let newListStrU = dropRight(newListStr, 1) | |
172 | 176 | let newListStrR = if ((take(newListStrU, 1) == ",")) | |
173 | 177 | then drop(newListStrU, 1) | |
174 | 178 | else newListStrU | |
175 | 179 | newListStrR | |
176 | 180 | } | |
177 | 181 | ||
178 | 182 | ||
179 | 183 | func strToList (_str) = split(_str, ",") | |
180 | 184 | ||
181 | 185 | ||
182 | 186 | func pushToQueue (_list,_maxSize,_value) = if ((size(_list) > _maxSize)) | |
183 | 187 | then (removeByIndex(_list, 0) :+ _value) | |
184 | 188 | else (_list :+ _value) | |
185 | 189 | ||
186 | 190 | ||
187 | 191 | func int (k) = valueOrErrorMessage(getInteger(this, k), ("no value for " + k)) | |
188 | 192 | ||
189 | 193 | ||
190 | 194 | func cbalance () = int(k_balance) | |
191 | 195 | ||
192 | 196 | ||
193 | 197 | func fee () = int(k_fee) | |
194 | 198 | ||
195 | 199 | ||
196 | 200 | func initMarginRatio () = int(k_initMarginRatio) | |
197 | 201 | ||
198 | 202 | ||
199 | 203 | func qtAstR () = int(k_quoteAssetReserve) | |
200 | 204 | ||
201 | 205 | ||
202 | 206 | func bsAstR () = int(k_baseAssetReserve) | |
203 | 207 | ||
204 | 208 | ||
205 | 209 | func totalPositionSize () = int(k_totalPositionSize) | |
206 | 210 | ||
207 | 211 | ||
208 | 212 | func cumulativeNotional () = int(k_cumulativeNotional) | |
209 | 213 | ||
210 | 214 | ||
211 | 215 | func openInterestNotional () = int(k_openInterestNotional) | |
212 | 216 | ||
213 | 217 | ||
214 | 218 | func nextFundingBlockTimestamp () = int(k_nextFundingBlock) | |
215 | 219 | ||
216 | 220 | ||
217 | 221 | func fundingPeriodRaw () = int(k_fundingPeriod) | |
218 | 222 | ||
219 | 223 | ||
220 | 224 | func fundingPeriodDecimal () = (fundingPeriodRaw() * DECIMAL_UNIT) | |
221 | 225 | ||
222 | 226 | ||
223 | 227 | func fundingPeriodSeconds () = (fundingPeriodRaw() * SECONDS) | |
224 | 228 | ||
225 | 229 | ||
226 | 230 | func maintenanceMarginRatio () = int(k_maintenanceMarginRatio) | |
227 | 231 | ||
228 | 232 | ||
229 | 233 | func liquidationFeeRatio () = int(k_liquidationFeeRatio) | |
230 | 234 | ||
231 | 235 | ||
236 | + | func partialLiquidationRatio () = int(k_partialLiquidationRatio) | |
237 | + | ||
238 | + | ||
232 | 239 | func spreadLimit () = int(k_spreadLimit) | |
233 | 240 | ||
234 | 241 | ||
235 | 242 | func maxPriceImpact () = int(k_maxPriceImpact) | |
243 | + | ||
244 | + | ||
245 | + | func maxPriceSpread () = int(k_maxPriceSpread) | |
236 | 246 | ||
237 | 247 | ||
238 | 248 | func latestLongCumulativePremiumFraction () = int(k_latestLongCumulativePremiumFraction) | |
239 | 249 | ||
240 | 250 | ||
241 | 251 | func latestShortCumulativePremiumFraction () = int(k_latestShortCumulativePremiumFraction) | |
242 | 252 | ||
243 | 253 | ||
244 | 254 | func totalShortPositionSize () = int(k_totalShortPositionSize) | |
245 | 255 | ||
246 | 256 | ||
247 | 257 | func totalLongPositionSize () = int(k_totalLongPositionSize) | |
248 | 258 | ||
249 | 259 | ||
250 | 260 | func requireMoreMarginRatio (_marginRatio,_baseMarginRatio,_largerThanOrEqualTo) = { | |
251 | 261 | let remainingMarginRatio = (_marginRatio - _baseMarginRatio) | |
252 | 262 | if (if (_largerThanOrEqualTo) | |
253 | 263 | then (0 > remainingMarginRatio) | |
254 | 264 | else false) | |
255 | 265 | then throw("Invalid margin") | |
256 | 266 | else if (if (!(_largerThanOrEqualTo)) | |
257 | 267 | then (remainingMarginRatio >= 0) | |
258 | 268 | else false) | |
259 | 269 | then throw("Invalid margin") | |
260 | 270 | else true | |
261 | 271 | } | |
262 | 272 | ||
263 | 273 | ||
264 | 274 | func latestCumulativePremiumFraction (_positionSize) = if ((_positionSize == 0)) | |
265 | 275 | then throw("Should not be called with _positionSize == 0") | |
266 | 276 | else if ((_positionSize > 0)) | |
267 | 277 | then latestLongCumulativePremiumFraction() | |
268 | 278 | else latestShortCumulativePremiumFraction() | |
269 | 279 | ||
270 | 280 | ||
271 | 281 | func getPosition (_trader) = { | |
272 | 282 | let positionSizeOpt = getInteger(this, toCompositeKey(k_positionSize, _trader)) | |
273 | 283 | match positionSizeOpt { | |
274 | 284 | case positionSize: Int => | |
275 | 285 | $Tuple4(positionSize, getIntegerValue(this, toCompositeKey(k_positionMargin, _trader)), getIntegerValue(this, toCompositeKey(k_positionOpenNotional, _trader)), getIntegerValue(this, toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _trader))) | |
276 | 286 | case _ => | |
277 | 287 | $Tuple4(0, 0, 0, 0) | |
278 | 288 | } | |
279 | 289 | } | |
280 | 290 | ||
281 | 291 | ||
282 | 292 | func requireOpenPosition (_trader) = if ((getPosition(_trader)._1 == 0)) | |
283 | 293 | then throw("No open position") | |
284 | 294 | else true | |
285 | 295 | ||
286 | 296 | ||
287 | 297 | func initialized () = valueOrElse(getBoolean(this, k_initialized), false) | |
288 | 298 | ||
289 | 299 | ||
290 | 300 | func paused () = valueOrElse(getBoolean(this, k_paused), false) | |
291 | 301 | ||
292 | 302 | ||
293 | 303 | func updateReserve (_isAdd,_quoteAssetAmount,_baseAssetAmount) = if (_isAdd) | |
294 | 304 | then { | |
295 | 305 | let newBase = (bsAstR() - _baseAssetAmount) | |
296 | 306 | if ((0 >= newBase)) | |
297 | 307 | then throw("Tx lead to base asset reserve <= 0, revert") | |
298 | 308 | else $Tuple4((qtAstR() + _quoteAssetAmount), newBase, (totalPositionSize() + _baseAssetAmount), (cumulativeNotional() + _quoteAssetAmount)) | |
299 | 309 | } | |
300 | 310 | else { | |
301 | 311 | let newQuote = (qtAstR() - _quoteAssetAmount) | |
302 | 312 | if ((0 >= newQuote)) | |
303 | 313 | then throw("Tx lead to base quote reserve <= 0, revert") | |
304 | 314 | else $Tuple4(newQuote, (bsAstR() + _baseAssetAmount), (totalPositionSize() - _baseAssetAmount), (cumulativeNotional() - _quoteAssetAmount)) | |
305 | 315 | } | |
306 | 316 | ||
307 | 317 | ||
308 | 318 | func swapInput (_isAdd,_quoteAssetAmount) = { | |
309 | 319 | let _qtAstR = qtAstR() | |
310 | 320 | let _bsAstR = bsAstR() | |
311 | 321 | let k = muld(_qtAstR, _bsAstR) | |
312 | 322 | let quoteAssetReserveAfter = if (_isAdd) | |
313 | 323 | then (_qtAstR + _quoteAssetAmount) | |
314 | 324 | else (_qtAstR - _quoteAssetAmount) | |
315 | 325 | let baseAssetReserveAfter = divd(k, quoteAssetReserveAfter) | |
316 | 326 | let amountBaseAssetBoughtAbs = abs((baseAssetReserveAfter - _bsAstR)) | |
317 | 327 | let amountBaseAssetBought = if (_isAdd) | |
318 | 328 | then amountBaseAssetBoughtAbs | |
319 | 329 | else -(amountBaseAssetBoughtAbs) | |
320 | - | let $ | |
321 | - | let quoteAssetReserveAfter1 = $ | |
322 | - | let baseAssetReserveAfter1 = $ | |
323 | - | let totalPositionSizeAfter1 = $ | |
324 | - | let cumulativeNotionalAfter1 = $ | |
330 | + | let $t01217712370 = updateReserve(_isAdd, _quoteAssetAmount, amountBaseAssetBoughtAbs) | |
331 | + | let quoteAssetReserveAfter1 = $t01217712370._1 | |
332 | + | let baseAssetReserveAfter1 = $t01217712370._2 | |
333 | + | let totalPositionSizeAfter1 = $t01217712370._3 | |
334 | + | let cumulativeNotionalAfter1 = $t01217712370._4 | |
325 | 335 | let priceBefore = divd(_qtAstR, _bsAstR) | |
326 | 336 | let marketPrice = divd(_quoteAssetAmount, amountBaseAssetBoughtAbs) | |
327 | 337 | let priceDiff = abs((priceBefore - marketPrice)) | |
328 | 338 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
329 | 339 | let maxPriceImpactValue = maxPriceImpact() | |
330 | 340 | if ((priceImpact > maxPriceImpactValue)) | |
331 | 341 | 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))) | |
332 | 342 | else $Tuple5(amountBaseAssetBought, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1) | |
333 | 343 | } | |
334 | 344 | ||
335 | 345 | ||
336 | 346 | func calcRemainMarginWithFundingPayment (_oldPositionSize,_oldPositionMargin,_oldPositionCumulativePremiumFraction,_marginDelta) = { | |
337 | 347 | let fundingPayment = if ((_oldPositionSize != 0)) | |
338 | 348 | then { | |
339 | 349 | let _latestCumulativePremiumFraction = latestCumulativePremiumFraction(_oldPositionSize) | |
340 | 350 | muld((_latestCumulativePremiumFraction - _oldPositionCumulativePremiumFraction), _oldPositionSize) | |
341 | 351 | } | |
342 | 352 | else 0 | |
343 | 353 | let signedMargin = ((_marginDelta - fundingPayment) + _oldPositionMargin) | |
344 | - | let $ | |
354 | + | let $t01386113988 = if ((0 > signedMargin)) | |
345 | 355 | then $Tuple2(0, abs(signedMargin)) | |
346 | 356 | else $Tuple2(abs(signedMargin), 0) | |
347 | - | let remainMargin = $ | |
348 | - | let badDebt = $ | |
357 | + | let remainMargin = $t01386113988._1 | |
358 | + | let badDebt = $t01386113988._2 | |
349 | 359 | $Tuple3(remainMargin, badDebt, fundingPayment) | |
350 | 360 | } | |
351 | 361 | ||
352 | 362 | ||
353 | - | func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = { | |
354 | - | let _quoteAssetReserve = qtAstR() | |
355 | - | let _baseAssetReserve = bsAstR() | |
363 | + | func swapOutputWithReserves (_isAdd,_baseAssetAmount,_checkMaxPriceImpact,_quoteAssetReserve,_baseAssetReserve) = { | |
356 | 364 | let priceBefore = divd(_quoteAssetReserve, _baseAssetReserve) | |
357 | 365 | if ((_baseAssetAmount == 0)) | |
358 | 366 | then throw("Invalid base asset amount") | |
359 | 367 | else { | |
360 | 368 | let k = muld(_quoteAssetReserve, _baseAssetReserve) | |
361 | 369 | let baseAssetPoolAmountAfter = if (_isAdd) | |
362 | 370 | then (_baseAssetReserve + _baseAssetAmount) | |
363 | 371 | else (_baseAssetReserve - _baseAssetAmount) | |
364 | 372 | let quoteAssetAfter = divd(k, baseAssetPoolAmountAfter) | |
365 | 373 | let quoteAssetSold = abs((quoteAssetAfter - _quoteAssetReserve)) | |
366 | 374 | let maxPriceImpactValue = maxPriceImpact() | |
367 | - | let $ | |
368 | - | let quoteAssetReserveAfter1 = $ | |
369 | - | let baseAssetReserveAfter1 = $ | |
370 | - | let totalPositionSizeAfter1 = $ | |
371 | - | let cumulativeNotionalAfter1 = $ | |
375 | + | let $t01496515158 = updateReserve(!(_isAdd), quoteAssetSold, _baseAssetAmount) | |
376 | + | let quoteAssetReserveAfter1 = $t01496515158._1 | |
377 | + | let baseAssetReserveAfter1 = $t01496515158._2 | |
378 | + | let totalPositionSizeAfter1 = $t01496515158._3 | |
379 | + | let cumulativeNotionalAfter1 = $t01496515158._4 | |
372 | 380 | let marketPrice = divd(quoteAssetSold, _baseAssetAmount) | |
373 | 381 | let priceDiff = abs((priceBefore - marketPrice)) | |
374 | 382 | let priceImpact = (DECIMAL_UNIT - divd(priceBefore, (priceBefore + priceDiff))) | |
375 | 383 | if (if ((priceImpact > maxPriceImpactValue)) | |
376 | 384 | then _checkMaxPriceImpact | |
377 | 385 | else false) | |
378 | 386 | then throw(((((((((((((("Price impact " + toString(priceImpact)) + " > max price impact ") + toString(maxPriceImpactValue)) + " before quote asset: ") + toString(_quoteAssetReserve)) + " before base asset: ") + toString(_baseAssetReserve)) + " base asset amount to exchange: ") + toString(_baseAssetAmount)) + " price before: ") + toString(priceBefore)) + " market price: ") + toString(marketPrice))) | |
379 | - | else $ | |
387 | + | else $Tuple8(quoteAssetSold, quoteAssetReserveAfter1, baseAssetReserveAfter1, totalPositionSizeAfter1, cumulativeNotionalAfter1, (totalLongPositionSize() - (if (_isAdd) | |
380 | 388 | then abs(_baseAssetAmount) | |
381 | 389 | else 0)), (totalShortPositionSize() - (if (!(_isAdd)) | |
382 | 390 | then abs(_baseAssetAmount) | |
383 | - | else 0))) | |
391 | + | else 0)), priceImpact) | |
384 | 392 | } | |
385 | 393 | } | |
394 | + | ||
395 | + | ||
396 | + | func swapOutput (_isAdd,_baseAssetAmount,_checkMaxPriceImpact) = swapOutputWithReserves(_isAdd, _baseAssetAmount, _checkMaxPriceImpact, qtAstR(), bsAstR()) | |
386 | 397 | ||
387 | 398 | ||
388 | 399 | func getOracleTwapPrice () = { | |
389 | 400 | let oracle = valueOrErrorMessage(addressFromString(getStringValue(this, k_ora)), "") | |
390 | 401 | let priceKey = getStringValue(this, k_ora_key) | |
391 | 402 | let blockKey = getStringValue(this, k_ora_block_key) | |
392 | 403 | let lastValue = valueOrErrorMessage(getInteger(oracle, priceKey), ((("Can not get oracle price. Oracle: " + toString(oracle)) + " key: ") + priceKey)) | |
393 | 404 | lastValue | |
405 | + | } | |
406 | + | ||
407 | + | ||
408 | + | func requireNotOverSpreadLimit (_quoteAssetReserve,_baseAssetReserve) = { | |
409 | + | let oraclePrice = getOracleTwapPrice() | |
410 | + | let priceAfter = divd(_quoteAssetReserve, _baseAssetReserve) | |
411 | + | let averagePrice = divd((oraclePrice + priceAfter), (2 * DECIMAL_UNIT)) | |
412 | + | let absPriceDiff = divd(abs((oraclePrice - priceAfter)), averagePrice) | |
413 | + | if ((absPriceDiff > maxPriceSpread())) | |
414 | + | then throw(((("Price spread " + toString(absPriceDiff)) + " > max price spread ") + toString(maxPriceSpread()))) | |
415 | + | else true | |
394 | 416 | } | |
395 | 417 | ||
396 | 418 | ||
397 | 419 | func getSpotPrice () = { | |
398 | 420 | let _quoteAssetReserve = qtAstR() | |
399 | 421 | let _baseAssetReserve = bsAstR() | |
400 | 422 | divd(_quoteAssetReserve, _baseAssetReserve) | |
401 | 423 | } | |
402 | 424 | ||
403 | 425 | ||
404 | 426 | func isOverFluctuationLimit () = { | |
405 | 427 | let oraclePrice = getOracleTwapPrice() | |
406 | 428 | let currentPrice = getSpotPrice() | |
407 | 429 | (divd(abs((oraclePrice - currentPrice)), oraclePrice) > spreadLimit()) | |
408 | 430 | } | |
409 | 431 | ||
410 | 432 | ||
433 | + | func getPositionAdjustedOpenNotional (_positionSize,_option,_quoteAssetReserve,_baseAssetReserve) = { | |
434 | + | let positionSizeAbs = abs(_positionSize) | |
435 | + | let isShort = (0 > _positionSize) | |
436 | + | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
437 | + | then { | |
438 | + | let $t01837618547 = swapOutputWithReserves(!(isShort), positionSizeAbs, false, _quoteAssetReserve, _baseAssetReserve) | |
439 | + | let outPositionNotional = $t01837618547._1 | |
440 | + | let x1 = $t01837618547._2 | |
441 | + | let x2 = $t01837618547._3 | |
442 | + | let x3 = $t01837618547._4 | |
443 | + | outPositionNotional | |
444 | + | } | |
445 | + | else muld(positionSizeAbs, getOracleTwapPrice()) | |
446 | + | positionNotional | |
447 | + | } | |
448 | + | ||
449 | + | ||
411 | 450 | func getPositionNotionalAndUnrealizedPnl (_trader,_option) = { | |
412 | - | let $t01729317421 = getPosition(_trader) | |
413 | - | let positionSize = $t01729317421._1 | |
414 | - | let positionMargin = $t01729317421._2 | |
415 | - | let positionOpenNotional = $t01729317421._3 | |
416 | - | let positionLstUpdCPF = $t01729317421._4 | |
417 | - | let positionSizeAbs = abs(positionSize) | |
418 | - | if ((positionSizeAbs == 0)) | |
451 | + | let $t01894119069 = getPosition(_trader) | |
452 | + | let positionSize = $t01894119069._1 | |
453 | + | let positionMargin = $t01894119069._2 | |
454 | + | let positionOpenNotional = $t01894119069._3 | |
455 | + | let positionLstUpdCPF = $t01894119069._4 | |
456 | + | if ((positionSize == 0)) | |
419 | 457 | then throw("Invalid position size") | |
420 | 458 | else { | |
421 | 459 | let isShort = (0 > positionSize) | |
422 | - | let positionNotional = if ((_option == PNL_OPTION_SPOT)) | |
423 | - | then { | |
424 | - | let $t01766817792 = swapOutput(!(isShort), positionSizeAbs, false) | |
425 | - | let outPositionNotional = $t01766817792._1 | |
426 | - | let x1 = $t01766817792._2 | |
427 | - | let x2 = $t01766817792._3 | |
428 | - | let x3 = $t01766817792._4 | |
429 | - | outPositionNotional | |
430 | - | } | |
431 | - | else muld(positionSizeAbs, getOracleTwapPrice()) | |
460 | + | let positionNotional = getPositionAdjustedOpenNotional(positionSize, _option, qtAstR(), bsAstR()) | |
432 | 461 | let unrealizedPnl = if (isShort) | |
433 | 462 | then (positionOpenNotional - positionNotional) | |
434 | 463 | else (positionNotional - positionOpenNotional) | |
435 | 464 | $Tuple2(positionNotional, unrealizedPnl) | |
436 | 465 | } | |
437 | 466 | } | |
438 | 467 | ||
439 | 468 | ||
440 | 469 | func calcMarginRatio (_remainMargin,_badDebt,_positionNotional) = divd((_remainMargin - _badDebt), _positionNotional) | |
441 | 470 | ||
442 | 471 | ||
443 | 472 | func getMarginRatioByOption (_trader,_option) = { | |
444 | - | let $ | |
445 | - | let positionSize = $ | |
446 | - | let positionMargin = $ | |
447 | - | let pon = $ | |
448 | - | let positionLstUpdCPF = $ | |
449 | - | let $ | |
450 | - | let positionNotional = $ | |
451 | - | let unrealizedPnl = $ | |
452 | - | let $ | |
453 | - | let remainMargin = $ | |
454 | - | let badDebt = $ | |
473 | + | let $t01990220013 = getPosition(_trader) | |
474 | + | let positionSize = $t01990220013._1 | |
475 | + | let positionMargin = $t01990220013._2 | |
476 | + | let pon = $t01990220013._3 | |
477 | + | let positionLstUpdCPF = $t01990220013._4 | |
478 | + | let $t02001920112 = getPositionNotionalAndUnrealizedPnl(_trader, _option) | |
479 | + | let positionNotional = $t02001920112._1 | |
480 | + | let unrealizedPnl = $t02001920112._2 | |
481 | + | let $t02011720283 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
482 | + | let remainMargin = $t02011720283._1 | |
483 | + | let badDebt = $t02011720283._2 | |
455 | 484 | calcMarginRatio(remainMargin, badDebt, positionNotional) | |
456 | 485 | } | |
457 | 486 | ||
458 | 487 | ||
459 | 488 | func getMarginRatio (_trader) = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
460 | 489 | ||
461 | 490 | ||
491 | + | func getPartialLiquidationAmount (_trader,_positionSize) = { | |
492 | + | let maximumRatio = vmax(partialLiquidationRatio(), (DECIMAL_UNIT - divd(getMarginRatio(_trader), maintenanceMarginRatio()))) | |
493 | + | let maxExchangedPositionSize = muld(abs(_positionSize), maximumRatio) | |
494 | + | let swapResult = swapOutput((_positionSize > 0), maxExchangedPositionSize, false) | |
495 | + | let maxExchangedQuoteAssetAmount = swapResult._1 | |
496 | + | let priceImpact = swapResult._8 | |
497 | + | if ((maxPriceImpact() > priceImpact)) | |
498 | + | then maxExchangedQuoteAssetAmount | |
499 | + | else { | |
500 | + | let exchangedPositionSize = muld(abs(_positionSize), partialLiquidationRatio()) | |
501 | + | let exchangedQuoteAssetAmount = swapOutput((_positionSize > 0), exchangedPositionSize, false)._1 | |
502 | + | exchangedQuoteAssetAmount | |
503 | + | } | |
504 | + | } | |
505 | + | ||
506 | + | ||
462 | 507 | func internalClosePosition (_trader,_checkMaxPriceImpact) = { | |
463 | - | let $t01919019318 = getPosition(_trader) | |
464 | - | let positionSize = $t01919019318._1 | |
465 | - | let positionMargin = $t01919019318._2 | |
466 | - | let positionOpenNotional = $t01919019318._3 | |
467 | - | let positionLstUpdCPF = $t01919019318._4 | |
468 | - | let $t01932419411 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
469 | - | let x1 = $t01932419411._1 | |
470 | - | let unrealizedPnl = $t01932419411._2 | |
471 | - | let $t01941619584 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
472 | - | let remainMargin = $t01941619584._1 | |
473 | - | let badDebt = $t01941619584._2 | |
508 | + | let $t02146521593 = getPosition(_trader) | |
509 | + | let positionSize = $t02146521593._1 | |
510 | + | let positionMargin = $t02146521593._2 | |
511 | + | let positionOpenNotional = $t02146521593._3 | |
512 | + | let positionLstUpdCPF = $t02146521593._4 | |
513 | + | let unrealizedPnl = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT)._2 | |
514 | + | let $t02168821856 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
515 | + | let remainMargin = $t02168821856._1 | |
516 | + | let badDebt = $t02168821856._2 | |
474 | 517 | let exchangedPositionSize = -(positionSize) | |
475 | 518 | let realizedPnl = unrealizedPnl | |
476 | 519 | let marginToVault = -(remainMargin) | |
477 | - | let $ | |
478 | - | let exchangedQuoteAssetAmount = $ | |
479 | - | let quoteAssetReserveAfter = $ | |
480 | - | let baseAssetReserveAfter = $ | |
481 | - | let totalPositionSizeAfter = $ | |
482 | - | let cumulativeNotionalAfter = $ | |
483 | - | let totalLongAfter = $ | |
484 | - | let totalShortAfter = $ | |
520 | + | let $t02198322294 = swapOutput((positionSize > 0), abs(positionSize), _checkMaxPriceImpact) | |
521 | + | let exchangedQuoteAssetAmount = $t02198322294._1 | |
522 | + | let quoteAssetReserveAfter = $t02198322294._2 | |
523 | + | let baseAssetReserveAfter = $t02198322294._3 | |
524 | + | let totalPositionSizeAfter = $t02198322294._4 | |
525 | + | let cumulativeNotionalAfter = $t02198322294._5 | |
526 | + | let totalLongAfter = $t02198322294._6 | |
527 | + | let totalShortAfter = $t02198322294._7 | |
485 | 528 | let openInterestNotionalAfter = (openInterestNotional() - positionOpenNotional) | |
486 | 529 | $Tuple12(exchangedPositionSize, badDebt, realizedPnl, marginToVault, quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, exchangedQuoteAssetAmount, totalLongAfter, totalShortAfter) | |
487 | 530 | } | |
488 | 531 | ||
489 | 532 | ||
490 | 533 | func getTwapSpotPrice () = { | |
491 | 534 | let minuteId = ((lastBlock.timestamp / 1000) / 60) | |
492 | 535 | let startMinuteId = (minuteId - TWAP_INTERVAL) | |
493 | 536 | let listStr = valueOrElse(getString(this, k_lastDataStr), "") | |
494 | 537 | let list = split(listStr, ",") | |
495 | 538 | func filterFn (accumulator,next) = if ((startMinuteId >= parseIntValue(next))) | |
496 | 539 | then (accumulator :+ parseIntValue(next)) | |
497 | 540 | else accumulator | |
498 | 541 | ||
499 | 542 | let listF = { | |
500 | 543 | let $l = list | |
501 | 544 | let $s = size($l) | |
502 | 545 | let $acc0 = nil | |
503 | 546 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
504 | 547 | then $a | |
505 | 548 | else filterFn($a, $l[$i]) | |
506 | 549 | ||
507 | 550 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
508 | 551 | then $a | |
509 | 552 | else throw("List size exceeds 20") | |
510 | 553 | ||
511 | 554 | $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) | |
512 | 555 | } | |
513 | 556 | let maxIndex = if ((size(listF) > 0)) | |
514 | 557 | then max(listF) | |
515 | 558 | else parseIntValue(list[0]) | |
516 | 559 | let lastMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
517 | 560 | let endLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(lastMinuteId))), 0) | |
518 | 561 | let endLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(lastMinuteId))), 0) | |
519 | 562 | let nowCumulativePrice = (endLastCumulativePrice + ((minuteId - lastMinuteId) * endLastPrice)) | |
520 | 563 | let startLastCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(maxIndex))), 0) | |
521 | 564 | let startLastPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(maxIndex))), 0) | |
522 | 565 | let startCumulativePrice = (startLastCumulativePrice + ((startMinuteId - maxIndex) * startLastPrice)) | |
523 | 566 | ((nowCumulativePrice - startCumulativePrice) / TWAP_INTERVAL) | |
524 | 567 | } | |
525 | 568 | ||
526 | 569 | ||
527 | - | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact)] | |
570 | + | func updateSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = [IntegerEntry(k_initMarginRatio, _initMarginRatio), IntegerEntry(k_maintenanceMarginRatio, _mmr), IntegerEntry(k_liquidationFeeRatio, _liquidationFeeRatio), IntegerEntry(k_fundingPeriod, _fundingPeriod), IntegerEntry(k_fee, _fee), IntegerEntry(k_spreadLimit, _spreadLimit), IntegerEntry(k_maxPriceImpact, _maxPriceImpact), IntegerEntry(k_partialLiquidationRatio, _partialLiquidationRatio), IntegerEntry(k_maxPriceSpread, _maxPriceSpread)] | |
528 | 571 | ||
529 | 572 | ||
530 | 573 | 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)] | |
531 | 574 | ||
532 | 575 | ||
533 | 576 | 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)] | |
534 | 577 | ||
535 | 578 | ||
536 | 579 | func appendTwap (price) = { | |
537 | 580 | let minuteId = ((lastBlock.timestamp / 1000) / 60) | |
538 | 581 | let previousMinuteId = valueOrElse(getInteger(this, k_lastMinuteId), 0) | |
539 | 582 | if ((previousMinuteId > minuteId)) | |
540 | 583 | then throw("TWAP out-of-order") | |
541 | 584 | else { | |
542 | 585 | let lastMinuteId = if ((previousMinuteId == 0)) | |
543 | 586 | then minuteId | |
544 | 587 | else previousMinuteId | |
545 | 588 | if ((minuteId > previousMinuteId)) | |
546 | 589 | then { | |
547 | 590 | let prevCumulativePrice = valueOrElse(getInteger(this, ((k_twapDataLastCumulativePrice + "_") + toString(previousMinuteId))), 0) | |
548 | 591 | let prevPrice = valueOrElse(getInteger(this, ((k_twapDataLastPrice + "_") + toString(previousMinuteId))), price) | |
549 | 592 | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - lastMinuteId) * prevPrice)) | |
550 | 593 | let list = pushToQueue(strToList(valueOrElse(getString(this, k_lastDataStr), "")), TWAP_INTERVAL, toString(minuteId)) | |
551 | 594 | [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))] | |
552 | 595 | } | |
553 | 596 | else { | |
554 | 597 | let twapDataPreviousMinuteId = valueOrElse(getInteger(this, toCompositeKey(k_twapDataPreviousMinuteId, toString(minuteId))), 0) | |
555 | 598 | let prevCumulativePrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastCumulativePrice, toString(twapDataPreviousMinuteId))), 0) | |
556 | 599 | let prevPrice = valueOrElse(getInteger(this, toCompositeKey(k_twapDataLastPrice, toString(twapDataPreviousMinuteId))), price) | |
557 | 600 | let lastCumulativePrice = (prevCumulativePrice + ((minuteId - twapDataPreviousMinuteId) * prevPrice)) | |
558 | 601 | [IntegerEntry(toCompositeKey(k_twapDataLastCumulativePrice, toString(minuteId)), lastCumulativePrice), IntegerEntry(toCompositeKey(k_twapDataLastPrice, toString(minuteId)), price)] | |
559 | 602 | } | |
560 | 603 | } | |
561 | 604 | } | |
562 | 605 | ||
563 | 606 | ||
564 | 607 | func updateAmmReserves (_qtAstR,_bsAstR) = [IntegerEntry(k_quoteAssetReserve, _qtAstR), IntegerEntry(k_baseAssetReserve, _bsAstR)] | |
565 | 608 | ||
566 | 609 | ||
567 | 610 | func updateAmm (_qtAstR,_bsAstR,_totalPositionSizeAfter,_cumulativeNotionalAfter,_openInterestNotional,_totalLongPositionSize,_totalShortPositionSize) = if (((_totalLongPositionSize - _totalShortPositionSize) != _totalPositionSizeAfter)) | |
568 | 611 | then throw(((((("Invalid AMM state data: " + toString(_totalLongPositionSize)) + " + ") + toString(_totalShortPositionSize)) + " != ") + toString(_totalPositionSizeAfter))) | |
569 | 612 | else ((updateAmmReserves(_qtAstR, _bsAstR) ++ [IntegerEntry(k_totalPositionSize, _totalPositionSizeAfter), IntegerEntry(k_cumulativeNotional, _cumulativeNotionalAfter), IntegerEntry(k_openInterestNotional, _openInterestNotional), IntegerEntry(k_totalLongPositionSize, _totalLongPositionSize), IntegerEntry(k_totalShortPositionSize, _totalShortPositionSize)]) ++ appendTwap(divd(_qtAstR, _bsAstR))) | |
570 | 613 | ||
571 | 614 | ||
572 | 615 | func deletePosition (_address) = [DeleteEntry(toCompositeKey(k_positionSize, _address)), DeleteEntry(toCompositeKey(k_positionMargin, _address)), DeleteEntry(toCompositeKey(k_positionOpenNotional, _address)), DeleteEntry(toCompositeKey(k_positionLastUpdatedCumulativePremiumFraction, _address))] | |
573 | 616 | ||
574 | 617 | ||
575 | 618 | func withdraw (_address,_amount) = { | |
576 | 619 | let balance = assetBalance(this, quoteAsset()) | |
577 | 620 | if ((_amount > balance)) | |
578 | 621 | then throw(((("Unable to withdraw " + toString(_amount)) + " from contract balance ") + toString(balance))) | |
579 | 622 | else [ScriptTransfer(_address, _amount, quoteAsset())] | |
580 | 623 | } | |
581 | 624 | ||
582 | 625 | ||
583 | 626 | func updateBalance (i) = if ((0 > i)) | |
584 | 627 | then throw("Balance") | |
585 | 628 | else [IntegerEntry(k_balance, i)] | |
586 | 629 | ||
587 | 630 | ||
588 | 631 | func transferFee (i) = [ScriptTransfer(stakingAddress(), i, quoteAsset())] | |
589 | 632 | ||
590 | 633 | ||
591 | 634 | @Callable(i) | |
592 | 635 | func pause () = if ((i.caller != adminAddress())) | |
593 | 636 | then throw("Invalid togglePause params") | |
594 | 637 | else [BooleanEntry(k_paused, true)] | |
595 | 638 | ||
596 | 639 | ||
597 | 640 | ||
598 | 641 | @Callable(i) | |
599 | 642 | func unpause () = if ((i.caller != adminAddress())) | |
600 | 643 | then throw("Invalid togglePause params") | |
601 | 644 | else [BooleanEntry(k_paused, false)] | |
602 | 645 | ||
603 | 646 | ||
604 | 647 | ||
605 | 648 | @Callable(i) | |
606 | 649 | func addLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress())) | |
607 | 650 | then true | |
608 | 651 | else (0 >= _quoteAssetAmount)) | |
609 | 652 | then throw("Invalid addLiquidity params") | |
610 | 653 | else { | |
611 | 654 | let _qtAstR = qtAstR() | |
612 | 655 | let _bsAstR = bsAstR() | |
613 | 656 | let price = divd(_qtAstR, _bsAstR) | |
614 | 657 | let baseAssetAmountToAdd = divd(_quoteAssetAmount, price) | |
615 | 658 | let qtAstRAfter = (_qtAstR + _quoteAssetAmount) | |
616 | 659 | let bsAstRAfter = (_bsAstR + baseAssetAmountToAdd) | |
617 | 660 | updateAmmReserves(qtAstRAfter, bsAstRAfter) | |
618 | 661 | } | |
619 | 662 | ||
620 | 663 | ||
621 | 664 | ||
622 | 665 | @Callable(i) | |
623 | 666 | func removeLiquidity (_quoteAssetAmount) = if (if ((i.caller != adminAddress())) | |
624 | 667 | then true | |
625 | 668 | else (0 >= _quoteAssetAmount)) | |
626 | 669 | then throw("Invalid removeLiquidity params") | |
627 | 670 | else { | |
628 | 671 | let _qtAstR = qtAstR() | |
629 | 672 | let _bsAstR = bsAstR() | |
630 | 673 | let price = divd(_qtAstR, _bsAstR) | |
631 | 674 | let baseAssetAmountToRemove = divd(_quoteAssetAmount, price) | |
632 | 675 | let qtAstRAfter = (_qtAstR - _quoteAssetAmount) | |
633 | 676 | let bsAstRAfter = (_bsAstR - baseAssetAmountToRemove) | |
634 | 677 | updateAmmReserves(qtAstRAfter, bsAstRAfter) | |
635 | 678 | } | |
636 | 679 | ||
637 | 680 | ||
638 | 681 | ||
639 | 682 | @Callable(i) | |
640 | - | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact) = if ((i.caller != adminAddress())) | |
683 | + | func changeSettings (_initMarginRatio,_mmr,_liquidationFeeRatio,_fundingPeriod,_fee,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if ((i.caller != adminAddress())) | |
641 | 684 | then throw("Invalid changeSettings params") | |
642 | - | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact) | |
685 | + | else updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread) | |
643 | 686 | ||
644 | 687 | ||
645 | 688 | ||
646 | 689 | @Callable(i) | |
647 | - | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact) = if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
690 | + | func initialize (_qtAstR,_bsAstR,_fundingPeriod,_initMarginRatio,_mmr,_liquidationFeeRatio,_fee,_oracle,_oracleKey,_coordinator,_spreadLimit,_maxPriceImpact,_partialLiquidationRatio,_maxPriceSpread) = if (if (if (if (if (if (if (if (if (if (if (if ((0 >= _qtAstR)) | |
648 | 691 | then true | |
649 | 692 | else (0 >= _bsAstR)) | |
650 | 693 | then true | |
651 | 694 | else (0 >= _fundingPeriod)) | |
652 | 695 | then true | |
653 | 696 | else (0 >= _initMarginRatio)) | |
654 | 697 | then true | |
655 | 698 | else (0 >= _mmr)) | |
656 | 699 | then true | |
657 | 700 | else (0 >= _liquidationFeeRatio)) | |
658 | 701 | then true | |
659 | 702 | else (0 >= _fee)) | |
660 | 703 | then true | |
661 | 704 | else (0 >= _spreadLimit)) | |
662 | 705 | then true | |
663 | 706 | else (0 >= _maxPriceImpact)) | |
664 | 707 | then true | |
708 | + | else (0 >= _partialLiquidationRatio)) | |
709 | + | then true | |
710 | + | else (0 >= _maxPriceSpread)) | |
711 | + | then true | |
665 | 712 | else initialized()) | |
666 | 713 | then throw("Invalid initialize parameters") | |
667 | - | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)]) | |
668 | - | ||
669 | - | ||
670 | - | ||
671 | - | @Callable(i) | |
672 | - | func setMaxPriceImpact (_maxPriceImpact) = if (if ((0 >= _maxPriceImpact)) | |
673 | - | then true | |
674 | - | else !(initialized())) | |
675 | - | then throw("Invalid _maxPriceImpact parameters") | |
676 | - | else updateSettings(initMarginRatio(), maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), _maxPriceImpact) | |
714 | + | else ((((updateAmm(_qtAstR, _bsAstR, 0, 0, 0, 0, 0) ++ updateSettings(_initMarginRatio, _mmr, _liquidationFeeRatio, _fundingPeriod, _fee, _spreadLimit, _maxPriceImpact, _partialLiquidationRatio, _maxPriceSpread)) ++ updateFunding((lastBlock.timestamp + _fundingPeriod), 0, 0, 0, 0)) ++ updateBalance(0)) ++ [BooleanEntry(k_initialized, true), StringEntry(k_ora, _oracle), StringEntry(k_ora_key, _oracleKey), StringEntry(k_coordinatorAddress, _coordinator)]) | |
677 | 715 | ||
678 | 716 | ||
679 | 717 | ||
680 | 718 | @Callable(i) | |
681 | 719 | func setInitMarginRatio (_initMarginRatio) = if (if ((0 >= _initMarginRatio)) | |
682 | 720 | then true | |
683 | 721 | else !(initialized())) | |
684 | 722 | then throw("Invalid setInitMarginRatio parameters") | |
685 | - | else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact()) | |
723 | + | else updateSettings(_initMarginRatio, maintenanceMarginRatio(), liquidationFeeRatio(), fundingPeriodRaw(), fee(), spreadLimit(), maxPriceImpact(), partialLiquidationRatio(), maxPriceSpread()) | |
686 | 724 | ||
687 | 725 | ||
688 | 726 | ||
689 | 727 | @Callable(i) | |
690 | 728 | func decreasePosition (_amount,_leverage,_minBaseAssetAmount) = if (if (if (if (if ((0 >= _amount)) | |
691 | 729 | then true | |
692 | 730 | else !(initialized())) | |
693 | 731 | then true | |
694 | 732 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
695 | 733 | then true | |
696 | 734 | else !(requireOpenPosition(toString(i.caller)))) | |
697 | 735 | then true | |
698 | 736 | else paused()) | |
699 | 737 | then throw("Invalid decreasePosition parameters") | |
700 | 738 | else { | |
701 | - | let $ | |
702 | - | let oldPositionSize = $ | |
703 | - | let oldPositionMargin = $ | |
704 | - | let oldPositionOpenNotional = $ | |
705 | - | let oldPositionLstUpdCPF = $ | |
739 | + | let $t03418734339 = getPosition(toString(i.caller)) | |
740 | + | let oldPositionSize = $t03418734339._1 | |
741 | + | let oldPositionMargin = $t03418734339._2 | |
742 | + | let oldPositionOpenNotional = $t03418734339._3 | |
743 | + | let oldPositionLstUpdCPF = $t03418734339._4 | |
706 | 744 | let _direction = if ((oldPositionSize > 0)) | |
707 | 745 | then DIR_SHORT | |
708 | 746 | else DIR_LONG | |
709 | 747 | let isAdd = (_direction == DIR_LONG) | |
710 | 748 | let openNotional = muld(_amount, _leverage) | |
711 | - | let $ | |
712 | - | let oldPositionNotional = $ | |
713 | - | let unrealizedPnl = $ | |
714 | - | let $ | |
749 | + | let $t03451234628 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
750 | + | let oldPositionNotional = $t03451234628._1 | |
751 | + | let unrealizedPnl = $t03451234628._2 | |
752 | + | let $t03463437183 = if ((oldPositionNotional > openNotional)) | |
715 | 753 | then { | |
716 | - | let $ | |
717 | - | let exchangedPositionSize = $ | |
718 | - | let quoteAssetReserveAfter = $ | |
719 | - | let baseAssetReserveAfter = $ | |
720 | - | let totalPositionSizeAfter = $ | |
721 | - | let cumulativeNotionalAfter = $ | |
754 | + | let $t03501135230 = swapInput(isAdd, openNotional) | |
755 | + | let exchangedPositionSize = $t03501135230._1 | |
756 | + | let quoteAssetReserveAfter = $t03501135230._2 | |
757 | + | let baseAssetReserveAfter = $t03501135230._3 | |
758 | + | let totalPositionSizeAfter = $t03501135230._4 | |
759 | + | let cumulativeNotionalAfter = $t03501135230._5 | |
722 | 760 | let exchangedPositionSizeAbs = abs(exchangedPositionSize) | |
723 | 761 | if (if ((_minBaseAssetAmount != 0)) | |
724 | 762 | then (_minBaseAssetAmount > exchangedPositionSizeAbs) | |
725 | 763 | else false) | |
726 | 764 | then throw(((("Too little base asset exchanged, got " + toString(exchangedPositionSizeAbs)) + " expected ") + toString(_minBaseAssetAmount))) | |
727 | 765 | else { | |
728 | 766 | let realizedPnl = divd(muld(unrealizedPnl, exchangedPositionSizeAbs), abs(oldPositionSize)) | |
729 | - | let $ | |
730 | - | let remainMargin = $ | |
731 | - | let badDebt = $ | |
732 | - | let fundingPayment = $ | |
767 | + | let $t03566735912 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
768 | + | let remainMargin = $t03566735912._1 | |
769 | + | let badDebt = $t03566735912._2 | |
770 | + | let fundingPayment = $t03566735912._3 | |
733 | 771 | let exchangedQuoteAssetAmount = openNotional | |
734 | 772 | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
735 | 773 | let remainOpenNotional = if ((oldPositionSize > 0)) | |
736 | 774 | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
737 | 775 | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
738 | 776 | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
739 | 777 | $Tuple11(newPositionSize, remainMargin, abs(remainOpenNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() - openNotional), (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
740 | 778 | then abs(exchangedPositionSize) | |
741 | 779 | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
742 | 780 | then abs(exchangedPositionSize) | |
743 | 781 | else 0))) | |
744 | 782 | } | |
745 | 783 | } | |
746 | 784 | else throw("Close position first") | |
747 | - | let newPositionSize = $ | |
748 | - | let newPositionRemainMargin = $ | |
749 | - | let newPositionOpenNotional = $ | |
750 | - | let newPositionLatestCPF = $ | |
751 | - | let baseAssetReserveAfter = $ | |
752 | - | let quoteAssetReserveAfter = $ | |
753 | - | let totalPositionSizeAfter = $ | |
754 | - | let cumulativeNotionalAfter = $ | |
755 | - | let openInterestNotionalAfter = $ | |
756 | - | let totalLongAfter = $ | |
757 | - | let totalShortAfter = $ | |
785 | + | let newPositionSize = $t03463437183._1 | |
786 | + | let newPositionRemainMargin = $t03463437183._2 | |
787 | + | let newPositionOpenNotional = $t03463437183._3 | |
788 | + | let newPositionLatestCPF = $t03463437183._4 | |
789 | + | let baseAssetReserveAfter = $t03463437183._5 | |
790 | + | let quoteAssetReserveAfter = $t03463437183._6 | |
791 | + | let totalPositionSizeAfter = $t03463437183._7 | |
792 | + | let cumulativeNotionalAfter = $t03463437183._8 | |
793 | + | let openInterestNotionalAfter = $t03463437183._9 | |
794 | + | let totalLongAfter = $t03463437183._10 | |
795 | + | let totalShortAfter = $t03463437183._11 | |
758 | 796 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
759 | 797 | if ((notifyNotional == notifyNotional)) | |
760 | 798 | then (updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) | |
761 | 799 | else throw("Strict value is not equal to itself.") | |
762 | 800 | } | |
763 | 801 | ||
764 | 802 | ||
765 | 803 | ||
766 | 804 | @Callable(i) | |
767 | 805 | func increasePosition (_direction,_leverage,_minBaseAssetAmount) = { | |
768 | 806 | let _rawAmount = i.payments[0].amount | |
769 | 807 | if (if (if (if (if (if (if ((_direction != DIR_LONG)) | |
770 | 808 | then (_direction != DIR_SHORT) | |
771 | 809 | else false) | |
772 | 810 | then true | |
773 | 811 | else (0 >= _rawAmount)) | |
774 | 812 | then true | |
775 | 813 | else !(initialized())) | |
776 | 814 | then true | |
777 | 815 | else (i.payments[0].assetId != quoteAsset())) | |
778 | 816 | then true | |
779 | 817 | else !(requireMoreMarginRatio(divd(DECIMAL_UNIT, _leverage), initMarginRatio(), true))) | |
780 | 818 | then true | |
781 | 819 | else paused()) | |
782 | 820 | then throw("Invalid increasePosition parameters") | |
783 | 821 | else { | |
784 | 822 | let feeAmount = muld(_rawAmount, fee()) | |
785 | 823 | let _amount = (_rawAmount - feeAmount) | |
786 | - | let $ | |
787 | - | let oldPositionSize = $ | |
788 | - | let oldPositionMargin = $ | |
789 | - | let oldPositionOpenNotional = $ | |
790 | - | let oldPositionLstUpdCPF = $ | |
824 | + | let $t03830138453 = getPosition(toString(i.caller)) | |
825 | + | let oldPositionSize = $t03830138453._1 | |
826 | + | let oldPositionMargin = $t03830138453._2 | |
827 | + | let oldPositionOpenNotional = $t03830138453._3 | |
828 | + | let oldPositionLstUpdCPF = $t03830138453._4 | |
791 | 829 | let isNewPosition = (oldPositionSize == 0) | |
792 | 830 | let isSameDirection = if ((oldPositionSize > 0)) | |
793 | 831 | then (_direction == DIR_LONG) | |
794 | 832 | else (_direction == DIR_SHORT) | |
795 | 833 | let expandExisting = if (!(isNewPosition)) | |
796 | 834 | then isSameDirection | |
797 | 835 | else false | |
798 | 836 | let isAdd = (_direction == DIR_LONG) | |
799 | - | let $ | |
837 | + | let $t03874241310 = if (if (isNewPosition) | |
800 | 838 | then true | |
801 | 839 | else expandExisting) | |
802 | 840 | then { | |
803 | 841 | let openNotional = muld(_amount, _leverage) | |
804 | - | let $ | |
805 | - | let amountBaseAssetBought = $ | |
806 | - | let quoteAssetReserveAfter = $ | |
807 | - | let baseAssetReserveAfter = $ | |
808 | - | let totalPositionSizeAfter = $ | |
809 | - | let cumulativeNotionalAfter = $ | |
842 | + | let $t03916639372 = swapInput(isAdd, openNotional) | |
843 | + | let amountBaseAssetBought = $t03916639372._1 | |
844 | + | let quoteAssetReserveAfter = $t03916639372._2 | |
845 | + | let baseAssetReserveAfter = $t03916639372._3 | |
846 | + | let totalPositionSizeAfter = $t03916639372._4 | |
847 | + | let cumulativeNotionalAfter = $t03916639372._5 | |
810 | 848 | if (if ((_minBaseAssetAmount != 0)) | |
811 | 849 | then (_minBaseAssetAmount > abs(amountBaseAssetBought)) | |
812 | 850 | else false) | |
813 | 851 | then throw(((("Limit error: " + toString(abs(amountBaseAssetBought))) + " < ") + toString(_minBaseAssetAmount))) | |
814 | 852 | else { | |
815 | 853 | let newPositionSize = (oldPositionSize + amountBaseAssetBought) | |
816 | 854 | let increaseMarginRequirement = divd(openNotional, _leverage) | |
817 | - | let $t03729737536 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
818 | - | let remainMargin = $t03729737536._1 | |
819 | - | let x1 = $t03729737536._2 | |
820 | - | let x2 = $t03729737536._3 | |
821 | - | $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
822 | - | then abs(amountBaseAssetBought) | |
823 | - | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
824 | - | then abs(amountBaseAssetBought) | |
825 | - | else 0))) | |
855 | + | let $t03975339992 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, increaseMarginRequirement) | |
856 | + | let remainMargin = $t03975339992._1 | |
857 | + | let x1 = $t03975339992._2 | |
858 | + | let x2 = $t03975339992._3 | |
859 | + | if (!(requireNotOverSpreadLimit(quoteAssetReserveAfter, baseAssetReserveAfter))) | |
860 | + | then throw("Over max spread limit") | |
861 | + | else $Tuple11(newPositionSize, remainMargin, (oldPositionOpenNotional + openNotional), latestCumulativePremiumFraction(newPositionSize), baseAssetReserveAfter, quoteAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, (openInterestNotional() + openNotional), (totalLongPositionSize() + (if ((newPositionSize > 0)) | |
862 | + | then abs(amountBaseAssetBought) | |
863 | + | else 0)), (totalShortPositionSize() + (if ((0 > newPositionSize)) | |
864 | + | then abs(amountBaseAssetBought) | |
865 | + | else 0))) | |
826 | 866 | } | |
827 | 867 | } | |
828 | 868 | else { | |
829 | 869 | let openNotional = muld(_amount, _leverage) | |
830 | - | let $ | |
831 | - | let oldPositionNotional = $ | |
832 | - | let unrealizedPnl = $ | |
870 | + | let $t04100341119 = getPositionNotionalAndUnrealizedPnl(toString(i.caller), PNL_OPTION_SPOT) | |
871 | + | let oldPositionNotional = $t04100341119._1 | |
872 | + | let unrealizedPnl = $t04100341119._2 | |
833 | 873 | if ((oldPositionNotional > openNotional)) | |
834 | 874 | then throw("Use decreasePosition to decrease position size") | |
835 | 875 | else throw("Close position first") | |
836 | 876 | } | |
837 | - | let newPositionSize = $ | |
838 | - | let newPositionRemainMargin = $ | |
839 | - | let newPositionOpenNotional = $ | |
840 | - | let newPositionLatestCPF = $ | |
841 | - | let baseAssetReserveAfter = $ | |
842 | - | let quoteAssetReserveAfter = $ | |
843 | - | let totalPositionSizeAfter = $ | |
844 | - | let cumulativeNotionalAfter = $ | |
845 | - | let openInterestNotionalAfter = $ | |
846 | - | let totalLongAfter = $ | |
847 | - | let totalShortAfter = $ | |
877 | + | let newPositionSize = $t03874241310._1 | |
878 | + | let newPositionRemainMargin = $t03874241310._2 | |
879 | + | let newPositionOpenNotional = $t03874241310._3 | |
880 | + | let newPositionLatestCPF = $t03874241310._4 | |
881 | + | let baseAssetReserveAfter = $t03874241310._5 | |
882 | + | let quoteAssetReserveAfter = $t03874241310._6 | |
883 | + | let totalPositionSizeAfter = $t03874241310._7 | |
884 | + | let cumulativeNotionalAfter = $t03874241310._8 | |
885 | + | let openInterestNotionalAfter = $t03874241310._9 | |
886 | + | let totalLongAfter = $t03874241310._10 | |
887 | + | let totalShortAfter = $t03874241310._11 | |
848 | 888 | let feeToStakers = (feeAmount / 2) | |
849 | 889 | let feeToInsurance = (feeAmount - feeToStakers) | |
850 | 890 | let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)]) | |
851 | 891 | if ((stake == stake)) | |
852 | 892 | then { | |
853 | 893 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
854 | 894 | if ((depositInsurance == depositInsurance)) | |
855 | 895 | then { | |
856 | 896 | let notifyFee = invoke(minerAddress(), "notifyFees", [toString(i.caller), feeAmount], nil) | |
857 | 897 | if ((notifyFee == notifyFee)) | |
858 | 898 | then { | |
859 | 899 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), newPositionOpenNotional], nil) | |
860 | 900 | if ((notifyNotional == notifyNotional)) | |
861 | 901 | then (((updatePosition(toString(i.caller), newPositionSize, newPositionRemainMargin, newPositionOpenNotional, newPositionLatestCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
862 | 902 | else throw("Strict value is not equal to itself.") | |
863 | 903 | } | |
864 | 904 | else throw("Strict value is not equal to itself.") | |
865 | 905 | } | |
866 | 906 | else throw("Strict value is not equal to itself.") | |
867 | 907 | } | |
868 | 908 | else throw("Strict value is not equal to itself.") | |
869 | 909 | } | |
870 | 910 | } | |
871 | 911 | ||
872 | 912 | ||
873 | 913 | ||
874 | 914 | @Callable(i) | |
875 | 915 | func addMargin () = { | |
876 | 916 | let _rawAmount = i.payments[0].amount | |
877 | 917 | if (if (if (if ((i.payments[0].assetId != quoteAsset())) | |
878 | 918 | then true | |
879 | 919 | else !(requireOpenPosition(toString(i.caller)))) | |
880 | 920 | then true | |
881 | 921 | else !(initialized())) | |
882 | 922 | then true | |
883 | 923 | else paused()) | |
884 | 924 | then throw("Invalid addMargin parameters") | |
885 | 925 | else { | |
886 | 926 | let feeAmount = muld(_rawAmount, fee()) | |
887 | 927 | let _amount = (_rawAmount - feeAmount) | |
888 | - | let $ | |
889 | - | let oldPositionSize = $ | |
890 | - | let oldPositionMargin = $ | |
891 | - | let oldPositionOpenNotional = $ | |
892 | - | let oldPositionLstUpdCPF = $ | |
928 | + | let $t04286643018 = getPosition(toString(i.caller)) | |
929 | + | let oldPositionSize = $t04286643018._1 | |
930 | + | let oldPositionMargin = $t04286643018._2 | |
931 | + | let oldPositionOpenNotional = $t04286643018._3 | |
932 | + | let oldPositionLstUpdCPF = $t04286643018._4 | |
893 | 933 | let feeToStakers = (feeAmount / 2) | |
894 | 934 | let feeToInsurance = (feeAmount - feeToStakers) | |
895 | 935 | let stake = invoke(quoteAssetStaking(), "lockNeutrinoSP", [toString(stakingAddress()), ALL_FEES], [AttachedPayment(quoteAsset(), _amount)]) | |
896 | 936 | if ((stake == stake)) | |
897 | 937 | then { | |
898 | 938 | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
899 | 939 | if ((depositInsurance == depositInsurance)) | |
900 | 940 | then { | |
901 | 941 | let notifyFee = invoke(minerAddress(), "notifyFees", [toString(i.caller), feeAmount], nil) | |
902 | 942 | if ((notifyFee == notifyFee)) | |
903 | 943 | then ((updatePosition(toString(i.caller), oldPositionSize, (oldPositionMargin + _amount), oldPositionOpenNotional, oldPositionLstUpdCPF) ++ transferFee(feeToStakers)) ++ updateBalance((cbalance() + _amount))) | |
904 | 944 | else throw("Strict value is not equal to itself.") | |
905 | 945 | } | |
906 | 946 | else throw("Strict value is not equal to itself.") | |
907 | 947 | } | |
908 | 948 | else throw("Strict value is not equal to itself.") | |
909 | 949 | } | |
910 | 950 | } | |
911 | 951 | ||
912 | 952 | ||
913 | 953 | ||
914 | 954 | @Callable(i) | |
915 | 955 | func removeMargin (_amount) = if (if (if (if ((0 >= _amount)) | |
916 | 956 | then true | |
917 | 957 | else !(requireOpenPosition(toString(i.caller)))) | |
918 | 958 | then true | |
919 | 959 | else !(initialized())) | |
920 | 960 | then true | |
921 | 961 | else paused()) | |
922 | 962 | then throw("Invalid removeMargin parameters") | |
923 | 963 | else { | |
924 | - | let $ | |
925 | - | let oldPositionSize = $ | |
926 | - | let oldPositionMargin = $ | |
927 | - | let oldPositionOpenNotional = $ | |
928 | - | let oldPositionLstUpdCPF = $ | |
964 | + | let $t04406744219 = getPosition(toString(i.caller)) | |
965 | + | let oldPositionSize = $t04406744219._1 | |
966 | + | let oldPositionMargin = $t04406744219._2 | |
967 | + | let oldPositionOpenNotional = $t04406744219._3 | |
968 | + | let oldPositionLstUpdCPF = $t04406744219._4 | |
929 | 969 | let marginDelta = -(_amount) | |
930 | - | let $ | |
931 | - | let remainMargin = $ | |
932 | - | let badDebt = $ | |
970 | + | let $t04425644435 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, marginDelta) | |
971 | + | let remainMargin = $t04425644435._1 | |
972 | + | let badDebt = $t04425644435._2 | |
933 | 973 | if ((badDebt != 0)) | |
934 | 974 | then throw("Invalid removed margin amount") | |
935 | 975 | else { | |
936 | 976 | let marginRatio = calcMarginRatio(remainMargin, badDebt, oldPositionOpenNotional) | |
937 | 977 | if (!(requireMoreMarginRatio(marginRatio, initMarginRatio(), true))) | |
938 | 978 | then throw(((("Too much margin removed: " + toString(marginRatio)) + " < ") + toString(initMarginRatio()))) | |
939 | 979 | else { | |
940 | 980 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [_amount, toBase58String(quoteAsset())], nil) | |
941 | 981 | if ((unstake == unstake)) | |
942 | 982 | then ((updatePosition(toString(i.caller), oldPositionSize, remainMargin, oldPositionOpenNotional, latestCumulativePremiumFraction(oldPositionSize)) ++ withdraw(i.caller, _amount)) ++ updateBalance((cbalance() - _amount))) | |
943 | 983 | else throw("Strict value is not equal to itself.") | |
944 | 984 | } | |
945 | 985 | } | |
946 | 986 | } | |
947 | 987 | ||
948 | 988 | ||
949 | 989 | ||
950 | 990 | @Callable(i) | |
951 | 991 | func closePosition () = if (if (if (!(requireOpenPosition(toString(i.caller)))) | |
952 | 992 | then true | |
953 | 993 | else !(initialized())) | |
954 | 994 | then true | |
955 | 995 | else paused()) | |
956 | 996 | then throw("Invalid closePosition parameters") | |
957 | 997 | else { | |
958 | - | let $ | |
959 | - | let x1 = $ | |
960 | - | let positionBadDebt = $ | |
961 | - | let realizedPnl = $ | |
962 | - | let marginToVault = $ | |
963 | - | let quoteAssetReserveAfter = $ | |
964 | - | let baseAssetReserveAfter = $ | |
965 | - | let totalPositionSizeAfter = $ | |
966 | - | let cumulativeNotionalAfter = $ | |
967 | - | let openInterestNotionalAfter = $ | |
968 | - | let x2 = $ | |
969 | - | let totalLongAfter = $ | |
970 | - | let totalShortAfter = $ | |
998 | + | let $t04553145921 = internalClosePosition(toString(i.caller), true) | |
999 | + | let x1 = $t04553145921._1 | |
1000 | + | let positionBadDebt = $t04553145921._2 | |
1001 | + | let realizedPnl = $t04553145921._3 | |
1002 | + | let marginToVault = $t04553145921._4 | |
1003 | + | let quoteAssetReserveAfter = $t04553145921._5 | |
1004 | + | let baseAssetReserveAfter = $t04553145921._6 | |
1005 | + | let totalPositionSizeAfter = $t04553145921._7 | |
1006 | + | let cumulativeNotionalAfter = $t04553145921._8 | |
1007 | + | let openInterestNotionalAfter = $t04553145921._9 | |
1008 | + | let x2 = $t04553145921._10 | |
1009 | + | let totalLongAfter = $t04553145921._11 | |
1010 | + | let totalShortAfter = $t04553145921._12 | |
971 | 1011 | if ((positionBadDebt > 0)) | |
972 | 1012 | then throw("Unable to close position with bad debt") | |
973 | 1013 | else { | |
974 | 1014 | let withdrawAmount = abs(marginToVault) | |
975 | 1015 | let ammBalance = (cbalance() - withdrawAmount) | |
976 | - | let $ | |
1016 | + | let $t04613046272 = if ((0 > ammBalance)) | |
977 | 1017 | then $Tuple2(0, abs(ammBalance)) | |
978 | 1018 | else $Tuple2(ammBalance, 0) | |
979 | - | let ammNewBalance = $ | |
980 | - | let getFromInsurance = $ | |
1019 | + | let ammNewBalance = $t04613046272._1 | |
1020 | + | let getFromInsurance = $t04613046272._2 | |
981 | 1021 | let x = if ((getFromInsurance > 0)) | |
982 | 1022 | then { | |
983 | 1023 | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [getFromInsurance], nil) | |
984 | 1024 | if ((withdrawInsurance == withdrawInsurance)) | |
985 | 1025 | then nil | |
986 | 1026 | else throw("Strict value is not equal to itself.") | |
987 | 1027 | } | |
988 | 1028 | else nil | |
989 | 1029 | if ((x == x)) | |
990 | 1030 | then { | |
991 | 1031 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(withdrawAmount - getFromInsurance), toBase58String(quoteAsset())], nil) | |
992 | 1032 | if ((unstake == unstake)) | |
993 | 1033 | then { | |
994 | 1034 | let notifyNotional = invoke(minerAddress(), "notifyNotional", [toString(i.caller), 0], nil) | |
995 | 1035 | if ((notifyNotional == notifyNotional)) | |
996 | 1036 | then (((deletePosition(toString(i.caller)) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, withdrawAmount)) ++ updateBalance(ammNewBalance)) | |
997 | 1037 | else throw("Strict value is not equal to itself.") | |
998 | 1038 | } | |
999 | 1039 | else throw("Strict value is not equal to itself.") | |
1000 | 1040 | } | |
1001 | 1041 | else throw("Strict value is not equal to itself.") | |
1002 | 1042 | } | |
1003 | 1043 | } | |
1004 | 1044 | ||
1005 | 1045 | ||
1006 | 1046 | ||
1007 | 1047 | @Callable(i) | |
1008 | 1048 | func liquidate (_trader) = { | |
1009 | 1049 | let spotMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_SPOT) | |
1010 | 1050 | let marginRatio = if (isOverFluctuationLimit()) | |
1011 | 1051 | then { | |
1012 | 1052 | let oracleMarginRatio = getMarginRatioByOption(_trader, PNL_OPTION_ORACLE) | |
1013 | 1053 | vmax(spotMarginRatio, oracleMarginRatio) | |
1014 | 1054 | } | |
1015 | 1055 | else spotMarginRatio | |
1016 | 1056 | if (if (if (if (!(requireMoreMarginRatio(marginRatio, maintenanceMarginRatio(), false))) | |
1017 | 1057 | then true | |
1018 | 1058 | else !(requireOpenPosition(_trader))) | |
1019 | 1059 | then true | |
1020 | 1060 | else !(initialized())) | |
1021 | 1061 | then true | |
1022 | 1062 | else paused()) | |
1023 | 1063 | then throw("Unable to liquidate") | |
1024 | - | else { | |
1025 | - | let $t04532745750 = internalClosePosition(_trader, false) | |
1026 | - | let x1 = $t04532745750._1 | |
1027 | - | let badDebt = $t04532745750._2 | |
1028 | - | let x2 = $t04532745750._3 | |
1029 | - | let x3 = $t04532745750._4 | |
1030 | - | let quoteAssetReserveAfter = $t04532745750._5 | |
1031 | - | let baseAssetReserveAfter = $t04532745750._6 | |
1032 | - | let totalPositionSizeAfter = $t04532745750._7 | |
1033 | - | let cumulativeNotionalAfter = $t04532745750._8 | |
1034 | - | let openInterestNotionalAfter = $t04532745750._9 | |
1035 | - | let exchangedQuoteAssetAmount = $t04532745750._10 | |
1036 | - | let totalLongAfter = $t04532745750._11 | |
1037 | - | let totalShortAfter = $t04532745750._12 | |
1038 | - | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1039 | - | let feeToLiquidator = (liquidationPenalty / 2) | |
1040 | - | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1041 | - | let ammBalance = (cbalance() - liquidationPenalty) | |
1042 | - | let $t04614846283 = if ((0 > ammBalance)) | |
1043 | - | then $Tuple2(0, abs(ammBalance)) | |
1044 | - | else $Tuple2(ammBalance, 0) | |
1045 | - | let newAmmBalance = $t04614846283._1 | |
1046 | - | let takeFromInsurance = $t04614846283._2 | |
1047 | - | let x = if ((takeFromInsurance > 0)) | |
1048 | - | then { | |
1049 | - | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1050 | - | if ((withdrawInsurance == withdrawInsurance)) | |
1051 | - | then nil | |
1052 | - | else throw("Strict value is not equal to itself.") | |
1053 | - | } | |
1054 | - | else nil | |
1055 | - | if ((x == x)) | |
1056 | - | then { | |
1057 | - | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil) | |
1058 | - | if ((unstake == unstake)) | |
1059 | - | then { | |
1060 | - | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1061 | - | if ((depositInsurance == depositInsurance)) | |
1062 | - | then { | |
1063 | - | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1064 | - | if ((notifyNotional == notifyNotional)) | |
1065 | - | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1066 | - | else throw("Strict value is not equal to itself.") | |
1067 | - | } | |
1068 | - | else throw("Strict value is not equal to itself.") | |
1069 | - | } | |
1070 | - | else throw("Strict value is not equal to itself.") | |
1071 | - | } | |
1072 | - | else throw("Strict value is not equal to itself.") | |
1073 | - | } | |
1064 | + | else if (if (if ((spotMarginRatio > liquidationFeeRatio())) | |
1065 | + | then (partialLiquidationRatio() > 0) | |
1066 | + | else false) | |
1067 | + | then (DECIMAL_UNIT > partialLiquidationRatio()) | |
1068 | + | else false) | |
1069 | + | then { | |
1070 | + | let $t04837348523 = getPosition(_trader) | |
1071 | + | let oldPositionSize = $t04837348523._1 | |
1072 | + | let oldPositionMargin = $t04837348523._2 | |
1073 | + | let oldPositionOpenNotional = $t04837348523._3 | |
1074 | + | let oldPositionLstUpdCPF = $t04837348523._4 | |
1075 | + | let _direction = if ((oldPositionSize > 0)) | |
1076 | + | then DIR_SHORT | |
1077 | + | else DIR_LONG | |
1078 | + | let isAdd = (_direction == DIR_LONG) | |
1079 | + | let exchangedQuoteAssetAmount = getPartialLiquidationAmount(_trader, oldPositionSize) | |
1080 | + | let $t04874848852 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1081 | + | let oldPositionNotional = $t04874848852._1 | |
1082 | + | let unrealizedPnl = $t04874848852._2 | |
1083 | + | let $t04886049150 = swapInput(isAdd, exchangedQuoteAssetAmount) | |
1084 | + | let exchangedPositionSize = $t04886049150._1 | |
1085 | + | let quoteAssetReserveAfter = $t04886049150._2 | |
1086 | + | let baseAssetReserveAfter = $t04886049150._3 | |
1087 | + | let totalPositionSizeAfter = $t04886049150._4 | |
1088 | + | let cumulativeNotionalAfter = $t04886049150._5 | |
1089 | + | let realizedPnl = divd(muld(unrealizedPnl, abs(exchangedPositionSize)), abs(oldPositionSize)) | |
1090 | + | let $t04925749490 = calcRemainMarginWithFundingPayment(oldPositionSize, oldPositionMargin, oldPositionLstUpdCPF, realizedPnl) | |
1091 | + | let remainMargin = $t04925749490._1 | |
1092 | + | let badDebt = $t04925749490._2 | |
1093 | + | let fundingPayment = $t04925749490._3 | |
1094 | + | let unrealizedPnlAfter = (unrealizedPnl - realizedPnl) | |
1095 | + | let remainOpenNotional = if ((oldPositionSize > 0)) | |
1096 | + | then ((oldPositionNotional - exchangedQuoteAssetAmount) - unrealizedPnlAfter) | |
1097 | + | else ((unrealizedPnlAfter + oldPositionNotional) - exchangedQuoteAssetAmount) | |
1098 | + | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1099 | + | let feeToLiquidator = (liquidationPenalty / 2) | |
1100 | + | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1101 | + | let newPositionMargin = (remainMargin - liquidationPenalty) | |
1102 | + | let newPositionSize = (oldPositionSize + exchangedPositionSize) | |
1103 | + | let newPositionOpenNotional = abs(remainOpenNotional) | |
1104 | + | let newPositionLstUpdCPF = latestCumulativePremiumFraction(newPositionSize) | |
1105 | + | let openInterestNotionalAfter = (openInterestNotional() - exchangedQuoteAssetAmount) | |
1106 | + | let ammBalance = (cbalance() - liquidationPenalty) | |
1107 | + | let $t05066350806 = if ((0 > ammBalance)) | |
1108 | + | then $Tuple2(0, abs(ammBalance)) | |
1109 | + | else $Tuple2(ammBalance, 0) | |
1110 | + | let newAmmBalance = $t05066350806._1 | |
1111 | + | let takeFromInsurance = $t05066350806._2 | |
1112 | + | let x = if ((takeFromInsurance > 0)) | |
1113 | + | then { | |
1114 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1115 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1116 | + | then nil | |
1117 | + | else throw("Strict value is not equal to itself.") | |
1118 | + | } | |
1119 | + | else nil | |
1120 | + | if ((x == x)) | |
1121 | + | then { | |
1122 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil) | |
1123 | + | if ((unstake == unstake)) | |
1124 | + | then { | |
1125 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1126 | + | if ((depositInsurance == depositInsurance)) | |
1127 | + | then { | |
1128 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, newPositionOpenNotional], nil) | |
1129 | + | if ((notifyNotional == notifyNotional)) | |
1130 | + | then (((updatePosition(_trader, newPositionSize, newPositionMargin, newPositionOpenNotional, newPositionLstUpdCPF) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, (totalLongPositionSize() - (if ((newPositionSize > 0)) | |
1131 | + | then abs(exchangedPositionSize) | |
1132 | + | else 0)), (totalShortPositionSize() - (if ((0 > newPositionSize)) | |
1133 | + | then abs(exchangedPositionSize) | |
1134 | + | else 0)))) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1135 | + | else throw("Strict value is not equal to itself.") | |
1136 | + | } | |
1137 | + | else throw("Strict value is not equal to itself.") | |
1138 | + | } | |
1139 | + | else throw("Strict value is not equal to itself.") | |
1140 | + | } | |
1141 | + | else throw("Strict value is not equal to itself.") | |
1142 | + | } | |
1143 | + | else { | |
1144 | + | let $t05226252717 = internalClosePosition(_trader, false) | |
1145 | + | let x1 = $t05226252717._1 | |
1146 | + | let badDebt = $t05226252717._2 | |
1147 | + | let x2 = $t05226252717._3 | |
1148 | + | let x3 = $t05226252717._4 | |
1149 | + | let quoteAssetReserveAfter = $t05226252717._5 | |
1150 | + | let baseAssetReserveAfter = $t05226252717._6 | |
1151 | + | let totalPositionSizeAfter = $t05226252717._7 | |
1152 | + | let cumulativeNotionalAfter = $t05226252717._8 | |
1153 | + | let openInterestNotionalAfter = $t05226252717._9 | |
1154 | + | let exchangedQuoteAssetAmount = $t05226252717._10 | |
1155 | + | let totalLongAfter = $t05226252717._11 | |
1156 | + | let totalShortAfter = $t05226252717._12 | |
1157 | + | let liquidationPenalty = muld(exchangedQuoteAssetAmount, liquidationFeeRatio()) | |
1158 | + | let feeToLiquidator = (liquidationPenalty / 2) | |
1159 | + | let feeToInsurance = (liquidationPenalty - feeToLiquidator) | |
1160 | + | let ammBalance = (cbalance() - liquidationPenalty) | |
1161 | + | let $t05312953272 = if ((0 > ammBalance)) | |
1162 | + | then $Tuple2(0, abs(ammBalance)) | |
1163 | + | else $Tuple2(ammBalance, 0) | |
1164 | + | let newAmmBalance = $t05312953272._1 | |
1165 | + | let takeFromInsurance = $t05312953272._2 | |
1166 | + | let x = if ((takeFromInsurance > 0)) | |
1167 | + | then { | |
1168 | + | let withdrawInsurance = invoke(insuranceAddress(), "withdraw", [takeFromInsurance], nil) | |
1169 | + | if ((withdrawInsurance == withdrawInsurance)) | |
1170 | + | then nil | |
1171 | + | else throw("Strict value is not equal to itself.") | |
1172 | + | } | |
1173 | + | else nil | |
1174 | + | if ((x == x)) | |
1175 | + | then { | |
1176 | + | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [(liquidationPenalty - takeFromInsurance), toBase58String(quoteAsset())], nil) | |
1177 | + | if ((unstake == unstake)) | |
1178 | + | then { | |
1179 | + | let depositInsurance = invoke(insuranceAddress(), "deposit", nil, [AttachedPayment(quoteAsset(), feeToInsurance)]) | |
1180 | + | if ((depositInsurance == depositInsurance)) | |
1181 | + | then { | |
1182 | + | let notifyNotional = invoke(minerAddress(), "notifyNotional", [_trader, 0], nil) | |
1183 | + | if ((notifyNotional == notifyNotional)) | |
1184 | + | then (((deletePosition(_trader) ++ updateAmm(quoteAssetReserveAfter, baseAssetReserveAfter, totalPositionSizeAfter, cumulativeNotionalAfter, openInterestNotionalAfter, totalLongAfter, totalShortAfter)) ++ withdraw(i.caller, feeToLiquidator)) ++ updateBalance(newAmmBalance)) | |
1185 | + | else throw("Strict value is not equal to itself.") | |
1186 | + | } | |
1187 | + | else throw("Strict value is not equal to itself.") | |
1188 | + | } | |
1189 | + | else throw("Strict value is not equal to itself.") | |
1190 | + | } | |
1191 | + | else throw("Strict value is not equal to itself.") | |
1192 | + | } | |
1074 | 1193 | } | |
1075 | 1194 | ||
1076 | 1195 | ||
1077 | 1196 | ||
1078 | 1197 | @Callable(i) | |
1079 | 1198 | func payFunding () = { | |
1080 | 1199 | let fundingBlockTimestamp = nextFundingBlockTimestamp() | |
1081 | 1200 | if (if (if ((fundingBlockTimestamp > lastBlock.timestamp)) | |
1082 | 1201 | then true | |
1083 | 1202 | else !(initialized())) | |
1084 | 1203 | then true | |
1085 | 1204 | else paused()) | |
1086 | 1205 | then throw(((("Invalid funding block timestamp: " + toString(lastBlock.timestamp)) + " < ") + toString(fundingBlockTimestamp))) | |
1087 | 1206 | else { | |
1088 | 1207 | let underlyingPrice = getOracleTwapPrice() | |
1089 | 1208 | let spotTwapPrice = getTwapSpotPrice() | |
1090 | 1209 | let premium = (spotTwapPrice - underlyingPrice) | |
1091 | - | let $ | |
1210 | + | let $t05486056195 = if (if ((totalShortPositionSize() == 0)) | |
1092 | 1211 | then true | |
1093 | 1212 | else (totalLongPositionSize() == 0)) | |
1094 | 1213 | then $Tuple2(0, 0) | |
1095 | 1214 | else if ((0 > premium)) | |
1096 | 1215 | then { | |
1097 | 1216 | let shortPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
1098 | 1217 | let longPremiumFraction = divd(muld(shortPremiumFraction, totalShortPositionSize()), totalLongPositionSize()) | |
1099 | 1218 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
1100 | 1219 | } | |
1101 | 1220 | else { | |
1102 | 1221 | let longPremiumFraction = divd(muld(premium, fundingPeriodDecimal()), ONE_DAY) | |
1103 | 1222 | let shortPremiumFraction = divd(muld(longPremiumFraction, totalLongPositionSize()), totalShortPositionSize()) | |
1104 | 1223 | $Tuple2(shortPremiumFraction, longPremiumFraction) | |
1105 | 1224 | } | |
1106 | - | let shortPremiumFraction = $ | |
1107 | - | let longPremiumFraction = $ | |
1225 | + | let shortPremiumFraction = $t05486056195._1 | |
1226 | + | let longPremiumFraction = $t05486056195._2 | |
1108 | 1227 | updateFunding((fundingBlockTimestamp + fundingPeriodSeconds()), (latestLongCumulativePremiumFraction() + longPremiumFraction), (latestShortCumulativePremiumFraction() + shortPremiumFraction), divd(longPremiumFraction, underlyingPrice), divd(shortPremiumFraction, underlyingPrice)) | |
1109 | 1228 | } | |
1110 | 1229 | } | |
1111 | 1230 | ||
1112 | 1231 | ||
1113 | 1232 | ||
1114 | 1233 | @Callable(i) | |
1115 | 1234 | func v_get (_trader) = { | |
1116 | - | let $ | |
1117 | - | let x1 = $ | |
1118 | - | let x2 = $ | |
1119 | - | let x3 = $ | |
1120 | - | let x4 = $ | |
1235 | + | let $t05657056630 = internalClosePosition(_trader, false) | |
1236 | + | let x1 = $t05657056630._1 | |
1237 | + | let x2 = $t05657056630._2 | |
1238 | + | let x3 = $t05657056630._3 | |
1239 | + | let x4 = $t05657056630._4 | |
1121 | 1240 | throw((((s(x2) + s(x3)) + s(x4)) + s(getMarginRatio(_trader)))) | |
1122 | 1241 | } | |
1123 | 1242 | ||
1124 | 1243 | ||
1125 | 1244 | ||
1126 | 1245 | @Callable(i) | |
1127 | 1246 | func view_calcRemainMarginWithFundingPayment (_trader) = { | |
1128 | - | let $ | |
1129 | - | let positionSize = $ | |
1130 | - | let positionMargin = $ | |
1131 | - | let pon = $ | |
1132 | - | let positionLstUpdCPF = $ | |
1133 | - | let $ | |
1134 | - | let positionNotional = $ | |
1135 | - | let unrealizedPnl = $ | |
1136 | - | let $ | |
1137 | - | let remainMargin = $ | |
1138 | - | let badDebt = $ | |
1139 | - | let fundingPayment = $ | |
1140 | - | throw(((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt))) | |
1247 | + | let $t05677756888 = getPosition(_trader) | |
1248 | + | let positionSize = $t05677756888._1 | |
1249 | + | let positionMargin = $t05677756888._2 | |
1250 | + | let pon = $t05677756888._3 | |
1251 | + | let positionLstUpdCPF = $t05677756888._4 | |
1252 | + | let $t05689356994 = getPositionNotionalAndUnrealizedPnl(_trader, PNL_OPTION_SPOT) | |
1253 | + | let positionNotional = $t05689356994._1 | |
1254 | + | let unrealizedPnl = $t05689356994._2 | |
1255 | + | let $t05699957181 = calcRemainMarginWithFundingPayment(positionSize, positionMargin, positionLstUpdCPF, unrealizedPnl) | |
1256 | + | let remainMargin = $t05699957181._1 | |
1257 | + | let badDebt = $t05699957181._2 | |
1258 | + | let fundingPayment = $t05699957181._3 | |
1259 | + | throw((((((s(remainMargin) + s(fundingPayment)) + s(getMarginRatio(_trader))) + s(unrealizedPnl)) + s(badDebt)) + s(positionNotional))) | |
1141 | 1260 | } | |
1142 | 1261 | ||
1143 | 1262 | ||
1144 | 1263 | ||
1145 | 1264 | @Callable(i) | |
1146 | 1265 | func forceMoveAsset (_trader,_amount) = if (if ((addressFromPublicKey(adminPublicKey()) != i.caller)) | |
1147 | 1266 | then true | |
1148 | 1267 | else (0 > _amount)) | |
1149 | 1268 | then throw("Invalid forceMoveAsset parameters") | |
1150 | 1269 | else { | |
1151 | 1270 | let unstake = invoke(quoteAssetStaking(), "unlockNeutrino", [_amount, toBase58String(quoteAsset())], nil) | |
1152 | 1271 | if ((unstake == unstake)) | |
1153 | 1272 | then (withdraw(addressFromStringValue(_trader), _amount) ++ updateBalance((cbalance() - _amount))) | |
1154 | 1273 | else throw("Strict value is not equal to itself.") | |
1155 | 1274 | } | |
1156 | 1275 | ||
1157 | 1276 | ||
1158 | 1277 | @Verifier(tx) | |
1159 | 1278 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], adminPublicKey()) | |
1160 | 1279 |
github/deemru/w8io/026f985 167.54 ms ◑