tx · 7kGW5zRoAzJRGB2eTbLgarqSAKLcoWzxg6XAS9H7hG6n

3MqXE9vrYjAGDbXPVqHEUufiqzMn9tRhdz1:  -0.03100000 Waves

2023.01.10 13:14 [2398713] smart account 3MqXE9vrYjAGDbXPVqHEUufiqzMn9tRhdz1 > SELF 0.00000000 Waves

{ "type": 13, "id": "7kGW5zRoAzJRGB2eTbLgarqSAKLcoWzxg6XAS9H7hG6n", "fee": 3100000, "feeAssetId": null, "timestamp": 1673345678359, "version": 1, "sender": "3MqXE9vrYjAGDbXPVqHEUufiqzMn9tRhdz1", "senderPublicKey": "5g8AQudVM8TuhK11MwRya5kECFAwuTLj1QBxmUdKms57", "proofs": [ "23cftMayjUfannHiPfqSQH85p2E1MPNdsemRcSfhvTnToH4iNaBbSZk9RLcwUvgWJJAyE62Y7h2rQKCs4Q9xRm2i" ], "script": "base64:BgK3JwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASAwoBCBIFCgMBAQESBAoCAQESBAoCCAESBAoCCAgSCwoJCAEBAgECCAQEEgYKBAgIAQgSABIDCgEBEgMKAQESBAoCCAEiCmxQZGVjaW1hbHMiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgt3YXZlc1N0cmluZyIDU0VQIgpQb29sQWN0aXZlIg9Qb29sUHV0RGlzYWJsZWQiE1Bvb2xNYXRjaGVyRGlzYWJsZWQiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiDWlkeFBvb2xTdGF0dXMiEGlkeFBvb2xMUEFzc2V0SWQiDWlkeEFtdEFzc2V0SWQiD2lkeFByaWNlQXNzZXRJZCIOaWR4QW10QXNzZXREY20iEGlkeFByaWNlQXNzZXREY20iDmlkeElBbXRBc3NldElkIhBpZHhJUHJpY2VBc3NldEl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J5dGVzCQCRAwIIBQJjUgZwcm9vZnMAAAgFAmNSD3NlbmRlclB1YmxpY0tleQQCYXQJAPQDAwgFAmNSCWJvZHlCeXRlcwkAkQMCCAUCY1IGcHJvb2ZzAAEFAmZMAwMDBQJhcgUCYXMHBQJhdAcGCQECYXEDBQJhcgUCYXMFAmF0AwkAAQIFAmRxAhRTZXRTY3JpcHRUcmFuc2FjdGlvbgQCZXcFAmRxBAJmTQkA9gMBCQEFdmFsdWUBCAUCZXcGc2NyaXB0BAJmTgkA2wQBCQEFdmFsdWUBCQCdCAIFAmFBCQECYW8ABAJmTwkA8QcBBQR0aGlzAwMJAAACBQJmTgUCZk0JAQIhPQIFAmZPBQJmTQcGCQD0AwMIBQJmSQlib2R5Qnl0ZXMJAJEDAggFAmZJBnByb29mcwAABQJmSwkA9AMDCAUCZkkJYm9keUJ5dGVzCQCRAwIIBQJmSQZwcm9vZnMAAAUCZkvBwFdz", "chainId": 84, "height": 2398713, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 42aSn28gAoCvcXg4bbedhiTzpNf31dx6r9Frd23jABvZ Next: 6zFZ9bVx3VFk3ZcspcyByoHYUX5ADBUANnfwQVqUM4nY 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
108105 func pa () = "%s__priceAsset"
109106
110107
111-let keyFee = "%s__fee"
112-
113-let feeDefault = fraction(10, scale8, 10000)
114-
115-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
116-
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-
127108 func keyFactoryConfig () = "%s__factoryConfig"
128109
129110
160141
161142
162143 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
163-
164-
165-func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
166144
167145
168146 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
213191
214192 let poolConfigParsed = parsePoolConfig(getPoolConfig())
215193
216-let $t082438409 = poolConfigParsed
194+let $t076017767 = poolConfigParsed
217195
218-let cfgPoolAddress = $t082438409._1
196+let cfgPoolAddress = $t076017767._1
219197
220-let cfgPoolStatus = $t082438409._2
198+let cfgPoolStatus = $t076017767._2
221199
222-let cfgLpAssetId = $t082438409._3
200+let cfgLpAssetId = $t076017767._3
223201
224-let cfgAmountAssetId = $t082438409._4
202+let cfgAmountAssetId = $t076017767._4
225203
226-let cfgPriceAssetId = $t082438409._5
204+let cfgPriceAssetId = $t076017767._5
227205
228-let cfgAmountAssetDecimals = $t082438409._6
206+let cfgAmountAssetDecimals = $t076017767._6
229207
230-let cfgPriceAssetDecimals = $t082438409._7
208+let cfgPriceAssetDecimals = $t076017767._7
231209
232210 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
233211
248226
249227
250228 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
251-
252-
253-func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
254229
255230
256231 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
302277 let lpEmissionX18 = toX18(lpEmission, scale8)
303278 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
304279 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
305- let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
306- let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
280+ let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281+ let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
307282 let state = if ((txId58 == ""))
308283 then nil
309284 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
362337 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
363338 else {
364339 let lpEmissionX18 = toX18(lpEmission, scale8)
365- let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
366- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
340+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
367342 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
368343 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
369344 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
370345 let expAmtAssetAmtX18 = expectedAmts._1
371346 let expPriceAssetAmtX18 = expectedAmts._2
372- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
373- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
347+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348+ $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
374349 }
375350 }
376351 let calcLpAmt = res._1
393368 }
394369
395370
396-func calcKLp (amountBalance,priceBalance,lpEmission) = {
397- let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
398- if ((lpEmission == big0))
399- then big0
400- else updatedKLp
401- }
402-
403-
404-func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
405- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
406- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
407- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
408- let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
409- currentKLp
410- }
411-
412-
413-func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
414- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
415- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
416- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
417- let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
418- let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
419- $Tuple2(actions, updatedKLp)
420- }
421-
422-
423-func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
424- then true
425- else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
426-
427-
428371 func validateMatcherOrderAllowed (order) = {
429- let amountAssetAmount = order.amount
430- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
431- let $t02098621198 = if ((order.orderType == Buy))
432- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
433- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
434- let amountAssetBalanceDelta = $t02098621198._1
435- let priceAssetBalanceDelta = $t02098621198._2
372+ let cfg = getPoolConfig()
373+ let amtAssetId = cfg[idxAmtAssetId]
374+ let priceAssetId = cfg[idxPriceAssetId]
375+ let poolStatus = parseIntValue(cfg[idxPoolStatus])
376+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
377+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
378+ let accAmtAssetBalance = getAccBalance(amtAssetId)
379+ let accPriceAssetBalance = getAccBalance(priceAssetId)
380+ let curPriceX18 = if ((order.orderType == Buy))
381+ then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
382+ else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
383+ let curPrice = fromX18(curPriceX18, scale8)
436384 if (if (if (isGlobalShutdown())
437385 then true
438- else (cfgPoolStatus == PoolMatcherDisabled))
386+ else (poolStatus == PoolMatcherDisabled))
439387 then true
440- else (cfgPoolStatus == PoolShutdown))
388+ else (poolStatus == PoolShutdown))
441389 then throw("Exchange operations disabled")
442- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
443- then true
444- else (order.assetPair.priceAsset != cfgPriceAssetId))
445- then throw("Wrong order assets.")
446- else {
447- let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
448- let $t02166921769 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
449- let unusedActions = $t02166921769._1
450- let kLpNew = $t02166921769._2
451- let isOrderValid = (kLpNew >= kLp)
452- isOrderValid
453- }
390+ else {
391+ let orderAmtAsset = order.assetPair.amountAsset
392+ let orderAmtAssetStr = if ((orderAmtAsset == unit))
393+ then "WAVES"
394+ else toBase58String(value(orderAmtAsset))
395+ let orderPriceAsset = order.assetPair.priceAsset
396+ let orderPriceAssetStr = if ((orderPriceAsset == unit))
397+ then "WAVES"
398+ else toBase58String(value(orderPriceAsset))
399+ if (if ((orderAmtAssetStr != amtAssetId))
400+ then true
401+ else (orderPriceAssetStr != priceAssetId))
402+ then throw("Wrong order assets.")
403+ else {
404+ let orderPrice = order.price
405+ let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
406+ let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
407+ let isOrderPriceValid = if ((order.orderType == Buy))
408+ then (curPrice >= castedOrderPrice)
409+ else (castedOrderPrice >= curPrice)
410+ true
411+ }
412+ }
454413 }
455414
456415
525484 else if ((paymentAssetId == cfgPriceAssetId))
526485 then false
527486 else throwErr("invalid asset")
528- let $t02449024783 = if (isEval)
487+ let $t02266422957 = if (isEval)
529488 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
530489 else if (paymentInAmountAsset)
531490 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
532491 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
533- let amountBalanceOld = $t02449024783._1
534- let priceBalanceOld = $t02449024783._2
535- let $t02478724936 = if (paymentInAmountAsset)
492+ let amountBalanceOld = $t02266422957._1
493+ let priceBalanceOld = $t02266422957._2
494+ let $t02296123110 = if (paymentInAmountAsset)
536495 then $Tuple2(paymentAmountRaw, 0)
537496 else $Tuple2(0, paymentAmountRaw)
538- let amountAssetAmountRaw = $t02478724936._1
539- let priceAssetAmountRaw = $t02478724936._2
497+ let amountAssetAmountRaw = $t02296123110._1
498+ let priceAssetAmountRaw = $t02296123110._2
540499 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
541500 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
542- let $t02506825132 = takeFee(paymentAmountRaw, inFee)
543- let paymentAmount = $t02506825132._1
544- let feeAmount = $t02506825132._2
501+ let $t02324223306 = takeFee(paymentAmountRaw, inFee)
502+ let paymentAmount = $t02324223306._1
503+ let feeAmount = $t02324223306._2
545504 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
546505 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
547506 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
564523 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
565524 let priceOld = fromX18(priceOldX18, scale8)
566525 let loss = {
567- let $t02681326980 = if (paymentInAmountAsset)
526+ let $t02478324950 = if (paymentInAmountAsset)
568527 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
569528 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
570- let amount = $t02681326980._1
571- let balance = $t02681326980._2
529+ let amount = $t02478324950._1
530+ let balance = $t02478324950._2
572531 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
573532 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
574533 }
575- $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
534+ $Tuple4(issueAmount, commonState, feeAmount, loss)
576535 }
577536 else throw("Strict value is not equal to itself.")
578537 }
580539
581540 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
582541 let isEval = (txId == unit)
583- let cfg = getPoolConfig()
584- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
585- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
586542 let checks = [if ((paymentAssetId == cfgLpAssetId))
587543 then true
588544 else throwErr("invalid lp asset")]
596552 let balanceBigInt = if (outInAmountAsset)
597553 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
598554 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
599- let outInAmountAssetDecimals = if (outInAmountAsset)
600- then amtAssetDcm
601- else priceAssetDcm
602555 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
603556 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
604557 let outBalance = if (outInAmountAsset)
608561 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
609562 let redeemedBigInt = toBigInt(paymentAmount)
610563 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
611- let $t02905829114 = takeFee(amountRaw, outFee)
612- let totalAmount = $t02905829114._1
613- let feeAmount = $t02905829114._2
614- let $t02911829344 = if (outInAmountAsset)
564+ let $t02653026586 = takeFee(amountRaw, outFee)
565+ let totalAmount = $t02653026586._1
566+ let feeAmount = $t02653026586._2
567+ let $t02659026816 = if (outInAmountAsset)
615568 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
616569 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
617- let outAmAmount = $t02911829344._1
618- let outPrAmount = $t02911829344._2
619- let amBalanceNew = $t02911829344._3
620- let prBalanceNew = $t02911829344._4
570+ let outAmAmount = $t02659026816._1
571+ let outPrAmount = $t02659026816._2
572+ let amBalanceNew = $t02659026816._3
573+ let prBalanceNew = $t02659026816._4
621574 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
622575 let priceNew = fromX18(priceNewX18, scale8)
623576 let commonState = if (isEval)
629582 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
630583 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
631584 }
632- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
585+ $Tuple4(totalAmount, commonState, feeAmount, loss)
633586 }
634587 else throw("Strict value is not equal to itself.")
635588 }
729682 let prDiff = estPut._11
730683 let amId = estPut._12
731684 let prId = estPut._13
732- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
733- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
734- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
735- if ((currentKLp == currentKLp))
685+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686+ if ((emitInv == emitInv))
736687 then {
737- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
738- if ((emitInv == emitInv))
688+ let emitInvLegacy = match emitInv {
689+ case legacyFactoryContract: Address =>
690+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
691+ case _ =>
692+ unit
693+ }
694+ if ((emitInvLegacy == emitInvLegacy))
739695 then {
740- let emitInvLegacy = match emitInv {
741- case legacyFactoryContract: Address =>
742- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
743- case _ =>
744- unit
745- }
746- if ((emitInvLegacy == emitInvLegacy))
696+ let slippageAInv = if ((amDiff > 0))
697+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698+ else nil
699+ if ((slippageAInv == slippageAInv))
747700 then {
748- let slippageAInv = if ((amDiff > 0))
749- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
701+ let slippagePInv = if ((prDiff > 0))
702+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
750703 else nil
751- if ((slippageAInv == slippageAInv))
704+ if ((slippagePInv == slippagePInv))
752705 then {
753- let slippagePInv = if ((prDiff > 0))
754- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
755- else nil
756- if ((slippagePInv == slippagePInv))
706+ let lpTransfer = if (shouldAutoStake)
757707 then {
758- let lpTransfer = if (shouldAutoStake)
759- then {
760- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
761- if ((slpStakeInv == slpStakeInv))
762- then nil
763- else throw("Strict value is not equal to itself.")
764- }
765- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
766- let $t03387234334 = refreshKLpInternal(0, 0, 0)
767- if (($t03387234334 == $t03387234334))
768- then {
769- let updatedKLp = $t03387234334._2
770- let refreshKLpActions = $t03387234334._1
771- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
772- if ((isUpdatedKLpValid == isUpdatedKLpValid))
773- then ((state ++ lpTransfer) ++ refreshKLpActions)
774- else throw("Strict value is not equal to itself.")
775- }
708+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709+ if ((slpStakeInv == slpStakeInv))
710+ then nil
776711 else throw("Strict value is not equal to itself.")
777712 }
778- else throw("Strict value is not equal to itself.")
713+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714+ (state ++ lpTransfer)
779715 }
780716 else throw("Strict value is not equal to itself.")
781717 }
793729 then throw("Invalid value passed")
794730 else {
795731 let estPut = commonPut(i, maxSlippage, false)
796- let state = estPut._9
797- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
798- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
799- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
800- if ((currentKLp == currentKLp))
801- then {
802- let $t03489634961 = refreshKLpInternal(0, 0, 0)
803- let refreshKLpActions = $t03489634961._1
804- let updatedKLp = $t03489634961._2
805- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
806- if ((isUpdatedKLpValid == isUpdatedKLpValid))
807- then (state ++ refreshKLpActions)
808- else throw("Strict value is not equal to itself.")
809- }
810- else throw("Strict value is not equal to itself.")
732+ estPut._9
811733 }
812734
813735
839761 let payment = i.payments[0]
840762 let paymentAssetId = payment.assetId
841763 let paymentAmountRaw = payment.amount
842- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
843- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
844- else if ((paymentAssetId == cfgPriceAssetId))
845- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
846- else throwErr("payment asset is not supported")
847- if ((currentKLp == currentKLp))
764+ let userAddress = i.caller
765+ let txId = i.transactionId
766+ let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
767+ if (($t03172331853 == $t03172331853))
848768 then {
849- let userAddress = i.caller
850- let txId = i.transactionId
851- let $t03614936301 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
852- if (($t03614936301 == $t03614936301))
769+ let bonus = $t03172331853._4
770+ let feeAmount = $t03172331853._3
771+ let commonState = $t03172331853._2
772+ let emitAmountEstimated = $t03172331853._1
773+ let emitAmount = if (if ((minOutAmount > 0))
774+ then (minOutAmount > emitAmountEstimated)
775+ else false)
776+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
777+ else emitAmountEstimated
778+ let emitInv = emit(emitAmount)
779+ if ((emitInv == emitInv))
853780 then {
854- let paymentInAmountAsset = $t03614936301._5
855- let bonus = $t03614936301._4
856- let feeAmount = $t03614936301._3
857- let commonState = $t03614936301._2
858- let emitAmountEstimated = $t03614936301._1
859- let emitAmount = if (if ((minOutAmount > 0))
860- then (minOutAmount > emitAmountEstimated)
861- else false)
862- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
863- else emitAmountEstimated
864- let emitInv = emit(emitAmount)
865- if ((emitInv == emitInv))
781+ let lpTransfer = if (autoStake)
866782 then {
867- let lpTransfer = if (autoStake)
868- then {
869- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
870- if ((stakeInv == stakeInv))
871- then nil
872- else throw("Strict value is not equal to itself.")
873- }
874- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
875- let sendFee = if ((feeAmount > 0))
876- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
877- else nil
878- let $t03688737084 = if ((this == feeCollectorAddress))
879- then $Tuple2(0, 0)
880- else if (paymentInAmountAsset)
881- then $Tuple2(-(feeAmount), 0)
882- else $Tuple2(0, -(feeAmount))
883- let amountAssetBalanceDelta = $t03688737084._1
884- let priceAssetBalanceDelta = $t03688737084._2
885- let $t03708737195 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
886- let refreshKLpActions = $t03708737195._1
887- let updatedKLp = $t03708737195._2
888- let kLp = value(getString(keyKLp))
889- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
890- if ((isUpdatedKLpValid == isUpdatedKLpValid))
891- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
783+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784+ if ((stakeInv == stakeInv))
785+ then nil
892786 else throw("Strict value is not equal to itself.")
893787 }
894- else throw("Strict value is not equal to itself.")
788+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
789+ let sendFee = if ((feeAmount > 0))
790+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
791+ else nil
792+ $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
895793 }
896794 else throw("Strict value is not equal to itself.")
897795 }
904802
905803 @Callable(i)
906804 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
907- let $t03750137658 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
908- let emitAmountEstimated = $t03750137658._1
909- let commonState = $t03750137658._2
910- let feeAmount = $t03750137658._3
911- let bonus = $t03750137658._4
912- let paymentInAmountAsset = $t03750137658._5
805+ let $t03258232717 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
806+ let emitAmountEstimated = $t03258232717._1
807+ let commonState = $t03258232717._2
808+ let feeAmount = $t03258232717._3
809+ let bonus = $t03258232717._4
913810 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
914811 }
915812
941838 let payment = i.payments[0]
942839 let paymentAssetId = payment.assetId
943840 let paymentAmount = payment.amount
944- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
945- if ((currentKLp == currentKLp))
841+ let userAddress = i.caller
842+ let txId = i.transactionId
843+ let $t03352233657 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
844+ if (($t03352233657 == $t03352233657))
946845 then {
947- let userAddress = i.caller
948- let txId = i.transactionId
949- let $t03854338696 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
950- if (($t03854338696 == $t03854338696))
846+ let bonus = $t03352233657._4
847+ let feeAmount = $t03352233657._3
848+ let commonState = $t03352233657._2
849+ let amountEstimated = $t03352233657._1
850+ let amount = if (if ((minOutAmount > 0))
851+ then (minOutAmount > amountEstimated)
852+ else false)
853+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
854+ else amountEstimated
855+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
856+ if ((burnInv == burnInv))
951857 then {
952- let outInAmountAsset = $t03854338696._5
953- let bonus = $t03854338696._4
954- let feeAmount = $t03854338696._3
955- let commonState = $t03854338696._2
956- let amountEstimated = $t03854338696._1
957- let amount = if (if ((minOutAmount > 0))
958- then (minOutAmount > amountEstimated)
959- else false)
960- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
961- else amountEstimated
962- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
963- if ((burnInv == burnInv))
964- then {
965- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
966- let sendFee = if ((feeAmount > 0))
967- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
968- else nil
969- let $t03919639443 = {
970- let feeAmountForCalc = if ((this == feeCollectorAddress))
971- then 0
972- else feeAmount
973- if (outInAmountAsset)
974- then $Tuple2(-((amount + feeAmountForCalc)), 0)
975- else $Tuple2(0, -((amount + feeAmountForCalc)))
976- }
977- let amountAssetBalanceDelta = $t03919639443._1
978- let priceAssetBalanceDelta = $t03919639443._2
979- let $t03944639554 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
980- let refreshKLpActions = $t03944639554._1
981- let updatedKLp = $t03944639554._2
982- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
983- if ((isUpdatedKLpValid == isUpdatedKLpValid))
984- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
985- else throw("Strict value is not equal to itself.")
986- }
987- else throw("Strict value is not equal to itself.")
858+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
859+ let sendFee = if ((feeAmount > 0))
860+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
861+ else nil
862+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
988863 }
989864 else throw("Strict value is not equal to itself.")
990865 }
997872
998873 @Callable(i)
999874 func getOneTknREADONLY (outAssetId,paymentAmount) = {
1000- let $t03981139967 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1001- let amountEstimated = $t03981139967._1
1002- let commonState = $t03981139967._2
1003- let feeAmount = $t03981139967._3
1004- let bonus = $t03981139967._4
1005- let outInAmountAsset = $t03981139967._5
875+ let $t03429234430 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
876+ let amountEstimated = $t03429234430._1
877+ let commonState = $t03429234430._2
878+ let feeAmount = $t03429234430._3
879+ let bonus = $t03429234430._4
1006880 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
1007881 }
1008882
1033907 let outAssetId = parseAssetId(outAssetIdStr)
1034908 let userAddress = i.caller
1035909 let txId = i.transactionId
1036- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1037- if ((currentKLp == currentKLp))
910+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
911+ if ((unstakeInv == unstakeInv))
1038912 then {
1039- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1040- if ((unstakeInv == unstakeInv))
913+ let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914+ if (($t03525535388 == $t03525535388))
1041915 then {
1042- let $t04087241023 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1043- if (($t04087241023 == $t04087241023))
916+ let bonus = $t03525535388._4
917+ let feeAmount = $t03525535388._3
918+ let commonState = $t03525535388._2
919+ let amountEstimated = $t03525535388._1
920+ let amount = if (if ((minOutAmount > 0))
921+ then (minOutAmount > amountEstimated)
922+ else false)
923+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
924+ else amountEstimated
925+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
926+ if ((burnInv == burnInv))
1044927 then {
1045- let outInAmountAsset = $t04087241023._5
1046- let bonus = $t04087241023._4
1047- let feeAmount = $t04087241023._3
1048- let commonState = $t04087241023._2
1049- let amountEstimated = $t04087241023._1
1050- let amount = if (if ((minOutAmount > 0))
1051- then (minOutAmount > amountEstimated)
1052- else false)
1053- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1054- else amountEstimated
1055- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1056- if ((burnInv == burnInv))
1057- then {
1058- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1059- let sendFee = if ((feeAmount > 0))
1060- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1061- else nil
1062- let $t04151841765 = {
1063- let feeAmountForCalc = if ((this == feeCollectorAddress))
1064- then 0
1065- else feeAmount
1066- if (outInAmountAsset)
1067- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1068- else $Tuple2(0, -((amount + feeAmountForCalc)))
1069- }
1070- let amountAssetBalanceDelta = $t04151841765._1
1071- let priceAssetBalanceDelta = $t04151841765._2
1072- let $t04176841876 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1073- let refreshKLpActions = $t04176841876._1
1074- let updatedKLp = $t04176841876._2
1075- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1076- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1077- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1078- else throw("Strict value is not equal to itself.")
1079- }
1080- else throw("Strict value is not equal to itself.")
928+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
929+ let sendFee = if ((feeAmount > 0))
930+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
931+ else nil
932+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1081933 }
1082934 else throw("Strict value is not equal to itself.")
1083935 }
1098950 let pmtAmt = res._3
1099951 let pmtAssetId = res._4
1100952 let state = res._5
1101- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1102- if ((currentKLp == currentKLp))
1103- then {
1104- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1105- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1106- then {
1107- let $t04282242904 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1108- let refreshKLpActions = $t04282242904._1
1109- let updatedKLp = $t04282242904._2
1110- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1111- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1112- then (state ++ refreshKLpActions)
1113- else throw("Strict value is not equal to itself.")
1114- }
1115- else throw("Strict value is not equal to itself.")
1116- }
953+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
954+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955+ then state
1117956 else throw("Strict value is not equal to itself.")
1118957 }
1119958
1132971 else if ((noLessThenPriceAsset > outPrAmt))
1133972 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1134973 else {
1135- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1136- if ((currentKLp == currentKLp))
1137- then {
1138- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1139- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1140- then {
1141- let $t04385343934 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1142- let refreshKLpActions = $t04385343934._1
1143- let updatedKLp = $t04385343934._2
1144- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1145- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1146- then (state ++ refreshKLpActions)
1147- else throw("Strict value is not equal to itself.")
1148- }
1149- else throw("Strict value is not equal to itself.")
1150- }
974+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
975+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
976+ then state
1151977 else throw("Strict value is not equal to itself.")
1152978 }
1153979 }
1163989 then {
1164990 let cfg = getPoolConfig()
1165991 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1166- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1167- if ((currentKLp == currentKLp))
992+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
993+ if ((unstakeInv == unstakeInv))
1168994 then {
1169- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1170- if ((unstakeInv == unstakeInv))
995+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
996+ let poolStatus = parseIntValue(res._9)
997+ let state = res._10
998+ let checkPoolStatus = if (if (isGlobalShutdown())
999+ then true
1000+ else (poolStatus == PoolShutdown))
1001+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1002+ else true
1003+ if ((checkPoolStatus == checkPoolStatus))
11711004 then {
1172- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1173- let outAmAmt = res._1
1174- let outPrAmt = res._2
1175- let poolStatus = parseIntValue(res._9)
1176- let state = res._10
1177- let checkPoolStatus = if (if (isGlobalShutdown())
1178- then true
1179- else (poolStatus == PoolShutdown))
1180- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1181- else true
1182- if ((checkPoolStatus == checkPoolStatus))
1183- then {
1184- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1185- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1186- then {
1187- let $t04506045141 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1188- let refreshKLpActions = $t04506045141._1
1189- let updatedKLp = $t04506045141._2
1190- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1191- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1192- then (state ++ refreshKLpActions)
1193- else throw("Strict value is not equal to itself.")
1194- }
1195- else throw("Strict value is not equal to itself.")
1196- }
1005+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1006+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1007+ then state
11971008 else throw("Strict value is not equal to itself.")
11981009 }
11991010 else throw("Strict value is not equal to itself.")
12171028 else throw("no payments are expected")]
12181029 if ((checks == checks))
12191030 then {
1220- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1221- if ((currentKLp == currentKLp))
1031+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1032+ if ((unstakeInv == unstakeInv))
12221033 then {
1223- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1224- if ((unstakeInv == unstakeInv))
1034+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1035+ let outAmAmt = res._1
1036+ let outPrAmt = res._2
1037+ let state = res._10
1038+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1039+ then true
1040+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1041+ then true
1042+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1043+ if ((checkAmounts == checkAmounts))
12251044 then {
1226- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1227- let outAmAmt = res._1
1228- let outPrAmt = res._2
1229- let state = res._10
1230- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1231- then true
1232- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1233- then true
1234- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1235- if ((checkAmounts == checkAmounts))
1236- then {
1237- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1238- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1239- then {
1240- let $t04643646517 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1241- let refreshKLpActions = $t04643646517._1
1242- let updatedKLp = $t04643646517._2
1243- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1244- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1245- then (state ++ refreshKLpActions)
1246- else throw("Strict value is not equal to itself.")
1247- }
1248- else throw("Strict value is not equal to itself.")
1249- }
1045+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1046+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1047+ then state
12501048 else throw("Strict value is not equal to itself.")
12511049 }
12521050 else throw("Strict value is not equal to itself.")
12621060 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12631061 then throw("permissions denied")
12641062 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1265-
1266-
1267-
1268-@Callable(i)
1269-func refreshKLp () = {
1270- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1271- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1272- then unit
1273- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1274- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1275- then {
1276- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1277- let $t04770447768 = refreshKLpInternal(0, 0, 0)
1278- let kLpUpdateActions = $t04770447768._1
1279- let updatedKLp = $t04770447768._2
1280- let actions = if ((kLp != updatedKLp))
1281- then kLpUpdateActions
1282- else throwErr("nothing to refresh")
1283- $Tuple2(actions, toString(updatedKLp))
1284- }
1285- else throw("Strict value is not equal to itself.")
1286- }
12871063
12881064
12891065
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
111-let keyFee = "%s__fee"
112-
113-let feeDefault = fraction(10, scale8, 10000)
114-
115-let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
116-
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-
127108 func keyFactoryConfig () = "%s__factoryConfig"
128109
129110
130111 func keyMatcherPub () = "%s%s__matcher__publicKey"
131112
132113
133114 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
134115
135116
136117 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
137118
138119
139120 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
140121
141122
142123 func keyAllPoolsShutdown () = "%s__shutdown"
143124
144125
145126 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
146127
147128
148129 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
149130
150131
151132 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
152133
153134 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
154135
155136
156137 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
157138
158139
159140 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
160141
161142
162143 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
163-
164-
165-func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
166144
167145
168146 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
169147
170148 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
171149
172150 let inFee = {
173151 let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
174152 if ($isInstanceOf(@, "Int"))
175153 then @
176154 else throw(($getType(@) + " couldn't be cast to Int"))
177155 }
178156
179157 let outFee = {
180158 let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
181159 if ($isInstanceOf(@, "Int"))
182160 then @
183161 else throw(($getType(@) + " couldn't be cast to Int"))
184162 }
185163
186164 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
187165
188166
189167 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
190168
191169
192170 func getPoolConfig () = {
193171 let amtAsset = getStringOrFail(this, aa())
194172 let priceAsset = getStringOrFail(this, pa())
195173 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
196174 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
197175 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
198176 }
199177
200178
201179 func parseAssetId (input) = if ((input == wavesString))
202180 then unit
203181 else fromBase58String(input)
204182
205183
206184 func assetIdToString (input) = if ((input == unit))
207185 then wavesString
208186 else toBase58String(value(input))
209187
210188
211189 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]))
212190
213191
214192 let poolConfigParsed = parsePoolConfig(getPoolConfig())
215193
216-let $t082438409 = poolConfigParsed
194+let $t076017767 = poolConfigParsed
217195
218-let cfgPoolAddress = $t082438409._1
196+let cfgPoolAddress = $t076017767._1
219197
220-let cfgPoolStatus = $t082438409._2
198+let cfgPoolStatus = $t076017767._2
221199
222-let cfgLpAssetId = $t082438409._3
200+let cfgLpAssetId = $t076017767._3
223201
224-let cfgAmountAssetId = $t082438409._4
202+let cfgAmountAssetId = $t076017767._4
225203
226-let cfgPriceAssetId = $t082438409._5
204+let cfgPriceAssetId = $t076017767._5
227205
228-let cfgAmountAssetDecimals = $t082438409._6
206+let cfgAmountAssetDecimals = $t076017767._6
229207
230-let cfgPriceAssetDecimals = $t082438409._7
208+let cfgPriceAssetDecimals = $t076017767._7
231209
232210 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
233211
234212
235213 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
236214
237215 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
238216
239217 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)
240218
241219
242220 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)
243221
244222
245223 func getAccBalance (assetId) = if ((assetId == "WAVES"))
246224 then wavesBalance(this).available
247225 else assetBalance(this, fromBase58String(assetId))
248226
249227
250228 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
251-
252-
253-func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
254229
255230
256231 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
257232 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
258233 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
259234 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
260235 }
261236
262237
263238 func calcPrices (amAmt,prAmt,lpAmt) = {
264239 let cfg = getPoolConfig()
265240 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
266241 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
267242 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
268243 let amAmtX18 = toX18(amAmt, amtAssetDcm)
269244 let prAmtX18 = toX18(prAmt, priceAssetDcm)
270245 let lpAmtX18 = toX18(lpAmt, scale8)
271246 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
272247 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
273248 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
274249 }
275250
276251
277252 func calculatePrices (amAmt,prAmt,lpAmt) = {
278253 let prices = calcPrices(amAmt, prAmt, lpAmt)
279254 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
280255 }
281256
282257
283258 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
284259 let cfg = getPoolConfig()
285260 let lpAssetId = cfg[idxPoolLPAssetId]
286261 let amAssetId = cfg[idxAmtAssetId]
287262 let prAssetId = cfg[idxPriceAssetId]
288263 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
289264 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
290265 let poolStatus = cfg[idxPoolStatus]
291266 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
292267 if ((lpAssetId != pmtAssetId))
293268 then throw("Invalid asset passed.")
294269 else {
295270 let amBalance = getAccBalance(amAssetId)
296271 let amBalanceX18 = toX18(amBalance, amAssetDcm)
297272 let prBalance = getAccBalance(prAssetId)
298273 let prBalanceX18 = toX18(prBalance, prAssetDcm)
299274 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
300275 let curPrice = fromX18(curPriceX18, scale8)
301276 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
302277 let lpEmissionX18 = toX18(lpEmission, scale8)
303278 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
304279 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
305- let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
306- let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
280+ let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281+ let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
307282 let state = if ((txId58 == ""))
308283 then nil
309284 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
310285 then unit
311286 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
312287 then unit
313288 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)]
314289 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
315290 }
316291 }
317292
318293
319294 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
320295 let cfg = getPoolConfig()
321296 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
322297 let amAssetIdStr = cfg[idxAmtAssetId]
323298 let prAssetIdStr = cfg[idxPriceAssetId]
324299 let iAmtAssetId = cfg[idxIAmtAssetId]
325300 let iPriceAssetId = cfg[idxIPriceAssetId]
326301 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
327302 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
328303 let poolStatus = cfg[idxPoolStatus]
329304 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
330305 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
331306 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
332307 if (if ((amAssetIdStr != inAmAssetIdStr))
333308 then true
334309 else (prAssetIdStr != inPrAssetIdStr))
335310 then throw("Invalid amt or price asset passed.")
336311 else {
337312 let amBalance = if (isEvaluate)
338313 then getAccBalance(amAssetIdStr)
339314 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
340315 let prBalance = if (isEvaluate)
341316 then getAccBalance(prAssetIdStr)
342317 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
343318 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
344319 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
345320 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
346321 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
347322 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
348323 let res = if ((lpEmission == 0))
349324 then {
350325 let curPriceX18 = zeroBigInt
351326 let slippageX18 = zeroBigInt
352327 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
353328 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
354329 }
355330 else {
356331 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
357332 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
358333 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
359334 if (if ((curPriceX18 != zeroBigInt))
360335 then (slippageX18 > slippageToleranceX18)
361336 else false)
362337 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
363338 else {
364339 let lpEmissionX18 = toX18(lpEmission, scale8)
365- let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
366- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
340+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
367342 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
368343 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
369344 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
370345 let expAmtAssetAmtX18 = expectedAmts._1
371346 let expPriceAssetAmtX18 = expectedAmts._2
372- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
373- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
347+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348+ $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
374349 }
375350 }
376351 let calcLpAmt = res._1
377352 let calcAmAssetPmt = res._2
378353 let calcPrAssetPmt = res._3
379354 let curPrice = fromX18(res._4, scale8)
380355 let slippageCalc = fromX18(res._5, scale8)
381356 if ((0 >= calcLpAmt))
382357 then throw("Invalid calculations. LP calculated is less than zero.")
383358 else {
384359 let emitLpAmt = if (!(emitLp))
385360 then 0
386361 else calcLpAmt
387362 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
388363 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
389364 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))]
390365 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
391366 }
392367 }
393368 }
394369
395370
396-func calcKLp (amountBalance,priceBalance,lpEmission) = {
397- let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
398- if ((lpEmission == big0))
399- then big0
400- else updatedKLp
401- }
402-
403-
404-func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
405- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
406- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
407- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
408- let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
409- currentKLp
410- }
411-
412-
413-func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
414- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
415- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
416- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
417- let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
418- let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
419- $Tuple2(actions, updatedKLp)
420- }
421-
422-
423-func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
424- then true
425- else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
426-
427-
428371 func validateMatcherOrderAllowed (order) = {
429- let amountAssetAmount = order.amount
430- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
431- let $t02098621198 = if ((order.orderType == Buy))
432- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
433- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
434- let amountAssetBalanceDelta = $t02098621198._1
435- let priceAssetBalanceDelta = $t02098621198._2
372+ let cfg = getPoolConfig()
373+ let amtAssetId = cfg[idxAmtAssetId]
374+ let priceAssetId = cfg[idxPriceAssetId]
375+ let poolStatus = parseIntValue(cfg[idxPoolStatus])
376+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
377+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
378+ let accAmtAssetBalance = getAccBalance(amtAssetId)
379+ let accPriceAssetBalance = getAccBalance(priceAssetId)
380+ let curPriceX18 = if ((order.orderType == Buy))
381+ then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance)
382+ else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance)
383+ let curPrice = fromX18(curPriceX18, scale8)
436384 if (if (if (isGlobalShutdown())
437385 then true
438- else (cfgPoolStatus == PoolMatcherDisabled))
386+ else (poolStatus == PoolMatcherDisabled))
439387 then true
440- else (cfgPoolStatus == PoolShutdown))
388+ else (poolStatus == PoolShutdown))
441389 then throw("Exchange operations disabled")
442- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
443- then true
444- else (order.assetPair.priceAsset != cfgPriceAssetId))
445- then throw("Wrong order assets.")
446- else {
447- let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
448- let $t02166921769 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
449- let unusedActions = $t02166921769._1
450- let kLpNew = $t02166921769._2
451- let isOrderValid = (kLpNew >= kLp)
452- isOrderValid
453- }
390+ else {
391+ let orderAmtAsset = order.assetPair.amountAsset
392+ let orderAmtAssetStr = if ((orderAmtAsset == unit))
393+ then "WAVES"
394+ else toBase58String(value(orderAmtAsset))
395+ let orderPriceAsset = order.assetPair.priceAsset
396+ let orderPriceAssetStr = if ((orderPriceAsset == unit))
397+ then "WAVES"
398+ else toBase58String(value(orderPriceAsset))
399+ if (if ((orderAmtAssetStr != amtAssetId))
400+ then true
401+ else (orderPriceAssetStr != priceAssetId))
402+ then throw("Wrong order assets.")
403+ else {
404+ let orderPrice = order.price
405+ let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm)
406+ let castedOrderPrice = toScale(orderPrice, scale8, priceDcm)
407+ let isOrderPriceValid = if ((order.orderType == Buy))
408+ then (curPrice >= castedOrderPrice)
409+ else (castedOrderPrice >= curPrice)
410+ true
411+ }
412+ }
454413 }
455414
456415
457416 func commonGet (i) = if ((size(i.payments) != 1))
458417 then throw("exactly 1 payment is expected")
459418 else {
460419 let pmt = value(i.payments[0])
461420 let pmtAssetId = value(pmt.assetId)
462421 let pmtAmt = pmt.amount
463422 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
464423 let outAmAmt = res._1
465424 let outPrAmt = res._2
466425 let poolStatus = parseIntValue(res._9)
467426 let state = res._10
468427 if (if (isGlobalShutdown())
469428 then true
470429 else (poolStatus == PoolShutdown))
471430 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
472431 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
473432 }
474433
475434
476435 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
477436 then throw("exactly 2 payments are expected")
478437 else {
479438 let amAssetPmt = value(i.payments[0])
480439 let prAssetPmt = value(i.payments[1])
481440 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
482441 let poolStatus = parseIntValue(estPut._8)
483442 if (if (if (isGlobalShutdown())
484443 then true
485444 else (poolStatus == PoolPutDisabled))
486445 then true
487446 else (poolStatus == PoolShutdown))
488447 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
489448 else estPut
490449 }
491450
492451
493452 func emit (amount) = {
494453 let emitInv = invoke(factoryContract, "emit", [amount], nil)
495454 if ((emitInv == emitInv))
496455 then {
497456 let emitInvLegacy = match emitInv {
498457 case legacyFactoryContract: Address =>
499458 invoke(legacyFactoryContract, "emit", [amount], nil)
500459 case _ =>
501460 unit
502461 }
503462 if ((emitInvLegacy == emitInvLegacy))
504463 then amount
505464 else throw("Strict value is not equal to itself.")
506465 }
507466 else throw("Strict value is not equal to itself.")
508467 }
509468
510469
511470 func takeFee (amount,fee) = {
512471 let feeAmount = if ((fee == 0))
513472 then 0
514473 else fraction(amount, fee, scale8)
515474 $Tuple2((amount - feeAmount), feeAmount)
516475 }
517476
518477
519478 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
520479 let isEval = (txId == unit)
521480 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
522481 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
523482 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
524483 then true
525484 else if ((paymentAssetId == cfgPriceAssetId))
526485 then false
527486 else throwErr("invalid asset")
528- let $t02449024783 = if (isEval)
487+ let $t02266422957 = if (isEval)
529488 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
530489 else if (paymentInAmountAsset)
531490 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
532491 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
533- let amountBalanceOld = $t02449024783._1
534- let priceBalanceOld = $t02449024783._2
535- let $t02478724936 = if (paymentInAmountAsset)
492+ let amountBalanceOld = $t02266422957._1
493+ let priceBalanceOld = $t02266422957._2
494+ let $t02296123110 = if (paymentInAmountAsset)
536495 then $Tuple2(paymentAmountRaw, 0)
537496 else $Tuple2(0, paymentAmountRaw)
538- let amountAssetAmountRaw = $t02478724936._1
539- let priceAssetAmountRaw = $t02478724936._2
497+ let amountAssetAmountRaw = $t02296123110._1
498+ let priceAssetAmountRaw = $t02296123110._2
540499 let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
541500 let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
542- let $t02506825132 = takeFee(paymentAmountRaw, inFee)
543- let paymentAmount = $t02506825132._1
544- let feeAmount = $t02506825132._2
501+ let $t02324223306 = takeFee(paymentAmountRaw, inFee)
502+ let paymentAmount = $t02324223306._1
503+ let feeAmount = $t02324223306._2
545504 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
546505 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
547506 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
548507 let priceNew = fromX18(priceNewX18, scale8)
549508 let paymentBalance = if (paymentInAmountAsset)
550509 then amountBalanceOld
551510 else priceBalanceOld
552511 let paymentBalanceBigInt = toBigInt(paymentBalance)
553512 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
554513 let chechSupply = if ((supplyBigInt > big0))
555514 then true
556515 else throwErr("initial deposit requires all coins")
557516 if ((chechSupply == chechSupply))
558517 then {
559518 let depositBigInt = toBigInt(paymentAmount)
560519 let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
561520 let commonState = if (isEval)
562521 then nil
563522 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))]
564523 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
565524 let priceOld = fromX18(priceOldX18, scale8)
566525 let loss = {
567- let $t02681326980 = if (paymentInAmountAsset)
526+ let $t02478324950 = if (paymentInAmountAsset)
568527 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
569528 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
570- let amount = $t02681326980._1
571- let balance = $t02681326980._2
529+ let amount = $t02478324950._1
530+ let balance = $t02478324950._2
572531 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
573532 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
574533 }
575- $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
534+ $Tuple4(issueAmount, commonState, feeAmount, loss)
576535 }
577536 else throw("Strict value is not equal to itself.")
578537 }
579538
580539
581540 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
582541 let isEval = (txId == unit)
583- let cfg = getPoolConfig()
584- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
585- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
586542 let checks = [if ((paymentAssetId == cfgLpAssetId))
587543 then true
588544 else throwErr("invalid lp asset")]
589545 if ((checks == checks))
590546 then {
591547 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
592548 then true
593549 else if ((outAssetId == cfgPriceAssetId))
594550 then false
595551 else throwErr("invalid asset")
596552 let balanceBigInt = if (outInAmountAsset)
597553 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
598554 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
599- let outInAmountAssetDecimals = if (outInAmountAsset)
600- then amtAssetDcm
601- else priceAssetDcm
602555 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
603556 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
604557 let outBalance = if (outInAmountAsset)
605558 then amBalanceOld
606559 else prBalanceOld
607560 let outBalanceBigInt = toBigInt(outBalance)
608561 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
609562 let redeemedBigInt = toBigInt(paymentAmount)
610563 let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
611- let $t02905829114 = takeFee(amountRaw, outFee)
612- let totalAmount = $t02905829114._1
613- let feeAmount = $t02905829114._2
614- let $t02911829344 = if (outInAmountAsset)
564+ let $t02653026586 = takeFee(amountRaw, outFee)
565+ let totalAmount = $t02653026586._1
566+ let feeAmount = $t02653026586._2
567+ let $t02659026816 = if (outInAmountAsset)
615568 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
616569 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
617- let outAmAmount = $t02911829344._1
618- let outPrAmount = $t02911829344._2
619- let amBalanceNew = $t02911829344._3
620- let prBalanceNew = $t02911829344._4
570+ let outAmAmount = $t02659026816._1
571+ let outPrAmount = $t02659026816._2
572+ let amBalanceNew = $t02659026816._3
573+ let prBalanceNew = $t02659026816._4
621574 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
622575 let priceNew = fromX18(priceNewX18, scale8)
623576 let commonState = if (isEval)
624577 then nil
625578 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)]
626579 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
627580 let priceOld = fromX18(priceOldX18, scale8)
628581 let loss = {
629582 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
630583 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
631584 }
632- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
585+ $Tuple4(totalAmount, commonState, feeAmount, loss)
633586 }
634587 else throw("Strict value is not equal to itself.")
635588 }
636589
637590
638591 func managerPublicKeyOrUnit () = match getString(mpk()) {
639592 case s: String =>
640593 fromBase58String(s)
641594 case _: Unit =>
642595 unit
643596 case _ =>
644597 throw("Match error")
645598 }
646599
647600
648601 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
649602 case s: String =>
650603 fromBase58String(s)
651604 case _: Unit =>
652605 unit
653606 case _ =>
654607 throw("Match error")
655608 }
656609
657610
658611 func isManager (i) = match managerPublicKeyOrUnit() {
659612 case pk: ByteVector =>
660613 (i.callerPublicKey == pk)
661614 case _: Unit =>
662615 (i.caller == this)
663616 case _ =>
664617 throw("Match error")
665618 }
666619
667620
668621 func mustManager (i) = {
669622 let pd = throw("Permission denied")
670623 match managerPublicKeyOrUnit() {
671624 case pk: ByteVector =>
672625 if ((i.callerPublicKey == pk))
673626 then true
674627 else pd
675628 case _: Unit =>
676629 if ((i.caller == this))
677630 then true
678631 else pd
679632 case _ =>
680633 throw("Match error")
681634 }
682635 }
683636
684637
685638 @Callable(i)
686639 func setManager (pendingManagerPublicKey) = {
687640 let checkCaller = mustManager(i)
688641 if ((checkCaller == checkCaller))
689642 then {
690643 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
691644 if ((checkManagerPublicKey == checkManagerPublicKey))
692645 then [StringEntry(pmpk(), pendingManagerPublicKey)]
693646 else throw("Strict value is not equal to itself.")
694647 }
695648 else throw("Strict value is not equal to itself.")
696649 }
697650
698651
699652
700653 @Callable(i)
701654 func confirmManager () = {
702655 let pm = pendingManagerPublicKeyOrUnit()
703656 let hasPM = if (isDefined(pm))
704657 then true
705658 else throw("No pending manager")
706659 if ((hasPM == hasPM))
707660 then {
708661 let checkPM = if ((i.callerPublicKey == value(pm)))
709662 then true
710663 else throw("You are not pending manager")
711664 if ((checkPM == checkPM))
712665 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
713666 else throw("Strict value is not equal to itself.")
714667 }
715668 else throw("Strict value is not equal to itself.")
716669 }
717670
718671
719672
720673 @Callable(i)
721674 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
722675 then throw("Invalid slippageTolerance passed")
723676 else {
724677 let estPut = commonPut(i, slippageTolerance, true)
725678 let emitLpAmt = estPut._2
726679 let lpAssetId = estPut._7
727680 let state = estPut._9
728681 let amDiff = estPut._10
729682 let prDiff = estPut._11
730683 let amId = estPut._12
731684 let prId = estPut._13
732- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
733- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
734- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
735- if ((currentKLp == currentKLp))
685+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686+ if ((emitInv == emitInv))
736687 then {
737- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
738- if ((emitInv == emitInv))
688+ let emitInvLegacy = match emitInv {
689+ case legacyFactoryContract: Address =>
690+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
691+ case _ =>
692+ unit
693+ }
694+ if ((emitInvLegacy == emitInvLegacy))
739695 then {
740- let emitInvLegacy = match emitInv {
741- case legacyFactoryContract: Address =>
742- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
743- case _ =>
744- unit
745- }
746- if ((emitInvLegacy == emitInvLegacy))
696+ let slippageAInv = if ((amDiff > 0))
697+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698+ else nil
699+ if ((slippageAInv == slippageAInv))
747700 then {
748- let slippageAInv = if ((amDiff > 0))
749- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
701+ let slippagePInv = if ((prDiff > 0))
702+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
750703 else nil
751- if ((slippageAInv == slippageAInv))
704+ if ((slippagePInv == slippagePInv))
752705 then {
753- let slippagePInv = if ((prDiff > 0))
754- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
755- else nil
756- if ((slippagePInv == slippagePInv))
706+ let lpTransfer = if (shouldAutoStake)
757707 then {
758- let lpTransfer = if (shouldAutoStake)
759- then {
760- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
761- if ((slpStakeInv == slpStakeInv))
762- then nil
763- else throw("Strict value is not equal to itself.")
764- }
765- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
766- let $t03387234334 = refreshKLpInternal(0, 0, 0)
767- if (($t03387234334 == $t03387234334))
768- then {
769- let updatedKLp = $t03387234334._2
770- let refreshKLpActions = $t03387234334._1
771- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
772- if ((isUpdatedKLpValid == isUpdatedKLpValid))
773- then ((state ++ lpTransfer) ++ refreshKLpActions)
774- else throw("Strict value is not equal to itself.")
775- }
708+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709+ if ((slpStakeInv == slpStakeInv))
710+ then nil
776711 else throw("Strict value is not equal to itself.")
777712 }
778- else throw("Strict value is not equal to itself.")
713+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714+ (state ++ lpTransfer)
779715 }
780716 else throw("Strict value is not equal to itself.")
781717 }
782718 else throw("Strict value is not equal to itself.")
783719 }
784720 else throw("Strict value is not equal to itself.")
785721 }
786722 else throw("Strict value is not equal to itself.")
787723 }
788724
789725
790726
791727 @Callable(i)
792728 func putForFree (maxSlippage) = if ((0 > maxSlippage))
793729 then throw("Invalid value passed")
794730 else {
795731 let estPut = commonPut(i, maxSlippage, false)
796- let state = estPut._9
797- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
798- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
799- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
800- if ((currentKLp == currentKLp))
801- then {
802- let $t03489634961 = refreshKLpInternal(0, 0, 0)
803- let refreshKLpActions = $t03489634961._1
804- let updatedKLp = $t03489634961._2
805- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
806- if ((isUpdatedKLpValid == isUpdatedKLpValid))
807- then (state ++ refreshKLpActions)
808- else throw("Strict value is not equal to itself.")
809- }
810- else throw("Strict value is not equal to itself.")
732+ estPut._9
811733 }
812734
813735
814736
815737 @Callable(i)
816738 func putOneTkn (minOutAmount,autoStake) = {
817739 let isPoolOneTokenOperationsDisabled = {
818740 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
819741 if ($isInstanceOf(@, "Boolean"))
820742 then @
821743 else throw(($getType(@) + " couldn't be cast to Boolean"))
822744 }
823745 let isPutDisabled = if (if (if (isGlobalShutdown())
824746 then true
825747 else (cfgPoolStatus == PoolPutDisabled))
826748 then true
827749 else (cfgPoolStatus == PoolShutdown))
828750 then true
829751 else isPoolOneTokenOperationsDisabled
830752 let checks = [if (if (!(isPutDisabled))
831753 then true
832754 else isManager(i))
833755 then true
834756 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
835757 then true
836758 else throwErr("exactly 1 payment are expected")]
837759 if ((checks == checks))
838760 then {
839761 let payment = i.payments[0]
840762 let paymentAssetId = payment.assetId
841763 let paymentAmountRaw = payment.amount
842- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
843- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
844- else if ((paymentAssetId == cfgPriceAssetId))
845- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
846- else throwErr("payment asset is not supported")
847- if ((currentKLp == currentKLp))
764+ let userAddress = i.caller
765+ let txId = i.transactionId
766+ let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
767+ if (($t03172331853 == $t03172331853))
848768 then {
849- let userAddress = i.caller
850- let txId = i.transactionId
851- let $t03614936301 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
852- if (($t03614936301 == $t03614936301))
769+ let bonus = $t03172331853._4
770+ let feeAmount = $t03172331853._3
771+ let commonState = $t03172331853._2
772+ let emitAmountEstimated = $t03172331853._1
773+ let emitAmount = if (if ((minOutAmount > 0))
774+ then (minOutAmount > emitAmountEstimated)
775+ else false)
776+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
777+ else emitAmountEstimated
778+ let emitInv = emit(emitAmount)
779+ if ((emitInv == emitInv))
853780 then {
854- let paymentInAmountAsset = $t03614936301._5
855- let bonus = $t03614936301._4
856- let feeAmount = $t03614936301._3
857- let commonState = $t03614936301._2
858- let emitAmountEstimated = $t03614936301._1
859- let emitAmount = if (if ((minOutAmount > 0))
860- then (minOutAmount > emitAmountEstimated)
861- else false)
862- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
863- else emitAmountEstimated
864- let emitInv = emit(emitAmount)
865- if ((emitInv == emitInv))
781+ let lpTransfer = if (autoStake)
866782 then {
867- let lpTransfer = if (autoStake)
868- then {
869- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
870- if ((stakeInv == stakeInv))
871- then nil
872- else throw("Strict value is not equal to itself.")
873- }
874- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
875- let sendFee = if ((feeAmount > 0))
876- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
877- else nil
878- let $t03688737084 = if ((this == feeCollectorAddress))
879- then $Tuple2(0, 0)
880- else if (paymentInAmountAsset)
881- then $Tuple2(-(feeAmount), 0)
882- else $Tuple2(0, -(feeAmount))
883- let amountAssetBalanceDelta = $t03688737084._1
884- let priceAssetBalanceDelta = $t03688737084._2
885- let $t03708737195 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
886- let refreshKLpActions = $t03708737195._1
887- let updatedKLp = $t03708737195._2
888- let kLp = value(getString(keyKLp))
889- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
890- if ((isUpdatedKLpValid == isUpdatedKLpValid))
891- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
783+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784+ if ((stakeInv == stakeInv))
785+ then nil
892786 else throw("Strict value is not equal to itself.")
893787 }
894- else throw("Strict value is not equal to itself.")
788+ else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
789+ let sendFee = if ((feeAmount > 0))
790+ then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
791+ else nil
792+ $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
895793 }
896794 else throw("Strict value is not equal to itself.")
897795 }
898796 else throw("Strict value is not equal to itself.")
899797 }
900798 else throw("Strict value is not equal to itself.")
901799 }
902800
903801
904802
905803 @Callable(i)
906804 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
907- let $t03750137658 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
908- let emitAmountEstimated = $t03750137658._1
909- let commonState = $t03750137658._2
910- let feeAmount = $t03750137658._3
911- let bonus = $t03750137658._4
912- let paymentInAmountAsset = $t03750137658._5
805+ let $t03258232717 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
806+ let emitAmountEstimated = $t03258232717._1
807+ let commonState = $t03258232717._2
808+ let feeAmount = $t03258232717._3
809+ let bonus = $t03258232717._4
913810 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
914811 }
915812
916813
917814
918815 @Callable(i)
919816 func getOneTkn (outAssetIdStr,minOutAmount) = {
920817 let isPoolOneTokenOperationsDisabled = {
921818 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
922819 if ($isInstanceOf(@, "Boolean"))
923820 then @
924821 else throw(($getType(@) + " couldn't be cast to Boolean"))
925822 }
926823 let isGetDisabled = if (if (isGlobalShutdown())
927824 then true
928825 else (cfgPoolStatus == PoolShutdown))
929826 then true
930827 else isPoolOneTokenOperationsDisabled
931828 let checks = [if (if (!(isGetDisabled))
932829 then true
933830 else isManager(i))
934831 then true
935832 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
936833 then true
937834 else throwErr("exactly 1 payment are expected")]
938835 if ((checks == checks))
939836 then {
940837 let outAssetId = parseAssetId(outAssetIdStr)
941838 let payment = i.payments[0]
942839 let paymentAssetId = payment.assetId
943840 let paymentAmount = payment.amount
944- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
945- if ((currentKLp == currentKLp))
841+ let userAddress = i.caller
842+ let txId = i.transactionId
843+ let $t03352233657 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
844+ if (($t03352233657 == $t03352233657))
946845 then {
947- let userAddress = i.caller
948- let txId = i.transactionId
949- let $t03854338696 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
950- if (($t03854338696 == $t03854338696))
846+ let bonus = $t03352233657._4
847+ let feeAmount = $t03352233657._3
848+ let commonState = $t03352233657._2
849+ let amountEstimated = $t03352233657._1
850+ let amount = if (if ((minOutAmount > 0))
851+ then (minOutAmount > amountEstimated)
852+ else false)
853+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
854+ else amountEstimated
855+ let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
856+ if ((burnInv == burnInv))
951857 then {
952- let outInAmountAsset = $t03854338696._5
953- let bonus = $t03854338696._4
954- let feeAmount = $t03854338696._3
955- let commonState = $t03854338696._2
956- let amountEstimated = $t03854338696._1
957- let amount = if (if ((minOutAmount > 0))
958- then (minOutAmount > amountEstimated)
959- else false)
960- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
961- else amountEstimated
962- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
963- if ((burnInv == burnInv))
964- then {
965- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
966- let sendFee = if ((feeAmount > 0))
967- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
968- else nil
969- let $t03919639443 = {
970- let feeAmountForCalc = if ((this == feeCollectorAddress))
971- then 0
972- else feeAmount
973- if (outInAmountAsset)
974- then $Tuple2(-((amount + feeAmountForCalc)), 0)
975- else $Tuple2(0, -((amount + feeAmountForCalc)))
976- }
977- let amountAssetBalanceDelta = $t03919639443._1
978- let priceAssetBalanceDelta = $t03919639443._2
979- let $t03944639554 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
980- let refreshKLpActions = $t03944639554._1
981- let updatedKLp = $t03944639554._2
982- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
983- if ((isUpdatedKLpValid == isUpdatedKLpValid))
984- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
985- else throw("Strict value is not equal to itself.")
986- }
987- else throw("Strict value is not equal to itself.")
858+ let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
859+ let sendFee = if ((feeAmount > 0))
860+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
861+ else nil
862+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
988863 }
989864 else throw("Strict value is not equal to itself.")
990865 }
991866 else throw("Strict value is not equal to itself.")
992867 }
993868 else throw("Strict value is not equal to itself.")
994869 }
995870
996871
997872
998873 @Callable(i)
999874 func getOneTknREADONLY (outAssetId,paymentAmount) = {
1000- let $t03981139967 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
1001- let amountEstimated = $t03981139967._1
1002- let commonState = $t03981139967._2
1003- let feeAmount = $t03981139967._3
1004- let bonus = $t03981139967._4
1005- let outInAmountAsset = $t03981139967._5
875+ let $t03429234430 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
876+ let amountEstimated = $t03429234430._1
877+ let commonState = $t03429234430._2
878+ let feeAmount = $t03429234430._3
879+ let bonus = $t03429234430._4
1006880 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
1007881 }
1008882
1009883
1010884
1011885 @Callable(i)
1012886 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
1013887 let isPoolOneTokenOperationsDisabled = {
1014888 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
1015889 if ($isInstanceOf(@, "Boolean"))
1016890 then @
1017891 else throw(($getType(@) + " couldn't be cast to Boolean"))
1018892 }
1019893 let isGetDisabled = if (if (isGlobalShutdown())
1020894 then true
1021895 else (cfgPoolStatus == PoolShutdown))
1022896 then true
1023897 else isPoolOneTokenOperationsDisabled
1024898 let checks = [if (if (!(isGetDisabled))
1025899 then true
1026900 else isManager(i))
1027901 then true
1028902 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
1029903 then true
1030904 else throwErr("no payments are expected")]
1031905 if ((checks == checks))
1032906 then {
1033907 let outAssetId = parseAssetId(outAssetIdStr)
1034908 let userAddress = i.caller
1035909 let txId = i.transactionId
1036- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1037- if ((currentKLp == currentKLp))
910+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
911+ if ((unstakeInv == unstakeInv))
1038912 then {
1039- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1040- if ((unstakeInv == unstakeInv))
913+ let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914+ if (($t03525535388 == $t03525535388))
1041915 then {
1042- let $t04087241023 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1043- if (($t04087241023 == $t04087241023))
916+ let bonus = $t03525535388._4
917+ let feeAmount = $t03525535388._3
918+ let commonState = $t03525535388._2
919+ let amountEstimated = $t03525535388._1
920+ let amount = if (if ((minOutAmount > 0))
921+ then (minOutAmount > amountEstimated)
922+ else false)
923+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
924+ else amountEstimated
925+ let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
926+ if ((burnInv == burnInv))
1044927 then {
1045- let outInAmountAsset = $t04087241023._5
1046- let bonus = $t04087241023._4
1047- let feeAmount = $t04087241023._3
1048- let commonState = $t04087241023._2
1049- let amountEstimated = $t04087241023._1
1050- let amount = if (if ((minOutAmount > 0))
1051- then (minOutAmount > amountEstimated)
1052- else false)
1053- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1054- else amountEstimated
1055- let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1056- if ((burnInv == burnInv))
1057- then {
1058- let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1059- let sendFee = if ((feeAmount > 0))
1060- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1061- else nil
1062- let $t04151841765 = {
1063- let feeAmountForCalc = if ((this == feeCollectorAddress))
1064- then 0
1065- else feeAmount
1066- if (outInAmountAsset)
1067- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1068- else $Tuple2(0, -((amount + feeAmountForCalc)))
1069- }
1070- let amountAssetBalanceDelta = $t04151841765._1
1071- let priceAssetBalanceDelta = $t04151841765._2
1072- let $t04176841876 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1073- let refreshKLpActions = $t04176841876._1
1074- let updatedKLp = $t04176841876._2
1075- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1076- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1077- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1078- else throw("Strict value is not equal to itself.")
1079- }
1080- else throw("Strict value is not equal to itself.")
928+ let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
929+ let sendFee = if ((feeAmount > 0))
930+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
931+ else nil
932+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1081933 }
1082934 else throw("Strict value is not equal to itself.")
1083935 }
1084936 else throw("Strict value is not equal to itself.")
1085937 }
1086938 else throw("Strict value is not equal to itself.")
1087939 }
1088940 else throw("Strict value is not equal to itself.")
1089941 }
1090942
1091943
1092944
1093945 @Callable(i)
1094946 func get () = {
1095947 let res = commonGet(i)
1096948 let outAmtAmt = res._1
1097949 let outPrAmt = res._2
1098950 let pmtAmt = res._3
1099951 let pmtAssetId = res._4
1100952 let state = res._5
1101- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1102- if ((currentKLp == currentKLp))
1103- then {
1104- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1105- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1106- then {
1107- let $t04282242904 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1108- let refreshKLpActions = $t04282242904._1
1109- let updatedKLp = $t04282242904._2
1110- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1111- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1112- then (state ++ refreshKLpActions)
1113- else throw("Strict value is not equal to itself.")
1114- }
1115- else throw("Strict value is not equal to itself.")
1116- }
953+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
954+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955+ then state
1117956 else throw("Strict value is not equal to itself.")
1118957 }
1119958
1120959
1121960
1122961 @Callable(i)
1123962 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
1124963 let res = commonGet(i)
1125964 let outAmAmt = res._1
1126965 let outPrAmt = res._2
1127966 let pmtAmt = res._3
1128967 let pmtAssetId = res._4
1129968 let state = res._5
1130969 if ((noLessThenAmtAsset > outAmAmt))
1131970 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
1132971 else if ((noLessThenPriceAsset > outPrAmt))
1133972 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1134973 else {
1135- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1136- if ((currentKLp == currentKLp))
1137- then {
1138- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1139- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1140- then {
1141- let $t04385343934 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1142- let refreshKLpActions = $t04385343934._1
1143- let updatedKLp = $t04385343934._2
1144- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1145- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1146- then (state ++ refreshKLpActions)
1147- else throw("Strict value is not equal to itself.")
1148- }
1149- else throw("Strict value is not equal to itself.")
1150- }
974+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
975+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
976+ then state
1151977 else throw("Strict value is not equal to itself.")
1152978 }
1153979 }
1154980
1155981
1156982
1157983 @Callable(i)
1158984 func unstakeAndGet (amount) = {
1159985 let checkPayments = if ((size(i.payments) != 0))
1160986 then throw("No payments are expected")
1161987 else true
1162988 if ((checkPayments == checkPayments))
1163989 then {
1164990 let cfg = getPoolConfig()
1165991 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1166- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1167- if ((currentKLp == currentKLp))
992+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
993+ if ((unstakeInv == unstakeInv))
1168994 then {
1169- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1170- if ((unstakeInv == unstakeInv))
995+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
996+ let poolStatus = parseIntValue(res._9)
997+ let state = res._10
998+ let checkPoolStatus = if (if (isGlobalShutdown())
999+ then true
1000+ else (poolStatus == PoolShutdown))
1001+ then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1002+ else true
1003+ if ((checkPoolStatus == checkPoolStatus))
11711004 then {
1172- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1173- let outAmAmt = res._1
1174- let outPrAmt = res._2
1175- let poolStatus = parseIntValue(res._9)
1176- let state = res._10
1177- let checkPoolStatus = if (if (isGlobalShutdown())
1178- then true
1179- else (poolStatus == PoolShutdown))
1180- then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
1181- else true
1182- if ((checkPoolStatus == checkPoolStatus))
1183- then {
1184- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1185- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1186- then {
1187- let $t04506045141 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1188- let refreshKLpActions = $t04506045141._1
1189- let updatedKLp = $t04506045141._2
1190- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1191- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1192- then (state ++ refreshKLpActions)
1193- else throw("Strict value is not equal to itself.")
1194- }
1195- else throw("Strict value is not equal to itself.")
1196- }
1005+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1006+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1007+ then state
11971008 else throw("Strict value is not equal to itself.")
11981009 }
11991010 else throw("Strict value is not equal to itself.")
12001011 }
12011012 else throw("Strict value is not equal to itself.")
12021013 }
12031014 else throw("Strict value is not equal to itself.")
12041015 }
12051016
12061017
12071018
12081019 @Callable(i)
12091020 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
12101021 let isGetDisabled = if (isGlobalShutdown())
12111022 then true
12121023 else (cfgPoolStatus == PoolShutdown)
12131024 let checks = [if (!(isGetDisabled))
12141025 then true
12151026 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
12161027 then true
12171028 else throw("no payments are expected")]
12181029 if ((checks == checks))
12191030 then {
1220- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1221- if ((currentKLp == currentKLp))
1031+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1032+ if ((unstakeInv == unstakeInv))
12221033 then {
1223- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1224- if ((unstakeInv == unstakeInv))
1034+ let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1035+ let outAmAmt = res._1
1036+ let outPrAmt = res._2
1037+ let state = res._10
1038+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1039+ then true
1040+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1041+ then true
1042+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1043+ if ((checkAmounts == checkAmounts))
12251044 then {
1226- let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1227- let outAmAmt = res._1
1228- let outPrAmt = res._2
1229- let state = res._10
1230- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1231- then true
1232- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1233- then true
1234- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1235- if ((checkAmounts == checkAmounts))
1236- then {
1237- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1238- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1239- then {
1240- let $t04643646517 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1241- let refreshKLpActions = $t04643646517._1
1242- let updatedKLp = $t04643646517._2
1243- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1244- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1245- then (state ++ refreshKLpActions)
1246- else throw("Strict value is not equal to itself.")
1247- }
1248- else throw("Strict value is not equal to itself.")
1249- }
1045+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1046+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1047+ then state
12501048 else throw("Strict value is not equal to itself.")
12511049 }
12521050 else throw("Strict value is not equal to itself.")
12531051 }
12541052 else throw("Strict value is not equal to itself.")
12551053 }
12561054 else throw("Strict value is not equal to itself.")
12571055 }
12581056
12591057
12601058
12611059 @Callable(i)
12621060 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12631061 then throw("permissions denied")
12641062 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1265-
1266-
1267-
1268-@Callable(i)
1269-func refreshKLp () = {
1270- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1271- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1272- then unit
1273- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1274- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1275- then {
1276- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1277- let $t04770447768 = refreshKLpInternal(0, 0, 0)
1278- let kLpUpdateActions = $t04770447768._1
1279- let updatedKLp = $t04770447768._2
1280- let actions = if ((kLp != updatedKLp))
1281- then kLpUpdateActions
1282- else throwErr("nothing to refresh")
1283- $Tuple2(actions, toString(updatedKLp))
1284- }
1285- else throw("Strict value is not equal to itself.")
1286- }
12871063
12881064
12891065
12901066 @Callable(i)
12911067 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
12921068
12931069
12941070
12951071 @Callable(i)
12961072 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
12971073
12981074
12991075
13001076 @Callable(i)
13011077 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
13021078 let prices = calcPrices(amAmt, prAmt, lpAmt)
13031079 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
13041080 }
13051081
13061082
13071083
13081084 @Callable(i)
13091085 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
13101086
13111087
13121088
13131089 @Callable(i)
13141090 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
13151091
13161092
13171093
13181094 @Callable(i)
13191095 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
13201096
13211097
13221098
13231099 @Callable(i)
13241100 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
13251101
13261102
13271103
13281104 @Callable(i)
13291105 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
13301106 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
13311107 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
13321108 }
13331109
13341110
13351111
13361112 @Callable(i)
13371113 func statsREADONLY () = {
13381114 let cfg = getPoolConfig()
13391115 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13401116 let amtAssetId = cfg[idxAmtAssetId]
13411117 let priceAssetId = cfg[idxPriceAssetId]
13421118 let iAmtAssetId = cfg[idxIAmtAssetId]
13431119 let iPriceAssetId = cfg[idxIPriceAssetId]
13441120 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13451121 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13461122 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13471123 let accAmtAssetBalance = getAccBalance(amtAssetId)
13481124 let accPriceAssetBalance = getAccBalance(priceAssetId)
13491125 let pricesList = if ((poolLPBalance == 0))
13501126 then [zeroBigInt, zeroBigInt, zeroBigInt]
13511127 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
13521128 let curPrice = 0
13531129 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
13541130 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
13551131 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
13561132 $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))
13571133 }
13581134
13591135
13601136
13611137 @Callable(i)
13621138 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
13631139 let cfg = getPoolConfig()
13641140 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13651141 let amAssetIdStr = cfg[idxAmtAssetId]
13661142 let amAssetId = fromBase58String(amAssetIdStr)
13671143 let prAssetIdStr = cfg[idxPriceAssetId]
13681144 let prAssetId = fromBase58String(prAssetIdStr)
13691145 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13701146 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13711147 let poolStatus = cfg[idxPoolStatus]
13721148 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13731149 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
13741150 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
13751151 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
13761152 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
13771153 let curPriceX18 = if ((poolLPBalance == 0))
13781154 then zeroBigInt
13791155 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
13801156 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
13811157 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
13821158 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
13831159 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
13841160 let calcLpAmt = estPut._1
13851161 let curPriceCalc = estPut._3
13861162 let amBalance = estPut._4
13871163 let prBalance = estPut._5
13881164 let lpEmission = estPut._6
13891165 $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))
13901166 }
13911167
13921168
13931169
13941170 @Callable(i)
13951171 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
13961172 let cfg = getPoolConfig()
13971173 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13981174 let amAssetIdStr = cfg[idxAmtAssetId]
13991175 let amAssetId = fromBase58String(amAssetIdStr)
14001176 let prAssetIdStr = cfg[idxPriceAssetId]
14011177 let prAssetId = fromBase58String(prAssetIdStr)
14021178 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
14031179 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
14041180 let poolStatus = cfg[idxPoolStatus]
14051181 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
14061182 let amBalanceRaw = getAccBalance(amAssetIdStr)
14071183 let prBalanceRaw = getAccBalance(prAssetIdStr)
14081184 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
14091185 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
14101186 let curPriceX18 = if ((poolLPBalance == 0))
14111187 then zeroBigInt
14121188 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
14131189 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
14141190 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
14151191 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
14161192 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
14171193 let calcLpAmt = estPut._1
14181194 let curPriceCalc = estPut._3
14191195 let amBalance = estPut._4
14201196 let prBalance = estPut._5
14211197 let lpEmission = estPut._6
14221198 $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))
14231199 }
14241200
14251201
14261202
14271203 @Callable(i)
14281204 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
14291205 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
14301206 let outAmAmt = res._1
14311207 let outPrAmt = res._2
14321208 let amBalance = res._5
14331209 let prBalance = res._6
14341210 let lpEmission = res._7
14351211 let curPrice = res._8
14361212 let poolStatus = parseIntValue(res._9)
14371213 $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))
14381214 }
14391215
14401216
14411217 @Verifier(tx)
14421218 func verify () = {
14431219 let targetPublicKey = match managerPublicKeyOrUnit() {
14441220 case pk: ByteVector =>
14451221 pk
14461222 case _: Unit =>
14471223 tx.senderPublicKey
14481224 case _ =>
14491225 throw("Match error")
14501226 }
14511227 match tx {
14521228 case order: Order =>
14531229 let matcherPub = getMatcherPubOrFail()
14541230 let orderValid = validateMatcherOrderAllowed(order)
14551231 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
14561232 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
14571233 if (if (if (orderValid)
14581234 then senderValid
14591235 else false)
14601236 then matcherValid
14611237 else false)
14621238 then true
14631239 else throwOrderError(orderValid, senderValid, matcherValid)
14641240 case s: SetScriptTransaction =>
14651241 let newHash = blake2b256(value(s.script))
14661242 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
14671243 let currentHash = scriptHash(this)
14681244 if (if ((allowedHash == newHash))
14691245 then (currentHash != newHash)
14701246 else false)
14711247 then true
14721248 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14731249 case _ =>
14741250 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14751251 }
14761252 }
14771253

github/deemru/w8io/026f985 
183.69 ms