tx · CzaqYqFb1Zd2QMcdPTA616SYMyNAmxhgBg1YZTbyc8e3 3Mz6JabBsxZgDscdZHoWmRW5PP8WVJ8r4n2: -0.02100000 Waves 2024.10.30 14:08 [3349522] smart account 3Mz6JabBsxZgDscdZHoWmRW5PP8WVJ8r4n2 > SELF 0.00000000 Waves
{ "type": 13, "id": "CzaqYqFb1Zd2QMcdPTA616SYMyNAmxhgBg1YZTbyc8e3", "fee": 2100000, "feeAssetId": null, "timestamp": 1730286513836, "version": 2, "chainId": 84, "sender": "3Mz6JabBsxZgDscdZHoWmRW5PP8WVJ8r4n2", "senderPublicKey": "jzHbeZEmXjiRimwbmDUcu7twaP3fRWZYg9YER9bDRUU", "proofs": [ "5YWzo97mgo4nMFEeDQTcnvdNqU59cwGNoHx6ysbh9Qhr1bmU2puwWMLBoJXst9ZbLw2HXJxTMEghX9nVgp9jQ1Eb" ], "script": "base64:BgItCAISBwoFCAgICAESBwoFCAgICAESABIDCgEIEgQKAggBEgUKAwgIARIDCgEIRwAHVkVSU0lPTgIIUE0tMC44LjAACWNvbmZpZ1N0cgkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzAg1jb25maWdBZGRyZXNzAiMzTjkxZTd3SGlWN1FhZERzeDNSVUpReHgxZXRxY0FLcmZIagAOQ09ORklHX0FERFJFU1MDCQAAAgUJY29uZmlnU3RyAgAFBHRoaXMJAQdBZGRyZXNzAQkA2QQBBQljb25maWdTdHIAFUFzc2V0c1dlaWdodHNEZWNpbWFscwAEAAVTY2FsZQCQTgAGU2NhbGU4AIDC1y8AB1NjYWxlMTYAgICE/qbe4REACEZlZVNjYWxlAJBOABFQb29sVG9rZW5EZWNpbWFscwAIAA5Qb29sVG9rZW5TY2FsZQkAbAYACgAABRFQb29sVG9rZW5EZWNpbWFscwAAAAAFBkhBTEZVUAAQTUlOX1NURVBTX0FNT1VOVAkBC3ZhbHVlT3JFbHNlAgkAmggCBQ5DT05GSUdfQUREUkVTUwIQbWluX3N0ZXBzX2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Y3QgaXMgb24gc3RvcAkAlAoCBQNuaWwFCUFtb3VudE91dAFpARF0cmFuc2Zlck93bmVyc2hpcAEPbmV3T3duZXJBZGRyZXNzAwkBAiE9AgkApQgBCAUBaQZjYWxsZXIJAQx0cnlHZXRTdHJpbmcBAhBzdGF0aWNfcG9vbE93bmVyCQACAQIndGhpcyBjYWxsIGF2YWlsYWJsZSBvbmx5IGZvciBwb29sIG93bmVyCQDMCAIJAQtTdHJpbmdFbnRyeQICEHN0YXRpY19wb29sT3duZXIFD25ld093bmVyQWRkcmVzcwUDbmlsAGGkg4U=", "height": 3349522, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EvYmFvPzNTKMBVRMK685kP6Ax4XWfZf8D9iGFK1GG2mK Next: 92zRoCsDm9M83smQR79Nc7qxs6rV8DvmnryUbefWR35H Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let VERSION = "PM-0. | |
4 | + | let VERSION = "PM-0.8.0" | |
5 | 5 | ||
6 | 6 | let configStr = valueOrElse(getString(this, "configAddress"), "3N91e7wHiV7QadDsx3RUJQxx1etqcAKrfHj") | |
7 | 7 | ||
22 | 22 | let PoolTokenDecimals = 8 | |
23 | 23 | ||
24 | 24 | let PoolTokenScale = pow(10, 0, PoolTokenDecimals, 0, 0, HALFUP) | |
25 | - | ||
26 | - | let InitalWavesLiquidity = Scale8 | |
27 | 25 | ||
28 | 26 | let MIN_STEPS_AMOUNT = valueOrElse(getInteger(CONFIG_ADDRESS, "min_steps_amount"), 1) | |
29 | 27 | ||
144 | 142 | ||
145 | 143 | let coldMasterAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "coldMasterAddress"), "3N91e7wHiV7QadDsx3RUJQxx1etqcAKrfHj"))) | |
146 | 144 | ||
147 | - | let factoryAccount = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "factoryAddress"), "3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr"))) | |
145 | + | let calculatorAccount = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "factoryAddress"), "3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr"))) | |
146 | + | ||
147 | + | let factoryAccount = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "factoryAddress"), "3MsgzbtRg8NEkbTcHBywtwTdCe9BRxMQo5T"))) | |
148 | 148 | ||
149 | 149 | let masterPubKey = fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "masterPubKey"), "4z8CKSYQBKkzx7PBb5uBP1YPa6YAHRNTApW1sQVHT5eU")) | |
150 | 150 | ||
214 | 214 | ||
215 | 215 | let earnedAssets = assetIds | |
216 | 216 | ||
217 | + | func getPoolStatus () = { | |
218 | + | let poolId = valueOrElse(getInteger(factoryAccount, ("pool__" + toString(this))), 0) | |
219 | + | let status = valueOrElse(getInteger(factoryAccount, ("pool__status__" + toString(poolId))), 2) | |
220 | + | status | |
221 | + | } | |
222 | + | ||
223 | + | ||
224 | + | func getSetting (key) = getIntegerValue(factoryAccount, ("setup__" + key)) | |
225 | + | ||
226 | + | ||
227 | + | let InitalWavesLiquidity = getSetting("virtualLiquidity") | |
228 | + | ||
229 | + | let CreationFee = getSetting("creationFee") | |
230 | + | ||
231 | + | let CurveTarget = getSetting("curveTarget") | |
232 | + | ||
217 | 233 | func isShutdown () = { | |
218 | 234 | let shutdownAddress = addressFromString(shutdownAddressStr) | |
219 | 235 | if ((shutdownAddress == unit)) | |
225 | 241 | false | |
226 | 242 | } | |
227 | 243 | } | |
228 | - | ||
229 | - | ||
230 | - | func getCurrentTokenBalance (tokenNum) = { | |
231 | - | let tokenIdStr = getAssetString(assetIds[tokenNum]) | |
232 | - | tryGetInteger((("global_" + tokenIdStr) + "_balance")) | |
233 | - | } | |
234 | - | ||
235 | - | ||
236 | - | func getKMult () = match getInteger("static_KMult") { | |
237 | - | case x: Int => | |
238 | - | x | |
239 | - | case _ => | |
240 | - | Scale16 | |
241 | - | } | |
242 | - | ||
243 | - | ||
244 | - | func getVirtualPoolTokenAmount () = fraction(tryGetInteger("global_poolToken_amount"), getKMult(), Scale16) | |
245 | 244 | ||
246 | 245 | ||
247 | 246 | func getPriceFromOracle (assetIdStr) = match getInteger(oracleAddress, (assetIdStr + "_twap5B")) { | |
262 | 261 | let valInFeeAsset = fraction(amount, (feeAssetBalance / feeAssetWeight), (aBalance / assetWeight)) | |
263 | 262 | let feeAssetPrice = getPriceFromOracle(feeAssetStr) | |
264 | 263 | fraction(valInFeeAsset, feeAssetPrice, feeAssetScale) | |
265 | - | } | |
266 | - | ||
267 | - | ||
268 | - | func handlePoolTokensRedeem (PRedeemed,userAddress) = { | |
269 | - | func handleTokenRedeem (accum,tokenId) = { | |
270 | - | let Bk = tryGetInteger((("global_" + getAssetString(tokenId)) + "_balance")) | |
271 | - | let PSupply = getVirtualPoolTokenAmount() | |
272 | - | let tokenDecimals = tryGetInteger((("static_" + getAssetString(tokenId)) + "_scale")) | |
273 | - | let psuppl = fraction((toBigInt((PSupply - PRedeemed)) * toBigInt(Scale8)), toBigInt(Scale8), toBigInt(PSupply), DOWN) | |
274 | - | let amount = toInt(fraction((toBigInt(Scale16) - psuppl), toBigInt(Bk), toBigInt(Scale16), CEILING)) | |
275 | - | (accum ++ [IntegerEntry((("global_" + getAssetString(tokenId)) + "_balance"), (Bk - amount)), ScriptTransfer(userAddress, amount, tokenId)]) | |
276 | - | } | |
277 | - | ||
278 | - | let $l = assetIds | |
279 | - | let $s = size($l) | |
280 | - | let $acc0 = nil | |
281 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
282 | - | then $a | |
283 | - | else handleTokenRedeem($a, $l[$i]) | |
284 | - | ||
285 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
286 | - | then $a | |
287 | - | else throw("List size exceeds 10") | |
288 | - | ||
289 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
290 | 264 | } | |
291 | 265 | ||
292 | 266 | ||
349 | 323 | } | |
350 | 324 | ||
351 | 325 | ||
352 | - | func indexStakeResult (addressStr,amount) = { | |
353 | - | let li = claimResult(addressFromStringValue(addressStr))._1 | |
354 | - | (li ++ [IntegerEntry((addressStr + "_indexStaked"), (tryGetInteger((addressStr + "_indexStaked")) + amount)), IntegerEntry("global_indexStaked", (tryGetInteger("global_indexStaked") + amount))]) | |
355 | - | } | |
356 | - | ||
357 | - | ||
358 | 326 | func sum (accum,n) = (accum + parseIntValue(n)) | |
359 | 327 | ||
360 | 328 | ||
363 | 331 | else false) | |
364 | 332 | then next | |
365 | 333 | else accum | |
366 | - | ||
367 | - | ||
368 | - | func getTmpRebalanceIds (newAssetIdsLi) = { | |
369 | - | let currentAssetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
370 | - | let result = newAssetIdsLi | |
371 | - | func f (accum,assetId) = if ((indexOf(result, assetId) == unit)) | |
372 | - | then (accum ++ [assetId]) | |
373 | - | else accum | |
374 | - | ||
375 | - | let $l = currentAssetIdsLi | |
376 | - | let $s = size($l) | |
377 | - | let $acc0 = result | |
378 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
379 | - | then $a | |
380 | - | else f($a, $l[$i]) | |
381 | - | ||
382 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
383 | - | then $a | |
384 | - | else throw("List size exceeds 10") | |
385 | - | ||
386 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
387 | - | } | |
388 | - | ||
389 | - | ||
390 | - | func checkTokensChange (newAssetIdsLi) = { | |
391 | - | let currentAssetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
392 | - | func rem (accum,assetId) = if ((indexOf(newAssetIdsLi, assetId) == unit)) | |
393 | - | then (accum + 1) | |
394 | - | else accum | |
395 | - | ||
396 | - | func add (accum,assetId) = if ((indexOf(currentAssetIdsLi, assetId) == unit)) | |
397 | - | then (accum + 1) | |
398 | - | else accum | |
399 | - | ||
400 | - | let removed = { | |
401 | - | let $l = currentAssetIdsLi | |
402 | - | let $s = size($l) | |
403 | - | let $acc0 = 0 | |
404 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
405 | - | then $a | |
406 | - | else rem($a, $l[$i]) | |
407 | - | ||
408 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
409 | - | then $a | |
410 | - | else throw("List size exceeds 10") | |
411 | - | ||
412 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
413 | - | } | |
414 | - | let added = { | |
415 | - | let $l = newAssetIdsLi | |
416 | - | let $s = size($l) | |
417 | - | let $acc0 = 0 | |
418 | - | func $f5_1 ($a,$i) = if (($i >= $s)) | |
419 | - | then $a | |
420 | - | else add($a, $l[$i]) | |
421 | - | ||
422 | - | func $f5_2 ($a,$i) = if (($i >= $s)) | |
423 | - | then $a | |
424 | - | else throw("List size exceeds 10") | |
425 | - | ||
426 | - | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
427 | - | } | |
428 | - | (removed + added) | |
429 | - | } | |
430 | - | ||
431 | - | ||
432 | - | func validatePayments (assetsList,payments) = { | |
433 | - | func getPaymentAssets (accum,next) = if ((0 >= next.amount)) | |
434 | - | then throw(((("Too low payment amount for " + getAssetString(next.assetId)) + ": ") + toString(next.amount))) | |
435 | - | else (accum ++ [getAssetString(next.assetId)]) | |
436 | - | ||
437 | - | let paymentList = { | |
438 | - | let $l = payments | |
439 | - | let $s = size($l) | |
440 | - | let $acc0 = nil | |
441 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
442 | - | then $a | |
443 | - | else getPaymentAssets($a, $l[$i]) | |
444 | - | ||
445 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
446 | - | then $a | |
447 | - | else throw("List size exceeds 10") | |
448 | - | ||
449 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
450 | - | } | |
451 | - | func f1 (accum,next) = if ((indexOf(assetsList, next) == unit)) | |
452 | - | then throw(((next + " asset is present in payments, but is not in new assets: ") + makeString(assetsList, ","))) | |
453 | - | else (accum + 1) | |
454 | - | ||
455 | - | func f2 (accum,next) = if ((indexOf(paymentList, next) == unit)) | |
456 | - | then throw(((next + " asset is present in new assets, but is not in payments: ") + makeString(paymentList, ","))) | |
457 | - | else (accum + 1) | |
458 | - | ||
459 | - | let a1 = { | |
460 | - | let $l = paymentList | |
461 | - | let $s = size($l) | |
462 | - | let $acc0 = 0 | |
463 | - | func $f5_1 ($a,$i) = if (($i >= $s)) | |
464 | - | then $a | |
465 | - | else f1($a, $l[$i]) | |
466 | - | ||
467 | - | func $f5_2 ($a,$i) = if (($i >= $s)) | |
468 | - | then $a | |
469 | - | else throw("List size exceeds 10") | |
470 | - | ||
471 | - | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
472 | - | } | |
473 | - | let a2 = { | |
474 | - | let $l = assetsList | |
475 | - | let $s = size($l) | |
476 | - | let $acc0 = 0 | |
477 | - | func $f6_1 ($a,$i) = if (($i >= $s)) | |
478 | - | then $a | |
479 | - | else f2($a, $l[$i]) | |
480 | - | ||
481 | - | func $f6_2 ($a,$i) = if (($i >= $s)) | |
482 | - | then $a | |
483 | - | else throw("List size exceeds 10") | |
484 | - | ||
485 | - | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
486 | - | } | |
487 | - | (a1 + a2) | |
488 | - | } | |
489 | 334 | ||
490 | 335 | ||
491 | 336 | func swapInternal (assetIn,assetOut,amountIn,minimum,receipientAddressStr) = { | |
544 | 389 | $Tuple2([assetOutChange, assetInChange, feeAssetOutChange, ScriptTransfer(addressFromStringValue(receipientAddressStr), AmountOut, AssetOut), ScriptTransfer(addressFromStringValue(tryGetString("static_poolOwner")), creatorFee, feeAssetOut), IntegerEntry("global_earnedByOwner", (tryGetInteger("global_earnedByOwner") + creatorFee)), IntegerEntry("global_volume_usd", (tryGetInteger("global_volume_usd") + volumeUsdUpdate)), ScriptTransfer(feesAddress, protocolFee, feeAssetOut)], AmountOut) | |
545 | 390 | } | |
546 | 391 | } | |
547 | - | ||
548 | - | ||
549 | - | @Callable(i) | |
550 | - | func deInit () = if (isShutdown()) | |
551 | - | then throw("contract is on stop") | |
552 | - | else if ((i.caller != this)) | |
553 | - | then throw("admin only") | |
554 | - | else [IntegerEntry("global_wasInited", 0)] | |
555 | - | ||
556 | 392 | ||
557 | 393 | ||
558 | 394 | @Callable(i) | |
638 | 474 | then "WAVES" | |
639 | 475 | else throw("you have to attach some WAVES") | |
640 | 476 | if ((this != this)) | |
641 | - | then throw(" | |
477 | + | then throw("self-invoke only") | |
642 | 478 | else if ((feeAssetStr == "")) | |
643 | 479 | then throw("pool must have one of the supported fee assets in the composition") | |
644 | 480 | else if ((size(poolDomain) > 13)) | |
713 | 549 | then @ | |
714 | 550 | else throw(($getType(@) + " couldn't be cast to String")) | |
715 | 551 | } | |
716 | - | swapInternal("WAVES", memeIdStr, (i.payments[0].amount - | |
552 | + | swapInternal("WAVES", memeIdStr, (i.payments[0].amount - CreationFee), 0, toString(i.caller))._1 | |
717 | 553 | } | |
718 | 554 | else throw("Strict value is not equal to itself.") | |
719 | 555 | } | |
720 | - | ||
721 | - | ||
722 | - | ||
723 | - | @Callable(i) | |
724 | - | func redeemIndex (sendToOrigin) = { | |
725 | - | let pmt = i.payments[0] | |
726 | - | if ((pmt.assetId != tryGetBinary("global_poolToken_id"))) | |
727 | - | then throw("please attach pool share token") | |
728 | - | else if (isShutdown()) | |
729 | - | then throw("contract is on stop") | |
730 | - | else { | |
731 | - | let PRedeemedWithMult = pmt.amount | |
732 | - | let PRedeemedWithNoMult = fraction(PRedeemedWithMult, getKMult(), Scale16, DOWN) | |
733 | - | let result = handlePoolTokensRedeem(PRedeemedWithNoMult, if (sendToOrigin) | |
734 | - | then i.originCaller | |
735 | - | else i.caller) | |
736 | - | (result ++ [Burn(tryGetBinary("global_poolToken_id"), PRedeemedWithMult), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") - PRedeemedWithMult))]) | |
737 | - | } | |
738 | - | } | |
739 | - | ||
740 | - | ||
741 | - | ||
742 | - | @Callable(i) | |
743 | - | func stakeIndex () = { | |
744 | - | let addressStr = toString(i.originCaller) | |
745 | - | let pmt = i.payments[0] | |
746 | - | if ((value(pmt.assetId) != tryGetBinary("global_poolToken_id"))) | |
747 | - | then throw("wrong asset attached") | |
748 | - | else indexStakeResult(addressStr, pmt.amount) | |
749 | - | } | |
750 | - | ||
751 | - | ||
752 | - | ||
753 | - | @Callable(i) | |
754 | - | func stakeIndexFor (addressStr) = { | |
755 | - | let pmt = i.payments[0] | |
756 | - | if ((value(pmt.assetId) != tryGetBinary("global_poolToken_id"))) | |
757 | - | then throw("wrong asset attached") | |
758 | - | else indexStakeResult(addressStr, pmt.amount) | |
759 | - | } | |
760 | - | ||
761 | - | ||
762 | - | ||
763 | - | @Callable(i) | |
764 | - | func unstakeIndex (indexAmount) = { | |
765 | - | let addressStr = if ((indexOf(layer2Addresses, toString(i.caller)) != unit)) | |
766 | - | then toString(i.originCaller) | |
767 | - | else toString(i.caller) | |
768 | - | let indexAvailable = tryGetInteger((addressStr + "_indexStaked")) | |
769 | - | if (isShutdown()) | |
770 | - | then throw("contract is on stop") | |
771 | - | else if ((indexAmount > indexAvailable)) | |
772 | - | then throw("you don't have index tokens available") | |
773 | - | else if (isShutdown()) | |
774 | - | then throw("contract is on stop") | |
775 | - | else (claimResult(addressFromStringValue(addressStr))._1 ++ [IntegerEntry((addressStr + "_indexStaked"), (indexAvailable - indexAmount)), IntegerEntry("global_indexStaked", (tryGetInteger("global_indexStaked") - indexAmount)), ScriptTransfer(i.caller, indexAmount, getBinaryValue("global_poolToken_id"))]) | |
776 | - | } | |
777 | 556 | ||
778 | 557 | ||
779 | 558 | ||
791 | 570 | ||
792 | 571 | @Callable(i) | |
793 | 572 | func swap (assetOut,minimum) = { | |
794 | - | let pmt = if ((size(i.payments) == 1)) | |
795 | - | then value(i.payments[0]) | |
796 | - | else throw("please attach exactly one payment") | |
797 | - | let AmountIn = value(i.payments[0].amount) | |
798 | - | let AssetIn = i.payments[0].assetId | |
799 | - | swapInternal(getAssetString(AssetIn), assetOut, AmountIn, minimum, toString(i.caller)) | |
573 | + | let status = getPoolStatus() | |
574 | + | if ((2 > status)) | |
575 | + | then { | |
576 | + | let pmt = if ((size(i.payments) == 1)) | |
577 | + | then value(i.payments[0]) | |
578 | + | else throw("please attach exactly one payment") | |
579 | + | let AmountIn = value(i.payments[0].amount) | |
580 | + | let AssetIn = i.payments[0].assetId | |
581 | + | let res = swapInternal(getAssetString(AssetIn), assetOut, AmountIn, minimum, toString(i.caller)) | |
582 | + | if ((getIntegerValue("global_WAVES_balance") > CurveTarget)) | |
583 | + | then { | |
584 | + | let notifyInv = invoke(factoryAccount, "notifyStatusUpdate", [2], nil) | |
585 | + | if ((notifyInv == notifyInv)) | |
586 | + | then res | |
587 | + | else throw("Strict value is not equal to itself.") | |
588 | + | } | |
589 | + | else res | |
590 | + | } | |
591 | + | else throw("pool is stopped: most probably it reached the target liquidity") | |
800 | 592 | } | |
801 | 593 | ||
802 | 594 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let VERSION = "PM-0. | |
4 | + | let VERSION = "PM-0.8.0" | |
5 | 5 | ||
6 | 6 | let configStr = valueOrElse(getString(this, "configAddress"), "3N91e7wHiV7QadDsx3RUJQxx1etqcAKrfHj") | |
7 | 7 | ||
8 | 8 | let CONFIG_ADDRESS = if ((configStr == "")) | |
9 | 9 | then this | |
10 | 10 | else Address(fromBase58String(configStr)) | |
11 | 11 | ||
12 | 12 | let AssetsWeightsDecimals = 4 | |
13 | 13 | ||
14 | 14 | let Scale = 10000 | |
15 | 15 | ||
16 | 16 | let Scale8 = 100000000 | |
17 | 17 | ||
18 | 18 | let Scale16 = 10000000000000000 | |
19 | 19 | ||
20 | 20 | let FeeScale = 10000 | |
21 | 21 | ||
22 | 22 | let PoolTokenDecimals = 8 | |
23 | 23 | ||
24 | 24 | let PoolTokenScale = pow(10, 0, PoolTokenDecimals, 0, 0, HALFUP) | |
25 | - | ||
26 | - | let InitalWavesLiquidity = Scale8 | |
27 | 25 | ||
28 | 26 | let MIN_STEPS_AMOUNT = valueOrElse(getInteger(CONFIG_ADDRESS, "min_steps_amount"), 1) | |
29 | 27 | ||
30 | 28 | let MAX_STEPS_AMOUNT = valueOrElse(getInteger(CONFIG_ADDRESS, "max_steps_amount"), 500) | |
31 | 29 | ||
32 | 30 | let MIN_STEPS_INTERVAL = valueOrElse(getInteger(CONFIG_ADDRESS, "min_steps_interval"), 1) | |
33 | 31 | ||
34 | 32 | let MAX_STEPS_INTERVAL = valueOrElse(getInteger(CONFIG_ADDRESS, "max_steps_interval"), 10000) | |
35 | 33 | ||
36 | 34 | let MIN_WEIGHT = valueOrElse(getInteger(CONFIG_ADDRESS, "min_weight"), 100) | |
37 | 35 | ||
38 | 36 | let MAX_WEIGHT = valueOrElse(getInteger(CONFIG_ADDRESS, "max_weight"), 9900) | |
39 | 37 | ||
40 | 38 | func tryGetInteger (key) = match getInteger(this, key) { | |
41 | 39 | case b: Int => | |
42 | 40 | b | |
43 | 41 | case _ => | |
44 | 42 | 0 | |
45 | 43 | } | |
46 | 44 | ||
47 | 45 | ||
48 | 46 | func tryGetBinary (key) = match getBinary(this, key) { | |
49 | 47 | case b: ByteVector => | |
50 | 48 | b | |
51 | 49 | case _ => | |
52 | 50 | base58'' | |
53 | 51 | } | |
54 | 52 | ||
55 | 53 | ||
56 | 54 | func tryGetString (key) = match getString(this, key) { | |
57 | 55 | case b: String => | |
58 | 56 | b | |
59 | 57 | case _ => | |
60 | 58 | "" | |
61 | 59 | } | |
62 | 60 | ||
63 | 61 | ||
64 | 62 | func tryGetStringOrThrow (key) = match getString(this, key) { | |
65 | 63 | case b: String => | |
66 | 64 | b | |
67 | 65 | case _ => | |
68 | 66 | throw(("no such key in data storage: " + key)) | |
69 | 67 | } | |
70 | 68 | ||
71 | 69 | ||
72 | 70 | func getAssetString (assetId) = match assetId { | |
73 | 71 | case b: ByteVector => | |
74 | 72 | toBase58String(b) | |
75 | 73 | case _ => | |
76 | 74 | "WAVES" | |
77 | 75 | } | |
78 | 76 | ||
79 | 77 | ||
80 | 78 | func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES")) | |
81 | 79 | then unit | |
82 | 80 | else fromBase58String(assetIdStr) | |
83 | 81 | ||
84 | 82 | ||
85 | 83 | func getTokenBalance (assetId) = match assetId { | |
86 | 84 | case t: ByteVector => | |
87 | 85 | assetBalance(this, t) | |
88 | 86 | case _ => | |
89 | 87 | wavesBalance(this).available | |
90 | 88 | } | |
91 | 89 | ||
92 | 90 | ||
93 | 91 | func addAssetBytesToList (accum,item) = (accum ++ [getAssetBytes(item)]) | |
94 | 92 | ||
95 | 93 | ||
96 | 94 | func addAssetWeightToList (accum,item) = (accum ++ [tryGetInteger((("static_" + getAssetString(item)) + "_weight"))]) | |
97 | 95 | ||
98 | 96 | ||
99 | 97 | func addAssetWeightToStrList (accum,item) = (accum ++ [toString(tryGetInteger((("static_" + item) + "_weight")))]) | |
100 | 98 | ||
101 | 99 | ||
102 | 100 | func addAssetDecimalsToList (accum,item) = (accum ++ [tryGetInteger((("static_" + getAssetString(item)) + "_decimals"))]) | |
103 | 101 | ||
104 | 102 | ||
105 | 103 | func addAssetScaleToList (accum,item) = (accum ++ [tryGetInteger((("static_" + getAssetString(item)) + "_scale"))]) | |
106 | 104 | ||
107 | 105 | ||
108 | 106 | func addIntToList (accum,item) = (accum ++ [parseIntValue(item)]) | |
109 | 107 | ||
110 | 108 | ||
111 | 109 | let usdnAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdnAssetIdStr"), "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p") | |
112 | 110 | ||
113 | 111 | let puzzleAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "puzzleAssetIdStr"), "HEB8Qaw9xrWpWs8tHsiATYGBWDBtP2S7kcPALrMu43AS") | |
114 | 112 | ||
115 | 113 | let usdtAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdtAssetIdStr"), "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ") | |
116 | 114 | ||
117 | 115 | let usdtPptAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "usdtPptAssetIdStr"), "9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi") | |
118 | 116 | ||
119 | 117 | let romeAssetIdStr = valueOrElse(getString(CONFIG_ADDRESS, "romeAssetIdStr"), "AP4Cb5xLYGH6ZigHreCZHoXpQTWDkPsG2BHqfDUx6taJ") | |
120 | 118 | ||
121 | 119 | let wavesAssetIdStr = "WAVES" | |
122 | 120 | ||
123 | 121 | let usdnAssetId = fromBase58String(usdnAssetIdStr) | |
124 | 122 | ||
125 | 123 | let puzzleAssetId = fromBase58String(puzzleAssetIdStr) | |
126 | 124 | ||
127 | 125 | let usdtAssetId = fromBase58String(usdtAssetIdStr) | |
128 | 126 | ||
129 | 127 | let usdtPptAssetId = fromBase58String(usdtPptAssetIdStr) | |
130 | 128 | ||
131 | 129 | let romeAssetId = fromBase58String(romeAssetIdStr) | |
132 | 130 | ||
133 | 131 | let wavesAssetId = unit | |
134 | 132 | ||
135 | 133 | let supportedFeeAssetsStr = [usdnAssetIdStr, puzzleAssetIdStr, usdtAssetIdStr, usdtPptAssetIdStr, wavesAssetIdStr, romeAssetIdStr] | |
136 | 134 | ||
137 | 135 | let oracleAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "oracleAddress"), "3N91e7wHiV7QadDsx3RUJQxx1etqcAKrfHj"))) | |
138 | 136 | ||
139 | 137 | let feesAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "feesAddress"), "3N91e7wHiV7QadDsx3RUJQxx1etqcAKrfHj"))) | |
140 | 138 | ||
141 | 139 | let shutdownAddressStr = valueOrElse(getString(CONFIG_ADDRESS, "shutdownAddress"), "3N91e7wHiV7QadDsx3RUJQxx1etqcAKrfHj") | |
142 | 140 | ||
143 | 141 | let layer2Addresses = valueOrElse(getString(CONFIG_ADDRESS, "layer2Addresses"), "3N91e7wHiV7QadDsx3RUJQxx1etqcAKrfHj") | |
144 | 142 | ||
145 | 143 | let coldMasterAddress = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "coldMasterAddress"), "3N91e7wHiV7QadDsx3RUJQxx1etqcAKrfHj"))) | |
146 | 144 | ||
147 | - | let factoryAccount = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "factoryAddress"), "3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr"))) | |
145 | + | let calculatorAccount = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "factoryAddress"), "3N1ytAUyhtig9X6F2hHHs1jbzYxr47Yp8Fr"))) | |
146 | + | ||
147 | + | let factoryAccount = Address(fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "factoryAddress"), "3MsgzbtRg8NEkbTcHBywtwTdCe9BRxMQo5T"))) | |
148 | 148 | ||
149 | 149 | let masterPubKey = fromBase58String(valueOrElse(getString(CONFIG_ADDRESS, "masterPubKey"), "4z8CKSYQBKkzx7PBb5uBP1YPa6YAHRNTApW1sQVHT5eU")) | |
150 | 150 | ||
151 | 151 | let T = tryGetInteger("static_tokensAmount") | |
152 | 152 | ||
153 | 153 | let assetIds = { | |
154 | 154 | let $l = split(tryGetString("static_tokenIds"), ",") | |
155 | 155 | let $s = size($l) | |
156 | 156 | let $acc0 = nil | |
157 | 157 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
158 | 158 | then $a | |
159 | 159 | else addAssetBytesToList($a, $l[$i]) | |
160 | 160 | ||
161 | 161 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
162 | 162 | then $a | |
163 | 163 | else throw("List size exceeds 10") | |
164 | 164 | ||
165 | 165 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
166 | 166 | } | |
167 | 167 | ||
168 | 168 | let AssetsWeights = { | |
169 | 169 | let $l = assetIds | |
170 | 170 | let $s = size($l) | |
171 | 171 | let $acc0 = nil | |
172 | 172 | func $f1_1 ($a,$i) = if (($i >= $s)) | |
173 | 173 | then $a | |
174 | 174 | else addAssetWeightToList($a, $l[$i]) | |
175 | 175 | ||
176 | 176 | func $f1_2 ($a,$i) = if (($i >= $s)) | |
177 | 177 | then $a | |
178 | 178 | else throw("List size exceeds 10") | |
179 | 179 | ||
180 | 180 | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
181 | 181 | } | |
182 | 182 | ||
183 | 183 | let Decimals = { | |
184 | 184 | let $l = assetIds | |
185 | 185 | let $s = size($l) | |
186 | 186 | let $acc0 = nil | |
187 | 187 | func $f2_1 ($a,$i) = if (($i >= $s)) | |
188 | 188 | then $a | |
189 | 189 | else addAssetDecimalsToList($a, $l[$i]) | |
190 | 190 | ||
191 | 191 | func $f2_2 ($a,$i) = if (($i >= $s)) | |
192 | 192 | then $a | |
193 | 193 | else throw("List size exceeds 10") | |
194 | 194 | ||
195 | 195 | $f2_2($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($f2_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
196 | 196 | } | |
197 | 197 | ||
198 | 198 | let Scales = { | |
199 | 199 | let $l = assetIds | |
200 | 200 | let $s = size($l) | |
201 | 201 | let $acc0 = nil | |
202 | 202 | func $f3_1 ($a,$i) = if (($i >= $s)) | |
203 | 203 | then $a | |
204 | 204 | else addAssetScaleToList($a, $l[$i]) | |
205 | 205 | ||
206 | 206 | func $f3_2 ($a,$i) = if (($i >= $s)) | |
207 | 207 | then $a | |
208 | 208 | else throw("List size exceeds 10") | |
209 | 209 | ||
210 | 210 | $f3_2($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($f3_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
211 | 211 | } | |
212 | 212 | ||
213 | 213 | let Fee = tryGetInteger("static_fee") | |
214 | 214 | ||
215 | 215 | let earnedAssets = assetIds | |
216 | 216 | ||
217 | + | func getPoolStatus () = { | |
218 | + | let poolId = valueOrElse(getInteger(factoryAccount, ("pool__" + toString(this))), 0) | |
219 | + | let status = valueOrElse(getInteger(factoryAccount, ("pool__status__" + toString(poolId))), 2) | |
220 | + | status | |
221 | + | } | |
222 | + | ||
223 | + | ||
224 | + | func getSetting (key) = getIntegerValue(factoryAccount, ("setup__" + key)) | |
225 | + | ||
226 | + | ||
227 | + | let InitalWavesLiquidity = getSetting("virtualLiquidity") | |
228 | + | ||
229 | + | let CreationFee = getSetting("creationFee") | |
230 | + | ||
231 | + | let CurveTarget = getSetting("curveTarget") | |
232 | + | ||
217 | 233 | func isShutdown () = { | |
218 | 234 | let shutdownAddress = addressFromString(shutdownAddressStr) | |
219 | 235 | if ((shutdownAddress == unit)) | |
220 | 236 | then false | |
221 | 237 | else match getBoolean(value(shutdownAddress), "is_shutdown") { | |
222 | 238 | case x: Boolean => | |
223 | 239 | x | |
224 | 240 | case _ => | |
225 | 241 | false | |
226 | 242 | } | |
227 | 243 | } | |
228 | - | ||
229 | - | ||
230 | - | func getCurrentTokenBalance (tokenNum) = { | |
231 | - | let tokenIdStr = getAssetString(assetIds[tokenNum]) | |
232 | - | tryGetInteger((("global_" + tokenIdStr) + "_balance")) | |
233 | - | } | |
234 | - | ||
235 | - | ||
236 | - | func getKMult () = match getInteger("static_KMult") { | |
237 | - | case x: Int => | |
238 | - | x | |
239 | - | case _ => | |
240 | - | Scale16 | |
241 | - | } | |
242 | - | ||
243 | - | ||
244 | - | func getVirtualPoolTokenAmount () = fraction(tryGetInteger("global_poolToken_amount"), getKMult(), Scale16) | |
245 | 244 | ||
246 | 245 | ||
247 | 246 | func getPriceFromOracle (assetIdStr) = match getInteger(oracleAddress, (assetIdStr + "_twap5B")) { | |
248 | 247 | case x: Int => | |
249 | 248 | x | |
250 | 249 | case _ => | |
251 | 250 | 1000000 | |
252 | 251 | } | |
253 | 252 | ||
254 | 253 | ||
255 | 254 | func calculateUsdValue (assetId,amount,aBalance) = { | |
256 | 255 | let assetWeight = tryGetInteger((("static_" + getAssetString(assetId)) + "_weight")) | |
257 | 256 | let feeAssetStr = tryGetString("static_feeToken") | |
258 | 257 | let feeAssetScale = getIntegerValue(this, (("static_" + feeAssetStr) + "_scale")) | |
259 | 258 | let feeAssetNum = value(indexOf(assetIds, getAssetBytes(feeAssetStr))) | |
260 | 259 | let feeAssetWeight = AssetsWeights[feeAssetNum] | |
261 | 260 | let feeAssetBalance = tryGetInteger((("global_" + feeAssetStr) + "_balance")) | |
262 | 261 | let valInFeeAsset = fraction(amount, (feeAssetBalance / feeAssetWeight), (aBalance / assetWeight)) | |
263 | 262 | let feeAssetPrice = getPriceFromOracle(feeAssetStr) | |
264 | 263 | fraction(valInFeeAsset, feeAssetPrice, feeAssetScale) | |
265 | - | } | |
266 | - | ||
267 | - | ||
268 | - | func handlePoolTokensRedeem (PRedeemed,userAddress) = { | |
269 | - | func handleTokenRedeem (accum,tokenId) = { | |
270 | - | let Bk = tryGetInteger((("global_" + getAssetString(tokenId)) + "_balance")) | |
271 | - | let PSupply = getVirtualPoolTokenAmount() | |
272 | - | let tokenDecimals = tryGetInteger((("static_" + getAssetString(tokenId)) + "_scale")) | |
273 | - | let psuppl = fraction((toBigInt((PSupply - PRedeemed)) * toBigInt(Scale8)), toBigInt(Scale8), toBigInt(PSupply), DOWN) | |
274 | - | let amount = toInt(fraction((toBigInt(Scale16) - psuppl), toBigInt(Bk), toBigInt(Scale16), CEILING)) | |
275 | - | (accum ++ [IntegerEntry((("global_" + getAssetString(tokenId)) + "_balance"), (Bk - amount)), ScriptTransfer(userAddress, amount, tokenId)]) | |
276 | - | } | |
277 | - | ||
278 | - | let $l = assetIds | |
279 | - | let $s = size($l) | |
280 | - | let $acc0 = nil | |
281 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
282 | - | then $a | |
283 | - | else handleTokenRedeem($a, $l[$i]) | |
284 | - | ||
285 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
286 | - | then $a | |
287 | - | else throw("List size exceeds 10") | |
288 | - | ||
289 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
290 | 264 | } | |
291 | 265 | ||
292 | 266 | ||
293 | 267 | func calculateOutAmount (AmountIn,assetIn,assetOut,BalanceIn,BalanceOut) = { | |
294 | 268 | let IndexIn = value(indexOf(assetIds, assetIn)) | |
295 | 269 | let IndexOut = value(indexOf(assetIds, assetOut)) | |
296 | 270 | if ((IndexIn == IndexOut)) | |
297 | 271 | then AmountIn | |
298 | 272 | else fraction(BalanceOut, ((Scale8 * Scale8) - toInt(pow(fraction((toBigInt(BalanceIn) * toBigInt(10000)), toBigInt((Scale8 * Scale8)), (toBigInt((BalanceIn + AmountIn)) * toBigInt(10000)), HALFUP), 16, toBigInt(fraction(AssetsWeights[IndexIn], 1000000000000, AssetsWeights[IndexOut])), 12, 16, CEILING))), (Scale8 * Scale8), HALFEVEN) | |
299 | 273 | } | |
300 | 274 | ||
301 | 275 | ||
302 | 276 | func calculateCurrentAssetInterest (assetId,assetIdStr,aBalance,tokenEarningsLastCheck) = { | |
303 | 277 | let totalStaked = tryGetInteger("global_indexStaked") | |
304 | 278 | let tokenBalanceLastCheck = tokenEarningsLastCheck | |
305 | 279 | let currentBalanceDelta = (getTokenBalance(assetId) - aBalance) | |
306 | 280 | let currentTokenEarnings = if ((currentBalanceDelta > tokenBalanceLastCheck)) | |
307 | 281 | then currentBalanceDelta | |
308 | 282 | else tokenBalanceLastCheck | |
309 | 283 | let newEarnings = (currentTokenEarnings - tokenBalanceLastCheck) | |
310 | 284 | let newInterest = if ((totalStaked == 0)) | |
311 | 285 | then 0 | |
312 | 286 | else fraction(newEarnings, Scale8, totalStaked) | |
313 | 287 | let lastCheckInterest = tryGetInteger((("global_lastCheck_" + assetIdStr) + "_interest")) | |
314 | 288 | (lastCheckInterest + newInterest) | |
315 | 289 | } | |
316 | 290 | ||
317 | 291 | ||
318 | 292 | func claimResult (address) = { | |
319 | 293 | let addressStr = toString(address) | |
320 | 294 | let puzzleAmount = tryGetInteger((addressStr + "_indexStaked")) | |
321 | 295 | func handler (accum,assetId) = { | |
322 | 296 | let assetIdStr = getAssetString(assetId) | |
323 | 297 | let aBalance = tryGetInteger((("global_" + getAssetString(assetId)) + "_balance")) | |
324 | 298 | let tokenEarningsLastCheck = tryGetInteger((("global_lastCheck_" + assetIdStr) + "_earnings")) | |
325 | 299 | let currentTokenInterest = calculateCurrentAssetInterest(assetId, assetIdStr, aBalance, tokenEarningsLastCheck) | |
326 | 300 | let currentTokenEarnings = max([tokenEarningsLastCheck, (getTokenBalance(assetId) - aBalance)]) | |
327 | 301 | let rewardAmount = fraction(puzzleAmount, (currentTokenInterest - tryGetInteger((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"))), Scale8) | |
328 | 302 | let transfer = if ((rewardAmount == 0)) | |
329 | 303 | then nil | |
330 | 304 | else [ScriptTransfer(address, rewardAmount, assetId)] | |
331 | 305 | $Tuple2(((accum._1 ++ transfer) ++ [IntegerEntry((("global_lastCheck_" + assetIdStr) + "_earnings"), (currentTokenEarnings - rewardAmount)), IntegerEntry((("global_lastCheck_" + assetIdStr) + "_interest"), currentTokenInterest), IntegerEntry((((addressStr + "_lastCheck_") + assetIdStr) + "_interest"), currentTokenInterest)]), (accum._2 + calculateUsdValue(assetId, rewardAmount, aBalance))) | |
332 | 306 | } | |
333 | 307 | ||
334 | 308 | let accum = { | |
335 | 309 | let $l = earnedAssets | |
336 | 310 | let $s = size($l) | |
337 | 311 | let $acc0 = $Tuple2(nil, 0) | |
338 | 312 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
339 | 313 | then $a | |
340 | 314 | else handler($a, $l[$i]) | |
341 | 315 | ||
342 | 316 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
343 | 317 | then $a | |
344 | 318 | else throw("List size exceeds 10") | |
345 | 319 | ||
346 | 320 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
347 | 321 | } | |
348 | 322 | $Tuple2((accum._1 ++ [IntegerEntry((addressStr + "_claimedRewardUSD"), (tryGetInteger((addressStr + "_claimedRewardUSD")) + accum._2)), IntegerEntry((addressStr + "_lastClaim"), lastBlock.timestamp)]), accum._2) | |
349 | 323 | } | |
350 | 324 | ||
351 | 325 | ||
352 | - | func indexStakeResult (addressStr,amount) = { | |
353 | - | let li = claimResult(addressFromStringValue(addressStr))._1 | |
354 | - | (li ++ [IntegerEntry((addressStr + "_indexStaked"), (tryGetInteger((addressStr + "_indexStaked")) + amount)), IntegerEntry("global_indexStaked", (tryGetInteger("global_indexStaked") + amount))]) | |
355 | - | } | |
356 | - | ||
357 | - | ||
358 | 326 | func sum (accum,n) = (accum + parseIntValue(n)) | |
359 | 327 | ||
360 | 328 | ||
361 | 329 | func checkFeeAsset (accum,next) = if (if ((indexOf(supportedFeeAssetsStr, next) != unit)) | |
362 | 330 | then (accum == "") | |
363 | 331 | else false) | |
364 | 332 | then next | |
365 | 333 | else accum | |
366 | - | ||
367 | - | ||
368 | - | func getTmpRebalanceIds (newAssetIdsLi) = { | |
369 | - | let currentAssetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
370 | - | let result = newAssetIdsLi | |
371 | - | func f (accum,assetId) = if ((indexOf(result, assetId) == unit)) | |
372 | - | then (accum ++ [assetId]) | |
373 | - | else accum | |
374 | - | ||
375 | - | let $l = currentAssetIdsLi | |
376 | - | let $s = size($l) | |
377 | - | let $acc0 = result | |
378 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
379 | - | then $a | |
380 | - | else f($a, $l[$i]) | |
381 | - | ||
382 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
383 | - | then $a | |
384 | - | else throw("List size exceeds 10") | |
385 | - | ||
386 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
387 | - | } | |
388 | - | ||
389 | - | ||
390 | - | func checkTokensChange (newAssetIdsLi) = { | |
391 | - | let currentAssetIdsLi = split(tryGetString("static_tokenIds"), ",") | |
392 | - | func rem (accum,assetId) = if ((indexOf(newAssetIdsLi, assetId) == unit)) | |
393 | - | then (accum + 1) | |
394 | - | else accum | |
395 | - | ||
396 | - | func add (accum,assetId) = if ((indexOf(currentAssetIdsLi, assetId) == unit)) | |
397 | - | then (accum + 1) | |
398 | - | else accum | |
399 | - | ||
400 | - | let removed = { | |
401 | - | let $l = currentAssetIdsLi | |
402 | - | let $s = size($l) | |
403 | - | let $acc0 = 0 | |
404 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
405 | - | then $a | |
406 | - | else rem($a, $l[$i]) | |
407 | - | ||
408 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
409 | - | then $a | |
410 | - | else throw("List size exceeds 10") | |
411 | - | ||
412 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
413 | - | } | |
414 | - | let added = { | |
415 | - | let $l = newAssetIdsLi | |
416 | - | let $s = size($l) | |
417 | - | let $acc0 = 0 | |
418 | - | func $f5_1 ($a,$i) = if (($i >= $s)) | |
419 | - | then $a | |
420 | - | else add($a, $l[$i]) | |
421 | - | ||
422 | - | func $f5_2 ($a,$i) = if (($i >= $s)) | |
423 | - | then $a | |
424 | - | else throw("List size exceeds 10") | |
425 | - | ||
426 | - | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
427 | - | } | |
428 | - | (removed + added) | |
429 | - | } | |
430 | - | ||
431 | - | ||
432 | - | func validatePayments (assetsList,payments) = { | |
433 | - | func getPaymentAssets (accum,next) = if ((0 >= next.amount)) | |
434 | - | then throw(((("Too low payment amount for " + getAssetString(next.assetId)) + ": ") + toString(next.amount))) | |
435 | - | else (accum ++ [getAssetString(next.assetId)]) | |
436 | - | ||
437 | - | let paymentList = { | |
438 | - | let $l = payments | |
439 | - | let $s = size($l) | |
440 | - | let $acc0 = nil | |
441 | - | func $f4_1 ($a,$i) = if (($i >= $s)) | |
442 | - | then $a | |
443 | - | else getPaymentAssets($a, $l[$i]) | |
444 | - | ||
445 | - | func $f4_2 ($a,$i) = if (($i >= $s)) | |
446 | - | then $a | |
447 | - | else throw("List size exceeds 10") | |
448 | - | ||
449 | - | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
450 | - | } | |
451 | - | func f1 (accum,next) = if ((indexOf(assetsList, next) == unit)) | |
452 | - | then throw(((next + " asset is present in payments, but is not in new assets: ") + makeString(assetsList, ","))) | |
453 | - | else (accum + 1) | |
454 | - | ||
455 | - | func f2 (accum,next) = if ((indexOf(paymentList, next) == unit)) | |
456 | - | then throw(((next + " asset is present in new assets, but is not in payments: ") + makeString(paymentList, ","))) | |
457 | - | else (accum + 1) | |
458 | - | ||
459 | - | let a1 = { | |
460 | - | let $l = paymentList | |
461 | - | let $s = size($l) | |
462 | - | let $acc0 = 0 | |
463 | - | func $f5_1 ($a,$i) = if (($i >= $s)) | |
464 | - | then $a | |
465 | - | else f1($a, $l[$i]) | |
466 | - | ||
467 | - | func $f5_2 ($a,$i) = if (($i >= $s)) | |
468 | - | then $a | |
469 | - | else throw("List size exceeds 10") | |
470 | - | ||
471 | - | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
472 | - | } | |
473 | - | let a2 = { | |
474 | - | let $l = assetsList | |
475 | - | let $s = size($l) | |
476 | - | let $acc0 = 0 | |
477 | - | func $f6_1 ($a,$i) = if (($i >= $s)) | |
478 | - | then $a | |
479 | - | else f2($a, $l[$i]) | |
480 | - | ||
481 | - | func $f6_2 ($a,$i) = if (($i >= $s)) | |
482 | - | then $a | |
483 | - | else throw("List size exceeds 10") | |
484 | - | ||
485 | - | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
486 | - | } | |
487 | - | (a1 + a2) | |
488 | - | } | |
489 | 334 | ||
490 | 335 | ||
491 | 336 | func swapInternal (assetIn,assetOut,amountIn,minimum,receipientAddressStr) = { | |
492 | 337 | let AmountIn = amountIn | |
493 | 338 | let AssetIn = getAssetBytes(assetIn) | |
494 | 339 | let AssetOut = getAssetBytes(assetOut) | |
495 | 340 | let scaleIn = (Scale8 / tryGetInteger((("static_" + assetIn) + "_scale"))) | |
496 | 341 | let scaleOut = (Scale8 / tryGetInteger((("static_" + assetOut) + "_scale"))) | |
497 | 342 | let feeAssetOutStr = tryGetString("static_feeToken") | |
498 | 343 | let feeAssetOut = if ((feeAssetOutStr == "")) | |
499 | 344 | then wavesAssetId | |
500 | 345 | else getAssetBytes(feeAssetOutStr) | |
501 | 346 | let AssetInBalance = tryGetInteger((("global_" + getAssetString(AssetIn)) + "_balance")) | |
502 | 347 | let AssetOutBalance = tryGetInteger((("global_" + assetOut) + "_balance")) | |
503 | 348 | let AssetInBalanceScaled = (AssetInBalance * scaleIn) | |
504 | 349 | let AssetOutBalanceScaled = (AssetOutBalance * scaleOut) | |
505 | 350 | let feeAmountIn = fraction(AmountIn, Fee, FeeScale) | |
506 | 351 | let cleanAmountIn = (AmountIn - feeAmountIn) | |
507 | 352 | let cleanAmountInScaled = (cleanAmountIn * scaleIn) | |
508 | 353 | let AmountOut1 = calculateOutAmount(cleanAmountInScaled, AssetIn, AssetOut, AssetInBalanceScaled, AssetOutBalanceScaled) | |
509 | 354 | let AmountOut = fraction(AmountOut1, 1, scaleOut) | |
510 | 355 | let AssetOutBalance2 = (AssetOutBalance - AmountOut) | |
511 | 356 | let AssetInBalance2 = (AssetInBalance + cleanAmountIn) | |
512 | 357 | let feeAssetOutBalance = if ((feeAssetOut == AssetIn)) | |
513 | 358 | then AssetInBalance2 | |
514 | 359 | else if ((feeAssetOut == AssetOut)) | |
515 | 360 | then AssetOutBalance2 | |
516 | 361 | else tryGetInteger((("global_" + getAssetString(feeAssetOut)) + "_balance")) | |
517 | 362 | let feeAmountOut = calculateOutAmount(feeAmountIn, AssetIn, feeAssetOut, AssetInBalance, feeAssetOutBalance) | |
518 | 363 | if ((minimum > AmountOut)) | |
519 | 364 | then throw("amount to recieve is lower than given one") | |
520 | 365 | else if ((AssetOut == AssetIn)) | |
521 | 366 | then throw("this swap is not allowed") | |
522 | 367 | else if ((0 > (AssetOutBalance - AmountOut))) | |
523 | 368 | then throw("contract is out of reserves") | |
524 | 369 | else if (isShutdown()) | |
525 | 370 | then throw("contract is on stop") | |
526 | 371 | else { | |
527 | 372 | let creatorFee = fraction(feeAmountOut, 1, 10) | |
528 | 373 | let protocolFee = fraction(feeAmountOut, 4, 10) | |
529 | 374 | let newBalanceIn = AssetInBalance2 | |
530 | 375 | let newBalanceOut = (AssetOutBalance2 - (if ((AssetOut == feeAssetOut)) | |
531 | 376 | then feeAmountOut | |
532 | 377 | else 0)) | |
533 | 378 | let newBalanceFeeAsset = if (if ((feeAssetOut != AssetIn)) | |
534 | 379 | then (feeAssetOut != AssetOut) | |
535 | 380 | else false) | |
536 | 381 | then (feeAssetOutBalance - feeAmountOut) | |
537 | 382 | else unit | |
538 | 383 | let assetInChange = IntegerEntry((("global_" + getAssetString(AssetIn)) + "_balance"), newBalanceIn) | |
539 | 384 | let assetOutChange = IntegerEntry((("global_" + assetOut) + "_balance"), newBalanceOut) | |
540 | 385 | let feeAssetOutChange = if ((newBalanceFeeAsset != unit)) | |
541 | 386 | then IntegerEntry((("global_" + getAssetString(feeAssetOut)) + "_balance"), value(newBalanceFeeAsset)) | |
542 | 387 | else StringEntry("hello", "world") | |
543 | 388 | let volumeUsdUpdate = calculateUsdValue(AssetIn, AmountIn, AssetInBalance) | |
544 | 389 | $Tuple2([assetOutChange, assetInChange, feeAssetOutChange, ScriptTransfer(addressFromStringValue(receipientAddressStr), AmountOut, AssetOut), ScriptTransfer(addressFromStringValue(tryGetString("static_poolOwner")), creatorFee, feeAssetOut), IntegerEntry("global_earnedByOwner", (tryGetInteger("global_earnedByOwner") + creatorFee)), IntegerEntry("global_volume_usd", (tryGetInteger("global_volume_usd") + volumeUsdUpdate)), ScriptTransfer(feesAddress, protocolFee, feeAssetOut)], AmountOut) | |
545 | 390 | } | |
546 | 391 | } | |
547 | - | ||
548 | - | ||
549 | - | @Callable(i) | |
550 | - | func deInit () = if (isShutdown()) | |
551 | - | then throw("contract is on stop") | |
552 | - | else if ((i.caller != this)) | |
553 | - | then throw("admin only") | |
554 | - | else [IntegerEntry("global_wasInited", 0)] | |
555 | - | ||
556 | 392 | ||
557 | 393 | ||
558 | 394 | @Callable(i) | |
559 | 395 | func initPool (poolDomain,poolOwner,tokenName,tokenDesc,tokenQuantity) = { | |
560 | 396 | func calculatePoolTokensAmount (payments) = { | |
561 | 397 | func handler (accum,pmt) = { | |
562 | 398 | let assetId = pmt.assetId | |
563 | 399 | func handler2 (accum,n) = if ((n == assetId)) | |
564 | 400 | then value(indexOf(assetIds, n)) | |
565 | 401 | else accum | |
566 | 402 | ||
567 | 403 | let Token = { | |
568 | 404 | let $l = assetIds | |
569 | 405 | let $s = size($l) | |
570 | 406 | let $acc0 = 1 | |
571 | 407 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
572 | 408 | then $a | |
573 | 409 | else handler2($a, $l[$i]) | |
574 | 410 | ||
575 | 411 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
576 | 412 | then $a | |
577 | 413 | else throw("List size exceeds 10") | |
578 | 414 | ||
579 | 415 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
580 | 416 | } | |
581 | 417 | fraction(accum, pow(pmt.amount, Decimals[Token], AssetsWeights[Token], AssetsWeightsDecimals, 8, FLOOR), Scale8) | |
582 | 418 | } | |
583 | 419 | ||
584 | 420 | let $l = payments | |
585 | 421 | let $s = size($l) | |
586 | 422 | let $acc0 = PoolTokenScale | |
587 | 423 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
588 | 424 | then $a | |
589 | 425 | else handler($a, $l[$i]) | |
590 | 426 | ||
591 | 427 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
592 | 428 | then $a | |
593 | 429 | else throw("List size exceeds 10") | |
594 | 430 | ||
595 | 431 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
596 | 432 | } | |
597 | 433 | ||
598 | 434 | let meme = Issue(tokenName, tokenDesc, tokenQuantity, 8, false) | |
599 | 435 | let memeId = calculateAssetId(meme) | |
600 | 436 | let memeIdStr = getAssetString(memeId) | |
601 | 437 | let assetWeightsStr = "5000,5000" | |
602 | 438 | let baseTokenIdStr = "WAVES" | |
603 | 439 | let poolOwnerAddress = Address(fromBase58String(poolOwner)) | |
604 | 440 | let assetIdsStr = ("WAVES," + memeIdStr) | |
605 | 441 | let assetIdsStrLi = split(assetIdsStr, ",") | |
606 | 442 | let assetIdsLi = { | |
607 | 443 | let $l = assetIdsStrLi | |
608 | 444 | let $s = size($l) | |
609 | 445 | let $acc0 = nil | |
610 | 446 | func $f4_1 ($a,$i) = if (($i >= $s)) | |
611 | 447 | then $a | |
612 | 448 | else addAssetBytesToList($a, $l[$i]) | |
613 | 449 | ||
614 | 450 | func $f4_2 ($a,$i) = if (($i >= $s)) | |
615 | 451 | then $a | |
616 | 452 | else throw("List size exceeds 10") | |
617 | 453 | ||
618 | 454 | $f4_2($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($f4_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
619 | 455 | } | |
620 | 456 | let fee = 100 | |
621 | 457 | let feeAssetStr = { | |
622 | 458 | let $l = assetIdsStrLi | |
623 | 459 | let $s = size($l) | |
624 | 460 | let $acc0 = "" | |
625 | 461 | func $f5_1 ($a,$i) = if (($i >= $s)) | |
626 | 462 | then $a | |
627 | 463 | else checkFeeAsset($a, $l[$i]) | |
628 | 464 | ||
629 | 465 | func $f5_2 ($a,$i) = if (($i >= $s)) | |
630 | 466 | then $a | |
631 | 467 | else throw("List size exceeds 10") | |
632 | 468 | ||
633 | 469 | $f5_2($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($f5_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
634 | 470 | } | |
635 | 471 | let pmt = i.payments[0] | |
636 | 472 | let amount = pmt.amount | |
637 | 473 | let pmtAsset = if ((pmt.assetId == unit)) | |
638 | 474 | then "WAVES" | |
639 | 475 | else throw("you have to attach some WAVES") | |
640 | 476 | if ((this != this)) | |
641 | - | then throw(" | |
477 | + | then throw("self-invoke only") | |
642 | 478 | else if ((feeAssetStr == "")) | |
643 | 479 | then throw("pool must have one of the supported fee assets in the composition") | |
644 | 480 | else if ((size(poolDomain) > 13)) | |
645 | 481 | then throw("too large pool domain") | |
646 | 482 | else if (if ((fee > 500)) | |
647 | 483 | then true | |
648 | 484 | else (0 > fee)) | |
649 | 485 | then throw("fee value must be between 50 and 500 (0.5-5%)") | |
650 | 486 | else if (isShutdown()) | |
651 | 487 | then throw("contract is on stop") | |
652 | 488 | else { | |
653 | 489 | let assetWeightsStrLi = split(assetWeightsStr, ",") | |
654 | 490 | let assetWeightsSum = { | |
655 | 491 | let $l = assetWeightsStrLi | |
656 | 492 | let $s = size($l) | |
657 | 493 | let $acc0 = 0 | |
658 | 494 | func $f6_1 ($a,$i) = if (($i >= $s)) | |
659 | 495 | then $a | |
660 | 496 | else sum($a, $l[$i]) | |
661 | 497 | ||
662 | 498 | func $f6_2 ($a,$i) = if (($i >= $s)) | |
663 | 499 | then $a | |
664 | 500 | else throw("List size exceeds 10") | |
665 | 501 | ||
666 | 502 | $f6_2($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($f6_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
667 | 503 | } | |
668 | 504 | func addTokenDataEntries (accum,assetNum) = if ((assetNum >= size(assetIdsLi))) | |
669 | 505 | then accum | |
670 | 506 | else { | |
671 | 507 | let assetDecimals = 8 | |
672 | 508 | (accum ++ [IntegerEntry((("static_" + assetIdsStrLi[assetNum]) + "_scale"), pow(10, 0, assetDecimals, 0, 0, DOWN)), IntegerEntry((("static_" + assetIdsStrLi[assetNum]) + "_decimals"), assetDecimals), IntegerEntry((("static_" + assetIdsStrLi[assetNum]) + "_weight"), value(parseInt(assetWeightsStrLi[assetNum])))]) | |
673 | 509 | } | |
674 | 510 | ||
675 | 511 | let initialPoolTokens = calculatePoolTokensAmount(i.payments) | |
676 | 512 | if ((assetWeightsSum != 10000)) | |
677 | 513 | then throw("sum of token weights must be equal to 10000") | |
678 | 514 | else if ((initialPoolTokens == 0)) | |
679 | 515 | then throw("you need a bigger tokens amount to launch the pool") | |
680 | 516 | else { | |
681 | 517 | let poolTokenIssue = Issue(("PZ " + poolDomain), "Puzzle Swap: pool index token", initialPoolTokens, PoolTokenDecimals, true, unit, 0) | |
682 | 518 | let poolTokenId = calculateAssetId(poolTokenIssue) | |
683 | 519 | $Tuple2(((({ | |
684 | 520 | let $l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
685 | 521 | let $s = size($l) | |
686 | 522 | let $acc0 = nil | |
687 | 523 | func $f7_1 ($a,$i) = if (($i >= $s)) | |
688 | 524 | then $a | |
689 | 525 | else addTokenDataEntries($a, $l[$i]) | |
690 | 526 | ||
691 | 527 | func $f7_2 ($a,$i) = if (($i >= $s)) | |
692 | 528 | then $a | |
693 | 529 | else throw("List size exceeds 10") | |
694 | 530 | ||
695 | 531 | $f7_2($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($f7_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10) | |
696 | 532 | } ++ [meme, StringEntry("static_tokenIds", assetIdsStr), StringEntry("static_feeToken", feeAssetStr), StringEntry("static_tokenWeights", assetWeightsStr), IntegerEntry("static_tokensAmount", size(assetIdsLi)), StringEntry("static_poolDomain", poolDomain), StringEntry("static_baseTokenId", baseTokenIdStr), StringEntry("static_poolOwner", poolOwner), IntegerEntry("static_fee", fee), IntegerEntry("static_KMult", Scale16), IntegerEntry("global_wasPreInited", 1)]) ++ [IntegerEntry("global_WAVES_balance", InitalWavesLiquidity), IntegerEntry((("global_" + memeIdStr) + "_balance"), tokenQuantity)]) ++ [poolTokenIssue, IntegerEntry("global_poolToken_amount", initialPoolTokens), IntegerEntry("global_wasInited", 1), BinaryEntry("global_poolToken_id", poolTokenId), StringEntry("static_poolToken_idStr", getAssetString(poolTokenId)), IntegerEntry((toString(i.caller) + "_indexStaked"), initialPoolTokens), IntegerEntry("global_indexStaked", initialPoolTokens)]), memeIdStr) | |
697 | 533 | } | |
698 | 534 | } | |
699 | 535 | } | |
700 | 536 | ||
701 | 537 | ||
702 | 538 | ||
703 | 539 | @Callable(i) | |
704 | 540 | func init (poolDomain,poolOwner,tokenName,tokenDesc,tokenQuantity) = if ((i.caller != factoryAccount)) | |
705 | 541 | then throw("admin only") | |
706 | 542 | else { | |
707 | 543 | let inv1 = invoke(this, "initPool", [poolDomain, poolOwner, tokenName, tokenDesc, tokenQuantity], nil) | |
708 | 544 | if ((inv1 == inv1)) | |
709 | 545 | then { | |
710 | 546 | let memeIdStr = { | |
711 | 547 | let @ = inv1 | |
712 | 548 | if ($isInstanceOf(@, "String")) | |
713 | 549 | then @ | |
714 | 550 | else throw(($getType(@) + " couldn't be cast to String")) | |
715 | 551 | } | |
716 | - | swapInternal("WAVES", memeIdStr, (i.payments[0].amount - | |
552 | + | swapInternal("WAVES", memeIdStr, (i.payments[0].amount - CreationFee), 0, toString(i.caller))._1 | |
717 | 553 | } | |
718 | 554 | else throw("Strict value is not equal to itself.") | |
719 | 555 | } | |
720 | - | ||
721 | - | ||
722 | - | ||
723 | - | @Callable(i) | |
724 | - | func redeemIndex (sendToOrigin) = { | |
725 | - | let pmt = i.payments[0] | |
726 | - | if ((pmt.assetId != tryGetBinary("global_poolToken_id"))) | |
727 | - | then throw("please attach pool share token") | |
728 | - | else if (isShutdown()) | |
729 | - | then throw("contract is on stop") | |
730 | - | else { | |
731 | - | let PRedeemedWithMult = pmt.amount | |
732 | - | let PRedeemedWithNoMult = fraction(PRedeemedWithMult, getKMult(), Scale16, DOWN) | |
733 | - | let result = handlePoolTokensRedeem(PRedeemedWithNoMult, if (sendToOrigin) | |
734 | - | then i.originCaller | |
735 | - | else i.caller) | |
736 | - | (result ++ [Burn(tryGetBinary("global_poolToken_id"), PRedeemedWithMult), IntegerEntry("global_poolToken_amount", (tryGetInteger("global_poolToken_amount") - PRedeemedWithMult))]) | |
737 | - | } | |
738 | - | } | |
739 | - | ||
740 | - | ||
741 | - | ||
742 | - | @Callable(i) | |
743 | - | func stakeIndex () = { | |
744 | - | let addressStr = toString(i.originCaller) | |
745 | - | let pmt = i.payments[0] | |
746 | - | if ((value(pmt.assetId) != tryGetBinary("global_poolToken_id"))) | |
747 | - | then throw("wrong asset attached") | |
748 | - | else indexStakeResult(addressStr, pmt.amount) | |
749 | - | } | |
750 | - | ||
751 | - | ||
752 | - | ||
753 | - | @Callable(i) | |
754 | - | func stakeIndexFor (addressStr) = { | |
755 | - | let pmt = i.payments[0] | |
756 | - | if ((value(pmt.assetId) != tryGetBinary("global_poolToken_id"))) | |
757 | - | then throw("wrong asset attached") | |
758 | - | else indexStakeResult(addressStr, pmt.amount) | |
759 | - | } | |
760 | - | ||
761 | - | ||
762 | - | ||
763 | - | @Callable(i) | |
764 | - | func unstakeIndex (indexAmount) = { | |
765 | - | let addressStr = if ((indexOf(layer2Addresses, toString(i.caller)) != unit)) | |
766 | - | then toString(i.originCaller) | |
767 | - | else toString(i.caller) | |
768 | - | let indexAvailable = tryGetInteger((addressStr + "_indexStaked")) | |
769 | - | if (isShutdown()) | |
770 | - | then throw("contract is on stop") | |
771 | - | else if ((indexAmount > indexAvailable)) | |
772 | - | then throw("you don't have index tokens available") | |
773 | - | else if (isShutdown()) | |
774 | - | then throw("contract is on stop") | |
775 | - | else (claimResult(addressFromStringValue(addressStr))._1 ++ [IntegerEntry((addressStr + "_indexStaked"), (indexAvailable - indexAmount)), IntegerEntry("global_indexStaked", (tryGetInteger("global_indexStaked") - indexAmount)), ScriptTransfer(i.caller, indexAmount, getBinaryValue("global_poolToken_id"))]) | |
776 | - | } | |
777 | 556 | ||
778 | 557 | ||
779 | 558 | ||
780 | 559 | @Callable(i) | |
781 | 560 | func claimIndexRewards () = if (isShutdown()) | |
782 | 561 | then throw("contract is on stop") | |
783 | 562 | else claimResult(i.caller) | |
784 | 563 | ||
785 | 564 | ||
786 | 565 | ||
787 | 566 | @Callable(i) | |
788 | 567 | func evaluateClaim (user) = $Tuple2(nil, claimResult(addressFromStringValue(user))._2) | |
789 | 568 | ||
790 | 569 | ||
791 | 570 | ||
792 | 571 | @Callable(i) | |
793 | 572 | func swap (assetOut,minimum) = { | |
794 | - | let pmt = if ((size(i.payments) == 1)) | |
795 | - | then value(i.payments[0]) | |
796 | - | else throw("please attach exactly one payment") | |
797 | - | let AmountIn = value(i.payments[0].amount) | |
798 | - | let AssetIn = i.payments[0].assetId | |
799 | - | swapInternal(getAssetString(AssetIn), assetOut, AmountIn, minimum, toString(i.caller)) | |
573 | + | let status = getPoolStatus() | |
574 | + | if ((2 > status)) | |
575 | + | then { | |
576 | + | let pmt = if ((size(i.payments) == 1)) | |
577 | + | then value(i.payments[0]) | |
578 | + | else throw("please attach exactly one payment") | |
579 | + | let AmountIn = value(i.payments[0].amount) | |
580 | + | let AssetIn = i.payments[0].assetId | |
581 | + | let res = swapInternal(getAssetString(AssetIn), assetOut, AmountIn, minimum, toString(i.caller)) | |
582 | + | if ((getIntegerValue("global_WAVES_balance") > CurveTarget)) | |
583 | + | then { | |
584 | + | let notifyInv = invoke(factoryAccount, "notifyStatusUpdate", [2], nil) | |
585 | + | if ((notifyInv == notifyInv)) | |
586 | + | then res | |
587 | + | else throw("Strict value is not equal to itself.") | |
588 | + | } | |
589 | + | else res | |
590 | + | } | |
591 | + | else throw("pool is stopped: most probably it reached the target liquidity") | |
800 | 592 | } | |
801 | 593 | ||
802 | 594 | ||
803 | 595 | ||
804 | 596 | @Callable(i) | |
805 | 597 | func swapReadOnly (assetIn,assetOut,AmountIn) = { | |
806 | 598 | let AssetIn = getAssetBytes(assetIn) | |
807 | 599 | let AssetOut = getAssetBytes(assetOut) | |
808 | 600 | let scaleIn = (Scale8 / tryGetInteger((("static_" + assetIn) + "_scale"))) | |
809 | 601 | let scaleOut = (Scale8 / tryGetInteger((("static_" + assetOut) + "_scale"))) | |
810 | 602 | let feeAssetOutStr = tryGetString("static_feeToken") | |
811 | 603 | let feeAssetOut = if ((feeAssetOutStr == "")) | |
812 | 604 | then usdnAssetId | |
813 | 605 | else getAssetBytes(feeAssetOutStr) | |
814 | 606 | let AssetInBalance = tryGetInteger((("global_" + getAssetString(AssetIn)) + "_balance")) | |
815 | 607 | let AssetOutBalance = tryGetInteger((("global_" + assetOut) + "_balance")) | |
816 | 608 | let AssetInBalanceScaled = (AssetInBalance * scaleIn) | |
817 | 609 | let AssetOutBalanceScaled = (AssetOutBalance * scaleOut) | |
818 | 610 | let feeAmountIn = fraction(AmountIn, Fee, FeeScale) | |
819 | 611 | let cleanAmountIn = (AmountIn - feeAmountIn) | |
820 | 612 | let cleanAmountInScaled = (cleanAmountIn * scaleIn) | |
821 | 613 | let AmountOut1 = calculateOutAmount(cleanAmountInScaled, AssetIn, AssetOut, AssetInBalanceScaled, AssetOutBalanceScaled) | |
822 | 614 | let AmountOut = fraction(AmountOut1, 1, scaleOut) | |
823 | 615 | let AssetOutBalance2 = (AssetOutBalance - AmountOut) | |
824 | 616 | let AssetInBalance2 = (AssetInBalance + cleanAmountIn) | |
825 | 617 | let feeAssetOutBalance = if ((feeAssetOut == AssetIn)) | |
826 | 618 | then AssetInBalance2 | |
827 | 619 | else if ((feeAssetOut == AssetOut)) | |
828 | 620 | then AssetOutBalance2 | |
829 | 621 | else tryGetInteger((("global_" + getAssetString(feeAssetOut)) + "_balance")) | |
830 | 622 | let feeAmountOut = calculateOutAmount(feeAmountIn, AssetIn, feeAssetOut, AssetInBalance, feeAssetOutBalance) | |
831 | 623 | if ((AssetOut == AssetIn)) | |
832 | 624 | then throw("this swap is not allowed") | |
833 | 625 | else if ((0 > (AssetOutBalance - AmountOut))) | |
834 | 626 | then throw("contract is out of reserves") | |
835 | 627 | else if (isShutdown()) | |
836 | 628 | then throw("contract is on stop") | |
837 | 629 | else $Tuple2(nil, AmountOut) | |
838 | 630 | } | |
839 | 631 | ||
840 | 632 | ||
841 | 633 | ||
842 | 634 | @Callable(i) | |
843 | 635 | func transferOwnership (newOwnerAddress) = if ((toString(i.caller) != tryGetString("static_poolOwner"))) | |
844 | 636 | then throw("this call available only for pool owner") | |
845 | 637 | else [StringEntry("static_poolOwner", newOwnerAddress)] | |
846 | 638 | ||
847 | 639 |
github/deemru/w8io/026f985 83.75 ms ◑