tx · 2YTUDVy5c9WEf2XUhRfABTXnpMgw11i9VWM6xBZivQZx 3N9be2mwrA52WJho6DiesZkk4351GvpnWuj: -0.04000000 Waves 2022.08.23 14:58 [2197101] smart account 3N9be2mwrA52WJho6DiesZkk4351GvpnWuj > SELF 0.00000000 Waves
{ "type": 13, "id": "2YTUDVy5c9WEf2XUhRfABTXnpMgw11i9VWM6xBZivQZx", "fee": 4000000, "feeAssetId": null, "timestamp": 1661256044342, "version": 1, "sender": "3N9be2mwrA52WJho6DiesZkk4351GvpnWuj", "senderPublicKey": "6mzmbCza9iqbzxMEELcEA4Xc9NeF4CYpbTtz1zMK3C7x", "proofs": [ "2V2z8cievbPeEHWzv92KTEALj7fcvp1TeKXPzWppy3yK8iBu4ZGff3q2qVnYyRkkmjKaL3yPvcWnMVJ9i76ktWUD", "iobcyHP3he3RdFjBhwoTPuQmgRQipKf5oxbCSrenaK3TbfFaNPNiQdkPPD9FnwHLYgByLhVBaB9x5V97vQom1tZ", "52BArtFQWrNzoUGL4URq3juMryFi6VQqKtB32aM4ucRFZN4AV9Z2PCM4qBUSWwydMNqrn873VRELPNdY8umbRudm" ], "script": "base64:BgJOCAISDgoMCAgICAgIAQEBAQEBEgUKAwgIARIAEgASBQoDCAEIEgMKAQESBAoCAQgSABIECgIIARIECgIBARIECgIIARIFCgMIAQESABIApQEBD2dldFN0cmluZ09yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAAQVsY2FsYwEBbAkAuQgBBQFsAQ5nZXROdW1iZXJCeUtleQEDa2V5CQELdmFsdWVPckVsc2UCCQCaCAIFBHRoaXMFA2tleQAAAQ5nZXRTdHJpbmdCeUtleQEDa2V5CQELdmFsd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JLZXlBZG1pbnNMaXN0AAMAAgAABAckbWF0Y2gwBQJ0eAMJAAECBQckbWF0Y2gwAhVTcG9uc29yRmVlVHJhbnNhY3Rpb24ECXNwb25zb3JUeAUHJG1hdGNoMAMJARtjaGVja0lzVmFsaWRNaW5TcG9uc29yZWRGZWUBBQlzcG9uc29yVHgJAGcCBQVjb3VudAADBwkAZwIFBWNvdW50AAMlKItO", "chainId": 84, "height": 2197101, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: T8qZPUstRzW3yfUS6qjcejZC78eSAJQxHoXTsHiFLY4 Next: 2YG32vXKqsqm5bGr318anrWctr9Uz2BQZiLuui7yxava Diff:
Old | New | Differences | |
---|---|---|---|
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | + | func asBytes (val) = match val { | |
53 | + | case valByte: ByteVector => | |
54 | + | valByte | |
55 | + | case _ => | |
56 | + | throw("fail to cast into ByteVector") | |
57 | + | } | |
58 | + | ||
59 | + | ||
52 | 60 | func asPayment (v) = match v { | |
53 | 61 | case p: AttachedPayment => | |
54 | 62 | p | |
58 | 66 | ||
59 | 67 | ||
60 | 68 | func asSwapParamsSTRUCT (v) = match v { | |
61 | - | case struct: (Int, Int, Int, Int, Int) => | |
69 | + | case struct: (Int, Int, Int, Int, Int, Int, Int) => | |
62 | 70 | struct | |
63 | 71 | case _ => | |
64 | - | throw("fail to cast into | |
72 | + | throw("fail to cast into Tuple5 ints") | |
65 | 73 | } | |
66 | 74 | ||
67 | 75 | ||
74 | 82 | let PRICELET = 1000000 | |
75 | 83 | ||
76 | 84 | let DEFAULTSWAPFEE = 20000 | |
85 | + | ||
86 | + | let BRPROTECTED = 100000 | |
77 | 87 | ||
78 | 88 | let IdxNetAmount = 0 | |
79 | 89 | ||
222 | 232 | func swapsTimeframeKEY () = "swaps_timeframe" | |
223 | 233 | ||
224 | 234 | ||
235 | + | func brProtectedKEY () = "min_BR_protection_level" | |
236 | + | ||
237 | + | ||
225 | 238 | func minSwapAmountREAD (swapType) = valueOrElse(getInteger(this, minSwapAmountKEY(swapType)), 0) | |
226 | 239 | ||
227 | 240 | ||
357 | 370 | } | |
358 | 371 | ||
359 | 372 | ||
360 | - | func applyFees ( | |
361 | - | let feeAmount = fraction( | |
362 | - | [( | |
373 | + | func applyFees (amountOutGross,inAmtToSURF,feePart) = { | |
374 | + | let feeAmount = fraction(amountOutGross, feePart, PAULI) | |
375 | + | [(amountOutGross - feeAmount), feeAmount] | |
363 | 376 | } | |
364 | 377 | ||
365 | 378 | ||
423 | 436 | ||
424 | 437 | ||
425 | 438 | func commonSwap (swapType,pmtAmount,userAddressStr,txId58,swapParamsByUserSYSREADONLY) = { | |
426 | - | let | |
427 | - | let | |
428 | - | let | |
429 | - | let | |
439 | + | let swapLimitSpent = swapParamsByUserSYSREADONLY._2 | |
440 | + | let blcks2LmtReset = swapParamsByUserSYSREADONLY._3 | |
441 | + | let wavesSwapLimitMax = swapParamsByUserSYSREADONLY._6 | |
442 | + | let usdnSwapLimitMax = swapParamsByUserSYSREADONLY._7 | |
430 | 443 | let minSwapAmount = minSwapAmountREAD(swapType) | |
431 | 444 | let totalLocked = totalLockedREAD(swapType) | |
432 | 445 | let totalLockedByUser = totalLockedByUserREAD(swapType, userAddressStr) | |
440 | 453 | let swapUsdnVolume = if ((swapType == "neutrino")) | |
441 | 454 | then pmtAmount | |
442 | 455 | else convertWavesToNeutrino(pmtAmount, priceByIndex) | |
456 | + | let swapLimitMax = if ((swapType == "neutrino")) | |
457 | + | then usdnSwapLimitMax | |
458 | + | else convertWavesToNeutrino(wavesSwapLimitMax, priceByIndex) | |
443 | 459 | if ((minSwapAmount > pmtAmount)) | |
444 | 460 | then minSwapAmountFAIL(swapType, minSwapAmount) | |
445 | 461 | else if (if (!(isSwapByNode)) | |
461 | 477 | } | |
462 | 478 | ||
463 | 479 | ||
480 | + | let nMetricIdxPrice = 0 | |
481 | + | ||
482 | + | let nMetricIdxUsdnLockedBalance = 1 | |
483 | + | ||
484 | + | let nMetricIdxWavesLockedBalance = 2 | |
485 | + | ||
486 | + | let nMetricIdxReserve = 3 | |
487 | + | ||
488 | + | let nMetricIdxReserveInUsdn = 4 | |
489 | + | ||
490 | + | let nMetricIdxUsdnSupply = 5 | |
491 | + | ||
492 | + | let nMetricIdxSurplus = 6 | |
493 | + | ||
494 | + | let nMetricIdxSurplusPercent = 7 | |
495 | + | ||
496 | + | let nMetricIdxBR = 8 | |
497 | + | ||
498 | + | let nMetricIdxNsbtSupply = 9 | |
499 | + | ||
500 | + | let nMetricIdxMaxNsbtSupply = 10 | |
501 | + | ||
502 | + | let nMetricIdxSurfSupply = 11 | |
503 | + | ||
504 | + | let bFuncIdxSurf = 0 | |
505 | + | ||
506 | + | let bFuncIdxWaves = 1 | |
507 | + | ||
508 | + | let bFuncIdxUsdn = 2 | |
509 | + | ||
510 | + | let bFuncIdxReserveStart = 3 | |
511 | + | ||
512 | + | let bFuncIdxSupplyStart = 4 | |
513 | + | ||
514 | + | let bFuncIdxBRStart = 5 | |
515 | + | ||
516 | + | let bFuncIdxReserveEnd = 6 | |
517 | + | ||
518 | + | let bFuncIdxSupplyEnd = 7 | |
519 | + | ||
520 | + | let bFuncIdxBREnd = 8 | |
521 | + | ||
522 | + | let bFuncIdxRest = 9 | |
523 | + | ||
524 | + | let bFuncIdxWavesPrice = 10 | |
525 | + | ||
526 | + | func calcWithdrawW2U (wavesIn,price) = { | |
527 | + | let outAmtGross = convertWavesToNeutrino(wavesIn, price) | |
528 | + | $Tuple9(outAmtGross, neutrinoAssetId, 0, unit, 0, wavesIn, 0, 0, 0) | |
529 | + | } | |
530 | + | ||
531 | + | ||
532 | + | func calcWithdrawU2W (usdnIn,price,br,reservesInUsdn,usdnSupply) = { | |
533 | + | let brProtected = valueOrElse(getInteger(this, brProtectedKEY()), BRPROTECTED) | |
534 | + | let maxAllowedUsdnBeforeMinBr = if ((brProtected >= br)) | |
535 | + | then 0 | |
536 | + | else fraction((reservesInUsdn - fraction(brProtected, usdnSupply, PAULI)), PAULI, (PAULI - brProtected)) | |
537 | + | let allowedUsdnBeforeMinBr = if ((usdnIn > maxAllowedUsdnBeforeMinBr)) | |
538 | + | then maxAllowedUsdnBeforeMinBr | |
539 | + | else usdnIn | |
540 | + | let allowedUsdnAfterMinBr = if ((usdnIn > maxAllowedUsdnBeforeMinBr)) | |
541 | + | then fraction((usdnIn - maxAllowedUsdnBeforeMinBr), br, PAULI) | |
542 | + | else 0 | |
543 | + | let allowedUsdn = (allowedUsdnBeforeMinBr + allowedUsdnAfterMinBr) | |
544 | + | let usdn2SURF = (usdnIn - allowedUsdn) | |
545 | + | let outAmtGross = convertNeutrinoToWaves(allowedUsdn, price) | |
546 | + | $Tuple9(outAmtGross, unit, usdn2SURF, neutrinoAssetId, outAmtGross, allowedUsdn, maxAllowedUsdnBeforeMinBr, allowedUsdnBeforeMinBr, allowedUsdnAfterMinBr) | |
547 | + | } | |
548 | + | ||
549 | + | ||
550 | + | func calcWithdraw (swapType,inAmount,price) = { | |
551 | + | let outFeePart = valueOrElse(getInteger(this, outFeePartKEY(swapType)), DEFAULTSWAPFEE) | |
552 | + | if (if ((0 > outFeePart)) | |
553 | + | then true | |
554 | + | else (outFeePart >= PAULI)) | |
555 | + | then throw(((("invalid outFeePart config for " + swapType) + " swap: outFeePart=") + toString(outFeePart))) | |
556 | + | else { | |
557 | + | let brProtected = valueOrElse(getInteger(this, brProtectedKEY()), BRPROTECTED) | |
558 | + | let neutrinoMetrics = asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil)) | |
559 | + | let BR = asInt(neutrinoMetrics[nMetricIdxBR]) | |
560 | + | let reservesInUsdn = asInt(neutrinoMetrics[nMetricIdxReserveInUsdn]) | |
561 | + | let usdnSupply = asInt(neutrinoMetrics[nMetricIdxUsdnSupply]) | |
562 | + | let outDataTuple = if ((swapType == "waves")) | |
563 | + | then calcWithdrawW2U(inAmount, price) | |
564 | + | else if ((swapType == "neutrino")) | |
565 | + | then calcWithdrawU2W(inAmount, price, BR, reservesInUsdn, usdnSupply) | |
566 | + | else throw(("Unsupported swap type " + swapType)) | |
567 | + | let outAmtGross = outDataTuple._1 | |
568 | + | let outAssetId = outDataTuple._2 | |
569 | + | let inAmtToSurfPart = outDataTuple._3 | |
570 | + | let inAssetId = outDataTuple._4 | |
571 | + | let unleaseAmt = outDataTuple._5 | |
572 | + | let payoutsArray = applyFees(outAmtGross, inAmtToSurfPart, outFeePart) | |
573 | + | let outNetAmt = payoutsArray[IdxNetAmount] | |
574 | + | let outFeeAmt = payoutsArray[IdxFeeAmount] | |
575 | + | let outSurfAmt = if ((0 >= inAmtToSurfPart)) | |
576 | + | then 0 | |
577 | + | else { | |
578 | + | let surfResult = asAnyList(invoke(mathContract, "surfFunctionREADONLY", [inAmtToSurfPart, inAssetId], nil)) | |
579 | + | asInt(surfResult[bFuncIdxSurf]) | |
580 | + | } | |
581 | + | $Tuple7(outNetAmt, outAssetId, outSurfAmt, inAmtToSurfPart, unleaseAmt, outFeeAmt, outAmtGross) | |
582 | + | } | |
583 | + | } | |
584 | + | ||
585 | + | ||
464 | 586 | func commonWithdraw (account,index,swapTxId,withdrawTxId) = { | |
465 | 587 | let userAddress = addressFromStringValue(account) | |
466 | 588 | let dataArray = swapDataFailOrREAD(account, swapTxId) | |
476 | 598 | let indexHeight = getHeightPriceByIndex(index) | |
477 | 599 | let prevIndexHeight = getHeightPriceByIndex((index - 1)) | |
478 | 600 | let priceByIndex = getPriceHistory(indexHeight) | |
479 | - | let outAmountGrossTuple = if ((swapType == "waves")) | |
480 | - | then $Tuple2(convertWavesToNeutrino(inAmount, priceByIndex), neutrinoAssetId) | |
481 | - | else if ((swapType == "neutrino")) | |
482 | - | then $Tuple2(convertNeutrinoToWaves(inAmount, priceByIndex), unit) | |
483 | - | else throw(("Unsupported swap type " + swapType)) | |
484 | - | let payoutsArray = applyFees(outAmountGrossTuple._1, outFeePart) | |
485 | - | let outNetAmount = payoutsArray[IdxNetAmount] | |
486 | - | let outFeeAmount = payoutsArray[IdxFeeAmount] | |
487 | 601 | if (isBlocked) | |
488 | 602 | then emergencyShutdownFAIL() | |
489 | 603 | else if ((swapStatus != "PENDING")) | |
498 | 612 | then (prevIndexHeight >= unlockHeight) | |
499 | 613 | else false) | |
500 | 614 | then priceIndexFAIL(index, priceIndex, indexHeight, unlockHeight, prevIndexHeight) | |
501 | - | else if ((0 >= payoutsArray[IdxGrossAmount])) | |
502 | - | then throw("balance equals zero") | |
503 | - | else if (if ((0 > outFeePart)) | |
504 | - | then true | |
505 | - | else (outFeePart >= PAULI)) | |
506 | - | then throw(((("invalid outFeePart config for " + swapType) + " swap: outFeePart=") + toString(outFeePart))) | |
615 | + | else { | |
616 | + | let withdrawTuple = calcWithdraw(swapType, inAmount, priceByIndex) | |
617 | + | let outNetAmount = withdrawTuple._1 | |
618 | + | let outAssetId = withdrawTuple._2 | |
619 | + | let outSurfAmt = withdrawTuple._3 | |
620 | + | let inAmtToSurfPart = withdrawTuple._4 | |
621 | + | let unleaseAmt = withdrawTuple._5 | |
622 | + | let outFeeAmount = withdrawTuple._6 | |
623 | + | let outAmtGross = withdrawTuple._7 | |
624 | + | if ((0 >= outAmtGross)) | |
625 | + | then throw("balance equals zero") | |
507 | 626 | else { | |
508 | - | let unleaseAmount = if (if ((swapType == "neutrino")) | |
509 | - | then (outAmountGrossTuple._1 > 0) | |
510 | - | else false) | |
511 | - | then outAmountGrossTuple._1 | |
627 | + | let state = [IntegerEntry(totalLockedByUserKEY(swapType, account), (totalLockedByUser - inAmount)), IntegerEntry(totalLockedKEY(swapType), (totalLocked - inAmount)), ScriptTransfer(userAddress, outNetAmount, outAssetId), StringEntry(swapKEY(account, swapTxId), finishSwapDATA(dataArray, priceByIndex, outNetAmount, outFeeAmount, unlockHeight, index, withdrawTxId))] | |
628 | + | let surfCondition = if ((outSurfAmt > 0)) | |
629 | + | then { | |
630 | + | let issueResult = invoke(auctionContract, "issueSurf", [outSurfAmt, account], nil) | |
631 | + | if ((issueResult == issueResult)) | |
632 | + | then 0 | |
633 | + | else throw("Strict value is not equal to itself.") | |
634 | + | } | |
512 | 635 | else 0 | |
513 | - | let state = [IntegerEntry(totalLockedByUserKEY(swapType, account), (totalLockedByUser - inAmount)), IntegerEntry(totalLockedKEY(swapType), (totalLocked - inAmount)), ScriptTransfer(userAddress, outNetAmount, outAmountGrossTuple._2), StringEntry(swapKEY(account, swapTxId), finishSwapDATA(dataArray, priceByIndex, outNetAmount, outFeeAmount, unlockHeight, index, withdrawTxId))] | |
514 | - | $Tuple3(state, AttachedPayment(outAmountGrossTuple._2, outFeeAmount), unleaseAmount) | |
636 | + | if ((surfCondition == surfCondition)) | |
637 | + | then $Tuple3(state, AttachedPayment(outAssetId, outFeeAmount), unleaseAmt) | |
638 | + | else throw("Strict value is not equal to itself.") | |
515 | 639 | } | |
640 | + | } | |
516 | 641 | } | |
517 | 642 | ||
518 | 643 | ||
665 | 790 | if ((i.callerPublicKey != mngPub)) | |
666 | 791 | then throw("approveLeasings not authorized") | |
667 | 792 | else { | |
668 | - | let $ | |
669 | - | let nAddr0 = $ | |
670 | - | let lAmtKEY0 = $ | |
671 | - | let lAmt0 = $ | |
672 | - | let lIdKEY0 = $ | |
673 | - | let lId0 = $ | |
674 | - | let $ | |
675 | - | let nAddr1 = $ | |
676 | - | let lAmtKEY1 = $ | |
677 | - | let lAmt1 = $ | |
678 | - | let lIdKEY1 = $ | |
679 | - | let lId1 = $ | |
793 | + | let $t03363933701 = readNodeInfo(0) | |
794 | + | let nAddr0 = $t03363933701._1 | |
795 | + | let lAmtKEY0 = $t03363933701._2 | |
796 | + | let lAmt0 = $t03363933701._3 | |
797 | + | let lIdKEY0 = $t03363933701._4 | |
798 | + | let lId0 = $t03363933701._5 | |
799 | + | let $t03370433766 = readNodeInfo(1) | |
800 | + | let nAddr1 = $t03370433766._1 | |
801 | + | let lAmtKEY1 = $t03370433766._2 | |
802 | + | let lAmt1 = $t03370433766._3 | |
803 | + | let lIdKEY1 = $t03370433766._4 | |
804 | + | let lId1 = $t03370433766._5 | |
680 | 805 | let newL0 = Lease(nAddr0, (lAmt0 - ((lAmt * expCount) / 2))) | |
681 | 806 | let newL1 = Lease(nAddr1, (lAmt1 - ((lAmt * expCount) / 2))) | |
682 | 807 | let validation = invoke(nodeRegAddr, "validateAndApproveLeasings", [nListS], nil) | |
711 | 836 | ||
712 | 837 | ||
713 | 838 | @Callable(i) | |
839 | + | func rebalanceLeasings (amount,groupNum) = { | |
840 | + | let nIdxs = [0, 1, 2, 3, 4, 5, 6, 7] | |
841 | + | let mngPubS = valueOrElse(getString("%s%s__cfg__leasingManagerPub"), "7AUMX54ukYMYvPmma7yoFf5NjZhs4Bu5nz3Ez9EV8sur") | |
842 | + | let mngPub = fromBase58String(mngPubS) | |
843 | + | let lGroupNodeListKEY = getLeaseGroupNodeListKey(groupNum) | |
844 | + | let nListS = getStringOrFail(this, lGroupNodeListKEY) | |
845 | + | let nList = split(nListS, SEP) | |
846 | + | if ((i.callerPublicKey != mngPub)) | |
847 | + | then throw("rebalanceLeasings not authorized") | |
848 | + | else { | |
849 | + | let unleaseAmt = ((amount / size(nList)) + 1) | |
850 | + | let $t03518335245 = readNodeInfo(0) | |
851 | + | let nAddr0 = $t03518335245._1 | |
852 | + | let lAmtKEY0 = $t03518335245._2 | |
853 | + | let lAmt0 = $t03518335245._3 | |
854 | + | let lIdKEY0 = $t03518335245._4 | |
855 | + | let lId0 = $t03518335245._5 | |
856 | + | let newL0 = Lease(nAddr0, (lAmt0 + (unleaseAmt * size(nList)))) | |
857 | + | func forEachNodeDoUnlease (a,i) = { | |
858 | + | let node = nList[i] | |
859 | + | let lIdKEY = getLeaseIdByAddressKey(node) | |
860 | + | let lId = getBinaryValue(this, lIdKEY) | |
861 | + | let lAmtKEY = getLeaseAmountByAddressKey(node) | |
862 | + | let lAmt = getIntegerValue(this, lAmtKEY) | |
863 | + | let ula = LeaseCancel(value(lId)) | |
864 | + | let la = Lease(addressFromStringValue(node), (lAmt - unleaseAmt)) | |
865 | + | (a ++ [LeaseCancel(value(lId)), la, BinaryEntry(lIdKEY, lcalc(la)), IntegerEntry(lAmtKEY, la.amount)]) | |
866 | + | } | |
867 | + | ||
868 | + | ({ | |
869 | + | let $l = nIdxs | |
870 | + | let $s = size($l) | |
871 | + | let $acc0 = nil | |
872 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
873 | + | then $a | |
874 | + | else forEachNodeDoUnlease($a, $l[$i]) | |
875 | + | ||
876 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
877 | + | then $a | |
878 | + | else throw("List size exceeds 8") | |
879 | + | ||
880 | + | $f0_2($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) | |
881 | + | } ++ [BinaryEntry(lIdKEY0, lcalc(newL0)), IntegerEntry(lAmtKEY0, newL0.amount), LeaseCancel(lId0), newL0]) | |
882 | + | } | |
883 | + | } | |
884 | + | ||
885 | + | ||
886 | + | ||
887 | + | @Callable(i) | |
714 | 888 | func swapParamsByUserSYSREADONLY (userAddressStr,gnsbtDiff) = { | |
715 | 889 | let gnsbtData = asAnyList(invoke(gnsbtControllerContract, "gnsbtInfoSYSREADONLY", [userAddressStr, 0, 0], nil)) | |
716 | 890 | let gnsbtAmt = (asInt(gnsbtData[0]) + gnsbtDiff) | |
717 | 891 | let gnsbtAmtTotal = (asInt(gnsbtData[1]) + gnsbtDiff) | |
718 | - | let swapLimitMax = asInt(invoke(mathContract, "calcSwapLimitREADONLY", [gnsbtAmt], nil)) | |
892 | + | let swapLimitData = asAnyList(invoke(mathContract, "calcSwapLimitREADONLY", [gnsbtAmt], nil)) | |
893 | + | let wavesSwapLimitInUsdnMax = asInt(swapLimitData[0]) | |
894 | + | let wavesSwapLimitMax = asInt(swapLimitData[1]) | |
895 | + | let usdnSwapLimitMax = asInt(swapLimitData[2]) | |
719 | 896 | let lastSwapHeight = valueOrElse(getInteger(this, keyUserLastSwapHeight(userAddressStr)), 0) | |
720 | 897 | let swapLimitTimelifeBlocks = swapsTimeframeREAD() | |
721 | 898 | let passedBlocksAfterLastSwap = (height - lastSwapHeight) | |
722 | 899 | let isSwapTimelifeNew = (passedBlocksAfterLastSwap >= swapLimitTimelifeBlocks) | |
723 | - | let | |
900 | + | let swapLimitSpentInUsdn = if (isSwapTimelifeNew) | |
724 | 901 | then 0 | |
725 | 902 | else valueOrElse(getInteger(this, keySwapUserSpentInPeriod(userAddressStr)), 0) | |
726 | 903 | let blcks2LmtReset = if (isSwapTimelifeNew) | |
727 | 904 | then 0 | |
728 | 905 | else (swapLimitTimelifeBlocks - passedBlocksAfterLastSwap) | |
729 | - | $Tuple2(nil, $ | |
906 | + | $Tuple2(nil, $Tuple7(wavesSwapLimitInUsdnMax, swapLimitSpentInUsdn, blcks2LmtReset, gnsbtAmt, gnsbtAmtTotal, wavesSwapLimitMax, usdnSwapLimitMax)) | |
730 | 907 | } | |
908 | + | ||
909 | + | ||
910 | + | ||
911 | + | @Callable(i) | |
912 | + | func calcWithdrawResultSYSREADONLY (swapType,inAmount,price) = $Tuple2(nil, calcWithdraw(swapType, inAmount, price)) | |
731 | 913 | ||
732 | 914 | ||
733 | 915 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func lcalc (l) = calculateLeaseId(l) | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func getBoolByKey (key) = valueOrElse(getBoolean(this, key), false) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(address, key), 0) | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func getStringByAddressAndKey (address,key) = valueOrElse(getString(addressFromStringValue(address), key), "") | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | func getBoolByAddressAndKey (address,key) = valueOrElse(getBoolean(address, key), false) | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func asAnyList (v) = match v { | |
29 | 29 | case l: List[Any] => | |
30 | 30 | l | |
31 | 31 | case _ => | |
32 | 32 | throw("fail to cast into List[Any]") | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func asString (v) = match v { | |
37 | 37 | case s: String => | |
38 | 38 | s | |
39 | 39 | case _ => | |
40 | 40 | throw("fail to cast into String") | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func asInt (v) = match v { | |
45 | 45 | case i: Int => | |
46 | 46 | i | |
47 | 47 | case _ => | |
48 | 48 | throw("fail to cast into Int") | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | + | func asBytes (val) = match val { | |
53 | + | case valByte: ByteVector => | |
54 | + | valByte | |
55 | + | case _ => | |
56 | + | throw("fail to cast into ByteVector") | |
57 | + | } | |
58 | + | ||
59 | + | ||
52 | 60 | func asPayment (v) = match v { | |
53 | 61 | case p: AttachedPayment => | |
54 | 62 | p | |
55 | 63 | case _ => | |
56 | 64 | throw("fail to cast into AttachedPayment") | |
57 | 65 | } | |
58 | 66 | ||
59 | 67 | ||
60 | 68 | func asSwapParamsSTRUCT (v) = match v { | |
61 | - | case struct: (Int, Int, Int, Int, Int) => | |
69 | + | case struct: (Int, Int, Int, Int, Int, Int, Int) => | |
62 | 70 | struct | |
63 | 71 | case _ => | |
64 | - | throw("fail to cast into | |
72 | + | throw("fail to cast into Tuple5 ints") | |
65 | 73 | } | |
66 | 74 | ||
67 | 75 | ||
68 | 76 | let SEP = "__" | |
69 | 77 | ||
70 | 78 | let WAVELET = 100000000 | |
71 | 79 | ||
72 | 80 | let PAULI = 1000000 | |
73 | 81 | ||
74 | 82 | let PRICELET = 1000000 | |
75 | 83 | ||
76 | 84 | let DEFAULTSWAPFEE = 20000 | |
85 | + | ||
86 | + | let BRPROTECTED = 100000 | |
77 | 87 | ||
78 | 88 | let IdxNetAmount = 0 | |
79 | 89 | ||
80 | 90 | let IdxFeeAmount = 1 | |
81 | 91 | ||
82 | 92 | let IdxGrossAmount = 2 | |
83 | 93 | ||
84 | 94 | let IdxControlCfgNeutrinoDapp = 1 | |
85 | 95 | ||
86 | 96 | let IdxControlCfgAuctionDapp = 2 | |
87 | 97 | ||
88 | 98 | let IdxControlCfgRpdDapp = 3 | |
89 | 99 | ||
90 | 100 | let IdxControlCfgMathDapp = 4 | |
91 | 101 | ||
92 | 102 | let IdxControlCfgLiquidationDapp = 5 | |
93 | 103 | ||
94 | 104 | let IdxControlCfgRestDapp = 6 | |
95 | 105 | ||
96 | 106 | let IdxControlCfgNodeRegistryDapp = 7 | |
97 | 107 | ||
98 | 108 | let IdxControlCfgNsbtStakingDapp = 8 | |
99 | 109 | ||
100 | 110 | let IdxControlCfgMediatorDapp = 9 | |
101 | 111 | ||
102 | 112 | let IdxControlCfgSurfStakingDapp = 10 | |
103 | 113 | ||
104 | 114 | let IdxControlCfgGnsbtControllerDapp = 11 | |
105 | 115 | ||
106 | 116 | func keyControlAddress () = "%s%s__config__controlAddress" | |
107 | 117 | ||
108 | 118 | ||
109 | 119 | func keyControlCfg () = "%s__controlConfig" | |
110 | 120 | ||
111 | 121 | ||
112 | 122 | func readControlCfgOrFail (control) = split(getStringOrFail(control, keyControlCfg()), SEP) | |
113 | 123 | ||
114 | 124 | ||
115 | 125 | func getContractAddressOrFail (controlCfg,idx) = valueOrErrorMessage(addressFromString(controlCfg[idx]), ("Control cfg doesn't contain address at index " + toString(idx))) | |
116 | 126 | ||
117 | 127 | ||
118 | 128 | let controlContract = addressFromStringValue(valueOrElse(getString(this, keyControlAddress()), "3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx")) | |
119 | 129 | ||
120 | 130 | let controlCfg = readControlCfgOrFail(controlContract) | |
121 | 131 | ||
122 | 132 | let mathContract = getContractAddressOrFail(controlCfg, IdxControlCfgMathDapp) | |
123 | 133 | ||
124 | 134 | let nsbtStakingContract = getContractAddressOrFail(controlCfg, IdxControlCfgNsbtStakingDapp) | |
125 | 135 | ||
126 | 136 | let surfStakingContract = getContractAddressOrFail(controlCfg, IdxControlCfgSurfStakingDapp) | |
127 | 137 | ||
128 | 138 | let gnsbtControllerContract = getContractAddressOrFail(controlCfg, IdxControlCfgGnsbtControllerDapp) | |
129 | 139 | ||
130 | 140 | let auctionContract = getContractAddressOrFail(controlCfg, IdxControlCfgAuctionDapp) | |
131 | 141 | ||
132 | 142 | let NeutrinoAssetIdKey = "neutrino_asset_id" | |
133 | 143 | ||
134 | 144 | let BondAssetIdKey = "bond_asset_id" | |
135 | 145 | ||
136 | 146 | let AuctionContractKey = "auction_contract" | |
137 | 147 | ||
138 | 148 | let NsbtStakingContractKey = "nsbtStakingContract" | |
139 | 149 | ||
140 | 150 | let LiquidationContractKey = "liquidation_contract" | |
141 | 151 | ||
142 | 152 | let RPDContractKey = "rpd_contract" | |
143 | 153 | ||
144 | 154 | let ContolContractKey = "control_contract" | |
145 | 155 | ||
146 | 156 | let MathContractKey = "math_contract" | |
147 | 157 | ||
148 | 158 | let BalanceWavesLockIntervalKey = "balance_waves_lock_interval" | |
149 | 159 | ||
150 | 160 | let BalanceNeutrinoLockIntervalKey = "balance_neutrino_lock_interval" | |
151 | 161 | ||
152 | 162 | let MinWavesSwapAmountKey = "min_waves_swap_amount" | |
153 | 163 | ||
154 | 164 | let MinNeutrinoSwapAmountKey = "min_neutrino_swap_amount" | |
155 | 165 | ||
156 | 166 | let NodeOracleProviderPubKeyKey = "node_oracle_provider" | |
157 | 167 | ||
158 | 168 | let NeutrinoOutFeePartKey = "neutrinoOut_swap_feePart" | |
159 | 169 | ||
160 | 170 | let WavesOutFeePartKey = "wavesOut_swap_feePart" | |
161 | 171 | ||
162 | 172 | func keyNodeRegistry (address) = ("%s__" + address) | |
163 | 173 | ||
164 | 174 | ||
165 | 175 | let PriceKey = "price" | |
166 | 176 | ||
167 | 177 | let PriceIndexKey = "price_index" | |
168 | 178 | ||
169 | 179 | let IsBlockedKey = "is_blocked" | |
170 | 180 | ||
171 | 181 | func getPriceHistoryKey (block) = ((PriceKey + "_") + toString(block)) | |
172 | 182 | ||
173 | 183 | ||
174 | 184 | func getHeightPriceByIndexKey (index) = ((PriceIndexKey + "_") + toString(index)) | |
175 | 185 | ||
176 | 186 | ||
177 | 187 | func getStakingNodeByIndex (idx) = getStringByKey(makeString(["%s%d%s", "lease", toString(idx), "nodeAddress"], SEP)) | |
178 | 188 | ||
179 | 189 | ||
180 | 190 | func getStakingNodeAddressByIndex (idx) = addressFromStringValue(getStakingNodeByIndex(idx)) | |
181 | 191 | ||
182 | 192 | ||
183 | 193 | func getReservedAmountForSponsorship () = valueOrElse(getInteger(this, makeString(["%s%s", "lease", "sponsorshipWavesReserve"], SEP)), (1000 * WAVELET)) | |
184 | 194 | ||
185 | 195 | ||
186 | 196 | func getBalanceUnlockBlockKey (owner) = ("balance_unlock_block_" + owner) | |
187 | 197 | ||
188 | 198 | ||
189 | 199 | func getLeaseIdKey (nodeIndex) = makeString(["%s%d%s", "lease", toString(nodeIndex), "id"], SEP) | |
190 | 200 | ||
191 | 201 | ||
192 | 202 | func getLeaseIdByAddressKey (nodeAddress) = makeString(["%s%s%s", "leaseByAddress", nodeAddress, "id"], SEP) | |
193 | 203 | ||
194 | 204 | ||
195 | 205 | func getLeaseAmountKey (nodeIndex) = makeString(["%s%d%s", "lease", toString(nodeIndex), "amount"], SEP) | |
196 | 206 | ||
197 | 207 | ||
198 | 208 | func getLeaseAmountByAddressKey (nodeAddress) = makeString(["%s%s%s", "leaseByAddress", nodeAddress, "amount"], SEP) | |
199 | 209 | ||
200 | 210 | ||
201 | 211 | func getLeaseGroupNodeListKey (groupNum) = makeString(["%s%d%s", "leaseGroup", toString(groupNum), "nodeList"], SEP) | |
202 | 212 | ||
203 | 213 | ||
204 | 214 | func minSwapAmountKEY (swapType) = (("min_" + swapType) + "_swap_amount") | |
205 | 215 | ||
206 | 216 | ||
207 | 217 | func totalLockedKEY (swapType) = ("balance_lock_" + swapType) | |
208 | 218 | ||
209 | 219 | ||
210 | 220 | func totalLockedByUserKEY (swapType,owner) = makeString(["balance_lock", swapType, owner], "_") | |
211 | 221 | ||
212 | 222 | ||
213 | 223 | func balanceLockIntervalKEY (swapType) = (("balance_" + swapType) + "_lock_interval") | |
214 | 224 | ||
215 | 225 | ||
216 | 226 | func nodeBalanceLockIntervalKEY () = "balance_node_lock_interval" | |
217 | 227 | ||
218 | 228 | ||
219 | 229 | func outFeePartKEY (swapType) = (swapType + "Out_swap_feePart") | |
220 | 230 | ||
221 | 231 | ||
222 | 232 | func swapsTimeframeKEY () = "swaps_timeframe" | |
223 | 233 | ||
224 | 234 | ||
235 | + | func brProtectedKEY () = "min_BR_protection_level" | |
236 | + | ||
237 | + | ||
225 | 238 | func minSwapAmountREAD (swapType) = valueOrElse(getInteger(this, minSwapAmountKEY(swapType)), 0) | |
226 | 239 | ||
227 | 240 | ||
228 | 241 | func swapsTimeframeREAD () = valueOrElse(getInteger(this, swapsTimeframeKEY()), 1440) | |
229 | 242 | ||
230 | 243 | ||
231 | 244 | func totalLockedREAD (swapType) = valueOrElse(getInteger(this, totalLockedKEY(swapType)), 0) | |
232 | 245 | ||
233 | 246 | ||
234 | 247 | func totalLockedByUserREAD (swapType,owner) = valueOrElse(getInteger(this, totalLockedByUserKEY(swapType, owner)), 0) | |
235 | 248 | ||
236 | 249 | ||
237 | 250 | func balanceLockIntervalREAD (swapType) = valueOrElse(getInteger(this, balanceLockIntervalKEY(swapType)), 1440) | |
238 | 251 | ||
239 | 252 | ||
240 | 253 | func nodeBalanceLockIntervalREAD () = valueOrElse(getInteger(this, nodeBalanceLockIntervalKEY()), 1) | |
241 | 254 | ||
242 | 255 | ||
243 | 256 | func keySwapUserSpentInPeriod (userAddress) = makeString(["%s%s", "swapUserSpentInPeriod", userAddress], SEP) | |
244 | 257 | ||
245 | 258 | ||
246 | 259 | func keyUserLastSwapHeight (userAddress) = makeString(["%s%s", "userLastSwapHeight", userAddress], SEP) | |
247 | 260 | ||
248 | 261 | ||
249 | 262 | func convertNeutrinoToWaves (amount,price) = fraction(fraction(amount, PRICELET, price), WAVELET, PAULI) | |
250 | 263 | ||
251 | 264 | ||
252 | 265 | func convertWavesToNeutrino (amount,price) = fraction(fraction(amount, price, PRICELET), PAULI, WAVELET) | |
253 | 266 | ||
254 | 267 | ||
255 | 268 | func convertWavesToBond (amount,price) = convertWavesToNeutrino(amount, price) | |
256 | 269 | ||
257 | 270 | ||
258 | 271 | func convertJsonArrayToList (jsonArray) = split(jsonArray, ",") | |
259 | 272 | ||
260 | 273 | ||
261 | 274 | func minSwapAmountFAIL (swapType,minSwapAmount) = throw(((("The specified amount in " + swapType) + " swap is less than the required minimum of ") + toString(minSwapAmount))) | |
262 | 275 | ||
263 | 276 | ||
264 | 277 | func emergencyShutdownFAIL () = throw("contract is blocked by EMERGENCY SHUTDOWN actions untill reactivation by emergency oracles") | |
265 | 278 | ||
266 | 279 | ||
267 | 280 | func priceIndexFAIL (index,priceIndex,indexHeight,unlockHeight,prevIndexHeight) = throw(((((((((("invalid price history index: index=" + toString(index)) + " priceIndex=") + toString(priceIndex)) + " indexHeight=") + toString(indexHeight)) + " unlockHeight=") + toString(unlockHeight)) + " prevIndexHeight=") + toString(prevIndexHeight))) | |
268 | 281 | ||
269 | 282 | ||
270 | 283 | let neutrinoAssetId = fromBase58String(getStringByKey(NeutrinoAssetIdKey)) | |
271 | 284 | ||
272 | 285 | let priceIndex = getNumberByAddressAndKey(controlContract, PriceIndexKey) | |
273 | 286 | ||
274 | 287 | let isBlocked = getBoolByAddressAndKey(controlContract, IsBlockedKey) | |
275 | 288 | ||
276 | 289 | let nodeOracleProviderPubKey = fromBase58String(getStringByKey(NodeOracleProviderPubKeyKey)) | |
277 | 290 | ||
278 | 291 | let bondAssetId = fromBase58String("F3iaxzruFeKujfVfYSZEkejpjh67wmRfPCRHiNmWKp3Z") | |
279 | 292 | ||
280 | 293 | let deprecatedBondAssetId = fromBase58String("975akZBfnMj513U7MZaHKzQrmsEx5aE3wdWKTrHBhbjF") | |
281 | 294 | ||
282 | 295 | let neutrinoContract = this | |
283 | 296 | ||
284 | 297 | let currentPrice = getNumberByAddressAndKey(controlContract, PriceKey) | |
285 | 298 | ||
286 | 299 | func checkIsValidMinSponsoredFee (tx) = { | |
287 | 300 | let MINTRANSFERFEE = 100000 | |
288 | 301 | let SponsoredFeeUpperBound = 1000 | |
289 | 302 | let realNeutrinoFee = convertWavesToNeutrino(MINTRANSFERFEE, currentPrice) | |
290 | 303 | let minNeutrinoFee = (realNeutrinoFee * 2) | |
291 | 304 | let maxNeutrinoFee = fraction(realNeutrinoFee, SponsoredFeeUpperBound, 100) | |
292 | 305 | let inputFee = value(tx.minSponsoredAssetFee) | |
293 | 306 | if (if ((inputFee >= minNeutrinoFee)) | |
294 | 307 | then (maxNeutrinoFee >= inputFee) | |
295 | 308 | else false) | |
296 | 309 | then (tx.assetId == neutrinoAssetId) | |
297 | 310 | else false | |
298 | 311 | } | |
299 | 312 | ||
300 | 313 | ||
301 | 314 | func getPriceHistory (block) = getNumberByAddressAndKey(controlContract, getPriceHistoryKey(block)) | |
302 | 315 | ||
303 | 316 | ||
304 | 317 | func getHeightPriceByIndex (index) = getNumberByAddressAndKey(controlContract, getHeightPriceByIndexKey(index)) | |
305 | 318 | ||
306 | 319 | ||
307 | 320 | func keyLockParamUserAmount (userAddress) = makeString(["%s%s%s", "paramByUser", userAddress, "amount"], SEP) | |
308 | 321 | ||
309 | 322 | ||
310 | 323 | let sIdxSwapType = 1 | |
311 | 324 | ||
312 | 325 | let sIdxStatus = 2 | |
313 | 326 | ||
314 | 327 | let sIdxInAmount = 3 | |
315 | 328 | ||
316 | 329 | let sIdxPrice = 4 | |
317 | 330 | ||
318 | 331 | let sIdxOutNetAmount = 5 | |
319 | 332 | ||
320 | 333 | let sIdxOutFeeAmount = 6 | |
321 | 334 | ||
322 | 335 | let sIdxStartHeight = 7 | |
323 | 336 | ||
324 | 337 | let sIdxStartTimestamp = 8 | |
325 | 338 | ||
326 | 339 | let sIdxEndHeight = 9 | |
327 | 340 | ||
328 | 341 | let sIdxEndTimestamp = 10 | |
329 | 342 | ||
330 | 343 | let sIdxSelfUnlockHeight = 11 | |
331 | 344 | ||
332 | 345 | let sIdxRandUnlockHeight = 12 | |
333 | 346 | ||
334 | 347 | let sIdxIndex = 13 | |
335 | 348 | ||
336 | 349 | let sIdxWithdrawTxId = 14 | |
337 | 350 | ||
338 | 351 | let sIdxMinRand = 15 | |
339 | 352 | ||
340 | 353 | let sIdxMaxRand = 16 | |
341 | 354 | ||
342 | 355 | func swapKEY (userAddress,txId) = makeString(["%s%s", userAddress, txId], SEP) | |
343 | 356 | ||
344 | 357 | ||
345 | 358 | func strSwapDATA (swapType,status,inAmount,price,outNetAmount,outFeeAmount,startHeight,startTimestamp,endHeight,endTimestamp,selfUnlockHeight,randUnlockHeight,index,withdrawTxId,randMin,randMax) = makeString(["%s%s%d%d%d%d%d%d%d%d%d%d%d%s", swapType, status, inAmount, price, outNetAmount, outFeeAmount, startHeight, startTimestamp, endHeight, endTimestamp, selfUnlockHeight, randUnlockHeight, index, withdrawTxId, randMin, randMax], SEP) | |
346 | 359 | ||
347 | 360 | ||
348 | 361 | func pendingSwapDATA (swapType,inAssetAmount,selfUnlockHeight) = strSwapDATA(swapType, "PENDING", toString(inAssetAmount), "0", "0", "0", toString(height), toString(lastBlock.timestamp), "0", "0", toString(selfUnlockHeight), "0", "0", "NULL", "0", "0") | |
349 | 362 | ||
350 | 363 | ||
351 | 364 | func finishSwapDATA (dataArray,price,outNetAmount,outFeeAmount,randUnlockHeight,index,withdrawTxId) = strSwapDATA(dataArray[sIdxSwapType], "FINISHED", dataArray[sIdxInAmount], toString(price), toString(outNetAmount), toString(outFeeAmount), dataArray[sIdxStartHeight], dataArray[sIdxStartTimestamp], toString(height), toString(lastBlock.timestamp), dataArray[sIdxSelfUnlockHeight], toString(randUnlockHeight), toString(index), withdrawTxId, dataArray[sIdxMinRand], dataArray[sIdxMaxRand]) | |
352 | 365 | ||
353 | 366 | ||
354 | 367 | func swapDataFailOrREAD (userAddress,swapTxId) = { | |
355 | 368 | let swapKey = swapKEY(userAddress, swapTxId) | |
356 | 369 | split(valueOrErrorMessage(getString(this, swapKey), ("no swap data for " + swapKey)), SEP) | |
357 | 370 | } | |
358 | 371 | ||
359 | 372 | ||
360 | - | func applyFees ( | |
361 | - | let feeAmount = fraction( | |
362 | - | [( | |
373 | + | func applyFees (amountOutGross,inAmtToSURF,feePart) = { | |
374 | + | let feeAmount = fraction(amountOutGross, feePart, PAULI) | |
375 | + | [(amountOutGross - feeAmount), feeAmount] | |
363 | 376 | } | |
364 | 377 | ||
365 | 378 | ||
366 | 379 | func abs (x) = if ((0 > x)) | |
367 | 380 | then -(x) | |
368 | 381 | else x | |
369 | 382 | ||
370 | 383 | ||
371 | 384 | func selectNode (unleaseAmount) = { | |
372 | 385 | let amountToLease = ((wavesBalance(neutrinoContract).available - unleaseAmount) - getReservedAmountForSponsorship()) | |
373 | 386 | let oldLeased0 = getNumberByKey(getLeaseAmountKey(0)) | |
374 | 387 | let oldLeased1 = getNumberByKey(getLeaseAmountKey(1)) | |
375 | 388 | let newLeased0 = (amountToLease + oldLeased0) | |
376 | 389 | let newLeased1 = (amountToLease + oldLeased1) | |
377 | 390 | if (if ((newLeased0 > 0)) | |
378 | 391 | then true | |
379 | 392 | else (newLeased1 > 0)) | |
380 | 393 | then { | |
381 | 394 | let delta0 = abs((newLeased0 - oldLeased1)) | |
382 | 395 | let delta1 = abs((newLeased1 - oldLeased0)) | |
383 | 396 | if ((delta1 >= delta0)) | |
384 | 397 | then $Tuple2(0, newLeased0) | |
385 | 398 | else $Tuple2(1, newLeased1) | |
386 | 399 | } | |
387 | 400 | else $Tuple2(-1, 0) | |
388 | 401 | } | |
389 | 402 | ||
390 | 403 | ||
391 | 404 | func thisOnly (i) = if ((i.caller != this)) | |
392 | 405 | then throw("Permission denied: this contract only allowed") | |
393 | 406 | else true | |
394 | 407 | ||
395 | 408 | ||
396 | 409 | func prepareUnleaseAndLease (unleaseAmount) = { | |
397 | 410 | let nodeTuple = selectNode(unleaseAmount) | |
398 | 411 | let nodeIndex = nodeTuple._1 | |
399 | 412 | let newLeaseAmount = nodeTuple._2 | |
400 | 413 | if ((newLeaseAmount > 0)) | |
401 | 414 | then { | |
402 | 415 | let leaseIdKey = getLeaseIdKey(nodeIndex) | |
403 | 416 | let oldLease = getBinary(this, leaseIdKey) | |
404 | 417 | let unleaseOrEmpty = if (isDefined(oldLease)) | |
405 | 418 | then [LeaseCancel(value(oldLease))] | |
406 | 419 | else nil | |
407 | 420 | let leaseAmountKey = getLeaseAmountKey(nodeIndex) | |
408 | 421 | let lease = Lease(getStakingNodeAddressByIndex(nodeIndex), newLeaseAmount) | |
409 | 422 | (unleaseOrEmpty ++ [lease, BinaryEntry(leaseIdKey, lcalc(lease)), IntegerEntry(getLeaseAmountKey(nodeIndex), newLeaseAmount)]) | |
410 | 423 | } | |
411 | 424 | else nil | |
412 | 425 | } | |
413 | 426 | ||
414 | 427 | ||
415 | 428 | func readNodeInfo (nodeIdx) = { | |
416 | 429 | let nodeAddress = getStakingNodeAddressByIndex(nodeIdx) | |
417 | 430 | let leasedAmtKEY = getLeaseAmountKey(nodeIdx) | |
418 | 431 | let leasedAmt = getNumberByKey(leasedAmtKEY) | |
419 | 432 | let leaseIdKEY = getLeaseIdKey(nodeIdx) | |
420 | 433 | let leaseId = value(getBinary(this, leaseIdKEY)) | |
421 | 434 | $Tuple5(nodeAddress, leasedAmtKEY, leasedAmt, leaseIdKEY, leaseId) | |
422 | 435 | } | |
423 | 436 | ||
424 | 437 | ||
425 | 438 | func commonSwap (swapType,pmtAmount,userAddressStr,txId58,swapParamsByUserSYSREADONLY) = { | |
426 | - | let | |
427 | - | let | |
428 | - | let | |
429 | - | let | |
439 | + | let swapLimitSpent = swapParamsByUserSYSREADONLY._2 | |
440 | + | let blcks2LmtReset = swapParamsByUserSYSREADONLY._3 | |
441 | + | let wavesSwapLimitMax = swapParamsByUserSYSREADONLY._6 | |
442 | + | let usdnSwapLimitMax = swapParamsByUserSYSREADONLY._7 | |
430 | 443 | let minSwapAmount = minSwapAmountREAD(swapType) | |
431 | 444 | let totalLocked = totalLockedREAD(swapType) | |
432 | 445 | let totalLockedByUser = totalLockedByUserREAD(swapType, userAddressStr) | |
433 | 446 | let nodeAddress = getStakingNodeByIndex(0) | |
434 | 447 | let priceByIndex = getPriceHistory(getHeightPriceByIndex(priceIndex)) | |
435 | 448 | let isSwapByNode = (nodeAddress == userAddressStr) | |
436 | 449 | let balanceLockMaxInterval = if (isSwapByNode) | |
437 | 450 | then nodeBalanceLockIntervalREAD() | |
438 | 451 | else balanceLockIntervalREAD(swapType) | |
439 | 452 | let selfUnlockHeight = (height + balanceLockMaxInterval) | |
440 | 453 | let swapUsdnVolume = if ((swapType == "neutrino")) | |
441 | 454 | then pmtAmount | |
442 | 455 | else convertWavesToNeutrino(pmtAmount, priceByIndex) | |
456 | + | let swapLimitMax = if ((swapType == "neutrino")) | |
457 | + | then usdnSwapLimitMax | |
458 | + | else convertWavesToNeutrino(wavesSwapLimitMax, priceByIndex) | |
443 | 459 | if ((minSwapAmount > pmtAmount)) | |
444 | 460 | then minSwapAmountFAIL(swapType, minSwapAmount) | |
445 | 461 | else if (if (!(isSwapByNode)) | |
446 | 462 | then (swapLimitSpent > 0) | |
447 | 463 | else false) | |
448 | 464 | then throw(("You have exceeded swap limit! Next allowed swap height is " + toString((height + blcks2LmtReset)))) | |
449 | 465 | else if (if (!(isSwapByNode)) | |
450 | 466 | then (swapUsdnVolume > swapLimitMax) | |
451 | 467 | else false) | |
452 | 468 | then throw(((("You have exceeded your swap limit! Requested: " + toString(swapUsdnVolume)) + ", available: ") + toString(swapLimitMax))) | |
453 | 469 | else if (isBlocked) | |
454 | 470 | then emergencyShutdownFAIL() | |
455 | 471 | else { | |
456 | 472 | let leasePart = if ((swapType == "waves")) | |
457 | 473 | then prepareUnleaseAndLease(0) | |
458 | 474 | else nil | |
459 | 475 | $Tuple2(([IntegerEntry(keySwapUserSpentInPeriod(userAddressStr), swapUsdnVolume), IntegerEntry(keyUserLastSwapHeight(userAddressStr), height), IntegerEntry(totalLockedByUserKEY(swapType, userAddressStr), (totalLockedByUser + pmtAmount)), IntegerEntry(getBalanceUnlockBlockKey(userAddressStr), selfUnlockHeight), IntegerEntry(totalLockedKEY(swapType), (totalLocked + pmtAmount)), StringEntry(swapKEY(userAddressStr, txId58), pendingSwapDATA(swapType, pmtAmount, selfUnlockHeight))] ++ leasePart), unit) | |
460 | 476 | } | |
461 | 477 | } | |
462 | 478 | ||
463 | 479 | ||
480 | + | let nMetricIdxPrice = 0 | |
481 | + | ||
482 | + | let nMetricIdxUsdnLockedBalance = 1 | |
483 | + | ||
484 | + | let nMetricIdxWavesLockedBalance = 2 | |
485 | + | ||
486 | + | let nMetricIdxReserve = 3 | |
487 | + | ||
488 | + | let nMetricIdxReserveInUsdn = 4 | |
489 | + | ||
490 | + | let nMetricIdxUsdnSupply = 5 | |
491 | + | ||
492 | + | let nMetricIdxSurplus = 6 | |
493 | + | ||
494 | + | let nMetricIdxSurplusPercent = 7 | |
495 | + | ||
496 | + | let nMetricIdxBR = 8 | |
497 | + | ||
498 | + | let nMetricIdxNsbtSupply = 9 | |
499 | + | ||
500 | + | let nMetricIdxMaxNsbtSupply = 10 | |
501 | + | ||
502 | + | let nMetricIdxSurfSupply = 11 | |
503 | + | ||
504 | + | let bFuncIdxSurf = 0 | |
505 | + | ||
506 | + | let bFuncIdxWaves = 1 | |
507 | + | ||
508 | + | let bFuncIdxUsdn = 2 | |
509 | + | ||
510 | + | let bFuncIdxReserveStart = 3 | |
511 | + | ||
512 | + | let bFuncIdxSupplyStart = 4 | |
513 | + | ||
514 | + | let bFuncIdxBRStart = 5 | |
515 | + | ||
516 | + | let bFuncIdxReserveEnd = 6 | |
517 | + | ||
518 | + | let bFuncIdxSupplyEnd = 7 | |
519 | + | ||
520 | + | let bFuncIdxBREnd = 8 | |
521 | + | ||
522 | + | let bFuncIdxRest = 9 | |
523 | + | ||
524 | + | let bFuncIdxWavesPrice = 10 | |
525 | + | ||
526 | + | func calcWithdrawW2U (wavesIn,price) = { | |
527 | + | let outAmtGross = convertWavesToNeutrino(wavesIn, price) | |
528 | + | $Tuple9(outAmtGross, neutrinoAssetId, 0, unit, 0, wavesIn, 0, 0, 0) | |
529 | + | } | |
530 | + | ||
531 | + | ||
532 | + | func calcWithdrawU2W (usdnIn,price,br,reservesInUsdn,usdnSupply) = { | |
533 | + | let brProtected = valueOrElse(getInteger(this, brProtectedKEY()), BRPROTECTED) | |
534 | + | let maxAllowedUsdnBeforeMinBr = if ((brProtected >= br)) | |
535 | + | then 0 | |
536 | + | else fraction((reservesInUsdn - fraction(brProtected, usdnSupply, PAULI)), PAULI, (PAULI - brProtected)) | |
537 | + | let allowedUsdnBeforeMinBr = if ((usdnIn > maxAllowedUsdnBeforeMinBr)) | |
538 | + | then maxAllowedUsdnBeforeMinBr | |
539 | + | else usdnIn | |
540 | + | let allowedUsdnAfterMinBr = if ((usdnIn > maxAllowedUsdnBeforeMinBr)) | |
541 | + | then fraction((usdnIn - maxAllowedUsdnBeforeMinBr), br, PAULI) | |
542 | + | else 0 | |
543 | + | let allowedUsdn = (allowedUsdnBeforeMinBr + allowedUsdnAfterMinBr) | |
544 | + | let usdn2SURF = (usdnIn - allowedUsdn) | |
545 | + | let outAmtGross = convertNeutrinoToWaves(allowedUsdn, price) | |
546 | + | $Tuple9(outAmtGross, unit, usdn2SURF, neutrinoAssetId, outAmtGross, allowedUsdn, maxAllowedUsdnBeforeMinBr, allowedUsdnBeforeMinBr, allowedUsdnAfterMinBr) | |
547 | + | } | |
548 | + | ||
549 | + | ||
550 | + | func calcWithdraw (swapType,inAmount,price) = { | |
551 | + | let outFeePart = valueOrElse(getInteger(this, outFeePartKEY(swapType)), DEFAULTSWAPFEE) | |
552 | + | if (if ((0 > outFeePart)) | |
553 | + | then true | |
554 | + | else (outFeePart >= PAULI)) | |
555 | + | then throw(((("invalid outFeePart config for " + swapType) + " swap: outFeePart=") + toString(outFeePart))) | |
556 | + | else { | |
557 | + | let brProtected = valueOrElse(getInteger(this, brProtectedKEY()), BRPROTECTED) | |
558 | + | let neutrinoMetrics = asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil)) | |
559 | + | let BR = asInt(neutrinoMetrics[nMetricIdxBR]) | |
560 | + | let reservesInUsdn = asInt(neutrinoMetrics[nMetricIdxReserveInUsdn]) | |
561 | + | let usdnSupply = asInt(neutrinoMetrics[nMetricIdxUsdnSupply]) | |
562 | + | let outDataTuple = if ((swapType == "waves")) | |
563 | + | then calcWithdrawW2U(inAmount, price) | |
564 | + | else if ((swapType == "neutrino")) | |
565 | + | then calcWithdrawU2W(inAmount, price, BR, reservesInUsdn, usdnSupply) | |
566 | + | else throw(("Unsupported swap type " + swapType)) | |
567 | + | let outAmtGross = outDataTuple._1 | |
568 | + | let outAssetId = outDataTuple._2 | |
569 | + | let inAmtToSurfPart = outDataTuple._3 | |
570 | + | let inAssetId = outDataTuple._4 | |
571 | + | let unleaseAmt = outDataTuple._5 | |
572 | + | let payoutsArray = applyFees(outAmtGross, inAmtToSurfPart, outFeePart) | |
573 | + | let outNetAmt = payoutsArray[IdxNetAmount] | |
574 | + | let outFeeAmt = payoutsArray[IdxFeeAmount] | |
575 | + | let outSurfAmt = if ((0 >= inAmtToSurfPart)) | |
576 | + | then 0 | |
577 | + | else { | |
578 | + | let surfResult = asAnyList(invoke(mathContract, "surfFunctionREADONLY", [inAmtToSurfPart, inAssetId], nil)) | |
579 | + | asInt(surfResult[bFuncIdxSurf]) | |
580 | + | } | |
581 | + | $Tuple7(outNetAmt, outAssetId, outSurfAmt, inAmtToSurfPart, unleaseAmt, outFeeAmt, outAmtGross) | |
582 | + | } | |
583 | + | } | |
584 | + | ||
585 | + | ||
464 | 586 | func commonWithdraw (account,index,swapTxId,withdrawTxId) = { | |
465 | 587 | let userAddress = addressFromStringValue(account) | |
466 | 588 | let dataArray = swapDataFailOrREAD(account, swapTxId) | |
467 | 589 | let selfUnlockHeight = parseIntValue(dataArray[sIdxSelfUnlockHeight]) | |
468 | 590 | let swapType = dataArray[sIdxSwapType] | |
469 | 591 | let inAmount = parseIntValue(dataArray[sIdxInAmount]) | |
470 | 592 | let swapStatus = dataArray[sIdxStatus] | |
471 | 593 | let startHeight = parseIntValue(dataArray[sIdxStartHeight]) | |
472 | 594 | let outFeePart = valueOrElse(getInteger(this, outFeePartKEY(swapType)), DEFAULTSWAPFEE) | |
473 | 595 | let totalLocked = totalLockedREAD(swapType) | |
474 | 596 | let totalLockedByUser = totalLockedByUserREAD(swapType, account) | |
475 | 597 | let unlockHeight = selfUnlockHeight | |
476 | 598 | let indexHeight = getHeightPriceByIndex(index) | |
477 | 599 | let prevIndexHeight = getHeightPriceByIndex((index - 1)) | |
478 | 600 | let priceByIndex = getPriceHistory(indexHeight) | |
479 | - | let outAmountGrossTuple = if ((swapType == "waves")) | |
480 | - | then $Tuple2(convertWavesToNeutrino(inAmount, priceByIndex), neutrinoAssetId) | |
481 | - | else if ((swapType == "neutrino")) | |
482 | - | then $Tuple2(convertNeutrinoToWaves(inAmount, priceByIndex), unit) | |
483 | - | else throw(("Unsupported swap type " + swapType)) | |
484 | - | let payoutsArray = applyFees(outAmountGrossTuple._1, outFeePart) | |
485 | - | let outNetAmount = payoutsArray[IdxNetAmount] | |
486 | - | let outFeeAmount = payoutsArray[IdxFeeAmount] | |
487 | 601 | if (isBlocked) | |
488 | 602 | then emergencyShutdownFAIL() | |
489 | 603 | else if ((swapStatus != "PENDING")) | |
490 | 604 | then throw("swap has been already processed") | |
491 | 605 | else if ((unlockHeight > height)) | |
492 | 606 | then throw((("please wait for: " + toString(unlockHeight)) + " block height to withdraw funds")) | |
493 | 607 | else if (if (if ((index > priceIndex)) | |
494 | 608 | then true | |
495 | 609 | else (unlockHeight > indexHeight)) | |
496 | 610 | then true | |
497 | 611 | else if ((prevIndexHeight != 0)) | |
498 | 612 | then (prevIndexHeight >= unlockHeight) | |
499 | 613 | else false) | |
500 | 614 | then priceIndexFAIL(index, priceIndex, indexHeight, unlockHeight, prevIndexHeight) | |
501 | - | else if ((0 >= payoutsArray[IdxGrossAmount])) | |
502 | - | then throw("balance equals zero") | |
503 | - | else if (if ((0 > outFeePart)) | |
504 | - | then true | |
505 | - | else (outFeePart >= PAULI)) | |
506 | - | then throw(((("invalid outFeePart config for " + swapType) + " swap: outFeePart=") + toString(outFeePart))) | |
615 | + | else { | |
616 | + | let withdrawTuple = calcWithdraw(swapType, inAmount, priceByIndex) | |
617 | + | let outNetAmount = withdrawTuple._1 | |
618 | + | let outAssetId = withdrawTuple._2 | |
619 | + | let outSurfAmt = withdrawTuple._3 | |
620 | + | let inAmtToSurfPart = withdrawTuple._4 | |
621 | + | let unleaseAmt = withdrawTuple._5 | |
622 | + | let outFeeAmount = withdrawTuple._6 | |
623 | + | let outAmtGross = withdrawTuple._7 | |
624 | + | if ((0 >= outAmtGross)) | |
625 | + | then throw("balance equals zero") | |
507 | 626 | else { | |
508 | - | let unleaseAmount = if (if ((swapType == "neutrino")) | |
509 | - | then (outAmountGrossTuple._1 > 0) | |
510 | - | else false) | |
511 | - | then outAmountGrossTuple._1 | |
627 | + | let state = [IntegerEntry(totalLockedByUserKEY(swapType, account), (totalLockedByUser - inAmount)), IntegerEntry(totalLockedKEY(swapType), (totalLocked - inAmount)), ScriptTransfer(userAddress, outNetAmount, outAssetId), StringEntry(swapKEY(account, swapTxId), finishSwapDATA(dataArray, priceByIndex, outNetAmount, outFeeAmount, unlockHeight, index, withdrawTxId))] | |
628 | + | let surfCondition = if ((outSurfAmt > 0)) | |
629 | + | then { | |
630 | + | let issueResult = invoke(auctionContract, "issueSurf", [outSurfAmt, account], nil) | |
631 | + | if ((issueResult == issueResult)) | |
632 | + | then 0 | |
633 | + | else throw("Strict value is not equal to itself.") | |
634 | + | } | |
512 | 635 | else 0 | |
513 | - | let state = [IntegerEntry(totalLockedByUserKEY(swapType, account), (totalLockedByUser - inAmount)), IntegerEntry(totalLockedKEY(swapType), (totalLocked - inAmount)), ScriptTransfer(userAddress, outNetAmount, outAmountGrossTuple._2), StringEntry(swapKEY(account, swapTxId), finishSwapDATA(dataArray, priceByIndex, outNetAmount, outFeeAmount, unlockHeight, index, withdrawTxId))] | |
514 | - | $Tuple3(state, AttachedPayment(outAmountGrossTuple._2, outFeeAmount), unleaseAmount) | |
636 | + | if ((surfCondition == surfCondition)) | |
637 | + | then $Tuple3(state, AttachedPayment(outAssetId, outFeeAmount), unleaseAmt) | |
638 | + | else throw("Strict value is not equal to itself.") | |
515 | 639 | } | |
640 | + | } | |
516 | 641 | } | |
517 | 642 | ||
518 | 643 | ||
519 | 644 | @Callable(i) | |
520 | 645 | func constructor (neutrinoAssetIdPrm,bondAssetIdPrm,auctionContractPrm,liquidationContractPrm,rpdContractPrm,nodeOracleProviderPubKeyPrm,balanceWavesLockIntervalPrm,balanceNeutrinoLockIntervalPrm,minWavesSwapAmountPrm,minNeutrinoSwapAmountPrm,neutrinoOutFeePartPrm,wavesOutFeePartPrm) = { | |
521 | 646 | let checkCaller = thisOnly(i) | |
522 | 647 | if ((checkCaller == checkCaller)) | |
523 | 648 | then if ((size(i.payments) != 0)) | |
524 | 649 | then throw("no payments allowed") | |
525 | 650 | else [StringEntry(NeutrinoAssetIdKey, neutrinoAssetIdPrm), StringEntry(BondAssetIdKey, bondAssetIdPrm), StringEntry(AuctionContractKey, auctionContractPrm), StringEntry(LiquidationContractKey, liquidationContractPrm), StringEntry(RPDContractKey, rpdContractPrm), StringEntry(NodeOracleProviderPubKeyKey, nodeOracleProviderPubKeyPrm), IntegerEntry(BalanceWavesLockIntervalKey, balanceWavesLockIntervalPrm), IntegerEntry(BalanceNeutrinoLockIntervalKey, balanceNeutrinoLockIntervalPrm), IntegerEntry(MinWavesSwapAmountKey, minWavesSwapAmountPrm), IntegerEntry(MinNeutrinoSwapAmountKey, minNeutrinoSwapAmountPrm), IntegerEntry(NeutrinoOutFeePartKey, neutrinoOutFeePartPrm), IntegerEntry(WavesOutFeePartKey, wavesOutFeePartPrm)] | |
526 | 651 | else throw("Strict value is not equal to itself.") | |
527 | 652 | } | |
528 | 653 | ||
529 | 654 | ||
530 | 655 | ||
531 | 656 | @Callable(i) | |
532 | 657 | func constructorV2 (mathContract,nsbtStakingContract,swapsTimeframeBlocks) = { | |
533 | 658 | let checkCaller = thisOnly(i) | |
534 | 659 | if ((checkCaller == checkCaller)) | |
535 | 660 | then if ((size(i.payments) != 0)) | |
536 | 661 | then throw("no payments allowed") | |
537 | 662 | else [StringEntry(MathContractKey, mathContract), StringEntry(NsbtStakingContractKey, nsbtStakingContract), IntegerEntry(swapsTimeframeKEY(), swapsTimeframeBlocks)] | |
538 | 663 | else throw("Strict value is not equal to itself.") | |
539 | 664 | } | |
540 | 665 | ||
541 | 666 | ||
542 | 667 | ||
543 | 668 | @Callable(i) | |
544 | 669 | func swapWavesToNeutrino () = if ((size(i.payments) != 1)) | |
545 | 670 | then throw("swapWavesToNeutrino require only one payment") | |
546 | 671 | else { | |
547 | 672 | let pmt = value(i.payments[0]) | |
548 | 673 | if (isDefined(pmt.assetId)) | |
549 | 674 | then throw("Only Waves token is allowed for swapping.") | |
550 | 675 | else { | |
551 | 676 | let userAddress = toString(i.caller) | |
552 | 677 | let txId58 = toBase58String(i.transactionId) | |
553 | 678 | let swapParamsSTRUCT = asSwapParamsSTRUCT(invoke(this, "swapParamsByUserSYSREADONLY", [userAddress, 0], nil)) | |
554 | 679 | let commonSwapResult = commonSwap("waves", pmt.amount, userAddress, txId58, swapParamsSTRUCT) | |
555 | 680 | commonSwapResult | |
556 | 681 | } | |
557 | 682 | } | |
558 | 683 | ||
559 | 684 | ||
560 | 685 | ||
561 | 686 | @Callable(i) | |
562 | 687 | func swapNeutrinoToWaves () = if ((size(i.payments) != 1)) | |
563 | 688 | then throw("swapNeutrinoToWaves require only one payment") | |
564 | 689 | else { | |
565 | 690 | let pmt = value(i.payments[0]) | |
566 | 691 | if ((pmt.assetId != neutrinoAssetId)) | |
567 | 692 | then throw("Only appropriate Neutrino tokens are allowed for swapping.") | |
568 | 693 | else { | |
569 | 694 | let userAddress = toString(i.caller) | |
570 | 695 | let txId58 = toBase58String(i.transactionId) | |
571 | 696 | let swapParamsSTRUCT = asSwapParamsSTRUCT(invoke(this, "swapParamsByUserSYSREADONLY", [userAddress, 0], nil)) | |
572 | 697 | let commonSwapResult = commonSwap("neutrino", pmt.amount, userAddress, txId58, swapParamsSTRUCT) | |
573 | 698 | commonSwapResult | |
574 | 699 | } | |
575 | 700 | } | |
576 | 701 | ||
577 | 702 | ||
578 | 703 | ||
579 | 704 | @Callable(i) | |
580 | 705 | func withdraw (account,index,swapTxId) = { | |
581 | 706 | let txId = toBase58String(i.transactionId) | |
582 | 707 | if ((size(i.payments) != 0)) | |
583 | 708 | then throw("no payments allowed") | |
584 | 709 | else { | |
585 | 710 | let commonTuple = commonWithdraw(account, index, swapTxId, txId) | |
586 | 711 | let state = commonTuple._1 | |
587 | 712 | let fee = commonTuple._2 | |
588 | 713 | let unleaseAmt = commonTuple._3 | |
589 | 714 | let unleaseInvOrEmpty = invoke(this, "internalUnleaseAndLease", [unleaseAmt], nil) | |
590 | 715 | if ((unleaseInvOrEmpty == unleaseInvOrEmpty)) | |
591 | 716 | then { | |
592 | 717 | let gnsbtData = asAnyList(invoke(gnsbtControllerContract, "gnsbtInfoSYSREADONLY", ["", 0, 0], nil)) | |
593 | 718 | let gnsbtAmtTotal = asInt(gnsbtData[1]) | |
594 | 719 | let gnsbtAmtFromSurfTotal = asInt(asAnyList(gnsbtData[3])[3]) | |
595 | 720 | let surfFeeAmt = if ((gnsbtAmtTotal != 0)) | |
596 | 721 | then fraction(fee.amount, gnsbtAmtFromSurfTotal, gnsbtAmtTotal) | |
597 | 722 | else 0 | |
598 | 723 | let nsbtFeeAmt = (fee.amount - surfFeeAmt) | |
599 | 724 | let surfDeposit = if ((surfFeeAmt > 0)) | |
600 | 725 | then { | |
601 | 726 | let surfInv = invoke(surfStakingContract, "deposit", nil, [AttachedPayment(fee.assetId, surfFeeAmt)]) | |
602 | 727 | if ((surfInv == surfInv)) | |
603 | 728 | then nil | |
604 | 729 | else throw("Strict value is not equal to itself.") | |
605 | 730 | } | |
606 | 731 | else nil | |
607 | 732 | if ((surfDeposit == surfDeposit)) | |
608 | 733 | then { | |
609 | 734 | let nsbtDeposit = if ((nsbtFeeAmt > 0)) | |
610 | 735 | then { | |
611 | 736 | let nsbtInv = invoke(nsbtStakingContract, "deposit", nil, [AttachedPayment(fee.assetId, nsbtFeeAmt)]) | |
612 | 737 | if ((nsbtInv == nsbtInv)) | |
613 | 738 | then nil | |
614 | 739 | else throw("Strict value is not equal to itself.") | |
615 | 740 | } | |
616 | 741 | else nil | |
617 | 742 | if ((nsbtDeposit == nsbtDeposit)) | |
618 | 743 | then state | |
619 | 744 | else throw("Strict value is not equal to itself.") | |
620 | 745 | } | |
621 | 746 | else throw("Strict value is not equal to itself.") | |
622 | 747 | } | |
623 | 748 | else throw("Strict value is not equal to itself.") | |
624 | 749 | } | |
625 | 750 | } | |
626 | 751 | ||
627 | 752 | ||
628 | 753 | ||
629 | 754 | @Callable(i) | |
630 | 755 | func internalUnleaseAndLease (unleaseAmount) = if ((i.caller != this)) | |
631 | 756 | then throw("internalUnleaseAndLease is not public method") | |
632 | 757 | else prepareUnleaseAndLease(unleaseAmount) | |
633 | 758 | ||
634 | 759 | ||
635 | 760 | ||
636 | 761 | @Callable(i) | |
637 | 762 | func transferUsdnToUser (amount,addr) = if ((i.caller != auctionContract)) | |
638 | 763 | then throw("Only auction contract is authorized") | |
639 | 764 | else [ScriptTransfer(addressFromStringValue(addr), amount, neutrinoAssetId)] | |
640 | 765 | ||
641 | 766 | ||
642 | 767 | ||
643 | 768 | @Callable(i) | |
644 | 769 | func acceptWaves () = if ((i.caller != auctionContract)) | |
645 | 770 | then throw("Currently only auction contract is allowed to call") | |
646 | 771 | else $Tuple2(prepareUnleaseAndLease(0), "success") | |
647 | 772 | ||
648 | 773 | ||
649 | 774 | ||
650 | 775 | @Callable(i) | |
651 | 776 | func approveLeasings (nListS,groupNum) = { | |
652 | 777 | let lAmt = (50 * WAVELET) | |
653 | 778 | let nIdxs = [0, 1, 2, 3, 4, 5, 6, 7] | |
654 | 779 | let mngPubS = valueOrElse(getString("%s%s__cfg__leasingManagerPub"), "7AUMX54ukYMYvPmma7yoFf5NjZhs4Bu5nz3Ez9EV8sur") | |
655 | 780 | let mngPub = fromBase58String(mngPubS) | |
656 | 781 | let nodeRegAddrStr = valueOrElse(getString("%s%s__cfg__nodesRegistryAddress"), "3P9vKqQKjUdmpXAfiWau8krREYAY1Xr69pE") | |
657 | 782 | let nodeRegAddr = addressFromStringValue(nodeRegAddrStr) | |
658 | 783 | let lGroupNodeListKEY = getLeaseGroupNodeListKey(groupNum) | |
659 | 784 | let lGrNodeOpt = getString(this, lGroupNodeListKEY) | |
660 | 785 | if (isDefined(lGrNodeOpt)) | |
661 | 786 | then throw((("group " + toString(groupNum)) + " already initialized")) | |
662 | 787 | else { | |
663 | 788 | let nList = split(nListS, SEP) | |
664 | 789 | let expCount = size(nIdxs) | |
665 | 790 | if ((i.callerPublicKey != mngPub)) | |
666 | 791 | then throw("approveLeasings not authorized") | |
667 | 792 | else { | |
668 | - | let $ | |
669 | - | let nAddr0 = $ | |
670 | - | let lAmtKEY0 = $ | |
671 | - | let lAmt0 = $ | |
672 | - | let lIdKEY0 = $ | |
673 | - | let lId0 = $ | |
674 | - | let $ | |
675 | - | let nAddr1 = $ | |
676 | - | let lAmtKEY1 = $ | |
677 | - | let lAmt1 = $ | |
678 | - | let lIdKEY1 = $ | |
679 | - | let lId1 = $ | |
793 | + | let $t03363933701 = readNodeInfo(0) | |
794 | + | let nAddr0 = $t03363933701._1 | |
795 | + | let lAmtKEY0 = $t03363933701._2 | |
796 | + | let lAmt0 = $t03363933701._3 | |
797 | + | let lIdKEY0 = $t03363933701._4 | |
798 | + | let lId0 = $t03363933701._5 | |
799 | + | let $t03370433766 = readNodeInfo(1) | |
800 | + | let nAddr1 = $t03370433766._1 | |
801 | + | let lAmtKEY1 = $t03370433766._2 | |
802 | + | let lAmt1 = $t03370433766._3 | |
803 | + | let lIdKEY1 = $t03370433766._4 | |
804 | + | let lId1 = $t03370433766._5 | |
680 | 805 | let newL0 = Lease(nAddr0, (lAmt0 - ((lAmt * expCount) / 2))) | |
681 | 806 | let newL1 = Lease(nAddr1, (lAmt1 - ((lAmt * expCount) / 2))) | |
682 | 807 | let validation = invoke(nodeRegAddr, "validateAndApproveLeasings", [nListS], nil) | |
683 | 808 | if ((validation == validation)) | |
684 | 809 | then { | |
685 | 810 | func forEachNodeValidateAndGenerateLease (a,i) = { | |
686 | 811 | let node = nList[i] | |
687 | 812 | let la = Lease(addressFromStringValue(node), lAmt) | |
688 | 813 | (a ++ [la, BinaryEntry(getLeaseIdByAddressKey(node), lcalc(la)), IntegerEntry(getLeaseAmountByAddressKey(node), lAmt)]) | |
689 | 814 | } | |
690 | 815 | ||
691 | 816 | ([StringEntry(lGroupNodeListKEY, nListS), BinaryEntry(lIdKEY0, lcalc(newL0)), BinaryEntry(lIdKEY1, lcalc(newL1)), IntegerEntry(lAmtKEY0, newL0.amount), IntegerEntry(lAmtKEY1, newL1.amount), LeaseCancel(lId0), LeaseCancel(lId1), newL0, newL1] ++ { | |
692 | 817 | let $l = nIdxs | |
693 | 818 | let $s = size($l) | |
694 | 819 | let $acc0 = nil | |
695 | 820 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
696 | 821 | then $a | |
697 | 822 | else forEachNodeValidateAndGenerateLease($a, $l[$i]) | |
698 | 823 | ||
699 | 824 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
700 | 825 | then $a | |
701 | 826 | else throw("List size exceeds 8") | |
702 | 827 | ||
703 | 828 | $f0_2($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) | |
704 | 829 | }) | |
705 | 830 | } | |
706 | 831 | else throw("Strict value is not equal to itself.") | |
707 | 832 | } | |
708 | 833 | } | |
709 | 834 | } | |
710 | 835 | ||
711 | 836 | ||
712 | 837 | ||
713 | 838 | @Callable(i) | |
839 | + | func rebalanceLeasings (amount,groupNum) = { | |
840 | + | let nIdxs = [0, 1, 2, 3, 4, 5, 6, 7] | |
841 | + | let mngPubS = valueOrElse(getString("%s%s__cfg__leasingManagerPub"), "7AUMX54ukYMYvPmma7yoFf5NjZhs4Bu5nz3Ez9EV8sur") | |
842 | + | let mngPub = fromBase58String(mngPubS) | |
843 | + | let lGroupNodeListKEY = getLeaseGroupNodeListKey(groupNum) | |
844 | + | let nListS = getStringOrFail(this, lGroupNodeListKEY) | |
845 | + | let nList = split(nListS, SEP) | |
846 | + | if ((i.callerPublicKey != mngPub)) | |
847 | + | then throw("rebalanceLeasings not authorized") | |
848 | + | else { | |
849 | + | let unleaseAmt = ((amount / size(nList)) + 1) | |
850 | + | let $t03518335245 = readNodeInfo(0) | |
851 | + | let nAddr0 = $t03518335245._1 | |
852 | + | let lAmtKEY0 = $t03518335245._2 | |
853 | + | let lAmt0 = $t03518335245._3 | |
854 | + | let lIdKEY0 = $t03518335245._4 | |
855 | + | let lId0 = $t03518335245._5 | |
856 | + | let newL0 = Lease(nAddr0, (lAmt0 + (unleaseAmt * size(nList)))) | |
857 | + | func forEachNodeDoUnlease (a,i) = { | |
858 | + | let node = nList[i] | |
859 | + | let lIdKEY = getLeaseIdByAddressKey(node) | |
860 | + | let lId = getBinaryValue(this, lIdKEY) | |
861 | + | let lAmtKEY = getLeaseAmountByAddressKey(node) | |
862 | + | let lAmt = getIntegerValue(this, lAmtKEY) | |
863 | + | let ula = LeaseCancel(value(lId)) | |
864 | + | let la = Lease(addressFromStringValue(node), (lAmt - unleaseAmt)) | |
865 | + | (a ++ [LeaseCancel(value(lId)), la, BinaryEntry(lIdKEY, lcalc(la)), IntegerEntry(lAmtKEY, la.amount)]) | |
866 | + | } | |
867 | + | ||
868 | + | ({ | |
869 | + | let $l = nIdxs | |
870 | + | let $s = size($l) | |
871 | + | let $acc0 = nil | |
872 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
873 | + | then $a | |
874 | + | else forEachNodeDoUnlease($a, $l[$i]) | |
875 | + | ||
876 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
877 | + | then $a | |
878 | + | else throw("List size exceeds 8") | |
879 | + | ||
880 | + | $f0_2($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) | |
881 | + | } ++ [BinaryEntry(lIdKEY0, lcalc(newL0)), IntegerEntry(lAmtKEY0, newL0.amount), LeaseCancel(lId0), newL0]) | |
882 | + | } | |
883 | + | } | |
884 | + | ||
885 | + | ||
886 | + | ||
887 | + | @Callable(i) | |
714 | 888 | func swapParamsByUserSYSREADONLY (userAddressStr,gnsbtDiff) = { | |
715 | 889 | let gnsbtData = asAnyList(invoke(gnsbtControllerContract, "gnsbtInfoSYSREADONLY", [userAddressStr, 0, 0], nil)) | |
716 | 890 | let gnsbtAmt = (asInt(gnsbtData[0]) + gnsbtDiff) | |
717 | 891 | let gnsbtAmtTotal = (asInt(gnsbtData[1]) + gnsbtDiff) | |
718 | - | let swapLimitMax = asInt(invoke(mathContract, "calcSwapLimitREADONLY", [gnsbtAmt], nil)) | |
892 | + | let swapLimitData = asAnyList(invoke(mathContract, "calcSwapLimitREADONLY", [gnsbtAmt], nil)) | |
893 | + | let wavesSwapLimitInUsdnMax = asInt(swapLimitData[0]) | |
894 | + | let wavesSwapLimitMax = asInt(swapLimitData[1]) | |
895 | + | let usdnSwapLimitMax = asInt(swapLimitData[2]) | |
719 | 896 | let lastSwapHeight = valueOrElse(getInteger(this, keyUserLastSwapHeight(userAddressStr)), 0) | |
720 | 897 | let swapLimitTimelifeBlocks = swapsTimeframeREAD() | |
721 | 898 | let passedBlocksAfterLastSwap = (height - lastSwapHeight) | |
722 | 899 | let isSwapTimelifeNew = (passedBlocksAfterLastSwap >= swapLimitTimelifeBlocks) | |
723 | - | let | |
900 | + | let swapLimitSpentInUsdn = if (isSwapTimelifeNew) | |
724 | 901 | then 0 | |
725 | 902 | else valueOrElse(getInteger(this, keySwapUserSpentInPeriod(userAddressStr)), 0) | |
726 | 903 | let blcks2LmtReset = if (isSwapTimelifeNew) | |
727 | 904 | then 0 | |
728 | 905 | else (swapLimitTimelifeBlocks - passedBlocksAfterLastSwap) | |
729 | - | $Tuple2(nil, $ | |
906 | + | $Tuple2(nil, $Tuple7(wavesSwapLimitInUsdnMax, swapLimitSpentInUsdn, blcks2LmtReset, gnsbtAmt, gnsbtAmtTotal, wavesSwapLimitMax, usdnSwapLimitMax)) | |
730 | 907 | } | |
908 | + | ||
909 | + | ||
910 | + | ||
911 | + | @Callable(i) | |
912 | + | func calcWithdrawResultSYSREADONLY (swapType,inAmount,price) = $Tuple2(nil, calcWithdraw(swapType, inAmount, price)) | |
731 | 913 | ||
732 | 914 | ||
733 | 915 | ||
734 | 916 | @Callable(i) | |
735 | 917 | func updateReservesAndNeutrinoSupply () = { | |
736 | 918 | func getNumberByKeyInternal (key) = match getInteger(this, key) { | |
737 | 919 | case a: Int => | |
738 | 920 | a | |
739 | 921 | case _ => | |
740 | 922 | 0 | |
741 | 923 | } | |
742 | 924 | ||
743 | 925 | let nMetrix = asAnyList(invoke(mathContract, "calcNeutinoMetricsREADONLY", nil, nil)) | |
744 | 926 | let idx = getNumberByKeyInternal("updateReservesAndNeutrinoSupplyIdx") | |
745 | 927 | let newIdx = (idx + 1) | |
746 | 928 | [IntegerEntry("updateReservesAndNeutrinoSupplyIdx", newIdx), IntegerEntry("reserve", asInt(nMetrix[3])), IntegerEntry("neutrinoSupply", asInt(nMetrix[5])), IntegerEntry("reservesInUsdn", convertWavesToNeutrino(asInt(nMetrix[3]), asInt(nMetrix[0]))), IntegerEntry("surplus", asInt(nMetrix[6])), IntegerEntry("deficit", -(asInt(nMetrix[6])))] | |
747 | 929 | } | |
748 | 930 | ||
749 | 931 | ||
750 | 932 | ||
751 | 933 | @Callable(i) | |
752 | 934 | func wavesBalancesVsPayment () = { | |
753 | 935 | let b = wavesBalance(this) | |
754 | 936 | [IntegerEntry("wavesBalance_available", b.available), IntegerEntry("wavesBalance_regular", b.regular), IntegerEntry("wavesBalance_generating", b.generating), IntegerEntry("wavesBalance_effective", b.effective), IntegerEntry("waves_payment", value(i.payments[0]).amount)] | |
755 | 937 | } | |
756 | 938 | ||
757 | 939 | ||
758 | 940 | @Verifier(tx) | |
759 | 941 | func verify () = { | |
760 | 942 | let id = toBase58String(tx.id) | |
761 | 943 | let pubKeyAdminsListStr = makeString(["ExtEEK19nmKj9mCpnWyvEEJFYATLMcVEMvohhUHkyHNm", "Ev5py5FfBQX9cZpYKnfQrTB49Byf8QmpZWeDVRim4yV7", "DUuuLjXu98nBwZc7fqwCTjtA3nnRwgTbkMSr5SU2NmDR", "DUuuLjXu98nBwZc7fqwCTjtA3nnRwgTbkMSr5SU2NmDR"], SEP) | |
762 | 944 | let pubKeyAdminsList = split(valueOrElse(getString(controlContract, "%s__multisig"), pubKeyAdminsListStr), SEP) | |
763 | 945 | let count = ((((if (sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String(pubKeyAdminsList[0]))) | |
764 | 946 | then 1 | |
765 | 947 | else 0) + (if (sigVerify(tx.bodyBytes, tx.proofs[1], fromBase58String(pubKeyAdminsList[1]))) | |
766 | 948 | then 1 | |
767 | 949 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[2], fromBase58String(pubKeyAdminsList[2]))) | |
768 | 950 | then 1 | |
769 | 951 | else 0)) + (if (sigVerify(tx.bodyBytes, tx.proofs[3], fromBase58String(pubKeyAdminsList[3]))) | |
770 | 952 | then 2 | |
771 | 953 | else 0)) | |
772 | 954 | match tx { | |
773 | 955 | case sponsorTx: SponsorFeeTransaction => | |
774 | 956 | if (checkIsValidMinSponsoredFee(sponsorTx)) | |
775 | 957 | then (count >= 3) | |
776 | 958 | else false | |
777 | 959 | case _ => | |
778 | 960 | (count >= 3) | |
779 | 961 | } | |
780 | 962 | } | |
781 | 963 |
github/deemru/w8io/026f985 106.21 ms ◑