tx · Fw7eDcBttrbr9afyrHC7w5eNZKYyN1Y4XoFcZeZ2s4mS

3N4JvGpYF8iwSPzqwqWcubTfWWaKxdgmE4H:  -0.03100000 Waves

2022.12.20 12:31 [2368432] smart account 3N4JvGpYF8iwSPzqwqWcubTfWWaKxdgmE4H > SELF 0.00000000 Waves

{ "type": 13, "id": "Fw7eDcBttrbr9afyrHC7w5eNZKYyN1Y4XoFcZeZ2s4mS", "fee": 3100000, "feeAssetId": null, "timestamp": 1671528720323, "version": 1, "sender": "3N4JvGpYF8iwSPzqwqWcubTfWWaKxdgmE4H", "senderPublicKey": "p2hzghiY7UemNr13x5jVMEC1aSdo6Tkv76kjMxRU9cZ", "proofs": [ "5RjK71WgjpU9Nnz2FLv5V7LpySg8qzBkXL9ymx28zU2t72scyDvKW1cBEaztA6TNrErwfW6JrtskBVWX1xvqTKof" ], "script": "base64:BgK3JwgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASAwoBCBIFCgMBAQESBAoCAQESBAoCCAESBAoCCAgSCwoJCAEBAgECCAQEEgYKBAgIAQgSABIDCgEBEgMKAQESBAoCCAEiCmxQZGVjaW1hbHMiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgt3YXZlc1N0cmluZyIDU0VQIgpQb29sQWN0aXZlIg9Qb29sUHV0RGlzYWJsZWQiE1Bvb2xNYXRjaGVyRGlzYWJsZWQiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiDWlkeFBvb2xTdGF0dXMiEGlkeFBvb2xMUEFzc2V0SWQiDWlkeEFtdEFzc2V0SWQiD2lkeFByaWNlQXNzZXRJZCIOaWR4QW10QXNzZXREY20iEGlkeFByaWNlQXNzZXREY20iDmlkeElBbXRBc3NldElkIhBpZHhJUHJpY2VBc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m9keUJ5dGVzCQCRAwIIBQJjUgZwcm9vZnMAAAgFAmNSD3NlbmRlclB1YmxpY0tleQQCYXQJAPQDAwgFAmNSCWJvZHlCeXRlcwkAkQMCCAUCY1IGcHJvb2ZzAAEFAmZMAwMDBQJhcgUCYXMHBQJhdAcGCQECYXEDBQJhcgUCYXMFAmF0AwkAAQIFAmRxAhRTZXRTY3JpcHRUcmFuc2FjdGlvbgQCZXcFAmRxBAJmTQkA9gMBCQEFdmFsdWUBCAUCZXcGc2NyaXB0BAJmTgkA2wQBCQEFdmFsdWUBCQCdCAIFAmFBCQECYW8ABAJmTwkA8QcBBQR0aGlzAwMJAAACBQJmTgUCZk0JAQIhPQIFAmZPBQJmTQcGCQD0AwMIBQJmSQlib2R5Qnl0ZXMJAJEDAggFAmZJBnByb29mcwAABQJmSwkA9AMDCAUCZkkJYm9keUJ5dGVzCQCRAwIIBQJmSQZwcm9vZnMAAAUCZkvBwFdz", "chainId": 84, "height": 2368432, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3c7MiDMw2g35LHMmWRsuK1RrfEjnwPt2PxxUxr9sXLhD Next: BWE4qH9jPKHfbsD3QfSydzpGqPba3duoRAHxzFXKLoVb 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
162143 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
163144
164145
165-func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
166-
167-
168146 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
169147
170148 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
149+
150+let inFee = {
151+ let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
152+ if ($isInstanceOf(@, "Int"))
153+ then @
154+ else throw(($getType(@) + " couldn't be cast to Int"))
155+ }
156+
157+let outFee = {
158+ let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
159+ if ($isInstanceOf(@, "Int"))
160+ then @
161+ else throw(($getType(@) + " couldn't be cast to Int"))
162+ }
171163
172164 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
173165
199191
200192 let poolConfigParsed = parsePoolConfig(getPoolConfig())
201193
202-let $t080588224 = poolConfigParsed
194+let $t076017767 = poolConfigParsed
203195
204-let cfgPoolAddress = $t080588224._1
196+let cfgPoolAddress = $t076017767._1
205197
206-let cfgPoolStatus = $t080588224._2
198+let cfgPoolStatus = $t076017767._2
207199
208-let cfgLpAssetId = $t080588224._3
200+let cfgLpAssetId = $t076017767._3
209201
210-let cfgAmountAssetId = $t080588224._4
202+let cfgAmountAssetId = $t076017767._4
211203
212-let cfgPriceAssetId = $t080588224._5
204+let cfgPriceAssetId = $t076017767._5
213205
214-let cfgAmountAssetDecimals = $t080588224._6
206+let cfgAmountAssetDecimals = $t076017767._6
215207
216-let cfgPriceAssetDecimals = $t080588224._7
208+let cfgPriceAssetDecimals = $t076017767._7
217209
218210 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
219211
234226
235227
236228 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
237-
238-
239-func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
240229
241230
242231 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
288277 let lpEmissionX18 = toX18(lpEmission, scale8)
289278 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
290279 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
291- let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
292- let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
280+ let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281+ let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
293282 let state = if ((txId58 == ""))
294283 then nil
295284 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
348337 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
349338 else {
350339 let lpEmissionX18 = toX18(lpEmission, scale8)
351- let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
352- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
340+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
353342 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
354343 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
355344 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
356345 let expAmtAssetAmtX18 = expectedAmts._1
357346 let expPriceAssetAmtX18 = expectedAmts._2
358- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
359- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
347+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348+ $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
360349 }
361350 }
362351 let calcLpAmt = res._1
379368 }
380369
381370
382-func calcKLp (amountBalance,priceBalance,lpEmission) = {
383- let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
384- if ((lpEmission == big0))
385- then big0
386- else updatedKLp
387- }
388-
389-
390-func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
391- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
392- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
393- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
394- let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
395- currentKLp
396- }
397-
398-
399-func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
400- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
401- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
402- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
403- let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
404- let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
405- $Tuple2(actions, updatedKLp)
406- }
407-
408-
409-func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
410- then true
411- else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
412-
413-
414371 func validateMatcherOrderAllowed (order) = {
415- let amountAssetAmount = order.amount
416- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
417- let $t02080121013 = if ((order.orderType == Buy))
418- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
419- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
420- let amountAssetBalanceDelta = $t02080121013._1
421- let priceAssetBalanceDelta = $t02080121013._2
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)
422384 if (if (if (isGlobalShutdown())
423385 then true
424- else (cfgPoolStatus == PoolMatcherDisabled))
386+ else (poolStatus == PoolMatcherDisabled))
425387 then true
426- else (cfgPoolStatus == PoolShutdown))
388+ else (poolStatus == PoolShutdown))
427389 then throw("Exchange operations disabled")
428- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
429- then true
430- else (order.assetPair.priceAsset != cfgPriceAssetId))
431- then throw("Wrong order assets.")
432- else {
433- let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
434- let $t02148421584 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
435- let unusedActions = $t02148421584._1
436- let kLpNew = $t02148421584._2
437- let isOrderValid = (kLpNew >= kLp)
438- isOrderValid
439- }
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+ }
440413 }
441414
442415
494467 }
495468
496469
497-func takeFee (amount) = {
498- let feeAmount = fraction(amount, fee, scale8)
470+func takeFee (amount,fee) = {
471+ let feeAmount = if ((fee == 0))
472+ then 0
473+ else fraction(amount, fee, scale8)
499474 $Tuple2((amount - feeAmount), feeAmount)
500475 }
501476
509484 else if ((paymentAssetId == cfgPriceAssetId))
510485 then false
511486 else throwErr("invalid asset")
512- let $t02426924562 = if (isEval)
487+ let $t02266422957 = if (isEval)
513488 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
514489 else if (paymentInAmountAsset)
515490 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
516491 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
517- let amountBalanceOld = $t02426924562._1
518- let priceBalanceOld = $t02426924562._2
519- let $t02456624715 = if (paymentInAmountAsset)
492+ let amountBalanceOld = $t02266422957._1
493+ let priceBalanceOld = $t02266422957._2
494+ let $t02296123110 = if (paymentInAmountAsset)
520495 then $Tuple2(paymentAmountRaw, 0)
521496 else $Tuple2(0, paymentAmountRaw)
522- let amountAssetAmountRaw = $t02456624715._1
523- let priceAssetAmountRaw = $t02456624715._2
524- let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
525- let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
526- let $t02483724896 = takeFee(paymentAmountRaw)
527- let paymentAmount = $t02483724896._1
528- let feeAmount = $t02483724896._2
497+ let amountAssetAmountRaw = $t02296123110._1
498+ let priceAssetAmountRaw = $t02296123110._2
499+ let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
500+ let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
501+ let $t02324223306 = takeFee(paymentAmountRaw, inFee)
502+ let paymentAmount = $t02324223306._1
503+ let feeAmount = $t02324223306._2
529504 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
530505 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
531506 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
541516 if ((chechSupply == chechSupply))
542517 then {
543518 let depositBigInt = toBigInt(paymentAmount)
544- let issueAmount = max([0, fromX18Round(fraction(supplyBigInt, (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18), scale18), scale8, FLOOR)])
519+ let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
545520 let commonState = if (isEval)
546521 then nil
547522 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))]
548523 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
549524 let priceOld = fromX18(priceOldX18, scale8)
550525 let loss = {
551- let $t02639726564 = if (paymentInAmountAsset)
526+ let $t02478324950 = if (paymentInAmountAsset)
552527 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
553528 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
554- let amount = $t02639726564._1
555- let balance = $t02639726564._2
529+ let amount = $t02478324950._1
530+ let balance = $t02478324950._2
556531 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
557532 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
558533 }
559- $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
534+ $Tuple4(issueAmount, commonState, feeAmount, loss)
560535 }
561536 else throw("Strict value is not equal to itself.")
562537 }
564539
565540 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
566541 let isEval = (txId == unit)
567- let cfg = getPoolConfig()
568- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
569- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
570542 let checks = [if ((paymentAssetId == cfgLpAssetId))
571543 then true
572544 else throwErr("invalid lp asset")]
580552 let balanceBigInt = if (outInAmountAsset)
581553 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
582554 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
583- let outInAmountAssetDecimals = if (outInAmountAsset)
584- then amtAssetDcm
585- else priceAssetDcm
586555 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
587556 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
588557 let outBalance = if (outInAmountAsset)
591560 let outBalanceBigInt = toBigInt(outBalance)
592561 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
593562 let redeemedBigInt = toBigInt(paymentAmount)
594- let amountRaw = max([0, fromX18Round(fraction(balanceBigInt, (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN)), scale18), outInAmountAssetDecimals, FLOOR)])
595- let $t02846528515 = takeFee(amountRaw)
596- let totalAmount = $t02846528515._1
597- let feeAmount = $t02846528515._2
598- let $t02851928745 = if (outInAmountAsset)
563+ let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
564+ let $t02653026586 = takeFee(amountRaw, outFee)
565+ let totalAmount = $t02653026586._1
566+ let feeAmount = $t02653026586._2
567+ let $t02659026816 = if (outInAmountAsset)
599568 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
600569 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
601- let outAmAmount = $t02851928745._1
602- let outPrAmount = $t02851928745._2
603- let amBalanceNew = $t02851928745._3
604- let prBalanceNew = $t02851928745._4
570+ let outAmAmount = $t02659026816._1
571+ let outPrAmount = $t02659026816._2
572+ let amBalanceNew = $t02659026816._3
573+ let prBalanceNew = $t02659026816._4
605574 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
606575 let priceNew = fromX18(priceNewX18, scale8)
607576 let commonState = if (isEval)
613582 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
614583 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
615584 }
616- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
585+ $Tuple4(totalAmount, commonState, feeAmount, loss)
617586 }
618587 else throw("Strict value is not equal to itself.")
619588 }
713682 let prDiff = estPut._11
714683 let amId = estPut._12
715684 let prId = estPut._13
716- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
717- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
718- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
719- if ((currentKLp == currentKLp))
685+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686+ if ((emitInv == emitInv))
720687 then {
721- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
722- 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))
723695 then {
724- let emitInvLegacy = match emitInv {
725- case legacyFactoryContract: Address =>
726- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
727- case _ =>
728- unit
729- }
730- if ((emitInvLegacy == emitInvLegacy))
696+ let slippageAInv = if ((amDiff > 0))
697+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698+ else nil
699+ if ((slippageAInv == slippageAInv))
731700 then {
732- let slippageAInv = if ((amDiff > 0))
733- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
701+ let slippagePInv = if ((prDiff > 0))
702+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
734703 else nil
735- if ((slippageAInv == slippageAInv))
704+ if ((slippagePInv == slippagePInv))
736705 then {
737- let slippagePInv = if ((prDiff > 0))
738- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
739- else nil
740- if ((slippagePInv == slippagePInv))
706+ let lpTransfer = if (shouldAutoStake)
741707 then {
742- let lpTransfer = if (shouldAutoStake)
743- then {
744- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
745- if ((slpStakeInv == slpStakeInv))
746- then nil
747- else throw("Strict value is not equal to itself.")
748- }
749- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
750- let $t03327333735 = refreshKLpInternal(0, 0, 0)
751- if (($t03327333735 == $t03327333735))
752- then {
753- let updatedKLp = $t03327333735._2
754- let refreshKLpActions = $t03327333735._1
755- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
756- if ((isUpdatedKLpValid == isUpdatedKLpValid))
757- then ((state ++ lpTransfer) ++ refreshKLpActions)
758- else throw("Strict value is not equal to itself.")
759- }
708+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709+ if ((slpStakeInv == slpStakeInv))
710+ then nil
760711 else throw("Strict value is not equal to itself.")
761712 }
762- else throw("Strict value is not equal to itself.")
713+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714+ (state ++ lpTransfer)
763715 }
764716 else throw("Strict value is not equal to itself.")
765717 }
777729 then throw("Invalid value passed")
778730 else {
779731 let estPut = commonPut(i, maxSlippage, false)
780- let state = estPut._9
781- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
782- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
783- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
784- if ((currentKLp == currentKLp))
785- then {
786- let $t03429734362 = refreshKLpInternal(0, 0, 0)
787- let refreshKLpActions = $t03429734362._1
788- let updatedKLp = $t03429734362._2
789- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
790- if ((isUpdatedKLpValid == isUpdatedKLpValid))
791- then (state ++ refreshKLpActions)
792- else throw("Strict value is not equal to itself.")
793- }
794- else throw("Strict value is not equal to itself.")
732+ estPut._9
795733 }
796734
797735
823761 let payment = i.payments[0]
824762 let paymentAssetId = payment.assetId
825763 let paymentAmountRaw = payment.amount
826- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
827- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
828- else if ((paymentAssetId == cfgPriceAssetId))
829- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
830- else throwErr("payment asset is not supported")
831- if ((currentKLp == currentKLp))
764+ let userAddress = i.caller
765+ let txId = i.transactionId
766+ let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
767+ if (($t03172331853 == $t03172331853))
832768 then {
833- let userAddress = i.caller
834- let txId = i.transactionId
835- let $t03555035702 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
836- if (($t03555035702 == $t03555035702))
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))
837780 then {
838- let paymentInAmountAsset = $t03555035702._5
839- let bonus = $t03555035702._4
840- let feeAmount = $t03555035702._3
841- let commonState = $t03555035702._2
842- let emitAmountEstimated = $t03555035702._1
843- let emitAmount = if (if ((minOutAmount > 0))
844- then (minOutAmount > emitAmountEstimated)
845- else false)
846- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
847- else emitAmountEstimated
848- let emitInv = emit(emitAmount)
849- if ((emitInv == emitInv))
781+ let lpTransfer = if (autoStake)
850782 then {
851- let lpTransfer = if (autoStake)
852- then {
853- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
854- if ((stakeInv == stakeInv))
855- then nil
856- else throw("Strict value is not equal to itself.")
857- }
858- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
859- let sendFee = if ((feeAmount > 0))
860- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
861- else nil
862- let $t03628836485 = if ((this == feeCollectorAddress))
863- then $Tuple2(0, 0)
864- else if (paymentInAmountAsset)
865- then $Tuple2(-(feeAmount), 0)
866- else $Tuple2(0, -(feeAmount))
867- let amountAssetBalanceDelta = $t03628836485._1
868- let priceAssetBalanceDelta = $t03628836485._2
869- let $t03648836596 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
870- let refreshKLpActions = $t03648836596._1
871- let updatedKLp = $t03648836596._2
872- let kLp = value(getString(keyKLp))
873- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
874- if ((isUpdatedKLpValid == isUpdatedKLpValid))
875- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
783+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784+ if ((stakeInv == stakeInv))
785+ then nil
876786 else throw("Strict value is not equal to itself.")
877787 }
878- 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)
879793 }
880794 else throw("Strict value is not equal to itself.")
881795 }
888802
889803 @Callable(i)
890804 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
891- let $t03690237059 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
892- let emitAmountEstimated = $t03690237059._1
893- let commonState = $t03690237059._2
894- let feeAmount = $t03690237059._3
895- let bonus = $t03690237059._4
896- let paymentInAmountAsset = $t03690237059._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
897810 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
898811 }
899812
925838 let payment = i.payments[0]
926839 let paymentAssetId = payment.assetId
927840 let paymentAmount = payment.amount
928- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
929- 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))
930845 then {
931- let userAddress = i.caller
932- let txId = i.transactionId
933- let $t03794438097 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
934- if (($t03794438097 == $t03794438097))
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))
935857 then {
936- let outInAmountAsset = $t03794438097._5
937- let bonus = $t03794438097._4
938- let feeAmount = $t03794438097._3
939- let commonState = $t03794438097._2
940- let amountEstimated = $t03794438097._1
941- let amount = if (if ((minOutAmount > 0))
942- then (minOutAmount > amountEstimated)
943- else false)
944- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
945- else amountEstimated
946- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
947- if ((burnInv == burnInv))
948- then {
949- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
950- let sendFee = if ((feeAmount > 0))
951- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
952- else nil
953- let $t03859738844 = {
954- let feeAmountForCalc = if ((this == feeCollectorAddress))
955- then 0
956- else feeAmount
957- if (outInAmountAsset)
958- then $Tuple2(-((amount + feeAmountForCalc)), 0)
959- else $Tuple2(0, -((amount + feeAmountForCalc)))
960- }
961- let amountAssetBalanceDelta = $t03859738844._1
962- let priceAssetBalanceDelta = $t03859738844._2
963- let $t03884738955 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
964- let refreshKLpActions = $t03884738955._1
965- let updatedKLp = $t03884738955._2
966- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
967- if ((isUpdatedKLpValid == isUpdatedKLpValid))
968- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
969- else throw("Strict value is not equal to itself.")
970- }
971- else throw("Strict value is not equal to itself.")
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)
972863 }
973864 else throw("Strict value is not equal to itself.")
974865 }
981872
982873 @Callable(i)
983874 func getOneTknREADONLY (outAssetId,paymentAmount) = {
984- let $t03921239368 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
985- let amountEstimated = $t03921239368._1
986- let commonState = $t03921239368._2
987- let feeAmount = $t03921239368._3
988- let bonus = $t03921239368._4
989- let outInAmountAsset = $t03921239368._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
990880 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
991881 }
992882
1017907 let outAssetId = parseAssetId(outAssetIdStr)
1018908 let userAddress = i.caller
1019909 let txId = i.transactionId
1020- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1021910 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1022911 if ((unstakeInv == unstakeInv))
1023912 then {
1024- let $t04027040421 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1025- if (($t04027040421 == $t04027040421))
913+ let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914+ if (($t03525535388 == $t03525535388))
1026915 then {
1027- let outInAmountAsset = $t04027040421._5
1028- let bonus = $t04027040421._4
1029- let feeAmount = $t04027040421._3
1030- let commonState = $t04027040421._2
1031- let amountEstimated = $t04027040421._1
916+ let bonus = $t03525535388._4
917+ let feeAmount = $t03525535388._3
918+ let commonState = $t03525535388._2
919+ let amountEstimated = $t03525535388._1
1032920 let amount = if (if ((minOutAmount > 0))
1033921 then (minOutAmount > amountEstimated)
1034922 else false)
1041929 let sendFee = if ((feeAmount > 0))
1042930 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1043931 else nil
1044- let $t04091641163 = {
1045- let feeAmountForCalc = if ((this == feeCollectorAddress))
1046- then 0
1047- else feeAmount
1048- if (outInAmountAsset)
1049- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1050- else $Tuple2(0, -((amount + feeAmountForCalc)))
1051- }
1052- let amountAssetBalanceDelta = $t04091641163._1
1053- let priceAssetBalanceDelta = $t04091641163._2
1054- let $t04116641274 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1055- let refreshKLpActions = $t04116641274._1
1056- let updatedKLp = $t04116641274._2
1057- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1058- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1059- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1060- else throw("Strict value is not equal to itself.")
932+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1061933 }
1062934 else throw("Strict value is not equal to itself.")
1063935 }
1078950 let pmtAmt = res._3
1079951 let pmtAssetId = res._4
1080952 let state = res._5
1081- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1082- if ((currentKLp == currentKLp))
1083- then {
1084- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1085- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1086- then {
1087- let $t04222042302 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1088- let refreshKLpActions = $t04222042302._1
1089- let updatedKLp = $t04222042302._2
1090- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1091- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1092- then (state ++ refreshKLpActions)
1093- else throw("Strict value is not equal to itself.")
1094- }
1095- else throw("Strict value is not equal to itself.")
1096- }
953+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
954+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955+ then state
1097956 else throw("Strict value is not equal to itself.")
1098957 }
1099958
1112971 else if ((noLessThenPriceAsset > outPrAmt))
1113972 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1114973 else {
1115- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
1116974 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1117975 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1118- then {
1119- let $t04325343334 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1120- let refreshKLpActions = $t04325343334._1
1121- let updatedKLp = $t04325343334._2
1122- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1123- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1124- then (state ++ refreshKLpActions)
1125- else throw("Strict value is not equal to itself.")
1126- }
976+ then state
1127977 else throw("Strict value is not equal to itself.")
1128978 }
1129979 }
1139989 then {
1140990 let cfg = getPoolConfig()
1141991 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1142- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1143992 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1144993 if ((unstakeInv == unstakeInv))
1145994 then {
1146995 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1147- let outAmAmt = res._1
1148- let outPrAmt = res._2
1149996 let poolStatus = parseIntValue(res._9)
1150997 let state = res._10
1151998 let checkPoolStatus = if (if (isGlobalShutdown())
11571004 then {
11581005 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
11591006 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1160- then {
1161- let $t04445744538 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1162- let refreshKLpActions = $t04445744538._1
1163- let updatedKLp = $t04445744538._2
1164- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1165- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1166- then (state ++ refreshKLpActions)
1167- else throw("Strict value is not equal to itself.")
1168- }
1007+ then state
11691008 else throw("Strict value is not equal to itself.")
11701009 }
11711010 else throw("Strict value is not equal to itself.")
11891028 else throw("no payments are expected")]
11901029 if ((checks == checks))
11911030 then {
1192- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11931031 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11941032 if ((unstakeInv == unstakeInv))
11951033 then {
12061044 then {
12071045 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
12081046 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1209- then {
1210- let $t04583045911 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1211- let refreshKLpActions = $t04583045911._1
1212- let updatedKLp = $t04583045911._2
1213- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1214- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1215- then (state ++ refreshKLpActions)
1216- else throw("Strict value is not equal to itself.")
1217- }
1047+ then state
12181048 else throw("Strict value is not equal to itself.")
12191049 }
12201050 else throw("Strict value is not equal to itself.")
12301060 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12311061 then throw("permissions denied")
12321062 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1233-
1234-
1235-
1236-@Callable(i)
1237-func refreshKLp () = {
1238- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1239- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1240- then unit
1241- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1242- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1243- then {
1244- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1245- let $t04709847162 = refreshKLpInternal(0, 0, 0)
1246- let kLpUpdateActions = $t04709847162._1
1247- let updatedKLp = $t04709847162._2
1248- let actions = if ((kLp != updatedKLp))
1249- then kLpUpdateActions
1250- else throwErr("nothing to refresh")
1251- $Tuple2(actions, toString(updatedKLp))
1252- }
1253- else throw("Strict value is not equal to itself.")
1254- }
12551063
12561064
12571065
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], " "))
163144
164145
165-func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
166-
167-
168146 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
169147
170148 let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress))
149+
150+let inFee = {
151+ let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil)
152+ if ($isInstanceOf(@, "Int"))
153+ then @
154+ else throw(($getType(@) + " couldn't be cast to Int"))
155+ }
156+
157+let outFee = {
158+ let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil)
159+ if ($isInstanceOf(@, "Int"))
160+ then @
161+ else throw(($getType(@) + " couldn't be cast to Int"))
162+ }
171163
172164 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
173165
174166
175167 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
176168
177169
178170 func getPoolConfig () = {
179171 let amtAsset = getStringOrFail(this, aa())
180172 let priceAsset = getStringOrFail(this, pa())
181173 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
182174 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
183175 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
184176 }
185177
186178
187179 func parseAssetId (input) = if ((input == wavesString))
188180 then unit
189181 else fromBase58String(input)
190182
191183
192184 func assetIdToString (input) = if ((input == unit))
193185 then wavesString
194186 else toBase58String(value(input))
195187
196188
197189 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]))
198190
199191
200192 let poolConfigParsed = parsePoolConfig(getPoolConfig())
201193
202-let $t080588224 = poolConfigParsed
194+let $t076017767 = poolConfigParsed
203195
204-let cfgPoolAddress = $t080588224._1
196+let cfgPoolAddress = $t076017767._1
205197
206-let cfgPoolStatus = $t080588224._2
198+let cfgPoolStatus = $t076017767._2
207199
208-let cfgLpAssetId = $t080588224._3
200+let cfgLpAssetId = $t076017767._3
209201
210-let cfgAmountAssetId = $t080588224._4
202+let cfgAmountAssetId = $t076017767._4
211203
212-let cfgPriceAssetId = $t080588224._5
204+let cfgPriceAssetId = $t076017767._5
213205
214-let cfgAmountAssetDecimals = $t080588224._6
206+let cfgAmountAssetDecimals = $t076017767._6
215207
216-let cfgPriceAssetDecimals = $t080588224._7
208+let cfgPriceAssetDecimals = $t076017767._7
217209
218210 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
219211
220212
221213 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
222214
223215 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
224216
225217 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)
226218
227219
228220 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)
229221
230222
231223 func getAccBalance (assetId) = if ((assetId == "WAVES"))
232224 then wavesBalance(this).available
233225 else assetBalance(this, fromBase58String(assetId))
234226
235227
236228 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
237-
238-
239-func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
240229
241230
242231 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
243232 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
244233 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
245234 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
246235 }
247236
248237
249238 func calcPrices (amAmt,prAmt,lpAmt) = {
250239 let cfg = getPoolConfig()
251240 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
252241 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
253242 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
254243 let amAmtX18 = toX18(amAmt, amtAssetDcm)
255244 let prAmtX18 = toX18(prAmt, priceAssetDcm)
256245 let lpAmtX18 = toX18(lpAmt, scale8)
257246 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
258247 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
259248 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
260249 }
261250
262251
263252 func calculatePrices (amAmt,prAmt,lpAmt) = {
264253 let prices = calcPrices(amAmt, prAmt, lpAmt)
265254 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
266255 }
267256
268257
269258 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
270259 let cfg = getPoolConfig()
271260 let lpAssetId = cfg[idxPoolLPAssetId]
272261 let amAssetId = cfg[idxAmtAssetId]
273262 let prAssetId = cfg[idxPriceAssetId]
274263 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
275264 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
276265 let poolStatus = cfg[idxPoolStatus]
277266 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
278267 if ((lpAssetId != pmtAssetId))
279268 then throw("Invalid asset passed.")
280269 else {
281270 let amBalance = getAccBalance(amAssetId)
282271 let amBalanceX18 = toX18(amBalance, amAssetDcm)
283272 let prBalance = getAccBalance(prAssetId)
284273 let prBalanceX18 = toX18(prBalance, prAssetDcm)
285274 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
286275 let curPrice = fromX18(curPriceX18, scale8)
287276 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
288277 let lpEmissionX18 = toX18(lpEmission, scale8)
289278 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
290279 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
291- let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
292- let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
280+ let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281+ let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
293282 let state = if ((txId58 == ""))
294283 then nil
295284 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
296285 then unit
297286 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
298287 then unit
299288 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)]
300289 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
301290 }
302291 }
303292
304293
305294 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
306295 let cfg = getPoolConfig()
307296 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
308297 let amAssetIdStr = cfg[idxAmtAssetId]
309298 let prAssetIdStr = cfg[idxPriceAssetId]
310299 let iAmtAssetId = cfg[idxIAmtAssetId]
311300 let iPriceAssetId = cfg[idxIPriceAssetId]
312301 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
313302 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
314303 let poolStatus = cfg[idxPoolStatus]
315304 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
316305 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
317306 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
318307 if (if ((amAssetIdStr != inAmAssetIdStr))
319308 then true
320309 else (prAssetIdStr != inPrAssetIdStr))
321310 then throw("Invalid amt or price asset passed.")
322311 else {
323312 let amBalance = if (isEvaluate)
324313 then getAccBalance(amAssetIdStr)
325314 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
326315 let prBalance = if (isEvaluate)
327316 then getAccBalance(prAssetIdStr)
328317 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
329318 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
330319 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
331320 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
332321 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
333322 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
334323 let res = if ((lpEmission == 0))
335324 then {
336325 let curPriceX18 = zeroBigInt
337326 let slippageX18 = zeroBigInt
338327 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
339328 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
340329 }
341330 else {
342331 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
343332 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
344333 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
345334 if (if ((curPriceX18 != zeroBigInt))
346335 then (slippageX18 > slippageToleranceX18)
347336 else false)
348337 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
349338 else {
350339 let lpEmissionX18 = toX18(lpEmission, scale8)
351- let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
352- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
340+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
353342 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
354343 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
355344 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
356345 let expAmtAssetAmtX18 = expectedAmts._1
357346 let expPriceAssetAmtX18 = expectedAmts._2
358- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
359- $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
347+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348+ $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
360349 }
361350 }
362351 let calcLpAmt = res._1
363352 let calcAmAssetPmt = res._2
364353 let calcPrAssetPmt = res._3
365354 let curPrice = fromX18(res._4, scale8)
366355 let slippageCalc = fromX18(res._5, scale8)
367356 if ((0 >= calcLpAmt))
368357 then throw("Invalid calculations. LP calculated is less than zero.")
369358 else {
370359 let emitLpAmt = if (!(emitLp))
371360 then 0
372361 else calcLpAmt
373362 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
374363 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
375364 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))]
376365 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
377366 }
378367 }
379368 }
380369
381370
382-func calcKLp (amountBalance,priceBalance,lpEmission) = {
383- let updatedKLp = fraction(pow((amountBalance * priceBalance), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission)
384- if ((lpEmission == big0))
385- then big0
386- else updatedKLp
387- }
388-
389-
390-func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
391- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
392- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
393- let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
394- let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
395- currentKLp
396- }
397-
398-
399-func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
400- let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
401- let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
402- let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
403- let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
404- let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))]
405- $Tuple2(actions, updatedKLp)
406- }
407-
408-
409-func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp))
410- then true
411- else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " "))
412-
413-
414371 func validateMatcherOrderAllowed (order) = {
415- let amountAssetAmount = order.amount
416- let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
417- let $t02080121013 = if ((order.orderType == Buy))
418- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
419- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
420- let amountAssetBalanceDelta = $t02080121013._1
421- let priceAssetBalanceDelta = $t02080121013._2
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)
422384 if (if (if (isGlobalShutdown())
423385 then true
424- else (cfgPoolStatus == PoolMatcherDisabled))
386+ else (poolStatus == PoolMatcherDisabled))
425387 then true
426- else (cfgPoolStatus == PoolShutdown))
388+ else (poolStatus == PoolShutdown))
427389 then throw("Exchange operations disabled")
428- else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
429- then true
430- else (order.assetPair.priceAsset != cfgPriceAssetId))
431- then throw("Wrong order assets.")
432- else {
433- let kLp = valueOrErrorMessage(parseBigInt(valueOrErrorMessage(getString(this, keyKLp), fmtErr("kLp is required"))), fmtErr("invalid kLp"))
434- let $t02148421584 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
435- let unusedActions = $t02148421584._1
436- let kLpNew = $t02148421584._2
437- let isOrderValid = (kLpNew >= kLp)
438- isOrderValid
439- }
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+ }
440413 }
441414
442415
443416 func commonGet (i) = if ((size(i.payments) != 1))
444417 then throw("exactly 1 payment is expected")
445418 else {
446419 let pmt = value(i.payments[0])
447420 let pmtAssetId = value(pmt.assetId)
448421 let pmtAmt = pmt.amount
449422 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
450423 let outAmAmt = res._1
451424 let outPrAmt = res._2
452425 let poolStatus = parseIntValue(res._9)
453426 let state = res._10
454427 if (if (isGlobalShutdown())
455428 then true
456429 else (poolStatus == PoolShutdown))
457430 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
458431 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
459432 }
460433
461434
462435 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
463436 then throw("exactly 2 payments are expected")
464437 else {
465438 let amAssetPmt = value(i.payments[0])
466439 let prAssetPmt = value(i.payments[1])
467440 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
468441 let poolStatus = parseIntValue(estPut._8)
469442 if (if (if (isGlobalShutdown())
470443 then true
471444 else (poolStatus == PoolPutDisabled))
472445 then true
473446 else (poolStatus == PoolShutdown))
474447 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
475448 else estPut
476449 }
477450
478451
479452 func emit (amount) = {
480453 let emitInv = invoke(factoryContract, "emit", [amount], nil)
481454 if ((emitInv == emitInv))
482455 then {
483456 let emitInvLegacy = match emitInv {
484457 case legacyFactoryContract: Address =>
485458 invoke(legacyFactoryContract, "emit", [amount], nil)
486459 case _ =>
487460 unit
488461 }
489462 if ((emitInvLegacy == emitInvLegacy))
490463 then amount
491464 else throw("Strict value is not equal to itself.")
492465 }
493466 else throw("Strict value is not equal to itself.")
494467 }
495468
496469
497-func takeFee (amount) = {
498- let feeAmount = fraction(amount, fee, scale8)
470+func takeFee (amount,fee) = {
471+ let feeAmount = if ((fee == 0))
472+ then 0
473+ else fraction(amount, fee, scale8)
499474 $Tuple2((amount - feeAmount), feeAmount)
500475 }
501476
502477
503478 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
504479 let isEval = (txId == unit)
505480 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
506481 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
507482 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
508483 then true
509484 else if ((paymentAssetId == cfgPriceAssetId))
510485 then false
511486 else throwErr("invalid asset")
512- let $t02426924562 = if (isEval)
487+ let $t02266422957 = if (isEval)
513488 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
514489 else if (paymentInAmountAsset)
515490 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
516491 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
517- let amountBalanceOld = $t02426924562._1
518- let priceBalanceOld = $t02426924562._2
519- let $t02456624715 = if (paymentInAmountAsset)
492+ let amountBalanceOld = $t02266422957._1
493+ let priceBalanceOld = $t02266422957._2
494+ let $t02296123110 = if (paymentInAmountAsset)
520495 then $Tuple2(paymentAmountRaw, 0)
521496 else $Tuple2(0, paymentAmountRaw)
522- let amountAssetAmountRaw = $t02456624715._1
523- let priceAssetAmountRaw = $t02456624715._2
524- let amountAssetAmount = takeFee(amountAssetAmountRaw)._1
525- let priceAssetAmount = takeFee(priceAssetAmountRaw)._1
526- let $t02483724896 = takeFee(paymentAmountRaw)
527- let paymentAmount = $t02483724896._1
528- let feeAmount = $t02483724896._2
497+ let amountAssetAmountRaw = $t02296123110._1
498+ let priceAssetAmountRaw = $t02296123110._2
499+ let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1
500+ let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1
501+ let $t02324223306 = takeFee(paymentAmountRaw, inFee)
502+ let paymentAmount = $t02324223306._1
503+ let feeAmount = $t02324223306._2
529504 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
530505 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
531506 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
532507 let priceNew = fromX18(priceNewX18, scale8)
533508 let paymentBalance = if (paymentInAmountAsset)
534509 then amountBalanceOld
535510 else priceBalanceOld
536511 let paymentBalanceBigInt = toBigInt(paymentBalance)
537512 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
538513 let chechSupply = if ((supplyBigInt > big0))
539514 then true
540515 else throwErr("initial deposit requires all coins")
541516 if ((chechSupply == chechSupply))
542517 then {
543518 let depositBigInt = toBigInt(paymentAmount)
544- let issueAmount = max([0, fromX18Round(fraction(supplyBigInt, (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18), scale18), scale8, FLOOR)])
519+ let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
545520 let commonState = if (isEval)
546521 then nil
547522 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))]
548523 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
549524 let priceOld = fromX18(priceOldX18, scale8)
550525 let loss = {
551- let $t02639726564 = if (paymentInAmountAsset)
526+ let $t02478324950 = if (paymentInAmountAsset)
552527 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
553528 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
554- let amount = $t02639726564._1
555- let balance = $t02639726564._2
529+ let amount = $t02478324950._1
530+ let balance = $t02478324950._2
556531 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
557532 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
558533 }
559- $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
534+ $Tuple4(issueAmount, commonState, feeAmount, loss)
560535 }
561536 else throw("Strict value is not equal to itself.")
562537 }
563538
564539
565540 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
566541 let isEval = (txId == unit)
567- let cfg = getPoolConfig()
568- let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
569- let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
570542 let checks = [if ((paymentAssetId == cfgLpAssetId))
571543 then true
572544 else throwErr("invalid lp asset")]
573545 if ((checks == checks))
574546 then {
575547 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
576548 then true
577549 else if ((outAssetId == cfgPriceAssetId))
578550 then false
579551 else throwErr("invalid asset")
580552 let balanceBigInt = if (outInAmountAsset)
581553 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
582554 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
583- let outInAmountAssetDecimals = if (outInAmountAsset)
584- then amtAssetDcm
585- else priceAssetDcm
586555 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
587556 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
588557 let outBalance = if (outInAmountAsset)
589558 then amBalanceOld
590559 else prBalanceOld
591560 let outBalanceBigInt = toBigInt(outBalance)
592561 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
593562 let redeemedBigInt = toBigInt(paymentAmount)
594- let amountRaw = max([0, fromX18Round(fraction(balanceBigInt, (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN)), scale18), outInAmountAssetDecimals, FLOOR)])
595- let $t02846528515 = takeFee(amountRaw)
596- let totalAmount = $t02846528515._1
597- let feeAmount = $t02846528515._2
598- let $t02851928745 = if (outInAmountAsset)
563+ let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))])
564+ let $t02653026586 = takeFee(amountRaw, outFee)
565+ let totalAmount = $t02653026586._1
566+ let feeAmount = $t02653026586._2
567+ let $t02659026816 = if (outInAmountAsset)
599568 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
600569 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
601- let outAmAmount = $t02851928745._1
602- let outPrAmount = $t02851928745._2
603- let amBalanceNew = $t02851928745._3
604- let prBalanceNew = $t02851928745._4
570+ let outAmAmount = $t02659026816._1
571+ let outPrAmount = $t02659026816._2
572+ let amBalanceNew = $t02659026816._3
573+ let prBalanceNew = $t02659026816._4
605574 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
606575 let priceNew = fromX18(priceNewX18, scale8)
607576 let commonState = if (isEval)
608577 then nil
609578 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)]
610579 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
611580 let priceOld = fromX18(priceOldX18, scale8)
612581 let loss = {
613582 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
614583 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
615584 }
616- $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
585+ $Tuple4(totalAmount, commonState, feeAmount, loss)
617586 }
618587 else throw("Strict value is not equal to itself.")
619588 }
620589
621590
622591 func managerPublicKeyOrUnit () = match getString(mpk()) {
623592 case s: String =>
624593 fromBase58String(s)
625594 case _: Unit =>
626595 unit
627596 case _ =>
628597 throw("Match error")
629598 }
630599
631600
632601 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
633602 case s: String =>
634603 fromBase58String(s)
635604 case _: Unit =>
636605 unit
637606 case _ =>
638607 throw("Match error")
639608 }
640609
641610
642611 func isManager (i) = match managerPublicKeyOrUnit() {
643612 case pk: ByteVector =>
644613 (i.callerPublicKey == pk)
645614 case _: Unit =>
646615 (i.caller == this)
647616 case _ =>
648617 throw("Match error")
649618 }
650619
651620
652621 func mustManager (i) = {
653622 let pd = throw("Permission denied")
654623 match managerPublicKeyOrUnit() {
655624 case pk: ByteVector =>
656625 if ((i.callerPublicKey == pk))
657626 then true
658627 else pd
659628 case _: Unit =>
660629 if ((i.caller == this))
661630 then true
662631 else pd
663632 case _ =>
664633 throw("Match error")
665634 }
666635 }
667636
668637
669638 @Callable(i)
670639 func setManager (pendingManagerPublicKey) = {
671640 let checkCaller = mustManager(i)
672641 if ((checkCaller == checkCaller))
673642 then {
674643 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
675644 if ((checkManagerPublicKey == checkManagerPublicKey))
676645 then [StringEntry(pmpk(), pendingManagerPublicKey)]
677646 else throw("Strict value is not equal to itself.")
678647 }
679648 else throw("Strict value is not equal to itself.")
680649 }
681650
682651
683652
684653 @Callable(i)
685654 func confirmManager () = {
686655 let pm = pendingManagerPublicKeyOrUnit()
687656 let hasPM = if (isDefined(pm))
688657 then true
689658 else throw("No pending manager")
690659 if ((hasPM == hasPM))
691660 then {
692661 let checkPM = if ((i.callerPublicKey == value(pm)))
693662 then true
694663 else throw("You are not pending manager")
695664 if ((checkPM == checkPM))
696665 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
697666 else throw("Strict value is not equal to itself.")
698667 }
699668 else throw("Strict value is not equal to itself.")
700669 }
701670
702671
703672
704673 @Callable(i)
705674 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
706675 then throw("Invalid slippageTolerance passed")
707676 else {
708677 let estPut = commonPut(i, slippageTolerance, true)
709678 let emitLpAmt = estPut._2
710679 let lpAssetId = estPut._7
711680 let state = estPut._9
712681 let amDiff = estPut._10
713682 let prDiff = estPut._11
714683 let amId = estPut._12
715684 let prId = estPut._13
716- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
717- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
718- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
719- if ((currentKLp == currentKLp))
685+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686+ if ((emitInv == emitInv))
720687 then {
721- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
722- 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))
723695 then {
724- let emitInvLegacy = match emitInv {
725- case legacyFactoryContract: Address =>
726- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
727- case _ =>
728- unit
729- }
730- if ((emitInvLegacy == emitInvLegacy))
696+ let slippageAInv = if ((amDiff > 0))
697+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698+ else nil
699+ if ((slippageAInv == slippageAInv))
731700 then {
732- let slippageAInv = if ((amDiff > 0))
733- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
701+ let slippagePInv = if ((prDiff > 0))
702+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
734703 else nil
735- if ((slippageAInv == slippageAInv))
704+ if ((slippagePInv == slippagePInv))
736705 then {
737- let slippagePInv = if ((prDiff > 0))
738- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
739- else nil
740- if ((slippagePInv == slippagePInv))
706+ let lpTransfer = if (shouldAutoStake)
741707 then {
742- let lpTransfer = if (shouldAutoStake)
743- then {
744- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
745- if ((slpStakeInv == slpStakeInv))
746- then nil
747- else throw("Strict value is not equal to itself.")
748- }
749- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
750- let $t03327333735 = refreshKLpInternal(0, 0, 0)
751- if (($t03327333735 == $t03327333735))
752- then {
753- let updatedKLp = $t03327333735._2
754- let refreshKLpActions = $t03327333735._1
755- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
756- if ((isUpdatedKLpValid == isUpdatedKLpValid))
757- then ((state ++ lpTransfer) ++ refreshKLpActions)
758- else throw("Strict value is not equal to itself.")
759- }
708+ let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709+ if ((slpStakeInv == slpStakeInv))
710+ then nil
760711 else throw("Strict value is not equal to itself.")
761712 }
762- else throw("Strict value is not equal to itself.")
713+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714+ (state ++ lpTransfer)
763715 }
764716 else throw("Strict value is not equal to itself.")
765717 }
766718 else throw("Strict value is not equal to itself.")
767719 }
768720 else throw("Strict value is not equal to itself.")
769721 }
770722 else throw("Strict value is not equal to itself.")
771723 }
772724
773725
774726
775727 @Callable(i)
776728 func putForFree (maxSlippage) = if ((0 > maxSlippage))
777729 then throw("Invalid value passed")
778730 else {
779731 let estPut = commonPut(i, maxSlippage, false)
780- let state = estPut._9
781- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
782- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
783- let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0))
784- if ((currentKLp == currentKLp))
785- then {
786- let $t03429734362 = refreshKLpInternal(0, 0, 0)
787- let refreshKLpActions = $t03429734362._1
788- let updatedKLp = $t03429734362._2
789- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
790- if ((isUpdatedKLpValid == isUpdatedKLpValid))
791- then (state ++ refreshKLpActions)
792- else throw("Strict value is not equal to itself.")
793- }
794- else throw("Strict value is not equal to itself.")
732+ estPut._9
795733 }
796734
797735
798736
799737 @Callable(i)
800738 func putOneTkn (minOutAmount,autoStake) = {
801739 let isPoolOneTokenOperationsDisabled = {
802740 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
803741 if ($isInstanceOf(@, "Boolean"))
804742 then @
805743 else throw(($getType(@) + " couldn't be cast to Boolean"))
806744 }
807745 let isPutDisabled = if (if (if (isGlobalShutdown())
808746 then true
809747 else (cfgPoolStatus == PoolPutDisabled))
810748 then true
811749 else (cfgPoolStatus == PoolShutdown))
812750 then true
813751 else isPoolOneTokenOperationsDisabled
814752 let checks = [if (if (!(isPutDisabled))
815753 then true
816754 else isManager(i))
817755 then true
818756 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
819757 then true
820758 else throwErr("exactly 1 payment are expected")]
821759 if ((checks == checks))
822760 then {
823761 let payment = i.payments[0]
824762 let paymentAssetId = payment.assetId
825763 let paymentAmountRaw = payment.amount
826- let currentKLp = if ((paymentAssetId == cfgAmountAssetId))
827- then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0))
828- else if ((paymentAssetId == cfgPriceAssetId))
829- then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0))
830- else throwErr("payment asset is not supported")
831- if ((currentKLp == currentKLp))
764+ let userAddress = i.caller
765+ let txId = i.transactionId
766+ let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
767+ if (($t03172331853 == $t03172331853))
832768 then {
833- let userAddress = i.caller
834- let txId = i.transactionId
835- let $t03555035702 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
836- if (($t03555035702 == $t03555035702))
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))
837780 then {
838- let paymentInAmountAsset = $t03555035702._5
839- let bonus = $t03555035702._4
840- let feeAmount = $t03555035702._3
841- let commonState = $t03555035702._2
842- let emitAmountEstimated = $t03555035702._1
843- let emitAmount = if (if ((minOutAmount > 0))
844- then (minOutAmount > emitAmountEstimated)
845- else false)
846- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
847- else emitAmountEstimated
848- let emitInv = emit(emitAmount)
849- if ((emitInv == emitInv))
781+ let lpTransfer = if (autoStake)
850782 then {
851- let lpTransfer = if (autoStake)
852- then {
853- let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
854- if ((stakeInv == stakeInv))
855- then nil
856- else throw("Strict value is not equal to itself.")
857- }
858- else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
859- let sendFee = if ((feeAmount > 0))
860- then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
861- else nil
862- let $t03628836485 = if ((this == feeCollectorAddress))
863- then $Tuple2(0, 0)
864- else if (paymentInAmountAsset)
865- then $Tuple2(-(feeAmount), 0)
866- else $Tuple2(0, -(feeAmount))
867- let amountAssetBalanceDelta = $t03628836485._1
868- let priceAssetBalanceDelta = $t03628836485._2
869- let $t03648836596 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
870- let refreshKLpActions = $t03648836596._1
871- let updatedKLp = $t03648836596._2
872- let kLp = value(getString(keyKLp))
873- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
874- if ((isUpdatedKLpValid == isUpdatedKLpValid))
875- then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
783+ let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784+ if ((stakeInv == stakeInv))
785+ then nil
876786 else throw("Strict value is not equal to itself.")
877787 }
878- 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)
879793 }
880794 else throw("Strict value is not equal to itself.")
881795 }
882796 else throw("Strict value is not equal to itself.")
883797 }
884798 else throw("Strict value is not equal to itself.")
885799 }
886800
887801
888802
889803 @Callable(i)
890804 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
891- let $t03690237059 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
892- let emitAmountEstimated = $t03690237059._1
893- let commonState = $t03690237059._2
894- let feeAmount = $t03690237059._3
895- let bonus = $t03690237059._4
896- let paymentInAmountAsset = $t03690237059._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
897810 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
898811 }
899812
900813
901814
902815 @Callable(i)
903816 func getOneTkn (outAssetIdStr,minOutAmount) = {
904817 let isPoolOneTokenOperationsDisabled = {
905818 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
906819 if ($isInstanceOf(@, "Boolean"))
907820 then @
908821 else throw(($getType(@) + " couldn't be cast to Boolean"))
909822 }
910823 let isGetDisabled = if (if (isGlobalShutdown())
911824 then true
912825 else (cfgPoolStatus == PoolShutdown))
913826 then true
914827 else isPoolOneTokenOperationsDisabled
915828 let checks = [if (if (!(isGetDisabled))
916829 then true
917830 else isManager(i))
918831 then true
919832 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
920833 then true
921834 else throwErr("exactly 1 payment are expected")]
922835 if ((checks == checks))
923836 then {
924837 let outAssetId = parseAssetId(outAssetIdStr)
925838 let payment = i.payments[0]
926839 let paymentAssetId = payment.assetId
927840 let paymentAmount = payment.amount
928- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
929- 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))
930845 then {
931- let userAddress = i.caller
932- let txId = i.transactionId
933- let $t03794438097 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
934- if (($t03794438097 == $t03794438097))
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))
935857 then {
936- let outInAmountAsset = $t03794438097._5
937- let bonus = $t03794438097._4
938- let feeAmount = $t03794438097._3
939- let commonState = $t03794438097._2
940- let amountEstimated = $t03794438097._1
941- let amount = if (if ((minOutAmount > 0))
942- then (minOutAmount > amountEstimated)
943- else false)
944- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
945- else amountEstimated
946- let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
947- if ((burnInv == burnInv))
948- then {
949- let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
950- let sendFee = if ((feeAmount > 0))
951- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
952- else nil
953- let $t03859738844 = {
954- let feeAmountForCalc = if ((this == feeCollectorAddress))
955- then 0
956- else feeAmount
957- if (outInAmountAsset)
958- then $Tuple2(-((amount + feeAmountForCalc)), 0)
959- else $Tuple2(0, -((amount + feeAmountForCalc)))
960- }
961- let amountAssetBalanceDelta = $t03859738844._1
962- let priceAssetBalanceDelta = $t03859738844._2
963- let $t03884738955 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
964- let refreshKLpActions = $t03884738955._1
965- let updatedKLp = $t03884738955._2
966- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
967- if ((isUpdatedKLpValid == isUpdatedKLpValid))
968- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
969- else throw("Strict value is not equal to itself.")
970- }
971- else throw("Strict value is not equal to itself.")
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)
972863 }
973864 else throw("Strict value is not equal to itself.")
974865 }
975866 else throw("Strict value is not equal to itself.")
976867 }
977868 else throw("Strict value is not equal to itself.")
978869 }
979870
980871
981872
982873 @Callable(i)
983874 func getOneTknREADONLY (outAssetId,paymentAmount) = {
984- let $t03921239368 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
985- let amountEstimated = $t03921239368._1
986- let commonState = $t03921239368._2
987- let feeAmount = $t03921239368._3
988- let bonus = $t03921239368._4
989- let outInAmountAsset = $t03921239368._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
990880 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
991881 }
992882
993883
994884
995885 @Callable(i)
996886 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
997887 let isPoolOneTokenOperationsDisabled = {
998888 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
999889 if ($isInstanceOf(@, "Boolean"))
1000890 then @
1001891 else throw(($getType(@) + " couldn't be cast to Boolean"))
1002892 }
1003893 let isGetDisabled = if (if (isGlobalShutdown())
1004894 then true
1005895 else (cfgPoolStatus == PoolShutdown))
1006896 then true
1007897 else isPoolOneTokenOperationsDisabled
1008898 let checks = [if (if (!(isGetDisabled))
1009899 then true
1010900 else isManager(i))
1011901 then true
1012902 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
1013903 then true
1014904 else throwErr("no payments are expected")]
1015905 if ((checks == checks))
1016906 then {
1017907 let outAssetId = parseAssetId(outAssetIdStr)
1018908 let userAddress = i.caller
1019909 let txId = i.transactionId
1020- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1021910 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1022911 if ((unstakeInv == unstakeInv))
1023912 then {
1024- let $t04027040421 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1025- if (($t04027040421 == $t04027040421))
913+ let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914+ if (($t03525535388 == $t03525535388))
1026915 then {
1027- let outInAmountAsset = $t04027040421._5
1028- let bonus = $t04027040421._4
1029- let feeAmount = $t04027040421._3
1030- let commonState = $t04027040421._2
1031- let amountEstimated = $t04027040421._1
916+ let bonus = $t03525535388._4
917+ let feeAmount = $t03525535388._3
918+ let commonState = $t03525535388._2
919+ let amountEstimated = $t03525535388._1
1032920 let amount = if (if ((minOutAmount > 0))
1033921 then (minOutAmount > amountEstimated)
1034922 else false)
1035923 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1036924 else amountEstimated
1037925 let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1038926 if ((burnInv == burnInv))
1039927 then {
1040928 let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
1041929 let sendFee = if ((feeAmount > 0))
1042930 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
1043931 else nil
1044- let $t04091641163 = {
1045- let feeAmountForCalc = if ((this == feeCollectorAddress))
1046- then 0
1047- else feeAmount
1048- if (outInAmountAsset)
1049- then $Tuple2(-((amount + feeAmountForCalc)), 0)
1050- else $Tuple2(0, -((amount + feeAmountForCalc)))
1051- }
1052- let amountAssetBalanceDelta = $t04091641163._1
1053- let priceAssetBalanceDelta = $t04091641163._2
1054- let $t04116641274 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1055- let refreshKLpActions = $t04116641274._1
1056- let updatedKLp = $t04116641274._2
1057- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1058- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1059- then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1060- else throw("Strict value is not equal to itself.")
932+ $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1061933 }
1062934 else throw("Strict value is not equal to itself.")
1063935 }
1064936 else throw("Strict value is not equal to itself.")
1065937 }
1066938 else throw("Strict value is not equal to itself.")
1067939 }
1068940 else throw("Strict value is not equal to itself.")
1069941 }
1070942
1071943
1072944
1073945 @Callable(i)
1074946 func get () = {
1075947 let res = commonGet(i)
1076948 let outAmtAmt = res._1
1077949 let outPrAmt = res._2
1078950 let pmtAmt = res._3
1079951 let pmtAssetId = res._4
1080952 let state = res._5
1081- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1082- if ((currentKLp == currentKLp))
1083- then {
1084- let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1085- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1086- then {
1087- let $t04222042302 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1088- let refreshKLpActions = $t04222042302._1
1089- let updatedKLp = $t04222042302._2
1090- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1091- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1092- then (state ++ refreshKLpActions)
1093- else throw("Strict value is not equal to itself.")
1094- }
1095- else throw("Strict value is not equal to itself.")
1096- }
953+ let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
954+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955+ then state
1097956 else throw("Strict value is not equal to itself.")
1098957 }
1099958
1100959
1101960
1102961 @Callable(i)
1103962 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
1104963 let res = commonGet(i)
1105964 let outAmAmt = res._1
1106965 let outPrAmt = res._2
1107966 let pmtAmt = res._3
1108967 let pmtAssetId = res._4
1109968 let state = res._5
1110969 if ((noLessThenAmtAsset > outAmAmt))
1111970 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
1112971 else if ((noLessThenPriceAsset > outPrAmt))
1113972 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
1114973 else {
1115- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
1116974 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1117975 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1118- then {
1119- let $t04325343334 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1120- let refreshKLpActions = $t04325343334._1
1121- let updatedKLp = $t04325343334._2
1122- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1123- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1124- then (state ++ refreshKLpActions)
1125- else throw("Strict value is not equal to itself.")
1126- }
976+ then state
1127977 else throw("Strict value is not equal to itself.")
1128978 }
1129979 }
1130980
1131981
1132982
1133983 @Callable(i)
1134984 func unstakeAndGet (amount) = {
1135985 let checkPayments = if ((size(i.payments) != 0))
1136986 then throw("No payments are expected")
1137987 else true
1138988 if ((checkPayments == checkPayments))
1139989 then {
1140990 let cfg = getPoolConfig()
1141991 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1142- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
1143992 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
1144993 if ((unstakeInv == unstakeInv))
1145994 then {
1146995 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1147- let outAmAmt = res._1
1148- let outPrAmt = res._2
1149996 let poolStatus = parseIntValue(res._9)
1150997 let state = res._10
1151998 let checkPoolStatus = if (if (isGlobalShutdown())
1152999 then true
11531000 else (poolStatus == PoolShutdown))
11541001 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
11551002 else true
11561003 if ((checkPoolStatus == checkPoolStatus))
11571004 then {
11581005 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
11591006 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1160- then {
1161- let $t04445744538 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1162- let refreshKLpActions = $t04445744538._1
1163- let updatedKLp = $t04445744538._2
1164- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1165- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1166- then (state ++ refreshKLpActions)
1167- else throw("Strict value is not equal to itself.")
1168- }
1007+ then state
11691008 else throw("Strict value is not equal to itself.")
11701009 }
11711010 else throw("Strict value is not equal to itself.")
11721011 }
11731012 else throw("Strict value is not equal to itself.")
11741013 }
11751014 else throw("Strict value is not equal to itself.")
11761015 }
11771016
11781017
11791018
11801019 @Callable(i)
11811020 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
11821021 let isGetDisabled = if (isGlobalShutdown())
11831022 then true
11841023 else (cfgPoolStatus == PoolShutdown)
11851024 let checks = [if (!(isGetDisabled))
11861025 then true
11871026 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
11881027 then true
11891028 else throw("no payments are expected")]
11901029 if ((checks == checks))
11911030 then {
1192- let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
11931031 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
11941032 if ((unstakeInv == unstakeInv))
11951033 then {
11961034 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
11971035 let outAmAmt = res._1
11981036 let outPrAmt = res._2
11991037 let state = res._10
12001038 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
12011039 then true
12021040 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
12031041 then true
12041042 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
12051043 if ((checkAmounts == checkAmounts))
12061044 then {
12071045 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
12081046 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1209- then {
1210- let $t04583045911 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1211- let refreshKLpActions = $t04583045911._1
1212- let updatedKLp = $t04583045911._2
1213- let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1214- if ((isUpdatedKLpValid == isUpdatedKLpValid))
1215- then (state ++ refreshKLpActions)
1216- else throw("Strict value is not equal to itself.")
1217- }
1047+ then state
12181048 else throw("Strict value is not equal to itself.")
12191049 }
12201050 else throw("Strict value is not equal to itself.")
12211051 }
12221052 else throw("Strict value is not equal to itself.")
12231053 }
12241054 else throw("Strict value is not equal to itself.")
12251055 }
12261056
12271057
12281058
12291059 @Callable(i)
12301060 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
12311061 then throw("permissions denied")
12321062 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1233-
1234-
1235-
1236-@Callable(i)
1237-func refreshKLp () = {
1238- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1239- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1240- then unit
1241- else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1242- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1243- then {
1244- let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1245- let $t04709847162 = refreshKLpInternal(0, 0, 0)
1246- let kLpUpdateActions = $t04709847162._1
1247- let updatedKLp = $t04709847162._2
1248- let actions = if ((kLp != updatedKLp))
1249- then kLpUpdateActions
1250- else throwErr("nothing to refresh")
1251- $Tuple2(actions, toString(updatedKLp))
1252- }
1253- else throw("Strict value is not equal to itself.")
1254- }
12551063
12561064
12571065
12581066 @Callable(i)
12591067 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
12601068
12611069
12621070
12631071 @Callable(i)
12641072 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
12651073
12661074
12671075
12681076 @Callable(i)
12691077 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
12701078 let prices = calcPrices(amAmt, prAmt, lpAmt)
12711079 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
12721080 }
12731081
12741082
12751083
12761084 @Callable(i)
12771085 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
12781086
12791087
12801088
12811089 @Callable(i)
12821090 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
12831091
12841092
12851093
12861094 @Callable(i)
12871095 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
12881096
12891097
12901098
12911099 @Callable(i)
12921100 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
12931101
12941102
12951103
12961104 @Callable(i)
12971105 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
12981106 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
12991107 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
13001108 }
13011109
13021110
13031111
13041112 @Callable(i)
13051113 func statsREADONLY () = {
13061114 let cfg = getPoolConfig()
13071115 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13081116 let amtAssetId = cfg[idxAmtAssetId]
13091117 let priceAssetId = cfg[idxPriceAssetId]
13101118 let iAmtAssetId = cfg[idxIAmtAssetId]
13111119 let iPriceAssetId = cfg[idxIPriceAssetId]
13121120 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13131121 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13141122 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13151123 let accAmtAssetBalance = getAccBalance(amtAssetId)
13161124 let accPriceAssetBalance = getAccBalance(priceAssetId)
13171125 let pricesList = if ((poolLPBalance == 0))
13181126 then [zeroBigInt, zeroBigInt, zeroBigInt]
13191127 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
13201128 let curPrice = 0
13211129 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
13221130 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
13231131 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
13241132 $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))
13251133 }
13261134
13271135
13281136
13291137 @Callable(i)
13301138 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
13311139 let cfg = getPoolConfig()
13321140 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13331141 let amAssetIdStr = cfg[idxAmtAssetId]
13341142 let amAssetId = fromBase58String(amAssetIdStr)
13351143 let prAssetIdStr = cfg[idxPriceAssetId]
13361144 let prAssetId = fromBase58String(prAssetIdStr)
13371145 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13381146 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13391147 let poolStatus = cfg[idxPoolStatus]
13401148 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13411149 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
13421150 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
13431151 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
13441152 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
13451153 let curPriceX18 = if ((poolLPBalance == 0))
13461154 then zeroBigInt
13471155 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
13481156 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
13491157 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
13501158 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
13511159 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
13521160 let calcLpAmt = estPut._1
13531161 let curPriceCalc = estPut._3
13541162 let amBalance = estPut._4
13551163 let prBalance = estPut._5
13561164 let lpEmission = estPut._6
13571165 $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))
13581166 }
13591167
13601168
13611169
13621170 @Callable(i)
13631171 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
13641172 let cfg = getPoolConfig()
13651173 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
13661174 let amAssetIdStr = cfg[idxAmtAssetId]
13671175 let amAssetId = fromBase58String(amAssetIdStr)
13681176 let prAssetIdStr = cfg[idxPriceAssetId]
13691177 let prAssetId = fromBase58String(prAssetIdStr)
13701178 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
13711179 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
13721180 let poolStatus = cfg[idxPoolStatus]
13731181 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
13741182 let amBalanceRaw = getAccBalance(amAssetIdStr)
13751183 let prBalanceRaw = getAccBalance(prAssetIdStr)
13761184 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
13771185 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
13781186 let curPriceX18 = if ((poolLPBalance == 0))
13791187 then zeroBigInt
13801188 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
13811189 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
13821190 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
13831191 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
13841192 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
13851193 let calcLpAmt = estPut._1
13861194 let curPriceCalc = estPut._3
13871195 let amBalance = estPut._4
13881196 let prBalance = estPut._5
13891197 let lpEmission = estPut._6
13901198 $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))
13911199 }
13921200
13931201
13941202
13951203 @Callable(i)
13961204 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
13971205 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
13981206 let outAmAmt = res._1
13991207 let outPrAmt = res._2
14001208 let amBalance = res._5
14011209 let prBalance = res._6
14021210 let lpEmission = res._7
14031211 let curPrice = res._8
14041212 let poolStatus = parseIntValue(res._9)
14051213 $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))
14061214 }
14071215
14081216
14091217 @Verifier(tx)
14101218 func verify () = {
14111219 let targetPublicKey = match managerPublicKeyOrUnit() {
14121220 case pk: ByteVector =>
14131221 pk
14141222 case _: Unit =>
14151223 tx.senderPublicKey
14161224 case _ =>
14171225 throw("Match error")
14181226 }
14191227 match tx {
14201228 case order: Order =>
14211229 let matcherPub = getMatcherPubOrFail()
14221230 let orderValid = validateMatcherOrderAllowed(order)
14231231 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
14241232 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
14251233 if (if (if (orderValid)
14261234 then senderValid
14271235 else false)
14281236 then matcherValid
14291237 else false)
14301238 then true
14311239 else throwOrderError(orderValid, senderValid, matcherValid)
14321240 case s: SetScriptTransaction =>
14331241 let newHash = blake2b256(value(s.script))
14341242 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
14351243 let currentHash = scriptHash(this)
14361244 if (if ((allowedHash == newHash))
14371245 then (currentHash != newHash)
14381246 else false)
14391247 then true
14401248 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14411249 case _ =>
14421250 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
14431251 }
14441252 }
14451253

github/deemru/w8io/026f985 
180.27 ms