tx · HZeNBr2KCrywZ5U1FQ31sHcrjq9chCNzxMic2qLym4iC

3NBLSz3BB8QU3BAPnsnrMyjFWr75tcEXryF:  -0.03100000 Waves

2022.12.09 09:33 [2352430] smart account 3NBLSz3BB8QU3BAPnsnrMyjFWr75tcEXryF > SELF 0.00000000 Waves

{ "type": 13, "id": "HZeNBr2KCrywZ5U1FQ31sHcrjq9chCNzxMic2qLym4iC", "fee": 3100000, "feeAssetId": null, "timestamp": 1670567515026, "version": 1, "sender": "3NBLSz3BB8QU3BAPnsnrMyjFWr75tcEXryF", "senderPublicKey": "BPTgianAtANVixAd7SHgec6W3RNNty3z1LVE9AQbYHdz", "proofs": [ "4GYTJUoGVtdZYoAXMXz76DYKmSVmoAxz4CRPnvFboVoUM4Uv9vySgGwFBZ8SnSpMgDqjCs4amDDENgJtuRggCwXP" ], "script": "base64:BgK8JwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASAwoBCBIFCgMBAQESBAoCAQESBAoCCAESBAoCCAgSCwoJCAEBAgECCAQEEgYKBAgIAQgSABIDCgEBEgMKAQESBAoCCAEiCmxQZGVjaW1hbHMiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgt3YXZlc1N0cmluZyIDU0VQIgpQb29sQWN0aXZlIg9Qb29sUHV0RGlzYWJsZWQiE1Bvb2xNYXRjaGVyRGlzYWJsZWQiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiDWlkeFBvb2xTdGF0dXMiEGlkeFBvb2xMUEFzc2V0SWQiDWlkeEFtdEFzc2V0SWQiD2lkeFByaWNlQXNzZXRJZCIOaWR4QW10QXNzZXREY20iEGlkeFByaWNlQXNzZXREY20iDmlkeElBbXRBc3NldElkIhBpZHhJUHJpY2VBc3NldElkIg1pZ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c2NyaXB0BAJmTgkA2wQBCQEFdmFsdWUBCQCdCAIFAmFECQECYXIABAJmTwkA8QcBBQR0aGlzAwMJAAACBQJmTgUCZk0JAQIhPQIFAmZPBQJmTQcGCQD0AwMIBQJmSQlib2R5Qnl0ZXMJAJEDAggFAmZJBnByb29mcwAABQJmSwkA9AMDCAUCZkkJYm9keUJ5dGVzCQCRAwIIBQJmSQZwcm9vZnMAAAUCZkuCh+//", "chainId": 84, "height": 2352430, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3rKLeDCTVR62PMog96oP2KNrFaaaBUJP1X7sZDsEXZo2 Next: 57fFPqbwLJnRBfDpRiaf9mQsJmnaYSpkzCmJyp1oA26v 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) = {
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 $t02077720989 = if ((order.orderType == Buy))
418- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
419- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
420- let amountAssetBalanceDelta = $t02077720989._1
421- let priceAssetBalanceDelta = $t02077720989._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 $t02146021560 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
435- let unusedActions = $t02146021560._1
436- let kLpNew = $t02146021560._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 $t02424524538 = 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 = $t02424524538._1
518- let priceBalanceOld = $t02424524538._2
519- let $t02454224691 = 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 = $t02454224691._1
523- let priceAssetAmountRaw = $t02454224691._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 $t02481324872 = takeFee(paymentAmountRaw)
527- let paymentAmount = $t02481324872._1
528- let feeAmount = $t02481324872._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 $t02634926516 = if (paymentInAmountAsset)
516+ let $t02467524842 = if (paymentInAmountAsset)
552517 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
553518 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
554- let amount = $t02634926516._1
555- let balance = $t02634926516._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 }
586551 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
587552 let redeemedBigInt = toBigInt(paymentAmount)
588553 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
589- let $t02811828168 = takeFee(amountRaw)
590- let totalAmount = $t02811828168._1
591- let feeAmount = $t02811828168._2
592- let $t02817228398 = if (outInAmountAsset)
554+ let $t02642226472 = takeFee(amountRaw)
555+ let totalAmount = $t02642226472._1
556+ let feeAmount = $t02642226472._2
557+ let $t02647626702 = if (outInAmountAsset)
593558 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
594559 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
595- let outAmAmount = $t02817228398._1
596- let outPrAmount = $t02817228398._2
597- let amBalanceNew = $t02817228398._3
598- let prBalanceNew = $t02817228398._4
560+ let outAmAmount = $t02647626702._1
561+ let outPrAmount = $t02647626702._2
562+ let amBalanceNew = $t02647626702._3
563+ let prBalanceNew = $t02647626702._4
599564 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
600565 let priceNew = fromX18(priceNewX18, scale8)
601566 let commonState = if (isEval)
607572 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
608573 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
609574 }
610- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
575+ $Tuple4(totalAmount, commonState, feeAmount, loss)
611576 }
612577 else throw("Strict value is not equal to itself.")
613578 }
707672 let prDiff = estPut._11
708673 let amId = estPut._12
709674 let prId = estPut._13
710- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
711- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
712- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
713- if ((currentKLp == currentKLp))
675+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
676+ if ((emitInv == emitInv))
714677 then {
715- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
716- 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))
717685 then {
718- let emitInvLegacy = match emitInv {
719- case legacyFactoryContract: Address =>
720- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
721- case _ =>
722- unit
723- }
724- 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))
725690 then {
726- let slippageAInv = if ((amDiff > 0))
727- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
691+ let slippagePInv = if ((prDiff > 0))
692+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
728693 else nil
729- if ((slippageAInv == slippageAInv))
694+ if ((slippagePInv == slippagePInv))
730695 then {
731- let slippagePInv = if ((prDiff > 0))
732- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
733- else nil
734- if ((slippagePInv == slippagePInv))
696+ let lpTransfer = if (shouldAutoStake)
735697 then {
736- let lpTransfer = if (shouldAutoStake)
737- then {
738- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
739- if ((slpStakeInv == slpStakeInv))
740- then nil
741- else throw("Strict value is not equal to itself.")
742- }
743- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
744- let $t03292633388 = refreshKLpInternal(0, 0, 0)
745- if (($t03292633388 == $t03292633388))
746- then {
747- let updatedKLp = $t03292633388._2
748- let refreshKLpActions = $t03292633388._1
749- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
750- if ((isUpdatedKLpValid == isUpdatedKLpValid))
751- then ((state ++ lpTransfer) ++ refreshKLpActions)
752- else throw("Strict value is not equal to itself.")
753- }
698+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
699+ if ((slpStakeInv == slpStakeInv))
700+ then nil
754701 else throw("Strict value is not equal to itself.")
755702 }
756- else throw("Strict value is not equal to itself.")
703+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
704+ (state ++ lpTransfer)
757705 }
758706 else throw("Strict value is not equal to itself.")
759707 }
771719 then throw("Invalid value passed")
772720 else {
773721 let estPut = commonPut(i, maxSlippage, false)
774- let state = estPut._9
775- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
776- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
777- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
778- if ((currentKLp == currentKLp))
779- then {
780- let $t03395034015 = refreshKLpInternal(0, 0, 0)
781- let refreshKLpActions = $t03395034015._1
782- let updatedKLp = $t03395034015._2
783- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
784- if ((isUpdatedKLpValid == isUpdatedKLpValid))
785- then (state ++ refreshKLpActions)
786- else throw("Strict value is not equal to itself.")
787- }
788- else throw("Strict value is not equal to itself.")
722+ estPut._9
789723 }
790724
791725
817751 let payment = i.payments[0]
818752 let paymentAssetId = payment.assetId
819753 let paymentAmountRaw = payment.amount
820- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
821- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
822- else if ((paymentAssetId == cfgPriceAssetId))
823- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
824- else throwErr("payment asset is not supported")
825754 let userAddress = i.caller
826755 let txId = i.transactionId
827- let $t03520035352 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
828- if (($t03520035352 == $t03520035352))
756+ let $t03160931739 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
757+ if (($t03160931739 == $t03160931739))
829758 then {
830- let paymentInAmountAsset = $t03520035352._5
831- let bonus = $t03520035352._4
832- let feeAmount = $t03520035352._3
833- let commonState = $t03520035352._2
834- let emitAmountEstimated = $t03520035352._1
759+ let bonus = $t03160931739._4
760+ let feeAmount = $t03160931739._3
761+ let commonState = $t03160931739._2
762+ let emitAmountEstimated = $t03160931739._1
835763 let emitAmount = if (if ((minOutAmount > 0))
836764 then (minOutAmount > emitAmountEstimated)
837765 else false)
851779 let sendFee = if ((feeAmount > 0))
852780 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
853781 else nil
854- let $t03593836135 = if ((this == feeCollectorAddress))
855- then $Tuple2(0, 0)
856- else if (paymentInAmountAsset)
857- then $Tuple2(-(feeAmount), 0)
858- else $Tuple2(0, -(feeAmount))
859- let amountAssetBalanceDelta = $t03593836135._1
860- let priceAssetBalanceDelta = $t03593836135._2
861- let $t03613836246 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
862- let refreshKLpActions = $t03613836246._1
863- let updatedKLp = $t03613836246._2
864- let kLp = value(getString(keyKLp))
865- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
866- if ((isUpdatedKLpValid == isUpdatedKLpValid))
867- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
868- else throw("Strict value is not equal to itself.")
782+ $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
869783 }
870784 else throw("Strict value is not equal to itself.")
871785 }
878792
879793 @Callable(i)
880794 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
881- let $t03655236709 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
882- let emitAmountEstimated = $t03655236709._1
883- let commonState = $t03655236709._2
884- let feeAmount = $t03655236709._3
885- let bonus = $t03655236709._4
886- let paymentInAmountAsset = $t03655236709._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
887800 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
888801 }
889802
915828 let payment = i.payments[0]
916829 let paymentAssetId = payment.assetId
917830 let paymentAmount = payment.amount
918- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount))
919831 let userAddress = i.caller
920832 let txId = i.transactionId
921- let $t03760337756 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
922- if (($t03760337756 == $t03760337756))
833+ let $t03340833543 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
834+ if (($t03340833543 == $t03340833543))
923835 then {
924- let outInAmountAsset = $t03760337756._5
925- let bonus = $t03760337756._4
926- let feeAmount = $t03760337756._3
927- let commonState = $t03760337756._2
928- let amountEstimated = $t03760337756._1
836+ let bonus = $t03340833543._4
837+ let feeAmount = $t03340833543._3
838+ let commonState = $t03340833543._2
839+ let amountEstimated = $t03340833543._1
929840 let amount = if (if ((minOutAmount > 0))
930841 then (minOutAmount > amountEstimated)
931842 else false)
938849 let sendFee = if ((feeAmount > 0))
939850 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
940851 else nil
941- let $t03825638503 = {
942- let feeAmountForCalc = if ((this == feeCollectorAddress))
943- then 0
944- else feeAmount
945- if (outInAmountAsset)
946- then $Tuple2(-((amount + feeAmountForCalc)), 0)
947- else $Tuple2(0, -((amount + feeAmountForCalc)))
948- }
949- let amountAssetBalanceDelta = $t03825638503._1
950- let priceAssetBalanceDelta = $t03825638503._2
951- let $t03850638614 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
952- let refreshKLpActions = $t03850638614._1
953- let updatedKLp = $t03850638614._2
954- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
955- if ((isUpdatedKLpValid == isUpdatedKLpValid))
956- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
957- else throw("Strict value is not equal to itself.")
852+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
958853 }
959854 else throw("Strict value is not equal to itself.")
960855 }
967862
968863 @Callable(i)
969864 func getOneTknREADONLY (outAssetId,paymentAmount) = {
970- let $t03887139027 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
971- let amountEstimated = $t03887139027._1
972- let commonState = $t03887139027._2
973- let feeAmount = $t03887139027._3
974- let bonus = $t03887139027._4
975- let outInAmountAsset = $t03887139027._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
976870 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
977871 }
978872
1003897 let outAssetId = parseAssetId(outAssetIdStr)
1004898 let userAddress = i.caller
1005899 let txId = i.transactionId
1006- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1007900 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1008901 if ((unstakeInv == unstakeInv))
1009902 then {
1010- let $t03992940080 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1011- if (($t03992940080 == $t03992940080))
903+ let $t03514135274 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
904+ if (($t03514135274 == $t03514135274))
1012905 then {
1013- let outInAmountAsset = $t03992940080._5
1014- let bonus = $t03992940080._4
1015- let feeAmount = $t03992940080._3
1016- let commonState = $t03992940080._2
1017- let amountEstimated = $t03992940080._1
906+ let bonus = $t03514135274._4
907+ let feeAmount = $t03514135274._3
908+ let commonState = $t03514135274._2
909+ let amountEstimated = $t03514135274._1
1018910 let amount = if (if ((minOutAmount > 0))
1019911 then (minOutAmount > amountEstimated)
1020912 else false)
1027919 let sendFee = if ((feeAmount > 0))
1028920 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1029921 else nil
1030- let $t04057540822 = {
1031- let feeAmountForCalc = if ((this == feeCollectorAddress))
1032- then 0
1033- else feeAmount
1034- if (outInAmountAsset)
1035- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1036- else $Tuple2(0, -((amount + feeAmountForCalc)))
1037- }
1038- let amountAssetBalanceDelta = $t04057540822._1
1039- let priceAssetBalanceDelta = $t04057540822._2
1040- let $t04082540933 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1041- let refreshKLpActions = $t04082540933._1
1042- let updatedKLp = $t04082540933._2
1043- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1044- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1045- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1046- else throw("Strict value is not equal to itself.")
922+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1047923 }
1048924 else throw("Strict value is not equal to itself.")
1049925 }
1064940 let pmtAmt = res._3
1065941 let pmtAssetId = res._4
1066942 let state = res._5
1067- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
1068943 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1069944 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1070- then {
1071- let $t04188141963 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1072- let refreshKLpActions = $t04188141963._1
1073- let updatedKLp = $t04188141963._2
1074- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1075- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1076- then (state ++ refreshKLpActions)
1077- else throw("Strict value is not equal to itself.")
1078- }
945+ then state
1079946 else throw("Strict value is not equal to itself.")
1080947 }
1081948
1094961 else if ((noLessThenPriceAsset > outPrAmt))
1095962 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1096963 else {
1097- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
1098964 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1099965 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1100- then {
1101- let $t04291442995 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1102- let refreshKLpActions = $t04291442995._1
1103- let updatedKLp = $t04291442995._2
1104- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1105- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1106- then (state ++ refreshKLpActions)
1107- else throw("Strict value is not equal to itself.")
1108- }
966+ then state
1109967 else throw("Strict value is not equal to itself.")
1110968 }
1111969 }
1121979 then {
1122980 let cfg = getPoolConfig()
1123981 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1124- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1125982 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1126983 if ((unstakeInv == unstakeInv))
1127984 then {
1128985 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1129- let outAmAmt = res._1
1130- let outPrAmt = res._2
1131986 let poolStatus = parseIntValue(res._9)
1132987 let state = res._10
1133988 let checkPoolStatus = if (if (isGlobalShutdown())
1139994 then {
1140995 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1141996 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1142- then {
1143- let $t04411844199 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1144- let refreshKLpActions = $t04411844199._1
1145- let updatedKLp = $t04411844199._2
1146- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1147- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1148- then (state ++ refreshKLpActions)
1149- else throw("Strict value is not equal to itself.")
1150- }
997+ then state
1151998 else throw("Strict value is not equal to itself.")
1152999 }
11531000 else throw("Strict value is not equal to itself.")
11711018 else throw("no payments are expected")]
11721019 if ((checks == checks))
11731020 then {
1174- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11751021 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11761022 if ((unstakeInv == unstakeInv))
11771023 then {
11881034 then {
11891035 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11901036 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1191- then {
1192- let $t04549145572 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1193- let refreshKLpActions = $t04549145572._1
1194- let updatedKLp = $t04549145572._2
1195- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1196- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1197- then (state ++ refreshKLpActions)
1198- else throw("Strict value is not equal to itself.")
1199- }
1037+ then state
12001038 else throw("Strict value is not equal to itself.")
12011039 }
12021040 else throw("Strict value is not equal to itself.")
12121050 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12131051 then throw("permissions denied")
12141052 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1215-
1216-
1217-
1218-@Callable(i)
1219-func refreshKLp () = {
1220- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1221- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1222- then unit
1223- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1224- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1225- then {
1226- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1227- let $t04675946823 = refreshKLpInternal(0, 0, 0)
1228- let kLpUpdateActions = $t04675946823._1
1229- let updatedKLp = $t04675946823._2
1230- let actions = if ((kLp != updatedKLp))
1231- then kLpUpdateActions
1232- else throwErr("nothing to refresh")
1233- $Tuple2(actions, toString(updatedKLp))
1234- }
1235- else throw("Strict value is not equal to itself.")
1236- }
12371053
12381054
12391055
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)
291272 let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
292273 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 $t02077720989 = if ((order.orderType == Buy))
418- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
419- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
420- let amountAssetBalanceDelta = $t02077720989._1
421- let priceAssetBalanceDelta = $t02077720989._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 $t02146021560 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
435- let unusedActions = $t02146021560._1
436- let kLpNew = $t02146021560._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 $t02424524538 = 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 = $t02424524538._1
518- let priceBalanceOld = $t02424524538._2
519- let $t02454224691 = 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 = $t02454224691._1
523- let priceAssetAmountRaw = $t02454224691._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 $t02481324872 = takeFee(paymentAmountRaw)
527- let paymentAmount = $t02481324872._1
528- let feeAmount = $t02481324872._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 $t02634926516 = if (paymentInAmountAsset)
516+ let $t02467524842 = if (paymentInAmountAsset)
552517 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
553518 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
554- let amount = $t02634926516._1
555- let balance = $t02634926516._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)
567532 let checks = [if ((paymentAssetId == cfgLpAssetId))
568533 then true
569534 else throwErr("invalid lp asset")]
570535 if ((checks == checks))
571536 then {
572537 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
573538 then true
574539 else if ((outAssetId == cfgPriceAssetId))
575540 then false
576541 else throwErr("invalid asset")
577542 let balanceBigInt = if (outInAmountAsset)
578543 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
579544 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
580545 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
581546 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
582547 let outBalance = if (outInAmountAsset)
583548 then amBalanceOld
584549 else prBalanceOld
585550 let outBalanceBigInt = toBigInt(outBalance)
586551 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
587552 let redeemedBigInt = toBigInt(paymentAmount)
588553 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
589- let $t02811828168 = takeFee(amountRaw)
590- let totalAmount = $t02811828168._1
591- let feeAmount = $t02811828168._2
592- let $t02817228398 = if (outInAmountAsset)
554+ let $t02642226472 = takeFee(amountRaw)
555+ let totalAmount = $t02642226472._1
556+ let feeAmount = $t02642226472._2
557+ let $t02647626702 = if (outInAmountAsset)
593558 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
594559 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
595- let outAmAmount = $t02817228398._1
596- let outPrAmount = $t02817228398._2
597- let amBalanceNew = $t02817228398._3
598- let prBalanceNew = $t02817228398._4
560+ let outAmAmount = $t02647626702._1
561+ let outPrAmount = $t02647626702._2
562+ let amBalanceNew = $t02647626702._3
563+ let prBalanceNew = $t02647626702._4
599564 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
600565 let priceNew = fromX18(priceNewX18, scale8)
601566 let commonState = if (isEval)
602567 then nil
603568 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)]
604569 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
605570 let priceOld = fromX18(priceOldX18, scale8)
606571 let loss = {
607572 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
608573 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
609574 }
610- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
575+ $Tuple4(totalAmount, commonState, feeAmount, loss)
611576 }
612577 else throw("Strict value is not equal to itself.")
613578 }
614579
615580
616581 func managerPublicKeyOrUnit () = match getString(mpk()) {
617582 case s: String =>
618583 fromBase58String(s)
619584 case _: Unit =>
620585 unit
621586 case _ =>
622587 throw("Match error")
623588 }
624589
625590
626591 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
627592 case s: String =>
628593 fromBase58String(s)
629594 case _: Unit =>
630595 unit
631596 case _ =>
632597 throw("Match error")
633598 }
634599
635600
636601 func isManager (i) = match managerPublicKeyOrUnit() {
637602 case pk: ByteVector =>
638603 (i.callerPublicKey == pk)
639604 case _: Unit =>
640605 (i.caller == this)
641606 case _ =>
642607 throw("Match error")
643608 }
644609
645610
646611 func mustManager (i) = {
647612 let pd = throw("Permission denied")
648613 match managerPublicKeyOrUnit() {
649614 case pk: ByteVector =>
650615 if ((i.callerPublicKey == pk))
651616 then true
652617 else pd
653618 case _: Unit =>
654619 if ((i.caller == this))
655620 then true
656621 else pd
657622 case _ =>
658623 throw("Match error")
659624 }
660625 }
661626
662627
663628 @Callable(i)
664629 func setManager (pendingManagerPublicKey) = {
665630 let checkCaller = mustManager(i)
666631 if ((checkCaller == checkCaller))
667632 then {
668633 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
669634 if ((checkManagerPublicKey == checkManagerPublicKey))
670635 then [StringEntry(pmpk(), pendingManagerPublicKey)]
671636 else throw("Strict value is not equal to itself.")
672637 }
673638 else throw("Strict value is not equal to itself.")
674639 }
675640
676641
677642
678643 @Callable(i)
679644 func confirmManager () = {
680645 let pm = pendingManagerPublicKeyOrUnit()
681646 let hasPM = if (isDefined(pm))
682647 then true
683648 else throw("No pending manager")
684649 if ((hasPM == hasPM))
685650 then {
686651 let checkPM = if ((i.callerPublicKey == value(pm)))
687652 then true
688653 else throw("You are not pending manager")
689654 if ((checkPM == checkPM))
690655 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
691656 else throw("Strict value is not equal to itself.")
692657 }
693658 else throw("Strict value is not equal to itself.")
694659 }
695660
696661
697662
698663 @Callable(i)
699664 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
700665 then throw("Invalid slippageTolerance passed")
701666 else {
702667 let estPut = commonPut(i, slippageTolerance, true)
703668 let emitLpAmt = estPut._2
704669 let lpAssetId = estPut._7
705670 let state = estPut._9
706671 let amDiff = estPut._10
707672 let prDiff = estPut._11
708673 let amId = estPut._12
709674 let prId = estPut._13
710- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
711- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
712- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
713- if ((currentKLp == currentKLp))
675+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
676+ if ((emitInv == emitInv))
714677 then {
715- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
716- 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))
717685 then {
718- let emitInvLegacy = match emitInv {
719- case legacyFactoryContract: Address =>
720- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
721- case _ =>
722- unit
723- }
724- 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))
725690 then {
726- let slippageAInv = if ((amDiff > 0))
727- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
691+ let slippagePInv = if ((prDiff > 0))
692+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
728693 else nil
729- if ((slippageAInv == slippageAInv))
694+ if ((slippagePInv == slippagePInv))
730695 then {
731- let slippagePInv = if ((prDiff > 0))
732- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
733- else nil
734- if ((slippagePInv == slippagePInv))
696+ let lpTransfer = if (shouldAutoStake)
735697 then {
736- let lpTransfer = if (shouldAutoStake)
737- then {
738- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
739- if ((slpStakeInv == slpStakeInv))
740- then nil
741- else throw("Strict value is not equal to itself.")
742- }
743- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
744- let $t03292633388 = refreshKLpInternal(0, 0, 0)
745- if (($t03292633388 == $t03292633388))
746- then {
747- let updatedKLp = $t03292633388._2
748- let refreshKLpActions = $t03292633388._1
749- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
750- if ((isUpdatedKLpValid == isUpdatedKLpValid))
751- then ((state ++ lpTransfer) ++ refreshKLpActions)
752- else throw("Strict value is not equal to itself.")
753- }
698+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
699+ if ((slpStakeInv == slpStakeInv))
700+ then nil
754701 else throw("Strict value is not equal to itself.")
755702 }
756- else throw("Strict value is not equal to itself.")
703+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
704+ (state ++ lpTransfer)
757705 }
758706 else throw("Strict value is not equal to itself.")
759707 }
760708 else throw("Strict value is not equal to itself.")
761709 }
762710 else throw("Strict value is not equal to itself.")
763711 }
764712 else throw("Strict value is not equal to itself.")
765713 }
766714
767715
768716
769717 @Callable(i)
770718 func putForFree (maxSlippage) = if ((0 > maxSlippage))
771719 then throw("Invalid value passed")
772720 else {
773721 let estPut = commonPut(i, maxSlippage, false)
774- let state = estPut._9
775- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
776- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
777- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
778- if ((currentKLp == currentKLp))
779- then {
780- let $t03395034015 = refreshKLpInternal(0, 0, 0)
781- let refreshKLpActions = $t03395034015._1
782- let updatedKLp = $t03395034015._2
783- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
784- if ((isUpdatedKLpValid == isUpdatedKLpValid))
785- then (state ++ refreshKLpActions)
786- else throw("Strict value is not equal to itself.")
787- }
788- else throw("Strict value is not equal to itself.")
722+ estPut._9
789723 }
790724
791725
792726
793727 @Callable(i)
794728 func putOneTkn (minOutAmount,autoStake) = {
795729 let isPoolOneTokenOperationsDisabled = {
796730 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
797731 if ($isInstanceOf(@, "Boolean"))
798732 then @
799733 else throw(($getType(@) + " couldn't be cast to Boolean"))
800734 }
801735 let isPutDisabled = if (if (if (isGlobalShutdown())
802736 then true
803737 else (cfgPoolStatus == PoolPutDisabled))
804738 then true
805739 else (cfgPoolStatus == PoolShutdown))
806740 then true
807741 else isPoolOneTokenOperationsDisabled
808742 let checks = [if (if (!(isPutDisabled))
809743 then true
810744 else isManager(i))
811745 then true
812746 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
813747 then true
814748 else throwErr("exactly 1 payment are expected")]
815749 if ((checks == checks))
816750 then {
817751 let payment = i.payments[0]
818752 let paymentAssetId = payment.assetId
819753 let paymentAmountRaw = payment.amount
820- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
821- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
822- else if ((paymentAssetId == cfgPriceAssetId))
823- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
824- else throwErr("payment asset is not supported")
825754 let userAddress = i.caller
826755 let txId = i.transactionId
827- let $t03520035352 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
828- if (($t03520035352 == $t03520035352))
756+ let $t03160931739 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
757+ if (($t03160931739 == $t03160931739))
829758 then {
830- let paymentInAmountAsset = $t03520035352._5
831- let bonus = $t03520035352._4
832- let feeAmount = $t03520035352._3
833- let commonState = $t03520035352._2
834- let emitAmountEstimated = $t03520035352._1
759+ let bonus = $t03160931739._4
760+ let feeAmount = $t03160931739._3
761+ let commonState = $t03160931739._2
762+ let emitAmountEstimated = $t03160931739._1
835763 let emitAmount = if (if ((minOutAmount > 0))
836764 then (minOutAmount > emitAmountEstimated)
837765 else false)
838766 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
839767 else emitAmountEstimated
840768 let emitInv = emit(emitAmount)
841769 if ((emitInv == emitInv))
842770 then {
843771 let lpTransfer = if (autoStake)
844772 then {
845773 let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
846774 if ((stakeInv == stakeInv))
847775 then nil
848776 else throw("Strict value is not equal to itself.")
849777 }
850778 else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
851779 let sendFee = if ((feeAmount > 0))
852780 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
853781 else nil
854- let $t03593836135 = if ((this == feeCollectorAddress))
855- then $Tuple2(0, 0)
856- else if (paymentInAmountAsset)
857- then $Tuple2(-(feeAmount), 0)
858- else $Tuple2(0, -(feeAmount))
859- let amountAssetBalanceDelta = $t03593836135._1
860- let priceAssetBalanceDelta = $t03593836135._2
861- let $t03613836246 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
862- let refreshKLpActions = $t03613836246._1
863- let updatedKLp = $t03613836246._2
864- let kLp = value(getString(keyKLp))
865- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
866- if ((isUpdatedKLpValid == isUpdatedKLpValid))
867- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
868- else throw("Strict value is not equal to itself.")
782+ $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
869783 }
870784 else throw("Strict value is not equal to itself.")
871785 }
872786 else throw("Strict value is not equal to itself.")
873787 }
874788 else throw("Strict value is not equal to itself.")
875789 }
876790
877791
878792
879793 @Callable(i)
880794 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
881- let $t03655236709 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
882- let emitAmountEstimated = $t03655236709._1
883- let commonState = $t03655236709._2
884- let feeAmount = $t03655236709._3
885- let bonus = $t03655236709._4
886- let paymentInAmountAsset = $t03655236709._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
887800 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
888801 }
889802
890803
891804
892805 @Callable(i)
893806 func getOneTkn (outAssetIdStr,minOutAmount) = {
894807 let isPoolOneTokenOperationsDisabled = {
895808 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
896809 if ($isInstanceOf(@, "Boolean"))
897810 then @
898811 else throw(($getType(@) + " couldn't be cast to Boolean"))
899812 }
900813 let isGetDisabled = if (if (isGlobalShutdown())
901814 then true
902815 else (cfgPoolStatus == PoolShutdown))
903816 then true
904817 else isPoolOneTokenOperationsDisabled
905818 let checks = [if (if (!(isGetDisabled))
906819 then true
907820 else isManager(i))
908821 then true
909822 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
910823 then true
911824 else throwErr("exactly 1 payment are expected")]
912825 if ((checks == checks))
913826 then {
914827 let outAssetId = parseAssetId(outAssetIdStr)
915828 let payment = i.payments[0]
916829 let paymentAssetId = payment.assetId
917830 let paymentAmount = payment.amount
918- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount))
919831 let userAddress = i.caller
920832 let txId = i.transactionId
921- let $t03760337756 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
922- if (($t03760337756 == $t03760337756))
833+ let $t03340833543 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
834+ if (($t03340833543 == $t03340833543))
923835 then {
924- let outInAmountAsset = $t03760337756._5
925- let bonus = $t03760337756._4
926- let feeAmount = $t03760337756._3
927- let commonState = $t03760337756._2
928- let amountEstimated = $t03760337756._1
836+ let bonus = $t03340833543._4
837+ let feeAmount = $t03340833543._3
838+ let commonState = $t03340833543._2
839+ let amountEstimated = $t03340833543._1
929840 let amount = if (if ((minOutAmount > 0))
930841 then (minOutAmount > amountEstimated)
931842 else false)
932843 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
933844 else amountEstimated
934845 let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
935846 if ((burnInv == burnInv))
936847 then {
937848 let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
938849 let sendFee = if ((feeAmount > 0))
939850 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
940851 else nil
941- let $t03825638503 = {
942- let feeAmountForCalc = if ((this == feeCollectorAddress))
943- then 0
944- else feeAmount
945- if (outInAmountAsset)
946- then $Tuple2(-((amount + feeAmountForCalc)), 0)
947- else $Tuple2(0, -((amount + feeAmountForCalc)))
948- }
949- let amountAssetBalanceDelta = $t03825638503._1
950- let priceAssetBalanceDelta = $t03825638503._2
951- let $t03850638614 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
952- let refreshKLpActions = $t03850638614._1
953- let updatedKLp = $t03850638614._2
954- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
955- if ((isUpdatedKLpValid == isUpdatedKLpValid))
956- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
957- else throw("Strict value is not equal to itself.")
852+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
958853 }
959854 else throw("Strict value is not equal to itself.")
960855 }
961856 else throw("Strict value is not equal to itself.")
962857 }
963858 else throw("Strict value is not equal to itself.")
964859 }
965860
966861
967862
968863 @Callable(i)
969864 func getOneTknREADONLY (outAssetId,paymentAmount) = {
970- let $t03887139027 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
971- let amountEstimated = $t03887139027._1
972- let commonState = $t03887139027._2
973- let feeAmount = $t03887139027._3
974- let bonus = $t03887139027._4
975- let outInAmountAsset = $t03887139027._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
976870 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
977871 }
978872
979873
980874
981875 @Callable(i)
982876 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
983877 let isPoolOneTokenOperationsDisabled = {
984878 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
985879 if ($isInstanceOf(@, "Boolean"))
986880 then @
987881 else throw(($getType(@) + " couldn't be cast to Boolean"))
988882 }
989883 let isGetDisabled = if (if (isGlobalShutdown())
990884 then true
991885 else (cfgPoolStatus == PoolShutdown))
992886 then true
993887 else isPoolOneTokenOperationsDisabled
994888 let checks = [if (if (!(isGetDisabled))
995889 then true
996890 else isManager(i))
997891 then true
998892 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
999893 then true
1000894 else throwErr("no payments are expected")]
1001895 if ((checks == checks))
1002896 then {
1003897 let outAssetId = parseAssetId(outAssetIdStr)
1004898 let userAddress = i.caller
1005899 let txId = i.transactionId
1006- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1007900 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1008901 if ((unstakeInv == unstakeInv))
1009902 then {
1010- let $t03992940080 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1011- if (($t03992940080 == $t03992940080))
903+ let $t03514135274 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
904+ if (($t03514135274 == $t03514135274))
1012905 then {
1013- let outInAmountAsset = $t03992940080._5
1014- let bonus = $t03992940080._4
1015- let feeAmount = $t03992940080._3
1016- let commonState = $t03992940080._2
1017- let amountEstimated = $t03992940080._1
906+ let bonus = $t03514135274._4
907+ let feeAmount = $t03514135274._3
908+ let commonState = $t03514135274._2
909+ let amountEstimated = $t03514135274._1
1018910 let amount = if (if ((minOutAmount > 0))
1019911 then (minOutAmount > amountEstimated)
1020912 else false)
1021913 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1022914 else amountEstimated
1023915 let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1024916 if ((burnInv == burnInv))
1025917 then {
1026918 let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1027919 let sendFee = if ((feeAmount > 0))
1028920 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1029921 else nil
1030- let $t04057540822 = {
1031- let feeAmountForCalc = if ((this == feeCollectorAddress))
1032- then 0
1033- else feeAmount
1034- if (outInAmountAsset)
1035- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1036- else $Tuple2(0, -((amount + feeAmountForCalc)))
1037- }
1038- let amountAssetBalanceDelta = $t04057540822._1
1039- let priceAssetBalanceDelta = $t04057540822._2
1040- let $t04082540933 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1041- let refreshKLpActions = $t04082540933._1
1042- let updatedKLp = $t04082540933._2
1043- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1044- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1045- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1046- else throw("Strict value is not equal to itself.")
922+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1047923 }
1048924 else throw("Strict value is not equal to itself.")
1049925 }
1050926 else throw("Strict value is not equal to itself.")
1051927 }
1052928 else throw("Strict value is not equal to itself.")
1053929 }
1054930 else throw("Strict value is not equal to itself.")
1055931 }
1056932
1057933
1058934
1059935 @Callable(i)
1060936 func get () = {
1061937 let res = commonGet(i)
1062938 let outAmtAmt = res._1
1063939 let outPrAmt = res._2
1064940 let pmtAmt = res._3
1065941 let pmtAssetId = res._4
1066942 let state = res._5
1067- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
1068943 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1069944 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1070- then {
1071- let $t04188141963 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1072- let refreshKLpActions = $t04188141963._1
1073- let updatedKLp = $t04188141963._2
1074- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1075- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1076- then (state ++ refreshKLpActions)
1077- else throw("Strict value is not equal to itself.")
1078- }
945+ then state
1079946 else throw("Strict value is not equal to itself.")
1080947 }
1081948
1082949
1083950
1084951 @Callable(i)
1085952 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
1086953 let res = commonGet(i)
1087954 let outAmAmt = res._1
1088955 let outPrAmt = res._2
1089956 let pmtAmt = res._3
1090957 let pmtAssetId = res._4
1091958 let state = res._5
1092959 if ((noLessThenAmtAsset > outAmAmt))
1093960 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
1094961 else if ((noLessThenPriceAsset > outPrAmt))
1095962 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1096963 else {
1097- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
1098964 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1099965 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1100- then {
1101- let $t04291442995 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1102- let refreshKLpActions = $t04291442995._1
1103- let updatedKLp = $t04291442995._2
1104- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1105- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1106- then (state ++ refreshKLpActions)
1107- else throw("Strict value is not equal to itself.")
1108- }
966+ then state
1109967 else throw("Strict value is not equal to itself.")
1110968 }
1111969 }
1112970
1113971
1114972
1115973 @Callable(i)
1116974 func unstakeAndGet (amount) = {
1117975 let checkPayments = if ((size(i.payments) != 0))
1118976 then throw("No payments are expected")
1119977 else true
1120978 if ((checkPayments == checkPayments))
1121979 then {
1122980 let cfg = getPoolConfig()
1123981 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1124- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1125982 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1126983 if ((unstakeInv == unstakeInv))
1127984 then {
1128985 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1129- let outAmAmt = res._1
1130- let outPrAmt = res._2
1131986 let poolStatus = parseIntValue(res._9)
1132987 let state = res._10
1133988 let checkPoolStatus = if (if (isGlobalShutdown())
1134989 then true
1135990 else (poolStatus == PoolShutdown))
1136991 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1137992 else true
1138993 if ((checkPoolStatus == checkPoolStatus))
1139994 then {
1140995 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1141996 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1142- then {
1143- let $t04411844199 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1144- let refreshKLpActions = $t04411844199._1
1145- let updatedKLp = $t04411844199._2
1146- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1147- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1148- then (state ++ refreshKLpActions)
1149- else throw("Strict value is not equal to itself.")
1150- }
997+ then state
1151998 else throw("Strict value is not equal to itself.")
1152999 }
11531000 else throw("Strict value is not equal to itself.")
11541001 }
11551002 else throw("Strict value is not equal to itself.")
11561003 }
11571004 else throw("Strict value is not equal to itself.")
11581005 }
11591006
11601007
11611008
11621009 @Callable(i)
11631010 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
11641011 let isGetDisabled = if (isGlobalShutdown())
11651012 then true
11661013 else (cfgPoolStatus == PoolShutdown)
11671014 let checks = [if (!(isGetDisabled))
11681015 then true
11691016 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
11701017 then true
11711018 else throw("no payments are expected")]
11721019 if ((checks == checks))
11731020 then {
1174- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11751021 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11761022 if ((unstakeInv == unstakeInv))
11771023 then {
11781024 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
11791025 let outAmAmt = res._1
11801026 let outPrAmt = res._2
11811027 let state = res._10
11821028 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
11831029 then true
11841030 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
11851031 then true
11861032 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
11871033 if ((checkAmounts == checkAmounts))
11881034 then {
11891035 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
11901036 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1191- then {
1192- let $t04549145572 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1193- let refreshKLpActions = $t04549145572._1
1194- let updatedKLp = $t04549145572._2
1195- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1196- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1197- then (state ++ refreshKLpActions)
1198- else throw("Strict value is not equal to itself.")
1199- }
1037+ then state
12001038 else throw("Strict value is not equal to itself.")
12011039 }
12021040 else throw("Strict value is not equal to itself.")
12031041 }
12041042 else throw("Strict value is not equal to itself.")
12051043 }
12061044 else throw("Strict value is not equal to itself.")
12071045 }
12081046
12091047
12101048
12111049 @Callable(i)
12121050 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12131051 then throw("permissions denied")
12141052 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1215-
1216-
1217-
1218-@Callable(i)
1219-func refreshKLp () = {
1220- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1221- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1222- then unit
1223- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1224- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1225- then {
1226- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1227- let $t04675946823 = refreshKLpInternal(0, 0, 0)
1228- let kLpUpdateActions = $t04675946823._1
1229- let updatedKLp = $t04675946823._2
1230- let actions = if ((kLp != updatedKLp))
1231- then kLpUpdateActions
1232- else throwErr("nothing to refresh")
1233- $Tuple2(actions, toString(updatedKLp))
1234- }
1235- else throw("Strict value is not equal to itself.")
1236- }
12371053
12381054
12391055
12401056 @Callable(i)
12411057 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
12421058
12431059
12441060
12451061 @Callable(i)
12461062 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
12471063
12481064
12491065
12501066 @Callable(i)
12511067 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
12521068 let prices = calcPrices(amAmt, prAmt, lpAmt)
12531069 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
12541070 }
12551071
12561072
12571073
12581074 @Callable(i)
12591075 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
12601076
12611077
12621078
12631079 @Callable(i)
12641080 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
12651081
12661082
12671083
12681084 @Callable(i)
12691085 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
12701086
12711087
12721088
12731089 @Callable(i)
12741090 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
12751091
12761092
12771093
12781094 @Callable(i)
12791095 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
12801096 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
12811097 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
12821098 }
12831099
12841100
12851101
12861102 @Callable(i)
12871103 func statsREADONLY () = {
12881104 let cfg = getPoolConfig()
12891105 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
12901106 let amtAssetId = cfg[idxAmtAssetId]
12911107 let priceAssetId = cfg[idxPriceAssetId]
12921108 let iAmtAssetId = cfg[idxIAmtAssetId]
12931109 let iPriceAssetId = cfg[idxIPriceAssetId]
12941110 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
12951111 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
12961112 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
12971113 let accAmtAssetBalance = getAccBalance(amtAssetId)
12981114 let accPriceAssetBalance = getAccBalance(priceAssetId)
12991115 let pricesList = if ((poolLPBalance == 0))
13001116 then [zeroBigInt, zeroBigInt, zeroBigInt]
13011117 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
13021118 let curPrice = 0
13031119 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
13041120 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
13051121 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
13061122 $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))
13071123 }
13081124
13091125
13101126
13111127 @Callable(i)
13121128 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
13131129 let cfg = getPoolConfig()
13141130 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13151131 let amAssetIdStr = cfg[idxAmtAssetId]
13161132 let amAssetId = fromBase58String(amAssetIdStr)
13171133 let prAssetIdStr = cfg[idxPriceAssetId]
13181134 let prAssetId = fromBase58String(prAssetIdStr)
13191135 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13201136 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13211137 let poolStatus = cfg[idxPoolStatus]
13221138 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13231139 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
13241140 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
13251141 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
13261142 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
13271143 let curPriceX18 = if ((poolLPBalance == 0))
13281144 then zeroBigInt
13291145 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
13301146 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
13311147 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
13321148 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
13331149 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
13341150 let calcLpAmt = estPut._1
13351151 let curPriceCalc = estPut._3
13361152 let amBalance = estPut._4
13371153 let prBalance = estPut._5
13381154 let lpEmission = estPut._6
13391155 $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))
13401156 }
13411157
13421158
13431159
13441160 @Callable(i)
13451161 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
13461162 let cfg = getPoolConfig()
13471163 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13481164 let amAssetIdStr = cfg[idxAmtAssetId]
13491165 let amAssetId = fromBase58String(amAssetIdStr)
13501166 let prAssetIdStr = cfg[idxPriceAssetId]
13511167 let prAssetId = fromBase58String(prAssetIdStr)
13521168 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13531169 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13541170 let poolStatus = cfg[idxPoolStatus]
13551171 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13561172 let amBalanceRaw = getAccBalance(amAssetIdStr)
13571173 let prBalanceRaw = getAccBalance(prAssetIdStr)
13581174 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
13591175 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
13601176 let curPriceX18 = if ((poolLPBalance == 0))
13611177 then zeroBigInt
13621178 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
13631179 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
13641180 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
13651181 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
13661182 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
13671183 let calcLpAmt = estPut._1
13681184 let curPriceCalc = estPut._3
13691185 let amBalance = estPut._4
13701186 let prBalance = estPut._5
13711187 let lpEmission = estPut._6
13721188 $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))
13731189 }
13741190
13751191
13761192
13771193 @Callable(i)
13781194 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
13791195 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
13801196 let outAmAmt = res._1
13811197 let outPrAmt = res._2
13821198 let amBalance = res._5
13831199 let prBalance = res._6
13841200 let lpEmission = res._7
13851201 let curPrice = res._8
13861202 let poolStatus = parseIntValue(res._9)
13871203 $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))
13881204 }
13891205
13901206
13911207 @Verifier(tx)
13921208 func verify () = {
13931209 let targetPublicKey = match managerPublicKeyOrUnit() {
13941210 case pk: ByteVector =>
13951211 pk
13961212 case _: Unit =>
13971213 tx.senderPublicKey
13981214 case _ =>
13991215 throw("Match error")
14001216 }
14011217 match tx {
14021218 case order: Order =>
14031219 let matcherPub = getMatcherPubOrFail()
14041220 let orderValid = validateMatcherOrderAllowed(order)
14051221 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
14061222 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
14071223 if (if (if (orderValid)
14081224 then senderValid
14091225 else false)
14101226 then matcherValid
14111227 else false)
14121228 then true
14131229 else throwOrderError(orderValid, senderValid, matcherValid)
14141230 case s: SetScriptTransaction =>
14151231 let newHash = blake2b256(value(s.script))
14161232 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
14171233 let currentHash = scriptHash(this)
14181234 if (if ((allowedHash == newHash))
14191235 then (currentHash != newHash)
14201236 else false)
14211237 then true
14221238 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14231239 case _ =>
14241240 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14251241 }
14261242 }
14271243

github/deemru/w8io/169f3d6 
163.20 ms