tx · 9St1E3jNK57fghZT9cW1HjuSCmGpXLgrB3YMxWo6praB 3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn: -0.03500000 Waves 2022.10.12 17:09 [2269237] smart account 3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn > SELF 0.00000000 Waves
{ "type": 13, "id": "9St1E3jNK57fghZT9cW1HjuSCmGpXLgrB3YMxWo6praB", "fee": 3500000, "feeAssetId": null, "timestamp": 1665583718910, "version": 1, "sender": "3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn", "senderPublicKey": "HpuFV1RhaXZ5gaJNgeLjyAKy3D5q7fMKdNFYYbPDafnb", "proofs": [ "5SjNhrKnmPBbiamfhvxz84fhjBgAF4Rjm6DL2rSYbMgB31riAX5NZDqpVXacwFrAq2MCQ3CAyRrpBD2gxSms3tKV" ], "script": "base64:BgJ7CAISAwoBCBIAEgQKAgEEEgMKAQESBAoCAQQSBQoDCAEBEgASBAoCAQESAwoBARIECgIICBIAEgMKAQgSBQoDAQEBEgQKAgEBEgQKAggBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIEgASAwoBARIDCgEBEgQKAggBUgAKbFBkZWNpbWFscwAIAAZzY2FsZTgAgMLXLwAMc2NhbGU4QmlnSW50CQC2AgEAgMLXLwAHc2NhbGUxOAkAtgIBAICAkLu61q3wDQAKemVyb0JpZ0ludAkAtgIBAAAABGJpZzAJALYCAQAAAARiaWcxCQC2AgEAAQAEYmlnMgkAtgIBAAEAC3dhdmVzU3RyaW5nAgVXQVZFUwADU0VQAgJfXwAKUG9vbEFjdGl2ZQABAA9Qb29sUHV0RGlzYWJsZWQAAgATUG9vbE1hdGNoZXJEaXNhYmxlZAADAAxQb29sU2h1dGRvd24ABAAOaWR4UG9vbEFkZHJlc3MAAQANaWR4UG9vbFN0YXR1cwACABBpZHhQb29sTFBBc3NldElkAAMADWlkeEFtdEFzc2V0SWQABAAPaWR4UHJpY2VBc3NldElkAAUADmlkeEFtdEFzc2V0RGNtAAY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ARZrZXlBbGxvd2VkTHBTY3JpcHRIYXNoAAQLY3VycmVudEhhc2gJAPEHAQUEdGhpcwMDCQAAAgULYWxsb3dlZEhhc2gFB25ld0hhc2gJAQIhPQIFC2N1cnJlbnRIYXNoBQduZXdIYXNoBwYJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFD3RhcmdldFB1YmxpY0tleQkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUPdGFyZ2V0UHVibGljS2V5KU/DiA==", "chainId": 84, "height": 2269237, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7A36noPRHhBa32kVCS1GvtYcEm3kEuGL4kpuW4YyJwFe Next: u1iELZx7g1GqhLLRoZgZ3kTbYf3rJDcaz8j3qpLkKQ2 Diff:
Old | New | Differences | |
---|---|---|---|
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | + | ||
14 | + | let big0 = toBigInt(0) | |
15 | + | ||
16 | + | let big1 = toBigInt(1) | |
17 | + | ||
18 | + | let big2 = toBigInt(1) | |
19 | + | ||
20 | + | let wavesString = "WAVES" | |
13 | 21 | ||
14 | 22 | let SEP = "__" | |
15 | 23 | ||
125 | 133 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
126 | 134 | ||
127 | 135 | ||
136 | + | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
137 | + | ||
138 | + | ||
128 | 139 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
129 | 140 | ||
130 | 141 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
142 | 153 | } | |
143 | 154 | ||
144 | 155 | ||
156 | + | func parseAssetId (input) = if ((input == wavesString)) | |
157 | + | then unit | |
158 | + | else fromBase58String(input) | |
159 | + | ||
160 | + | ||
161 | + | func assetIdToString (input) = if ((input == unit)) | |
162 | + | then wavesString | |
163 | + | else toBase58String(value(input)) | |
164 | + | ||
165 | + | ||
166 | + | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolStatus]), fromBase58String(poolConfig[idxPoolLPAssetId]), parseAssetId(poolConfig[idxAmtAssetId]), parseAssetId(poolConfig[idxPriceAssetId]), parseIntValue(poolConfig[idxAmtAssetDcm]), parseIntValue(poolConfig[idxPriceAssetDcm])) | |
167 | + | ||
168 | + | ||
145 | 169 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
146 | 170 | ||
171 | + | ||
172 | + | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
173 | + | ||
174 | + | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
147 | 175 | ||
148 | 176 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
149 | 177 | ||
380 | 408 | } | |
381 | 409 | ||
382 | 410 | ||
411 | + | func emit (amount) = { | |
412 | + | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
413 | + | if ((emitInv == emitInv)) | |
414 | + | then { | |
415 | + | let emitInvLegacy = match emitInv { | |
416 | + | case legacyFactoryContract: Address => | |
417 | + | invoke(legacyFactoryContract, "emit", [amount], nil) | |
418 | + | case _ => | |
419 | + | unit | |
420 | + | } | |
421 | + | if ((emitInvLegacy == emitInvLegacy)) | |
422 | + | then amount | |
423 | + | else throw("Strict value is not equal to itself.") | |
424 | + | } | |
425 | + | else throw("Strict value is not equal to itself.") | |
426 | + | } | |
427 | + | ||
428 | + | ||
429 | + | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
430 | + | let isEval = (txId == unit) | |
431 | + | let $t02148521663 = parsePoolConfig(getPoolConfig()) | |
432 | + | let poolAddress = $t02148521663._1 | |
433 | + | let poolStatus = $t02148521663._2 | |
434 | + | let lpAssetId = $t02148521663._3 | |
435 | + | let amountAssetId = $t02148521663._4 | |
436 | + | let priceAssetId = $t02148521663._5 | |
437 | + | let amountAssetDecimals = $t02148521663._6 | |
438 | + | let priceAssetDecimals = $t02148521663._7 | |
439 | + | let paymentAmount = paymentAmountRaw | |
440 | + | let balanceRaw = if ((paymentAssetId == amountAssetId)) | |
441 | + | then getAccBalance(assetIdToString(amountAssetId)) | |
442 | + | else if ((paymentAssetId == priceAssetId)) | |
443 | + | then getAccBalance(assetIdToString(priceAssetId)) | |
444 | + | else throwErr("invalid asset") | |
445 | + | let amountToSubtract = if (isEval) | |
446 | + | then 0 | |
447 | + | else paymentAmount | |
448 | + | let balance = (balanceRaw - amountToSubtract) | |
449 | + | let balanceBigInt = toBigInt(balance) | |
450 | + | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(lpAssetId), (("asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity) | |
451 | + | let depositBigInt = toBigInt(paymentAmount) | |
452 | + | let issueAmount = ((supplyBigInt * (sqrtBigInt((scale8BigInt + ((depositBigInt * scale8BigInt) / balanceBigInt)), 8, 8, DOWN) - scale8BigInt)) / scale8BigInt) | |
453 | + | toInt(issueAmount) | |
454 | + | } | |
455 | + | ||
456 | + | ||
457 | + | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
458 | + | let isEval = (txId == unit) | |
459 | + | let $t02267122849 = parsePoolConfig(getPoolConfig()) | |
460 | + | let poolAddress = $t02267122849._1 | |
461 | + | let poolStatus = $t02267122849._2 | |
462 | + | let lpAssetId = $t02267122849._3 | |
463 | + | let amountAssetId = $t02267122849._4 | |
464 | + | let priceAssetId = $t02267122849._5 | |
465 | + | let amountAssetDecimals = $t02267122849._6 | |
466 | + | let priceAssetDecimals = $t02267122849._7 | |
467 | + | let checks = [if ((paymentAssetId == lpAssetId)) | |
468 | + | then true | |
469 | + | else throw("invalid lp asset")] | |
470 | + | if ((checks == checks)) | |
471 | + | then { | |
472 | + | let balanceBigInt = if ((outAssetId == amountAssetId)) | |
473 | + | then toBigInt(getAccBalance(assetIdToString(amountAssetId))) | |
474 | + | else if ((outAssetId == priceAssetId)) | |
475 | + | then toBigInt(getAccBalance(assetIdToString(priceAssetId))) | |
476 | + | else throwErr("invalid asset") | |
477 | + | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(lpAssetId), (("asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity) | |
478 | + | let redeemedBigInt = toBigInt(paymentAmount) | |
479 | + | let amount = ((balanceBigInt * (scale8BigInt - pow((scale8BigInt - ((redeemedBigInt * scale8BigInt) / supplyBigInt)), 8, big2, 0, 8, DOWN))) / scale8BigInt) | |
480 | + | toInt(amount) | |
481 | + | } | |
482 | + | else throw("Strict value is not equal to itself.") | |
483 | + | } | |
484 | + | ||
485 | + | ||
383 | 486 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
384 | 487 | case s: String => | |
385 | 488 | fromBase58String(s) | |
418 | 521 | ||
419 | 522 | ||
420 | 523 | @Callable(i) | |
421 | - | func constructor (factoryContract) = { | |
422 | - | let checkCaller = mustManager(i) | |
423 | - | if ((checkCaller == checkCaller)) | |
424 | - | then [StringEntry(fc(), factoryContract)] | |
425 | - | else throw("Strict value is not equal to itself.") | |
426 | - | } | |
427 | - | ||
428 | - | ||
429 | - | ||
430 | - | @Callable(i) | |
431 | 524 | func setManager (pendingManagerPublicKey) = { | |
432 | 525 | let checkCaller = mustManager(i) | |
433 | 526 | if ((checkCaller == checkCaller)) | |
463 | 556 | ||
464 | 557 | ||
465 | 558 | @Callable(i) | |
466 | - | func put (slippageTolerance,shouldAutoStake) = { | |
467 | - | let factoryCfg = getFactoryConfig() | |
468 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.") | |
469 | - | let slippageContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactorySlippageContract]), "Error. Incorrect slippage contract address.") | |
470 | - | if ((0 > slippageTolerance)) | |
471 | - | then throw("Invalid slippageTolerance passed") | |
472 | - | else { | |
473 | - | let estPut = commonPut(i, slippageTolerance, true) | |
474 | - | let emitLpAmt = estPut._2 | |
475 | - | let lpAssetId = estPut._7 | |
476 | - | let state = estPut._9 | |
477 | - | let amDiff = estPut._10 | |
478 | - | let prDiff = estPut._11 | |
479 | - | let amId = estPut._12 | |
480 | - | let prId = estPut._13 | |
481 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
482 | - | if ((emitInv == emitInv)) | |
483 | - | then { | |
484 | - | let emitInvLegacy = match emitInv { | |
485 | - | case legacyFactoryContract: Address => | |
486 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
487 | - | case _ => | |
488 | - | unit | |
489 | - | } | |
490 | - | if ((emitInvLegacy == emitInvLegacy)) | |
491 | - | then { | |
492 | - | let slippageAInv = if ((amDiff > 0)) | |
493 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
494 | - | else nil | |
495 | - | if ((slippageAInv == slippageAInv)) | |
496 | - | then { | |
497 | - | let slippagePInv = if ((prDiff > 0)) | |
498 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
499 | - | else nil | |
500 | - | if ((slippagePInv == slippagePInv)) | |
501 | - | then { | |
502 | - | let lpTransfer = if (shouldAutoStake) | |
503 | - | then { | |
504 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
505 | - | if ((slpStakeInv == slpStakeInv)) | |
506 | - | then nil | |
507 | - | else throw("Strict value is not equal to itself.") | |
508 | - | } | |
509 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
510 | - | (state ++ lpTransfer) | |
511 | - | } | |
512 | - | else throw("Strict value is not equal to itself.") | |
513 | - | } | |
514 | - | else throw("Strict value is not equal to itself.") | |
515 | - | } | |
516 | - | else throw("Strict value is not equal to itself.") | |
517 | - | } | |
518 | - | else throw("Strict value is not equal to itself.") | |
519 | - | } | |
520 | - | } | |
559 | + | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
560 | + | then throw("Invalid slippageTolerance passed") | |
561 | + | else { | |
562 | + | let estPut = commonPut(i, slippageTolerance, true) | |
563 | + | let emitLpAmt = estPut._2 | |
564 | + | let lpAssetId = estPut._7 | |
565 | + | let state = estPut._9 | |
566 | + | let amDiff = estPut._10 | |
567 | + | let prDiff = estPut._11 | |
568 | + | let amId = estPut._12 | |
569 | + | let prId = estPut._13 | |
570 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
571 | + | if ((emitInv == emitInv)) | |
572 | + | then { | |
573 | + | let emitInvLegacy = match emitInv { | |
574 | + | case legacyFactoryContract: Address => | |
575 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
576 | + | case _ => | |
577 | + | unit | |
578 | + | } | |
579 | + | if ((emitInvLegacy == emitInvLegacy)) | |
580 | + | then { | |
581 | + | let slippageAInv = if ((amDiff > 0)) | |
582 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
583 | + | else nil | |
584 | + | if ((slippageAInv == slippageAInv)) | |
585 | + | then { | |
586 | + | let slippagePInv = if ((prDiff > 0)) | |
587 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
588 | + | else nil | |
589 | + | if ((slippagePInv == slippagePInv)) | |
590 | + | then { | |
591 | + | let lpTransfer = if (shouldAutoStake) | |
592 | + | then { | |
593 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
594 | + | if ((slpStakeInv == slpStakeInv)) | |
595 | + | then nil | |
596 | + | else throw("Strict value is not equal to itself.") | |
597 | + | } | |
598 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
599 | + | (state ++ lpTransfer) | |
600 | + | } | |
601 | + | else throw("Strict value is not equal to itself.") | |
602 | + | } | |
603 | + | else throw("Strict value is not equal to itself.") | |
604 | + | } | |
605 | + | else throw("Strict value is not equal to itself.") | |
606 | + | } | |
607 | + | else throw("Strict value is not equal to itself.") | |
608 | + | } | |
521 | 609 | ||
522 | 610 | ||
523 | 611 | ||
528 | 616 | let estPut = commonPut(i, maxSlippage, false) | |
529 | 617 | estPut._9 | |
530 | 618 | } | |
619 | + | ||
620 | + | ||
621 | + | ||
622 | + | @Callable(i) | |
623 | + | func putOneTkn (minOutAmount,autoStake) = { | |
624 | + | let $t02675626934 = parsePoolConfig(getPoolConfig()) | |
625 | + | let poolAddress = $t02675626934._1 | |
626 | + | let poolStatus = $t02675626934._2 | |
627 | + | let lpAssetId = $t02675626934._3 | |
628 | + | let amountAssetId = $t02675626934._4 | |
629 | + | let priceAssetId = $t02675626934._5 | |
630 | + | let amountAssetDecimals = $t02675626934._6 | |
631 | + | let priceAssetDecimals = $t02675626934._7 | |
632 | + | let isPutDisabled = if (if (isGlobalShutdown()) | |
633 | + | then true | |
634 | + | else (poolStatus == PoolPutDisabled)) | |
635 | + | then true | |
636 | + | else (poolStatus == PoolShutdown) | |
637 | + | let checks = [if (!(isPutDisabled)) | |
638 | + | then true | |
639 | + | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
640 | + | then true | |
641 | + | else throwErr("exactly 1 payment are expected")] | |
642 | + | if ((checks == checks)) | |
643 | + | then { | |
644 | + | let payment = i.payments[0] | |
645 | + | let paymentAssetId = payment.assetId | |
646 | + | let paymentAmountRaw = payment.amount | |
647 | + | let paymentAmount = paymentAmountRaw | |
648 | + | let userAddress = i.caller | |
649 | + | let txId = i.transactionId | |
650 | + | let emitAmount = { | |
651 | + | let emitAmountEstimated = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
652 | + | if (if ((minOutAmount > 0)) | |
653 | + | then (minOutAmount > emitAmountEstimated) | |
654 | + | else false) | |
655 | + | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
656 | + | else emitAmountEstimated | |
657 | + | } | |
658 | + | let emitInv = emit(emitAmount) | |
659 | + | if ((emitInv == emitInv)) | |
660 | + | then { | |
661 | + | let lpTransfer = if (autoStake) | |
662 | + | then { | |
663 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitAmount)]) | |
664 | + | if ((stakeInv == stakeInv)) | |
665 | + | then nil | |
666 | + | else throw("Strict value is not equal to itself.") | |
667 | + | } | |
668 | + | else [ScriptTransfer(i.caller, emitAmount, lpAssetId)] | |
669 | + | $Tuple2(lpTransfer, emitAmount) | |
670 | + | } | |
671 | + | else throw("Strict value is not equal to itself.") | |
672 | + | } | |
673 | + | else throw("Strict value is not equal to itself.") | |
674 | + | } | |
675 | + | ||
676 | + | ||
677 | + | ||
678 | + | @Callable(i) | |
679 | + | func getOneTkn (outAssetId,minOutAmount,unstakeAmount) = { | |
680 | + | let $t02816728345 = parsePoolConfig(getPoolConfig()) | |
681 | + | let poolAddress = $t02816728345._1 | |
682 | + | let poolStatus = $t02816728345._2 | |
683 | + | let lpAssetId = $t02816728345._3 | |
684 | + | let amountAssetId = $t02816728345._4 | |
685 | + | let priceAssetId = $t02816728345._5 | |
686 | + | let amountAssetDecimals = $t02816728345._6 | |
687 | + | let priceAssetDecimals = $t02816728345._7 | |
688 | + | let isGetDisabled = if (isGlobalShutdown()) | |
689 | + | then true | |
690 | + | else (poolStatus == PoolShutdown) | |
691 | + | let checks = [if (!(isGetDisabled)) | |
692 | + | then true | |
693 | + | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
694 | + | then true | |
695 | + | else throwErr("exactly 1 payment are expected")] | |
696 | + | if ((checks == checks)) | |
697 | + | then { | |
698 | + | let payment = i.payments[0] | |
699 | + | let paymentAssetId = payment.assetId | |
700 | + | let paymentAmount = payment.amount | |
701 | + | let userAddress = i.caller | |
702 | + | let txId = i.transactionId | |
703 | + | let amount = { | |
704 | + | let amountEstimated = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, paymentAssetId, userAddress, txId) | |
705 | + | if (if ((minOutAmount > 0)) | |
706 | + | then (minOutAmount > amountEstimated) | |
707 | + | else false) | |
708 | + | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
709 | + | else amountEstimated | |
710 | + | } | |
711 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
712 | + | if ((burnInv == burnInv)) | |
713 | + | then { | |
714 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, parseAssetId(outAssetId))] | |
715 | + | $Tuple2(assetTransfer, amount) | |
716 | + | } | |
717 | + | else throw("Strict value is not equal to itself.") | |
718 | + | } | |
719 | + | else throw("Strict value is not equal to itself.") | |
720 | + | } | |
531 | 721 | ||
532 | 722 | ||
533 | 723 | ||
577 | 767 | if ((checkPayments == checkPayments)) | |
578 | 768 | then { | |
579 | 769 | let cfg = getPoolConfig() | |
580 | - | let factoryCfg = getFactoryConfig() | |
581 | 770 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
582 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.") | |
583 | 771 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
584 | 772 | if ((unstakeInv == unstakeInv)) | |
585 | 773 | then { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | + | ||
14 | + | let big0 = toBigInt(0) | |
15 | + | ||
16 | + | let big1 = toBigInt(1) | |
17 | + | ||
18 | + | let big2 = toBigInt(1) | |
19 | + | ||
20 | + | let wavesString = "WAVES" | |
13 | 21 | ||
14 | 22 | let SEP = "__" | |
15 | 23 | ||
16 | 24 | let PoolActive = 1 | |
17 | 25 | ||
18 | 26 | let PoolPutDisabled = 2 | |
19 | 27 | ||
20 | 28 | let PoolMatcherDisabled = 3 | |
21 | 29 | ||
22 | 30 | let PoolShutdown = 4 | |
23 | 31 | ||
24 | 32 | let idxPoolAddress = 1 | |
25 | 33 | ||
26 | 34 | let idxPoolStatus = 2 | |
27 | 35 | ||
28 | 36 | let idxPoolLPAssetId = 3 | |
29 | 37 | ||
30 | 38 | let idxAmtAssetId = 4 | |
31 | 39 | ||
32 | 40 | let idxPriceAssetId = 5 | |
33 | 41 | ||
34 | 42 | let idxAmtAssetDcm = 6 | |
35 | 43 | ||
36 | 44 | let idxPriceAssetDcm = 7 | |
37 | 45 | ||
38 | 46 | let idxIAmtAssetId = 8 | |
39 | 47 | ||
40 | 48 | let idxIPriceAssetId = 9 | |
41 | 49 | ||
42 | 50 | let idxLPAssetDcm = 10 | |
43 | 51 | ||
44 | 52 | let idxPoolAmtAssetAmt = 1 | |
45 | 53 | ||
46 | 54 | let idxPoolPriceAssetAmt = 2 | |
47 | 55 | ||
48 | 56 | let idxPoolLPAssetAmt = 3 | |
49 | 57 | ||
50 | 58 | let idxFactoryStakingContract = 1 | |
51 | 59 | ||
52 | 60 | let idxFactorySlippageContract = 7 | |
53 | 61 | ||
54 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
55 | 63 | ||
56 | 64 | ||
57 | 65 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
58 | 66 | ||
59 | 67 | ||
60 | 68 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
61 | 69 | ||
62 | 70 | ||
63 | 71 | func abs (val) = if ((zeroBigInt > val)) | |
64 | 72 | then -(val) | |
65 | 73 | else val | |
66 | 74 | ||
67 | 75 | ||
68 | 76 | func fc () = "%s__factoryContract" | |
69 | 77 | ||
70 | 78 | ||
71 | 79 | func mpk () = "%s__managerPublicKey" | |
72 | 80 | ||
73 | 81 | ||
74 | 82 | func pmpk () = "%s__pendingManagerPublicKey" | |
75 | 83 | ||
76 | 84 | ||
77 | 85 | func pl () = "%s%s__price__last" | |
78 | 86 | ||
79 | 87 | ||
80 | 88 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
81 | 89 | ||
82 | 90 | ||
83 | 91 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
84 | 92 | ||
85 | 93 | ||
86 | 94 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
87 | 95 | ||
88 | 96 | ||
89 | 97 | func aa () = "%s__amountAsset" | |
90 | 98 | ||
91 | 99 | ||
92 | 100 | func pa () = "%s__priceAsset" | |
93 | 101 | ||
94 | 102 | ||
95 | 103 | func keyFactoryConfig () = "%s__factoryConfig" | |
96 | 104 | ||
97 | 105 | ||
98 | 106 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
99 | 107 | ||
100 | 108 | ||
101 | 109 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
102 | 110 | ||
103 | 111 | ||
104 | 112 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
105 | 113 | ||
106 | 114 | ||
107 | 115 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
108 | 116 | ||
109 | 117 | ||
110 | 118 | func keyAllPoolsShutdown () = "%s__shutdown" | |
111 | 119 | ||
112 | 120 | ||
113 | 121 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
114 | 122 | ||
115 | 123 | ||
116 | 124 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
117 | 125 | ||
118 | 126 | ||
119 | 127 | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
120 | 128 | ||
121 | 129 | ||
122 | 130 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
123 | 131 | ||
124 | 132 | ||
125 | 133 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
126 | 134 | ||
127 | 135 | ||
136 | + | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
137 | + | ||
138 | + | ||
128 | 139 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
129 | 140 | ||
130 | 141 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
131 | 142 | ||
132 | 143 | ||
133 | 144 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
134 | 145 | ||
135 | 146 | ||
136 | 147 | func getPoolConfig () = { | |
137 | 148 | let amtAsset = getStringOrFail(this, aa()) | |
138 | 149 | let priceAsset = getStringOrFail(this, pa()) | |
139 | 150 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
140 | 151 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
141 | 152 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
142 | 153 | } | |
143 | 154 | ||
144 | 155 | ||
156 | + | func parseAssetId (input) = if ((input == wavesString)) | |
157 | + | then unit | |
158 | + | else fromBase58String(input) | |
159 | + | ||
160 | + | ||
161 | + | func assetIdToString (input) = if ((input == unit)) | |
162 | + | then wavesString | |
163 | + | else toBase58String(value(input)) | |
164 | + | ||
165 | + | ||
166 | + | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolStatus]), fromBase58String(poolConfig[idxPoolLPAssetId]), parseAssetId(poolConfig[idxAmtAssetId]), parseAssetId(poolConfig[idxPriceAssetId]), parseIntValue(poolConfig[idxAmtAssetDcm]), parseIntValue(poolConfig[idxPriceAssetDcm])) | |
167 | + | ||
168 | + | ||
145 | 169 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
146 | 170 | ||
171 | + | ||
172 | + | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
173 | + | ||
174 | + | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
147 | 175 | ||
148 | 176 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
149 | 177 | ||
150 | 178 | ||
151 | 179 | func dataGetActionInfo (outAmtAssetAmt,outPriceAssetAmt,inLpAmt,price,txHeight,txTimestamp) = makeString(["%d%d%d%d%d%d", toString(outAmtAssetAmt), toString(outPriceAssetAmt), toString(inLpAmt), toString(price), toString(txHeight), toString(txTimestamp)], SEP) | |
152 | 180 | ||
153 | 181 | ||
154 | 182 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
155 | 183 | then wavesBalance(this).available | |
156 | 184 | else assetBalance(this, fromBase58String(assetId)) | |
157 | 185 | ||
158 | 186 | ||
159 | 187 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
160 | 188 | ||
161 | 189 | ||
162 | 190 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
163 | 191 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
164 | 192 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
165 | 193 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
166 | 194 | } | |
167 | 195 | ||
168 | 196 | ||
169 | 197 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
170 | 198 | let cfg = getPoolConfig() | |
171 | 199 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
172 | 200 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
173 | 201 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
174 | 202 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
175 | 203 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
176 | 204 | let lpAmtX18 = toX18(lpAmt, scale8) | |
177 | 205 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
178 | 206 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
179 | 207 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
180 | 208 | } | |
181 | 209 | ||
182 | 210 | ||
183 | 211 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
184 | 212 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
185 | 213 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
186 | 214 | } | |
187 | 215 | ||
188 | 216 | ||
189 | 217 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
190 | 218 | let cfg = getPoolConfig() | |
191 | 219 | let lpAssetId = cfg[idxPoolLPAssetId] | |
192 | 220 | let amAssetId = cfg[idxAmtAssetId] | |
193 | 221 | let prAssetId = cfg[idxPriceAssetId] | |
194 | 222 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
195 | 223 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
196 | 224 | let poolStatus = cfg[idxPoolStatus] | |
197 | 225 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
198 | 226 | if ((lpAssetId != pmtAssetId)) | |
199 | 227 | then throw("Invalid asset passed.") | |
200 | 228 | else { | |
201 | 229 | let amBalance = getAccBalance(amAssetId) | |
202 | 230 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
203 | 231 | let prBalance = getAccBalance(prAssetId) | |
204 | 232 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
205 | 233 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
206 | 234 | let curPrice = fromX18(curPriceX18, scale8) | |
207 | 235 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
208 | 236 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
209 | 237 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
210 | 238 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
211 | 239 | let outAmAmt = fromX18(outAmAmtX18, amAssetDcm) | |
212 | 240 | let outPrAmt = fromX18(outPrAmtX18, prAssetDcm) | |
213 | 241 | let state = if ((txId58 == "")) | |
214 | 242 | then nil | |
215 | 243 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
216 | 244 | then unit | |
217 | 245 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
218 | 246 | then unit | |
219 | 247 | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
220 | 248 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
221 | 249 | } | |
222 | 250 | } | |
223 | 251 | ||
224 | 252 | ||
225 | 253 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
226 | 254 | let cfg = getPoolConfig() | |
227 | 255 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
228 | 256 | let amAssetIdStr = cfg[idxAmtAssetId] | |
229 | 257 | let prAssetIdStr = cfg[idxPriceAssetId] | |
230 | 258 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
231 | 259 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
232 | 260 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
233 | 261 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
234 | 262 | let poolStatus = cfg[idxPoolStatus] | |
235 | 263 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
236 | 264 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
237 | 265 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
238 | 266 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
239 | 267 | then true | |
240 | 268 | else (prAssetIdStr != inPrAssetIdStr)) | |
241 | 269 | then throw("Invalid amt or price asset passed.") | |
242 | 270 | else { | |
243 | 271 | let amBalance = if (isEvaluate) | |
244 | 272 | then getAccBalance(amAssetIdStr) | |
245 | 273 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
246 | 274 | let prBalance = if (isEvaluate) | |
247 | 275 | then getAccBalance(prAssetIdStr) | |
248 | 276 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
249 | 277 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
250 | 278 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
251 | 279 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
252 | 280 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
253 | 281 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
254 | 282 | let res = if ((lpEmission == 0)) | |
255 | 283 | then { | |
256 | 284 | let curPriceX18 = zeroBigInt | |
257 | 285 | let slippageX18 = zeroBigInt | |
258 | 286 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
259 | 287 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
260 | 288 | } | |
261 | 289 | else { | |
262 | 290 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
263 | 291 | let slippageX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
264 | 292 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
265 | 293 | if (if ((curPriceX18 != zeroBigInt)) | |
266 | 294 | then (slippageX18 > slippageToleranceX18) | |
267 | 295 | else false) | |
268 | 296 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
269 | 297 | else { | |
270 | 298 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
271 | 299 | let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
272 | 300 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
273 | 301 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
274 | 302 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
275 | 303 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
276 | 304 | let expAmtAssetAmtX18 = expectedAmts._1 | |
277 | 305 | let expPriceAssetAmtX18 = expectedAmts._2 | |
278 | 306 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
279 | 307 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18) | |
280 | 308 | } | |
281 | 309 | } | |
282 | 310 | let calcLpAmt = res._1 | |
283 | 311 | let calcAmAssetPmt = res._2 | |
284 | 312 | let calcPrAssetPmt = res._3 | |
285 | 313 | let curPrice = fromX18(res._4, scale8) | |
286 | 314 | let slippageCalc = fromX18(res._5, scale8) | |
287 | 315 | if ((0 >= calcLpAmt)) | |
288 | 316 | then throw("Invalid calculations. LP calculated is less than zero.") | |
289 | 317 | else { | |
290 | 318 | let emitLpAmt = if (!(emitLp)) | |
291 | 319 | then 0 | |
292 | 320 | else calcLpAmt | |
293 | 321 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
294 | 322 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
295 | 323 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
296 | 324 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
297 | 325 | } | |
298 | 326 | } | |
299 | 327 | } | |
300 | 328 | ||
301 | 329 | ||
302 | 330 | func validateMatcherOrderAllowed (order) = { | |
303 | 331 | let cfg = getPoolConfig() | |
304 | 332 | let amtAssetId = cfg[idxAmtAssetId] | |
305 | 333 | let priceAssetId = cfg[idxPriceAssetId] | |
306 | 334 | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
307 | 335 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
308 | 336 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
309 | 337 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
310 | 338 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
311 | 339 | let curPriceX18 = if ((order.orderType == Buy)) | |
312 | 340 | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
313 | 341 | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
314 | 342 | let curPrice = fromX18(curPriceX18, scale8) | |
315 | 343 | if (if (if (isGlobalShutdown()) | |
316 | 344 | then true | |
317 | 345 | else (poolStatus == PoolMatcherDisabled)) | |
318 | 346 | then true | |
319 | 347 | else (poolStatus == PoolShutdown)) | |
320 | 348 | then throw("Exchange operations disabled") | |
321 | 349 | else { | |
322 | 350 | let orderAmtAsset = order.assetPair.amountAsset | |
323 | 351 | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
324 | 352 | then "WAVES" | |
325 | 353 | else toBase58String(value(orderAmtAsset)) | |
326 | 354 | let orderPriceAsset = order.assetPair.priceAsset | |
327 | 355 | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
328 | 356 | then "WAVES" | |
329 | 357 | else toBase58String(value(orderPriceAsset)) | |
330 | 358 | if (if ((orderAmtAssetStr != amtAssetId)) | |
331 | 359 | then true | |
332 | 360 | else (orderPriceAssetStr != priceAssetId)) | |
333 | 361 | then throw("Wrong order assets.") | |
334 | 362 | else { | |
335 | 363 | let orderPrice = order.price | |
336 | 364 | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
337 | 365 | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
338 | 366 | let isOrderPriceValid = if ((order.orderType == Buy)) | |
339 | 367 | then (curPrice >= castedOrderPrice) | |
340 | 368 | else (castedOrderPrice >= curPrice) | |
341 | 369 | true | |
342 | 370 | } | |
343 | 371 | } | |
344 | 372 | } | |
345 | 373 | ||
346 | 374 | ||
347 | 375 | func commonGet (i) = if ((size(i.payments) != 1)) | |
348 | 376 | then throw("exactly 1 payment is expected") | |
349 | 377 | else { | |
350 | 378 | let pmt = value(i.payments[0]) | |
351 | 379 | let pmtAssetId = value(pmt.assetId) | |
352 | 380 | let pmtAmt = pmt.amount | |
353 | 381 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
354 | 382 | let outAmAmt = res._1 | |
355 | 383 | let outPrAmt = res._2 | |
356 | 384 | let poolStatus = parseIntValue(res._9) | |
357 | 385 | let state = res._10 | |
358 | 386 | if (if (isGlobalShutdown()) | |
359 | 387 | then true | |
360 | 388 | else (poolStatus == PoolShutdown)) | |
361 | 389 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
362 | 390 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
363 | 391 | } | |
364 | 392 | ||
365 | 393 | ||
366 | 394 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
367 | 395 | then throw("exactly 2 payments are expected") | |
368 | 396 | else { | |
369 | 397 | let amAssetPmt = value(i.payments[0]) | |
370 | 398 | let prAssetPmt = value(i.payments[1]) | |
371 | 399 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
372 | 400 | let poolStatus = parseIntValue(estPut._8) | |
373 | 401 | if (if (if (isGlobalShutdown()) | |
374 | 402 | then true | |
375 | 403 | else (poolStatus == PoolPutDisabled)) | |
376 | 404 | then true | |
377 | 405 | else (poolStatus == PoolShutdown)) | |
378 | 406 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
379 | 407 | else estPut | |
380 | 408 | } | |
381 | 409 | ||
382 | 410 | ||
411 | + | func emit (amount) = { | |
412 | + | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
413 | + | if ((emitInv == emitInv)) | |
414 | + | then { | |
415 | + | let emitInvLegacy = match emitInv { | |
416 | + | case legacyFactoryContract: Address => | |
417 | + | invoke(legacyFactoryContract, "emit", [amount], nil) | |
418 | + | case _ => | |
419 | + | unit | |
420 | + | } | |
421 | + | if ((emitInvLegacy == emitInvLegacy)) | |
422 | + | then amount | |
423 | + | else throw("Strict value is not equal to itself.") | |
424 | + | } | |
425 | + | else throw("Strict value is not equal to itself.") | |
426 | + | } | |
427 | + | ||
428 | + | ||
429 | + | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
430 | + | let isEval = (txId == unit) | |
431 | + | let $t02148521663 = parsePoolConfig(getPoolConfig()) | |
432 | + | let poolAddress = $t02148521663._1 | |
433 | + | let poolStatus = $t02148521663._2 | |
434 | + | let lpAssetId = $t02148521663._3 | |
435 | + | let amountAssetId = $t02148521663._4 | |
436 | + | let priceAssetId = $t02148521663._5 | |
437 | + | let amountAssetDecimals = $t02148521663._6 | |
438 | + | let priceAssetDecimals = $t02148521663._7 | |
439 | + | let paymentAmount = paymentAmountRaw | |
440 | + | let balanceRaw = if ((paymentAssetId == amountAssetId)) | |
441 | + | then getAccBalance(assetIdToString(amountAssetId)) | |
442 | + | else if ((paymentAssetId == priceAssetId)) | |
443 | + | then getAccBalance(assetIdToString(priceAssetId)) | |
444 | + | else throwErr("invalid asset") | |
445 | + | let amountToSubtract = if (isEval) | |
446 | + | then 0 | |
447 | + | else paymentAmount | |
448 | + | let balance = (balanceRaw - amountToSubtract) | |
449 | + | let balanceBigInt = toBigInt(balance) | |
450 | + | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(lpAssetId), (("asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity) | |
451 | + | let depositBigInt = toBigInt(paymentAmount) | |
452 | + | let issueAmount = ((supplyBigInt * (sqrtBigInt((scale8BigInt + ((depositBigInt * scale8BigInt) / balanceBigInt)), 8, 8, DOWN) - scale8BigInt)) / scale8BigInt) | |
453 | + | toInt(issueAmount) | |
454 | + | } | |
455 | + | ||
456 | + | ||
457 | + | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
458 | + | let isEval = (txId == unit) | |
459 | + | let $t02267122849 = parsePoolConfig(getPoolConfig()) | |
460 | + | let poolAddress = $t02267122849._1 | |
461 | + | let poolStatus = $t02267122849._2 | |
462 | + | let lpAssetId = $t02267122849._3 | |
463 | + | let amountAssetId = $t02267122849._4 | |
464 | + | let priceAssetId = $t02267122849._5 | |
465 | + | let amountAssetDecimals = $t02267122849._6 | |
466 | + | let priceAssetDecimals = $t02267122849._7 | |
467 | + | let checks = [if ((paymentAssetId == lpAssetId)) | |
468 | + | then true | |
469 | + | else throw("invalid lp asset")] | |
470 | + | if ((checks == checks)) | |
471 | + | then { | |
472 | + | let balanceBigInt = if ((outAssetId == amountAssetId)) | |
473 | + | then toBigInt(getAccBalance(assetIdToString(amountAssetId))) | |
474 | + | else if ((outAssetId == priceAssetId)) | |
475 | + | then toBigInt(getAccBalance(assetIdToString(priceAssetId))) | |
476 | + | else throwErr("invalid asset") | |
477 | + | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(lpAssetId), (("asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity) | |
478 | + | let redeemedBigInt = toBigInt(paymentAmount) | |
479 | + | let amount = ((balanceBigInt * (scale8BigInt - pow((scale8BigInt - ((redeemedBigInt * scale8BigInt) / supplyBigInt)), 8, big2, 0, 8, DOWN))) / scale8BigInt) | |
480 | + | toInt(amount) | |
481 | + | } | |
482 | + | else throw("Strict value is not equal to itself.") | |
483 | + | } | |
484 | + | ||
485 | + | ||
383 | 486 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
384 | 487 | case s: String => | |
385 | 488 | fromBase58String(s) | |
386 | 489 | case _: Unit => | |
387 | 490 | unit | |
388 | 491 | case _ => | |
389 | 492 | throw("Match error") | |
390 | 493 | } | |
391 | 494 | ||
392 | 495 | ||
393 | 496 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
394 | 497 | case s: String => | |
395 | 498 | fromBase58String(s) | |
396 | 499 | case _: Unit => | |
397 | 500 | unit | |
398 | 501 | case _ => | |
399 | 502 | throw("Match error") | |
400 | 503 | } | |
401 | 504 | ||
402 | 505 | ||
403 | 506 | func mustManager (i) = { | |
404 | 507 | let pd = throw("Permission denied") | |
405 | 508 | match managerPublicKeyOrUnit() { | |
406 | 509 | case pk: ByteVector => | |
407 | 510 | if ((i.callerPublicKey == pk)) | |
408 | 511 | then true | |
409 | 512 | else pd | |
410 | 513 | case _: Unit => | |
411 | 514 | if ((i.caller == this)) | |
412 | 515 | then true | |
413 | 516 | else pd | |
414 | 517 | case _ => | |
415 | 518 | throw("Match error") | |
416 | 519 | } | |
417 | 520 | } | |
418 | 521 | ||
419 | 522 | ||
420 | 523 | @Callable(i) | |
421 | - | func constructor (factoryContract) = { | |
422 | - | let checkCaller = mustManager(i) | |
423 | - | if ((checkCaller == checkCaller)) | |
424 | - | then [StringEntry(fc(), factoryContract)] | |
425 | - | else throw("Strict value is not equal to itself.") | |
426 | - | } | |
427 | - | ||
428 | - | ||
429 | - | ||
430 | - | @Callable(i) | |
431 | 524 | func setManager (pendingManagerPublicKey) = { | |
432 | 525 | let checkCaller = mustManager(i) | |
433 | 526 | if ((checkCaller == checkCaller)) | |
434 | 527 | then { | |
435 | 528 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
436 | 529 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
437 | 530 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
438 | 531 | else throw("Strict value is not equal to itself.") | |
439 | 532 | } | |
440 | 533 | else throw("Strict value is not equal to itself.") | |
441 | 534 | } | |
442 | 535 | ||
443 | 536 | ||
444 | 537 | ||
445 | 538 | @Callable(i) | |
446 | 539 | func confirmManager () = { | |
447 | 540 | let pm = pendingManagerPublicKeyOrUnit() | |
448 | 541 | let hasPM = if (isDefined(pm)) | |
449 | 542 | then true | |
450 | 543 | else throw("No pending manager") | |
451 | 544 | if ((hasPM == hasPM)) | |
452 | 545 | then { | |
453 | 546 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
454 | 547 | then true | |
455 | 548 | else throw("You are not pending manager") | |
456 | 549 | if ((checkPM == checkPM)) | |
457 | 550 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
458 | 551 | else throw("Strict value is not equal to itself.") | |
459 | 552 | } | |
460 | 553 | else throw("Strict value is not equal to itself.") | |
461 | 554 | } | |
462 | 555 | ||
463 | 556 | ||
464 | 557 | ||
465 | 558 | @Callable(i) | |
466 | - | func put (slippageTolerance,shouldAutoStake) = { | |
467 | - | let factoryCfg = getFactoryConfig() | |
468 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.") | |
469 | - | let slippageContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactorySlippageContract]), "Error. Incorrect slippage contract address.") | |
470 | - | if ((0 > slippageTolerance)) | |
471 | - | then throw("Invalid slippageTolerance passed") | |
472 | - | else { | |
473 | - | let estPut = commonPut(i, slippageTolerance, true) | |
474 | - | let emitLpAmt = estPut._2 | |
475 | - | let lpAssetId = estPut._7 | |
476 | - | let state = estPut._9 | |
477 | - | let amDiff = estPut._10 | |
478 | - | let prDiff = estPut._11 | |
479 | - | let amId = estPut._12 | |
480 | - | let prId = estPut._13 | |
481 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
482 | - | if ((emitInv == emitInv)) | |
483 | - | then { | |
484 | - | let emitInvLegacy = match emitInv { | |
485 | - | case legacyFactoryContract: Address => | |
486 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
487 | - | case _ => | |
488 | - | unit | |
489 | - | } | |
490 | - | if ((emitInvLegacy == emitInvLegacy)) | |
491 | - | then { | |
492 | - | let slippageAInv = if ((amDiff > 0)) | |
493 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
494 | - | else nil | |
495 | - | if ((slippageAInv == slippageAInv)) | |
496 | - | then { | |
497 | - | let slippagePInv = if ((prDiff > 0)) | |
498 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
499 | - | else nil | |
500 | - | if ((slippagePInv == slippagePInv)) | |
501 | - | then { | |
502 | - | let lpTransfer = if (shouldAutoStake) | |
503 | - | then { | |
504 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
505 | - | if ((slpStakeInv == slpStakeInv)) | |
506 | - | then nil | |
507 | - | else throw("Strict value is not equal to itself.") | |
508 | - | } | |
509 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
510 | - | (state ++ lpTransfer) | |
511 | - | } | |
512 | - | else throw("Strict value is not equal to itself.") | |
513 | - | } | |
514 | - | else throw("Strict value is not equal to itself.") | |
515 | - | } | |
516 | - | else throw("Strict value is not equal to itself.") | |
517 | - | } | |
518 | - | else throw("Strict value is not equal to itself.") | |
519 | - | } | |
520 | - | } | |
559 | + | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
560 | + | then throw("Invalid slippageTolerance passed") | |
561 | + | else { | |
562 | + | let estPut = commonPut(i, slippageTolerance, true) | |
563 | + | let emitLpAmt = estPut._2 | |
564 | + | let lpAssetId = estPut._7 | |
565 | + | let state = estPut._9 | |
566 | + | let amDiff = estPut._10 | |
567 | + | let prDiff = estPut._11 | |
568 | + | let amId = estPut._12 | |
569 | + | let prId = estPut._13 | |
570 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
571 | + | if ((emitInv == emitInv)) | |
572 | + | then { | |
573 | + | let emitInvLegacy = match emitInv { | |
574 | + | case legacyFactoryContract: Address => | |
575 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
576 | + | case _ => | |
577 | + | unit | |
578 | + | } | |
579 | + | if ((emitInvLegacy == emitInvLegacy)) | |
580 | + | then { | |
581 | + | let slippageAInv = if ((amDiff > 0)) | |
582 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
583 | + | else nil | |
584 | + | if ((slippageAInv == slippageAInv)) | |
585 | + | then { | |
586 | + | let slippagePInv = if ((prDiff > 0)) | |
587 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
588 | + | else nil | |
589 | + | if ((slippagePInv == slippagePInv)) | |
590 | + | then { | |
591 | + | let lpTransfer = if (shouldAutoStake) | |
592 | + | then { | |
593 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
594 | + | if ((slpStakeInv == slpStakeInv)) | |
595 | + | then nil | |
596 | + | else throw("Strict value is not equal to itself.") | |
597 | + | } | |
598 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
599 | + | (state ++ lpTransfer) | |
600 | + | } | |
601 | + | else throw("Strict value is not equal to itself.") | |
602 | + | } | |
603 | + | else throw("Strict value is not equal to itself.") | |
604 | + | } | |
605 | + | else throw("Strict value is not equal to itself.") | |
606 | + | } | |
607 | + | else throw("Strict value is not equal to itself.") | |
608 | + | } | |
521 | 609 | ||
522 | 610 | ||
523 | 611 | ||
524 | 612 | @Callable(i) | |
525 | 613 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
526 | 614 | then throw("Invalid value passed") | |
527 | 615 | else { | |
528 | 616 | let estPut = commonPut(i, maxSlippage, false) | |
529 | 617 | estPut._9 | |
530 | 618 | } | |
619 | + | ||
620 | + | ||
621 | + | ||
622 | + | @Callable(i) | |
623 | + | func putOneTkn (minOutAmount,autoStake) = { | |
624 | + | let $t02675626934 = parsePoolConfig(getPoolConfig()) | |
625 | + | let poolAddress = $t02675626934._1 | |
626 | + | let poolStatus = $t02675626934._2 | |
627 | + | let lpAssetId = $t02675626934._3 | |
628 | + | let amountAssetId = $t02675626934._4 | |
629 | + | let priceAssetId = $t02675626934._5 | |
630 | + | let amountAssetDecimals = $t02675626934._6 | |
631 | + | let priceAssetDecimals = $t02675626934._7 | |
632 | + | let isPutDisabled = if (if (isGlobalShutdown()) | |
633 | + | then true | |
634 | + | else (poolStatus == PoolPutDisabled)) | |
635 | + | then true | |
636 | + | else (poolStatus == PoolShutdown) | |
637 | + | let checks = [if (!(isPutDisabled)) | |
638 | + | then true | |
639 | + | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
640 | + | then true | |
641 | + | else throwErr("exactly 1 payment are expected")] | |
642 | + | if ((checks == checks)) | |
643 | + | then { | |
644 | + | let payment = i.payments[0] | |
645 | + | let paymentAssetId = payment.assetId | |
646 | + | let paymentAmountRaw = payment.amount | |
647 | + | let paymentAmount = paymentAmountRaw | |
648 | + | let userAddress = i.caller | |
649 | + | let txId = i.transactionId | |
650 | + | let emitAmount = { | |
651 | + | let emitAmountEstimated = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
652 | + | if (if ((minOutAmount > 0)) | |
653 | + | then (minOutAmount > emitAmountEstimated) | |
654 | + | else false) | |
655 | + | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
656 | + | else emitAmountEstimated | |
657 | + | } | |
658 | + | let emitInv = emit(emitAmount) | |
659 | + | if ((emitInv == emitInv)) | |
660 | + | then { | |
661 | + | let lpTransfer = if (autoStake) | |
662 | + | then { | |
663 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitAmount)]) | |
664 | + | if ((stakeInv == stakeInv)) | |
665 | + | then nil | |
666 | + | else throw("Strict value is not equal to itself.") | |
667 | + | } | |
668 | + | else [ScriptTransfer(i.caller, emitAmount, lpAssetId)] | |
669 | + | $Tuple2(lpTransfer, emitAmount) | |
670 | + | } | |
671 | + | else throw("Strict value is not equal to itself.") | |
672 | + | } | |
673 | + | else throw("Strict value is not equal to itself.") | |
674 | + | } | |
675 | + | ||
676 | + | ||
677 | + | ||
678 | + | @Callable(i) | |
679 | + | func getOneTkn (outAssetId,minOutAmount,unstakeAmount) = { | |
680 | + | let $t02816728345 = parsePoolConfig(getPoolConfig()) | |
681 | + | let poolAddress = $t02816728345._1 | |
682 | + | let poolStatus = $t02816728345._2 | |
683 | + | let lpAssetId = $t02816728345._3 | |
684 | + | let amountAssetId = $t02816728345._4 | |
685 | + | let priceAssetId = $t02816728345._5 | |
686 | + | let amountAssetDecimals = $t02816728345._6 | |
687 | + | let priceAssetDecimals = $t02816728345._7 | |
688 | + | let isGetDisabled = if (isGlobalShutdown()) | |
689 | + | then true | |
690 | + | else (poolStatus == PoolShutdown) | |
691 | + | let checks = [if (!(isGetDisabled)) | |
692 | + | then true | |
693 | + | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
694 | + | then true | |
695 | + | else throwErr("exactly 1 payment are expected")] | |
696 | + | if ((checks == checks)) | |
697 | + | then { | |
698 | + | let payment = i.payments[0] | |
699 | + | let paymentAssetId = payment.assetId | |
700 | + | let paymentAmount = payment.amount | |
701 | + | let userAddress = i.caller | |
702 | + | let txId = i.transactionId | |
703 | + | let amount = { | |
704 | + | let amountEstimated = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, paymentAssetId, userAddress, txId) | |
705 | + | if (if ((minOutAmount > 0)) | |
706 | + | then (minOutAmount > amountEstimated) | |
707 | + | else false) | |
708 | + | then throw(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
709 | + | else amountEstimated | |
710 | + | } | |
711 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
712 | + | if ((burnInv == burnInv)) | |
713 | + | then { | |
714 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, parseAssetId(outAssetId))] | |
715 | + | $Tuple2(assetTransfer, amount) | |
716 | + | } | |
717 | + | else throw("Strict value is not equal to itself.") | |
718 | + | } | |
719 | + | else throw("Strict value is not equal to itself.") | |
720 | + | } | |
531 | 721 | ||
532 | 722 | ||
533 | 723 | ||
534 | 724 | @Callable(i) | |
535 | 725 | func get () = { | |
536 | 726 | let res = commonGet(i) | |
537 | 727 | let outAmtAmt = res._1 | |
538 | 728 | let outPrAmt = res._2 | |
539 | 729 | let pmtAmt = res._3 | |
540 | 730 | let pmtAssetId = res._4 | |
541 | 731 | let state = res._5 | |
542 | 732 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
543 | 733 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
544 | 734 | then state | |
545 | 735 | else throw("Strict value is not equal to itself.") | |
546 | 736 | } | |
547 | 737 | ||
548 | 738 | ||
549 | 739 | ||
550 | 740 | @Callable(i) | |
551 | 741 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
552 | 742 | let res = commonGet(i) | |
553 | 743 | let outAmAmt = res._1 | |
554 | 744 | let outPrAmt = res._2 | |
555 | 745 | let pmtAmt = res._3 | |
556 | 746 | let pmtAssetId = res._4 | |
557 | 747 | let state = res._5 | |
558 | 748 | if ((noLessThenAmtAsset > outAmAmt)) | |
559 | 749 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
560 | 750 | else if ((noLessThenPriceAsset > outPrAmt)) | |
561 | 751 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
562 | 752 | else { | |
563 | 753 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
564 | 754 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
565 | 755 | then state | |
566 | 756 | else throw("Strict value is not equal to itself.") | |
567 | 757 | } | |
568 | 758 | } | |
569 | 759 | ||
570 | 760 | ||
571 | 761 | ||
572 | 762 | @Callable(i) | |
573 | 763 | func unstakeAndGet (amount) = { | |
574 | 764 | let checkPayments = if ((size(i.payments) != 0)) | |
575 | 765 | then throw("No payments are expected") | |
576 | 766 | else true | |
577 | 767 | if ((checkPayments == checkPayments)) | |
578 | 768 | then { | |
579 | 769 | let cfg = getPoolConfig() | |
580 | - | let factoryCfg = getFactoryConfig() | |
581 | 770 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
582 | - | let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.") | |
583 | 771 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
584 | 772 | if ((unstakeInv == unstakeInv)) | |
585 | 773 | then { | |
586 | 774 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
587 | 775 | let poolStatus = parseIntValue(res._9) | |
588 | 776 | let state = res._10 | |
589 | 777 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
590 | 778 | then true | |
591 | 779 | else (poolStatus == PoolShutdown)) | |
592 | 780 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
593 | 781 | else true | |
594 | 782 | if ((checkPoolStatus == checkPoolStatus)) | |
595 | 783 | then { | |
596 | 784 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
597 | 785 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
598 | 786 | then state | |
599 | 787 | else throw("Strict value is not equal to itself.") | |
600 | 788 | } | |
601 | 789 | else throw("Strict value is not equal to itself.") | |
602 | 790 | } | |
603 | 791 | else throw("Strict value is not equal to itself.") | |
604 | 792 | } | |
605 | 793 | else throw("Strict value is not equal to itself.") | |
606 | 794 | } | |
607 | 795 | ||
608 | 796 | ||
609 | 797 | ||
610 | 798 | @Callable(i) | |
611 | 799 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
612 | 800 | then throw("permissions denied") | |
613 | 801 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
614 | 802 | ||
615 | 803 | ||
616 | 804 | ||
617 | 805 | @Callable(i) | |
618 | 806 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
619 | 807 | ||
620 | 808 | ||
621 | 809 | ||
622 | 810 | @Callable(i) | |
623 | 811 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
624 | 812 | ||
625 | 813 | ||
626 | 814 | ||
627 | 815 | @Callable(i) | |
628 | 816 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
629 | 817 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
630 | 818 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
631 | 819 | } | |
632 | 820 | ||
633 | 821 | ||
634 | 822 | ||
635 | 823 | @Callable(i) | |
636 | 824 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
637 | 825 | ||
638 | 826 | ||
639 | 827 | ||
640 | 828 | @Callable(i) | |
641 | 829 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
642 | 830 | ||
643 | 831 | ||
644 | 832 | ||
645 | 833 | @Callable(i) | |
646 | 834 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
647 | 835 | ||
648 | 836 | ||
649 | 837 | ||
650 | 838 | @Callable(i) | |
651 | 839 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
652 | 840 | ||
653 | 841 | ||
654 | 842 | ||
655 | 843 | @Callable(i) | |
656 | 844 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
657 | 845 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
658 | 846 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
659 | 847 | } | |
660 | 848 | ||
661 | 849 | ||
662 | 850 | ||
663 | 851 | @Callable(i) | |
664 | 852 | func statsREADONLY () = { | |
665 | 853 | let cfg = getPoolConfig() | |
666 | 854 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
667 | 855 | let amtAssetId = cfg[idxAmtAssetId] | |
668 | 856 | let priceAssetId = cfg[idxPriceAssetId] | |
669 | 857 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
670 | 858 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
671 | 859 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
672 | 860 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
673 | 861 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
674 | 862 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
675 | 863 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
676 | 864 | let pricesList = if ((poolLPBalance == 0)) | |
677 | 865 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
678 | 866 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
679 | 867 | let curPrice = 0 | |
680 | 868 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
681 | 869 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
682 | 870 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
683 | 871 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP)) | |
684 | 872 | } | |
685 | 873 | ||
686 | 874 | ||
687 | 875 | ||
688 | 876 | @Callable(i) | |
689 | 877 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
690 | 878 | let cfg = getPoolConfig() | |
691 | 879 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
692 | 880 | let amAssetIdStr = cfg[idxAmtAssetId] | |
693 | 881 | let amAssetId = fromBase58String(amAssetIdStr) | |
694 | 882 | let prAssetIdStr = cfg[idxPriceAssetId] | |
695 | 883 | let prAssetId = fromBase58String(prAssetIdStr) | |
696 | 884 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
697 | 885 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
698 | 886 | let poolStatus = cfg[idxPoolStatus] | |
699 | 887 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
700 | 888 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
701 | 889 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
702 | 890 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
703 | 891 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
704 | 892 | let curPriceX18 = if ((poolLPBalance == 0)) | |
705 | 893 | then zeroBigInt | |
706 | 894 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
707 | 895 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
708 | 896 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
709 | 897 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
710 | 898 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
711 | 899 | let calcLpAmt = estPut._1 | |
712 | 900 | let curPriceCalc = estPut._3 | |
713 | 901 | let amBalance = estPut._4 | |
714 | 902 | let prBalance = estPut._5 | |
715 | 903 | let lpEmission = estPut._6 | |
716 | 904 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
717 | 905 | } | |
718 | 906 | ||
719 | 907 | ||
720 | 908 | ||
721 | 909 | @Callable(i) | |
722 | 910 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
723 | 911 | let cfg = getPoolConfig() | |
724 | 912 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
725 | 913 | let amAssetIdStr = cfg[idxAmtAssetId] | |
726 | 914 | let amAssetId = fromBase58String(amAssetIdStr) | |
727 | 915 | let prAssetIdStr = cfg[idxPriceAssetId] | |
728 | 916 | let prAssetId = fromBase58String(prAssetIdStr) | |
729 | 917 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
730 | 918 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
731 | 919 | let poolStatus = cfg[idxPoolStatus] | |
732 | 920 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
733 | 921 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
734 | 922 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
735 | 923 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
736 | 924 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
737 | 925 | let curPriceX18 = if ((poolLPBalance == 0)) | |
738 | 926 | then zeroBigInt | |
739 | 927 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
740 | 928 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
741 | 929 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
742 | 930 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
743 | 931 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
744 | 932 | let calcLpAmt = estPut._1 | |
745 | 933 | let curPriceCalc = estPut._3 | |
746 | 934 | let amBalance = estPut._4 | |
747 | 935 | let prBalance = estPut._5 | |
748 | 936 | let lpEmission = estPut._6 | |
749 | 937 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
750 | 938 | } | |
751 | 939 | ||
752 | 940 | ||
753 | 941 | ||
754 | 942 | @Callable(i) | |
755 | 943 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
756 | 944 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
757 | 945 | let outAmAmt = res._1 | |
758 | 946 | let outPrAmt = res._2 | |
759 | 947 | let amBalance = res._5 | |
760 | 948 | let prBalance = res._6 | |
761 | 949 | let lpEmission = res._7 | |
762 | 950 | let curPrice = res._8 | |
763 | 951 | let poolStatus = parseIntValue(res._9) | |
764 | 952 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), toString(curPrice), toString(poolStatus)], SEP)) | |
765 | 953 | } | |
766 | 954 | ||
767 | 955 | ||
768 | 956 | @Verifier(tx) | |
769 | 957 | func verify () = { | |
770 | 958 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
771 | 959 | case pk: ByteVector => | |
772 | 960 | pk | |
773 | 961 | case _: Unit => | |
774 | 962 | tx.senderPublicKey | |
775 | 963 | case _ => | |
776 | 964 | throw("Match error") | |
777 | 965 | } | |
778 | 966 | match tx { | |
779 | 967 | case order: Order => | |
780 | 968 | let matcherPub = getMatcherPubOrFail() | |
781 | 969 | let orderValid = validateMatcherOrderAllowed(order) | |
782 | 970 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
783 | 971 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
784 | 972 | if (if (if (orderValid) | |
785 | 973 | then senderValid | |
786 | 974 | else false) | |
787 | 975 | then matcherValid | |
788 | 976 | else false) | |
789 | 977 | then true | |
790 | 978 | else throwOrderError(orderValid, senderValid, matcherValid) | |
791 | 979 | case s: SetScriptTransaction => | |
792 | 980 | let newHash = blake2b256(value(s.script)) | |
793 | 981 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
794 | 982 | let currentHash = scriptHash(this) | |
795 | 983 | if (if ((allowedHash == newHash)) | |
796 | 984 | then (currentHash != newHash) | |
797 | 985 | else false) | |
798 | 986 | then true | |
799 | 987 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
800 | 988 | case _ => | |
801 | 989 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
802 | 990 | } | |
803 | 991 | } | |
804 | 992 |
github/deemru/w8io/026f985 84.23 ms ◑