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