tx · 9eQDLr195DKt1eCpGGydqr2s8gg81GXTJaB3bZBoHx9A 3N3LtGiBDqDjfHpd7WnTCTKXB3gPWqUrDLL: -0.03800000 Waves 2023.04.06 17:30 [2522825] smart account 3N3LtGiBDqDjfHpd7WnTCTKXB3gPWqUrDLL > SELF 0.00000000 Waves
{ "type": 13, "id": "9eQDLr195DKt1eCpGGydqr2s8gg81GXTJaB3bZBoHx9A", "fee": 3800000, "feeAssetId": null, "timestamp": 1680791414430, "version": 2, "chainId": 84, "sender": "3N3LtGiBDqDjfHpd7WnTCTKXB3gPWqUrDLL", "senderPublicKey": "3wnnbmrpP3X4LxULFVHTeu7zNZBzFV7NSxRokwryVFaJ", "proofs": [ "5S2TFnStLJR8BMaYRwkLEY3A8ktEdBqtYFPVFD8PaMvjBax1y3mst7sdjGChev7nDJnsAxs8fNZMujiYs3sGdagy" ], "script": "base64:BgLiLwgCEgUKAwEEARIHCgUBBAEIARIDCgEIEgASBAoCAQQSAwoBARIECgIBBBIECgIIARIECgIIARIECgIIARIFCgMBCAESABIECgIBARIDCgEBEgUKAwEBARIECgIICBIAEgASAwoBCBIFCgMBAQESBAoCAQESBAoCCAESBAoCCAgSCwoJCAEBAgECCAQEEgYKBAgIAQgSABIDCgEBEgMKAQESBAoCCAEiCmxQZGVjaW1hbHMiBnNjYWxlOCIMc2NhbGU4QmlnSW50IgdzY2FsZTE4Igp6ZXJvQmlnSW50IgRiaWcwIgRiaWcxIgRiaWcyIgt3YXZlc1N0cmluZyIDU0VQIgpQb29sQWN0aXZlIg9Qb29sUHV0RGlzYWJsZWQiE1Bvb2xNYXRjaGVyRGlzYWJsZWQiDFBvb2xTaHV0ZG93biIOaWR4UG9vbEFkZHJlc3MiDWlkeFBvb2xTdGF0dXMiEGlkeFBvb2xMUEFzc2V0SWQiDWlkeEFtdEFzc2V0SWQiD2lkeFByaWNlQXNzZXRJZCIOaWR4QW10QXNzZXREY20iEGlkeFByaWNlQXNzZXREY20iDmlkeElBbXRBc3NldElk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AAAgFAmRBD3NlbmRlclB1YmxpY0tleQQCYUcJAPQDAwgFAmRBCWJvZHlCeXRlcwkAkQMCCAUCZEEGcHJvb2ZzAAEFAmhjAwMDBQJhRAUCYUYHBQJhRwcGCQECYUMEBQJhRAUCYUUFAmFGBQJhRwMJAAECBQJkVwIUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAmZhBQJkVwMJAPQDAwgFAmdaCWJvZHlCeXRlcwkAkQMCCAUCZ1oGcHJvb2ZzAAAFAmhiBgQCaGUJAPYDAQkBBXZhbHVlAQgFAmZhBnNjcmlwdAQCaGYJANsEAQkBBXZhbHVlAQkAnQgCBQJhTwkBAmFBAAQCaGcJAPEHAQUEdGhpcwMJAAACBQJoZgUCaGUJAQIhPQIFAmhnBQJoZQcJAPQDAwgFAmdaCWJvZHlCeXRlcwkAkQMCCAUCZ1oGcHJvb2ZzAAAFAmhiqF/ylA==", "height": 2522825, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Fqoxy1w8o5Hkp11tzgXo7rx64A1dqbCZzteCAc1PYmg5 Next: AddZaFeP1D6xnNbpEnsFK7sPBday1aH1obmiUFhEwU8H Diff:
Old | New | Differences | |
---|---|---|---|
130 | 130 | ||
131 | 131 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
132 | 132 | ||
133 | - | func keyAdditionalBalance (assetId) = makeString(["%s%s", "stakedBalance", assetId], SEP) | |
134 | - | ||
135 | - | ||
136 | - | func keyStakingAssetBalance (assetId) = makeString(["%s%s", "shareAssetBalance", assetId], SEP) | |
137 | - | ||
138 | - | ||
139 | - | func getAdditionalBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0) | |
140 | - | ||
141 | - | ||
142 | - | func getStakingAssetBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0) | |
143 | - | ||
144 | - | ||
145 | 133 | func keyFactoryConfig () = "%s__factoryConfig" | |
146 | 134 | ||
147 | 135 | ||
231 | 219 | ||
232 | 220 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
233 | 221 | ||
234 | - | let $ | |
222 | + | let $t084698635 = poolConfigParsed | |
235 | 223 | ||
236 | - | let cfgPoolAddress = $ | |
224 | + | let cfgPoolAddress = $t084698635._1 | |
237 | 225 | ||
238 | - | let cfgPoolStatus = $ | |
226 | + | let cfgPoolStatus = $t084698635._2 | |
239 | 227 | ||
240 | - | let cfgLpAssetId = $ | |
228 | + | let cfgLpAssetId = $t084698635._3 | |
241 | 229 | ||
242 | - | let cfgAmountAssetId = $ | |
230 | + | let cfgAmountAssetId = $t084698635._4 | |
243 | 231 | ||
244 | - | let cfgPriceAssetId = $ | |
232 | + | let cfgPriceAssetId = $t084698635._5 | |
245 | 233 | ||
246 | - | let cfgAmountAssetDecimals = $ | |
234 | + | let cfgAmountAssetDecimals = $t084698635._6 | |
247 | 235 | ||
248 | - | let cfgPriceAssetDecimals = $ | |
236 | + | let cfgPriceAssetDecimals = $t084698635._7 | |
249 | 237 | ||
250 | 238 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
251 | 239 | ||
260 | 248 | 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) | |
261 | 249 | ||
262 | 250 | ||
263 | - | func getAccBalance (assetId) = { | |
264 | - | let balanceOnPool = if ((assetId == "WAVES")) | |
265 | - | then wavesBalance(this).available | |
266 | - | else assetBalance(this, fromBase58String(assetId)) | |
267 | - | let totalBalance = ((balanceOnPool + getAdditionalBalanceOrZero(assetId)) - getStakingAssetBalanceOrZero(assetId)) | |
268 | - | max([0, totalBalance]) | |
269 | - | } | |
251 | + | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
252 | + | then wavesBalance(this).available | |
253 | + | else assetBalance(this, fromBase58String(assetId)) | |
270 | 254 | ||
271 | 255 | ||
272 | 256 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
273 | 257 | ||
274 | 258 | ||
275 | 259 | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
276 | - | ||
277 | - | ||
278 | - | func getRate (proxy) = { | |
279 | - | let inv = invoke(proxy, "getRate", nil, nil) | |
280 | - | if ((inv == inv)) | |
281 | - | then match inv { | |
282 | - | case r: Int => | |
283 | - | r | |
284 | - | case _ => | |
285 | - | throwErr("proxy.getRate() unexpected value") | |
286 | - | } | |
287 | - | else throw("Strict value is not equal to itself.") | |
288 | - | } | |
289 | - | ||
290 | - | ||
291 | - | func deposit (assetId,amount,stakingAssetId,proxy) = { | |
292 | - | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
293 | - | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
294 | - | then { | |
295 | - | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
296 | - | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
297 | - | then { | |
298 | - | let asset = parseAssetId(assetId) | |
299 | - | if ((amount > 0)) | |
300 | - | then { | |
301 | - | let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)]) | |
302 | - | if ((depositInvoke == depositInvoke)) | |
303 | - | then match depositInvoke { | |
304 | - | case receivedStakingAsset: Int => | |
305 | - | let newAdditionalBalance = (currentAdditionalBalance + amount) | |
306 | - | let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset) | |
307 | - | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
308 | - | case _ => | |
309 | - | nil | |
310 | - | } | |
311 | - | else throw("Strict value is not equal to itself.") | |
312 | - | } | |
313 | - | else nil | |
314 | - | } | |
315 | - | else throw("Strict value is not equal to itself.") | |
316 | - | } | |
317 | - | else throw("Strict value is not equal to itself.") | |
318 | - | } | |
319 | - | ||
320 | - | ||
321 | - | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = { | |
322 | - | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
323 | - | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
324 | - | then { | |
325 | - | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
326 | - | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
327 | - | then { | |
328 | - | let currentProxyRate = getRate(proxy) | |
329 | - | if ((currentProxyRate == currentProxyRate)) | |
330 | - | then { | |
331 | - | let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance) | |
332 | - | let stakingAsset = parseAssetId(stakingAssetId) | |
333 | - | let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate) | |
334 | - | let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate) | |
335 | - | let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)]) | |
336 | - | if ((sendStakingAssetAmount > 0)) | |
337 | - | then { | |
338 | - | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)]) | |
339 | - | if ((withdrawInvoke == withdrawInvoke)) | |
340 | - | then match withdrawInvoke { | |
341 | - | case receivedAssets: Int => | |
342 | - | let newAdditionalBalance = (currentAdditionalBalance - receivedAssets) | |
343 | - | let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount) | |
344 | - | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))] | |
345 | - | case _ => | |
346 | - | nil | |
347 | - | } | |
348 | - | else throw("Strict value is not equal to itself.") | |
349 | - | } | |
350 | - | else nil | |
351 | - | } | |
352 | - | else throw("Strict value is not equal to itself.") | |
353 | - | } | |
354 | - | else throw("Strict value is not equal to itself.") | |
355 | - | } | |
356 | - | else throw("Strict value is not equal to itself.") | |
357 | - | } | |
358 | - | ||
359 | - | ||
360 | - | func getLeaseProxyConfig (assetId) = match invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) { | |
361 | - | case a: (Boolean, Int, Int, String, String, Int, String) => | |
362 | - | a | |
363 | - | case _ => | |
364 | - | throwErr((("[" + assetId) + "] getLeaseProxyConfig() error")) | |
365 | - | } | |
366 | - | ||
367 | - | ||
368 | - | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = { | |
369 | - | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
370 | - | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
371 | - | then { | |
372 | - | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
373 | - | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
374 | - | then { | |
375 | - | let leasableTotalBalance = max([0, (getAccBalance(assetId) - minBalance)]) | |
376 | - | let targetAdditionalBalance = fraction(targetRatio, leasableTotalBalance, 100) | |
377 | - | let diff = (currentAdditionalBalance - targetAdditionalBalance) | |
378 | - | if ((diff == 0)) | |
379 | - | then nil | |
380 | - | else if ((0 > diff)) | |
381 | - | then { | |
382 | - | let sendAssetAmount = -(diff) | |
383 | - | deposit(assetId, sendAssetAmount, stakingAssetId, proxy) | |
384 | - | } | |
385 | - | else { | |
386 | - | let getAssetAmount = diff | |
387 | - | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress) | |
388 | - | } | |
389 | - | } | |
390 | - | else throw("Strict value is not equal to itself.") | |
391 | - | } | |
392 | - | else throw("Strict value is not equal to itself.") | |
393 | - | } | |
394 | - | ||
395 | - | ||
396 | - | func rebalanceAsset (assetId) = { | |
397 | - | let $t01536415500 = getLeaseProxyConfig(assetId) | |
398 | - | let isLeasable = $t01536415500._1 | |
399 | - | let leasedRatio = $t01536415500._2 | |
400 | - | let minBalance = $t01536415500._3 | |
401 | - | let proxyAddress = $t01536415500._4 | |
402 | - | let proxyAssetId = $t01536415500._5 | |
403 | - | let proxyRateMul = $t01536415500._6 | |
404 | - | let stakingProfitAddress = $t01536415500._7 | |
405 | - | if (isLeasable) | |
406 | - | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
407 | - | else nil | |
408 | - | } | |
409 | - | ||
410 | - | ||
411 | - | func withdrawAndRebalanceAsset (assetId,getAmount) = { | |
412 | - | let $t01588916025 = getLeaseProxyConfig(assetId) | |
413 | - | let isLeasable = $t01588916025._1 | |
414 | - | let leasedRatio = $t01588916025._2 | |
415 | - | let minBalance = $t01588916025._3 | |
416 | - | let proxyAddress = $t01588916025._4 | |
417 | - | let proxyAssetId = $t01588916025._5 | |
418 | - | let proxyRateMul = $t01588916025._6 | |
419 | - | let stakingProfitAddress = $t01588916025._7 | |
420 | - | if (isLeasable) | |
421 | - | then { | |
422 | - | let newTotalLeasableBalance = max([0, ((getAccBalance(assetId) - getAmount) - minBalance)]) | |
423 | - | if ((newTotalLeasableBalance == newTotalLeasableBalance)) | |
424 | - | then { | |
425 | - | let newAdditionalBalance = fraction(leasedRatio, newTotalLeasableBalance, 100) | |
426 | - | if ((newAdditionalBalance == newAdditionalBalance)) | |
427 | - | then { | |
428 | - | let withdrawAmount = max([0, (getAdditionalBalanceOrZero(assetId) - newAdditionalBalance)]) | |
429 | - | if ((withdrawAmount == withdrawAmount)) | |
430 | - | then withdraw(assetId, withdrawAmount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
431 | - | else throw("Strict value is not equal to itself.") | |
432 | - | } | |
433 | - | else throw("Strict value is not equal to itself.") | |
434 | - | } | |
435 | - | else throw("Strict value is not equal to itself.") | |
436 | - | } | |
437 | - | else nil | |
438 | - | } | |
439 | - | ||
440 | - | ||
441 | - | func withdrawAndRebalanceAll (amountAssetOutAmount,priceAssetOutAmount) = { | |
442 | - | let AmAmtWithdrawState = withdrawAndRebalanceAsset(getStringOrFail(this, aa()), amountAssetOutAmount) | |
443 | - | let PrAmtWithdrawState = withdrawAndRebalanceAsset(getStringOrFail(this, pa()), priceAssetOutAmount) | |
444 | - | (AmAmtWithdrawState ++ PrAmtWithdrawState) | |
445 | - | } | |
446 | 260 | ||
447 | 261 | ||
448 | 262 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
624 | 438 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
625 | 439 | let amountAssetAmount = order.amount | |
626 | 440 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
627 | - | let $ | |
441 | + | let $t02154121753 = if ((order.orderType == Buy)) | |
628 | 442 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
629 | 443 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
630 | - | let amountAssetBalanceDelta = $ | |
631 | - | let priceAssetBalanceDelta = $ | |
444 | + | let amountAssetBalanceDelta = $t02154121753._1 | |
445 | + | let priceAssetBalanceDelta = $t02154121753._2 | |
632 | 446 | if (if (if (isGlobalShutdown()) | |
633 | 447 | then true | |
634 | 448 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
641 | 455 | then throw("Wrong order assets.") | |
642 | 456 | else { | |
643 | 457 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
644 | - | let $ | |
645 | - | let unusedActions = $ | |
646 | - | let kLpNew = $ | |
458 | + | let $t02219322293 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
459 | + | let unusedActions = $t02219322293._1 | |
460 | + | let kLpNew = $t02219322293._2 | |
647 | 461 | let isOrderValid = (kLpNew >= kLp) | |
648 | 462 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
649 | 463 | $Tuple2(isOrderValid, info) | |
722 | 536 | else if ((paymentAssetId == cfgPriceAssetId)) | |
723 | 537 | then false | |
724 | 538 | else throwErr("invalid asset") | |
725 | - | let $ | |
539 | + | let $t02540625699 = if (isEval) | |
726 | 540 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
727 | 541 | else if (paymentInAmountAsset) | |
728 | 542 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
729 | 543 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
730 | - | let amountBalanceOld = $ | |
731 | - | let priceBalanceOld = $ | |
732 | - | let $ | |
544 | + | let amountBalanceOld = $t02540625699._1 | |
545 | + | let priceBalanceOld = $t02540625699._2 | |
546 | + | let $t02570325852 = if (paymentInAmountAsset) | |
733 | 547 | then $Tuple2(paymentAmountRaw, 0) | |
734 | 548 | else $Tuple2(0, paymentAmountRaw) | |
735 | - | let amountAssetAmountRaw = $ | |
736 | - | let priceAssetAmountRaw = $ | |
549 | + | let amountAssetAmountRaw = $t02570325852._1 | |
550 | + | let priceAssetAmountRaw = $t02570325852._2 | |
737 | 551 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
738 | 552 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
739 | - | let $ | |
740 | - | let paymentAmount = $ | |
741 | - | let feeAmount = $ | |
553 | + | let $t02598426048 = takeFee(paymentAmountRaw, inFee) | |
554 | + | let paymentAmount = $t02598426048._1 | |
555 | + | let feeAmount = $t02598426048._2 | |
742 | 556 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
743 | 557 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
744 | 558 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
761 | 575 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
762 | 576 | let priceOld = fromX18(priceOldX18, scale8) | |
763 | 577 | let loss = { | |
764 | - | let $ | |
578 | + | let $t02772927896 = if (paymentInAmountAsset) | |
765 | 579 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
766 | 580 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
767 | - | let amount = $ | |
768 | - | let balance = $ | |
581 | + | let amount = $t02772927896._1 | |
582 | + | let balance = $t02772927896._2 | |
769 | 583 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
770 | 584 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
771 | 585 | } | |
805 | 619 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
806 | 620 | let redeemedBigInt = toBigInt(paymentAmount) | |
807 | 621 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
808 | - | let $ | |
809 | - | let totalAmount = $ | |
810 | - | let feeAmount = $ | |
811 | - | let $ | |
622 | + | let $t02997430030 = takeFee(amountRaw, outFee) | |
623 | + | let totalAmount = $t02997430030._1 | |
624 | + | let feeAmount = $t02997430030._2 | |
625 | + | let $t03003430260 = if (outInAmountAsset) | |
812 | 626 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
813 | 627 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
814 | - | let outAmAmount = $ | |
815 | - | let outPrAmount = $ | |
816 | - | let amBalanceNew = $ | |
817 | - | let prBalanceNew = $ | |
628 | + | let outAmAmount = $t03003430260._1 | |
629 | + | let outPrAmount = $t03003430260._2 | |
630 | + | let amBalanceNew = $t03003430260._3 | |
631 | + | let prBalanceNew = $t03003430260._4 | |
818 | 632 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
819 | 633 | let priceNew = fromX18(priceNewX18, scale8) | |
820 | 634 | let commonState = if (isEval) | |
880 | 694 | ||
881 | 695 | ||
882 | 696 | @Callable(i) | |
883 | - | func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa()))) | |
884 | - | ||
885 | - | ||
886 | - | ||
887 | - | @Callable(i) | |
888 | 697 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
889 | - | let $ | |
698 | + | let $t03197732282 = if ((isReverse == false)) | |
890 | 699 | then { | |
891 | 700 | let assetOut = getStringOrFail(this, pa()) | |
892 | 701 | let assetIn = getStringOrFail(this, aa()) | |
897 | 706 | let assetIn = getStringOrFail(this, pa()) | |
898 | 707 | $Tuple2(assetOut, assetIn) | |
899 | 708 | } | |
900 | - | let assetOut = $ | |
901 | - | let assetIn = $ | |
709 | + | let assetOut = $t03197732282._1 | |
710 | + | let assetIn = $t03197732282._2 | |
902 | 711 | let poolAssetInBalance = getAccBalance(assetIn) | |
903 | 712 | let poolAssetOutBalance = getAccBalance(assetOut) | |
904 | 713 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
948 | 757 | then true | |
949 | 758 | else throw("Exchange result is fewer coins than expected") | |
950 | 759 | if ((checkMin == checkMin)) | |
951 | - | then { | |
952 | - | let rebalanceState = rebalanceAsset(assetIn) | |
953 | - | if ((rebalanceState == rebalanceState)) | |
954 | - | then { | |
955 | - | let withdrawState = withdrawAndRebalanceAsset(assetOut, amountOut) | |
956 | - | if ((withdrawState == withdrawState)) | |
957 | - | then $Tuple2(((withdrawState ++ rebalanceState) ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
958 | - | else throw("Strict value is not equal to itself.") | |
959 | - | } | |
960 | - | else throw("Strict value is not equal to itself.") | |
961 | - | } | |
760 | + | then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut) | |
962 | 761 | else throw("Strict value is not equal to itself.") | |
963 | 762 | } | |
964 | 763 | else throw("Strict value is not equal to itself.") | |
1049 | 848 | else throw("Strict value is not equal to itself.") | |
1050 | 849 | } | |
1051 | 850 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1052 | - | let $ | |
1053 | - | if (($ | |
851 | + | let $t03716637628 = refreshKLpInternal(0, 0, 0) | |
852 | + | if (($t03716637628 == $t03716637628)) | |
1054 | 853 | then { | |
1055 | - | let updatedKLp = $ | |
1056 | - | let refreshKLpActions = $ | |
854 | + | let updatedKLp = $t03716637628._2 | |
855 | + | let refreshKLpActions = $t03716637628._1 | |
1057 | 856 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1058 | 857 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1059 | - | then { | |
1060 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1061 | - | if ((reb == reb)) | |
1062 | - | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
1063 | - | else throw("Strict value is not equal to itself.") | |
1064 | - | } | |
858 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
1065 | 859 | else throw("Strict value is not equal to itself.") | |
1066 | 860 | } | |
1067 | 861 | else throw("Strict value is not equal to itself.") | |
1090 | 884 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1091 | 885 | if ((currentKLp == currentKLp)) | |
1092 | 886 | then { | |
1093 | - | let $ | |
1094 | - | let refreshKLpActions = $ | |
1095 | - | let updatedKLp = $ | |
887 | + | let $t03819038255 = refreshKLpInternal(0, 0, 0) | |
888 | + | let refreshKLpActions = $t03819038255._1 | |
889 | + | let updatedKLp = $t03819038255._2 | |
1096 | 890 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1097 | 891 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1098 | 892 | then (state ++ refreshKLpActions) | |
1139 | 933 | then { | |
1140 | 934 | let userAddress = i.caller | |
1141 | 935 | let txId = i.transactionId | |
1142 | - | let $ | |
1143 | - | if (($ | |
936 | + | let $t03944339595 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
937 | + | if (($t03944339595 == $t03944339595)) | |
1144 | 938 | then { | |
1145 | - | let paymentInAmountAsset = $ | |
1146 | - | let bonus = $ | |
1147 | - | let feeAmount = $ | |
1148 | - | let commonState = $ | |
1149 | - | let emitAmountEstimated = $ | |
939 | + | let paymentInAmountAsset = $t03944339595._5 | |
940 | + | let bonus = $t03944339595._4 | |
941 | + | let feeAmount = $t03944339595._3 | |
942 | + | let commonState = $t03944339595._2 | |
943 | + | let emitAmountEstimated = $t03944339595._1 | |
1150 | 944 | let emitAmount = if (if ((minOutAmount > 0)) | |
1151 | 945 | then (minOutAmount > emitAmountEstimated) | |
1152 | 946 | else false) | |
1166 | 960 | let sendFee = if ((feeAmount > 0)) | |
1167 | 961 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
1168 | 962 | else nil | |
1169 | - | let $ | |
963 | + | let $t04018140378 = if ((this == feeCollectorAddress)) | |
1170 | 964 | then $Tuple2(0, 0) | |
1171 | 965 | else if (paymentInAmountAsset) | |
1172 | 966 | then $Tuple2(-(feeAmount), 0) | |
1173 | 967 | else $Tuple2(0, -(feeAmount)) | |
1174 | - | let amountAssetBalanceDelta = $ | |
1175 | - | let priceAssetBalanceDelta = $ | |
1176 | - | let $ | |
1177 | - | let refreshKLpActions = $ | |
1178 | - | let updatedKLp = $ | |
968 | + | let amountAssetBalanceDelta = $t04018140378._1 | |
969 | + | let priceAssetBalanceDelta = $t04018140378._2 | |
970 | + | let $t04038140489 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
971 | + | let refreshKLpActions = $t04038140489._1 | |
972 | + | let updatedKLp = $t04038140489._2 | |
1179 | 973 | let kLp = value(getString(keyKLp)) | |
1180 | 974 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1181 | 975 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1182 | - | then { | |
1183 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1184 | - | if ((reb == reb)) | |
1185 | - | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1186 | - | else throw("Strict value is not equal to itself.") | |
1187 | - | } | |
976 | + | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1188 | 977 | else throw("Strict value is not equal to itself.") | |
1189 | 978 | } | |
1190 | 979 | else throw("Strict value is not equal to itself.") | |
1200 | 989 | ||
1201 | 990 | @Callable(i) | |
1202 | 991 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
1203 | - | let $ | |
1204 | - | let emitAmountEstimated = $ | |
1205 | - | let commonState = $ | |
1206 | - | let feeAmount = $ | |
1207 | - | let bonus = $ | |
1208 | - | let paymentInAmountAsset = $ | |
992 | + | let $t04079540952 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
993 | + | let emitAmountEstimated = $t04079540952._1 | |
994 | + | let commonState = $t04079540952._2 | |
995 | + | let feeAmount = $t04079540952._3 | |
996 | + | let bonus = $t04079540952._4 | |
997 | + | let paymentInAmountAsset = $t04079540952._5 | |
1209 | 998 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
1210 | 999 | } | |
1211 | 1000 | ||
1242 | 1031 | then { | |
1243 | 1032 | let userAddress = i.caller | |
1244 | 1033 | let txId = i.transactionId | |
1245 | - | let $ | |
1246 | - | if (($ | |
1034 | + | let $t04183741990 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1035 | + | if (($t04183741990 == $t04183741990)) | |
1247 | 1036 | then { | |
1248 | - | let outInAmountAsset = $ | |
1249 | - | let bonus = $ | |
1250 | - | let feeAmount = $ | |
1251 | - | let commonState = $ | |
1252 | - | let amountEstimated = $ | |
1037 | + | let outInAmountAsset = $t04183741990._5 | |
1038 | + | let bonus = $t04183741990._4 | |
1039 | + | let feeAmount = $t04183741990._3 | |
1040 | + | let commonState = $t04183741990._2 | |
1041 | + | let amountEstimated = $t04183741990._1 | |
1253 | 1042 | let amount = if (if ((minOutAmount > 0)) | |
1254 | 1043 | then (minOutAmount > amountEstimated) | |
1255 | 1044 | else false) | |
1258 | 1047 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
1259 | 1048 | if ((burnInv == burnInv)) | |
1260 | 1049 | then { | |
1261 | - | let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount) | |
1262 | 1050 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1263 | 1051 | let sendFee = if ((feeAmount > 0)) | |
1264 | 1052 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1265 | 1053 | else nil | |
1266 | - | let $ | |
1054 | + | let $t04249042737 = { | |
1267 | 1055 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1268 | 1056 | then 0 | |
1269 | 1057 | else feeAmount | |
1271 | 1059 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1272 | 1060 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1273 | 1061 | } | |
1274 | - | let amountAssetBalanceDelta = $ | |
1275 | - | let priceAssetBalanceDelta = $ | |
1276 | - | let $ | |
1277 | - | let refreshKLpActions = $ | |
1278 | - | let updatedKLp = $ | |
1062 | + | let amountAssetBalanceDelta = $t04249042737._1 | |
1063 | + | let priceAssetBalanceDelta = $t04249042737._2 | |
1064 | + | let $t04274042848 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1065 | + | let refreshKLpActions = $t04274042848._1 | |
1066 | + | let updatedKLp = $t04274042848._2 | |
1279 | 1067 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1280 | 1068 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1281 | - | then $Tuple2(((( | |
1069 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1282 | 1070 | else throw("Strict value is not equal to itself.") | |
1283 | 1071 | } | |
1284 | 1072 | else throw("Strict value is not equal to itself.") | |
1294 | 1082 | ||
1295 | 1083 | @Callable(i) | |
1296 | 1084 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1297 | - | let $ | |
1298 | - | let amountEstimated = $ | |
1299 | - | let commonState = $ | |
1300 | - | let feeAmount = $ | |
1301 | - | let bonus = $ | |
1302 | - | let outInAmountAsset = $ | |
1085 | + | let $t04310543261 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1086 | + | let amountEstimated = $t04310543261._1 | |
1087 | + | let commonState = $t04310543261._2 | |
1088 | + | let feeAmount = $t04310543261._3 | |
1089 | + | let bonus = $t04310543261._4 | |
1090 | + | let outInAmountAsset = $t04310543261._5 | |
1303 | 1091 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1304 | 1092 | } | |
1305 | 1093 | ||
1336 | 1124 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1337 | 1125 | if ((unstakeInv == unstakeInv)) | |
1338 | 1126 | then { | |
1339 | - | let $ | |
1340 | - | if (($ | |
1127 | + | let $t04416644317 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1128 | + | if (($t04416644317 == $t04416644317)) | |
1341 | 1129 | then { | |
1342 | - | let outInAmountAsset = $ | |
1343 | - | let bonus = $ | |
1344 | - | let feeAmount = $ | |
1345 | - | let commonState = $ | |
1346 | - | let amountEstimated = $ | |
1130 | + | let outInAmountAsset = $t04416644317._5 | |
1131 | + | let bonus = $t04416644317._4 | |
1132 | + | let feeAmount = $t04416644317._3 | |
1133 | + | let commonState = $t04416644317._2 | |
1134 | + | let amountEstimated = $t04416644317._1 | |
1347 | 1135 | let amount = if (if ((minOutAmount > 0)) | |
1348 | 1136 | then (minOutAmount > amountEstimated) | |
1349 | 1137 | else false) | |
1352 | 1140 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1353 | 1141 | if ((burnInv == burnInv)) | |
1354 | 1142 | then { | |
1355 | - | let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount) | |
1356 | 1143 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1357 | 1144 | let sendFee = if ((feeAmount > 0)) | |
1358 | 1145 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1359 | 1146 | else nil | |
1360 | - | let $ | |
1147 | + | let $t04481245059 = { | |
1361 | 1148 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1362 | 1149 | then 0 | |
1363 | 1150 | else feeAmount | |
1365 | 1152 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1366 | 1153 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1367 | 1154 | } | |
1368 | - | let amountAssetBalanceDelta = $ | |
1369 | - | let priceAssetBalanceDelta = $ | |
1370 | - | let $ | |
1371 | - | let refreshKLpActions = $ | |
1372 | - | let updatedKLp = $ | |
1155 | + | let amountAssetBalanceDelta = $t04481245059._1 | |
1156 | + | let priceAssetBalanceDelta = $t04481245059._2 | |
1157 | + | let $t04506245170 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1158 | + | let refreshKLpActions = $t04506245170._1 | |
1159 | + | let updatedKLp = $t04506245170._2 | |
1373 | 1160 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1374 | 1161 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1375 | - | then $Tuple2(((( | |
1162 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1376 | 1163 | else throw("Strict value is not equal to itself.") | |
1377 | 1164 | } | |
1378 | 1165 | else throw("Strict value is not equal to itself.") | |
1391 | 1178 | @Callable(i) | |
1392 | 1179 | func get () = { | |
1393 | 1180 | let res = commonGet(i) | |
1394 | - | let | |
1181 | + | let outAmtAmt = res._1 | |
1395 | 1182 | let outPrAmt = res._2 | |
1396 | 1183 | let pmtAmt = res._3 | |
1397 | 1184 | let pmtAssetId = res._4 | |
1398 | 1185 | let state = res._5 | |
1399 | - | let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt) | |
1400 | 1186 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1401 | 1187 | if ((currentKLp == currentKLp)) | |
1402 | 1188 | then { | |
1403 | 1189 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1404 | 1190 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1405 | 1191 | then { | |
1406 | - | let $ | |
1407 | - | let refreshKLpActions = $ | |
1408 | - | let updatedKLp = $ | |
1192 | + | let $t04611646198 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1193 | + | let refreshKLpActions = $t04611646198._1 | |
1194 | + | let updatedKLp = $t04611646198._2 | |
1409 | 1195 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1410 | 1196 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1411 | - | then ( | |
1197 | + | then (state ++ refreshKLpActions) | |
1412 | 1198 | else throw("Strict value is not equal to itself.") | |
1413 | 1199 | } | |
1414 | 1200 | else throw("Strict value is not equal to itself.") | |
1431 | 1217 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1432 | 1218 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1433 | 1219 | else { | |
1434 | - | let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt) | |
1435 | 1220 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1436 | 1221 | if ((currentKLp == currentKLp)) | |
1437 | 1222 | then { | |
1438 | 1223 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1439 | 1224 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1440 | 1225 | then { | |
1441 | - | let $ | |
1442 | - | let refreshKLpActions = $ | |
1443 | - | let updatedKLp = $ | |
1226 | + | let $t04714747228 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1227 | + | let refreshKLpActions = $t04714747228._1 | |
1228 | + | let updatedKLp = $t04714747228._2 | |
1444 | 1229 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1445 | 1230 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1446 | - | then ( | |
1231 | + | then (state ++ refreshKLpActions) | |
1447 | 1232 | else throw("Strict value is not equal to itself.") | |
1448 | 1233 | } | |
1449 | 1234 | else throw("Strict value is not equal to itself.") | |
1474 | 1259 | let outPrAmt = res._2 | |
1475 | 1260 | let poolStatus = parseIntValue(res._9) | |
1476 | 1261 | let state = res._10 | |
1477 | - | let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt) | |
1478 | 1262 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1479 | 1263 | then true | |
1480 | 1264 | else (poolStatus == PoolShutdown)) | |
1485 | 1269 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1486 | 1270 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1487 | 1271 | then { | |
1488 | - | let $ | |
1489 | - | let refreshKLpActions = $ | |
1490 | - | let updatedKLp = $ | |
1272 | + | let $t04835448435 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1273 | + | let refreshKLpActions = $t04835448435._1 | |
1274 | + | let updatedKLp = $t04835448435._2 | |
1491 | 1275 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1492 | 1276 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1493 | - | then ( | |
1277 | + | then (state ++ refreshKLpActions) | |
1494 | 1278 | else throw("Strict value is not equal to itself.") | |
1495 | 1279 | } | |
1496 | 1280 | else throw("Strict value is not equal to itself.") | |
1528 | 1312 | let outAmAmt = res._1 | |
1529 | 1313 | let outPrAmt = res._2 | |
1530 | 1314 | let state = res._10 | |
1531 | - | let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt) | |
1532 | 1315 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1533 | 1316 | then true | |
1534 | 1317 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1539 | 1322 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1540 | 1323 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1541 | 1324 | then { | |
1542 | - | let $ | |
1543 | - | let refreshKLpActions = $ | |
1544 | - | let updatedKLp = $ | |
1325 | + | let $t04973049811 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1326 | + | let refreshKLpActions = $t04973049811._1 | |
1327 | + | let updatedKLp = $t04973049811._2 | |
1545 | 1328 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1546 | 1329 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1547 | - | then ( | |
1330 | + | then (state ++ refreshKLpActions) | |
1548 | 1331 | else throw("Strict value is not equal to itself.") | |
1549 | 1332 | } | |
1550 | 1333 | else throw("Strict value is not equal to itself.") | |
1576 | 1359 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1577 | 1360 | then { | |
1578 | 1361 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1579 | - | let $ | |
1580 | - | let kLpUpdateActions = $ | |
1581 | - | let updatedKLp = $ | |
1362 | + | let $t05099851062 = refreshKLpInternal(0, 0, 0) | |
1363 | + | let kLpUpdateActions = $t05099851062._1 | |
1364 | + | let updatedKLp = $t05099851062._2 | |
1582 | 1365 | let actions = if ((kLp != updatedKLp)) | |
1583 | 1366 | then kLpUpdateActions | |
1584 | 1367 | else throwErr("nothing to refresh") | |
1753 | 1536 | match tx { | |
1754 | 1537 | case order: Order => | |
1755 | 1538 | let matcherPub = getMatcherPubOrFail() | |
1756 | - | let $ | |
1757 | - | let orderValid = $ | |
1758 | - | let orderValidInfo = $ | |
1539 | + | let $t05972459793 = validateMatcherOrderAllowed(order) | |
1540 | + | let orderValid = $t05972459793._1 | |
1541 | + | let orderValidInfo = $t05972459793._2 | |
1759 | 1542 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1760 | 1543 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1761 | 1544 | if (if (if (orderValid) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let 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 | 87 | func swapContract () = "%s__swapContract" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func fc () = "%s__factoryContract" | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func mpk () = "%s__managerPublicKey" | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func pmpk () = "%s__pendingManagerPublicKey" | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func pl () = "%s%s__price__last" | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func ph (h,timestamp) = makeString(["%s%s%d%d__price__history", toString(h), toString(timestamp)], SEP) | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func pau (userAddress,txId) = ((("%s%s%s__P__" + userAddress) + "__") + txId) | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | func gau (userAddress,txId) = ((("%s%s%s__G__" + userAddress) + "__") + txId) | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | func aa () = "%s__amountAsset" | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func pa () = "%s__priceAsset" | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | let keyFee = "%s__fee" | |
118 | 118 | ||
119 | 119 | let feeDefault = fraction(10, scale8, 10000) | |
120 | 120 | ||
121 | 121 | let fee = valueOrElse(getInteger(this, keyFee), feeDefault) | |
122 | 122 | ||
123 | 123 | let keyKLp = makeString(["%s", "kLp"], SEP) | |
124 | 124 | ||
125 | 125 | let keyKLpRefreshedHeight = makeString(["%s", "kLpRefreshedHeight"], SEP) | |
126 | 126 | ||
127 | 127 | let keyKLpRefreshDelay = makeString(["%s", "refreshKLpDelay"], SEP) | |
128 | 128 | ||
129 | 129 | let kLpRefreshDelayDefault = 30 | |
130 | 130 | ||
131 | 131 | let kLpRefreshDelay = valueOrElse(getInteger(this, keyKLpRefreshDelay), kLpRefreshDelayDefault) | |
132 | 132 | ||
133 | - | func keyAdditionalBalance (assetId) = makeString(["%s%s", "stakedBalance", assetId], SEP) | |
134 | - | ||
135 | - | ||
136 | - | func keyStakingAssetBalance (assetId) = makeString(["%s%s", "shareAssetBalance", assetId], SEP) | |
137 | - | ||
138 | - | ||
139 | - | func getAdditionalBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyAdditionalBalance(assetId)), 0) | |
140 | - | ||
141 | - | ||
142 | - | func getStakingAssetBalanceOrZero (assetId) = valueOrElse(getInteger(this, keyStakingAssetBalance(assetId)), 0) | |
143 | - | ||
144 | - | ||
145 | 133 | func keyFactoryConfig () = "%s__factoryConfig" | |
146 | 134 | ||
147 | 135 | ||
148 | 136 | func keyMatcherPub () = "%s%s__matcher__publicKey" | |
149 | 137 | ||
150 | 138 | ||
151 | 139 | func keyMappingPoolContractAddressToPoolAssets (poolContractAddress) = (("%s%s%s__" + poolContractAddress) + "__mappings__poolContract2LpAsset") | |
152 | 140 | ||
153 | 141 | ||
154 | 142 | func keyPoolConfig (iAmtAsset,iPriceAsset) = (((("%d%d%s__" + iAmtAsset) + "__") + iPriceAsset) + "__config") | |
155 | 143 | ||
156 | 144 | ||
157 | 145 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
158 | 146 | ||
159 | 147 | ||
160 | 148 | func keyAllPoolsShutdown () = "%s__shutdown" | |
161 | 149 | ||
162 | 150 | ||
163 | 151 | func keyPoolWeight (contractAddress) = ("%s%s__poolWeight__" + contractAddress) | |
164 | 152 | ||
165 | 153 | ||
166 | 154 | func keyAllowedLpScriptHash () = "%s__allowedLpScriptHash" | |
167 | 155 | ||
168 | 156 | ||
169 | 157 | let keyFeeCollectorAddress = "%s__feeCollectorAddress" | |
170 | 158 | ||
171 | 159 | func throwOrderError (orderValid,orderValidInfo,senderValid,matcherValid) = throw((((((((("order validation failed: orderValid=" + toString(orderValid)) + " (") + orderValidInfo) + ")") + " senderValid=") + toString(senderValid)) + " matcherValid=") + toString(matcherValid))) | |
172 | 160 | ||
173 | 161 | ||
174 | 162 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
175 | 163 | ||
176 | 164 | ||
177 | 165 | func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
178 | 166 | ||
179 | 167 | ||
180 | 168 | func throwErr (msg) = throw(makeString(["lp.ride:", msg], " ")) | |
181 | 169 | ||
182 | 170 | ||
183 | 171 | func fmtErr (msg) = makeString(["lp.ride:", msg], " ") | |
184 | 172 | ||
185 | 173 | ||
186 | 174 | let factoryContract = addressFromStringValue(getStringOrFail(this, fc())) | |
187 | 175 | ||
188 | 176 | let feeCollectorAddress = addressFromStringValue(getStringOrFail(factoryContract, keyFeeCollectorAddress)) | |
189 | 177 | ||
190 | 178 | let inFee = { | |
191 | 179 | let @ = invoke(factoryContract, "getInFeeREADONLY", [toString(this)], nil) | |
192 | 180 | if ($isInstanceOf(@, "Int")) | |
193 | 181 | then @ | |
194 | 182 | else throw(($getType(@) + " couldn't be cast to Int")) | |
195 | 183 | } | |
196 | 184 | ||
197 | 185 | let outFee = { | |
198 | 186 | let @ = invoke(factoryContract, "getOutFeeREADONLY", [toString(this)], nil) | |
199 | 187 | if ($isInstanceOf(@, "Int")) | |
200 | 188 | then @ | |
201 | 189 | else throw(($getType(@) + " couldn't be cast to Int")) | |
202 | 190 | } | |
203 | 191 | ||
204 | 192 | func isGlobalShutdown () = valueOrElse(getBoolean(factoryContract, keyAllPoolsShutdown()), false) | |
205 | 193 | ||
206 | 194 | ||
207 | 195 | func getMatcherPubOrFail () = fromBase58String(getStringOrFail(factoryContract, keyMatcherPub())) | |
208 | 196 | ||
209 | 197 | ||
210 | 198 | func getPoolConfig () = { | |
211 | 199 | let amtAsset = getStringOrFail(this, aa()) | |
212 | 200 | let priceAsset = getStringOrFail(this, pa()) | |
213 | 201 | let iPriceAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(priceAsset)) | |
214 | 202 | let iAmtAsset = getIntOrFail(factoryContract, keyMappingsBaseAsset2internalId(amtAsset)) | |
215 | 203 | split(getStringOrFail(factoryContract, keyPoolConfig(toString(iAmtAsset), toString(iPriceAsset))), SEP) | |
216 | 204 | } | |
217 | 205 | ||
218 | 206 | ||
219 | 207 | func parseAssetId (input) = if ((input == wavesString)) | |
220 | 208 | then unit | |
221 | 209 | else fromBase58String(input) | |
222 | 210 | ||
223 | 211 | ||
224 | 212 | func assetIdToString (input) = if ((input == unit)) | |
225 | 213 | then wavesString | |
226 | 214 | else toBase58String(value(input)) | |
227 | 215 | ||
228 | 216 | ||
229 | 217 | 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])) | |
230 | 218 | ||
231 | 219 | ||
232 | 220 | let poolConfigParsed = parsePoolConfig(getPoolConfig()) | |
233 | 221 | ||
234 | - | let $ | |
222 | + | let $t084698635 = poolConfigParsed | |
235 | 223 | ||
236 | - | let cfgPoolAddress = $ | |
224 | + | let cfgPoolAddress = $t084698635._1 | |
237 | 225 | ||
238 | - | let cfgPoolStatus = $ | |
226 | + | let cfgPoolStatus = $t084698635._2 | |
239 | 227 | ||
240 | - | let cfgLpAssetId = $ | |
228 | + | let cfgLpAssetId = $t084698635._3 | |
241 | 229 | ||
242 | - | let cfgAmountAssetId = $ | |
230 | + | let cfgAmountAssetId = $t084698635._4 | |
243 | 231 | ||
244 | - | let cfgPriceAssetId = $ | |
232 | + | let cfgPriceAssetId = $t084698635._5 | |
245 | 233 | ||
246 | - | let cfgAmountAssetDecimals = $ | |
234 | + | let cfgAmountAssetDecimals = $t084698635._6 | |
247 | 235 | ||
248 | - | let cfgPriceAssetDecimals = $ | |
236 | + | let cfgPriceAssetDecimals = $t084698635._7 | |
249 | 237 | ||
250 | 238 | func getFactoryConfig () = split(getStringOrFail(factoryContract, keyFactoryConfig()), SEP) | |
251 | 239 | ||
252 | 240 | ||
253 | 241 | let stakingContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactoryStakingContract]), "incorrect staking address") | |
254 | 242 | ||
255 | 243 | let slippageContract = valueOrErrorMessage(addressFromString(getFactoryConfig()[idxFactorySlippageContract]), "incorrect staking address") | |
256 | 244 | ||
257 | 245 | 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) | |
258 | 246 | ||
259 | 247 | ||
260 | 248 | 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) | |
261 | 249 | ||
262 | 250 | ||
263 | - | func getAccBalance (assetId) = { | |
264 | - | let balanceOnPool = if ((assetId == "WAVES")) | |
265 | - | then wavesBalance(this).available | |
266 | - | else assetBalance(this, fromBase58String(assetId)) | |
267 | - | let totalBalance = ((balanceOnPool + getAdditionalBalanceOrZero(assetId)) - getStakingAssetBalanceOrZero(assetId)) | |
268 | - | max([0, totalBalance]) | |
269 | - | } | |
251 | + | func getAccBalance (assetId) = if ((assetId == "WAVES")) | |
252 | + | then wavesBalance(this).available | |
253 | + | else assetBalance(this, fromBase58String(assetId)) | |
270 | 254 | ||
271 | 255 | ||
272 | 256 | func calcPriceBigInt (prAmtX18,amAmtX18) = fraction(prAmtX18, scale18, amAmtX18) | |
273 | 257 | ||
274 | 258 | ||
275 | 259 | func calcPriceBigIntRound (prAmtX18,amAmtX18,round) = fraction(prAmtX18, scale18, amAmtX18, round) | |
276 | - | ||
277 | - | ||
278 | - | func getRate (proxy) = { | |
279 | - | let inv = invoke(proxy, "getRate", nil, nil) | |
280 | - | if ((inv == inv)) | |
281 | - | then match inv { | |
282 | - | case r: Int => | |
283 | - | r | |
284 | - | case _ => | |
285 | - | throwErr("proxy.getRate() unexpected value") | |
286 | - | } | |
287 | - | else throw("Strict value is not equal to itself.") | |
288 | - | } | |
289 | - | ||
290 | - | ||
291 | - | func deposit (assetId,amount,stakingAssetId,proxy) = { | |
292 | - | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
293 | - | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
294 | - | then { | |
295 | - | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
296 | - | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
297 | - | then { | |
298 | - | let asset = parseAssetId(assetId) | |
299 | - | if ((amount > 0)) | |
300 | - | then { | |
301 | - | let depositInvoke = invoke(proxy, "deposit", nil, [AttachedPayment(asset, amount)]) | |
302 | - | if ((depositInvoke == depositInvoke)) | |
303 | - | then match depositInvoke { | |
304 | - | case receivedStakingAsset: Int => | |
305 | - | let newAdditionalBalance = (currentAdditionalBalance + amount) | |
306 | - | let newStakingAssetBalance = (currentStakingAssetBalance + receivedStakingAsset) | |
307 | - | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance)] | |
308 | - | case _ => | |
309 | - | nil | |
310 | - | } | |
311 | - | else throw("Strict value is not equal to itself.") | |
312 | - | } | |
313 | - | else nil | |
314 | - | } | |
315 | - | else throw("Strict value is not equal to itself.") | |
316 | - | } | |
317 | - | else throw("Strict value is not equal to itself.") | |
318 | - | } | |
319 | - | ||
320 | - | ||
321 | - | func withdraw (assetId,amount,stakingAssetId,proxy,proxyRateMul,profitAddress) = { | |
322 | - | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
323 | - | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
324 | - | then { | |
325 | - | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
326 | - | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
327 | - | then { | |
328 | - | let currentProxyRate = getRate(proxy) | |
329 | - | if ((currentProxyRate == currentProxyRate)) | |
330 | - | then { | |
331 | - | let oldRate = fraction(proxyRateMul, currentAdditionalBalance, currentStakingAssetBalance) | |
332 | - | let stakingAsset = parseAssetId(stakingAssetId) | |
333 | - | let oldSendStakingAmount = fraction(proxyRateMul, amount, oldRate) | |
334 | - | let sendStakingAssetAmount = fraction(proxyRateMul, amount, currentProxyRate) | |
335 | - | let profitAmount = max([0, (oldSendStakingAmount - sendStakingAssetAmount)]) | |
336 | - | if ((sendStakingAssetAmount > 0)) | |
337 | - | then { | |
338 | - | let withdrawInvoke = invoke(proxy, "withdraw", nil, [AttachedPayment(stakingAsset, sendStakingAssetAmount)]) | |
339 | - | if ((withdrawInvoke == withdrawInvoke)) | |
340 | - | then match withdrawInvoke { | |
341 | - | case receivedAssets: Int => | |
342 | - | let newAdditionalBalance = (currentAdditionalBalance - receivedAssets) | |
343 | - | let newStakingAssetBalance = ((currentStakingAssetBalance - sendStakingAssetAmount) - profitAmount) | |
344 | - | [IntegerEntry(keyAdditionalBalance(assetId), newAdditionalBalance), IntegerEntry(keyStakingAssetBalance(stakingAssetId), newStakingAssetBalance), ScriptTransfer(profitAddress, profitAmount, parseAssetId(stakingAssetId))] | |
345 | - | case _ => | |
346 | - | nil | |
347 | - | } | |
348 | - | else throw("Strict value is not equal to itself.") | |
349 | - | } | |
350 | - | else nil | |
351 | - | } | |
352 | - | else throw("Strict value is not equal to itself.") | |
353 | - | } | |
354 | - | else throw("Strict value is not equal to itself.") | |
355 | - | } | |
356 | - | else throw("Strict value is not equal to itself.") | |
357 | - | } | |
358 | - | ||
359 | - | ||
360 | - | func getLeaseProxyConfig (assetId) = match invoke(factoryContract, "getPoolLeaseConfigREADONLY", [toString(this), assetId], nil) { | |
361 | - | case a: (Boolean, Int, Int, String, String, Int, String) => | |
362 | - | a | |
363 | - | case _ => | |
364 | - | throwErr((("[" + assetId) + "] getLeaseProxyConfig() error")) | |
365 | - | } | |
366 | - | ||
367 | - | ||
368 | - | func rebalanceInternal (targetRatio,assetId,stakingAssetId,minBalance,proxy,proxyRateMul,profitAddress) = { | |
369 | - | let currentAdditionalBalance = getAdditionalBalanceOrZero(assetId) | |
370 | - | if ((currentAdditionalBalance == currentAdditionalBalance)) | |
371 | - | then { | |
372 | - | let currentStakingAssetBalance = getStakingAssetBalanceOrZero(stakingAssetId) | |
373 | - | if ((currentStakingAssetBalance == currentStakingAssetBalance)) | |
374 | - | then { | |
375 | - | let leasableTotalBalance = max([0, (getAccBalance(assetId) - minBalance)]) | |
376 | - | let targetAdditionalBalance = fraction(targetRatio, leasableTotalBalance, 100) | |
377 | - | let diff = (currentAdditionalBalance - targetAdditionalBalance) | |
378 | - | if ((diff == 0)) | |
379 | - | then nil | |
380 | - | else if ((0 > diff)) | |
381 | - | then { | |
382 | - | let sendAssetAmount = -(diff) | |
383 | - | deposit(assetId, sendAssetAmount, stakingAssetId, proxy) | |
384 | - | } | |
385 | - | else { | |
386 | - | let getAssetAmount = diff | |
387 | - | withdraw(assetId, getAssetAmount, stakingAssetId, proxy, proxyRateMul, profitAddress) | |
388 | - | } | |
389 | - | } | |
390 | - | else throw("Strict value is not equal to itself.") | |
391 | - | } | |
392 | - | else throw("Strict value is not equal to itself.") | |
393 | - | } | |
394 | - | ||
395 | - | ||
396 | - | func rebalanceAsset (assetId) = { | |
397 | - | let $t01536415500 = getLeaseProxyConfig(assetId) | |
398 | - | let isLeasable = $t01536415500._1 | |
399 | - | let leasedRatio = $t01536415500._2 | |
400 | - | let minBalance = $t01536415500._3 | |
401 | - | let proxyAddress = $t01536415500._4 | |
402 | - | let proxyAssetId = $t01536415500._5 | |
403 | - | let proxyRateMul = $t01536415500._6 | |
404 | - | let stakingProfitAddress = $t01536415500._7 | |
405 | - | if (isLeasable) | |
406 | - | then rebalanceInternal(leasedRatio, assetId, proxyAssetId, minBalance, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
407 | - | else nil | |
408 | - | } | |
409 | - | ||
410 | - | ||
411 | - | func withdrawAndRebalanceAsset (assetId,getAmount) = { | |
412 | - | let $t01588916025 = getLeaseProxyConfig(assetId) | |
413 | - | let isLeasable = $t01588916025._1 | |
414 | - | let leasedRatio = $t01588916025._2 | |
415 | - | let minBalance = $t01588916025._3 | |
416 | - | let proxyAddress = $t01588916025._4 | |
417 | - | let proxyAssetId = $t01588916025._5 | |
418 | - | let proxyRateMul = $t01588916025._6 | |
419 | - | let stakingProfitAddress = $t01588916025._7 | |
420 | - | if (isLeasable) | |
421 | - | then { | |
422 | - | let newTotalLeasableBalance = max([0, ((getAccBalance(assetId) - getAmount) - minBalance)]) | |
423 | - | if ((newTotalLeasableBalance == newTotalLeasableBalance)) | |
424 | - | then { | |
425 | - | let newAdditionalBalance = fraction(leasedRatio, newTotalLeasableBalance, 100) | |
426 | - | if ((newAdditionalBalance == newAdditionalBalance)) | |
427 | - | then { | |
428 | - | let withdrawAmount = max([0, (getAdditionalBalanceOrZero(assetId) - newAdditionalBalance)]) | |
429 | - | if ((withdrawAmount == withdrawAmount)) | |
430 | - | then withdraw(assetId, withdrawAmount, proxyAssetId, addressFromStringValue(proxyAddress), proxyRateMul, addressFromStringValue(stakingProfitAddress)) | |
431 | - | else throw("Strict value is not equal to itself.") | |
432 | - | } | |
433 | - | else throw("Strict value is not equal to itself.") | |
434 | - | } | |
435 | - | else throw("Strict value is not equal to itself.") | |
436 | - | } | |
437 | - | else nil | |
438 | - | } | |
439 | - | ||
440 | - | ||
441 | - | func withdrawAndRebalanceAll (amountAssetOutAmount,priceAssetOutAmount) = { | |
442 | - | let AmAmtWithdrawState = withdrawAndRebalanceAsset(getStringOrFail(this, aa()), amountAssetOutAmount) | |
443 | - | let PrAmtWithdrawState = withdrawAndRebalanceAsset(getStringOrFail(this, pa()), priceAssetOutAmount) | |
444 | - | (AmAmtWithdrawState ++ PrAmtWithdrawState) | |
445 | - | } | |
446 | 260 | ||
447 | 261 | ||
448 | 262 | func privateCalcPrice (amAssetDcm,prAssetDcm,amAmt,prAmt) = { | |
449 | 263 | let amtAssetAmtX18 = toX18(amAmt, amAssetDcm) | |
450 | 264 | let priceAssetAmtX18 = toX18(prAmt, prAssetDcm) | |
451 | 265 | calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
452 | 266 | } | |
453 | 267 | ||
454 | 268 | ||
455 | 269 | func calcPrices (amAmt,prAmt,lpAmt) = { | |
456 | 270 | let cfg = getPoolConfig() | |
457 | 271 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
458 | 272 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
459 | 273 | let priceX18 = privateCalcPrice(amtAssetDcm, priceAssetDcm, amAmt, prAmt) | |
460 | 274 | let amAmtX18 = toX18(amAmt, amtAssetDcm) | |
461 | 275 | let prAmtX18 = toX18(prAmt, priceAssetDcm) | |
462 | 276 | let lpAmtX18 = toX18(lpAmt, scale8) | |
463 | 277 | let lpPriceInAmAssetX18 = calcPriceBigInt(amAmtX18, lpAmtX18) | |
464 | 278 | let lpPriceInPrAssetX18 = calcPriceBigInt(prAmtX18, lpAmtX18) | |
465 | 279 | [priceX18, lpPriceInAmAssetX18, lpPriceInPrAssetX18] | |
466 | 280 | } | |
467 | 281 | ||
468 | 282 | ||
469 | 283 | func calculatePrices (amAmt,prAmt,lpAmt) = { | |
470 | 284 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
471 | 285 | [fromX18(prices[0], scale8), fromX18(prices[1], scale8), fromX18(prices[2], scale8)] | |
472 | 286 | } | |
473 | 287 | ||
474 | 288 | ||
475 | 289 | func estimateGetOperation (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
476 | 290 | let cfg = getPoolConfig() | |
477 | 291 | let lpAssetId = cfg[idxPoolLPAssetId] | |
478 | 292 | let amAssetId = cfg[idxAmtAssetId] | |
479 | 293 | let prAssetId = cfg[idxPriceAssetId] | |
480 | 294 | let amAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
481 | 295 | let prAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
482 | 296 | let poolStatus = cfg[idxPoolStatus] | |
483 | 297 | let lpEmission = valueOrErrorMessage(assetInfo(fromBase58String(lpAssetId)), (("Asset " + lpAssetId) + " doesn't exist")).quantity | |
484 | 298 | if ((lpAssetId != pmtAssetId)) | |
485 | 299 | then throw("Invalid asset passed.") | |
486 | 300 | else { | |
487 | 301 | let amBalance = getAccBalance(amAssetId) | |
488 | 302 | let amBalanceX18 = toX18(amBalance, amAssetDcm) | |
489 | 303 | let prBalance = getAccBalance(prAssetId) | |
490 | 304 | let prBalanceX18 = toX18(prBalance, prAssetDcm) | |
491 | 305 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
492 | 306 | let curPrice = fromX18(curPriceX18, scale8) | |
493 | 307 | let pmtLpAmtX18 = toX18(pmtLpAmt, scale8) | |
494 | 308 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
495 | 309 | let outAmAmtX18 = fraction(amBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
496 | 310 | let outPrAmtX18 = fraction(prBalanceX18, pmtLpAmtX18, lpEmissionX18) | |
497 | 311 | let outAmAmt = fromX18Round(outAmAmtX18, amAssetDcm, FLOOR) | |
498 | 312 | let outPrAmt = fromX18Round(outPrAmtX18, prAssetDcm, FLOOR) | |
499 | 313 | let state = if ((txId58 == "")) | |
500 | 314 | then nil | |
501 | 315 | else [ScriptTransfer(userAddress, outAmAmt, if ((amAssetId == "WAVES")) | |
502 | 316 | then unit | |
503 | 317 | else fromBase58String(amAssetId)), ScriptTransfer(userAddress, outPrAmt, if ((prAssetId == "WAVES")) | |
504 | 318 | then unit | |
505 | 319 | 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)] | |
506 | 320 | $Tuple10(outAmAmt, outPrAmt, amAssetId, prAssetId, amBalance, prBalance, lpEmission, curPriceX18, poolStatus, state) | |
507 | 321 | } | |
508 | 322 | } | |
509 | 323 | ||
510 | 324 | ||
511 | 325 | func estimatePutOperation (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = { | |
512 | 326 | let cfg = getPoolConfig() | |
513 | 327 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
514 | 328 | let amAssetIdStr = cfg[idxAmtAssetId] | |
515 | 329 | let prAssetIdStr = cfg[idxPriceAssetId] | |
516 | 330 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
517 | 331 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
518 | 332 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
519 | 333 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
520 | 334 | let poolStatus = cfg[idxPoolStatus] | |
521 | 335 | let lpEmission = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
522 | 336 | let inAmAssetIdStr = toBase58String(valueOrElse(inAmAssetId, fromBase58String("WAVES"))) | |
523 | 337 | let inPrAssetIdStr = toBase58String(valueOrElse(inPrAssetId, fromBase58String("WAVES"))) | |
524 | 338 | if (if ((amAssetIdStr != inAmAssetIdStr)) | |
525 | 339 | then true | |
526 | 340 | else (prAssetIdStr != inPrAssetIdStr)) | |
527 | 341 | then throw("Invalid amt or price asset passed.") | |
528 | 342 | else { | |
529 | 343 | let amBalance = if (isEvaluate) | |
530 | 344 | then getAccBalance(amAssetIdStr) | |
531 | 345 | else (getAccBalance(amAssetIdStr) - inAmAssetAmt) | |
532 | 346 | let prBalance = if (isEvaluate) | |
533 | 347 | then getAccBalance(prAssetIdStr) | |
534 | 348 | else (getAccBalance(prAssetIdStr) - inPrAssetAmt) | |
535 | 349 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
536 | 350 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
537 | 351 | let userPriceX18 = calcPriceBigInt(inPrAssetAmtX18, inAmAssetAmtX18) | |
538 | 352 | let amBalanceX18 = toX18(amBalance, amtAssetDcm) | |
539 | 353 | let prBalanceX18 = toX18(prBalance, priceAssetDcm) | |
540 | 354 | let res = if ((lpEmission == 0)) | |
541 | 355 | then { | |
542 | 356 | let curPriceX18 = zeroBigInt | |
543 | 357 | let slippageX18 = zeroBigInt | |
544 | 358 | let lpAmtX18 = pow((inAmAssetAmtX18 * inPrAssetAmtX18), 0, toBigInt(5), 1, 0, DOWN) | |
545 | 359 | $Tuple5(fromX18(lpAmtX18, scale8), fromX18(inAmAssetAmtX18, amtAssetDcm), fromX18(inPrAssetAmtX18, priceAssetDcm), calcPriceBigInt((prBalanceX18 + inPrAssetAmtX18), (amBalanceX18 + inAmAssetAmtX18)), slippageX18) | |
546 | 360 | } | |
547 | 361 | else { | |
548 | 362 | let curPriceX18 = calcPriceBigInt(prBalanceX18, amBalanceX18) | |
549 | 363 | let slippageX18 = fraction(absBigInt((curPriceX18 - userPriceX18)), scale18, curPriceX18) | |
550 | 364 | let slippageToleranceX18 = toX18(slippageTolerance, scale8) | |
551 | 365 | if (if ((curPriceX18 != zeroBigInt)) | |
552 | 366 | then (slippageX18 > slippageToleranceX18) | |
553 | 367 | else false) | |
554 | 368 | then throw(((("Price slippage " + toString(slippageX18)) + " exceeded the passed limit of ") + toString(slippageToleranceX18))) | |
555 | 369 | else { | |
556 | 370 | let lpEmissionX18 = toX18(lpEmission, scale8) | |
557 | 371 | let prViaAmX18 = fraction(inAmAssetAmtX18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, CEILING), scale18, CEILING) | |
558 | 372 | let amViaPrX18 = fraction(inPrAssetAmtX18, scale18, calcPriceBigIntRound(prBalanceX18, amBalanceX18, FLOOR), CEILING) | |
559 | 373 | let expectedAmts = if ((prViaAmX18 > inPrAssetAmtX18)) | |
560 | 374 | then $Tuple2(amViaPrX18, inPrAssetAmtX18) | |
561 | 375 | else $Tuple2(inAmAssetAmtX18, prViaAmX18) | |
562 | 376 | let expAmtAssetAmtX18 = expectedAmts._1 | |
563 | 377 | let expPriceAssetAmtX18 = expectedAmts._2 | |
564 | 378 | let lpAmtX18 = fraction(lpEmissionX18, expPriceAssetAmtX18, prBalanceX18, FLOOR) | |
565 | 379 | $Tuple5(fromX18Round(lpAmtX18, scale8, FLOOR), fromX18Round(expAmtAssetAmtX18, amtAssetDcm, CEILING), fromX18Round(expPriceAssetAmtX18, priceAssetDcm, CEILING), curPriceX18, slippageX18) | |
566 | 380 | } | |
567 | 381 | } | |
568 | 382 | let calcLpAmt = res._1 | |
569 | 383 | let calcAmAssetPmt = res._2 | |
570 | 384 | let calcPrAssetPmt = res._3 | |
571 | 385 | let curPrice = fromX18(res._4, scale8) | |
572 | 386 | let slippageCalc = fromX18(res._5, scale8) | |
573 | 387 | if ((0 >= calcLpAmt)) | |
574 | 388 | then throw("Invalid calculations. LP calculated is less than zero.") | |
575 | 389 | else { | |
576 | 390 | let emitLpAmt = if (!(emitLp)) | |
577 | 391 | then 0 | |
578 | 392 | else calcLpAmt | |
579 | 393 | let amDiff = (inAmAssetAmt - calcAmAssetPmt) | |
580 | 394 | let prDiff = (inPrAssetAmt - calcPrAssetPmt) | |
581 | 395 | 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))] | |
582 | 396 | $Tuple13(calcLpAmt, emitLpAmt, curPrice, amBalance, prBalance, lpEmission, lpAssetId, poolStatus, commonState, amDiff, prDiff, inAmAssetId, inPrAssetId) | |
583 | 397 | } | |
584 | 398 | } | |
585 | 399 | } | |
586 | 400 | ||
587 | 401 | ||
588 | 402 | func calcKLp (amountBalance,priceBalance,lpEmission) = { | |
589 | 403 | let amountBalanceX18 = toX18BigInt(amountBalance, toBigInt(cfgAmountAssetDecimals)) | |
590 | 404 | let priceBalanceX18 = toX18BigInt(priceBalance, toBigInt(cfgPriceAssetDecimals)) | |
591 | 405 | let updatedKLp = fraction(pow((amountBalanceX18 * priceBalanceX18), 0, toBigInt(5), 1, 18, DOWN), big1, lpEmission) | |
592 | 406 | if ((lpEmission == big0)) | |
593 | 407 | then big0 | |
594 | 408 | else updatedKLp | |
595 | 409 | } | |
596 | 410 | ||
597 | 411 | ||
598 | 412 | func calcCurrentKLp (amountAssetDelta,priceAssetDelta,lpAssetEmissionDelta) = { | |
599 | 413 | let amountAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) - amountAssetDelta) | |
600 | 414 | let priceAssetBalance = (toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) - priceAssetDelta) | |
601 | 415 | let lpAssetEmission = (toBigInt(value(assetInfo(cfgLpAssetId)).quantity) - lpAssetEmissionDelta) | |
602 | 416 | let currentKLp = calcKLp(amountAssetBalance, priceAssetBalance, lpAssetEmission) | |
603 | 417 | currentKLp | |
604 | 418 | } | |
605 | 419 | ||
606 | 420 | ||
607 | 421 | func refreshKLpInternal (amountAssetBalanceDelta,priceAssetBalanceDelta,lpAssetEmissionDelta) = { | |
608 | 422 | let amountAssetBalance = (getAccBalance(assetIdToString(cfgAmountAssetId)) + amountAssetBalanceDelta) | |
609 | 423 | let priceAssetBalance = (getAccBalance(assetIdToString(cfgPriceAssetId)) + priceAssetBalanceDelta) | |
610 | 424 | let lpAssetEmission = (value(assetInfo(cfgLpAssetId)).quantity + lpAssetEmissionDelta) | |
611 | 425 | let updatedKLp = calcKLp(toBigInt(amountAssetBalance), toBigInt(priceAssetBalance), toBigInt(lpAssetEmission)) | |
612 | 426 | let actions = [IntegerEntry(keyKLpRefreshedHeight, height), StringEntry(keyKLp, toString(updatedKLp))] | |
613 | 427 | $Tuple2(actions, updatedKLp) | |
614 | 428 | } | |
615 | 429 | ||
616 | 430 | ||
617 | 431 | func validateUpdatedKLp (oldKLp,updatedKLp) = if ((updatedKLp >= oldKLp)) | |
618 | 432 | then true | |
619 | 433 | else throwErr(makeString(["updated KLp lower than current KLp", toString(oldKLp), toString(updatedKLp)], " ")) | |
620 | 434 | ||
621 | 435 | ||
622 | 436 | func validateMatcherOrderAllowed (order) = { | |
623 | 437 | let amountAssetBalance = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
624 | 438 | let priceAssetBalance = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
625 | 439 | let amountAssetAmount = order.amount | |
626 | 440 | let priceAssetAmount = fraction(order.amount, order.price, scale8, FLOOR) | |
627 | - | let $ | |
441 | + | let $t02154121753 = if ((order.orderType == Buy)) | |
628 | 442 | then $Tuple2(amountAssetAmount, -(priceAssetAmount)) | |
629 | 443 | else $Tuple2(-(amountAssetAmount), priceAssetAmount) | |
630 | - | let amountAssetBalanceDelta = $ | |
631 | - | let priceAssetBalanceDelta = $ | |
444 | + | let amountAssetBalanceDelta = $t02154121753._1 | |
445 | + | let priceAssetBalanceDelta = $t02154121753._2 | |
632 | 446 | if (if (if (isGlobalShutdown()) | |
633 | 447 | then true | |
634 | 448 | else (cfgPoolStatus == PoolMatcherDisabled)) | |
635 | 449 | then true | |
636 | 450 | else (cfgPoolStatus == PoolShutdown)) | |
637 | 451 | then throw("Exchange operations disabled") | |
638 | 452 | else if (if ((order.assetPair.amountAsset != cfgAmountAssetId)) | |
639 | 453 | then true | |
640 | 454 | else (order.assetPair.priceAsset != cfgPriceAssetId)) | |
641 | 455 | then throw("Wrong order assets.") | |
642 | 456 | else { | |
643 | 457 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
644 | - | let $ | |
645 | - | let unusedActions = $ | |
646 | - | let kLpNew = $ | |
458 | + | let $t02219322293 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
459 | + | let unusedActions = $t02219322293._1 | |
460 | + | let kLpNew = $t02219322293._2 | |
647 | 461 | let isOrderValid = (kLpNew >= kLp) | |
648 | 462 | let info = makeString(["kLp=", toString(kLp), " kLpNew=", toString(kLpNew), " amountAssetBalance=", toString(amountAssetBalance), " priceAssetBalance=", toString(priceAssetBalance), " amountAssetBalanceDelta=", toString(amountAssetBalanceDelta), " priceAssetBalanceDelta=", toString(priceAssetBalanceDelta), " height=", toString(height)], "") | |
649 | 463 | $Tuple2(isOrderValid, info) | |
650 | 464 | } | |
651 | 465 | } | |
652 | 466 | ||
653 | 467 | ||
654 | 468 | func commonGet (i) = if ((size(i.payments) != 1)) | |
655 | 469 | then throw("exactly 1 payment is expected") | |
656 | 470 | else { | |
657 | 471 | let pmt = value(i.payments[0]) | |
658 | 472 | let pmtAssetId = value(pmt.assetId) | |
659 | 473 | let pmtAmt = pmt.amount | |
660 | 474 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(pmtAssetId), pmtAmt, i.caller) | |
661 | 475 | let outAmAmt = res._1 | |
662 | 476 | let outPrAmt = res._2 | |
663 | 477 | let poolStatus = parseIntValue(res._9) | |
664 | 478 | let state = res._10 | |
665 | 479 | if (if (isGlobalShutdown()) | |
666 | 480 | then true | |
667 | 481 | else (poolStatus == PoolShutdown)) | |
668 | 482 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
669 | 483 | else $Tuple5(outAmAmt, outPrAmt, pmtAmt, pmtAssetId, state) | |
670 | 484 | } | |
671 | 485 | ||
672 | 486 | ||
673 | 487 | func commonPut (i,slippageTolerance,emitLp) = if ((size(i.payments) != 2)) | |
674 | 488 | then throw("exactly 2 payments are expected") | |
675 | 489 | else { | |
676 | 490 | let amAssetPmt = value(i.payments[0]) | |
677 | 491 | let prAssetPmt = value(i.payments[1]) | |
678 | 492 | let estPut = estimatePutOperation(toBase58String(i.transactionId), slippageTolerance, amAssetPmt.amount, amAssetPmt.assetId, prAssetPmt.amount, prAssetPmt.assetId, toString(i.caller), false, emitLp) | |
679 | 493 | let poolStatus = parseIntValue(estPut._8) | |
680 | 494 | if (if (if (isGlobalShutdown()) | |
681 | 495 | then true | |
682 | 496 | else (poolStatus == PoolPutDisabled)) | |
683 | 497 | then true | |
684 | 498 | else (poolStatus == PoolShutdown)) | |
685 | 499 | then throw(("Put operation is blocked by admin. Status = " + toString(poolStatus))) | |
686 | 500 | else estPut | |
687 | 501 | } | |
688 | 502 | ||
689 | 503 | ||
690 | 504 | func emit (amount) = { | |
691 | 505 | let emitInv = invoke(factoryContract, "emit", [amount], nil) | |
692 | 506 | if ((emitInv == emitInv)) | |
693 | 507 | then { | |
694 | 508 | let emitInvLegacy = match emitInv { | |
695 | 509 | case legacyFactoryContract: Address => | |
696 | 510 | invoke(legacyFactoryContract, "emit", [amount], nil) | |
697 | 511 | case _ => | |
698 | 512 | unit | |
699 | 513 | } | |
700 | 514 | if ((emitInvLegacy == emitInvLegacy)) | |
701 | 515 | then amount | |
702 | 516 | else throw("Strict value is not equal to itself.") | |
703 | 517 | } | |
704 | 518 | else throw("Strict value is not equal to itself.") | |
705 | 519 | } | |
706 | 520 | ||
707 | 521 | ||
708 | 522 | func takeFee (amount,fee) = { | |
709 | 523 | let feeAmount = if ((fee == 0)) | |
710 | 524 | then 0 | |
711 | 525 | else fraction(amount, fee, scale8) | |
712 | 526 | $Tuple2((amount - feeAmount), feeAmount) | |
713 | 527 | } | |
714 | 528 | ||
715 | 529 | ||
716 | 530 | func calcPutOneToken (paymentAmountRaw,paymentAssetId,userAddress,txId) = { | |
717 | 531 | let isEval = (txId == unit) | |
718 | 532 | let amountBalanceRaw = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
719 | 533 | let priceBalanceRaw = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
720 | 534 | let paymentInAmountAsset = if ((paymentAssetId == cfgAmountAssetId)) | |
721 | 535 | then true | |
722 | 536 | else if ((paymentAssetId == cfgPriceAssetId)) | |
723 | 537 | then false | |
724 | 538 | else throwErr("invalid asset") | |
725 | - | let $ | |
539 | + | let $t02540625699 = if (isEval) | |
726 | 540 | then $Tuple2(amountBalanceRaw, priceBalanceRaw) | |
727 | 541 | else if (paymentInAmountAsset) | |
728 | 542 | then $Tuple2((amountBalanceRaw - paymentAmountRaw), priceBalanceRaw) | |
729 | 543 | else $Tuple2(amountBalanceRaw, (priceBalanceRaw - paymentAmountRaw)) | |
730 | - | let amountBalanceOld = $ | |
731 | - | let priceBalanceOld = $ | |
732 | - | let $ | |
544 | + | let amountBalanceOld = $t02540625699._1 | |
545 | + | let priceBalanceOld = $t02540625699._2 | |
546 | + | let $t02570325852 = if (paymentInAmountAsset) | |
733 | 547 | then $Tuple2(paymentAmountRaw, 0) | |
734 | 548 | else $Tuple2(0, paymentAmountRaw) | |
735 | - | let amountAssetAmountRaw = $ | |
736 | - | let priceAssetAmountRaw = $ | |
549 | + | let amountAssetAmountRaw = $t02570325852._1 | |
550 | + | let priceAssetAmountRaw = $t02570325852._2 | |
737 | 551 | let amountAssetAmount = takeFee(amountAssetAmountRaw, inFee)._1 | |
738 | 552 | let priceAssetAmount = takeFee(priceAssetAmountRaw, inFee)._1 | |
739 | - | let $ | |
740 | - | let paymentAmount = $ | |
741 | - | let feeAmount = $ | |
553 | + | let $t02598426048 = takeFee(paymentAmountRaw, inFee) | |
554 | + | let paymentAmount = $t02598426048._1 | |
555 | + | let feeAmount = $t02598426048._2 | |
742 | 556 | let amountBalanceNew = (amountBalanceOld + amountAssetAmount) | |
743 | 557 | let priceBalanceNew = (priceBalanceOld + priceAssetAmount) | |
744 | 558 | let priceNewX18 = calcPriceBigInt(toX18(priceBalanceNew, cfgPriceAssetDecimals), toX18(amountBalanceNew, cfgAmountAssetDecimals)) | |
745 | 559 | let priceNew = fromX18(priceNewX18, scale8) | |
746 | 560 | let paymentBalance = if (paymentInAmountAsset) | |
747 | 561 | then amountBalanceOld | |
748 | 562 | else priceBalanceOld | |
749 | 563 | let paymentBalanceBigInt = toBigInt(paymentBalance) | |
750 | 564 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
751 | 565 | let chechSupply = if ((supplyBigInt > big0)) | |
752 | 566 | then true | |
753 | 567 | else throwErr("initial deposit requires all coins") | |
754 | 568 | if ((chechSupply == chechSupply)) | |
755 | 569 | then { | |
756 | 570 | let depositBigInt = toBigInt(paymentAmount) | |
757 | 571 | let issueAmount = max([0, toInt(((supplyBigInt * (sqrtBigInt((scale18 + ((depositBigInt * scale18) / paymentBalanceBigInt)), 18, 18, DOWN) - scale18)) / scale18))]) | |
758 | 572 | let commonState = if (isEval) | |
759 | 573 | then nil | |
760 | 574 | 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))] | |
761 | 575 | let priceOldX18 = calcPriceBigInt(toX18(priceBalanceOld, cfgPriceAssetDecimals), toX18(amountBalanceOld, cfgAmountAssetDecimals)) | |
762 | 576 | let priceOld = fromX18(priceOldX18, scale8) | |
763 | 577 | let loss = { | |
764 | - | let $ | |
578 | + | let $t02772927896 = if (paymentInAmountAsset) | |
765 | 579 | then $Tuple2(amountAssetAmountRaw, amountBalanceOld) | |
766 | 580 | else $Tuple2(priceAssetAmountRaw, priceBalanceOld) | |
767 | - | let amount = $ | |
768 | - | let balance = $ | |
581 | + | let amount = $t02772927896._1 | |
582 | + | let balance = $t02772927896._2 | |
769 | 583 | let issueAmountBoth = toInt(fraction(supplyBigInt, toBigInt((amount / 2)), toBigInt(balance))) | |
770 | 584 | fraction((issueAmount - issueAmountBoth), scale8, issueAmountBoth) | |
771 | 585 | } | |
772 | 586 | $Tuple5(issueAmount, commonState, feeAmount, loss, paymentInAmountAsset) | |
773 | 587 | } | |
774 | 588 | else throw("Strict value is not equal to itself.") | |
775 | 589 | } | |
776 | 590 | ||
777 | 591 | ||
778 | 592 | func calcGetOneToken (outAssetId,paymentAmount,paymentAssetId,userAddress,txId) = { | |
779 | 593 | let isEval = (txId == unit) | |
780 | 594 | let cfg = getPoolConfig() | |
781 | 595 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
782 | 596 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
783 | 597 | let checks = [if ((paymentAssetId == cfgLpAssetId)) | |
784 | 598 | then true | |
785 | 599 | else throwErr("invalid lp asset")] | |
786 | 600 | if ((checks == checks)) | |
787 | 601 | then { | |
788 | 602 | let outInAmountAsset = if ((outAssetId == cfgAmountAssetId)) | |
789 | 603 | then true | |
790 | 604 | else if ((outAssetId == cfgPriceAssetId)) | |
791 | 605 | then false | |
792 | 606 | else throwErr("invalid asset") | |
793 | 607 | let balanceBigInt = if (outInAmountAsset) | |
794 | 608 | then toBigInt(getAccBalance(assetIdToString(cfgAmountAssetId))) | |
795 | 609 | else toBigInt(getAccBalance(assetIdToString(cfgPriceAssetId))) | |
796 | 610 | let outInAmountAssetDecimals = if (outInAmountAsset) | |
797 | 611 | then amtAssetDcm | |
798 | 612 | else priceAssetDcm | |
799 | 613 | let amBalanceOld = getAccBalance(assetIdToString(cfgAmountAssetId)) | |
800 | 614 | let prBalanceOld = getAccBalance(assetIdToString(cfgPriceAssetId)) | |
801 | 615 | let outBalance = if (outInAmountAsset) | |
802 | 616 | then amBalanceOld | |
803 | 617 | else prBalanceOld | |
804 | 618 | let outBalanceBigInt = toBigInt(outBalance) | |
805 | 619 | let supplyBigInt = toBigInt(valueOrErrorMessage(assetInfo(cfgLpAssetId), (("asset " + toBase58String(cfgLpAssetId)) + " doesn't exist")).quantity) | |
806 | 620 | let redeemedBigInt = toBigInt(paymentAmount) | |
807 | 621 | let amountRaw = max([0, toInt(((balanceBigInt * (scale18 - pow((scale18 - ((redeemedBigInt * scale18) / supplyBigInt)), 18, big2, 0, 18, DOWN))) / scale18))]) | |
808 | - | let $ | |
809 | - | let totalAmount = $ | |
810 | - | let feeAmount = $ | |
811 | - | let $ | |
622 | + | let $t02997430030 = takeFee(amountRaw, outFee) | |
623 | + | let totalAmount = $t02997430030._1 | |
624 | + | let feeAmount = $t02997430030._2 | |
625 | + | let $t03003430260 = if (outInAmountAsset) | |
812 | 626 | then $Tuple4(totalAmount, 0, (amBalanceOld - amountRaw), prBalanceOld) | |
813 | 627 | else $Tuple4(0, totalAmount, amBalanceOld, (prBalanceOld - amountRaw)) | |
814 | - | let outAmAmount = $ | |
815 | - | let outPrAmount = $ | |
816 | - | let amBalanceNew = $ | |
817 | - | let prBalanceNew = $ | |
628 | + | let outAmAmount = $t03003430260._1 | |
629 | + | let outPrAmount = $t03003430260._2 | |
630 | + | let amBalanceNew = $t03003430260._3 | |
631 | + | let prBalanceNew = $t03003430260._4 | |
818 | 632 | let priceNewX18 = calcPriceBigInt(toX18(prBalanceNew, cfgPriceAssetDecimals), toX18(amBalanceNew, cfgAmountAssetDecimals)) | |
819 | 633 | let priceNew = fromX18(priceNewX18, scale8) | |
820 | 634 | let commonState = if (isEval) | |
821 | 635 | then nil | |
822 | 636 | 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)] | |
823 | 637 | let priceOldX18 = calcPriceBigInt(toX18(prBalanceOld, cfgPriceAssetDecimals), toX18(amBalanceOld, cfgAmountAssetDecimals)) | |
824 | 638 | let priceOld = fromX18(priceOldX18, scale8) | |
825 | 639 | let loss = { | |
826 | 640 | let amountBothInPaymentAsset = (toInt(fraction(balanceBigInt, redeemedBigInt, supplyBigInt)) * 2) | |
827 | 641 | fraction((totalAmount - amountBothInPaymentAsset), scale8, amountBothInPaymentAsset) | |
828 | 642 | } | |
829 | 643 | $Tuple5(totalAmount, commonState, feeAmount, loss, outInAmountAsset) | |
830 | 644 | } | |
831 | 645 | else throw("Strict value is not equal to itself.") | |
832 | 646 | } | |
833 | 647 | ||
834 | 648 | ||
835 | 649 | func managerPublicKeyOrUnit () = match getString(mpk()) { | |
836 | 650 | case s: String => | |
837 | 651 | fromBase58String(s) | |
838 | 652 | case _: Unit => | |
839 | 653 | unit | |
840 | 654 | case _ => | |
841 | 655 | throw("Match error") | |
842 | 656 | } | |
843 | 657 | ||
844 | 658 | ||
845 | 659 | func pendingManagerPublicKeyOrUnit () = match getString(pmpk()) { | |
846 | 660 | case s: String => | |
847 | 661 | fromBase58String(s) | |
848 | 662 | case _: Unit => | |
849 | 663 | unit | |
850 | 664 | case _ => | |
851 | 665 | throw("Match error") | |
852 | 666 | } | |
853 | 667 | ||
854 | 668 | ||
855 | 669 | func isManager (i) = match managerPublicKeyOrUnit() { | |
856 | 670 | case pk: ByteVector => | |
857 | 671 | (i.callerPublicKey == pk) | |
858 | 672 | case _: Unit => | |
859 | 673 | (i.caller == this) | |
860 | 674 | case _ => | |
861 | 675 | throw("Match error") | |
862 | 676 | } | |
863 | 677 | ||
864 | 678 | ||
865 | 679 | func mustManager (i) = { | |
866 | 680 | let pd = throw("Permission denied") | |
867 | 681 | match managerPublicKeyOrUnit() { | |
868 | 682 | case pk: ByteVector => | |
869 | 683 | if ((i.callerPublicKey == pk)) | |
870 | 684 | then true | |
871 | 685 | else pd | |
872 | 686 | case _: Unit => | |
873 | 687 | if ((i.caller == this)) | |
874 | 688 | then true | |
875 | 689 | else pd | |
876 | 690 | case _ => | |
877 | 691 | throw("Match error") | |
878 | 692 | } | |
879 | 693 | } | |
880 | 694 | ||
881 | 695 | ||
882 | 696 | @Callable(i) | |
883 | - | func rebalance () = (rebalanceAsset(getStringOrFail(this, aa())) ++ rebalanceAsset(getStringOrFail(this, pa()))) | |
884 | - | ||
885 | - | ||
886 | - | ||
887 | - | @Callable(i) | |
888 | 697 | func calculateAmountOutForSwapREADONLY (cleanAmountIn,isReverse,feePoolAmount) = { | |
889 | - | let $ | |
698 | + | let $t03197732282 = if ((isReverse == false)) | |
890 | 699 | then { | |
891 | 700 | let assetOut = getStringOrFail(this, pa()) | |
892 | 701 | let assetIn = getStringOrFail(this, aa()) | |
893 | 702 | $Tuple2(assetOut, assetIn) | |
894 | 703 | } | |
895 | 704 | else { | |
896 | 705 | let assetOut = getStringOrFail(this, aa()) | |
897 | 706 | let assetIn = getStringOrFail(this, pa()) | |
898 | 707 | $Tuple2(assetOut, assetIn) | |
899 | 708 | } | |
900 | - | let assetOut = $ | |
901 | - | let assetIn = $ | |
709 | + | let assetOut = $t03197732282._1 | |
710 | + | let assetIn = $t03197732282._2 | |
902 | 711 | let poolAssetInBalance = getAccBalance(assetIn) | |
903 | 712 | let poolAssetOutBalance = getAccBalance(assetOut) | |
904 | 713 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
905 | 714 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
906 | 715 | let newK = (((toBigInt(getAccBalance(assetIn)) + toBigInt(cleanAmountIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
907 | 716 | let checkK = if ((newK >= oldK)) | |
908 | 717 | then true | |
909 | 718 | else throw("new K is fewer error") | |
910 | 719 | if ((checkK == checkK)) | |
911 | 720 | then $Tuple2(nil, amountOut) | |
912 | 721 | else throw("Strict value is not equal to itself.") | |
913 | 722 | } | |
914 | 723 | ||
915 | 724 | ||
916 | 725 | ||
917 | 726 | @Callable(i) | |
918 | 727 | func calculateAmountOutForSwapAndSendTokens (cleanAmountIn,isReverse,amountOutMin,addressTo,feePoolAmount) = { | |
919 | 728 | let swapContact = { | |
920 | 729 | let @ = invoke(factoryContract, "getSwapContractREADONLY", nil, nil) | |
921 | 730 | if ($isInstanceOf(@, "String")) | |
922 | 731 | then @ | |
923 | 732 | else throw(($getType(@) + " couldn't be cast to String")) | |
924 | 733 | } | |
925 | 734 | let checks = [if ((value(i.payments[0]).amount >= cleanAmountIn)) | |
926 | 735 | then true | |
927 | 736 | else throwErr("Wrong amount"), if ((i.caller == addressFromStringValue(swapContact))) | |
928 | 737 | then true | |
929 | 738 | else throwErr("Permission denied")] | |
930 | 739 | if ((checks == checks)) | |
931 | 740 | then { | |
932 | 741 | let pmt = value(i.payments[0]) | |
933 | 742 | let assetIn = assetIdToString(pmt.assetId) | |
934 | 743 | let assetOut = if ((isReverse == false)) | |
935 | 744 | then getStringOrFail(this, pa()) | |
936 | 745 | else getStringOrFail(this, aa()) | |
937 | 746 | let poolAssetInBalance = (getAccBalance(assetIn) - value(i.payments[0]).amount) | |
938 | 747 | let poolAssetOutBalance = getAccBalance(assetOut) | |
939 | 748 | let amountOut = fraction(poolAssetOutBalance, cleanAmountIn, (poolAssetInBalance + cleanAmountIn)) | |
940 | 749 | let oldK = (toBigInt(poolAssetInBalance) * toBigInt(poolAssetOutBalance)) | |
941 | 750 | let newK = ((toBigInt(getAccBalance(assetIn)) + toBigInt(feePoolAmount)) * (toBigInt(getAccBalance(assetOut)) - toBigInt(amountOut))) | |
942 | 751 | let checkK = if ((newK >= oldK)) | |
943 | 752 | then true | |
944 | 753 | else throw("new K is fewer error") | |
945 | 754 | if ((checkK == checkK)) | |
946 | 755 | then { | |
947 | 756 | let checkMin = if ((amountOut >= amountOutMin)) | |
948 | 757 | then true | |
949 | 758 | else throw("Exchange result is fewer coins than expected") | |
950 | 759 | if ((checkMin == checkMin)) | |
951 | - | then { | |
952 | - | let rebalanceState = rebalanceAsset(assetIn) | |
953 | - | if ((rebalanceState == rebalanceState)) | |
954 | - | then { | |
955 | - | let withdrawState = withdrawAndRebalanceAsset(assetOut, amountOut) | |
956 | - | if ((withdrawState == withdrawState)) | |
957 | - | then $Tuple2(((withdrawState ++ rebalanceState) ++ [ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))]), amountOut) | |
958 | - | else throw("Strict value is not equal to itself.") | |
959 | - | } | |
960 | - | else throw("Strict value is not equal to itself.") | |
961 | - | } | |
760 | + | then $Tuple2([ScriptTransfer(addressFromStringValue(addressTo), amountOut, parseAssetId(assetOut))], amountOut) | |
962 | 761 | else throw("Strict value is not equal to itself.") | |
963 | 762 | } | |
964 | 763 | else throw("Strict value is not equal to itself.") | |
965 | 764 | } | |
966 | 765 | else throw("Strict value is not equal to itself.") | |
967 | 766 | } | |
968 | 767 | ||
969 | 768 | ||
970 | 769 | ||
971 | 770 | @Callable(i) | |
972 | 771 | func setManager (pendingManagerPublicKey) = { | |
973 | 772 | let checkCaller = mustManager(i) | |
974 | 773 | if ((checkCaller == checkCaller)) | |
975 | 774 | then { | |
976 | 775 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
977 | 776 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
978 | 777 | then [StringEntry(pmpk(), pendingManagerPublicKey)] | |
979 | 778 | else throw("Strict value is not equal to itself.") | |
980 | 779 | } | |
981 | 780 | else throw("Strict value is not equal to itself.") | |
982 | 781 | } | |
983 | 782 | ||
984 | 783 | ||
985 | 784 | ||
986 | 785 | @Callable(i) | |
987 | 786 | func confirmManager () = { | |
988 | 787 | let pm = pendingManagerPublicKeyOrUnit() | |
989 | 788 | let hasPM = if (isDefined(pm)) | |
990 | 789 | then true | |
991 | 790 | else throw("No pending manager") | |
992 | 791 | if ((hasPM == hasPM)) | |
993 | 792 | then { | |
994 | 793 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
995 | 794 | then true | |
996 | 795 | else throw("You are not pending manager") | |
997 | 796 | if ((checkPM == checkPM)) | |
998 | 797 | then [StringEntry(mpk(), toBase58String(value(pm))), DeleteEntry(pmpk())] | |
999 | 798 | else throw("Strict value is not equal to itself.") | |
1000 | 799 | } | |
1001 | 800 | else throw("Strict value is not equal to itself.") | |
1002 | 801 | } | |
1003 | 802 | ||
1004 | 803 | ||
1005 | 804 | ||
1006 | 805 | @Callable(i) | |
1007 | 806 | func put (slippageTolerance,shouldAutoStake) = if ((0 > slippageTolerance)) | |
1008 | 807 | then throw("Invalid slippageTolerance passed") | |
1009 | 808 | else { | |
1010 | 809 | let estPut = commonPut(i, slippageTolerance, true) | |
1011 | 810 | let emitLpAmt = estPut._2 | |
1012 | 811 | let lpAssetId = estPut._7 | |
1013 | 812 | let state = estPut._9 | |
1014 | 813 | let amDiff = estPut._10 | |
1015 | 814 | let prDiff = estPut._11 | |
1016 | 815 | let amId = estPut._12 | |
1017 | 816 | let prId = estPut._13 | |
1018 | 817 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1019 | 818 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1020 | 819 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1021 | 820 | if ((currentKLp == currentKLp)) | |
1022 | 821 | then { | |
1023 | 822 | let emitInv = invoke(factoryContract, "emit", [emitLpAmt], nil) | |
1024 | 823 | if ((emitInv == emitInv)) | |
1025 | 824 | then { | |
1026 | 825 | let emitInvLegacy = match emitInv { | |
1027 | 826 | case legacyFactoryContract: Address => | |
1028 | 827 | invoke(legacyFactoryContract, "emit", [emitLpAmt], nil) | |
1029 | 828 | case _ => | |
1030 | 829 | unit | |
1031 | 830 | } | |
1032 | 831 | if ((emitInvLegacy == emitInvLegacy)) | |
1033 | 832 | then { | |
1034 | 833 | let slippageAInv = if ((amDiff > 0)) | |
1035 | 834 | then invoke(slippageContract, "put", nil, [AttachedPayment(amId, amDiff)]) | |
1036 | 835 | else nil | |
1037 | 836 | if ((slippageAInv == slippageAInv)) | |
1038 | 837 | then { | |
1039 | 838 | let slippagePInv = if ((prDiff > 0)) | |
1040 | 839 | then invoke(slippageContract, "put", nil, [AttachedPayment(prId, prDiff)]) | |
1041 | 840 | else nil | |
1042 | 841 | if ((slippagePInv == slippagePInv)) | |
1043 | 842 | then { | |
1044 | 843 | let lpTransfer = if (shouldAutoStake) | |
1045 | 844 | then { | |
1046 | 845 | let slpStakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(lpAssetId, emitLpAmt)]) | |
1047 | 846 | if ((slpStakeInv == slpStakeInv)) | |
1048 | 847 | then nil | |
1049 | 848 | else throw("Strict value is not equal to itself.") | |
1050 | 849 | } | |
1051 | 850 | else [ScriptTransfer(i.caller, emitLpAmt, lpAssetId)] | |
1052 | - | let $ | |
1053 | - | if (($ | |
851 | + | let $t03716637628 = refreshKLpInternal(0, 0, 0) | |
852 | + | if (($t03716637628 == $t03716637628)) | |
1054 | 853 | then { | |
1055 | - | let updatedKLp = $ | |
1056 | - | let refreshKLpActions = $ | |
854 | + | let updatedKLp = $t03716637628._2 | |
855 | + | let refreshKLpActions = $t03716637628._1 | |
1057 | 856 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1058 | 857 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1059 | - | then { | |
1060 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1061 | - | if ((reb == reb)) | |
1062 | - | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
1063 | - | else throw("Strict value is not equal to itself.") | |
1064 | - | } | |
858 | + | then ((state ++ lpTransfer) ++ refreshKLpActions) | |
1065 | 859 | else throw("Strict value is not equal to itself.") | |
1066 | 860 | } | |
1067 | 861 | else throw("Strict value is not equal to itself.") | |
1068 | 862 | } | |
1069 | 863 | else throw("Strict value is not equal to itself.") | |
1070 | 864 | } | |
1071 | 865 | else throw("Strict value is not equal to itself.") | |
1072 | 866 | } | |
1073 | 867 | else throw("Strict value is not equal to itself.") | |
1074 | 868 | } | |
1075 | 869 | else throw("Strict value is not equal to itself.") | |
1076 | 870 | } | |
1077 | 871 | else throw("Strict value is not equal to itself.") | |
1078 | 872 | } | |
1079 | 873 | ||
1080 | 874 | ||
1081 | 875 | ||
1082 | 876 | @Callable(i) | |
1083 | 877 | func putForFree (maxSlippage) = if ((0 > maxSlippage)) | |
1084 | 878 | then throw("Invalid value passed") | |
1085 | 879 | else { | |
1086 | 880 | let estPut = commonPut(i, maxSlippage, false) | |
1087 | 881 | let state = estPut._9 | |
1088 | 882 | let amAssetPmt = toBigInt(value(i.payments[0]).amount) | |
1089 | 883 | let prAssetPmt = toBigInt(value(i.payments[1]).amount) | |
1090 | 884 | let currentKLp = calcCurrentKLp(amAssetPmt, prAssetPmt, toBigInt(0)) | |
1091 | 885 | if ((currentKLp == currentKLp)) | |
1092 | 886 | then { | |
1093 | - | let $ | |
1094 | - | let refreshKLpActions = $ | |
1095 | - | let updatedKLp = $ | |
887 | + | let $t03819038255 = refreshKLpInternal(0, 0, 0) | |
888 | + | let refreshKLpActions = $t03819038255._1 | |
889 | + | let updatedKLp = $t03819038255._2 | |
1096 | 890 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1097 | 891 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1098 | 892 | then (state ++ refreshKLpActions) | |
1099 | 893 | else throw("Strict value is not equal to itself.") | |
1100 | 894 | } | |
1101 | 895 | else throw("Strict value is not equal to itself.") | |
1102 | 896 | } | |
1103 | 897 | ||
1104 | 898 | ||
1105 | 899 | ||
1106 | 900 | @Callable(i) | |
1107 | 901 | func putOneTkn (minOutAmount,autoStake) = { | |
1108 | 902 | let isPoolOneTokenOperationsDisabled = { | |
1109 | 903 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1110 | 904 | if ($isInstanceOf(@, "Boolean")) | |
1111 | 905 | then @ | |
1112 | 906 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1113 | 907 | } | |
1114 | 908 | let isPutDisabled = if (if (if (isGlobalShutdown()) | |
1115 | 909 | then true | |
1116 | 910 | else (cfgPoolStatus == PoolPutDisabled)) | |
1117 | 911 | then true | |
1118 | 912 | else (cfgPoolStatus == PoolShutdown)) | |
1119 | 913 | then true | |
1120 | 914 | else isPoolOneTokenOperationsDisabled | |
1121 | 915 | let checks = [if (if (!(isPutDisabled)) | |
1122 | 916 | then true | |
1123 | 917 | else isManager(i)) | |
1124 | 918 | then true | |
1125 | 919 | else throwErr("put operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1126 | 920 | then true | |
1127 | 921 | else throwErr("exactly 1 payment are expected")] | |
1128 | 922 | if ((checks == checks)) | |
1129 | 923 | then { | |
1130 | 924 | let payment = i.payments[0] | |
1131 | 925 | let paymentAssetId = payment.assetId | |
1132 | 926 | let paymentAmountRaw = payment.amount | |
1133 | 927 | let currentKLp = if ((paymentAssetId == cfgAmountAssetId)) | |
1134 | 928 | then calcCurrentKLp(toBigInt(paymentAmountRaw), toBigInt(0), toBigInt(0)) | |
1135 | 929 | else if ((paymentAssetId == cfgPriceAssetId)) | |
1136 | 930 | then calcCurrentKLp(toBigInt(0), toBigInt(paymentAmountRaw), toBigInt(0)) | |
1137 | 931 | else throwErr("payment asset is not supported") | |
1138 | 932 | if ((currentKLp == currentKLp)) | |
1139 | 933 | then { | |
1140 | 934 | let userAddress = i.caller | |
1141 | 935 | let txId = i.transactionId | |
1142 | - | let $ | |
1143 | - | if (($ | |
936 | + | let $t03944339595 = calcPutOneToken(paymentAmountRaw, paymentAssetId, userAddress, txId) | |
937 | + | if (($t03944339595 == $t03944339595)) | |
1144 | 938 | then { | |
1145 | - | let paymentInAmountAsset = $ | |
1146 | - | let bonus = $ | |
1147 | - | let feeAmount = $ | |
1148 | - | let commonState = $ | |
1149 | - | let emitAmountEstimated = $ | |
939 | + | let paymentInAmountAsset = $t03944339595._5 | |
940 | + | let bonus = $t03944339595._4 | |
941 | + | let feeAmount = $t03944339595._3 | |
942 | + | let commonState = $t03944339595._2 | |
943 | + | let emitAmountEstimated = $t03944339595._1 | |
1150 | 944 | let emitAmount = if (if ((minOutAmount > 0)) | |
1151 | 945 | then (minOutAmount > emitAmountEstimated) | |
1152 | 946 | else false) | |
1153 | 947 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1154 | 948 | else emitAmountEstimated | |
1155 | 949 | let emitInv = emit(emitAmount) | |
1156 | 950 | if ((emitInv == emitInv)) | |
1157 | 951 | then { | |
1158 | 952 | let lpTransfer = if (autoStake) | |
1159 | 953 | then { | |
1160 | 954 | let stakeInv = invoke(stakingContract, "stake", nil, [AttachedPayment(cfgLpAssetId, emitAmount)]) | |
1161 | 955 | if ((stakeInv == stakeInv)) | |
1162 | 956 | then nil | |
1163 | 957 | else throw("Strict value is not equal to itself.") | |
1164 | 958 | } | |
1165 | 959 | else [ScriptTransfer(i.caller, emitAmount, cfgLpAssetId)] | |
1166 | 960 | let sendFee = if ((feeAmount > 0)) | |
1167 | 961 | then [ScriptTransfer(feeCollectorAddress, feeAmount, paymentAssetId)] | |
1168 | 962 | else nil | |
1169 | - | let $ | |
963 | + | let $t04018140378 = if ((this == feeCollectorAddress)) | |
1170 | 964 | then $Tuple2(0, 0) | |
1171 | 965 | else if (paymentInAmountAsset) | |
1172 | 966 | then $Tuple2(-(feeAmount), 0) | |
1173 | 967 | else $Tuple2(0, -(feeAmount)) | |
1174 | - | let amountAssetBalanceDelta = $ | |
1175 | - | let priceAssetBalanceDelta = $ | |
1176 | - | let $ | |
1177 | - | let refreshKLpActions = $ | |
1178 | - | let updatedKLp = $ | |
968 | + | let amountAssetBalanceDelta = $t04018140378._1 | |
969 | + | let priceAssetBalanceDelta = $t04018140378._2 | |
970 | + | let $t04038140489 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
971 | + | let refreshKLpActions = $t04038140489._1 | |
972 | + | let updatedKLp = $t04038140489._2 | |
1179 | 973 | let kLp = value(getString(keyKLp)) | |
1180 | 974 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1181 | 975 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1182 | - | then { | |
1183 | - | let reb = invoke(this, "rebalance", nil, nil) | |
1184 | - | if ((reb == reb)) | |
1185 | - | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1186 | - | else throw("Strict value is not equal to itself.") | |
1187 | - | } | |
976 | + | then $Tuple2((((commonState ++ lpTransfer) ++ sendFee) ++ refreshKLpActions), emitAmount) | |
1188 | 977 | else throw("Strict value is not equal to itself.") | |
1189 | 978 | } | |
1190 | 979 | else throw("Strict value is not equal to itself.") | |
1191 | 980 | } | |
1192 | 981 | else throw("Strict value is not equal to itself.") | |
1193 | 982 | } | |
1194 | 983 | else throw("Strict value is not equal to itself.") | |
1195 | 984 | } | |
1196 | 985 | else throw("Strict value is not equal to itself.") | |
1197 | 986 | } | |
1198 | 987 | ||
1199 | 988 | ||
1200 | 989 | ||
1201 | 990 | @Callable(i) | |
1202 | 991 | func putOneTknREADONLY (paymentAssetId,paymentAmountRaw) = { | |
1203 | - | let $ | |
1204 | - | let emitAmountEstimated = $ | |
1205 | - | let commonState = $ | |
1206 | - | let feeAmount = $ | |
1207 | - | let bonus = $ | |
1208 | - | let paymentInAmountAsset = $ | |
992 | + | let $t04079540952 = calcPutOneToken(paymentAmountRaw, parseAssetId(paymentAssetId), unit, unit) | |
993 | + | let emitAmountEstimated = $t04079540952._1 | |
994 | + | let commonState = $t04079540952._2 | |
995 | + | let feeAmount = $t04079540952._3 | |
996 | + | let bonus = $t04079540952._4 | |
997 | + | let paymentInAmountAsset = $t04079540952._5 | |
1209 | 998 | $Tuple2(nil, $Tuple3(emitAmountEstimated, feeAmount, bonus)) | |
1210 | 999 | } | |
1211 | 1000 | ||
1212 | 1001 | ||
1213 | 1002 | ||
1214 | 1003 | @Callable(i) | |
1215 | 1004 | func getOneTkn (outAssetIdStr,minOutAmount) = { | |
1216 | 1005 | let isPoolOneTokenOperationsDisabled = { | |
1217 | 1006 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1218 | 1007 | if ($isInstanceOf(@, "Boolean")) | |
1219 | 1008 | then @ | |
1220 | 1009 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1221 | 1010 | } | |
1222 | 1011 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1223 | 1012 | then true | |
1224 | 1013 | else (cfgPoolStatus == PoolShutdown)) | |
1225 | 1014 | then true | |
1226 | 1015 | else isPoolOneTokenOperationsDisabled | |
1227 | 1016 | let checks = [if (if (!(isGetDisabled)) | |
1228 | 1017 | then true | |
1229 | 1018 | else isManager(i)) | |
1230 | 1019 | then true | |
1231 | 1020 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 1)) | |
1232 | 1021 | then true | |
1233 | 1022 | else throwErr("exactly 1 payment are expected")] | |
1234 | 1023 | if ((checks == checks)) | |
1235 | 1024 | then { | |
1236 | 1025 | let outAssetId = parseAssetId(outAssetIdStr) | |
1237 | 1026 | let payment = i.payments[0] | |
1238 | 1027 | let paymentAssetId = payment.assetId | |
1239 | 1028 | let paymentAmount = payment.amount | |
1240 | 1029 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1241 | 1030 | if ((currentKLp == currentKLp)) | |
1242 | 1031 | then { | |
1243 | 1032 | let userAddress = i.caller | |
1244 | 1033 | let txId = i.transactionId | |
1245 | - | let $ | |
1246 | - | if (($ | |
1034 | + | let $t04183741990 = calcGetOneToken(outAssetId, paymentAmount, paymentAssetId, userAddress, txId) | |
1035 | + | if (($t04183741990 == $t04183741990)) | |
1247 | 1036 | then { | |
1248 | - | let outInAmountAsset = $ | |
1249 | - | let bonus = $ | |
1250 | - | let feeAmount = $ | |
1251 | - | let commonState = $ | |
1252 | - | let amountEstimated = $ | |
1037 | + | let outInAmountAsset = $t04183741990._5 | |
1038 | + | let bonus = $t04183741990._4 | |
1039 | + | let feeAmount = $t04183741990._3 | |
1040 | + | let commonState = $t04183741990._2 | |
1041 | + | let amountEstimated = $t04183741990._1 | |
1253 | 1042 | let amount = if (if ((minOutAmount > 0)) | |
1254 | 1043 | then (minOutAmount > amountEstimated) | |
1255 | 1044 | else false) | |
1256 | 1045 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1257 | 1046 | else amountEstimated | |
1258 | 1047 | let burnInv = invoke(factoryContract, "burn", [paymentAmount], [AttachedPayment(paymentAssetId, paymentAmount)]) | |
1259 | 1048 | if ((burnInv == burnInv)) | |
1260 | 1049 | then { | |
1261 | - | let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount) | |
1262 | 1050 | let assetTransfer = [ScriptTransfer(userAddress, amount, outAssetId)] | |
1263 | 1051 | let sendFee = if ((feeAmount > 0)) | |
1264 | 1052 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1265 | 1053 | else nil | |
1266 | - | let $ | |
1054 | + | let $t04249042737 = { | |
1267 | 1055 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1268 | 1056 | then 0 | |
1269 | 1057 | else feeAmount | |
1270 | 1058 | if (outInAmountAsset) | |
1271 | 1059 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1272 | 1060 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1273 | 1061 | } | |
1274 | - | let amountAssetBalanceDelta = $ | |
1275 | - | let priceAssetBalanceDelta = $ | |
1276 | - | let $ | |
1277 | - | let refreshKLpActions = $ | |
1278 | - | let updatedKLp = $ | |
1062 | + | let amountAssetBalanceDelta = $t04249042737._1 | |
1063 | + | let priceAssetBalanceDelta = $t04249042737._2 | |
1064 | + | let $t04274042848 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1065 | + | let refreshKLpActions = $t04274042848._1 | |
1066 | + | let updatedKLp = $t04274042848._2 | |
1279 | 1067 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1280 | 1068 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1281 | - | then $Tuple2(((( | |
1069 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1282 | 1070 | else throw("Strict value is not equal to itself.") | |
1283 | 1071 | } | |
1284 | 1072 | else throw("Strict value is not equal to itself.") | |
1285 | 1073 | } | |
1286 | 1074 | else throw("Strict value is not equal to itself.") | |
1287 | 1075 | } | |
1288 | 1076 | else throw("Strict value is not equal to itself.") | |
1289 | 1077 | } | |
1290 | 1078 | else throw("Strict value is not equal to itself.") | |
1291 | 1079 | } | |
1292 | 1080 | ||
1293 | 1081 | ||
1294 | 1082 | ||
1295 | 1083 | @Callable(i) | |
1296 | 1084 | func getOneTknREADONLY (outAssetId,paymentAmount) = { | |
1297 | - | let $ | |
1298 | - | let amountEstimated = $ | |
1299 | - | let commonState = $ | |
1300 | - | let feeAmount = $ | |
1301 | - | let bonus = $ | |
1302 | - | let outInAmountAsset = $ | |
1085 | + | let $t04310543261 = calcGetOneToken(parseAssetId(outAssetId), paymentAmount, cfgLpAssetId, unit, unit) | |
1086 | + | let amountEstimated = $t04310543261._1 | |
1087 | + | let commonState = $t04310543261._2 | |
1088 | + | let feeAmount = $t04310543261._3 | |
1089 | + | let bonus = $t04310543261._4 | |
1090 | + | let outInAmountAsset = $t04310543261._5 | |
1303 | 1091 | $Tuple2(nil, $Tuple3(amountEstimated, feeAmount, bonus)) | |
1304 | 1092 | } | |
1305 | 1093 | ||
1306 | 1094 | ||
1307 | 1095 | ||
1308 | 1096 | @Callable(i) | |
1309 | 1097 | func unstakeAndGetOneTkn (unstakeAmount,outAssetIdStr,minOutAmount) = { | |
1310 | 1098 | let isPoolOneTokenOperationsDisabled = { | |
1311 | 1099 | let @ = invoke(factoryContract, "isPoolOneTokenOperationsDisabledREADONLY", [toString(this)], nil) | |
1312 | 1100 | if ($isInstanceOf(@, "Boolean")) | |
1313 | 1101 | then @ | |
1314 | 1102 | else throw(($getType(@) + " couldn't be cast to Boolean")) | |
1315 | 1103 | } | |
1316 | 1104 | let isGetDisabled = if (if (isGlobalShutdown()) | |
1317 | 1105 | then true | |
1318 | 1106 | else (cfgPoolStatus == PoolShutdown)) | |
1319 | 1107 | then true | |
1320 | 1108 | else isPoolOneTokenOperationsDisabled | |
1321 | 1109 | let checks = [if (if (!(isGetDisabled)) | |
1322 | 1110 | then true | |
1323 | 1111 | else isManager(i)) | |
1324 | 1112 | then true | |
1325 | 1113 | else throwErr("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1326 | 1114 | then true | |
1327 | 1115 | else throwErr("no payments are expected")] | |
1328 | 1116 | if ((checks == checks)) | |
1329 | 1117 | then { | |
1330 | 1118 | let outAssetId = parseAssetId(outAssetIdStr) | |
1331 | 1119 | let userAddress = i.caller | |
1332 | 1120 | let txId = i.transactionId | |
1333 | 1121 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1334 | 1122 | if ((currentKLp == currentKLp)) | |
1335 | 1123 | then { | |
1336 | 1124 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1337 | 1125 | if ((unstakeInv == unstakeInv)) | |
1338 | 1126 | then { | |
1339 | - | let $ | |
1340 | - | if (($ | |
1127 | + | let $t04416644317 = calcGetOneToken(outAssetId, unstakeAmount, cfgLpAssetId, userAddress, txId) | |
1128 | + | if (($t04416644317 == $t04416644317)) | |
1341 | 1129 | then { | |
1342 | - | let outInAmountAsset = $ | |
1343 | - | let bonus = $ | |
1344 | - | let feeAmount = $ | |
1345 | - | let commonState = $ | |
1346 | - | let amountEstimated = $ | |
1130 | + | let outInAmountAsset = $t04416644317._5 | |
1131 | + | let bonus = $t04416644317._4 | |
1132 | + | let feeAmount = $t04416644317._3 | |
1133 | + | let commonState = $t04416644317._2 | |
1134 | + | let amountEstimated = $t04416644317._1 | |
1347 | 1135 | let amount = if (if ((minOutAmount > 0)) | |
1348 | 1136 | then (minOutAmount > amountEstimated) | |
1349 | 1137 | else false) | |
1350 | 1138 | then throwErr(makeString(["amount to receive is less than ", toString(minOutAmount)], "")) | |
1351 | 1139 | else amountEstimated | |
1352 | 1140 | let burnInv = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1353 | 1141 | if ((burnInv == burnInv)) | |
1354 | 1142 | then { | |
1355 | - | let withdrawState = withdrawAndRebalanceAsset(outAssetIdStr, amount) | |
1356 | 1143 | let assetTransfer = [ScriptTransfer(i.caller, amount, outAssetId)] | |
1357 | 1144 | let sendFee = if ((feeAmount > 0)) | |
1358 | 1145 | then [ScriptTransfer(feeCollectorAddress, feeAmount, outAssetId)] | |
1359 | 1146 | else nil | |
1360 | - | let $ | |
1147 | + | let $t04481245059 = { | |
1361 | 1148 | let feeAmountForCalc = if ((this == feeCollectorAddress)) | |
1362 | 1149 | then 0 | |
1363 | 1150 | else feeAmount | |
1364 | 1151 | if (outInAmountAsset) | |
1365 | 1152 | then $Tuple2(-((amount + feeAmountForCalc)), 0) | |
1366 | 1153 | else $Tuple2(0, -((amount + feeAmountForCalc))) | |
1367 | 1154 | } | |
1368 | - | let amountAssetBalanceDelta = $ | |
1369 | - | let priceAssetBalanceDelta = $ | |
1370 | - | let $ | |
1371 | - | let refreshKLpActions = $ | |
1372 | - | let updatedKLp = $ | |
1155 | + | let amountAssetBalanceDelta = $t04481245059._1 | |
1156 | + | let priceAssetBalanceDelta = $t04481245059._2 | |
1157 | + | let $t04506245170 = refreshKLpInternal(amountAssetBalanceDelta, priceAssetBalanceDelta, 0) | |
1158 | + | let refreshKLpActions = $t04506245170._1 | |
1159 | + | let updatedKLp = $t04506245170._2 | |
1373 | 1160 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1374 | 1161 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1375 | - | then $Tuple2(((( | |
1162 | + | then $Tuple2((((commonState ++ assetTransfer) ++ sendFee) ++ refreshKLpActions), amount) | |
1376 | 1163 | else throw("Strict value is not equal to itself.") | |
1377 | 1164 | } | |
1378 | 1165 | else throw("Strict value is not equal to itself.") | |
1379 | 1166 | } | |
1380 | 1167 | else throw("Strict value is not equal to itself.") | |
1381 | 1168 | } | |
1382 | 1169 | else throw("Strict value is not equal to itself.") | |
1383 | 1170 | } | |
1384 | 1171 | else throw("Strict value is not equal to itself.") | |
1385 | 1172 | } | |
1386 | 1173 | else throw("Strict value is not equal to itself.") | |
1387 | 1174 | } | |
1388 | 1175 | ||
1389 | 1176 | ||
1390 | 1177 | ||
1391 | 1178 | @Callable(i) | |
1392 | 1179 | func get () = { | |
1393 | 1180 | let res = commonGet(i) | |
1394 | - | let | |
1181 | + | let outAmtAmt = res._1 | |
1395 | 1182 | let outPrAmt = res._2 | |
1396 | 1183 | let pmtAmt = res._3 | |
1397 | 1184 | let pmtAssetId = res._4 | |
1398 | 1185 | let state = res._5 | |
1399 | - | let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt) | |
1400 | 1186 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1401 | 1187 | if ((currentKLp == currentKLp)) | |
1402 | 1188 | then { | |
1403 | 1189 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1404 | 1190 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1405 | 1191 | then { | |
1406 | - | let $ | |
1407 | - | let refreshKLpActions = $ | |
1408 | - | let updatedKLp = $ | |
1192 | + | let $t04611646198 = refreshKLpInternal(-(outAmtAmt), -(outPrAmt), 0) | |
1193 | + | let refreshKLpActions = $t04611646198._1 | |
1194 | + | let updatedKLp = $t04611646198._2 | |
1409 | 1195 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1410 | 1196 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1411 | - | then ( | |
1197 | + | then (state ++ refreshKLpActions) | |
1412 | 1198 | else throw("Strict value is not equal to itself.") | |
1413 | 1199 | } | |
1414 | 1200 | else throw("Strict value is not equal to itself.") | |
1415 | 1201 | } | |
1416 | 1202 | else throw("Strict value is not equal to itself.") | |
1417 | 1203 | } | |
1418 | 1204 | ||
1419 | 1205 | ||
1420 | 1206 | ||
1421 | 1207 | @Callable(i) | |
1422 | 1208 | func getNoLess (noLessThenAmtAsset,noLessThenPriceAsset) = { | |
1423 | 1209 | let res = commonGet(i) | |
1424 | 1210 | let outAmAmt = res._1 | |
1425 | 1211 | let outPrAmt = res._2 | |
1426 | 1212 | let pmtAmt = res._3 | |
1427 | 1213 | let pmtAssetId = res._4 | |
1428 | 1214 | let state = res._5 | |
1429 | 1215 | if ((noLessThenAmtAsset > outAmAmt)) | |
1430 | 1216 | then throw(((("noLessThenAmtAsset failed: " + toString(outAmAmt)) + " < ") + toString(noLessThenAmtAsset))) | |
1431 | 1217 | else if ((noLessThenPriceAsset > outPrAmt)) | |
1432 | 1218 | then throw(((("noLessThenPriceAsset failed: " + toString(outPrAmt)) + " < ") + toString(noLessThenPriceAsset))) | |
1433 | 1219 | else { | |
1434 | - | let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt) | |
1435 | 1220 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1436 | 1221 | if ((currentKLp == currentKLp)) | |
1437 | 1222 | then { | |
1438 | 1223 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [pmtAmt], [AttachedPayment(pmtAssetId, pmtAmt)]) | |
1439 | 1224 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1440 | 1225 | then { | |
1441 | - | let $ | |
1442 | - | let refreshKLpActions = $ | |
1443 | - | let updatedKLp = $ | |
1226 | + | let $t04714747228 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1227 | + | let refreshKLpActions = $t04714747228._1 | |
1228 | + | let updatedKLp = $t04714747228._2 | |
1444 | 1229 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1445 | 1230 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1446 | - | then ( | |
1231 | + | then (state ++ refreshKLpActions) | |
1447 | 1232 | else throw("Strict value is not equal to itself.") | |
1448 | 1233 | } | |
1449 | 1234 | else throw("Strict value is not equal to itself.") | |
1450 | 1235 | } | |
1451 | 1236 | else throw("Strict value is not equal to itself.") | |
1452 | 1237 | } | |
1453 | 1238 | } | |
1454 | 1239 | ||
1455 | 1240 | ||
1456 | 1241 | ||
1457 | 1242 | @Callable(i) | |
1458 | 1243 | func unstakeAndGet (amount) = { | |
1459 | 1244 | let checkPayments = if ((size(i.payments) != 0)) | |
1460 | 1245 | then throw("No payments are expected") | |
1461 | 1246 | else true | |
1462 | 1247 | if ((checkPayments == checkPayments)) | |
1463 | 1248 | then { | |
1464 | 1249 | let cfg = getPoolConfig() | |
1465 | 1250 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1466 | 1251 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1467 | 1252 | if ((currentKLp == currentKLp)) | |
1468 | 1253 | then { | |
1469 | 1254 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(lpAssetId), amount], nil) | |
1470 | 1255 | if ((unstakeInv == unstakeInv)) | |
1471 | 1256 | then { | |
1472 | 1257 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(lpAssetId), amount, i.caller) | |
1473 | 1258 | let outAmAmt = res._1 | |
1474 | 1259 | let outPrAmt = res._2 | |
1475 | 1260 | let poolStatus = parseIntValue(res._9) | |
1476 | 1261 | let state = res._10 | |
1477 | - | let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt) | |
1478 | 1262 | let checkPoolStatus = if (if (isGlobalShutdown()) | |
1479 | 1263 | then true | |
1480 | 1264 | else (poolStatus == PoolShutdown)) | |
1481 | 1265 | then throw(("Get operation is blocked by admin. Status = " + toString(poolStatus))) | |
1482 | 1266 | else true | |
1483 | 1267 | if ((checkPoolStatus == checkPoolStatus)) | |
1484 | 1268 | then { | |
1485 | 1269 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [amount], [AttachedPayment(lpAssetId, amount)]) | |
1486 | 1270 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1487 | 1271 | then { | |
1488 | - | let $ | |
1489 | - | let refreshKLpActions = $ | |
1490 | - | let updatedKLp = $ | |
1272 | + | let $t04835448435 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1273 | + | let refreshKLpActions = $t04835448435._1 | |
1274 | + | let updatedKLp = $t04835448435._2 | |
1491 | 1275 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1492 | 1276 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1493 | - | then ( | |
1277 | + | then (state ++ refreshKLpActions) | |
1494 | 1278 | else throw("Strict value is not equal to itself.") | |
1495 | 1279 | } | |
1496 | 1280 | else throw("Strict value is not equal to itself.") | |
1497 | 1281 | } | |
1498 | 1282 | else throw("Strict value is not equal to itself.") | |
1499 | 1283 | } | |
1500 | 1284 | else throw("Strict value is not equal to itself.") | |
1501 | 1285 | } | |
1502 | 1286 | else throw("Strict value is not equal to itself.") | |
1503 | 1287 | } | |
1504 | 1288 | else throw("Strict value is not equal to itself.") | |
1505 | 1289 | } | |
1506 | 1290 | ||
1507 | 1291 | ||
1508 | 1292 | ||
1509 | 1293 | @Callable(i) | |
1510 | 1294 | func unstakeAndGetNoLess (unstakeAmount,noLessThenAmountAsset,noLessThenPriceAsset) = { | |
1511 | 1295 | let isGetDisabled = if (isGlobalShutdown()) | |
1512 | 1296 | then true | |
1513 | 1297 | else (cfgPoolStatus == PoolShutdown) | |
1514 | 1298 | let checks = [if (!(isGetDisabled)) | |
1515 | 1299 | then true | |
1516 | 1300 | else throw("get operation is blocked by admin"), if ((size(i.payments) == 0)) | |
1517 | 1301 | then true | |
1518 | 1302 | else throw("no payments are expected")] | |
1519 | 1303 | if ((checks == checks)) | |
1520 | 1304 | then { | |
1521 | 1305 | let currentKLp = calcCurrentKLp(toBigInt(0), toBigInt(0), toBigInt(0)) | |
1522 | 1306 | if ((currentKLp == currentKLp)) | |
1523 | 1307 | then { | |
1524 | 1308 | let unstakeInv = invoke(stakingContract, "unstake", [toBase58String(cfgLpAssetId), unstakeAmount], nil) | |
1525 | 1309 | if ((unstakeInv == unstakeInv)) | |
1526 | 1310 | then { | |
1527 | 1311 | let res = estimateGetOperation(toBase58String(i.transactionId), toBase58String(cfgLpAssetId), unstakeAmount, i.caller) | |
1528 | 1312 | let outAmAmt = res._1 | |
1529 | 1313 | let outPrAmt = res._2 | |
1530 | 1314 | let state = res._10 | |
1531 | - | let withdrawState = withdrawAndRebalanceAll(outAmAmt, outPrAmt) | |
1532 | 1315 | let checkAmounts = [if ((outAmAmt >= noLessThenAmountAsset)) | |
1533 | 1316 | then true | |
1534 | 1317 | else throw(makeString(["amount asset amount to receive is less than ", toString(noLessThenAmountAsset)], "")), if ((outPrAmt >= noLessThenPriceAsset)) | |
1535 | 1318 | then true | |
1536 | 1319 | else throw(makeString(["price asset amount to receive is less than ", toString(noLessThenPriceAsset)], ""))] | |
1537 | 1320 | if ((checkAmounts == checkAmounts)) | |
1538 | 1321 | then { | |
1539 | 1322 | let burnLPAssetOnFactory = invoke(factoryContract, "burn", [unstakeAmount], [AttachedPayment(cfgLpAssetId, unstakeAmount)]) | |
1540 | 1323 | if ((burnLPAssetOnFactory == burnLPAssetOnFactory)) | |
1541 | 1324 | then { | |
1542 | - | let $ | |
1543 | - | let refreshKLpActions = $ | |
1544 | - | let updatedKLp = $ | |
1325 | + | let $t04973049811 = refreshKLpInternal(-(outAmAmt), -(outPrAmt), 0) | |
1326 | + | let refreshKLpActions = $t04973049811._1 | |
1327 | + | let updatedKLp = $t04973049811._2 | |
1545 | 1328 | let isUpdatedKLpValid = validateUpdatedKLp(currentKLp, updatedKLp) | |
1546 | 1329 | if ((isUpdatedKLpValid == isUpdatedKLpValid)) | |
1547 | - | then ( | |
1330 | + | then (state ++ refreshKLpActions) | |
1548 | 1331 | else throw("Strict value is not equal to itself.") | |
1549 | 1332 | } | |
1550 | 1333 | else throw("Strict value is not equal to itself.") | |
1551 | 1334 | } | |
1552 | 1335 | else throw("Strict value is not equal to itself.") | |
1553 | 1336 | } | |
1554 | 1337 | else throw("Strict value is not equal to itself.") | |
1555 | 1338 | } | |
1556 | 1339 | else throw("Strict value is not equal to itself.") | |
1557 | 1340 | } | |
1558 | 1341 | else throw("Strict value is not equal to itself.") | |
1559 | 1342 | } | |
1560 | 1343 | ||
1561 | 1344 | ||
1562 | 1345 | ||
1563 | 1346 | @Callable(i) | |
1564 | 1347 | func activate (amtAssetStr,priceAssetStr) = if ((toString(i.caller) != toString(factoryContract))) | |
1565 | 1348 | then throw("permissions denied") | |
1566 | 1349 | else $Tuple2([StringEntry(aa(), amtAssetStr), StringEntry(pa(), priceAssetStr)], "success") | |
1567 | 1350 | ||
1568 | 1351 | ||
1569 | 1352 | ||
1570 | 1353 | @Callable(i) | |
1571 | 1354 | func refreshKLp () = { | |
1572 | 1355 | let lastRefreshedBlockHeight = valueOrElse(getInteger(keyKLpRefreshedHeight), 0) | |
1573 | 1356 | let checkLastRefreshedBlockHeight = if (((height - lastRefreshedBlockHeight) >= kLpRefreshDelay)) | |
1574 | 1357 | then unit | |
1575 | 1358 | else throwErr(makeString([toString(kLpRefreshDelay), " blocks have not passed since the previous call"], "")) | |
1576 | 1359 | if ((checkLastRefreshedBlockHeight == checkLastRefreshedBlockHeight)) | |
1577 | 1360 | then { | |
1578 | 1361 | let kLp = valueOrErrorMessage(parseBigInt(valueOrElse(getString(this, keyKLp), "0")), fmtErr("invalid kLp")) | |
1579 | - | let $ | |
1580 | - | let kLpUpdateActions = $ | |
1581 | - | let updatedKLp = $ | |
1362 | + | let $t05099851062 = refreshKLpInternal(0, 0, 0) | |
1363 | + | let kLpUpdateActions = $t05099851062._1 | |
1364 | + | let updatedKLp = $t05099851062._2 | |
1582 | 1365 | let actions = if ((kLp != updatedKLp)) | |
1583 | 1366 | then kLpUpdateActions | |
1584 | 1367 | else throwErr("nothing to refresh") | |
1585 | 1368 | $Tuple2(actions, toString(updatedKLp)) | |
1586 | 1369 | } | |
1587 | 1370 | else throw("Strict value is not equal to itself.") | |
1588 | 1371 | } | |
1589 | 1372 | ||
1590 | 1373 | ||
1591 | 1374 | ||
1592 | 1375 | @Callable(i) | |
1593 | 1376 | func getPoolConfigWrapperREADONLY () = $Tuple2(nil, getPoolConfig()) | |
1594 | 1377 | ||
1595 | 1378 | ||
1596 | 1379 | ||
1597 | 1380 | @Callable(i) | |
1598 | 1381 | func getAccBalanceWrapperREADONLY (assetId) = $Tuple2(nil, getAccBalance(assetId)) | |
1599 | 1382 | ||
1600 | 1383 | ||
1601 | 1384 | ||
1602 | 1385 | @Callable(i) | |
1603 | 1386 | func calcPricesWrapperREADONLY (amAmt,prAmt,lpAmt) = { | |
1604 | 1387 | let prices = calcPrices(amAmt, prAmt, lpAmt) | |
1605 | 1388 | $Tuple2(nil, [toString(prices[0]), toString(prices[1]), toString(prices[2])]) | |
1606 | 1389 | } | |
1607 | 1390 | ||
1608 | 1391 | ||
1609 | 1392 | ||
1610 | 1393 | @Callable(i) | |
1611 | 1394 | func toX18WrapperREADONLY (origVal,origScaleMult) = $Tuple2(nil, toString(toX18(origVal, origScaleMult))) | |
1612 | 1395 | ||
1613 | 1396 | ||
1614 | 1397 | ||
1615 | 1398 | @Callable(i) | |
1616 | 1399 | func fromX18WrapperREADONLY (val,resultScaleMult) = $Tuple2(nil, fromX18(parseBigIntValue(val), resultScaleMult)) | |
1617 | 1400 | ||
1618 | 1401 | ||
1619 | 1402 | ||
1620 | 1403 | @Callable(i) | |
1621 | 1404 | func calcPriceBigIntWrapperREADONLY (prAmtX18,amAmtX18) = $Tuple2(nil, toString(calcPriceBigInt(parseBigIntValue(prAmtX18), parseBigIntValue(amAmtX18)))) | |
1622 | 1405 | ||
1623 | 1406 | ||
1624 | 1407 | ||
1625 | 1408 | @Callable(i) | |
1626 | 1409 | func estimatePutOperationWrapperREADONLY (txId58,slippageTolerance,inAmAssetAmt,inAmAssetId,inPrAssetAmt,inPrAssetId,userAddress,isEvaluate,emitLp) = $Tuple2(nil, estimatePutOperation(txId58, slippageTolerance, inAmAssetAmt, inAmAssetId, inPrAssetAmt, inPrAssetId, userAddress, isEvaluate, emitLp)) | |
1627 | 1410 | ||
1628 | 1411 | ||
1629 | 1412 | ||
1630 | 1413 | @Callable(i) | |
1631 | 1414 | func estimateGetOperationWrapperREADONLY (txId58,pmtAssetId,pmtLpAmt,userAddress) = { | |
1632 | 1415 | let res = estimateGetOperation(txId58, pmtAssetId, pmtLpAmt, addressFromStringValue(userAddress)) | |
1633 | 1416 | $Tuple2(nil, $Tuple10(res._1, res._2, res._3, res._4, res._5, res._6, res._7, toString(res._8), res._9, res._10)) | |
1634 | 1417 | } | |
1635 | 1418 | ||
1636 | 1419 | ||
1637 | 1420 | ||
1638 | 1421 | @Callable(i) | |
1639 | 1422 | func statsREADONLY () = { | |
1640 | 1423 | let cfg = getPoolConfig() | |
1641 | 1424 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1642 | 1425 | let amtAssetId = cfg[idxAmtAssetId] | |
1643 | 1426 | let priceAssetId = cfg[idxPriceAssetId] | |
1644 | 1427 | let iAmtAssetId = cfg[idxIAmtAssetId] | |
1645 | 1428 | let iPriceAssetId = cfg[idxIPriceAssetId] | |
1646 | 1429 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1647 | 1430 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1648 | 1431 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1649 | 1432 | let accAmtAssetBalance = getAccBalance(amtAssetId) | |
1650 | 1433 | let accPriceAssetBalance = getAccBalance(priceAssetId) | |
1651 | 1434 | let pricesList = if ((poolLPBalance == 0)) | |
1652 | 1435 | then [zeroBigInt, zeroBigInt, zeroBigInt] | |
1653 | 1436 | else calcPrices(accAmtAssetBalance, accPriceAssetBalance, poolLPBalance) | |
1654 | 1437 | let curPrice = 0 | |
1655 | 1438 | let lpAmtAssetShare = fromX18(pricesList[1], scale8) | |
1656 | 1439 | let lpPriceAssetShare = fromX18(pricesList[2], scale8) | |
1657 | 1440 | let poolWeight = value(getInteger(factoryContract, keyPoolWeight(toString(this)))) | |
1658 | 1441 | $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)) | |
1659 | 1442 | } | |
1660 | 1443 | ||
1661 | 1444 | ||
1662 | 1445 | ||
1663 | 1446 | @Callable(i) | |
1664 | 1447 | func evaluatePutByAmountAssetREADONLY (inAmAssetAmt) = { | |
1665 | 1448 | let cfg = getPoolConfig() | |
1666 | 1449 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1667 | 1450 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1668 | 1451 | let amAssetId = fromBase58String(amAssetIdStr) | |
1669 | 1452 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1670 | 1453 | let prAssetId = fromBase58String(prAssetIdStr) | |
1671 | 1454 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1672 | 1455 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1673 | 1456 | let poolStatus = cfg[idxPoolStatus] | |
1674 | 1457 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1675 | 1458 | let accAmtAssetBalance = getAccBalance(amAssetIdStr) | |
1676 | 1459 | let accPriceAssetBalance = getAccBalance(prAssetIdStr) | |
1677 | 1460 | let amtAssetAmtX18 = toX18(accAmtAssetBalance, amtAssetDcm) | |
1678 | 1461 | let priceAssetAmtX18 = toX18(accPriceAssetBalance, priceAssetDcm) | |
1679 | 1462 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1680 | 1463 | then zeroBigInt | |
1681 | 1464 | else calcPriceBigInt(priceAssetAmtX18, amtAssetAmtX18) | |
1682 | 1465 | let inAmAssetAmtX18 = toX18(inAmAssetAmt, amtAssetDcm) | |
1683 | 1466 | let inPrAssetAmtX18 = fraction(inAmAssetAmtX18, curPriceX18, scale18) | |
1684 | 1467 | let inPrAssetAmt = fromX18(inPrAssetAmtX18, priceAssetDcm) | |
1685 | 1468 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1686 | 1469 | let calcLpAmt = estPut._1 | |
1687 | 1470 | let curPriceCalc = estPut._3 | |
1688 | 1471 | let amBalance = estPut._4 | |
1689 | 1472 | let prBalance = estPut._5 | |
1690 | 1473 | let lpEmission = estPut._6 | |
1691 | 1474 | $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)) | |
1692 | 1475 | } | |
1693 | 1476 | ||
1694 | 1477 | ||
1695 | 1478 | ||
1696 | 1479 | @Callable(i) | |
1697 | 1480 | func evaluatePutByPriceAssetREADONLY (inPrAssetAmt) = { | |
1698 | 1481 | let cfg = getPoolConfig() | |
1699 | 1482 | let lpAssetId = fromBase58String(cfg[idxPoolLPAssetId]) | |
1700 | 1483 | let amAssetIdStr = cfg[idxAmtAssetId] | |
1701 | 1484 | let amAssetId = fromBase58String(amAssetIdStr) | |
1702 | 1485 | let prAssetIdStr = cfg[idxPriceAssetId] | |
1703 | 1486 | let prAssetId = fromBase58String(prAssetIdStr) | |
1704 | 1487 | let amtAssetDcm = parseIntValue(cfg[idxAmtAssetDcm]) | |
1705 | 1488 | let priceAssetDcm = parseIntValue(cfg[idxPriceAssetDcm]) | |
1706 | 1489 | let poolStatus = cfg[idxPoolStatus] | |
1707 | 1490 | let poolLPBalance = valueOrErrorMessage(assetInfo(lpAssetId), (("Asset " + toBase58String(lpAssetId)) + " doesn't exist")).quantity | |
1708 | 1491 | let amBalanceRaw = getAccBalance(amAssetIdStr) | |
1709 | 1492 | let prBalanceRaw = getAccBalance(prAssetIdStr) | |
1710 | 1493 | let amBalanceRawX18 = toX18(amBalanceRaw, amtAssetDcm) | |
1711 | 1494 | let prBalanceRawX18 = toX18(prBalanceRaw, priceAssetDcm) | |
1712 | 1495 | let curPriceX18 = if ((poolLPBalance == 0)) | |
1713 | 1496 | then zeroBigInt | |
1714 | 1497 | else calcPriceBigInt(prBalanceRawX18, amBalanceRawX18) | |
1715 | 1498 | let inPrAssetAmtX18 = toX18(inPrAssetAmt, priceAssetDcm) | |
1716 | 1499 | let inAmAssetAmtX18 = fraction(inPrAssetAmtX18, scale18, curPriceX18) | |
1717 | 1500 | let inAmAssetAmt = fromX18(inAmAssetAmtX18, amtAssetDcm) | |
1718 | 1501 | let estPut = estimatePutOperation("", 500000, inAmAssetAmt, amAssetId, inPrAssetAmt, prAssetId, "", true, false) | |
1719 | 1502 | let calcLpAmt = estPut._1 | |
1720 | 1503 | let curPriceCalc = estPut._3 | |
1721 | 1504 | let amBalance = estPut._4 | |
1722 | 1505 | let prBalance = estPut._5 | |
1723 | 1506 | let lpEmission = estPut._6 | |
1724 | 1507 | $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)) | |
1725 | 1508 | } | |
1726 | 1509 | ||
1727 | 1510 | ||
1728 | 1511 | ||
1729 | 1512 | @Callable(i) | |
1730 | 1513 | func evaluateGetREADONLY (paymentLpAssetId,paymentLpAmt) = { | |
1731 | 1514 | let res = estimateGetOperation("", paymentLpAssetId, paymentLpAmt, this) | |
1732 | 1515 | let outAmAmt = res._1 | |
1733 | 1516 | let outPrAmt = res._2 | |
1734 | 1517 | let amBalance = res._5 | |
1735 | 1518 | let prBalance = res._6 | |
1736 | 1519 | let lpEmission = res._7 | |
1737 | 1520 | let curPrice = res._8 | |
1738 | 1521 | let poolStatus = parseIntValue(res._9) | |
1739 | 1522 | $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)) | |
1740 | 1523 | } | |
1741 | 1524 | ||
1742 | 1525 | ||
1743 | 1526 | @Verifier(tx) | |
1744 | 1527 | func verify () = { | |
1745 | 1528 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
1746 | 1529 | case pk: ByteVector => | |
1747 | 1530 | pk | |
1748 | 1531 | case _: Unit => | |
1749 | 1532 | tx.senderPublicKey | |
1750 | 1533 | case _ => | |
1751 | 1534 | throw("Match error") | |
1752 | 1535 | } | |
1753 | 1536 | match tx { | |
1754 | 1537 | case order: Order => | |
1755 | 1538 | let matcherPub = getMatcherPubOrFail() | |
1756 | - | let $ | |
1757 | - | let orderValid = $ | |
1758 | - | let orderValidInfo = $ | |
1539 | + | let $t05972459793 = validateMatcherOrderAllowed(order) | |
1540 | + | let orderValid = $t05972459793._1 | |
1541 | + | let orderValidInfo = $t05972459793._2 | |
1759 | 1542 | let senderValid = sigVerify(order.bodyBytes, order.proofs[0], order.senderPublicKey) | |
1760 | 1543 | let matcherValid = sigVerify(order.bodyBytes, order.proofs[1], matcherPub) | |
1761 | 1544 | if (if (if (orderValid) | |
1762 | 1545 | then senderValid | |
1763 | 1546 | else false) | |
1764 | 1547 | then matcherValid | |
1765 | 1548 | else false) | |
1766 | 1549 | then true | |
1767 | 1550 | else throwOrderError(orderValid, orderValidInfo, senderValid, matcherValid) | |
1768 | 1551 | case s: SetScriptTransaction => | |
1769 | 1552 | if (sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)) | |
1770 | 1553 | then true | |
1771 | 1554 | else { | |
1772 | 1555 | let newHash = blake2b256(value(s.script)) | |
1773 | 1556 | let allowedHash = fromBase64String(value(getString(factoryContract, keyAllowedLpScriptHash()))) | |
1774 | 1557 | let currentHash = scriptHash(this) | |
1775 | 1558 | if ((allowedHash == newHash)) | |
1776 | 1559 | then (currentHash != newHash) | |
1777 | 1560 | else false | |
1778 | 1561 | } | |
1779 | 1562 | case _ => | |
1780 | 1563 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1781 | 1564 | } | |
1782 | 1565 | } | |
1783 | 1566 |
github/deemru/w8io/169f3d6 476.72 ms ◑