tx · 4F6gaEjzJwnbH6RunRAXrup6Zc8mBMLYCE2zwAC8hSKn

3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn:  -0.03500000 Waves

2022.12.16 09:27 [2362492] smart account 3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn > SELF 0.00000000 Waves

{ "type": 13, "id": "4F6gaEjzJwnbH6RunRAXrup6Zc8mBMLYCE2zwAC8hSKn", "fee": 3500000, "feeAssetId": null, "timestamp": 1671172028465, "version": 1, "sender": "3N55kCyUFy8M2ooKRwierKnP7L6viqzScNn", "senderPublicKey": "HpuFV1RhaXZ5gaJNgeLjyAKy3D5q7fMKdNFYYbPDafnb", "proofs": [ "4vQzHxpc8UXX15b7VWjT2vm7MBpBqfSn9PTQ2Ufr5GUohwqENbzyGLWW3tj51gnsQZqumTU8aRW3ViFTcciF5EkF" ], "script": "base64:BgKdLQgCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZX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JjZgkAzAgCCQCkAwEFAmNoCQDMCAIJAKQDAQUCY2UJAMwIAgkApgMBBQJjawkAzAgCCQCkAwEFAmNkBQNuaWwFAWoBAmdCAQJnQwAEAmdEBAJkTgkBAmVRAAMJAAECBQJkTgIKQnl0ZVZlY3RvcgQCZVUFAmROBQJlVQMJAAECBQJkTgIEVW5pdAgFAmdCD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yBAJkTgUCZ0IDCQABAgUCZE4CBU9yZGVyBAJkcwUCZE4EAmdFCQECYU8ABAJhQgkBAmRyAQUCZHMEAmFDCQD0AwMIBQJkcwlib2R5Qnl0ZXMJAJEDAggFAmRzBnByb29mcwAACAUCZHMPc2VuZGVyUHVibGljS2V5BAJhRAkA9AMDCAUCZHMJYm9keUJ5dGVzCQCRAwIIBQJkcwZwcm9vZnMAAQUCZ0UDAwMFAmFCBQJhQwcFAmFEBwYJAQJhQQMFAmFCBQJhQwUCYUQDCQABAgUCZE4CFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJlUgUCZE4EAmdGCQD2AwEJAQV2YWx1ZQEIBQJlUgZzY3JpcHQEAmdHCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYUwJAQJheQAEAmdICQDxBwEFBHRoaXMDAwkAAAIFAmdHBQJnRgkBAiE9AgUCZ0gFAmdGBwYJAPQDAwgFAmdCCWJvZHlCeXRlcwkAkQMCCAUCZ0IGcHJvb2ZzAAAFAmdECQD0AwMIBQJnQglib2R5Qnl0ZXMJAJEDAggFAmdCBnByb29mcwAABQJnRE1P6gM=", "chainId": 84, "height": 2362492, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5Nbfjx2SUo9z3eMPUXPhEUQQtRY4hsKenUxvmk1ZPvsY Next: FyPDuShMpw6erGAAKPZBZkKSrg4G2nxUK6qBYq4eUaWi 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+
6871 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6972
7073
105108 func pa () = "%s__priceAsset"
106109
107110
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+
108127 func keyFactoryConfig () = "%s__factoryConfig"
109128
110129
143162 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
144163
145164
165+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
166+
167+
146168 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
147169
148170 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- }
163171
164172 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
165173
191199
192200 let poolConfigParsed = parsePoolConfig(getPoolConfig())
193201
194-let $t076017767 = poolConfigParsed
202+let $t080588224 = poolConfigParsed
195203
196-let cfgPoolAddress = $t076017767._1
204+let cfgPoolAddress = $t080588224._1
197205
198-let cfgPoolStatus = $t076017767._2
206+let cfgPoolStatus = $t080588224._2
199207
200-let cfgLpAssetId = $t076017767._3
208+let cfgLpAssetId = $t080588224._3
201209
202-let cfgAmountAssetId = $t076017767._4
210+let cfgAmountAssetId = $t080588224._4
203211
204-let cfgPriceAssetId = $t076017767._5
212+let cfgPriceAssetId = $t080588224._5
205213
206-let cfgAmountAssetDecimals = $t076017767._6
214+let cfgAmountAssetDecimals = $t080588224._6
207215
208-let cfgPriceAssetDecimals = $t076017767._7
216+let cfgPriceAssetDecimals = $t080588224._7
209217
210218 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
211219
226234
227235
228236 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
237+
238+
239+func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
229240
230241
231242 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
277288 let lpEmissionX18 = toX18(lpEmission, scale8)
278289 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
279290 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
280- let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281- let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
291+ let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
292+ let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
282293 let state = if ((txId58 == ""))
283294 then nil
284295 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
337348 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
338349 else {
339350 let lpEmissionX18 = toX18(lpEmission, scale8)
340- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
351+ let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
352+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
342353 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
343354 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
344355 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
345356 let expAmtAssetAmtX18 = expectedAmts._1
346357 let expPriceAssetAmtX18 = expectedAmts._2
347- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348- $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
358+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
359+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
349360 }
350361 }
351362 let calcLpAmt = res._1
368379 }
369380
370381
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+
371414 func validateMatcherOrderAllowed (order) = {
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)
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
384422 if (if (if (isGlobalShutdown())
385423 then true
386- else (poolStatus == PoolMatcherDisabled))
424+ else (cfgPoolStatus == PoolMatcherDisabled))
387425 then true
388- else (poolStatus == PoolShutdown))
426+ else (cfgPoolStatus == PoolShutdown))
389427 then throw("Exchange operations disabled")
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- }
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+ }
413440 }
414441
415442
467494 }
468495
469496
470-func takeFee (amount,fee) = {
471- let feeAmount = if ((fee == 0))
472- then 0
473- else fraction(amount, fee, scale8)
497+func takeFee (amount) = {
498+ let feeAmount = fraction(amount, fee, scale8)
474499 $Tuple2((amount - feeAmount), feeAmount)
475500 }
476501
484509 else if ((paymentAssetId == cfgPriceAssetId))
485510 then false
486511 else throwErr("invalid asset")
487- let $t02266422957 = if (isEval)
512+ let $t02426924562 = if (isEval)
488513 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
489514 else if (paymentInAmountAsset)
490515 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
491516 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
492- let amountBalanceOld = $t02266422957._1
493- let priceBalanceOld = $t02266422957._2
494- let $t02296123110 = if (paymentInAmountAsset)
517+ let amountBalanceOld = $t02426924562._1
518+ let priceBalanceOld = $t02426924562._2
519+ let $t02456624715 = if (paymentInAmountAsset)
495520 then $Tuple2(paymentAmountRaw, 0)
496521 else $Tuple2(0, paymentAmountRaw)
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
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
504529 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
505530 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
506531 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
516541 if ((chechSupply == chechSupply))
517542 then {
518543 let depositBigInt = toBigInt(paymentAmount)
519- let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
544+ let issueAmount = max([0, fromX18Round(fraction(supplyBigInt, (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18), scale18), scale8, FLOOR)])
520545 let commonState = if (isEval)
521546 then nil
522547 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))]
523548 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
524549 let priceOld = fromX18(priceOldX18, scale8)
525550 let loss = {
526- let $t02478324950 = if (paymentInAmountAsset)
551+ let $t02639726564 = if (paymentInAmountAsset)
527552 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
528553 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
529- let amount = $t02478324950._1
530- let balance = $t02478324950._2
554+ let amount = $t02639726564._1
555+ let balance = $t02639726564._2
531556 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
532557 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
533558 }
534- $Tuple4(issueAmount, commonState, feeAmount, loss)
559+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
535560 }
536561 else throw("Strict value is not equal to itself.")
537562 }
539564
540565 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
541566 let isEval = (txId == unit)
567+ let cfg = getPoolConfig()
568+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
569+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
542570 let checks = [if ((paymentAssetId == cfgLpAssetId))
543571 then true
544572 else throwErr("invalid lp asset")]
552580 let balanceBigInt = if (outInAmountAsset)
553581 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
554582 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
583+ let outInAmountAssetDecimals = if (outInAmountAsset)
584+ then amtAssetDcm
585+ else priceAssetDcm
555586 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
556587 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
557588 let outBalance = if (outInAmountAsset)
560591 let outBalanceBigInt = toBigInt(outBalance)
561592 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
562593 let redeemedBigInt = toBigInt(paymentAmount)
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)
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)
568599 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
569600 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
570- let outAmAmount = $t02659026816._1
571- let outPrAmount = $t02659026816._2
572- let amBalanceNew = $t02659026816._3
573- let prBalanceNew = $t02659026816._4
601+ let outAmAmount = $t02851928745._1
602+ let outPrAmount = $t02851928745._2
603+ let amBalanceNew = $t02851928745._3
604+ let prBalanceNew = $t02851928745._4
574605 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
575606 let priceNew = fromX18(priceNewX18, scale8)
576607 let commonState = if (isEval)
582613 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
583614 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
584615 }
585- $Tuple4(totalAmount, commonState, feeAmount, loss)
616+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
586617 }
587618 else throw("Strict value is not equal to itself.")
588619 }
682713 let prDiff = estPut._11
683714 let amId = estPut._12
684715 let prId = estPut._13
685- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686- if ((emitInv == emitInv))
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))
687720 then {
688- let emitInvLegacy = match emitInv {
689- case legacyFactoryContract: Address =>
690- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
691- case _ =>
692- unit
693- }
694- if ((emitInvLegacy == emitInvLegacy))
721+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
722+ if ((emitInv == emitInv))
695723 then {
696- let slippageAInv = if ((amDiff > 0))
697- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698- else nil
699- if ((slippageAInv == slippageAInv))
724+ let emitInvLegacy = match emitInv {
725+ case legacyFactoryContract: Address =>
726+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
727+ case _ =>
728+ unit
729+ }
730+ if ((emitInvLegacy == emitInvLegacy))
700731 then {
701- let slippagePInv = if ((prDiff > 0))
702- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
732+ let slippageAInv = if ((amDiff > 0))
733+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
703734 else nil
704- if ((slippagePInv == slippagePInv))
735+ if ((slippageAInv == slippageAInv))
705736 then {
706- let lpTransfer = if (shouldAutoStake)
737+ let slippagePInv = if ((prDiff > 0))
738+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
739+ else nil
740+ if ((slippagePInv == slippagePInv))
707741 then {
708- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709- if ((slpStakeInv == slpStakeInv))
710- then nil
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+ }
711760 else throw("Strict value is not equal to itself.")
712761 }
713- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714- (state ++ lpTransfer)
762+ else throw("Strict value is not equal to itself.")
715763 }
716764 else throw("Strict value is not equal to itself.")
717765 }
729777 then throw("Invalid value passed")
730778 else {
731779 let estPut = commonPut(i, maxSlippage, false)
732- estPut._9
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.")
733795 }
734796
735797
761823 let payment = i.payments[0]
762824 let paymentAssetId = payment.assetId
763825 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")
764831 let userAddress = i.caller
765832 let txId = i.transactionId
766- let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
767- if (($t03172331853 == $t03172331853))
833+ let $t03554735699 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
834+ if (($t03554735699 == $t03554735699))
768835 then {
769- let bonus = $t03172331853._4
770- let feeAmount = $t03172331853._3
771- let commonState = $t03172331853._2
772- let emitAmountEstimated = $t03172331853._1
836+ let paymentInAmountAsset = $t03554735699._5
837+ let bonus = $t03554735699._4
838+ let feeAmount = $t03554735699._3
839+ let commonState = $t03554735699._2
840+ let emitAmountEstimated = $t03554735699._1
773841 let emitAmount = if (if ((minOutAmount > 0))
774842 then (minOutAmount > emitAmountEstimated)
775843 else false)
789857 let sendFee = if ((feeAmount > 0))
790858 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
791859 else nil
792- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
860+ let $t03628536482 = if ((this == feeCollectorAddress))
861+ then $Tuple2(0, 0)
862+ else if (paymentInAmountAsset)
863+ then $Tuple2(-(feeAmount), 0)
864+ else $Tuple2(0, -(feeAmount))
865+ let amountAssetBalanceDelta = $t03628536482._1
866+ let priceAssetBalanceDelta = $t03628536482._2
867+ let $t03648536593 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
868+ let refreshKLpActions = $t03648536593._1
869+ let updatedKLp = $t03648536593._2
870+ let kLp = value(getString(keyKLp))
871+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
872+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
873+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
874+ else throw("Strict value is not equal to itself.")
793875 }
794876 else throw("Strict value is not equal to itself.")
795877 }
802884
803885 @Callable(i)
804886 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
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
887+ let $t03689937056 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
888+ let emitAmountEstimated = $t03689937056._1
889+ let commonState = $t03689937056._2
890+ let feeAmount = $t03689937056._3
891+ let bonus = $t03689937056._4
892+ let paymentInAmountAsset = $t03689937056._5
810893 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
811894 }
812895
838921 let payment = i.payments[0]
839922 let paymentAssetId = payment.assetId
840923 let paymentAmount = payment.amount
924+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount))
841925 let userAddress = i.caller
842926 let txId = i.transactionId
843- let $t03352233657 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
844- if (($t03352233657 == $t03352233657))
927+ let $t03795038103 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
928+ if (($t03795038103 == $t03795038103))
845929 then {
846- let bonus = $t03352233657._4
847- let feeAmount = $t03352233657._3
848- let commonState = $t03352233657._2
849- let amountEstimated = $t03352233657._1
930+ let outInAmountAsset = $t03795038103._5
931+ let bonus = $t03795038103._4
932+ let feeAmount = $t03795038103._3
933+ let commonState = $t03795038103._2
934+ let amountEstimated = $t03795038103._1
850935 let amount = if (if ((minOutAmount > 0))
851936 then (minOutAmount > amountEstimated)
852937 else false)
859944 let sendFee = if ((feeAmount > 0))
860945 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
861946 else nil
862- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
947+ let $t03860338850 = {
948+ let feeAmountForCalc = if ((this == feeCollectorAddress))
949+ then 0
950+ else feeAmount
951+ if (outInAmountAsset)
952+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
953+ else $Tuple2(0, -((amount + feeAmountForCalc)))
954+ }
955+ let amountAssetBalanceDelta = $t03860338850._1
956+ let priceAssetBalanceDelta = $t03860338850._2
957+ let $t03885338961 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
958+ let refreshKLpActions = $t03885338961._1
959+ let updatedKLp = $t03885338961._2
960+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
961+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
962+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
963+ else throw("Strict value is not equal to itself.")
863964 }
864965 else throw("Strict value is not equal to itself.")
865966 }
872973
873974 @Callable(i)
874975 func getOneTknREADONLY (outAssetId,paymentAmount) = {
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
976+ let $t03921839374 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
977+ let amountEstimated = $t03921839374._1
978+ let commonState = $t03921839374._2
979+ let feeAmount = $t03921839374._3
980+ let bonus = $t03921839374._4
981+ let outInAmountAsset = $t03921839374._5
880982 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
881983 }
882984
9071009 let outAssetId = parseAssetId(outAssetIdStr)
9081010 let userAddress = i.caller
9091011 let txId = i.transactionId
1012+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
9101013 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
9111014 if ((unstakeInv == unstakeInv))
9121015 then {
913- let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914- if (($t03525535388 == $t03525535388))
1016+ let $t04027640427 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1017+ if (($t04027640427 == $t04027640427))
9151018 then {
916- let bonus = $t03525535388._4
917- let feeAmount = $t03525535388._3
918- let commonState = $t03525535388._2
919- let amountEstimated = $t03525535388._1
1019+ let outInAmountAsset = $t04027640427._5
1020+ let bonus = $t04027640427._4
1021+ let feeAmount = $t04027640427._3
1022+ let commonState = $t04027640427._2
1023+ let amountEstimated = $t04027640427._1
9201024 let amount = if (if ((minOutAmount > 0))
9211025 then (minOutAmount > amountEstimated)
9221026 else false)
9291033 let sendFee = if ((feeAmount > 0))
9301034 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
9311035 else nil
932- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1036+ let $t04092241169 = {
1037+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1038+ then 0
1039+ else feeAmount
1040+ if (outInAmountAsset)
1041+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1042+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1043+ }
1044+ let amountAssetBalanceDelta = $t04092241169._1
1045+ let priceAssetBalanceDelta = $t04092241169._2
1046+ let $t04117241280 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1047+ let refreshKLpActions = $t04117241280._1
1048+ let updatedKLp = $t04117241280._2
1049+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1050+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1051+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1052+ else throw("Strict value is not equal to itself.")
9331053 }
9341054 else throw("Strict value is not equal to itself.")
9351055 }
9501070 let pmtAmt = res._3
9511071 let pmtAssetId = res._4
9521072 let state = res._5
1073+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
9531074 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
9541075 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955- then state
1076+ then {
1077+ let $t04222842310 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1078+ let refreshKLpActions = $t04222842310._1
1079+ let updatedKLp = $t04222842310._2
1080+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1081+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1082+ then (state ++ refreshKLpActions)
1083+ else throw("Strict value is not equal to itself.")
1084+ }
9561085 else throw("Strict value is not equal to itself.")
9571086 }
9581087
9711100 else if ((noLessThenPriceAsset > outPrAmt))
9721101 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
9731102 else {
1103+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
9741104 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
9751105 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
976- then state
1106+ then {
1107+ let $t04326143342 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1108+ let refreshKLpActions = $t04326143342._1
1109+ let updatedKLp = $t04326143342._2
1110+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1111+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1112+ then (state ++ refreshKLpActions)
1113+ else throw("Strict value is not equal to itself.")
1114+ }
9771115 else throw("Strict value is not equal to itself.")
9781116 }
9791117 }
9891127 then {
9901128 let cfg = getPoolConfig()
9911129 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1130+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
9921131 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
9931132 if ((unstakeInv == unstakeInv))
9941133 then {
9951134 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1135+ let outAmAmt = res._1
1136+ let outPrAmt = res._2
9961137 let poolStatus = parseIntValue(res._9)
9971138 let state = res._10
9981139 let checkPoolStatus = if (if (isGlobalShutdown())
10041145 then {
10051146 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
10061147 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1007- then state
1148+ then {
1149+ let $t04446544546 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1150+ let refreshKLpActions = $t04446544546._1
1151+ let updatedKLp = $t04446544546._2
1152+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1153+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1154+ then (state ++ refreshKLpActions)
1155+ else throw("Strict value is not equal to itself.")
1156+ }
10081157 else throw("Strict value is not equal to itself.")
10091158 }
10101159 else throw("Strict value is not equal to itself.")
10281177 else throw("no payments are expected")]
10291178 if ((checks == checks))
10301179 then {
1180+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
10311181 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
10321182 if ((unstakeInv == unstakeInv))
10331183 then {
10441194 then {
10451195 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
10461196 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1047- then state
1197+ then {
1198+ let $t04583845919 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1199+ let refreshKLpActions = $t04583845919._1
1200+ let updatedKLp = $t04583845919._2
1201+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1202+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1203+ then (state ++ refreshKLpActions)
1204+ else throw("Strict value is not equal to itself.")
1205+ }
10481206 else throw("Strict value is not equal to itself.")
10491207 }
10501208 else throw("Strict value is not equal to itself.")
10601218 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
10611219 then throw("permissions denied")
10621220 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1221+
1222+
1223+
1224+@Callable(i)
1225+func refreshKLp () = {
1226+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1227+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1228+ then unit
1229+ else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1230+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1231+ then {
1232+ let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1233+ let $t04710647170 = refreshKLpInternal(0, 0, 0)
1234+ let kLpUpdateActions = $t04710647170._1
1235+ let updatedKLp = $t04710647170._2
1236+ let actions = if ((kLp != updatedKLp))
1237+ then kLpUpdateActions
1238+ else throwErr("nothing to refresh")
1239+ $Tuple2(actions, toString(updatedKLp))
1240+ }
1241+ else throw("Strict value is not equal to itself.")
1242+ }
10631243
10641244
10651245
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+
6871 func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale)
6972
7073
7174 func abs (val) = if ((0 > val))
7275 then -(val)
7376 else val
7477
7578
7679 func absBigInt (val) = if ((zeroBigInt > val))
7780 then -(val)
7881 else val
7982
8083
8184 func fc () = "%s__factoryContract"
8285
8386
8487 func mpk () = "%s__managerPublicKey"
8588
8689
8790 func pmpk () = "%s__pendingManagerPublicKey"
8891
8992
9093 func pl () = "%s%s__price__last"
9194
9295
9396 func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP)
9497
9598
9699 func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId)
97100
98101
99102 func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId)
100103
101104
102105 func aa () = "%s__amountAsset"
103106
104107
105108 func pa () = "%s__priceAsset"
106109
107110
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+
108127 func keyFactoryConfig () = "%s__factoryConfig"
109128
110129
111130 func keyMatcherPub () = "%s%s__matcher__publicKey"
112131
113132
114133 func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset")
115134
116135
117136 func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config")
118137
119138
120139 func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr)
121140
122141
123142 func keyAllPoolsShutdown () = "%s__shutdown"
124143
125144
126145 func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress)
127146
128147
129148 func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash"
130149
131150
132151 let keyFeeCollectorAddress = "%s__feeCollectorAddress"
133152
134153 func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
135154
136155
137156 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
138157
139158
140159 func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
141160
142161
143162 func throwErr (msg) = throw(makeString(["lp.ride:", msg], " "))
144163
145164
165+func fmtErr (msg) = makeString(["lp.ride:", msg], " ")
166+
167+
146168 let factoryContract = addressFromStringValue(getStringOrFail(this, fc()))
147169
148170 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- }
163171
164172 func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false)
165173
166174
167175 func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub()))
168176
169177
170178 func getPoolConfig () = {
171179 let amtAsset = getStringOrFail(this, aa())
172180 let priceAsset = getStringOrFail(this, pa())
173181 let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset))
174182 let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset))
175183 split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP)
176184 }
177185
178186
179187 func parseAssetId (input) = if ((input == wavesString))
180188 then unit
181189 else fromBase58String(input)
182190
183191
184192 func assetIdToString (input) = if ((input == unit))
185193 then wavesString
186194 else toBase58String(value(input))
187195
188196
189197 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]))
190198
191199
192200 let poolConfigParsed = parsePoolConfig(getPoolConfig())
193201
194-let $t076017767 = poolConfigParsed
202+let $t080588224 = poolConfigParsed
195203
196-let cfgPoolAddress = $t076017767._1
204+let cfgPoolAddress = $t080588224._1
197205
198-let cfgPoolStatus = $t076017767._2
206+let cfgPoolStatus = $t080588224._2
199207
200-let cfgLpAssetId = $t076017767._3
208+let cfgLpAssetId = $t080588224._3
201209
202-let cfgAmountAssetId = $t076017767._4
210+let cfgAmountAssetId = $t080588224._4
203211
204-let cfgPriceAssetId = $t076017767._5
212+let cfgPriceAssetId = $t080588224._5
205213
206-let cfgAmountAssetDecimals = $t076017767._6
214+let cfgAmountAssetDecimals = $t080588224._6
207215
208-let cfgPriceAssetDecimals = $t076017767._7
216+let cfgPriceAssetDecimals = $t080588224._7
209217
210218 func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP)
211219
212220
213221 let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address")
214222
215223 let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address")
216224
217225 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)
218226
219227
220228 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)
221229
222230
223231 func getAccBalance (assetId) = if ((assetId == "WAVES"))
224232 then wavesBalance(this).available
225233 else assetBalance(this, fromBase58String(assetId))
226234
227235
228236 func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
237+
238+
239+func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
229240
230241
231242 func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
232243 let amtAssetAmtX18 = toX18(amAmt, amAssetDcm)
233244 let priceAssetAmtX18 = toX18(prAmt, prAssetDcm)
234245 calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
235246 }
236247
237248
238249 func calcPrices (amAmt,prAmt,lpAmt) = {
239250 let cfg = getPoolConfig()
240251 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
241252 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
242253 let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt)
243254 let amAmtX18 = toX18(amAmt, amtAssetDcm)
244255 let prAmtX18 = toX18(prAmt, priceAssetDcm)
245256 let lpAmtX18 = toX18(lpAmt, scale8)
246257 let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18)
247258 let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18)
248259 [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18]
249260 }
250261
251262
252263 func calculatePrices (amAmt,prAmt,lpAmt) = {
253264 let prices = calcPrices(amAmt, prAmt, lpAmt)
254265 [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)]
255266 }
256267
257268
258269 func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
259270 let cfg = getPoolConfig()
260271 let lpAssetId = cfg[idxPoolLPAssetId]
261272 let amAssetId = cfg[idxAmtAssetId]
262273 let prAssetId = cfg[idxPriceAssetId]
263274 let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
264275 let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
265276 let poolStatus = cfg[idxPoolStatus]
266277 let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity
267278 if ((lpAssetId != pmtAssetId))
268279 then throw("Invalid asset passed.")
269280 else {
270281 let amBalance = getAccBalance(amAssetId)
271282 let amBalanceX18 = toX18(amBalance, amAssetDcm)
272283 let prBalance = getAccBalance(prAssetId)
273284 let prBalanceX18 = toX18(prBalance, prAssetDcm)
274285 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
275286 let curPrice = fromX18(curPriceX18, scale8)
276287 let pmtLpAmtX18 = toX18(pmtLpAmt, scale8)
277288 let lpEmissionX18 = toX18(lpEmission, scale8)
278289 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18)
279290 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18)
280- let outAmAmt = fromX18(outAmAmtX18, amAssetDcm)
281- let outPrAmt = fromX18(outPrAmtX18, prAssetDcm)
291+ let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR)
292+ let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR)
282293 let state = if ((txId58 == ""))
283294 then nil
284295 else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES"))
285296 then unit
286297 else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES"))
287298 then unit
288299 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)]
289300 $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state)
290301 }
291302 }
292303
293304
294305 func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = {
295306 let cfg = getPoolConfig()
296307 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
297308 let amAssetIdStr = cfg[idxAmtAssetId]
298309 let prAssetIdStr = cfg[idxPriceAssetId]
299310 let iAmtAssetId = cfg[idxIAmtAssetId]
300311 let iPriceAssetId = cfg[idxIPriceAssetId]
301312 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
302313 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
303314 let poolStatus = cfg[idxPoolStatus]
304315 let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
305316 let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES")))
306317 let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES")))
307318 if (if ((amAssetIdStr != inAmAssetIdStr))
308319 then true
309320 else (prAssetIdStr != inPrAssetIdStr))
310321 then throw("Invalid amt or price asset passed.")
311322 else {
312323 let amBalance = if (isEvaluate)
313324 then getAccBalance(amAssetIdStr)
314325 else (getAccBalance(amAssetIdStr) - inAmAssetAmt)
315326 let prBalance = if (isEvaluate)
316327 then getAccBalance(prAssetIdStr)
317328 else (getAccBalance(prAssetIdStr) - inPrAssetAmt)
318329 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
319330 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
320331 let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18)
321332 let amBalanceX18 = toX18(amBalance, amtAssetDcm)
322333 let prBalanceX18 = toX18(prBalance, priceAssetDcm)
323334 let res = if ((lpEmission == 0))
324335 then {
325336 let curPriceX18 = zeroBigInt
326337 let slippageX18 = zeroBigInt
327338 let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
328339 $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
329340 }
330341 else {
331342 let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18)
332343 let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18)
333344 let slippageToleranceX18 = toX18(slippageTolerance, scale8)
334345 if (if ((curPriceX18 != zeroBigInt))
335346 then (slippageX18 > slippageToleranceX18)
336347 else false)
337348 then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18)))
338349 else {
339350 let lpEmissionX18 = toX18(lpEmission, scale8)
340- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
341- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
351+ let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
352+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING)
342353 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
343354 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
344355 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
345356 let expAmtAssetAmtX18 = expectedAmts._1
346357 let expPriceAssetAmtX18 = expectedAmts._2
347- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
348- $Tuple5(fromX18(lpAmtX18, scale8), fromX18(expAmtAssetAmtX18, amtAssetDcm), fromX18(expPriceAssetAmtX18, priceAssetDcm), curPriceX18, slippageX18)
358+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR)
359+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18)
349360 }
350361 }
351362 let calcLpAmt = res._1
352363 let calcAmAssetPmt = res._2
353364 let calcPrAssetPmt = res._3
354365 let curPrice = fromX18(res._4, scale8)
355366 let slippageCalc = fromX18(res._5, scale8)
356367 if ((0 >= calcLpAmt))
357368 then throw("Invalid calculations. LP calculated is less than zero.")
358369 else {
359370 let emitLpAmt = if (!(emitLp))
360371 then 0
361372 else calcLpAmt
362373 let amDiff = (inAmAssetAmt - calcAmAssetPmt)
363374 let prDiff = (inPrAssetAmt - calcPrAssetPmt)
364375 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))]
365376 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId)
366377 }
367378 }
368379 }
369380
370381
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+
371414 func validateMatcherOrderAllowed (order) = {
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)
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
384422 if (if (if (isGlobalShutdown())
385423 then true
386- else (poolStatus == PoolMatcherDisabled))
424+ else (cfgPoolStatus == PoolMatcherDisabled))
387425 then true
388- else (poolStatus == PoolShutdown))
426+ else (cfgPoolStatus == PoolShutdown))
389427 then throw("Exchange operations disabled")
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- }
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+ }
413440 }
414441
415442
416443 func commonGet (i) = if ((size(i.payments) != 1))
417444 then throw("exactly 1 payment is expected")
418445 else {
419446 let pmt = value(i.payments[0])
420447 let pmtAssetId = value(pmt.assetId)
421448 let pmtAmt = pmt.amount
422449 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
423450 let outAmAmt = res._1
424451 let outPrAmt = res._2
425452 let poolStatus = parseIntValue(res._9)
426453 let state = res._10
427454 if (if (isGlobalShutdown())
428455 then true
429456 else (poolStatus == PoolShutdown))
430457 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
431458 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
432459 }
433460
434461
435462 func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2))
436463 then throw("exactly 2 payments are expected")
437464 else {
438465 let amAssetPmt = value(i.payments[0])
439466 let prAssetPmt = value(i.payments[1])
440467 let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp)
441468 let poolStatus = parseIntValue(estPut._8)
442469 if (if (if (isGlobalShutdown())
443470 then true
444471 else (poolStatus == PoolPutDisabled))
445472 then true
446473 else (poolStatus == PoolShutdown))
447474 then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus)))
448475 else estPut
449476 }
450477
451478
452479 func emit (amount) = {
453480 let emitInv = invoke(factoryContract, "emit", [amount], nil)
454481 if ((emitInv == emitInv))
455482 then {
456483 let emitInvLegacy = match emitInv {
457484 case legacyFactoryContract: Address =>
458485 invoke(legacyFactoryContract, "emit", [amount], nil)
459486 case _ =>
460487 unit
461488 }
462489 if ((emitInvLegacy == emitInvLegacy))
463490 then amount
464491 else throw("Strict value is not equal to itself.")
465492 }
466493 else throw("Strict value is not equal to itself.")
467494 }
468495
469496
470-func takeFee (amount,fee) = {
471- let feeAmount = if ((fee == 0))
472- then 0
473- else fraction(amount, fee, scale8)
497+func takeFee (amount) = {
498+ let feeAmount = fraction(amount, fee, scale8)
474499 $Tuple2((amount - feeAmount), feeAmount)
475500 }
476501
477502
478503 func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = {
479504 let isEval = (txId == unit)
480505 let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId))
481506 let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId))
482507 let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId))
483508 then true
484509 else if ((paymentAssetId == cfgPriceAssetId))
485510 then false
486511 else throwErr("invalid asset")
487- let $t02266422957 = if (isEval)
512+ let $t02426924562 = if (isEval)
488513 then $Tuple2(amountBalanceRaw, priceBalanceRaw)
489514 else if (paymentInAmountAsset)
490515 then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw)
491516 else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw))
492- let amountBalanceOld = $t02266422957._1
493- let priceBalanceOld = $t02266422957._2
494- let $t02296123110 = if (paymentInAmountAsset)
517+ let amountBalanceOld = $t02426924562._1
518+ let priceBalanceOld = $t02426924562._2
519+ let $t02456624715 = if (paymentInAmountAsset)
495520 then $Tuple2(paymentAmountRaw, 0)
496521 else $Tuple2(0, paymentAmountRaw)
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
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
504529 let amountBalanceNew = (amountBalanceOld + amountAssetAmount)
505530 let priceBalanceNew = (priceBalanceOld + priceAssetAmount)
506531 let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals))
507532 let priceNew = fromX18(priceNewX18, scale8)
508533 let paymentBalance = if (paymentInAmountAsset)
509534 then amountBalanceOld
510535 else priceBalanceOld
511536 let paymentBalanceBigInt = toBigInt(paymentBalance)
512537 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
513538 let chechSupply = if ((supplyBigInt > big0))
514539 then true
515540 else throwErr("initial deposit requires all coins")
516541 if ((chechSupply == chechSupply))
517542 then {
518543 let depositBigInt = toBigInt(paymentAmount)
519- let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))])
544+ let issueAmount = max([0, fromX18Round(fraction(supplyBigInt, (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18), scale18), scale8, FLOOR)])
520545 let commonState = if (isEval)
521546 then nil
522547 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))]
523548 let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals))
524549 let priceOld = fromX18(priceOldX18, scale8)
525550 let loss = {
526- let $t02478324950 = if (paymentInAmountAsset)
551+ let $t02639726564 = if (paymentInAmountAsset)
527552 then $Tuple2(amountAssetAmountRaw, amountBalanceOld)
528553 else $Tuple2(priceAssetAmountRaw, priceBalanceOld)
529- let amount = $t02478324950._1
530- let balance = $t02478324950._2
554+ let amount = $t02639726564._1
555+ let balance = $t02639726564._2
531556 let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance)))
532557 fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth)
533558 }
534- $Tuple4(issueAmount, commonState, feeAmount, loss)
559+ $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset)
535560 }
536561 else throw("Strict value is not equal to itself.")
537562 }
538563
539564
540565 func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = {
541566 let isEval = (txId == unit)
567+ let cfg = getPoolConfig()
568+ let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
569+ let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
542570 let checks = [if ((paymentAssetId == cfgLpAssetId))
543571 then true
544572 else throwErr("invalid lp asset")]
545573 if ((checks == checks))
546574 then {
547575 let outInAmountAsset = if ((outAssetId == cfgAmountAssetId))
548576 then true
549577 else if ((outAssetId == cfgPriceAssetId))
550578 then false
551579 else throwErr("invalid asset")
552580 let balanceBigInt = if (outInAmountAsset)
553581 then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId)))
554582 else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId)))
583+ let outInAmountAssetDecimals = if (outInAmountAsset)
584+ then amtAssetDcm
585+ else priceAssetDcm
555586 let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId))
556587 let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId))
557588 let outBalance = if (outInAmountAsset)
558589 then amBalanceOld
559590 else prBalanceOld
560591 let outBalanceBigInt = toBigInt(outBalance)
561592 let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity)
562593 let redeemedBigInt = toBigInt(paymentAmount)
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)
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)
568599 then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld)
569600 else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw))
570- let outAmAmount = $t02659026816._1
571- let outPrAmount = $t02659026816._2
572- let amBalanceNew = $t02659026816._3
573- let prBalanceNew = $t02659026816._4
601+ let outAmAmount = $t02851928745._1
602+ let outPrAmount = $t02851928745._2
603+ let amBalanceNew = $t02851928745._3
604+ let prBalanceNew = $t02851928745._4
574605 let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals))
575606 let priceNew = fromX18(priceNewX18, scale8)
576607 let commonState = if (isEval)
577608 then nil
578609 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)]
579610 let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals))
580611 let priceOld = fromX18(priceOldX18, scale8)
581612 let loss = {
582613 let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2)
583614 fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset)
584615 }
585- $Tuple4(totalAmount, commonState, feeAmount, loss)
616+ $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset)
586617 }
587618 else throw("Strict value is not equal to itself.")
588619 }
589620
590621
591622 func managerPublicKeyOrUnit () = match getString(mpk()) {
592623 case s: String =>
593624 fromBase58String(s)
594625 case _: Unit =>
595626 unit
596627 case _ =>
597628 throw("Match error")
598629 }
599630
600631
601632 func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) {
602633 case s: String =>
603634 fromBase58String(s)
604635 case _: Unit =>
605636 unit
606637 case _ =>
607638 throw("Match error")
608639 }
609640
610641
611642 func isManager (i) = match managerPublicKeyOrUnit() {
612643 case pk: ByteVector =>
613644 (i.callerPublicKey == pk)
614645 case _: Unit =>
615646 (i.caller == this)
616647 case _ =>
617648 throw("Match error")
618649 }
619650
620651
621652 func mustManager (i) = {
622653 let pd = throw("Permission denied")
623654 match managerPublicKeyOrUnit() {
624655 case pk: ByteVector =>
625656 if ((i.callerPublicKey == pk))
626657 then true
627658 else pd
628659 case _: Unit =>
629660 if ((i.caller == this))
630661 then true
631662 else pd
632663 case _ =>
633664 throw("Match error")
634665 }
635666 }
636667
637668
638669 @Callable(i)
639670 func setManager (pendingManagerPublicKey) = {
640671 let checkCaller = mustManager(i)
641672 if ((checkCaller == checkCaller))
642673 then {
643674 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
644675 if ((checkManagerPublicKey == checkManagerPublicKey))
645676 then [StringEntry(pmpk(), pendingManagerPublicKey)]
646677 else throw("Strict value is not equal to itself.")
647678 }
648679 else throw("Strict value is not equal to itself.")
649680 }
650681
651682
652683
653684 @Callable(i)
654685 func confirmManager () = {
655686 let pm = pendingManagerPublicKeyOrUnit()
656687 let hasPM = if (isDefined(pm))
657688 then true
658689 else throw("No pending manager")
659690 if ((hasPM == hasPM))
660691 then {
661692 let checkPM = if ((i.callerPublicKey == value(pm)))
662693 then true
663694 else throw("You are not pending manager")
664695 if ((checkPM == checkPM))
665696 then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())]
666697 else throw("Strict value is not equal to itself.")
667698 }
668699 else throw("Strict value is not equal to itself.")
669700 }
670701
671702
672703
673704 @Callable(i)
674705 func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance))
675706 then throw("Invalid slippageTolerance passed")
676707 else {
677708 let estPut = commonPut(i, slippageTolerance, true)
678709 let emitLpAmt = estPut._2
679710 let lpAssetId = estPut._7
680711 let state = estPut._9
681712 let amDiff = estPut._10
682713 let prDiff = estPut._11
683714 let amId = estPut._12
684715 let prId = estPut._13
685- let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
686- if ((emitInv == emitInv))
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))
687720 then {
688- let emitInvLegacy = match emitInv {
689- case legacyFactoryContract: Address =>
690- invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
691- case _ =>
692- unit
693- }
694- if ((emitInvLegacy == emitInvLegacy))
721+ let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil)
722+ if ((emitInv == emitInv))
695723 then {
696- let slippageAInv = if ((amDiff > 0))
697- then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
698- else nil
699- if ((slippageAInv == slippageAInv))
724+ let emitInvLegacy = match emitInv {
725+ case legacyFactoryContract: Address =>
726+ invoke(legacyFactoryContract, "emit", [emitLpAmt], nil)
727+ case _ =>
728+ unit
729+ }
730+ if ((emitInvLegacy == emitInvLegacy))
700731 then {
701- let slippagePInv = if ((prDiff > 0))
702- then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
732+ let slippageAInv = if ((amDiff > 0))
733+ then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)])
703734 else nil
704- if ((slippagePInv == slippagePInv))
735+ if ((slippageAInv == slippageAInv))
705736 then {
706- let lpTransfer = if (shouldAutoStake)
737+ let slippagePInv = if ((prDiff > 0))
738+ then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)])
739+ else nil
740+ if ((slippagePInv == slippagePInv))
707741 then {
708- let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
709- if ((slpStakeInv == slpStakeInv))
710- then nil
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+ }
711760 else throw("Strict value is not equal to itself.")
712761 }
713- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
714- (state ++ lpTransfer)
762+ else throw("Strict value is not equal to itself.")
715763 }
716764 else throw("Strict value is not equal to itself.")
717765 }
718766 else throw("Strict value is not equal to itself.")
719767 }
720768 else throw("Strict value is not equal to itself.")
721769 }
722770 else throw("Strict value is not equal to itself.")
723771 }
724772
725773
726774
727775 @Callable(i)
728776 func putForFree (maxSlippage) = if ((0 > maxSlippage))
729777 then throw("Invalid value passed")
730778 else {
731779 let estPut = commonPut(i, maxSlippage, false)
732- estPut._9
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.")
733795 }
734796
735797
736798
737799 @Callable(i)
738800 func putOneTkn (minOutAmount,autoStake) = {
739801 let isPoolOneTokenOperationsDisabled = {
740802 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
741803 if ($isInstanceOf(@, "Boolean"))
742804 then @
743805 else throw(($getType(@) + " couldn't be cast to Boolean"))
744806 }
745807 let isPutDisabled = if (if (if (isGlobalShutdown())
746808 then true
747809 else (cfgPoolStatus == PoolPutDisabled))
748810 then true
749811 else (cfgPoolStatus == PoolShutdown))
750812 then true
751813 else isPoolOneTokenOperationsDisabled
752814 let checks = [if (if (!(isPutDisabled))
753815 then true
754816 else isManager(i))
755817 then true
756818 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
757819 then true
758820 else throwErr("exactly 1 payment are expected")]
759821 if ((checks == checks))
760822 then {
761823 let payment = i.payments[0]
762824 let paymentAssetId = payment.assetId
763825 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")
764831 let userAddress = i.caller
765832 let txId = i.transactionId
766- let $t03172331853 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
767- if (($t03172331853 == $t03172331853))
833+ let $t03554735699 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId)
834+ if (($t03554735699 == $t03554735699))
768835 then {
769- let bonus = $t03172331853._4
770- let feeAmount = $t03172331853._3
771- let commonState = $t03172331853._2
772- let emitAmountEstimated = $t03172331853._1
836+ let paymentInAmountAsset = $t03554735699._5
837+ let bonus = $t03554735699._4
838+ let feeAmount = $t03554735699._3
839+ let commonState = $t03554735699._2
840+ let emitAmountEstimated = $t03554735699._1
773841 let emitAmount = if (if ((minOutAmount > 0))
774842 then (minOutAmount > emitAmountEstimated)
775843 else false)
776844 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
777845 else emitAmountEstimated
778846 let emitInv = emit(emitAmount)
779847 if ((emitInv == emitInv))
780848 then {
781849 let lpTransfer = if (autoStake)
782850 then {
783851 let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)])
784852 if ((stakeInv == stakeInv))
785853 then nil
786854 else throw("Strict value is not equal to itself.")
787855 }
788856 else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)]
789857 let sendFee = if ((feeAmount > 0))
790858 then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)]
791859 else nil
792- $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount)
860+ let $t03628536482 = if ((this == feeCollectorAddress))
861+ then $Tuple2(0, 0)
862+ else if (paymentInAmountAsset)
863+ then $Tuple2(-(feeAmount), 0)
864+ else $Tuple2(0, -(feeAmount))
865+ let amountAssetBalanceDelta = $t03628536482._1
866+ let priceAssetBalanceDelta = $t03628536482._2
867+ let $t03648536593 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
868+ let refreshKLpActions = $t03648536593._1
869+ let updatedKLp = $t03648536593._2
870+ let kLp = value(getString(keyKLp))
871+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
872+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
873+ then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount)
874+ else throw("Strict value is not equal to itself.")
793875 }
794876 else throw("Strict value is not equal to itself.")
795877 }
796878 else throw("Strict value is not equal to itself.")
797879 }
798880 else throw("Strict value is not equal to itself.")
799881 }
800882
801883
802884
803885 @Callable(i)
804886 func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = {
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
887+ let $t03689937056 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit)
888+ let emitAmountEstimated = $t03689937056._1
889+ let commonState = $t03689937056._2
890+ let feeAmount = $t03689937056._3
891+ let bonus = $t03689937056._4
892+ let paymentInAmountAsset = $t03689937056._5
810893 $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus))
811894 }
812895
813896
814897
815898 @Callable(i)
816899 func getOneTkn (outAssetIdStr,minOutAmount) = {
817900 let isPoolOneTokenOperationsDisabled = {
818901 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
819902 if ($isInstanceOf(@, "Boolean"))
820903 then @
821904 else throw(($getType(@) + " couldn't be cast to Boolean"))
822905 }
823906 let isGetDisabled = if (if (isGlobalShutdown())
824907 then true
825908 else (cfgPoolStatus == PoolShutdown))
826909 then true
827910 else isPoolOneTokenOperationsDisabled
828911 let checks = [if (if (!(isGetDisabled))
829912 then true
830913 else isManager(i))
831914 then true
832915 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
833916 then true
834917 else throwErr("exactly 1 payment are expected")]
835918 if ((checks == checks))
836919 then {
837920 let outAssetId = parseAssetId(outAssetIdStr)
838921 let payment = i.payments[0]
839922 let paymentAssetId = payment.assetId
840923 let paymentAmount = payment.amount
924+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(paymentAmount))
841925 let userAddress = i.caller
842926 let txId = i.transactionId
843- let $t03352233657 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
844- if (($t03352233657 == $t03352233657))
927+ let $t03795038103 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId)
928+ if (($t03795038103 == $t03795038103))
845929 then {
846- let bonus = $t03352233657._4
847- let feeAmount = $t03352233657._3
848- let commonState = $t03352233657._2
849- let amountEstimated = $t03352233657._1
930+ let outInAmountAsset = $t03795038103._5
931+ let bonus = $t03795038103._4
932+ let feeAmount = $t03795038103._3
933+ let commonState = $t03795038103._2
934+ let amountEstimated = $t03795038103._1
850935 let amount = if (if ((minOutAmount > 0))
851936 then (minOutAmount > amountEstimated)
852937 else false)
853938 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
854939 else amountEstimated
855940 let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)])
856941 if ((burnInv == burnInv))
857942 then {
858943 let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)]
859944 let sendFee = if ((feeAmount > 0))
860945 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
861946 else nil
862- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
947+ let $t03860338850 = {
948+ let feeAmountForCalc = if ((this == feeCollectorAddress))
949+ then 0
950+ else feeAmount
951+ if (outInAmountAsset)
952+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
953+ else $Tuple2(0, -((amount + feeAmountForCalc)))
954+ }
955+ let amountAssetBalanceDelta = $t03860338850._1
956+ let priceAssetBalanceDelta = $t03860338850._2
957+ let $t03885338961 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
958+ let refreshKLpActions = $t03885338961._1
959+ let updatedKLp = $t03885338961._2
960+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
961+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
962+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
963+ else throw("Strict value is not equal to itself.")
863964 }
864965 else throw("Strict value is not equal to itself.")
865966 }
866967 else throw("Strict value is not equal to itself.")
867968 }
868969 else throw("Strict value is not equal to itself.")
869970 }
870971
871972
872973
873974 @Callable(i)
874975 func getOneTknREADONLY (outAssetId,paymentAmount) = {
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
976+ let $t03921839374 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit)
977+ let amountEstimated = $t03921839374._1
978+ let commonState = $t03921839374._2
979+ let feeAmount = $t03921839374._3
980+ let bonus = $t03921839374._4
981+ let outInAmountAsset = $t03921839374._5
880982 $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus))
881983 }
882984
883985
884986
885987 @Callable(i)
886988 func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = {
887989 let isPoolOneTokenOperationsDisabled = {
888990 let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
889991 if ($isInstanceOf(@, "Boolean"))
890992 then @
891993 else throw(($getType(@) + " couldn't be cast to Boolean"))
892994 }
893995 let isGetDisabled = if (if (isGlobalShutdown())
894996 then true
895997 else (cfgPoolStatus == PoolShutdown))
896998 then true
897999 else isPoolOneTokenOperationsDisabled
8981000 let checks = [if (if (!(isGetDisabled))
8991001 then true
9001002 else isManager(i))
9011003 then true
9021004 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
9031005 then true
9041006 else throwErr("no payments are expected")]
9051007 if ((checks == checks))
9061008 then {
9071009 let outAssetId = parseAssetId(outAssetIdStr)
9081010 let userAddress = i.caller
9091011 let txId = i.transactionId
1012+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
9101013 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
9111014 if ((unstakeInv == unstakeInv))
9121015 then {
913- let $t03525535388 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
914- if (($t03525535388 == $t03525535388))
1016+ let $t04027640427 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId)
1017+ if (($t04027640427 == $t04027640427))
9151018 then {
916- let bonus = $t03525535388._4
917- let feeAmount = $t03525535388._3
918- let commonState = $t03525535388._2
919- let amountEstimated = $t03525535388._1
1019+ let outInAmountAsset = $t04027640427._5
1020+ let bonus = $t04027640427._4
1021+ let feeAmount = $t04027640427._3
1022+ let commonState = $t04027640427._2
1023+ let amountEstimated = $t04027640427._1
9201024 let amount = if (if ((minOutAmount > 0))
9211025 then (minOutAmount > amountEstimated)
9221026 else false)
9231027 then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
9241028 else amountEstimated
9251029 let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
9261030 if ((burnInv == burnInv))
9271031 then {
9281032 let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)]
9291033 let sendFee = if ((feeAmount > 0))
9301034 then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)]
9311035 else nil
932- $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount)
1036+ let $t04092241169 = {
1037+ let feeAmountForCalc = if ((this == feeCollectorAddress))
1038+ then 0
1039+ else feeAmount
1040+ if (outInAmountAsset)
1041+ then $Tuple2(-((amount + feeAmountForCalc)), 0)
1042+ else $Tuple2(0, -((amount + feeAmountForCalc)))
1043+ }
1044+ let amountAssetBalanceDelta = $t04092241169._1
1045+ let priceAssetBalanceDelta = $t04092241169._2
1046+ let $t04117241280 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1047+ let refreshKLpActions = $t04117241280._1
1048+ let updatedKLp = $t04117241280._2
1049+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1050+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1051+ then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount)
1052+ else throw("Strict value is not equal to itself.")
9331053 }
9341054 else throw("Strict value is not equal to itself.")
9351055 }
9361056 else throw("Strict value is not equal to itself.")
9371057 }
9381058 else throw("Strict value is not equal to itself.")
9391059 }
9401060 else throw("Strict value is not equal to itself.")
9411061 }
9421062
9431063
9441064
9451065 @Callable(i)
9461066 func get () = {
9471067 let res = commonGet(i)
9481068 let outAmtAmt = res._1
9491069 let outPrAmt = res._2
9501070 let pmtAmt = res._3
9511071 let pmtAssetId = res._4
9521072 let state = res._5
1073+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
9531074 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
9541075 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
955- then state
1076+ then {
1077+ let $t04222842310 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1078+ let refreshKLpActions = $t04222842310._1
1079+ let updatedKLp = $t04222842310._2
1080+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1081+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1082+ then (state ++ refreshKLpActions)
1083+ else throw("Strict value is not equal to itself.")
1084+ }
9561085 else throw("Strict value is not equal to itself.")
9571086 }
9581087
9591088
9601089
9611090 @Callable(i)
9621091 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
9631092 let res = commonGet(i)
9641093 let outAmAmt = res._1
9651094 let outPrAmt = res._2
9661095 let pmtAmt = res._3
9671096 let pmtAssetId = res._4
9681097 let state = res._5
9691098 if ((noLessThenAmtAsset > outAmAmt))
9701099 then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
9711100 else if ((noLessThenPriceAsset > outPrAmt))
9721101 then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
9731102 else {
1103+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(pmtAmt))
9741104 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
9751105 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
976- then state
1106+ then {
1107+ let $t04326143342 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1108+ let refreshKLpActions = $t04326143342._1
1109+ let updatedKLp = $t04326143342._2
1110+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1111+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1112+ then (state ++ refreshKLpActions)
1113+ else throw("Strict value is not equal to itself.")
1114+ }
9771115 else throw("Strict value is not equal to itself.")
9781116 }
9791117 }
9801118
9811119
9821120
9831121 @Callable(i)
9841122 func unstakeAndGet (amount) = {
9851123 let checkPayments = if ((size(i.payments) != 0))
9861124 then throw("No payments are expected")
9871125 else true
9881126 if ((checkPayments == checkPayments))
9891127 then {
9901128 let cfg = getPoolConfig()
9911129 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
1130+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
9921131 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil)
9931132 if ((unstakeInv == unstakeInv))
9941133 then {
9951134 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1135+ let outAmAmt = res._1
1136+ let outPrAmt = res._2
9961137 let poolStatus = parseIntValue(res._9)
9971138 let state = res._10
9981139 let checkPoolStatus = if (if (isGlobalShutdown())
9991140 then true
10001141 else (poolStatus == PoolShutdown))
10011142 then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus)))
10021143 else true
10031144 if ((checkPoolStatus == checkPoolStatus))
10041145 then {
10051146 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
10061147 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1007- then state
1148+ then {
1149+ let $t04446544546 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1150+ let refreshKLpActions = $t04446544546._1
1151+ let updatedKLp = $t04446544546._2
1152+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1153+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1154+ then (state ++ refreshKLpActions)
1155+ else throw("Strict value is not equal to itself.")
1156+ }
10081157 else throw("Strict value is not equal to itself.")
10091158 }
10101159 else throw("Strict value is not equal to itself.")
10111160 }
10121161 else throw("Strict value is not equal to itself.")
10131162 }
10141163 else throw("Strict value is not equal to itself.")
10151164 }
10161165
10171166
10181167
10191168 @Callable(i)
10201169 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
10211170 let isGetDisabled = if (isGlobalShutdown())
10221171 then true
10231172 else (cfgPoolStatus == PoolShutdown)
10241173 let checks = [if (!(isGetDisabled))
10251174 then true
10261175 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
10271176 then true
10281177 else throw("no payments are expected")]
10291178 if ((checks == checks))
10301179 then {
1180+ let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0))
10311181 let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
10321182 if ((unstakeInv == unstakeInv))
10331183 then {
10341184 let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
10351185 let outAmAmt = res._1
10361186 let outPrAmt = res._2
10371187 let state = res._10
10381188 let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
10391189 then true
10401190 else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
10411191 then true
10421192 else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
10431193 if ((checkAmounts == checkAmounts))
10441194 then {
10451195 let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
10461196 if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1047- then state
1197+ then {
1198+ let $t04583845919 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0)
1199+ let refreshKLpActions = $t04583845919._1
1200+ let updatedKLp = $t04583845919._2
1201+ let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp)
1202+ if ((isUpdatedKLpValid == isUpdatedKLpValid))
1203+ then (state ++ refreshKLpActions)
1204+ else throw("Strict value is not equal to itself.")
1205+ }
10481206 else throw("Strict value is not equal to itself.")
10491207 }
10501208 else throw("Strict value is not equal to itself.")
10511209 }
10521210 else throw("Strict value is not equal to itself.")
10531211 }
10541212 else throw("Strict value is not equal to itself.")
10551213 }
10561214
10571215
10581216
10591217 @Callable(i)
10601218 func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract)))
10611219 then throw("permissions denied")
10621220 else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success")
1221+
1222+
1223+
1224+@Callable(i)
1225+func refreshKLp () = {
1226+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0)
1227+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay))
1228+ then unit
1229+ else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1230+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1231+ then {
1232+ let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp"))
1233+ let $t04710647170 = refreshKLpInternal(0, 0, 0)
1234+ let kLpUpdateActions = $t04710647170._1
1235+ let updatedKLp = $t04710647170._2
1236+ let actions = if ((kLp != updatedKLp))
1237+ then kLpUpdateActions
1238+ else throwErr("nothing to refresh")
1239+ $Tuple2(actions, toString(updatedKLp))
1240+ }
1241+ else throw("Strict value is not equal to itself.")
1242+ }
10631243
10641244
10651245
10661246 @Callable(i)
10671247 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig())
10681248
10691249
10701250
10711251 @Callable(i)
10721252 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
10731253
10741254
10751255
10761256 @Callable(i)
10771257 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
10781258 let prices = calcPrices(amAmt, prAmt, lpAmt)
10791259 $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])])
10801260 }
10811261
10821262
10831263
10841264 @Callable(i)
10851265 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult)))
10861266
10871267
10881268
10891269 @Callable(i)
10901270 func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult))
10911271
10921272
10931273
10941274 @Callable(i)
10951275 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
10961276
10971277
10981278
10991279 @Callable(i)
11001280 func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp))
11011281
11021282
11031283
11041284 @Callable(i)
11051285 func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
11061286 let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress))
11071287 $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10))
11081288 }
11091289
11101290
11111291
11121292 @Callable(i)
11131293 func statsREADONLY () = {
11141294 let cfg = getPoolConfig()
11151295 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11161296 let amtAssetId = cfg[idxAmtAssetId]
11171297 let priceAssetId = cfg[idxPriceAssetId]
11181298 let iAmtAssetId = cfg[idxIAmtAssetId]
11191299 let iPriceAssetId = cfg[idxIPriceAssetId]
11201300 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11211301 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11221302 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11231303 let accAmtAssetBalance = getAccBalance(amtAssetId)
11241304 let accPriceAssetBalance = getAccBalance(priceAssetId)
11251305 let pricesList = if ((poolLPBalance == 0))
11261306 then [zeroBigInt, zeroBigInt, zeroBigInt]
11271307 else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance)
11281308 let curPrice = 0
11291309 let lpAmtAssetShare = fromX18(pricesList[1], scale8)
11301310 let lpPriceAssetShare = fromX18(pricesList[2], scale8)
11311311 let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this))))
11321312 $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))
11331313 }
11341314
11351315
11361316
11371317 @Callable(i)
11381318 func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = {
11391319 let cfg = getPoolConfig()
11401320 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11411321 let amAssetIdStr = cfg[idxAmtAssetId]
11421322 let amAssetId = fromBase58String(amAssetIdStr)
11431323 let prAssetIdStr = cfg[idxPriceAssetId]
11441324 let prAssetId = fromBase58String(prAssetIdStr)
11451325 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11461326 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11471327 let poolStatus = cfg[idxPoolStatus]
11481328 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11491329 let accAmtAssetBalance = getAccBalance(amAssetIdStr)
11501330 let accPriceAssetBalance = getAccBalance(prAssetIdStr)
11511331 let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm)
11521332 let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm)
11531333 let curPriceX18 = if ((poolLPBalance == 0))
11541334 then zeroBigInt
11551335 else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18)
11561336 let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm)
11571337 let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
11581338 let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm)
11591339 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
11601340 let calcLpAmt = estPut._1
11611341 let curPriceCalc = estPut._3
11621342 let amBalance = estPut._4
11631343 let prBalance = estPut._5
11641344 let lpEmission = estPut._6
11651345 $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))
11661346 }
11671347
11681348
11691349
11701350 @Callable(i)
11711351 func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = {
11721352 let cfg = getPoolConfig()
11731353 let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId])
11741354 let amAssetIdStr = cfg[idxAmtAssetId]
11751355 let amAssetId = fromBase58String(amAssetIdStr)
11761356 let prAssetIdStr = cfg[idxPriceAssetId]
11771357 let prAssetId = fromBase58String(prAssetIdStr)
11781358 let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm])
11791359 let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm])
11801360 let poolStatus = cfg[idxPoolStatus]
11811361 let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity
11821362 let amBalanceRaw = getAccBalance(amAssetIdStr)
11831363 let prBalanceRaw = getAccBalance(prAssetIdStr)
11841364 let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm)
11851365 let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm)
11861366 let curPriceX18 = if ((poolLPBalance == 0))
11871367 then zeroBigInt
11881368 else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18)
11891369 let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm)
11901370 let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
11911371 let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm)
11921372 let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false)
11931373 let calcLpAmt = estPut._1
11941374 let curPriceCalc = estPut._3
11951375 let amBalance = estPut._4
11961376 let prBalance = estPut._5
11971377 let lpEmission = estPut._6
11981378 $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))
11991379 }
12001380
12011381
12021382
12031383 @Callable(i)
12041384 func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = {
12051385 let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this)
12061386 let outAmAmt = res._1
12071387 let outPrAmt = res._2
12081388 let amBalance = res._5
12091389 let prBalance = res._6
12101390 let lpEmission = res._7
12111391 let curPrice = res._8
12121392 let poolStatus = parseIntValue(res._9)
12131393 $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))
12141394 }
12151395
12161396
12171397 @Verifier(tx)
12181398 func verify () = {
12191399 let targetPublicKey = match managerPublicKeyOrUnit() {
12201400 case pk: ByteVector =>
12211401 pk
12221402 case _: Unit =>
12231403 tx.senderPublicKey
12241404 case _ =>
12251405 throw("Match error")
12261406 }
12271407 match tx {
12281408 case order: Order =>
12291409 let matcherPub = getMatcherPubOrFail()
12301410 let orderValid = validateMatcherOrderAllowed(order)
12311411 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
12321412 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
12331413 if (if (if (orderValid)
12341414 then senderValid
12351415 else false)
12361416 then matcherValid
12371417 else false)
12381418 then true
12391419 else throwOrderError(orderValid, senderValid, matcherValid)
12401420 case s: SetScriptTransaction =>
12411421 let newHash = blake2b256(value(s.script))
12421422 let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash())))
12431423 let currentHash = scriptHash(this)
12441424 if (if ((allowedHash == newHash))
12451425 then (currentHash != newHash)
12461426 else false)
12471427 then true
12481428 else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
12491429 case _ =>
12501430 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
12511431 }
12521432 }
12531433

github/deemru/w8io/026f985 
181.99 ms