tx · FCgGzRvw6fdH5SmPd5M5JNpfGPqa99GziSpQ8X6sGo1A

3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT:  -0.03200000 Waves

2023.02.27 12:42 [2467950] smart account 3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT > SELF 0.00000000 Waves

{ "type": 13, "id": "FCgGzRvw6fdH5SmPd5M5JNpfGPqa99GziSpQ8X6sGo1A", "fee": 3200000, "feeAssetId": null, "timestamp": 1677490954751, "version": 1, "sender": "3NAefciWv6f9fWvEXdGgpHfanJFG8HqfjuT", "senderPublicKey": "D1BL65meykxFZTCuq7jq9HSGLLnWvQamQPUNrguW5w39", "proofs": [ "4VXRnbE8FJ1A6mb4pn6CtHagCGPFt3uXZgjcr1K8R1pHYRsm8fivvx5UHyK5EHGsvNFMvZfKivi9nqQxRe7V7TCt" ], "script": "base64:BgK/IggCEgMKAQgSAwoBCBIAEgQKAgEEEgQKAgEEEgMKAQESABIECgIIARIECgIIARIECgIIARIECgIBARIDCgEBEgUKAwEBARIFCgMBCAESBAoCAQgSBAoCAQgSBAoCCAgSBAoCCAgSBAoCCAESABIDCgEIEgUKAwEBARIECgIIARIECgIBARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCCIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiCnNsaXBwYWdlNEQiC3dhdmVzU3RyaW5nIgVBbXVsdCIFRGNvbnYiA1NFUCIFRU1QVFkiClBvb2xBY3RpdmUiClBvb2xQdXREaXMiDlBvb2xNYXRjaGVyRGlzIgxQb29sU2h1dGRvd24iDmlkeFBvb2xBZGRyZXNzIglpZHhQb29sU3QiCWlkeExQQXNJZCIJaWR4QW1Bc0lkIglpZHhQckFzSWQiC2lkeEFtdEFzRGNtIg1pZHhQcmljZUFzRGNtIgtpZHhJQW10QXNJZCINaWR4SVByaWNlQXNJZCIPaWR4RmFjdFN0YWtDbnRyIhJp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JsaWNLZXkJAAIBAgtNYXRjaCBlcnJvcgQCYXYFAmdPAwkAAQIFAmF2AgVPcmRlcgQCZHoFAmF2BAJnUgkBAmFKAAQCZ1MJAQJkeQEFAmR6BAJnVAkA9AMDCAUCZHoJYm9keUJ5dGVzCQCRAwIIBQJkegZwcm9vZnMAAAgFAmR6D3NlbmRlclB1YmxpY0tleQQCZ1UJAPQDAwgFAmR6CWJvZHlCeXRlcwkAkQMCCAUCZHoGcHJvb2ZzAAEFAmdSAwMDBQJnUwUCZ1QHBQJnVQcGCQECYXEDBQJnUwUCZ1QFAmdVAwkAAQIFAmF2AhRTZXRTY3JpcHRUcmFuc2FjdGlvbgQCZFoFAmF2BAJnVgkA9gMBCQEFdmFsdWUBCAUCZFoGc2NyaXB0BAJnVwkA2wQBCQEFdmFsdWUBCQCdCAIFAmFECQECYW8ABAJnWAkA8QcBBQR0aGlzAwMJAAACBQJnVwUCZ1YJAQIhPQIFAmdYBQJnVgcGCQD0AwMIBQJnTwlib2R5Qnl0ZXMJAJEDAggFAmdPBnByb29mcwAABQJnUQkA9AMDCAUCZ08JYm9keUJ5dGVzCQCRAwIIBQJnTwZwcm9vZnMAAAUCZ1GEykE/", "chainId": 84, "height": 2467950, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2vZHFhDbkCCjV4QTWnhMjjpBiGJjeB1Sqb7A2VcJShT1 Next: Gm59MEY78Hw4gwPA5rhY7dMdDAVeZw3BX9kVG1962tmP 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)
2117
2218 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
2319
7066 func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
7167
7268
73-func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
74-
75-
7669 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)
8670
8771
8872 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
131115 func ada () = "%s__addonAddr"
132116
133117
134-let keyFee = "%s__fee"
135-
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)
147-
148118 func fcfg () = "%s__factoryConfig"
149119
150120
166136 func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
167137
168138
169-func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
139+func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
140+
141+
142+func str (val) = match val {
143+ case valStr: String =>
144+ valStr
145+ case _ =>
146+ throw("fail cast to String")
147+}
170148
171149
172150 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
176154
177155
178156 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
179-
180-
181-func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
182157
183158
184159 let fca = addressFromStringValue(strf(this, fc()))
226201 else toBase58String(value(input))
227202
228203
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]))
204+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]))
230205
231206
232207 let poolConfigParsed = parsePoolConfig(gpc())
233208
234-let $t079658194 = poolConfigParsed
209+let $t069097095 = poolConfigParsed
235210
236-let cfgPoolAddress = $t079658194._1
211+let cfgPoolAddress = $t069097095._1
237212
238-let cfgPoolStatus = $t079658194._2
213+let cfgPoolStatus = $t069097095._2
239214
240-let cfgLpAssetId = $t079658194._3
215+let cfgLpAssetId = $t069097095._3
241216
242-let cfgAmountAssetId = $t079658194._4
217+let cfgAmountAssetId = $t069097095._4
243218
244-let cfgPriceAssetId = $t079658194._5
219+let cfgPriceAssetId = $t069097095._5
245220
246-let cfgAmountAssetDecimals = $t079658194._6
221+let cfgAmountAssetDecimals = $t069097095._6
247222
248-let cfgPriceAssetDecimals = $t079658194._7
249-
250-let cfgInAmountAssedId = $t079658194._8
251-
252-let cfgInPriceAssetId = $t079658194._9
223+let cfgPriceAssetDecimals = $t069097095._7
253224
254225 func gfc () = split(strf(fca, fcfg()), SEP)
255226
276247
277248
278249 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
279-
280-
281-func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
282250
283251
284252 func vad (A1,A2,slippage) = {
309277
310278
311279 func calcPrices (amAmt,prAmt,lpAmt) = {
312- let amtAsDcm = cfgAmountAssetDecimals
313- let prAsDcm = cfgPriceAssetDecimals
280+ let cfg = gpc()
281+ let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
282+ let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
314283 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
315284 let amAmtX18 = t1(amAmt, amtAsDcm)
316285 let prAmtX18 = t1(prAmt, prAsDcm)
335304 }
336305
337306
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, 15, 16, 17]
373- let $t01270312751 = {
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 18")
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($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)
386- }
387- let d = $t01270312751._1
388- let found = $t01270312751._2
389- if (found)
390- then d
391- else throw(("D calculation error, D = " + toString(d)))
392- }
393- }
394-
395-
396307 func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
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))
308+ let cfg = gpc()
309+ let lpId = cfg[idxLPAsId]
310+ let amId = cfg[idxAmAsId]
311+ let prId = cfg[idxPrAsId]
312+ let amDcm = parseIntValue(cfg[idxAmtAsDcm])
313+ let prDcm = parseIntValue(cfg[idxPriceAsDcm])
314+ let sts = cfg[idxPoolSt]
315+ let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
316+ if ((lpId != pmtAssetId))
405317 then throw("Wrong pmt asset")
406318 else {
407319 let amBalance = getAccBalance(amId)
414326 let lpEmissX18 = t1(lpEmiss, scale8)
415327 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
416328 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
417- let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
418- let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
329+ let outAmAmt = f1(outAmAmtX18, amDcm)
330+ let outPrAmt = f1(outPrAmtX18, prDcm)
419331 let state = if ((txId58 == ""))
420332 then nil
421333 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
429341
430342
431343 func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
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)
344+ let cfg = gpc()
345+ let lpId = fromBase58String(cfg[idxLPAsId])
346+ let amIdStr = cfg[idxAmAsId]
347+ let prIdStr = cfg[idxPrAsId]
348+ let inAmIdStr = cfg[idxIAmtAsId]
349+ let inPrIdStr = cfg[idxIPriceAsId]
350+ let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
351+ let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
352+ let sts = cfg[idxPoolSt]
440353 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
441354 let amBalance = if (isEval)
442355 then getAccBalance(amIdStr)
461374 let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
462375 let amBalanceX18 = t1(amBalance, amtDcm)
463376 let prBalanceX18 = t1(prBalance, priceDcm)
464- let D0 = getD([amBalanceX18, prBalanceX18])
465377 let r = if ((lpEm == 0))
466378 then {
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.")
379+ let curPriceX18 = zeroBigInt
380+ let slippageX18 = zeroBigInt
381+ let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
382+ $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
479383 }
480384 else {
481385 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
489393 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
490394 else {
491395 let lpEmissionX18 = t1(lpEm, scale8)
492- let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
493- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
396+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
397+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
494398 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
495399 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
496400 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
497401 let expAmtAssetAmtX18 = expectedAmts._1
498402 let expPriceAssetAmtX18 = expectedAmts._2
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.")
403+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
404+ $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
509405 }
510406 }
511407 let calcLpAmt = r._1
521417 else calcLpAmt
522418 let amDiff = (inAmAmt - calcAmAssetPmt)
523419 let prDiff = (inPrAmt - calcPrAssetPmt)
524- let $t02059020935 = if (if (isOneAsset)
420+ let $t01756217907 = if (if (isOneAsset)
525421 then (pmtId == amIdStr)
526422 else false)
527423 then $Tuple2(pmtAmt, 0)
530426 else false)
531427 then $Tuple2(0, pmtAmt)
532428 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
533- let writeAmAmt = $t02059020935._1
534- let writePrAmt = $t02059020935._2
429+ let writeAmAmt = $t01756217907._1
430+ let writePrAmt = $t01756217907._2
535431 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))]
536432 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
537433 }
538434 }
539435
540436
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 $t02213022150 = acc
554- let y = $t02213022150._1
555- let found = $t02213022150._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 $t02245722504 = {
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 = $t02245722504._1
583- let found = $t02245722504._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 $t02470224914 = if ((order.orderType == Buy))
628- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
629- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
630- let amountAssetBalanceDelta = $t02470224914._1
631- let priceAssetBalanceDelta = $t02470224914._2
437+func moa (order) = {
438+ let cfg = gpc()
439+ let amtAsId = cfg[idxAmAsId]
440+ let prAsId = cfg[idxPrAsId]
441+ let sts = parseIntValue(cfg[idxPoolSt])
442+ let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
443+ let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
444+ let accAmtAsBalance = getAccBalance(amtAsId)
445+ let accPrAsBalance = getAccBalance(prAsId)
446+ let curPriceX18 = if ((order.orderType == Buy))
447+ then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
448+ else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
449+ let curPrice = f1(curPriceX18, scale8)
632450 if (if (if (igs())
633451 then true
634- else (cfgPoolStatus == PoolMatcherDis))
452+ else (sts == PoolMatcherDis))
635453 then true
636- else (cfgPoolStatus == PoolShutdown))
454+ else (sts == PoolShutdown))
637455 then throw("Admin blocked")
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 $t02525625356 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
645- let unusedActions = $t02525625356._1
646- let dLpNew = $t02525625356._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- }
456+ else {
457+ let orAmtAsset = order.assetPair.amountAsset
458+ let orAmtAsStr = if ((orAmtAsset == unit))
459+ then "WAVES"
460+ else toBase58String(value(orAmtAsset))
461+ let orPrAsset = order.assetPair.priceAsset
462+ let orPrAsStr = if ((orPrAsset == unit))
463+ then "WAVES"
464+ else toBase58String(value(orPrAsset))
465+ if (if ((orAmtAsStr != amtAsId))
466+ then true
467+ else (orPrAsStr != prAsId))
468+ then throw("Wr assets")
469+ else {
470+ let orderPrice = order.price
471+ let priceDcm = fraction(scale8, prAsDcm, amtAsDcm)
472+ let castOrderPrice = ts(orderPrice, scale8, priceDcm)
473+ let isOrderPriceValid = if ((order.orderType == Buy))
474+ then (curPrice >= castOrderPrice)
475+ else (castOrderPrice >= curPrice)
476+ true
477+ }
478+ }
651479 }
652480
653481
683511 }
684512
685513
514+func getD (xp) = {
515+ let n = big2
516+ let xp0 = xp[0]
517+ let xp1 = xp[1]
518+ let aPrecision = parseBigIntValue(Amult)
519+ let a = (parseBigIntValue(A) * aPrecision)
520+ let s = (xp0 + xp1)
521+ if ((s == big0))
522+ then big0
523+ else {
524+ let ann = (a * n)
525+ let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
526+ let ann_s_aPrecision = ((ann * s) / aPrecision)
527+ let ann_aPrecision = (ann - aPrecision)
528+ let n1 = (n + big1)
529+ func calc (acc,cur) = {
530+ let $t02245922479 = acc
531+ let d = $t02245922479._1
532+ let found = $t02245922479._2
533+ if ((found != unit))
534+ then acc
535+ else {
536+ let dp = (((d * d) * d) / xp0_xp1_n_n)
537+ let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
538+ let dDiff = absBigInt((dNext - value(d)))
539+ if ((big1 >= dDiff))
540+ then $Tuple2(dNext, cur)
541+ else $Tuple2(dNext, unit)
542+ }
543+ }
544+
545+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
546+ let $t02290022947 = {
547+ let $l = arr
548+ let $s = size($l)
549+ let $acc0 = $Tuple2(s, unit)
550+ func $f0_1 ($a,$i) = if (($i >= $s))
551+ then $a
552+ else calc($a, $l[$i])
553+
554+ func $f0_2 ($a,$i) = if (($i >= $s))
555+ then $a
556+ else throw("List size exceeds 15")
557+
558+ $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)
559+ }
560+ let d = $t02290022947._1
561+ let found = $t02290022947._2
562+ if ((found != unit))
563+ then d
564+ else throw(("D calculation error, D = " + toString(d)))
565+ }
566+ }
567+
568+
569+func getYD (xp,i,D) = {
570+ let n = big2
571+ let x = xp[if ((i == 0))
572+ then 1
573+ else 0]
574+ let aPrecision = parseBigIntValue(Amult)
575+ let a = (parseBigIntValue(A) * aPrecision)
576+ let s = x
577+ let ann = (a * n)
578+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
579+ let b = ((s + ((D * aPrecision) / ann)) - D)
580+ func calc (acc,cur) = {
581+ let $t02344723467 = acc
582+ let y = $t02344723467._1
583+ let found = $t02344723467._2
584+ if ((found != unit))
585+ then acc
586+ else {
587+ let yNext = (((y * y) + c) / ((big2 * y) + b))
588+ let yDiff = absBigInt((yNext - value(y)))
589+ if ((big1 >= yDiff))
590+ then $Tuple2(yNext, cur)
591+ else $Tuple2(yNext, unit)
592+ }
593+ }
594+
595+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
596+ let $t02377423821 = {
597+ let $l = arr
598+ let $s = size($l)
599+ let $acc0 = $Tuple2(D, unit)
600+ func $f0_1 ($a,$i) = if (($i >= $s))
601+ then $a
602+ else calc($a, $l[$i])
603+
604+ func $f0_2 ($a,$i) = if (($i >= $s))
605+ then $a
606+ else throw("List size exceeds 15")
607+
608+ $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)
609+ }
610+ let y = $t02377423821._1
611+ let found = $t02377423821._2
612+ if ((found != unit))
613+ then y
614+ else throw(("Y calculation error, Y = " + toString(y)))
615+ }
616+
617+
686618 func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
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)
619+ let poolConfig = gpc()
620+ let amId = poolConfig[idxAmAsId]
621+ let prId = poolConfig[idxPrAsId]
622+ let lpId = poolConfig[idxLPAsId]
623+ let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm])
624+ let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm])
625+ let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
693626 let chechEmission = if ((lpAssetEmission > big0))
694627 then true
695628 else throw("initial deposit requires all coins")
697630 then {
698631 let amBalance = getAccBalance(amId)
699632 let prBalance = getAccBalance(prId)
700- let $t02801228474 = if ((txId == ""))
633+ let $t02460425066 = if ((txId == ""))
701634 then $Tuple2(amBalance, prBalance)
702635 else if ((pmtAssetId == amId))
703636 then if ((pmtAmtRaw > amBalance))
708641 then throw("invalid payment amount")
709642 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
710643 else throw("wrong pmtAssetId")
711- let amBalanceOld = $t02801228474._1
712- let prBalanceOld = $t02801228474._2
713- let $t02848028656 = if ((pmtAssetId == amId))
644+ let amBalanceOld = $t02460425066._1
645+ let prBalanceOld = $t02460425066._2
646+ let $t02507225248 = if ((pmtAssetId == amId))
714647 then $Tuple2(pmtAmtRaw, 0)
715648 else if ((pmtAssetId == prId))
716649 then $Tuple2(0, pmtAmtRaw)
717650 else throw("invalid payment")
718- let amAmountRaw = $t02848028656._1
719- let prAmountRaw = $t02848028656._2
720- let $t02866028914 = if (withTakeFee)
651+ let amAmountRaw = $t02507225248._1
652+ let prAmountRaw = $t02507225248._2
653+ let $t02525225506 = if (withTakeFee)
721654 then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
722655 else $Tuple3(amAmountRaw, prAmountRaw, 0)
723- let amAmount = $t02866028914._1
724- let prAmount = $t02866028914._2
725- let feeAmount = $t02866028914._3
656+ let amAmount = $t02525225506._1
657+ let prAmount = $t02525225506._2
658+ let feeAmount = $t02525225506._3
726659 let amBalanceNew = (amBalanceOld + amAmount)
727660 let prBalanceNew = (prBalanceOld + prAmount)
728- let D0 = getD([t1(amBalanceOld, cfgAmountAssetDecimals), t1(prBalanceOld, cfgPriceAssetDecimals)])
729- let D1 = getD([t1(amBalanceNew, cfgAmountAssetDecimals), t1(prBalanceNew, cfgPriceAssetDecimals)])
661+ let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
662+ let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)])
730663 let checkD = if ((D1 > D0))
731664 then true
732665 else throw()
733666 if ((checkD == checkD))
734667 then {
735- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
668+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
736669 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
737670 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))]
738671 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
749682
750683
751684 func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = {
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
685+ let poolConfig = gpc()
686+ let lpId = poolConfig[idxLPAsId]
687+ let amId = poolConfig[idxAmAsId]
688+ let prId = poolConfig[idxPrAsId]
689+ let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
690+ let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
691+ let poolStatus = poolConfig[idxPoolSt]
758692 let userAddress = if ((caller == restContract))
759693 then originCaller
760694 else caller
761695 let pmt = value(payments[0])
762696 let pmtAssetId = value(pmt.assetId)
763697 let pmtAmt = pmt.amount
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 $t03102631137 = {
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 (($t03102631137 == $t03102631137))
698+ let txId58 = toBase58String(transactionId)
699+ if ((lpId != toBase58String(pmtAssetId)))
700+ then throw("Wrong LP")
701+ else {
702+ let amBalance = getAccBalance(amId)
703+ let prBalance = getAccBalance(prId)
704+ let $t02750827619 = {
705+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
706+ if ($isInstanceOf(@, "(Int, Int)"))
707+ then @
708+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
709+ }
710+ if (($t02750827619 == $t02750827619))
711+ then {
712+ let feeAmount = $t02750827619._2
713+ let totalGet = $t02750827619._1
714+ let totalAmount = if (if ((minOutAmount > 0))
715+ then (minOutAmount > totalGet)
716+ else false)
717+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
718+ else totalGet
719+ let $t02780928116 = if ((outAssetId == amId))
720+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
721+ else if ((outAssetId == prId))
722+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
723+ else throw("invalid out asset id")
724+ let outAm = $t02780928116._1
725+ let outPr = $t02780928116._2
726+ let amBalanceNew = $t02780928116._3
727+ let prBalanceNew = $t02780928116._4
728+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
729+ let curPr = f1(curPrX18, scale8)
730+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
731+ then unit
732+ else fromBase58String(outAssetId)
733+ let sendFeeToMatcher = if ((feeAmount > 0))
734+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
735+ else nil
736+ 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)
737+ if ((state == state))
780738 then {
781- let feeAmount = $t03102631137._2
782- let totalGet = $t03102631137._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 $t03132731634 = 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 = $t03132731634._1
794- let outPr = $t03132731634._2
795- let amBalanceNew = $t03132731634._3
796- let prBalanceNew = $t03132731634._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 $t03241932769 = {
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 = $t03241932769._1
823- let priceAssetBalanceDelta = $t03241932769._2
824- let $t03277232880 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
825- let refreshDLpActions = $t03277232880._1
826- let updatedDLp = $t03277232880._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- }
739+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
740+ if ((burn == burn))
741+ then $Tuple2(state, totalAmount)
834742 else throw("Strict value is not equal to itself.")
835743 }
836744 else throw("Strict value is not equal to itself.")
837745 }
746+ else throw("Strict value is not equal to itself.")
838747 }
839- else throw("Strict value is not equal to itself.")
840748 }
841749
842750
884792 case _ =>
885793 throw("Match error")
886794 }
887-
888-
889-func getY (isReverse,D,poolAmountInBalance) = {
890- let poolConfig = gpc()
891- let amId = poolConfig[idxAmAsId]
892- let prId = poolConfig[idxPrAsId]
893- let n = big2
894- let aPrecision = parseBigIntValue(Amult)
895- let a = (parseBigIntValue(A) * aPrecision)
896- let xp = if ((isReverse == false))
897- then [(toBigInt(getAccBalance(amId)) + poolAmountInBalance), toBigInt(getAccBalance(prId))]
898- else [(toBigInt(getAccBalance(prId)) + poolAmountInBalance), toBigInt(getAccBalance(amId))]
899- let x = xp[0]
900- let s = x
901- let ann = (a * n)
902- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
903- let b = ((s + ((D * aPrecision) / ann)) - D)
904- func calc (acc,cur) = {
905- let $t03432734347 = acc
906- let y = $t03432734347._1
907- let found = $t03432734347._2
908- if ((found != unit))
909- then acc
910- else {
911- let yNext = (((y * y) + c) / ((big2 * y) + b))
912- let yDiff = absBigInt((yNext - value(y)))
913- if ((big1 >= yDiff))
914- then $Tuple2(yNext, cur)
915- else $Tuple2(yNext, unit)
916- }
917- }
918-
919- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
920- let $t03467834725 = {
921- let $l = arr
922- let $s = size($l)
923- let $acc0 = $Tuple2(D, unit)
924- func $f0_1 ($a,$i) = if (($i >= $s))
925- then $a
926- else calc($a, $l[$i])
927-
928- func $f0_2 ($a,$i) = if (($i >= $s))
929- then $a
930- else throw("List size exceeds 15")
931-
932- $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)
933- }
934- let y = $t03467834725._1
935- let found = $t03467834725._2
936- if ((found != unit))
937- then y
938- else throw(("Y calculation error, Y = " + toString(y)))
939- }
940-
941-
942-@Callable(i)
943-func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = {
944- let $t03496635390 = if ((isReverse == false))
945- then {
946- let assetOut = strf(this, pa())
947- let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn))
948- $Tuple2(assetOut, poolAmountInBalance)
949- }
950- else {
951- let assetOut = strf(this, aa())
952- let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn))
953- $Tuple2(assetOut, poolAmountInBalance)
954- }
955- let assetOut = $t03496635390._1
956- let poolAmountInBalance = $t03496635390._2
957- let poolConfig = gpc()
958- let amId = poolConfig[idxAmAsId]
959- let prId = poolConfig[idxPrAsId]
960- let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
961- let D = getD(xp)
962- let y = getY(isReverse, D, toBigInt(cleanAmountIn))
963- let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
964- let totalGetRaw = max([0, toInt(dy)])
965- let newXp = if ((isReverse == false))
966- then [((toBigInt(getAccBalance(amId)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)), (toBigInt(getAccBalance(prId)) - dy)]
967- else [(toBigInt(getAccBalance(amId)) - dy), ((toBigInt(getAccBalance(prId)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount))]
968- let newD = getD(newXp)
969- let checkD = if ((newD >= D))
970- then true
971- else throw(makeString(["new D is fewer error", toString(D), toString(newD)], "__"))
972- if ((checkD == checkD))
973- then $Tuple2(nil, totalGetRaw)
974- else throw("Strict value is not equal to itself.")
975- }
976-
977-
978-
979-@Callable(i)
980-func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = {
981- let swapContact = {
982- let @ = invoke(fca, "getSwapContractREADONLY", nil, nil)
983- if ($isInstanceOf(@, "String"))
984- then @
985- else throw(($getType(@) + " couldn't be cast to String"))
986- }
987- let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
988- then true
989- else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact)))
990- then true
991- else throwErr("Permission denied")]
992- if ((checks == checks))
993- then {
994- let pmt = value(i.payments[0])
995- let assetIn = assetIdToString(pmt.assetId)
996- let $t03682637220 = if ((isReverse == false))
997- then {
998- let assetOut = strf(this, pa())
999- let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
1000- $Tuple2(assetOut, poolAmountInBalance)
1001- }
1002- else {
1003- let assetOut = strf(this, aa())
1004- let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
1005- $Tuple2(assetOut, poolAmountInBalance)
1006- }
1007- let assetOut = $t03682637220._1
1008- let poolAmountInBalance = $t03682637220._2
1009- let poolConfig = gpc()
1010- let amId = poolConfig[idxAmAsId]
1011- let prId = poolConfig[idxPrAsId]
1012- let xp = if ((isReverse == false))
1013- then [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))]
1014- else [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - toBigInt(value(i.payments[0]).amount))]
1015- let D = getD(xp)
1016- let y = getY(isReverse, D, toBigInt(0))
1017- let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
1018- let totalGetRaw = max([0, toInt(dy)])
1019- let checkMin = if ((totalGetRaw >= amountOutMin))
1020- then true
1021- else throw("Exchange result is fewer coins than expected")
1022- if ((checkMin == checkMin))
1023- then {
1024- let newXp = if ((isReverse == false))
1025- then [(toBigInt(getAccBalance(amId)) + toBigInt(feePoolAmount)), (toBigInt(getAccBalance(prId)) - dy)]
1026- else [(toBigInt(getAccBalance(amId)) - dy), (toBigInt(getAccBalance(prId)) + toBigInt(feePoolAmount))]
1027- let newD = getD(newXp)
1028- let checkD = if ((newD >= D))
1029- then true
1030- else throw("new D is fewer error")
1031- if ((checkD == checkD))
1032- then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, parseAssetId(assetOut))], totalGetRaw)
1033- else throw("Strict value is not equal to itself.")
1034- }
1035- else throw("Strict value is not equal to itself.")
1036- }
1037- else throw("Strict value is not equal to itself.")
1038- }
1039-
1040795
1041796
1042797 @Callable(i)
1094849 else if ((size(i.payments) != 2))
1095850 then throw("2 pmnts expd")
1096851 else {
1097- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1098- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1099- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
1100- if ((amountAssetBalance == amountAssetBalance))
852+ 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, "")
853+ let emitLpAmt = e._2
854+ let lpAssetId = e._7
855+ let state = e._9
856+ let amDiff = e._10
857+ let prDiff = e._11
858+ let amId = e._12
859+ let prId = e._13
860+ let r = invoke(fca, "emit", [emitLpAmt], nil)
861+ if ((r == r))
1101862 then {
1102- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
1103- if ((priceAssetBalance == priceAssetBalance))
863+ let el = match r {
864+ case legacy: Address =>
865+ invoke(legacy, "emit", [emitLpAmt], nil)
866+ case _ =>
867+ unit
868+ }
869+ if ((el == el))
1104870 then {
1105- let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
1106- if ((lpAssetEmission == lpAssetEmission))
871+ let sa = if ((amDiff > 0))
872+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
873+ else nil
874+ if ((sa == sa))
1107875 then {
1108- let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1109- if ((currentDLp == currentDLp))
876+ let sp = if ((prDiff > 0))
877+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
878+ else nil
879+ if ((sp == sp))
1110880 then {
1111- 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, "")
1112- let emitLpAmt = e._2
1113- let lpAssetId = e._7
1114- let state = e._9
1115- let amDiff = e._10
1116- let prDiff = e._11
1117- let amId = e._12
1118- let prId = e._13
1119- let r = invoke(fca, "emit", [emitLpAmt], nil)
1120- if ((r == r))
881+ let lpTrnsfr = if (autoStake)
1121882 then {
1122- let el = match r {
1123- case legacy: Address =>
1124- invoke(legacy, "emit", [emitLpAmt], nil)
1125- case _ =>
1126- unit
1127- }
1128- if ((el == el))
1129- then {
1130- let sa = if ((amDiff > 0))
1131- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1132- else nil
1133- if ((sa == sa))
1134- then {
1135- let sp = if ((prDiff > 0))
1136- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1137- else nil
1138- if ((sp == sp))
1139- then {
1140- let lpTrnsfr = if (autoStake)
1141- then {
1142- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1143- if ((ss == ss))
1144- then nil
1145- else throw("Strict value is not equal to itself.")
1146- }
1147- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1148- let $t04183941981 = refreshDLpInternal(0, 0, 0)
1149- let refreshDLpActions = $t04183941981._1
1150- let updatedDLp = $t04183941981._2
1151- let check = if ((updatedDLp >= currentDLp))
1152- then true
1153- else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1154- if ((check == check))
1155- then {
1156- let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1157- if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1158- then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1159- else throw("Strict value is not equal to itself.")
1160- }
1161- else throw("Strict value is not equal to itself.")
1162- }
1163- else throw("Strict value is not equal to itself.")
1164- }
1165- else throw("Strict value is not equal to itself.")
1166- }
883+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
884+ if ((ss == ss))
885+ then nil
1167886 else throw("Strict value is not equal to itself.")
1168887 }
1169- else throw("Strict value is not equal to itself.")
888+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
889+ (state ++ lpTrnsfr)
1170890 }
1171891 else throw("Strict value is not equal to itself.")
1172892 }
1204924 else throwErr("exactly 1 payment are expected")]
1205925 if ((checks == checks))
1206926 then {
1207- let amId = toBase58String(value(cfgAmountAssetId))
1208- let prId = toBase58String(value(cfgPriceAssetId))
1209- let lpId = cfgLpAssetId
1210- let amDecimals = cfgAmountAssetDecimals
1211- let prDecimals = cfgPriceAssetDecimals
927+ let poolConfig = gpc()
928+ let amId = poolConfig[idxAmAsId]
929+ let prId = poolConfig[idxPrAsId]
930+ let lpId = fromBase58String(poolConfig[idxLPAsId])
931+ let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
932+ let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
1212933 let userAddress = if ((i.caller == this))
1213934 then i.originCaller
1214935 else i.caller
1215936 let pmt = value(i.payments[0])
1216937 let pmtAssetId = toBase58String(value(pmt.assetId))
1217938 let pmtAmt = pmt.amount
1218- let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1219- then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1220- else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1221- if ((currentDLp == currentDLp))
939+ let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
940+ if (($t03347833636 == $t03347833636))
1222941 then {
1223- let $t04362243780 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1224- if (($t04362243780 == $t04362243780))
942+ let feeAmount = $t03347833636._3
943+ let state = $t03347833636._2
944+ let estimLP = $t03347833636._1
945+ let emitLpAmt = if (if ((minOutAmount > 0))
946+ then (minOutAmount > estimLP)
947+ else false)
948+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
949+ else estimLP
950+ let e = invoke(fca, "emit", [emitLpAmt], nil)
951+ if ((e == e))
1225952 then {
1226- let feeAmount = $t04362243780._3
1227- let state = $t04362243780._2
1228- let estimLP = $t04362243780._1
1229- let emitLpAmt = if (if ((minOutAmount > 0))
1230- then (minOutAmount > estimLP)
1231- else false)
1232- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1233- else estimLP
1234- let e = invoke(fca, "emit", [emitLpAmt], nil)
1235- if ((e == e))
953+ let el = match e {
954+ case legacy: Address =>
955+ invoke(legacy, "emit", [emitLpAmt], nil)
956+ case _ =>
957+ unit
958+ }
959+ if ((el == el))
1236960 then {
1237- let el = match e {
1238- case legacy: Address =>
1239- invoke(legacy, "emit", [emitLpAmt], nil)
1240- case _ =>
1241- unit
1242- }
1243- if ((el == el))
961+ let lpTrnsfr = if (autoStake)
1244962 then {
1245- let lpTrnsfr = if (autoStake)
1246- then {
1247- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1248- if ((ss == ss))
1249- then nil
1250- else throw("Strict value is not equal to itself.")
1251- }
1252- else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1253- let sendFeeToMatcher = if ((feeAmount > 0))
1254- then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1255- else nil
1256- let $t04459544944 = if ((this == feeCollectorAddress))
1257- then $Tuple2(0, 0)
1258- else {
1259- let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1260- then true
1261- else false
1262- if (paymentInAmountAsset)
1263- then $Tuple2(-(feeAmount), 0)
1264- else $Tuple2(0, -(feeAmount))
1265- }
1266- let amountAssetBalanceDelta = $t04459544944._1
1267- let priceAssetBalanceDelta = $t04459544944._2
1268- let $t04494745055 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1269- let refreshDLpActions = $t04494745055._1
1270- let updatedDLp = $t04494745055._2
1271- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1272- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1273- then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
963+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
964+ if ((ss == ss))
965+ then nil
1274966 else throw("Strict value is not equal to itself.")
1275967 }
1276- else throw("Strict value is not equal to itself.")
968+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
969+ let sendFeeToMatcher = if ((feeAmount > 0))
970+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
971+ else nil
972+ $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt)
1277973 }
1278974 else throw("Strict value is not equal to itself.")
1279975 }
1293989 then throw("2 pmnts expd")
1294990 else {
1295991 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, "")
1296- let state = estPut._9
1297- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1298- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1299- let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1300- if ((currentDLp == currentDLp))
1301- then {
1302- let $t04608546150 = refreshDLpInternal(0, 0, 0)
1303- let refreshDLpActions = $t04608546150._1
1304- let updatedDLp = $t04608546150._2
1305- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1306- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1307- then (state ++ refreshDLpActions)
1308- else throw("Strict value is not equal to itself.")
1309- }
1310- else throw("Strict value is not equal to itself.")
992+ estPut._9
1311993 }
1312994
1313995
1314996
1315997 @Callable(i)
1316998 func get () = {
1317- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1318- if ((currentDLp == currentDLp))
1319- then {
1320- let r = cg(i)
1321- let outAmtAmt = r._1
1322- let outPrAmt = r._2
1323- let pmtAmt = r._3
1324- let pmtAssetId = r._4
1325- let state = r._5
1326- let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1327- if ((b == b))
1328- then {
1329- let $t04732347405 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1330- let refreshDLpActions = $t04732347405._1
1331- let updatedDLp = $t04732347405._2
1332- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1333- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1334- then (state ++ refreshDLpActions)
1335- else throw("Strict value is not equal to itself.")
1336- }
1337- else throw("Strict value is not equal to itself.")
1338- }
999+ let r = cg(i)
1000+ let outAmtAmt = r._1
1001+ let outPrAmt = r._2
1002+ let pmtAmt = r._3
1003+ let pmtAssetId = r._4
1004+ let state = r._5
1005+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1006+ if ((b == b))
1007+ then state
13391008 else throw("Strict value is not equal to itself.")
13401009 }
13411010
13631032 else throwErr("exactly 1 payment are expected")]
13641033 if ((checks == checks))
13651034 then {
1366- let $t04802348178 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1367- let state = $t04802348178._1
1368- let totalAmount = $t04802348178._2
1035+ let $t03625836413 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1036+ let state = $t03625836413._1
1037+ let totalAmount = $t03625836413._2
13691038 $Tuple2(state, totalAmount)
13701039 }
13711040 else throw("Strict value is not equal to itself.")
13741043
13751044
13761045 @Callable(i)
1377-func refreshDLp () = {
1378- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1379- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1380- then unit
1381- else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1382- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1383- then {
1384- let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1385- let $t04870248766 = refreshDLpInternal(0, 0, 0)
1386- let dLpUpdateActions = $t04870248766._1
1387- let updatedDLp = $t04870248766._2
1388- let actions = if ((dLp != updatedDLp))
1389- then dLpUpdateActions
1390- else throwErr("nothing to refresh")
1391- $Tuple2(actions, toString(updatedDLp))
1392- }
1393- else throw("Strict value is not equal to itself.")
1394- }
1395-
1396-
1397-
1398-@Callable(i)
13991046 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1400- let amId = toBase58String(value(cfgAmountAssetId))
1401- let prId = toBase58String(value(cfgPriceAssetId))
1402- let lpId = toBase58String(value(cfgLpAssetId))
1047+ let poolConfig = gpc()
1048+ let amId = poolConfig[idxAmAsId]
1049+ let prId = poolConfig[idxPrAsId]
1050+ let lpId = poolConfig[idxLPAsId]
14031051 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
14041052 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
14051053 let D0 = getD(xp)
14121060 let newY = getYD(xp, index, D1)
14131061 let dy = (xp[index] - newY)
14141062 let totalGetRaw = max([0, toInt((dy - big1))])
1415- let $t04977649831 = takeFee(totalGetRaw, outFee)
1416- let totalGet = $t04977649831._1
1417- let feeAmount = $t04977649831._2
1063+ let $t03720337258 = takeFee(totalGetRaw, outFee)
1064+ let totalGet = $t03720337258._1
1065+ let feeAmount = $t03720337258._2
14181066 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
14191067 }
14201068
14221070
14231071 @Callable(i)
14241072 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1425- let amId = toBase58String(value(cfgAmountAssetId))
1426- let prId = toBase58String(value(cfgPriceAssetId))
1427- let lpId = toBase58String(value(cfgLpAssetId))
1073+ let poolConfig = gpc()
1074+ let amId = poolConfig[idxAmAsId]
1075+ let prId = poolConfig[idxPrAsId]
1076+ let lpId = poolConfig[idxLPAsId]
14281077 let amBalance = getAccBalance(amId)
14291078 let prBalance = getAccBalance(prId)
1430- let $t05020650321 = {
1079+ let $t03760337718 = {
14311080 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
14321081 if ($isInstanceOf(@, "(Int, Int)"))
14331082 then @
14341083 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
14351084 }
1436- let totalGet = $t05020650321._1
1437- let feeAmount = $t05020650321._2
1085+ let totalGet = $t03760337718._1
1086+ let feeAmount = $t03760337718._2
14381087 let r = ego("", lpId, lpAssetAmount, this)
14391088 let outAmAmt = r._1
14401089 let outPrAmt = r._2
14621111 else if ((noLessThenPriceAsset > outPrAmt))
14631112 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
14641113 else {
1465- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1466- if ((currentDLp == currentDLp))
1467- then {
1468- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1469- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1470- then {
1471- let $t05148751568 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1472- let refreshDLpActions = $t05148751568._1
1473- let updatedDLp = $t05148751568._2
1474- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1475- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1476- then (state ++ refreshDLpActions)
1477- else throw("Strict value is not equal to itself.")
1478- }
1479- else throw("Strict value is not equal to itself.")
1480- }
1114+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1115+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1116+ then state
14811117 else throw("Strict value is not equal to itself.")
14821118 }
14831119 }
14911127 else true
14921128 if ((checkPayments == checkPayments))
14931129 then {
1130+ let cfg = gpc()
14941131 let factoryCfg = gfc()
1495- let lpAssetId = cfgLpAssetId
1132+ let lpAssetId = fromBase58String(cfg[idxLPAsId])
14961133 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1497- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1498- if ((currentDLp == currentDLp))
1134+ let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1135+ if ((unstakeInv == unstakeInv))
14991136 then {
1500- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1501- if ((unstakeInv == unstakeInv))
1137+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1138+ let sts = parseIntValue(r._9)
1139+ let state = r._10
1140+ let v = if (if (igs())
1141+ then true
1142+ else (sts == PoolShutdown))
1143+ then throw(("Blocked: " + toString(sts)))
1144+ else true
1145+ if ((v == v))
15021146 then {
1503- let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1504- let outAmAmt = r._1
1505- let outPrAmt = r._2
1506- let sts = parseIntValue(r._9)
1507- let state = r._10
1508- let v = if (if (igs())
1509- then true
1510- else (sts == PoolShutdown))
1511- then throw(("Blocked: " + toString(sts)))
1512- else true
1513- if ((v == v))
1514- then {
1515- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1516- if ((burnA == burnA))
1517- then {
1518- let $t05259552676 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1519- let refreshDLpActions = $t05259552676._1
1520- let updatedDLp = $t05259552676._2
1521- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1522- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1523- then (state ++ refreshDLpActions)
1524- else throw("Strict value is not equal to itself.")
1525- }
1526- else throw("Strict value is not equal to itself.")
1527- }
1147+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1148+ if ((burnA == burnA))
1149+ then state
15281150 else throw("Strict value is not equal to itself.")
15291151 }
15301152 else throw("Strict value is not equal to itself.")
15481170 else throw("no payments are expected")]
15491171 if ((checks == checks))
15501172 then {
1551- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1552- if ((currentDLp == currentDLp))
1173+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1174+ if ((unstakeInv == unstakeInv))
15531175 then {
1554- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1555- if ((unstakeInv == unstakeInv))
1176+ let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1177+ let outAmAmt = res._1
1178+ let outPrAmt = res._2
1179+ let state = res._10
1180+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1181+ then true
1182+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1183+ then true
1184+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1185+ if ((checkAmounts == checkAmounts))
15561186 then {
1557- let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1558- let outAmAmt = res._1
1559- let outPrAmt = res._2
1560- let state = res._10
1561- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1562- then true
1563- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1564- then true
1565- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1566- if ((checkAmounts == checkAmounts))
1567- then {
1568- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1569- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1570- then {
1571- let $t05392754008 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1572- let refreshDLpActions = $t05392754008._1
1573- let updatedDLp = $t05392754008._2
1574- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1575- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1576- then (state ++ refreshDLpActions)
1577- else throw("Strict value is not equal to itself.")
1578- }
1579- else throw("Strict value is not equal to itself.")
1580- }
1187+ let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1188+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1189+ then state
15811190 else throw("Strict value is not equal to itself.")
15821191 }
15831192 else throw("Strict value is not equal to itself.")
16111220 else throwErr("no payments are expected")]
16121221 if ((checks == checks))
16131222 then {
1223+ let cfg = gpc()
16141224 let factoryCfg = gfc()
1615- let lpAssetId = cfgLpAssetId
1225+ let lpAssetId = fromBase58String(cfg[idxLPAsId])
16161226 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1617- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
1227+ let userAddress = i.caller
1228+ let lpAssetRecipientAddress = this
1229+ let unstakeInv = invoke(staking, "unstakeINTERNAL", [lpAssetId, unstakeAmount, userAddress.bytes, lpAssetRecipientAddress.bytes], nil)
16181230 if ((unstakeInv == unstakeInv))
16191231 then {
1620- let $t05490355091 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1621- let state = $t05490355091._1
1622- let totalAmount = $t05490355091._2
1232+ let $t04168341871 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1233+ let state = $t04168341871._1
1234+ let totalAmount = $t04168341871._2
16231235 $Tuple2(state, totalAmount)
16241236 }
16251237 else throw("Strict value is not equal to itself.")
16311243
16321244 @Callable(i)
16331245 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1634- let $t05521955322 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1635- let lpAmount = $t05521955322._1
1636- let state = $t05521955322._2
1637- let feeAmount = $t05521955322._3
1638- let bonus = $t05521955322._4
1246+ let poolConfig = gpc()
1247+ let amId = poolConfig[idxAmAsId]
1248+ let prId = poolConfig[idxPrAsId]
1249+ let lpId = poolConfig[idxLPAsId]
1250+ let $t04213042233 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1251+ let lpAmount = $t04213042233._1
1252+ let state = $t04213042233._2
1253+ let feeAmount = $t04213042233._3
1254+ let bonus = $t04213042233._4
16391255 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
16401256 }
16411257
16431259
16441260 @Callable(i)
16451261 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1646- let $t05547055574 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1647- let lpAmount = $t05547055574._1
1648- let state = $t05547055574._2
1649- let feeAmount = $t05547055574._3
1650- let bonus = $t05547055574._4
1262+ let poolConfig = gpc()
1263+ let amId = poolConfig[idxAmAsId]
1264+ let prId = poolConfig[idxPrAsId]
1265+ let lpId = poolConfig[idxLPAsId]
1266+ let $t04251242616 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1267+ let lpAmount = $t04251242616._1
1268+ let state = $t04251242616._2
1269+ let feeAmount = $t04251242616._3
1270+ let bonus = $t04251242616._4
16511271 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
16521272 }
16531273
17321352 match tx {
17331353 case order: Order =>
17341354 let matcherPub = mp()
1735- let $t05836658435 = validateMatcherOrderAllowed(order)
1736- let orderValid = $t05836658435._1
1737- let orderValidInfo = $t05836658435._2
1355+ let orderValid = moa(order)
17381356 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
17391357 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
17401358 if (if (if (orderValid)
17431361 then matcherValid
17441362 else false)
17451363 then true
1746- else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
1364+ else toe(orderValid, senderValid, matcherValid)
17471365 case s: SetScriptTransaction =>
1748- if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
1366+ let newHash = blake2b256(value(s.script))
1367+ let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1368+ let currentHash = scriptHash(this)
1369+ if (if ((allowedHash == newHash))
1370+ then (currentHash != newHash)
1371+ else false)
17491372 then true
1750- else {
1751- let newHash = blake2b256(value(s.script))
1752- let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1753- let currentHash = scriptHash(this)
1754- if ((allowedHash == newHash))
1755- then (currentHash != newHash)
1756- else false
1757- }
1373+ else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
17581374 case _ =>
17591375 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
17601376 }
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)
2117
2218 let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8)))
2319
2420 let wavesString = "WAVES"
2521
2622 let Amult = "100"
2723
2824 let Dconv = "1"
2925
3026 let SEP = "__"
3127
3228 let EMPTY = ""
3329
3430 let PoolActive = 1
3531
3632 let PoolPutDis = 2
3733
3834 let PoolMatcherDis = 3
3935
4036 let PoolShutdown = 4
4137
4238 let idxPoolAddress = 1
4339
4440 let idxPoolSt = 2
4541
4642 let idxLPAsId = 3
4743
4844 let idxAmAsId = 4
4945
5046 let idxPrAsId = 5
5147
5248 let idxAmtAsDcm = 6
5349
5450 let idxPriceAsDcm = 7
5551
5652 let idxIAmtAsId = 8
5753
5854 let idxIPriceAsId = 9
5955
6056 let idxFactStakCntr = 1
6157
6258 let idxFactoryRestCntr = 6
6359
6460 let idxFactSlippCntr = 7
6561
6662 let idxFactGwxRewCntr = 10
6763
6864 let feeDefault = fraction(10, scale8, 10000)
6965
7066 func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult))
7167
7268
73-func t1BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult)
74-
75-
7669 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)
8670
8771
8872 func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale)
8973
9074
9175 func abs (val) = if ((zeroBigInt > val))
9276 then -(val)
9377 else val
9478
9579
9680 func absBigInt (val) = if ((zeroBigInt > val))
9781 then -(val)
9882 else val
9983
10084
10185 func fc () = "%s__factoryContract"
10286
10387
10488 func mpk () = "%s__managerPublicKey"
10589
10690
10791 func pmpk () = "%s__pendingManagerPublicKey"
10892
10993
11094 func pl () = "%s%s__price__last"
11195
11296
11397 func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP)
11498
11599
116100 func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId)
117101
118102
119103 func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId)
120104
121105
122106 func aa () = "%s__amountAsset"
123107
124108
125109 func pa () = "%s__priceAsset"
126110
127111
128112 func amp () = "%s__amp"
129113
130114
131115 func ada () = "%s__addonAddr"
132116
133117
134-let keyFee = "%s__fee"
135-
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)
147-
148118 func fcfg () = "%s__factoryConfig"
149119
150120
151121 func mtpk () = "%s%s__matcher__publicKey"
152122
153123
154124 func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config")
155125
156126
157127 func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr)
158128
159129
160130 func aps () = "%s__shutdown"
161131
162132
163133 func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash"
164134
165135
166136 func keyFeeCollectorAddress () = "%s__feeCollectorAddress"
167137
168138
169-func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid)))
139+func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV)))
140+
141+
142+func str (val) = match val {
143+ case valStr: String =>
144+ valStr
145+ case _ =>
146+ throw("fail cast to String")
147+}
170148
171149
172150 func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
173151
174152
175153 func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], ""))
176154
177155
178156 func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " "))
179-
180-
181-func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ")
182157
183158
184159 let fca = addressFromStringValue(strf(this, fc()))
185160
186161 let inFee = {
187162 let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil)
188163 if ($isInstanceOf(@, "Int"))
189164 then @
190165 else throw(($getType(@) + " couldn't be cast to Int"))
191166 }
192167
193168 let outFee = {
194169 let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil)
195170 if ($isInstanceOf(@, "Int"))
196171 then @
197172 else throw(($getType(@) + " couldn't be cast to Int"))
198173 }
199174
200175 let A = strf(this, amp())
201176
202177 func igs () = valueOrElse(getBoolean(fca, aps()), false)
203178
204179
205180 func mp () = fromBase58String(strf(fca, mtpk()))
206181
207182
208183 let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress()))
209184
210185 func gpc () = {
211186 let amtAs = strf(this, aa())
212187 let priceAs = strf(this, pa())
213188 let iPriceAs = intf(fca, mba(priceAs))
214189 let iAmtAs = intf(fca, mba(amtAs))
215190 split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP)
216191 }
217192
218193
219194 func parseAssetId (input) = if ((input == wavesString))
220195 then unit
221196 else fromBase58String(input)
222197
223198
224199 func assetIdToString (input) = if ((input == unit))
225200 then wavesString
226201 else toBase58String(value(input))
227202
228203
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]))
204+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]))
230205
231206
232207 let poolConfigParsed = parsePoolConfig(gpc())
233208
234-let $t079658194 = poolConfigParsed
209+let $t069097095 = poolConfigParsed
235210
236-let cfgPoolAddress = $t079658194._1
211+let cfgPoolAddress = $t069097095._1
237212
238-let cfgPoolStatus = $t079658194._2
213+let cfgPoolStatus = $t069097095._2
239214
240-let cfgLpAssetId = $t079658194._3
215+let cfgLpAssetId = $t069097095._3
241216
242-let cfgAmountAssetId = $t079658194._4
217+let cfgAmountAssetId = $t069097095._4
243218
244-let cfgPriceAssetId = $t079658194._5
219+let cfgPriceAssetId = $t069097095._5
245220
246-let cfgAmountAssetDecimals = $t079658194._6
221+let cfgAmountAssetDecimals = $t069097095._6
247222
248-let cfgPriceAssetDecimals = $t079658194._7
249-
250-let cfgInAmountAssedId = $t079658194._8
251-
252-let cfgInPriceAssetId = $t079658194._9
223+let cfgPriceAssetDecimals = $t069097095._7
253224
254225 func gfc () = split(strf(fca, fcfg()), SEP)
255226
256227
257228 let factoryConfig = gfc()
258229
259230 let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address")
260231
261232 let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address")
262233
263234 let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address")
264235
265236 let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address")
266237
267238 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)
268239
269240
270241 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)
271242
272243
273244 func getAccBalance (assetId) = if ((assetId == "WAVES"))
274245 then wavesBalance(this).available
275246 else assetBalance(this, fromBase58String(assetId))
276247
277248
278249 func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18)
279-
280-
281-func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round)
282250
283251
284252 func vad (A1,A2,slippage) = {
285253 let diff = fraction((A1 - A2), scale8BigInt, A2)
286254 let pass = ((slippage - abs(diff)) > zeroBigInt)
287255 if (!(pass))
288256 then throw(("Big slpg: " + toString(diff)))
289257 else $Tuple2(pass, min([A1, A2]))
290258 }
291259
292260
293261 func vd (D1,D0,slpg) = {
294262 let diff = fraction(D0, scale8BigInt, D1)
295263 let fail = (slpg > diff)
296264 if (if (fail)
297265 then true
298266 else (D0 > D1))
299267 then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg)))
300268 else fail
301269 }
302270
303271
304272 func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = {
305273 let amtAsAmtX18 = t1(amAmt, amAssetDcm)
306274 let prAsAmtX18 = t1(prAmt, prAssetDcm)
307275 cpbi(prAsAmtX18, amtAsAmtX18)
308276 }
309277
310278
311279 func calcPrices (amAmt,prAmt,lpAmt) = {
312- let amtAsDcm = cfgAmountAssetDecimals
313- let prAsDcm = cfgPriceAssetDecimals
280+ let cfg = gpc()
281+ let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
282+ let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
314283 let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt)
315284 let amAmtX18 = t1(amAmt, amtAsDcm)
316285 let prAmtX18 = t1(prAmt, prAsDcm)
317286 let lpAmtX18 = t1(lpAmt, scale8)
318287 let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18)
319288 let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18)
320289 [priceX18, lpPrInAmAsX18, lpPrInPrAsX18]
321290 }
322291
323292
324293 func calculatePrices (amAmt,prAmt,lpAmt) = {
325294 let p = calcPrices(amAmt, prAmt, lpAmt)
326295 [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)]
327296 }
328297
329298
330299 func takeFee (amount,fee) = {
331300 let feeAmount = if ((fee == 0))
332301 then 0
333302 else fraction(amount, fee, scale8)
334303 $Tuple2((amount - feeAmount), feeAmount)
335304 }
336305
337306
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, 15, 16, 17]
373- let $t01270312751 = {
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 18")
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($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)
386- }
387- let d = $t01270312751._1
388- let found = $t01270312751._2
389- if (found)
390- then d
391- else throw(("D calculation error, D = " + toString(d)))
392- }
393- }
394-
395-
396307 func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = {
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))
308+ let cfg = gpc()
309+ let lpId = cfg[idxLPAsId]
310+ let amId = cfg[idxAmAsId]
311+ let prId = cfg[idxPrAsId]
312+ let amDcm = parseIntValue(cfg[idxAmtAsDcm])
313+ let prDcm = parseIntValue(cfg[idxPriceAsDcm])
314+ let sts = cfg[idxPoolSt]
315+ let lpEmiss = valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "Wrong LP id").quantity
316+ if ((lpId != pmtAssetId))
405317 then throw("Wrong pmt asset")
406318 else {
407319 let amBalance = getAccBalance(amId)
408320 let amBalanceX18 = t1(amBalance, amDcm)
409321 let prBalance = getAccBalance(prId)
410322 let prBalanceX18 = t1(prBalance, prDcm)
411323 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
412324 let curPrice = f1(curPriceX18, scale8)
413325 let pmtLpAmtX18 = t1(pmtLpAmt, scale8)
414326 let lpEmissX18 = t1(lpEmiss, scale8)
415327 let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18)
416328 let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18)
417- let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR)
418- let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR)
329+ let outAmAmt = f1(outAmAmtX18, amDcm)
330+ let outPrAmt = f1(outPrAmtX18, prDcm)
419331 let state = if ((txId58 == ""))
420332 then nil
421333 else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES"))
422334 then unit
423335 else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES"))
424336 then unit
425337 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)]
426338 $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state)
427339 }
428340 }
429341
430342
431343 func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
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)
344+ let cfg = gpc()
345+ let lpId = fromBase58String(cfg[idxLPAsId])
346+ let amIdStr = cfg[idxAmAsId]
347+ let prIdStr = cfg[idxPrAsId]
348+ let inAmIdStr = cfg[idxIAmtAsId]
349+ let inPrIdStr = cfg[idxIPriceAsId]
350+ let amtDcm = parseIntValue(cfg[idxAmtAsDcm])
351+ let priceDcm = parseIntValue(cfg[idxPriceAsDcm])
352+ let sts = cfg[idxPoolSt]
440353 let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity
441354 let amBalance = if (isEval)
442355 then getAccBalance(amIdStr)
443356 else if (if (isOneAsset)
444357 then (pmtId == amIdStr)
445358 else false)
446359 then (getAccBalance(amIdStr) - pmtAmt)
447360 else if (isOneAsset)
448361 then getAccBalance(amIdStr)
449362 else (getAccBalance(amIdStr) - inAmAmt)
450363 let prBalance = if (isEval)
451364 then getAccBalance(prIdStr)
452365 else if (if (isOneAsset)
453366 then (pmtId == prIdStr)
454367 else false)
455368 then (getAccBalance(prIdStr) - pmtAmt)
456369 else if (isOneAsset)
457370 then getAccBalance(prIdStr)
458371 else (getAccBalance(prIdStr) - inPrAmt)
459372 let inAmAssetAmtX18 = t1(inAmAmt, amtDcm)
460373 let inPrAssetAmtX18 = t1(inPrAmt, priceDcm)
461374 let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18)
462375 let amBalanceX18 = t1(amBalance, amtDcm)
463376 let prBalanceX18 = t1(prBalance, priceDcm)
464- let D0 = getD([amBalanceX18, prBalanceX18])
465377 let r = if ((lpEm == 0))
466378 then {
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.")
379+ let curPriceX18 = zeroBigInt
380+ let slippageX18 = zeroBigInt
381+ let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN)
382+ $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18)
479383 }
480384 else {
481385 let curPriceX18 = cpbi(prBalanceX18, amBalanceX18)
482386 let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18)
483387 let slippageX18 = t1(slippage, scale8)
484388 if (if (if (validateSlippage)
485389 then (curPriceX18 != zeroBigInt)
486390 else false)
487391 then (slippageRealX18 > slippageX18)
488392 else false)
489393 then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18)))
490394 else {
491395 let lpEmissionX18 = t1(lpEm, scale8)
492- let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING)
493- let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING)
396+ let prViaAmX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18)
397+ let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18)
494398 let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18))
495399 then $Tuple2(amViaPrX18, inPrAssetAmtX18)
496400 else $Tuple2(inAmAssetAmtX18, prViaAmX18)
497401 let expAmtAssetAmtX18 = expectedAmts._1
498402 let expPriceAssetAmtX18 = expectedAmts._2
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.")
403+ let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18)
404+ $Tuple5(f1(lpAmtX18, scale8), f1(expAmtAssetAmtX18, amtDcm), f1(expPriceAssetAmtX18, priceDcm), curPriceX18, slippageX18)
509405 }
510406 }
511407 let calcLpAmt = r._1
512408 let calcAmAssetPmt = r._2
513409 let calcPrAssetPmt = r._3
514410 let curPrice = f1(r._4, scale8)
515411 let slippageCalc = f1(r._5, scale8)
516412 if ((0 >= calcLpAmt))
517413 then throw("LP <= 0")
518414 else {
519415 let emitLpAmt = if (!(emitLp))
520416 then 0
521417 else calcLpAmt
522418 let amDiff = (inAmAmt - calcAmAssetPmt)
523419 let prDiff = (inPrAmt - calcPrAssetPmt)
524- let $t02059020935 = if (if (isOneAsset)
420+ let $t01756217907 = if (if (isOneAsset)
525421 then (pmtId == amIdStr)
526422 else false)
527423 then $Tuple2(pmtAmt, 0)
528424 else if (if (isOneAsset)
529425 then (pmtId == prIdStr)
530426 else false)
531427 then $Tuple2(0, pmtAmt)
532428 else $Tuple2(calcAmAssetPmt, calcPrAssetPmt)
533- let writeAmAmt = $t02059020935._1
534- let writePrAmt = $t02059020935._2
429+ let writeAmAmt = $t01756217907._1
430+ let writePrAmt = $t01756217907._2
535431 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))]
536432 $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId)
537433 }
538434 }
539435
540436
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 $t02213022150 = acc
554- let y = $t02213022150._1
555- let found = $t02213022150._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 $t02245722504 = {
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 = $t02245722504._1
583- let found = $t02245722504._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 $t02470224914 = if ((order.orderType == Buy))
628- then $Tuple2(amountAssetAmount, -(priceAssetAmount))
629- else $Tuple2(-(amountAssetAmount), priceAssetAmount)
630- let amountAssetBalanceDelta = $t02470224914._1
631- let priceAssetBalanceDelta = $t02470224914._2
437+func moa (order) = {
438+ let cfg = gpc()
439+ let amtAsId = cfg[idxAmAsId]
440+ let prAsId = cfg[idxPrAsId]
441+ let sts = parseIntValue(cfg[idxPoolSt])
442+ let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm])
443+ let prAsDcm = parseIntValue(cfg[idxPriceAsDcm])
444+ let accAmtAsBalance = getAccBalance(amtAsId)
445+ let accPrAsBalance = getAccBalance(prAsId)
446+ let curPriceX18 = if ((order.orderType == Buy))
447+ then pcp(amtAsDcm, prAsDcm, (accAmtAsBalance + order.amount), accPrAsBalance)
448+ else pcp(amtAsDcm, prAsDcm, (accAmtAsBalance - order.amount), accPrAsBalance)
449+ let curPrice = f1(curPriceX18, scale8)
632450 if (if (if (igs())
633451 then true
634- else (cfgPoolStatus == PoolMatcherDis))
452+ else (sts == PoolMatcherDis))
635453 then true
636- else (cfgPoolStatus == PoolShutdown))
454+ else (sts == PoolShutdown))
637455 then throw("Admin blocked")
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 $t02525625356 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
645- let unusedActions = $t02525625356._1
646- let dLpNew = $t02525625356._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- }
456+ else {
457+ let orAmtAsset = order.assetPair.amountAsset
458+ let orAmtAsStr = if ((orAmtAsset == unit))
459+ then "WAVES"
460+ else toBase58String(value(orAmtAsset))
461+ let orPrAsset = order.assetPair.priceAsset
462+ let orPrAsStr = if ((orPrAsset == unit))
463+ then "WAVES"
464+ else toBase58String(value(orPrAsset))
465+ if (if ((orAmtAsStr != amtAsId))
466+ then true
467+ else (orPrAsStr != prAsId))
468+ then throw("Wr assets")
469+ else {
470+ let orderPrice = order.price
471+ let priceDcm = fraction(scale8, prAsDcm, amtAsDcm)
472+ let castOrderPrice = ts(orderPrice, scale8, priceDcm)
473+ let isOrderPriceValid = if ((order.orderType == Buy))
474+ then (curPrice >= castOrderPrice)
475+ else (castOrderPrice >= curPrice)
476+ true
477+ }
478+ }
651479 }
652480
653481
654482 func cg (i) = if ((size(i.payments) != 1))
655483 then throw("1 pmnt exp")
656484 else {
657485 let pmt = value(i.payments[0])
658486 let pmtAssetId = value(pmt.assetId)
659487 let pmtAmt = pmt.amount
660488 let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller)
661489 let outAmAmt = r._1
662490 let outPrAmt = r._2
663491 let sts = parseIntValue(r._9)
664492 let state = r._10
665493 if (if (igs())
666494 then true
667495 else (sts == PoolShutdown))
668496 then throw(("Admin blocked: " + toString(sts)))
669497 else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state)
670498 }
671499
672500
673501 func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = {
674502 let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId)
675503 let sts = parseIntValue(r._8)
676504 if (if (if (igs())
677505 then true
678506 else (sts == PoolPutDis))
679507 then true
680508 else (sts == PoolShutdown))
681509 then throw(("Blocked:" + toString(sts)))
682510 else r
683511 }
684512
685513
514+func getD (xp) = {
515+ let n = big2
516+ let xp0 = xp[0]
517+ let xp1 = xp[1]
518+ let aPrecision = parseBigIntValue(Amult)
519+ let a = (parseBigIntValue(A) * aPrecision)
520+ let s = (xp0 + xp1)
521+ if ((s == big0))
522+ then big0
523+ else {
524+ let ann = (a * n)
525+ let xp0_xp1_n_n = (((xp0 * xp1) * n) * n)
526+ let ann_s_aPrecision = ((ann * s) / aPrecision)
527+ let ann_aPrecision = (ann - aPrecision)
528+ let n1 = (n + big1)
529+ func calc (acc,cur) = {
530+ let $t02245922479 = acc
531+ let d = $t02245922479._1
532+ let found = $t02245922479._2
533+ if ((found != unit))
534+ then acc
535+ else {
536+ let dp = (((d * d) * d) / xp0_xp1_n_n)
537+ let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp)))
538+ let dDiff = absBigInt((dNext - value(d)))
539+ if ((big1 >= dDiff))
540+ then $Tuple2(dNext, cur)
541+ else $Tuple2(dNext, unit)
542+ }
543+ }
544+
545+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
546+ let $t02290022947 = {
547+ let $l = arr
548+ let $s = size($l)
549+ let $acc0 = $Tuple2(s, unit)
550+ func $f0_1 ($a,$i) = if (($i >= $s))
551+ then $a
552+ else calc($a, $l[$i])
553+
554+ func $f0_2 ($a,$i) = if (($i >= $s))
555+ then $a
556+ else throw("List size exceeds 15")
557+
558+ $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)
559+ }
560+ let d = $t02290022947._1
561+ let found = $t02290022947._2
562+ if ((found != unit))
563+ then d
564+ else throw(("D calculation error, D = " + toString(d)))
565+ }
566+ }
567+
568+
569+func getYD (xp,i,D) = {
570+ let n = big2
571+ let x = xp[if ((i == 0))
572+ then 1
573+ else 0]
574+ let aPrecision = parseBigIntValue(Amult)
575+ let a = (parseBigIntValue(A) * aPrecision)
576+ let s = x
577+ let ann = (a * n)
578+ let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
579+ let b = ((s + ((D * aPrecision) / ann)) - D)
580+ func calc (acc,cur) = {
581+ let $t02344723467 = acc
582+ let y = $t02344723467._1
583+ let found = $t02344723467._2
584+ if ((found != unit))
585+ then acc
586+ else {
587+ let yNext = (((y * y) + c) / ((big2 * y) + b))
588+ let yDiff = absBigInt((yNext - value(y)))
589+ if ((big1 >= yDiff))
590+ then $Tuple2(yNext, cur)
591+ else $Tuple2(yNext, unit)
592+ }
593+ }
594+
595+ let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
596+ let $t02377423821 = {
597+ let $l = arr
598+ let $s = size($l)
599+ let $acc0 = $Tuple2(D, unit)
600+ func $f0_1 ($a,$i) = if (($i >= $s))
601+ then $a
602+ else calc($a, $l[$i])
603+
604+ func $f0_2 ($a,$i) = if (($i >= $s))
605+ then $a
606+ else throw("List size exceeds 15")
607+
608+ $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)
609+ }
610+ let y = $t02377423821._1
611+ let found = $t02377423821._2
612+ if ((found != unit))
613+ then y
614+ else throw(("Y calculation error, Y = " + toString(y)))
615+ }
616+
617+
686618 func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = {
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)
619+ let poolConfig = gpc()
620+ let amId = poolConfig[idxAmAsId]
621+ let prId = poolConfig[idxPrAsId]
622+ let lpId = poolConfig[idxLPAsId]
623+ let amtDcm = parseIntValue(poolConfig[idxAmtAsDcm])
624+ let priceDcm = parseIntValue(poolConfig[idxPriceAsDcm])
625+ let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
693626 let chechEmission = if ((lpAssetEmission > big0))
694627 then true
695628 else throw("initial deposit requires all coins")
696629 if ((chechEmission == chechEmission))
697630 then {
698631 let amBalance = getAccBalance(amId)
699632 let prBalance = getAccBalance(prId)
700- let $t02801228474 = if ((txId == ""))
633+ let $t02460425066 = if ((txId == ""))
701634 then $Tuple2(amBalance, prBalance)
702635 else if ((pmtAssetId == amId))
703636 then if ((pmtAmtRaw > amBalance))
704637 then throw("invalid payment amount")
705638 else $Tuple2((amBalance - pmtAmtRaw), prBalance)
706639 else if ((pmtAssetId == prId))
707640 then if ((pmtAmtRaw > prBalance))
708641 then throw("invalid payment amount")
709642 else $Tuple2(amBalance, (prBalance - pmtAmtRaw))
710643 else throw("wrong pmtAssetId")
711- let amBalanceOld = $t02801228474._1
712- let prBalanceOld = $t02801228474._2
713- let $t02848028656 = if ((pmtAssetId == amId))
644+ let amBalanceOld = $t02460425066._1
645+ let prBalanceOld = $t02460425066._2
646+ let $t02507225248 = if ((pmtAssetId == amId))
714647 then $Tuple2(pmtAmtRaw, 0)
715648 else if ((pmtAssetId == prId))
716649 then $Tuple2(0, pmtAmtRaw)
717650 else throw("invalid payment")
718- let amAmountRaw = $t02848028656._1
719- let prAmountRaw = $t02848028656._2
720- let $t02866028914 = if (withTakeFee)
651+ let amAmountRaw = $t02507225248._1
652+ let prAmountRaw = $t02507225248._2
653+ let $t02525225506 = if (withTakeFee)
721654 then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2)
722655 else $Tuple3(amAmountRaw, prAmountRaw, 0)
723- let amAmount = $t02866028914._1
724- let prAmount = $t02866028914._2
725- let feeAmount = $t02866028914._3
656+ let amAmount = $t02525225506._1
657+ let prAmount = $t02525225506._2
658+ let feeAmount = $t02525225506._3
726659 let amBalanceNew = (amBalanceOld + amAmount)
727660 let prBalanceNew = (prBalanceOld + prAmount)
728- let D0 = getD([t1(amBalanceOld, cfgAmountAssetDecimals), t1(prBalanceOld, cfgPriceAssetDecimals)])
729- let D1 = getD([t1(amBalanceNew, cfgAmountAssetDecimals), t1(prBalanceNew, cfgPriceAssetDecimals)])
661+ let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)])
662+ let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)])
730663 let checkD = if ((D1 > D0))
731664 then true
732665 else throw()
733666 if ((checkD == checkD))
734667 then {
735- let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR)
668+ let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0)
736669 let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8)
737670 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))]
738671 let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld)
739672 let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8))
740673 let priceAssetPart = (pmtAmtRaw - amountAssetPart)
741674 let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld))
742675 let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth))
743676 $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus)
744677 }
745678 else throw("Strict value is not equal to itself.")
746679 }
747680 else throw("Strict value is not equal to itself.")
748681 }
749682
750683
751684 func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = {
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
685+ let poolConfig = gpc()
686+ let lpId = poolConfig[idxLPAsId]
687+ let amId = poolConfig[idxAmAsId]
688+ let prId = poolConfig[idxPrAsId]
689+ let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
690+ let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
691+ let poolStatus = poolConfig[idxPoolSt]
758692 let userAddress = if ((caller == restContract))
759693 then originCaller
760694 else caller
761695 let pmt = value(payments[0])
762696 let pmtAssetId = value(pmt.assetId)
763697 let pmtAmt = pmt.amount
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 $t03102631137 = {
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 (($t03102631137 == $t03102631137))
698+ let txId58 = toBase58String(transactionId)
699+ if ((lpId != toBase58String(pmtAssetId)))
700+ then throw("Wrong LP")
701+ else {
702+ let amBalance = getAccBalance(amId)
703+ let prBalance = getAccBalance(prId)
704+ let $t02750827619 = {
705+ let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil)
706+ if ($isInstanceOf(@, "(Int, Int)"))
707+ then @
708+ else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
709+ }
710+ if (($t02750827619 == $t02750827619))
711+ then {
712+ let feeAmount = $t02750827619._2
713+ let totalGet = $t02750827619._1
714+ let totalAmount = if (if ((minOutAmount > 0))
715+ then (minOutAmount > totalGet)
716+ else false)
717+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
718+ else totalGet
719+ let $t02780928116 = if ((outAssetId == amId))
720+ then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance)
721+ else if ((outAssetId == prId))
722+ then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount))
723+ else throw("invalid out asset id")
724+ let outAm = $t02780928116._1
725+ let outPr = $t02780928116._2
726+ let amBalanceNew = $t02780928116._3
727+ let prBalanceNew = $t02780928116._4
728+ let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals))
729+ let curPr = f1(curPrX18, scale8)
730+ let outAssetIdOrWaves = if ((outAssetId == "WAVES"))
731+ then unit
732+ else fromBase58String(outAssetId)
733+ let sendFeeToMatcher = if ((feeAmount > 0))
734+ then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)]
735+ else nil
736+ 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)
737+ if ((state == state))
780738 then {
781- let feeAmount = $t03102631137._2
782- let totalGet = $t03102631137._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 $t03132731634 = 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 = $t03132731634._1
794- let outPr = $t03132731634._2
795- let amBalanceNew = $t03132731634._3
796- let prBalanceNew = $t03132731634._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 $t03241932769 = {
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 = $t03241932769._1
823- let priceAssetBalanceDelta = $t03241932769._2
824- let $t03277232880 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
825- let refreshDLpActions = $t03277232880._1
826- let updatedDLp = $t03277232880._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- }
739+ let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
740+ if ((burn == burn))
741+ then $Tuple2(state, totalAmount)
834742 else throw("Strict value is not equal to itself.")
835743 }
836744 else throw("Strict value is not equal to itself.")
837745 }
746+ else throw("Strict value is not equal to itself.")
838747 }
839- else throw("Strict value is not equal to itself.")
840748 }
841749
842750
843751 func m () = match getString(mpk()) {
844752 case s: String =>
845753 fromBase58String(s)
846754 case _: Unit =>
847755 unit
848756 case _ =>
849757 throw("Match error")
850758 }
851759
852760
853761 func pm () = match getString(pmpk()) {
854762 case s: String =>
855763 fromBase58String(s)
856764 case _: Unit =>
857765 unit
858766 case _ =>
859767 throw("Match error")
860768 }
861769
862770
863771 let pd = throw("Permission denied")
864772
865773 func isManager (i) = match m() {
866774 case pk: ByteVector =>
867775 (i.callerPublicKey == pk)
868776 case _: Unit =>
869777 (i.caller == this)
870778 case _ =>
871779 throw("Match error")
872780 }
873781
874782
875783 func mm (i) = match m() {
876784 case pk: ByteVector =>
877785 if ((i.callerPublicKey == pk))
878786 then true
879787 else pd
880788 case _: Unit =>
881789 if ((i.caller == this))
882790 then true
883791 else pd
884792 case _ =>
885793 throw("Match error")
886794 }
887-
888-
889-func getY (isReverse,D,poolAmountInBalance) = {
890- let poolConfig = gpc()
891- let amId = poolConfig[idxAmAsId]
892- let prId = poolConfig[idxPrAsId]
893- let n = big2
894- let aPrecision = parseBigIntValue(Amult)
895- let a = (parseBigIntValue(A) * aPrecision)
896- let xp = if ((isReverse == false))
897- then [(toBigInt(getAccBalance(amId)) + poolAmountInBalance), toBigInt(getAccBalance(prId))]
898- else [(toBigInt(getAccBalance(prId)) + poolAmountInBalance), toBigInt(getAccBalance(amId))]
899- let x = xp[0]
900- let s = x
901- let ann = (a * n)
902- let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n))
903- let b = ((s + ((D * aPrecision) / ann)) - D)
904- func calc (acc,cur) = {
905- let $t03432734347 = acc
906- let y = $t03432734347._1
907- let found = $t03432734347._2
908- if ((found != unit))
909- then acc
910- else {
911- let yNext = (((y * y) + c) / ((big2 * y) + b))
912- let yDiff = absBigInt((yNext - value(y)))
913- if ((big1 >= yDiff))
914- then $Tuple2(yNext, cur)
915- else $Tuple2(yNext, unit)
916- }
917- }
918-
919- let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
920- let $t03467834725 = {
921- let $l = arr
922- let $s = size($l)
923- let $acc0 = $Tuple2(D, unit)
924- func $f0_1 ($a,$i) = if (($i >= $s))
925- then $a
926- else calc($a, $l[$i])
927-
928- func $f0_2 ($a,$i) = if (($i >= $s))
929- then $a
930- else throw("List size exceeds 15")
931-
932- $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)
933- }
934- let y = $t03467834725._1
935- let found = $t03467834725._2
936- if ((found != unit))
937- then y
938- else throw(("Y calculation error, Y = " + toString(y)))
939- }
940-
941-
942-@Callable(i)
943-func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = {
944- let $t03496635390 = if ((isReverse == false))
945- then {
946- let assetOut = strf(this, pa())
947- let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, aa()))) + toBigInt(cleanAmountIn))
948- $Tuple2(assetOut, poolAmountInBalance)
949- }
950- else {
951- let assetOut = strf(this, aa())
952- let poolAmountInBalance = (toBigInt(getAccBalance(strf(this, pa()))) + toBigInt(cleanAmountIn))
953- $Tuple2(assetOut, poolAmountInBalance)
954- }
955- let assetOut = $t03496635390._1
956- let poolAmountInBalance = $t03496635390._2
957- let poolConfig = gpc()
958- let amId = poolConfig[idxAmAsId]
959- let prId = poolConfig[idxPrAsId]
960- let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
961- let D = getD(xp)
962- let y = getY(isReverse, D, toBigInt(cleanAmountIn))
963- let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
964- let totalGetRaw = max([0, toInt(dy)])
965- let newXp = if ((isReverse == false))
966- then [((toBigInt(getAccBalance(amId)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)), (toBigInt(getAccBalance(prId)) - dy)]
967- else [(toBigInt(getAccBalance(amId)) - dy), ((toBigInt(getAccBalance(prId)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount))]
968- let newD = getD(newXp)
969- let checkD = if ((newD >= D))
970- then true
971- else throw(makeString(["new D is fewer error", toString(D), toString(newD)], "__"))
972- if ((checkD == checkD))
973- then $Tuple2(nil, totalGetRaw)
974- else throw("Strict value is not equal to itself.")
975- }
976-
977-
978-
979-@Callable(i)
980-func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = {
981- let swapContact = {
982- let @ = invoke(fca, "getSwapContractREADONLY", nil, nil)
983- if ($isInstanceOf(@, "String"))
984- then @
985- else throw(($getType(@) + " couldn't be cast to String"))
986- }
987- let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn))
988- then true
989- else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact)))
990- then true
991- else throwErr("Permission denied")]
992- if ((checks == checks))
993- then {
994- let pmt = value(i.payments[0])
995- let assetIn = assetIdToString(pmt.assetId)
996- let $t03682637220 = if ((isReverse == false))
997- then {
998- let assetOut = strf(this, pa())
999- let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
1000- $Tuple2(assetOut, poolAmountInBalance)
1001- }
1002- else {
1003- let assetOut = strf(this, aa())
1004- let poolAmountInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount)
1005- $Tuple2(assetOut, poolAmountInBalance)
1006- }
1007- let assetOut = $t03682637220._1
1008- let poolAmountInBalance = $t03682637220._2
1009- let poolConfig = gpc()
1010- let amId = poolConfig[idxAmAsId]
1011- let prId = poolConfig[idxPrAsId]
1012- let xp = if ((isReverse == false))
1013- then [(toBigInt(getAccBalance(amId)) - toBigInt(value(i.payments[0]).amount)), toBigInt(getAccBalance(prId))]
1014- else [toBigInt(getAccBalance(amId)), (toBigInt(getAccBalance(prId)) - toBigInt(value(i.payments[0]).amount))]
1015- let D = getD(xp)
1016- let y = getY(isReverse, D, toBigInt(0))
1017- let dy = ((toBigInt(getAccBalance(assetOut)) - y) - toBigInt(1))
1018- let totalGetRaw = max([0, toInt(dy)])
1019- let checkMin = if ((totalGetRaw >= amountOutMin))
1020- then true
1021- else throw("Exchange result is fewer coins than expected")
1022- if ((checkMin == checkMin))
1023- then {
1024- let newXp = if ((isReverse == false))
1025- then [(toBigInt(getAccBalance(amId)) + toBigInt(feePoolAmount)), (toBigInt(getAccBalance(prId)) - dy)]
1026- else [(toBigInt(getAccBalance(amId)) - dy), (toBigInt(getAccBalance(prId)) + toBigInt(feePoolAmount))]
1027- let newD = getD(newXp)
1028- let checkD = if ((newD >= D))
1029- then true
1030- else throw("new D is fewer error")
1031- if ((checkD == checkD))
1032- then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), totalGetRaw, parseAssetId(assetOut))], totalGetRaw)
1033- else throw("Strict value is not equal to itself.")
1034- }
1035- else throw("Strict value is not equal to itself.")
1036- }
1037- else throw("Strict value is not equal to itself.")
1038- }
1039-
1040795
1041796
1042797 @Callable(i)
1043798 func constructor (fc) = {
1044799 let c = mm(i)
1045800 if ((c == c))
1046801 then [StringEntry(fc(), fc)]
1047802 else throw("Strict value is not equal to itself.")
1048803 }
1049804
1050805
1051806
1052807 @Callable(i)
1053808 func setManager (pendingManagerPublicKey) = {
1054809 let c = mm(i)
1055810 if ((c == c))
1056811 then {
1057812 let cm = fromBase58String(pendingManagerPublicKey)
1058813 if ((cm == cm))
1059814 then [StringEntry(pmpk(), pendingManagerPublicKey)]
1060815 else throw("Strict value is not equal to itself.")
1061816 }
1062817 else throw("Strict value is not equal to itself.")
1063818 }
1064819
1065820
1066821
1067822 @Callable(i)
1068823 func confirmManager () = {
1069824 let p = pm()
1070825 let hpm = if (isDefined(p))
1071826 then true
1072827 else throw("No pending manager")
1073828 if ((hpm == hpm))
1074829 then {
1075830 let cpm = if ((i.callerPublicKey == value(p)))
1076831 then true
1077832 else throw("You are not pending manager")
1078833 if ((cpm == cpm))
1079834 then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())]
1080835 else throw("Strict value is not equal to itself.")
1081836 }
1082837 else throw("Strict value is not equal to itself.")
1083838 }
1084839
1085840
1086841
1087842 @Callable(i)
1088843 func put (slip,autoStake) = {
1089844 let factCfg = gfc()
1090845 let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr")
1091846 let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr")
1092847 if ((0 > slip))
1093848 then throw("Wrong slippage")
1094849 else if ((size(i.payments) != 2))
1095850 then throw("2 pmnts expd")
1096851 else {
1097- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1098- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1099- let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt)
1100- if ((amountAssetBalance == amountAssetBalance))
852+ 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, "")
853+ let emitLpAmt = e._2
854+ let lpAssetId = e._7
855+ let state = e._9
856+ let amDiff = e._10
857+ let prDiff = e._11
858+ let amId = e._12
859+ let prId = e._13
860+ let r = invoke(fca, "emit", [emitLpAmt], nil)
861+ if ((r == r))
1101862 then {
1102- let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt)
1103- if ((priceAssetBalance == priceAssetBalance))
863+ let el = match r {
864+ case legacy: Address =>
865+ invoke(legacy, "emit", [emitLpAmt], nil)
866+ case _ =>
867+ unit
868+ }
869+ if ((el == el))
1104870 then {
1105- let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity)
1106- if ((lpAssetEmission == lpAssetEmission))
871+ let sa = if ((amDiff > 0))
872+ then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
873+ else nil
874+ if ((sa == sa))
1107875 then {
1108- let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1109- if ((currentDLp == currentDLp))
876+ let sp = if ((prDiff > 0))
877+ then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
878+ else nil
879+ if ((sp == sp))
1110880 then {
1111- 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, "")
1112- let emitLpAmt = e._2
1113- let lpAssetId = e._7
1114- let state = e._9
1115- let amDiff = e._10
1116- let prDiff = e._11
1117- let amId = e._12
1118- let prId = e._13
1119- let r = invoke(fca, "emit", [emitLpAmt], nil)
1120- if ((r == r))
881+ let lpTrnsfr = if (autoStake)
1121882 then {
1122- let el = match r {
1123- case legacy: Address =>
1124- invoke(legacy, "emit", [emitLpAmt], nil)
1125- case _ =>
1126- unit
1127- }
1128- if ((el == el))
1129- then {
1130- let sa = if ((amDiff > 0))
1131- then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)])
1132- else nil
1133- if ((sa == sa))
1134- then {
1135- let sp = if ((prDiff > 0))
1136- then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)])
1137- else nil
1138- if ((sp == sp))
1139- then {
1140- let lpTrnsfr = if (autoStake)
1141- then {
1142- let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
1143- if ((ss == ss))
1144- then nil
1145- else throw("Strict value is not equal to itself.")
1146- }
1147- else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
1148- let $t04183941981 = refreshDLpInternal(0, 0, 0)
1149- let refreshDLpActions = $t04183941981._1
1150- let updatedDLp = $t04183941981._2
1151- let check = if ((updatedDLp >= currentDLp))
1152- then true
1153- else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " "))
1154- if ((check == check))
1155- then {
1156- let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity
1157- if ((lpAssetEmissionAfter == lpAssetEmissionAfter))
1158- then ((state ++ lpTrnsfr) ++ refreshDLpActions)
1159- else throw("Strict value is not equal to itself.")
1160- }
1161- else throw("Strict value is not equal to itself.")
1162- }
1163- else throw("Strict value is not equal to itself.")
1164- }
1165- else throw("Strict value is not equal to itself.")
1166- }
883+ let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)])
884+ if ((ss == ss))
885+ then nil
1167886 else throw("Strict value is not equal to itself.")
1168887 }
1169- else throw("Strict value is not equal to itself.")
888+ else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)]
889+ (state ++ lpTrnsfr)
1170890 }
1171891 else throw("Strict value is not equal to itself.")
1172892 }
1173893 else throw("Strict value is not equal to itself.")
1174894 }
1175895 else throw("Strict value is not equal to itself.")
1176896 }
1177897 else throw("Strict value is not equal to itself.")
1178898 }
1179899 }
1180900
1181901
1182902
1183903 @Callable(i)
1184904 func putOneTknV2 (minOutAmount,autoStake) = {
1185905 let isPoolOneTokenOperationsDisabled = {
1186906 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
1187907 if ($isInstanceOf(@, "Boolean"))
1188908 then @
1189909 else throw(($getType(@) + " couldn't be cast to Boolean"))
1190910 }
1191911 let isPutDisabled = if (if (if (igs())
1192912 then true
1193913 else (cfgPoolStatus == PoolPutDis))
1194914 then true
1195915 else (cfgPoolStatus == PoolShutdown))
1196916 then true
1197917 else isPoolOneTokenOperationsDisabled
1198918 let checks = [if (if (!(isPutDisabled))
1199919 then true
1200920 else isManager(i))
1201921 then true
1202922 else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1))
1203923 then true
1204924 else throwErr("exactly 1 payment are expected")]
1205925 if ((checks == checks))
1206926 then {
1207- let amId = toBase58String(value(cfgAmountAssetId))
1208- let prId = toBase58String(value(cfgPriceAssetId))
1209- let lpId = cfgLpAssetId
1210- let amDecimals = cfgAmountAssetDecimals
1211- let prDecimals = cfgPriceAssetDecimals
927+ let poolConfig = gpc()
928+ let amId = poolConfig[idxAmAsId]
929+ let prId = poolConfig[idxPrAsId]
930+ let lpId = fromBase58String(poolConfig[idxLPAsId])
931+ let amDecimals = parseIntValue(poolConfig[idxAmtAsDcm])
932+ let prDecimals = parseIntValue(poolConfig[idxPriceAsDcm])
1212933 let userAddress = if ((i.caller == this))
1213934 then i.originCaller
1214935 else i.caller
1215936 let pmt = value(i.payments[0])
1216937 let pmtAssetId = toBase58String(value(pmt.assetId))
1217938 let pmtAmt = pmt.amount
1218- let currentDLp = if ((pmt.assetId == cfgAmountAssetId))
1219- then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0))
1220- else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0))
1221- if ((currentDLp == currentDLp))
939+ let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
940+ if (($t03347833636 == $t03347833636))
1222941 then {
1223- let $t04362243780 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true)
1224- if (($t04362243780 == $t04362243780))
942+ let feeAmount = $t03347833636._3
943+ let state = $t03347833636._2
944+ let estimLP = $t03347833636._1
945+ let emitLpAmt = if (if ((minOutAmount > 0))
946+ then (minOutAmount > estimLP)
947+ else false)
948+ then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
949+ else estimLP
950+ let e = invoke(fca, "emit", [emitLpAmt], nil)
951+ if ((e == e))
1225952 then {
1226- let feeAmount = $t04362243780._3
1227- let state = $t04362243780._2
1228- let estimLP = $t04362243780._1
1229- let emitLpAmt = if (if ((minOutAmount > 0))
1230- then (minOutAmount > estimLP)
1231- else false)
1232- then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], ""))
1233- else estimLP
1234- let e = invoke(fca, "emit", [emitLpAmt], nil)
1235- if ((e == e))
953+ let el = match e {
954+ case legacy: Address =>
955+ invoke(legacy, "emit", [emitLpAmt], nil)
956+ case _ =>
957+ unit
958+ }
959+ if ((el == el))
1236960 then {
1237- let el = match e {
1238- case legacy: Address =>
1239- invoke(legacy, "emit", [emitLpAmt], nil)
1240- case _ =>
1241- unit
1242- }
1243- if ((el == el))
961+ let lpTrnsfr = if (autoStake)
1244962 then {
1245- let lpTrnsfr = if (autoStake)
1246- then {
1247- let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
1248- if ((ss == ss))
1249- then nil
1250- else throw("Strict value is not equal to itself.")
1251- }
1252- else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
1253- let sendFeeToMatcher = if ((feeAmount > 0))
1254- then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
1255- else nil
1256- let $t04459544944 = if ((this == feeCollectorAddress))
1257- then $Tuple2(0, 0)
1258- else {
1259- let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId))
1260- then true
1261- else false
1262- if (paymentInAmountAsset)
1263- then $Tuple2(-(feeAmount), 0)
1264- else $Tuple2(0, -(feeAmount))
1265- }
1266- let amountAssetBalanceDelta = $t04459544944._1
1267- let priceAssetBalanceDelta = $t04459544944._2
1268- let $t04494745055 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0)
1269- let refreshDLpActions = $t04494745055._1
1270- let updatedDLp = $t04494745055._2
1271- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1272- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1273- then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt)
963+ let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)])
964+ if ((ss == ss))
965+ then nil
1274966 else throw("Strict value is not equal to itself.")
1275967 }
1276- else throw("Strict value is not equal to itself.")
968+ else [ScriptTransfer(i.caller, emitLpAmt, lpId)]
969+ let sendFeeToMatcher = if ((feeAmount > 0))
970+ then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))]
971+ else nil
972+ $Tuple2(((state ++ lpTrnsfr) ++ sendFeeToMatcher), emitLpAmt)
1277973 }
1278974 else throw("Strict value is not equal to itself.")
1279975 }
1280976 else throw("Strict value is not equal to itself.")
1281977 }
1282978 else throw("Strict value is not equal to itself.")
1283979 }
1284980 else throw("Strict value is not equal to itself.")
1285981 }
1286982
1287983
1288984
1289985 @Callable(i)
1290986 func putForFree (maxSlpg) = if ((0 > maxSlpg))
1291987 then throw("Wrong slpg")
1292988 else if ((size(i.payments) != 2))
1293989 then throw("2 pmnts expd")
1294990 else {
1295991 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, "")
1296- let state = estPut._9
1297- let amAssetPmt = toBigInt(value(i.payments[0]).amount)
1298- let prAssetPmt = toBigInt(value(i.payments[1]).amount)
1299- let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0))
1300- if ((currentDLp == currentDLp))
1301- then {
1302- let $t04608546150 = refreshDLpInternal(0, 0, 0)
1303- let refreshDLpActions = $t04608546150._1
1304- let updatedDLp = $t04608546150._2
1305- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1306- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1307- then (state ++ refreshDLpActions)
1308- else throw("Strict value is not equal to itself.")
1309- }
1310- else throw("Strict value is not equal to itself.")
992+ estPut._9
1311993 }
1312994
1313995
1314996
1315997 @Callable(i)
1316998 func get () = {
1317- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1318- if ((currentDLp == currentDLp))
1319- then {
1320- let r = cg(i)
1321- let outAmtAmt = r._1
1322- let outPrAmt = r._2
1323- let pmtAmt = r._3
1324- let pmtAssetId = r._4
1325- let state = r._5
1326- let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1327- if ((b == b))
1328- then {
1329- let $t04732347405 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0)
1330- let refreshDLpActions = $t04732347405._1
1331- let updatedDLp = $t04732347405._2
1332- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1333- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1334- then (state ++ refreshDLpActions)
1335- else throw("Strict value is not equal to itself.")
1336- }
1337- else throw("Strict value is not equal to itself.")
1338- }
999+ let r = cg(i)
1000+ let outAmtAmt = r._1
1001+ let outPrAmt = r._2
1002+ let pmtAmt = r._3
1003+ let pmtAssetId = r._4
1004+ let state = r._5
1005+ let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1006+ if ((b == b))
1007+ then state
13391008 else throw("Strict value is not equal to itself.")
13401009 }
13411010
13421011
13431012
13441013 @Callable(i)
13451014 func getOneTknV2 (outAssetId,minOutAmount) = {
13461015 let isPoolOneTokenOperationsDisabled = {
13471016 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
13481017 if ($isInstanceOf(@, "Boolean"))
13491018 then @
13501019 else throw(($getType(@) + " couldn't be cast to Boolean"))
13511020 }
13521021 let isGetDisabled = if (if (igs())
13531022 then true
13541023 else (cfgPoolStatus == PoolShutdown))
13551024 then true
13561025 else isPoolOneTokenOperationsDisabled
13571026 let checks = [if (if (!(isGetDisabled))
13581027 then true
13591028 else isManager(i))
13601029 then true
13611030 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1))
13621031 then true
13631032 else throwErr("exactly 1 payment are expected")]
13641033 if ((checks == checks))
13651034 then {
1366- let $t04802348178 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1367- let state = $t04802348178._1
1368- let totalAmount = $t04802348178._2
1035+ let $t03625836413 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId)
1036+ let state = $t03625836413._1
1037+ let totalAmount = $t03625836413._2
13691038 $Tuple2(state, totalAmount)
13701039 }
13711040 else throw("Strict value is not equal to itself.")
13721041 }
13731042
13741043
13751044
13761045 @Callable(i)
1377-func refreshDLp () = {
1378- let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0)
1379- let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay))
1380- then unit
1381- else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], ""))
1382- if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight))
1383- then {
1384- let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp"))
1385- let $t04870248766 = refreshDLpInternal(0, 0, 0)
1386- let dLpUpdateActions = $t04870248766._1
1387- let updatedDLp = $t04870248766._2
1388- let actions = if ((dLp != updatedDLp))
1389- then dLpUpdateActions
1390- else throwErr("nothing to refresh")
1391- $Tuple2(actions, toString(updatedDLp))
1392- }
1393- else throw("Strict value is not equal to itself.")
1394- }
1395-
1396-
1397-
1398-@Callable(i)
13991046 func getOneTknV2READONLY (outAssetId,lpAssetAmount) = {
1400- let amId = toBase58String(value(cfgAmountAssetId))
1401- let prId = toBase58String(value(cfgPriceAssetId))
1402- let lpId = toBase58String(value(cfgLpAssetId))
1047+ let poolConfig = gpc()
1048+ let amId = poolConfig[idxAmAsId]
1049+ let prId = poolConfig[idxPrAsId]
1050+ let lpId = poolConfig[idxLPAsId]
14031051 let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))]
14041052 let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity)
14051053 let D0 = getD(xp)
14061054 let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission))
14071055 let index = if ((outAssetId == amId))
14081056 then 0
14091057 else if ((outAssetId == prId))
14101058 then 1
14111059 else throw("invalid out asset id")
14121060 let newY = getYD(xp, index, D1)
14131061 let dy = (xp[index] - newY)
14141062 let totalGetRaw = max([0, toInt((dy - big1))])
1415- let $t04977649831 = takeFee(totalGetRaw, outFee)
1416- let totalGet = $t04977649831._1
1417- let feeAmount = $t04977649831._2
1063+ let $t03720337258 = takeFee(totalGetRaw, outFee)
1064+ let totalGet = $t03720337258._1
1065+ let feeAmount = $t03720337258._2
14181066 $Tuple2(nil, $Tuple2(totalGet, feeAmount))
14191067 }
14201068
14211069
14221070
14231071 @Callable(i)
14241072 func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = {
1425- let amId = toBase58String(value(cfgAmountAssetId))
1426- let prId = toBase58String(value(cfgPriceAssetId))
1427- let lpId = toBase58String(value(cfgLpAssetId))
1073+ let poolConfig = gpc()
1074+ let amId = poolConfig[idxAmAsId]
1075+ let prId = poolConfig[idxPrAsId]
1076+ let lpId = poolConfig[idxLPAsId]
14281077 let amBalance = getAccBalance(amId)
14291078 let prBalance = getAccBalance(prId)
1430- let $t05020650321 = {
1079+ let $t03760337718 = {
14311080 let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil)
14321081 if ($isInstanceOf(@, "(Int, Int)"))
14331082 then @
14341083 else throw(($getType(@) + " couldn't be cast to (Int, Int)"))
14351084 }
1436- let totalGet = $t05020650321._1
1437- let feeAmount = $t05020650321._2
1085+ let totalGet = $t03760337718._1
1086+ let feeAmount = $t03760337718._2
14381087 let r = ego("", lpId, lpAssetAmount, this)
14391088 let outAmAmt = r._1
14401089 let outPrAmt = r._2
14411090 let sumOfGetAssets = (outAmAmt + outPrAmt)
14421091 let bonus = if ((sumOfGetAssets == 0))
14431092 then if ((totalGet == 0))
14441093 then 0
14451094 else throw("bonus calculation error")
14461095 else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets)
14471096 $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus))
14481097 }
14491098
14501099
14511100
14521101 @Callable(i)
14531102 func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = {
14541103 let r = cg(i)
14551104 let outAmAmt = r._1
14561105 let outPrAmt = r._2
14571106 let pmtAmt = r._3
14581107 let pmtAssetId = r._4
14591108 let state = r._5
14601109 if ((noLessThenAmtAsset > outAmAmt))
14611110 then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset)))
14621111 else if ((noLessThenPriceAsset > outPrAmt))
14631112 then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset)))
14641113 else {
1465- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1466- if ((currentDLp == currentDLp))
1467- then {
1468- let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1469- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1470- then {
1471- let $t05148751568 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1472- let refreshDLpActions = $t05148751568._1
1473- let updatedDLp = $t05148751568._2
1474- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1475- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1476- then (state ++ refreshDLpActions)
1477- else throw("Strict value is not equal to itself.")
1478- }
1479- else throw("Strict value is not equal to itself.")
1480- }
1114+ let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)])
1115+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1116+ then state
14811117 else throw("Strict value is not equal to itself.")
14821118 }
14831119 }
14841120
14851121
14861122
14871123 @Callable(i)
14881124 func unstakeAndGet (amount) = {
14891125 let checkPayments = if ((size(i.payments) != 0))
14901126 then throw("No pmnts expd")
14911127 else true
14921128 if ((checkPayments == checkPayments))
14931129 then {
1130+ let cfg = gpc()
14941131 let factoryCfg = gfc()
1495- let lpAssetId = cfgLpAssetId
1132+ let lpAssetId = fromBase58String(cfg[idxLPAsId])
14961133 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1497- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1498- if ((currentDLp == currentDLp))
1134+ let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1135+ if ((unstakeInv == unstakeInv))
14991136 then {
1500- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil)
1501- if ((unstakeInv == unstakeInv))
1137+ let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1138+ let sts = parseIntValue(r._9)
1139+ let state = r._10
1140+ let v = if (if (igs())
1141+ then true
1142+ else (sts == PoolShutdown))
1143+ then throw(("Blocked: " + toString(sts)))
1144+ else true
1145+ if ((v == v))
15021146 then {
1503- let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller)
1504- let outAmAmt = r._1
1505- let outPrAmt = r._2
1506- let sts = parseIntValue(r._9)
1507- let state = r._10
1508- let v = if (if (igs())
1509- then true
1510- else (sts == PoolShutdown))
1511- then throw(("Blocked: " + toString(sts)))
1512- else true
1513- if ((v == v))
1514- then {
1515- let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1516- if ((burnA == burnA))
1517- then {
1518- let $t05259552676 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1519- let refreshDLpActions = $t05259552676._1
1520- let updatedDLp = $t05259552676._2
1521- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1522- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1523- then (state ++ refreshDLpActions)
1524- else throw("Strict value is not equal to itself.")
1525- }
1526- else throw("Strict value is not equal to itself.")
1527- }
1147+ let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)])
1148+ if ((burnA == burnA))
1149+ then state
15281150 else throw("Strict value is not equal to itself.")
15291151 }
15301152 else throw("Strict value is not equal to itself.")
15311153 }
15321154 else throw("Strict value is not equal to itself.")
15331155 }
15341156 else throw("Strict value is not equal to itself.")
15351157 }
15361158
15371159
15381160
15391161 @Callable(i)
15401162 func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = {
15411163 let isGetDisabled = if (igs())
15421164 then true
15431165 else (cfgPoolStatus == PoolShutdown)
15441166 let checks = [if (!(isGetDisabled))
15451167 then true
15461168 else throw("get operation is blocked by admin"), if ((size(i.payments) == 0))
15471169 then true
15481170 else throw("no payments are expected")]
15491171 if ((checks == checks))
15501172 then {
1551- let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0))
1552- if ((currentDLp == currentDLp))
1173+ let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1174+ if ((unstakeInv == unstakeInv))
15531175 then {
1554- let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil)
1555- if ((unstakeInv == unstakeInv))
1176+ let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1177+ let outAmAmt = res._1
1178+ let outPrAmt = res._2
1179+ let state = res._10
1180+ let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1181+ then true
1182+ else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1183+ then true
1184+ else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1185+ if ((checkAmounts == checkAmounts))
15561186 then {
1557- let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller)
1558- let outAmAmt = res._1
1559- let outPrAmt = res._2
1560- let state = res._10
1561- let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset))
1562- then true
1563- else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset))
1564- then true
1565- else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))]
1566- if ((checkAmounts == checkAmounts))
1567- then {
1568- let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1569- if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1570- then {
1571- let $t05392754008 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0)
1572- let refreshDLpActions = $t05392754008._1
1573- let updatedDLp = $t05392754008._2
1574- let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp)
1575- if ((isUpdatedDLpValid == isUpdatedDLpValid))
1576- then (state ++ refreshDLpActions)
1577- else throw("Strict value is not equal to itself.")
1578- }
1579- else throw("Strict value is not equal to itself.")
1580- }
1187+ let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)])
1188+ if ((burnLPAssetOnFactory == burnLPAssetOnFactory))
1189+ then state
15811190 else throw("Strict value is not equal to itself.")
15821191 }
15831192 else throw("Strict value is not equal to itself.")
15841193 }
15851194 else throw("Strict value is not equal to itself.")
15861195 }
15871196 else throw("Strict value is not equal to itself.")
15881197 }
15891198
15901199
15911200
15921201 @Callable(i)
15931202 func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = {
15941203 let isPoolOneTokenOperationsDisabled = {
15951204 let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil)
15961205 if ($isInstanceOf(@, "Boolean"))
15971206 then @
15981207 else throw(($getType(@) + " couldn't be cast to Boolean"))
15991208 }
16001209 let isGetDisabled = if (if (igs())
16011210 then true
16021211 else (cfgPoolStatus == PoolShutdown))
16031212 then true
16041213 else isPoolOneTokenOperationsDisabled
16051214 let checks = [if (if (!(isGetDisabled))
16061215 then true
16071216 else isManager(i))
16081217 then true
16091218 else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0))
16101219 then true
16111220 else throwErr("no payments are expected")]
16121221 if ((checks == checks))
16131222 then {
1223+ let cfg = gpc()
16141224 let factoryCfg = gfc()
1615- let lpAssetId = cfgLpAssetId
1225+ let lpAssetId = fromBase58String(cfg[idxLPAsId])
16161226 let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr")
1617- let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil)
1227+ let userAddress = i.caller
1228+ let lpAssetRecipientAddress = this
1229+ let unstakeInv = invoke(staking, "unstakeINTERNAL", [lpAssetId, unstakeAmount, userAddress.bytes, lpAssetRecipientAddress.bytes], nil)
16181230 if ((unstakeInv == unstakeInv))
16191231 then {
1620- let $t05490355091 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1621- let state = $t05490355091._1
1622- let totalAmount = $t05490355091._2
1232+ let $t04168341871 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId)
1233+ let state = $t04168341871._1
1234+ let totalAmount = $t04168341871._2
16231235 $Tuple2(state, totalAmount)
16241236 }
16251237 else throw("Strict value is not equal to itself.")
16261238 }
16271239 else throw("Strict value is not equal to itself.")
16281240 }
16291241
16301242
16311243
16321244 @Callable(i)
16331245 func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = {
1634- let $t05521955322 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1635- let lpAmount = $t05521955322._1
1636- let state = $t05521955322._2
1637- let feeAmount = $t05521955322._3
1638- let bonus = $t05521955322._4
1246+ let poolConfig = gpc()
1247+ let amId = poolConfig[idxAmAsId]
1248+ let prId = poolConfig[idxPrAsId]
1249+ let lpId = poolConfig[idxLPAsId]
1250+ let $t04213042233 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true)
1251+ let lpAmount = $t04213042233._1
1252+ let state = $t04213042233._2
1253+ let feeAmount = $t04213042233._3
1254+ let bonus = $t04213042233._4
16391255 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
16401256 }
16411257
16421258
16431259
16441260 @Callable(i)
16451261 func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = {
1646- let $t05547055574 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1647- let lpAmount = $t05547055574._1
1648- let state = $t05547055574._2
1649- let feeAmount = $t05547055574._3
1650- let bonus = $t05547055574._4
1262+ let poolConfig = gpc()
1263+ let amId = poolConfig[idxAmAsId]
1264+ let prId = poolConfig[idxPrAsId]
1265+ let lpId = poolConfig[idxLPAsId]
1266+ let $t04251242616 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false)
1267+ let lpAmount = $t04251242616._1
1268+ let state = $t04251242616._2
1269+ let feeAmount = $t04251242616._3
1270+ let bonus = $t04251242616._4
16511271 $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus))
16521272 }
16531273
16541274
16551275
16561276 @Callable(i)
16571277 func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca)))
16581278 then throw("denied")
16591279 else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success")
16601280
16611281
16621282
16631283 @Callable(i)
16641284 func setS (k,v) = if ((toString(i.caller) != strf(this, ada())))
16651285 then pd
16661286 else [StringEntry(k, v)]
16671287
16681288
16691289
16701290 @Callable(i)
16711291 func setI (k,v) = if ((toString(i.caller) != strf(this, ada())))
16721292 then pd
16731293 else [IntegerEntry(k, v)]
16741294
16751295
16761296
16771297 @Callable(i)
16781298 func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc())
16791299
16801300
16811301
16821302 @Callable(i)
16831303 func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId))
16841304
16851305
16861306
16871307 @Callable(i)
16881308 func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = {
16891309 let pr = calcPrices(amAmt, prAmt, lpAmt)
16901310 $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])])
16911311 }
16921312
16931313
16941314
16951315 @Callable(i)
16961316 func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult))
16971317
16981318
16991319
17001320 @Callable(i)
17011321 func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult)))
17021322
17031323
17041324
17051325 @Callable(i)
17061326 func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18))))
17071327
17081328
17091329
17101330 @Callable(i)
17111331 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, ""))
17121332
17131333
17141334
17151335 @Callable(i)
17161336 func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = {
17171337 let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr))
17181338 $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10))
17191339 }
17201340
17211341
17221342 @Verifier(tx)
17231343 func verify () = {
17241344 let targetPublicKey = match m() {
17251345 case pk: ByteVector =>
17261346 pk
17271347 case _: Unit =>
17281348 tx.senderPublicKey
17291349 case _ =>
17301350 throw("Match error")
17311351 }
17321352 match tx {
17331353 case order: Order =>
17341354 let matcherPub = mp()
1735- let $t05836658435 = validateMatcherOrderAllowed(order)
1736- let orderValid = $t05836658435._1
1737- let orderValidInfo = $t05836658435._2
1355+ let orderValid = moa(order)
17381356 let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey)
17391357 let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub)
17401358 if (if (if (orderValid)
17411359 then senderValid
17421360 else false)
17431361 then matcherValid
17441362 else false)
17451363 then true
1746- else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid)
1364+ else toe(orderValid, senderValid, matcherValid)
17471365 case s: SetScriptTransaction =>
1748- if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey))
1366+ let newHash = blake2b256(value(s.script))
1367+ let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1368+ let currentHash = scriptHash(this)
1369+ if (if ((allowedHash == newHash))
1370+ then (currentHash != newHash)
1371+ else false)
17491372 then true
1750- else {
1751- let newHash = blake2b256(value(s.script))
1752- let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash())))
1753- let currentHash = scriptHash(this)
1754- if ((allowedHash == newHash))
1755- then (currentHash != newHash)
1756- else false
1757- }
1373+ else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
17581374 case _ =>
17591375 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
17601376 }
17611377 }
17621378

github/deemru/w8io/026f985 
201.99 ms