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