tx · F4UBamPVbcazYQE3hXENcaKnxnT5QDne7aFFAEDJRgnM

3Msa444cj3rGwoUM28fK5iMwFXn61SfJpqs:  -0.03100000 Waves

2022.12.27 12:18 [2378492] smart account 3Msa444cj3rGwoUM28fK5iMwFXn61SfJpqs > SELF 0.00000000 Waves

{ "type": 13, "id": "F4UBamPVbcazYQE3hXENcaKnxnT5QDne7aFFAEDJRgnM", "fee": 3100000, "feeAssetId": null, "timestamp": 1672132705881, "version": 1, "sender": "3Msa444cj3rGwoUM28fK5iMwFXn61SfJpqs", "senderPublicKey": "Fv4cVRzKj6MwfJQ2BrrtpyPyc3dSbKxA91GqxHZCCqC3", "proofs": [ "2bysF4zgSRPLVh1iJUkT9TfHRdhzaTyrH7x7pn6nRA23uEaw6VZks5YX3SDvKsMBxgYKtoDyNjFi84i7P7tZtd3s" ], "script": "base64:BgK8JwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASAwoBCBIFCgMBAQESBAoCAQESBAoCCAESBAoCCAgSCwoJCAEBAgECCAQEEgYKBAgIAQgSABIDCgEBEgMKAQESBAoCCAEiCmxQZGVjaW1hbHMiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgt3YXZlc1N0cmluZyIDU0VQIgpQb29sQWN0aXZlIg9Qb29sUHV0RGlzYWJsZWQiE1Bvb2xNYXRjaGVyRGlzYWJsZWQiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiDWlkeFBvb2xTdGF0dXMiEGlkeFBvb2xMUEFzc2V0SWQiDWlkeEFtdEFzc2V0SWQiD2lkeFByaWNlQXNzZXRJZCIOaWR4QW10QXNzZXREY20iEGlkeFByaWNlQXNzZXREY20iDmlkeElBbXRBc3NldElkIhBpZHhJUHJpY2VBc3NldElkIg1pZH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2NyaXB0BAJmTgkA2wQBCQEFdmFsdWUBCQCdCAIFAmFECQECYXIABAJmTwkA8QcBBQR0aGlzAwMJAAACBQJmTgUCZk0JAQIhPQIFAmZPBQJmTQcGCQD0AwMIBQJmSQlib2R5Qnl0ZXMJAJEDAggFAmZJBnByb29mcwAABQJmSwkA9AMDCAUCZkkJYm9keUJ5dGVzCQCRAwIIBQJmSQZwcm9vZnMAAAUCZkuCh+//", "chainId": 84, "height": 2378492, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AMMCsG5EgSwq8mDRY4oB3M2Uyai8656vud8MqKXRRW5c Next: 23nX1NhB13H9Dmt4aMRHX72qgXRZ1Zs44xaFFcrn2bDQ Diff:
OldNewDifferences
6565 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6666
6767
68-func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
69-
70-
7168 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7269
7370
114111
115112 let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
116113
117-let keyKLp = makeString(["%s", "kLp"], SEP)
118-
119-let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
120-
121-let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
122-
123-let kLpRefreshDelayDefault = 30
124-
125-let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
126-
127114 func keyFactoryConfig () = "%s__factoryConfig"
128115
129116
162149 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
163150
164151
165-func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
166-
167-
168152 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
169153
170154 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
199183
200184 let poolConfigParsed = parsePoolConfig(getPoolConfig())
201185
202-let $t080588224 = poolConfigParsed
186+let $t075447710 = poolConfigParsed
203187
204-let cfgPoolAddress = $t080588224._1
188+let cfgPoolAddress = $t075447710._1
205189
206-let cfgPoolStatus = $t080588224._2
190+let cfgPoolStatus = $t075447710._2
207191
208-let cfgLpAssetId = $t080588224._3
192+let cfgLpAssetId = $t075447710._3
209193
210-let cfgAmountAssetId = $t080588224._4
194+let cfgAmountAssetId = $t075447710._4
211195
212-let cfgPriceAssetId = $t080588224._5
196+let cfgPriceAssetId = $t075447710._5
213197
214-let cfgAmountAssetDecimals = $t080588224._6
198+let cfgAmountAssetDecimals = $t075447710._6
215199
216-let cfgPriceAssetDecimals = $t080588224._7
200+let cfgPriceAssetDecimals = $t075447710._7
217201
218202 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
219203
234218
235219
236220 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
237-
238-
239-func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
240221
241222
242223 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
288269 let lpEmissionX18 = toX18(lpEmission, scale8)
289270 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
290271 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
291- let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
292- let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
272+ let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
273+ let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
293274 let state = if ((txId58 == ""))
294275 then nil
295276 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
348329 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
349330 else {
350331 let lpEmissionX18 = toX18(lpEmission, scale8)
351- let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
352- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
332+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
333+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
353334 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
354335 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
355336 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
356337 let expAmtAssetAmtX18 = expectedAmts._1
357338 let expPriceAssetAmtX18 = expectedAmts._2
358- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
359- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
339+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
340+ $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
360341 }
361342 }
362343 let calcLpAmt = res._1
379360 }
380361
381362
382-func calcKLp (amountBalance,priceBalance,lpEmission) = {
383- let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
384- if ((lpEmission == big0))
385- then big0
386- else updatedKLp
387- }
388-
389-
390-func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
391- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
392- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
393- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
394- let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
395- currentKLp
396- }
397-
398-
399-func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
400- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
401- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
402- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
403- let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
404- let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
405- $Tuple2(actions, updatedKLp)
406- }
407-
408-
409-func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
410- then true
411- else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
412-
413-
414363 func validateMatcherOrderAllowed (order) = {
415- let amountAssetAmount = order.amount
416- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
417- let $t02080121013 = if ((order.orderType == Buy))
418- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
419- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
420- let amountAssetBalanceDelta = $t02080121013._1
421- let priceAssetBalanceDelta = $t02080121013._2
364+ let cfg = getPoolConfig()
365+ let amtAssetId = cfg[idxAmtAssetId]
366+ let priceAssetId = cfg[idxPriceAssetId]
367+ let poolStatus = parseIntValue(cfg[idxPoolStatus])
368+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
369+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
370+ let accAmtAssetBalance = getAccBalance(amtAssetId)
371+ let accPriceAssetBalance = getAccBalance(priceAssetId)
372+ let curPriceX18 = if ((order.orderType == Buy))
373+ then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
374+ else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
375+ let curPrice = fromX18(curPriceX18, scale8)
422376 if (if (if (isGlobalShutdown())
423377 then true
424- else (cfgPoolStatus == PoolMatcherDisabled))
378+ else (poolStatus == PoolMatcherDisabled))
425379 then true
426- else (cfgPoolStatus == PoolShutdown))
380+ else (poolStatus == PoolShutdown))
427381 then throw("Exchange operations disabled")
428- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
429- then true
430- else (order.assetPair.priceAsset != cfgPriceAssetId))
431- then throw("Wrong order assets.")
432- else {
433- let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
434- let $t02148421584 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
435- let unusedActions = $t02148421584._1
436- let kLpNew = $t02148421584._2
437- let isOrderValid = (kLpNew >= kLp)
438- isOrderValid
439- }
382+ else {
383+ let orderAmtAsset = order.assetPair.amountAsset
384+ let orderAmtAssetStr = if ((orderAmtAsset == unit))
385+ then "WAVES"
386+ else toBase58String(value(orderAmtAsset))
387+ let orderPriceAsset = order.assetPair.priceAsset
388+ let orderPriceAssetStr = if ((orderPriceAsset == unit))
389+ then "WAVES"
390+ else toBase58String(value(orderPriceAsset))
391+ if (if ((orderAmtAssetStr != amtAssetId))
392+ then true
393+ else (orderPriceAssetStr != priceAssetId))
394+ then throw("Wrong order assets.")
395+ else {
396+ let orderPrice = order.price
397+ let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
398+ let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
399+ let isOrderPriceValid = if ((order.orderType == Buy))
400+ then (curPrice >= castedOrderPrice)
401+ else (castedOrderPrice >= curPrice)
402+ true
403+ }
404+ }
440405 }
441406
442407
509474 else if ((paymentAssetId == cfgPriceAssetId))
510475 then false
511476 else throwErr("invalid asset")
512- let $t02426924562 = if (isEval)
477+ let $t02257122864 = if (isEval)
513478 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
514479 else if (paymentInAmountAsset)
515480 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
516481 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
517- let amountBalanceOld = $t02426924562._1
518- let priceBalanceOld = $t02426924562._2
519- let $t02456624715 = if (paymentInAmountAsset)
482+ let amountBalanceOld = $t02257122864._1
483+ let priceBalanceOld = $t02257122864._2
484+ let $t02286823017 = if (paymentInAmountAsset)
520485 then $Tuple2(paymentAmountRaw, 0)
521486 else $Tuple2(0, paymentAmountRaw)
522- let amountAssetAmountRaw = $t02456624715._1
523- let priceAssetAmountRaw = $t02456624715._2
487+ let amountAssetAmountRaw = $t02286823017._1
488+ let priceAssetAmountRaw = $t02286823017._2
524489 let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
525490 let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
526- let $t02483724896 = takeFee(paymentAmountRaw)
527- let paymentAmount = $t02483724896._1
528- let feeAmount = $t02483724896._2
491+ let $t02313923198 = takeFee(paymentAmountRaw)
492+ let paymentAmount = $t02313923198._1
493+ let feeAmount = $t02313923198._2
529494 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
530495 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
531496 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
548513 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
549514 let priceOld = fromX18(priceOldX18, scale8)
550515 let loss = {
551- let $t02657726744 = if (paymentInAmountAsset)
516+ let $t02467524842 = if (paymentInAmountAsset)
552517 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
553518 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
554- let amount = $t02657726744._1
555- let balance = $t02657726744._2
519+ let amount = $t02467524842._1
520+ let balance = $t02467524842._2
556521 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
557522 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
558523 }
559- $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
524+ $Tuple4(issueAmount, commonState, feeAmount, loss)
560525 }
561526 else throw("Strict value is not equal to itself.")
562527 }
564529
565530 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
566531 let isEval = (txId == unit)
567- let cfg = getPoolConfig()
568- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
569- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
570532 let checks = [if ((paymentAssetId == cfgLpAssetId))
571533 then true
572534 else throwErr("invalid lp asset")]
580542 let balanceBigInt = if (outInAmountAsset)
581543 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
582544 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
583- let outInAmountAssetDecimals = if (outInAmountAsset)
584- then amtAssetDcm
585- else priceAssetDcm
586545 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
587546 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
588547 let outBalance = if (outInAmountAsset)
592551 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
593552 let redeemedBigInt = toBigInt(paymentAmount)
594553 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
595- let $t02882328873 = takeFee(amountRaw)
596- let totalAmount = $t02882328873._1
597- let feeAmount = $t02882328873._2
598- let $t02887729103 = if (outInAmountAsset)
554+ let $t02642226472 = takeFee(amountRaw)
555+ let totalAmount = $t02642226472._1
556+ let feeAmount = $t02642226472._2
557+ let $t02647626702 = if (outInAmountAsset)
599558 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
600559 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
601- let outAmAmount = $t02887729103._1
602- let outPrAmount = $t02887729103._2
603- let amBalanceNew = $t02887729103._3
604- let prBalanceNew = $t02887729103._4
560+ let outAmAmount = $t02647626702._1
561+ let outPrAmount = $t02647626702._2
562+ let amBalanceNew = $t02647626702._3
563+ let prBalanceNew = $t02647626702._4
605564 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
606565 let priceNew = fromX18(priceNewX18, scale8)
607566 let commonState = if (isEval)
613572 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
614573 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
615574 }
616- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
575+ $Tuple4(totalAmount, commonState, feeAmount, loss)
617576 }
618577 else throw("Strict value is not equal to itself.")
619578 }
713672 let prDiff = estPut._11
714673 let amId = estPut._12
715674 let prId = estPut._13
716- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
717- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
718- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
719- if ((currentKLp == currentKLp))
675+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
676+ if ((emitInv == emitInv))
720677 then {
721- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
722- if ((emitInv == emitInv))
678+ let emitInvLegacy = match emitInv {
679+ case legacyFactoryContract: Address =>
680+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
681+ case _ =>
682+ unit
683+ }
684+ if ((emitInvLegacy == emitInvLegacy))
723685 then {
724- let emitInvLegacy = match emitInv {
725- case legacyFactoryContract: Address =>
726- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
727- case _ =>
728- unit
729- }
730- if ((emitInvLegacy == emitInvLegacy))
686+ let slippageAInv = if ((amDiff > 0))
687+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
688+ else nil
689+ if ((slippageAInv == slippageAInv))
731690 then {
732- let slippageAInv = if ((amDiff > 0))
733- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
691+ let slippagePInv = if ((prDiff > 0))
692+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
734693 else nil
735- if ((slippageAInv == slippageAInv))
694+ if ((slippagePInv == slippagePInv))
736695 then {
737- let slippagePInv = if ((prDiff > 0))
738- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
739- else nil
740- if ((slippagePInv == slippagePInv))
696+ let lpTransfer = if (shouldAutoStake)
741697 then {
742- let lpTransfer = if (shouldAutoStake)
743- then {
744- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
745- if ((slpStakeInv == slpStakeInv))
746- then nil
747- else throw("Strict value is not equal to itself.")
748- }
749- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
750- let $t03363134093 = refreshKLpInternal(0, 0, 0)
751- if (($t03363134093 == $t03363134093))
752- then {
753- let updatedKLp = $t03363134093._2
754- let refreshKLpActions = $t03363134093._1
755- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
756- if ((isUpdatedKLpValid == isUpdatedKLpValid))
757- then ((state ++ lpTransfer) ++ refreshKLpActions)
758- else throw("Strict value is not equal to itself.")
759- }
698+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
699+ if ((slpStakeInv == slpStakeInv))
700+ then nil
760701 else throw("Strict value is not equal to itself.")
761702 }
762- else throw("Strict value is not equal to itself.")
703+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
704+ (state ++ lpTransfer)
763705 }
764706 else throw("Strict value is not equal to itself.")
765707 }
777719 then throw("Invalid value passed")
778720 else {
779721 let estPut = commonPut(i, maxSlippage, false)
780- let state = estPut._9
781- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
782- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
783- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
784- if ((currentKLp == currentKLp))
785- then {
786- let $t03465534720 = refreshKLpInternal(0, 0, 0)
787- let refreshKLpActions = $t03465534720._1
788- let updatedKLp = $t03465534720._2
789- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
790- if ((isUpdatedKLpValid == isUpdatedKLpValid))
791- then (state ++ refreshKLpActions)
792- else throw("Strict value is not equal to itself.")
793- }
794- else throw("Strict value is not equal to itself.")
722+ estPut._9
795723 }
796724
797725
823751 let payment = i.payments[0]
824752 let paymentAssetId = payment.assetId
825753 let paymentAmountRaw = payment.amount
826- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
827- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
828- else if ((paymentAssetId == cfgPriceAssetId))
829- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
830- else throwErr("payment asset is not supported")
831- if ((currentKLp == currentKLp))
754+ let userAddress = i.caller
755+ let txId = i.transactionId
756+ let $t03160931739 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
757+ if (($t03160931739 == $t03160931739))
832758 then {
833- let userAddress = i.caller
834- let txId = i.transactionId
835- let $t03590836060 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
836- if (($t03590836060 == $t03590836060))
759+ let bonus = $t03160931739._4
760+ let feeAmount = $t03160931739._3
761+ let commonState = $t03160931739._2
762+ let emitAmountEstimated = $t03160931739._1
763+ let emitAmount = if (if ((minOutAmount > 0))
764+ then (minOutAmount > emitAmountEstimated)
765+ else false)
766+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
767+ else emitAmountEstimated
768+ let emitInv = emit(emitAmount)
769+ if ((emitInv == emitInv))
837770 then {
838- let paymentInAmountAsset = $t03590836060._5
839- let bonus = $t03590836060._4
840- let feeAmount = $t03590836060._3
841- let commonState = $t03590836060._2
842- let emitAmountEstimated = $t03590836060._1
843- let emitAmount = if (if ((minOutAmount > 0))
844- then (minOutAmount > emitAmountEstimated)
845- else false)
846- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
847- else emitAmountEstimated
848- let emitInv = emit(emitAmount)
849- if ((emitInv == emitInv))
771+ let lpTransfer = if (autoStake)
850772 then {
851- let lpTransfer = if (autoStake)
852- then {
853- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
854- if ((stakeInv == stakeInv))
855- then nil
856- else throw("Strict value is not equal to itself.")
857- }
858- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
859- let sendFee = if ((feeAmount > 0))
860- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
861- else nil
862- let $t03664636843 = if ((this == feeCollectorAddress))
863- then $Tuple2(0, 0)
864- else if (paymentInAmountAsset)
865- then $Tuple2(-(feeAmount), 0)
866- else $Tuple2(0, -(feeAmount))
867- let amountAssetBalanceDelta = $t03664636843._1
868- let priceAssetBalanceDelta = $t03664636843._2
869- let $t03684636954 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
870- let refreshKLpActions = $t03684636954._1
871- let updatedKLp = $t03684636954._2
872- let kLp = value(getString(keyKLp))
873- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
874- if ((isUpdatedKLpValid == isUpdatedKLpValid))
875- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
773+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
774+ if ((stakeInv == stakeInv))
775+ then nil
876776 else throw("Strict value is not equal to itself.")
877777 }
878- else throw("Strict value is not equal to itself.")
778+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
779+ let sendFee = if ((feeAmount > 0))
780+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
781+ else nil
782+ $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
879783 }
880784 else throw("Strict value is not equal to itself.")
881785 }
888792
889793 @Callable(i)
890794 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
891- let $t03726037417 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
892- let emitAmountEstimated = $t03726037417._1
893- let commonState = $t03726037417._2
894- let feeAmount = $t03726037417._3
895- let bonus = $t03726037417._4
896- let paymentInAmountAsset = $t03726037417._5
795+ let $t03246832603 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
796+ let emitAmountEstimated = $t03246832603._1
797+ let commonState = $t03246832603._2
798+ let feeAmount = $t03246832603._3
799+ let bonus = $t03246832603._4
897800 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
898801 }
899802
925828 let payment = i.payments[0]
926829 let paymentAssetId = payment.assetId
927830 let paymentAmount = payment.amount
928- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
929- if ((currentKLp == currentKLp))
831+ let userAddress = i.caller
832+ let txId = i.transactionId
833+ let $t03340833543 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
834+ if (($t03340833543 == $t03340833543))
930835 then {
931- let userAddress = i.caller
932- let txId = i.transactionId
933- let $t03830238455 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
934- if (($t03830238455 == $t03830238455))
836+ let bonus = $t03340833543._4
837+ let feeAmount = $t03340833543._3
838+ let commonState = $t03340833543._2
839+ let amountEstimated = $t03340833543._1
840+ let amount = if (if ((minOutAmount > 0))
841+ then (minOutAmount > amountEstimated)
842+ else false)
843+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
844+ else amountEstimated
845+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
846+ if ((burnInv == burnInv))
935847 then {
936- let outInAmountAsset = $t03830238455._5
937- let bonus = $t03830238455._4
938- let feeAmount = $t03830238455._3
939- let commonState = $t03830238455._2
940- let amountEstimated = $t03830238455._1
941- let amount = if (if ((minOutAmount > 0))
942- then (minOutAmount > amountEstimated)
943- else false)
944- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
945- else amountEstimated
946- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
947- if ((burnInv == burnInv))
948- then {
949- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
950- let sendFee = if ((feeAmount > 0))
951- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
952- else nil
953- let $t03895539202 = {
954- let feeAmountForCalc = if ((this == feeCollectorAddress))
955- then 0
956- else feeAmount
957- if (outInAmountAsset)
958- then $Tuple2(-((amount + feeAmountForCalc)), 0)
959- else $Tuple2(0, -((amount + feeAmountForCalc)))
960- }
961- let amountAssetBalanceDelta = $t03895539202._1
962- let priceAssetBalanceDelta = $t03895539202._2
963- let $t03920539313 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
964- let refreshKLpActions = $t03920539313._1
965- let updatedKLp = $t03920539313._2
966- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
967- if ((isUpdatedKLpValid == isUpdatedKLpValid))
968- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
969- else throw("Strict value is not equal to itself.")
970- }
971- else throw("Strict value is not equal to itself.")
848+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
849+ let sendFee = if ((feeAmount > 0))
850+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
851+ else nil
852+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
972853 }
973854 else throw("Strict value is not equal to itself.")
974855 }
981862
982863 @Callable(i)
983864 func getOneTknREADONLY (outAssetId,paymentAmount) = {
984- let $t03957039726 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
985- let amountEstimated = $t03957039726._1
986- let commonState = $t03957039726._2
987- let feeAmount = $t03957039726._3
988- let bonus = $t03957039726._4
989- let outInAmountAsset = $t03957039726._5
865+ let $t03417834316 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
866+ let amountEstimated = $t03417834316._1
867+ let commonState = $t03417834316._2
868+ let feeAmount = $t03417834316._3
869+ let bonus = $t03417834316._4
990870 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
991871 }
992872
1017897 let outAssetId = parseAssetId(outAssetIdStr)
1018898 let userAddress = i.caller
1019899 let txId = i.transactionId
1020- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1021- if ((currentKLp == currentKLp))
900+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
901+ if ((unstakeInv == unstakeInv))
1022902 then {
1023- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1024- if ((unstakeInv == unstakeInv))
903+ let $t03514135274 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
904+ if (($t03514135274 == $t03514135274))
1025905 then {
1026- let $t04063140782 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1027- if (($t04063140782 == $t04063140782))
906+ let bonus = $t03514135274._4
907+ let feeAmount = $t03514135274._3
908+ let commonState = $t03514135274._2
909+ let amountEstimated = $t03514135274._1
910+ let amount = if (if ((minOutAmount > 0))
911+ then (minOutAmount > amountEstimated)
912+ else false)
913+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
914+ else amountEstimated
915+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
916+ if ((burnInv == burnInv))
1028917 then {
1029- let outInAmountAsset = $t04063140782._5
1030- let bonus = $t04063140782._4
1031- let feeAmount = $t04063140782._3
1032- let commonState = $t04063140782._2
1033- let amountEstimated = $t04063140782._1
1034- let amount = if (if ((minOutAmount > 0))
1035- then (minOutAmount > amountEstimated)
1036- else false)
1037- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1038- else amountEstimated
1039- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1040- if ((burnInv == burnInv))
1041- then {
1042- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1043- let sendFee = if ((feeAmount > 0))
1044- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1045- else nil
1046- let $t04127741524 = {
1047- let feeAmountForCalc = if ((this == feeCollectorAddress))
1048- then 0
1049- else feeAmount
1050- if (outInAmountAsset)
1051- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1052- else $Tuple2(0, -((amount + feeAmountForCalc)))
1053- }
1054- let amountAssetBalanceDelta = $t04127741524._1
1055- let priceAssetBalanceDelta = $t04127741524._2
1056- let $t04152741635 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1057- let refreshKLpActions = $t04152741635._1
1058- let updatedKLp = $t04152741635._2
1059- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1060- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1061- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1062- else throw("Strict value is not equal to itself.")
1063- }
1064- else throw("Strict value is not equal to itself.")
918+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
919+ let sendFee = if ((feeAmount > 0))
920+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
921+ else nil
922+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1065923 }
1066924 else throw("Strict value is not equal to itself.")
1067925 }
1082940 let pmtAmt = res._3
1083941 let pmtAssetId = res._4
1084942 let state = res._5
1085- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1086- if ((currentKLp == currentKLp))
1087- then {
1088- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1089- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1090- then {
1091- let $t04258142663 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1092- let refreshKLpActions = $t04258142663._1
1093- let updatedKLp = $t04258142663._2
1094- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1095- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1096- then (state ++ refreshKLpActions)
1097- else throw("Strict value is not equal to itself.")
1098- }
1099- else throw("Strict value is not equal to itself.")
1100- }
943+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
944+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
945+ then state
1101946 else throw("Strict value is not equal to itself.")
1102947 }
1103948
1116961 else if ((noLessThenPriceAsset > outPrAmt))
1117962 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1118963 else {
1119- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1120- if ((currentKLp == currentKLp))
1121- then {
1122- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1123- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1124- then {
1125- let $t04361243693 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1126- let refreshKLpActions = $t04361243693._1
1127- let updatedKLp = $t04361243693._2
1128- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1129- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1130- then (state ++ refreshKLpActions)
1131- else throw("Strict value is not equal to itself.")
1132- }
1133- else throw("Strict value is not equal to itself.")
1134- }
964+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
965+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
966+ then state
1135967 else throw("Strict value is not equal to itself.")
1136968 }
1137969 }
1147979 then {
1148980 let cfg = getPoolConfig()
1149981 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1150- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1151- if ((currentKLp == currentKLp))
982+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
983+ if ((unstakeInv == unstakeInv))
1152984 then {
1153- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1154- if ((unstakeInv == unstakeInv))
985+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
986+ let poolStatus = parseIntValue(res._9)
987+ let state = res._10
988+ let checkPoolStatus = if (if (isGlobalShutdown())
989+ then true
990+ else (poolStatus == PoolShutdown))
991+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
992+ else true
993+ if ((checkPoolStatus == checkPoolStatus))
1155994 then {
1156- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1157- let outAmAmt = res._1
1158- let outPrAmt = res._2
1159- let poolStatus = parseIntValue(res._9)
1160- let state = res._10
1161- let checkPoolStatus = if (if (isGlobalShutdown())
1162- then true
1163- else (poolStatus == PoolShutdown))
1164- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1165- else true
1166- if ((checkPoolStatus == checkPoolStatus))
1167- then {
1168- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1169- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1170- then {
1171- let $t04481944900 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1172- let refreshKLpActions = $t04481944900._1
1173- let updatedKLp = $t04481944900._2
1174- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1175- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1176- then (state ++ refreshKLpActions)
1177- else throw("Strict value is not equal to itself.")
1178- }
1179- else throw("Strict value is not equal to itself.")
1180- }
995+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
996+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
997+ then state
1181998 else throw("Strict value is not equal to itself.")
1182999 }
11831000 else throw("Strict value is not equal to itself.")
12011018 else throw("no payments are expected")]
12021019 if ((checks == checks))
12031020 then {
1204- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1205- if ((currentKLp == currentKLp))
1021+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1022+ if ((unstakeInv == unstakeInv))
12061023 then {
1207- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1208- if ((unstakeInv == unstakeInv))
1024+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1025+ let outAmAmt = res._1
1026+ let outPrAmt = res._2
1027+ let state = res._10
1028+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1029+ then true
1030+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1031+ then true
1032+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1033+ if ((checkAmounts == checkAmounts))
12091034 then {
1210- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1211- let outAmAmt = res._1
1212- let outPrAmt = res._2
1213- let state = res._10
1214- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1215- then true
1216- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1217- then true
1218- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1219- if ((checkAmounts == checkAmounts))
1220- then {
1221- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1222- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1223- then {
1224- let $t04619546276 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1225- let refreshKLpActions = $t04619546276._1
1226- let updatedKLp = $t04619546276._2
1227- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1228- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1229- then (state ++ refreshKLpActions)
1230- else throw("Strict value is not equal to itself.")
1231- }
1232- else throw("Strict value is not equal to itself.")
1233- }
1035+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1036+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1037+ then state
12341038 else throw("Strict value is not equal to itself.")
12351039 }
12361040 else throw("Strict value is not equal to itself.")
12461050 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12471051 then throw("permissions denied")
12481052 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1249-
1250-
1251-
1252-@Callable(i)
1253-func refreshKLp () = {
1254- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1255- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1256- then unit
1257- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1258- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1259- then {
1260- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1261- let $t04746347527 = refreshKLpInternal(0, 0, 0)
1262- let kLpUpdateActions = $t04746347527._1
1263- let updatedKLp = $t04746347527._2
1264- let actions = if ((kLp != updatedKLp))
1265- then kLpUpdateActions
1266- else throwErr("nothing to refresh")
1267- $Tuple2(actions, toString(updatedKLp))
1268- }
1269- else throw("Strict value is not equal to itself.")
1270- }
12711053
12721054
12731055
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)
1313
1414 let big0 = toBigInt(0)
1515
1616 let big1 = toBigInt(1)
1717
1818 let big2 = toBigInt(2)
1919
2020 let wavesString = "WAVES"
2121
2222 let SEP = "__"
2323
2424 let PoolActive = 1
2525
2626 let PoolPutDisabled = 2
2727
2828 let PoolMatcherDisabled = 3
2929
3030 let PoolShutdown = 4
3131
3232 let idxPoolAddress = 1
3333
3434 let idxPoolStatus = 2
3535
3636 let idxPoolLPAssetId = 3
3737
3838 let idxAmtAssetId = 4
3939
4040 let idxPriceAssetId = 5
4141
4242 let idxAmtAssetDcm = 6
4343
4444 let idxPriceAssetDcm = 7
4545
4646 let idxIAmtAssetId = 8
4747
4848 let idxIPriceAssetId = 9
4949
5050 let idxLPAssetDcm = 10
5151
5252 let idxPoolAmtAssetAmt = 1
5353
5454 let idxPoolPriceAssetAmt = 2
5555
5656 let idxPoolLPAssetAmt = 3
5757
5858 let idxFactoryStakingContract = 1
5959
6060 let idxFactorySlippageContract = 7
6161
6262 func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6363
6464
6565 func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
6666
6767
68-func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
69-
70-
7168 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7269
7370
7471 func abs (val) = if ((0 > val))
7572 then -(val)
7673 else val
7774
7875
7976 func absBigInt (val) = if ((zeroBigInt > val))
8077 then -(val)
8178 else val
8279
8380
8481 func fc () = "%s__factoryContract"
8582
8683
8784 func mpk () = "%s__managerPublicKey"
8885
8986
9087 func pmpk () = "%s__pendingManagerPublicKey"
9188
9289
9390 func pl () = "%s%s__price__last"
9491
9592
9693 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
9794
9895
9996 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
10097
10198
10299 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
103100
104101
105102 func aa () = "%s__amountAsset"
106103
107104
108105 func pa () = "%s__priceAsset"
109106
110107
111108 let keyFee = "%s__fee"
112109
113110 let feeDefault = fraction(10, scale8, 10000)
114111
115112 let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
116113
117-let keyKLp = makeString(["%s", "kLp"], SEP)
118-
119-let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP)
120-
121-let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP)
122-
123-let kLpRefreshDelayDefault = 30
124-
125-let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault)
126-
127114 func keyFactoryConfig () = "%s__factoryConfig"
128115
129116
130117 func keyMatcherPub () = "%s%s__matcher__publicKey"
131118
132119
133120 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
134121
135122
136123 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
137124
138125
139126 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
140127
141128
142129 func keyAllPoolsShutdown () = "%s__shutdown"
143130
144131
145132 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
146133
147134
148135 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
149136
150137
151138 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
152139
153140 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
154141
155142
156143 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
157144
158145
159146 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
160147
161148
162149 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
163150
164151
165-func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
166-
167-
168152 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
169153
170154 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
171155
172156 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
173157
174158
175159 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
176160
177161
178162 func getPoolConfig () = {
179163 let amtAsset = getStringOrFail(this, aa())
180164 let priceAsset = getStringOrFail(this, pa())
181165 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
182166 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
183167 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
184168 }
185169
186170
187171 func parseAssetId (input) = if ((input == wavesString))
188172 then unit
189173 else fromBase58String(input)
190174
191175
192176 func assetIdToString (input) = if ((input == unit))
193177 then wavesString
194178 else toBase58String(value(input))
195179
196180
197181 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]))
198182
199183
200184 let poolConfigParsed = parsePoolConfig(getPoolConfig())
201185
202-let $t080588224 = poolConfigParsed
186+let $t075447710 = poolConfigParsed
203187
204-let cfgPoolAddress = $t080588224._1
188+let cfgPoolAddress = $t075447710._1
205189
206-let cfgPoolStatus = $t080588224._2
190+let cfgPoolStatus = $t075447710._2
207191
208-let cfgLpAssetId = $t080588224._3
192+let cfgLpAssetId = $t075447710._3
209193
210-let cfgAmountAssetId = $t080588224._4
194+let cfgAmountAssetId = $t075447710._4
211195
212-let cfgPriceAssetId = $t080588224._5
196+let cfgPriceAssetId = $t075447710._5
213197
214-let cfgAmountAssetDecimals = $t080588224._6
198+let cfgAmountAssetDecimals = $t075447710._6
215199
216-let cfgPriceAssetDecimals = $t080588224._7
200+let cfgPriceAssetDecimals = $t075447710._7
217201
218202 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
219203
220204
221205 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
222206
223207 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
224208
225209 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)
226210
227211
228212 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)
229213
230214
231215 func getAccBalance (assetId) = if ((assetId == "WAVES"))
232216 then wavesBalance(this).available
233217 else assetBalance(this, fromBase58String(assetId))
234218
235219
236220 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
237-
238-
239-func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
240221
241222
242223 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
243224 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
244225 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
245226 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
246227 }
247228
248229
249230 func calcPrices (amAmt,prAmt,lpAmt) = {
250231 let cfg = getPoolConfig()
251232 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
252233 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
253234 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
254235 let amAmtX18 = toX18(amAmt, amtAssetDcm)
255236 let prAmtX18 = toX18(prAmt, priceAssetDcm)
256237 let lpAmtX18 = toX18(lpAmt, scale8)
257238 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
258239 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
259240 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
260241 }
261242
262243
263244 func calculatePrices (amAmt,prAmt,lpAmt) = {
264245 let prices = calcPrices(amAmt, prAmt, lpAmt)
265246 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
266247 }
267248
268249
269250 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
270251 let cfg = getPoolConfig()
271252 let lpAssetId = cfg[idxPoolLPAssetId]
272253 let amAssetId = cfg[idxAmtAssetId]
273254 let prAssetId = cfg[idxPriceAssetId]
274255 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
275256 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
276257 let poolStatus = cfg[idxPoolStatus]
277258 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
278259 if ((lpAssetId != pmtAssetId))
279260 then throw("Invalid asset passed.")
280261 else {
281262 let amBalance = getAccBalance(amAssetId)
282263 let amBalanceX18 = toX18(amBalance, amAssetDcm)
283264 let prBalance = getAccBalance(prAssetId)
284265 let prBalanceX18 = toX18(prBalance, prAssetDcm)
285266 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
286267 let curPrice = fromX18(curPriceX18, scale8)
287268 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
288269 let lpEmissionX18 = toX18(lpEmission, scale8)
289270 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
290271 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
291- let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
292- let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
272+ let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
273+ let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
293274 let state = if ((txId58 == ""))
294275 then nil
295276 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
296277 then unit
297278 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
298279 then unit
299280 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)]
300281 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
301282 }
302283 }
303284
304285
305286 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
306287 let cfg = getPoolConfig()
307288 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
308289 let amAssetIdStr = cfg[idxAmtAssetId]
309290 let prAssetIdStr = cfg[idxPriceAssetId]
310291 let iAmtAssetId = cfg[idxIAmtAssetId]
311292 let iPriceAssetId = cfg[idxIPriceAssetId]
312293 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
313294 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
314295 let poolStatus = cfg[idxPoolStatus]
315296 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
316297 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
317298 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
318299 if (if ((amAssetIdStr != inAmAssetIdStr))
319300 then true
320301 else (prAssetIdStr != inPrAssetIdStr))
321302 then throw("Invalid amt or price asset passed.")
322303 else {
323304 let amBalance = if (isEvaluate)
324305 then getAccBalance(amAssetIdStr)
325306 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
326307 let prBalance = if (isEvaluate)
327308 then getAccBalance(prAssetIdStr)
328309 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
329310 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
330311 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
331312 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
332313 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
333314 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
334315 let res = if ((lpEmission == 0))
335316 then {
336317 let curPriceX18 = zeroBigInt
337318 let slippageX18 = zeroBigInt
338319 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
339320 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
340321 }
341322 else {
342323 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
343324 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
344325 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
345326 if (if ((curPriceX18 != zeroBigInt))
346327 then (slippageX18 > slippageToleranceX18)
347328 else false)
348329 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
349330 else {
350331 let lpEmissionX18 = toX18(lpEmission, scale8)
351- let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
352- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
332+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
333+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
353334 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
354335 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
355336 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
356337 let expAmtAssetAmtX18 = expectedAmts._1
357338 let expPriceAssetAmtX18 = expectedAmts._2
358- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
359- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
339+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
340+ $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
360341 }
361342 }
362343 let calcLpAmt = res._1
363344 let calcAmAssetPmt = res._2
364345 let calcPrAssetPmt = res._3
365346 let curPrice = fromX18(res._4, scale8)
366347 let slippageCalc = fromX18(res._5, scale8)
367348 if ((0 >= calcLpAmt))
368349 then throw("Invalid calculations. LP calculated is less than zero.")
369350 else {
370351 let emitLpAmt = if (!(emitLp))
371352 then 0
372353 else calcLpAmt
373354 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
374355 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
375356 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))]
376357 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
377358 }
378359 }
379360 }
380361
381362
382-func calcKLp (amountBalance,priceBalance,lpEmission) = {
383- let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
384- if ((lpEmission == big0))
385- then big0
386- else updatedKLp
387- }
388-
389-
390-func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
391- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
392- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
393- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
394- let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
395- currentKLp
396- }
397-
398-
399-func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
400- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
401- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
402- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
403- let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
404- let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
405- $Tuple2(actions, updatedKLp)
406- }
407-
408-
409-func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
410- then true
411- else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
412-
413-
414363 func validateMatcherOrderAllowed (order) = {
415- let amountAssetAmount = order.amount
416- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
417- let $t02080121013 = if ((order.orderType == Buy))
418- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
419- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
420- let amountAssetBalanceDelta = $t02080121013._1
421- let priceAssetBalanceDelta = $t02080121013._2
364+ let cfg = getPoolConfig()
365+ let amtAssetId = cfg[idxAmtAssetId]
366+ let priceAssetId = cfg[idxPriceAssetId]
367+ let poolStatus = parseIntValue(cfg[idxPoolStatus])
368+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
369+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
370+ let accAmtAssetBalance = getAccBalance(amtAssetId)
371+ let accPriceAssetBalance = getAccBalance(priceAssetId)
372+ let curPriceX18 = if ((order.orderType == Buy))
373+ then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
374+ else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
375+ let curPrice = fromX18(curPriceX18, scale8)
422376 if (if (if (isGlobalShutdown())
423377 then true
424- else (cfgPoolStatus == PoolMatcherDisabled))
378+ else (poolStatus == PoolMatcherDisabled))
425379 then true
426- else (cfgPoolStatus == PoolShutdown))
380+ else (poolStatus == PoolShutdown))
427381 then throw("Exchange operations disabled")
428- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
429- then true
430- else (order.assetPair.priceAsset != cfgPriceAssetId))
431- then throw("Wrong order assets.")
432- else {
433- let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
434- let $t02148421584 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
435- let unusedActions = $t02148421584._1
436- let kLpNew = $t02148421584._2
437- let isOrderValid = (kLpNew >= kLp)
438- isOrderValid
439- }
382+ else {
383+ let orderAmtAsset = order.assetPair.amountAsset
384+ let orderAmtAssetStr = if ((orderAmtAsset == unit))
385+ then "WAVES"
386+ else toBase58String(value(orderAmtAsset))
387+ let orderPriceAsset = order.assetPair.priceAsset
388+ let orderPriceAssetStr = if ((orderPriceAsset == unit))
389+ then "WAVES"
390+ else toBase58String(value(orderPriceAsset))
391+ if (if ((orderAmtAssetStr != amtAssetId))
392+ then true
393+ else (orderPriceAssetStr != priceAssetId))
394+ then throw("Wrong order assets.")
395+ else {
396+ let orderPrice = order.price
397+ let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
398+ let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
399+ let isOrderPriceValid = if ((order.orderType == Buy))
400+ then (curPrice >= castedOrderPrice)
401+ else (castedOrderPrice >= curPrice)
402+ true
403+ }
404+ }
440405 }
441406
442407
443408 func commonGet (i) = if ((size(i.payments) != 1))
444409 then throw("exactly 1 payment is expected")
445410 else {
446411 let pmt = value(i.payments[0])
447412 let pmtAssetId = value(pmt.assetId)
448413 let pmtAmt = pmt.amount
449414 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
450415 let outAmAmt = res._1
451416 let outPrAmt = res._2
452417 let poolStatus = parseIntValue(res._9)
453418 let state = res._10
454419 if (if (isGlobalShutdown())
455420 then true
456421 else (poolStatus == PoolShutdown))
457422 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
458423 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
459424 }
460425
461426
462427 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
463428 then throw("exactly 2 payments are expected")
464429 else {
465430 let amAssetPmt = value(i.payments[0])
466431 let prAssetPmt = value(i.payments[1])
467432 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
468433 let poolStatus = parseIntValue(estPut._8)
469434 if (if (if (isGlobalShutdown())
470435 then true
471436 else (poolStatus == PoolPutDisabled))
472437 then true
473438 else (poolStatus == PoolShutdown))
474439 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
475440 else estPut
476441 }
477442
478443
479444 func emit (amount) = {
480445 let emitInv = invoke(factoryContract, "emit", [amount], nil)
481446 if ((emitInv == emitInv))
482447 then {
483448 let emitInvLegacy = match emitInv {
484449 case legacyFactoryContract: Address =>
485450 invoke(legacyFactoryContract, "emit", [amount], nil)
486451 case _ =>
487452 unit
488453 }
489454 if ((emitInvLegacy == emitInvLegacy))
490455 then amount
491456 else throw("Strict value is not equal to itself.")
492457 }
493458 else throw("Strict value is not equal to itself.")
494459 }
495460
496461
497462 func takeFee (amount) = {
498463 let feeAmount = fraction(amount, fee, scale8)
499464 $Tuple2((amount - feeAmount), feeAmount)
500465 }
501466
502467
503468 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
504469 let isEval = (txId == unit)
505470 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
506471 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
507472 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
508473 then true
509474 else if ((paymentAssetId == cfgPriceAssetId))
510475 then false
511476 else throwErr("invalid asset")
512- let $t02426924562 = if (isEval)
477+ let $t02257122864 = if (isEval)
513478 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
514479 else if (paymentInAmountAsset)
515480 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
516481 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
517- let amountBalanceOld = $t02426924562._1
518- let priceBalanceOld = $t02426924562._2
519- let $t02456624715 = if (paymentInAmountAsset)
482+ let amountBalanceOld = $t02257122864._1
483+ let priceBalanceOld = $t02257122864._2
484+ let $t02286823017 = if (paymentInAmountAsset)
520485 then $Tuple2(paymentAmountRaw, 0)
521486 else $Tuple2(0, paymentAmountRaw)
522- let amountAssetAmountRaw = $t02456624715._1
523- let priceAssetAmountRaw = $t02456624715._2
487+ let amountAssetAmountRaw = $t02286823017._1
488+ let priceAssetAmountRaw = $t02286823017._2
524489 let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
525490 let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
526- let $t02483724896 = takeFee(paymentAmountRaw)
527- let paymentAmount = $t02483724896._1
528- let feeAmount = $t02483724896._2
491+ let $t02313923198 = takeFee(paymentAmountRaw)
492+ let paymentAmount = $t02313923198._1
493+ let feeAmount = $t02313923198._2
529494 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
530495 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
531496 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
532497 let priceNew = fromX18(priceNewX18, scale8)
533498 let paymentBalance = if (paymentInAmountAsset)
534499 then amountBalanceOld
535500 else priceBalanceOld
536501 let paymentBalanceBigInt = toBigInt(paymentBalance)
537502 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
538503 let chechSupply = if ((supplyBigInt > big0))
539504 then true
540505 else throwErr("initial deposit requires all coins")
541506 if ((chechSupply == chechSupply))
542507 then {
543508 let depositBigInt = toBigInt(paymentAmount)
544509 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
545510 let commonState = if (isEval)
546511 then nil
547512 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))]
548513 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
549514 let priceOld = fromX18(priceOldX18, scale8)
550515 let loss = {
551- let $t02657726744 = if (paymentInAmountAsset)
516+ let $t02467524842 = if (paymentInAmountAsset)
552517 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
553518 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
554- let amount = $t02657726744._1
555- let balance = $t02657726744._2
519+ let amount = $t02467524842._1
520+ let balance = $t02467524842._2
556521 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
557522 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
558523 }
559- $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
524+ $Tuple4(issueAmount, commonState, feeAmount, loss)
560525 }
561526 else throw("Strict value is not equal to itself.")
562527 }
563528
564529
565530 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
566531 let isEval = (txId == unit)
567- let cfg = getPoolConfig()
568- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
569- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
570532 let checks = [if ((paymentAssetId == cfgLpAssetId))
571533 then true
572534 else throwErr("invalid lp asset")]
573535 if ((checks == checks))
574536 then {
575537 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
576538 then true
577539 else if ((outAssetId == cfgPriceAssetId))
578540 then false
579541 else throwErr("invalid asset")
580542 let balanceBigInt = if (outInAmountAsset)
581543 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
582544 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
583- let outInAmountAssetDecimals = if (outInAmountAsset)
584- then amtAssetDcm
585- else priceAssetDcm
586545 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
587546 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
588547 let outBalance = if (outInAmountAsset)
589548 then amBalanceOld
590549 else prBalanceOld
591550 let outBalanceBigInt = toBigInt(outBalance)
592551 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
593552 let redeemedBigInt = toBigInt(paymentAmount)
594553 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
595- let $t02882328873 = takeFee(amountRaw)
596- let totalAmount = $t02882328873._1
597- let feeAmount = $t02882328873._2
598- let $t02887729103 = if (outInAmountAsset)
554+ let $t02642226472 = takeFee(amountRaw)
555+ let totalAmount = $t02642226472._1
556+ let feeAmount = $t02642226472._2
557+ let $t02647626702 = if (outInAmountAsset)
599558 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
600559 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
601- let outAmAmount = $t02887729103._1
602- let outPrAmount = $t02887729103._2
603- let amBalanceNew = $t02887729103._3
604- let prBalanceNew = $t02887729103._4
560+ let outAmAmount = $t02647626702._1
561+ let outPrAmount = $t02647626702._2
562+ let amBalanceNew = $t02647626702._3
563+ let prBalanceNew = $t02647626702._4
605564 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
606565 let priceNew = fromX18(priceNewX18, scale8)
607566 let commonState = if (isEval)
608567 then nil
609568 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)]
610569 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
611570 let priceOld = fromX18(priceOldX18, scale8)
612571 let loss = {
613572 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
614573 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
615574 }
616- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
575+ $Tuple4(totalAmount, commonState, feeAmount, loss)
617576 }
618577 else throw("Strict value is not equal to itself.")
619578 }
620579
621580
622581 func managerPublicKeyOrUnit () = match getString(mpk()) {
623582 case s: String =>
624583 fromBase58String(s)
625584 case _: Unit =>
626585 unit
627586 case _ =>
628587 throw("Match error")
629588 }
630589
631590
632591 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
633592 case s: String =>
634593 fromBase58String(s)
635594 case _: Unit =>
636595 unit
637596 case _ =>
638597 throw("Match error")
639598 }
640599
641600
642601 func isManager (i) = match managerPublicKeyOrUnit() {
643602 case pk: ByteVector =>
644603 (i.callerPublicKey == pk)
645604 case _: Unit =>
646605 (i.caller == this)
647606 case _ =>
648607 throw("Match error")
649608 }
650609
651610
652611 func mustManager (i) = {
653612 let pd = throw("Permission denied")
654613 match managerPublicKeyOrUnit() {
655614 case pk: ByteVector =>
656615 if ((i.callerPublicKey == pk))
657616 then true
658617 else pd
659618 case _: Unit =>
660619 if ((i.caller == this))
661620 then true
662621 else pd
663622 case _ =>
664623 throw("Match error")
665624 }
666625 }
667626
668627
669628 @Callable(i)
670629 func setManager (pendingManagerPublicKey) = {
671630 let checkCaller = mustManager(i)
672631 if ((checkCaller == checkCaller))
673632 then {
674633 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
675634 if ((checkManagerPublicKey == checkManagerPublicKey))
676635 then [StringEntry(pmpk(), pendingManagerPublicKey)]
677636 else throw("Strict value is not equal to itself.")
678637 }
679638 else throw("Strict value is not equal to itself.")
680639 }
681640
682641
683642
684643 @Callable(i)
685644 func confirmManager () = {
686645 let pm = pendingManagerPublicKeyOrUnit()
687646 let hasPM = if (isDefined(pm))
688647 then true
689648 else throw("No pending manager")
690649 if ((hasPM == hasPM))
691650 then {
692651 let checkPM = if ((i.callerPublicKey == value(pm)))
693652 then true
694653 else throw("You are not pending manager")
695654 if ((checkPM == checkPM))
696655 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
697656 else throw("Strict value is not equal to itself.")
698657 }
699658 else throw("Strict value is not equal to itself.")
700659 }
701660
702661
703662
704663 @Callable(i)
705664 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
706665 then throw("Invalid slippageTolerance passed")
707666 else {
708667 let estPut = commonPut(i, slippageTolerance, true)
709668 let emitLpAmt = estPut._2
710669 let lpAssetId = estPut._7
711670 let state = estPut._9
712671 let amDiff = estPut._10
713672 let prDiff = estPut._11
714673 let amId = estPut._12
715674 let prId = estPut._13
716- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
717- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
718- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
719- if ((currentKLp == currentKLp))
675+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
676+ if ((emitInv == emitInv))
720677 then {
721- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
722- if ((emitInv == emitInv))
678+ let emitInvLegacy = match emitInv {
679+ case legacyFactoryContract: Address =>
680+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
681+ case _ =>
682+ unit
683+ }
684+ if ((emitInvLegacy == emitInvLegacy))
723685 then {
724- let emitInvLegacy = match emitInv {
725- case legacyFactoryContract: Address =>
726- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
727- case _ =>
728- unit
729- }
730- if ((emitInvLegacy == emitInvLegacy))
686+ let slippageAInv = if ((amDiff > 0))
687+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
688+ else nil
689+ if ((slippageAInv == slippageAInv))
731690 then {
732- let slippageAInv = if ((amDiff > 0))
733- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
691+ let slippagePInv = if ((prDiff > 0))
692+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
734693 else nil
735- if ((slippageAInv == slippageAInv))
694+ if ((slippagePInv == slippagePInv))
736695 then {
737- let slippagePInv = if ((prDiff > 0))
738- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
739- else nil
740- if ((slippagePInv == slippagePInv))
696+ let lpTransfer = if (shouldAutoStake)
741697 then {
742- let lpTransfer = if (shouldAutoStake)
743- then {
744- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
745- if ((slpStakeInv == slpStakeInv))
746- then nil
747- else throw("Strict value is not equal to itself.")
748- }
749- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
750- let $t03363134093 = refreshKLpInternal(0, 0, 0)
751- if (($t03363134093 == $t03363134093))
752- then {
753- let updatedKLp = $t03363134093._2
754- let refreshKLpActions = $t03363134093._1
755- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
756- if ((isUpdatedKLpValid == isUpdatedKLpValid))
757- then ((state ++ lpTransfer) ++ refreshKLpActions)
758- else throw("Strict value is not equal to itself.")
759- }
698+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
699+ if ((slpStakeInv == slpStakeInv))
700+ then nil
760701 else throw("Strict value is not equal to itself.")
761702 }
762- else throw("Strict value is not equal to itself.")
703+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
704+ (state ++ lpTransfer)
763705 }
764706 else throw("Strict value is not equal to itself.")
765707 }
766708 else throw("Strict value is not equal to itself.")
767709 }
768710 else throw("Strict value is not equal to itself.")
769711 }
770712 else throw("Strict value is not equal to itself.")
771713 }
772714
773715
774716
775717 @Callable(i)
776718 func putForFree (maxSlippage) = if ((0 > maxSlippage))
777719 then throw("Invalid value passed")
778720 else {
779721 let estPut = commonPut(i, maxSlippage, false)
780- let state = estPut._9
781- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
782- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
783- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
784- if ((currentKLp == currentKLp))
785- then {
786- let $t03465534720 = refreshKLpInternal(0, 0, 0)
787- let refreshKLpActions = $t03465534720._1
788- let updatedKLp = $t03465534720._2
789- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
790- if ((isUpdatedKLpValid == isUpdatedKLpValid))
791- then (state ++ refreshKLpActions)
792- else throw("Strict value is not equal to itself.")
793- }
794- else throw("Strict value is not equal to itself.")
722+ estPut._9
795723 }
796724
797725
798726
799727 @Callable(i)
800728 func putOneTkn (minOutAmount,autoStake) = {
801729 let isPoolOneTokenOperationsDisabled = {
802730 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
803731 if ($isInstanceOf(@, "Boolean"))
804732 then @
805733 else throw(($getType(@) + " couldn't be cast to Boolean"))
806734 }
807735 let isPutDisabled = if (if (if (isGlobalShutdown())
808736 then true
809737 else (cfgPoolStatus == PoolPutDisabled))
810738 then true
811739 else (cfgPoolStatus == PoolShutdown))
812740 then true
813741 else isPoolOneTokenOperationsDisabled
814742 let checks = [if (if (!(isPutDisabled))
815743 then true
816744 else isManager(i))
817745 then true
818746 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
819747 then true
820748 else throwErr("exactly 1 payment are expected")]
821749 if ((checks == checks))
822750 then {
823751 let payment = i.payments[0]
824752 let paymentAssetId = payment.assetId
825753 let paymentAmountRaw = payment.amount
826- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
827- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
828- else if ((paymentAssetId == cfgPriceAssetId))
829- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
830- else throwErr("payment asset is not supported")
831- if ((currentKLp == currentKLp))
754+ let userAddress = i.caller
755+ let txId = i.transactionId
756+ let $t03160931739 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
757+ if (($t03160931739 == $t03160931739))
832758 then {
833- let userAddress = i.caller
834- let txId = i.transactionId
835- let $t03590836060 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
836- if (($t03590836060 == $t03590836060))
759+ let bonus = $t03160931739._4
760+ let feeAmount = $t03160931739._3
761+ let commonState = $t03160931739._2
762+ let emitAmountEstimated = $t03160931739._1
763+ let emitAmount = if (if ((minOutAmount > 0))
764+ then (minOutAmount > emitAmountEstimated)
765+ else false)
766+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
767+ else emitAmountEstimated
768+ let emitInv = emit(emitAmount)
769+ if ((emitInv == emitInv))
837770 then {
838- let paymentInAmountAsset = $t03590836060._5
839- let bonus = $t03590836060._4
840- let feeAmount = $t03590836060._3
841- let commonState = $t03590836060._2
842- let emitAmountEstimated = $t03590836060._1
843- let emitAmount = if (if ((minOutAmount > 0))
844- then (minOutAmount > emitAmountEstimated)
845- else false)
846- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
847- else emitAmountEstimated
848- let emitInv = emit(emitAmount)
849- if ((emitInv == emitInv))
771+ let lpTransfer = if (autoStake)
850772 then {
851- let lpTransfer = if (autoStake)
852- then {
853- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
854- if ((stakeInv == stakeInv))
855- then nil
856- else throw("Strict value is not equal to itself.")
857- }
858- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
859- let sendFee = if ((feeAmount > 0))
860- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
861- else nil
862- let $t03664636843 = if ((this == feeCollectorAddress))
863- then $Tuple2(0, 0)
864- else if (paymentInAmountAsset)
865- then $Tuple2(-(feeAmount), 0)
866- else $Tuple2(0, -(feeAmount))
867- let amountAssetBalanceDelta = $t03664636843._1
868- let priceAssetBalanceDelta = $t03664636843._2
869- let $t03684636954 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
870- let refreshKLpActions = $t03684636954._1
871- let updatedKLp = $t03684636954._2
872- let kLp = value(getString(keyKLp))
873- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
874- if ((isUpdatedKLpValid == isUpdatedKLpValid))
875- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
773+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
774+ if ((stakeInv == stakeInv))
775+ then nil
876776 else throw("Strict value is not equal to itself.")
877777 }
878- else throw("Strict value is not equal to itself.")
778+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
779+ let sendFee = if ((feeAmount > 0))
780+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
781+ else nil
782+ $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
879783 }
880784 else throw("Strict value is not equal to itself.")
881785 }
882786 else throw("Strict value is not equal to itself.")
883787 }
884788 else throw("Strict value is not equal to itself.")
885789 }
886790
887791
888792
889793 @Callable(i)
890794 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
891- let $t03726037417 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
892- let emitAmountEstimated = $t03726037417._1
893- let commonState = $t03726037417._2
894- let feeAmount = $t03726037417._3
895- let bonus = $t03726037417._4
896- let paymentInAmountAsset = $t03726037417._5
795+ let $t03246832603 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
796+ let emitAmountEstimated = $t03246832603._1
797+ let commonState = $t03246832603._2
798+ let feeAmount = $t03246832603._3
799+ let bonus = $t03246832603._4
897800 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
898801 }
899802
900803
901804
902805 @Callable(i)
903806 func getOneTkn (outAssetIdStr,minOutAmount) = {
904807 let isPoolOneTokenOperationsDisabled = {
905808 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
906809 if ($isInstanceOf(@, "Boolean"))
907810 then @
908811 else throw(($getType(@) + " couldn't be cast to Boolean"))
909812 }
910813 let isGetDisabled = if (if (isGlobalShutdown())
911814 then true
912815 else (cfgPoolStatus == PoolShutdown))
913816 then true
914817 else isPoolOneTokenOperationsDisabled
915818 let checks = [if (if (!(isGetDisabled))
916819 then true
917820 else isManager(i))
918821 then true
919822 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
920823 then true
921824 else throwErr("exactly 1 payment are expected")]
922825 if ((checks == checks))
923826 then {
924827 let outAssetId = parseAssetId(outAssetIdStr)
925828 let payment = i.payments[0]
926829 let paymentAssetId = payment.assetId
927830 let paymentAmount = payment.amount
928- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
929- if ((currentKLp == currentKLp))
831+ let userAddress = i.caller
832+ let txId = i.transactionId
833+ let $t03340833543 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
834+ if (($t03340833543 == $t03340833543))
930835 then {
931- let userAddress = i.caller
932- let txId = i.transactionId
933- let $t03830238455 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
934- if (($t03830238455 == $t03830238455))
836+ let bonus = $t03340833543._4
837+ let feeAmount = $t03340833543._3
838+ let commonState = $t03340833543._2
839+ let amountEstimated = $t03340833543._1
840+ let amount = if (if ((minOutAmount > 0))
841+ then (minOutAmount > amountEstimated)
842+ else false)
843+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
844+ else amountEstimated
845+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
846+ if ((burnInv == burnInv))
935847 then {
936- let outInAmountAsset = $t03830238455._5
937- let bonus = $t03830238455._4
938- let feeAmount = $t03830238455._3
939- let commonState = $t03830238455._2
940- let amountEstimated = $t03830238455._1
941- let amount = if (if ((minOutAmount > 0))
942- then (minOutAmount > amountEstimated)
943- else false)
944- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
945- else amountEstimated
946- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
947- if ((burnInv == burnInv))
948- then {
949- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
950- let sendFee = if ((feeAmount > 0))
951- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
952- else nil
953- let $t03895539202 = {
954- let feeAmountForCalc = if ((this == feeCollectorAddress))
955- then 0
956- else feeAmount
957- if (outInAmountAsset)
958- then $Tuple2(-((amount + feeAmountForCalc)), 0)
959- else $Tuple2(0, -((amount + feeAmountForCalc)))
960- }
961- let amountAssetBalanceDelta = $t03895539202._1
962- let priceAssetBalanceDelta = $t03895539202._2
963- let $t03920539313 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
964- let refreshKLpActions = $t03920539313._1
965- let updatedKLp = $t03920539313._2
966- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
967- if ((isUpdatedKLpValid == isUpdatedKLpValid))
968- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
969- else throw("Strict value is not equal to itself.")
970- }
971- else throw("Strict value is not equal to itself.")
848+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
849+ let sendFee = if ((feeAmount > 0))
850+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
851+ else nil
852+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
972853 }
973854 else throw("Strict value is not equal to itself.")
974855 }
975856 else throw("Strict value is not equal to itself.")
976857 }
977858 else throw("Strict value is not equal to itself.")
978859 }
979860
980861
981862
982863 @Callable(i)
983864 func getOneTknREADONLY (outAssetId,paymentAmount) = {
984- let $t03957039726 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
985- let amountEstimated = $t03957039726._1
986- let commonState = $t03957039726._2
987- let feeAmount = $t03957039726._3
988- let bonus = $t03957039726._4
989- let outInAmountAsset = $t03957039726._5
865+ let $t03417834316 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
866+ let amountEstimated = $t03417834316._1
867+ let commonState = $t03417834316._2
868+ let feeAmount = $t03417834316._3
869+ let bonus = $t03417834316._4
990870 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
991871 }
992872
993873
994874
995875 @Callable(i)
996876 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
997877 let isPoolOneTokenOperationsDisabled = {
998878 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
999879 if ($isInstanceOf(@, "Boolean"))
1000880 then @
1001881 else throw(($getType(@) + " couldn't be cast to Boolean"))
1002882 }
1003883 let isGetDisabled = if (if (isGlobalShutdown())
1004884 then true
1005885 else (cfgPoolStatus == PoolShutdown))
1006886 then true
1007887 else isPoolOneTokenOperationsDisabled
1008888 let checks = [if (if (!(isGetDisabled))
1009889 then true
1010890 else isManager(i))
1011891 then true
1012892 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
1013893 then true
1014894 else throwErr("no payments are expected")]
1015895 if ((checks == checks))
1016896 then {
1017897 let outAssetId = parseAssetId(outAssetIdStr)
1018898 let userAddress = i.caller
1019899 let txId = i.transactionId
1020- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1021- if ((currentKLp == currentKLp))
900+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
901+ if ((unstakeInv == unstakeInv))
1022902 then {
1023- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1024- if ((unstakeInv == unstakeInv))
903+ let $t03514135274 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
904+ if (($t03514135274 == $t03514135274))
1025905 then {
1026- let $t04063140782 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1027- if (($t04063140782 == $t04063140782))
906+ let bonus = $t03514135274._4
907+ let feeAmount = $t03514135274._3
908+ let commonState = $t03514135274._2
909+ let amountEstimated = $t03514135274._1
910+ let amount = if (if ((minOutAmount > 0))
911+ then (minOutAmount > amountEstimated)
912+ else false)
913+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
914+ else amountEstimated
915+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
916+ if ((burnInv == burnInv))
1028917 then {
1029- let outInAmountAsset = $t04063140782._5
1030- let bonus = $t04063140782._4
1031- let feeAmount = $t04063140782._3
1032- let commonState = $t04063140782._2
1033- let amountEstimated = $t04063140782._1
1034- let amount = if (if ((minOutAmount > 0))
1035- then (minOutAmount > amountEstimated)
1036- else false)
1037- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1038- else amountEstimated
1039- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1040- if ((burnInv == burnInv))
1041- then {
1042- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1043- let sendFee = if ((feeAmount > 0))
1044- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1045- else nil
1046- let $t04127741524 = {
1047- let feeAmountForCalc = if ((this == feeCollectorAddress))
1048- then 0
1049- else feeAmount
1050- if (outInAmountAsset)
1051- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1052- else $Tuple2(0, -((amount + feeAmountForCalc)))
1053- }
1054- let amountAssetBalanceDelta = $t04127741524._1
1055- let priceAssetBalanceDelta = $t04127741524._2
1056- let $t04152741635 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1057- let refreshKLpActions = $t04152741635._1
1058- let updatedKLp = $t04152741635._2
1059- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1060- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1061- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1062- else throw("Strict value is not equal to itself.")
1063- }
1064- else throw("Strict value is not equal to itself.")
918+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
919+ let sendFee = if ((feeAmount > 0))
920+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
921+ else nil
922+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1065923 }
1066924 else throw("Strict value is not equal to itself.")
1067925 }
1068926 else throw("Strict value is not equal to itself.")
1069927 }
1070928 else throw("Strict value is not equal to itself.")
1071929 }
1072930 else throw("Strict value is not equal to itself.")
1073931 }
1074932
1075933
1076934
1077935 @Callable(i)
1078936 func get () = {
1079937 let res = commonGet(i)
1080938 let outAmtAmt = res._1
1081939 let outPrAmt = res._2
1082940 let pmtAmt = res._3
1083941 let pmtAssetId = res._4
1084942 let state = res._5
1085- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1086- if ((currentKLp == currentKLp))
1087- then {
1088- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1089- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1090- then {
1091- let $t04258142663 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1092- let refreshKLpActions = $t04258142663._1
1093- let updatedKLp = $t04258142663._2
1094- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1095- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1096- then (state ++ refreshKLpActions)
1097- else throw("Strict value is not equal to itself.")
1098- }
1099- else throw("Strict value is not equal to itself.")
1100- }
943+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
944+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
945+ then state
1101946 else throw("Strict value is not equal to itself.")
1102947 }
1103948
1104949
1105950
1106951 @Callable(i)
1107952 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
1108953 let res = commonGet(i)
1109954 let outAmAmt = res._1
1110955 let outPrAmt = res._2
1111956 let pmtAmt = res._3
1112957 let pmtAssetId = res._4
1113958 let state = res._5
1114959 if ((noLessThenAmtAsset > outAmAmt))
1115960 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
1116961 else if ((noLessThenPriceAsset > outPrAmt))
1117962 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1118963 else {
1119- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1120- if ((currentKLp == currentKLp))
1121- then {
1122- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1123- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1124- then {
1125- let $t04361243693 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1126- let refreshKLpActions = $t04361243693._1
1127- let updatedKLp = $t04361243693._2
1128- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1129- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1130- then (state ++ refreshKLpActions)
1131- else throw("Strict value is not equal to itself.")
1132- }
1133- else throw("Strict value is not equal to itself.")
1134- }
964+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
965+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
966+ then state
1135967 else throw("Strict value is not equal to itself.")
1136968 }
1137969 }
1138970
1139971
1140972
1141973 @Callable(i)
1142974 func unstakeAndGet (amount) = {
1143975 let checkPayments = if ((size(i.payments) != 0))
1144976 then throw("No payments are expected")
1145977 else true
1146978 if ((checkPayments == checkPayments))
1147979 then {
1148980 let cfg = getPoolConfig()
1149981 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1150- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1151- if ((currentKLp == currentKLp))
982+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
983+ if ((unstakeInv == unstakeInv))
1152984 then {
1153- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1154- if ((unstakeInv == unstakeInv))
985+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
986+ let poolStatus = parseIntValue(res._9)
987+ let state = res._10
988+ let checkPoolStatus = if (if (isGlobalShutdown())
989+ then true
990+ else (poolStatus == PoolShutdown))
991+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
992+ else true
993+ if ((checkPoolStatus == checkPoolStatus))
1155994 then {
1156- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1157- let outAmAmt = res._1
1158- let outPrAmt = res._2
1159- let poolStatus = parseIntValue(res._9)
1160- let state = res._10
1161- let checkPoolStatus = if (if (isGlobalShutdown())
1162- then true
1163- else (poolStatus == PoolShutdown))
1164- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1165- else true
1166- if ((checkPoolStatus == checkPoolStatus))
1167- then {
1168- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1169- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1170- then {
1171- let $t04481944900 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1172- let refreshKLpActions = $t04481944900._1
1173- let updatedKLp = $t04481944900._2
1174- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1175- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1176- then (state ++ refreshKLpActions)
1177- else throw("Strict value is not equal to itself.")
1178- }
1179- else throw("Strict value is not equal to itself.")
1180- }
995+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
996+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
997+ then state
1181998 else throw("Strict value is not equal to itself.")
1182999 }
11831000 else throw("Strict value is not equal to itself.")
11841001 }
11851002 else throw("Strict value is not equal to itself.")
11861003 }
11871004 else throw("Strict value is not equal to itself.")
11881005 }
11891006
11901007
11911008
11921009 @Callable(i)
11931010 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
11941011 let isGetDisabled = if (isGlobalShutdown())
11951012 then true
11961013 else (cfgPoolStatus == PoolShutdown)
11971014 let checks = [if (!(isGetDisabled))
11981015 then true
11991016 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
12001017 then true
12011018 else throw("no payments are expected")]
12021019 if ((checks == checks))
12031020 then {
1204- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1205- if ((currentKLp == currentKLp))
1021+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1022+ if ((unstakeInv == unstakeInv))
12061023 then {
1207- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1208- if ((unstakeInv == unstakeInv))
1024+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1025+ let outAmAmt = res._1
1026+ let outPrAmt = res._2
1027+ let state = res._10
1028+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1029+ then true
1030+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1031+ then true
1032+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1033+ if ((checkAmounts == checkAmounts))
12091034 then {
1210- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1211- let outAmAmt = res._1
1212- let outPrAmt = res._2
1213- let state = res._10
1214- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1215- then true
1216- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1217- then true
1218- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1219- if ((checkAmounts == checkAmounts))
1220- then {
1221- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1222- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1223- then {
1224- let $t04619546276 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1225- let refreshKLpActions = $t04619546276._1
1226- let updatedKLp = $t04619546276._2
1227- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1228- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1229- then (state ++ refreshKLpActions)
1230- else throw("Strict value is not equal to itself.")
1231- }
1232- else throw("Strict value is not equal to itself.")
1233- }
1035+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1036+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1037+ then state
12341038 else throw("Strict value is not equal to itself.")
12351039 }
12361040 else throw("Strict value is not equal to itself.")
12371041 }
12381042 else throw("Strict value is not equal to itself.")
12391043 }
12401044 else throw("Strict value is not equal to itself.")
12411045 }
12421046
12431047
12441048
12451049 @Callable(i)
12461050 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12471051 then throw("permissions denied")
12481052 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1249-
1250-
1251-
1252-@Callable(i)
1253-func refreshKLp () = {
1254- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1255- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1256- then unit
1257- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1258- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1259- then {
1260- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1261- let $t04746347527 = refreshKLpInternal(0, 0, 0)
1262- let kLpUpdateActions = $t04746347527._1
1263- let updatedKLp = $t04746347527._2
1264- let actions = if ((kLp != updatedKLp))
1265- then kLpUpdateActions
1266- else throwErr("nothing to refresh")
1267- $Tuple2(actions, toString(updatedKLp))
1268- }
1269- else throw("Strict value is not equal to itself.")
1270- }
12711053
12721054
12731055
12741056 @Callable(i)
12751057 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
12761058
12771059
12781060
12791061 @Callable(i)
12801062 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
12811063
12821064
12831065
12841066 @Callable(i)
12851067 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
12861068 let prices = calcPrices(amAmt, prAmt, lpAmt)
12871069 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
12881070 }
12891071
12901072
12911073
12921074 @Callable(i)
12931075 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
12941076
12951077
12961078
12971079 @Callable(i)
12981080 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
12991081
13001082
13011083
13021084 @Callable(i)
13031085 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
13041086
13051087
13061088
13071089 @Callable(i)
13081090 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
13091091
13101092
13111093
13121094 @Callable(i)
13131095 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
13141096 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
13151097 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
13161098 }
13171099
13181100
13191101
13201102 @Callable(i)
13211103 func statsREADONLY () = {
13221104 let cfg = getPoolConfig()
13231105 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13241106 let amtAssetId = cfg[idxAmtAssetId]
13251107 let priceAssetId = cfg[idxPriceAssetId]
13261108 let iAmtAssetId = cfg[idxIAmtAssetId]
13271109 let iPriceAssetId = cfg[idxIPriceAssetId]
13281110 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13291111 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13301112 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13311113 let accAmtAssetBalance = getAccBalance(amtAssetId)
13321114 let accPriceAssetBalance = getAccBalance(priceAssetId)
13331115 let pricesList = if ((poolLPBalance == 0))
13341116 then [zeroBigInt, zeroBigInt, zeroBigInt]
13351117 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
13361118 let curPrice = 0
13371119 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
13381120 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
13391121 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
13401122 $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))
13411123 }
13421124
13431125
13441126
13451127 @Callable(i)
13461128 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
13471129 let cfg = getPoolConfig()
13481130 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13491131 let amAssetIdStr = cfg[idxAmtAssetId]
13501132 let amAssetId = fromBase58String(amAssetIdStr)
13511133 let prAssetIdStr = cfg[idxPriceAssetId]
13521134 let prAssetId = fromBase58String(prAssetIdStr)
13531135 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13541136 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13551137 let poolStatus = cfg[idxPoolStatus]
13561138 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13571139 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
13581140 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
13591141 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
13601142 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
13611143 let curPriceX18 = if ((poolLPBalance == 0))
13621144 then zeroBigInt
13631145 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
13641146 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
13651147 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
13661148 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
13671149 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
13681150 let calcLpAmt = estPut._1
13691151 let curPriceCalc = estPut._3
13701152 let amBalance = estPut._4
13711153 let prBalance = estPut._5
13721154 let lpEmission = estPut._6
13731155 $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))
13741156 }
13751157
13761158
13771159
13781160 @Callable(i)
13791161 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
13801162 let cfg = getPoolConfig()
13811163 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13821164 let amAssetIdStr = cfg[idxAmtAssetId]
13831165 let amAssetId = fromBase58String(amAssetIdStr)
13841166 let prAssetIdStr = cfg[idxPriceAssetId]
13851167 let prAssetId = fromBase58String(prAssetIdStr)
13861168 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13871169 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13881170 let poolStatus = cfg[idxPoolStatus]
13891171 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13901172 let amBalanceRaw = getAccBalance(amAssetIdStr)
13911173 let prBalanceRaw = getAccBalance(prAssetIdStr)
13921174 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
13931175 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
13941176 let curPriceX18 = if ((poolLPBalance == 0))
13951177 then zeroBigInt
13961178 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
13971179 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
13981180 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
13991181 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
14001182 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
14011183 let calcLpAmt = estPut._1
14021184 let curPriceCalc = estPut._3
14031185 let amBalance = estPut._4
14041186 let prBalance = estPut._5
14051187 let lpEmission = estPut._6
14061188 $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))
14071189 }
14081190
14091191
14101192
14111193 @Callable(i)
14121194 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
14131195 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
14141196 let outAmAmt = res._1
14151197 let outPrAmt = res._2
14161198 let amBalance = res._5
14171199 let prBalance = res._6
14181200 let lpEmission = res._7
14191201 let curPrice = res._8
14201202 let poolStatus = parseIntValue(res._9)
14211203 $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))
14221204 }
14231205
14241206
14251207 @Verifier(tx)
14261208 func verify () = {
14271209 let targetPublicKey = match managerPublicKeyOrUnit() {
14281210 case pk: ByteVector =>
14291211 pk
14301212 case _: Unit =>
14311213 tx.senderPublicKey
14321214 case _ =>
14331215 throw("Match error")
14341216 }
14351217 match tx {
14361218 case order: Order =>
14371219 let matcherPub = getMatcherPubOrFail()
14381220 let orderValid = validateMatcherOrderAllowed(order)
14391221 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
14401222 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
14411223 if (if (if (orderValid)
14421224 then senderValid
14431225 else false)
14441226 then matcherValid
14451227 else false)
14461228 then true
14471229 else throwOrderError(orderValid, senderValid, matcherValid)
14481230 case s: SetScriptTransaction =>
14491231 let newHash = blake2b256(value(s.script))
14501232 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
14511233 let currentHash = scriptHash(this)
14521234 if (if ((allowedHash == newHash))
14531235 then (currentHash != newHash)
14541236 else false)
14551237 then true
14561238 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14571239 case _ =>
14581240 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14591241 }
14601242 }
14611243

github/deemru/w8io/026f985 
175.97 ms