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