tx · AGsP8Ym1mk848FFLDZKoFojG7dBg2ztABQjkqkxEP2uM 3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy: -0.02300000 Waves 2023.03.14 10:06 [2489384] smart account 3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy > SELF 0.00000000 Waves
{ "type": 13, "id": "AGsP8Ym1mk848FFLDZKoFojG7dBg2ztABQjkqkxEP2uM", "fee": 2300000, "feeAssetId": null, "timestamp": 1678777584503, "version": 2, "chainId": 84, "sender": "3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy", "senderPublicKey": "9W33iCCNfmFxUbiC6XZcH5x7f6xfwC7Jb3BoExT5q2PV", "proofs": [ "3Bs7neZfbNkMrvLE5R85hm3cAnJMWNrkwzDnGP5YKhTyn7a199Q7T1LdoSk29NhN88jGgSkTF2ZWotjnEiB2pxg7" ], "script": "base64:BgLAJggCEggKBggIAQEBCBIFCgMBCAISAwoBARIDCgEBEgQKAggIEgQKAggIEgMKAQgSAwoBCBIDCgEIEgQKAggBEgASAwoBCBIAIgNTRVAiBlNDQUxFOCIFTVVMVDgiDlBPT0xXRUlHSFRNVUxUIgd3cmFwRXJyIgNtc2ciCHRocm93RXJyIgRzdHJmIgdhZGRyZXNzIgNrZXkiA2lveiIDaW9kIgpkZWZhdWx0VmFsIgNpb2YiA2FicyIDdmFsIgNhYWwiByRtYXRjaDAiCnZhbEFueUx5c3QiAmFpIgZ2YWxJbnQiG2tleVJlZmVycmFsc0NvbnRyYWN0QWRkcmVzcyIecmVmZXJyYWxzQ29udHJhY3RBZGRyZXNzT3JGYWlsIhZrZXlSZWZlcnJhbFByb2dyYW1OYW1lIhpyZWZlcnJhbFByb2dyYW1OYW1lRGVmYXVsdCITcmVmZXJyYWxQcm9ncmFtTmFtZSIRa2V5RmFjdG9yeUFkZHJlc3MiGElkeEZhY3RvcnlDZmdTdGFraW5nRGFwcCIZSWR4RmFjdG9yeUNmZ0Jvb3N0aW5nRGFwcCIUSWR4R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wIAgkBC0RlbGV0ZUVudHJ5AQkBAmFnAAUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJldwECZXgABAJleQQBcgkBAmFDAAMJAAECBQFyAgpCeXRlVmVjdG9yBAJhSQUBcgUCYUkDCQABAgUBcgIEVW5pdAgFAmV3D3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJldwlib2R5Qnl0ZXMJAJEDAggFAmV3BnByb29mcwAABQJlecET4hE=", "height": 2489384, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FzV24NVEjjqLnb7UqqJizKNRYBRrZELS3FnsSSHSfCUQ Next: 9nADWe8u2wXQ4GtPDijPpNWMpf89X1wkAox3R9brWmHt Diff:
Old | New | Differences | |
---|---|---|---|
136 | 136 | ||
137 | 137 | ||
138 | 138 | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
139 | - | ||
140 | - | ||
141 | - | func keyBoostingV2LastUpdateHeight () = "%s%s__boostingV2__startBlock" | |
142 | - | ||
143 | - | ||
144 | - | func keyBoostingV2Integral () = "%s%s__boostingV2__integral" | |
145 | 139 | ||
146 | 140 | ||
147 | 141 | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
283 | 277 | func keyStatsUsersCount () = "%s%s__stats__activeUsersCount" | |
284 | 278 | ||
285 | 279 | ||
286 | - | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__ | |
280 | + | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastInt", userNum], SEP) | |
287 | 281 | ||
288 | 282 | ||
289 | - | func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__ | |
283 | + | func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__userBoostEmissionLastInt", userNum, lpAssetId], SEP) | |
290 | 284 | ||
291 | 285 | ||
292 | 286 | func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", userNum], SEP) | |
319 | 313 | ||
320 | 314 | let lpStakingPoolsContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(makeString(["%s", "lpStakingPoolsContract"], SEP)), wrapErr("lp_staking_pools contract address is undefined"))), wrapErr("invalid lp_staking_pools contract address")) | |
321 | 315 | ||
322 | - | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], SEP) | |
323 | - | ||
324 | - | let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract)) | |
325 | - | ||
326 | - | let boostCoeff = { | |
327 | - | let @ = invoke(emissionContract, "getBoostCoeffREADONLY", nil, nil) | |
328 | - | if ($isInstanceOf(@, "Int")) | |
329 | - | then @ | |
330 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
331 | - | } | |
332 | - | ||
333 | 316 | func getTotalCachedGwx (correct) = { | |
317 | + | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], SEP) | |
318 | + | let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract)) | |
334 | 319 | let keyCurrentEpochUi = makeString(["%s", "currentEpochUi"], SEP) | |
335 | 320 | let currentEpochUi = getIntegerValue(votingEmissionContract, keyCurrentEpochUi) | |
336 | 321 | let keyTargetEpoch = makeString(["%s%s", "totalCachedGwxCorrection__activationEpoch"], SEP) | |
416 | 401 | func calcCurrentGwxAmount (userAddress) = calcUserGwxAmountAtHeight(userAddress, height) | |
417 | 402 | ||
418 | 403 | ||
419 | - | func getVotingEmissionEpochInfo () = { | |
420 | - | let keyCurrentEpochUi = makeString(["%s", "currentEpochUi"], SEP) | |
421 | - | let $t01515015438 = { | |
422 | - | let currentEpochUi = value(getInteger(votingEmissionContract, keyCurrentEpochUi)) | |
423 | - | let lastFinalizedEpoch = (currentEpochUi - 1) | |
424 | - | if ((0 > lastFinalizedEpoch)) | |
425 | - | then throwErr("invalid epoch") | |
426 | - | else $Tuple2(currentEpochUi, lastFinalizedEpoch) | |
427 | - | } | |
428 | - | let currentEpochUi = $t01515015438._1 | |
429 | - | let lastFinalizedEpoch = $t01515015438._2 | |
430 | - | func keyStartHeightByEpoch (epoch) = makeString(["%s%d", "startHeight", toString(epoch)], SEP) | |
431 | - | ||
432 | - | let currentEpochStartHeight = value(getInteger(votingEmissionContract, keyStartHeightByEpoch(currentEpochUi))) | |
433 | - | $Tuple2(lastFinalizedEpoch, currentEpochStartHeight) | |
434 | - | } | |
435 | - | ||
436 | - | ||
437 | - | func getPoolAssetsByLpAssetId (lpAssetIdStr) = { | |
438 | - | let idxAmountAssetId = 4 | |
439 | - | let idxPriceAssetId = 5 | |
440 | - | let poolCfg = { | |
441 | - | let @ = invoke(factoryContract, "getPoolConfigByLpAssetId", [lpAssetIdStr], nil) | |
442 | - | if ($isInstanceOf(@, "List[Any]")) | |
443 | - | then @ | |
444 | - | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
445 | - | } | |
446 | - | let amountAssetId = { | |
447 | - | let @ = poolCfg[idxAmountAssetId] | |
448 | - | if ($isInstanceOf(@, "String")) | |
449 | - | then @ | |
450 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
451 | - | } | |
452 | - | let priceAssetId = { | |
453 | - | let @ = poolCfg[idxPriceAssetId] | |
454 | - | if ($isInstanceOf(@, "String")) | |
455 | - | then @ | |
456 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
457 | - | } | |
458 | - | $Tuple2(amountAssetId, priceAssetId) | |
459 | - | } | |
460 | - | ||
461 | - | ||
462 | - | func keyVote (amountAssetId,priceAssetId,address,epoch) = makeString(["%s%s%s%s%d", "vote", amountAssetId, priceAssetId, toString(address), toString(epoch)], SEP) | |
463 | - | ||
464 | - | ||
465 | - | func keyVotingResultStaked (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStaked", lpAssetIdStr, toString(epoch)], SEP) | |
466 | - | ||
467 | - | ||
468 | - | func keyVotingResultStakedIntegral (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegral", lpAssetIdStr, toString(epoch)], SEP) | |
469 | - | ||
470 | - | ||
471 | - | func keyVotingResultStakedLastUpdateHeight (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(epoch)], SEP) | |
472 | - | ||
473 | - | ||
474 | - | func keyVotingResultStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "votingResultStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
475 | - | ||
476 | - | ||
477 | - | func keyVoteStakedIntegral (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegral", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
478 | - | ||
479 | - | ||
480 | - | func keyVoteStakedLastUpdateHeight (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
481 | - | ||
482 | - | ||
483 | - | func keyVoteStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
484 | - | ||
485 | - | ||
486 | - | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s", "staked", userAddressStr, lpAssetIdStr], SEP) | |
487 | - | ||
488 | - | ||
489 | - | func getUserVoteFinalized (lpAssetIdStr,userAddressStr) = { | |
490 | - | let userAddress = addressFromStringValue(userAddressStr) | |
491 | - | let $t01822818308 = getVotingEmissionEpochInfo() | |
492 | - | let lastFinalizedEpoch = $t01822818308._1 | |
493 | - | let currentEpochStartHeight = $t01822818308._2 | |
494 | - | let $t01831118386 = getPoolAssetsByLpAssetId(lpAssetIdStr) | |
495 | - | let amountAssetId = $t01831118386._1 | |
496 | - | let priceAssetId = $t01831118386._2 | |
497 | - | let userVoteKey = keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch) | |
498 | - | let userVote = valueOrElse(getInteger(votingEmissionContract, userVoteKey), 0) | |
499 | - | userVote | |
500 | - | } | |
501 | - | ||
502 | - | ||
503 | - | func getUserVoteStaked (lpAssetIdStr,userAddressStr) = { | |
504 | - | let stakedByUser = valueOrElse(getInteger(stakingContract, keyStakedByUser(userAddressStr, lpAssetIdStr)), 0) | |
505 | - | let userVote = getUserVoteFinalized(lpAssetIdStr, userAddressStr) | |
506 | - | if ((stakedByUser == 0)) | |
507 | - | then 0 | |
508 | - | else userVote | |
509 | - | } | |
510 | - | ||
511 | - | ||
512 | - | func getVotingResultStaked (lpAssetIdStr) = { | |
513 | - | let $t01893019010 = getVotingEmissionEpochInfo() | |
514 | - | let lastFinalizedEpoch = $t01893019010._1 | |
515 | - | let currentEpochStartHeight = $t01893019010._2 | |
516 | - | let votingResultStakedStart = valueOrElse(getInteger(votingEmissionContract, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
517 | - | let votingResultStaked = valueOrElse(getInteger(this, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), votingResultStakedStart) | |
518 | - | votingResultStaked | |
519 | - | } | |
520 | - | ||
521 | - | ||
522 | - | func refreshVotingResultStakedIntegral (lpAssetIdStr,stakedVoteDelta) = { | |
523 | - | let $t01953119611 = getVotingEmissionEpochInfo() | |
524 | - | let lastFinalizedEpoch = $t01953119611._1 | |
525 | - | let currentEpochStartHeight = $t01953119611._2 | |
526 | - | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
527 | - | let votingResultStakedNew = (votingResultStaked + stakedVoteDelta) | |
528 | - | let votingResultStakedIntegralKey = keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch) | |
529 | - | let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, votingResultStakedIntegralKey), 0) | |
530 | - | let votingResultLastUpdateHeightKey = keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch) | |
531 | - | let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, votingResultLastUpdateHeightKey), currentEpochStartHeight) | |
532 | - | let votingResultStakedIntegralDh = (height - votingResultStakedLastUpdateHeight) | |
533 | - | let votingResultStakedIntegral = ((votingResultStakedIntegralDh * votingResultStaked) + votingResultStakedIntegralPrev) | |
534 | - | $Tuple2([IntegerEntry(keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch), votingResultStakedNew), IntegerEntry(votingResultLastUpdateHeightKey, height), IntegerEntry(votingResultStakedIntegralKey, votingResultStakedIntegral)], votingResultStakedIntegral) | |
535 | - | } | |
536 | - | ||
537 | - | ||
538 | - | func refreshVoteStakedIntegral (lpAssetIdStr,userAddressStr,edge) = { | |
539 | - | let $t02081120891 = getVotingEmissionEpochInfo() | |
540 | - | let lastFinalizedEpoch = $t02081120891._1 | |
541 | - | let currentEpochStartHeight = $t02081120891._2 | |
542 | - | let userAddress = addressFromStringValue(userAddressStr) | |
543 | - | let idxAmountAssetId = 4 | |
544 | - | let idxPriceAssetId = 5 | |
545 | - | let poolCfg = { | |
546 | - | let @ = invoke(factoryContract, "getPoolConfigByLpAssetId", [lpAssetIdStr], nil) | |
547 | - | if ($isInstanceOf(@, "List[Any]")) | |
548 | - | then @ | |
549 | - | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
550 | - | } | |
551 | - | let amountAssetId = { | |
552 | - | let @ = poolCfg[idxAmountAssetId] | |
553 | - | if ($isInstanceOf(@, "String")) | |
554 | - | then @ | |
555 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
556 | - | } | |
557 | - | let priceAssetId = { | |
558 | - | let @ = poolCfg[idxPriceAssetId] | |
559 | - | if ($isInstanceOf(@, "String")) | |
560 | - | then @ | |
561 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
562 | - | } | |
563 | - | let userVote = valueOrElse(getInteger(votingEmissionContract, keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch)), 0) | |
564 | - | let actions = if ((userVote == 0)) | |
565 | - | then nil | |
566 | - | else { | |
567 | - | let stakedVoteDelta = if (edge) | |
568 | - | then userVote | |
569 | - | else -(userVote) | |
570 | - | let $t02149621615 = refreshVotingResultStakedIntegral(lpAssetIdStr, stakedVoteDelta) | |
571 | - | let votingResultActions = $t02149621615._1 | |
572 | - | let votingResultStakedIntegral = $t02149621615._2 | |
573 | - | let userVoteStaked = if (edge) | |
574 | - | then 0 | |
575 | - | else userVote | |
576 | - | let userVoteStakedIntegralKey = keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
577 | - | let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, userVoteStakedIntegralKey), 0) | |
578 | - | let userVoteStakedLastUpdateHeightKey = keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
579 | - | let userVoteStakedLastUpdateHeight = valueOrElse(getInteger(this, userVoteStakedLastUpdateHeightKey), currentEpochStartHeight) | |
580 | - | let userVoteStakedIntegralDh = (height - userVoteStakedLastUpdateHeight) | |
581 | - | let userVoteStakedIntegral = ((userVoteStakedIntegralDh * userVoteStaked) + userVoteStakedIntegralPrev) | |
582 | - | let voteActions = [IntegerEntry(userVoteStakedLastUpdateHeightKey, height), IntegerEntry(userVoteStakedIntegralKey, userVoteStakedIntegral)] | |
583 | - | (votingResultActions ++ voteActions) | |
584 | - | } | |
585 | - | actions | |
586 | - | } | |
587 | - | ||
588 | - | ||
589 | - | func getStakedVotesIntegralsDiff (lpAssetIdStr,userAddressStr) = { | |
590 | - | let $t02260722687 = getVotingEmissionEpochInfo() | |
591 | - | let lastFinalizedEpoch = $t02260722687._1 | |
592 | - | let currentEpochStartHeight = $t02260722687._2 | |
593 | - | let userAddress = addressFromStringValue(userAddressStr) | |
594 | - | let userVoteStaked = getUserVoteStaked(lpAssetIdStr, userAddressStr) | |
595 | - | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
596 | - | let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch)), 0) | |
597 | - | let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
598 | - | let userVoteStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch)), currentEpochStartHeight) | |
599 | - | let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch)), currentEpochStartHeight) | |
600 | - | let userVoteStakedIntegralKey = keyVoteStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
601 | - | let userVoteStakedIntegralLast = valueOrElse(getInteger(this, userVoteStakedIntegralKey), 0) | |
602 | - | let votingResultStakedIntegralKey = keyVotingResultStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
603 | - | let votingResultStakedIntegralLast = valueOrElse(getInteger(this, votingResultStakedIntegralKey), 0) | |
604 | - | let userVoteStakedIntegralDh = (height - userVoteStakedLastUpdateHeight) | |
605 | - | let votingResultStakedIntegralDh = (height - votingResultStakedLastUpdateHeight) | |
606 | - | let userVoteStakedIntegral = ((userVoteStakedIntegralDh * userVoteStaked) + userVoteStakedIntegralPrev) | |
607 | - | let votingResultStakedIntegral = ((votingResultStakedIntegralDh * votingResultStaked) + votingResultStakedIntegralPrev) | |
608 | - | let userVoteStakedIntegralDiff = (userVoteStakedIntegral - userVoteStakedIntegralLast) | |
609 | - | let votingResultStakedIntegralDiff = (votingResultStakedIntegral - votingResultStakedIntegralLast) | |
610 | - | $Tuple3([IntegerEntry(userVoteStakedIntegralKey, userVoteStakedIntegral), IntegerEntry(votingResultStakedIntegralKey, votingResultStakedIntegral)], userVoteStakedIntegralDiff, votingResultStakedIntegralDiff) | |
611 | - | } | |
612 | - | ||
613 | - | ||
614 | - | func refreshBoostEmissionIntegral () = { | |
615 | - | let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent()) | |
616 | - | let boostingV2LastUpdateHeightOption = getInteger(emissionContract, keyBoostingV2LastUpdateHeight()) | |
617 | - | let boostingV2IngergalOption = getInteger(this, keyBoostingV2Integral()) | |
618 | - | let emissionEnd = iof(emissionContract, keyEmissionEndBlock()) | |
619 | - | let h = if ((height > emissionEnd)) | |
620 | - | then emissionEnd | |
621 | - | else height | |
622 | - | let dh = match boostingV2LastUpdateHeightOption { | |
623 | - | case lastUpdateHeight: Int => | |
624 | - | max([(h - lastUpdateHeight), 0]) | |
625 | - | case _: Unit => | |
626 | - | 0 | |
627 | - | case _ => | |
628 | - | throw("Match error") | |
629 | - | } | |
630 | - | let boostEmissionPerBlock = ((wxEmissionPerBlock * (boostCoeff - 1)) / boostCoeff) | |
631 | - | let boostEmissionIntegralPrev = valueOrElse(boostingV2IngergalOption, 0) | |
632 | - | let boostEmissionIntegral = ((boostEmissionPerBlock * dh) + boostEmissionIntegralPrev) | |
633 | - | $Tuple2([IntegerEntry(keyBoostingV2Integral(), boostEmissionIntegral), IntegerEntry(keyBoostingV2LastUpdateHeight(), height)], boostEmissionIntegral) | |
634 | - | } | |
635 | - | ||
636 | - | ||
637 | 404 | func internalClaimWxBoost (lpAssetIdStr,userAddressStr,readOnly) = { | |
638 | - | let userRecordOption = getString(this, keyLockParamsRecord(userAddressStr)) | |
639 | - | if ((userRecordOption == unit)) | |
405 | + | let EMPTY = "EMPTY" | |
406 | + | let userRecordOrEmpty = valueOrElse(getString(this, keyLockParamsRecord(userAddressStr)), EMPTY) | |
407 | + | if ((userRecordOrEmpty == EMPTY)) | |
640 | 408 | then $Tuple3(0, nil, "userRecord::is::empty") | |
641 | 409 | else { | |
642 | - | let userRecordArray = split( | |
410 | + | let userRecordArray = split(userRecordOrEmpty, SEP) | |
643 | 411 | let userNumStr = userRecordArray[IdxLockUserNum] | |
412 | + | let gwxRewardEmissionStartHeight = valueOrElse(getInteger(gwxRewardContract, keyGwxRewardEmissionStartHeight()), 0) | |
644 | 413 | let EMPTYSTR = "empty" | |
645 | - | let | |
414 | + | let $t01539715965 = if ((lpAssetIdStr != EMPTYSTR)) | |
646 | 415 | then { | |
647 | 416 | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
648 | - | getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
417 | + | let pw1 = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
418 | + | let pw0 = valueOrElse(getInteger(factoryContract, keyFactoryPoolWeightHistory(poolAddressStr, 0)), pw1) | |
419 | + | $Tuple2(pw0, pw1) | |
649 | 420 | } | |
650 | 421 | else if (readOnly) | |
651 | - | then 0 | |
422 | + | then $Tuple2(0, 0) | |
652 | 423 | else throw(("not readonly mode: unsupported lp asset " + lpAssetIdStr)) | |
424 | + | let poolWeight0 = $t01539715965._1 | |
425 | + | let poolWeight1 = $t01539715965._2 | |
426 | + | let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent()) | |
427 | + | let emissionStart = iof(emissionContract, keyEmissionStartBlock()) | |
428 | + | let emissionEnd = iof(emissionContract, keyEmissionEndBlock()) | |
429 | + | let h = if ((height > emissionEnd)) | |
430 | + | then emissionEnd | |
431 | + | else height | |
432 | + | let dh = max([(h - emissionStart), 0]) | |
653 | 433 | let userLpBoostEmissionLastIntegralKEY = keyUserLpBoostEmissionLastINTEGRAL(userNumStr, lpAssetIdStr) | |
654 | 434 | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr) | |
655 | 435 | let userBoostEmissionLastIntegral = valueOrElse(getInteger(this, userLpBoostEmissionLastIntegralKEY), ioz(this, userBoostEmissionLastIntegralKEY)) | |
656 | - | let boostEmissionIntegral = | |
436 | + | let boostEmissionIntegral = (((wxEmissionPerBlock * dh) * 2) / 3) | |
657 | 437 | let userBoostEmissionIntegral = (boostEmissionIntegral - userBoostEmissionLastIntegral) | |
658 | - | if ((0 > userBoostEmissionIntegral)) | |
659 | - | then throw("wrong calculations") | |
660 | - | else { | |
661 | - | let $t02721227351 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr) | |
662 | - | let stakedVotesIntegralsActions = $t02721227351._1 | |
663 | - | let userVoteIntegralDiff = $t02721227351._2 | |
664 | - | let totalVotesIntegralDiff = $t02721227351._3 | |
665 | - | let poolUserBoostEmissionIntegral = fraction(userBoostEmissionIntegral, poolWeight, POOLWEIGHTMULT) | |
666 | - | let userBoostAvaliableToClaimTotalNew = if ((totalVotesIntegralDiff == 0)) | |
667 | - | then 0 | |
668 | - | else fraction(poolUserBoostEmissionIntegral, userVoteIntegralDiff, totalVotesIntegralDiff) | |
669 | - | let dataState = ([IntegerEntry(userLpBoostEmissionLastIntegralKEY, boostEmissionIntegral)] ++ stakedVotesIntegralsActions) | |
670 | - | let debug = makeString([toString(userBoostEmissionLastIntegral), toString(userBoostEmissionIntegral), toString(poolWeight), toString(userVoteIntegralDiff), toString(totalVotesIntegralDiff)], ":") | |
671 | - | $Tuple3(userBoostAvaliableToClaimTotalNew, dataState, debug) | |
672 | - | } | |
438 | + | let udh = fraction(userBoostEmissionIntegral, 3, (2 * wxEmissionPerBlock)) | |
439 | + | let uLastH = (h - udh) | |
440 | + | let udh0 = max([(gwxRewardEmissionStartHeight - uLastH), 0]) | |
441 | + | let udh1 = ((h - uLastH) - udh0) | |
442 | + | if (if (if ((0 > uLastH)) | |
443 | + | then true | |
444 | + | else (0 > udh1)) | |
445 | + | then true | |
446 | + | else (abs(((udh0 + udh1) - udh)) >= 1)) | |
447 | + | then throw(((((((((((("invalid udh calc: udh=" + toString(udh)) + " uLastH=") + toString(uLastH)) + " udh0=") + toString(udh0)) + " udh1=") + toString(udh1)) + " lpAssetId=") + lpAssetIdStr) + " userAddress=") + userAddressStr)) | |
448 | + | else if ((0 > userBoostEmissionIntegral)) | |
449 | + | then throw("wrong calculations") | |
450 | + | else { | |
451 | + | let userMaxBoostIntegralKEY = keyUserMaxBoostINTEGRAL(userNumStr) | |
452 | + | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() | |
453 | + | let userMaxBoostInt = ioz(this, userMaxBoostIntegralKEY) | |
454 | + | let totalMaxBoostInt = ioz(this, totalMaxBoostIntegralKEY) | |
455 | + | let totalCachedGwxCorrected = getTotalCachedGwx(true) | |
456 | + | let userCurrGwx = calcCurrentGwxAmount(userAddressStr) | |
457 | + | let userBoostAvalaibleToClaimTotalKEY = keyUserBoostAvalaibleToClaimTotal(userNumStr) | |
458 | + | let userBoostAvaliableToClaimTotal = ioz(this, userBoostAvalaibleToClaimTotalKEY) | |
459 | + | let userBoostEmissionIntegral0 = if ((udh == 0)) | |
460 | + | then 0 | |
461 | + | else fraction(userBoostEmissionIntegral, udh0, udh) | |
462 | + | let userBoostEmissionIntegral1 = if ((udh == 0)) | |
463 | + | then 0 | |
464 | + | else fraction(userBoostEmissionIntegral, udh1, udh) | |
465 | + | let poolUserBoostEmissionIntegral0 = fraction(userBoostEmissionIntegral0, poolWeight0, POOLWEIGHTMULT) | |
466 | + | let poolUserBoostEmissionIntegral1 = fraction(userBoostEmissionIntegral1, poolWeight1, POOLWEIGHTMULT) | |
467 | + | let userBoostAvaliableToClaimTotalNew0 = if ((totalCachedGwxCorrected == 0)) | |
468 | + | then 0 | |
469 | + | else fraction(poolUserBoostEmissionIntegral0, userCurrGwx, totalCachedGwxCorrected) | |
470 | + | let userBoostAvaliableToClaimTotalNew1 = if ((totalCachedGwxCorrected == 0)) | |
471 | + | then 0 | |
472 | + | else fraction(poolUserBoostEmissionIntegral1, userCurrGwx, totalCachedGwxCorrected) | |
473 | + | let userBoostAvaliableToClaimTotalNew = (userBoostAvaliableToClaimTotalNew0 + userBoostAvaliableToClaimTotalNew1) | |
474 | + | let userBoostClaimedKEY = keyUserBoostClaimed(userNumStr) | |
475 | + | let userBoostClaimed = ioz(this, userBoostClaimedKEY) | |
476 | + | let userBoostAvailable = (userBoostAvaliableToClaimTotalNew - userBoostClaimed) | |
477 | + | let dataState = [IntegerEntry(userLpBoostEmissionLastIntegralKEY, boostEmissionIntegral)] | |
478 | + | let debug = makeString([toString(userBoostEmissionLastIntegral), toString(userBoostEmissionIntegral), toString(userBoostClaimed), toString(userBoostAvailable), toString(poolWeight0), toString(poolWeight1), toString(h), toString(udh), toString(uLastH), toString(udh0), toString(udh1), toString(userCurrGwx), toString(totalCachedGwxCorrected)], ":") | |
479 | + | $Tuple3(userBoostAvaliableToClaimTotalNew, dataState, debug) | |
480 | + | } | |
673 | 481 | } | |
674 | 482 | } | |
675 | 483 | ||
721 | 529 | let k = ai(gWxParamsResultList[0]) | |
722 | 530 | let b = ai(gWxParamsResultList[1]) | |
723 | 531 | let period = toString(ai(gWxParamsResultList[2])) | |
532 | + | let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent()) | |
533 | + | let emissionStart = iof(emissionContract, keyEmissionStartBlock()) | |
534 | + | let emissionEnd = iof(emissionContract, keyEmissionEndBlock()) | |
535 | + | let h = if ((height > emissionEnd)) | |
536 | + | then emissionEnd | |
537 | + | else height | |
538 | + | let dh = max([(h - emissionStart), 0]) | |
539 | + | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr) | |
540 | + | let boostEmissionIntegral = (((wxEmissionPerBlock * dh) * 2) / 3) | |
541 | + | let userMaxBoostIntegralKEY = keyUserMaxBoostINTEGRAL(userNumStr) | |
542 | + | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() | |
543 | + | let userMaxBoostInt = ((gWxAmountStart * duration) / 2) | |
544 | + | let totalMaxBoostInt = ioz(this, totalMaxBoostIntegralKEY) | |
724 | 545 | let totalCachedGwxRaw = getTotalCachedGwx(false) | |
725 | - | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr) | |
726 | - | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
727 | 546 | let arr = if (userIsExisting) | |
728 | 547 | then nil | |
729 | 548 | else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)] | |
748 | 567 | ||
749 | 568 | @Callable(i) | |
750 | 569 | func lockRef (duration,referrerAddress,signature) = { | |
751 | - | let $ | |
752 | - | let lockActionsResult = $ | |
753 | - | let gWxAmountStart = $ | |
570 | + | let $t02443024495 = lockActions(i, duration) | |
571 | + | let lockActionsResult = $t02443024495._1 | |
572 | + | let gWxAmountStart = $t02443024495._2 | |
754 | 573 | let referralAddress = toString(i.caller) | |
755 | 574 | let refInv = if (if ((referrerAddress == "")) | |
756 | 575 | then true | |
771 | 590 | ||
772 | 591 | @Callable(i) | |
773 | 592 | func lock (duration) = { | |
774 | - | let $ | |
775 | - | let lockActionsResult = $ | |
776 | - | let gWxAmountStart = $ | |
593 | + | let $t02495325018 = lockActions(i, duration) | |
594 | + | let lockActionsResult = $t02495325018._1 | |
595 | + | let gWxAmountStart = $t02495325018._2 | |
777 | 596 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
778 | 597 | if ((updateRefActivity == updateRefActivity)) | |
779 | 598 | then $Tuple2(lockActionsResult, unit) | |
817 | 636 | let k = ai(gWxParamsResultList[0]) | |
818 | 637 | let b = ai(gWxParamsResultList[1]) | |
819 | 638 | let period = toString(ai(gWxParamsResultList[2])) | |
820 | - | let currUserGwx = calcCurrentGwxAmount(userAddressStr) | |
821 | - | let gwxDiff = (gWxAmountStart - currUserGwx) | |
822 | - | if ((0 > gwxDiff)) | |
823 | - | then throw(("gwxDiff is less then 0: " + toString(gwxDiff))) | |
639 | + | let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent()) | |
640 | + | let emissionStart = iof(emissionContract, keyEmissionStartBlock()) | |
641 | + | let emissionEnd = iof(emissionContract, keyEmissionEndBlock()) | |
642 | + | let h = if ((height > emissionEnd)) | |
643 | + | then emissionEnd | |
644 | + | else height | |
645 | + | let dh = max([(h - emissionStart), 0]) | |
646 | + | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr) | |
647 | + | let userBoostEmissionLastIntegral = ioz(this, userBoostEmissionLastIntegralKEY) | |
648 | + | let boostEmissionIntegral = (((wxEmissionPerBlock * dh) * 2) / 3) | |
649 | + | let userBoostEmissionIntegral = (boostEmissionIntegral - userBoostEmissionLastIntegral) | |
650 | + | if ((0 > userBoostEmissionIntegral)) | |
651 | + | then throw("wrong calculations") | |
824 | 652 | else { | |
825 | - | let totalCachedGwxRaw = getTotalCachedGwx(false) | |
826 | - | let totalCachedGwxCorrected = getTotalCachedGwx(true) | |
827 | - | (((LockParamsEntry(userAddressStr, userNumStr, userAmountNew, lockStartNew, lockDurationNew, k, b, period) ++ StatsEntry(pmtAmount, deltaDuration, 0, 0)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, lockDurationNew, k, b, i)) ++ [IntegerEntry(keyTotalCachedGwx(), (totalCachedGwxRaw + gwxDiff))]) | |
653 | + | let userMaxBoostIntegralKEY = keyUserMaxBoostINTEGRAL(userNumStr) | |
654 | + | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() | |
655 | + | let userMaxBoostInt = ioz(this, userMaxBoostIntegralKEY) | |
656 | + | let totalMaxBoostInt = ioz(this, totalMaxBoostIntegralKEY) | |
657 | + | let currUserGwx = calcCurrentGwxAmount(userAddressStr) | |
658 | + | let gwxDiff = (gWxAmountStart - currUserGwx) | |
659 | + | if ((0 > gwxDiff)) | |
660 | + | then throw(("gwxDiff is less then 0: " + toString(gwxDiff))) | |
661 | + | else { | |
662 | + | let totalCachedGwxRaw = getTotalCachedGwx(false) | |
663 | + | let totalCachedGwxCorrected = getTotalCachedGwx(true) | |
664 | + | let userBoostAvalaibleToClaimTotalKEY = keyUserBoostAvalaibleToClaimTotal(userNumStr) | |
665 | + | let userBoostAvaliableToClaimTotal = ioz(this, userBoostAvalaibleToClaimTotalKEY) | |
666 | + | let userBoostAvaliableToClaimTotalNew = fraction(userBoostEmissionIntegral, currUserGwx, totalCachedGwxCorrected) | |
667 | + | let userMaxBoostIntNew = ((gWxAmountStart * lockDurationNew) / 2) | |
668 | + | let remainingUserMaxBoostInt = ((currUserGwx * remainingDuration) / 2) | |
669 | + | let userMaxBoostIntDiff = (userMaxBoostIntNew - remainingUserMaxBoostInt) | |
670 | + | (((LockParamsEntry(userAddressStr, userNumStr, userAmountNew, lockStartNew, lockDurationNew, k, b, period) ++ StatsEntry(pmtAmount, deltaDuration, 0, 0)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, lockDurationNew, k, b, i)) ++ [IntegerEntry(keyTotalCachedGwx(), (totalCachedGwxRaw + gwxDiff))]) | |
671 | + | } | |
828 | 672 | } | |
829 | 673 | } | |
830 | 674 | else throw("Strict value is not equal to itself.") | |
837 | 681 | func claimWxBoost (lpAssetIdStr,userAddressStr) = if ((stakingContract != i.caller)) | |
838 | 682 | then throw("permissions denied") | |
839 | 683 | else { | |
840 | - | let $ | |
841 | - | let userBoostAvailable = $ | |
842 | - | let dataState = $ | |
843 | - | let debug = $ | |
684 | + | let $t02999930101 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false) | |
685 | + | let userBoostAvailable = $t02999930101._1 | |
686 | + | let dataState = $t02999930101._2 | |
687 | + | let debug = $t02999930101._3 | |
844 | 688 | $Tuple2(dataState, [userBoostAvailable]) | |
845 | 689 | } | |
846 | 690 | ||
848 | 692 | ||
849 | 693 | @Callable(i) | |
850 | 694 | func claimWxBoostREADONLY (lpAssetIdStr,userAddressStr) = { | |
851 | - | let $ | |
852 | - | let userBoostAvailable = $ | |
853 | - | let dataState = $ | |
854 | - | let debug = $ | |
695 | + | let $t03023330334 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true) | |
696 | + | let userBoostAvailable = $t03023330334._1 | |
697 | + | let dataState = $t03023330334._2 | |
698 | + | let debug = $t03023330334._3 | |
855 | 699 | $Tuple2(nil, [userBoostAvailable, debug]) | |
856 | 700 | } | |
857 | 701 | ||
921 | 765 | ||
922 | 766 | ||
923 | 767 | @Callable(i) | |
924 | - | func onBoostEmissionUpdate () = { | |
925 | - | let checkCaller = if ((i.caller == emissionContract)) | |
926 | - | then true | |
927 | - | else mustManager(i) | |
928 | - | if ((checkCaller == checkCaller)) | |
929 | - | then refreshBoostEmissionIntegral() | |
930 | - | else throw("Strict value is not equal to itself.") | |
931 | - | } | |
932 | - | ||
933 | - | ||
934 | - | ||
935 | - | @Callable(i) | |
936 | - | func onStakedVoteUpdate (lpAssetIdStr,userAddressStr,edge) = { | |
937 | - | let checkCaller = if ((i.caller == stakingContract)) | |
938 | - | then true | |
939 | - | else mustManager(i) | |
940 | - | if ((checkCaller == checkCaller)) | |
941 | - | then { | |
942 | - | let actions = refreshVoteStakedIntegral(lpAssetIdStr, userAddressStr, edge) | |
943 | - | $Tuple2(actions, unit) | |
944 | - | } | |
945 | - | else throw("Strict value is not equal to itself.") | |
946 | - | } | |
947 | - | ||
948 | - | ||
949 | - | ||
950 | - | @Callable(i) | |
951 | - | func getVotingResultStakedREADONLY (lpAssetIdStr) = $Tuple2(nil, getVotingResultStaked(lpAssetIdStr)) | |
952 | - | ||
953 | - | ||
954 | - | ||
955 | - | @Callable(i) | |
956 | - | func getUserVoteFinalizedREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteFinalized(lpAssetIdStr, userAddressStr)) | |
957 | - | ||
958 | - | ||
959 | - | ||
960 | - | @Callable(i) | |
961 | 768 | func setManager (pendingManagerPublicKey) = { | |
962 | 769 | let checkCaller = mustManager(i) | |
963 | 770 | if ((checkCaller == checkCaller)) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let SCALE8 = 8 | |
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | 10 | let POOLWEIGHTMULT = MULT8 | |
11 | 11 | ||
12 | 12 | func wrapErr (msg) = makeString(["boosting.ride:", msg], " ") | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func throwErr (msg) = throw(wrapErr(msg)) | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func strf (address,key) = valueOrErrorMessage(getString(address, key), (("mandatory this." + key) + " is not defined")) | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func ioz (address,key) = valueOrElse(getInteger(address, key), 0) | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func iod (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func iof (address,key) = valueOrErrorMessage(getInteger(address, key), (("mandatory this." + key) + " is not defined")) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func abs (val) = if ((0 > val)) | |
31 | 31 | then -(val) | |
32 | 32 | else val | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func aal (val) = match val { | |
36 | 36 | case valAnyLyst: List[Any] => | |
37 | 37 | valAnyLyst | |
38 | 38 | case _ => | |
39 | 39 | throw("fail to cast into List[Any]") | |
40 | 40 | } | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func ai (val) = match val { | |
44 | 44 | case valInt: Int => | |
45 | 45 | valInt | |
46 | 46 | case _ => | |
47 | 47 | throw("fail to cast into Int") | |
48 | 48 | } | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | let referralsContractAddressOrFail = addressFromStringValue(strf(this, keyReferralsContractAddress())) | |
55 | 55 | ||
56 | 56 | let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP) | |
57 | 57 | ||
58 | 58 | let referralProgramNameDefault = "wxlock" | |
59 | 59 | ||
60 | 60 | let referralProgramName = valueOrElse(getString(this, keyReferralProgramName), referralProgramNameDefault) | |
61 | 61 | ||
62 | 62 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | let IdxFactoryCfgStakingDapp = 1 | |
66 | 66 | ||
67 | 67 | let IdxFactoryCfgBoostingDapp = 2 | |
68 | 68 | ||
69 | 69 | let IdxFactoryCfgIdoDapp = 3 | |
70 | 70 | ||
71 | 71 | let IdxFactoryCfgTeamDapp = 4 | |
72 | 72 | ||
73 | 73 | let IdxFactoryCfgEmissionDapp = 5 | |
74 | 74 | ||
75 | 75 | let IdxFactoryCfgRestDapp = 6 | |
76 | 76 | ||
77 | 77 | let IdxFactoryCfgSlippageDapp = 7 | |
78 | 78 | ||
79 | 79 | let IdxFactoryCfgDaoDapp = 8 | |
80 | 80 | ||
81 | 81 | let IdxFactoryCfgMarketingDapp = 9 | |
82 | 82 | ||
83 | 83 | let IdxFactoryCfgGwxRewardDapp = 10 | |
84 | 84 | ||
85 | 85 | let IdxFactoryCfgBirdsDapp = 11 | |
86 | 86 | ||
87 | 87 | func keyFactoryCfg () = "%s__factoryConfig" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func keyFactoryLp2AssetsMapping (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func keyFactoryLpList () = "%s__lpTokensList" | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP) | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func keyFactoryPoolWeightHistory (poolAddress,num) = ((("%s%s__poolWeight__" + poolAddress) + "__") + toString(num)) | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | func readFactoryAddressOrFail () = addressFromStringValue(strf(this, keyFactoryAddress())) | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP) | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | func readFactoryCfgOrFail (factory) = split(strf(factory, keyFactoryCfg()), SEP) | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp]) | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp]) | |
118 | 118 | ||
119 | 119 | ||
120 | 120 | func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp]) | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp]) | |
124 | 124 | ||
125 | 125 | ||
126 | 126 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
127 | 127 | ||
128 | 128 | ||
129 | 129 | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
130 | 130 | ||
131 | 131 | ||
132 | 132 | func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
133 | 133 | ||
134 | 134 | ||
135 | 135 | func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current" | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | func keyEmissionStartBlock () = "%s%s__emission__startBlock" | |
139 | - | ||
140 | - | ||
141 | - | func keyBoostingV2LastUpdateHeight () = "%s%s__boostingV2__startBlock" | |
142 | - | ||
143 | - | ||
144 | - | func keyBoostingV2Integral () = "%s%s__boostingV2__integral" | |
145 | 139 | ||
146 | 140 | ||
147 | 141 | func keyEmissionDurationInBlocks () = "%s%s__emission__duration" | |
148 | 142 | ||
149 | 143 | ||
150 | 144 | func keyEmissionEndBlock () = "%s%s__emission__endBlock" | |
151 | 145 | ||
152 | 146 | ||
153 | 147 | func keyNextPeriod () = "%s__nextPeriod" | |
154 | 148 | ||
155 | 149 | ||
156 | 150 | func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight" | |
157 | 151 | ||
158 | 152 | ||
159 | 153 | let IdxCfgAssetId = 1 | |
160 | 154 | ||
161 | 155 | let IdxCfgMinLockAmount = 2 | |
162 | 156 | ||
163 | 157 | let IdxCfgMinLockDuration = 3 | |
164 | 158 | ||
165 | 159 | let IdxCfgMaxLockDuration = 4 | |
166 | 160 | ||
167 | 161 | let IdxCfgMathContract = 5 | |
168 | 162 | ||
169 | 163 | func keyConfig () = "%s__config" | |
170 | 164 | ||
171 | 165 | ||
172 | 166 | func readConfigArrayOrFail () = split(strf(this, keyConfig()), SEP) | |
173 | 167 | ||
174 | 168 | ||
175 | 169 | let mathContract = addressFromStringValue(readConfigArrayOrFail()[IdxCfgMathContract]) | |
176 | 170 | ||
177 | 171 | func formatConfigS (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = makeString(["%s%d%d%d", assetId, minLockAmount, minLockDuration, maxLockDuration, mathContract], SEP) | |
178 | 172 | ||
179 | 173 | ||
180 | 174 | func formatConfig (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = formatConfigS(assetId, toString(minLockAmount), toString(minLockDuration), toString(maxLockDuration), mathContract) | |
181 | 175 | ||
182 | 176 | ||
183 | 177 | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
184 | 178 | case s: String => | |
185 | 179 | fromBase58String(s) | |
186 | 180 | case _: Unit => | |
187 | 181 | unit | |
188 | 182 | case _ => | |
189 | 183 | throw("Match error") | |
190 | 184 | } | |
191 | 185 | ||
192 | 186 | ||
193 | 187 | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
194 | 188 | case s: String => | |
195 | 189 | fromBase58String(s) | |
196 | 190 | case _: Unit => | |
197 | 191 | unit | |
198 | 192 | case _ => | |
199 | 193 | throw("Match error") | |
200 | 194 | } | |
201 | 195 | ||
202 | 196 | ||
203 | 197 | func mustManager (i) = { | |
204 | 198 | let pd = throw("Permission denied") | |
205 | 199 | match managerPublicKeyOrUnit() { | |
206 | 200 | case pk: ByteVector => | |
207 | 201 | if ((i.callerPublicKey == pk)) | |
208 | 202 | then true | |
209 | 203 | else pd | |
210 | 204 | case _: Unit => | |
211 | 205 | if ((i.caller == this)) | |
212 | 206 | then true | |
213 | 207 | else pd | |
214 | 208 | case _ => | |
215 | 209 | throw("Match error") | |
216 | 210 | } | |
217 | 211 | } | |
218 | 212 | ||
219 | 213 | ||
220 | 214 | let IdxLockUserNum = 1 | |
221 | 215 | ||
222 | 216 | let IdxLockAmount = 2 | |
223 | 217 | ||
224 | 218 | let IdxLockStart = 3 | |
225 | 219 | ||
226 | 220 | let IdxLockDuration = 4 | |
227 | 221 | ||
228 | 222 | let IdxLockParamK = 5 | |
229 | 223 | ||
230 | 224 | let IdxLockParamB = 6 | |
231 | 225 | ||
232 | 226 | func keyLockParamsRecord (userAddress) = makeString(["%s%s__lock", userAddress], SEP) | |
233 | 227 | ||
234 | 228 | ||
235 | 229 | func readLockParamsRecordOrFail (userAddress) = split(strf(this, keyLockParamsRecord(userAddress)), SEP) | |
236 | 230 | ||
237 | 231 | ||
238 | 232 | func formatLockParamsRecordS (userNum,amount,start,duration,paramK,paramB,lastUpdTimestamp,gwxAmount) = makeString(["%d%d%d%d%d%d%d%d", userNum, amount, start, duration, paramK, paramB, lastUpdTimestamp, gwxAmount], SEP) | |
239 | 233 | ||
240 | 234 | ||
241 | 235 | func formatLockParamsRecord (userNum,amount,start,duration,paramK,paramB,gwxAmount) = formatLockParamsRecordS(userNum, toString(amount), toString(start), toString(duration), toString(paramK), toString(paramB), toString(lastBlock.timestamp), toString(gwxAmount)) | |
242 | 236 | ||
243 | 237 | ||
244 | 238 | func keyNextUserNum () = "%s__nextUserNum" | |
245 | 239 | ||
246 | 240 | ||
247 | 241 | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", userAddress], SEP) | |
248 | 242 | ||
249 | 243 | ||
250 | 244 | func keyNum2UserMapping (num) = makeString(["%s%s%s__mapping__num2user", num], SEP) | |
251 | 245 | ||
252 | 246 | ||
253 | 247 | func keyLockParamUserAmount (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "amount"], SEP) | |
254 | 248 | ||
255 | 249 | ||
256 | 250 | func keyLockParamStartBlock (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "start"], SEP) | |
257 | 251 | ||
258 | 252 | ||
259 | 253 | func keyLockParamDuration (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "duration"], SEP) | |
260 | 254 | ||
261 | 255 | ||
262 | 256 | func keyLockParamK (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "k"], SEP) | |
263 | 257 | ||
264 | 258 | ||
265 | 259 | func keyLockParamB (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "b"], SEP) | |
266 | 260 | ||
267 | 261 | ||
268 | 262 | func keyLockParamByPeriodK (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "k", period], SEP) | |
269 | 263 | ||
270 | 264 | ||
271 | 265 | func keyLockParamByPeriodB (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "b", period], SEP) | |
272 | 266 | ||
273 | 267 | ||
274 | 268 | func keyLockParamTotalAmount () = "%s%s__stats__activeTotalLocked" | |
275 | 269 | ||
276 | 270 | ||
277 | 271 | func keyStatsLocksDurationSumInBlocks () = "%s%s__stats__locksDurationSumInBlocks" | |
278 | 272 | ||
279 | 273 | ||
280 | 274 | func keyStatsLocksCount () = "%s%s__stats__locksCount" | |
281 | 275 | ||
282 | 276 | ||
283 | 277 | func keyStatsUsersCount () = "%s%s__stats__activeUsersCount" | |
284 | 278 | ||
285 | 279 | ||
286 | - | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__ | |
280 | + | func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastInt", userNum], SEP) | |
287 | 281 | ||
288 | 282 | ||
289 | - | func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__ | |
283 | + | func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__userBoostEmissionLastInt", userNum, lpAssetId], SEP) | |
290 | 284 | ||
291 | 285 | ||
292 | 286 | func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", userNum], SEP) | |
293 | 287 | ||
294 | 288 | ||
295 | 289 | func keyTotalMaxBoostINTEGRAL () = "%s%s__maxBoostInt__total" | |
296 | 290 | ||
297 | 291 | ||
298 | 292 | func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", userNum], SEP) | |
299 | 293 | ||
300 | 294 | ||
301 | 295 | func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", userNum], SEP) | |
302 | 296 | ||
303 | 297 | ||
304 | 298 | func keyTotalCachedGwx () = "%s%s__gwxCached__total" | |
305 | 299 | ||
306 | 300 | ||
307 | 301 | func keyTotalCachedGwxCorrective () = "%s__gwxCachedTotalCorrective" | |
308 | 302 | ||
309 | 303 | ||
310 | 304 | let factoryContract = readFactoryAddressOrFail() | |
311 | 305 | ||
312 | 306 | let factoryCfg = readFactoryCfgOrFail(factoryContract) | |
313 | 307 | ||
314 | 308 | let emissionContract = getEmissionAddressOrFail(factoryCfg) | |
315 | 309 | ||
316 | 310 | let stakingContract = getStakingAddressOrFail(factoryCfg) | |
317 | 311 | ||
318 | 312 | let gwxRewardContract = getGwxRewardAddressOrFail(factoryCfg) | |
319 | 313 | ||
320 | 314 | let lpStakingPoolsContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(makeString(["%s", "lpStakingPoolsContract"], SEP)), wrapErr("lp_staking_pools contract address is undefined"))), wrapErr("invalid lp_staking_pools contract address")) | |
321 | 315 | ||
322 | - | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], SEP) | |
323 | - | ||
324 | - | let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract)) | |
325 | - | ||
326 | - | let boostCoeff = { | |
327 | - | let @ = invoke(emissionContract, "getBoostCoeffREADONLY", nil, nil) | |
328 | - | if ($isInstanceOf(@, "Int")) | |
329 | - | then @ | |
330 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
331 | - | } | |
332 | - | ||
333 | 316 | func getTotalCachedGwx (correct) = { | |
317 | + | let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], SEP) | |
318 | + | let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract)) | |
334 | 319 | let keyCurrentEpochUi = makeString(["%s", "currentEpochUi"], SEP) | |
335 | 320 | let currentEpochUi = getIntegerValue(votingEmissionContract, keyCurrentEpochUi) | |
336 | 321 | let keyTargetEpoch = makeString(["%s%s", "totalCachedGwxCorrection__activationEpoch"], SEP) | |
337 | 322 | let targetEpochOption = getInteger(this, keyTargetEpoch) | |
338 | 323 | let totalCachedGwxRaw = valueOrElse(getInteger(this, keyTotalCachedGwx()), 0) | |
339 | 324 | let isCorrectionActivated = if (isDefined(targetEpochOption)) | |
340 | 325 | then (currentEpochUi >= value(targetEpochOption)) | |
341 | 326 | else false | |
342 | 327 | let corrective = if (if (isCorrectionActivated) | |
343 | 328 | then correct | |
344 | 329 | else false) | |
345 | 330 | then valueOrElse(getInteger(this, keyTotalCachedGwxCorrective()), 0) | |
346 | 331 | else 0 | |
347 | 332 | max([0, (totalCachedGwxRaw + corrective)]) | |
348 | 333 | } | |
349 | 334 | ||
350 | 335 | ||
351 | 336 | func HistoryEntry (type,user,amount,lockStart,duration,k,b,i) = { | |
352 | 337 | let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP) | |
353 | 338 | let historyDATA = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount), toString(lockStart), toString(duration), toString(k), toString(b)], SEP) | |
354 | 339 | StringEntry(historyKEY, historyDATA) | |
355 | 340 | } | |
356 | 341 | ||
357 | 342 | ||
358 | 343 | func StatsEntry (totalLockedInc,durationInc,lockCountInc,usersCountInc) = { | |
359 | 344 | let locksDurationSumInBlocksKEY = keyStatsLocksDurationSumInBlocks() | |
360 | 345 | let locksCountKEY = keyStatsLocksCount() | |
361 | 346 | let usersCountKEY = keyStatsUsersCount() | |
362 | 347 | let totalAmountKEY = keyLockParamTotalAmount() | |
363 | 348 | let locksDurationSumInBlocks = ioz(this, locksDurationSumInBlocksKEY) | |
364 | 349 | let locksCount = ioz(this, locksCountKEY) | |
365 | 350 | let usersCount = ioz(this, usersCountKEY) | |
366 | 351 | let totalAmount = ioz(this, totalAmountKEY) | |
367 | 352 | [IntegerEntry(locksDurationSumInBlocksKEY, (locksDurationSumInBlocks + durationInc)), IntegerEntry(locksCountKEY, (locksCount + lockCountInc)), IntegerEntry(usersCountKEY, (usersCount + usersCountInc)), IntegerEntry(totalAmountKEY, (totalAmount + totalLockedInc))] | |
368 | 353 | } | |
369 | 354 | ||
370 | 355 | ||
371 | 356 | func calcGwxAmount (kRaw,bRaw,h) = { | |
372 | 357 | let SCALE = 1000 | |
373 | 358 | (((kRaw * h) + bRaw) / SCALE) | |
374 | 359 | } | |
375 | 360 | ||
376 | 361 | ||
377 | 362 | func LockParamsEntry (userAddress,userNum,amount,start,duration,k,b,period) = { | |
378 | 363 | let userAmountKEY = keyLockParamUserAmount(userNum) | |
379 | 364 | let startBlockKEY = keyLockParamStartBlock(userNum) | |
380 | 365 | let durationKEY = keyLockParamDuration(userNum) | |
381 | 366 | let kKEY = keyLockParamK(userNum) | |
382 | 367 | let bKEY = keyLockParamB(userNum) | |
383 | 368 | let kByPeriodKEY = keyLockParamByPeriodK(userNum, period) | |
384 | 369 | let bByPeriodKEY = keyLockParamByPeriodB(userNum, period) | |
385 | 370 | let gwxAmount = calcGwxAmount(k, b, height) | |
386 | 371 | [IntegerEntry(userAmountKEY, amount), IntegerEntry(startBlockKEY, start), IntegerEntry(durationKEY, duration), IntegerEntry(kKEY, k), IntegerEntry(bKEY, b), IntegerEntry(kByPeriodKEY, k), IntegerEntry(bByPeriodKEY, b), StringEntry(keyLockParamsRecord(userAddress), formatLockParamsRecord(userNum, amount, start, duration, k, b, gwxAmount))] | |
387 | 372 | } | |
388 | 373 | ||
389 | 374 | ||
390 | 375 | func extractOptionalPaymentAmountOrFail (i,expectedAssetId) = if ((size(i.payments) > 1)) | |
391 | 376 | then throw("only one payment is allowed") | |
392 | 377 | else if ((size(i.payments) == 0)) | |
393 | 378 | then 0 | |
394 | 379 | else { | |
395 | 380 | let pmt = i.payments[0] | |
396 | 381 | if ((value(pmt.assetId) != expectedAssetId)) | |
397 | 382 | then throw("invalid asset id in payment") | |
398 | 383 | else pmt.amount | |
399 | 384 | } | |
400 | 385 | ||
401 | 386 | ||
402 | 387 | func calcUserGwxAmountAtHeight (userAddress,targetHeight) = { | |
403 | 388 | let EMPTY = "empty" | |
404 | 389 | let user2NumMappingKEY = keyUser2NumMapping(userAddress) | |
405 | 390 | let userNum = valueOrElse(getString(user2NumMappingKEY), EMPTY) | |
406 | 391 | let k = valueOrElse(getInteger(keyLockParamK(userNum)), 0) | |
407 | 392 | let b = valueOrElse(getInteger(keyLockParamB(userNum)), 0) | |
408 | 393 | let gwxAmountCalc = calcGwxAmount(k, b, targetHeight) | |
409 | 394 | let gwxAmount = if ((0 > gwxAmountCalc)) | |
410 | 395 | then 0 | |
411 | 396 | else gwxAmountCalc | |
412 | 397 | gwxAmount | |
413 | 398 | } | |
414 | 399 | ||
415 | 400 | ||
416 | 401 | func calcCurrentGwxAmount (userAddress) = calcUserGwxAmountAtHeight(userAddress, height) | |
417 | 402 | ||
418 | 403 | ||
419 | - | func getVotingEmissionEpochInfo () = { | |
420 | - | let keyCurrentEpochUi = makeString(["%s", "currentEpochUi"], SEP) | |
421 | - | let $t01515015438 = { | |
422 | - | let currentEpochUi = value(getInteger(votingEmissionContract, keyCurrentEpochUi)) | |
423 | - | let lastFinalizedEpoch = (currentEpochUi - 1) | |
424 | - | if ((0 > lastFinalizedEpoch)) | |
425 | - | then throwErr("invalid epoch") | |
426 | - | else $Tuple2(currentEpochUi, lastFinalizedEpoch) | |
427 | - | } | |
428 | - | let currentEpochUi = $t01515015438._1 | |
429 | - | let lastFinalizedEpoch = $t01515015438._2 | |
430 | - | func keyStartHeightByEpoch (epoch) = makeString(["%s%d", "startHeight", toString(epoch)], SEP) | |
431 | - | ||
432 | - | let currentEpochStartHeight = value(getInteger(votingEmissionContract, keyStartHeightByEpoch(currentEpochUi))) | |
433 | - | $Tuple2(lastFinalizedEpoch, currentEpochStartHeight) | |
434 | - | } | |
435 | - | ||
436 | - | ||
437 | - | func getPoolAssetsByLpAssetId (lpAssetIdStr) = { | |
438 | - | let idxAmountAssetId = 4 | |
439 | - | let idxPriceAssetId = 5 | |
440 | - | let poolCfg = { | |
441 | - | let @ = invoke(factoryContract, "getPoolConfigByLpAssetId", [lpAssetIdStr], nil) | |
442 | - | if ($isInstanceOf(@, "List[Any]")) | |
443 | - | then @ | |
444 | - | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
445 | - | } | |
446 | - | let amountAssetId = { | |
447 | - | let @ = poolCfg[idxAmountAssetId] | |
448 | - | if ($isInstanceOf(@, "String")) | |
449 | - | then @ | |
450 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
451 | - | } | |
452 | - | let priceAssetId = { | |
453 | - | let @ = poolCfg[idxPriceAssetId] | |
454 | - | if ($isInstanceOf(@, "String")) | |
455 | - | then @ | |
456 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
457 | - | } | |
458 | - | $Tuple2(amountAssetId, priceAssetId) | |
459 | - | } | |
460 | - | ||
461 | - | ||
462 | - | func keyVote (amountAssetId,priceAssetId,address,epoch) = makeString(["%s%s%s%s%d", "vote", amountAssetId, priceAssetId, toString(address), toString(epoch)], SEP) | |
463 | - | ||
464 | - | ||
465 | - | func keyVotingResultStaked (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStaked", lpAssetIdStr, toString(epoch)], SEP) | |
466 | - | ||
467 | - | ||
468 | - | func keyVotingResultStakedIntegral (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegral", lpAssetIdStr, toString(epoch)], SEP) | |
469 | - | ||
470 | - | ||
471 | - | func keyVotingResultStakedLastUpdateHeight (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(epoch)], SEP) | |
472 | - | ||
473 | - | ||
474 | - | func keyVotingResultStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "votingResultStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
475 | - | ||
476 | - | ||
477 | - | func keyVoteStakedIntegral (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegral", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
478 | - | ||
479 | - | ||
480 | - | func keyVoteStakedLastUpdateHeight (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
481 | - | ||
482 | - | ||
483 | - | func keyVoteStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP) | |
484 | - | ||
485 | - | ||
486 | - | func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s", "staked", userAddressStr, lpAssetIdStr], SEP) | |
487 | - | ||
488 | - | ||
489 | - | func getUserVoteFinalized (lpAssetIdStr,userAddressStr) = { | |
490 | - | let userAddress = addressFromStringValue(userAddressStr) | |
491 | - | let $t01822818308 = getVotingEmissionEpochInfo() | |
492 | - | let lastFinalizedEpoch = $t01822818308._1 | |
493 | - | let currentEpochStartHeight = $t01822818308._2 | |
494 | - | let $t01831118386 = getPoolAssetsByLpAssetId(lpAssetIdStr) | |
495 | - | let amountAssetId = $t01831118386._1 | |
496 | - | let priceAssetId = $t01831118386._2 | |
497 | - | let userVoteKey = keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch) | |
498 | - | let userVote = valueOrElse(getInteger(votingEmissionContract, userVoteKey), 0) | |
499 | - | userVote | |
500 | - | } | |
501 | - | ||
502 | - | ||
503 | - | func getUserVoteStaked (lpAssetIdStr,userAddressStr) = { | |
504 | - | let stakedByUser = valueOrElse(getInteger(stakingContract, keyStakedByUser(userAddressStr, lpAssetIdStr)), 0) | |
505 | - | let userVote = getUserVoteFinalized(lpAssetIdStr, userAddressStr) | |
506 | - | if ((stakedByUser == 0)) | |
507 | - | then 0 | |
508 | - | else userVote | |
509 | - | } | |
510 | - | ||
511 | - | ||
512 | - | func getVotingResultStaked (lpAssetIdStr) = { | |
513 | - | let $t01893019010 = getVotingEmissionEpochInfo() | |
514 | - | let lastFinalizedEpoch = $t01893019010._1 | |
515 | - | let currentEpochStartHeight = $t01893019010._2 | |
516 | - | let votingResultStakedStart = valueOrElse(getInteger(votingEmissionContract, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
517 | - | let votingResultStaked = valueOrElse(getInteger(this, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), votingResultStakedStart) | |
518 | - | votingResultStaked | |
519 | - | } | |
520 | - | ||
521 | - | ||
522 | - | func refreshVotingResultStakedIntegral (lpAssetIdStr,stakedVoteDelta) = { | |
523 | - | let $t01953119611 = getVotingEmissionEpochInfo() | |
524 | - | let lastFinalizedEpoch = $t01953119611._1 | |
525 | - | let currentEpochStartHeight = $t01953119611._2 | |
526 | - | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
527 | - | let votingResultStakedNew = (votingResultStaked + stakedVoteDelta) | |
528 | - | let votingResultStakedIntegralKey = keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch) | |
529 | - | let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, votingResultStakedIntegralKey), 0) | |
530 | - | let votingResultLastUpdateHeightKey = keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch) | |
531 | - | let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, votingResultLastUpdateHeightKey), currentEpochStartHeight) | |
532 | - | let votingResultStakedIntegralDh = (height - votingResultStakedLastUpdateHeight) | |
533 | - | let votingResultStakedIntegral = ((votingResultStakedIntegralDh * votingResultStaked) + votingResultStakedIntegralPrev) | |
534 | - | $Tuple2([IntegerEntry(keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch), votingResultStakedNew), IntegerEntry(votingResultLastUpdateHeightKey, height), IntegerEntry(votingResultStakedIntegralKey, votingResultStakedIntegral)], votingResultStakedIntegral) | |
535 | - | } | |
536 | - | ||
537 | - | ||
538 | - | func refreshVoteStakedIntegral (lpAssetIdStr,userAddressStr,edge) = { | |
539 | - | let $t02081120891 = getVotingEmissionEpochInfo() | |
540 | - | let lastFinalizedEpoch = $t02081120891._1 | |
541 | - | let currentEpochStartHeight = $t02081120891._2 | |
542 | - | let userAddress = addressFromStringValue(userAddressStr) | |
543 | - | let idxAmountAssetId = 4 | |
544 | - | let idxPriceAssetId = 5 | |
545 | - | let poolCfg = { | |
546 | - | let @ = invoke(factoryContract, "getPoolConfigByLpAssetId", [lpAssetIdStr], nil) | |
547 | - | if ($isInstanceOf(@, "List[Any]")) | |
548 | - | then @ | |
549 | - | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
550 | - | } | |
551 | - | let amountAssetId = { | |
552 | - | let @ = poolCfg[idxAmountAssetId] | |
553 | - | if ($isInstanceOf(@, "String")) | |
554 | - | then @ | |
555 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
556 | - | } | |
557 | - | let priceAssetId = { | |
558 | - | let @ = poolCfg[idxPriceAssetId] | |
559 | - | if ($isInstanceOf(@, "String")) | |
560 | - | then @ | |
561 | - | else throw(($getType(@) + " couldn't be cast to String")) | |
562 | - | } | |
563 | - | let userVote = valueOrElse(getInteger(votingEmissionContract, keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch)), 0) | |
564 | - | let actions = if ((userVote == 0)) | |
565 | - | then nil | |
566 | - | else { | |
567 | - | let stakedVoteDelta = if (edge) | |
568 | - | then userVote | |
569 | - | else -(userVote) | |
570 | - | let $t02149621615 = refreshVotingResultStakedIntegral(lpAssetIdStr, stakedVoteDelta) | |
571 | - | let votingResultActions = $t02149621615._1 | |
572 | - | let votingResultStakedIntegral = $t02149621615._2 | |
573 | - | let userVoteStaked = if (edge) | |
574 | - | then 0 | |
575 | - | else userVote | |
576 | - | let userVoteStakedIntegralKey = keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
577 | - | let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, userVoteStakedIntegralKey), 0) | |
578 | - | let userVoteStakedLastUpdateHeightKey = keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
579 | - | let userVoteStakedLastUpdateHeight = valueOrElse(getInteger(this, userVoteStakedLastUpdateHeightKey), currentEpochStartHeight) | |
580 | - | let userVoteStakedIntegralDh = (height - userVoteStakedLastUpdateHeight) | |
581 | - | let userVoteStakedIntegral = ((userVoteStakedIntegralDh * userVoteStaked) + userVoteStakedIntegralPrev) | |
582 | - | let voteActions = [IntegerEntry(userVoteStakedLastUpdateHeightKey, height), IntegerEntry(userVoteStakedIntegralKey, userVoteStakedIntegral)] | |
583 | - | (votingResultActions ++ voteActions) | |
584 | - | } | |
585 | - | actions | |
586 | - | } | |
587 | - | ||
588 | - | ||
589 | - | func getStakedVotesIntegralsDiff (lpAssetIdStr,userAddressStr) = { | |
590 | - | let $t02260722687 = getVotingEmissionEpochInfo() | |
591 | - | let lastFinalizedEpoch = $t02260722687._1 | |
592 | - | let currentEpochStartHeight = $t02260722687._2 | |
593 | - | let userAddress = addressFromStringValue(userAddressStr) | |
594 | - | let userVoteStaked = getUserVoteStaked(lpAssetIdStr, userAddressStr) | |
595 | - | let votingResultStaked = getVotingResultStaked(lpAssetIdStr) | |
596 | - | let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch)), 0) | |
597 | - | let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch)), 0) | |
598 | - | let userVoteStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch)), currentEpochStartHeight) | |
599 | - | let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch)), currentEpochStartHeight) | |
600 | - | let userVoteStakedIntegralKey = keyVoteStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
601 | - | let userVoteStakedIntegralLast = valueOrElse(getInteger(this, userVoteStakedIntegralKey), 0) | |
602 | - | let votingResultStakedIntegralKey = keyVotingResultStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch) | |
603 | - | let votingResultStakedIntegralLast = valueOrElse(getInteger(this, votingResultStakedIntegralKey), 0) | |
604 | - | let userVoteStakedIntegralDh = (height - userVoteStakedLastUpdateHeight) | |
605 | - | let votingResultStakedIntegralDh = (height - votingResultStakedLastUpdateHeight) | |
606 | - | let userVoteStakedIntegral = ((userVoteStakedIntegralDh * userVoteStaked) + userVoteStakedIntegralPrev) | |
607 | - | let votingResultStakedIntegral = ((votingResultStakedIntegralDh * votingResultStaked) + votingResultStakedIntegralPrev) | |
608 | - | let userVoteStakedIntegralDiff = (userVoteStakedIntegral - userVoteStakedIntegralLast) | |
609 | - | let votingResultStakedIntegralDiff = (votingResultStakedIntegral - votingResultStakedIntegralLast) | |
610 | - | $Tuple3([IntegerEntry(userVoteStakedIntegralKey, userVoteStakedIntegral), IntegerEntry(votingResultStakedIntegralKey, votingResultStakedIntegral)], userVoteStakedIntegralDiff, votingResultStakedIntegralDiff) | |
611 | - | } | |
612 | - | ||
613 | - | ||
614 | - | func refreshBoostEmissionIntegral () = { | |
615 | - | let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent()) | |
616 | - | let boostingV2LastUpdateHeightOption = getInteger(emissionContract, keyBoostingV2LastUpdateHeight()) | |
617 | - | let boostingV2IngergalOption = getInteger(this, keyBoostingV2Integral()) | |
618 | - | let emissionEnd = iof(emissionContract, keyEmissionEndBlock()) | |
619 | - | let h = if ((height > emissionEnd)) | |
620 | - | then emissionEnd | |
621 | - | else height | |
622 | - | let dh = match boostingV2LastUpdateHeightOption { | |
623 | - | case lastUpdateHeight: Int => | |
624 | - | max([(h - lastUpdateHeight), 0]) | |
625 | - | case _: Unit => | |
626 | - | 0 | |
627 | - | case _ => | |
628 | - | throw("Match error") | |
629 | - | } | |
630 | - | let boostEmissionPerBlock = ((wxEmissionPerBlock * (boostCoeff - 1)) / boostCoeff) | |
631 | - | let boostEmissionIntegralPrev = valueOrElse(boostingV2IngergalOption, 0) | |
632 | - | let boostEmissionIntegral = ((boostEmissionPerBlock * dh) + boostEmissionIntegralPrev) | |
633 | - | $Tuple2([IntegerEntry(keyBoostingV2Integral(), boostEmissionIntegral), IntegerEntry(keyBoostingV2LastUpdateHeight(), height)], boostEmissionIntegral) | |
634 | - | } | |
635 | - | ||
636 | - | ||
637 | 404 | func internalClaimWxBoost (lpAssetIdStr,userAddressStr,readOnly) = { | |
638 | - | let userRecordOption = getString(this, keyLockParamsRecord(userAddressStr)) | |
639 | - | if ((userRecordOption == unit)) | |
405 | + | let EMPTY = "EMPTY" | |
406 | + | let userRecordOrEmpty = valueOrElse(getString(this, keyLockParamsRecord(userAddressStr)), EMPTY) | |
407 | + | if ((userRecordOrEmpty == EMPTY)) | |
640 | 408 | then $Tuple3(0, nil, "userRecord::is::empty") | |
641 | 409 | else { | |
642 | - | let userRecordArray = split( | |
410 | + | let userRecordArray = split(userRecordOrEmpty, SEP) | |
643 | 411 | let userNumStr = userRecordArray[IdxLockUserNum] | |
412 | + | let gwxRewardEmissionStartHeight = valueOrElse(getInteger(gwxRewardContract, keyGwxRewardEmissionStartHeight()), 0) | |
644 | 413 | let EMPTYSTR = "empty" | |
645 | - | let | |
414 | + | let $t01539715965 = if ((lpAssetIdStr != EMPTYSTR)) | |
646 | 415 | then { | |
647 | 416 | let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLp2AssetsMapping(lpAssetIdStr)), ("unsupported lp asset " + lpAssetIdStr)) | |
648 | - | getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
417 | + | let pw1 = getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr)) | |
418 | + | let pw0 = valueOrElse(getInteger(factoryContract, keyFactoryPoolWeightHistory(poolAddressStr, 0)), pw1) | |
419 | + | $Tuple2(pw0, pw1) | |
649 | 420 | } | |
650 | 421 | else if (readOnly) | |
651 | - | then 0 | |
422 | + | then $Tuple2(0, 0) | |
652 | 423 | else throw(("not readonly mode: unsupported lp asset " + lpAssetIdStr)) | |
424 | + | let poolWeight0 = $t01539715965._1 | |
425 | + | let poolWeight1 = $t01539715965._2 | |
426 | + | let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent()) | |
427 | + | let emissionStart = iof(emissionContract, keyEmissionStartBlock()) | |
428 | + | let emissionEnd = iof(emissionContract, keyEmissionEndBlock()) | |
429 | + | let h = if ((height > emissionEnd)) | |
430 | + | then emissionEnd | |
431 | + | else height | |
432 | + | let dh = max([(h - emissionStart), 0]) | |
653 | 433 | let userLpBoostEmissionLastIntegralKEY = keyUserLpBoostEmissionLastINTEGRAL(userNumStr, lpAssetIdStr) | |
654 | 434 | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr) | |
655 | 435 | let userBoostEmissionLastIntegral = valueOrElse(getInteger(this, userLpBoostEmissionLastIntegralKEY), ioz(this, userBoostEmissionLastIntegralKEY)) | |
656 | - | let boostEmissionIntegral = | |
436 | + | let boostEmissionIntegral = (((wxEmissionPerBlock * dh) * 2) / 3) | |
657 | 437 | let userBoostEmissionIntegral = (boostEmissionIntegral - userBoostEmissionLastIntegral) | |
658 | - | if ((0 > userBoostEmissionIntegral)) | |
659 | - | then throw("wrong calculations") | |
660 | - | else { | |
661 | - | let $t02721227351 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr) | |
662 | - | let stakedVotesIntegralsActions = $t02721227351._1 | |
663 | - | let userVoteIntegralDiff = $t02721227351._2 | |
664 | - | let totalVotesIntegralDiff = $t02721227351._3 | |
665 | - | let poolUserBoostEmissionIntegral = fraction(userBoostEmissionIntegral, poolWeight, POOLWEIGHTMULT) | |
666 | - | let userBoostAvaliableToClaimTotalNew = if ((totalVotesIntegralDiff == 0)) | |
667 | - | then 0 | |
668 | - | else fraction(poolUserBoostEmissionIntegral, userVoteIntegralDiff, totalVotesIntegralDiff) | |
669 | - | let dataState = ([IntegerEntry(userLpBoostEmissionLastIntegralKEY, boostEmissionIntegral)] ++ stakedVotesIntegralsActions) | |
670 | - | let debug = makeString([toString(userBoostEmissionLastIntegral), toString(userBoostEmissionIntegral), toString(poolWeight), toString(userVoteIntegralDiff), toString(totalVotesIntegralDiff)], ":") | |
671 | - | $Tuple3(userBoostAvaliableToClaimTotalNew, dataState, debug) | |
672 | - | } | |
438 | + | let udh = fraction(userBoostEmissionIntegral, 3, (2 * wxEmissionPerBlock)) | |
439 | + | let uLastH = (h - udh) | |
440 | + | let udh0 = max([(gwxRewardEmissionStartHeight - uLastH), 0]) | |
441 | + | let udh1 = ((h - uLastH) - udh0) | |
442 | + | if (if (if ((0 > uLastH)) | |
443 | + | then true | |
444 | + | else (0 > udh1)) | |
445 | + | then true | |
446 | + | else (abs(((udh0 + udh1) - udh)) >= 1)) | |
447 | + | then throw(((((((((((("invalid udh calc: udh=" + toString(udh)) + " uLastH=") + toString(uLastH)) + " udh0=") + toString(udh0)) + " udh1=") + toString(udh1)) + " lpAssetId=") + lpAssetIdStr) + " userAddress=") + userAddressStr)) | |
448 | + | else if ((0 > userBoostEmissionIntegral)) | |
449 | + | then throw("wrong calculations") | |
450 | + | else { | |
451 | + | let userMaxBoostIntegralKEY = keyUserMaxBoostINTEGRAL(userNumStr) | |
452 | + | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() | |
453 | + | let userMaxBoostInt = ioz(this, userMaxBoostIntegralKEY) | |
454 | + | let totalMaxBoostInt = ioz(this, totalMaxBoostIntegralKEY) | |
455 | + | let totalCachedGwxCorrected = getTotalCachedGwx(true) | |
456 | + | let userCurrGwx = calcCurrentGwxAmount(userAddressStr) | |
457 | + | let userBoostAvalaibleToClaimTotalKEY = keyUserBoostAvalaibleToClaimTotal(userNumStr) | |
458 | + | let userBoostAvaliableToClaimTotal = ioz(this, userBoostAvalaibleToClaimTotalKEY) | |
459 | + | let userBoostEmissionIntegral0 = if ((udh == 0)) | |
460 | + | then 0 | |
461 | + | else fraction(userBoostEmissionIntegral, udh0, udh) | |
462 | + | let userBoostEmissionIntegral1 = if ((udh == 0)) | |
463 | + | then 0 | |
464 | + | else fraction(userBoostEmissionIntegral, udh1, udh) | |
465 | + | let poolUserBoostEmissionIntegral0 = fraction(userBoostEmissionIntegral0, poolWeight0, POOLWEIGHTMULT) | |
466 | + | let poolUserBoostEmissionIntegral1 = fraction(userBoostEmissionIntegral1, poolWeight1, POOLWEIGHTMULT) | |
467 | + | let userBoostAvaliableToClaimTotalNew0 = if ((totalCachedGwxCorrected == 0)) | |
468 | + | then 0 | |
469 | + | else fraction(poolUserBoostEmissionIntegral0, userCurrGwx, totalCachedGwxCorrected) | |
470 | + | let userBoostAvaliableToClaimTotalNew1 = if ((totalCachedGwxCorrected == 0)) | |
471 | + | then 0 | |
472 | + | else fraction(poolUserBoostEmissionIntegral1, userCurrGwx, totalCachedGwxCorrected) | |
473 | + | let userBoostAvaliableToClaimTotalNew = (userBoostAvaliableToClaimTotalNew0 + userBoostAvaliableToClaimTotalNew1) | |
474 | + | let userBoostClaimedKEY = keyUserBoostClaimed(userNumStr) | |
475 | + | let userBoostClaimed = ioz(this, userBoostClaimedKEY) | |
476 | + | let userBoostAvailable = (userBoostAvaliableToClaimTotalNew - userBoostClaimed) | |
477 | + | let dataState = [IntegerEntry(userLpBoostEmissionLastIntegralKEY, boostEmissionIntegral)] | |
478 | + | let debug = makeString([toString(userBoostEmissionLastIntegral), toString(userBoostEmissionIntegral), toString(userBoostClaimed), toString(userBoostAvailable), toString(poolWeight0), toString(poolWeight1), toString(h), toString(udh), toString(uLastH), toString(udh0), toString(udh1), toString(userCurrGwx), toString(totalCachedGwxCorrected)], ":") | |
479 | + | $Tuple3(userBoostAvaliableToClaimTotalNew, dataState, debug) | |
480 | + | } | |
673 | 481 | } | |
674 | 482 | } | |
675 | 483 | ||
676 | 484 | ||
677 | 485 | func lockActions (i,duration) = { | |
678 | 486 | let cfgArray = readConfigArrayOrFail() | |
679 | 487 | let assetIdStr = cfgArray[IdxCfgAssetId] | |
680 | 488 | let assetId = fromBase58String(assetIdStr) | |
681 | 489 | let minLockAmount = parseIntValue(cfgArray[IdxCfgMinLockAmount]) | |
682 | 490 | let minLockDuration = parseIntValue(cfgArray[IdxCfgMinLockDuration]) | |
683 | 491 | let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration]) | |
684 | 492 | if ((size(i.payments) != 1)) | |
685 | 493 | then throw("invalid payment - exact one payment must be attached") | |
686 | 494 | else { | |
687 | 495 | let pmt = i.payments[0] | |
688 | 496 | let pmtAmount = pmt.amount | |
689 | 497 | if ((assetId != value(pmt.assetId))) | |
690 | 498 | then throw((("invalid asset is in payment - " + assetIdStr) + " is expected")) | |
691 | 499 | else { | |
692 | 500 | let nextUserNumKEY = keyNextUserNum() | |
693 | 501 | let userAddressStr = toString(i.caller) | |
694 | 502 | let userIsExisting = isDefined(getString(keyUser2NumMapping(userAddressStr))) | |
695 | 503 | let userNumStr = if (userIsExisting) | |
696 | 504 | then value(getString(keyUser2NumMapping(userAddressStr))) | |
697 | 505 | else toString(iof(this, nextUserNumKEY)) | |
698 | 506 | let userNum = parseIntValue(userNumStr) | |
699 | 507 | let lockStart = height | |
700 | 508 | let startBlockKEY = keyLockParamStartBlock(userNumStr) | |
701 | 509 | let durationKEY = keyLockParamDuration(userNumStr) | |
702 | 510 | let userAmountKEY = keyLockParamUserAmount(userNumStr) | |
703 | 511 | if (if ((minLockAmount > pmtAmount)) | |
704 | 512 | then (i.caller != lpStakingPoolsContract) | |
705 | 513 | else false) | |
706 | 514 | then throw(("amount is less then minLockAmount=" + toString(minLockAmount))) | |
707 | 515 | else if ((minLockDuration > duration)) | |
708 | 516 | then throw(("passed duration is less then minLockDuration=" + toString(minLockDuration))) | |
709 | 517 | else if ((duration > maxLockDuration)) | |
710 | 518 | then throw(("passed duration is greater then maxLockDuration=" + toString(maxLockDuration))) | |
711 | 519 | else if (if (userIsExisting) | |
712 | 520 | then ((iof(this, startBlockKEY) + iof(this, durationKEY)) >= lockStart) | |
713 | 521 | else false) | |
714 | 522 | then throw("there is an active lock - consider to use increaseLock") | |
715 | 523 | else if ((ioz(this, userAmountKEY) > 0)) | |
716 | 524 | then throw(("there are locked WXs - consider to use increaseLock " + userAmountKEY)) | |
717 | 525 | else { | |
718 | 526 | let coeffX8 = fraction(duration, MULT8, maxLockDuration) | |
719 | 527 | let gWxAmountStart = fraction(pmtAmount, coeffX8, MULT8) | |
720 | 528 | let gWxParamsResultList = aal(invoke(mathContract, "calcGwxParamsREADONLY", [gWxAmountStart, lockStart, duration], nil)) | |
721 | 529 | let k = ai(gWxParamsResultList[0]) | |
722 | 530 | let b = ai(gWxParamsResultList[1]) | |
723 | 531 | let period = toString(ai(gWxParamsResultList[2])) | |
532 | + | let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent()) | |
533 | + | let emissionStart = iof(emissionContract, keyEmissionStartBlock()) | |
534 | + | let emissionEnd = iof(emissionContract, keyEmissionEndBlock()) | |
535 | + | let h = if ((height > emissionEnd)) | |
536 | + | then emissionEnd | |
537 | + | else height | |
538 | + | let dh = max([(h - emissionStart), 0]) | |
539 | + | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr) | |
540 | + | let boostEmissionIntegral = (((wxEmissionPerBlock * dh) * 2) / 3) | |
541 | + | let userMaxBoostIntegralKEY = keyUserMaxBoostINTEGRAL(userNumStr) | |
542 | + | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() | |
543 | + | let userMaxBoostInt = ((gWxAmountStart * duration) / 2) | |
544 | + | let totalMaxBoostInt = ioz(this, totalMaxBoostIntegralKEY) | |
724 | 545 | let totalCachedGwxRaw = getTotalCachedGwx(false) | |
725 | - | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr) | |
726 | - | let boostEmissionIntegral = refreshBoostEmissionIntegral()._2 | |
727 | 546 | let arr = if (userIsExisting) | |
728 | 547 | then nil | |
729 | 548 | else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)] | |
730 | 549 | $Tuple2(((((arr ++ LockParamsEntry(userAddressStr, userNumStr, pmtAmount, lockStart, duration, k, b, period)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting) | |
731 | 550 | then 0 | |
732 | 551 | else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, k, b, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyTotalCachedGwx(), (totalCachedGwxRaw + gWxAmountStart))]), gWxAmountStart) | |
733 | 552 | } | |
734 | 553 | } | |
735 | 554 | } | |
736 | 555 | } | |
737 | 556 | ||
738 | 557 | ||
739 | 558 | @Callable(i) | |
740 | 559 | func constructor (factoryAddressStr,lockAssetIdStr,minLockAmount,minDuration,maxDuration,mathContract) = { | |
741 | 560 | let checkCaller = mustManager(i) | |
742 | 561 | if ((checkCaller == checkCaller)) | |
743 | 562 | then ([IntegerEntry(keyNextUserNum(), 0), StringEntry(keyConfig(), formatConfig(lockAssetIdStr, minLockAmount, minDuration, maxDuration, mathContract)), StringEntry(keyFactoryAddress(), factoryAddressStr)] ++ StatsEntry(0, 0, 0, 0)) | |
744 | 563 | else throw("Strict value is not equal to itself.") | |
745 | 564 | } | |
746 | 565 | ||
747 | 566 | ||
748 | 567 | ||
749 | 568 | @Callable(i) | |
750 | 569 | func lockRef (duration,referrerAddress,signature) = { | |
751 | - | let $ | |
752 | - | let lockActionsResult = $ | |
753 | - | let gWxAmountStart = $ | |
570 | + | let $t02443024495 = lockActions(i, duration) | |
571 | + | let lockActionsResult = $t02443024495._1 | |
572 | + | let gWxAmountStart = $t02443024495._2 | |
754 | 573 | let referralAddress = toString(i.caller) | |
755 | 574 | let refInv = if (if ((referrerAddress == "")) | |
756 | 575 | then true | |
757 | 576 | else (signature == base58'')) | |
758 | 577 | then unit | |
759 | 578 | else invoke(referralsContractAddressOrFail, "createPair", [referralProgramName, referrerAddress, referralAddress, signature], nil) | |
760 | 579 | if ((refInv == refInv)) | |
761 | 580 | then { | |
762 | 581 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
763 | 582 | if ((updateRefActivity == updateRefActivity)) | |
764 | 583 | then $Tuple2(lockActionsResult, unit) | |
765 | 584 | else throw("Strict value is not equal to itself.") | |
766 | 585 | } | |
767 | 586 | else throw("Strict value is not equal to itself.") | |
768 | 587 | } | |
769 | 588 | ||
770 | 589 | ||
771 | 590 | ||
772 | 591 | @Callable(i) | |
773 | 592 | func lock (duration) = { | |
774 | - | let $ | |
775 | - | let lockActionsResult = $ | |
776 | - | let gWxAmountStart = $ | |
593 | + | let $t02495325018 = lockActions(i, duration) | |
594 | + | let lockActionsResult = $t02495325018._1 | |
595 | + | let gWxAmountStart = $t02495325018._2 | |
777 | 596 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
778 | 597 | if ((updateRefActivity == updateRefActivity)) | |
779 | 598 | then $Tuple2(lockActionsResult, unit) | |
780 | 599 | else throw("Strict value is not equal to itself.") | |
781 | 600 | } | |
782 | 601 | ||
783 | 602 | ||
784 | 603 | ||
785 | 604 | @Callable(i) | |
786 | 605 | func increaseLock (deltaDuration) = { | |
787 | 606 | let cfgArray = readConfigArrayOrFail() | |
788 | 607 | let assetIdStr = cfgArray[IdxCfgAssetId] | |
789 | 608 | let assetId = fromBase58String(assetIdStr) | |
790 | 609 | let minLockDuration = parseIntValue(cfgArray[IdxCfgMinLockDuration]) | |
791 | 610 | let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration]) | |
792 | 611 | let pmtAmount = extractOptionalPaymentAmountOrFail(i, assetId) | |
793 | 612 | let userAddressStr = toString(i.caller) | |
794 | 613 | let userRecordArray = readLockParamsRecordOrFail(userAddressStr) | |
795 | 614 | let userNumStr = userRecordArray[IdxLockUserNum] | |
796 | 615 | let userAmount = parseIntValue(userRecordArray[IdxLockAmount]) | |
797 | 616 | let lockStart = parseIntValue(userRecordArray[IdxLockStart]) | |
798 | 617 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
799 | 618 | let lockEnd = (lockStart + lockDuration) | |
800 | 619 | let remainingDuration = max([(lockEnd - height), 0]) | |
801 | 620 | let userAmountNew = (userAmount + pmtAmount) | |
802 | 621 | let lockDurationNew = (remainingDuration + deltaDuration) | |
803 | 622 | if ((0 > deltaDuration)) | |
804 | 623 | then throw("duration is less then zero") | |
805 | 624 | else if ((minLockDuration > lockDurationNew)) | |
806 | 625 | then throw(("lockDurationNew is less then minLockDuration=" + toString(minLockDuration))) | |
807 | 626 | else if ((lockDurationNew > maxLockDuration)) | |
808 | 627 | then throw(("deltaDuration + existedLockDuration is greater then maxLockDuration=" + toString(maxLockDuration))) | |
809 | 628 | else { | |
810 | 629 | let coeffX8 = fraction(lockDurationNew, MULT8, maxLockDuration) | |
811 | 630 | let gWxAmountStart = fraction(userAmountNew, coeffX8, MULT8) | |
812 | 631 | let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil) | |
813 | 632 | if ((updateRefActivity == updateRefActivity)) | |
814 | 633 | then { | |
815 | 634 | let lockStartNew = height | |
816 | 635 | let gWxParamsResultList = aal(invoke(mathContract, "calcGwxParamsREADONLY", [gWxAmountStart, lockStartNew, lockDurationNew], nil)) | |
817 | 636 | let k = ai(gWxParamsResultList[0]) | |
818 | 637 | let b = ai(gWxParamsResultList[1]) | |
819 | 638 | let period = toString(ai(gWxParamsResultList[2])) | |
820 | - | let currUserGwx = calcCurrentGwxAmount(userAddressStr) | |
821 | - | let gwxDiff = (gWxAmountStart - currUserGwx) | |
822 | - | if ((0 > gwxDiff)) | |
823 | - | then throw(("gwxDiff is less then 0: " + toString(gwxDiff))) | |
639 | + | let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent()) | |
640 | + | let emissionStart = iof(emissionContract, keyEmissionStartBlock()) | |
641 | + | let emissionEnd = iof(emissionContract, keyEmissionEndBlock()) | |
642 | + | let h = if ((height > emissionEnd)) | |
643 | + | then emissionEnd | |
644 | + | else height | |
645 | + | let dh = max([(h - emissionStart), 0]) | |
646 | + | let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr) | |
647 | + | let userBoostEmissionLastIntegral = ioz(this, userBoostEmissionLastIntegralKEY) | |
648 | + | let boostEmissionIntegral = (((wxEmissionPerBlock * dh) * 2) / 3) | |
649 | + | let userBoostEmissionIntegral = (boostEmissionIntegral - userBoostEmissionLastIntegral) | |
650 | + | if ((0 > userBoostEmissionIntegral)) | |
651 | + | then throw("wrong calculations") | |
824 | 652 | else { | |
825 | - | let totalCachedGwxRaw = getTotalCachedGwx(false) | |
826 | - | let totalCachedGwxCorrected = getTotalCachedGwx(true) | |
827 | - | (((LockParamsEntry(userAddressStr, userNumStr, userAmountNew, lockStartNew, lockDurationNew, k, b, period) ++ StatsEntry(pmtAmount, deltaDuration, 0, 0)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, lockDurationNew, k, b, i)) ++ [IntegerEntry(keyTotalCachedGwx(), (totalCachedGwxRaw + gwxDiff))]) | |
653 | + | let userMaxBoostIntegralKEY = keyUserMaxBoostINTEGRAL(userNumStr) | |
654 | + | let totalMaxBoostIntegralKEY = keyTotalMaxBoostINTEGRAL() | |
655 | + | let userMaxBoostInt = ioz(this, userMaxBoostIntegralKEY) | |
656 | + | let totalMaxBoostInt = ioz(this, totalMaxBoostIntegralKEY) | |
657 | + | let currUserGwx = calcCurrentGwxAmount(userAddressStr) | |
658 | + | let gwxDiff = (gWxAmountStart - currUserGwx) | |
659 | + | if ((0 > gwxDiff)) | |
660 | + | then throw(("gwxDiff is less then 0: " + toString(gwxDiff))) | |
661 | + | else { | |
662 | + | let totalCachedGwxRaw = getTotalCachedGwx(false) | |
663 | + | let totalCachedGwxCorrected = getTotalCachedGwx(true) | |
664 | + | let userBoostAvalaibleToClaimTotalKEY = keyUserBoostAvalaibleToClaimTotal(userNumStr) | |
665 | + | let userBoostAvaliableToClaimTotal = ioz(this, userBoostAvalaibleToClaimTotalKEY) | |
666 | + | let userBoostAvaliableToClaimTotalNew = fraction(userBoostEmissionIntegral, currUserGwx, totalCachedGwxCorrected) | |
667 | + | let userMaxBoostIntNew = ((gWxAmountStart * lockDurationNew) / 2) | |
668 | + | let remainingUserMaxBoostInt = ((currUserGwx * remainingDuration) / 2) | |
669 | + | let userMaxBoostIntDiff = (userMaxBoostIntNew - remainingUserMaxBoostInt) | |
670 | + | (((LockParamsEntry(userAddressStr, userNumStr, userAmountNew, lockStartNew, lockDurationNew, k, b, period) ++ StatsEntry(pmtAmount, deltaDuration, 0, 0)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, lockDurationNew, k, b, i)) ++ [IntegerEntry(keyTotalCachedGwx(), (totalCachedGwxRaw + gwxDiff))]) | |
671 | + | } | |
828 | 672 | } | |
829 | 673 | } | |
830 | 674 | else throw("Strict value is not equal to itself.") | |
831 | 675 | } | |
832 | 676 | } | |
833 | 677 | ||
834 | 678 | ||
835 | 679 | ||
836 | 680 | @Callable(i) | |
837 | 681 | func claimWxBoost (lpAssetIdStr,userAddressStr) = if ((stakingContract != i.caller)) | |
838 | 682 | then throw("permissions denied") | |
839 | 683 | else { | |
840 | - | let $ | |
841 | - | let userBoostAvailable = $ | |
842 | - | let dataState = $ | |
843 | - | let debug = $ | |
684 | + | let $t02999930101 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false) | |
685 | + | let userBoostAvailable = $t02999930101._1 | |
686 | + | let dataState = $t02999930101._2 | |
687 | + | let debug = $t02999930101._3 | |
844 | 688 | $Tuple2(dataState, [userBoostAvailable]) | |
845 | 689 | } | |
846 | 690 | ||
847 | 691 | ||
848 | 692 | ||
849 | 693 | @Callable(i) | |
850 | 694 | func claimWxBoostREADONLY (lpAssetIdStr,userAddressStr) = { | |
851 | - | let $ | |
852 | - | let userBoostAvailable = $ | |
853 | - | let dataState = $ | |
854 | - | let debug = $ | |
695 | + | let $t03023330334 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true) | |
696 | + | let userBoostAvailable = $t03023330334._1 | |
697 | + | let dataState = $t03023330334._2 | |
698 | + | let debug = $t03023330334._3 | |
855 | 699 | $Tuple2(nil, [userBoostAvailable, debug]) | |
856 | 700 | } | |
857 | 701 | ||
858 | 702 | ||
859 | 703 | ||
860 | 704 | @Callable(i) | |
861 | 705 | func unlock (userAddress) = { | |
862 | 706 | let userRecordArray = readLockParamsRecordOrFail(userAddress) | |
863 | 707 | let userNumStr = userRecordArray[IdxLockUserNum] | |
864 | 708 | let userAmount = parseIntValue(userRecordArray[IdxLockAmount]) | |
865 | 709 | let lockStart = parseIntValue(userRecordArray[IdxLockStart]) | |
866 | 710 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
867 | 711 | let lockEnd = (lockStart + lockDuration) | |
868 | 712 | let cfgArray = readConfigArrayOrFail() | |
869 | 713 | let assetId = fromBase58String(cfgArray[IdxCfgAssetId]) | |
870 | 714 | if ((lockEnd >= height)) | |
871 | 715 | then throw((("wait " + toString(lockEnd)) + " to unlock")) | |
872 | 716 | else if ((0 >= userAmount)) | |
873 | 717 | then throw("nothing to unlock") | |
874 | 718 | else { | |
875 | 719 | let period = valueOrElse(getInteger(mathContract, keyNextPeriod()), 0) | |
876 | 720 | (((LockParamsEntry(userAddress, userNumStr, 0, lockStart, lockDuration, 0, 0, toString(period)) ++ StatsEntry(-(userAmount), 0, 0, -1)) :+ HistoryEntry("unlock", userAddress, userAmount, lockStart, lockDuration, 0, 0, i)) :+ ScriptTransfer(addressFromStringValue(userAddress), userAmount, assetId)) | |
877 | 721 | } | |
878 | 722 | } | |
879 | 723 | ||
880 | 724 | ||
881 | 725 | ||
882 | 726 | @Callable(i) | |
883 | 727 | func gwxUserInfoREADONLY (userAddress) = { | |
884 | 728 | let gwxAmount = calcCurrentGwxAmount(userAddress) | |
885 | 729 | $Tuple2(nil, [gwxAmount]) | |
886 | 730 | } | |
887 | 731 | ||
888 | 732 | ||
889 | 733 | ||
890 | 734 | @Callable(i) | |
891 | 735 | func userMaxDurationREADONLY (userAddressStr) = { | |
892 | 736 | let cfgArray = readConfigArrayOrFail() | |
893 | 737 | let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration]) | |
894 | 738 | let userRecordOption = getString(this, keyLockParamsRecord(userAddressStr)) | |
895 | 739 | if ((userRecordOption == unit)) | |
896 | 740 | then $Tuple2(nil, $Tuple2("lock", maxLockDuration)) | |
897 | 741 | else { | |
898 | 742 | let userRecordArray = split(value(userRecordOption), SEP) | |
899 | 743 | let lockStart = parseIntValue(userRecordArray[IdxLockStart]) | |
900 | 744 | let lockDuration = parseIntValue(userRecordArray[IdxLockDuration]) | |
901 | 745 | let lockEnd = (lockStart + lockDuration) | |
902 | 746 | let remainingDuration = max([(lockEnd - height), 0]) | |
903 | 747 | let maxDeltaDuration = (maxLockDuration - remainingDuration) | |
904 | 748 | $Tuple2(nil, $Tuple2("increaseLock", maxDeltaDuration)) | |
905 | 749 | } | |
906 | 750 | } | |
907 | 751 | ||
908 | 752 | ||
909 | 753 | ||
910 | 754 | @Callable(i) | |
911 | 755 | func getUserGwxAmountAtHeightREADONLY (userAddress,targetHeight) = { | |
912 | 756 | let gwxAmount = calcUserGwxAmountAtHeight(userAddress, targetHeight) | |
913 | 757 | $Tuple2(nil, gwxAmount) | |
914 | 758 | } | |
915 | 759 | ||
916 | 760 | ||
917 | 761 | ||
918 | 762 | @Callable(i) | |
919 | 763 | func getTotalCachedGwxREADONLY () = $Tuple2(nil, getTotalCachedGwx(true)) | |
920 | 764 | ||
921 | 765 | ||
922 | 766 | ||
923 | 767 | @Callable(i) | |
924 | - | func onBoostEmissionUpdate () = { | |
925 | - | let checkCaller = if ((i.caller == emissionContract)) | |
926 | - | then true | |
927 | - | else mustManager(i) | |
928 | - | if ((checkCaller == checkCaller)) | |
929 | - | then refreshBoostEmissionIntegral() | |
930 | - | else throw("Strict value is not equal to itself.") | |
931 | - | } | |
932 | - | ||
933 | - | ||
934 | - | ||
935 | - | @Callable(i) | |
936 | - | func onStakedVoteUpdate (lpAssetIdStr,userAddressStr,edge) = { | |
937 | - | let checkCaller = if ((i.caller == stakingContract)) | |
938 | - | then true | |
939 | - | else mustManager(i) | |
940 | - | if ((checkCaller == checkCaller)) | |
941 | - | then { | |
942 | - | let actions = refreshVoteStakedIntegral(lpAssetIdStr, userAddressStr, edge) | |
943 | - | $Tuple2(actions, unit) | |
944 | - | } | |
945 | - | else throw("Strict value is not equal to itself.") | |
946 | - | } | |
947 | - | ||
948 | - | ||
949 | - | ||
950 | - | @Callable(i) | |
951 | - | func getVotingResultStakedREADONLY (lpAssetIdStr) = $Tuple2(nil, getVotingResultStaked(lpAssetIdStr)) | |
952 | - | ||
953 | - | ||
954 | - | ||
955 | - | @Callable(i) | |
956 | - | func getUserVoteFinalizedREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteFinalized(lpAssetIdStr, userAddressStr)) | |
957 | - | ||
958 | - | ||
959 | - | ||
960 | - | @Callable(i) | |
961 | 768 | func setManager (pendingManagerPublicKey) = { | |
962 | 769 | let checkCaller = mustManager(i) | |
963 | 770 | if ((checkCaller == checkCaller)) | |
964 | 771 | then { | |
965 | 772 | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
966 | 773 | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
967 | 774 | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
968 | 775 | else throw("Strict value is not equal to itself.") | |
969 | 776 | } | |
970 | 777 | else throw("Strict value is not equal to itself.") | |
971 | 778 | } | |
972 | 779 | ||
973 | 780 | ||
974 | 781 | ||
975 | 782 | @Callable(i) | |
976 | 783 | func confirmManager () = { | |
977 | 784 | let pm = pendingManagerPublicKeyOrUnit() | |
978 | 785 | let hasPM = if (isDefined(pm)) | |
979 | 786 | then true | |
980 | 787 | else throw("No pending manager") | |
981 | 788 | if ((hasPM == hasPM)) | |
982 | 789 | then { | |
983 | 790 | let checkPM = if ((i.callerPublicKey == value(pm))) | |
984 | 791 | then true | |
985 | 792 | else throw("You are not pending manager") | |
986 | 793 | if ((checkPM == checkPM)) | |
987 | 794 | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
988 | 795 | else throw("Strict value is not equal to itself.") | |
989 | 796 | } | |
990 | 797 | else throw("Strict value is not equal to itself.") | |
991 | 798 | } | |
992 | 799 | ||
993 | 800 | ||
994 | 801 | @Verifier(tx) | |
995 | 802 | func verify () = { | |
996 | 803 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
997 | 804 | case pk: ByteVector => | |
998 | 805 | pk | |
999 | 806 | case _: Unit => | |
1000 | 807 | tx.senderPublicKey | |
1001 | 808 | case _ => | |
1002 | 809 | throw("Match error") | |
1003 | 810 | } | |
1004 | 811 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
1005 | 812 | } | |
1006 | 813 |
github/deemru/w8io/fabc49c 107.08 ms ◑