tx · AnNydRNcvYpQYRa2DBnBYvr9c6U6egWb1XZAw4fB1wCN

3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb:  -0.02200000 Waves

2022.11.01 13:52 [2297955] smart account 3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb > SELF 0.00000000 Waves

{ "type": 13, "id": "AnNydRNcvYpQYRa2DBnBYvr9c6U6egWb1XZAw4fB1wCN", "fee": 2200000, "feeAssetId": null, "timestamp": 1667299962315, "version": 1, "sender": "3N1xHtFLmVxy153ELFALTEt3HuVXvv4rnqb", "senderPublicKey": "FbottDhjAqYmSxiGz2jbuu6xQEvdqZoV43vksDrkTTgb", "proofs": [ "gZjr2Rwa4qr31VbAePv1hHcUidBDbbx9AhjQb5CiiNXu3dN7ssdfyiu9ivGm8myc5cwnTDCfZZX2qLsGrBWqcu9" ], "script": "base64:BgK1GwgCEgMKAQgSAwoBCBIAEgQKAgEEEgMKAQESABIECgIBARIDCgEBEgQKAggIEgASAwoBCBIFCgMBAQESBAoCAQESBAoCCAESBAoCCAgSCwoJCAEBAgECCAQEEgYKBAgIAQgSABIDCgEBEgMKAQESBAoCCAEiCmxQZGVjaW1hbHMiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY20iEmlkeFBvb2xBbXRBc3NldEFtdCIUaWR4UG9vbFByaWNlQXNzZXRBbXQiEWlkeFBvb2xMUEFzc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Wx1ZQEIBQJiWQJfOQkAlAoCBQNuaWwJALkJAgkAzAgCAg4lZCVkJWQlZCVkJWQlZAkAzAgCCQCkAwEFAmJFCQDMCAIJAKQDAQUCYkYJAMwIAgkApAMBBQJidQkAzAgCCQCkAwEFAmJ3CQDMCAIJAKQDAQUCYnQJAMwIAgkApgMBBQJiegkAzAgCCQCkAwEFAmJzBQNuaWwFAWYBAmRIAQJkSQAEAmRKBAJjTAkBAmNLAAMJAAECBQJjTAIKQnl0ZVZlY3RvcgQCY1EFAmNMBQJjUQMJAAECBQJjTAIEVW5pdAgFAmRID3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yBAJjTAUCZEgDCQABAgUCY0wCBU9yZGVyBAJjcAUCY0wEAmRLCQECYXUABAJhbAkBAmNvAQUCY3AEAmFtCQD0AwMIBQJjcAlib2R5Qnl0ZXMJAJEDAggFAmNwBnByb29mcwAACAUCY3APc2VuZGVyUHVibGljS2V5BAJhbgkA9AMDCAUCY3AJYm9keUJ5dGVzCQCRAwIIBQJjcAZwcm9vZnMAAQUCZEsDAwMFAmFsBQJhbQcFAmFuBwYJAQJhawMFAmFsBQJhbQUCYW4DCQABAgUCY0wCFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJjTQUCY0wEAmRMCQD2AwEJAQV2YWx1ZQEIBQJjTQZzY3JpcHQEAmRNCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYXMJAQJhagAEAmROCQDxBwEFBHRoaXMDAwkAAAIFAmRNBQJkTAkBAiE9AgUCZE4FAmRMBwYJAPQDAwgFAmRICWJvZHlCeXRlcwkAkQMCCAUCZEgGcHJvb2ZzAAAFAmRKCQD0AwMIBQJkSAlib2R5Qnl0ZXMJAJEDAggFAmRIBnByb29mcwAABQJkSmyaPXk=", "chainId": 84, "height": 2297955, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BiuH9T75XviqqVkkHUwdjHfg29nY5RdZmmxpKA5ETSek Next: ySxzJay9ciAgKjtJjM1TZHxU9NvSuTz8n8BrYBxVCfY Diff:
OldNewDifferences
1010 let scale18 = toBigInt(1000000000000000000)
1111
1212 let zeroBigInt = toBigInt(0)
13-
14-let big0 = toBigInt(0)
15-
16-let big1 = toBigInt(1)
17-
18-let big2 = toBigInt(2)
19-
20-let wavesString = "WAVES"
2113
2214 let SEP = "__"
2315
6860 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6961
7062
71-func abs (val) = if ((0 > val))
72- then -(val)
73- else val
74-
75-
76-func absBigInt (val) = if ((zeroBigInt > val))
63+func abs (val) = if ((zeroBigInt > val))
7764 then -(val)
7865 else val
7966
10592 func pa () = "%s__priceAsset"
10693
10794
108-let keyFee = "%s__fee"
109-
110-let feeDefault = fraction(5, scale8, 10000)
111-
112-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
113-
11495 func keyFactoryConfig () = "%s__factoryConfig"
11596
11697
135116 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
136117
137118
138-let keyFeeCollectorAddress = "%s__feeCollectorAddress"
139-
140119 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
141120
142121
146125 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
147126
148127
149-func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
150-
151-
152128 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
153-
154-let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
155129
156130 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
157131
168142 }
169143
170144
171-func parseAssetId (input) = if ((input == wavesString))
172- then unit
173- else fromBase58String(input)
174-
175-
176-func assetIdToString (input) = if ((input == unit))
177- then wavesString
178- else toBase58String(value(input))
179-
180-
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]))
182-
183-
184-let poolConfigParsed = parsePoolConfig(getPoolConfig())
185-
186-let $t075437709 = poolConfigParsed
187-
188-let cfgPoolAddress = $t075437709._1
189-
190-let cfgPoolStatus = $t075437709._2
191-
192-let cfgLpAssetId = $t075437709._3
193-
194-let cfgAmountAssetId = $t075437709._4
195-
196-let cfgPriceAssetId = $t075437709._5
197-
198-let cfgAmountAssetDecimals = $t075437709._6
199-
200-let cfgPriceAssetDecimals = $t075437709._7
201-
202145 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
203146
204-
205-let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
206-
207-let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
208147
209148 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)
210149
321260 }
322261 else {
323262 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
324- let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
263+ let slippageX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
325264 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
326265 if (if ((curPriceX18 != zeroBigInt))
327266 then (slippageX18 > slippageToleranceX18)
441380 }
442381
443382
444-func emit (amount) = {
445- let emitInv = invoke(factoryContract, "emit", [amount], nil)
446- if ((emitInv == emitInv))
447- then {
448- let emitInvLegacy = match emitInv {
449- case legacyFactoryContract: Address =>
450- invoke(legacyFactoryContract, "emit", [amount], nil)
451- case _ =>
452- unit
453- }
454- if ((emitInvLegacy == emitInvLegacy))
455- then amount
456- else throw("Strict value is not equal to itself.")
457- }
458- else throw("Strict value is not equal to itself.")
459- }
460-
461-
462-func takeFee (amount) = {
463- let feeAmount = fraction(amount, fee, scale8)
464- $Tuple2((amount - feeAmount), feeAmount)
465- }
466-
467-
468-func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
469- let isEval = (txId == unit)
470- let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
471- let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
472- let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
473- then true
474- else if ((paymentAssetId == cfgPriceAssetId))
475- then false
476- else throwErr("invalid asset")
477- let $t02257022863 = if (isEval)
478- then $Tuple2(amountBalanceRaw, priceBalanceRaw)
479- else if (paymentInAmountAsset)
480- then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
481- else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
482- let amountBalanceOld = $t02257022863._1
483- let priceBalanceOld = $t02257022863._2
484- let $t02286723016 = if (paymentInAmountAsset)
485- then $Tuple2(paymentAmountRaw, 0)
486- else $Tuple2(0, paymentAmountRaw)
487- let amountAssetAmountRaw = $t02286723016._1
488- let priceAssetAmountRaw = $t02286723016._2
489- let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
490- let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
491- let $t02313823197 = takeFee(paymentAmountRaw)
492- let paymentAmount = $t02313823197._1
493- let feeAmount = $t02313823197._2
494- let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
495- let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
496- let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
497- let priceNew = fromX18(priceNewX18, scale8)
498- let paymentBalance = if (paymentInAmountAsset)
499- then amountBalanceOld
500- else priceBalanceOld
501- let paymentBalanceBigInt = toBigInt(paymentBalance)
502- let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
503- let chechSupply = if ((supplyBigInt > big0))
504- then true
505- else throwErr("initial deposit requires all coins")
506- if ((chechSupply == chechSupply))
507- then {
508- let depositBigInt = toBigInt(paymentAmount)
509- let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
510- let commonState = if (isEval)
511- then nil
512- 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))]
513- let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
514- let priceOld = fromX18(priceOldX18, scale8)
515- let priceImpact = abs((((priceNew - priceOld) * scale8) / priceOld))
516- $Tuple4(issueAmount, commonState, feeAmount, priceImpact)
517- }
518- else throw("Strict value is not equal to itself.")
519- }
520-
521-
522-func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
523- let isEval = (txId == unit)
524- let checks = [if ((paymentAssetId == cfgLpAssetId))
525- then true
526- else throwErr("invalid lp asset")]
527- if ((checks == checks))
528- then {
529- let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
530- then true
531- else if ((outAssetId == cfgPriceAssetId))
532- then false
533- else throwErr("invalid asset")
534- let balanceBigInt = if (outInAmountAsset)
535- then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
536- else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
537- let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
538- let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
539- let outBalance = if (outInAmountAsset)
540- then amBalanceOld
541- else prBalanceOld
542- let outBalanceBigInt = toBigInt(outBalance)
543- let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
544- let redeemedBigInt = toBigInt(paymentAmount)
545- let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
546- let $t02613526185 = takeFee(amountRaw)
547- let totalAmount = $t02613526185._1
548- let feeAmount = $t02613526185._2
549- let $t02618926415 = if (outInAmountAsset)
550- then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
551- else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
552- let outAmAmount = $t02618926415._1
553- let outPrAmount = $t02618926415._2
554- let amBalanceNew = $t02618926415._3
555- let prBalanceNew = $t02618926415._4
556- let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
557- let priceNew = fromX18(priceNewX18, scale8)
558- let commonState = if (isEval)
559- then nil
560- 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)]
561- let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
562- let priceOld = fromX18(priceOldX18, scale8)
563- let priceImpact = abs((((priceNew - priceOld) * scale8) / priceOld))
564- $Tuple4(totalAmount, commonState, feeAmount, priceImpact)
565- }
566- else throw("Strict value is not equal to itself.")
567- }
568-
569-
570383 func managerPublicKeyOrUnit () = match getString(mpk()) {
571384 case s: String =>
572385 fromBase58String(s)
605418
606419
607420 @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)
608431 func setManager (pendingManagerPublicKey) = {
609432 let checkCaller = mustManager(i)
610433 if ((checkCaller == checkCaller))
640463
641464
642465 @Callable(i)
643-func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
644- then throw("Invalid slippageTolerance passed")
645- else {
646- let estPut = commonPut(i, slippageTolerance, true)
647- let emitLpAmt = estPut._2
648- let lpAssetId = estPut._7
649- let state = estPut._9
650- let amDiff = estPut._10
651- let prDiff = estPut._11
652- let amId = estPut._12
653- let prId = estPut._13
654- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
655- if ((emitInv == emitInv))
656- then {
657- let emitInvLegacy = match emitInv {
658- case legacyFactoryContract: Address =>
659- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
660- case _ =>
661- unit
662- }
663- if ((emitInvLegacy == emitInvLegacy))
664- then {
665- let slippageAInv = if ((amDiff > 0))
666- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
667- else nil
668- if ((slippageAInv == slippageAInv))
669- then {
670- let slippagePInv = if ((prDiff > 0))
671- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
672- else nil
673- if ((slippagePInv == slippagePInv))
674- then {
675- let lpTransfer = if (shouldAutoStake)
676- then {
677- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
678- if ((slpStakeInv == slpStakeInv))
679- then nil
680- else throw("Strict value is not equal to itself.")
681- }
682- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
683- (state ++ lpTransfer)
684- }
685- else throw("Strict value is not equal to itself.")
686- }
687- else throw("Strict value is not equal to itself.")
688- }
689- else throw("Strict value is not equal to itself.")
690- }
691- else throw("Strict value is not equal to itself.")
692- }
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+ }
693521
694522
695523
700528 let estPut = commonPut(i, maxSlippage, false)
701529 estPut._9
702530 }
703-
704-
705-
706-@Callable(i)
707-func putOneTkn (minOutAmount,autoStake) = {
708- let isPoolOneTokenOperationsDisabled = {
709- let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
710- if ($isInstanceOf(@, "Boolean"))
711- then @
712- else throw(($getType(@) + " couldn't be cast to Boolean"))
713- }
714- let isPutDisabled = if (if (if (isGlobalShutdown())
715- then true
716- else (cfgPoolStatus == PoolPutDisabled))
717- then true
718- else (cfgPoolStatus == PoolShutdown))
719- then true
720- else isPoolOneTokenOperationsDisabled
721- let checks = [if (!(isPutDisabled))
722- then true
723- else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
724- then true
725- else throwErr("exactly 1 payment are expected")]
726- if ((checks == checks))
727- then {
728- let payment = i.payments[0]
729- let paymentAssetId = payment.assetId
730- let paymentAmountRaw = payment.amount
731- let userAddress = i.caller
732- let txId = i.transactionId
733- let $t03099731124 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
734- let emitAmountEstimated = $t03099731124._1
735- let commonState = $t03099731124._2
736- let feeAmount = $t03099731124._3
737- let bonus = $t03099731124._4
738- let emitAmount = if (if ((minOutAmount > 0))
739- then (minOutAmount > emitAmountEstimated)
740- else false)
741- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
742- else emitAmountEstimated
743- let emitInv = emit(emitAmount)
744- if ((emitInv == emitInv))
745- then {
746- let lpTransfer = if (autoStake)
747- then {
748- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
749- if ((stakeInv == stakeInv))
750- then nil
751- else throw("Strict value is not equal to itself.")
752- }
753- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
754- let sendFee = if ((feeAmount > 0))
755- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
756- else nil
757- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
758- }
759- else throw("Strict value is not equal to itself.")
760- }
761- else throw("Strict value is not equal to itself.")
762- }
763-
764-
765-
766-@Callable(i)
767-func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
768- let $t03185331988 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
769- let emitAmountEstimated = $t03185331988._1
770- let commonState = $t03185331988._2
771- let feeAmount = $t03185331988._3
772- let bonus = $t03185331988._4
773- $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
774- }
775-
776-
777-
778-@Callable(i)
779-func getOneTkn (outAssetIdStr,minOutAmount) = {
780- let isPoolOneTokenOperationsDisabled = {
781- let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
782- if ($isInstanceOf(@, "Boolean"))
783- then @
784- else throw(($getType(@) + " couldn't be cast to Boolean"))
785- }
786- let isGetDisabled = if (if (isGlobalShutdown())
787- then true
788- else (cfgPoolStatus == PoolShutdown))
789- then true
790- else isPoolOneTokenOperationsDisabled
791- let checks = [if (!(isGetDisabled))
792- then true
793- else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
794- then true
795- else throwErr("exactly 1 payment are expected")]
796- if ((checks == checks))
797- then {
798- let outAssetId = parseAssetId(outAssetIdStr)
799- let payment = i.payments[0]
800- let paymentAssetId = payment.assetId
801- let paymentAmount = payment.amount
802- let userAddress = i.caller
803- let txId = i.transactionId
804- let $t03276032892 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
805- let amountEstimated = $t03276032892._1
806- let commonState = $t03276032892._2
807- let feeAmount = $t03276032892._3
808- let bonus = $t03276032892._4
809- let amount = if (if ((minOutAmount > 0))
810- then (minOutAmount > amountEstimated)
811- else false)
812- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
813- else amountEstimated
814- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
815- if ((burnInv == burnInv))
816- then {
817- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
818- let sendFee = if ((feeAmount > 0))
819- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
820- else nil
821- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
822- }
823- else throw("Strict value is not equal to itself.")
824- }
825- else throw("Strict value is not equal to itself.")
826- }
827-
828-
829-
830-@Callable(i)
831-func getOneTknREADONLY (outAssetId,paymentAmount) = {
832- let $t03352733665 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
833- let amountEstimated = $t03352733665._1
834- let commonState = $t03352733665._2
835- let feeAmount = $t03352733665._3
836- let bonus = $t03352733665._4
837- $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
838- }
839-
840-
841-
842-@Callable(i)
843-func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
844- let isPoolOneTokenOperationsDisabled = {
845- let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
846- if ($isInstanceOf(@, "Boolean"))
847- then @
848- else throw(($getType(@) + " couldn't be cast to Boolean"))
849- }
850- let isGetDisabled = if (if (isGlobalShutdown())
851- then true
852- else (cfgPoolStatus == PoolShutdown))
853- then true
854- else isPoolOneTokenOperationsDisabled
855- let checks = [if (!(isGetDisabled))
856- then true
857- else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
858- then true
859- else throwErr("no payments are expected")]
860- if ((checks == checks))
861- then {
862- let outAssetId = parseAssetId(outAssetIdStr)
863- let userAddress = i.caller
864- let txId = i.transactionId
865- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
866- if ((unstakeInv == unstakeInv))
867- then {
868- let $t03445734587 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
869- let amountEstimated = $t03445734587._1
870- let commonState = $t03445734587._2
871- let feeAmount = $t03445734587._3
872- let bonus = $t03445734587._4
873- let amount = if (if ((minOutAmount > 0))
874- then (minOutAmount > amountEstimated)
875- else false)
876- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
877- else amountEstimated
878- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
879- if ((burnInv == burnInv))
880- then {
881- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
882- let sendFee = if ((feeAmount > 0))
883- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
884- else nil
885- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
886- }
887- else throw("Strict value is not equal to itself.")
888- }
889- else throw("Strict value is not equal to itself.")
890- }
891- else throw("Strict value is not equal to itself.")
892- }
893531
894532
895533
939577 if ((checkPayments == checkPayments))
940578 then {
941579 let cfg = getPoolConfig()
580+ let factoryCfg = getFactoryConfig()
942581 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
582+ let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.")
943583 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
944584 if ((unstakeInv == unstakeInv))
945585 then {
954594 if ((checkPoolStatus == checkPoolStatus))
955595 then {
956596 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
957- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
958- then state
959- else throw("Strict value is not equal to itself.")
960- }
961- else throw("Strict value is not equal to itself.")
962- }
963- else throw("Strict value is not equal to itself.")
964- }
965- else throw("Strict value is not equal to itself.")
966- }
967-
968-
969-
970-@Callable(i)
971-func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
972- let isGetDisabled = if (isGlobalShutdown())
973- then true
974- else (cfgPoolStatus == PoolShutdown)
975- let checks = [if (!(isGetDisabled))
976- then true
977- else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
978- then true
979- else throw("no payments are expected")]
980- if ((checks == checks))
981- then {
982- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
983- if ((unstakeInv == unstakeInv))
984- then {
985- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
986- let outAmAmt = res._1
987- let outPrAmt = res._2
988- let state = res._10
989- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
990- then true
991- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
992- then true
993- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
994- if ((checkAmounts == checkAmounts))
995- then {
996- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
997597 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
998598 then state
999599 else throw("Strict value is not equal to itself.")
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let lPdecimals = 8
55
66 let scale8 = 100000000
77
88 let scale8BigInt = toBigInt(100000000)
99
1010 let scale18 = toBigInt(1000000000000000000)
1111
1212 let zeroBigInt = toBigInt(0)
13-
14-let big0 = toBigInt(0)
15-
16-let big1 = toBigInt(1)
17-
18-let big2 = toBigInt(2)
19-
20-let wavesString = "WAVES"
2113
2214 let SEP = "__"
2315
2416 let PoolActive = 1
2517
2618 let PoolPutDisabled = 2
2719
2820 let PoolMatcherDisabled = 3
2921
3022 let PoolShutdown = 4
3123
3224 let idxPoolAddress = 1
3325
3426 let idxPoolStatus = 2
3527
3628 let idxPoolLPAssetId = 3
3729
3830 let idxAmtAssetId = 4
3931
4032 let idxPriceAssetId = 5
4133
4234 let idxAmtAssetDcm = 6
4335
4436 let idxPriceAssetDcm = 7
4537
4638 let idxIAmtAssetId = 8
4739
4840 let idxIPriceAssetId = 9
4941
5042 let idxLPAssetDcm = 10
5143
5244 let idxPoolAmtAssetAmt = 1
5345
5446 let idxPoolPriceAssetAmt = 2
5547
5648 let idxPoolLPAssetAmt = 3
5749
5850 let idxFactoryStakingContract = 1
5951
6052 let idxFactorySlippageContract = 7
6153
6254 func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6355
6456
6557 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6658
6759
6860 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6961
7062
71-func abs (val) = if ((0 > val))
72- then -(val)
73- else val
74-
75-
76-func absBigInt (val) = if ((zeroBigInt > val))
63+func abs (val) = if ((zeroBigInt > val))
7764 then -(val)
7865 else val
7966
8067
8168 func fc () = "%s__factoryContract"
8269
8370
8471 func mpk () = "%s__managerPublicKey"
8572
8673
8774 func pmpk () = "%s__pendingManagerPublicKey"
8875
8976
9077 func pl () = "%s%s__price__last"
9178
9279
9380 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
9481
9582
9683 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
9784
9885
9986 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
10087
10188
10289 func aa () = "%s__amountAsset"
10390
10491
10592 func pa () = "%s__priceAsset"
10693
10794
108-let keyFee = "%s__fee"
109-
110-let feeDefault = fraction(5, scale8, 10000)
111-
112-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
113-
11495 func keyFactoryConfig () = "%s__factoryConfig"
11596
11697
11798 func keyMatcherPub () = "%s%s__matcher__publicKey"
11899
119100
120101 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
121102
122103
123104 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
124105
125106
126107 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
127108
128109
129110 func keyAllPoolsShutdown () = "%s__shutdown"
130111
131112
132113 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
133114
134115
135116 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
136117
137118
138-let keyFeeCollectorAddress = "%s__feeCollectorAddress"
139-
140119 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
141120
142121
143122 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
144123
145124
146125 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
147126
148127
149-func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
150-
151-
152128 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
153-
154-let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
155129
156130 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
157131
158132
159133 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
160134
161135
162136 func getPoolConfig () = {
163137 let amtAsset = getStringOrFail(this, aa())
164138 let priceAsset = getStringOrFail(this, pa())
165139 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
166140 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
167141 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
168142 }
169143
170144
171-func parseAssetId (input) = if ((input == wavesString))
172- then unit
173- else fromBase58String(input)
174-
175-
176-func assetIdToString (input) = if ((input == unit))
177- then wavesString
178- else toBase58String(value(input))
179-
180-
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]))
182-
183-
184-let poolConfigParsed = parsePoolConfig(getPoolConfig())
185-
186-let $t075437709 = poolConfigParsed
187-
188-let cfgPoolAddress = $t075437709._1
189-
190-let cfgPoolStatus = $t075437709._2
191-
192-let cfgLpAssetId = $t075437709._3
193-
194-let cfgAmountAssetId = $t075437709._4
195-
196-let cfgPriceAssetId = $t075437709._5
197-
198-let cfgAmountAssetDecimals = $t075437709._6
199-
200-let cfgPriceAssetDecimals = $t075437709._7
201-
202145 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
203146
204-
205-let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
206-
207-let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
208147
209148 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)
210149
211150
212151 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)
213152
214153
215154 func getAccBalance (assetId) = if ((assetId == "WAVES"))
216155 then wavesBalance(this).available
217156 else assetBalance(this, fromBase58String(assetId))
218157
219158
220159 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
221160
222161
223162 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
224163 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
225164 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
226165 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
227166 }
228167
229168
230169 func calcPrices (amAmt,prAmt,lpAmt) = {
231170 let cfg = getPoolConfig()
232171 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
233172 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
234173 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
235174 let amAmtX18 = toX18(amAmt, amtAssetDcm)
236175 let prAmtX18 = toX18(prAmt, priceAssetDcm)
237176 let lpAmtX18 = toX18(lpAmt, scale8)
238177 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
239178 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
240179 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
241180 }
242181
243182
244183 func calculatePrices (amAmt,prAmt,lpAmt) = {
245184 let prices = calcPrices(amAmt, prAmt, lpAmt)
246185 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
247186 }
248187
249188
250189 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
251190 let cfg = getPoolConfig()
252191 let lpAssetId = cfg[idxPoolLPAssetId]
253192 let amAssetId = cfg[idxAmtAssetId]
254193 let prAssetId = cfg[idxPriceAssetId]
255194 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
256195 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
257196 let poolStatus = cfg[idxPoolStatus]
258197 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
259198 if ((lpAssetId != pmtAssetId))
260199 then throw("Invalid asset passed.")
261200 else {
262201 let amBalance = getAccBalance(amAssetId)
263202 let amBalanceX18 = toX18(amBalance, amAssetDcm)
264203 let prBalance = getAccBalance(prAssetId)
265204 let prBalanceX18 = toX18(prBalance, prAssetDcm)
266205 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
267206 let curPrice = fromX18(curPriceX18, scale8)
268207 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
269208 let lpEmissionX18 = toX18(lpEmission, scale8)
270209 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
271210 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
272211 let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
273212 let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
274213 let state = if ((txId58 == ""))
275214 then nil
276215 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
277216 then unit
278217 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
279218 then unit
280219 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)]
281220 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
282221 }
283222 }
284223
285224
286225 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
287226 let cfg = getPoolConfig()
288227 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
289228 let amAssetIdStr = cfg[idxAmtAssetId]
290229 let prAssetIdStr = cfg[idxPriceAssetId]
291230 let iAmtAssetId = cfg[idxIAmtAssetId]
292231 let iPriceAssetId = cfg[idxIPriceAssetId]
293232 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
294233 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
295234 let poolStatus = cfg[idxPoolStatus]
296235 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
297236 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
298237 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
299238 if (if ((amAssetIdStr != inAmAssetIdStr))
300239 then true
301240 else (prAssetIdStr != inPrAssetIdStr))
302241 then throw("Invalid amt or price asset passed.")
303242 else {
304243 let amBalance = if (isEvaluate)
305244 then getAccBalance(amAssetIdStr)
306245 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
307246 let prBalance = if (isEvaluate)
308247 then getAccBalance(prAssetIdStr)
309248 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
310249 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
311250 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
312251 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
313252 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
314253 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
315254 let res = if ((lpEmission == 0))
316255 then {
317256 let curPriceX18 = zeroBigInt
318257 let slippageX18 = zeroBigInt
319258 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
320259 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
321260 }
322261 else {
323262 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
324- let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
263+ let slippageX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
325264 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
326265 if (if ((curPriceX18 != zeroBigInt))
327266 then (slippageX18 > slippageToleranceX18)
328267 else false)
329268 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
330269 else {
331270 let lpEmissionX18 = toX18(lpEmission, scale8)
332271 let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
333272 let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
334273 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
335274 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
336275 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
337276 let expAmtAssetAmtX18 = expectedAmts._1
338277 let expPriceAssetAmtX18 = expectedAmts._2
339278 let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
340279 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
341280 }
342281 }
343282 let calcLpAmt = res._1
344283 let calcAmAssetPmt = res._2
345284 let calcPrAssetPmt = res._3
346285 let curPrice = fromX18(res._4, scale8)
347286 let slippageCalc = fromX18(res._5, scale8)
348287 if ((0 >= calcLpAmt))
349288 then throw("Invalid calculations. LP calculated is less than zero.")
350289 else {
351290 let emitLpAmt = if (!(emitLp))
352291 then 0
353292 else calcLpAmt
354293 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
355294 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
356295 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))]
357296 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
358297 }
359298 }
360299 }
361300
362301
363302 func validateMatcherOrderAllowed (order) = {
364303 let cfg = getPoolConfig()
365304 let amtAssetId = cfg[idxAmtAssetId]
366305 let priceAssetId = cfg[idxPriceAssetId]
367306 let poolStatus = parseIntValue(cfg[idxPoolStatus])
368307 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
369308 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
370309 let accAmtAssetBalance = getAccBalance(amtAssetId)
371310 let accPriceAssetBalance = getAccBalance(priceAssetId)
372311 let curPriceX18 = if ((order.orderType == Buy))
373312 then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
374313 else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
375314 let curPrice = fromX18(curPriceX18, scale8)
376315 if (if (if (isGlobalShutdown())
377316 then true
378317 else (poolStatus == PoolMatcherDisabled))
379318 then true
380319 else (poolStatus == PoolShutdown))
381320 then throw("Exchange operations disabled")
382321 else {
383322 let orderAmtAsset = order.assetPair.amountAsset
384323 let orderAmtAssetStr = if ((orderAmtAsset == unit))
385324 then "WAVES"
386325 else toBase58String(value(orderAmtAsset))
387326 let orderPriceAsset = order.assetPair.priceAsset
388327 let orderPriceAssetStr = if ((orderPriceAsset == unit))
389328 then "WAVES"
390329 else toBase58String(value(orderPriceAsset))
391330 if (if ((orderAmtAssetStr != amtAssetId))
392331 then true
393332 else (orderPriceAssetStr != priceAssetId))
394333 then throw("Wrong order assets.")
395334 else {
396335 let orderPrice = order.price
397336 let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
398337 let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
399338 let isOrderPriceValid = if ((order.orderType == Buy))
400339 then (curPrice >= castedOrderPrice)
401340 else (castedOrderPrice >= curPrice)
402341 true
403342 }
404343 }
405344 }
406345
407346
408347 func commonGet (i) = if ((size(i.payments) != 1))
409348 then throw("exactly 1 payment is expected")
410349 else {
411350 let pmt = value(i.payments[0])
412351 let pmtAssetId = value(pmt.assetId)
413352 let pmtAmt = pmt.amount
414353 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
415354 let outAmAmt = res._1
416355 let outPrAmt = res._2
417356 let poolStatus = parseIntValue(res._9)
418357 let state = res._10
419358 if (if (isGlobalShutdown())
420359 then true
421360 else (poolStatus == PoolShutdown))
422361 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
423362 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
424363 }
425364
426365
427366 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
428367 then throw("exactly 2 payments are expected")
429368 else {
430369 let amAssetPmt = value(i.payments[0])
431370 let prAssetPmt = value(i.payments[1])
432371 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
433372 let poolStatus = parseIntValue(estPut._8)
434373 if (if (if (isGlobalShutdown())
435374 then true
436375 else (poolStatus == PoolPutDisabled))
437376 then true
438377 else (poolStatus == PoolShutdown))
439378 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
440379 else estPut
441380 }
442381
443382
444-func emit (amount) = {
445- let emitInv = invoke(factoryContract, "emit", [amount], nil)
446- if ((emitInv == emitInv))
447- then {
448- let emitInvLegacy = match emitInv {
449- case legacyFactoryContract: Address =>
450- invoke(legacyFactoryContract, "emit", [amount], nil)
451- case _ =>
452- unit
453- }
454- if ((emitInvLegacy == emitInvLegacy))
455- then amount
456- else throw("Strict value is not equal to itself.")
457- }
458- else throw("Strict value is not equal to itself.")
459- }
460-
461-
462-func takeFee (amount) = {
463- let feeAmount = fraction(amount, fee, scale8)
464- $Tuple2((amount - feeAmount), feeAmount)
465- }
466-
467-
468-func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
469- let isEval = (txId == unit)
470- let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
471- let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
472- let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
473- then true
474- else if ((paymentAssetId == cfgPriceAssetId))
475- then false
476- else throwErr("invalid asset")
477- let $t02257022863 = if (isEval)
478- then $Tuple2(amountBalanceRaw, priceBalanceRaw)
479- else if (paymentInAmountAsset)
480- then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
481- else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
482- let amountBalanceOld = $t02257022863._1
483- let priceBalanceOld = $t02257022863._2
484- let $t02286723016 = if (paymentInAmountAsset)
485- then $Tuple2(paymentAmountRaw, 0)
486- else $Tuple2(0, paymentAmountRaw)
487- let amountAssetAmountRaw = $t02286723016._1
488- let priceAssetAmountRaw = $t02286723016._2
489- let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
490- let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
491- let $t02313823197 = takeFee(paymentAmountRaw)
492- let paymentAmount = $t02313823197._1
493- let feeAmount = $t02313823197._2
494- let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
495- let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
496- let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
497- let priceNew = fromX18(priceNewX18, scale8)
498- let paymentBalance = if (paymentInAmountAsset)
499- then amountBalanceOld
500- else priceBalanceOld
501- let paymentBalanceBigInt = toBigInt(paymentBalance)
502- let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
503- let chechSupply = if ((supplyBigInt > big0))
504- then true
505- else throwErr("initial deposit requires all coins")
506- if ((chechSupply == chechSupply))
507- then {
508- let depositBigInt = toBigInt(paymentAmount)
509- let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
510- let commonState = if (isEval)
511- then nil
512- 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))]
513- let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
514- let priceOld = fromX18(priceOldX18, scale8)
515- let priceImpact = abs((((priceNew - priceOld) * scale8) / priceOld))
516- $Tuple4(issueAmount, commonState, feeAmount, priceImpact)
517- }
518- else throw("Strict value is not equal to itself.")
519- }
520-
521-
522-func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
523- let isEval = (txId == unit)
524- let checks = [if ((paymentAssetId == cfgLpAssetId))
525- then true
526- else throwErr("invalid lp asset")]
527- if ((checks == checks))
528- then {
529- let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
530- then true
531- else if ((outAssetId == cfgPriceAssetId))
532- then false
533- else throwErr("invalid asset")
534- let balanceBigInt = if (outInAmountAsset)
535- then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
536- else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
537- let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
538- let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
539- let outBalance = if (outInAmountAsset)
540- then amBalanceOld
541- else prBalanceOld
542- let outBalanceBigInt = toBigInt(outBalance)
543- let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
544- let redeemedBigInt = toBigInt(paymentAmount)
545- let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
546- let $t02613526185 = takeFee(amountRaw)
547- let totalAmount = $t02613526185._1
548- let feeAmount = $t02613526185._2
549- let $t02618926415 = if (outInAmountAsset)
550- then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
551- else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
552- let outAmAmount = $t02618926415._1
553- let outPrAmount = $t02618926415._2
554- let amBalanceNew = $t02618926415._3
555- let prBalanceNew = $t02618926415._4
556- let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
557- let priceNew = fromX18(priceNewX18, scale8)
558- let commonState = if (isEval)
559- then nil
560- 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)]
561- let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
562- let priceOld = fromX18(priceOldX18, scale8)
563- let priceImpact = abs((((priceNew - priceOld) * scale8) / priceOld))
564- $Tuple4(totalAmount, commonState, feeAmount, priceImpact)
565- }
566- else throw("Strict value is not equal to itself.")
567- }
568-
569-
570383 func managerPublicKeyOrUnit () = match getString(mpk()) {
571384 case s: String =>
572385 fromBase58String(s)
573386 case _: Unit =>
574387 unit
575388 case _ =>
576389 throw("Match error")
577390 }
578391
579392
580393 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
581394 case s: String =>
582395 fromBase58String(s)
583396 case _: Unit =>
584397 unit
585398 case _ =>
586399 throw("Match error")
587400 }
588401
589402
590403 func mustManager (i) = {
591404 let pd = throw("Permission denied")
592405 match managerPublicKeyOrUnit() {
593406 case pk: ByteVector =>
594407 if ((i.callerPublicKey == pk))
595408 then true
596409 else pd
597410 case _: Unit =>
598411 if ((i.caller == this))
599412 then true
600413 else pd
601414 case _ =>
602415 throw("Match error")
603416 }
604417 }
605418
606419
607420 @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)
608431 func setManager (pendingManagerPublicKey) = {
609432 let checkCaller = mustManager(i)
610433 if ((checkCaller == checkCaller))
611434 then {
612435 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
613436 if ((checkManagerPublicKey == checkManagerPublicKey))
614437 then [StringEntry(pmpk(), pendingManagerPublicKey)]
615438 else throw("Strict value is not equal to itself.")
616439 }
617440 else throw("Strict value is not equal to itself.")
618441 }
619442
620443
621444
622445 @Callable(i)
623446 func confirmManager () = {
624447 let pm = pendingManagerPublicKeyOrUnit()
625448 let hasPM = if (isDefined(pm))
626449 then true
627450 else throw("No pending manager")
628451 if ((hasPM == hasPM))
629452 then {
630453 let checkPM = if ((i.callerPublicKey == value(pm)))
631454 then true
632455 else throw("You are not pending manager")
633456 if ((checkPM == checkPM))
634457 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
635458 else throw("Strict value is not equal to itself.")
636459 }
637460 else throw("Strict value is not equal to itself.")
638461 }
639462
640463
641464
642465 @Callable(i)
643-func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
644- then throw("Invalid slippageTolerance passed")
645- else {
646- let estPut = commonPut(i, slippageTolerance, true)
647- let emitLpAmt = estPut._2
648- let lpAssetId = estPut._7
649- let state = estPut._9
650- let amDiff = estPut._10
651- let prDiff = estPut._11
652- let amId = estPut._12
653- let prId = estPut._13
654- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
655- if ((emitInv == emitInv))
656- then {
657- let emitInvLegacy = match emitInv {
658- case legacyFactoryContract: Address =>
659- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
660- case _ =>
661- unit
662- }
663- if ((emitInvLegacy == emitInvLegacy))
664- then {
665- let slippageAInv = if ((amDiff > 0))
666- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
667- else nil
668- if ((slippageAInv == slippageAInv))
669- then {
670- let slippagePInv = if ((prDiff > 0))
671- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
672- else nil
673- if ((slippagePInv == slippagePInv))
674- then {
675- let lpTransfer = if (shouldAutoStake)
676- then {
677- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
678- if ((slpStakeInv == slpStakeInv))
679- then nil
680- else throw("Strict value is not equal to itself.")
681- }
682- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
683- (state ++ lpTransfer)
684- }
685- else throw("Strict value is not equal to itself.")
686- }
687- else throw("Strict value is not equal to itself.")
688- }
689- else throw("Strict value is not equal to itself.")
690- }
691- else throw("Strict value is not equal to itself.")
692- }
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+ }
693521
694522
695523
696524 @Callable(i)
697525 func putForFree (maxSlippage) = if ((0 > maxSlippage))
698526 then throw("Invalid value passed")
699527 else {
700528 let estPut = commonPut(i, maxSlippage, false)
701529 estPut._9
702530 }
703-
704-
705-
706-@Callable(i)
707-func putOneTkn (minOutAmount,autoStake) = {
708- let isPoolOneTokenOperationsDisabled = {
709- let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
710- if ($isInstanceOf(@, "Boolean"))
711- then @
712- else throw(($getType(@) + " couldn't be cast to Boolean"))
713- }
714- let isPutDisabled = if (if (if (isGlobalShutdown())
715- then true
716- else (cfgPoolStatus == PoolPutDisabled))
717- then true
718- else (cfgPoolStatus == PoolShutdown))
719- then true
720- else isPoolOneTokenOperationsDisabled
721- let checks = [if (!(isPutDisabled))
722- then true
723- else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
724- then true
725- else throwErr("exactly 1 payment are expected")]
726- if ((checks == checks))
727- then {
728- let payment = i.payments[0]
729- let paymentAssetId = payment.assetId
730- let paymentAmountRaw = payment.amount
731- let userAddress = i.caller
732- let txId = i.transactionId
733- let $t03099731124 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
734- let emitAmountEstimated = $t03099731124._1
735- let commonState = $t03099731124._2
736- let feeAmount = $t03099731124._3
737- let bonus = $t03099731124._4
738- let emitAmount = if (if ((minOutAmount > 0))
739- then (minOutAmount > emitAmountEstimated)
740- else false)
741- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
742- else emitAmountEstimated
743- let emitInv = emit(emitAmount)
744- if ((emitInv == emitInv))
745- then {
746- let lpTransfer = if (autoStake)
747- then {
748- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
749- if ((stakeInv == stakeInv))
750- then nil
751- else throw("Strict value is not equal to itself.")
752- }
753- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
754- let sendFee = if ((feeAmount > 0))
755- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
756- else nil
757- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
758- }
759- else throw("Strict value is not equal to itself.")
760- }
761- else throw("Strict value is not equal to itself.")
762- }
763-
764-
765-
766-@Callable(i)
767-func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
768- let $t03185331988 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
769- let emitAmountEstimated = $t03185331988._1
770- let commonState = $t03185331988._2
771- let feeAmount = $t03185331988._3
772- let bonus = $t03185331988._4
773- $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
774- }
775-
776-
777-
778-@Callable(i)
779-func getOneTkn (outAssetIdStr,minOutAmount) = {
780- let isPoolOneTokenOperationsDisabled = {
781- let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
782- if ($isInstanceOf(@, "Boolean"))
783- then @
784- else throw(($getType(@) + " couldn't be cast to Boolean"))
785- }
786- let isGetDisabled = if (if (isGlobalShutdown())
787- then true
788- else (cfgPoolStatus == PoolShutdown))
789- then true
790- else isPoolOneTokenOperationsDisabled
791- let checks = [if (!(isGetDisabled))
792- then true
793- else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
794- then true
795- else throwErr("exactly 1 payment are expected")]
796- if ((checks == checks))
797- then {
798- let outAssetId = parseAssetId(outAssetIdStr)
799- let payment = i.payments[0]
800- let paymentAssetId = payment.assetId
801- let paymentAmount = payment.amount
802- let userAddress = i.caller
803- let txId = i.transactionId
804- let $t03276032892 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
805- let amountEstimated = $t03276032892._1
806- let commonState = $t03276032892._2
807- let feeAmount = $t03276032892._3
808- let bonus = $t03276032892._4
809- let amount = if (if ((minOutAmount > 0))
810- then (minOutAmount > amountEstimated)
811- else false)
812- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
813- else amountEstimated
814- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
815- if ((burnInv == burnInv))
816- then {
817- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
818- let sendFee = if ((feeAmount > 0))
819- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
820- else nil
821- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
822- }
823- else throw("Strict value is not equal to itself.")
824- }
825- else throw("Strict value is not equal to itself.")
826- }
827-
828-
829-
830-@Callable(i)
831-func getOneTknREADONLY (outAssetId,paymentAmount) = {
832- let $t03352733665 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
833- let amountEstimated = $t03352733665._1
834- let commonState = $t03352733665._2
835- let feeAmount = $t03352733665._3
836- let bonus = $t03352733665._4
837- $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
838- }
839-
840-
841-
842-@Callable(i)
843-func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
844- let isPoolOneTokenOperationsDisabled = {
845- let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
846- if ($isInstanceOf(@, "Boolean"))
847- then @
848- else throw(($getType(@) + " couldn't be cast to Boolean"))
849- }
850- let isGetDisabled = if (if (isGlobalShutdown())
851- then true
852- else (cfgPoolStatus == PoolShutdown))
853- then true
854- else isPoolOneTokenOperationsDisabled
855- let checks = [if (!(isGetDisabled))
856- then true
857- else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
858- then true
859- else throwErr("no payments are expected")]
860- if ((checks == checks))
861- then {
862- let outAssetId = parseAssetId(outAssetIdStr)
863- let userAddress = i.caller
864- let txId = i.transactionId
865- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
866- if ((unstakeInv == unstakeInv))
867- then {
868- let $t03445734587 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
869- let amountEstimated = $t03445734587._1
870- let commonState = $t03445734587._2
871- let feeAmount = $t03445734587._3
872- let bonus = $t03445734587._4
873- let amount = if (if ((minOutAmount > 0))
874- then (minOutAmount > amountEstimated)
875- else false)
876- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
877- else amountEstimated
878- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
879- if ((burnInv == burnInv))
880- then {
881- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
882- let sendFee = if ((feeAmount > 0))
883- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
884- else nil
885- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
886- }
887- else throw("Strict value is not equal to itself.")
888- }
889- else throw("Strict value is not equal to itself.")
890- }
891- else throw("Strict value is not equal to itself.")
892- }
893531
894532
895533
896534 @Callable(i)
897535 func get () = {
898536 let res = commonGet(i)
899537 let outAmtAmt = res._1
900538 let outPrAmt = res._2
901539 let pmtAmt = res._3
902540 let pmtAssetId = res._4
903541 let state = res._5
904542 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
905543 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
906544 then state
907545 else throw("Strict value is not equal to itself.")
908546 }
909547
910548
911549
912550 @Callable(i)
913551 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
914552 let res = commonGet(i)
915553 let outAmAmt = res._1
916554 let outPrAmt = res._2
917555 let pmtAmt = res._3
918556 let pmtAssetId = res._4
919557 let state = res._5
920558 if ((noLessThenAmtAsset > outAmAmt))
921559 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
922560 else if ((noLessThenPriceAsset > outPrAmt))
923561 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
924562 else {
925563 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
926564 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
927565 then state
928566 else throw("Strict value is not equal to itself.")
929567 }
930568 }
931569
932570
933571
934572 @Callable(i)
935573 func unstakeAndGet (amount) = {
936574 let checkPayments = if ((size(i.payments) != 0))
937575 then throw("No payments are expected")
938576 else true
939577 if ((checkPayments == checkPayments))
940578 then {
941579 let cfg = getPoolConfig()
580+ let factoryCfg = getFactoryConfig()
942581 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
582+ let stakingContract = valueOrErrorMessage(addressFromString(factoryCfg[idxFactoryStakingContract]), "Error. Incorrect staking address.")
943583 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
944584 if ((unstakeInv == unstakeInv))
945585 then {
946586 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
947587 let poolStatus = parseIntValue(res._9)
948588 let state = res._10
949589 let checkPoolStatus = if (if (isGlobalShutdown())
950590 then true
951591 else (poolStatus == PoolShutdown))
952592 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
953593 else true
954594 if ((checkPoolStatus == checkPoolStatus))
955595 then {
956596 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
957- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
958- then state
959- else throw("Strict value is not equal to itself.")
960- }
961- else throw("Strict value is not equal to itself.")
962- }
963- else throw("Strict value is not equal to itself.")
964- }
965- else throw("Strict value is not equal to itself.")
966- }
967-
968-
969-
970-@Callable(i)
971-func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
972- let isGetDisabled = if (isGlobalShutdown())
973- then true
974- else (cfgPoolStatus == PoolShutdown)
975- let checks = [if (!(isGetDisabled))
976- then true
977- else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
978- then true
979- else throw("no payments are expected")]
980- if ((checks == checks))
981- then {
982- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
983- if ((unstakeInv == unstakeInv))
984- then {
985- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
986- let outAmAmt = res._1
987- let outPrAmt = res._2
988- let state = res._10
989- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
990- then true
991- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
992- then true
993- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
994- if ((checkAmounts == checkAmounts))
995- then {
996- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
997597 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
998598 then state
999599 else throw("Strict value is not equal to itself.")
1000600 }
1001601 else throw("Strict value is not equal to itself.")
1002602 }
1003603 else throw("Strict value is not equal to itself.")
1004604 }
1005605 else throw("Strict value is not equal to itself.")
1006606 }
1007607
1008608
1009609
1010610 @Callable(i)
1011611 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
1012612 then throw("permissions denied")
1013613 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1014614
1015615
1016616
1017617 @Callable(i)
1018618 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
1019619
1020620
1021621
1022622 @Callable(i)
1023623 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
1024624
1025625
1026626
1027627 @Callable(i)
1028628 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
1029629 let prices = calcPrices(amAmt, prAmt, lpAmt)
1030630 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
1031631 }
1032632
1033633
1034634
1035635 @Callable(i)
1036636 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
1037637
1038638
1039639
1040640 @Callable(i)
1041641 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
1042642
1043643
1044644
1045645 @Callable(i)
1046646 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
1047647
1048648
1049649
1050650 @Callable(i)
1051651 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
1052652
1053653
1054654
1055655 @Callable(i)
1056656 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
1057657 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
1058658 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
1059659 }
1060660
1061661
1062662
1063663 @Callable(i)
1064664 func statsREADONLY () = {
1065665 let cfg = getPoolConfig()
1066666 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1067667 let amtAssetId = cfg[idxAmtAssetId]
1068668 let priceAssetId = cfg[idxPriceAssetId]
1069669 let iAmtAssetId = cfg[idxIAmtAssetId]
1070670 let iPriceAssetId = cfg[idxIPriceAssetId]
1071671 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
1072672 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
1073673 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
1074674 let accAmtAssetBalance = getAccBalance(amtAssetId)
1075675 let accPriceAssetBalance = getAccBalance(priceAssetId)
1076676 let pricesList = if ((poolLPBalance == 0))
1077677 then [zeroBigInt, zeroBigInt, zeroBigInt]
1078678 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
1079679 let curPrice = 0
1080680 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
1081681 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
1082682 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
1083683 $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))
1084684 }
1085685
1086686
1087687
1088688 @Callable(i)
1089689 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
1090690 let cfg = getPoolConfig()
1091691 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1092692 let amAssetIdStr = cfg[idxAmtAssetId]
1093693 let amAssetId = fromBase58String(amAssetIdStr)
1094694 let prAssetIdStr = cfg[idxPriceAssetId]
1095695 let prAssetId = fromBase58String(prAssetIdStr)
1096696 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
1097697 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
1098698 let poolStatus = cfg[idxPoolStatus]
1099699 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
1100700 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
1101701 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
1102702 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
1103703 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
1104704 let curPriceX18 = if ((poolLPBalance == 0))
1105705 then zeroBigInt
1106706 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
1107707 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
1108708 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
1109709 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
1110710 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
1111711 let calcLpAmt = estPut._1
1112712 let curPriceCalc = estPut._3
1113713 let amBalance = estPut._4
1114714 let prBalance = estPut._5
1115715 let lpEmission = estPut._6
1116716 $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))
1117717 }
1118718
1119719
1120720
1121721 @Callable(i)
1122722 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
1123723 let cfg = getPoolConfig()
1124724 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1125725 let amAssetIdStr = cfg[idxAmtAssetId]
1126726 let amAssetId = fromBase58String(amAssetIdStr)
1127727 let prAssetIdStr = cfg[idxPriceAssetId]
1128728 let prAssetId = fromBase58String(prAssetIdStr)
1129729 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
1130730 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
1131731 let poolStatus = cfg[idxPoolStatus]
1132732 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
1133733 let amBalanceRaw = getAccBalance(amAssetIdStr)
1134734 let prBalanceRaw = getAccBalance(prAssetIdStr)
1135735 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
1136736 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
1137737 let curPriceX18 = if ((poolLPBalance == 0))
1138738 then zeroBigInt
1139739 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
1140740 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
1141741 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
1142742 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
1143743 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
1144744 let calcLpAmt = estPut._1
1145745 let curPriceCalc = estPut._3
1146746 let amBalance = estPut._4
1147747 let prBalance = estPut._5
1148748 let lpEmission = estPut._6
1149749 $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))
1150750 }
1151751
1152752
1153753
1154754 @Callable(i)
1155755 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
1156756 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
1157757 let outAmAmt = res._1
1158758 let outPrAmt = res._2
1159759 let amBalance = res._5
1160760 let prBalance = res._6
1161761 let lpEmission = res._7
1162762 let curPrice = res._8
1163763 let poolStatus = parseIntValue(res._9)
1164764 $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))
1165765 }
1166766
1167767
1168768 @Verifier(tx)
1169769 func verify () = {
1170770 let targetPublicKey = match managerPublicKeyOrUnit() {
1171771 case pk: ByteVector =>
1172772 pk
1173773 case _: Unit =>
1174774 tx.senderPublicKey
1175775 case _ =>
1176776 throw("Match error")
1177777 }
1178778 match tx {
1179779 case order: Order =>
1180780 let matcherPub = getMatcherPubOrFail()
1181781 let orderValid = validateMatcherOrderAllowed(order)
1182782 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
1183783 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
1184784 if (if (if (orderValid)
1185785 then senderValid
1186786 else false)
1187787 then matcherValid
1188788 else false)
1189789 then true
1190790 else throwOrderError(orderValid, senderValid, matcherValid)
1191791 case s: SetScriptTransaction =>
1192792 let newHash = blake2b256(value(s.script))
1193793 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
1194794 let currentHash = scriptHash(this)
1195795 if (if ((allowedHash == newHash))
1196796 then (currentHash != newHash)
1197797 else false)
1198798 then true
1199799 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1200800 case _ =>
1201801 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1202802 }
1203803 }
1204804

github/deemru/w8io/169f3d6 
132.00 ms