tx · H6KaSV79q6U8himNxYJkhm3ivk6H51theadhdYM9zcEY 3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt: -0.03600000 Waves 2023.02.09 15:49 [2442107] smart account 3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt > SELF 0.00000000 Waves
{ "type": 13, "id": "H6KaSV79q6U8himNxYJkhm3ivk6H51theadhdYM9zcEY", "fee": 3600000, "feeAssetId": null, "timestamp": 1675946992259, "version": 1, "sender": "3MrULQRLc52GWrJF1tMcAm4M78fPe57o9Kt", "senderPublicKey": "Aig94J3pRT3J41eXw33rJrs67gTCECiMVRZrbtuoARit", "proofs": [ "AnPT5PB7QU5kmF42nshLZ8AFcTgXDZ8XfZktbPjsHYDFGHgBGT4qGCFaYE2ncbzt6wZwwdL4tTRK9i1kSZ3R8o1" ], "script": "base64:BgKBLggCEgMKAQgSABIECgIBBBIDCgEBEgQKAgEEEgQKAggBEgQKAggBEgQKAggBEgUKAwEIARIAEgQKAgEBEgMKAQESBQoDAQEBEgQKAggIEgASABIDCgEIEgUKAwEBARIECgIBARIECgIIARIECgIICBILCgkIAQECAQIIBAQSBgoECAgBCBIAEgMKAQESAwoBARIECgIIASIKbFBkZWNpbWFscyIGc2NhbGU4IgxzY2FsZThCaWdJbnQiB3NjYWxlMTgiCnplcm9CaWdJbnQiBGJpZzAiBGJpZzEiBGJpZzIiC3dhdmVzU3RyaW5nIgNTRVAiClBvb2xBY3RpdmUiD1Bvb2xQdXREaXNhYmxlZCITUG9vbE1hdGNoZXJEaXNhYmxlZCIMUG9vbFNodXRkb3duIg5pZHhQb29sQWRkcmVzcyINaWR4UG9vbFN0YXR1cyIQaWR4UG9vbExQQXNzZXRJZCINaWR4QW10QXNzZXRJZCIPaWR4UHJpY2VBc3NldElkIg5pZHhBbXRBc3NldERjbSIQaWR4UHJpY2VBc3NldERjbSIOaWR4SUFtdEFzc2V0SWQiEGlkeElQcmljZUFzc2V0SWQiDWlkeExQQXNzZXREY20iEmlkeFBvb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wMIBQJnSQlib2R5Qnl0ZXMJAJEDAggFAmdJBnByb29mcwAABQJnSwYEAmdOCQD2AwEJAQV2YWx1ZQEIBQJlWgZzY3JpcHQEAmdPCQDbBAEJAQV2YWx1ZQEJAJ0IAgUCYU4JAQJhegAEAmdQCQDxBwEFBHRoaXMDCQAAAgUCZ08FAmdOCQECIT0CBQJnUAUCZ04HCQD0AwMIBQJnSQlib2R5Qnl0ZXMJAJEDAggFAmdJBnByb29mcwAABQJnS0Hdfx8=", "chainId": 84, "height": 2442107, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AwWkqBbUqcToRCoKbiHUvxqQK2Ej8TARad4qRVXyJy2g Next: 5n6Lq1rt6PqMEEABZaqoKynoFU3mSPn93aD3HhVis3yQ Diff:
Old | New | Differences | |
---|---|---|---|
84 | 84 | else val | |
85 | 85 | ||
86 | 86 | ||
87 | - | func swapContract () = "%s__swapContract" | |
88 | - | ||
89 | - | ||
90 | 87 | func fc () = "%s__factoryContract" | |
91 | 88 | ||
92 | 89 | ||
114 | 111 | func pa () = "%s__priceAsset" | |
115 | 112 | ||
116 | 113 | ||
114 | + | let keyFee = "%s__fee" | |
115 | + | ||
116 | + | let feeDefault = fraction(10, scale8, 10000) | |
117 | + | ||
118 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
119 | + | ||
120 | + | let keyKLp = makeString(["%s", "kLp"], SEP) | |
121 | + | ||
122 | + | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
123 | + | ||
124 | + | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
125 | + | ||
126 | + | let kLpRefreshDelayDefault = 30 | |
127 | + | ||
128 | + | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
129 | + | ||
117 | 130 | func keyFactoryConfig () = "%s__factoryConfig" | |
118 | 131 | ||
119 | 132 | ||
140 | 153 | ||
141 | 154 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
142 | 155 | ||
143 | - | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
156 | + | func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
144 | 157 | ||
145 | 158 | ||
146 | 159 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
150 | 163 | ||
151 | 164 | ||
152 | 165 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
166 | + | ||
167 | + | ||
168 | + | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
153 | 169 | ||
154 | 170 | ||
155 | 171 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
200 | 216 | ||
201 | 217 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
202 | 218 | ||
203 | - | let $ | |
219 | + | let $t084088574 = poolConfigParsed | |
204 | 220 | ||
205 | - | let cfgPoolAddress = $ | |
221 | + | let cfgPoolAddress = $t084088574._1 | |
206 | 222 | ||
207 | - | let cfgPoolStatus = $ | |
223 | + | let cfgPoolStatus = $t084088574._2 | |
208 | 224 | ||
209 | - | let cfgLpAssetId = $ | |
225 | + | let cfgLpAssetId = $t084088574._3 | |
210 | 226 | ||
211 | - | let cfgAmountAssetId = $ | |
227 | + | let cfgAmountAssetId = $t084088574._4 | |
212 | 228 | ||
213 | - | let cfgPriceAssetId = $ | |
229 | + | let cfgPriceAssetId = $t084088574._5 | |
214 | 230 | ||
215 | - | let cfgAmountAssetDecimals = $ | |
231 | + | let cfgAmountAssetDecimals = $t084088574._6 | |
216 | 232 | ||
217 | - | let cfgPriceAssetDecimals = $ | |
233 | + | let cfgPriceAssetDecimals = $t084088574._7 | |
218 | 234 | ||
219 | 235 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
220 | 236 | ||
235 | 251 | ||
236 | 252 | ||
237 | 253 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
254 | + | ||
255 | + | ||
256 | + | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
238 | 257 | ||
239 | 258 | ||
240 | 259 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
286 | 305 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
287 | 306 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
288 | 307 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
289 | - | let outAmAmt = | |
290 | - | let outPrAmt = | |
308 | + | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
309 | + | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
291 | 310 | let state = if ((txId58 == "")) | |
292 | 311 | then nil | |
293 | 312 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
346 | 365 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
347 | 366 | else { | |
348 | 367 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
349 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, | |
350 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, | |
368 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
369 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
351 | 370 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
352 | 371 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
353 | 372 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
354 | 373 | let expAmtAssetAmtX18 = expectedAmts._1 | |
355 | 374 | let expPriceAssetAmtX18 = expectedAmts._2 | |
356 | - | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
357 | - | $Tuple5( | |
375 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
376 | + | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
358 | 377 | } | |
359 | 378 | } | |
360 | 379 | let calcLpAmt = res._1 | |
377 | 396 | } | |
378 | 397 | ||
379 | 398 | ||
399 | + | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
400 | + | let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)) | |
401 | + | let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals)) | |
402 | + | let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
403 | + | if ((lpEmission == big0)) | |
404 | + | then big0 | |
405 | + | else updatedKLp | |
406 | + | } | |
407 | + | ||
408 | + | ||
409 | + | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
410 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
411 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
412 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
413 | + | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
414 | + | currentKLp | |
415 | + | } | |
416 | + | ||
417 | + | ||
418 | + | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
419 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
420 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
421 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
422 | + | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
423 | + | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
424 | + | $Tuple2(actions, updatedKLp) | |
425 | + | } | |
426 | + | ||
427 | + | ||
428 | + | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
429 | + | then true | |
430 | + | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
431 | + | ||
432 | + | ||
380 | 433 | func validateMatcherOrderAllowed (order) = { | |
381 | - | let cfg = getPoolConfig() | |
382 | - | let amtAssetId = cfg[idxAmtAssetId] | |
383 | - | let priceAssetId = cfg[idxPriceAssetId] | |
384 | - | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
385 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
386 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
387 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
388 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
389 | - | let curPriceX18 = if ((order.orderType == Buy)) | |
390 | - | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
391 | - | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
392 | - | let curPrice = fromX18(curPriceX18, scale8) | |
434 | + | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
435 | + | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
436 | + | let amountAssetAmount = order.amount | |
437 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
438 | + | let $t02148021692 = if ((order.orderType == Buy)) | |
439 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
440 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
441 | + | let amountAssetBalanceDelta = $t02148021692._1 | |
442 | + | let priceAssetBalanceDelta = $t02148021692._2 | |
393 | 443 | if (if (if (isGlobalShutdown()) | |
394 | 444 | then true | |
395 | - | else ( | |
445 | + | else (cfgPoolStatus == PoolMatcherDisabled)) | |
396 | 446 | then true | |
397 | - | else ( | |
447 | + | else (cfgPoolStatus == PoolShutdown)) | |
398 | 448 | then throw("Exchange operations disabled") | |
399 | - | else { | |
400 | - | let orderAmtAsset = order.assetPair.amountAsset | |
401 | - | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
402 | - | then "WAVES" | |
403 | - | else toBase58String(value(orderAmtAsset)) | |
404 | - | let orderPriceAsset = order.assetPair.priceAsset | |
405 | - | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
406 | - | then "WAVES" | |
407 | - | else toBase58String(value(orderPriceAsset)) | |
408 | - | if (if ((orderAmtAssetStr != amtAssetId)) | |
409 | - | then true | |
410 | - | else (orderPriceAssetStr != priceAssetId)) | |
411 | - | then throw("Wrong order assets.") | |
412 | - | else { | |
413 | - | let orderPrice = order.price | |
414 | - | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
415 | - | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
416 | - | let isOrderPriceValid = if ((order.orderType == Buy)) | |
417 | - | then (curPrice >= castedOrderPrice) | |
418 | - | else (castedOrderPrice >= curPrice) | |
419 | - | true | |
420 | - | } | |
421 | - | } | |
449 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
450 | + | then true | |
451 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
452 | + | then throw("Wrong order assets.") | |
453 | + | else { | |
454 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
455 | + | let $t02213222232 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
456 | + | let unusedActions = $t02213222232._1 | |
457 | + | let kLpNew = $t02213222232._2 | |
458 | + | let isOrderValid = (kLpNew >= kLp) | |
459 | + | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
460 | + | $Tuple2(isOrderValid, info) | |
461 | + | } | |
422 | 462 | } | |
423 | 463 | ||
424 | 464 | ||
493 | 533 | else if ((paymentAssetId == cfgPriceAssetId)) | |
494 | 534 | then false | |
495 | 535 | else throwErr("invalid asset") | |
496 | - | let $ | |
536 | + | let $t02534525638 = if (isEval) | |
497 | 537 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
498 | 538 | else if (paymentInAmountAsset) | |
499 | 539 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
500 | 540 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
501 | - | let amountBalanceOld = $ | |
502 | - | let priceBalanceOld = $ | |
503 | - | let $ | |
541 | + | let amountBalanceOld = $t02534525638._1 | |
542 | + | let priceBalanceOld = $t02534525638._2 | |
543 | + | let $t02564225791 = if (paymentInAmountAsset) | |
504 | 544 | then $Tuple2(paymentAmountRaw, 0) | |
505 | 545 | else $Tuple2(0, paymentAmountRaw) | |
506 | - | let amountAssetAmountRaw = $ | |
507 | - | let priceAssetAmountRaw = $ | |
546 | + | let amountAssetAmountRaw = $t02564225791._1 | |
547 | + | let priceAssetAmountRaw = $t02564225791._2 | |
508 | 548 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
509 | 549 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
510 | - | let $ | |
511 | - | let paymentAmount = $ | |
512 | - | let feeAmount = $ | |
550 | + | let $t02592325987 = takeFee(paymentAmountRaw, inFee) | |
551 | + | let paymentAmount = $t02592325987._1 | |
552 | + | let feeAmount = $t02592325987._2 | |
513 | 553 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
514 | 554 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
515 | 555 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
532 | 572 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
533 | 573 | let priceOld = fromX18(priceOldX18, scale8) | |
534 | 574 | let loss = { | |
535 | - | let $ | |
575 | + | let $t02766827835 = if (paymentInAmountAsset) | |
536 | 576 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
537 | 577 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
538 | - | let amount = $ | |
539 | - | let balance = $ | |
578 | + | let amount = $t02766827835._1 | |
579 | + | let balance = $t02766827835._2 | |
540 | 580 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
541 | 581 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
542 | 582 | } | |
543 | - | $ | |
583 | + | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
544 | 584 | } | |
545 | 585 | else throw("Strict value is not equal to itself.") | |
546 | 586 | } | |
548 | 588 | ||
549 | 589 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
550 | 590 | let isEval = (txId == unit) | |
591 | + | let cfg = getPoolConfig() | |
592 | + | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
593 | + | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
551 | 594 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
552 | 595 | then true | |
553 | 596 | else throwErr("invalid lp asset")] | |
561 | 604 | let balanceBigInt = if (outInAmountAsset) | |
562 | 605 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
563 | 606 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
607 | + | let outInAmountAssetDecimals = if (outInAmountAsset) | |
608 | + | then amtAssetDcm | |
609 | + | else priceAssetDcm | |
564 | 610 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
565 | 611 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
566 | 612 | let outBalance = if (outInAmountAsset) | |
570 | 616 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
571 | 617 | let redeemedBigInt = toBigInt(paymentAmount) | |
572 | 618 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
573 | - | let $ | |
574 | - | let totalAmount = $ | |
575 | - | let feeAmount = $ | |
576 | - | let $ | |
619 | + | let $t02991329969 = takeFee(amountRaw, outFee) | |
620 | + | let totalAmount = $t02991329969._1 | |
621 | + | let feeAmount = $t02991329969._2 | |
622 | + | let $t02997330199 = if (outInAmountAsset) | |
577 | 623 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
578 | 624 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
579 | - | let outAmAmount = $ | |
580 | - | let outPrAmount = $ | |
581 | - | let amBalanceNew = $ | |
582 | - | let prBalanceNew = $ | |
625 | + | let outAmAmount = $t02997330199._1 | |
626 | + | let outPrAmount = $t02997330199._2 | |
627 | + | let amBalanceNew = $t02997330199._3 | |
628 | + | let prBalanceNew = $t02997330199._4 | |
583 | 629 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
584 | 630 | let priceNew = fromX18(priceNewX18, scale8) | |
585 | 631 | let commonState = if (isEval) | |
591 | 637 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
592 | 638 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
593 | 639 | } | |
594 | - | $ | |
640 | + | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
595 | 641 | } | |
596 | 642 | else throw("Strict value is not equal to itself.") | |
597 | 643 | } | |
645 | 691 | ||
646 | 692 | ||
647 | 693 | @Callable(i) | |
648 | - | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = { | |
649 | - | let $t02879829103 = if ((isReverse == false)) | |
650 | - | then { | |
651 | - | let assetOut = getStringOrFail(this, pa()) | |
652 | - | let assetIn = getStringOrFail(this, aa()) | |
653 | - | $Tuple2(assetOut, assetIn) | |
654 | - | } | |
655 | - | else { | |
656 | - | let assetOut = getStringOrFail(this, aa()) | |
657 | - | let assetIn = getStringOrFail(this, pa()) | |
658 | - | $Tuple2(assetOut, assetIn) | |
659 | - | } | |
660 | - | let assetOut = $t02879829103._1 | |
661 | - | let assetIn = $t02879829103._2 | |
662 | - | let poolAssetInBalance = getAccBalance(assetIn) | |
663 | - | let poolAssetOutBalance = getAccBalance(assetOut) | |
664 | - | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
665 | - | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
666 | - | let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
667 | - | let checkK = if ((newK >= oldK)) | |
668 | - | then true | |
669 | - | else throw("new K is fewer error") | |
670 | - | if ((checkK == checkK)) | |
671 | - | then $Tuple2(nil, amountOut) | |
672 | - | else throw("Strict value is not equal to itself.") | |
673 | - | } | |
674 | - | ||
675 | - | ||
676 | - | ||
677 | - | @Callable(i) | |
678 | - | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = { | |
679 | - | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
680 | - | then true | |
681 | - | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(getStringOrFail(this, swapContract())))) | |
682 | - | then true | |
683 | - | else throwErr("Permission denied")] | |
684 | - | if ((checks == checks)) | |
685 | - | then { | |
686 | - | let pmt = value(i.payments[0]) | |
687 | - | let assetIn = if ((pmt.assetId == unit)) | |
688 | - | then toBase58String(toBytes("WAVES")) | |
689 | - | else toBase58String(value(pmt.assetId)) | |
690 | - | let assetOut = if ((isReverse == false)) | |
691 | - | then getStringOrFail(this, pa()) | |
692 | - | else getStringOrFail(this, aa()) | |
693 | - | let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
694 | - | let poolAssetOutBalance = getAccBalance(assetOut) | |
695 | - | let amountOut = ((poolAssetOutBalance * cleanAmountIn) / (poolAssetInBalance + cleanAmountIn)) | |
696 | - | let oldK = (poolAssetInBalance * poolAssetOutBalance) | |
697 | - | let newK = (getAccBalance(assetIn) * (getAccBalance(assetOut) - amountOut)) | |
698 | - | let checkK = if ((newK >= oldK)) | |
699 | - | then true | |
700 | - | else throw("new K is fewer error") | |
701 | - | if ((checkK == checkK)) | |
702 | - | then { | |
703 | - | let checkMin = if ((amountOut >= amountOutMin)) | |
704 | - | then true | |
705 | - | else throw("Exchange result is fewer coins than expected") | |
706 | - | if ((checkMin == checkMin)) | |
707 | - | then [ScriptTransfer(addressFromStringValue(addressTo), amountOut, if ((assetIn == "WAVES")) | |
708 | - | then unit | |
709 | - | else fromBase58String(assetOut))] | |
710 | - | else throw("Strict value is not equal to itself.") | |
711 | - | } | |
712 | - | else throw("Strict value is not equal to itself.") | |
713 | - | } | |
714 | - | else throw("Strict value is not equal to itself.") | |
715 | - | } | |
716 | - | ||
717 | - | ||
718 | - | ||
719 | - | @Callable(i) | |
720 | 694 | func setManager (pendingManagerPublicKey) = { | |
721 | 695 | let checkCaller = mustManager(i) | |
722 | 696 | if ((checkCaller == checkCaller)) | |
763 | 737 | let prDiff = estPut._11 | |
764 | 738 | let amId = estPut._12 | |
765 | 739 | let prId = estPut._13 | |
766 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
767 | - | if ((emitInv == emitInv)) | |
740 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
741 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
742 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
743 | + | if ((currentKLp == currentKLp)) | |
768 | 744 | then { | |
769 | - | let emitInvLegacy = match emitInv { | |
770 | - | case legacyFactoryContract: Address => | |
771 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
772 | - | case _ => | |
773 | - | unit | |
774 | - | } | |
775 | - | if ((emitInvLegacy == emitInvLegacy)) | |
745 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
746 | + | if ((emitInv == emitInv)) | |
776 | 747 | then { | |
777 | - | let slippageAInv = if ((amDiff > 0)) | |
778 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
779 | - | else nil | |
780 | - | if ((slippageAInv == slippageAInv)) | |
748 | + | let emitInvLegacy = match emitInv { | |
749 | + | case legacyFactoryContract: Address => | |
750 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
751 | + | case _ => | |
752 | + | unit | |
753 | + | } | |
754 | + | if ((emitInvLegacy == emitInvLegacy)) | |
781 | 755 | then { | |
782 | - | let | |
783 | - | then invoke(slippageContract, "put", nil, [AttachedPayment( | |
756 | + | let slippageAInv = if ((amDiff > 0)) | |
757 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
784 | 758 | else nil | |
785 | - | if (( | |
759 | + | if ((slippageAInv == slippageAInv)) | |
786 | 760 | then { | |
787 | - | let lpTransfer = if (shouldAutoStake) | |
761 | + | let slippagePInv = if ((prDiff > 0)) | |
762 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
763 | + | else nil | |
764 | + | if ((slippagePInv == slippagePInv)) | |
788 | 765 | then { | |
789 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
790 | - | if ((slpStakeInv == slpStakeInv)) | |
791 | - | then nil | |
766 | + | let lpTransfer = if (shouldAutoStake) | |
767 | + | then { | |
768 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
769 | + | if ((slpStakeInv == slpStakeInv)) | |
770 | + | then nil | |
771 | + | else throw("Strict value is not equal to itself.") | |
772 | + | } | |
773 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
774 | + | let $t03472735189 = refreshKLpInternal(0, 0, 0) | |
775 | + | if (($t03472735189 == $t03472735189)) | |
776 | + | then { | |
777 | + | let updatedKLp = $t03472735189._2 | |
778 | + | let refreshKLpActions = $t03472735189._1 | |
779 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
780 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
781 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
782 | + | else throw("Strict value is not equal to itself.") | |
783 | + | } | |
792 | 784 | else throw("Strict value is not equal to itself.") | |
793 | 785 | } | |
794 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
795 | - | (state ++ lpTransfer) | |
786 | + | else throw("Strict value is not equal to itself.") | |
796 | 787 | } | |
797 | 788 | else throw("Strict value is not equal to itself.") | |
798 | 789 | } | |
810 | 801 | then throw("Invalid value passed") | |
811 | 802 | else { | |
812 | 803 | let estPut = commonPut(i, maxSlippage, false) | |
813 | - | estPut._9 | |
804 | + | let state = estPut._9 | |
805 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
806 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
807 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
808 | + | if ((currentKLp == currentKLp)) | |
809 | + | then { | |
810 | + | let $t03575135816 = refreshKLpInternal(0, 0, 0) | |
811 | + | let refreshKLpActions = $t03575135816._1 | |
812 | + | let updatedKLp = $t03575135816._2 | |
813 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
814 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
815 | + | then (state ++ refreshKLpActions) | |
816 | + | else throw("Strict value is not equal to itself.") | |
817 | + | } | |
818 | + | else throw("Strict value is not equal to itself.") | |
814 | 819 | } | |
815 | 820 | ||
816 | 821 | ||
842 | 847 | let payment = i.payments[0] | |
843 | 848 | let paymentAssetId = payment.assetId | |
844 | 849 | let paymentAmountRaw = payment.amount | |
845 | - | let userAddress = i.caller | |
846 | - | let txId = i.transactionId | |
847 | - | let $t03429434424 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
848 | - | if (($t03429434424 == $t03429434424)) | |
850 | + | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
851 | + | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
852 | + | else if ((paymentAssetId == cfgPriceAssetId)) | |
853 | + | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
854 | + | else throwErr("payment asset is not supported") | |
855 | + | if ((currentKLp == currentKLp)) | |
849 | 856 | then { | |
850 | - | let bonus = $t03429434424._4 | |
851 | - | let feeAmount = $t03429434424._3 | |
852 | - | let commonState = $t03429434424._2 | |
853 | - | let emitAmountEstimated = $t03429434424._1 | |
854 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
855 | - | then (minOutAmount > emitAmountEstimated) | |
856 | - | else false) | |
857 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
858 | - | else emitAmountEstimated | |
859 | - | let emitInv = emit(emitAmount) | |
860 | - | if ((emitInv == emitInv)) | |
857 | + | let userAddress = i.caller | |
858 | + | let txId = i.transactionId | |
859 | + | let $t03700437156 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
860 | + | if (($t03700437156 == $t03700437156)) | |
861 | 861 | then { | |
862 | - | let lpTransfer = if (autoStake) | |
862 | + | let paymentInAmountAsset = $t03700437156._5 | |
863 | + | let bonus = $t03700437156._4 | |
864 | + | let feeAmount = $t03700437156._3 | |
865 | + | let commonState = $t03700437156._2 | |
866 | + | let emitAmountEstimated = $t03700437156._1 | |
867 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
868 | + | then (minOutAmount > emitAmountEstimated) | |
869 | + | else false) | |
870 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
871 | + | else emitAmountEstimated | |
872 | + | let emitInv = emit(emitAmount) | |
873 | + | if ((emitInv == emitInv)) | |
863 | 874 | then { | |
864 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
865 | - | if ((stakeInv == stakeInv)) | |
866 | - | then nil | |
875 | + | let lpTransfer = if (autoStake) | |
876 | + | then { | |
877 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
878 | + | if ((stakeInv == stakeInv)) | |
879 | + | then nil | |
880 | + | else throw("Strict value is not equal to itself.") | |
881 | + | } | |
882 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
883 | + | let sendFee = if ((feeAmount > 0)) | |
884 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
885 | + | else nil | |
886 | + | let $t03774237939 = if ((this == feeCollectorAddress)) | |
887 | + | then $Tuple2(0, 0) | |
888 | + | else if (paymentInAmountAsset) | |
889 | + | then $Tuple2(-(feeAmount), 0) | |
890 | + | else $Tuple2(0, -(feeAmount)) | |
891 | + | let amountAssetBalanceDelta = $t03774237939._1 | |
892 | + | let priceAssetBalanceDelta = $t03774237939._2 | |
893 | + | let $t03794238050 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
894 | + | let refreshKLpActions = $t03794238050._1 | |
895 | + | let updatedKLp = $t03794238050._2 | |
896 | + | let kLp = value(getString(keyKLp)) | |
897 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
898 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
899 | + | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
867 | 900 | else throw("Strict value is not equal to itself.") | |
868 | 901 | } | |
869 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
870 | - | let sendFee = if ((feeAmount > 0)) | |
871 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
872 | - | else nil | |
873 | - | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
902 | + | else throw("Strict value is not equal to itself.") | |
874 | 903 | } | |
875 | 904 | else throw("Strict value is not equal to itself.") | |
876 | 905 | } | |
883 | 912 | ||
884 | 913 | @Callable(i) | |
885 | 914 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
886 | - | let $t03515335288 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
887 | - | let emitAmountEstimated = $t03515335288._1 | |
888 | - | let commonState = $t03515335288._2 | |
889 | - | let feeAmount = $t03515335288._3 | |
890 | - | let bonus = $t03515335288._4 | |
915 | + | let $t03835638513 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
916 | + | let emitAmountEstimated = $t03835638513._1 | |
917 | + | let commonState = $t03835638513._2 | |
918 | + | let feeAmount = $t03835638513._3 | |
919 | + | let bonus = $t03835638513._4 | |
920 | + | let paymentInAmountAsset = $t03835638513._5 | |
891 | 921 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
892 | 922 | } | |
893 | 923 | ||
919 | 949 | let payment = i.payments[0] | |
920 | 950 | let paymentAssetId = payment.assetId | |
921 | 951 | let paymentAmount = payment.amount | |
922 | - | let userAddress = i.caller | |
923 | - | let txId = i.transactionId | |
924 | - | let $t03609336228 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
925 | - | if (($t03609336228 == $t03609336228)) | |
952 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
953 | + | if ((currentKLp == currentKLp)) | |
926 | 954 | then { | |
927 | - | let bonus = $t03609336228._4 | |
928 | - | let feeAmount = $t03609336228._3 | |
929 | - | let commonState = $t03609336228._2 | |
930 | - | let amountEstimated = $t03609336228._1 | |
931 | - | let amount = if (if ((minOutAmount > 0)) | |
932 | - | then (minOutAmount > amountEstimated) | |
933 | - | else false) | |
934 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
935 | - | else amountEstimated | |
936 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
937 | - | if ((burnInv == burnInv)) | |
955 | + | let userAddress = i.caller | |
956 | + | let txId = i.transactionId | |
957 | + | let $t03939839551 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
958 | + | if (($t03939839551 == $t03939839551)) | |
938 | 959 | then { | |
939 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
940 | - | let sendFee = if ((feeAmount > 0)) | |
941 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
942 | - | else nil | |
943 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
960 | + | let outInAmountAsset = $t03939839551._5 | |
961 | + | let bonus = $t03939839551._4 | |
962 | + | let feeAmount = $t03939839551._3 | |
963 | + | let commonState = $t03939839551._2 | |
964 | + | let amountEstimated = $t03939839551._1 | |
965 | + | let amount = if (if ((minOutAmount > 0)) | |
966 | + | then (minOutAmount > amountEstimated) | |
967 | + | else false) | |
968 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
969 | + | else amountEstimated | |
970 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
971 | + | if ((burnInv == burnInv)) | |
972 | + | then { | |
973 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
974 | + | let sendFee = if ((feeAmount > 0)) | |
975 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
976 | + | else nil | |
977 | + | let $t04005140298 = { | |
978 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
979 | + | then 0 | |
980 | + | else feeAmount | |
981 | + | if (outInAmountAsset) | |
982 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
983 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
984 | + | } | |
985 | + | let amountAssetBalanceDelta = $t04005140298._1 | |
986 | + | let priceAssetBalanceDelta = $t04005140298._2 | |
987 | + | let $t04030140409 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
988 | + | let refreshKLpActions = $t04030140409._1 | |
989 | + | let updatedKLp = $t04030140409._2 | |
990 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
991 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
992 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
993 | + | else throw("Strict value is not equal to itself.") | |
994 | + | } | |
995 | + | else throw("Strict value is not equal to itself.") | |
944 | 996 | } | |
945 | 997 | else throw("Strict value is not equal to itself.") | |
946 | 998 | } | |
953 | 1005 | ||
954 | 1006 | @Callable(i) | |
955 | 1007 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
956 | - | let $t03686337001 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
957 | - | let amountEstimated = $t03686337001._1 | |
958 | - | let commonState = $t03686337001._2 | |
959 | - | let feeAmount = $t03686337001._3 | |
960 | - | let bonus = $t03686337001._4 | |
1008 | + | let $t04066640822 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1009 | + | let amountEstimated = $t04066640822._1 | |
1010 | + | let commonState = $t04066640822._2 | |
1011 | + | let feeAmount = $t04066640822._3 | |
1012 | + | let bonus = $t04066640822._4 | |
1013 | + | let outInAmountAsset = $t04066640822._5 | |
961 | 1014 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
962 | 1015 | } | |
963 | 1016 | ||
988 | 1041 | let outAssetId = parseAssetId(outAssetIdStr) | |
989 | 1042 | let userAddress = i.caller | |
990 | 1043 | let txId = i.transactionId | |
991 | - | let | |
992 | - | if (( | |
1044 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1045 | + | if ((currentKLp == currentKLp)) | |
993 | 1046 | then { | |
994 | - | let | |
995 | - | if (( | |
1047 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1048 | + | if ((unstakeInv == unstakeInv)) | |
996 | 1049 | then { | |
997 | - | let bonus = $t03782637959._4 | |
998 | - | let feeAmount = $t03782637959._3 | |
999 | - | let commonState = $t03782637959._2 | |
1000 | - | let amountEstimated = $t03782637959._1 | |
1001 | - | let amount = if (if ((minOutAmount > 0)) | |
1002 | - | then (minOutAmount > amountEstimated) | |
1003 | - | else false) | |
1004 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1005 | - | else amountEstimated | |
1006 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1007 | - | if ((burnInv == burnInv)) | |
1050 | + | let $t04172741878 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1051 | + | if (($t04172741878 == $t04172741878)) | |
1008 | 1052 | then { | |
1009 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1010 | - | let sendFee = if ((feeAmount > 0)) | |
1011 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1012 | - | else nil | |
1013 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
1053 | + | let outInAmountAsset = $t04172741878._5 | |
1054 | + | let bonus = $t04172741878._4 | |
1055 | + | let feeAmount = $t04172741878._3 | |
1056 | + | let commonState = $t04172741878._2 | |
1057 | + | let amountEstimated = $t04172741878._1 | |
1058 | + | let amount = if (if ((minOutAmount > 0)) | |
1059 | + | then (minOutAmount > amountEstimated) | |
1060 | + | else false) | |
1061 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1062 | + | else amountEstimated | |
1063 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1064 | + | if ((burnInv == burnInv)) | |
1065 | + | then { | |
1066 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1067 | + | let sendFee = if ((feeAmount > 0)) | |
1068 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1069 | + | else nil | |
1070 | + | let $t04237342620 = { | |
1071 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1072 | + | then 0 | |
1073 | + | else feeAmount | |
1074 | + | if (outInAmountAsset) | |
1075 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1076 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1077 | + | } | |
1078 | + | let amountAssetBalanceDelta = $t04237342620._1 | |
1079 | + | let priceAssetBalanceDelta = $t04237342620._2 | |
1080 | + | let $t04262342731 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1081 | + | let refreshKLpActions = $t04262342731._1 | |
1082 | + | let updatedKLp = $t04262342731._2 | |
1083 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1084 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1085 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1086 | + | else throw("Strict value is not equal to itself.") | |
1087 | + | } | |
1088 | + | else throw("Strict value is not equal to itself.") | |
1014 | 1089 | } | |
1015 | 1090 | else throw("Strict value is not equal to itself.") | |
1016 | 1091 | } | |
1031 | 1106 | let pmtAmt = res._3 | |
1032 | 1107 | let pmtAssetId = res._4 | |
1033 | 1108 | let state = res._5 | |
1034 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1035 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1036 | - | then state | |
1109 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1110 | + | if ((currentKLp == currentKLp)) | |
1111 | + | then { | |
1112 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1113 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1114 | + | then { | |
1115 | + | let $t04367743759 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1116 | + | let refreshKLpActions = $t04367743759._1 | |
1117 | + | let updatedKLp = $t04367743759._2 | |
1118 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1119 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1120 | + | then (state ++ refreshKLpActions) | |
1121 | + | else throw("Strict value is not equal to itself.") | |
1122 | + | } | |
1123 | + | else throw("Strict value is not equal to itself.") | |
1124 | + | } | |
1037 | 1125 | else throw("Strict value is not equal to itself.") | |
1038 | 1126 | } | |
1039 | 1127 | ||
1052 | 1140 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1053 | 1141 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1054 | 1142 | else { | |
1055 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1056 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1057 | - | then state | |
1143 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1144 | + | if ((currentKLp == currentKLp)) | |
1145 | + | then { | |
1146 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1147 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1148 | + | then { | |
1149 | + | let $t04470844789 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1150 | + | let refreshKLpActions = $t04470844789._1 | |
1151 | + | let updatedKLp = $t04470844789._2 | |
1152 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1153 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1154 | + | then (state ++ refreshKLpActions) | |
1155 | + | else throw("Strict value is not equal to itself.") | |
1156 | + | } | |
1157 | + | else throw("Strict value is not equal to itself.") | |
1158 | + | } | |
1058 | 1159 | else throw("Strict value is not equal to itself.") | |
1059 | 1160 | } | |
1060 | 1161 | } | |
1070 | 1171 | then { | |
1071 | 1172 | let cfg = getPoolConfig() | |
1072 | 1173 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1073 | - | let | |
1074 | - | if (( | |
1174 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1175 | + | if ((currentKLp == currentKLp)) | |
1075 | 1176 | then { | |
1076 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1077 | - | let poolStatus = parseIntValue(res._9) | |
1078 | - | let state = res._10 | |
1079 | - | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1080 | - | then true | |
1081 | - | else (poolStatus == PoolShutdown)) | |
1082 | - | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1083 | - | else true | |
1084 | - | if ((checkPoolStatus == checkPoolStatus)) | |
1177 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1178 | + | if ((unstakeInv == unstakeInv)) | |
1085 | 1179 | then { | |
1086 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1087 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1088 | - | then state | |
1180 | + | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1181 | + | let outAmAmt = res._1 | |
1182 | + | let outPrAmt = res._2 | |
1183 | + | let poolStatus = parseIntValue(res._9) | |
1184 | + | let state = res._10 | |
1185 | + | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1186 | + | then true | |
1187 | + | else (poolStatus == PoolShutdown)) | |
1188 | + | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1189 | + | else true | |
1190 | + | if ((checkPoolStatus == checkPoolStatus)) | |
1191 | + | then { | |
1192 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1193 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1194 | + | then { | |
1195 | + | let $t04591545996 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1196 | + | let refreshKLpActions = $t04591545996._1 | |
1197 | + | let updatedKLp = $t04591545996._2 | |
1198 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1199 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1200 | + | then (state ++ refreshKLpActions) | |
1201 | + | else throw("Strict value is not equal to itself.") | |
1202 | + | } | |
1203 | + | else throw("Strict value is not equal to itself.") | |
1204 | + | } | |
1089 | 1205 | else throw("Strict value is not equal to itself.") | |
1090 | 1206 | } | |
1091 | 1207 | else throw("Strict value is not equal to itself.") | |
1109 | 1225 | else throw("no payments are expected")] | |
1110 | 1226 | if ((checks == checks)) | |
1111 | 1227 | then { | |
1112 | - | let | |
1113 | - | if (( | |
1228 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1229 | + | if ((currentKLp == currentKLp)) | |
1114 | 1230 | then { | |
1115 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1116 | - | let outAmAmt = res._1 | |
1117 | - | let outPrAmt = res._2 | |
1118 | - | let state = res._10 | |
1119 | - | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1120 | - | then true | |
1121 | - | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1122 | - | then true | |
1123 | - | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1124 | - | if ((checkAmounts == checkAmounts)) | |
1231 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1232 | + | if ((unstakeInv == unstakeInv)) | |
1125 | 1233 | then { | |
1126 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1127 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1128 | - | then state | |
1234 | + | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1235 | + | let outAmAmt = res._1 | |
1236 | + | let outPrAmt = res._2 | |
1237 | + | let state = res._10 | |
1238 | + | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1239 | + | then true | |
1240 | + | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1241 | + | then true | |
1242 | + | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1243 | + | if ((checkAmounts == checkAmounts)) | |
1244 | + | then { | |
1245 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1246 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1247 | + | then { | |
1248 | + | let $t04729147372 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1249 | + | let refreshKLpActions = $t04729147372._1 | |
1250 | + | let updatedKLp = $t04729147372._2 | |
1251 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1252 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1253 | + | then (state ++ refreshKLpActions) | |
1254 | + | else throw("Strict value is not equal to itself.") | |
1255 | + | } | |
1256 | + | else throw("Strict value is not equal to itself.") | |
1257 | + | } | |
1129 | 1258 | else throw("Strict value is not equal to itself.") | |
1130 | 1259 | } | |
1131 | 1260 | else throw("Strict value is not equal to itself.") | |
1141 | 1270 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1142 | 1271 | then throw("permissions denied") | |
1143 | 1272 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1273 | + | ||
1274 | + | ||
1275 | + | ||
1276 | + | @Callable(i) | |
1277 | + | func refreshKLp () = { | |
1278 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1279 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1280 | + | then unit | |
1281 | + | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1282 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1283 | + | then { | |
1284 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1285 | + | let $t04855948623 = refreshKLpInternal(0, 0, 0) | |
1286 | + | let kLpUpdateActions = $t04855948623._1 | |
1287 | + | let updatedKLp = $t04855948623._2 | |
1288 | + | let actions = if ((kLp != updatedKLp)) | |
1289 | + | then kLpUpdateActions | |
1290 | + | else throwErr("nothing to refresh") | |
1291 | + | $Tuple2(actions, toString(updatedKLp)) | |
1292 | + | } | |
1293 | + | else throw("Strict value is not equal to itself.") | |
1294 | + | } | |
1144 | 1295 | ||
1145 | 1296 | ||
1146 | 1297 | ||
1308 | 1459 | match tx { | |
1309 | 1460 | case order: Order => | |
1310 | 1461 | let matcherPub = getMatcherPubOrFail() | |
1311 | - | let orderValid = validateMatcherOrderAllowed(order) | |
1462 | + | let $t05728557354 = validateMatcherOrderAllowed(order) | |
1463 | + | let orderValid = $t05728557354._1 | |
1464 | + | let orderValidInfo = $t05728557354._2 | |
1312 | 1465 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1313 | 1466 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1314 | 1467 | if (if (if (orderValid) | |
1317 | 1470 | then matcherValid | |
1318 | 1471 | else false) | |
1319 | 1472 | then true | |
1320 | - | else throwOrderError(orderValid, senderValid, matcherValid) | |
1473 | + | else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid) | |
1321 | 1474 | case s: SetScriptTransaction => | |
1322 | - | let newHash = blake2b256(value(s.script)) | |
1323 | - | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1324 | - | let currentHash = scriptHash(this) | |
1325 | - | if (if ((allowedHash == newHash)) | |
1326 | - | then (currentHash != newHash) | |
1327 | - | else false) | |
1475 | + | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1328 | 1476 | then true | |
1329 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1477 | + | else { | |
1478 | + | let newHash = blake2b256(value(s.script)) | |
1479 | + | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1480 | + | let currentHash = scriptHash(this) | |
1481 | + | if ((allowedHash == newHash)) | |
1482 | + | then (currentHash != newHash) | |
1483 | + | else false | |
1484 | + | } | |
1330 | 1485 | case _ => | |
1331 | 1486 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1332 | 1487 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lPdecimals = 8 | |
5 | 5 | ||
6 | 6 | let scale8 = 100000000 | |
7 | 7 | ||
8 | 8 | let scale8BigInt = toBigInt(100000000) | |
9 | 9 | ||
10 | 10 | let scale18 = toBigInt(1000000000000000000) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let big0 = toBigInt(0) | |
15 | 15 | ||
16 | 16 | let big1 = toBigInt(1) | |
17 | 17 | ||
18 | 18 | let big2 = toBigInt(2) | |
19 | 19 | ||
20 | 20 | let wavesString = "WAVES" | |
21 | 21 | ||
22 | 22 | let SEP = "__" | |
23 | 23 | ||
24 | 24 | let PoolActive = 1 | |
25 | 25 | ||
26 | 26 | let PoolPutDisabled = 2 | |
27 | 27 | ||
28 | 28 | let PoolMatcherDisabled = 3 | |
29 | 29 | ||
30 | 30 | let PoolShutdown = 4 | |
31 | 31 | ||
32 | 32 | let idxPoolAddress = 1 | |
33 | 33 | ||
34 | 34 | let idxPoolStatus = 2 | |
35 | 35 | ||
36 | 36 | let idxPoolLPAssetId = 3 | |
37 | 37 | ||
38 | 38 | let idxAmtAssetId = 4 | |
39 | 39 | ||
40 | 40 | let idxPriceAssetId = 5 | |
41 | 41 | ||
42 | 42 | let idxAmtAssetDcm = 6 | |
43 | 43 | ||
44 | 44 | let idxPriceAssetDcm = 7 | |
45 | 45 | ||
46 | 46 | let idxIAmtAssetId = 8 | |
47 | 47 | ||
48 | 48 | let idxIPriceAssetId = 9 | |
49 | 49 | ||
50 | 50 | let idxLPAssetDcm = 10 | |
51 | 51 | ||
52 | 52 | let idxPoolAmtAssetAmt = 1 | |
53 | 53 | ||
54 | 54 | let idxPoolPriceAssetAmt = 2 | |
55 | 55 | ||
56 | 56 | let idxPoolLPAssetAmt = 3 | |
57 | 57 | ||
58 | 58 | let idxFactoryStakingContract = 1 | |
59 | 59 | ||
60 | 60 | let idxFactorySlippageContract = 7 | |
61 | 61 | ||
62 | 62 | func toX18 (origVal,origScaleMult) = fraction(toBigInt(origVal), scale18, toBigInt(origScaleMult)) | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func toX18BigInt (origVal,origScaleMult) = fraction(origVal, scale18, origScaleMult) | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func fromX18 (val,resultScaleMult) = toInt(fraction(val, toBigInt(resultScaleMult), scale18)) | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func fromX18Round (val,resultScaleMult,round) = toInt(fraction(val, toBigInt(resultScaleMult), scale18, round)) | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | func toScale (amt,resScale,curScale) = fraction(amt, resScale, curScale) | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func abs (val) = if ((0 > val)) | |
78 | 78 | then -(val) | |
79 | 79 | else val | |
80 | 80 | ||
81 | 81 | ||
82 | 82 | func absBigInt (val) = if ((zeroBigInt > val)) | |
83 | 83 | then -(val) | |
84 | 84 | else val | |
85 | 85 | ||
86 | 86 | ||
87 | - | func swapContract () = "%s__swapContract" | |
88 | - | ||
89 | - | ||
90 | 87 | func fc () = "%s__factoryContract" | |
91 | 88 | ||
92 | 89 | ||
93 | 90 | func mpk () = "%s__managerPublicKey" | |
94 | 91 | ||
95 | 92 | ||
96 | 93 | func pmpk () = "%s__pendingManagerPublicKey" | |
97 | 94 | ||
98 | 95 | ||
99 | 96 | func pl () = "%s%s__price__last" | |
100 | 97 | ||
101 | 98 | ||
102 | 99 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
103 | 100 | ||
104 | 101 | ||
105 | 102 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
106 | 103 | ||
107 | 104 | ||
108 | 105 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
109 | 106 | ||
110 | 107 | ||
111 | 108 | func aa () = "%s__amountAsset" | |
112 | 109 | ||
113 | 110 | ||
114 | 111 | func pa () = "%s__priceAsset" | |
115 | 112 | ||
116 | 113 | ||
114 | + | let keyFee = "%s__fee" | |
115 | + | ||
116 | + | let feeDefault = fraction(10, scale8, 10000) | |
117 | + | ||
118 | + | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
119 | + | ||
120 | + | let keyKLp = makeString(["%s", "kLp"], SEP) | |
121 | + | ||
122 | + | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
123 | + | ||
124 | + | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
125 | + | ||
126 | + | let kLpRefreshDelayDefault = 30 | |
127 | + | ||
128 | + | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
129 | + | ||
117 | 130 | func keyFactoryConfig () = "%s__factoryConfig" | |
118 | 131 | ||
119 | 132 | ||
120 | 133 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
121 | 134 | ||
122 | 135 | ||
123 | 136 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
124 | 137 | ||
125 | 138 | ||
126 | 139 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
127 | 140 | ||
128 | 141 | ||
129 | 142 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
130 | 143 | ||
131 | 144 | ||
132 | 145 | func keyAllPoolsShutdown () = "%s__shutdown" | |
133 | 146 | ||
134 | 147 | ||
135 | 148 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
136 | 149 | ||
137 | 150 | ||
138 | 151 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
139 | 152 | ||
140 | 153 | ||
141 | 154 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
142 | 155 | ||
143 | - | func throwOrderError (orderValid,senderValid,matcherValid) = throw(((((("order validation failed: orderValid=" + toString(orderValid)) + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
156 | + | func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
144 | 157 | ||
145 | 158 | ||
146 | 159 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
147 | 160 | ||
148 | 161 | ||
149 | 162 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
150 | 163 | ||
151 | 164 | ||
152 | 165 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
166 | + | ||
167 | + | ||
168 | + | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
153 | 169 | ||
154 | 170 | ||
155 | 171 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
156 | 172 | ||
157 | 173 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
158 | 174 | ||
159 | 175 | let inFee = { | |
160 | 176 | let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil) | |
161 | 177 | if ($isInstanceOf(@, "Int")) | |
162 | 178 | then @ | |
163 | 179 | else throw(($getType(@) + " couldn't be cast to Int")) | |
164 | 180 | } | |
165 | 181 | ||
166 | 182 | let outFee = { | |
167 | 183 | let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil) | |
168 | 184 | if ($isInstanceOf(@, "Int")) | |
169 | 185 | then @ | |
170 | 186 | else throw(($getType(@) + " couldn't be cast to Int")) | |
171 | 187 | } | |
172 | 188 | ||
173 | 189 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
174 | 190 | ||
175 | 191 | ||
176 | 192 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
177 | 193 | ||
178 | 194 | ||
179 | 195 | func getPoolConfig () = { | |
180 | 196 | let amtAsset = getStringOrFail(this, aa()) | |
181 | 197 | let priceAsset = getStringOrFail(this, pa()) | |
182 | 198 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
183 | 199 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
184 | 200 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
185 | 201 | } | |
186 | 202 | ||
187 | 203 | ||
188 | 204 | func parseAssetId (input) = if ((input == wavesString)) | |
189 | 205 | then unit | |
190 | 206 | else fromBase58String(input) | |
191 | 207 | ||
192 | 208 | ||
193 | 209 | func assetIdToString (input) = if ((input == unit)) | |
194 | 210 | then wavesString | |
195 | 211 | else toBase58String(value(input)) | |
196 | 212 | ||
197 | 213 | ||
198 | 214 | func parsePoolConfig (poolConfig) = $Tuple7(addressFromStringValue(poolConfig[idxPoolAddress]), parseIntValue(poolConfig[idxPoolStatus]), fromBase58String(poolConfig[idxPoolLPAssetId]), parseAssetId(poolConfig[idxAmtAssetId]), parseAssetId(poolConfig[idxPriceAssetId]), parseIntValue(poolConfig[idxAmtAssetDcm]), parseIntValue(poolConfig[idxPriceAssetDcm])) | |
199 | 215 | ||
200 | 216 | ||
201 | 217 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
202 | 218 | ||
203 | - | let $ | |
219 | + | let $t084088574 = poolConfigParsed | |
204 | 220 | ||
205 | - | let cfgPoolAddress = $ | |
221 | + | let cfgPoolAddress = $t084088574._1 | |
206 | 222 | ||
207 | - | let cfgPoolStatus = $ | |
223 | + | let cfgPoolStatus = $t084088574._2 | |
208 | 224 | ||
209 | - | let cfgLpAssetId = $ | |
225 | + | let cfgLpAssetId = $t084088574._3 | |
210 | 226 | ||
211 | - | let cfgAmountAssetId = $ | |
227 | + | let cfgAmountAssetId = $t084088574._4 | |
212 | 228 | ||
213 | - | let cfgPriceAssetId = $ | |
229 | + | let cfgPriceAssetId = $t084088574._5 | |
214 | 230 | ||
215 | - | let cfgAmountAssetDecimals = $ | |
231 | + | let cfgAmountAssetDecimals = $t084088574._6 | |
216 | 232 | ||
217 | - | let cfgPriceAssetDecimals = $ | |
233 | + | let cfgPriceAssetDecimals = $t084088574._7 | |
218 | 234 | ||
219 | 235 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
220 | 236 | ||
221 | 237 | ||
222 | 238 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
223 | 239 | ||
224 | 240 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
225 | 241 | ||
226 | 242 | func dataPutActionInfo (inAmtAssetAmt,inPriceAssetAmt,outLpAmt,price,slippageTolerancePassedByUser,slippageToleranceReal,txHeight,txTimestamp,slipageAmtAssetAmt,slipagePriceAssetAmt) = makeString(["%d%d%d%d%d%d%d%d%d%d", toString(inAmtAssetAmt), toString(inPriceAssetAmt), toString(outLpAmt), toString(price), toString(slippageTolerancePassedByUser), toString(slippageToleranceReal), toString(txHeight), toString(txTimestamp), toString(slipageAmtAssetAmt), toString(slipagePriceAssetAmt)], SEP) | |
227 | 243 | ||
228 | 244 | ||
229 | 245 | 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) | |
230 | 246 | ||
231 | 247 | ||
232 | 248 | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
233 | 249 | then wavesBalance(this).available | |
234 | 250 | else assetBalance(this, fromBase58String(assetId)) | |
235 | 251 | ||
236 | 252 | ||
237 | 253 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
254 | + | ||
255 | + | ||
256 | + | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
238 | 257 | ||
239 | 258 | ||
240 | 259 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
241 | 260 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
242 | 261 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
243 | 262 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
244 | 263 | } | |
245 | 264 | ||
246 | 265 | ||
247 | 266 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
248 | 267 | let cfg = getPoolConfig() | |
249 | 268 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
250 | 269 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
251 | 270 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
252 | 271 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
253 | 272 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
254 | 273 | let lpAmtX18 = toX18(lpAmt, scale8) | |
255 | 274 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
256 | 275 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
257 | 276 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
258 | 277 | } | |
259 | 278 | ||
260 | 279 | ||
261 | 280 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
262 | 281 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
263 | 282 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
264 | 283 | } | |
265 | 284 | ||
266 | 285 | ||
267 | 286 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
268 | 287 | let cfg = getPoolConfig() | |
269 | 288 | let lpAssetId = cfg[idxPoolLPAssetId] | |
270 | 289 | let amAssetId = cfg[idxAmtAssetId] | |
271 | 290 | let prAssetId = cfg[idxPriceAssetId] | |
272 | 291 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
273 | 292 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
274 | 293 | let poolStatus = cfg[idxPoolStatus] | |
275 | 294 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
276 | 295 | if ((lpAssetId != pmtAssetId)) | |
277 | 296 | then throw("Invalid asset passed.") | |
278 | 297 | else { | |
279 | 298 | let amBalance = getAccBalance(amAssetId) | |
280 | 299 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
281 | 300 | let prBalance = getAccBalance(prAssetId) | |
282 | 301 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
283 | 302 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
284 | 303 | let curPrice = fromX18(curPriceX18, scale8) | |
285 | 304 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
286 | 305 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
287 | 306 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
288 | 307 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
289 | - | let outAmAmt = | |
290 | - | let outPrAmt = | |
308 | + | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
309 | + | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
291 | 310 | let state = if ((txId58 == "")) | |
292 | 311 | then nil | |
293 | 312 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
294 | 313 | then unit | |
295 | 314 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
296 | 315 | then unit | |
297 | 316 | else fromBase58String(prAssetId)), StringEntry(gau(toString(userAddress), txId58), dataGetActionInfo(outAmAmt, outPrAmt, pmtLpAmt, curPrice, height, lastBlock.timestamp)), IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice)] | |
298 | 317 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
299 | 318 | } | |
300 | 319 | } | |
301 | 320 | ||
302 | 321 | ||
303 | 322 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
304 | 323 | let cfg = getPoolConfig() | |
305 | 324 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
306 | 325 | let amAssetIdStr = cfg[idxAmtAssetId] | |
307 | 326 | let prAssetIdStr = cfg[idxPriceAssetId] | |
308 | 327 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
309 | 328 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
310 | 329 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
311 | 330 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
312 | 331 | let poolStatus = cfg[idxPoolStatus] | |
313 | 332 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
314 | 333 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
315 | 334 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
316 | 335 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
317 | 336 | then true | |
318 | 337 | else (prAssetIdStr != inPrAssetIdStr)) | |
319 | 338 | then throw("Invalid amt or price asset passed.") | |
320 | 339 | else { | |
321 | 340 | let amBalance = if (isEvaluate) | |
322 | 341 | then getAccBalance(amAssetIdStr) | |
323 | 342 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
324 | 343 | let prBalance = if (isEvaluate) | |
325 | 344 | then getAccBalance(prAssetIdStr) | |
326 | 345 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
327 | 346 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
328 | 347 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
329 | 348 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
330 | 349 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
331 | 350 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
332 | 351 | let res = if ((lpEmission == 0)) | |
333 | 352 | then { | |
334 | 353 | let curPriceX18 = zeroBigInt | |
335 | 354 | let slippageX18 = zeroBigInt | |
336 | 355 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
337 | 356 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
338 | 357 | } | |
339 | 358 | else { | |
340 | 359 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
341 | 360 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
342 | 361 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
343 | 362 | if (if ((curPriceX18 != zeroBigInt)) | |
344 | 363 | then (slippageX18 > slippageToleranceX18) | |
345 | 364 | else false) | |
346 | 365 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
347 | 366 | else { | |
348 | 367 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
349 | - | let prViaAmX18 = fraction(inAmAssetAmtX18, | |
350 | - | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, | |
368 | + | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
369 | + | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
351 | 370 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
352 | 371 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
353 | 372 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
354 | 373 | let expAmtAssetAmtX18 = expectedAmts._1 | |
355 | 374 | let expPriceAssetAmtX18 = expectedAmts._2 | |
356 | - | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18) | |
357 | - | $Tuple5( | |
375 | + | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
376 | + | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
358 | 377 | } | |
359 | 378 | } | |
360 | 379 | let calcLpAmt = res._1 | |
361 | 380 | let calcAmAssetPmt = res._2 | |
362 | 381 | let calcPrAssetPmt = res._3 | |
363 | 382 | let curPrice = fromX18(res._4, scale8) | |
364 | 383 | let slippageCalc = fromX18(res._5, scale8) | |
365 | 384 | if ((0 >= calcLpAmt)) | |
366 | 385 | then throw("Invalid calculations. LP calculated is less than zero.") | |
367 | 386 | else { | |
368 | 387 | let emitLpAmt = if (!(emitLp)) | |
369 | 388 | then 0 | |
370 | 389 | else calcLpAmt | |
371 | 390 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
372 | 391 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
373 | 392 | let commonState = [IntegerEntry(pl(), curPrice), IntegerEntry(ph(height, lastBlock.timestamp), curPrice), StringEntry(pau(userAddress, txId58), dataPutActionInfo(calcAmAssetPmt, calcPrAssetPmt, emitLpAmt, curPrice, slippageTolerance, slippageCalc, height, lastBlock.timestamp, amDiff, prDiff))] | |
374 | 393 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
375 | 394 | } | |
376 | 395 | } | |
377 | 396 | } | |
378 | 397 | ||
379 | 398 | ||
399 | + | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
400 | + | let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)) | |
401 | + | let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals)) | |
402 | + | let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
403 | + | if ((lpEmission == big0)) | |
404 | + | then big0 | |
405 | + | else updatedKLp | |
406 | + | } | |
407 | + | ||
408 | + | ||
409 | + | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
410 | + | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
411 | + | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
412 | + | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
413 | + | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
414 | + | currentKLp | |
415 | + | } | |
416 | + | ||
417 | + | ||
418 | + | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
419 | + | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
420 | + | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
421 | + | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
422 | + | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
423 | + | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
424 | + | $Tuple2(actions, updatedKLp) | |
425 | + | } | |
426 | + | ||
427 | + | ||
428 | + | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
429 | + | then true | |
430 | + | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
431 | + | ||
432 | + | ||
380 | 433 | func validateMatcherOrderAllowed (order) = { | |
381 | - | let cfg = getPoolConfig() | |
382 | - | let amtAssetId = cfg[idxAmtAssetId] | |
383 | - | let priceAssetId = cfg[idxPriceAssetId] | |
384 | - | let poolStatus = parseIntValue(cfg[idxPoolStatus]) | |
385 | - | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
386 | - | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
387 | - | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
388 | - | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
389 | - | let curPriceX18 = if ((order.orderType == Buy)) | |
390 | - | then privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance + order.amount), accPriceAssetBalance) | |
391 | - | else privateCalcPrice(amtAssetDcm, priceAssetDcm, (accAmtAssetBalance - order.amount), accPriceAssetBalance) | |
392 | - | let curPrice = fromX18(curPriceX18, scale8) | |
434 | + | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
435 | + | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
436 | + | let amountAssetAmount = order.amount | |
437 | + | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
438 | + | let $t02148021692 = if ((order.orderType == Buy)) | |
439 | + | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
440 | + | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
441 | + | let amountAssetBalanceDelta = $t02148021692._1 | |
442 | + | let priceAssetBalanceDelta = $t02148021692._2 | |
393 | 443 | if (if (if (isGlobalShutdown()) | |
394 | 444 | then true | |
395 | - | else ( | |
445 | + | else (cfgPoolStatus == PoolMatcherDisabled)) | |
396 | 446 | then true | |
397 | - | else ( | |
447 | + | else (cfgPoolStatus == PoolShutdown)) | |
398 | 448 | then throw("Exchange operations disabled") | |
399 | - | else { | |
400 | - | let orderAmtAsset = order.assetPair.amountAsset | |
401 | - | let orderAmtAssetStr = if ((orderAmtAsset == unit)) | |
402 | - | then "WAVES" | |
403 | - | else toBase58String(value(orderAmtAsset)) | |
404 | - | let orderPriceAsset = order.assetPair.priceAsset | |
405 | - | let orderPriceAssetStr = if ((orderPriceAsset == unit)) | |
406 | - | then "WAVES" | |
407 | - | else toBase58String(value(orderPriceAsset)) | |
408 | - | if (if ((orderAmtAssetStr != amtAssetId)) | |
409 | - | then true | |
410 | - | else (orderPriceAssetStr != priceAssetId)) | |
411 | - | then throw("Wrong order assets.") | |
412 | - | else { | |
413 | - | let orderPrice = order.price | |
414 | - | let priceDcm = fraction(scale8, priceAssetDcm, amtAssetDcm) | |
415 | - | let castedOrderPrice = toScale(orderPrice, scale8, priceDcm) | |
416 | - | let isOrderPriceValid = if ((order.orderType == Buy)) | |
417 | - | then (curPrice >= castedOrderPrice) | |
418 | - | else (castedOrderPrice >= curPrice) | |
419 | - | true | |
420 | - | } | |
421 | - | } | |
449 | + | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
450 | + | then true | |
451 | + | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
452 | + | then throw("Wrong order assets.") | |
453 | + | else { | |
454 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
455 | + | let $t02213222232 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
456 | + | let unusedActions = $t02213222232._1 | |
457 | + | let kLpNew = $t02213222232._2 | |
458 | + | let isOrderValid = (kLpNew >= kLp) | |
459 | + | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
460 | + | $Tuple2(isOrderValid, info) | |
461 | + | } | |
422 | 462 | } | |
423 | 463 | ||
424 | 464 | ||
425 | 465 | func commonGet (i) = if ((size(i.payments) != 1)) | |
426 | 466 | then throw("exactly 1 payment is expected") | |
427 | 467 | else { | |
428 | 468 | let pmt = value(i.payments[0]) | |
429 | 469 | let pmtAssetId = value(pmt.assetId) | |
430 | 470 | let pmtAmt = pmt.amount | |
431 | 471 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
432 | 472 | let outAmAmt = res._1 | |
433 | 473 | let outPrAmt = res._2 | |
434 | 474 | let poolStatus = parseIntValue(res._9) | |
435 | 475 | let state = res._10 | |
436 | 476 | if (if (isGlobalShutdown()) | |
437 | 477 | then true | |
438 | 478 | else (poolStatus == PoolShutdown)) | |
439 | 479 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
440 | 480 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
441 | 481 | } | |
442 | 482 | ||
443 | 483 | ||
444 | 484 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
445 | 485 | then throw("exactly 2 payments are expected") | |
446 | 486 | else { | |
447 | 487 | let amAssetPmt = value(i.payments[0]) | |
448 | 488 | let prAssetPmt = value(i.payments[1]) | |
449 | 489 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
450 | 490 | let poolStatus = parseIntValue(estPut._8) | |
451 | 491 | if (if (if (isGlobalShutdown()) | |
452 | 492 | then true | |
453 | 493 | else (poolStatus == PoolPutDisabled)) | |
454 | 494 | then true | |
455 | 495 | else (poolStatus == PoolShutdown)) | |
456 | 496 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
457 | 497 | else estPut | |
458 | 498 | } | |
459 | 499 | ||
460 | 500 | ||
461 | 501 | func emit (amount) = { | |
462 | 502 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
463 | 503 | if ((emitInv == emitInv)) | |
464 | 504 | then { | |
465 | 505 | let emitInvLegacy = match emitInv { | |
466 | 506 | case legacyFactoryContract: Address => | |
467 | 507 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
468 | 508 | case _ => | |
469 | 509 | unit | |
470 | 510 | } | |
471 | 511 | if ((emitInvLegacy == emitInvLegacy)) | |
472 | 512 | then amount | |
473 | 513 | else throw("Strict value is not equal to itself.") | |
474 | 514 | } | |
475 | 515 | else throw("Strict value is not equal to itself.") | |
476 | 516 | } | |
477 | 517 | ||
478 | 518 | ||
479 | 519 | func takeFee (amount,fee) = { | |
480 | 520 | let feeAmount = if ((fee == 0)) | |
481 | 521 | then 0 | |
482 | 522 | else fraction(amount, fee, scale8) | |
483 | 523 | $Tuple2((amount - feeAmount), feeAmount) | |
484 | 524 | } | |
485 | 525 | ||
486 | 526 | ||
487 | 527 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
488 | 528 | let isEval = (txId == unit) | |
489 | 529 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
490 | 530 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
491 | 531 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
492 | 532 | then true | |
493 | 533 | else if ((paymentAssetId == cfgPriceAssetId)) | |
494 | 534 | then false | |
495 | 535 | else throwErr("invalid asset") | |
496 | - | let $ | |
536 | + | let $t02534525638 = if (isEval) | |
497 | 537 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
498 | 538 | else if (paymentInAmountAsset) | |
499 | 539 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
500 | 540 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
501 | - | let amountBalanceOld = $ | |
502 | - | let priceBalanceOld = $ | |
503 | - | let $ | |
541 | + | let amountBalanceOld = $t02534525638._1 | |
542 | + | let priceBalanceOld = $t02534525638._2 | |
543 | + | let $t02564225791 = if (paymentInAmountAsset) | |
504 | 544 | then $Tuple2(paymentAmountRaw, 0) | |
505 | 545 | else $Tuple2(0, paymentAmountRaw) | |
506 | - | let amountAssetAmountRaw = $ | |
507 | - | let priceAssetAmountRaw = $ | |
546 | + | let amountAssetAmountRaw = $t02564225791._1 | |
547 | + | let priceAssetAmountRaw = $t02564225791._2 | |
508 | 548 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
509 | 549 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
510 | - | let $ | |
511 | - | let paymentAmount = $ | |
512 | - | let feeAmount = $ | |
550 | + | let $t02592325987 = takeFee(paymentAmountRaw, inFee) | |
551 | + | let paymentAmount = $t02592325987._1 | |
552 | + | let feeAmount = $t02592325987._2 | |
513 | 553 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
514 | 554 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
515 | 555 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
516 | 556 | let priceNew = fromX18(priceNewX18, scale8) | |
517 | 557 | let paymentBalance = if (paymentInAmountAsset) | |
518 | 558 | then amountBalanceOld | |
519 | 559 | else priceBalanceOld | |
520 | 560 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
521 | 561 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
522 | 562 | let chechSupply = if ((supplyBigInt > big0)) | |
523 | 563 | then true | |
524 | 564 | else throwErr("initial deposit requires all coins") | |
525 | 565 | if ((chechSupply == chechSupply)) | |
526 | 566 | then { | |
527 | 567 | let depositBigInt = toBigInt(paymentAmount) | |
528 | 568 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
529 | 569 | let commonState = if (isEval) | |
530 | 570 | then nil | |
531 | 571 | else [IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew), StringEntry(pau(toString(value(userAddress)), toBase58String(value(txId))), dataPutActionInfo(amountAssetAmountRaw, priceAssetAmountRaw, issueAmount, priceNew, 0, 0, height, lastBlock.timestamp, 0, 0))] | |
532 | 572 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
533 | 573 | let priceOld = fromX18(priceOldX18, scale8) | |
534 | 574 | let loss = { | |
535 | - | let $ | |
575 | + | let $t02766827835 = if (paymentInAmountAsset) | |
536 | 576 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
537 | 577 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
538 | - | let amount = $ | |
539 | - | let balance = $ | |
578 | + | let amount = $t02766827835._1 | |
579 | + | let balance = $t02766827835._2 | |
540 | 580 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
541 | 581 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
542 | 582 | } | |
543 | - | $ | |
583 | + | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
544 | 584 | } | |
545 | 585 | else throw("Strict value is not equal to itself.") | |
546 | 586 | } | |
547 | 587 | ||
548 | 588 | ||
549 | 589 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
550 | 590 | let isEval = (txId == unit) | |
591 | + | let cfg = getPoolConfig() | |
592 | + | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
593 | + | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
551 | 594 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
552 | 595 | then true | |
553 | 596 | else throwErr("invalid lp asset")] | |
554 | 597 | if ((checks == checks)) | |
555 | 598 | then { | |
556 | 599 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
557 | 600 | then true | |
558 | 601 | else if ((outAssetId == cfgPriceAssetId)) | |
559 | 602 | then false | |
560 | 603 | else throwErr("invalid asset") | |
561 | 604 | let balanceBigInt = if (outInAmountAsset) | |
562 | 605 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
563 | 606 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
607 | + | let outInAmountAssetDecimals = if (outInAmountAsset) | |
608 | + | then amtAssetDcm | |
609 | + | else priceAssetDcm | |
564 | 610 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
565 | 611 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
566 | 612 | let outBalance = if (outInAmountAsset) | |
567 | 613 | then amBalanceOld | |
568 | 614 | else prBalanceOld | |
569 | 615 | let outBalanceBigInt = toBigInt(outBalance) | |
570 | 616 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
571 | 617 | let redeemedBigInt = toBigInt(paymentAmount) | |
572 | 618 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
573 | - | let $ | |
574 | - | let totalAmount = $ | |
575 | - | let feeAmount = $ | |
576 | - | let $ | |
619 | + | let $t02991329969 = takeFee(amountRaw, outFee) | |
620 | + | let totalAmount = $t02991329969._1 | |
621 | + | let feeAmount = $t02991329969._2 | |
622 | + | let $t02997330199 = if (outInAmountAsset) | |
577 | 623 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
578 | 624 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
579 | - | let outAmAmount = $ | |
580 | - | let outPrAmount = $ | |
581 | - | let amBalanceNew = $ | |
582 | - | let prBalanceNew = $ | |
625 | + | let outAmAmount = $t02997330199._1 | |
626 | + | let outPrAmount = $t02997330199._2 | |
627 | + | let amBalanceNew = $t02997330199._3 | |
628 | + | let prBalanceNew = $t02997330199._4 | |
583 | 629 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
584 | 630 | let priceNew = fromX18(priceNewX18, scale8) | |
585 | 631 | let commonState = if (isEval) | |
586 | 632 | then nil | |
587 | 633 | else [StringEntry(gau(toString(value(userAddress)), toBase58String(value(txId))), dataGetActionInfo(outAmAmount, outPrAmount, paymentAmount, priceNew, height, lastBlock.timestamp)), IntegerEntry(pl(), priceNew), IntegerEntry(ph(height, lastBlock.timestamp), priceNew)] | |
588 | 634 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
589 | 635 | let priceOld = fromX18(priceOldX18, scale8) | |
590 | 636 | let loss = { | |
591 | 637 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
592 | 638 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
593 | 639 | } | |
594 | - | $ | |
640 | + | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
595 | 641 | } | |
596 | 642 | else throw("Strict value is not equal to itself.") | |
597 | 643 | } | |
598 | 644 | ||
599 | 645 | ||
600 | 646 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
601 | 647 | case s: String => | |
602 | 648 | fromBase58String(s) | |
603 | 649 | case _: Unit => | |
604 | 650 | unit | |
605 | 651 | case _ => | |
606 | 652 | throw("Match error") | |
607 | 653 | } | |
608 | 654 | ||
609 | 655 | ||
610 | 656 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
611 | 657 | case s: String => | |
612 | 658 | fromBase58String(s) | |
613 | 659 | case _: Unit => | |
614 | 660 | unit | |
615 | 661 | case _ => | |
616 | 662 | throw("Match error") | |
617 | 663 | } | |
618 | 664 | ||
619 | 665 | ||
620 | 666 | func isManager (i) = match managerPublicKeyOrUnit() { | |
621 | 667 | case pk: ByteVector => | |
622 | 668 | (i.callerPublicKey == pk) | |
623 | 669 | case _: Unit => | |
624 | 670 | (i.caller == this) | |
625 | 671 | case _ => | |
626 | 672 | throw("Match error") | |
627 | 673 | } | |
628 | 674 | ||
629 | 675 | ||
630 | 676 | func mustManager (i) = { | |
631 | 677 | let pd = throw("Permission denied") | |
632 | 678 | match managerPublicKeyOrUnit() { | |
633 | 679 | case pk: ByteVector => | |
634 | 680 | if ((i.callerPublicKey == pk)) | |
635 | 681 | then true | |
636 | 682 | else pd | |
637 | 683 | case _: Unit => | |
638 | 684 | if ((i.caller == this)) | |
639 | 685 | then true | |
640 | 686 | else pd | |
641 | 687 | case _ => | |
642 | 688 | throw("Match error") | |
643 | 689 | } | |
644 | 690 | } | |
645 | 691 | ||
646 | 692 | ||
647 | 693 | @Callable(i) | |
648 | - | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse) = { | |
649 | - | let $t02879829103 = if ((isReverse == false)) | |
650 | - | then { | |
651 | - | let assetOut = getStringOrFail(this, pa()) | |
652 | - | let assetIn = getStringOrFail(this, aa()) | |
653 | - | $Tuple2(assetOut, assetIn) | |
654 | - | } | |
655 | - | else { | |
656 | - | let assetOut = getStringOrFail(this, aa()) | |
657 | - | let assetIn = getStringOrFail(this, pa()) | |
658 | - | $Tuple2(assetOut, assetIn) | |
659 | - | } | |
660 | - | let assetOut = $t02879829103._1 | |
661 | - | let assetIn = $t02879829103._2 | |
662 | - | let poolAssetInBalance = getAccBalance(assetIn) | |
663 | - | let poolAssetOutBalance = getAccBalance(assetOut) | |
664 | - | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
665 | - | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
666 | - | let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
667 | - | let checkK = if ((newK >= oldK)) | |
668 | - | then true | |
669 | - | else throw("new K is fewer error") | |
670 | - | if ((checkK == checkK)) | |
671 | - | then $Tuple2(nil, amountOut) | |
672 | - | else throw("Strict value is not equal to itself.") | |
673 | - | } | |
674 | - | ||
675 | - | ||
676 | - | ||
677 | - | @Callable(i) | |
678 | - | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo) = { | |
679 | - | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
680 | - | then true | |
681 | - | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(getStringOrFail(this, swapContract())))) | |
682 | - | then true | |
683 | - | else throwErr("Permission denied")] | |
684 | - | if ((checks == checks)) | |
685 | - | then { | |
686 | - | let pmt = value(i.payments[0]) | |
687 | - | let assetIn = if ((pmt.assetId == unit)) | |
688 | - | then toBase58String(toBytes("WAVES")) | |
689 | - | else toBase58String(value(pmt.assetId)) | |
690 | - | let assetOut = if ((isReverse == false)) | |
691 | - | then getStringOrFail(this, pa()) | |
692 | - | else getStringOrFail(this, aa()) | |
693 | - | let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
694 | - | let poolAssetOutBalance = getAccBalance(assetOut) | |
695 | - | let amountOut = ((poolAssetOutBalance * cleanAmountIn) / (poolAssetInBalance + cleanAmountIn)) | |
696 | - | let oldK = (poolAssetInBalance * poolAssetOutBalance) | |
697 | - | let newK = (getAccBalance(assetIn) * (getAccBalance(assetOut) - amountOut)) | |
698 | - | let checkK = if ((newK >= oldK)) | |
699 | - | then true | |
700 | - | else throw("new K is fewer error") | |
701 | - | if ((checkK == checkK)) | |
702 | - | then { | |
703 | - | let checkMin = if ((amountOut >= amountOutMin)) | |
704 | - | then true | |
705 | - | else throw("Exchange result is fewer coins than expected") | |
706 | - | if ((checkMin == checkMin)) | |
707 | - | then [ScriptTransfer(addressFromStringValue(addressTo), amountOut, if ((assetIn == "WAVES")) | |
708 | - | then unit | |
709 | - | else fromBase58String(assetOut))] | |
710 | - | else throw("Strict value is not equal to itself.") | |
711 | - | } | |
712 | - | else throw("Strict value is not equal to itself.") | |
713 | - | } | |
714 | - | else throw("Strict value is not equal to itself.") | |
715 | - | } | |
716 | - | ||
717 | - | ||
718 | - | ||
719 | - | @Callable(i) | |
720 | 694 | func setManager (pendingManagerPublicKey) = { | |
721 | 695 | let checkCaller = mustManager(i) | |
722 | 696 | if ((checkCaller == checkCaller)) | |
723 | 697 | then { | |
724 | 698 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
725 | 699 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
726 | 700 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
727 | 701 | else throw("Strict value is not equal to itself.") | |
728 | 702 | } | |
729 | 703 | else throw("Strict value is not equal to itself.") | |
730 | 704 | } | |
731 | 705 | ||
732 | 706 | ||
733 | 707 | ||
734 | 708 | @Callable(i) | |
735 | 709 | func confirmManager () = { | |
736 | 710 | let pm = pendingManagerPublicKeyOrUnit() | |
737 | 711 | let hasPM = if (isDefined(pm)) | |
738 | 712 | then true | |
739 | 713 | else throw("No pending manager") | |
740 | 714 | if ((hasPM == hasPM)) | |
741 | 715 | then { | |
742 | 716 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
743 | 717 | then true | |
744 | 718 | else throw("You are not pending manager") | |
745 | 719 | if ((checkPM == checkPM)) | |
746 | 720 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
747 | 721 | else throw("Strict value is not equal to itself.") | |
748 | 722 | } | |
749 | 723 | else throw("Strict value is not equal to itself.") | |
750 | 724 | } | |
751 | 725 | ||
752 | 726 | ||
753 | 727 | ||
754 | 728 | @Callable(i) | |
755 | 729 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
756 | 730 | then throw("Invalid slippageTolerance passed") | |
757 | 731 | else { | |
758 | 732 | let estPut = commonPut(i, slippageTolerance, true) | |
759 | 733 | let emitLpAmt = estPut._2 | |
760 | 734 | let lpAssetId = estPut._7 | |
761 | 735 | let state = estPut._9 | |
762 | 736 | let amDiff = estPut._10 | |
763 | 737 | let prDiff = estPut._11 | |
764 | 738 | let amId = estPut._12 | |
765 | 739 | let prId = estPut._13 | |
766 | - | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
767 | - | if ((emitInv == emitInv)) | |
740 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
741 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
742 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
743 | + | if ((currentKLp == currentKLp)) | |
768 | 744 | then { | |
769 | - | let emitInvLegacy = match emitInv { | |
770 | - | case legacyFactoryContract: Address => | |
771 | - | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
772 | - | case _ => | |
773 | - | unit | |
774 | - | } | |
775 | - | if ((emitInvLegacy == emitInvLegacy)) | |
745 | + | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
746 | + | if ((emitInv == emitInv)) | |
776 | 747 | then { | |
777 | - | let slippageAInv = if ((amDiff > 0)) | |
778 | - | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
779 | - | else nil | |
780 | - | if ((slippageAInv == slippageAInv)) | |
748 | + | let emitInvLegacy = match emitInv { | |
749 | + | case legacyFactoryContract: Address => | |
750 | + | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
751 | + | case _ => | |
752 | + | unit | |
753 | + | } | |
754 | + | if ((emitInvLegacy == emitInvLegacy)) | |
781 | 755 | then { | |
782 | - | let | |
783 | - | then invoke(slippageContract, "put", nil, [AttachedPayment( | |
756 | + | let slippageAInv = if ((amDiff > 0)) | |
757 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
784 | 758 | else nil | |
785 | - | if (( | |
759 | + | if ((slippageAInv == slippageAInv)) | |
786 | 760 | then { | |
787 | - | let lpTransfer = if (shouldAutoStake) | |
761 | + | let slippagePInv = if ((prDiff > 0)) | |
762 | + | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
763 | + | else nil | |
764 | + | if ((slippagePInv == slippagePInv)) | |
788 | 765 | then { | |
789 | - | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
790 | - | if ((slpStakeInv == slpStakeInv)) | |
791 | - | then nil | |
766 | + | let lpTransfer = if (shouldAutoStake) | |
767 | + | then { | |
768 | + | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
769 | + | if ((slpStakeInv == slpStakeInv)) | |
770 | + | then nil | |
771 | + | else throw("Strict value is not equal to itself.") | |
772 | + | } | |
773 | + | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
774 | + | let $t03472735189 = refreshKLpInternal(0, 0, 0) | |
775 | + | if (($t03472735189 == $t03472735189)) | |
776 | + | then { | |
777 | + | let updatedKLp = $t03472735189._2 | |
778 | + | let refreshKLpActions = $t03472735189._1 | |
779 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
780 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
781 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
782 | + | else throw("Strict value is not equal to itself.") | |
783 | + | } | |
792 | 784 | else throw("Strict value is not equal to itself.") | |
793 | 785 | } | |
794 | - | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
795 | - | (state ++ lpTransfer) | |
786 | + | else throw("Strict value is not equal to itself.") | |
796 | 787 | } | |
797 | 788 | else throw("Strict value is not equal to itself.") | |
798 | 789 | } | |
799 | 790 | else throw("Strict value is not equal to itself.") | |
800 | 791 | } | |
801 | 792 | else throw("Strict value is not equal to itself.") | |
802 | 793 | } | |
803 | 794 | else throw("Strict value is not equal to itself.") | |
804 | 795 | } | |
805 | 796 | ||
806 | 797 | ||
807 | 798 | ||
808 | 799 | @Callable(i) | |
809 | 800 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
810 | 801 | then throw("Invalid value passed") | |
811 | 802 | else { | |
812 | 803 | let estPut = commonPut(i, maxSlippage, false) | |
813 | - | estPut._9 | |
804 | + | let state = estPut._9 | |
805 | + | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
806 | + | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
807 | + | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
808 | + | if ((currentKLp == currentKLp)) | |
809 | + | then { | |
810 | + | let $t03575135816 = refreshKLpInternal(0, 0, 0) | |
811 | + | let refreshKLpActions = $t03575135816._1 | |
812 | + | let updatedKLp = $t03575135816._2 | |
813 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
814 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
815 | + | then (state ++ refreshKLpActions) | |
816 | + | else throw("Strict value is not equal to itself.") | |
817 | + | } | |
818 | + | else throw("Strict value is not equal to itself.") | |
814 | 819 | } | |
815 | 820 | ||
816 | 821 | ||
817 | 822 | ||
818 | 823 | @Callable(i) | |
819 | 824 | func putOneTkn (minOutAmount,autoStake) = { | |
820 | 825 | let isPoolOneTokenOperationsDisabled = { | |
821 | 826 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
822 | 827 | if ($isInstanceOf(@, "Boolean")) | |
823 | 828 | then @ | |
824 | 829 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
825 | 830 | } | |
826 | 831 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
827 | 832 | then true | |
828 | 833 | else (cfgPoolStatus == PoolPutDisabled)) | |
829 | 834 | then true | |
830 | 835 | else (cfgPoolStatus == PoolShutdown)) | |
831 | 836 | then true | |
832 | 837 | else isPoolOneTokenOperationsDisabled | |
833 | 838 | let checks = [if (if (!(isPutDisabled)) | |
834 | 839 | then true | |
835 | 840 | else isManager(i)) | |
836 | 841 | then true | |
837 | 842 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
838 | 843 | then true | |
839 | 844 | else throwErr("exactly 1 payment are expected")] | |
840 | 845 | if ((checks == checks)) | |
841 | 846 | then { | |
842 | 847 | let payment = i.payments[0] | |
843 | 848 | let paymentAssetId = payment.assetId | |
844 | 849 | let paymentAmountRaw = payment.amount | |
845 | - | let userAddress = i.caller | |
846 | - | let txId = i.transactionId | |
847 | - | let $t03429434424 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
848 | - | if (($t03429434424 == $t03429434424)) | |
850 | + | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
851 | + | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
852 | + | else if ((paymentAssetId == cfgPriceAssetId)) | |
853 | + | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
854 | + | else throwErr("payment asset is not supported") | |
855 | + | if ((currentKLp == currentKLp)) | |
849 | 856 | then { | |
850 | - | let bonus = $t03429434424._4 | |
851 | - | let feeAmount = $t03429434424._3 | |
852 | - | let commonState = $t03429434424._2 | |
853 | - | let emitAmountEstimated = $t03429434424._1 | |
854 | - | let emitAmount = if (if ((minOutAmount > 0)) | |
855 | - | then (minOutAmount > emitAmountEstimated) | |
856 | - | else false) | |
857 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
858 | - | else emitAmountEstimated | |
859 | - | let emitInv = emit(emitAmount) | |
860 | - | if ((emitInv == emitInv)) | |
857 | + | let userAddress = i.caller | |
858 | + | let txId = i.transactionId | |
859 | + | let $t03700437156 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
860 | + | if (($t03700437156 == $t03700437156)) | |
861 | 861 | then { | |
862 | - | let lpTransfer = if (autoStake) | |
862 | + | let paymentInAmountAsset = $t03700437156._5 | |
863 | + | let bonus = $t03700437156._4 | |
864 | + | let feeAmount = $t03700437156._3 | |
865 | + | let commonState = $t03700437156._2 | |
866 | + | let emitAmountEstimated = $t03700437156._1 | |
867 | + | let emitAmount = if (if ((minOutAmount > 0)) | |
868 | + | then (minOutAmount > emitAmountEstimated) | |
869 | + | else false) | |
870 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
871 | + | else emitAmountEstimated | |
872 | + | let emitInv = emit(emitAmount) | |
873 | + | if ((emitInv == emitInv)) | |
863 | 874 | then { | |
864 | - | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
865 | - | if ((stakeInv == stakeInv)) | |
866 | - | then nil | |
875 | + | let lpTransfer = if (autoStake) | |
876 | + | then { | |
877 | + | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
878 | + | if ((stakeInv == stakeInv)) | |
879 | + | then nil | |
880 | + | else throw("Strict value is not equal to itself.") | |
881 | + | } | |
882 | + | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
883 | + | let sendFee = if ((feeAmount > 0)) | |
884 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
885 | + | else nil | |
886 | + | let $t03774237939 = if ((this == feeCollectorAddress)) | |
887 | + | then $Tuple2(0, 0) | |
888 | + | else if (paymentInAmountAsset) | |
889 | + | then $Tuple2(-(feeAmount), 0) | |
890 | + | else $Tuple2(0, -(feeAmount)) | |
891 | + | let amountAssetBalanceDelta = $t03774237939._1 | |
892 | + | let priceAssetBalanceDelta = $t03774237939._2 | |
893 | + | let $t03794238050 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
894 | + | let refreshKLpActions = $t03794238050._1 | |
895 | + | let updatedKLp = $t03794238050._2 | |
896 | + | let kLp = value(getString(keyKLp)) | |
897 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
898 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
899 | + | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
867 | 900 | else throw("Strict value is not equal to itself.") | |
868 | 901 | } | |
869 | - | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
870 | - | let sendFee = if ((feeAmount > 0)) | |
871 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
872 | - | else nil | |
873 | - | $Tuple2(((commonState ++ lpTransfer) ++ sendFee), emitAmount) | |
902 | + | else throw("Strict value is not equal to itself.") | |
874 | 903 | } | |
875 | 904 | else throw("Strict value is not equal to itself.") | |
876 | 905 | } | |
877 | 906 | else throw("Strict value is not equal to itself.") | |
878 | 907 | } | |
879 | 908 | else throw("Strict value is not equal to itself.") | |
880 | 909 | } | |
881 | 910 | ||
882 | 911 | ||
883 | 912 | ||
884 | 913 | @Callable(i) | |
885 | 914 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
886 | - | let $t03515335288 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
887 | - | let emitAmountEstimated = $t03515335288._1 | |
888 | - | let commonState = $t03515335288._2 | |
889 | - | let feeAmount = $t03515335288._3 | |
890 | - | let bonus = $t03515335288._4 | |
915 | + | let $t03835638513 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
916 | + | let emitAmountEstimated = $t03835638513._1 | |
917 | + | let commonState = $t03835638513._2 | |
918 | + | let feeAmount = $t03835638513._3 | |
919 | + | let bonus = $t03835638513._4 | |
920 | + | let paymentInAmountAsset = $t03835638513._5 | |
891 | 921 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
892 | 922 | } | |
893 | 923 | ||
894 | 924 | ||
895 | 925 | ||
896 | 926 | @Callable(i) | |
897 | 927 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
898 | 928 | let isPoolOneTokenOperationsDisabled = { | |
899 | 929 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
900 | 930 | if ($isInstanceOf(@, "Boolean")) | |
901 | 931 | then @ | |
902 | 932 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
903 | 933 | } | |
904 | 934 | let isGetDisabled = if (if (isGlobalShutdown()) | |
905 | 935 | then true | |
906 | 936 | else (cfgPoolStatus == PoolShutdown)) | |
907 | 937 | then true | |
908 | 938 | else isPoolOneTokenOperationsDisabled | |
909 | 939 | let checks = [if (if (!(isGetDisabled)) | |
910 | 940 | then true | |
911 | 941 | else isManager(i)) | |
912 | 942 | then true | |
913 | 943 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
914 | 944 | then true | |
915 | 945 | else throwErr("exactly 1 payment are expected")] | |
916 | 946 | if ((checks == checks)) | |
917 | 947 | then { | |
918 | 948 | let outAssetId = parseAssetId(outAssetIdStr) | |
919 | 949 | let payment = i.payments[0] | |
920 | 950 | let paymentAssetId = payment.assetId | |
921 | 951 | let paymentAmount = payment.amount | |
922 | - | let userAddress = i.caller | |
923 | - | let txId = i.transactionId | |
924 | - | let $t03609336228 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
925 | - | if (($t03609336228 == $t03609336228)) | |
952 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
953 | + | if ((currentKLp == currentKLp)) | |
926 | 954 | then { | |
927 | - | let bonus = $t03609336228._4 | |
928 | - | let feeAmount = $t03609336228._3 | |
929 | - | let commonState = $t03609336228._2 | |
930 | - | let amountEstimated = $t03609336228._1 | |
931 | - | let amount = if (if ((minOutAmount > 0)) | |
932 | - | then (minOutAmount > amountEstimated) | |
933 | - | else false) | |
934 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
935 | - | else amountEstimated | |
936 | - | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
937 | - | if ((burnInv == burnInv)) | |
955 | + | let userAddress = i.caller | |
956 | + | let txId = i.transactionId | |
957 | + | let $t03939839551 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
958 | + | if (($t03939839551 == $t03939839551)) | |
938 | 959 | then { | |
939 | - | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
940 | - | let sendFee = if ((feeAmount > 0)) | |
941 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
942 | - | else nil | |
943 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
960 | + | let outInAmountAsset = $t03939839551._5 | |
961 | + | let bonus = $t03939839551._4 | |
962 | + | let feeAmount = $t03939839551._3 | |
963 | + | let commonState = $t03939839551._2 | |
964 | + | let amountEstimated = $t03939839551._1 | |
965 | + | let amount = if (if ((minOutAmount > 0)) | |
966 | + | then (minOutAmount > amountEstimated) | |
967 | + | else false) | |
968 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
969 | + | else amountEstimated | |
970 | + | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
971 | + | if ((burnInv == burnInv)) | |
972 | + | then { | |
973 | + | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
974 | + | let sendFee = if ((feeAmount > 0)) | |
975 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
976 | + | else nil | |
977 | + | let $t04005140298 = { | |
978 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
979 | + | then 0 | |
980 | + | else feeAmount | |
981 | + | if (outInAmountAsset) | |
982 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
983 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
984 | + | } | |
985 | + | let amountAssetBalanceDelta = $t04005140298._1 | |
986 | + | let priceAssetBalanceDelta = $t04005140298._2 | |
987 | + | let $t04030140409 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
988 | + | let refreshKLpActions = $t04030140409._1 | |
989 | + | let updatedKLp = $t04030140409._2 | |
990 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
991 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
992 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
993 | + | else throw("Strict value is not equal to itself.") | |
994 | + | } | |
995 | + | else throw("Strict value is not equal to itself.") | |
944 | 996 | } | |
945 | 997 | else throw("Strict value is not equal to itself.") | |
946 | 998 | } | |
947 | 999 | else throw("Strict value is not equal to itself.") | |
948 | 1000 | } | |
949 | 1001 | else throw("Strict value is not equal to itself.") | |
950 | 1002 | } | |
951 | 1003 | ||
952 | 1004 | ||
953 | 1005 | ||
954 | 1006 | @Callable(i) | |
955 | 1007 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
956 | - | let $t03686337001 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
957 | - | let amountEstimated = $t03686337001._1 | |
958 | - | let commonState = $t03686337001._2 | |
959 | - | let feeAmount = $t03686337001._3 | |
960 | - | let bonus = $t03686337001._4 | |
1008 | + | let $t04066640822 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1009 | + | let amountEstimated = $t04066640822._1 | |
1010 | + | let commonState = $t04066640822._2 | |
1011 | + | let feeAmount = $t04066640822._3 | |
1012 | + | let bonus = $t04066640822._4 | |
1013 | + | let outInAmountAsset = $t04066640822._5 | |
961 | 1014 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
962 | 1015 | } | |
963 | 1016 | ||
964 | 1017 | ||
965 | 1018 | ||
966 | 1019 | @Callable(i) | |
967 | 1020 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
968 | 1021 | let isPoolOneTokenOperationsDisabled = { | |
969 | 1022 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
970 | 1023 | if ($isInstanceOf(@, "Boolean")) | |
971 | 1024 | then @ | |
972 | 1025 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
973 | 1026 | } | |
974 | 1027 | let isGetDisabled = if (if (isGlobalShutdown()) | |
975 | 1028 | then true | |
976 | 1029 | else (cfgPoolStatus == PoolShutdown)) | |
977 | 1030 | then true | |
978 | 1031 | else isPoolOneTokenOperationsDisabled | |
979 | 1032 | let checks = [if (if (!(isGetDisabled)) | |
980 | 1033 | then true | |
981 | 1034 | else isManager(i)) | |
982 | 1035 | then true | |
983 | 1036 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
984 | 1037 | then true | |
985 | 1038 | else throwErr("no payments are expected")] | |
986 | 1039 | if ((checks == checks)) | |
987 | 1040 | then { | |
988 | 1041 | let outAssetId = parseAssetId(outAssetIdStr) | |
989 | 1042 | let userAddress = i.caller | |
990 | 1043 | let txId = i.transactionId | |
991 | - | let | |
992 | - | if (( | |
1044 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1045 | + | if ((currentKLp == currentKLp)) | |
993 | 1046 | then { | |
994 | - | let | |
995 | - | if (( | |
1047 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1048 | + | if ((unstakeInv == unstakeInv)) | |
996 | 1049 | then { | |
997 | - | let bonus = $t03782637959._4 | |
998 | - | let feeAmount = $t03782637959._3 | |
999 | - | let commonState = $t03782637959._2 | |
1000 | - | let amountEstimated = $t03782637959._1 | |
1001 | - | let amount = if (if ((minOutAmount > 0)) | |
1002 | - | then (minOutAmount > amountEstimated) | |
1003 | - | else false) | |
1004 | - | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1005 | - | else amountEstimated | |
1006 | - | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1007 | - | if ((burnInv == burnInv)) | |
1050 | + | let $t04172741878 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1051 | + | if (($t04172741878 == $t04172741878)) | |
1008 | 1052 | then { | |
1009 | - | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1010 | - | let sendFee = if ((feeAmount > 0)) | |
1011 | - | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1012 | - | else nil | |
1013 | - | $Tuple2(((commonState ++ assetTransfer) ++ sendFee), amount) | |
1053 | + | let outInAmountAsset = $t04172741878._5 | |
1054 | + | let bonus = $t04172741878._4 | |
1055 | + | let feeAmount = $t04172741878._3 | |
1056 | + | let commonState = $t04172741878._2 | |
1057 | + | let amountEstimated = $t04172741878._1 | |
1058 | + | let amount = if (if ((minOutAmount > 0)) | |
1059 | + | then (minOutAmount > amountEstimated) | |
1060 | + | else false) | |
1061 | + | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1062 | + | else amountEstimated | |
1063 | + | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1064 | + | if ((burnInv == burnInv)) | |
1065 | + | then { | |
1066 | + | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1067 | + | let sendFee = if ((feeAmount > 0)) | |
1068 | + | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1069 | + | else nil | |
1070 | + | let $t04237342620 = { | |
1071 | + | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1072 | + | then 0 | |
1073 | + | else feeAmount | |
1074 | + | if (outInAmountAsset) | |
1075 | + | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1076 | + | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1077 | + | } | |
1078 | + | let amountAssetBalanceDelta = $t04237342620._1 | |
1079 | + | let priceAssetBalanceDelta = $t04237342620._2 | |
1080 | + | let $t04262342731 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1081 | + | let refreshKLpActions = $t04262342731._1 | |
1082 | + | let updatedKLp = $t04262342731._2 | |
1083 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1084 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1085 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1086 | + | else throw("Strict value is not equal to itself.") | |
1087 | + | } | |
1088 | + | else throw("Strict value is not equal to itself.") | |
1014 | 1089 | } | |
1015 | 1090 | else throw("Strict value is not equal to itself.") | |
1016 | 1091 | } | |
1017 | 1092 | else throw("Strict value is not equal to itself.") | |
1018 | 1093 | } | |
1019 | 1094 | else throw("Strict value is not equal to itself.") | |
1020 | 1095 | } | |
1021 | 1096 | else throw("Strict value is not equal to itself.") | |
1022 | 1097 | } | |
1023 | 1098 | ||
1024 | 1099 | ||
1025 | 1100 | ||
1026 | 1101 | @Callable(i) | |
1027 | 1102 | func get () = { | |
1028 | 1103 | let res = commonGet(i) | |
1029 | 1104 | let outAmtAmt = res._1 | |
1030 | 1105 | let outPrAmt = res._2 | |
1031 | 1106 | let pmtAmt = res._3 | |
1032 | 1107 | let pmtAssetId = res._4 | |
1033 | 1108 | let state = res._5 | |
1034 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1035 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1036 | - | then state | |
1109 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1110 | + | if ((currentKLp == currentKLp)) | |
1111 | + | then { | |
1112 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1113 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1114 | + | then { | |
1115 | + | let $t04367743759 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1116 | + | let refreshKLpActions = $t04367743759._1 | |
1117 | + | let updatedKLp = $t04367743759._2 | |
1118 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1119 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1120 | + | then (state ++ refreshKLpActions) | |
1121 | + | else throw("Strict value is not equal to itself.") | |
1122 | + | } | |
1123 | + | else throw("Strict value is not equal to itself.") | |
1124 | + | } | |
1037 | 1125 | else throw("Strict value is not equal to itself.") | |
1038 | 1126 | } | |
1039 | 1127 | ||
1040 | 1128 | ||
1041 | 1129 | ||
1042 | 1130 | @Callable(i) | |
1043 | 1131 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1044 | 1132 | let res = commonGet(i) | |
1045 | 1133 | let outAmAmt = res._1 | |
1046 | 1134 | let outPrAmt = res._2 | |
1047 | 1135 | let pmtAmt = res._3 | |
1048 | 1136 | let pmtAssetId = res._4 | |
1049 | 1137 | let state = res._5 | |
1050 | 1138 | if ((noLessThenAmtAsset > outAmAmt)) | |
1051 | 1139 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1052 | 1140 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1053 | 1141 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1054 | 1142 | else { | |
1055 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1056 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1057 | - | then state | |
1143 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1144 | + | if ((currentKLp == currentKLp)) | |
1145 | + | then { | |
1146 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1147 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1148 | + | then { | |
1149 | + | let $t04470844789 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1150 | + | let refreshKLpActions = $t04470844789._1 | |
1151 | + | let updatedKLp = $t04470844789._2 | |
1152 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1153 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1154 | + | then (state ++ refreshKLpActions) | |
1155 | + | else throw("Strict value is not equal to itself.") | |
1156 | + | } | |
1157 | + | else throw("Strict value is not equal to itself.") | |
1158 | + | } | |
1058 | 1159 | else throw("Strict value is not equal to itself.") | |
1059 | 1160 | } | |
1060 | 1161 | } | |
1061 | 1162 | ||
1062 | 1163 | ||
1063 | 1164 | ||
1064 | 1165 | @Callable(i) | |
1065 | 1166 | func unstakeAndGet (amount) = { | |
1066 | 1167 | let checkPayments = if ((size(i.payments) != 0)) | |
1067 | 1168 | then throw("No payments are expected") | |
1068 | 1169 | else true | |
1069 | 1170 | if ((checkPayments == checkPayments)) | |
1070 | 1171 | then { | |
1071 | 1172 | let cfg = getPoolConfig() | |
1072 | 1173 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1073 | - | let | |
1074 | - | if (( | |
1174 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1175 | + | if ((currentKLp == currentKLp)) | |
1075 | 1176 | then { | |
1076 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1077 | - | let poolStatus = parseIntValue(res._9) | |
1078 | - | let state = res._10 | |
1079 | - | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1080 | - | then true | |
1081 | - | else (poolStatus == PoolShutdown)) | |
1082 | - | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1083 | - | else true | |
1084 | - | if ((checkPoolStatus == checkPoolStatus)) | |
1177 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1178 | + | if ((unstakeInv == unstakeInv)) | |
1085 | 1179 | then { | |
1086 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1087 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1088 | - | then state | |
1180 | + | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1181 | + | let outAmAmt = res._1 | |
1182 | + | let outPrAmt = res._2 | |
1183 | + | let poolStatus = parseIntValue(res._9) | |
1184 | + | let state = res._10 | |
1185 | + | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1186 | + | then true | |
1187 | + | else (poolStatus == PoolShutdown)) | |
1188 | + | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1189 | + | else true | |
1190 | + | if ((checkPoolStatus == checkPoolStatus)) | |
1191 | + | then { | |
1192 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1193 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1194 | + | then { | |
1195 | + | let $t04591545996 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1196 | + | let refreshKLpActions = $t04591545996._1 | |
1197 | + | let updatedKLp = $t04591545996._2 | |
1198 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1199 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1200 | + | then (state ++ refreshKLpActions) | |
1201 | + | else throw("Strict value is not equal to itself.") | |
1202 | + | } | |
1203 | + | else throw("Strict value is not equal to itself.") | |
1204 | + | } | |
1089 | 1205 | else throw("Strict value is not equal to itself.") | |
1090 | 1206 | } | |
1091 | 1207 | else throw("Strict value is not equal to itself.") | |
1092 | 1208 | } | |
1093 | 1209 | else throw("Strict value is not equal to itself.") | |
1094 | 1210 | } | |
1095 | 1211 | else throw("Strict value is not equal to itself.") | |
1096 | 1212 | } | |
1097 | 1213 | ||
1098 | 1214 | ||
1099 | 1215 | ||
1100 | 1216 | @Callable(i) | |
1101 | 1217 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1102 | 1218 | let isGetDisabled = if (isGlobalShutdown()) | |
1103 | 1219 | then true | |
1104 | 1220 | else (cfgPoolStatus == PoolShutdown) | |
1105 | 1221 | let checks = [if (!(isGetDisabled)) | |
1106 | 1222 | then true | |
1107 | 1223 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1108 | 1224 | then true | |
1109 | 1225 | else throw("no payments are expected")] | |
1110 | 1226 | if ((checks == checks)) | |
1111 | 1227 | then { | |
1112 | - | let | |
1113 | - | if (( | |
1228 | + | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1229 | + | if ((currentKLp == currentKLp)) | |
1114 | 1230 | then { | |
1115 | - | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1116 | - | let outAmAmt = res._1 | |
1117 | - | let outPrAmt = res._2 | |
1118 | - | let state = res._10 | |
1119 | - | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1120 | - | then true | |
1121 | - | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1122 | - | then true | |
1123 | - | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1124 | - | if ((checkAmounts == checkAmounts)) | |
1231 | + | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1232 | + | if ((unstakeInv == unstakeInv)) | |
1125 | 1233 | then { | |
1126 | - | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1127 | - | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1128 | - | then state | |
1234 | + | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1235 | + | let outAmAmt = res._1 | |
1236 | + | let outPrAmt = res._2 | |
1237 | + | let state = res._10 | |
1238 | + | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1239 | + | then true | |
1240 | + | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1241 | + | then true | |
1242 | + | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1243 | + | if ((checkAmounts == checkAmounts)) | |
1244 | + | then { | |
1245 | + | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1246 | + | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1247 | + | then { | |
1248 | + | let $t04729147372 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1249 | + | let refreshKLpActions = $t04729147372._1 | |
1250 | + | let updatedKLp = $t04729147372._2 | |
1251 | + | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1252 | + | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1253 | + | then (state ++ refreshKLpActions) | |
1254 | + | else throw("Strict value is not equal to itself.") | |
1255 | + | } | |
1256 | + | else throw("Strict value is not equal to itself.") | |
1257 | + | } | |
1129 | 1258 | else throw("Strict value is not equal to itself.") | |
1130 | 1259 | } | |
1131 | 1260 | else throw("Strict value is not equal to itself.") | |
1132 | 1261 | } | |
1133 | 1262 | else throw("Strict value is not equal to itself.") | |
1134 | 1263 | } | |
1135 | 1264 | else throw("Strict value is not equal to itself.") | |
1136 | 1265 | } | |
1137 | 1266 | ||
1138 | 1267 | ||
1139 | 1268 | ||
1140 | 1269 | @Callable(i) | |
1141 | 1270 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1142 | 1271 | then throw("permissions denied") | |
1143 | 1272 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1273 | + | ||
1274 | + | ||
1275 | + | ||
1276 | + | @Callable(i) | |
1277 | + | func refreshKLp () = { | |
1278 | + | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1279 | + | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1280 | + | then unit | |
1281 | + | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1282 | + | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1283 | + | then { | |
1284 | + | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1285 | + | let $t04855948623 = refreshKLpInternal(0, 0, 0) | |
1286 | + | let kLpUpdateActions = $t04855948623._1 | |
1287 | + | let updatedKLp = $t04855948623._2 | |
1288 | + | let actions = if ((kLp != updatedKLp)) | |
1289 | + | then kLpUpdateActions | |
1290 | + | else throwErr("nothing to refresh") | |
1291 | + | $Tuple2(actions, toString(updatedKLp)) | |
1292 | + | } | |
1293 | + | else throw("Strict value is not equal to itself.") | |
1294 | + | } | |
1144 | 1295 | ||
1145 | 1296 | ||
1146 | 1297 | ||
1147 | 1298 | @Callable(i) | |
1148 | 1299 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1149 | 1300 | ||
1150 | 1301 | ||
1151 | 1302 | ||
1152 | 1303 | @Callable(i) | |
1153 | 1304 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1154 | 1305 | ||
1155 | 1306 | ||
1156 | 1307 | ||
1157 | 1308 | @Callable(i) | |
1158 | 1309 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1159 | 1310 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1160 | 1311 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1161 | 1312 | } | |
1162 | 1313 | ||
1163 | 1314 | ||
1164 | 1315 | ||
1165 | 1316 | @Callable(i) | |
1166 | 1317 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1167 | 1318 | ||
1168 | 1319 | ||
1169 | 1320 | ||
1170 | 1321 | @Callable(i) | |
1171 | 1322 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1172 | 1323 | ||
1173 | 1324 | ||
1174 | 1325 | ||
1175 | 1326 | @Callable(i) | |
1176 | 1327 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1177 | 1328 | ||
1178 | 1329 | ||
1179 | 1330 | ||
1180 | 1331 | @Callable(i) | |
1181 | 1332 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1182 | 1333 | ||
1183 | 1334 | ||
1184 | 1335 | ||
1185 | 1336 | @Callable(i) | |
1186 | 1337 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1187 | 1338 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1188 | 1339 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1189 | 1340 | } | |
1190 | 1341 | ||
1191 | 1342 | ||
1192 | 1343 | ||
1193 | 1344 | @Callable(i) | |
1194 | 1345 | func statsREADONLY () = { | |
1195 | 1346 | let cfg = getPoolConfig() | |
1196 | 1347 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1197 | 1348 | let amtAssetId = cfg[idxAmtAssetId] | |
1198 | 1349 | let priceAssetId = cfg[idxPriceAssetId] | |
1199 | 1350 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1200 | 1351 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1201 | 1352 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1202 | 1353 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1203 | 1354 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1204 | 1355 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1205 | 1356 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1206 | 1357 | let pricesList = if ((poolLPBalance == 0)) | |
1207 | 1358 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1208 | 1359 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1209 | 1360 | let curPrice = 0 | |
1210 | 1361 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1211 | 1362 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1212 | 1363 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1213 | 1364 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(accAmtAssetBalance), toString(accPriceAssetBalance), toString(poolLPBalance), toString(curPrice), toString(lpAmtAssetShare), toString(lpPriceAssetShare), toString(poolWeight)], SEP)) | |
1214 | 1365 | } | |
1215 | 1366 | ||
1216 | 1367 | ||
1217 | 1368 | ||
1218 | 1369 | @Callable(i) | |
1219 | 1370 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1220 | 1371 | let cfg = getPoolConfig() | |
1221 | 1372 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1222 | 1373 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1223 | 1374 | let amAssetId = fromBase58String(amAssetIdStr) | |
1224 | 1375 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1225 | 1376 | let prAssetId = fromBase58String(prAssetIdStr) | |
1226 | 1377 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1227 | 1378 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1228 | 1379 | let poolStatus = cfg[idxPoolStatus] | |
1229 | 1380 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1230 | 1381 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1231 | 1382 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1232 | 1383 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1233 | 1384 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1234 | 1385 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1235 | 1386 | then zeroBigInt | |
1236 | 1387 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1237 | 1388 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1238 | 1389 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1239 | 1390 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1240 | 1391 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1241 | 1392 | let calcLpAmt = estPut._1 | |
1242 | 1393 | let curPriceCalc = estPut._3 | |
1243 | 1394 | let amBalance = estPut._4 | |
1244 | 1395 | let prBalance = estPut._5 | |
1245 | 1396 | let lpEmission = estPut._6 | |
1246 | 1397 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
1247 | 1398 | } | |
1248 | 1399 | ||
1249 | 1400 | ||
1250 | 1401 | ||
1251 | 1402 | @Callable(i) | |
1252 | 1403 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1253 | 1404 | let cfg = getPoolConfig() | |
1254 | 1405 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1255 | 1406 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1256 | 1407 | let amAssetId = fromBase58String(amAssetIdStr) | |
1257 | 1408 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1258 | 1409 | let prAssetId = fromBase58String(prAssetIdStr) | |
1259 | 1410 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1260 | 1411 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1261 | 1412 | let poolStatus = cfg[idxPoolStatus] | |
1262 | 1413 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1263 | 1414 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1264 | 1415 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1265 | 1416 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1266 | 1417 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1267 | 1418 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1268 | 1419 | then zeroBigInt | |
1269 | 1420 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1270 | 1421 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1271 | 1422 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1272 | 1423 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1273 | 1424 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1274 | 1425 | let calcLpAmt = estPut._1 | |
1275 | 1426 | let curPriceCalc = estPut._3 | |
1276 | 1427 | let amBalance = estPut._4 | |
1277 | 1428 | let prBalance = estPut._5 | |
1278 | 1429 | let lpEmission = estPut._6 | |
1279 | 1430 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d%d", toString(calcLpAmt), toString(fromX18(curPriceX18, scale8)), toString(amBalance), toString(prBalance), toString(lpEmission), poolStatus, toString(inAmAssetAmt), toString(inPrAssetAmt)], SEP)) | |
1280 | 1431 | } | |
1281 | 1432 | ||
1282 | 1433 | ||
1283 | 1434 | ||
1284 | 1435 | @Callable(i) | |
1285 | 1436 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1286 | 1437 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1287 | 1438 | let outAmAmt = res._1 | |
1288 | 1439 | let outPrAmt = res._2 | |
1289 | 1440 | let amBalance = res._5 | |
1290 | 1441 | let prBalance = res._6 | |
1291 | 1442 | let lpEmission = res._7 | |
1292 | 1443 | let curPrice = res._8 | |
1293 | 1444 | let poolStatus = parseIntValue(res._9) | |
1294 | 1445 | $Tuple2(nil, makeString(["%d%d%d%d%d%d%d", toString(outAmAmt), toString(outPrAmt), toString(amBalance), toString(prBalance), toString(lpEmission), toString(curPrice), toString(poolStatus)], SEP)) | |
1295 | 1446 | } | |
1296 | 1447 | ||
1297 | 1448 | ||
1298 | 1449 | @Verifier(tx) | |
1299 | 1450 | func verify () = { | |
1300 | 1451 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1301 | 1452 | case pk: ByteVector => | |
1302 | 1453 | pk | |
1303 | 1454 | case _: Unit => | |
1304 | 1455 | tx.senderPublicKey | |
1305 | 1456 | case _ => | |
1306 | 1457 | throw("Match error") | |
1307 | 1458 | } | |
1308 | 1459 | match tx { | |
1309 | 1460 | case order: Order => | |
1310 | 1461 | let matcherPub = getMatcherPubOrFail() | |
1311 | - | let orderValid = validateMatcherOrderAllowed(order) | |
1462 | + | let $t05728557354 = validateMatcherOrderAllowed(order) | |
1463 | + | let orderValid = $t05728557354._1 | |
1464 | + | let orderValidInfo = $t05728557354._2 | |
1312 | 1465 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1313 | 1466 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1314 | 1467 | if (if (if (orderValid) | |
1315 | 1468 | then senderValid | |
1316 | 1469 | else false) | |
1317 | 1470 | then matcherValid | |
1318 | 1471 | else false) | |
1319 | 1472 | then true | |
1320 | - | else throwOrderError(orderValid, senderValid, matcherValid) | |
1473 | + | else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid) | |
1321 | 1474 | case s: SetScriptTransaction => | |
1322 | - | let newHash = blake2b256(value(s.script)) | |
1323 | - | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1324 | - | let currentHash = scriptHash(this) | |
1325 | - | if (if ((allowedHash == newHash)) | |
1326 | - | then (currentHash != newHash) | |
1327 | - | else false) | |
1475 | + | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1328 | 1476 | then true | |
1329 | - | else sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1477 | + | else { | |
1478 | + | let newHash = blake2b256(value(s.script)) | |
1479 | + | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1480 | + | let currentHash = scriptHash(this) | |
1481 | + | if ((allowedHash == newHash)) | |
1482 | + | then (currentHash != newHash) | |
1483 | + | else false | |
1484 | + | } | |
1330 | 1485 | case _ => | |
1331 | 1486 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1332 | 1487 | } | |
1333 | 1488 | } | |
1334 | 1489 |
github/deemru/w8io/026f985 174.48 ms ◑