tx · GeE4KG5d4Hrq1FxkHiryNNZkcTWzx7DUdmah2zzt8wNN

3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT:  -0.03900000 Waves

2023.02.09 12:51 [2441946] smart account 3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT > SELF 0.00000000 Waves

{ "type": 13, "id": "GeE4KG5d4Hrq1FxkHiryNNZkcTWzx7DUdmah2zzt8wNN", "fee": 3900000, "feeAssetId": null, "timestamp": 1675936262002, "version": 2, "chainId": 84, "sender": "3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT", "senderPublicKey": "D1BL65meykxFZTCuq7jq9HSGLLnWvQamQPUNrguW5w39", "proofs": [ "tA17RTegwngLv4CJmhz5hAfFB6sc67eLkk8p73CpLxHpGCytTnQLE1MUt9ynEyNZoyNBuoh5PUDgys7pZ21j2UL" ], "script": "base64:BgLYKggCEgQKAgEEEgYKBAEEAQgSAwoBCBIDCgEIEgASBAoCAQQSBAoCAQQSAwoBARIAEgQKAggBEgASBAoCCAESBAoCCAESBAoCAQESAwoBARIFCgMBAQESBQoDAQgBEgQKAgEIEgQKAgEIEgQKAggIEgQKAggIEgQKAggBEgASAwoBCBIFCgMBAQESBAoCCAESBAoCAQESBAoCCAgSCwoJCAEBAgECCAQEEgYKBAgIAQgiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgRiaWczIgRiaWc0IgpzbGlwcGFnZTREIgt3YXZlc1N0cmluZyIFQW11bHQiBURjb252IgNTRVAiBUVNUFRZIgpQb29sQWN0aXZlIgpQb29sUHV0RGlzIg5Qb29sTWF0Y2hlckRpcyIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyIJaWR4UG9vbFN0IglpZHhMUEFzSWQiCWlkeEFtQXNJZCIJaWR4UHJBc0lkIgtpZHhBbXRBc0RjbSINaWR4UHJpY2VBc0RjbSILaWR4SUFtdEFzSWQi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AwMIBQJlWglib2R5Qnl0ZXMJAJEDAggFAmVaBnByb29mcwABBQJpagMDAwUCYUYFAmFIBwUCYUkHBgkBAmFFBAUCYUYFAmFHBQJhSAUCYUkDCQABAgUCZ2wCFFNldFNjcmlwdFRyYW5zYWN0aW9uBAJjQwUCZ2wDCQD0AwMIBQJpZwlib2R5Qnl0ZXMJAJEDAggFAmlnBnByb29mcwAABQJpaQYEAmlsCQD2AwEJAQV2YWx1ZQEIBQJjQwZzY3JpcHQEAmltCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYVEJAQJhQwAEAmluCQDxBwEFBHRoaXMDCQAAAgUCaW0FAmlsCQECIT0CBQJpbgUCaWwHCQD0AwMIBQJpZwlib2R5Qnl0ZXMJAJEDAggFAmlnBnByb29mcwAABQJpaV4cxMs=", "height": 2441946, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7CLV6ivn8wgpx7bfYAuMh4ycvfpSikVdh6soTQ2fLCd8 Next: 84vGc8UaLAsvFNuz7VVRUTbGsSib6ifQjqANt5P4bRMC 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
813902 let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
814903 let b = ((s + ((D * aPrecision) / ann)) - D)
815904 func calc (acc,cur) = {
816- let $t03057130591 = acc
817- let y = $t03057130591._1
818- let found = $t03057130591._2
905+ let $t03431534335 = acc
906+ let y = $t03431534335._1
907+ let found = $t03431534335._2
819908 if ((found != unit))
820909 then acc
821910 else {
828917 }
829918
830919 let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
831- let $t03092230969 = {
920+ let $t03466634713 = {
832921 let $l = arr
833922 let $s = size($l)
834923 let $acc0 = $Tuple2(D, unit)
842931
843932 $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)
844933 }
845- let y = $t03092230969._1
846- let found = $t03092230969._2
934+ let y = $t03466634713._1
935+ let found = $t03466634713._2
847936 if ((found != unit))
848937 then y
849938 else throw(("Y calculation error, Y = " + toString(y)))
852941
853942 @Callable(i)
854943 func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = {
855- let $t03119031614 = if ((isReverse == false))
944+ let $t03493435358 = if ((isReverse == false))
856945 then {
857946 let assetOut = strf(this, pa())
858947 let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn))
863952 let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn))
864953 $Tuple2(assetOut, poolAmountInBalance)
865954 }
866- let assetOut = $t03119031614._1
867- let poolAmountInBalance = $t03119031614._2
955+ let assetOut = $t03493435358._1
956+ let poolAmountInBalance = $t03493435358._2
868957 let poolConfig = gpc()
869958 let amId = poolConfig[idxAmAsId]
870959 let prId = poolConfig[idxPrAsId]
889978
890979 @Callable(i)
891980 func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = {
981+ let swapContact = {
982+ let @ = invoke(addressFromStringValue(fc()), "getSwapContractREADONLY", nil, nil)
983+ if ($isInstanceOf(@, "String"))
984+ then @
985+ else throw(($getType(@) + " couldn't be cast to String"))
986+ }
892987 let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
893988 then true
894- else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(strf(this, swapContract()))))
989+ else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact)))
895990 then true
896991 else throwErr("Permission denied")]
897992 if ((checks == checks))
900995 let assetIn = if ((pmt.assetId == unit))
901996 then toBase58String(toBytes("WAVES"))
902997 else toBase58String(value(pmt.assetId))
903- let $t03301633410 = if ((isReverse == false))
998+ let $t03682137215 = if ((isReverse == false))
904999 then {
9051000 let assetOut = strf(this, pa())
9061001 let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
9111006 let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
9121007 $Tuple2(assetOut, poolAmountInBalance)
9131008 }
914- let assetOut = $t03301633410._1
915- let poolAmountInBalance = $t03301633410._2
1009+ let assetOut = $t03682137215._1
1010+ let poolAmountInBalance = $t03682137215._2
9161011 let poolConfig = gpc()
9171012 let amId = poolConfig[idxAmAsId]
9181013 let prId = poolConfig[idxPrAsId]
10031098 else if ((size(i.payments) != 2))
10041099 then throw("2 pmnts expd")
10051100 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))
1101+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1102+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1103+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
1104+ if ((amountAssetBalance == amountAssetBalance))
10161105 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))
1106+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
1107+ if ((priceAssetBalance == priceAssetBalance))
10241108 then {
1025- let sa = if ((amDiff > 0))
1026- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1027- else nil
1028- if ((sa == sa))
1109+ let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
1110+ if ((lpAssetEmission == lpAssetEmission))
10291111 then {
1030- let sp = if ((prDiff > 0))
1031- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1032- else nil
1033- if ((sp == sp))
1112+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1113+ if ((currentDLp == currentDLp))
10341114 then {
1035- let lpTrnsfr = if (autoStake)
1115+ 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, "")
1116+ let emitLpAmt = e._2
1117+ let lpAssetId = e._7
1118+ let state = e._9
1119+ let amDiff = e._10
1120+ let prDiff = e._11
1121+ let amId = e._12
1122+ let prId = e._13
1123+ let r = invoke(fca, "emit", [emitLpAmt], nil)
1124+ if ((r == r))
10361125 then {
1037- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1038- if ((ss == ss))
1039- then nil
1126+ let el = match r {
1127+ case legacy: Address =>
1128+ invoke(legacy, "emit", [emitLpAmt], nil)
1129+ case _ =>
1130+ unit
1131+ }
1132+ if ((el == el))
1133+ then {
1134+ let sa = if ((amDiff > 0))
1135+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1136+ else nil
1137+ if ((sa == sa))
1138+ then {
1139+ let sp = if ((prDiff > 0))
1140+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1141+ else nil
1142+ if ((sp == sp))
1143+ then {
1144+ let lpTrnsfr = if (autoStake)
1145+ then {
1146+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1147+ if ((ss == ss))
1148+ then nil
1149+ else throw("Strict value is not equal to itself.")
1150+ }
1151+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1152+ let $t04207642218 = refreshDLpInternal(0, 0, 0)
1153+ let refreshDLpActions = $t04207642218._1
1154+ let updatedDLp = $t04207642218._2
1155+ let check = if ((updatedDLp >= currentDLp))
1156+ then true
1157+ else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1158+ if ((check == check))
1159+ then {
1160+ let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1161+ if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1162+ then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1163+ else throw("Strict value is not equal to itself.")
1164+ }
1165+ else throw("Strict value is not equal to itself.")
1166+ }
1167+ else throw("Strict value is not equal to itself.")
1168+ }
1169+ else throw("Strict value is not equal to itself.")
1170+ }
10401171 else throw("Strict value is not equal to itself.")
10411172 }
1042- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1043- (state ++ lpTrnsfr)
1173+ else throw("Strict value is not equal to itself.")
10441174 }
10451175 else throw("Strict value is not equal to itself.")
10461176 }
10781208 else throwErr("exactly 1 payment are expected")]
10791209 if ((checks == checks))
10801210 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])
1211+ let amId = toBase58String(value(cfgAmountAssetId))
1212+ let prId = toBase58String(value(cfgPriceAssetId))
1213+ let lpId = cfgLpAssetId
1214+ let amDecimals = cfgAmountAssetDecimals
1215+ let prDecimals = cfgPriceAssetDecimals
10871216 let userAddress = if ((i.caller == this))
10881217 then i.originCaller
10891218 else i.caller
10901219 let pmt = value(i.payments[0])
10911220 let pmtAssetId = toBase58String(value(pmt.assetId))
10921221 let pmtAmt = pmt.amount
1093- let $t03879838956 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1094- if (($t03879838956 == $t03879838956))
1222+ let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1223+ then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1224+ else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1225+ if ((currentDLp == currentDLp))
10951226 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))
1227+ let $t04385944017 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1228+ if (($t04385944017 == $t04385944017))
11061229 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))
1230+ let feeAmount = $t04385944017._3
1231+ let state = $t04385944017._2
1232+ let estimLP = $t04385944017._1
1233+ let emitLpAmt = if (if ((minOutAmount > 0))
1234+ then (minOutAmount > estimLP)
1235+ else false)
1236+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1237+ else estimLP
1238+ let e = invoke(fca, "emit", [emitLpAmt], nil)
1239+ if ((e == e))
11141240 then {
1115- let lpTrnsfr = if (autoStake)
1241+ let el = match e {
1242+ case legacy: Address =>
1243+ invoke(legacy, "emit", [emitLpAmt], nil)
1244+ case _ =>
1245+ unit
1246+ }
1247+ if ((el == el))
11161248 then {
1117- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1118- if ((ss == ss))
1119- then nil
1249+ let lpTrnsfr = if (autoStake)
1250+ then {
1251+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1252+ if ((ss == ss))
1253+ then nil
1254+ else throw("Strict value is not equal to itself.")
1255+ }
1256+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1257+ let sendFeeToMatcher = if ((feeAmount > 0))
1258+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1259+ else nil
1260+ let $t04483245181 = if ((this == feeCollectorAddress))
1261+ then $Tuple2(0, 0)
1262+ else {
1263+ let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1264+ then true
1265+ else false
1266+ if (paymentInAmountAsset)
1267+ then $Tuple2(-(feeAmount), 0)
1268+ else $Tuple2(0, -(feeAmount))
1269+ }
1270+ let amountAssetBalanceDelta = $t04483245181._1
1271+ let priceAssetBalanceDelta = $t04483245181._2
1272+ let $t04518445292 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1273+ let refreshDLpActions = $t04518445292._1
1274+ let updatedDLp = $t04518445292._2
1275+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1276+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1277+ then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
11201278 else throw("Strict value is not equal to itself.")
11211279 }
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)
1280+ else throw("Strict value is not equal to itself.")
11271281 }
11281282 else throw("Strict value is not equal to itself.")
11291283 }
11431297 then throw("2 pmnts expd")
11441298 else {
11451299 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
1300+ let state = estPut._9
1301+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1302+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1303+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1304+ if ((currentDLp == currentDLp))
1305+ then {
1306+ let $t04632246387 = refreshDLpInternal(0, 0, 0)
1307+ let refreshDLpActions = $t04632246387._1
1308+ let updatedDLp = $t04632246387._2
1309+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1310+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1311+ then (state ++ refreshDLpActions)
1312+ else throw("Strict value is not equal to itself.")
1313+ }
1314+ else throw("Strict value is not equal to itself.")
11471315 }
11481316
11491317
11501318
11511319 @Callable(i)
11521320 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
1321+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1322+ if ((currentDLp == currentDLp))
1323+ then {
1324+ let r = cg(i)
1325+ let outAmtAmt = r._1
1326+ let outPrAmt = r._2
1327+ let pmtAmt = r._3
1328+ let pmtAssetId = r._4
1329+ let state = r._5
1330+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1331+ if ((b == b))
1332+ then {
1333+ let $t04756047642 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1334+ let refreshDLpActions = $t04756047642._1
1335+ let updatedDLp = $t04756047642._2
1336+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1337+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1338+ then (state ++ refreshDLpActions)
1339+ else throw("Strict value is not equal to itself.")
1340+ }
1341+ else throw("Strict value is not equal to itself.")
1342+ }
11621343 else throw("Strict value is not equal to itself.")
11631344 }
11641345
11861367 else throwErr("exactly 1 payment are expected")]
11871368 if ((checks == checks))
11881369 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
1370+ let $t04826048415 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1371+ let state = $t04826048415._1
1372+ let totalAmount = $t04826048415._2
11921373 $Tuple2(state, totalAmount)
11931374 }
11941375 else throw("Strict value is not equal to itself.")
11971378
11981379
11991380 @Callable(i)
1381+func refreshDLp () = {
1382+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1383+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1384+ then unit
1385+ else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1386+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1387+ then {
1388+ let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1389+ let $t04893949003 = refreshDLpInternal(0, 0, 0)
1390+ let dLpUpdateActions = $t04893949003._1
1391+ let updatedDLp = $t04893949003._2
1392+ let actions = if ((dLp != updatedDLp))
1393+ then dLpUpdateActions
1394+ else throwErr("nothing to refresh")
1395+ $Tuple2(actions, toString(updatedDLp))
1396+ }
1397+ else throw("Strict value is not equal to itself.")
1398+ }
1399+
1400+
1401+
1402+@Callable(i)
12001403 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1201- let poolConfig = gpc()
1202- let amId = poolConfig[idxAmAsId]
1203- let prId = poolConfig[idxPrAsId]
1204- let lpId = poolConfig[idxLPAsId]
1404+ let amId = toBase58String(value(cfgAmountAssetId))
1405+ let prId = toBase58String(value(cfgPriceAssetId))
1406+ let lpId = toBase58String(value(cfgLpAssetId))
12051407 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
12061408 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
12071409 let D0 = getD(xp)
12141416 let newY = getYD(xp, index, D1)
12151417 let dy = (xp[index] - newY)
12161418 let totalGetRaw = max([0, toInt((dy - big1))])
1217- let $t04260342658 = takeFee(totalGetRaw, outFee)
1218- let totalGet = $t04260342658._1
1219- let feeAmount = $t04260342658._2
1419+ let $t05001350068 = takeFee(totalGetRaw, outFee)
1420+ let totalGet = $t05001350068._1
1421+ let feeAmount = $t05001350068._2
12201422 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
12211423 }
12221424
12241426
12251427 @Callable(i)
12261428 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1227- let poolConfig = gpc()
1228- let amId = poolConfig[idxAmAsId]
1229- let prId = poolConfig[idxPrAsId]
1230- let lpId = poolConfig[idxLPAsId]
1429+ let amId = toBase58String(value(cfgAmountAssetId))
1430+ let prId = toBase58String(value(cfgPriceAssetId))
1431+ let lpId = toBase58String(value(cfgLpAssetId))
12311432 let amBalance = getAccBalance(amId)
12321433 let prBalance = getAccBalance(prId)
1233- let $t04300343118 = {
1434+ let $t05044350558 = {
12341435 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
12351436 if ($isInstanceOf(@, "(Int, Int)"))
12361437 then @
12371438 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
12381439 }
1239- let totalGet = $t04300343118._1
1240- let feeAmount = $t04300343118._2
1440+ let totalGet = $t05044350558._1
1441+ let feeAmount = $t05044350558._2
12411442 let r = ego("", lpId, lpAssetAmount, this)
12421443 let outAmAmt = r._1
12431444 let outPrAmt = r._2
12651466 else if ((noLessThenPriceAsset > outPrAmt))
12661467 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
12671468 else {
1268- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1269- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1270- then state
1469+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1470+ if ((currentDLp == currentDLp))
1471+ then {
1472+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1473+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1474+ then {
1475+ let $t05172451805 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1476+ let refreshDLpActions = $t05172451805._1
1477+ let updatedDLp = $t05172451805._2
1478+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1479+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1480+ then (state ++ refreshDLpActions)
1481+ else throw("Strict value is not equal to itself.")
1482+ }
1483+ else throw("Strict value is not equal to itself.")
1484+ }
12711485 else throw("Strict value is not equal to itself.")
12721486 }
12731487 }
12811495 else true
12821496 if ((checkPayments == checkPayments))
12831497 then {
1284- let cfg = gpc()
12851498 let factoryCfg = gfc()
1286- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1499+ let lpAssetId = cfgLpAssetId
12871500 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1288- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1289- if ((unstakeInv == unstakeInv))
1501+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1502+ if ((currentDLp == currentDLp))
12901503 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))
1504+ let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1505+ if ((unstakeInv == unstakeInv))
13001506 then {
1301- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1302- if ((burnA == burnA))
1303- then state
1507+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1508+ let outAmAmt = r._1
1509+ let outPrAmt = r._2
1510+ let sts = parseIntValue(r._9)
1511+ let state = r._10
1512+ let v = if (if (igs())
1513+ then true
1514+ else (sts == PoolShutdown))
1515+ then throw(("Blocked: " + toString(sts)))
1516+ else true
1517+ if ((v == v))
1518+ then {
1519+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1520+ if ((burnA == burnA))
1521+ then {
1522+ let $t05283252913 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1523+ let refreshDLpActions = $t05283252913._1
1524+ let updatedDLp = $t05283252913._2
1525+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1526+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1527+ then (state ++ refreshDLpActions)
1528+ else throw("Strict value is not equal to itself.")
1529+ }
1530+ else throw("Strict value is not equal to itself.")
1531+ }
13041532 else throw("Strict value is not equal to itself.")
13051533 }
13061534 else throw("Strict value is not equal to itself.")
13241552 else throw("no payments are expected")]
13251553 if ((checks == checks))
13261554 then {
1327- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1328- if ((unstakeInv == unstakeInv))
1555+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1556+ if ((currentDLp == currentDLp))
13291557 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))
1558+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1559+ if ((unstakeInv == unstakeInv))
13401560 then {
1341- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1342- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1343- then state
1561+ let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1562+ let outAmAmt = res._1
1563+ let outPrAmt = res._2
1564+ let state = res._10
1565+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1566+ then true
1567+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1568+ then true
1569+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1570+ if ((checkAmounts == checkAmounts))
1571+ then {
1572+ let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1573+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1574+ then {
1575+ let $t05416454245 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1576+ let refreshDLpActions = $t05416454245._1
1577+ let updatedDLp = $t05416454245._2
1578+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1579+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1580+ then (state ++ refreshDLpActions)
1581+ else throw("Strict value is not equal to itself.")
1582+ }
1583+ else throw("Strict value is not equal to itself.")
1584+ }
13441585 else throw("Strict value is not equal to itself.")
13451586 }
13461587 else throw("Strict value is not equal to itself.")
13741615 else throwErr("no payments are expected")]
13751616 if ((checks == checks))
13761617 then {
1377- let cfg = gpc()
13781618 let factoryCfg = gfc()
1379- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1619+ let lpAssetId = cfgLpAssetId
13801620 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
13811621 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
13821622 if ((unstakeInv == unstakeInv))
13831623 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
1624+ let $t05514055328 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1625+ let state = $t05514055328._1
1626+ let totalAmount = $t05514055328._2
13871627 $Tuple2(state, totalAmount)
13881628 }
13891629 else throw("Strict value is not equal to itself.")
13951635
13961636 @Callable(i)
13971637 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
1638+ let $t05545655559 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1639+ let lpAmount = $t05545655559._1
1640+ let state = $t05545655559._2
1641+ let feeAmount = $t05545655559._3
1642+ let bonus = $t05545655559._4
14071643 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
14081644 }
14091645
14111647
14121648 @Callable(i)
14131649 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
1650+ let $t05570755811 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1651+ let lpAmount = $t05570755811._1
1652+ let state = $t05570755811._2
1653+ let feeAmount = $t05570755811._3
1654+ let bonus = $t05570755811._4
14231655 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
14241656 }
14251657
15041736 match tx {
15051737 case order: Order =>
15061738 let matcherPub = mp()
1507- let orderValid = moa(order)
1739+ let $t05860358672 = validateMatcherOrderAllowed(order)
1740+ let orderValid = $t05860358672._1
1741+ let orderValidInfo = $t05860358672._2
15081742 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
15091743 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
15101744 if (if (if (orderValid)
15131747 then matcherValid
15141748 else false)
15151749 then true
1516- else toe(orderValid, senderValid, matcherValid)
1750+ else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
15171751 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)
1752+ if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
15241753 then true
1525- else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1754+ else {
1755+ let newHash = blake2b256(value(s.script))
1756+ let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1757+ let currentHash = scriptHash(this)
1758+ if ((allowedHash == newHash))
1759+ then (currentHash != newHash)
1760+ else false
1761+ }
15261762 case _ =>
15271763 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
15281764 }
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 }
798887
799888
800889 func getY (isReverse,D,poolAmountInBalance) = {
801890 let poolConfig = gpc()
802891 let amId = poolConfig[idxAmAsId]
803892 let prId = poolConfig[idxPrAsId]
804893 let n = big2
805894 let aPrecision = parseBigIntValue(Amult)
806895 let a = (parseBigIntValue(A) * aPrecision)
807896 let xp = if ((isReverse == false))
808897 then [(toBigInt(getAccBalance(amId)) + poolAmountInBalance), toBigInt(getAccBalance(prId))]
809898 else [(toBigInt(getAccBalance(prId)) + poolAmountInBalance), toBigInt(getAccBalance(amId))]
810899 let x = xp[0]
811900 let s = x
812901 let ann = (a * n)
813902 let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
814903 let b = ((s + ((D * aPrecision) / ann)) - D)
815904 func calc (acc,cur) = {
816- let $t03057130591 = acc
817- let y = $t03057130591._1
818- let found = $t03057130591._2
905+ let $t03431534335 = acc
906+ let y = $t03431534335._1
907+ let found = $t03431534335._2
819908 if ((found != unit))
820909 then acc
821910 else {
822911 let yNext = (((y * y) + c) / ((big2 * y) + b))
823912 let yDiff = absBigInt((yNext - value(y)))
824913 if ((big1 >= yDiff))
825914 then $Tuple2(yNext, cur)
826915 else $Tuple2(yNext, unit)
827916 }
828917 }
829918
830919 let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
831- let $t03092230969 = {
920+ let $t03466634713 = {
832921 let $l = arr
833922 let $s = size($l)
834923 let $acc0 = $Tuple2(D, unit)
835924 func $f0_1 ($a,$i) = if (($i >= $s))
836925 then $a
837926 else calc($a, $l[$i])
838927
839928 func $f0_2 ($a,$i) = if (($i >= $s))
840929 then $a
841930 else throw("List size exceeds 15")
842931
843932 $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)
844933 }
845- let y = $t03092230969._1
846- let found = $t03092230969._2
934+ let y = $t03466634713._1
935+ let found = $t03466634713._2
847936 if ((found != unit))
848937 then y
849938 else throw(("Y calculation error, Y = " + toString(y)))
850939 }
851940
852941
853942 @Callable(i)
854943 func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = {
855- let $t03119031614 = if ((isReverse == false))
944+ let $t03493435358 = if ((isReverse == false))
856945 then {
857946 let assetOut = strf(this, pa())
858947 let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn))
859948 $Tuple2(assetOut, poolAmountInBalance)
860949 }
861950 else {
862951 let assetOut = strf(this, aa())
863952 let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn))
864953 $Tuple2(assetOut, poolAmountInBalance)
865954 }
866- let assetOut = $t03119031614._1
867- let poolAmountInBalance = $t03119031614._2
955+ let assetOut = $t03493435358._1
956+ let poolAmountInBalance = $t03493435358._2
868957 let poolConfig = gpc()
869958 let amId = poolConfig[idxAmAsId]
870959 let prId = poolConfig[idxPrAsId]
871960 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
872961 let D = getD(xp)
873962 let y = getY(isReverse, D, toBigInt(cleanAmountIn))
874963 let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
875964 let totalGetRaw = max([0, toInt(dy)])
876965 let newXp = if ((isReverse == false))
877966 then [(toBigInt(getAccBalance(amId)) + toBigInt(cleanAmountIn)), (toBigInt(getAccBalance(prId)) - dy)]
878967 else [(toBigInt(getAccBalance(amId)) - dy), (toBigInt(getAccBalance(prId)) + toBigInt(cleanAmountIn))]
879968 let newD = getD(newXp)
880969 let checkD = if ((newD >= D))
881970 then true
882971 else throw(makeString(["new D is fewer error", toString(D), toString(newD)], "__"))
883972 if ((checkD == checkD))
884973 then $Tuple2(nil, totalGetRaw)
885974 else throw("Strict value is not equal to itself.")
886975 }
887976
888977
889978
890979 @Callable(i)
891980 func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = {
981+ let swapContact = {
982+ let @ = invoke(addressFromStringValue(fc()), "getSwapContractREADONLY", nil, nil)
983+ if ($isInstanceOf(@, "String"))
984+ then @
985+ else throw(($getType(@) + " couldn't be cast to String"))
986+ }
892987 let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
893988 then true
894- else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(strf(this, swapContract()))))
989+ else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact)))
895990 then true
896991 else throwErr("Permission denied")]
897992 if ((checks == checks))
898993 then {
899994 let pmt = value(i.payments[0])
900995 let assetIn = if ((pmt.assetId == unit))
901996 then toBase58String(toBytes("WAVES"))
902997 else toBase58String(value(pmt.assetId))
903- let $t03301633410 = if ((isReverse == false))
998+ let $t03682137215 = if ((isReverse == false))
904999 then {
9051000 let assetOut = strf(this, pa())
9061001 let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
9071002 $Tuple2(assetOut, poolAmountInBalance)
9081003 }
9091004 else {
9101005 let assetOut = strf(this, aa())
9111006 let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
9121007 $Tuple2(assetOut, poolAmountInBalance)
9131008 }
914- let assetOut = $t03301633410._1
915- let poolAmountInBalance = $t03301633410._2
1009+ let assetOut = $t03682137215._1
1010+ let poolAmountInBalance = $t03682137215._2
9161011 let poolConfig = gpc()
9171012 let amId = poolConfig[idxAmAsId]
9181013 let prId = poolConfig[idxPrAsId]
9191014 let xp = if ((isReverse == false))
9201015 then [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))]
9211016 else [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - toBigInt(value(i.payments[0]).amount))]
9221017 let D = getD(xp)
9231018 let y = getY(isReverse, D, toBigInt(0))
9241019 let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
9251020 let totalGetRaw = max([0, toInt(dy)])
9261021 let checkMin = if ((totalGetRaw >= amountOutMin))
9271022 then true
9281023 else throw("Exchange result is fewer coins than expected")
9291024 if ((checkMin == checkMin))
9301025 then {
9311026 let newXp = if ((isReverse == false))
9321027 then [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - dy)]
9331028 else [(toBigInt(getAccBalance(amId)) - dy), toBigInt(getAccBalance(prId))]
9341029 let newD = getD(newXp)
9351030 let checkD = if ((newD >= D))
9361031 then true
9371032 else throw("new D is fewer error")
9381033 if ((checkD == checkD))
9391034 then [ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, if ((assetIn == "WAVES"))
9401035 then unit
9411036 else fromBase58String(assetOut))]
9421037 else throw("Strict value is not equal to itself.")
9431038 }
9441039 else throw("Strict value is not equal to itself.")
9451040 }
9461041 else throw("Strict value is not equal to itself.")
9471042 }
9481043
9491044
9501045
9511046 @Callable(i)
9521047 func constructor (fc) = {
9531048 let c = mm(i)
9541049 if ((c == c))
9551050 then [StringEntry(fc(), fc)]
9561051 else throw("Strict value is not equal to itself.")
9571052 }
9581053
9591054
9601055
9611056 @Callable(i)
9621057 func setManager (pendingManagerPublicKey) = {
9631058 let c = mm(i)
9641059 if ((c == c))
9651060 then {
9661061 let cm = fromBase58String(pendingManagerPublicKey)
9671062 if ((cm == cm))
9681063 then [StringEntry(pmpk(), pendingManagerPublicKey)]
9691064 else throw("Strict value is not equal to itself.")
9701065 }
9711066 else throw("Strict value is not equal to itself.")
9721067 }
9731068
9741069
9751070
9761071 @Callable(i)
9771072 func confirmManager () = {
9781073 let p = pm()
9791074 let hpm = if (isDefined(p))
9801075 then true
9811076 else throw("No pending manager")
9821077 if ((hpm == hpm))
9831078 then {
9841079 let cpm = if ((i.callerPublicKey == value(p)))
9851080 then true
9861081 else throw("You are not pending manager")
9871082 if ((cpm == cpm))
9881083 then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
9891084 else throw("Strict value is not equal to itself.")
9901085 }
9911086 else throw("Strict value is not equal to itself.")
9921087 }
9931088
9941089
9951090
9961091 @Callable(i)
9971092 func put (slip,autoStake) = {
9981093 let factCfg = gfc()
9991094 let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
10001095 let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
10011096 if ((0 > slip))
10021097 then throw("Wrong slippage")
10031098 else if ((size(i.payments) != 2))
10041099 then throw("2 pmnts expd")
10051100 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))
1101+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1102+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1103+ let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
1104+ if ((amountAssetBalance == amountAssetBalance))
10161105 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))
1106+ let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
1107+ if ((priceAssetBalance == priceAssetBalance))
10241108 then {
1025- let sa = if ((amDiff > 0))
1026- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1027- else nil
1028- if ((sa == sa))
1109+ let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
1110+ if ((lpAssetEmission == lpAssetEmission))
10291111 then {
1030- let sp = if ((prDiff > 0))
1031- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1032- else nil
1033- if ((sp == sp))
1112+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1113+ if ((currentDLp == currentDLp))
10341114 then {
1035- let lpTrnsfr = if (autoStake)
1115+ 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, "")
1116+ let emitLpAmt = e._2
1117+ let lpAssetId = e._7
1118+ let state = e._9
1119+ let amDiff = e._10
1120+ let prDiff = e._11
1121+ let amId = e._12
1122+ let prId = e._13
1123+ let r = invoke(fca, "emit", [emitLpAmt], nil)
1124+ if ((r == r))
10361125 then {
1037- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1038- if ((ss == ss))
1039- then nil
1126+ let el = match r {
1127+ case legacy: Address =>
1128+ invoke(legacy, "emit", [emitLpAmt], nil)
1129+ case _ =>
1130+ unit
1131+ }
1132+ if ((el == el))
1133+ then {
1134+ let sa = if ((amDiff > 0))
1135+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1136+ else nil
1137+ if ((sa == sa))
1138+ then {
1139+ let sp = if ((prDiff > 0))
1140+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1141+ else nil
1142+ if ((sp == sp))
1143+ then {
1144+ let lpTrnsfr = if (autoStake)
1145+ then {
1146+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1147+ if ((ss == ss))
1148+ then nil
1149+ else throw("Strict value is not equal to itself.")
1150+ }
1151+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1152+ let $t04207642218 = refreshDLpInternal(0, 0, 0)
1153+ let refreshDLpActions = $t04207642218._1
1154+ let updatedDLp = $t04207642218._2
1155+ let check = if ((updatedDLp >= currentDLp))
1156+ then true
1157+ else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1158+ if ((check == check))
1159+ then {
1160+ let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1161+ if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1162+ then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1163+ else throw("Strict value is not equal to itself.")
1164+ }
1165+ else throw("Strict value is not equal to itself.")
1166+ }
1167+ else throw("Strict value is not equal to itself.")
1168+ }
1169+ else throw("Strict value is not equal to itself.")
1170+ }
10401171 else throw("Strict value is not equal to itself.")
10411172 }
1042- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1043- (state ++ lpTrnsfr)
1173+ else throw("Strict value is not equal to itself.")
10441174 }
10451175 else throw("Strict value is not equal to itself.")
10461176 }
10471177 else throw("Strict value is not equal to itself.")
10481178 }
10491179 else throw("Strict value is not equal to itself.")
10501180 }
10511181 else throw("Strict value is not equal to itself.")
10521182 }
10531183 }
10541184
10551185
10561186
10571187 @Callable(i)
10581188 func putOneTknV2 (minOutAmount,autoStake) = {
10591189 let isPoolOneTokenOperationsDisabled = {
10601190 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
10611191 if ($isInstanceOf(@, "Boolean"))
10621192 then @
10631193 else throw(($getType(@) + " couldn't be cast to Boolean"))
10641194 }
10651195 let isPutDisabled = if (if (if (igs())
10661196 then true
10671197 else (cfgPoolStatus == PoolPutDis))
10681198 then true
10691199 else (cfgPoolStatus == PoolShutdown))
10701200 then true
10711201 else isPoolOneTokenOperationsDisabled
10721202 let checks = [if (if (!(isPutDisabled))
10731203 then true
10741204 else isManager(i))
10751205 then true
10761206 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
10771207 then true
10781208 else throwErr("exactly 1 payment are expected")]
10791209 if ((checks == checks))
10801210 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])
1211+ let amId = toBase58String(value(cfgAmountAssetId))
1212+ let prId = toBase58String(value(cfgPriceAssetId))
1213+ let lpId = cfgLpAssetId
1214+ let amDecimals = cfgAmountAssetDecimals
1215+ let prDecimals = cfgPriceAssetDecimals
10871216 let userAddress = if ((i.caller == this))
10881217 then i.originCaller
10891218 else i.caller
10901219 let pmt = value(i.payments[0])
10911220 let pmtAssetId = toBase58String(value(pmt.assetId))
10921221 let pmtAmt = pmt.amount
1093- let $t03879838956 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1094- if (($t03879838956 == $t03879838956))
1222+ let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1223+ then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1224+ else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1225+ if ((currentDLp == currentDLp))
10951226 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))
1227+ let $t04385944017 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1228+ if (($t04385944017 == $t04385944017))
11061229 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))
1230+ let feeAmount = $t04385944017._3
1231+ let state = $t04385944017._2
1232+ let estimLP = $t04385944017._1
1233+ let emitLpAmt = if (if ((minOutAmount > 0))
1234+ then (minOutAmount > estimLP)
1235+ else false)
1236+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1237+ else estimLP
1238+ let e = invoke(fca, "emit", [emitLpAmt], nil)
1239+ if ((e == e))
11141240 then {
1115- let lpTrnsfr = if (autoStake)
1241+ let el = match e {
1242+ case legacy: Address =>
1243+ invoke(legacy, "emit", [emitLpAmt], nil)
1244+ case _ =>
1245+ unit
1246+ }
1247+ if ((el == el))
11161248 then {
1117- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1118- if ((ss == ss))
1119- then nil
1249+ let lpTrnsfr = if (autoStake)
1250+ then {
1251+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1252+ if ((ss == ss))
1253+ then nil
1254+ else throw("Strict value is not equal to itself.")
1255+ }
1256+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1257+ let sendFeeToMatcher = if ((feeAmount > 0))
1258+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1259+ else nil
1260+ let $t04483245181 = if ((this == feeCollectorAddress))
1261+ then $Tuple2(0, 0)
1262+ else {
1263+ let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1264+ then true
1265+ else false
1266+ if (paymentInAmountAsset)
1267+ then $Tuple2(-(feeAmount), 0)
1268+ else $Tuple2(0, -(feeAmount))
1269+ }
1270+ let amountAssetBalanceDelta = $t04483245181._1
1271+ let priceAssetBalanceDelta = $t04483245181._2
1272+ let $t04518445292 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1273+ let refreshDLpActions = $t04518445292._1
1274+ let updatedDLp = $t04518445292._2
1275+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1276+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1277+ then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
11201278 else throw("Strict value is not equal to itself.")
11211279 }
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)
1280+ else throw("Strict value is not equal to itself.")
11271281 }
11281282 else throw("Strict value is not equal to itself.")
11291283 }
11301284 else throw("Strict value is not equal to itself.")
11311285 }
11321286 else throw("Strict value is not equal to itself.")
11331287 }
11341288 else throw("Strict value is not equal to itself.")
11351289 }
11361290
11371291
11381292
11391293 @Callable(i)
11401294 func putForFree (maxSlpg) = if ((0 > maxSlpg))
11411295 then throw("Wrong slpg")
11421296 else if ((size(i.payments) != 2))
11431297 then throw("2 pmnts expd")
11441298 else {
11451299 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
1300+ let state = estPut._9
1301+ let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1302+ let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1303+ let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1304+ if ((currentDLp == currentDLp))
1305+ then {
1306+ let $t04632246387 = refreshDLpInternal(0, 0, 0)
1307+ let refreshDLpActions = $t04632246387._1
1308+ let updatedDLp = $t04632246387._2
1309+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1310+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1311+ then (state ++ refreshDLpActions)
1312+ else throw("Strict value is not equal to itself.")
1313+ }
1314+ else throw("Strict value is not equal to itself.")
11471315 }
11481316
11491317
11501318
11511319 @Callable(i)
11521320 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
1321+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1322+ if ((currentDLp == currentDLp))
1323+ then {
1324+ let r = cg(i)
1325+ let outAmtAmt = r._1
1326+ let outPrAmt = r._2
1327+ let pmtAmt = r._3
1328+ let pmtAssetId = r._4
1329+ let state = r._5
1330+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1331+ if ((b == b))
1332+ then {
1333+ let $t04756047642 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1334+ let refreshDLpActions = $t04756047642._1
1335+ let updatedDLp = $t04756047642._2
1336+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1337+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1338+ then (state ++ refreshDLpActions)
1339+ else throw("Strict value is not equal to itself.")
1340+ }
1341+ else throw("Strict value is not equal to itself.")
1342+ }
11621343 else throw("Strict value is not equal to itself.")
11631344 }
11641345
11651346
11661347
11671348 @Callable(i)
11681349 func getOneTknV2 (outAssetId,minOutAmount) = {
11691350 let isPoolOneTokenOperationsDisabled = {
11701351 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
11711352 if ($isInstanceOf(@, "Boolean"))
11721353 then @
11731354 else throw(($getType(@) + " couldn't be cast to Boolean"))
11741355 }
11751356 let isGetDisabled = if (if (igs())
11761357 then true
11771358 else (cfgPoolStatus == PoolShutdown))
11781359 then true
11791360 else isPoolOneTokenOperationsDisabled
11801361 let checks = [if (if (!(isGetDisabled))
11811362 then true
11821363 else isManager(i))
11831364 then true
11841365 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
11851366 then true
11861367 else throwErr("exactly 1 payment are expected")]
11871368 if ((checks == checks))
11881369 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
1370+ let $t04826048415 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1371+ let state = $t04826048415._1
1372+ let totalAmount = $t04826048415._2
11921373 $Tuple2(state, totalAmount)
11931374 }
11941375 else throw("Strict value is not equal to itself.")
11951376 }
11961377
11971378
11981379
11991380 @Callable(i)
1381+func refreshDLp () = {
1382+ let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1383+ let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1384+ then unit
1385+ else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1386+ if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1387+ then {
1388+ let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1389+ let $t04893949003 = refreshDLpInternal(0, 0, 0)
1390+ let dLpUpdateActions = $t04893949003._1
1391+ let updatedDLp = $t04893949003._2
1392+ let actions = if ((dLp != updatedDLp))
1393+ then dLpUpdateActions
1394+ else throwErr("nothing to refresh")
1395+ $Tuple2(actions, toString(updatedDLp))
1396+ }
1397+ else throw("Strict value is not equal to itself.")
1398+ }
1399+
1400+
1401+
1402+@Callable(i)
12001403 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1201- let poolConfig = gpc()
1202- let amId = poolConfig[idxAmAsId]
1203- let prId = poolConfig[idxPrAsId]
1204- let lpId = poolConfig[idxLPAsId]
1404+ let amId = toBase58String(value(cfgAmountAssetId))
1405+ let prId = toBase58String(value(cfgPriceAssetId))
1406+ let lpId = toBase58String(value(cfgLpAssetId))
12051407 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
12061408 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
12071409 let D0 = getD(xp)
12081410 let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission))
12091411 let index = if ((outAssetId == amId))
12101412 then 0
12111413 else if ((outAssetId == prId))
12121414 then 1
12131415 else throw("invalid out asset id")
12141416 let newY = getYD(xp, index, D1)
12151417 let dy = (xp[index] - newY)
12161418 let totalGetRaw = max([0, toInt((dy - big1))])
1217- let $t04260342658 = takeFee(totalGetRaw, outFee)
1218- let totalGet = $t04260342658._1
1219- let feeAmount = $t04260342658._2
1419+ let $t05001350068 = takeFee(totalGetRaw, outFee)
1420+ let totalGet = $t05001350068._1
1421+ let feeAmount = $t05001350068._2
12201422 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
12211423 }
12221424
12231425
12241426
12251427 @Callable(i)
12261428 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1227- let poolConfig = gpc()
1228- let amId = poolConfig[idxAmAsId]
1229- let prId = poolConfig[idxPrAsId]
1230- let lpId = poolConfig[idxLPAsId]
1429+ let amId = toBase58String(value(cfgAmountAssetId))
1430+ let prId = toBase58String(value(cfgPriceAssetId))
1431+ let lpId = toBase58String(value(cfgLpAssetId))
12311432 let amBalance = getAccBalance(amId)
12321433 let prBalance = getAccBalance(prId)
1233- let $t04300343118 = {
1434+ let $t05044350558 = {
12341435 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
12351436 if ($isInstanceOf(@, "(Int, Int)"))
12361437 then @
12371438 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
12381439 }
1239- let totalGet = $t04300343118._1
1240- let feeAmount = $t04300343118._2
1440+ let totalGet = $t05044350558._1
1441+ let feeAmount = $t05044350558._2
12411442 let r = ego("", lpId, lpAssetAmount, this)
12421443 let outAmAmt = r._1
12431444 let outPrAmt = r._2
12441445 let sumOfGetAssets = (outAmAmt + outPrAmt)
12451446 let bonus = if ((sumOfGetAssets == 0))
12461447 then if ((totalGet == 0))
12471448 then 0
12481449 else throw("bonus calculation error")
12491450 else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets)
12501451 $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus))
12511452 }
12521453
12531454
12541455
12551456 @Callable(i)
12561457 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
12571458 let r = cg(i)
12581459 let outAmAmt = r._1
12591460 let outPrAmt = r._2
12601461 let pmtAmt = r._3
12611462 let pmtAssetId = r._4
12621463 let state = r._5
12631464 if ((noLessThenAmtAsset > outAmAmt))
12641465 then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
12651466 else if ((noLessThenPriceAsset > outPrAmt))
12661467 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
12671468 else {
1268- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1269- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1270- then state
1469+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1470+ if ((currentDLp == currentDLp))
1471+ then {
1472+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1473+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1474+ then {
1475+ let $t05172451805 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1476+ let refreshDLpActions = $t05172451805._1
1477+ let updatedDLp = $t05172451805._2
1478+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1479+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1480+ then (state ++ refreshDLpActions)
1481+ else throw("Strict value is not equal to itself.")
1482+ }
1483+ else throw("Strict value is not equal to itself.")
1484+ }
12711485 else throw("Strict value is not equal to itself.")
12721486 }
12731487 }
12741488
12751489
12761490
12771491 @Callable(i)
12781492 func unstakeAndGet (amount) = {
12791493 let checkPayments = if ((size(i.payments) != 0))
12801494 then throw("No pmnts expd")
12811495 else true
12821496 if ((checkPayments == checkPayments))
12831497 then {
1284- let cfg = gpc()
12851498 let factoryCfg = gfc()
1286- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1499+ let lpAssetId = cfgLpAssetId
12871500 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1288- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1289- if ((unstakeInv == unstakeInv))
1501+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1502+ if ((currentDLp == currentDLp))
12901503 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))
1504+ let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1505+ if ((unstakeInv == unstakeInv))
13001506 then {
1301- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1302- if ((burnA == burnA))
1303- then state
1507+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1508+ let outAmAmt = r._1
1509+ let outPrAmt = r._2
1510+ let sts = parseIntValue(r._9)
1511+ let state = r._10
1512+ let v = if (if (igs())
1513+ then true
1514+ else (sts == PoolShutdown))
1515+ then throw(("Blocked: " + toString(sts)))
1516+ else true
1517+ if ((v == v))
1518+ then {
1519+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1520+ if ((burnA == burnA))
1521+ then {
1522+ let $t05283252913 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1523+ let refreshDLpActions = $t05283252913._1
1524+ let updatedDLp = $t05283252913._2
1525+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1526+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1527+ then (state ++ refreshDLpActions)
1528+ else throw("Strict value is not equal to itself.")
1529+ }
1530+ else throw("Strict value is not equal to itself.")
1531+ }
13041532 else throw("Strict value is not equal to itself.")
13051533 }
13061534 else throw("Strict value is not equal to itself.")
13071535 }
13081536 else throw("Strict value is not equal to itself.")
13091537 }
13101538 else throw("Strict value is not equal to itself.")
13111539 }
13121540
13131541
13141542
13151543 @Callable(i)
13161544 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
13171545 let isGetDisabled = if (igs())
13181546 then true
13191547 else (cfgPoolStatus == PoolShutdown)
13201548 let checks = [if (!(isGetDisabled))
13211549 then true
13221550 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
13231551 then true
13241552 else throw("no payments are expected")]
13251553 if ((checks == checks))
13261554 then {
1327- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1328- if ((unstakeInv == unstakeInv))
1555+ let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1556+ if ((currentDLp == currentDLp))
13291557 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))
1558+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1559+ if ((unstakeInv == unstakeInv))
13401560 then {
1341- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1342- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1343- then state
1561+ let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1562+ let outAmAmt = res._1
1563+ let outPrAmt = res._2
1564+ let state = res._10
1565+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1566+ then true
1567+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1568+ then true
1569+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1570+ if ((checkAmounts == checkAmounts))
1571+ then {
1572+ let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1573+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1574+ then {
1575+ let $t05416454245 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1576+ let refreshDLpActions = $t05416454245._1
1577+ let updatedDLp = $t05416454245._2
1578+ let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1579+ if ((isUpdatedDLpValid == isUpdatedDLpValid))
1580+ then (state ++ refreshDLpActions)
1581+ else throw("Strict value is not equal to itself.")
1582+ }
1583+ else throw("Strict value is not equal to itself.")
1584+ }
13441585 else throw("Strict value is not equal to itself.")
13451586 }
13461587 else throw("Strict value is not equal to itself.")
13471588 }
13481589 else throw("Strict value is not equal to itself.")
13491590 }
13501591 else throw("Strict value is not equal to itself.")
13511592 }
13521593
13531594
13541595
13551596 @Callable(i)
13561597 func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = {
13571598 let isPoolOneTokenOperationsDisabled = {
13581599 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
13591600 if ($isInstanceOf(@, "Boolean"))
13601601 then @
13611602 else throw(($getType(@) + " couldn't be cast to Boolean"))
13621603 }
13631604 let isGetDisabled = if (if (igs())
13641605 then true
13651606 else (cfgPoolStatus == PoolShutdown))
13661607 then true
13671608 else isPoolOneTokenOperationsDisabled
13681609 let checks = [if (if (!(isGetDisabled))
13691610 then true
13701611 else isManager(i))
13711612 then true
13721613 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
13731614 then true
13741615 else throwErr("no payments are expected")]
13751616 if ((checks == checks))
13761617 then {
1377- let cfg = gpc()
13781618 let factoryCfg = gfc()
1379- let lpAssetId = fromBase58String(cfg[idxLPAsId])
1619+ let lpAssetId = cfgLpAssetId
13801620 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
13811621 let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
13821622 if ((unstakeInv == unstakeInv))
13831623 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
1624+ let $t05514055328 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1625+ let state = $t05514055328._1
1626+ let totalAmount = $t05514055328._2
13871627 $Tuple2(state, totalAmount)
13881628 }
13891629 else throw("Strict value is not equal to itself.")
13901630 }
13911631 else throw("Strict value is not equal to itself.")
13921632 }
13931633
13941634
13951635
13961636 @Callable(i)
13971637 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
1638+ let $t05545655559 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1639+ let lpAmount = $t05545655559._1
1640+ let state = $t05545655559._2
1641+ let feeAmount = $t05545655559._3
1642+ let bonus = $t05545655559._4
14071643 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
14081644 }
14091645
14101646
14111647
14121648 @Callable(i)
14131649 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
1650+ let $t05570755811 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1651+ let lpAmount = $t05570755811._1
1652+ let state = $t05570755811._2
1653+ let feeAmount = $t05570755811._3
1654+ let bonus = $t05570755811._4
14231655 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
14241656 }
14251657
14261658
14271659
14281660 @Callable(i)
14291661 func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
14301662 then throw("denied")
14311663 else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
14321664
14331665
14341666
14351667 @Callable(i)
14361668 func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
14371669 then pd
14381670 else [StringEntry(k, v)]
14391671
14401672
14411673
14421674 @Callable(i)
14431675 func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
14441676 then pd
14451677 else [IntegerEntry(k, v)]
14461678
14471679
14481680
14491681 @Callable(i)
14501682 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
14511683
14521684
14531685
14541686 @Callable(i)
14551687 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
14561688
14571689
14581690
14591691 @Callable(i)
14601692 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
14611693 let pr = calcPrices(amAmt, prAmt, lpAmt)
14621694 $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])])
14631695 }
14641696
14651697
14661698
14671699 @Callable(i)
14681700 func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
14691701
14701702
14711703
14721704 @Callable(i)
14731705 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
14741706
14751707
14761708
14771709 @Callable(i)
14781710 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
14791711
14801712
14811713
14821714 @Callable(i)
14831715 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, ""))
14841716
14851717
14861718
14871719 @Callable(i)
14881720 func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
14891721 let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
14901722 $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
14911723 }
14921724
14931725
14941726 @Verifier(tx)
14951727 func verify () = {
14961728 let targetPublicKey = match m() {
14971729 case pk: ByteVector =>
14981730 pk
14991731 case _: Unit =>
15001732 tx.senderPublicKey
15011733 case _ =>
15021734 throw("Match error")
15031735 }
15041736 match tx {
15051737 case order: Order =>
15061738 let matcherPub = mp()
1507- let orderValid = moa(order)
1739+ let $t05860358672 = validateMatcherOrderAllowed(order)
1740+ let orderValid = $t05860358672._1
1741+ let orderValidInfo = $t05860358672._2
15081742 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
15091743 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
15101744 if (if (if (orderValid)
15111745 then senderValid
15121746 else false)
15131747 then matcherValid
15141748 else false)
15151749 then true
1516- else toe(orderValid, senderValid, matcherValid)
1750+ else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
15171751 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)
1752+ if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
15241753 then true
1525- else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
1754+ else {
1755+ let newHash = blake2b256(value(s.script))
1756+ let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1757+ let currentHash = scriptHash(this)
1758+ if ((allowedHash == newHash))
1759+ then (currentHash != newHash)
1760+ else false
1761+ }
15261762 case _ =>
15271763 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
15281764 }
15291765 }
15301766

github/deemru/w8io/fabc49c 
195.69 ms