tx · 6EEv2betnTcYJmKFzDKp8Y4KEdCWibVmC1vbANmpPHUv 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA: -0.03700000 Waves 2023.01.19 12:46 [2411646] smart account 3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA > SELF 0.00000000 Waves
{ "type": 13, "id": "6EEv2betnTcYJmKFzDKp8Y4KEdCWibVmC1vbANmpPHUv", "fee": 3700000, "feeAssetId": null, "timestamp": 1674121626440, "version": 1, "sender": "3MzKSdTH2jFbypLsoNfrH7QgkzSbx3EYwCA", "senderPublicKey": "35yd3qw1gxKDxKwGAykHN9fANbXNWwseaUwbWDj24o3x", "proofs": [ "3THcJHeowG9HareZngwYakL9gSN8Uk9fMf4abFSfoZ4YJg5kfpJLRmnEhZLNVXQimbKK1SvY46YxoHEFTp2cw488" ], "script": "base64:BgKwKQgCEgMKAQgSAwoBCBIAEgQKAgEEEgQKAgEEEgMKAQESABIECgIIARIAEgQKAggBEgQKAggBEgQKAgEBEgMKAQESBQoDAQEBEgUKAwEIARIECgIBCBIECgIBCBIECgIICBIECgIICBIECgIIARIAEgMKAQgSBQoDAQEBEgQKAggBEgQKAgEBEgQKAggIEgsKCQgBAQIBAggEBBIGCgQICAEIIgZzY2FsZTgiDHNjYWxlOEJpZ0ludCIHc2NhbGUxOCIKemVyb0JpZ0ludCIEYmlnMCIEYmlnMSIEYmlnMiIEYmlnMyIEYmlnNCIKc2xpcHBhZ2U0RCILd2F2ZXNTdHJpbmciBUFtdWx0IgVEY29udiIDU0VQIgVFTVBUWSIKUG9vbEFjdGl2ZSIKUG9vbFB1dERpcyIOUG9vbE1hdGNoZXJEaXMiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiCWlkeFBvb2xTdCIJaWR4TFBBc0lkIglpZHhBbUFzSWQiCWlkeFByQXNJZCILaWR4QW10QXNEY20iDWlkeFByaWNlQXNEY20iC2lkeElBbXRBc0lkIg1pZHhJUHJpY2VBc0lkIg9p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WEJAQIhPQIFAmljBQJpYQcGCQD0AwMIBQJoVAlib2R5Qnl0ZXMJAJEDAggFAmhUBnByb29mcwAABQJoVgkA9AMDCAUCaFQJYm9keUJ5dGVzCQCRAwIIBQJoVAZwcm9vZnMAAAUCaFZGJSnc", "chainId": 84, "height": 2411646, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G8os4y3tFkDVyQcyiMe3tmNQriSde5gfgqKGog2rNvQY Next: HtxBRBvzm6VyqrpLEecYPuvcLhEsKyshCF9itCAE5Taa Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | let big1 = toBigInt(1) | |
15 | 15 | ||
16 | 16 | let big2 = toBigInt(2) | |
17 | + | ||
18 | + | let big3 = toBigInt(3) | |
19 | + | ||
20 | + | let big4 = toBigInt(4) | |
17 | 21 | ||
18 | 22 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
19 | 23 | ||
69 | 73 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
70 | 74 | ||
71 | 75 | ||
76 | + | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
77 | + | ||
78 | + | ||
79 | + | func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult)) | |
80 | + | ||
81 | + | ||
82 | + | func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18) | |
83 | + | ||
84 | + | ||
72 | 85 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
73 | 86 | ||
74 | 87 | ||
115 | 128 | func ada () = "%s__addonAddr" | |
116 | 129 | ||
117 | 130 | ||
131 | + | let keyFee = "%s__fee" | |
132 | + | ||
133 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
134 | + | ||
135 | + | let keyDLp = makeString(["%s", "dLp"], SEP) | |
136 | + | ||
137 | + | let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP) | |
138 | + | ||
139 | + | let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP) | |
140 | + | ||
141 | + | let dLpRefreshDelayDefault = 1 | |
142 | + | ||
143 | + | let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault) | |
144 | + | ||
118 | 145 | func fcfg () = "%s__factoryConfig" | |
119 | 146 | ||
120 | 147 | ||
139 | 166 | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
140 | 167 | ||
141 | 168 | ||
142 | - | func str (val) = match val { | |
143 | - | case valStr: String => | |
144 | - | valStr | |
145 | - | case _ => | |
146 | - | throw("fail cast to String") | |
147 | - | } | |
148 | - | ||
149 | - | ||
150 | 169 | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
151 | 170 | ||
152 | 171 | ||
154 | 173 | ||
155 | 174 | ||
156 | 175 | func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " ")) | |
176 | + | ||
177 | + | ||
178 | + | func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ") | |
157 | 179 | ||
158 | 180 | ||
159 | 181 | let fca = addressFromStringValue(strf(this, fc())) | |
201 | 223 | else toBase58String(value(input)) | |
202 | 224 | ||
203 | 225 | ||
204 | - | func parsePoolConfig (poolConfig) = $ | |
226 | + | 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])) | |
205 | 227 | ||
206 | 228 | ||
207 | 229 | let poolConfigParsed = parsePoolConfig(gpc()) | |
208 | 230 | ||
209 | - | let $ | |
231 | + | let $t077427971 = poolConfigParsed | |
210 | 232 | ||
211 | - | let cfgPoolAddress = $ | |
233 | + | let cfgPoolAddress = $t077427971._1 | |
212 | 234 | ||
213 | - | let cfgPoolStatus = $ | |
235 | + | let cfgPoolStatus = $t077427971._2 | |
214 | 236 | ||
215 | - | let cfgLpAssetId = $ | |
237 | + | let cfgLpAssetId = $t077427971._3 | |
216 | 238 | ||
217 | - | let cfgAmountAssetId = $ | |
239 | + | let cfgAmountAssetId = $t077427971._4 | |
218 | 240 | ||
219 | - | let cfgPriceAssetId = $ | |
241 | + | let cfgPriceAssetId = $t077427971._5 | |
220 | 242 | ||
221 | - | let cfgAmountAssetDecimals = $ | |
243 | + | let cfgAmountAssetDecimals = $t077427971._6 | |
222 | 244 | ||
223 | - | let cfgPriceAssetDecimals = $t069097095._7 | |
245 | + | let cfgPriceAssetDecimals = $t077427971._7 | |
246 | + | ||
247 | + | let cfgInAmountAssedId = $t077427971._8 | |
248 | + | ||
249 | + | let cfgInPriceAssetId = $t077427971._9 | |
224 | 250 | ||
225 | 251 | func gfc () = split(strf(fca, fcfg()), SEP) | |
226 | 252 | ||
247 | 273 | ||
248 | 274 | ||
249 | 275 | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
276 | + | ||
277 | + | ||
278 | + | func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
250 | 279 | ||
251 | 280 | ||
252 | 281 | func vad (A1,A2,slippage) = { | |
277 | 306 | ||
278 | 307 | ||
279 | 308 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
280 | - | let cfg = gpc() | |
281 | - | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
282 | - | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
309 | + | let amtAsDcm = cfgAmountAssetDecimals | |
310 | + | let prAsDcm = cfgPriceAssetDecimals | |
283 | 311 | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
284 | 312 | let amAmtX18 = t1(amAmt, amtAsDcm) | |
285 | 313 | let prAmtX18 = t1(prAmt, prAsDcm) | |
305 | 333 | ||
306 | 334 | ||
307 | 335 | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
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)) | |
336 | + | let lpId = cfgLpAssetId | |
337 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
338 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
339 | + | let amDcm = cfgAmountAssetDecimals | |
340 | + | let prDcm = cfgPriceAssetDecimals | |
341 | + | let sts = toString(cfgPoolStatus) | |
342 | + | let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity | |
343 | + | if ((toBase58String(lpId) != pmtAssetId)) | |
317 | 344 | then throw("Wrong pmt asset") | |
318 | 345 | else { | |
319 | 346 | let amBalance = getAccBalance(amId) | |
326 | 353 | let lpEmissX18 = t1(lpEmiss, scale8) | |
327 | 354 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
328 | 355 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
329 | - | let outAmAmt = | |
330 | - | let outPrAmt = | |
356 | + | let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR) | |
357 | + | let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR) | |
331 | 358 | let state = if ((txId58 == "")) | |
332 | 359 | then nil | |
333 | 360 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
341 | 368 | ||
342 | 369 | ||
343 | 370 | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
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] | |
371 | + | let lpId = cfgLpAssetId | |
372 | + | let amIdStr = toBase58String(value(cfgAmountAssetId)) | |
373 | + | let prIdStr = toBase58String(value(cfgPriceAssetId)) | |
374 | + | let inAmIdStr = cfgInAmountAssedId | |
375 | + | let inPrIdStr = cfgInPriceAssetId | |
376 | + | let amtDcm = cfgAmountAssetDecimals | |
377 | + | let priceDcm = cfgPriceAssetDecimals | |
378 | + | let sts = toString(cfgPoolStatus) | |
353 | 379 | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
354 | 380 | let amBalance = if (isEval) | |
355 | 381 | then getAccBalance(amIdStr) | |
393 | 419 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
394 | 420 | else { | |
395 | 421 | let lpEmissionX18 = t1(lpEm, scale8) | |
396 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, | |
397 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, | |
422 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
423 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
398 | 424 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
399 | 425 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
400 | 426 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
401 | 427 | let expAmtAssetAmtX18 = expectedAmts._1 | |
402 | 428 | let expPriceAssetAmtX18 = expectedAmts._2 | |
403 | - | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
404 | - | $Tuple5( | |
429 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
430 | + | $Tuple5((fromX18Round(lpAmtX18, scale8, FLOOR) - 100), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18) | |
405 | 431 | } | |
406 | 432 | } | |
407 | 433 | let calcLpAmt = r._1 | |
417 | 443 | else calcLpAmt | |
418 | 444 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
419 | 445 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
420 | - | let $ | |
446 | + | let $t01862718972 = if (if (isOneAsset) | |
421 | 447 | then (pmtId == amIdStr) | |
422 | 448 | else false) | |
423 | 449 | then $Tuple2(pmtAmt, 0) | |
426 | 452 | else false) | |
427 | 453 | then $Tuple2(0, pmtAmt) | |
428 | 454 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
429 | - | let writeAmAmt = $ | |
430 | - | let writePrAmt = $ | |
455 | + | let writeAmAmt = $t01862718972._1 | |
456 | + | let writePrAmt = $t01862718972._2 | |
431 | 457 | 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))] | |
432 | 458 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
433 | 459 | } | |
434 | 460 | } | |
435 | 461 | ||
436 | 462 | ||
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) | |
463 | + | func getD (xp) = { | |
464 | + | let xp0 = xp[0] | |
465 | + | let xp1 = xp[1] | |
466 | + | let s = (xp0 + xp1) | |
467 | + | if ((s == big0)) | |
468 | + | then big0 | |
469 | + | else { | |
470 | + | let a = parseIntValue(A) | |
471 | + | let ann = (a * 2) | |
472 | + | let p = fraction(xp0, xp1, big1) | |
473 | + | let xp0_xp1_n_n = fraction(p, big4, big1) | |
474 | + | let ann_s = fraction(toBigInt(ann), s, big1) | |
475 | + | let ann_1 = toBigInt((ann - 1)) | |
476 | + | func calcDNext (d) = { | |
477 | + | let dd = fraction(d, d, big1) | |
478 | + | let ddd = fraction(dd, d, big1) | |
479 | + | let dp = fraction(ddd, big1, xp0_xp1_n_n) | |
480 | + | fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)), CEILING) | |
481 | + | } | |
482 | + | ||
483 | + | func calc (acc,i) = if (acc._2) | |
484 | + | then acc | |
485 | + | else { | |
486 | + | let d = acc._1 | |
487 | + | let dNext = calcDNext(d) | |
488 | + | let dDiffRaw = toInt((dNext - value(d))) | |
489 | + | let dDiff = if ((0 > dDiffRaw)) | |
490 | + | then -(dDiffRaw) | |
491 | + | else dDiffRaw | |
492 | + | if ((1 >= dDiff)) | |
493 | + | then $Tuple2(dNext, true) | |
494 | + | else $Tuple2(dNext, false) | |
495 | + | } | |
496 | + | ||
497 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
498 | + | let $t02090020948 = { | |
499 | + | let $l = arr | |
500 | + | let $s = size($l) | |
501 | + | let $acc0 = $Tuple2(s, false) | |
502 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
503 | + | then $a | |
504 | + | else calc($a, $l[$i]) | |
505 | + | ||
506 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
507 | + | then $a | |
508 | + | else throw("List size exceeds 15") | |
509 | + | ||
510 | + | $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) | |
511 | + | } | |
512 | + | let d = $t02090020948._1 | |
513 | + | let found = $t02090020948._2 | |
514 | + | if (found) | |
515 | + | then d | |
516 | + | else throw(("D calculation error, D = " + toString(d))) | |
517 | + | } | |
518 | + | } | |
519 | + | ||
520 | + | ||
521 | + | func getDOld (xp) = { | |
522 | + | let n = big2 | |
523 | + | let xp0 = xp[0] | |
524 | + | let xp1 = xp[1] | |
525 | + | let aPrecision = parseBigIntValue(Amult) | |
526 | + | let a = (parseBigIntValue(A) * aPrecision) | |
527 | + | let s = (xp0 + xp1) | |
528 | + | if ((s == big0)) | |
529 | + | then big0 | |
530 | + | else { | |
531 | + | let ann = (a * n) | |
532 | + | let xp0_xp1_n_n = (((xp0 * xp1) * n) * n) | |
533 | + | let ann_s_aPrecision = ((ann * s) / aPrecision) | |
534 | + | let ann_aPrecision = (ann - aPrecision) | |
535 | + | let n1 = (n + big1) | |
536 | + | func calc (acc,cur) = { | |
537 | + | let $t02157721597 = acc | |
538 | + | let d = $t02157721597._1 | |
539 | + | let found = $t02157721597._2 | |
540 | + | if ((found != unit)) | |
541 | + | then acc | |
542 | + | else { | |
543 | + | let dp = (((d * d) * d) / xp0_xp1_n_n) | |
544 | + | let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp))) | |
545 | + | let dDiff = absBigInt((dNext - value(d))) | |
546 | + | if ((big1 >= dDiff)) | |
547 | + | then $Tuple2(dNext, cur) | |
548 | + | else $Tuple2(dNext, unit) | |
549 | + | } | |
550 | + | } | |
551 | + | ||
552 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
553 | + | let $t02201822065 = { | |
554 | + | let $l = arr | |
555 | + | let $s = size($l) | |
556 | + | let $acc0 = $Tuple2(s, unit) | |
557 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
558 | + | then $a | |
559 | + | else calc($a, $l[$i]) | |
560 | + | ||
561 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
562 | + | then $a | |
563 | + | else throw("List size exceeds 15") | |
564 | + | ||
565 | + | $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) | |
566 | + | } | |
567 | + | let d = $t02201822065._1 | |
568 | + | let found = $t02201822065._2 | |
569 | + | if ((found != unit)) | |
570 | + | then d | |
571 | + | else throw(("D calculation error, D = " + toString(d))) | |
572 | + | } | |
573 | + | } | |
574 | + | ||
575 | + | ||
576 | + | func getYD (xp,i,D) = { | |
577 | + | let n = big2 | |
578 | + | let x = xp[if ((i == 0)) | |
579 | + | then 1 | |
580 | + | else 0] | |
581 | + | let aPrecision = parseBigIntValue(Amult) | |
582 | + | let a = (parseBigIntValue(A) * aPrecision) | |
583 | + | let s = x | |
584 | + | let ann = (a * n) | |
585 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
586 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
587 | + | func calc (acc,cur) = { | |
588 | + | let $t02256522585 = acc | |
589 | + | let y = $t02256522585._1 | |
590 | + | let found = $t02256522585._2 | |
591 | + | if ((found != unit)) | |
592 | + | then acc | |
593 | + | else { | |
594 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
595 | + | let yDiff = absBigInt((yNext - value(y))) | |
596 | + | if ((big1 >= yDiff)) | |
597 | + | then $Tuple2(yNext, cur) | |
598 | + | else $Tuple2(yNext, unit) | |
599 | + | } | |
600 | + | } | |
601 | + | ||
602 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
603 | + | let $t02289222939 = { | |
604 | + | let $l = arr | |
605 | + | let $s = size($l) | |
606 | + | let $acc0 = $Tuple2(D, unit) | |
607 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
608 | + | then $a | |
609 | + | else calc($a, $l[$i]) | |
610 | + | ||
611 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
612 | + | then $a | |
613 | + | else throw("List size exceeds 15") | |
614 | + | ||
615 | + | $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) | |
616 | + | } | |
617 | + | let y = $t02289222939._1 | |
618 | + | let found = $t02289222939._2 | |
619 | + | if ((found != unit)) | |
620 | + | then y | |
621 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
622 | + | } | |
623 | + | ||
624 | + | ||
625 | + | func calcDLp (amountBalance,priceBalance,lpEmission) = { | |
626 | + | let updatedDLp = fraction(getD([amountBalance, priceBalance]), scale18, lpEmission) | |
627 | + | if ((lpEmission == big0)) | |
628 | + | then big0 | |
629 | + | else updatedDLp | |
630 | + | } | |
631 | + | ||
632 | + | ||
633 | + | func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
634 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
635 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
636 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
637 | + | let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
638 | + | currentDLp | |
639 | + | } | |
640 | + | ||
641 | + | ||
642 | + | func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
643 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
644 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
645 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
646 | + | let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
647 | + | let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))] | |
648 | + | $Tuple2(actions, updatedDLp) | |
649 | + | } | |
650 | + | ||
651 | + | ||
652 | + | func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp)) | |
653 | + | then true | |
654 | + | else throwErr("updated DLp lower than current DLp") | |
655 | + | ||
656 | + | ||
657 | + | func validateMatcherOrderAllowed (order) = { | |
658 | + | let amountAssetAmount = order.amount | |
659 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
660 | + | let $t02487825090 = if ((order.orderType == Buy)) | |
661 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
662 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
663 | + | let amountAssetBalanceDelta = $t02487825090._1 | |
664 | + | let priceAssetBalanceDelta = $t02487825090._2 | |
450 | 665 | if (if (if (igs()) | |
451 | 666 | then true | |
452 | - | else ( | |
667 | + | else (cfgPoolStatus == PoolMatcherDis)) | |
453 | 668 | then true | |
454 | - | else ( | |
669 | + | else (cfgPoolStatus == PoolShutdown)) | |
455 | 670 | then throw("Admin blocked") | |
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 | - | } | |
671 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
672 | + | then true | |
673 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
674 | + | then throw("Wr assets") | |
675 | + | else { | |
676 | + | let dLp = parseBigIntValue(getStringValue(this, keyDLp)) | |
677 | + | let $t02542025520 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
678 | + | let unusedActions = $t02542025520._1 | |
679 | + | let dLpNew = $t02542025520._2 | |
680 | + | let isOrderValid = (dLpNew >= dLp) | |
681 | + | isOrderValid | |
682 | + | } | |
479 | 683 | } | |
480 | 684 | ||
481 | 685 | ||
511 | 715 | } | |
512 | 716 | ||
513 | 717 | ||
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 | - | ||
618 | 718 | func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = { | |
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) | |
719 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
720 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
721 | + | let lpId = cfgLpAssetId | |
722 | + | let amtDcm = cfgAmountAssetDecimals | |
723 | + | let priceDcm = cfgPriceAssetDecimals | |
724 | + | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity) | |
626 | 725 | let chechEmission = if ((lpAssetEmission > big0)) | |
627 | 726 | then true | |
628 | 727 | else throw("initial deposit requires all coins") | |
630 | 729 | then { | |
631 | 730 | let amBalance = getAccBalance(amId) | |
632 | 731 | let prBalance = getAccBalance(prId) | |
633 | - | let $ | |
732 | + | let $t02778628248 = if ((txId == "")) | |
634 | 733 | then $Tuple2(amBalance, prBalance) | |
635 | 734 | else if ((pmtAssetId == amId)) | |
636 | 735 | then if ((pmtAmtRaw > amBalance)) | |
641 | 740 | then throw("invalid payment amount") | |
642 | 741 | else $Tuple2(amBalance, (prBalance - pmtAmtRaw)) | |
643 | 742 | else throw("wrong pmtAssetId") | |
644 | - | let amBalanceOld = $ | |
645 | - | let prBalanceOld = $ | |
646 | - | let $ | |
743 | + | let amBalanceOld = $t02778628248._1 | |
744 | + | let prBalanceOld = $t02778628248._2 | |
745 | + | let $t02825428430 = if ((pmtAssetId == amId)) | |
647 | 746 | then $Tuple2(pmtAmtRaw, 0) | |
648 | 747 | else if ((pmtAssetId == prId)) | |
649 | 748 | then $Tuple2(0, pmtAmtRaw) | |
650 | 749 | else throw("invalid payment") | |
651 | - | let amAmountRaw = $ | |
652 | - | let prAmountRaw = $ | |
653 | - | let $ | |
750 | + | let amAmountRaw = $t02825428430._1 | |
751 | + | let prAmountRaw = $t02825428430._2 | |
752 | + | let $t02843428688 = if (withTakeFee) | |
654 | 753 | then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2) | |
655 | 754 | else $Tuple3(amAmountRaw, prAmountRaw, 0) | |
656 | - | let amAmount = $ | |
657 | - | let prAmount = $ | |
658 | - | let feeAmount = $ | |
755 | + | let amAmount = $t02843428688._1 | |
756 | + | let prAmount = $t02843428688._2 | |
757 | + | let feeAmount = $t02843428688._3 | |
659 | 758 | let amBalanceNew = (amBalanceOld + amAmount) | |
660 | 759 | let prBalanceNew = (prBalanceOld + prAmount) | |
661 | 760 | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
665 | 764 | else throw() | |
666 | 765 | if ((checkD == checkD)) | |
667 | 766 | then { | |
668 | - | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0) | |
767 | + | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR) | |
669 | 768 | let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8) | |
670 | 769 | 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))] | |
671 | 770 | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
682 | 781 | ||
683 | 782 | ||
684 | 783 | func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = { | |
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] | |
784 | + | let lpId = toBase58String(value(cfgLpAssetId)) | |
785 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
786 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
787 | + | let amDecimals = cfgAmountAssetDecimals | |
788 | + | let prDecimals = cfgPriceAssetDecimals | |
789 | + | let poolStatus = cfgPoolStatus | |
692 | 790 | let userAddress = if ((caller == restContract)) | |
693 | 791 | then originCaller | |
694 | 792 | else caller | |
695 | 793 | let pmt = value(payments[0]) | |
696 | 794 | let pmtAssetId = value(pmt.assetId) | |
697 | 795 | let pmtAmt = pmt.amount | |
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)) | |
796 | + | let currentDLp = calcCurrentDLp(big0, big0, big0) | |
797 | + | if ((currentDLp == currentDLp)) | |
798 | + | then { | |
799 | + | let txId58 = toBase58String(transactionId) | |
800 | + | if ((lpId != toBase58String(pmtAssetId))) | |
801 | + | then throw("Wrong LP") | |
802 | + | else { | |
803 | + | let amBalance = getAccBalance(amId) | |
804 | + | let prBalance = getAccBalance(prId) | |
805 | + | let $t03073830849 = { | |
806 | + | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
807 | + | if ($isInstanceOf(@, "(Int, Int)")) | |
808 | + | then @ | |
809 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
810 | + | } | |
811 | + | if (($t03073830849 == $t03073830849)) | |
738 | 812 | then { | |
739 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
740 | - | if ((burn == burn)) | |
741 | - | then $Tuple2(state, totalAmount) | |
813 | + | let feeAmount = $t03073830849._2 | |
814 | + | let totalGet = $t03073830849._1 | |
815 | + | let totalAmount = if (if ((minOutAmount > 0)) | |
816 | + | then (minOutAmount > totalGet) | |
817 | + | else false) | |
818 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
819 | + | else totalGet | |
820 | + | let $t03103931346 = if ((outAssetId == amId)) | |
821 | + | then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance) | |
822 | + | else if ((outAssetId == prId)) | |
823 | + | then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount)) | |
824 | + | else throw("invalid out asset id") | |
825 | + | let outAm = $t03103931346._1 | |
826 | + | let outPr = $t03103931346._2 | |
827 | + | let amBalanceNew = $t03103931346._3 | |
828 | + | let prBalanceNew = $t03103931346._4 | |
829 | + | let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals)) | |
830 | + | let curPr = f1(curPrX18, scale8) | |
831 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
832 | + | then unit | |
833 | + | else fromBase58String(outAssetId) | |
834 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
835 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
836 | + | else nil | |
837 | + | 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) | |
838 | + | if ((state == state)) | |
839 | + | then { | |
840 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
841 | + | if ((burn == burn)) | |
842 | + | then { | |
843 | + | let $t03213132481 = { | |
844 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
845 | + | then 0 | |
846 | + | else feeAmount | |
847 | + | let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId)) | |
848 | + | then true | |
849 | + | else false | |
850 | + | if (outInAmountAsset) | |
851 | + | then $Tuple2(-((totalGet + feeAmountForCalc)), 0) | |
852 | + | else $Tuple2(0, -((totalGet + feeAmountForCalc))) | |
853 | + | } | |
854 | + | let amountAssetBalanceDelta = $t03213132481._1 | |
855 | + | let priceAssetBalanceDelta = $t03213132481._2 | |
856 | + | let $t03248432592 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
857 | + | let refreshDLpActions = $t03248432592._1 | |
858 | + | let updatedDLp = $t03248432592._2 | |
859 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
860 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
861 | + | then $Tuple2((state ++ refreshDLpActions), totalAmount) | |
862 | + | else throw("Strict value is not equal to itself.") | |
863 | + | } | |
864 | + | else throw("Strict value is not equal to itself.") | |
865 | + | } | |
742 | 866 | else throw("Strict value is not equal to itself.") | |
743 | 867 | } | |
744 | 868 | else throw("Strict value is not equal to itself.") | |
745 | 869 | } | |
746 | - | else throw("Strict value is not equal to itself.") | |
747 | 870 | } | |
871 | + | else throw("Strict value is not equal to itself.") | |
748 | 872 | } | |
749 | 873 | ||
750 | 874 | ||
849 | 973 | else if ((size(i.payments) != 2)) | |
850 | 974 | then throw("2 pmnts expd") | |
851 | 975 | else { | |
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)) | |
976 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
977 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
978 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt) | |
979 | + | if ((amountAssetBalance == amountAssetBalance)) | |
862 | 980 | then { | |
863 | - | let el = match r { | |
864 | - | case legacy: Address => | |
865 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
866 | - | case _ => | |
867 | - | unit | |
868 | - | } | |
869 | - | if ((el == el)) | |
981 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt) | |
982 | + | if ((priceAssetBalance == priceAssetBalance)) | |
870 | 983 | then { | |
871 | - | let sa = if ((amDiff > 0)) | |
872 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
873 | - | else nil | |
874 | - | if ((sa == sa)) | |
984 | + | let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity) | |
985 | + | if ((lpAssetEmission == lpAssetEmission)) | |
875 | 986 | then { | |
876 | - | let sp = if ((prDiff > 0)) | |
877 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
878 | - | else nil | |
879 | - | if ((sp == sp)) | |
987 | + | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
988 | + | if ((currentDLp == currentDLp)) | |
880 | 989 | then { | |
881 | - | let lpTrnsfr = if (autoStake) | |
990 | + | 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, "") | |
991 | + | let emitLpAmt = e._2 | |
992 | + | let lpAssetId = e._7 | |
993 | + | let state = e._9 | |
994 | + | let amDiff = e._10 | |
995 | + | let prDiff = e._11 | |
996 | + | let amId = e._12 | |
997 | + | let prId = e._13 | |
998 | + | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
999 | + | if ((r == r)) | |
882 | 1000 | then { | |
883 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
884 | - | if ((ss == ss)) | |
885 | - | then nil | |
1001 | + | let el = match r { | |
1002 | + | case legacy: Address => | |
1003 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
1004 | + | case _ => | |
1005 | + | unit | |
1006 | + | } | |
1007 | + | if ((el == el)) | |
1008 | + | then { | |
1009 | + | let sa = if ((amDiff > 0)) | |
1010 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
1011 | + | else nil | |
1012 | + | if ((sa == sa)) | |
1013 | + | then { | |
1014 | + | let sp = if ((prDiff > 0)) | |
1015 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
1016 | + | else nil | |
1017 | + | if ((sp == sp)) | |
1018 | + | then { | |
1019 | + | let lpTrnsfr = if (autoStake) | |
1020 | + | then { | |
1021 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
1022 | + | if ((ss == ss)) | |
1023 | + | then nil | |
1024 | + | else throw("Strict value is not equal to itself.") | |
1025 | + | } | |
1026 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1027 | + | let $t03674136883 = refreshDLpInternal(0, 0, 0) | |
1028 | + | let refreshDLpActions = $t03674136883._1 | |
1029 | + | let updatedDLp = $t03674136883._2 | |
1030 | + | let check = if ((updatedDLp >= currentDLp)) | |
1031 | + | then true | |
1032 | + | else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " ")) | |
1033 | + | if ((check == check)) | |
1034 | + | then { | |
1035 | + | let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity | |
1036 | + | if ((lpAssetEmissionAfter == lpAssetEmissionAfter)) | |
1037 | + | then ((state ++ lpTrnsfr) ++ refreshDLpActions) | |
1038 | + | else throw("Strict value is not equal to itself.") | |
1039 | + | } | |
1040 | + | else throw("Strict value is not equal to itself.") | |
1041 | + | } | |
1042 | + | else throw("Strict value is not equal to itself.") | |
1043 | + | } | |
1044 | + | else throw("Strict value is not equal to itself.") | |
1045 | + | } | |
886 | 1046 | else throw("Strict value is not equal to itself.") | |
887 | 1047 | } | |
888 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
889 | - | (state ++ lpTrnsfr) | |
1048 | + | else throw("Strict value is not equal to itself.") | |
890 | 1049 | } | |
891 | 1050 | else throw("Strict value is not equal to itself.") | |
892 | 1051 | } | |
924 | 1083 | else throwErr("exactly 1 payment are expected")] | |
925 | 1084 | if ((checks == checks)) | |
926 | 1085 | then { | |
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]) | |
1086 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
1087 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
1088 | + | let lpId = cfgLpAssetId | |
1089 | + | let amDecimals = cfgAmountAssetDecimals | |
1090 | + | let prDecimals = cfgPriceAssetDecimals | |
933 | 1091 | let userAddress = if ((i.caller == this)) | |
934 | 1092 | then i.originCaller | |
935 | 1093 | else i.caller | |
936 | 1094 | let pmt = value(i.payments[0]) | |
937 | 1095 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
938 | 1096 | let pmtAmt = pmt.amount | |
939 | - | let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
940 | - | if (($t03347833636 == $t03347833636)) | |
1097 | + | let currentDLp = if ((pmt.assetId == cfgAmountAssetId)) | |
1098 | + | then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0)) | |
1099 | + | else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0)) | |
1100 | + | if ((currentDLp == currentDLp)) | |
941 | 1101 | then { | |
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)) | |
1102 | + | let $t03852438682 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
1103 | + | if (($t03852438682 == $t03852438682)) | |
952 | 1104 | then { | |
953 | - | let el = match e { | |
954 | - | case legacy: Address => | |
955 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
956 | - | case _ => | |
957 | - | unit | |
958 | - | } | |
959 | - | if ((el == el)) | |
1105 | + | let feeAmount = $t03852438682._3 | |
1106 | + | let state = $t03852438682._2 | |
1107 | + | let estimLP = $t03852438682._1 | |
1108 | + | let emitLpAmt = if (if ((minOutAmount > 0)) | |
1109 | + | then (minOutAmount > estimLP) | |
1110 | + | else false) | |
1111 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1112 | + | else estimLP | |
1113 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
1114 | + | if ((e == e)) | |
960 | 1115 | then { | |
961 | - | let lpTrnsfr = if (autoStake) | |
1116 | + | let el = match e { | |
1117 | + | case legacy: Address => | |
1118 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
1119 | + | case _ => | |
1120 | + | unit | |
1121 | + | } | |
1122 | + | if ((el == el)) | |
962 | 1123 | then { | |
963 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
964 | - | if ((ss == ss)) | |
965 | - | then nil | |
1124 | + | let lpTrnsfr = if (autoStake) | |
1125 | + | then { | |
1126 | + | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
1127 | + | if ((ss == ss)) | |
1128 | + | then nil | |
1129 | + | else throw("Strict value is not equal to itself.") | |
1130 | + | } | |
1131 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
1132 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
1133 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
1134 | + | else nil | |
1135 | + | let $t03949739846 = if ((this == feeCollectorAddress)) | |
1136 | + | then $Tuple2(0, 0) | |
1137 | + | else { | |
1138 | + | let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId)) | |
1139 | + | then true | |
1140 | + | else false | |
1141 | + | if (paymentInAmountAsset) | |
1142 | + | then $Tuple2(-(feeAmount), 0) | |
1143 | + | else $Tuple2(0, -(feeAmount)) | |
1144 | + | } | |
1145 | + | let amountAssetBalanceDelta = $t03949739846._1 | |
1146 | + | let priceAssetBalanceDelta = $t03949739846._2 | |
1147 | + | let $t03984939957 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1148 | + | let refreshDLpActions = $t03984939957._1 | |
1149 | + | let updatedDLp = $t03984939957._2 | |
1150 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1151 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1152 | + | then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt) | |
966 | 1153 | else throw("Strict value is not equal to itself.") | |
967 | 1154 | } | |
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) | |
1155 | + | else throw("Strict value is not equal to itself.") | |
973 | 1156 | } | |
974 | 1157 | else throw("Strict value is not equal to itself.") | |
975 | 1158 | } | |
989 | 1172 | then throw("2 pmnts expd") | |
990 | 1173 | else { | |
991 | 1174 | 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, "") | |
992 | - | estPut._9 | |
1175 | + | let state = estPut._9 | |
1176 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1177 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1178 | + | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1179 | + | if ((currentDLp == currentDLp)) | |
1180 | + | then { | |
1181 | + | let $t04098741052 = refreshDLpInternal(0, 0, 0) | |
1182 | + | let refreshDLpActions = $t04098741052._1 | |
1183 | + | let updatedDLp = $t04098741052._2 | |
1184 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1185 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1186 | + | then (state ++ refreshDLpActions) | |
1187 | + | else throw("Strict value is not equal to itself.") | |
1188 | + | } | |
1189 | + | else throw("Strict value is not equal to itself.") | |
993 | 1190 | } | |
994 | 1191 | ||
995 | 1192 | ||
996 | 1193 | ||
997 | 1194 | @Callable(i) | |
998 | 1195 | func get () = { | |
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 | |
1196 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1197 | + | if ((currentDLp == currentDLp)) | |
1198 | + | then { | |
1199 | + | let r = cg(i) | |
1200 | + | let outAmtAmt = r._1 | |
1201 | + | let outPrAmt = r._2 | |
1202 | + | let pmtAmt = r._3 | |
1203 | + | let pmtAssetId = r._4 | |
1204 | + | let state = r._5 | |
1205 | + | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1206 | + | if ((b == b)) | |
1207 | + | then { | |
1208 | + | let $t04222542307 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1209 | + | let refreshDLpActions = $t04222542307._1 | |
1210 | + | let updatedDLp = $t04222542307._2 | |
1211 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1212 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1213 | + | then (state ++ refreshDLpActions) | |
1214 | + | else throw("Strict value is not equal to itself.") | |
1215 | + | } | |
1216 | + | else throw("Strict value is not equal to itself.") | |
1217 | + | } | |
1008 | 1218 | else throw("Strict value is not equal to itself.") | |
1009 | 1219 | } | |
1010 | 1220 | ||
1032 | 1242 | else throwErr("exactly 1 payment are expected")] | |
1033 | 1243 | if ((checks == checks)) | |
1034 | 1244 | then { | |
1035 | - | let $ | |
1036 | - | let state = $ | |
1037 | - | let totalAmount = $ | |
1245 | + | let $t04292543080 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId) | |
1246 | + | let state = $t04292543080._1 | |
1247 | + | let totalAmount = $t04292543080._2 | |
1038 | 1248 | $Tuple2(state, totalAmount) | |
1039 | 1249 | } | |
1040 | 1250 | else throw("Strict value is not equal to itself.") | |
1043 | 1253 | ||
1044 | 1254 | ||
1045 | 1255 | @Callable(i) | |
1256 | + | func refreshDLp () = { | |
1257 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0) | |
1258 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay)) | |
1259 | + | then unit | |
1260 | + | else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1261 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1262 | + | then { | |
1263 | + | let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp")) | |
1264 | + | let $t04360443668 = refreshDLpInternal(0, 0, 0) | |
1265 | + | let dLpUpdateActions = $t04360443668._1 | |
1266 | + | let updatedDLp = $t04360443668._2 | |
1267 | + | let actions = if ((dLp != updatedDLp)) | |
1268 | + | then dLpUpdateActions | |
1269 | + | else throwErr("nothing to refresh") | |
1270 | + | $Tuple2(actions, toString(updatedDLp)) | |
1271 | + | } | |
1272 | + | else throw("Strict value is not equal to itself.") | |
1273 | + | } | |
1274 | + | ||
1275 | + | ||
1276 | + | ||
1277 | + | @Callable(i) | |
1046 | 1278 | func getOneTknV2READONLY (outAssetId,lpAssetAmount) = { | |
1047 | - | let poolConfig = gpc() | |
1048 | - | let amId = poolConfig[idxAmAsId] | |
1049 | - | let prId = poolConfig[idxPrAsId] | |
1050 | - | let lpId = poolConfig[idxLPAsId] | |
1279 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
1280 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
1281 | + | let lpId = toBase58String(value(cfgLpAssetId)) | |
1051 | 1282 | let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))] | |
1052 | 1283 | let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
1053 | 1284 | let D0 = getD(xp) | |
1060 | 1291 | let newY = getYD(xp, index, D1) | |
1061 | 1292 | let dy = (xp[index] - newY) | |
1062 | 1293 | let totalGetRaw = max([0, toInt((dy - big1))]) | |
1063 | - | let $ | |
1064 | - | let totalGet = $ | |
1065 | - | let feeAmount = $ | |
1294 | + | let $t04459844653 = takeFee(totalGetRaw, outFee) | |
1295 | + | let totalGet = $t04459844653._1 | |
1296 | + | let feeAmount = $t04459844653._2 | |
1066 | 1297 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1067 | 1298 | } | |
1068 | 1299 | ||
1070 | 1301 | ||
1071 | 1302 | @Callable(i) | |
1072 | 1303 | func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = { | |
1073 | - | let poolConfig = gpc() | |
1074 | - | let amId = poolConfig[idxAmAsId] | |
1075 | - | let prId = poolConfig[idxPrAsId] | |
1076 | - | let lpId = poolConfig[idxLPAsId] | |
1304 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
1305 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
1306 | + | let lpId = toBase58String(value(cfgLpAssetId)) | |
1077 | 1307 | let amBalance = getAccBalance(amId) | |
1078 | 1308 | let prBalance = getAccBalance(prId) | |
1079 | - | let $ | |
1309 | + | let $t04502845143 = { | |
1080 | 1310 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil) | |
1081 | 1311 | if ($isInstanceOf(@, "(Int, Int)")) | |
1082 | 1312 | then @ | |
1083 | 1313 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
1084 | 1314 | } | |
1085 | - | let totalGet = $ | |
1086 | - | let feeAmount = $ | |
1315 | + | let totalGet = $t04502845143._1 | |
1316 | + | let feeAmount = $t04502845143._2 | |
1087 | 1317 | let r = ego("", lpId, lpAssetAmount, this) | |
1088 | 1318 | let outAmAmt = r._1 | |
1089 | 1319 | let outPrAmt = r._2 | |
1111 | 1341 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1112 | 1342 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1113 | 1343 | else { | |
1114 | - | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1115 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1116 | - | then state | |
1344 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1345 | + | if ((currentDLp == currentDLp)) | |
1346 | + | then { | |
1347 | + | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1348 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1349 | + | then { | |
1350 | + | let $t04630946390 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1351 | + | let refreshDLpActions = $t04630946390._1 | |
1352 | + | let updatedDLp = $t04630946390._2 | |
1353 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1354 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1355 | + | then (state ++ refreshDLpActions) | |
1356 | + | else throw("Strict value is not equal to itself.") | |
1357 | + | } | |
1358 | + | else throw("Strict value is not equal to itself.") | |
1359 | + | } | |
1117 | 1360 | else throw("Strict value is not equal to itself.") | |
1118 | 1361 | } | |
1119 | 1362 | } | |
1127 | 1370 | else true | |
1128 | 1371 | if ((checkPayments == checkPayments)) | |
1129 | 1372 | then { | |
1130 | - | let cfg = gpc() | |
1131 | 1373 | let factoryCfg = gfc() | |
1132 | - | let lpAssetId = | |
1374 | + | let lpAssetId = cfgLpAssetId | |
1133 | 1375 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1376 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1134 | 1377 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1135 | 1378 | if ((unstakeInv == unstakeInv)) | |
1136 | 1379 | then { | |
1137 | 1380 | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1381 | + | let outAmAmt = r._1 | |
1382 | + | let outPrAmt = r._2 | |
1138 | 1383 | let sts = parseIntValue(r._9) | |
1139 | 1384 | let state = r._10 | |
1140 | 1385 | let v = if (if (igs()) | |
1146 | 1391 | then { | |
1147 | 1392 | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1148 | 1393 | if ((burnA == burnA)) | |
1149 | - | then state | |
1394 | + | then { | |
1395 | + | let $t04741447495 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1396 | + | let refreshDLpActions = $t04741447495._1 | |
1397 | + | let updatedDLp = $t04741447495._2 | |
1398 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1399 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1400 | + | then (state ++ refreshDLpActions) | |
1401 | + | else throw("Strict value is not equal to itself.") | |
1402 | + | } | |
1150 | 1403 | else throw("Strict value is not equal to itself.") | |
1151 | 1404 | } | |
1152 | 1405 | else throw("Strict value is not equal to itself.") | |
1170 | 1423 | else throw("no payments are expected")] | |
1171 | 1424 | if ((checks == checks)) | |
1172 | 1425 | then { | |
1426 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1173 | 1427 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1174 | 1428 | if ((unstakeInv == unstakeInv)) | |
1175 | 1429 | then { | |
1186 | 1440 | then { | |
1187 | 1441 | let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1188 | 1442 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1189 | - | then state | |
1443 | + | then { | |
1444 | + | let $t04874348824 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1445 | + | let refreshDLpActions = $t04874348824._1 | |
1446 | + | let updatedDLp = $t04874348824._2 | |
1447 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1448 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1449 | + | then (state ++ refreshDLpActions) | |
1450 | + | else throw("Strict value is not equal to itself.") | |
1451 | + | } | |
1190 | 1452 | else throw("Strict value is not equal to itself.") | |
1191 | 1453 | } | |
1192 | 1454 | else throw("Strict value is not equal to itself.") | |
1220 | 1482 | else throwErr("no payments are expected")] | |
1221 | 1483 | if ((checks == checks)) | |
1222 | 1484 | then { | |
1223 | - | let cfg = gpc() | |
1224 | 1485 | let factoryCfg = gfc() | |
1225 | - | let lpAssetId = | |
1486 | + | let lpAssetId = cfgLpAssetId | |
1226 | 1487 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1227 | 1488 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil) | |
1228 | 1489 | if ((unstakeInv == unstakeInv)) | |
1229 | 1490 | then { | |
1230 | - | let $ | |
1231 | - | let state = $ | |
1232 | - | let totalAmount = $ | |
1491 | + | let $t04971949907 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId) | |
1492 | + | let state = $t04971949907._1 | |
1493 | + | let totalAmount = $t04971949907._2 | |
1233 | 1494 | $Tuple2(state, totalAmount) | |
1234 | 1495 | } | |
1235 | 1496 | else throw("Strict value is not equal to itself.") | |
1241 | 1502 | ||
1242 | 1503 | @Callable(i) | |
1243 | 1504 | func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1244 | - | let poolConfig = gpc() | |
1245 | - | let amId = poolConfig[idxAmAsId] | |
1246 | - | let prId = poolConfig[idxPrAsId] | |
1247 | - | let lpId = poolConfig[idxLPAsId] | |
1248 | - | let $t04200342106 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1249 | - | let lpAmount = $t04200342106._1 | |
1250 | - | let state = $t04200342106._2 | |
1251 | - | let feeAmount = $t04200342106._3 | |
1252 | - | let bonus = $t04200342106._4 | |
1505 | + | let $t05003550138 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1506 | + | let lpAmount = $t05003550138._1 | |
1507 | + | let state = $t05003550138._2 | |
1508 | + | let feeAmount = $t05003550138._3 | |
1509 | + | let bonus = $t05003550138._4 | |
1253 | 1510 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1254 | 1511 | } | |
1255 | 1512 | ||
1257 | 1514 | ||
1258 | 1515 | @Callable(i) | |
1259 | 1516 | func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1260 | - | let poolConfig = gpc() | |
1261 | - | let amId = poolConfig[idxAmAsId] | |
1262 | - | let prId = poolConfig[idxPrAsId] | |
1263 | - | let lpId = poolConfig[idxLPAsId] | |
1264 | - | let $t04238542489 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1265 | - | let lpAmount = $t04238542489._1 | |
1266 | - | let state = $t04238542489._2 | |
1267 | - | let feeAmount = $t04238542489._3 | |
1268 | - | let bonus = $t04238542489._4 | |
1517 | + | let $t05028650390 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1518 | + | let lpAmount = $t05028650390._1 | |
1519 | + | let state = $t05028650390._2 | |
1520 | + | let feeAmount = $t05028650390._3 | |
1521 | + | let bonus = $t05028650390._4 | |
1269 | 1522 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1270 | 1523 | } | |
1271 | 1524 | ||
1350 | 1603 | match tx { | |
1351 | 1604 | case order: Order => | |
1352 | 1605 | let matcherPub = mp() | |
1353 | - | let orderValid = | |
1606 | + | let orderValid = validateMatcherOrderAllowed(order) | |
1354 | 1607 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1355 | 1608 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1356 | 1609 | if (if (if (orderValid) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let scale8 = 100000000 | |
5 | 5 | ||
6 | 6 | let scale8BigInt = toBigInt(100000000) | |
7 | 7 | ||
8 | 8 | let scale18 = toBigInt(1000000000000000000) | |
9 | 9 | ||
10 | 10 | let zeroBigInt = toBigInt(0) | |
11 | 11 | ||
12 | 12 | let big0 = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big1 = toBigInt(1) | |
15 | 15 | ||
16 | 16 | let big2 = toBigInt(2) | |
17 | + | ||
18 | + | let big3 = toBigInt(3) | |
19 | + | ||
20 | + | let big4 = toBigInt(4) | |
17 | 21 | ||
18 | 22 | let slippage4D = toBigInt((scale8 - ((scale8 * 1) / scale8))) | |
19 | 23 | ||
20 | 24 | let wavesString = "WAVES" | |
21 | 25 | ||
22 | 26 | let Amult = "100" | |
23 | 27 | ||
24 | 28 | let Dconv = "1" | |
25 | 29 | ||
26 | 30 | let SEP = "__" | |
27 | 31 | ||
28 | 32 | let EMPTY = "" | |
29 | 33 | ||
30 | 34 | let PoolActive = 1 | |
31 | 35 | ||
32 | 36 | let PoolPutDis = 2 | |
33 | 37 | ||
34 | 38 | let PoolMatcherDis = 3 | |
35 | 39 | ||
36 | 40 | let PoolShutdown = 4 | |
37 | 41 | ||
38 | 42 | let idxPoolAddress = 1 | |
39 | 43 | ||
40 | 44 | let idxPoolSt = 2 | |
41 | 45 | ||
42 | 46 | let idxLPAsId = 3 | |
43 | 47 | ||
44 | 48 | let idxAmAsId = 4 | |
45 | 49 | ||
46 | 50 | let idxPrAsId = 5 | |
47 | 51 | ||
48 | 52 | let idxAmtAsDcm = 6 | |
49 | 53 | ||
50 | 54 | let idxPriceAsDcm = 7 | |
51 | 55 | ||
52 | 56 | let idxIAmtAsId = 8 | |
53 | 57 | ||
54 | 58 | let idxIPriceAsId = 9 | |
55 | 59 | ||
56 | 60 | let idxFactStakCntr = 1 | |
57 | 61 | ||
58 | 62 | let idxFactoryRestCntr = 6 | |
59 | 63 | ||
60 | 64 | let idxFactSlippCntr = 7 | |
61 | 65 | ||
62 | 66 | let idxFactGwxRewCntr = 10 | |
63 | 67 | ||
64 | 68 | let feeDefault = fraction(10, scale8, 10000) | |
65 | 69 | ||
66 | 70 | func t1 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
67 | 71 | ||
68 | 72 | ||
69 | 73 | func f1 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
70 | 74 | ||
71 | 75 | ||
76 | + | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
77 | + | ||
78 | + | ||
79 | + | func t2 (origVal,origScaleMult) = fraction(origVal, scale18, toBigInt(origScaleMult)) | |
80 | + | ||
81 | + | ||
82 | + | func f2 (val,resultScaleMult) = fraction(val, toBigInt(resultScaleMult), scale18) | |
83 | + | ||
84 | + | ||
72 | 85 | func ts (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
73 | 86 | ||
74 | 87 | ||
75 | 88 | func abs (val) = if ((zeroBigInt > val)) | |
76 | 89 | then -(val) | |
77 | 90 | else val | |
78 | 91 | ||
79 | 92 | ||
80 | 93 | func absBigInt (val) = if ((zeroBigInt > val)) | |
81 | 94 | then -(val) | |
82 | 95 | else val | |
83 | 96 | ||
84 | 97 | ||
85 | 98 | func fc () = "%s__factoryContract" | |
86 | 99 | ||
87 | 100 | ||
88 | 101 | func mpk () = "%s__managerPublicKey" | |
89 | 102 | ||
90 | 103 | ||
91 | 104 | func pmpk () = "%s__pendingManagerPublicKey" | |
92 | 105 | ||
93 | 106 | ||
94 | 107 | func pl () = "%s%s__price__last" | |
95 | 108 | ||
96 | 109 | ||
97 | 110 | func ph (h,t) = makeString(["%s%s%d%d__price__history", toString(h), toString(t)], SEP) | |
98 | 111 | ||
99 | 112 | ||
100 | 113 | func pau (ua,txId) = ((("%s%s%s__P__" + ua) + "__") + txId) | |
101 | 114 | ||
102 | 115 | ||
103 | 116 | func gau (ua,txId) = ((("%s%s%s__G__" + ua) + "__") + txId) | |
104 | 117 | ||
105 | 118 | ||
106 | 119 | func aa () = "%s__amountAsset" | |
107 | 120 | ||
108 | 121 | ||
109 | 122 | func pa () = "%s__priceAsset" | |
110 | 123 | ||
111 | 124 | ||
112 | 125 | func amp () = "%s__amp" | |
113 | 126 | ||
114 | 127 | ||
115 | 128 | func ada () = "%s__addonAddr" | |
116 | 129 | ||
117 | 130 | ||
131 | + | let keyFee = "%s__fee" | |
132 | + | ||
133 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
134 | + | ||
135 | + | let keyDLp = makeString(["%s", "dLp"], SEP) | |
136 | + | ||
137 | + | let keyDLpRefreshedHeight = makeString(["%s", "dLpRefreshedHeight"], SEP) | |
138 | + | ||
139 | + | let keyDLpRefreshDelay = makeString(["%s", "refreshDLpDelay"], SEP) | |
140 | + | ||
141 | + | let dLpRefreshDelayDefault = 1 | |
142 | + | ||
143 | + | let dLpRefreshDelay = valueOrElse(getInteger(this, keyDLpRefreshDelay), dLpRefreshDelayDefault) | |
144 | + | ||
118 | 145 | func fcfg () = "%s__factoryConfig" | |
119 | 146 | ||
120 | 147 | ||
121 | 148 | func mtpk () = "%s%s__matcher__publicKey" | |
122 | 149 | ||
123 | 150 | ||
124 | 151 | func pc (iAmtAs,iPrAs) = (((("%d%d%s__" + iAmtAs) + "__") + iPrAs) + "__config") | |
125 | 152 | ||
126 | 153 | ||
127 | 154 | func mba (bAStr) = ("%s%s%s__mappings__baseAsset2internalId__" + bAStr) | |
128 | 155 | ||
129 | 156 | ||
130 | 157 | func aps () = "%s__shutdown" | |
131 | 158 | ||
132 | 159 | ||
133 | 160 | func keyAllowedLpStableScriptHash () = "%s__allowedLpStableScriptHash" | |
134 | 161 | ||
135 | 162 | ||
136 | 163 | func keyFeeCollectorAddress () = "%s__feeCollectorAddress" | |
137 | 164 | ||
138 | 165 | ||
139 | 166 | func toe (orV,sendrV,matchV) = throw(((((("Failed: ordValid=" + toString(orV)) + " sndrValid=") + toString(sendrV)) + " mtchrValid=") + toString(matchV))) | |
140 | 167 | ||
141 | 168 | ||
142 | - | func str (val) = match val { | |
143 | - | case valStr: String => | |
144 | - | valStr | |
145 | - | case _ => | |
146 | - | throw("fail cast to String") | |
147 | - | } | |
148 | - | ||
149 | - | ||
150 | 169 | func strf (addr,key) = valueOrErrorMessage(getString(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
151 | 170 | ||
152 | 171 | ||
153 | 172 | func intf (addr,key) = valueOrErrorMessage(getInteger(addr, key), makeString(["mandatory ", toString(addr), ".", key, " not defined"], "")) | |
154 | 173 | ||
155 | 174 | ||
156 | 175 | func throwErr (msg) = throw(makeString(["lp_stable.ride:", msg], " ")) | |
176 | + | ||
177 | + | ||
178 | + | func fmtErr (msg) = makeString(["lp_stable.ride:", msg], " ") | |
157 | 179 | ||
158 | 180 | ||
159 | 181 | let fca = addressFromStringValue(strf(this, fc())) | |
160 | 182 | ||
161 | 183 | let inFee = { | |
162 | 184 | let @ = invoke(fca, "getInFeeREADONLY", [toString(this)], nil) | |
163 | 185 | if ($isInstanceOf(@, "Int")) | |
164 | 186 | then @ | |
165 | 187 | else throw(($getType(@) + " couldn't be cast to Int")) | |
166 | 188 | } | |
167 | 189 | ||
168 | 190 | let outFee = { | |
169 | 191 | let @ = invoke(fca, "getOutFeeREADONLY", [toString(this)], nil) | |
170 | 192 | if ($isInstanceOf(@, "Int")) | |
171 | 193 | then @ | |
172 | 194 | else throw(($getType(@) + " couldn't be cast to Int")) | |
173 | 195 | } | |
174 | 196 | ||
175 | 197 | let A = strf(this, amp()) | |
176 | 198 | ||
177 | 199 | func igs () = valueOrElse(getBoolean(fca, aps()), false) | |
178 | 200 | ||
179 | 201 | ||
180 | 202 | func mp () = fromBase58String(strf(fca, mtpk())) | |
181 | 203 | ||
182 | 204 | ||
183 | 205 | let feeCollectorAddress = addressFromStringValue(strf(fca, keyFeeCollectorAddress())) | |
184 | 206 | ||
185 | 207 | func gpc () = { | |
186 | 208 | let amtAs = strf(this, aa()) | |
187 | 209 | let priceAs = strf(this, pa()) | |
188 | 210 | let iPriceAs = intf(fca, mba(priceAs)) | |
189 | 211 | let iAmtAs = intf(fca, mba(amtAs)) | |
190 | 212 | split(strf(fca, pc(toString(iAmtAs), toString(iPriceAs))), SEP) | |
191 | 213 | } | |
192 | 214 | ||
193 | 215 | ||
194 | 216 | func parseAssetId (input) = if ((input == wavesString)) | |
195 | 217 | then unit | |
196 | 218 | else fromBase58String(input) | |
197 | 219 | ||
198 | 220 | ||
199 | 221 | func assetIdToString (input) = if ((input == unit)) | |
200 | 222 | then wavesString | |
201 | 223 | else toBase58String(value(input)) | |
202 | 224 | ||
203 | 225 | ||
204 | - | func parsePoolConfig (poolConfig) = $ | |
226 | + | 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])) | |
205 | 227 | ||
206 | 228 | ||
207 | 229 | let poolConfigParsed = parsePoolConfig(gpc()) | |
208 | 230 | ||
209 | - | let $ | |
231 | + | let $t077427971 = poolConfigParsed | |
210 | 232 | ||
211 | - | let cfgPoolAddress = $ | |
233 | + | let cfgPoolAddress = $t077427971._1 | |
212 | 234 | ||
213 | - | let cfgPoolStatus = $ | |
235 | + | let cfgPoolStatus = $t077427971._2 | |
214 | 236 | ||
215 | - | let cfgLpAssetId = $ | |
237 | + | let cfgLpAssetId = $t077427971._3 | |
216 | 238 | ||
217 | - | let cfgAmountAssetId = $ | |
239 | + | let cfgAmountAssetId = $t077427971._4 | |
218 | 240 | ||
219 | - | let cfgPriceAssetId = $ | |
241 | + | let cfgPriceAssetId = $t077427971._5 | |
220 | 242 | ||
221 | - | let cfgAmountAssetDecimals = $ | |
243 | + | let cfgAmountAssetDecimals = $t077427971._6 | |
222 | 244 | ||
223 | - | let cfgPriceAssetDecimals = $t069097095._7 | |
245 | + | let cfgPriceAssetDecimals = $t077427971._7 | |
246 | + | ||
247 | + | let cfgInAmountAssedId = $t077427971._8 | |
248 | + | ||
249 | + | let cfgInPriceAssetId = $t077427971._9 | |
224 | 250 | ||
225 | 251 | func gfc () = split(strf(fca, fcfg()), SEP) | |
226 | 252 | ||
227 | 253 | ||
228 | 254 | let factoryConfig = gfc() | |
229 | 255 | ||
230 | 256 | let stakingContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactStakCntr]), "Invalid staking contract address") | |
231 | 257 | ||
232 | 258 | let slipageContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactSlippCntr]), "Invalid slipage contract address") | |
233 | 259 | ||
234 | 260 | let gwxContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactGwxRewCntr]), "Invalid gwx contract address") | |
235 | 261 | ||
236 | 262 | let restContract = valueOrErrorMessage(addressFromString(factoryConfig[idxFactoryRestCntr]), "Invalid gwx contract address") | |
237 | 263 | ||
238 | 264 | 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) | |
239 | 265 | ||
240 | 266 | ||
241 | 267 | 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) | |
242 | 268 | ||
243 | 269 | ||
244 | 270 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
245 | 271 | then wavesBalance(this).available | |
246 | 272 | else assetBalance(this, fromBase58String(assetId)) | |
247 | 273 | ||
248 | 274 | ||
249 | 275 | func cpbi (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
276 | + | ||
277 | + | ||
278 | + | func cpbir (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
250 | 279 | ||
251 | 280 | ||
252 | 281 | func vad (A1,A2,slippage) = { | |
253 | 282 | let diff = fraction((A1 - A2), scale8BigInt, A2) | |
254 | 283 | let pass = ((slippage - abs(diff)) > zeroBigInt) | |
255 | 284 | if (!(pass)) | |
256 | 285 | then throw(("Big slpg: " + toString(diff))) | |
257 | 286 | else $Tuple2(pass, min([A1, A2])) | |
258 | 287 | } | |
259 | 288 | ||
260 | 289 | ||
261 | 290 | func vd (D1,D0,slpg) = { | |
262 | 291 | let diff = fraction(D0, scale8BigInt, D1) | |
263 | 292 | let fail = (slpg > diff) | |
264 | 293 | if (if (fail) | |
265 | 294 | then true | |
266 | 295 | else (D0 > D1)) | |
267 | 296 | then throw(((((((toString(D0) + " ") + toString(D1)) + " ") + toString(diff)) + " ") + toString(slpg))) | |
268 | 297 | else fail | |
269 | 298 | } | |
270 | 299 | ||
271 | 300 | ||
272 | 301 | func pcp (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
273 | 302 | let amtAsAmtX18 = t1(amAmt, amAssetDcm) | |
274 | 303 | let prAsAmtX18 = t1(prAmt, prAssetDcm) | |
275 | 304 | cpbi(prAsAmtX18, amtAsAmtX18) | |
276 | 305 | } | |
277 | 306 | ||
278 | 307 | ||
279 | 308 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
280 | - | let cfg = gpc() | |
281 | - | let amtAsDcm = parseIntValue(cfg[idxAmtAsDcm]) | |
282 | - | let prAsDcm = parseIntValue(cfg[idxPriceAsDcm]) | |
309 | + | let amtAsDcm = cfgAmountAssetDecimals | |
310 | + | let prAsDcm = cfgPriceAssetDecimals | |
283 | 311 | let priceX18 = pcp(amtAsDcm, prAsDcm, amAmt, prAmt) | |
284 | 312 | let amAmtX18 = t1(amAmt, amtAsDcm) | |
285 | 313 | let prAmtX18 = t1(prAmt, prAsDcm) | |
286 | 314 | let lpAmtX18 = t1(lpAmt, scale8) | |
287 | 315 | let lpPrInAmAsX18 = cpbi(amAmtX18, lpAmtX18) | |
288 | 316 | let lpPrInPrAsX18 = cpbi(prAmtX18, lpAmtX18) | |
289 | 317 | [priceX18, lpPrInAmAsX18, lpPrInPrAsX18] | |
290 | 318 | } | |
291 | 319 | ||
292 | 320 | ||
293 | 321 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
294 | 322 | let p = calcPrices(amAmt, prAmt, lpAmt) | |
295 | 323 | [f1(p[0], scale8), f1(p[1], scale8), f1(p[2], scale8)] | |
296 | 324 | } | |
297 | 325 | ||
298 | 326 | ||
299 | 327 | func takeFee (amount,fee) = { | |
300 | 328 | let feeAmount = if ((fee == 0)) | |
301 | 329 | then 0 | |
302 | 330 | else fraction(amount, fee, scale8) | |
303 | 331 | $Tuple2((amount - feeAmount), feeAmount) | |
304 | 332 | } | |
305 | 333 | ||
306 | 334 | ||
307 | 335 | func ego (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
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)) | |
336 | + | let lpId = cfgLpAssetId | |
337 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
338 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
339 | + | let amDcm = cfgAmountAssetDecimals | |
340 | + | let prDcm = cfgPriceAssetDecimals | |
341 | + | let sts = toString(cfgPoolStatus) | |
342 | + | let lpEmiss = valueOrErrorMessage(assetInfo(lpId), "Wrong LP id").quantity | |
343 | + | if ((toBase58String(lpId) != pmtAssetId)) | |
317 | 344 | then throw("Wrong pmt asset") | |
318 | 345 | else { | |
319 | 346 | let amBalance = getAccBalance(amId) | |
320 | 347 | let amBalanceX18 = t1(amBalance, amDcm) | |
321 | 348 | let prBalance = getAccBalance(prId) | |
322 | 349 | let prBalanceX18 = t1(prBalance, prDcm) | |
323 | 350 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
324 | 351 | let curPrice = f1(curPriceX18, scale8) | |
325 | 352 | let pmtLpAmtX18 = t1(pmtLpAmt, scale8) | |
326 | 353 | let lpEmissX18 = t1(lpEmiss, scale8) | |
327 | 354 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissX18) | |
328 | 355 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissX18) | |
329 | - | let outAmAmt = | |
330 | - | let outPrAmt = | |
356 | + | let outAmAmt = fromX18Round(outAmAmtX18, amDcm, FLOOR) | |
357 | + | let outPrAmt = fromX18Round(outPrAmtX18, prDcm, FLOOR) | |
331 | 358 | let state = if ((txId58 == "")) | |
332 | 359 | then nil | |
333 | 360 | else [ScriptTransfer(userAddress, outAmAmt, if ((amId == "WAVES")) | |
334 | 361 | then unit | |
335 | 362 | else fromBase58String(amId)), ScriptTransfer(userAddress, outPrAmt, if ((prId == "WAVES")) | |
336 | 363 | then unit | |
337 | 364 | 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)] | |
338 | 365 | $Tuple10(outAmAmt, outPrAmt, amId, prId, amBalance, prBalance, lpEmiss, curPriceX18, sts, state) | |
339 | 366 | } | |
340 | 367 | } | |
341 | 368 | ||
342 | 369 | ||
343 | 370 | func epo (txId58,slippage,inAmAmt,inAmId,inPrAmt,inPrId,userAddress,isEval,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
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] | |
371 | + | let lpId = cfgLpAssetId | |
372 | + | let amIdStr = toBase58String(value(cfgAmountAssetId)) | |
373 | + | let prIdStr = toBase58String(value(cfgPriceAssetId)) | |
374 | + | let inAmIdStr = cfgInAmountAssedId | |
375 | + | let inPrIdStr = cfgInPriceAssetId | |
376 | + | let amtDcm = cfgAmountAssetDecimals | |
377 | + | let priceDcm = cfgPriceAssetDecimals | |
378 | + | let sts = toString(cfgPoolStatus) | |
353 | 379 | let lpEm = valueOrErrorMessage(assetInfo(lpId), "Wr lp as").quantity | |
354 | 380 | let amBalance = if (isEval) | |
355 | 381 | then getAccBalance(amIdStr) | |
356 | 382 | else if (if (isOneAsset) | |
357 | 383 | then (pmtId == amIdStr) | |
358 | 384 | else false) | |
359 | 385 | then (getAccBalance(amIdStr) - pmtAmt) | |
360 | 386 | else if (isOneAsset) | |
361 | 387 | then getAccBalance(amIdStr) | |
362 | 388 | else (getAccBalance(amIdStr) - inAmAmt) | |
363 | 389 | let prBalance = if (isEval) | |
364 | 390 | then getAccBalance(prIdStr) | |
365 | 391 | else if (if (isOneAsset) | |
366 | 392 | then (pmtId == prIdStr) | |
367 | 393 | else false) | |
368 | 394 | then (getAccBalance(prIdStr) - pmtAmt) | |
369 | 395 | else if (isOneAsset) | |
370 | 396 | then getAccBalance(prIdStr) | |
371 | 397 | else (getAccBalance(prIdStr) - inPrAmt) | |
372 | 398 | let inAmAssetAmtX18 = t1(inAmAmt, amtDcm) | |
373 | 399 | let inPrAssetAmtX18 = t1(inPrAmt, priceDcm) | |
374 | 400 | let userPriceX18 = cpbi(inPrAssetAmtX18, inAmAssetAmtX18) | |
375 | 401 | let amBalanceX18 = t1(amBalance, amtDcm) | |
376 | 402 | let prBalanceX18 = t1(prBalance, priceDcm) | |
377 | 403 | let r = if ((lpEm == 0)) | |
378 | 404 | then { | |
379 | 405 | let curPriceX18 = zeroBigInt | |
380 | 406 | let slippageX18 = zeroBigInt | |
381 | 407 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
382 | 408 | $Tuple5(f1(lpAmtX18, scale8), f1(inAmAssetAmtX18, amtDcm), f1(inPrAssetAmtX18, priceDcm), cpbi((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
383 | 409 | } | |
384 | 410 | else { | |
385 | 411 | let curPriceX18 = cpbi(prBalanceX18, amBalanceX18) | |
386 | 412 | let slippageRealX18 = fraction(abs((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
387 | 413 | let slippageX18 = t1(slippage, scale8) | |
388 | 414 | if (if (if (validateSlippage) | |
389 | 415 | then (curPriceX18 != zeroBigInt) | |
390 | 416 | else false) | |
391 | 417 | then (slippageRealX18 > slippageX18) | |
392 | 418 | else false) | |
393 | 419 | then throw(((("Price slippage " + toString(slippageRealX18)) + " > ") + toString(slippageX18))) | |
394 | 420 | else { | |
395 | 421 | let lpEmissionX18 = t1(lpEm, scale8) | |
396 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, | |
397 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, | |
422 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, cpbir(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
423 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, cpbir(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
398 | 424 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
399 | 425 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
400 | 426 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
401 | 427 | let expAmtAssetAmtX18 = expectedAmts._1 | |
402 | 428 | let expPriceAssetAmtX18 = expectedAmts._2 | |
403 | - | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
404 | - | $Tuple5( | |
429 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
430 | + | $Tuple5((fromX18Round(lpAmtX18, scale8, FLOOR) - 100), fromX18Round(expAmtAssetAmtX18, amtDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceDcm, CEILING), curPriceX18, slippageX18) | |
405 | 431 | } | |
406 | 432 | } | |
407 | 433 | let calcLpAmt = r._1 | |
408 | 434 | let calcAmAssetPmt = r._2 | |
409 | 435 | let calcPrAssetPmt = r._3 | |
410 | 436 | let curPrice = f1(r._4, scale8) | |
411 | 437 | let slippageCalc = f1(r._5, scale8) | |
412 | 438 | if ((0 >= calcLpAmt)) | |
413 | 439 | then throw("LP <= 0") | |
414 | 440 | else { | |
415 | 441 | let emitLpAmt = if (!(emitLp)) | |
416 | 442 | then 0 | |
417 | 443 | else calcLpAmt | |
418 | 444 | let amDiff = (inAmAmt - calcAmAssetPmt) | |
419 | 445 | let prDiff = (inPrAmt - calcPrAssetPmt) | |
420 | - | let $ | |
446 | + | let $t01862718972 = if (if (isOneAsset) | |
421 | 447 | then (pmtId == amIdStr) | |
422 | 448 | else false) | |
423 | 449 | then $Tuple2(pmtAmt, 0) | |
424 | 450 | else if (if (isOneAsset) | |
425 | 451 | then (pmtId == prIdStr) | |
426 | 452 | else false) | |
427 | 453 | then $Tuple2(0, pmtAmt) | |
428 | 454 | else $Tuple2(calcAmAssetPmt, calcPrAssetPmt) | |
429 | - | let writeAmAmt = $ | |
430 | - | let writePrAmt = $ | |
455 | + | let writeAmAmt = $t01862718972._1 | |
456 | + | let writePrAmt = $t01862718972._2 | |
431 | 457 | 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))] | |
432 | 458 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEm, lpId, sts, commonState, amDiff, prDiff, inAmId, inPrId) | |
433 | 459 | } | |
434 | 460 | } | |
435 | 461 | ||
436 | 462 | ||
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) | |
463 | + | func getD (xp) = { | |
464 | + | let xp0 = xp[0] | |
465 | + | let xp1 = xp[1] | |
466 | + | let s = (xp0 + xp1) | |
467 | + | if ((s == big0)) | |
468 | + | then big0 | |
469 | + | else { | |
470 | + | let a = parseIntValue(A) | |
471 | + | let ann = (a * 2) | |
472 | + | let p = fraction(xp0, xp1, big1) | |
473 | + | let xp0_xp1_n_n = fraction(p, big4, big1) | |
474 | + | let ann_s = fraction(toBigInt(ann), s, big1) | |
475 | + | let ann_1 = toBigInt((ann - 1)) | |
476 | + | func calcDNext (d) = { | |
477 | + | let dd = fraction(d, d, big1) | |
478 | + | let ddd = fraction(dd, d, big1) | |
479 | + | let dp = fraction(ddd, big1, xp0_xp1_n_n) | |
480 | + | fraction((ann_s + fraction(dp, big2, big1)), d, (fraction(ann_1, d, big1) + fraction(big3, dp, big1)), CEILING) | |
481 | + | } | |
482 | + | ||
483 | + | func calc (acc,i) = if (acc._2) | |
484 | + | then acc | |
485 | + | else { | |
486 | + | let d = acc._1 | |
487 | + | let dNext = calcDNext(d) | |
488 | + | let dDiffRaw = toInt((dNext - value(d))) | |
489 | + | let dDiff = if ((0 > dDiffRaw)) | |
490 | + | then -(dDiffRaw) | |
491 | + | else dDiffRaw | |
492 | + | if ((1 >= dDiff)) | |
493 | + | then $Tuple2(dNext, true) | |
494 | + | else $Tuple2(dNext, false) | |
495 | + | } | |
496 | + | ||
497 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
498 | + | let $t02090020948 = { | |
499 | + | let $l = arr | |
500 | + | let $s = size($l) | |
501 | + | let $acc0 = $Tuple2(s, false) | |
502 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
503 | + | then $a | |
504 | + | else calc($a, $l[$i]) | |
505 | + | ||
506 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
507 | + | then $a | |
508 | + | else throw("List size exceeds 15") | |
509 | + | ||
510 | + | $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) | |
511 | + | } | |
512 | + | let d = $t02090020948._1 | |
513 | + | let found = $t02090020948._2 | |
514 | + | if (found) | |
515 | + | then d | |
516 | + | else throw(("D calculation error, D = " + toString(d))) | |
517 | + | } | |
518 | + | } | |
519 | + | ||
520 | + | ||
521 | + | func getDOld (xp) = { | |
522 | + | let n = big2 | |
523 | + | let xp0 = xp[0] | |
524 | + | let xp1 = xp[1] | |
525 | + | let aPrecision = parseBigIntValue(Amult) | |
526 | + | let a = (parseBigIntValue(A) * aPrecision) | |
527 | + | let s = (xp0 + xp1) | |
528 | + | if ((s == big0)) | |
529 | + | then big0 | |
530 | + | else { | |
531 | + | let ann = (a * n) | |
532 | + | let xp0_xp1_n_n = (((xp0 * xp1) * n) * n) | |
533 | + | let ann_s_aPrecision = ((ann * s) / aPrecision) | |
534 | + | let ann_aPrecision = (ann - aPrecision) | |
535 | + | let n1 = (n + big1) | |
536 | + | func calc (acc,cur) = { | |
537 | + | let $t02157721597 = acc | |
538 | + | let d = $t02157721597._1 | |
539 | + | let found = $t02157721597._2 | |
540 | + | if ((found != unit)) | |
541 | + | then acc | |
542 | + | else { | |
543 | + | let dp = (((d * d) * d) / xp0_xp1_n_n) | |
544 | + | let dNext = (((ann_s_aPrecision + (dp * n)) * d) / (((ann_aPrecision * d) / aPrecision) + (n1 * dp))) | |
545 | + | let dDiff = absBigInt((dNext - value(d))) | |
546 | + | if ((big1 >= dDiff)) | |
547 | + | then $Tuple2(dNext, cur) | |
548 | + | else $Tuple2(dNext, unit) | |
549 | + | } | |
550 | + | } | |
551 | + | ||
552 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
553 | + | let $t02201822065 = { | |
554 | + | let $l = arr | |
555 | + | let $s = size($l) | |
556 | + | let $acc0 = $Tuple2(s, unit) | |
557 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
558 | + | then $a | |
559 | + | else calc($a, $l[$i]) | |
560 | + | ||
561 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
562 | + | then $a | |
563 | + | else throw("List size exceeds 15") | |
564 | + | ||
565 | + | $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) | |
566 | + | } | |
567 | + | let d = $t02201822065._1 | |
568 | + | let found = $t02201822065._2 | |
569 | + | if ((found != unit)) | |
570 | + | then d | |
571 | + | else throw(("D calculation error, D = " + toString(d))) | |
572 | + | } | |
573 | + | } | |
574 | + | ||
575 | + | ||
576 | + | func getYD (xp,i,D) = { | |
577 | + | let n = big2 | |
578 | + | let x = xp[if ((i == 0)) | |
579 | + | then 1 | |
580 | + | else 0] | |
581 | + | let aPrecision = parseBigIntValue(Amult) | |
582 | + | let a = (parseBigIntValue(A) * aPrecision) | |
583 | + | let s = x | |
584 | + | let ann = (a * n) | |
585 | + | let c = (((((D * D) / (x * n)) * D) * aPrecision) / (ann * n)) | |
586 | + | let b = ((s + ((D * aPrecision) / ann)) - D) | |
587 | + | func calc (acc,cur) = { | |
588 | + | let $t02256522585 = acc | |
589 | + | let y = $t02256522585._1 | |
590 | + | let found = $t02256522585._2 | |
591 | + | if ((found != unit)) | |
592 | + | then acc | |
593 | + | else { | |
594 | + | let yNext = (((y * y) + c) / ((big2 * y) + b)) | |
595 | + | let yDiff = absBigInt((yNext - value(y))) | |
596 | + | if ((big1 >= yDiff)) | |
597 | + | then $Tuple2(yNext, cur) | |
598 | + | else $Tuple2(yNext, unit) | |
599 | + | } | |
600 | + | } | |
601 | + | ||
602 | + | let arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] | |
603 | + | let $t02289222939 = { | |
604 | + | let $l = arr | |
605 | + | let $s = size($l) | |
606 | + | let $acc0 = $Tuple2(D, unit) | |
607 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
608 | + | then $a | |
609 | + | else calc($a, $l[$i]) | |
610 | + | ||
611 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
612 | + | then $a | |
613 | + | else throw("List size exceeds 15") | |
614 | + | ||
615 | + | $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) | |
616 | + | } | |
617 | + | let y = $t02289222939._1 | |
618 | + | let found = $t02289222939._2 | |
619 | + | if ((found != unit)) | |
620 | + | then y | |
621 | + | else throw(("Y calculation error, Y = " + toString(y))) | |
622 | + | } | |
623 | + | ||
624 | + | ||
625 | + | func calcDLp (amountBalance,priceBalance,lpEmission) = { | |
626 | + | let updatedDLp = fraction(getD([amountBalance, priceBalance]), scale18, lpEmission) | |
627 | + | if ((lpEmission == big0)) | |
628 | + | then big0 | |
629 | + | else updatedDLp | |
630 | + | } | |
631 | + | ||
632 | + | ||
633 | + | func calcCurrentDLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
634 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
635 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
636 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
637 | + | let currentDLp = calcDLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
638 | + | currentDLp | |
639 | + | } | |
640 | + | ||
641 | + | ||
642 | + | func refreshDLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
643 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
644 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
645 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
646 | + | let updatedDLp = calcDLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
647 | + | let actions = [IntegerEntry(keyDLpRefreshedHeight, height), StringEntry(keyDLp, toString(updatedDLp))] | |
648 | + | $Tuple2(actions, updatedDLp) | |
649 | + | } | |
650 | + | ||
651 | + | ||
652 | + | func validateUpdatedDLp (oldDLp,updatedDLp) = if ((updatedDLp >= oldDLp)) | |
653 | + | then true | |
654 | + | else throwErr("updated DLp lower than current DLp") | |
655 | + | ||
656 | + | ||
657 | + | func validateMatcherOrderAllowed (order) = { | |
658 | + | let amountAssetAmount = order.amount | |
659 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
660 | + | let $t02487825090 = if ((order.orderType == Buy)) | |
661 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
662 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
663 | + | let amountAssetBalanceDelta = $t02487825090._1 | |
664 | + | let priceAssetBalanceDelta = $t02487825090._2 | |
450 | 665 | if (if (if (igs()) | |
451 | 666 | then true | |
452 | - | else ( | |
667 | + | else (cfgPoolStatus == PoolMatcherDis)) | |
453 | 668 | then true | |
454 | - | else ( | |
669 | + | else (cfgPoolStatus == PoolShutdown)) | |
455 | 670 | then throw("Admin blocked") | |
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 | - | } | |
671 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
672 | + | then true | |
673 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
674 | + | then throw("Wr assets") | |
675 | + | else { | |
676 | + | let dLp = parseBigIntValue(getStringValue(this, keyDLp)) | |
677 | + | let $t02542025520 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
678 | + | let unusedActions = $t02542025520._1 | |
679 | + | let dLpNew = $t02542025520._2 | |
680 | + | let isOrderValid = (dLpNew >= dLp) | |
681 | + | isOrderValid | |
682 | + | } | |
479 | 683 | } | |
480 | 684 | ||
481 | 685 | ||
482 | 686 | func cg (i) = if ((size(i.payments) != 1)) | |
483 | 687 | then throw("1 pmnt exp") | |
484 | 688 | else { | |
485 | 689 | let pmt = value(i.payments[0]) | |
486 | 690 | let pmtAssetId = value(pmt.assetId) | |
487 | 691 | let pmtAmt = pmt.amount | |
488 | 692 | let r = ego(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
489 | 693 | let outAmAmt = r._1 | |
490 | 694 | let outPrAmt = r._2 | |
491 | 695 | let sts = parseIntValue(r._9) | |
492 | 696 | let state = r._10 | |
493 | 697 | if (if (igs()) | |
494 | 698 | then true | |
495 | 699 | else (sts == PoolShutdown)) | |
496 | 700 | then throw(("Admin blocked: " + toString(sts))) | |
497 | 701 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
498 | 702 | } | |
499 | 703 | ||
500 | 704 | ||
501 | 705 | func cp (caller,txId,amAsPmt,prAsPmt,slippage,emitLp,isOneAsset,validateSlippage,pmtAmt,pmtId) = { | |
502 | 706 | let r = epo(txId, slippage, value(amAsPmt).amount, value(amAsPmt).assetId, value(prAsPmt).amount, value(prAsPmt).assetId, caller, (txId == ""), emitLp, isOneAsset, validateSlippage, pmtAmt, pmtId) | |
503 | 707 | let sts = parseIntValue(r._8) | |
504 | 708 | if (if (if (igs()) | |
505 | 709 | then true | |
506 | 710 | else (sts == PoolPutDis)) | |
507 | 711 | then true | |
508 | 712 | else (sts == PoolShutdown)) | |
509 | 713 | then throw(("Blocked:" + toString(sts))) | |
510 | 714 | else r | |
511 | 715 | } | |
512 | 716 | ||
513 | 717 | ||
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 | - | ||
618 | 718 | func calcPutOneTkn (pmtAmtRaw,pmtAssetId,userAddress,txId,withTakeFee) = { | |
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) | |
719 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
720 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
721 | + | let lpId = cfgLpAssetId | |
722 | + | let amtDcm = cfgAmountAssetDecimals | |
723 | + | let priceDcm = cfgPriceAssetDecimals | |
724 | + | let lpAssetEmission = toBigInt(valueOrErrorMessage(assetInfo(lpId), "invalid lp asset").quantity) | |
626 | 725 | let chechEmission = if ((lpAssetEmission > big0)) | |
627 | 726 | then true | |
628 | 727 | else throw("initial deposit requires all coins") | |
629 | 728 | if ((chechEmission == chechEmission)) | |
630 | 729 | then { | |
631 | 730 | let amBalance = getAccBalance(amId) | |
632 | 731 | let prBalance = getAccBalance(prId) | |
633 | - | let $ | |
732 | + | let $t02778628248 = if ((txId == "")) | |
634 | 733 | then $Tuple2(amBalance, prBalance) | |
635 | 734 | else if ((pmtAssetId == amId)) | |
636 | 735 | then if ((pmtAmtRaw > amBalance)) | |
637 | 736 | then throw("invalid payment amount") | |
638 | 737 | else $Tuple2((amBalance - pmtAmtRaw), prBalance) | |
639 | 738 | else if ((pmtAssetId == prId)) | |
640 | 739 | then if ((pmtAmtRaw > prBalance)) | |
641 | 740 | then throw("invalid payment amount") | |
642 | 741 | else $Tuple2(amBalance, (prBalance - pmtAmtRaw)) | |
643 | 742 | else throw("wrong pmtAssetId") | |
644 | - | let amBalanceOld = $ | |
645 | - | let prBalanceOld = $ | |
646 | - | let $ | |
743 | + | let amBalanceOld = $t02778628248._1 | |
744 | + | let prBalanceOld = $t02778628248._2 | |
745 | + | let $t02825428430 = if ((pmtAssetId == amId)) | |
647 | 746 | then $Tuple2(pmtAmtRaw, 0) | |
648 | 747 | else if ((pmtAssetId == prId)) | |
649 | 748 | then $Tuple2(0, pmtAmtRaw) | |
650 | 749 | else throw("invalid payment") | |
651 | - | let amAmountRaw = $ | |
652 | - | let prAmountRaw = $ | |
653 | - | let $ | |
750 | + | let amAmountRaw = $t02825428430._1 | |
751 | + | let prAmountRaw = $t02825428430._2 | |
752 | + | let $t02843428688 = if (withTakeFee) | |
654 | 753 | then $Tuple3(takeFee(amAmountRaw, inFee)._1, takeFee(prAmountRaw, inFee)._1, takeFee(pmtAmtRaw, inFee)._2) | |
655 | 754 | else $Tuple3(amAmountRaw, prAmountRaw, 0) | |
656 | - | let amAmount = $ | |
657 | - | let prAmount = $ | |
658 | - | let feeAmount = $ | |
755 | + | let amAmount = $t02843428688._1 | |
756 | + | let prAmount = $t02843428688._2 | |
757 | + | let feeAmount = $t02843428688._3 | |
659 | 758 | let amBalanceNew = (amBalanceOld + amAmount) | |
660 | 759 | let prBalanceNew = (prBalanceOld + prAmount) | |
661 | 760 | let D0 = getD([toBigInt(amBalanceOld), toBigInt(prBalanceOld)]) | |
662 | 761 | let D1 = getD([toBigInt(amBalanceNew), toBigInt(prBalanceNew)]) | |
663 | 762 | let checkD = if ((D1 > D0)) | |
664 | 763 | then true | |
665 | 764 | else throw() | |
666 | 765 | if ((checkD == checkD)) | |
667 | 766 | then { | |
668 | - | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0) | |
767 | + | let lpAmount = fraction(lpAssetEmission, (D1 - D0), D0, FLOOR) | |
669 | 768 | let curPrice = f1(cpbi(t1(prBalanceNew, priceDcm), t1(amBalanceNew, amtDcm)), scale8) | |
670 | 769 | 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))] | |
671 | 770 | let poolProportion = fraction(prBalanceOld, scale8, amBalanceOld) | |
672 | 771 | let amountAssetPart = fraction(pmtAmtRaw, scale8, (poolProportion + scale8)) | |
673 | 772 | let priceAssetPart = (pmtAmtRaw - amountAssetPart) | |
674 | 773 | let lpAmtBoth = fraction(lpAssetEmission, toBigInt(priceAssetPart), toBigInt(prBalanceOld)) | |
675 | 774 | let bonus = toInt(fraction((lpAmount - lpAmtBoth), scale8BigInt, lpAmtBoth)) | |
676 | 775 | $Tuple4(toInt(lpAmount), commonState, feeAmount, bonus) | |
677 | 776 | } | |
678 | 777 | else throw("Strict value is not equal to itself.") | |
679 | 778 | } | |
680 | 779 | else throw("Strict value is not equal to itself.") | |
681 | 780 | } | |
682 | 781 | ||
683 | 782 | ||
684 | 783 | func getOneTknV2Internal (outAssetId,minOutAmount,payments,caller,originCaller,transactionId) = { | |
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] | |
784 | + | let lpId = toBase58String(value(cfgLpAssetId)) | |
785 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
786 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
787 | + | let amDecimals = cfgAmountAssetDecimals | |
788 | + | let prDecimals = cfgPriceAssetDecimals | |
789 | + | let poolStatus = cfgPoolStatus | |
692 | 790 | let userAddress = if ((caller == restContract)) | |
693 | 791 | then originCaller | |
694 | 792 | else caller | |
695 | 793 | let pmt = value(payments[0]) | |
696 | 794 | let pmtAssetId = value(pmt.assetId) | |
697 | 795 | let pmtAmt = pmt.amount | |
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)) | |
796 | + | let currentDLp = calcCurrentDLp(big0, big0, big0) | |
797 | + | if ((currentDLp == currentDLp)) | |
798 | + | then { | |
799 | + | let txId58 = toBase58String(transactionId) | |
800 | + | if ((lpId != toBase58String(pmtAssetId))) | |
801 | + | then throw("Wrong LP") | |
802 | + | else { | |
803 | + | let amBalance = getAccBalance(amId) | |
804 | + | let prBalance = getAccBalance(prId) | |
805 | + | let $t03073830849 = { | |
806 | + | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, pmtAmt], nil) | |
807 | + | if ($isInstanceOf(@, "(Int, Int)")) | |
808 | + | then @ | |
809 | + | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
810 | + | } | |
811 | + | if (($t03073830849 == $t03073830849)) | |
738 | 812 | then { | |
739 | - | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
740 | - | if ((burn == burn)) | |
741 | - | then $Tuple2(state, totalAmount) | |
813 | + | let feeAmount = $t03073830849._2 | |
814 | + | let totalGet = $t03073830849._1 | |
815 | + | let totalAmount = if (if ((minOutAmount > 0)) | |
816 | + | then (minOutAmount > totalGet) | |
817 | + | else false) | |
818 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
819 | + | else totalGet | |
820 | + | let $t03103931346 = if ((outAssetId == amId)) | |
821 | + | then $Tuple4(totalAmount, 0, ((amBalance - totalAmount) - feeAmount), prBalance) | |
822 | + | else if ((outAssetId == prId)) | |
823 | + | then $Tuple4(0, totalAmount, amBalance, ((prBalance - totalAmount) - feeAmount)) | |
824 | + | else throw("invalid out asset id") | |
825 | + | let outAm = $t03103931346._1 | |
826 | + | let outPr = $t03103931346._2 | |
827 | + | let amBalanceNew = $t03103931346._3 | |
828 | + | let prBalanceNew = $t03103931346._4 | |
829 | + | let curPrX18 = cpbi(t1(prBalanceNew, prDecimals), t1(amBalanceNew, amDecimals)) | |
830 | + | let curPr = f1(curPrX18, scale8) | |
831 | + | let outAssetIdOrWaves = if ((outAssetId == "WAVES")) | |
832 | + | then unit | |
833 | + | else fromBase58String(outAssetId) | |
834 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
835 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetIdOrWaves)] | |
836 | + | else nil | |
837 | + | 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) | |
838 | + | if ((state == state)) | |
839 | + | then { | |
840 | + | let burn = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
841 | + | if ((burn == burn)) | |
842 | + | then { | |
843 | + | let $t03213132481 = { | |
844 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
845 | + | then 0 | |
846 | + | else feeAmount | |
847 | + | let outInAmountAsset = if ((parseAssetId(outAssetId) == cfgAmountAssetId)) | |
848 | + | then true | |
849 | + | else false | |
850 | + | if (outInAmountAsset) | |
851 | + | then $Tuple2(-((totalGet + feeAmountForCalc)), 0) | |
852 | + | else $Tuple2(0, -((totalGet + feeAmountForCalc))) | |
853 | + | } | |
854 | + | let amountAssetBalanceDelta = $t03213132481._1 | |
855 | + | let priceAssetBalanceDelta = $t03213132481._2 | |
856 | + | let $t03248432592 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
857 | + | let refreshDLpActions = $t03248432592._1 | |
858 | + | let updatedDLp = $t03248432592._2 | |
859 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
860 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
861 | + | then $Tuple2((state ++ refreshDLpActions), totalAmount) | |
862 | + | else throw("Strict value is not equal to itself.") | |
863 | + | } | |
864 | + | else throw("Strict value is not equal to itself.") | |
865 | + | } | |
742 | 866 | else throw("Strict value is not equal to itself.") | |
743 | 867 | } | |
744 | 868 | else throw("Strict value is not equal to itself.") | |
745 | 869 | } | |
746 | - | else throw("Strict value is not equal to itself.") | |
747 | 870 | } | |
871 | + | else throw("Strict value is not equal to itself.") | |
748 | 872 | } | |
749 | 873 | ||
750 | 874 | ||
751 | 875 | func m () = match getString(mpk()) { | |
752 | 876 | case s: String => | |
753 | 877 | fromBase58String(s) | |
754 | 878 | case _: Unit => | |
755 | 879 | unit | |
756 | 880 | case _ => | |
757 | 881 | throw("Match error") | |
758 | 882 | } | |
759 | 883 | ||
760 | 884 | ||
761 | 885 | func pm () = match getString(pmpk()) { | |
762 | 886 | case s: String => | |
763 | 887 | fromBase58String(s) | |
764 | 888 | case _: Unit => | |
765 | 889 | unit | |
766 | 890 | case _ => | |
767 | 891 | throw("Match error") | |
768 | 892 | } | |
769 | 893 | ||
770 | 894 | ||
771 | 895 | let pd = throw("Permission denied") | |
772 | 896 | ||
773 | 897 | func isManager (i) = match m() { | |
774 | 898 | case pk: ByteVector => | |
775 | 899 | (i.callerPublicKey == pk) | |
776 | 900 | case _: Unit => | |
777 | 901 | (i.caller == this) | |
778 | 902 | case _ => | |
779 | 903 | throw("Match error") | |
780 | 904 | } | |
781 | 905 | ||
782 | 906 | ||
783 | 907 | func mm (i) = match m() { | |
784 | 908 | case pk: ByteVector => | |
785 | 909 | if ((i.callerPublicKey == pk)) | |
786 | 910 | then true | |
787 | 911 | else pd | |
788 | 912 | case _: Unit => | |
789 | 913 | if ((i.caller == this)) | |
790 | 914 | then true | |
791 | 915 | else pd | |
792 | 916 | case _ => | |
793 | 917 | throw("Match error") | |
794 | 918 | } | |
795 | 919 | ||
796 | 920 | ||
797 | 921 | @Callable(i) | |
798 | 922 | func constructor (fc) = { | |
799 | 923 | let c = mm(i) | |
800 | 924 | if ((c == c)) | |
801 | 925 | then [StringEntry(fc(), fc)] | |
802 | 926 | else throw("Strict value is not equal to itself.") | |
803 | 927 | } | |
804 | 928 | ||
805 | 929 | ||
806 | 930 | ||
807 | 931 | @Callable(i) | |
808 | 932 | func setManager (pendingManagerPublicKey) = { | |
809 | 933 | let c = mm(i) | |
810 | 934 | if ((c == c)) | |
811 | 935 | then { | |
812 | 936 | let cm = fromBase58String(pendingManagerPublicKey) | |
813 | 937 | if ((cm == cm)) | |
814 | 938 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
815 | 939 | else throw("Strict value is not equal to itself.") | |
816 | 940 | } | |
817 | 941 | else throw("Strict value is not equal to itself.") | |
818 | 942 | } | |
819 | 943 | ||
820 | 944 | ||
821 | 945 | ||
822 | 946 | @Callable(i) | |
823 | 947 | func confirmManager () = { | |
824 | 948 | let p = pm() | |
825 | 949 | let hpm = if (isDefined(p)) | |
826 | 950 | then true | |
827 | 951 | else throw("No pending manager") | |
828 | 952 | if ((hpm == hpm)) | |
829 | 953 | then { | |
830 | 954 | let cpm = if ((i.callerPublicKey == value(p))) | |
831 | 955 | then true | |
832 | 956 | else throw("You are not pending manager") | |
833 | 957 | if ((cpm == cpm)) | |
834 | 958 | then [StringEntry(mpk(), toBase58String(value(p))), DeleteEntry(pmpk())] | |
835 | 959 | else throw("Strict value is not equal to itself.") | |
836 | 960 | } | |
837 | 961 | else throw("Strict value is not equal to itself.") | |
838 | 962 | } | |
839 | 963 | ||
840 | 964 | ||
841 | 965 | ||
842 | 966 | @Callable(i) | |
843 | 967 | func put (slip,autoStake) = { | |
844 | 968 | let factCfg = gfc() | |
845 | 969 | let stakingCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactStakCntr]), "Wr st addr") | |
846 | 970 | let slipCntr = valueOrErrorMessage(addressFromString(factCfg[idxFactSlippCntr]), "Wr sl addr") | |
847 | 971 | if ((0 > slip)) | |
848 | 972 | then throw("Wrong slippage") | |
849 | 973 | else if ((size(i.payments) != 2)) | |
850 | 974 | then throw("2 pmnts expd") | |
851 | 975 | else { | |
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)) | |
976 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
977 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
978 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amAssetPmt) | |
979 | + | if ((amountAssetBalance == amountAssetBalance)) | |
862 | 980 | then { | |
863 | - | let el = match r { | |
864 | - | case legacy: Address => | |
865 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
866 | - | case _ => | |
867 | - | unit | |
868 | - | } | |
869 | - | if ((el == el)) | |
981 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - prAssetPmt) | |
982 | + | if ((priceAssetBalance == priceAssetBalance)) | |
870 | 983 | then { | |
871 | - | let sa = if ((amDiff > 0)) | |
872 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
873 | - | else nil | |
874 | - | if ((sa == sa)) | |
984 | + | let lpAssetEmission = toBigInt(value(assetInfo(cfgLpAssetId)).quantity) | |
985 | + | if ((lpAssetEmission == lpAssetEmission)) | |
875 | 986 | then { | |
876 | - | let sp = if ((prDiff > 0)) | |
877 | - | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
878 | - | else nil | |
879 | - | if ((sp == sp)) | |
987 | + | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
988 | + | if ((currentDLp == currentDLp)) | |
880 | 989 | then { | |
881 | - | let lpTrnsfr = if (autoStake) | |
990 | + | 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, "") | |
991 | + | let emitLpAmt = e._2 | |
992 | + | let lpAssetId = e._7 | |
993 | + | let state = e._9 | |
994 | + | let amDiff = e._10 | |
995 | + | let prDiff = e._11 | |
996 | + | let amId = e._12 | |
997 | + | let prId = e._13 | |
998 | + | let r = invoke(fca, "emit", [emitLpAmt], nil) | |
999 | + | if ((r == r)) | |
882 | 1000 | then { | |
883 | - | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
884 | - | if ((ss == ss)) | |
885 | - | then nil | |
1001 | + | let el = match r { | |
1002 | + | case legacy: Address => | |
1003 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
1004 | + | case _ => | |
1005 | + | unit | |
1006 | + | } | |
1007 | + | if ((el == el)) | |
1008 | + | then { | |
1009 | + | let sa = if ((amDiff > 0)) | |
1010 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(amId, amDiff)]) | |
1011 | + | else nil | |
1012 | + | if ((sa == sa)) | |
1013 | + | then { | |
1014 | + | let sp = if ((prDiff > 0)) | |
1015 | + | then invoke(slipCntr, "put", nil, [AttachedPayment(prId, prDiff)]) | |
1016 | + | else nil | |
1017 | + | if ((sp == sp)) | |
1018 | + | then { | |
1019 | + | let lpTrnsfr = if (autoStake) | |
1020 | + | then { | |
1021 | + | let ss = invoke(stakingCntr, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
1022 | + | if ((ss == ss)) | |
1023 | + | then nil | |
1024 | + | else throw("Strict value is not equal to itself.") | |
1025 | + | } | |
1026 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1027 | + | let $t03674136883 = refreshDLpInternal(0, 0, 0) | |
1028 | + | let refreshDLpActions = $t03674136883._1 | |
1029 | + | let updatedDLp = $t03674136883._2 | |
1030 | + | let check = if ((updatedDLp >= currentDLp)) | |
1031 | + | then true | |
1032 | + | else throwErr(makeString(["updated DLp lower than current DLp", toString(amountAssetBalance), toString(priceAssetBalance), toString(lpAssetEmission), toString(currentDLp), toString(updatedDLp), toString(amDiff), toString(prDiff)], " ")) | |
1033 | + | if ((check == check)) | |
1034 | + | then { | |
1035 | + | let lpAssetEmissionAfter = value(assetInfo(cfgLpAssetId)).quantity | |
1036 | + | if ((lpAssetEmissionAfter == lpAssetEmissionAfter)) | |
1037 | + | then ((state ++ lpTrnsfr) ++ refreshDLpActions) | |
1038 | + | else throw("Strict value is not equal to itself.") | |
1039 | + | } | |
1040 | + | else throw("Strict value is not equal to itself.") | |
1041 | + | } | |
1042 | + | else throw("Strict value is not equal to itself.") | |
1043 | + | } | |
1044 | + | else throw("Strict value is not equal to itself.") | |
1045 | + | } | |
886 | 1046 | else throw("Strict value is not equal to itself.") | |
887 | 1047 | } | |
888 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
889 | - | (state ++ lpTrnsfr) | |
1048 | + | else throw("Strict value is not equal to itself.") | |
890 | 1049 | } | |
891 | 1050 | else throw("Strict value is not equal to itself.") | |
892 | 1051 | } | |
893 | 1052 | else throw("Strict value is not equal to itself.") | |
894 | 1053 | } | |
895 | 1054 | else throw("Strict value is not equal to itself.") | |
896 | 1055 | } | |
897 | 1056 | else throw("Strict value is not equal to itself.") | |
898 | 1057 | } | |
899 | 1058 | } | |
900 | 1059 | ||
901 | 1060 | ||
902 | 1061 | ||
903 | 1062 | @Callable(i) | |
904 | 1063 | func putOneTknV2 (minOutAmount,autoStake) = { | |
905 | 1064 | let isPoolOneTokenOperationsDisabled = { | |
906 | 1065 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
907 | 1066 | if ($isInstanceOf(@, "Boolean")) | |
908 | 1067 | then @ | |
909 | 1068 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
910 | 1069 | } | |
911 | 1070 | let isPutDisabled = if (if (if (igs()) | |
912 | 1071 | then true | |
913 | 1072 | else (cfgPoolStatus == PoolPutDis)) | |
914 | 1073 | then true | |
915 | 1074 | else (cfgPoolStatus == PoolShutdown)) | |
916 | 1075 | then true | |
917 | 1076 | else isPoolOneTokenOperationsDisabled | |
918 | 1077 | let checks = [if (if (!(isPutDisabled)) | |
919 | 1078 | then true | |
920 | 1079 | else isManager(i)) | |
921 | 1080 | then true | |
922 | 1081 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
923 | 1082 | then true | |
924 | 1083 | else throwErr("exactly 1 payment are expected")] | |
925 | 1084 | if ((checks == checks)) | |
926 | 1085 | then { | |
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]) | |
1086 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
1087 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
1088 | + | let lpId = cfgLpAssetId | |
1089 | + | let amDecimals = cfgAmountAssetDecimals | |
1090 | + | let prDecimals = cfgPriceAssetDecimals | |
933 | 1091 | let userAddress = if ((i.caller == this)) | |
934 | 1092 | then i.originCaller | |
935 | 1093 | else i.caller | |
936 | 1094 | let pmt = value(i.payments[0]) | |
937 | 1095 | let pmtAssetId = toBase58String(value(pmt.assetId)) | |
938 | 1096 | let pmtAmt = pmt.amount | |
939 | - | let $t03347833636 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
940 | - | if (($t03347833636 == $t03347833636)) | |
1097 | + | let currentDLp = if ((pmt.assetId == cfgAmountAssetId)) | |
1098 | + | then calcCurrentDLp(toBigInt(pmtAmt), toBigInt(0), toBigInt(0)) | |
1099 | + | else calcCurrentDLp(toBigInt(0), toBigInt(pmtAmt), toBigInt(0)) | |
1100 | + | if ((currentDLp == currentDLp)) | |
941 | 1101 | then { | |
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)) | |
1102 | + | let $t03852438682 = calcPutOneTkn(pmtAmt, pmtAssetId, toString(userAddress), toBase58String(i.transactionId), true) | |
1103 | + | if (($t03852438682 == $t03852438682)) | |
952 | 1104 | then { | |
953 | - | let el = match e { | |
954 | - | case legacy: Address => | |
955 | - | invoke(legacy, "emit", [emitLpAmt], nil) | |
956 | - | case _ => | |
957 | - | unit | |
958 | - | } | |
959 | - | if ((el == el)) | |
1105 | + | let feeAmount = $t03852438682._3 | |
1106 | + | let state = $t03852438682._2 | |
1107 | + | let estimLP = $t03852438682._1 | |
1108 | + | let emitLpAmt = if (if ((minOutAmount > 0)) | |
1109 | + | then (minOutAmount > estimLP) | |
1110 | + | else false) | |
1111 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1112 | + | else estimLP | |
1113 | + | let e = invoke(fca, "emit", [emitLpAmt], nil) | |
1114 | + | if ((e == e)) | |
960 | 1115 | then { | |
961 | - | let lpTrnsfr = if (autoStake) | |
1116 | + | let el = match e { | |
1117 | + | case legacy: Address => | |
1118 | + | invoke(legacy, "emit", [emitLpAmt], nil) | |
1119 | + | case _ => | |
1120 | + | unit | |
1121 | + | } | |
1122 | + | if ((el == el)) | |
962 | 1123 | then { | |
963 | - | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
964 | - | if ((ss == ss)) | |
965 | - | then nil | |
1124 | + | let lpTrnsfr = if (autoStake) | |
1125 | + | then { | |
1126 | + | let ss = invoke(stakingContract, "stake", nil, [AttachedPayment(lpId, emitLpAmt)]) | |
1127 | + | if ((ss == ss)) | |
1128 | + | then nil | |
1129 | + | else throw("Strict value is not equal to itself.") | |
1130 | + | } | |
1131 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpId)] | |
1132 | + | let sendFeeToMatcher = if ((feeAmount > 0)) | |
1133 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, fromBase58String(pmtAssetId))] | |
1134 | + | else nil | |
1135 | + | let $t03949739846 = if ((this == feeCollectorAddress)) | |
1136 | + | then $Tuple2(0, 0) | |
1137 | + | else { | |
1138 | + | let paymentInAmountAsset = if ((pmt.assetId == cfgAmountAssetId)) | |
1139 | + | then true | |
1140 | + | else false | |
1141 | + | if (paymentInAmountAsset) | |
1142 | + | then $Tuple2(-(feeAmount), 0) | |
1143 | + | else $Tuple2(0, -(feeAmount)) | |
1144 | + | } | |
1145 | + | let amountAssetBalanceDelta = $t03949739846._1 | |
1146 | + | let priceAssetBalanceDelta = $t03949739846._2 | |
1147 | + | let $t03984939957 = refreshDLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1148 | + | let refreshDLpActions = $t03984939957._1 | |
1149 | + | let updatedDLp = $t03984939957._2 | |
1150 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1151 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1152 | + | then $Tuple2((((state ++ lpTrnsfr) ++ sendFeeToMatcher) ++ refreshDLpActions), emitLpAmt) | |
966 | 1153 | else throw("Strict value is not equal to itself.") | |
967 | 1154 | } | |
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) | |
1155 | + | else throw("Strict value is not equal to itself.") | |
973 | 1156 | } | |
974 | 1157 | else throw("Strict value is not equal to itself.") | |
975 | 1158 | } | |
976 | 1159 | else throw("Strict value is not equal to itself.") | |
977 | 1160 | } | |
978 | 1161 | else throw("Strict value is not equal to itself.") | |
979 | 1162 | } | |
980 | 1163 | else throw("Strict value is not equal to itself.") | |
981 | 1164 | } | |
982 | 1165 | ||
983 | 1166 | ||
984 | 1167 | ||
985 | 1168 | @Callable(i) | |
986 | 1169 | func putForFree (maxSlpg) = if ((0 > maxSlpg)) | |
987 | 1170 | then throw("Wrong slpg") | |
988 | 1171 | else if ((size(i.payments) != 2)) | |
989 | 1172 | then throw("2 pmnts expd") | |
990 | 1173 | else { | |
991 | 1174 | 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, "") | |
992 | - | estPut._9 | |
1175 | + | let state = estPut._9 | |
1176 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1177 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1178 | + | let currentDLp = calcCurrentDLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1179 | + | if ((currentDLp == currentDLp)) | |
1180 | + | then { | |
1181 | + | let $t04098741052 = refreshDLpInternal(0, 0, 0) | |
1182 | + | let refreshDLpActions = $t04098741052._1 | |
1183 | + | let updatedDLp = $t04098741052._2 | |
1184 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1185 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1186 | + | then (state ++ refreshDLpActions) | |
1187 | + | else throw("Strict value is not equal to itself.") | |
1188 | + | } | |
1189 | + | else throw("Strict value is not equal to itself.") | |
993 | 1190 | } | |
994 | 1191 | ||
995 | 1192 | ||
996 | 1193 | ||
997 | 1194 | @Callable(i) | |
998 | 1195 | func get () = { | |
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 | |
1196 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1197 | + | if ((currentDLp == currentDLp)) | |
1198 | + | then { | |
1199 | + | let r = cg(i) | |
1200 | + | let outAmtAmt = r._1 | |
1201 | + | let outPrAmt = r._2 | |
1202 | + | let pmtAmt = r._3 | |
1203 | + | let pmtAssetId = r._4 | |
1204 | + | let state = r._5 | |
1205 | + | let b = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1206 | + | if ((b == b)) | |
1207 | + | then { | |
1208 | + | let $t04222542307 = refreshDLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1209 | + | let refreshDLpActions = $t04222542307._1 | |
1210 | + | let updatedDLp = $t04222542307._2 | |
1211 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1212 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1213 | + | then (state ++ refreshDLpActions) | |
1214 | + | else throw("Strict value is not equal to itself.") | |
1215 | + | } | |
1216 | + | else throw("Strict value is not equal to itself.") | |
1217 | + | } | |
1008 | 1218 | else throw("Strict value is not equal to itself.") | |
1009 | 1219 | } | |
1010 | 1220 | ||
1011 | 1221 | ||
1012 | 1222 | ||
1013 | 1223 | @Callable(i) | |
1014 | 1224 | func getOneTknV2 (outAssetId,minOutAmount) = { | |
1015 | 1225 | let isPoolOneTokenOperationsDisabled = { | |
1016 | 1226 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1017 | 1227 | if ($isInstanceOf(@, "Boolean")) | |
1018 | 1228 | then @ | |
1019 | 1229 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1020 | 1230 | } | |
1021 | 1231 | let isGetDisabled = if (if (igs()) | |
1022 | 1232 | then true | |
1023 | 1233 | else (cfgPoolStatus == PoolShutdown)) | |
1024 | 1234 | then true | |
1025 | 1235 | else isPoolOneTokenOperationsDisabled | |
1026 | 1236 | let checks = [if (if (!(isGetDisabled)) | |
1027 | 1237 | then true | |
1028 | 1238 | else isManager(i)) | |
1029 | 1239 | then true | |
1030 | 1240 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1031 | 1241 | then true | |
1032 | 1242 | else throwErr("exactly 1 payment are expected")] | |
1033 | 1243 | if ((checks == checks)) | |
1034 | 1244 | then { | |
1035 | - | let $ | |
1036 | - | let state = $ | |
1037 | - | let totalAmount = $ | |
1245 | + | let $t04292543080 = getOneTknV2Internal(outAssetId, minOutAmount, i.payments, i.caller, i.originCaller, i.transactionId) | |
1246 | + | let state = $t04292543080._1 | |
1247 | + | let totalAmount = $t04292543080._2 | |
1038 | 1248 | $Tuple2(state, totalAmount) | |
1039 | 1249 | } | |
1040 | 1250 | else throw("Strict value is not equal to itself.") | |
1041 | 1251 | } | |
1042 | 1252 | ||
1043 | 1253 | ||
1044 | 1254 | ||
1045 | 1255 | @Callable(i) | |
1256 | + | func refreshDLp () = { | |
1257 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyDLpRefreshedHeight), 0) | |
1258 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= dLpRefreshDelay)) | |
1259 | + | then unit | |
1260 | + | else throwErr(makeString([toString(dLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1261 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1262 | + | then { | |
1263 | + | let dLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyDLp), "0")), fmtErr("invalid dLp")) | |
1264 | + | let $t04360443668 = refreshDLpInternal(0, 0, 0) | |
1265 | + | let dLpUpdateActions = $t04360443668._1 | |
1266 | + | let updatedDLp = $t04360443668._2 | |
1267 | + | let actions = if ((dLp != updatedDLp)) | |
1268 | + | then dLpUpdateActions | |
1269 | + | else throwErr("nothing to refresh") | |
1270 | + | $Tuple2(actions, toString(updatedDLp)) | |
1271 | + | } | |
1272 | + | else throw("Strict value is not equal to itself.") | |
1273 | + | } | |
1274 | + | ||
1275 | + | ||
1276 | + | ||
1277 | + | @Callable(i) | |
1046 | 1278 | func getOneTknV2READONLY (outAssetId,lpAssetAmount) = { | |
1047 | - | let poolConfig = gpc() | |
1048 | - | let amId = poolConfig[idxAmAsId] | |
1049 | - | let prId = poolConfig[idxPrAsId] | |
1050 | - | let lpId = poolConfig[idxLPAsId] | |
1279 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
1280 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
1281 | + | let lpId = toBase58String(value(cfgLpAssetId)) | |
1051 | 1282 | let xp = [toBigInt(getAccBalance(amId)), toBigInt(getAccBalance(prId))] | |
1052 | 1283 | let lpEmission = toBigInt(valueOrErrorMessage(assetInfo(fromBase58String(lpId)), "invalid lp asset").quantity) | |
1053 | 1284 | let D0 = getD(xp) | |
1054 | 1285 | let D1 = (D0 - fraction(toBigInt(lpAssetAmount), D0, lpEmission)) | |
1055 | 1286 | let index = if ((outAssetId == amId)) | |
1056 | 1287 | then 0 | |
1057 | 1288 | else if ((outAssetId == prId)) | |
1058 | 1289 | then 1 | |
1059 | 1290 | else throw("invalid out asset id") | |
1060 | 1291 | let newY = getYD(xp, index, D1) | |
1061 | 1292 | let dy = (xp[index] - newY) | |
1062 | 1293 | let totalGetRaw = max([0, toInt((dy - big1))]) | |
1063 | - | let $ | |
1064 | - | let totalGet = $ | |
1065 | - | let feeAmount = $ | |
1294 | + | let $t04459844653 = takeFee(totalGetRaw, outFee) | |
1295 | + | let totalGet = $t04459844653._1 | |
1296 | + | let feeAmount = $t04459844653._2 | |
1066 | 1297 | $Tuple2(nil, $Tuple2(totalGet, feeAmount)) | |
1067 | 1298 | } | |
1068 | 1299 | ||
1069 | 1300 | ||
1070 | 1301 | ||
1071 | 1302 | @Callable(i) | |
1072 | 1303 | func getOneTknV2WithBonusREADONLY (outAssetId,lpAssetAmount) = { | |
1073 | - | let poolConfig = gpc() | |
1074 | - | let amId = poolConfig[idxAmAsId] | |
1075 | - | let prId = poolConfig[idxPrAsId] | |
1076 | - | let lpId = poolConfig[idxLPAsId] | |
1304 | + | let amId = toBase58String(value(cfgAmountAssetId)) | |
1305 | + | let prId = toBase58String(value(cfgPriceAssetId)) | |
1306 | + | let lpId = toBase58String(value(cfgLpAssetId)) | |
1077 | 1307 | let amBalance = getAccBalance(amId) | |
1078 | 1308 | let prBalance = getAccBalance(prId) | |
1079 | - | let $ | |
1309 | + | let $t04502845143 = { | |
1080 | 1310 | let @ = invoke(this, "getOneTknV2READONLY", [outAssetId, lpAssetAmount], nil) | |
1081 | 1311 | if ($isInstanceOf(@, "(Int, Int)")) | |
1082 | 1312 | then @ | |
1083 | 1313 | else throw(($getType(@) + " couldn't be cast to (Int, Int)")) | |
1084 | 1314 | } | |
1085 | - | let totalGet = $ | |
1086 | - | let feeAmount = $ | |
1315 | + | let totalGet = $t04502845143._1 | |
1316 | + | let feeAmount = $t04502845143._2 | |
1087 | 1317 | let r = ego("", lpId, lpAssetAmount, this) | |
1088 | 1318 | let outAmAmt = r._1 | |
1089 | 1319 | let outPrAmt = r._2 | |
1090 | 1320 | let sumOfGetAssets = (outAmAmt + outPrAmt) | |
1091 | 1321 | let bonus = if ((sumOfGetAssets == 0)) | |
1092 | 1322 | then if ((totalGet == 0)) | |
1093 | 1323 | then 0 | |
1094 | 1324 | else throw("bonus calculation error") | |
1095 | 1325 | else fraction((totalGet - sumOfGetAssets), scale8, sumOfGetAssets) | |
1096 | 1326 | $Tuple2(nil, $Tuple3(totalGet, feeAmount, bonus)) | |
1097 | 1327 | } | |
1098 | 1328 | ||
1099 | 1329 | ||
1100 | 1330 | ||
1101 | 1331 | @Callable(i) | |
1102 | 1332 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1103 | 1333 | let r = cg(i) | |
1104 | 1334 | let outAmAmt = r._1 | |
1105 | 1335 | let outPrAmt = r._2 | |
1106 | 1336 | let pmtAmt = r._3 | |
1107 | 1337 | let pmtAssetId = r._4 | |
1108 | 1338 | let state = r._5 | |
1109 | 1339 | if ((noLessThenAmtAsset > outAmAmt)) | |
1110 | 1340 | then throw(((("Failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1111 | 1341 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1112 | 1342 | then throw(((("Failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1113 | 1343 | else { | |
1114 | - | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1115 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1116 | - | then state | |
1344 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1345 | + | if ((currentDLp == currentDLp)) | |
1346 | + | then { | |
1347 | + | let burnLPAssetOnFactory = invoke(fca, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1348 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1349 | + | then { | |
1350 | + | let $t04630946390 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1351 | + | let refreshDLpActions = $t04630946390._1 | |
1352 | + | let updatedDLp = $t04630946390._2 | |
1353 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1354 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1355 | + | then (state ++ refreshDLpActions) | |
1356 | + | else throw("Strict value is not equal to itself.") | |
1357 | + | } | |
1358 | + | else throw("Strict value is not equal to itself.") | |
1359 | + | } | |
1117 | 1360 | else throw("Strict value is not equal to itself.") | |
1118 | 1361 | } | |
1119 | 1362 | } | |
1120 | 1363 | ||
1121 | 1364 | ||
1122 | 1365 | ||
1123 | 1366 | @Callable(i) | |
1124 | 1367 | func unstakeAndGet (amount) = { | |
1125 | 1368 | let checkPayments = if ((size(i.payments) != 0)) | |
1126 | 1369 | then throw("No pmnts expd") | |
1127 | 1370 | else true | |
1128 | 1371 | if ((checkPayments == checkPayments)) | |
1129 | 1372 | then { | |
1130 | - | let cfg = gpc() | |
1131 | 1373 | let factoryCfg = gfc() | |
1132 | - | let lpAssetId = | |
1374 | + | let lpAssetId = cfgLpAssetId | |
1133 | 1375 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1376 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1134 | 1377 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1135 | 1378 | if ((unstakeInv == unstakeInv)) | |
1136 | 1379 | then { | |
1137 | 1380 | let r = ego(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1381 | + | let outAmAmt = r._1 | |
1382 | + | let outPrAmt = r._2 | |
1138 | 1383 | let sts = parseIntValue(r._9) | |
1139 | 1384 | let state = r._10 | |
1140 | 1385 | let v = if (if (igs()) | |
1141 | 1386 | then true | |
1142 | 1387 | else (sts == PoolShutdown)) | |
1143 | 1388 | then throw(("Blocked: " + toString(sts))) | |
1144 | 1389 | else true | |
1145 | 1390 | if ((v == v)) | |
1146 | 1391 | then { | |
1147 | 1392 | let burnA = invoke(fca, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1148 | 1393 | if ((burnA == burnA)) | |
1149 | - | then state | |
1394 | + | then { | |
1395 | + | let $t04741447495 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1396 | + | let refreshDLpActions = $t04741447495._1 | |
1397 | + | let updatedDLp = $t04741447495._2 | |
1398 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1399 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1400 | + | then (state ++ refreshDLpActions) | |
1401 | + | else throw("Strict value is not equal to itself.") | |
1402 | + | } | |
1150 | 1403 | else throw("Strict value is not equal to itself.") | |
1151 | 1404 | } | |
1152 | 1405 | else throw("Strict value is not equal to itself.") | |
1153 | 1406 | } | |
1154 | 1407 | else throw("Strict value is not equal to itself.") | |
1155 | 1408 | } | |
1156 | 1409 | else throw("Strict value is not equal to itself.") | |
1157 | 1410 | } | |
1158 | 1411 | ||
1159 | 1412 | ||
1160 | 1413 | ||
1161 | 1414 | @Callable(i) | |
1162 | 1415 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1163 | 1416 | let isGetDisabled = if (igs()) | |
1164 | 1417 | then true | |
1165 | 1418 | else (cfgPoolStatus == PoolShutdown) | |
1166 | 1419 | let checks = [if (!(isGetDisabled)) | |
1167 | 1420 | then true | |
1168 | 1421 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1169 | 1422 | then true | |
1170 | 1423 | else throw("no payments are expected")] | |
1171 | 1424 | if ((checks == checks)) | |
1172 | 1425 | then { | |
1426 | + | let currentDLp = calcCurrentDLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1173 | 1427 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1174 | 1428 | if ((unstakeInv == unstakeInv)) | |
1175 | 1429 | then { | |
1176 | 1430 | let res = ego(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1177 | 1431 | let outAmAmt = res._1 | |
1178 | 1432 | let outPrAmt = res._2 | |
1179 | 1433 | let state = res._10 | |
1180 | 1434 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1181 | 1435 | then true | |
1182 | 1436 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1183 | 1437 | then true | |
1184 | 1438 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1185 | 1439 | if ((checkAmounts == checkAmounts)) | |
1186 | 1440 | then { | |
1187 | 1441 | let burnLPAssetOnFactory = invoke(fca, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1188 | 1442 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1189 | - | then state | |
1443 | + | then { | |
1444 | + | let $t04874348824 = refreshDLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1445 | + | let refreshDLpActions = $t04874348824._1 | |
1446 | + | let updatedDLp = $t04874348824._2 | |
1447 | + | let isUpdatedDLpValid = validateUpdatedDLp(currentDLp, updatedDLp) | |
1448 | + | if ((isUpdatedDLpValid == isUpdatedDLpValid)) | |
1449 | + | then (state ++ refreshDLpActions) | |
1450 | + | else throw("Strict value is not equal to itself.") | |
1451 | + | } | |
1190 | 1452 | else throw("Strict value is not equal to itself.") | |
1191 | 1453 | } | |
1192 | 1454 | else throw("Strict value is not equal to itself.") | |
1193 | 1455 | } | |
1194 | 1456 | else throw("Strict value is not equal to itself.") | |
1195 | 1457 | } | |
1196 | 1458 | else throw("Strict value is not equal to itself.") | |
1197 | 1459 | } | |
1198 | 1460 | ||
1199 | 1461 | ||
1200 | 1462 | ||
1201 | 1463 | @Callable(i) | |
1202 | 1464 | func unstakeAndGetOneTknV2 (unstakeAmount,outAssetId,minOutAmount) = { | |
1203 | 1465 | let isPoolOneTokenOperationsDisabled = { | |
1204 | 1466 | let @ = invoke(fca, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1205 | 1467 | if ($isInstanceOf(@, "Boolean")) | |
1206 | 1468 | then @ | |
1207 | 1469 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1208 | 1470 | } | |
1209 | 1471 | let isGetDisabled = if (if (igs()) | |
1210 | 1472 | then true | |
1211 | 1473 | else (cfgPoolStatus == PoolShutdown)) | |
1212 | 1474 | then true | |
1213 | 1475 | else isPoolOneTokenOperationsDisabled | |
1214 | 1476 | let checks = [if (if (!(isGetDisabled)) | |
1215 | 1477 | then true | |
1216 | 1478 | else isManager(i)) | |
1217 | 1479 | then true | |
1218 | 1480 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1219 | 1481 | then true | |
1220 | 1482 | else throwErr("no payments are expected")] | |
1221 | 1483 | if ((checks == checks)) | |
1222 | 1484 | then { | |
1223 | - | let cfg = gpc() | |
1224 | 1485 | let factoryCfg = gfc() | |
1225 | - | let lpAssetId = | |
1486 | + | let lpAssetId = cfgLpAssetId | |
1226 | 1487 | let staking = valueOrErrorMessage(addressFromString(factoryCfg[idxFactStakCntr]), "Wr st addr") | |
1227 | 1488 | let unstakeInv = invoke(staking, "unstake", [toBase58String(lpAssetId), unstakeAmount], nil) | |
1228 | 1489 | if ((unstakeInv == unstakeInv)) | |
1229 | 1490 | then { | |
1230 | - | let $ | |
1231 | - | let state = $ | |
1232 | - | let totalAmount = $ | |
1491 | + | let $t04971949907 = getOneTknV2Internal(outAssetId, minOutAmount, [AttachedPayment(lpAssetId, unstakeAmount)], i.caller, i.originCaller, i.transactionId) | |
1492 | + | let state = $t04971949907._1 | |
1493 | + | let totalAmount = $t04971949907._2 | |
1233 | 1494 | $Tuple2(state, totalAmount) | |
1234 | 1495 | } | |
1235 | 1496 | else throw("Strict value is not equal to itself.") | |
1236 | 1497 | } | |
1237 | 1498 | else throw("Strict value is not equal to itself.") | |
1238 | 1499 | } | |
1239 | 1500 | ||
1240 | 1501 | ||
1241 | 1502 | ||
1242 | 1503 | @Callable(i) | |
1243 | 1504 | func putOneTknV2WithBonusREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1244 | - | let poolConfig = gpc() | |
1245 | - | let amId = poolConfig[idxAmAsId] | |
1246 | - | let prId = poolConfig[idxPrAsId] | |
1247 | - | let lpId = poolConfig[idxLPAsId] | |
1248 | - | let $t04200342106 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1249 | - | let lpAmount = $t04200342106._1 | |
1250 | - | let state = $t04200342106._2 | |
1251 | - | let feeAmount = $t04200342106._3 | |
1252 | - | let bonus = $t04200342106._4 | |
1505 | + | let $t05003550138 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", true) | |
1506 | + | let lpAmount = $t05003550138._1 | |
1507 | + | let state = $t05003550138._2 | |
1508 | + | let feeAmount = $t05003550138._3 | |
1509 | + | let bonus = $t05003550138._4 | |
1253 | 1510 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1254 | 1511 | } | |
1255 | 1512 | ||
1256 | 1513 | ||
1257 | 1514 | ||
1258 | 1515 | @Callable(i) | |
1259 | 1516 | func putOneTknV2WithoutTakeFeeREADONLY (paymentAmountRaw,paymentAssetId) = { | |
1260 | - | let poolConfig = gpc() | |
1261 | - | let amId = poolConfig[idxAmAsId] | |
1262 | - | let prId = poolConfig[idxPrAsId] | |
1263 | - | let lpId = poolConfig[idxLPAsId] | |
1264 | - | let $t04238542489 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1265 | - | let lpAmount = $t04238542489._1 | |
1266 | - | let state = $t04238542489._2 | |
1267 | - | let feeAmount = $t04238542489._3 | |
1268 | - | let bonus = $t04238542489._4 | |
1517 | + | let $t05028650390 = calcPutOneTkn(paymentAmountRaw, paymentAssetId, "", "", false) | |
1518 | + | let lpAmount = $t05028650390._1 | |
1519 | + | let state = $t05028650390._2 | |
1520 | + | let feeAmount = $t05028650390._3 | |
1521 | + | let bonus = $t05028650390._4 | |
1269 | 1522 | $Tuple2(nil, $Tuple3(lpAmount, feeAmount, bonus)) | |
1270 | 1523 | } | |
1271 | 1524 | ||
1272 | 1525 | ||
1273 | 1526 | ||
1274 | 1527 | @Callable(i) | |
1275 | 1528 | func activate (amtAsStr,prAsStr) = if ((toString(i.caller) != toString(fca))) | |
1276 | 1529 | then throw("denied") | |
1277 | 1530 | else $Tuple2([StringEntry(aa(), amtAsStr), StringEntry(pa(), prAsStr)], "success") | |
1278 | 1531 | ||
1279 | 1532 | ||
1280 | 1533 | ||
1281 | 1534 | @Callable(i) | |
1282 | 1535 | func setS (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1283 | 1536 | then pd | |
1284 | 1537 | else [StringEntry(k, v)] | |
1285 | 1538 | ||
1286 | 1539 | ||
1287 | 1540 | ||
1288 | 1541 | @Callable(i) | |
1289 | 1542 | func setI (k,v) = if ((toString(i.caller) != strf(this, ada()))) | |
1290 | 1543 | then pd | |
1291 | 1544 | else [IntegerEntry(k, v)] | |
1292 | 1545 | ||
1293 | 1546 | ||
1294 | 1547 | ||
1295 | 1548 | @Callable(i) | |
1296 | 1549 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, gpc()) | |
1297 | 1550 | ||
1298 | 1551 | ||
1299 | 1552 | ||
1300 | 1553 | @Callable(i) | |
1301 | 1554 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1302 | 1555 | ||
1303 | 1556 | ||
1304 | 1557 | ||
1305 | 1558 | @Callable(i) | |
1306 | 1559 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1307 | 1560 | let pr = calcPrices(amAmt, prAmt, lpAmt) | |
1308 | 1561 | $Tuple2(nil, [toString(pr[0]), toString(pr[1]), toString(pr[2])]) | |
1309 | 1562 | } | |
1310 | 1563 | ||
1311 | 1564 | ||
1312 | 1565 | ||
1313 | 1566 | @Callable(i) | |
1314 | 1567 | func fromX18WrapperREADONLY (val,resScaleMult) = $Tuple2(nil, f1(parseBigIntValue(val), resScaleMult)) | |
1315 | 1568 | ||
1316 | 1569 | ||
1317 | 1570 | ||
1318 | 1571 | @Callable(i) | |
1319 | 1572 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(t1(origVal, origScaleMult))) | |
1320 | 1573 | ||
1321 | 1574 | ||
1322 | 1575 | ||
1323 | 1576 | @Callable(i) | |
1324 | 1577 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(cpbi(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1325 | 1578 | ||
1326 | 1579 | ||
1327 | 1580 | ||
1328 | 1581 | @Callable(i) | |
1329 | 1582 | 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, "")) | |
1330 | 1583 | ||
1331 | 1584 | ||
1332 | 1585 | ||
1333 | 1586 | @Callable(i) | |
1334 | 1587 | func estimateGetOperationWrapperREADONLY (txId58,pmtAsId,pmtLpAmt,usrAddr) = { | |
1335 | 1588 | let r = ego(txId58, pmtAsId, pmtLpAmt, addressFromStringValue(usrAddr)) | |
1336 | 1589 | $Tuple2(nil, $Tuple10(r._1, r._2, r._3, r._4, r._5, r._6, r._7, toString(r._8), r._9, r._10)) | |
1337 | 1590 | } | |
1338 | 1591 | ||
1339 | 1592 | ||
1340 | 1593 | @Verifier(tx) | |
1341 | 1594 | func verify () = { | |
1342 | 1595 | let targetPublicKey = match m() { | |
1343 | 1596 | case pk: ByteVector => | |
1344 | 1597 | pk | |
1345 | 1598 | case _: Unit => | |
1346 | 1599 | tx.senderPublicKey | |
1347 | 1600 | case _ => | |
1348 | 1601 | throw("Match error") | |
1349 | 1602 | } | |
1350 | 1603 | match tx { | |
1351 | 1604 | case order: Order => | |
1352 | 1605 | let matcherPub = mp() | |
1353 | - | let orderValid = | |
1606 | + | let orderValid = validateMatcherOrderAllowed(order) | |
1354 | 1607 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1355 | 1608 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1356 | 1609 | if (if (if (orderValid) | |
1357 | 1610 | then senderValid | |
1358 | 1611 | else false) | |
1359 | 1612 | then matcherValid | |
1360 | 1613 | else false) | |
1361 | 1614 | then true | |
1362 | 1615 | else toe(orderValid, senderValid, matcherValid) | |
1363 | 1616 | case s: SetScriptTransaction => | |
1364 | 1617 | let newHash = blake2b256(value(s.script)) | |
1365 | 1618 | let allowedHash = fromBase64String(value(getString(fca, keyAllowedLpStableScriptHash()))) | |
1366 | 1619 | let currentHash = scriptHash(this) | |
1367 | 1620 | if (if ((allowedHash == newHash)) | |
1368 | 1621 | then (currentHash != newHash) | |
1369 | 1622 | else false) | |
1370 | 1623 | then true | |
1371 | 1624 | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1372 | 1625 | case _ => | |
1373 | 1626 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1374 | 1627 | } | |
1375 | 1628 | } | |
1376 | 1629 |
github/deemru/w8io/026f985 167.97 ms ◑