tx · Etcr5RSDHKjb4BAfvjFkpsDVBczA29RRiznZomszwXYz

3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA:  -0.03700000 Waves

2023.02.09 15:50 [2442108] smart account 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA > SELF 0.00000000 Waves

{ "type": 13, "id": "Etcr5RSDHKjb4BAfvjFkpsDVBczA29RRiznZomszwXYz", "fee": 3700000, "feeAssetId": null, "timestamp": 1675947016267, "version": 1, "sender": "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA", "senderPublicKey": "35yd3qw1gxKDxKwGAykHN9fANbXNWwseaUwbWDj24o3x", "proofs": [ "8NpzCJ9rhWDSSaZHuo2kd9xc5q9xUAGhPRGTHy1vvR44QhAkwPUEb6Xs3ywP69STaaAwuLz7MYJXxBD3wf9RiHe" ], "script": "base64:BgKJKQgCEgMKAQgSAwoBCBIAEgQKAgEEEgQKAgEEEgMKAQESABIECgIIARIAEgQKAggBEgQKAggBEgQKAgEBEgMKAQESBQoDAQEBEgUKAwEIARIECgIBCBIECgIBCBIECgIICBIECgIICBIECgIIARIAEgMKAQgSBQoDAQEBEgQKAggBEgQKAgEBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIIgZzY2FsZTgiDHNjYWxlOEJpZ0ludCIHc2NhbGUxOCIKemVyb0JpZ0ludCIEYmlnMCIEYmlnMSIEYmlnMiIEYmlnMyIEYmlnNCIKc2xpcHBhZ2U0RCILd2F2ZXNTdHJpbmciBUFtdWx0IgVEY29udiIDU0VQIgVFTVBUWSIKUG9vbEFjdGl2ZSIKUG9vbFB1dERpcyIOUG9vbE1hdGNoZXJEaXMiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiCWlkeFBvb2xTdCIJaWR4TFBBc0lkIglpZHhBbUFzSWQiCWlkeFByQXNJZCILaWR4QW10QXNEY20iDWlkeFByaWNlQXNEY20iC2lkeElBbXRBc0lkIg1pZHhJUHJpY2VBc0lkI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0 } View: original | compacted Prev: 5N6Nupq41km5BSEUTFgE2kbGessS7ZnNh5CR5ZiqoXJM Next: 3YdpRDwmRZgvUagbDG6SzXJgjkXvYsFqQYvvErrY4N9N Diff:
OldNewDifferences
1414 let big1 = toBigInt(1)
1515
1616 let big2 = toBigInt(2)
17+
18+let big3 = toBigInt(3)
19+
20+let big4 = toBigInt(4)
1721
1822 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
1923
6670 func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6771
6872
73+func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
74+
75+
6976 func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
77+
78+
79+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
80+
81+
82+func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult))
83+
84+
85+func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18)
7086
7187
7288 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
115131 func ada () = "%s__addonAddr"
116132
117133
118-func swapContract () = "%s__swapContract"
134+let keyFee = "%s__fee"
119135
136+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
137+
138+let keyDLp = makeString(["%s", "dLp"], SEP)
139+
140+let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
141+
142+let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
143+
144+let dLpRefreshDelayDefault = 30
145+
146+let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
120147
121148 func fcfg () = "%s__factoryConfig"
122149
139166 func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
140167
141168
142-func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
143-
144-
145-func str (val) = match val {
146- case valStr: String =>
147- valStr
148- case _ =>
149- throw("fail cast to String")
150-}
169+func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
151170
152171
153172 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
157176
158177
159178 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
179+
180+
181+func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
160182
161183
162184 let fca = addressFromStringValue(strf(this, fc()))
204226 else toBase58String(value(input))
205227
206228
207-func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm]))
229+func parsePoolConfig (poolConfig) = $Tuple9(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm]), fromBase58String(poolConfig[idxIAmtAsId]), fromBase58String(poolConfig[idxIPriceAsId]))
208230
209231
210232 let poolConfigParsed = parsePoolConfig(gpc())
211233
212-let $t069527138 = poolConfigParsed
234+let $t079658194 = poolConfigParsed
213235
214-let cfgPoolAddress = $t069527138._1
236+let cfgPoolAddress = $t079658194._1
215237
216-let cfgPoolStatus = $t069527138._2
238+let cfgPoolStatus = $t079658194._2
217239
218-let cfgLpAssetId = $t069527138._3
240+let cfgLpAssetId = $t079658194._3
219241
220-let cfgAmountAssetId = $t069527138._4
242+let cfgAmountAssetId = $t079658194._4
221243
222-let cfgPriceAssetId = $t069527138._5
244+let cfgPriceAssetId = $t079658194._5
223245
224-let cfgAmountAssetDecimals = $t069527138._6
246+let cfgAmountAssetDecimals = $t079658194._6
225247
226-let cfgPriceAssetDecimals = $t069527138._7
248+let cfgPriceAssetDecimals = $t079658194._7
249+
250+let cfgInAmountAssedId = $t079658194._8
251+
252+let cfgInPriceAssetId = $t079658194._9
227253
228254 func gfc () = split(strf(fca, fcfg()), SEP)
229255
250276
251277
252278 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
279+
280+
281+func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
253282
254283
255284 func vad (A1,A2,slippage) = {
280309
281310
282311 func calcPrices (amAmt,prAmt,lpAmt) = {
283- let cfg = gpc()
284- let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
285- let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
312+ let amtAsDcm = cfgAmountAssetDecimals
313+ let prAsDcm = cfgPriceAssetDecimals
286314 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
287315 let amAmtX18 = t1(amAmt, amtAsDcm)
288316 let prAmtX18 = t1(prAmt, prAsDcm)
307335 }
308336
309337
338+func getD (xp) = {
339+ let xp0 = xp[0]
340+ let xp1 = xp[1]
341+ let s = (xp0 + xp1)
342+ if ((s == big0))
343+ then big0
344+ else {
345+ let a = parseIntValue(A)
346+ let ann = (a * 2)
347+ let p = fraction(xp0, xp1, big1)
348+ let xp0_xp1_n_n = fraction(p, big4, big1)
349+ let ann_s = fraction(toBigInt(ann), s, big1)
350+ let ann_1 = toBigInt((ann - 1))
351+ func calcDNext (d) = {
352+ let dd = fraction(d, d, big1)
353+ let ddd = fraction(dd, d, big1)
354+ let dp = fraction(ddd, big1, xp0_xp1_n_n)
355+ fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)))
356+ }
357+
358+ func calc (acc,i) = if (acc._2)
359+ then acc
360+ else {
361+ let d = acc._1
362+ let dNext = calcDNext(d)
363+ let dDiffRaw = (dNext - value(d))
364+ let dDiff = if ((big0 > dDiffRaw))
365+ then -(dDiffRaw)
366+ else dDiffRaw
367+ if ((big1 >= dDiff))
368+ then $Tuple2(dNext, true)
369+ else $Tuple2(dNext, false)
370+ }
371+
372+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
373+ let $t01269112739 = {
374+ let $l = arr
375+ let $s = size($l)
376+ let $acc0 = $Tuple2(s, false)
377+ func $f0_1 ($a,$i) = if (($i >= $s))
378+ then $a
379+ else calc($a, $l[$i])
380+
381+ func $f0_2 ($a,$i) = if (($i >= $s))
382+ then $a
383+ else throw("List size exceeds 15")
384+
385+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
386+ }
387+ let d = $t01269112739._1
388+ let found = $t01269112739._2
389+ if (found)
390+ then d
391+ else throw(("D calculation error, D = " + toString(d)))
392+ }
393+ }
394+
395+
310396 func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
311- let cfg = gpc()
312- let lpId = cfg[idxLPAsId]
313- let amId = cfg[idxAmAsId]
314- let prId = cfg[idxPrAsId]
315- let amDcm = parseIntValue(cfg[idxAmtAsDcm])
316- let prDcm = parseIntValue(cfg[idxPriceAsDcm])
317- let sts = cfg[idxPoolSt]
318- let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
319- if ((lpId != pmtAssetId))
397+ let lpId = cfgLpAssetId
398+ let amId = toBase58String(value(cfgAmountAssetId))
399+ let prId = toBase58String(value(cfgPriceAssetId))
400+ let amDcm = cfgAmountAssetDecimals
401+ let prDcm = cfgPriceAssetDecimals
402+ let sts = toString(cfgPoolStatus)
403+ let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity
404+ if ((toBase58String(lpId) != pmtAssetId))
320405 then throw("Wrong pmt asset")
321406 else {
322407 let amBalance = getAccBalance(amId)
329414 let lpEmissX18 = t1(lpEmiss, scale8)
330415 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
331416 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
332- let outAmAmt = f1(outAmAmtX18, amDcm)
333- let outPrAmt = f1(outPrAmtX18, prDcm)
417+ let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
418+ let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
334419 let state = if ((txId58 == ""))
335420 then nil
336421 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
344429
345430
346431 func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
347- let cfg = gpc()
348- let lpId = fromBase58String(cfg[idxLPAsId])
349- let amIdStr = cfg[idxAmAsId]
350- let prIdStr = cfg[idxPrAsId]
351- let inAmIdStr = cfg[idxIAmtAsId]
352- let inPrIdStr = cfg[idxIPriceAsId]
353- let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
354- let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
355- let sts = cfg[idxPoolSt]
432+ let lpId = cfgLpAssetId
433+ let amIdStr = toBase58String(value(cfgAmountAssetId))
434+ let prIdStr = toBase58String(value(cfgPriceAssetId))
435+ let inAmIdStr = cfgInAmountAssedId
436+ let inPrIdStr = cfgInPriceAssetId
437+ let amtDcm = cfgAmountAssetDecimals
438+ let priceDcm = cfgPriceAssetDecimals
439+ let sts = toString(cfgPoolStatus)
356440 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
357441 let amBalance = if (isEval)
358442 then getAccBalance(amIdStr)
377461 let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
378462 let amBalanceX18 = t1(amBalance, amtDcm)
379463 let prBalanceX18 = t1(prBalance, priceDcm)
464+ let D0 = getD([amBalanceX18, prBalanceX18])
380465 let r = if ((lpEm == 0))
381466 then {
382- let curPriceX18 = zeroBigInt
383- let slippageX18 = zeroBigInt
384- let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
385- $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
467+ let D1 = getD([(amBalanceX18 + inAmAssetAmtX18), (prBalanceX18 + inPrAssetAmtX18)])
468+ let checkD = if ((D1 > D0))
469+ then true
470+ else throw("D1 should be greater than D0")
471+ if ((checkD == checkD))
472+ then {
473+ let curPriceX18 = zeroBigInt
474+ let slippageX18 = zeroBigInt
475+ let lpAmtX18 = D1
476+ $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
477+ }
478+ else throw("Strict value is not equal to itself.")
386479 }
387480 else {
388481 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
396489 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
397490 else {
398491 let lpEmissionX18 = t1(lpEm, scale8)
399- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
400- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
492+ let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
493+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
401494 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
402495 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
403496 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
404497 let expAmtAssetAmtX18 = expectedAmts._1
405498 let expPriceAssetAmtX18 = expectedAmts._2
406- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
407- $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
499+ let D1 = getD([(amBalanceX18 + expAmtAssetAmtX18), (prBalanceX18 + expPriceAssetAmtX18)])
500+ let checkD = if ((D1 > D0))
501+ then true
502+ else throw("D1 should be greater than D0")
503+ if ((checkD == checkD))
504+ then {
505+ let lpAmtX18 = fraction(lpEmissionX18, (D1 - D0), D0)
506+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
507+ }
508+ else throw("Strict value is not equal to itself.")
408509 }
409510 }
410511 let calcLpAmt = r._1
420521 else calcLpAmt
421522 let amDiff = (inAmAmt - calcAmAssetPmt)
422523 let prDiff = (inPrAmt - calcPrAssetPmt)
423- let $t01760517950 = if (if (isOneAsset)
524+ let $t02057820923 = if (if (isOneAsset)
424525 then (pmtId == amIdStr)
425526 else false)
426527 then $Tuple2(pmtAmt, 0)
429530 else false)
430531 then $Tuple2(0, pmtAmt)
431532 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
432- let writeAmAmt = $t01760517950._1
433- let writePrAmt = $t01760517950._2
533+ let writeAmAmt = $t02057820923._1
534+ let writePrAmt = $t02057820923._2
434535 let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))]
435536 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
436537 }
437538 }
438539
439540
440-func moa (order) = {
441- let cfg = gpc()
442- let amtAsId = cfg[idxAmAsId]
443- let prAsId = cfg[idxPrAsId]
444- let sts = parseIntValue(cfg[idxPoolSt])
445- let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
446- let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
447- let accAmtAsBalance = getAccBalance(amtAsId)
448- let accPrAsBalance = getAccBalance(prAsId)
449- let curPriceX18 = if ((order.orderType == Buy))
450- then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
451- else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
452- let curPrice = f1(curPriceX18, scale8)
541+func getYD (xp,i,D) = {
542+ let n = big2
543+ let x = xp[if ((i == 0))
544+ then 1
545+ else 0]
546+ let aPrecision = parseBigIntValue(Amult)
547+ let a = (parseBigIntValue(A) * aPrecision)
548+ let s = x
549+ let ann = (a * n)
550+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
551+ let b = ((s + ((D * aPrecision) / ann)) - D)
552+ func calc (acc,cur) = {
553+ let $t02211822138 = acc
554+ let y = $t02211822138._1
555+ let found = $t02211822138._2
556+ if ((found != unit))
557+ then acc
558+ else {
559+ let yNext = (((y * y) + c) / ((big2 * y) + b))
560+ let yDiff = absBigInt((yNext - value(y)))
561+ if ((big1 >= yDiff))
562+ then $Tuple2(yNext, cur)
563+ else $Tuple2(yNext, unit)
564+ }
565+ }
566+
567+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
568+ let $t02244522492 = {
569+ let $l = arr
570+ let $s = size($l)
571+ let $acc0 = $Tuple2(D, unit)
572+ func $f0_1 ($a,$i) = if (($i >= $s))
573+ then $a
574+ else calc($a, $l[$i])
575+
576+ func $f0_2 ($a,$i) = if (($i >= $s))
577+ then $a
578+ else throw("List size exceeds 15")
579+
580+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
581+ }
582+ let y = $t02244522492._1
583+ let found = $t02244522492._2
584+ if ((found != unit))
585+ then y
586+ else throw(("Y calculation error, Y = " + toString(y)))
587+ }
588+
589+
590+func calcDLp (amountBalance,priceBalance,lpEmission) = {
591+ let updatedDLp = fraction(getD([t1BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)), t1BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))]), scale18, lpEmission)
592+ if ((lpEmission == big0))
593+ then big0
594+ else updatedDLp
595+ }
596+
597+
598+func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
599+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
600+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
601+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
602+ let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
603+ currentDLp
604+ }
605+
606+
607+func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
608+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
609+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
610+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
611+ let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
612+ let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
613+ $Tuple2(actions, updatedDLp)
614+ }
615+
616+
617+func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
618+ then true
619+ else throwErr("updated DLp lower than current DLp")
620+
621+
622+func validateMatcherOrderAllowed (order) = {
623+ let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
624+ let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
625+ let amountAssetAmount = order.amount
626+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
627+ let $t02469024902 = if ((order.orderType == Buy))
628+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
629+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
630+ let amountAssetBalanceDelta = $t02469024902._1
631+ let priceAssetBalanceDelta = $t02469024902._2
453632 if (if (if (igs())
454633 then true
455- else (sts == PoolMatcherDis))
634+ else (cfgPoolStatus == PoolMatcherDis))
456635 then true
457- else (sts == PoolShutdown))
636+ else (cfgPoolStatus == PoolShutdown))
458637 then throw("Admin blocked")
459- else {
460- let orAmtAsset = order.assetPair.amountAsset
461- let orAmtAsStr = if ((orAmtAsset == unit))
462- then "WAVES"
463- else toBase58String(value(orAmtAsset))
464- let orPrAsset = order.assetPair.priceAsset
465- let orPrAsStr = if ((orPrAsset == unit))
466- then "WAVES"
467- else toBase58String(value(orPrAsset))
468- if (if ((orAmtAsStr != amtAsId))
469- then true
470- else (orPrAsStr != prAsId))
471- then throw("Wr assets")
472- else {
473- let orderPrice = order.price
474- let priceDcm = fraction(scale8, prAsDcm, amtAsDcm)
475- let castOrderPrice = ts(orderPrice, scale8, priceDcm)
476- let isOrderPriceValid = if ((order.orderType == Buy))
477- then (curPrice >= castOrderPrice)
478- else (castOrderPrice >= curPrice)
479- true
480- }
481- }
638+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
639+ then true
640+ else (order.assetPair.priceAsset != cfgPriceAssetId))
641+ then throw("Wr assets")
642+ else {
643+ let dLp = parseBigIntValue(valueOrElse(getString(this, keyDLp), "0"))
644+ let $t02524425344 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
645+ let unusedActions = $t02524425344._1
646+ let dLpNew = $t02524425344._2
647+ let isOrderValid = (dLpNew >= dLp)
648+ let info = makeString(["dLp=", toString(dLp), " dLpNew=", toString(dLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
649+ $Tuple2(isOrderValid, info)
650+ }
482651 }
483652
484653
514683 }
515684
516685
517-func getD (xp) = {
518- let n = big2
519- let xp0 = xp[0]
520- let xp1 = xp[1]
521- let aPrecision = parseBigIntValue(Amult)
522- let a = (parseBigIntValue(A) * aPrecision)
523- let s = (xp0 + xp1)
524- if ((s == big0))
525- then big0
526- else {
527- let ann = (a * n)
528- let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
529- let ann_s_aPrecision = ((ann * s) / aPrecision)
530- let ann_aPrecision = (ann - aPrecision)
531- let n1 = (n + big1)
532- func calc (acc,cur) = {
533- let $t02250222522 = acc
534- let d = $t02250222522._1
535- let found = $t02250222522._2
536- if ((found != unit))
537- then acc
538- else {
539- let dp = (((d * d) * d) / xp0_xp1_n_n)
540- let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
541- let dDiff = absBigInt((dNext - value(d)))
542- if ((big1 >= dDiff))
543- then $Tuple2(dNext, cur)
544- else $Tuple2(dNext, unit)
545- }
546- }
547-
548- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
549- let $t02298323030 = {
550- let $l = arr
551- let $s = size($l)
552- let $acc0 = $Tuple2(s, unit)
553- func $f0_1 ($a,$i) = if (($i >= $s))
554- then $a
555- else calc($a, $l[$i])
556-
557- func $f0_2 ($a,$i) = if (($i >= $s))
558- then $a
559- else throw("List size exceeds 25")
560-
561- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25)
562- }
563- let d = $t02298323030._1
564- let found = $t02298323030._2
565- if ((found != unit))
566- then d
567- else throw(("D calculation error, D = " + toString(d)))
568- }
569- }
570-
571-
572-func getYD (xp,i,D) = {
573- let n = big2
574- let x = xp[if ((i == 0))
575- then 1
576- else 0]
577- let aPrecision = parseBigIntValue(Amult)
578- let a = (parseBigIntValue(A) * aPrecision)
579- let s = x
580- let ann = (a * n)
581- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
582- let b = ((s + ((D * aPrecision) / ann)) - D)
583- func calc (acc,cur) = {
584- let $t02353023550 = acc
585- let y = $t02353023550._1
586- let found = $t02353023550._2
587- if ((found != unit))
588- then acc
589- else {
590- let yNext = (((y * y) + c) / ((big2 * y) + b))
591- let yDiff = absBigInt((yNext - value(y)))
592- if ((big1 >= yDiff))
593- then $Tuple2(yNext, cur)
594- else $Tuple2(yNext, unit)
595- }
596- }
597-
598- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
599- let $t02385723904 = {
600- let $l = arr
601- let $s = size($l)
602- let $acc0 = $Tuple2(D, unit)
603- func $f0_1 ($a,$i) = if (($i >= $s))
604- then $a
605- else calc($a, $l[$i])
606-
607- func $f0_2 ($a,$i) = if (($i >= $s))
608- then $a
609- else throw("List size exceeds 15")
610-
611- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
612- }
613- let y = $t02385723904._1
614- let found = $t02385723904._2
615- if ((found != unit))
616- then y
617- else throw(("Y calculation error, Y = " + toString(y)))
618- }
619-
620-
621686 func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
622- let poolConfig = gpc()
623- let amId = poolConfig[idxAmAsId]
624- let prId = poolConfig[idxPrAsId]
625- let lpId = poolConfig[idxLPAsId]
626- let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm])
627- let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm])
628- let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
687+ let amId = toBase58String(value(cfgAmountAssetId))
688+ let prId = toBase58String(value(cfgPriceAssetId))
689+ let lpId = cfgLpAssetId
690+ let amtDcm = cfgAmountAssetDecimals
691+ let priceDcm = cfgPriceAssetDecimals
692+ let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity)
629693 let chechEmission = if ((lpAssetEmission > big0))
630694 then true
631695 else throw("initial deposit requires all coins")
633697 then {
634698 let amBalance = getAccBalance(amId)
635699 let prBalance = getAccBalance(prId)
636- let $t02468725149 = if ((txId == ""))
700+ let $t02800028462 = if ((txId == ""))
637701 then $Tuple2(amBalance, prBalance)
638702 else if ((pmtAssetId == amId))
639703 then if ((pmtAmtRaw > amBalance))
644708 then throw("invalid payment amount")
645709 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
646710 else throw("wrong pmtAssetId")
647- let amBalanceOld = $t02468725149._1
648- let prBalanceOld = $t02468725149._2
649- let $t02515525331 = if ((pmtAssetId == amId))
711+ let amBalanceOld = $t02800028462._1
712+ let prBalanceOld = $t02800028462._2
713+ let $t02846828644 = if ((pmtAssetId == amId))
650714 then $Tuple2(pmtAmtRaw, 0)
651715 else if ((pmtAssetId == prId))
652716 then $Tuple2(0, pmtAmtRaw)
653717 else throw("invalid payment")
654- let amAmountRaw = $t02515525331._1
655- let prAmountRaw = $t02515525331._2
656- let $t02533525589 = if (withTakeFee)
718+ let amAmountRaw = $t02846828644._1
719+ let prAmountRaw = $t02846828644._2
720+ let $t02864828902 = if (withTakeFee)
657721 then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
658722 else $Tuple3(amAmountRaw, prAmountRaw, 0)
659- let amAmount = $t02533525589._1
660- let prAmount = $t02533525589._2
661- let feeAmount = $t02533525589._3
723+ let amAmount = $t02864828902._1
724+ let prAmount = $t02864828902._2
725+ let feeAmount = $t02864828902._3
662726 let amBalanceNew = (amBalanceOld + amAmount)
663727 let prBalanceNew = (prBalanceOld + prAmount)
664- let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
665- let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)])
728+ let D0 = getD([t1(amBalanceOld, cfgAmountAssetDecimals), t1(prBalanceOld, cfgPriceAssetDecimals)])
729+ let D1 = getD([t1(amBalanceNew, cfgAmountAssetDecimals), t1(prBalanceNew, cfgPriceAssetDecimals)])
666730 let checkD = if ((D1 > D0))
667731 then true
668732 else throw()
669733 if ((checkD == checkD))
670734 then {
671- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
735+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
672736 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
673737 let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmountRaw, prAmountRaw, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))]
674738 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
685749
686750
687751 func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = {
688- let poolConfig = gpc()
689- let lpId = poolConfig[idxLPAsId]
690- let amId = poolConfig[idxAmAsId]
691- let prId = poolConfig[idxPrAsId]
692- let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
693- let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
694- let poolStatus = poolConfig[idxPoolSt]
752+ let lpId = toBase58String(value(cfgLpAssetId))
753+ let amId = toBase58String(value(cfgAmountAssetId))
754+ let prId = toBase58String(value(cfgPriceAssetId))
755+ let amDecimals = cfgAmountAssetDecimals
756+ let prDecimals = cfgPriceAssetDecimals
757+ let poolStatus = cfgPoolStatus
695758 let userAddress = if ((caller == restContract))
696759 then originCaller
697760 else caller
698761 let pmt = value(payments[0])
699762 let pmtAssetId = value(pmt.assetId)
700763 let pmtAmt = pmt.amount
701- let txId58 = toBase58String(transactionId)
702- if ((lpId != toBase58String(pmtAssetId)))
703- then throw("Wrong LP")
704- else {
705- let amBalance = getAccBalance(amId)
706- let prBalance = getAccBalance(prId)
707- let $t02759127702 = {
708- let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
709- if ($isInstanceOf(@, "(Int, Int)"))
710- then @
711- else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
712- }
713- if (($t02759127702 == $t02759127702))
714- then {
715- let feeAmount = $t02759127702._2
716- let totalGet = $t02759127702._1
717- let totalAmount = if (if ((minOutAmount > 0))
718- then (minOutAmount > totalGet)
719- else false)
720- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
721- else totalGet
722- let $t02789228199 = if ((outAssetId == amId))
723- then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
724- else if ((outAssetId == prId))
725- then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
726- else throw("invalid out asset id")
727- let outAm = $t02789228199._1
728- let outPr = $t02789228199._2
729- let amBalanceNew = $t02789228199._3
730- let prBalanceNew = $t02789228199._4
731- let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
732- let curPr = f1(curPrX18, scale8)
733- let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
734- then unit
735- else fromBase58String(outAssetId)
736- let sendFeeToMatcher = if ((feeAmount > 0))
737- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
738- else nil
739- let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
740- if ((state == state))
764+ let currentDLp = calcCurrentDLp(big0, big0, big0)
765+ if ((currentDLp == currentDLp))
766+ then {
767+ let txId58 = toBase58String(transactionId)
768+ if ((lpId != toBase58String(pmtAssetId)))
769+ then throw("Wrong LP")
770+ else {
771+ let amBalance = getAccBalance(amId)
772+ let prBalance = getAccBalance(prId)
773+ let $t03101431125 = {
774+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
775+ if ($isInstanceOf(@, "(Int, Int)"))
776+ then @
777+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
778+ }
779+ if (($t03101431125 == $t03101431125))
741780 then {
742- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
743- if ((burn == burn))
744- then $Tuple2(state, totalAmount)
781+ let feeAmount = $t03101431125._2
782+ let totalGet = $t03101431125._1
783+ let totalAmount = if (if ((minOutAmount > 0))
784+ then (minOutAmount > totalGet)
785+ else false)
786+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
787+ else totalGet
788+ let $t03131531622 = if ((outAssetId == amId))
789+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
790+ else if ((outAssetId == prId))
791+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
792+ else throw("invalid out asset id")
793+ let outAm = $t03131531622._1
794+ let outPr = $t03131531622._2
795+ let amBalanceNew = $t03131531622._3
796+ let prBalanceNew = $t03131531622._4
797+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
798+ let curPr = f1(curPrX18, scale8)
799+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
800+ then unit
801+ else fromBase58String(outAssetId)
802+ let sendFeeToMatcher = if ((feeAmount > 0))
803+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
804+ else nil
805+ let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
806+ if ((state == state))
807+ then {
808+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
809+ if ((burn == burn))
810+ then {
811+ let $t03240732757 = {
812+ let feeAmountForCalc = if ((this == feeCollectorAddress))
813+ then 0
814+ else feeAmount
815+ let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
816+ then true
817+ else false
818+ if (outInAmountAsset)
819+ then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
820+ else $Tuple2(0, -((totalGet + feeAmountForCalc)))
821+ }
822+ let amountAssetBalanceDelta = $t03240732757._1
823+ let priceAssetBalanceDelta = $t03240732757._2
824+ let $t03276032868 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
825+ let refreshDLpActions = $t03276032868._1
826+ let updatedDLp = $t03276032868._2
827+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
828+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
829+ then $Tuple2((state ++ refreshDLpActions), totalAmount)
830+ else throw("Strict value is not equal to itself.")
831+ }
832+ else throw("Strict value is not equal to itself.")
833+ }
745834 else throw("Strict value is not equal to itself.")
746835 }
747836 else throw("Strict value is not equal to itself.")
748837 }
749- else throw("Strict value is not equal to itself.")
750838 }
839+ else throw("Strict value is not equal to itself.")
751840 }
752841
753842
795884 case _ =>
796885 throw("Match error")
797886 }
798-
799-
800-func getY (isReverse,D,poolAmountInBalance) = {
801- let poolConfig = gpc()
802- let amId = poolConfig[idxAmAsId]
803- let prId = poolConfig[idxPrAsId]
804- let n = big2
805- let aPrecision = parseBigIntValue(Amult)
806- let a = (parseBigIntValue(A) * aPrecision)
807- let xp = if ((isReverse == false))
808- then [(toBigInt(getAccBalance(amId)) + poolAmountInBalance), toBigInt(getAccBalance(prId))]
809- else [(toBigInt(getAccBalance(prId)) + poolAmountInBalance), toBigInt(getAccBalance(amId))]
810- let x = xp[0]
811- let s = x
812- let ann = (a * n)
813- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
814- let b = ((s + ((D * aPrecision) / ann)) - D)
815- func calc (acc,cur) = {
816- let $t03057130591 = acc
817- let y = $t03057130591._1
818- let found = $t03057130591._2
819- if ((found != unit))
820- then acc
821- else {
822- let yNext = (((y * y) + c) / ((big2 * y) + b))
823- let yDiff = absBigInt((yNext - value(y)))
824- if ((big1 >= yDiff))
825- then $Tuple2(yNext, cur)
826- else $Tuple2(yNext, unit)
827- }
828- }
829-
830- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
831- let $t03092230969 = {
832- let $l = arr
833- let $s = size($l)
834- let $acc0 = $Tuple2(D, unit)
835- func $f0_1 ($a,$i) = if (($i >= $s))
836- then $a
837- else calc($a, $l[$i])
838-
839- func $f0_2 ($a,$i) = if (($i >= $s))
840- then $a
841- else throw("List size exceeds 15")
842-
843- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
844- }
845- let y = $t03092230969._1
846- let found = $t03092230969._2
847- if ((found != unit))
848- then y
849- else throw(("Y calculation error, Y = " + toString(y)))
850- }
851-
852-
853-@Callable(i)
854-func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = {
855- let $t03119031614 = if ((isReverse == false))
856- then {
857- let assetOut = strf(this, pa())
858- let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn))
859- $Tuple2(assetOut, poolAmountInBalance)
860- }
861- else {
862- let assetOut = strf(this, aa())
863- let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn))
864- $Tuple2(assetOut, poolAmountInBalance)
865- }
866- let assetOut = $t03119031614._1
867- let poolAmountInBalance = $t03119031614._2
868- let poolConfig = gpc()
869- let amId = poolConfig[idxAmAsId]
870- let prId = poolConfig[idxPrAsId]
871- let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
872- let D = getD(xp)
873- let y = getY(isReverse, D, toBigInt(cleanAmountIn))
874- let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
875- let totalGetRaw = max([0, toInt(dy)])
876- let newXp = if ((isReverse == false))
877- then [(toBigInt(getAccBalance(amId)) + toBigInt(cleanAmountIn)), (toBigInt(getAccBalance(prId)) - dy)]
878- else [(toBigInt(getAccBalance(amId)) - dy), (toBigInt(getAccBalance(prId)) + toBigInt(cleanAmountIn))]
879- let newD = getD(newXp)
880- let checkD = if ((newD >= D))
881- then true
882- else throw(makeString(["new D is fewer error", toString(D), toString(newD)], "__"))
883- if ((checkD == checkD))
884- then $Tuple2(nil, totalGetRaw)
885- else throw("Strict value is not equal to itself.")
886- }
887-
888-
889-
890-@Callable(i)
891-func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = {
892- let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
893- then true
894- else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(strf(this, swapContract()))))
895- then true
896- else throwErr("Permission denied")]
897- if ((checks == checks))
898- then {
899- let pmt = value(i.payments[0])
900- let assetIn = if ((pmt.assetId == unit))
901- then toBase58String(toBytes("WAVES"))
902- else toBase58String(value(pmt.assetId))
903- let $t03301633410 = if ((isReverse == false))
904- then {
905- let assetOut = strf(this, pa())
906- let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
907- $Tuple2(assetOut, poolAmountInBalance)
908- }
909- else {
910- let assetOut = strf(this, aa())
911- let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
912- $Tuple2(assetOut, poolAmountInBalance)
913- }
914- let assetOut = $t03301633410._1
915- let poolAmountInBalance = $t03301633410._2
916- let poolConfig = gpc()
917- let amId = poolConfig[idxAmAsId]
918- let prId = poolConfig[idxPrAsId]
919- let xp = if ((isReverse == false))
920- then [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))]
921- else [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - toBigInt(value(i.payments[0]).amount))]
922- let D = getD(xp)
923- let y = getY(isReverse, D, toBigInt(0))
924- let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
925- let totalGetRaw = max([0, toInt(dy)])
926- let checkMin = if ((totalGetRaw >= amountOutMin))
927- then true
928- else throw("Exchange result is fewer coins than expected")
929- if ((checkMin == checkMin))
930- then {
931- let newXp = if ((isReverse == false))
932- then [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - dy)]
933- else [(toBigInt(getAccBalance(amId)) - dy), toBigInt(getAccBalance(prId))]
934- let newD = getD(newXp)
935- let checkD = if ((newD >= D))
936- then true
937- else throw("new D is fewer error")
938- if ((checkD == checkD))
939- then [ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, if ((assetIn == "WAVES"))
940- then unit
941- else fromBase58String(assetOut))]
942- else throw("Strict value is not equal to itself.")
943- }
944- else throw("Strict value is not equal to itself.")
945- }
946- else throw("Strict value is not equal to itself.")
947- }
948-
949887
950888
951889 @Callable(i)
1003941 else if ((size(i.payments) != 2))
1004942 then throw("2 pmnts expd")
1005943 else {
1006- let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "")
1007- let emitLpAmt = e._2
1008- let lpAssetId = e._7
1009- let state = e._9
1010- let amDiff = e._10
1011- let prDiff = e._11
1012- let amId = e._12
1013- let prId = e._13
1014- let r = invoke(fca, "emit", [emitLpAmt], nil)
1015- if ((r == r))
944+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
945+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
946+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
947+ if ((amountAssetBalance == amountAssetBalance))
1016948 then {
1017- let el = match r {
1018- case legacy: Address =>
1019- invoke(legacy, "emit", [emitLpAmt], nil)
1020- case _ =>
1021- unit
1022- }
1023- if ((el == el))
949+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
950+ if ((priceAssetBalance == priceAssetBalance))
1024951 then {
1025- let sa = if ((amDiff > 0))
1026- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1027- else nil
1028- if ((sa == sa))
952+ let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
953+ if ((lpAssetEmission == lpAssetEmission))
1029954 then {
1030- let sp = if ((prDiff > 0))
1031- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1032- else nil
1033- if ((sp == sp))
955+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
956+ if ((currentDLp == currentDLp))
1034957 then {
1035- let lpTrnsfr = if (autoStake)
958+ let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "")
959+ let emitLpAmt = e._2
960+ let lpAssetId = e._7
961+ let state = e._9
962+ let amDiff = e._10
963+ let prDiff = e._11
964+ let amId = e._12
965+ let prId = e._13
966+ let r = invoke(fca, "emit", [emitLpAmt], nil)
967+ if ((r == r))
1036968 then {
1037- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1038- if ((ss == ss))
1039- then nil
969+ let el = match r {
970+ case legacy: Address =>
971+ invoke(legacy, "emit", [emitLpAmt], nil)
972+ case _ =>
973+ unit
974+ }
975+ if ((el == el))
976+ then {
977+ let sa = if ((amDiff > 0))
978+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
979+ else nil
980+ if ((sa == sa))
981+ then {
982+ let sp = if ((prDiff > 0))
983+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
984+ else nil
985+ if ((sp == sp))
986+ then {
987+ let lpTrnsfr = if (autoStake)
988+ then {
989+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
990+ if ((ss == ss))
991+ then nil
992+ else throw("Strict value is not equal to itself.")
993+ }
994+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
995+ let $t03701737159 = refreshDLpInternal(0, 0, 0)
996+ let refreshDLpActions = $t03701737159._1
997+ let updatedDLp = $t03701737159._2
998+ let check = if ((updatedDLp >= currentDLp))
999+ then true
1000+ else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1001+ if ((check == check))
1002+ then {
1003+ let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1004+ if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1005+ then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1006+ else throw("Strict value is not equal to itself.")
1007+ }
1008+ else throw("Strict value is not equal to itself.")
1009+ }
1010+ else throw("Strict value is not equal to itself.")
1011+ }
1012+ else throw("Strict value is not equal to itself.")
1013+ }
10401014 else throw("Strict value is not equal to itself.")
10411015 }
1042- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1043- (state ++ lpTrnsfr)
1016+ else throw("Strict value is not equal to itself.")
10441017 }
10451018 else throw("Strict value is not equal to itself.")
10461019 }
10781051 else throwErr("exactly 1 payment are expected")]
10791052 if ((checks == checks))
10801053 then {
1081- let poolConfig = gpc()
1082- let amId = poolConfig[idxAmAsId]
1083- let prId = poolConfig[idxPrAsId]
1084- let lpId = fromBase58String(poolConfig[idxLPAsId])
1085- let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
1086- let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
1054+ let amId = toBase58String(value(cfgAmountAssetId))
1055+ let prId = toBase58String(value(cfgPriceAssetId))
1056+ let lpId = cfgLpAssetId
1057+ let amDecimals = cfgAmountAssetDecimals
1058+ let prDecimals = cfgPriceAssetDecimals
10871059 let userAddress = if ((i.caller == this))
10881060 then i.originCaller
10891061 else i.caller
10901062 let pmt = value(i.payments[0])
10911063 let pmtAssetId = toBase58String(value(pmt.assetId))
10921064 let pmtAmt = pmt.amount
1093- let $t03879838956 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1094- if (($t03879838956 == $t03879838956))
1065+ let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1066+ then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1067+ else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1068+ if ((currentDLp == currentDLp))
10951069 then {
1096- let feeAmount = $t03879838956._3
1097- let state = $t03879838956._2
1098- let estimLP = $t03879838956._1
1099- let emitLpAmt = if (if ((minOutAmount > 0))
1100- then (minOutAmount > estimLP)
1101- else false)
1102- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1103- else estimLP
1104- let e = invoke(fca, "emit", [emitLpAmt], nil)
1105- if ((e == e))
1070+ let $t03880038958 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1071+ if (($t03880038958 == $t03880038958))
11061072 then {
1107- let el = match e {
1108- case legacy: Address =>
1109- invoke(legacy, "emit", [emitLpAmt], nil)
1110- case _ =>
1111- unit
1112- }
1113- if ((el == el))
1073+ let feeAmount = $t03880038958._3
1074+ let state = $t03880038958._2
1075+ let estimLP = $t03880038958._1
1076+ let emitLpAmt = if (if ((minOutAmount > 0))
1077+ then (minOutAmount > estimLP)
1078+ else false)
1079+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1080+ else estimLP
1081+ let e = invoke(fca, "emit", [emitLpAmt], nil)
1082+ if ((e == e))
11141083 then {
1115- let lpTrnsfr = if (autoStake)
1084+ let el = match e {
1085+ case legacy: Address =>
1086+ invoke(legacy, "emit", [emitLpAmt], nil)
1087+ case _ =>
1088+ unit
1089+ }
1090+ if ((el == el))
11161091 then {
1117- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1118- if ((ss == ss))
1119- then nil
1092+ let lpTrnsfr = if (autoStake)
1093+ then {
1094+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1095+ if ((ss == ss))
1096+ then nil
1097+ else throw("Strict value is not equal to itself.")
1098+ }
1099+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1100+ let sendFeeToMatcher = if ((feeAmount > 0))
1101+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1102+ else nil
1103+ let $t03977340122 = if ((this == feeCollectorAddress))
1104+ then $Tuple2(0, 0)
1105+ else {
1106+ let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1107+ then true
1108+ else false
1109+ if (paymentInAmountAsset)
1110+ then $Tuple2(-(feeAmount), 0)
1111+ else $Tuple2(0, -(feeAmount))
1112+ }
1113+ let amountAssetBalanceDelta = $t03977340122._1
1114+ let priceAssetBalanceDelta = $t03977340122._2
1115+ let $t04012540233 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1116+ let refreshDLpActions = $t04012540233._1
1117+ let updatedDLp = $t04012540233._2
1118+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1119+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1120+ then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
11201121 else throw("Strict value is not equal to itself.")
11211122 }
1122- else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1123- let sendFeeToMatcher = if ((feeAmount > 0))
1124- then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1125- else nil
1126- $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt)
1123+ else throw("Strict value is not equal to itself.")
11271124 }
11281125 else throw("Strict value is not equal to itself.")
11291126 }
11431140 then throw("2 pmnts expd")
11441141 else {
11451142 let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, true, 0, "")
1146- estPut._9
1143+ let state = estPut._9
1144+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1145+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1146+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1147+ if ((currentDLp == currentDLp))
1148+ then {
1149+ let $t04126341328 = refreshDLpInternal(0, 0, 0)
1150+ let refreshDLpActions = $t04126341328._1
1151+ let updatedDLp = $t04126341328._2
1152+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1153+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1154+ then (state ++ refreshDLpActions)
1155+ else throw("Strict value is not equal to itself.")
1156+ }
1157+ else throw("Strict value is not equal to itself.")
11471158 }
11481159
11491160
11501161
11511162 @Callable(i)
11521163 func get () = {
1153- let r = cg(i)
1154- let outAmtAmt = r._1
1155- let outPrAmt = r._2
1156- let pmtAmt = r._3
1157- let pmtAssetId = r._4
1158- let state = r._5
1159- let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1160- if ((b == b))
1161- then state
1164+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1165+ if ((currentDLp == currentDLp))
1166+ then {
1167+ let r = cg(i)
1168+ let outAmtAmt = r._1
1169+ let outPrAmt = r._2
1170+ let pmtAmt = r._3
1171+ let pmtAssetId = r._4
1172+ let state = r._5
1173+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1174+ if ((b == b))
1175+ then {
1176+ let $t04250142583 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1177+ let refreshDLpActions = $t04250142583._1
1178+ let updatedDLp = $t04250142583._2
1179+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1180+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1181+ then (state ++ refreshDLpActions)
1182+ else throw("Strict value is not equal to itself.")
1183+ }
1184+ else throw("Strict value is not equal to itself.")
1185+ }
11621186 else throw("Strict value is not equal to itself.")
11631187 }
11641188
11861210 else throwErr("exactly 1 payment are expected")]
11871211 if ((checks == checks))
11881212 then {
1189- let $t04157841733 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1190- let state = $t04157841733._1
1191- let totalAmount = $t04157841733._2
1213+ let $t04320143356 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1214+ let state = $t04320143356._1
1215+ let totalAmount = $t04320143356._2
11921216 $Tuple2(state, totalAmount)
11931217 }
11941218 else throw("Strict value is not equal to itself.")
11971221
11981222
11991223 @Callable(i)
1224+func refreshDLp () = {
1225+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1226+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1227+ then unit
1228+ else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1229+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1230+ then {
1231+ let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1232+ let $t04388043944 = refreshDLpInternal(0, 0, 0)
1233+ let dLpUpdateActions = $t04388043944._1
1234+ let updatedDLp = $t04388043944._2
1235+ let actions = if ((dLp != updatedDLp))
1236+ then dLpUpdateActions
1237+ else throwErr("nothing to refresh")
1238+ $Tuple2(actions, toString(updatedDLp))
1239+ }
1240+ else throw("Strict value is not equal to itself.")
1241+ }
1242+
1243+
1244+
1245+@Callable(i)
12001246 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1201- let poolConfig = gpc()
1202- let amId = poolConfig[idxAmAsId]
1203- let prId = poolConfig[idxPrAsId]
1204- let lpId = poolConfig[idxLPAsId]
1247+ let amId = toBase58String(value(cfgAmountAssetId))
1248+ let prId = toBase58String(value(cfgPriceAssetId))
1249+ let lpId = toBase58String(value(cfgLpAssetId))
12051250 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
12061251 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
12071252 let D0 = getD(xp)
12141259 let newY = getYD(xp, index, D1)
12151260 let dy = (xp[index] - newY)
12161261 let totalGetRaw = max([0, toInt((dy - big1))])
1217- let $t04260342658 = takeFee(totalGetRaw, outFee)
1218- let totalGet = $t04260342658._1
1219- let feeAmount = $t04260342658._2
1262+ let $t04487444929 = takeFee(totalGetRaw, outFee)
1263+ let totalGet = $t04487444929._1
1264+ let feeAmount = $t04487444929._2
12201265 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
12211266 }
12221267
12241269
12251270 @Callable(i)
12261271 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1227- let poolConfig = gpc()
1228- let amId = poolConfig[idxAmAsId]
1229- let prId = poolConfig[idxPrAsId]
1230- let lpId = poolConfig[idxLPAsId]
1272+ let amId = toBase58String(value(cfgAmountAssetId))
1273+ let prId = toBase58String(value(cfgPriceAssetId))
1274+ let lpId = toBase58String(value(cfgLpAssetId))
12311275 let amBalance = getAccBalance(amId)
12321276 let prBalance = getAccBalance(prId)
1233- let $t04300343118 = {
1277+ let $t04530445419 = {
12341278 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
12351279 if ($isInstanceOf(@, "(Int, Int)"))
12361280 then @
12371281 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
12381282 }
1239- let totalGet = $t04300343118._1
1240- let feeAmount = $t04300343118._2
1283+ let totalGet = $t04530445419._1
1284+ let feeAmount = $t04530445419._2
12411285 let r = ego("", lpId, lpAssetAmount, this)
12421286 let outAmAmt = r._1
12431287 let outPrAmt = r._2
12651309 else if ((noLessThenPriceAsset > outPrAmt))
12661310 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
12671311 else {
1268- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1269- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1270- then state
1312+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1313+ if ((currentDLp == currentDLp))
1314+ then {
1315+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1316+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1317+ then {
1318+ let $t04658546666 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1319+ let refreshDLpActions = $t04658546666._1
1320+ let updatedDLp = $t04658546666._2
1321+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1322+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1323+ then (state ++ refreshDLpActions)
1324+ else throw("Strict value is not equal to itself.")
1325+ }
1326+ else throw("Strict value is not equal to itself.")
1327+ }
12711328 else throw("Strict value is not equal to itself.")
12721329 }
12731330 }
12811338 else true
12821339 if ((checkPayments == checkPayments))
12831340 then {
1284- let cfg = gpc()
12851341 let factoryCfg = gfc()
1286- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1342+ let lpAssetId = cfgLpAssetId
12871343 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1288- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1289- if ((unstakeInv == unstakeInv))
1344+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1345+ if ((currentDLp == currentDLp))
12901346 then {
1291- let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1292- let sts = parseIntValue(r._9)
1293- let state = r._10
1294- let v = if (if (igs())
1295- then true
1296- else (sts == PoolShutdown))
1297- then throw(("Blocked: " + toString(sts)))
1298- else true
1299- if ((v == v))
1347+ let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1348+ if ((unstakeInv == unstakeInv))
13001349 then {
1301- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1302- if ((burnA == burnA))
1303- then state
1350+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1351+ let outAmAmt = r._1
1352+ let outPrAmt = r._2
1353+ let sts = parseIntValue(r._9)
1354+ let state = r._10
1355+ let v = if (if (igs())
1356+ then true
1357+ else (sts == PoolShutdown))
1358+ then throw(("Blocked: " + toString(sts)))
1359+ else true
1360+ if ((v == v))
1361+ then {
1362+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1363+ if ((burnA == burnA))
1364+ then {
1365+ let $t04769347774 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1366+ let refreshDLpActions = $t04769347774._1
1367+ let updatedDLp = $t04769347774._2
1368+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1369+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1370+ then (state ++ refreshDLpActions)
1371+ else throw("Strict value is not equal to itself.")
1372+ }
1373+ else throw("Strict value is not equal to itself.")
1374+ }
13041375 else throw("Strict value is not equal to itself.")
13051376 }
13061377 else throw("Strict value is not equal to itself.")
13241395 else throw("no payments are expected")]
13251396 if ((checks == checks))
13261397 then {
1327- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1328- if ((unstakeInv == unstakeInv))
1398+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1399+ if ((currentDLp == currentDLp))
13291400 then {
1330- let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1331- let outAmAmt = res._1
1332- let outPrAmt = res._2
1333- let state = res._10
1334- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1335- then true
1336- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1337- then true
1338- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1339- if ((checkAmounts == checkAmounts))
1401+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1402+ if ((unstakeInv == unstakeInv))
13401403 then {
1341- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1342- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1343- then state
1404+ let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1405+ let outAmAmt = res._1
1406+ let outPrAmt = res._2
1407+ let state = res._10
1408+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1409+ then true
1410+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1411+ then true
1412+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1413+ if ((checkAmounts == checkAmounts))
1414+ then {
1415+ let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1416+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1417+ then {
1418+ let $t04902549106 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1419+ let refreshDLpActions = $t04902549106._1
1420+ let updatedDLp = $t04902549106._2
1421+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1422+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1423+ then (state ++ refreshDLpActions)
1424+ else throw("Strict value is not equal to itself.")
1425+ }
1426+ else throw("Strict value is not equal to itself.")
1427+ }
13441428 else throw("Strict value is not equal to itself.")
13451429 }
13461430 else throw("Strict value is not equal to itself.")
13741458 else throwErr("no payments are expected")]
13751459 if ((checks == checks))
13761460 then {
1377- let cfg = gpc()
13781461 let factoryCfg = gfc()
1379- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1462+ let lpAssetId = cfgLpAssetId
13801463 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
13811464 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
13821465 if ((unstakeInv == unstakeInv))
13831466 then {
1384- let $t04695647144 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1385- let state = $t04695647144._1
1386- let totalAmount = $t04695647144._2
1467+ let $t05000150189 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1468+ let state = $t05000150189._1
1469+ let totalAmount = $t05000150189._2
13871470 $Tuple2(state, totalAmount)
13881471 }
13891472 else throw("Strict value is not equal to itself.")
13951478
13961479 @Callable(i)
13971480 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1398- let poolConfig = gpc()
1399- let amId = poolConfig[idxAmAsId]
1400- let prId = poolConfig[idxPrAsId]
1401- let lpId = poolConfig[idxLPAsId]
1402- let $t04740347506 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1403- let lpAmount = $t04740347506._1
1404- let state = $t04740347506._2
1405- let feeAmount = $t04740347506._3
1406- let bonus = $t04740347506._4
1481+ let $t05031750420 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1482+ let lpAmount = $t05031750420._1
1483+ let state = $t05031750420._2
1484+ let feeAmount = $t05031750420._3
1485+ let bonus = $t05031750420._4
14071486 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
14081487 }
14091488
14111490
14121491 @Callable(i)
14131492 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1414- let poolConfig = gpc()
1415- let amId = poolConfig[idxAmAsId]
1416- let prId = poolConfig[idxPrAsId]
1417- let lpId = poolConfig[idxLPAsId]
1418- let $t04778547889 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1419- let lpAmount = $t04778547889._1
1420- let state = $t04778547889._2
1421- let feeAmount = $t04778547889._3
1422- let bonus = $t04778547889._4
1493+ let $t05056850672 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1494+ let lpAmount = $t05056850672._1
1495+ let state = $t05056850672._2
1496+ let feeAmount = $t05056850672._3
1497+ let bonus = $t05056850672._4
14231498 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
14241499 }
14251500
15041579 match tx {
15051580 case order: Order =>
15061581 let matcherPub = mp()
1507- let orderValid = moa(order)
1582+ let $t05346453533 = validateMatcherOrderAllowed(order)
1583+ let orderValid = $t05346453533._1
1584+ let orderValidInfo = $t05346453533._2
15081585 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
15091586 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
15101587 if (if (if (orderValid)
15131590 then matcherValid
15141591 else false)
15151592 then true
1516- else toe(orderValid, senderValid, matcherValid)
1593+ else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
15171594 case s: SetScriptTransaction =>
1518- let newHash = blake2b256(value(s.script))
1519- let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1520- let currentHash = scriptHash(this)
1521- if (if ((allowedHash == newHash))
1522- then (currentHash != newHash)
1523- else false)
1595+ if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
15241596 then true
1525- else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1597+ else {
1598+ let newHash = blake2b256(value(s.script))
1599+ let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1600+ let currentHash = scriptHash(this)
1601+ if ((allowedHash == newHash))
1602+ then (currentHash != newHash)
1603+ else false
1604+ }
15261605 case _ =>
15271606 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
15281607 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let scale8 = 100000000
55
66 let scale8BigInt = toBigInt(100000000)
77
88 let scale18 = toBigInt(1000000000000000000)
99
1010 let zeroBigInt = toBigInt(0)
1111
1212 let big0 = toBigInt(0)
1313
1414 let big1 = toBigInt(1)
1515
1616 let big2 = toBigInt(2)
17+
18+let big3 = toBigInt(3)
19+
20+let big4 = toBigInt(4)
1721
1822 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
1923
2024 let wavesString = "WAVES"
2125
2226 let Amult = "100"
2327
2428 let Dconv = "1"
2529
2630 let SEP = "__"
2731
2832 let EMPTY = ""
2933
3034 let PoolActive = 1
3135
3236 let PoolPutDis = 2
3337
3438 let PoolMatcherDis = 3
3539
3640 let PoolShutdown = 4
3741
3842 let idxPoolAddress = 1
3943
4044 let idxPoolSt = 2
4145
4246 let idxLPAsId = 3
4347
4448 let idxAmAsId = 4
4549
4650 let idxPrAsId = 5
4751
4852 let idxAmtAsDcm = 6
4953
5054 let idxPriceAsDcm = 7
5155
5256 let idxIAmtAsId = 8
5357
5458 let idxIPriceAsId = 9
5559
5660 let idxFactStakCntr = 1
5761
5862 let idxFactoryRestCntr = 6
5963
6064 let idxFactSlippCntr = 7
6165
6266 let idxFactGwxRewCntr = 10
6367
6468 let feeDefault = fraction(10, scale8, 10000)
6569
6670 func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
6771
6872
73+func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
74+
75+
6976 func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18))
77+
78+
79+func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round))
80+
81+
82+func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult))
83+
84+
85+func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18)
7086
7187
7288 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
7389
7490
7591 func abs (val) = if ((zeroBigInt > val))
7692 then -(val)
7793 else val
7894
7995
8096 func absBigInt (val) = if ((zeroBigInt > val))
8197 then -(val)
8298 else val
8399
84100
85101 func fc () = "%s__factoryContract"
86102
87103
88104 func mpk () = "%s__managerPublicKey"
89105
90106
91107 func pmpk () = "%s__pendingManagerPublicKey"
92108
93109
94110 func pl () = "%s%s__price__last"
95111
96112
97113 func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
98114
99115
100116 func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
101117
102118
103119 func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
104120
105121
106122 func aa () = "%s__amountAsset"
107123
108124
109125 func pa () = "%s__priceAsset"
110126
111127
112128 func amp () = "%s__amp"
113129
114130
115131 func ada () = "%s__addonAddr"
116132
117133
118-func swapContract () = "%s__swapContract"
134+let keyFee = "%s__fee"
119135
136+let fee = valueOrElse(getInteger(this, keyFee), feeDefault)
137+
138+let keyDLp = makeString(["%s", "dLp"], SEP)
139+
140+let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP)
141+
142+let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP)
143+
144+let dLpRefreshDelayDefault = 30
145+
146+let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault)
120147
121148 func fcfg () = "%s__factoryConfig"
122149
123150
124151 func mtpk () = "%s%s__matcher__publicKey"
125152
126153
127154 func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config")
128155
129156
130157 func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr)
131158
132159
133160 func aps () = "%s__shutdown"
134161
135162
136163 func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash"
137164
138165
139166 func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
140167
141168
142-func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
143-
144-
145-func str (val) = match val {
146- case valStr: String =>
147- valStr
148- case _ =>
149- throw("fail cast to String")
150-}
169+func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
151170
152171
153172 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
154173
155174
156175 func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
157176
158177
159178 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
179+
180+
181+func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
160182
161183
162184 let fca = addressFromStringValue(strf(this, fc()))
163185
164186 let inFee = {
165187 let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil)
166188 if ($isInstanceOf(@, "Int"))
167189 then @
168190 else throw(($getType(@) + " couldn't be cast to Int"))
169191 }
170192
171193 let outFee = {
172194 let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil)
173195 if ($isInstanceOf(@, "Int"))
174196 then @
175197 else throw(($getType(@) + " couldn't be cast to Int"))
176198 }
177199
178200 let A = strf(this, amp())
179201
180202 func igs () = valueOrElse(getBoolean(fca, aps()), false)
181203
182204
183205 func mp () = fromBase58String(strf(fca, mtpk()))
184206
185207
186208 let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress()))
187209
188210 func gpc () = {
189211 let amtAs = strf(this, aa())
190212 let priceAs = strf(this, pa())
191213 let iPriceAs = intf(fca, mba(priceAs))
192214 let iAmtAs = intf(fca, mba(amtAs))
193215 split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
194216 }
195217
196218
197219 func parseAssetId (input) = if ((input == wavesString))
198220 then unit
199221 else fromBase58String(input)
200222
201223
202224 func assetIdToString (input) = if ((input == unit))
203225 then wavesString
204226 else toBase58String(value(input))
205227
206228
207-func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm]))
229+func parsePoolConfig (poolConfig) = $Tuple9(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolSt]), fromBase58String(poolConfig[idxLPAsId]), parseAssetId(poolConfig[idxAmAsId]), parseAssetId(poolConfig[idxPrAsId]), parseIntValue(poolConfig[idxAmtAsDcm]), parseIntValue(poolConfig[idxPriceAsDcm]), fromBase58String(poolConfig[idxIAmtAsId]), fromBase58String(poolConfig[idxIPriceAsId]))
208230
209231
210232 let poolConfigParsed = parsePoolConfig(gpc())
211233
212-let $t069527138 = poolConfigParsed
234+let $t079658194 = poolConfigParsed
213235
214-let cfgPoolAddress = $t069527138._1
236+let cfgPoolAddress = $t079658194._1
215237
216-let cfgPoolStatus = $t069527138._2
238+let cfgPoolStatus = $t079658194._2
217239
218-let cfgLpAssetId = $t069527138._3
240+let cfgLpAssetId = $t079658194._3
219241
220-let cfgAmountAssetId = $t069527138._4
242+let cfgAmountAssetId = $t079658194._4
221243
222-let cfgPriceAssetId = $t069527138._5
244+let cfgPriceAssetId = $t079658194._5
223245
224-let cfgAmountAssetDecimals = $t069527138._6
246+let cfgAmountAssetDecimals = $t079658194._6
225247
226-let cfgPriceAssetDecimals = $t069527138._7
248+let cfgPriceAssetDecimals = $t079658194._7
249+
250+let cfgInAmountAssedId = $t079658194._8
251+
252+let cfgInPriceAssetId = $t079658194._9
227253
228254 func gfc () = split(strf(fca, fcfg()), SEP)
229255
230256
231257 let factoryConfig = gfc()
232258
233259 let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address")
234260
235261 let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address")
236262
237263 let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address")
238264
239265 let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address")
240266
241267 func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slipByUser,slippageReal,txHeight,txTimestamp,slipageAmAmt,slipagePrAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slipByUser), toString(slippageReal), toString(txHeight), toString(txTimestamp), toString(slipageAmAmt), toString(slipagePrAmt)], SEP)
242268
243269
244270 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)
245271
246272
247273 func getAccBalance (assetId) = if ((assetId == "WAVES"))
248274 then wavesBalance(this).available
249275 else assetBalance(this, fromBase58String(assetId))
250276
251277
252278 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
279+
280+
281+func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
253282
254283
255284 func vad (A1,A2,slippage) = {
256285 let diff = fraction((A1 - A2), scale8BigInt, A2)
257286 let pass = ((slippage - abs(diff)) > zeroBigInt)
258287 if (!(pass))
259288 then throw(("Big slpg: " + toString(diff)))
260289 else $Tuple2(pass, min([A1, A2]))
261290 }
262291
263292
264293 func vd (D1,D0,slpg) = {
265294 let diff = fraction(D0, scale8BigInt, D1)
266295 let fail = (slpg > diff)
267296 if (if (fail)
268297 then true
269298 else (D0 > D1))
270299 then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg)))
271300 else fail
272301 }
273302
274303
275304 func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
276305 let amtAsAmtX18 = t1(amAmt, amAssetDcm)
277306 let prAsAmtX18 = t1(prAmt, prAssetDcm)
278307 cpbi(prAsAmtX18, amtAsAmtX18)
279308 }
280309
281310
282311 func calcPrices (amAmt,prAmt,lpAmt) = {
283- let cfg = gpc()
284- let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
285- let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
312+ let amtAsDcm = cfgAmountAssetDecimals
313+ let prAsDcm = cfgPriceAssetDecimals
286314 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
287315 let amAmtX18 = t1(amAmt, amtAsDcm)
288316 let prAmtX18 = t1(prAmt, prAsDcm)
289317 let lpAmtX18 = t1(lpAmt, scale8)
290318 let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18)
291319 let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18)
292320 [priceX18, lpPrInAmAsX18, lpPrInPrAsX18]
293321 }
294322
295323
296324 func calculatePrices (amAmt,prAmt,lpAmt) = {
297325 let p = calcPrices(amAmt, prAmt, lpAmt)
298326 [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)]
299327 }
300328
301329
302330 func takeFee (amount,fee) = {
303331 let feeAmount = if ((fee == 0))
304332 then 0
305333 else fraction(amount, fee, scale8)
306334 $Tuple2((amount - feeAmount), feeAmount)
307335 }
308336
309337
338+func getD (xp) = {
339+ let xp0 = xp[0]
340+ let xp1 = xp[1]
341+ let s = (xp0 + xp1)
342+ if ((s == big0))
343+ then big0
344+ else {
345+ let a = parseIntValue(A)
346+ let ann = (a * 2)
347+ let p = fraction(xp0, xp1, big1)
348+ let xp0_xp1_n_n = fraction(p, big4, big1)
349+ let ann_s = fraction(toBigInt(ann), s, big1)
350+ let ann_1 = toBigInt((ann - 1))
351+ func calcDNext (d) = {
352+ let dd = fraction(d, d, big1)
353+ let ddd = fraction(dd, d, big1)
354+ let dp = fraction(ddd, big1, xp0_xp1_n_n)
355+ fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)))
356+ }
357+
358+ func calc (acc,i) = if (acc._2)
359+ then acc
360+ else {
361+ let d = acc._1
362+ let dNext = calcDNext(d)
363+ let dDiffRaw = (dNext - value(d))
364+ let dDiff = if ((big0 > dDiffRaw))
365+ then -(dDiffRaw)
366+ else dDiffRaw
367+ if ((big1 >= dDiff))
368+ then $Tuple2(dNext, true)
369+ else $Tuple2(dNext, false)
370+ }
371+
372+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
373+ let $t01269112739 = {
374+ let $l = arr
375+ let $s = size($l)
376+ let $acc0 = $Tuple2(s, false)
377+ func $f0_1 ($a,$i) = if (($i >= $s))
378+ then $a
379+ else calc($a, $l[$i])
380+
381+ func $f0_2 ($a,$i) = if (($i >= $s))
382+ then $a
383+ else throw("List size exceeds 15")
384+
385+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
386+ }
387+ let d = $t01269112739._1
388+ let found = $t01269112739._2
389+ if (found)
390+ then d
391+ else throw(("D calculation error, D = " + toString(d)))
392+ }
393+ }
394+
395+
310396 func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
311- let cfg = gpc()
312- let lpId = cfg[idxLPAsId]
313- let amId = cfg[idxAmAsId]
314- let prId = cfg[idxPrAsId]
315- let amDcm = parseIntValue(cfg[idxAmtAsDcm])
316- let prDcm = parseIntValue(cfg[idxPriceAsDcm])
317- let sts = cfg[idxPoolSt]
318- let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
319- if ((lpId != pmtAssetId))
397+ let lpId = cfgLpAssetId
398+ let amId = toBase58String(value(cfgAmountAssetId))
399+ let prId = toBase58String(value(cfgPriceAssetId))
400+ let amDcm = cfgAmountAssetDecimals
401+ let prDcm = cfgPriceAssetDecimals
402+ let sts = toString(cfgPoolStatus)
403+ let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity
404+ if ((toBase58String(lpId) != pmtAssetId))
320405 then throw("Wrong pmt asset")
321406 else {
322407 let amBalance = getAccBalance(amId)
323408 let amBalanceX18 = t1(amBalance, amDcm)
324409 let prBalance = getAccBalance(prId)
325410 let prBalanceX18 = t1(prBalance, prDcm)
326411 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
327412 let curPrice = f1(curPriceX18, scale8)
328413 let pmtLpAmtX18 = t1(pmtLpAmt, scale8)
329414 let lpEmissX18 = t1(lpEmiss, scale8)
330415 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
331416 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
332- let outAmAmt = f1(outAmAmtX18, amDcm)
333- let outPrAmt = f1(outPrAmtX18, prDcm)
417+ let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
418+ let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
334419 let state = if ((txId58 == ""))
335420 then nil
336421 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
337422 then unit
338423 else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES"))
339424 then unit
340425 else fromBase58String(prId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)]
341426 $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state)
342427 }
343428 }
344429
345430
346431 func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
347- let cfg = gpc()
348- let lpId = fromBase58String(cfg[idxLPAsId])
349- let amIdStr = cfg[idxAmAsId]
350- let prIdStr = cfg[idxPrAsId]
351- let inAmIdStr = cfg[idxIAmtAsId]
352- let inPrIdStr = cfg[idxIPriceAsId]
353- let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
354- let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
355- let sts = cfg[idxPoolSt]
432+ let lpId = cfgLpAssetId
433+ let amIdStr = toBase58String(value(cfgAmountAssetId))
434+ let prIdStr = toBase58String(value(cfgPriceAssetId))
435+ let inAmIdStr = cfgInAmountAssedId
436+ let inPrIdStr = cfgInPriceAssetId
437+ let amtDcm = cfgAmountAssetDecimals
438+ let priceDcm = cfgPriceAssetDecimals
439+ let sts = toString(cfgPoolStatus)
356440 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
357441 let amBalance = if (isEval)
358442 then getAccBalance(amIdStr)
359443 else if (if (isOneAsset)
360444 then (pmtId == amIdStr)
361445 else false)
362446 then (getAccBalance(amIdStr) - pmtAmt)
363447 else if (isOneAsset)
364448 then getAccBalance(amIdStr)
365449 else (getAccBalance(amIdStr) - inAmAmt)
366450 let prBalance = if (isEval)
367451 then getAccBalance(prIdStr)
368452 else if (if (isOneAsset)
369453 then (pmtId == prIdStr)
370454 else false)
371455 then (getAccBalance(prIdStr) - pmtAmt)
372456 else if (isOneAsset)
373457 then getAccBalance(prIdStr)
374458 else (getAccBalance(prIdStr) - inPrAmt)
375459 let inAmAssetAmtX18 = t1(inAmAmt, amtDcm)
376460 let inPrAssetAmtX18 = t1(inPrAmt, priceDcm)
377461 let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
378462 let amBalanceX18 = t1(amBalance, amtDcm)
379463 let prBalanceX18 = t1(prBalance, priceDcm)
464+ let D0 = getD([amBalanceX18, prBalanceX18])
380465 let r = if ((lpEm == 0))
381466 then {
382- let curPriceX18 = zeroBigInt
383- let slippageX18 = zeroBigInt
384- let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
385- $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
467+ let D1 = getD([(amBalanceX18 + inAmAssetAmtX18), (prBalanceX18 + inPrAssetAmtX18)])
468+ let checkD = if ((D1 > D0))
469+ then true
470+ else throw("D1 should be greater than D0")
471+ if ((checkD == checkD))
472+ then {
473+ let curPriceX18 = zeroBigInt
474+ let slippageX18 = zeroBigInt
475+ let lpAmtX18 = D1
476+ $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
477+ }
478+ else throw("Strict value is not equal to itself.")
386479 }
387480 else {
388481 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
389482 let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
390483 let slippageX18 = t1(slippage, scale8)
391484 if (if (if (validateSlippage)
392485 then (curPriceX18 != zeroBigInt)
393486 else false)
394487 then (slippageRealX18 > slippageX18)
395488 else false)
396489 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
397490 else {
398491 let lpEmissionX18 = t1(lpEm, scale8)
399- let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
400- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
492+ let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
493+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
401494 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
402495 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
403496 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
404497 let expAmtAssetAmtX18 = expectedAmts._1
405498 let expPriceAssetAmtX18 = expectedAmts._2
406- let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
407- $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
499+ let D1 = getD([(amBalanceX18 + expAmtAssetAmtX18), (prBalanceX18 + expPriceAssetAmtX18)])
500+ let checkD = if ((D1 > D0))
501+ then true
502+ else throw("D1 should be greater than D0")
503+ if ((checkD == checkD))
504+ then {
505+ let lpAmtX18 = fraction(lpEmissionX18, (D1 - D0), D0)
506+ $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18)
507+ }
508+ else throw("Strict value is not equal to itself.")
408509 }
409510 }
410511 let calcLpAmt = r._1
411512 let calcAmAssetPmt = r._2
412513 let calcPrAssetPmt = r._3
413514 let curPrice = f1(r._4, scale8)
414515 let slippageCalc = f1(r._5, scale8)
415516 if ((0 >= calcLpAmt))
416517 then throw("LP <= 0")
417518 else {
418519 let emitLpAmt = if (!(emitLp))
419520 then 0
420521 else calcLpAmt
421522 let amDiff = (inAmAmt - calcAmAssetPmt)
422523 let prDiff = (inPrAmt - calcPrAssetPmt)
423- let $t01760517950 = if (if (isOneAsset)
524+ let $t02057820923 = if (if (isOneAsset)
424525 then (pmtId == amIdStr)
425526 else false)
426527 then $Tuple2(pmtAmt, 0)
427528 else if (if (isOneAsset)
428529 then (pmtId == prIdStr)
429530 else false)
430531 then $Tuple2(0, pmtAmt)
431532 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
432- let writeAmAmt = $t01760517950._1
433- let writePrAmt = $t01760517950._2
533+ let writeAmAmt = $t02057820923._1
534+ let writePrAmt = $t02057820923._2
434535 let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(writeAmAmt, writePrAmt, emitLpAmt, curPrice, slippage, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))]
435536 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
436537 }
437538 }
438539
439540
440-func moa (order) = {
441- let cfg = gpc()
442- let amtAsId = cfg[idxAmAsId]
443- let prAsId = cfg[idxPrAsId]
444- let sts = parseIntValue(cfg[idxPoolSt])
445- let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
446- let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
447- let accAmtAsBalance = getAccBalance(amtAsId)
448- let accPrAsBalance = getAccBalance(prAsId)
449- let curPriceX18 = if ((order.orderType == Buy))
450- then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
451- else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
452- let curPrice = f1(curPriceX18, scale8)
541+func getYD (xp,i,D) = {
542+ let n = big2
543+ let x = xp[if ((i == 0))
544+ then 1
545+ else 0]
546+ let aPrecision = parseBigIntValue(Amult)
547+ let a = (parseBigIntValue(A) * aPrecision)
548+ let s = x
549+ let ann = (a * n)
550+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
551+ let b = ((s + ((D * aPrecision) / ann)) - D)
552+ func calc (acc,cur) = {
553+ let $t02211822138 = acc
554+ let y = $t02211822138._1
555+ let found = $t02211822138._2
556+ if ((found != unit))
557+ then acc
558+ else {
559+ let yNext = (((y * y) + c) / ((big2 * y) + b))
560+ let yDiff = absBigInt((yNext - value(y)))
561+ if ((big1 >= yDiff))
562+ then $Tuple2(yNext, cur)
563+ else $Tuple2(yNext, unit)
564+ }
565+ }
566+
567+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
568+ let $t02244522492 = {
569+ let $l = arr
570+ let $s = size($l)
571+ let $acc0 = $Tuple2(D, unit)
572+ func $f0_1 ($a,$i) = if (($i >= $s))
573+ then $a
574+ else calc($a, $l[$i])
575+
576+ func $f0_2 ($a,$i) = if (($i >= $s))
577+ then $a
578+ else throw("List size exceeds 15")
579+
580+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
581+ }
582+ let y = $t02244522492._1
583+ let found = $t02244522492._2
584+ if ((found != unit))
585+ then y
586+ else throw(("Y calculation error, Y = " + toString(y)))
587+ }
588+
589+
590+func calcDLp (amountBalance,priceBalance,lpEmission) = {
591+ let updatedDLp = fraction(getD([t1BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)), t1BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals))]), scale18, lpEmission)
592+ if ((lpEmission == big0))
593+ then big0
594+ else updatedDLp
595+ }
596+
597+
598+func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = {
599+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta)
600+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta)
601+ let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta)
602+ let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission)
603+ currentDLp
604+ }
605+
606+
607+func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = {
608+ let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta)
609+ let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta)
610+ let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta)
611+ let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission))
612+ let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))]
613+ $Tuple2(actions, updatedDLp)
614+ }
615+
616+
617+func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp))
618+ then true
619+ else throwErr("updated DLp lower than current DLp")
620+
621+
622+func validateMatcherOrderAllowed (order) = {
623+ let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId))
624+ let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId))
625+ let amountAssetAmount = order.amount
626+ let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR)
627+ let $t02469024902 = if ((order.orderType == Buy))
628+ then $Tuple2(amountAssetAmount, -(priceAssetAmount))
629+ else $Tuple2(-(amountAssetAmount), priceAssetAmount)
630+ let amountAssetBalanceDelta = $t02469024902._1
631+ let priceAssetBalanceDelta = $t02469024902._2
453632 if (if (if (igs())
454633 then true
455- else (sts == PoolMatcherDis))
634+ else (cfgPoolStatus == PoolMatcherDis))
456635 then true
457- else (sts == PoolShutdown))
636+ else (cfgPoolStatus == PoolShutdown))
458637 then throw("Admin blocked")
459- else {
460- let orAmtAsset = order.assetPair.amountAsset
461- let orAmtAsStr = if ((orAmtAsset == unit))
462- then "WAVES"
463- else toBase58String(value(orAmtAsset))
464- let orPrAsset = order.assetPair.priceAsset
465- let orPrAsStr = if ((orPrAsset == unit))
466- then "WAVES"
467- else toBase58String(value(orPrAsset))
468- if (if ((orAmtAsStr != amtAsId))
469- then true
470- else (orPrAsStr != prAsId))
471- then throw("Wr assets")
472- else {
473- let orderPrice = order.price
474- let priceDcm = fraction(scale8, prAsDcm, amtAsDcm)
475- let castOrderPrice = ts(orderPrice, scale8, priceDcm)
476- let isOrderPriceValid = if ((order.orderType == Buy))
477- then (curPrice >= castOrderPrice)
478- else (castOrderPrice >= curPrice)
479- true
480- }
481- }
638+ else if (if ((order.assetPair.amountAsset != cfgAmountAssetId))
639+ then true
640+ else (order.assetPair.priceAsset != cfgPriceAssetId))
641+ then throw("Wr assets")
642+ else {
643+ let dLp = parseBigIntValue(valueOrElse(getString(this, keyDLp), "0"))
644+ let $t02524425344 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
645+ let unusedActions = $t02524425344._1
646+ let dLpNew = $t02524425344._2
647+ let isOrderValid = (dLpNew >= dLp)
648+ let info = makeString(["dLp=", toString(dLp), " dLpNew=", toString(dLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "")
649+ $Tuple2(isOrderValid, info)
650+ }
482651 }
483652
484653
485654 func cg (i) = if ((size(i.payments) != 1))
486655 then throw("1 pmnt exp")
487656 else {
488657 let pmt = value(i.payments[0])
489658 let pmtAssetId = value(pmt.assetId)
490659 let pmtAmt = pmt.amount
491660 let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
492661 let outAmAmt = r._1
493662 let outPrAmt = r._2
494663 let sts = parseIntValue(r._9)
495664 let state = r._10
496665 if (if (igs())
497666 then true
498667 else (sts == PoolShutdown))
499668 then throw(("Admin blocked: " + toString(sts)))
500669 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
501670 }
502671
503672
504673 func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
505674 let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId)
506675 let sts = parseIntValue(r._8)
507676 if (if (if (igs())
508677 then true
509678 else (sts == PoolPutDis))
510679 then true
511680 else (sts == PoolShutdown))
512681 then throw(("Blocked:" + toString(sts)))
513682 else r
514683 }
515684
516685
517-func getD (xp) = {
518- let n = big2
519- let xp0 = xp[0]
520- let xp1 = xp[1]
521- let aPrecision = parseBigIntValue(Amult)
522- let a = (parseBigIntValue(A) * aPrecision)
523- let s = (xp0 + xp1)
524- if ((s == big0))
525- then big0
526- else {
527- let ann = (a * n)
528- let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
529- let ann_s_aPrecision = ((ann * s) / aPrecision)
530- let ann_aPrecision = (ann - aPrecision)
531- let n1 = (n + big1)
532- func calc (acc,cur) = {
533- let $t02250222522 = acc
534- let d = $t02250222522._1
535- let found = $t02250222522._2
536- if ((found != unit))
537- then acc
538- else {
539- let dp = (((d * d) * d) / xp0_xp1_n_n)
540- let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
541- let dDiff = absBigInt((dNext - value(d)))
542- if ((big1 >= dDiff))
543- then $Tuple2(dNext, cur)
544- else $Tuple2(dNext, unit)
545- }
546- }
547-
548- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
549- let $t02298323030 = {
550- let $l = arr
551- let $s = size($l)
552- let $acc0 = $Tuple2(s, unit)
553- func $f0_1 ($a,$i) = if (($i >= $s))
554- then $a
555- else calc($a, $l[$i])
556-
557- func $f0_2 ($a,$i) = if (($i >= $s))
558- then $a
559- else throw("List size exceeds 25")
560-
561- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25)
562- }
563- let d = $t02298323030._1
564- let found = $t02298323030._2
565- if ((found != unit))
566- then d
567- else throw(("D calculation error, D = " + toString(d)))
568- }
569- }
570-
571-
572-func getYD (xp,i,D) = {
573- let n = big2
574- let x = xp[if ((i == 0))
575- then 1
576- else 0]
577- let aPrecision = parseBigIntValue(Amult)
578- let a = (parseBigIntValue(A) * aPrecision)
579- let s = x
580- let ann = (a * n)
581- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
582- let b = ((s + ((D * aPrecision) / ann)) - D)
583- func calc (acc,cur) = {
584- let $t02353023550 = acc
585- let y = $t02353023550._1
586- let found = $t02353023550._2
587- if ((found != unit))
588- then acc
589- else {
590- let yNext = (((y * y) + c) / ((big2 * y) + b))
591- let yDiff = absBigInt((yNext - value(y)))
592- if ((big1 >= yDiff))
593- then $Tuple2(yNext, cur)
594- else $Tuple2(yNext, unit)
595- }
596- }
597-
598- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
599- let $t02385723904 = {
600- let $l = arr
601- let $s = size($l)
602- let $acc0 = $Tuple2(D, unit)
603- func $f0_1 ($a,$i) = if (($i >= $s))
604- then $a
605- else calc($a, $l[$i])
606-
607- func $f0_2 ($a,$i) = if (($i >= $s))
608- then $a
609- else throw("List size exceeds 15")
610-
611- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
612- }
613- let y = $t02385723904._1
614- let found = $t02385723904._2
615- if ((found != unit))
616- then y
617- else throw(("Y calculation error, Y = " + toString(y)))
618- }
619-
620-
621686 func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
622- let poolConfig = gpc()
623- let amId = poolConfig[idxAmAsId]
624- let prId = poolConfig[idxPrAsId]
625- let lpId = poolConfig[idxLPAsId]
626- let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm])
627- let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm])
628- let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
687+ let amId = toBase58String(value(cfgAmountAssetId))
688+ let prId = toBase58String(value(cfgPriceAssetId))
689+ let lpId = cfgLpAssetId
690+ let amtDcm = cfgAmountAssetDecimals
691+ let priceDcm = cfgPriceAssetDecimals
692+ let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity)
629693 let chechEmission = if ((lpAssetEmission > big0))
630694 then true
631695 else throw("initial deposit requires all coins")
632696 if ((chechEmission == chechEmission))
633697 then {
634698 let amBalance = getAccBalance(amId)
635699 let prBalance = getAccBalance(prId)
636- let $t02468725149 = if ((txId == ""))
700+ let $t02800028462 = if ((txId == ""))
637701 then $Tuple2(amBalance, prBalance)
638702 else if ((pmtAssetId == amId))
639703 then if ((pmtAmtRaw > amBalance))
640704 then throw("invalid payment amount")
641705 else $Tuple2((amBalance - pmtAmtRaw), prBalance)
642706 else if ((pmtAssetId == prId))
643707 then if ((pmtAmtRaw > prBalance))
644708 then throw("invalid payment amount")
645709 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
646710 else throw("wrong pmtAssetId")
647- let amBalanceOld = $t02468725149._1
648- let prBalanceOld = $t02468725149._2
649- let $t02515525331 = if ((pmtAssetId == amId))
711+ let amBalanceOld = $t02800028462._1
712+ let prBalanceOld = $t02800028462._2
713+ let $t02846828644 = if ((pmtAssetId == amId))
650714 then $Tuple2(pmtAmtRaw, 0)
651715 else if ((pmtAssetId == prId))
652716 then $Tuple2(0, pmtAmtRaw)
653717 else throw("invalid payment")
654- let amAmountRaw = $t02515525331._1
655- let prAmountRaw = $t02515525331._2
656- let $t02533525589 = if (withTakeFee)
718+ let amAmountRaw = $t02846828644._1
719+ let prAmountRaw = $t02846828644._2
720+ let $t02864828902 = if (withTakeFee)
657721 then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
658722 else $Tuple3(amAmountRaw, prAmountRaw, 0)
659- let amAmount = $t02533525589._1
660- let prAmount = $t02533525589._2
661- let feeAmount = $t02533525589._3
723+ let amAmount = $t02864828902._1
724+ let prAmount = $t02864828902._2
725+ let feeAmount = $t02864828902._3
662726 let amBalanceNew = (amBalanceOld + amAmount)
663727 let prBalanceNew = (prBalanceOld + prAmount)
664- let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
665- let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)])
728+ let D0 = getD([t1(amBalanceOld, cfgAmountAssetDecimals), t1(prBalanceOld, cfgPriceAssetDecimals)])
729+ let D1 = getD([t1(amBalanceNew, cfgAmountAssetDecimals), t1(prBalanceNew, cfgPriceAssetDecimals)])
666730 let checkD = if ((D1 > D0))
667731 then true
668732 else throw()
669733 if ((checkD == checkD))
670734 then {
671- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
735+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
672736 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
673737 let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId), dataPutActionInfo(amAmountRaw, prAmountRaw, toInt(lpAmount), curPrice, 0, 0, height, lastBlock.timestamp, 0, 0))]
674738 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
675739 let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8))
676740 let priceAssetPart = (pmtAmtRaw - amountAssetPart)
677741 let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld))
678742 let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth))
679743 $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus)
680744 }
681745 else throw("Strict value is not equal to itself.")
682746 }
683747 else throw("Strict value is not equal to itself.")
684748 }
685749
686750
687751 func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = {
688- let poolConfig = gpc()
689- let lpId = poolConfig[idxLPAsId]
690- let amId = poolConfig[idxAmAsId]
691- let prId = poolConfig[idxPrAsId]
692- let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
693- let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
694- let poolStatus = poolConfig[idxPoolSt]
752+ let lpId = toBase58String(value(cfgLpAssetId))
753+ let amId = toBase58String(value(cfgAmountAssetId))
754+ let prId = toBase58String(value(cfgPriceAssetId))
755+ let amDecimals = cfgAmountAssetDecimals
756+ let prDecimals = cfgPriceAssetDecimals
757+ let poolStatus = cfgPoolStatus
695758 let userAddress = if ((caller == restContract))
696759 then originCaller
697760 else caller
698761 let pmt = value(payments[0])
699762 let pmtAssetId = value(pmt.assetId)
700763 let pmtAmt = pmt.amount
701- let txId58 = toBase58String(transactionId)
702- if ((lpId != toBase58String(pmtAssetId)))
703- then throw("Wrong LP")
704- else {
705- let amBalance = getAccBalance(amId)
706- let prBalance = getAccBalance(prId)
707- let $t02759127702 = {
708- let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
709- if ($isInstanceOf(@, "(Int, Int)"))
710- then @
711- else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
712- }
713- if (($t02759127702 == $t02759127702))
714- then {
715- let feeAmount = $t02759127702._2
716- let totalGet = $t02759127702._1
717- let totalAmount = if (if ((minOutAmount > 0))
718- then (minOutAmount > totalGet)
719- else false)
720- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
721- else totalGet
722- let $t02789228199 = if ((outAssetId == amId))
723- then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
724- else if ((outAssetId == prId))
725- then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
726- else throw("invalid out asset id")
727- let outAm = $t02789228199._1
728- let outPr = $t02789228199._2
729- let amBalanceNew = $t02789228199._3
730- let prBalanceNew = $t02789228199._4
731- let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
732- let curPr = f1(curPrX18, scale8)
733- let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
734- then unit
735- else fromBase58String(outAssetId)
736- let sendFeeToMatcher = if ((feeAmount > 0))
737- then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
738- else nil
739- let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
740- if ((state == state))
764+ let currentDLp = calcCurrentDLp(big0, big0, big0)
765+ if ((currentDLp == currentDLp))
766+ then {
767+ let txId58 = toBase58String(transactionId)
768+ if ((lpId != toBase58String(pmtAssetId)))
769+ then throw("Wrong LP")
770+ else {
771+ let amBalance = getAccBalance(amId)
772+ let prBalance = getAccBalance(prId)
773+ let $t03101431125 = {
774+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
775+ if ($isInstanceOf(@, "(Int, Int)"))
776+ then @
777+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
778+ }
779+ if (($t03101431125 == $t03101431125))
741780 then {
742- let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
743- if ((burn == burn))
744- then $Tuple2(state, totalAmount)
781+ let feeAmount = $t03101431125._2
782+ let totalGet = $t03101431125._1
783+ let totalAmount = if (if ((minOutAmount > 0))
784+ then (minOutAmount > totalGet)
785+ else false)
786+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
787+ else totalGet
788+ let $t03131531622 = if ((outAssetId == amId))
789+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
790+ else if ((outAssetId == prId))
791+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
792+ else throw("invalid out asset id")
793+ let outAm = $t03131531622._1
794+ let outPr = $t03131531622._2
795+ let amBalanceNew = $t03131531622._3
796+ let prBalanceNew = $t03131531622._4
797+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
798+ let curPr = f1(curPrX18, scale8)
799+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
800+ then unit
801+ else fromBase58String(outAssetId)
802+ let sendFeeToMatcher = if ((feeAmount > 0))
803+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
804+ else nil
805+ let state = ([ScriptTransfer(userAddress, totalAmount, outAssetIdOrWaves), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAm, outPr, pmtAmt, curPr, height, lastBlock.timestamp)), IntegerEntry(pl(), curPr), IntegerEntry(ph(height, lastBlock.timestamp), curPr)] ++ sendFeeToMatcher)
806+ if ((state == state))
807+ then {
808+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
809+ if ((burn == burn))
810+ then {
811+ let $t03240732757 = {
812+ let feeAmountForCalc = if ((this == feeCollectorAddress))
813+ then 0
814+ else feeAmount
815+ let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId))
816+ then true
817+ else false
818+ if (outInAmountAsset)
819+ then $Tuple2(-((totalGet + feeAmountForCalc)), 0)
820+ else $Tuple2(0, -((totalGet + feeAmountForCalc)))
821+ }
822+ let amountAssetBalanceDelta = $t03240732757._1
823+ let priceAssetBalanceDelta = $t03240732757._2
824+ let $t03276032868 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
825+ let refreshDLpActions = $t03276032868._1
826+ let updatedDLp = $t03276032868._2
827+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
828+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
829+ then $Tuple2((state ++ refreshDLpActions), totalAmount)
830+ else throw("Strict value is not equal to itself.")
831+ }
832+ else throw("Strict value is not equal to itself.")
833+ }
745834 else throw("Strict value is not equal to itself.")
746835 }
747836 else throw("Strict value is not equal to itself.")
748837 }
749- else throw("Strict value is not equal to itself.")
750838 }
839+ else throw("Strict value is not equal to itself.")
751840 }
752841
753842
754843 func m () = match getString(mpk()) {
755844 case s: String =>
756845 fromBase58String(s)
757846 case _: Unit =>
758847 unit
759848 case _ =>
760849 throw("Match error")
761850 }
762851
763852
764853 func pm () = match getString(pmpk()) {
765854 case s: String =>
766855 fromBase58String(s)
767856 case _: Unit =>
768857 unit
769858 case _ =>
770859 throw("Match error")
771860 }
772861
773862
774863 let pd = throw("Permission denied")
775864
776865 func isManager (i) = match m() {
777866 case pk: ByteVector =>
778867 (i.callerPublicKey == pk)
779868 case _: Unit =>
780869 (i.caller == this)
781870 case _ =>
782871 throw("Match error")
783872 }
784873
785874
786875 func mm (i) = match m() {
787876 case pk: ByteVector =>
788877 if ((i.callerPublicKey == pk))
789878 then true
790879 else pd
791880 case _: Unit =>
792881 if ((i.caller == this))
793882 then true
794883 else pd
795884 case _ =>
796885 throw("Match error")
797886 }
798-
799-
800-func getY (isReverse,D,poolAmountInBalance) = {
801- let poolConfig = gpc()
802- let amId = poolConfig[idxAmAsId]
803- let prId = poolConfig[idxPrAsId]
804- let n = big2
805- let aPrecision = parseBigIntValue(Amult)
806- let a = (parseBigIntValue(A) * aPrecision)
807- let xp = if ((isReverse == false))
808- then [(toBigInt(getAccBalance(amId)) + poolAmountInBalance), toBigInt(getAccBalance(prId))]
809- else [(toBigInt(getAccBalance(prId)) + poolAmountInBalance), toBigInt(getAccBalance(amId))]
810- let x = xp[0]
811- let s = x
812- let ann = (a * n)
813- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
814- let b = ((s + ((D * aPrecision) / ann)) - D)
815- func calc (acc,cur) = {
816- let $t03057130591 = acc
817- let y = $t03057130591._1
818- let found = $t03057130591._2
819- if ((found != unit))
820- then acc
821- else {
822- let yNext = (((y * y) + c) / ((big2 * y) + b))
823- let yDiff = absBigInt((yNext - value(y)))
824- if ((big1 >= yDiff))
825- then $Tuple2(yNext, cur)
826- else $Tuple2(yNext, unit)
827- }
828- }
829-
830- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
831- let $t03092230969 = {
832- let $l = arr
833- let $s = size($l)
834- let $acc0 = $Tuple2(D, unit)
835- func $f0_1 ($a,$i) = if (($i >= $s))
836- then $a
837- else calc($a, $l[$i])
838-
839- func $f0_2 ($a,$i) = if (($i >= $s))
840- then $a
841- else throw("List size exceeds 15")
842-
843- $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15)
844- }
845- let y = $t03092230969._1
846- let found = $t03092230969._2
847- if ((found != unit))
848- then y
849- else throw(("Y calculation error, Y = " + toString(y)))
850- }
851-
852-
853-@Callable(i)
854-func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = {
855- let $t03119031614 = if ((isReverse == false))
856- then {
857- let assetOut = strf(this, pa())
858- let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn))
859- $Tuple2(assetOut, poolAmountInBalance)
860- }
861- else {
862- let assetOut = strf(this, aa())
863- let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn))
864- $Tuple2(assetOut, poolAmountInBalance)
865- }
866- let assetOut = $t03119031614._1
867- let poolAmountInBalance = $t03119031614._2
868- let poolConfig = gpc()
869- let amId = poolConfig[idxAmAsId]
870- let prId = poolConfig[idxPrAsId]
871- let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
872- let D = getD(xp)
873- let y = getY(isReverse, D, toBigInt(cleanAmountIn))
874- let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
875- let totalGetRaw = max([0, toInt(dy)])
876- let newXp = if ((isReverse == false))
877- then [(toBigInt(getAccBalance(amId)) + toBigInt(cleanAmountIn)), (toBigInt(getAccBalance(prId)) - dy)]
878- else [(toBigInt(getAccBalance(amId)) - dy), (toBigInt(getAccBalance(prId)) + toBigInt(cleanAmountIn))]
879- let newD = getD(newXp)
880- let checkD = if ((newD >= D))
881- then true
882- else throw(makeString(["new D is fewer error", toString(D), toString(newD)], "__"))
883- if ((checkD == checkD))
884- then $Tuple2(nil, totalGetRaw)
885- else throw("Strict value is not equal to itself.")
886- }
887-
888-
889-
890-@Callable(i)
891-func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = {
892- let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
893- then true
894- else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(strf(this, swapContract()))))
895- then true
896- else throwErr("Permission denied")]
897- if ((checks == checks))
898- then {
899- let pmt = value(i.payments[0])
900- let assetIn = if ((pmt.assetId == unit))
901- then toBase58String(toBytes("WAVES"))
902- else toBase58String(value(pmt.assetId))
903- let $t03301633410 = if ((isReverse == false))
904- then {
905- let assetOut = strf(this, pa())
906- let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
907- $Tuple2(assetOut, poolAmountInBalance)
908- }
909- else {
910- let assetOut = strf(this, aa())
911- let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
912- $Tuple2(assetOut, poolAmountInBalance)
913- }
914- let assetOut = $t03301633410._1
915- let poolAmountInBalance = $t03301633410._2
916- let poolConfig = gpc()
917- let amId = poolConfig[idxAmAsId]
918- let prId = poolConfig[idxPrAsId]
919- let xp = if ((isReverse == false))
920- then [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))]
921- else [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - toBigInt(value(i.payments[0]).amount))]
922- let D = getD(xp)
923- let y = getY(isReverse, D, toBigInt(0))
924- let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
925- let totalGetRaw = max([0, toInt(dy)])
926- let checkMin = if ((totalGetRaw >= amountOutMin))
927- then true
928- else throw("Exchange result is fewer coins than expected")
929- if ((checkMin == checkMin))
930- then {
931- let newXp = if ((isReverse == false))
932- then [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - dy)]
933- else [(toBigInt(getAccBalance(amId)) - dy), toBigInt(getAccBalance(prId))]
934- let newD = getD(newXp)
935- let checkD = if ((newD >= D))
936- then true
937- else throw("new D is fewer error")
938- if ((checkD == checkD))
939- then [ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, if ((assetIn == "WAVES"))
940- then unit
941- else fromBase58String(assetOut))]
942- else throw("Strict value is not equal to itself.")
943- }
944- else throw("Strict value is not equal to itself.")
945- }
946- else throw("Strict value is not equal to itself.")
947- }
948-
949887
950888
951889 @Callable(i)
952890 func constructor (fc) = {
953891 let c = mm(i)
954892 if ((c == c))
955893 then [StringEntry(fc(), fc)]
956894 else throw("Strict value is not equal to itself.")
957895 }
958896
959897
960898
961899 @Callable(i)
962900 func setManager (pendingManagerPublicKey) = {
963901 let c = mm(i)
964902 if ((c == c))
965903 then {
966904 let cm = fromBase58String(pendingManagerPublicKey)
967905 if ((cm == cm))
968906 then [StringEntry(pmpk(), pendingManagerPublicKey)]
969907 else throw("Strict value is not equal to itself.")
970908 }
971909 else throw("Strict value is not equal to itself.")
972910 }
973911
974912
975913
976914 @Callable(i)
977915 func confirmManager () = {
978916 let p = pm()
979917 let hpm = if (isDefined(p))
980918 then true
981919 else throw("No pending manager")
982920 if ((hpm == hpm))
983921 then {
984922 let cpm = if ((i.callerPublicKey == value(p)))
985923 then true
986924 else throw("You are not pending manager")
987925 if ((cpm == cpm))
988926 then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
989927 else throw("Strict value is not equal to itself.")
990928 }
991929 else throw("Strict value is not equal to itself.")
992930 }
993931
994932
995933
996934 @Callable(i)
997935 func put (slip,autoStake) = {
998936 let factCfg = gfc()
999937 let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
1000938 let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
1001939 if ((0 > slip))
1002940 then throw("Wrong slippage")
1003941 else if ((size(i.payments) != 2))
1004942 then throw("2 pmnts expd")
1005943 else {
1006- let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "")
1007- let emitLpAmt = e._2
1008- let lpAssetId = e._7
1009- let state = e._9
1010- let amDiff = e._10
1011- let prDiff = e._11
1012- let amId = e._12
1013- let prId = e._13
1014- let r = invoke(fca, "emit", [emitLpAmt], nil)
1015- if ((r == r))
944+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
945+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
946+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
947+ if ((amountAssetBalance == amountAssetBalance))
1016948 then {
1017- let el = match r {
1018- case legacy: Address =>
1019- invoke(legacy, "emit", [emitLpAmt], nil)
1020- case _ =>
1021- unit
1022- }
1023- if ((el == el))
949+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
950+ if ((priceAssetBalance == priceAssetBalance))
1024951 then {
1025- let sa = if ((amDiff > 0))
1026- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1027- else nil
1028- if ((sa == sa))
952+ let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
953+ if ((lpAssetEmission == lpAssetEmission))
1029954 then {
1030- let sp = if ((prDiff > 0))
1031- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1032- else nil
1033- if ((sp == sp))
955+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
956+ if ((currentDLp == currentDLp))
1034957 then {
1035- let lpTrnsfr = if (autoStake)
958+ let e = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], slip, true, false, true, 0, "")
959+ let emitLpAmt = e._2
960+ let lpAssetId = e._7
961+ let state = e._9
962+ let amDiff = e._10
963+ let prDiff = e._11
964+ let amId = e._12
965+ let prId = e._13
966+ let r = invoke(fca, "emit", [emitLpAmt], nil)
967+ if ((r == r))
1036968 then {
1037- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1038- if ((ss == ss))
1039- then nil
969+ let el = match r {
970+ case legacy: Address =>
971+ invoke(legacy, "emit", [emitLpAmt], nil)
972+ case _ =>
973+ unit
974+ }
975+ if ((el == el))
976+ then {
977+ let sa = if ((amDiff > 0))
978+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
979+ else nil
980+ if ((sa == sa))
981+ then {
982+ let sp = if ((prDiff > 0))
983+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
984+ else nil
985+ if ((sp == sp))
986+ then {
987+ let lpTrnsfr = if (autoStake)
988+ then {
989+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
990+ if ((ss == ss))
991+ then nil
992+ else throw("Strict value is not equal to itself.")
993+ }
994+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
995+ let $t03701737159 = refreshDLpInternal(0, 0, 0)
996+ let refreshDLpActions = $t03701737159._1
997+ let updatedDLp = $t03701737159._2
998+ let check = if ((updatedDLp >= currentDLp))
999+ then true
1000+ else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1001+ if ((check == check))
1002+ then {
1003+ let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1004+ if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1005+ then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1006+ else throw("Strict value is not equal to itself.")
1007+ }
1008+ else throw("Strict value is not equal to itself.")
1009+ }
1010+ else throw("Strict value is not equal to itself.")
1011+ }
1012+ else throw("Strict value is not equal to itself.")
1013+ }
10401014 else throw("Strict value is not equal to itself.")
10411015 }
1042- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1043- (state ++ lpTrnsfr)
1016+ else throw("Strict value is not equal to itself.")
10441017 }
10451018 else throw("Strict value is not equal to itself.")
10461019 }
10471020 else throw("Strict value is not equal to itself.")
10481021 }
10491022 else throw("Strict value is not equal to itself.")
10501023 }
10511024 else throw("Strict value is not equal to itself.")
10521025 }
10531026 }
10541027
10551028
10561029
10571030 @Callable(i)
10581031 func putOneTknV2 (minOutAmount,autoStake) = {
10591032 let isPoolOneTokenOperationsDisabled = {
10601033 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
10611034 if ($isInstanceOf(@, "Boolean"))
10621035 then @
10631036 else throw(($getType(@) + " couldn't be cast to Boolean"))
10641037 }
10651038 let isPutDisabled = if (if (if (igs())
10661039 then true
10671040 else (cfgPoolStatus == PoolPutDis))
10681041 then true
10691042 else (cfgPoolStatus == PoolShutdown))
10701043 then true
10711044 else isPoolOneTokenOperationsDisabled
10721045 let checks = [if (if (!(isPutDisabled))
10731046 then true
10741047 else isManager(i))
10751048 then true
10761049 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
10771050 then true
10781051 else throwErr("exactly 1 payment are expected")]
10791052 if ((checks == checks))
10801053 then {
1081- let poolConfig = gpc()
1082- let amId = poolConfig[idxAmAsId]
1083- let prId = poolConfig[idxPrAsId]
1084- let lpId = fromBase58String(poolConfig[idxLPAsId])
1085- let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
1086- let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
1054+ let amId = toBase58String(value(cfgAmountAssetId))
1055+ let prId = toBase58String(value(cfgPriceAssetId))
1056+ let lpId = cfgLpAssetId
1057+ let amDecimals = cfgAmountAssetDecimals
1058+ let prDecimals = cfgPriceAssetDecimals
10871059 let userAddress = if ((i.caller == this))
10881060 then i.originCaller
10891061 else i.caller
10901062 let pmt = value(i.payments[0])
10911063 let pmtAssetId = toBase58String(value(pmt.assetId))
10921064 let pmtAmt = pmt.amount
1093- let $t03879838956 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1094- if (($t03879838956 == $t03879838956))
1065+ let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1066+ then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1067+ else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1068+ if ((currentDLp == currentDLp))
10951069 then {
1096- let feeAmount = $t03879838956._3
1097- let state = $t03879838956._2
1098- let estimLP = $t03879838956._1
1099- let emitLpAmt = if (if ((minOutAmount > 0))
1100- then (minOutAmount > estimLP)
1101- else false)
1102- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1103- else estimLP
1104- let e = invoke(fca, "emit", [emitLpAmt], nil)
1105- if ((e == e))
1070+ let $t03880038958 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1071+ if (($t03880038958 == $t03880038958))
11061072 then {
1107- let el = match e {
1108- case legacy: Address =>
1109- invoke(legacy, "emit", [emitLpAmt], nil)
1110- case _ =>
1111- unit
1112- }
1113- if ((el == el))
1073+ let feeAmount = $t03880038958._3
1074+ let state = $t03880038958._2
1075+ let estimLP = $t03880038958._1
1076+ let emitLpAmt = if (if ((minOutAmount > 0))
1077+ then (minOutAmount > estimLP)
1078+ else false)
1079+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1080+ else estimLP
1081+ let e = invoke(fca, "emit", [emitLpAmt], nil)
1082+ if ((e == e))
11141083 then {
1115- let lpTrnsfr = if (autoStake)
1084+ let el = match e {
1085+ case legacy: Address =>
1086+ invoke(legacy, "emit", [emitLpAmt], nil)
1087+ case _ =>
1088+ unit
1089+ }
1090+ if ((el == el))
11161091 then {
1117- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1118- if ((ss == ss))
1119- then nil
1092+ let lpTrnsfr = if (autoStake)
1093+ then {
1094+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1095+ if ((ss == ss))
1096+ then nil
1097+ else throw("Strict value is not equal to itself.")
1098+ }
1099+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1100+ let sendFeeToMatcher = if ((feeAmount > 0))
1101+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1102+ else nil
1103+ let $t03977340122 = if ((this == feeCollectorAddress))
1104+ then $Tuple2(0, 0)
1105+ else {
1106+ let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1107+ then true
1108+ else false
1109+ if (paymentInAmountAsset)
1110+ then $Tuple2(-(feeAmount), 0)
1111+ else $Tuple2(0, -(feeAmount))
1112+ }
1113+ let amountAssetBalanceDelta = $t03977340122._1
1114+ let priceAssetBalanceDelta = $t03977340122._2
1115+ let $t04012540233 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1116+ let refreshDLpActions = $t04012540233._1
1117+ let updatedDLp = $t04012540233._2
1118+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1119+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1120+ then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
11201121 else throw("Strict value is not equal to itself.")
11211122 }
1122- else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1123- let sendFeeToMatcher = if ((feeAmount > 0))
1124- then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1125- else nil
1126- $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt)
1123+ else throw("Strict value is not equal to itself.")
11271124 }
11281125 else throw("Strict value is not equal to itself.")
11291126 }
11301127 else throw("Strict value is not equal to itself.")
11311128 }
11321129 else throw("Strict value is not equal to itself.")
11331130 }
11341131 else throw("Strict value is not equal to itself.")
11351132 }
11361133
11371134
11381135
11391136 @Callable(i)
11401137 func putForFree (maxSlpg) = if ((0 > maxSlpg))
11411138 then throw("Wrong slpg")
11421139 else if ((size(i.payments) != 2))
11431140 then throw("2 pmnts expd")
11441141 else {
11451142 let estPut = cp(toString(i.caller), toBase58String(i.transactionId), AttachedPayment(value(i.payments[0]).assetId, value(i.payments[0]).amount), i.payments[1], maxSlpg, false, false, true, 0, "")
1146- estPut._9
1143+ let state = estPut._9
1144+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1145+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1146+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1147+ if ((currentDLp == currentDLp))
1148+ then {
1149+ let $t04126341328 = refreshDLpInternal(0, 0, 0)
1150+ let refreshDLpActions = $t04126341328._1
1151+ let updatedDLp = $t04126341328._2
1152+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1153+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1154+ then (state ++ refreshDLpActions)
1155+ else throw("Strict value is not equal to itself.")
1156+ }
1157+ else throw("Strict value is not equal to itself.")
11471158 }
11481159
11491160
11501161
11511162 @Callable(i)
11521163 func get () = {
1153- let r = cg(i)
1154- let outAmtAmt = r._1
1155- let outPrAmt = r._2
1156- let pmtAmt = r._3
1157- let pmtAssetId = r._4
1158- let state = r._5
1159- let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1160- if ((b == b))
1161- then state
1164+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1165+ if ((currentDLp == currentDLp))
1166+ then {
1167+ let r = cg(i)
1168+ let outAmtAmt = r._1
1169+ let outPrAmt = r._2
1170+ let pmtAmt = r._3
1171+ let pmtAssetId = r._4
1172+ let state = r._5
1173+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1174+ if ((b == b))
1175+ then {
1176+ let $t04250142583 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1177+ let refreshDLpActions = $t04250142583._1
1178+ let updatedDLp = $t04250142583._2
1179+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1180+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1181+ then (state ++ refreshDLpActions)
1182+ else throw("Strict value is not equal to itself.")
1183+ }
1184+ else throw("Strict value is not equal to itself.")
1185+ }
11621186 else throw("Strict value is not equal to itself.")
11631187 }
11641188
11651189
11661190
11671191 @Callable(i)
11681192 func getOneTknV2 (outAssetId,minOutAmount) = {
11691193 let isPoolOneTokenOperationsDisabled = {
11701194 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
11711195 if ($isInstanceOf(@, "Boolean"))
11721196 then @
11731197 else throw(($getType(@) + " couldn't be cast to Boolean"))
11741198 }
11751199 let isGetDisabled = if (if (igs())
11761200 then true
11771201 else (cfgPoolStatus == PoolShutdown))
11781202 then true
11791203 else isPoolOneTokenOperationsDisabled
11801204 let checks = [if (if (!(isGetDisabled))
11811205 then true
11821206 else isManager(i))
11831207 then true
11841208 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
11851209 then true
11861210 else throwErr("exactly 1 payment are expected")]
11871211 if ((checks == checks))
11881212 then {
1189- let $t04157841733 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1190- let state = $t04157841733._1
1191- let totalAmount = $t04157841733._2
1213+ let $t04320143356 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1214+ let state = $t04320143356._1
1215+ let totalAmount = $t04320143356._2
11921216 $Tuple2(state, totalAmount)
11931217 }
11941218 else throw("Strict value is not equal to itself.")
11951219 }
11961220
11971221
11981222
11991223 @Callable(i)
1224+func refreshDLp () = {
1225+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1226+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1227+ then unit
1228+ else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1229+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1230+ then {
1231+ let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1232+ let $t04388043944 = refreshDLpInternal(0, 0, 0)
1233+ let dLpUpdateActions = $t04388043944._1
1234+ let updatedDLp = $t04388043944._2
1235+ let actions = if ((dLp != updatedDLp))
1236+ then dLpUpdateActions
1237+ else throwErr("nothing to refresh")
1238+ $Tuple2(actions, toString(updatedDLp))
1239+ }
1240+ else throw("Strict value is not equal to itself.")
1241+ }
1242+
1243+
1244+
1245+@Callable(i)
12001246 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1201- let poolConfig = gpc()
1202- let amId = poolConfig[idxAmAsId]
1203- let prId = poolConfig[idxPrAsId]
1204- let lpId = poolConfig[idxLPAsId]
1247+ let amId = toBase58String(value(cfgAmountAssetId))
1248+ let prId = toBase58String(value(cfgPriceAssetId))
1249+ let lpId = toBase58String(value(cfgLpAssetId))
12051250 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
12061251 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
12071252 let D0 = getD(xp)
12081253 let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission))
12091254 let index = if ((outAssetId == amId))
12101255 then 0
12111256 else if ((outAssetId == prId))
12121257 then 1
12131258 else throw("invalid out asset id")
12141259 let newY = getYD(xp, index, D1)
12151260 let dy = (xp[index] - newY)
12161261 let totalGetRaw = max([0, toInt((dy - big1))])
1217- let $t04260342658 = takeFee(totalGetRaw, outFee)
1218- let totalGet = $t04260342658._1
1219- let feeAmount = $t04260342658._2
1262+ let $t04487444929 = takeFee(totalGetRaw, outFee)
1263+ let totalGet = $t04487444929._1
1264+ let feeAmount = $t04487444929._2
12201265 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
12211266 }
12221267
12231268
12241269
12251270 @Callable(i)
12261271 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1227- let poolConfig = gpc()
1228- let amId = poolConfig[idxAmAsId]
1229- let prId = poolConfig[idxPrAsId]
1230- let lpId = poolConfig[idxLPAsId]
1272+ let amId = toBase58String(value(cfgAmountAssetId))
1273+ let prId = toBase58String(value(cfgPriceAssetId))
1274+ let lpId = toBase58String(value(cfgLpAssetId))
12311275 let amBalance = getAccBalance(amId)
12321276 let prBalance = getAccBalance(prId)
1233- let $t04300343118 = {
1277+ let $t04530445419 = {
12341278 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
12351279 if ($isInstanceOf(@, "(Int, Int)"))
12361280 then @
12371281 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
12381282 }
1239- let totalGet = $t04300343118._1
1240- let feeAmount = $t04300343118._2
1283+ let totalGet = $t04530445419._1
1284+ let feeAmount = $t04530445419._2
12411285 let r = ego("", lpId, lpAssetAmount, this)
12421286 let outAmAmt = r._1
12431287 let outPrAmt = r._2
12441288 let sumOfGetAssets = (outAmAmt + outPrAmt)
12451289 let bonus = if ((sumOfGetAssets == 0))
12461290 then if ((totalGet == 0))
12471291 then 0
12481292 else throw("bonus calculation error")
12491293 else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets)
12501294 $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus))
12511295 }
12521296
12531297
12541298
12551299 @Callable(i)
12561300 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
12571301 let r = cg(i)
12581302 let outAmAmt = r._1
12591303 let outPrAmt = r._2
12601304 let pmtAmt = r._3
12611305 let pmtAssetId = r._4
12621306 let state = r._5
12631307 if ((noLessThenAmtAsset > outAmAmt))
12641308 then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
12651309 else if ((noLessThenPriceAsset > outPrAmt))
12661310 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
12671311 else {
1268- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1269- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1270- then state
1312+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1313+ if ((currentDLp == currentDLp))
1314+ then {
1315+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1316+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1317+ then {
1318+ let $t04658546666 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1319+ let refreshDLpActions = $t04658546666._1
1320+ let updatedDLp = $t04658546666._2
1321+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1322+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1323+ then (state ++ refreshDLpActions)
1324+ else throw("Strict value is not equal to itself.")
1325+ }
1326+ else throw("Strict value is not equal to itself.")
1327+ }
12711328 else throw("Strict value is not equal to itself.")
12721329 }
12731330 }
12741331
12751332
12761333
12771334 @Callable(i)
12781335 func unstakeAndGet (amount) = {
12791336 let checkPayments = if ((size(i.payments) != 0))
12801337 then throw("No pmnts expd")
12811338 else true
12821339 if ((checkPayments == checkPayments))
12831340 then {
1284- let cfg = gpc()
12851341 let factoryCfg = gfc()
1286- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1342+ let lpAssetId = cfgLpAssetId
12871343 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1288- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1289- if ((unstakeInv == unstakeInv))
1344+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1345+ if ((currentDLp == currentDLp))
12901346 then {
1291- let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1292- let sts = parseIntValue(r._9)
1293- let state = r._10
1294- let v = if (if (igs())
1295- then true
1296- else (sts == PoolShutdown))
1297- then throw(("Blocked: " + toString(sts)))
1298- else true
1299- if ((v == v))
1347+ let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1348+ if ((unstakeInv == unstakeInv))
13001349 then {
1301- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1302- if ((burnA == burnA))
1303- then state
1350+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1351+ let outAmAmt = r._1
1352+ let outPrAmt = r._2
1353+ let sts = parseIntValue(r._9)
1354+ let state = r._10
1355+ let v = if (if (igs())
1356+ then true
1357+ else (sts == PoolShutdown))
1358+ then throw(("Blocked: " + toString(sts)))
1359+ else true
1360+ if ((v == v))
1361+ then {
1362+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1363+ if ((burnA == burnA))
1364+ then {
1365+ let $t04769347774 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1366+ let refreshDLpActions = $t04769347774._1
1367+ let updatedDLp = $t04769347774._2
1368+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1369+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1370+ then (state ++ refreshDLpActions)
1371+ else throw("Strict value is not equal to itself.")
1372+ }
1373+ else throw("Strict value is not equal to itself.")
1374+ }
13041375 else throw("Strict value is not equal to itself.")
13051376 }
13061377 else throw("Strict value is not equal to itself.")
13071378 }
13081379 else throw("Strict value is not equal to itself.")
13091380 }
13101381 else throw("Strict value is not equal to itself.")
13111382 }
13121383
13131384
13141385
13151386 @Callable(i)
13161387 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
13171388 let isGetDisabled = if (igs())
13181389 then true
13191390 else (cfgPoolStatus == PoolShutdown)
13201391 let checks = [if (!(isGetDisabled))
13211392 then true
13221393 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
13231394 then true
13241395 else throw("no payments are expected")]
13251396 if ((checks == checks))
13261397 then {
1327- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1328- if ((unstakeInv == unstakeInv))
1398+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1399+ if ((currentDLp == currentDLp))
13291400 then {
1330- let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1331- let outAmAmt = res._1
1332- let outPrAmt = res._2
1333- let state = res._10
1334- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1335- then true
1336- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1337- then true
1338- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1339- if ((checkAmounts == checkAmounts))
1401+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1402+ if ((unstakeInv == unstakeInv))
13401403 then {
1341- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1342- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1343- then state
1404+ let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1405+ let outAmAmt = res._1
1406+ let outPrAmt = res._2
1407+ let state = res._10
1408+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1409+ then true
1410+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1411+ then true
1412+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1413+ if ((checkAmounts == checkAmounts))
1414+ then {
1415+ let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1416+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1417+ then {
1418+ let $t04902549106 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1419+ let refreshDLpActions = $t04902549106._1
1420+ let updatedDLp = $t04902549106._2
1421+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1422+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1423+ then (state ++ refreshDLpActions)
1424+ else throw("Strict value is not equal to itself.")
1425+ }
1426+ else throw("Strict value is not equal to itself.")
1427+ }
13441428 else throw("Strict value is not equal to itself.")
13451429 }
13461430 else throw("Strict value is not equal to itself.")
13471431 }
13481432 else throw("Strict value is not equal to itself.")
13491433 }
13501434 else throw("Strict value is not equal to itself.")
13511435 }
13521436
13531437
13541438
13551439 @Callable(i)
13561440 func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = {
13571441 let isPoolOneTokenOperationsDisabled = {
13581442 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
13591443 if ($isInstanceOf(@, "Boolean"))
13601444 then @
13611445 else throw(($getType(@) + " couldn't be cast to Boolean"))
13621446 }
13631447 let isGetDisabled = if (if (igs())
13641448 then true
13651449 else (cfgPoolStatus == PoolShutdown))
13661450 then true
13671451 else isPoolOneTokenOperationsDisabled
13681452 let checks = [if (if (!(isGetDisabled))
13691453 then true
13701454 else isManager(i))
13711455 then true
13721456 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
13731457 then true
13741458 else throwErr("no payments are expected")]
13751459 if ((checks == checks))
13761460 then {
1377- let cfg = gpc()
13781461 let factoryCfg = gfc()
1379- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1462+ let lpAssetId = cfgLpAssetId
13801463 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
13811464 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
13821465 if ((unstakeInv == unstakeInv))
13831466 then {
1384- let $t04695647144 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1385- let state = $t04695647144._1
1386- let totalAmount = $t04695647144._2
1467+ let $t05000150189 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1468+ let state = $t05000150189._1
1469+ let totalAmount = $t05000150189._2
13871470 $Tuple2(state, totalAmount)
13881471 }
13891472 else throw("Strict value is not equal to itself.")
13901473 }
13911474 else throw("Strict value is not equal to itself.")
13921475 }
13931476
13941477
13951478
13961479 @Callable(i)
13971480 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1398- let poolConfig = gpc()
1399- let amId = poolConfig[idxAmAsId]
1400- let prId = poolConfig[idxPrAsId]
1401- let lpId = poolConfig[idxLPAsId]
1402- let $t04740347506 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1403- let lpAmount = $t04740347506._1
1404- let state = $t04740347506._2
1405- let feeAmount = $t04740347506._3
1406- let bonus = $t04740347506._4
1481+ let $t05031750420 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1482+ let lpAmount = $t05031750420._1
1483+ let state = $t05031750420._2
1484+ let feeAmount = $t05031750420._3
1485+ let bonus = $t05031750420._4
14071486 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
14081487 }
14091488
14101489
14111490
14121491 @Callable(i)
14131492 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1414- let poolConfig = gpc()
1415- let amId = poolConfig[idxAmAsId]
1416- let prId = poolConfig[idxPrAsId]
1417- let lpId = poolConfig[idxLPAsId]
1418- let $t04778547889 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1419- let lpAmount = $t04778547889._1
1420- let state = $t04778547889._2
1421- let feeAmount = $t04778547889._3
1422- let bonus = $t04778547889._4
1493+ let $t05056850672 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1494+ let lpAmount = $t05056850672._1
1495+ let state = $t05056850672._2
1496+ let feeAmount = $t05056850672._3
1497+ let bonus = $t05056850672._4
14231498 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
14241499 }
14251500
14261501
14271502
14281503 @Callable(i)
14291504 func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
14301505 then throw("denied")
14311506 else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
14321507
14331508
14341509
14351510 @Callable(i)
14361511 func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
14371512 then pd
14381513 else [StringEntry(k, v)]
14391514
14401515
14411516
14421517 @Callable(i)
14431518 func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
14441519 then pd
14451520 else [IntegerEntry(k, v)]
14461521
14471522
14481523
14491524 @Callable(i)
14501525 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
14511526
14521527
14531528
14541529 @Callable(i)
14551530 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
14561531
14571532
14581533
14591534 @Callable(i)
14601535 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
14611536 let pr = calcPrices(amAmt, prAmt, lpAmt)
14621537 $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])])
14631538 }
14641539
14651540
14661541
14671542 @Callable(i)
14681543 func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
14691544
14701545
14711546
14721547 @Callable(i)
14731548 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
14741549
14751550
14761551
14771552 @Callable(i)
14781553 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
14791554
14801555
14811556
14821557 @Callable(i)
14831558 func estimatePutOperationWrapperREADONLY (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,usrAddr,isEval,emitLp) = $Tuple2(nil, epo(txId58, slippage, inAmAmt, inAmId, inPrAmt, inPrId, usrAddr, isEval, emitLp, true, false, 0, ""))
14841559
14851560
14861561
14871562 @Callable(i)
14881563 func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
14891564 let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
14901565 $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
14911566 }
14921567
14931568
14941569 @Verifier(tx)
14951570 func verify () = {
14961571 let targetPublicKey = match m() {
14971572 case pk: ByteVector =>
14981573 pk
14991574 case _: Unit =>
15001575 tx.senderPublicKey
15011576 case _ =>
15021577 throw("Match error")
15031578 }
15041579 match tx {
15051580 case order: Order =>
15061581 let matcherPub = mp()
1507- let orderValid = moa(order)
1582+ let $t05346453533 = validateMatcherOrderAllowed(order)
1583+ let orderValid = $t05346453533._1
1584+ let orderValidInfo = $t05346453533._2
15081585 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
15091586 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
15101587 if (if (if (orderValid)
15111588 then senderValid
15121589 else false)
15131590 then matcherValid
15141591 else false)
15151592 then true
1516- else toe(orderValid, senderValid, matcherValid)
1593+ else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
15171594 case s: SetScriptTransaction =>
1518- let newHash = blake2b256(value(s.script))
1519- let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1520- let currentHash = scriptHash(this)
1521- if (if ((allowedHash == newHash))
1522- then (currentHash != newHash)
1523- else false)
1595+ if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
15241596 then true
1525- else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1597+ else {
1598+ let newHash = blake2b256(value(s.script))
1599+ let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1600+ let currentHash = scriptHash(this)
1601+ if ((allowedHash == newHash))
1602+ then (currentHash != newHash)
1603+ else false
1604+ }
15261605 case _ =>
15271606 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
15281607 }
15291608 }
15301609

github/deemru/w8io/026f985 
450.63 ms