tx · BE7P4d1VrWjaXjVwVjZhZvHBSuLE16cAiF9H8fsC8HEq

3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy:  -0.02700000 Waves

2023.09.07 10:50 [2744682] smart account 3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy > SELF 0.00000000 Waves

{ "type": 13, "id": "BE7P4d1VrWjaXjVwVjZhZvHBSuLE16cAiF9H8fsC8HEq", "fee": 2700000, "feeAssetId": null, "timestamp": 1694073039645, "version": 2, "chainId": 84, "sender": "3Myn55vLkduxbX3ZXfiDCZhaQsLxYp1kmCy", "senderPublicKey": "9W33iCCNfmFxUbiC6XZcH5x7f6xfwC7Jb3BoExT5q2PV", "proofs": [ "457MijRzJqD58vvjBLTizFsHECxjmCFLtsu5RSP9ZcEYbkrDewMqDwpUDVsFXcgreCtBpiwu8qH3A1ivsN5AnjHZ" ], "script": "base64:BgKZLwgCEggKBggIAQEBCBIFCgMBCAISAwoBARIDCgEBEgQKAggIEgQKAggIEgMKAQgSAwoBCBIDCgEIEgQKAggBEgASABIFCgMICAQSAwoBCBIDCgEIEgQKAggIEgQKAggIIgNTRVAiBlNDQUxFOCIFTVVMVDgiDlBPT0xXRUlHSFRNVUxUIgd3cmFwRXJyIgNtc2ciCHRocm93RXJyIgRzdHJmIgdhZGRyZXNzIgNrZXkiA2lveiIDaW9kIgpkZWZhdWx0VmFsIgNpb2YiA2FicyIDdmFsIgNhYWwiByRtYXRjaDAiCnZhbEFueUx5c3QiAmFpIgZ2YWxJbnQiG2tleVJlZmVycmFsc0NvbnRyYWN0QWRkcmVzcyIecmVmZXJyYWxzQ29udHJhY3RBZGRyZXNzT3JGYWlsIhZrZXlSZWZlcnJhbFByb2dyYW1OYW1lIhpyZWZlcnJhbFByb2dyYW1OYW1lRGVmYXVsdCITcmVmZXJyYWxQcm9ncmFtTmFtZSIRa2V5RmFjdG9yeUFkZHJlc3MiGElkeEZhY3RvcnlDZmdTdGFraW5nRGFwcCIZSWR4RmFjdG9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YUkBHGdldFVzZXJWb3RlRmluYWxpemVkUkVBRE9OTFkCAmJKAmJSCQCUCgIFA25pbAkBAmRpAgUCYkoFAmJSAmFJASFnZXRVc2VyVm90ZVN0YWtlZEludGVncmFsUkVBRE9OTFkCAmJKAmJSCQCUCgIFA25pbAkBAmREAgUCYkoFAmJSAQJmcAECZnEABAJmcgQBcgkBAmFGAAMJAAECBQFyAgpCeXRlVmVjdG9yBAJhSwUBcgUCYUsDCQABAgUBcgIEVW5pdAgFAmZwD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJmcAlib2R5Qnl0ZXMJAJEDAggFAmZwBnByb29mcwAABQJmclpY1bA=", "height": 2744682, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BkHd8EfLoabZ6orf7VCraMbdRkLcFyLVSAgE35Me34UD Next: 2W6GEYb1Qp7G2TLnpexs7Vtif7LGDSDtNLn2bZSnFGyz Diff:
OldNewDifferences
99
1010 let POOLWEIGHTMULT = MULT8
1111
12-let contractFilename = "boosting.ride"
13-
14-let SCALE18 = 18
15-
16-let MULT18 = 1000000000000000000
17-
18-let MULT18BI = toBigInt(MULT18)
19-
20-let DECAY_CONSTANT = 8
21-
22-func wrapErr (msg) = makeString([contractFilename, ": ", msg], "")
12+func wrapErr (msg) = makeString(["boosting.ride:", msg], " ")
2313
2414
2515 func throwErr (msg) = throw(wrapErr(msg))
2616
2717
28-func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((("mandatory this." + key) + " is not defined")))
18+func strf (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((("mandatory this." + key) + " is not defined")))
2919
3020
31-func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0)
21+func ioz (address,key) = valueOrElse(getInteger(address, key), 0)
3222
3323
34-func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal)
24+func iod (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal)
3525
3626
37-func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), wrapErr((("mandatory this." + key) + " is not defined")))
27+func iof (address,key) = valueOrErrorMessage(getInteger(address, key), wrapErr((("mandatory this." + key) + " is not defined")))
3828
3929
4030 func abs (val) = if ((0 > val))
4232 else val
4333
4434
45-func ensurePositive (v,m) = if ((v >= 0))
46- then v
47- else throwErr((valueOrElse(m, "value") + " should be positive"))
35+func aal (val) = match val {
36+ case valAnyLyst: List[Any] =>
37+ valAnyLyst
38+ case _ =>
39+ throwErr("fail to cast into List[Any]")
40+}
41+
42+
43+func ai (val) = match val {
44+ case valInt: Int =>
45+ valInt
46+ case _ =>
47+ throwErr("fail to cast into Int")
48+}
4849
4950
5051 func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP)
5152
5253
53-let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(this, keyReferralsContractAddress()))
54+let referralsContractAddressOrFail = addressFromStringValue(strf(this, keyReferralsContractAddress()))
5455
5556 let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP)
5657
8687 func keyFactoryCfg () = "%s__factoryConfig"
8788
8889
90+func keyFactoryLpList () = "%s__lpTokensList"
91+
92+
8993 func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP)
9094
9195
9599 func keyFactoryPoolWeightHistory (poolAddress,num) = ((("%s%s__poolWeight__" + poolAddress) + "__") + toString(num))
96100
97101
98-func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress()))
102+func readFactoryAddressOrFail () = addressFromStringValue(strf(this, keyFactoryAddress()))
99103
100104
101-func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP)
105+func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP)
106+
107+
108+func readFactoryCfgOrFail (factory) = split(strf(factory, keyFactoryCfg()), SEP)
102109
103110
104111 func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp])
140147 func keyEmissionEndBlock () = "%s%s__emission__endBlock"
141148
142149
150+func keyNextPeriod () = "%s__nextPeriod"
151+
152+
153+func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight"
154+
155+
143156 let IdxCfgAssetId = 1
144157
145158 let IdxCfgMinLockAmount = 2
150163
151164 let IdxCfgMathContract = 5
152165
153-let IdxCfgBlocksInPeriod = 6
154-
155-let IdxCfgLockStepBlocks = 7
156-
157166 func keyConfig () = "%s__config"
158167
159168
160-func readConfigArrayOrFail () = split(getStringOrFail(this, keyConfig()), SEP)
169+func readConfigArrayOrFail () = split(strf(this, keyConfig()), SEP)
161170
162171
163-let cfgArray = readConfigArrayOrFail()
172+let mathContract = addressFromStringValue(readConfigArrayOrFail()[IdxCfgMathContract])
164173
165-let assetId = fromBase58String(cfgArray[IdxCfgAssetId])
174+func formatConfigS (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = makeString(["%s%d%d%d", assetId, minLockAmount, minLockDuration, maxLockDuration, mathContract], SEP)
166175
167-let minLockAmount = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMinLockAmount]), wrapErr("invalid min lock amount"))
168176
169-let minLockDuration = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMinLockDuration]), wrapErr("invalid min lock duration"))
170-
171-let maxLockDuration = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMaxLockDuration]), wrapErr("invalid max lock duration"))
172-
173-let mathContract = valueOrErrorMessage(addressFromString(cfgArray[IdxCfgMathContract]), wrapErr("invalid math contract address"))
174-
175-let blocksInPeriod = valueOrErrorMessage(parseInt(cfgArray[IdxCfgBlocksInPeriod]), wrapErr("invalid blocks in period"))
176-
177-let lockStepBlocks = valueOrErrorMessage(parseInt(cfgArray[IdxCfgLockStepBlocks]), wrapErr("invalid lock step blocks"))
178-
179-let keySuspension = "%s__suspension"
180-
181-let isSuspended = valueOrElse(getBoolean(this, keySuspension), false)
182-
183-func throwIfSuspended () = if (!(isSuspended))
184- then true
185- else throwErr("suspended")
177+func formatConfig (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = formatConfigS(assetId, toString(minLockAmount), toString(minLockDuration), toString(maxLockDuration), mathContract)
186178
187179
188180 func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) {
223215 }
224216
225217
226-let IdxLockAmount = 1
218+let IdxLockUserNum = 1
227219
228-let IdxLockStart = 2
220+let IdxLockAmount = 2
229221
230-let IdxLockDuration = 3
222+let IdxLockStart = 3
231223
232-let IdxLockLastUpdateTimestamp = 4
224+let IdxLockDuration = 4
233225
234-let IdxLockGwxAmount = 5
226+let IdxLockParamK = 5
235227
236-let IdxLockWxClaimed = 6
228+let IdxLockParamB = 6
237229
238-func keyLockParamsRecord (userAddress,txId) = makeString(["%s%s%s__lock", toString(userAddress), match txId {
239- case b: ByteVector =>
240- toBase58String(b)
241- case _: Unit =>
242- "legacy"
243- case _ =>
244- throw("Match error")
245-}], SEP)
230+func keyLockParamsRecord (userAddress) = makeString(["%s%s__lock", userAddress], SEP)
246231
247232
248-func readLockParamsRecordOrFail (userAddress,txId) = split(getStringOrFail(this, keyLockParamsRecord(userAddress, txId)), SEP)
233+func readLockParamsRecordOrFail (userAddress) = split(strf(this, keyLockParamsRecord(userAddress)), SEP)
249234
250235
251-func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP)
236+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)
252237
253238
254-func formatLockParamsRecord (amount,start,duration,gwxAmount,wxClaimed) = makeString(["%d%d%d%d%d%d", toString(amount), toString(start), toString(duration), toString(lastBlock.timestamp), toString(gwxAmount), toString(wxClaimed)], SEP)
239+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))
255240
256241
257242 func keyNextUserNum () = "%s__nextUserNum"
261246
262247
263248 func keyNum2UserMapping (num) = makeString(["%s%s%s__mapping__num2user", num], SEP)
249+
250+
251+func keyLockParamUserAmount (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "amount"], SEP)
252+
253+
254+func keyLockParamStartBlock (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "start"], SEP)
255+
256+
257+func keyLockParamDuration (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "duration"], SEP)
258+
259+
260+func keyLockParamK (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "k"], SEP)
261+
262+
263+func keyLockParamB (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "b"], SEP)
264+
265+
266+func keyLockParamByPeriodK (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "k", period], SEP)
267+
268+
269+func keyLockParamByPeriodB (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "b", period], SEP)
264270
265271
266272 func keyLockParamTotalAmount () = "%s%s__stats__activeTotalLocked"
275281 func keyStatsUsersCount () = "%s%s__stats__activeUsersCount"
276282
277283
278-func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastIntV2", toString(userNum)], SEP)
284+func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastIntV2", userNum], SEP)
279285
280286
281-func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__userBoostEmissionLastIntV2", toString(userNum), lpAssetId], SEP)
287+func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__userBoostEmissionLastIntV2", userNum, lpAssetId], SEP)
282288
283289
284-func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", toString(userNum)], SEP)
290+func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", userNum], SEP)
285291
286292
287293 func keyTotalMaxBoostINTEGRAL () = "%s%s__maxBoostInt__total"
288294
289295
290-func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", toString(userNum)], SEP)
296+func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", userNum], SEP)
291297
292298
293-func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", toString(userNum)], SEP)
299+func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", userNum], SEP)
294300
295301
296-func keyGwxTotal () = "%s%s__gwx__total"
302+func keyTotalCachedGwx () = "%s%s__gwxCached__total"
303+
304+
305+func keyTotalCachedGwxCorrective () = "%s__gwxCachedTotalCorrective"
297306
298307
299308 func keyVote (amountAssetId,priceAssetId,address,epoch) = makeString(["%s%s%s%s%d", "vote", amountAssetId, priceAssetId, toString(address), toString(epoch)], SEP)
345354
346355 let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract))
347356
348-let keyVotingEmissionRateContract = makeString(["%s", "votingEmissionRateContract"], SEP)
349-
350357 let boostCoeff = {
351358 let @ = invoke(emissionContract, "getBoostCoeffREADONLY", nil, nil)
352359 if ($isInstanceOf(@, "Int"))
354361 else throw(($getType(@) + " couldn't be cast to Int"))
355362 }
356363
357-func userNumberByAddressOrFail (userAddress) = match getString(this, keyUser2NumMapping(toString(userAddress))) {
358- case s: String =>
359- valueOrErrorMessage(parseInt(s), wrapErr("invalid user number"))
360- case _: Unit =>
361- throwErr("invalid user")
362- case _ =>
363- throw("Match error")
364-}
365-
366-
367-func getGwxAmountTotal () = valueOrElse(getInteger(this, keyGwxTotal()), 0)
368-
369-
370-func getLockedGwxAmount (userAddress) = {
371- let functionName = "getLockedGwxAmount"
372- let votingEmissionRateContract = valueOrErrorMessage( match getString(votingEmissionContract, keyVotingEmissionRateContract) {
373- case _: Unit =>
374- unit
375- case s: String =>
376- addressFromString(s)
377- case _ =>
378- throw("Match error")
379- }, wrapErr("invalid voting emission rate address"))
380- let lockedVotingEmissionRate = {
381- let @ = invoke(votingEmissionContract, functionName, [toString(userAddress)], nil)
382- if ($isInstanceOf(@, "Int"))
383- then @
384- else throw(($getType(@) + " couldn't be cast to Int"))
385- }
386- let lockedVotingEmission = {
387- let @ = invoke(votingEmissionRateContract, functionName, [toString(userAddress)], nil)
388- if ($isInstanceOf(@, "Int"))
389- then @
390- else throw(($getType(@) + " couldn't be cast to Int"))
391- }
392- let locked = max([lockedVotingEmissionRate, lockedVotingEmission])
393- locked
364+func getTotalCachedGwx (correct) = {
365+ let currentEpochUi = getIntegerValue(votingEmissionContract, keyCurrentEpochUi())
366+ let keyTargetEpoch = makeString(["%s%s", "totalCachedGwxCorrection__activationEpoch"], SEP)
367+ let targetEpochOption = getInteger(this, keyTargetEpoch)
368+ let totalCachedGwxRaw = valueOrElse(getInteger(this, keyTotalCachedGwx()), 0)
369+ let isCorrectionActivated = if (isDefined(targetEpochOption))
370+ then (currentEpochUi >= value(targetEpochOption))
371+ else false
372+ let corrective = if (if (isCorrectionActivated)
373+ then correct
374+ else false)
375+ then valueOrElse(getInteger(this, keyTotalCachedGwxCorrective()), 0)
376+ else 0
377+ max([0, (totalCachedGwxRaw + corrective)])
394378 }
395379
396380
397-func HistoryEntry (type,user,amount,lockStart,duration,gwxAmount,i) = {
381+func HistoryEntry (type,user,amount,lockStart,duration,k,b,i) = {
398382 let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP)
399- let historyDATA = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount), toString(lockStart), toString(duration), toString(gwxAmount)], SEP)
383+ 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)
400384 StringEntry(historyKEY, historyDATA)
401385 }
402386
406390 let locksCountKEY = keyStatsLocksCount()
407391 let usersCountKEY = keyStatsUsersCount()
408392 let totalAmountKEY = keyLockParamTotalAmount()
409- let locksDurationSumInBlocks = getIntOrZero(this, locksDurationSumInBlocksKEY)
410- let locksCount = getIntOrZero(this, locksCountKEY)
411- let usersCount = getIntOrZero(this, usersCountKEY)
412- let totalAmount = getIntOrZero(this, totalAmountKEY)
393+ let locksDurationSumInBlocks = ioz(this, locksDurationSumInBlocksKEY)
394+ let locksCount = ioz(this, locksCountKEY)
395+ let usersCount = ioz(this, usersCountKEY)
396+ let totalAmount = ioz(this, totalAmountKEY)
413397 [IntegerEntry(locksDurationSumInBlocksKEY, (locksDurationSumInBlocks + durationInc)), IntegerEntry(locksCountKEY, (locksCount + lockCountInc)), IntegerEntry(usersCountKEY, (usersCount + usersCountInc)), IntegerEntry(totalAmountKEY, (totalAmount + totalLockedInc))]
414398 }
415399
416400
417-func LockParamsEntry (userAddress,txId,amount,start,duration,gwxAmount,wxClaimed) = [StringEntry(keyLockParamsRecord(userAddress, txId), formatLockParamsRecord(amount, start, duration, gwxAmount, wxClaimed))]
401+func calcGwxAmount (kRaw,bRaw,h) = {
402+ let SCALE = 1000
403+ (((kRaw * h) + bRaw) / SCALE)
404+ }
405+
406+
407+func LockParamsEntry (userAddress,userNum,amount,start,duration,k,b,period) = {
408+ let userAmountKEY = keyLockParamUserAmount(userNum)
409+ let startBlockKEY = keyLockParamStartBlock(userNum)
410+ let durationKEY = keyLockParamDuration(userNum)
411+ let kKEY = keyLockParamK(userNum)
412+ let bKEY = keyLockParamB(userNum)
413+ let kByPeriodKEY = keyLockParamByPeriodK(userNum, period)
414+ let bByPeriodKEY = keyLockParamByPeriodB(userNum, period)
415+ let gwxAmount = calcGwxAmount(k, b, height)
416+[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))]
417+ }
418418
419419
420420 func extractOptionalPaymentAmountOrFail (i,expectedAssetId) = if ((size(i.payments) > 1))
429429 }
430430
431431
432-func getUserGwxAmountTotal (userAddress) = valueOrElse(getInteger(this, keyUserGwxAmountTotal(userAddress)), 0)
432+func calcUserGwxAmountAtHeight (userAddress,targetHeight) = {
433+ let EMPTY = "empty"
434+ let user2NumMappingKEY = keyUser2NumMapping(userAddress)
435+ let userNum = valueOrElse(getString(user2NumMappingKEY), EMPTY)
436+ let k = valueOrElse(getInteger(keyLockParamK(userNum)), 0)
437+ let b = valueOrElse(getInteger(keyLockParamB(userNum)), 0)
438+ let gwxAmountCalc = calcGwxAmount(k, b, targetHeight)
439+ let gwxAmount = if ((0 > gwxAmountCalc))
440+ then 0
441+ else gwxAmountCalc
442+ gwxAmount
443+ }
444+
445+
446+func calcCurrentGwxAmount (userAddress) = calcUserGwxAmountAtHeight(userAddress, height)
433447
434448
435449 func getVotingEmissionEpochInfo () = {
436- let $t01468614976 = {
450+ let $t01718617476 = {
437451 let currentEpochUi = value(getInteger(votingEmissionContract, keyCurrentEpochUi()))
438452 let lastFinalizedEpoch = (currentEpochUi - 1)
439453 if ((0 > lastFinalizedEpoch))
440454 then throwErr("invalid epoch")
441455 else $Tuple2(currentEpochUi, lastFinalizedEpoch)
442456 }
443- let currentEpochUi = $t01468614976._1
444- let lastFinalizedEpoch = $t01468614976._2
457+ let currentEpochUi = $t01718617476._1
458+ let lastFinalizedEpoch = $t01718617476._2
445459 let currentEpochStartHeight = value(getInteger(votingEmissionContract, keyStartHeightByEpoch(currentEpochUi)))
446460 $Tuple2(lastFinalizedEpoch, currentEpochStartHeight)
447461 }
474488
475489 func getUserVoteFinalized (lpAssetIdStr,userAddressStr) = {
476490 let userAddress = addressFromStringValue(userAddressStr)
477- let $t01566715747 = getVotingEmissionEpochInfo()
478- let lastFinalizedEpoch = $t01566715747._1
479- let currentEpochStartHeight = $t01566715747._2
480- let $t01575015825 = getPoolAssetsByLpAssetId(lpAssetIdStr)
481- let amountAssetId = $t01575015825._1
482- let priceAssetId = $t01575015825._2
491+ let $t01816718247 = getVotingEmissionEpochInfo()
492+ let lastFinalizedEpoch = $t01816718247._1
493+ let currentEpochStartHeight = $t01816718247._2
494+ let $t01825018325 = getPoolAssetsByLpAssetId(lpAssetIdStr)
495+ let amountAssetId = $t01825018325._1
496+ let priceAssetId = $t01825018325._2
483497 let userVoteKey = keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch)
484498 let userVote = valueOrElse(getInteger(votingEmissionContract, userVoteKey), 0)
485499 userVote
496510
497511
498512 func getVotingResultStaked (lpAssetIdStr) = {
499- let $t01636916449 = getVotingEmissionEpochInfo()
500- let lastFinalizedEpoch = $t01636916449._1
501- let currentEpochStartHeight = $t01636916449._2
513+ let $t01886918949 = getVotingEmissionEpochInfo()
514+ let lastFinalizedEpoch = $t01886918949._1
515+ let currentEpochStartHeight = $t01886918949._2
502516 let votingResultStakedStart = valueOrElse(getInteger(votingEmissionContract, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), 0)
503517 let votingResultStaked = valueOrElse(getInteger(this, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), votingResultStakedStart)
504518 votingResultStaked
506520
507521
508522 func getVotingResultStakedIntegral (lpAssetIdStr) = {
509- let $t01681116891 = getVotingEmissionEpochInfo()
510- let lastFinalizedEpoch = $t01681116891._1
511- let currentEpochStartHeight = $t01681116891._2
523+ let $t01931119391 = getVotingEmissionEpochInfo()
524+ let lastFinalizedEpoch = $t01931119391._1
525+ let currentEpochStartHeight = $t01931119391._2
512526 let votingResultStaked = getVotingResultStaked(lpAssetIdStr)
513527 let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch)), 0)
514528 let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch)), currentEpochStartHeight)
519533
520534
521535 func refreshVotingResultStakedIntegral (lpAssetIdStr,stakedVoteDelta) = {
522- let $t01772817808 = getVotingEmissionEpochInfo()
523- let lastFinalizedEpoch = $t01772817808._1
524- let currentEpochStartHeight = $t01772817808._2
536+ let $t02022820308 = getVotingEmissionEpochInfo()
537+ let lastFinalizedEpoch = $t02022820308._1
538+ let currentEpochStartHeight = $t02022820308._2
525539 let votingResultStaked = getVotingResultStaked(lpAssetIdStr)
526540 let votingResultStakedNew = (votingResultStaked + stakedVoteDelta)
527541 let votingResultStakedIntegral = getVotingResultStakedIntegral(lpAssetIdStr)
530544
531545
532546 func getUserVoteStakedIntegral (lpAssetIdStr,userAddressStr) = {
533- let $t01841918499 = getVotingEmissionEpochInfo()
534- let lastFinalizedEpoch = $t01841918499._1
535- let currentEpochStartHeight = $t01841918499._2
547+ let $t02091920999 = getVotingEmissionEpochInfo()
548+ let lastFinalizedEpoch = $t02091920999._1
549+ let currentEpochStartHeight = $t02091920999._2
536550 let userAddress = addressFromStringValue(userAddressStr)
537551 let userVoteStaked = getUserVoteStaked(lpAssetIdStr, userAddressStr)
538552 let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch)), 0)
544558
545559
546560 func refreshVoteStakedIntegral (lpAssetIdStr,userAddressStr,edge) = {
547- let $t01928719367 = getVotingEmissionEpochInfo()
548- let lastFinalizedEpoch = $t01928719367._1
549- let currentEpochStartHeight = $t01928719367._2
561+ let $t02178721867 = getVotingEmissionEpochInfo()
562+ let lastFinalizedEpoch = $t02178721867._1
563+ let currentEpochStartHeight = $t02178721867._2
550564 let userAddress = addressFromStringValue(userAddressStr)
551565 let userVoteFinalized = getUserVoteFinalized(lpAssetIdStr, userAddressStr)
552566 let actions = if ((userVoteFinalized == 0))
565579
566580
567581 func getStakedVotesIntegralsDiff (lpAssetIdStr,userAddressStr) = {
568- let $t02022120301 = getVotingEmissionEpochInfo()
569- let lastFinalizedEpoch = $t02022120301._1
570- let currentEpochStartHeight = $t02022120301._2
582+ let $t02272122801 = getVotingEmissionEpochInfo()
583+ let lastFinalizedEpoch = $t02272122801._1
584+ let currentEpochStartHeight = $t02272122801._2
571585 let userAddress = addressFromStringValue(userAddressStr)
572586 let userVoteStakedIntegralLastKey = keyVoteStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch)
573587 let userVoteStakedIntegralLast = valueOrElse(getInteger(this, userVoteStakedIntegralLastKey), 0)
582596
583597
584598 func refreshBoostEmissionIntegral () = {
585- let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent())
599+ let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent())
586600 let boostingV2LastUpdateHeightOption = getInteger(this, keyBoostingV2LastUpdateHeight())
587601 let boostingV2IngergalOption = getInteger(this, keyBoostingV2Integral())
588- let emissionEnd = getIntOrFail(emissionContract, keyEmissionEndBlock())
602+ let emissionEnd = iof(emissionContract, keyEmissionEndBlock())
589603 let h = if ((height > emissionEnd))
590604 then emissionEnd
591605 else height
605619
606620
607621 func internalClaimWxBoost (lpAssetIdStr,userAddressStr,readOnly) = {
608- let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
609- let userNum = userNumberByAddressOrFail(userAddress)
610- if ((userNum == userNum))
611- then {
622+ let userRecordOption = getString(this, keyLockParamsRecord(userAddressStr))
623+ if ((userRecordOption == unit))
624+ then $Tuple3(0, nil, "userRecord::is::empty")
625+ else {
626+ let userRecordArray = split(value(userRecordOption), SEP)
627+ let userNumStr = userRecordArray[IdxLockUserNum]
612628 let EMPTYSTR = "empty"
613629 let poolWeight = if ((lpAssetIdStr != EMPTYSTR))
614630 then {
618634 else if (readOnly)
619635 then 0
620636 else throwErr(("not readonly mode: unsupported lp asset " + lpAssetIdStr))
621- let userLpBoostEmissionLastIntegralKEY = keyUserLpBoostEmissionLastINTEGRAL(userNum, lpAssetIdStr)
622- let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum)
623- let userBoostEmissionLastIntegral = valueOrElse(getInteger(this, userLpBoostEmissionLastIntegralKEY), getIntOrZero(this, userBoostEmissionLastIntegralKEY))
637+ let userLpBoostEmissionLastIntegralKEY = keyUserLpBoostEmissionLastINTEGRAL(userNumStr, lpAssetIdStr)
638+ let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr)
639+ let userBoostEmissionLastIntegral = valueOrElse(getInteger(this, userLpBoostEmissionLastIntegralKEY), ioz(this, userBoostEmissionLastIntegralKEY))
624640 let boostEmissionIntegral = refreshBoostEmissionIntegral()._2
625641 let userBoostEmissionIntegral = (boostEmissionIntegral - userBoostEmissionLastIntegral)
626642 if ((0 > userBoostEmissionIntegral))
627643 then throwErr("wrong calculations")
628644 else {
629- let $t02384323982 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr)
630- let stakedVotesIntegralsActions = $t02384323982._1
631- let userVoteIntegralDiff = $t02384323982._2
632- let totalVotesIntegralDiff = $t02384323982._3
645+ let $t02642026559 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr)
646+ let stakedVotesIntegralsActions = $t02642026559._1
647+ let userVoteIntegralDiff = $t02642026559._2
648+ let totalVotesIntegralDiff = $t02642026559._3
633649 let poolUserBoostEmissionIntegral = fraction(userBoostEmissionIntegral, poolWeight, POOLWEIGHTMULT)
634650 let userBoostAvaliableToClaimTotalNew = if ((totalVotesIntegralDiff == 0))
635651 then 0
639655 $Tuple3(userBoostAvaliableToClaimTotalNew, dataState, debug)
640656 }
641657 }
642- else throw("Strict value is not equal to itself.")
643658 }
644659
645660
646661 func lockActions (i,duration) = {
647- let assetIdStr = toBase58String(assetId)
662+ let cfgArray = readConfigArrayOrFail()
663+ let assetIdStr = cfgArray[IdxCfgAssetId]
664+ let assetId = fromBase58String(assetIdStr)
665+ let minLockAmount = parseIntValue(cfgArray[IdxCfgMinLockAmount])
666+ let minLockDuration = parseIntValue(cfgArray[IdxCfgMinLockDuration])
667+ let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration])
648668 if ((size(i.payments) != 1))
649669 then throwErr("invalid payment - exact one payment must be attached")
650670 else {
654674 then throwErr((("invalid asset is in payment - " + assetIdStr) + " is expected"))
655675 else {
656676 let nextUserNumKEY = keyNextUserNum()
657- let userAddress = i.caller
658- let userAddressStr = toString(userAddress)
677+ let userAddressStr = toString(i.caller)
659678 let userIsExisting = isDefined(getString(keyUser2NumMapping(userAddressStr)))
660679 let userNumStr = if (userIsExisting)
661680 then value(getString(keyUser2NumMapping(userAddressStr)))
662- else toString(getIntOrFail(this, nextUserNumKEY))
681+ else toString(iof(this, nextUserNumKEY))
663682 let userNum = parseIntValue(userNumStr)
664683 let lockStart = height
684+ let startBlockKEY = keyLockParamStartBlock(userNumStr)
685+ let durationKEY = keyLockParamDuration(userNumStr)
686+ let userAmountKEY = keyLockParamUserAmount(userNumStr)
665687 if (if ((minLockAmount > pmtAmount))
666- then (userAddress != lpStakingPoolsContract)
688+ then (i.caller != lpStakingPoolsContract)
667689 else false)
668690 then throwErr(("amount is less then minLockAmount=" + toString(minLockAmount)))
669691 else if ((minLockDuration > duration))
670- then throwErr(("passed duration is less than minLockDuration=" + toString(minLockDuration)))
692+ then throwErr(("passed duration is less then minLockDuration=" + toString(minLockDuration)))
671693 else if ((duration > maxLockDuration))
672- then throwErr(("passed duration is greater than maxLockDuration=" + toString(maxLockDuration)))
673- else if (((duration % lockStepBlocks) != 0))
674- then throwErr(("duration must be multiple of lockStepBlocks=" + toString(lockStepBlocks)))
675- else {
676- let gWxAmountStart = fraction(pmtAmount, duration, maxLockDuration)
677- let gwxAmountTotal = getGwxAmountTotal()
678- let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum)
679- let boostEmissionIntegral = refreshBoostEmissionIntegral()._2
680- let userGwxAmountTotal = getUserGwxAmountTotal(userAddress)
681- let gwxRewardInv = invoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes, userNum], nil)
682- if ((gwxRewardInv == gwxRewardInv))
683- then {
684- let arr = if (userIsExisting)
685- then nil
686- else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)]
687- $Tuple2(((((arr ++ LockParamsEntry(userAddress, i.transactionId, pmtAmount, lockStart, duration, gWxAmountStart, 0)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting)
688- then 0
689- else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, gWxAmountStart, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyGwxTotal(), (gwxAmountTotal + gWxAmountStart)), IntegerEntry(keyUserGwxAmountTotal(userAddress), (userGwxAmountTotal + gWxAmountStart))]), gWxAmountStart)
690- }
691- else throw("Strict value is not equal to itself.")
692- }
694+ then throwErr(("passed duration is greater then maxLockDuration=" + toString(maxLockDuration)))
695+ else if (if (userIsExisting)
696+ then ((iof(this, startBlockKEY) + iof(this, durationKEY)) >= lockStart)
697+ else false)
698+ then throwErr("there is an active lock - consider to use increaseLock")
699+ else if ((ioz(this, userAmountKEY) > 0))
700+ then throwErr(("there are locked WXs - consider to use increaseLock " + userAmountKEY))
701+ else {
702+ let coeffX8 = fraction(duration, MULT8, maxLockDuration)
703+ let gWxAmountStart = fraction(pmtAmount, coeffX8, MULT8)
704+ let gWxParamsResultList = aal(invoke(mathContract, "calcGwxParamsREADONLY", [gWxAmountStart, lockStart, duration], nil))
705+ let k = ai(gWxParamsResultList[0])
706+ let b = ai(gWxParamsResultList[1])
707+ let period = toString(ai(gWxParamsResultList[2]))
708+ let totalCachedGwxRaw = getTotalCachedGwx(false)
709+ let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr)
710+ let boostEmissionIntegral = refreshBoostEmissionIntegral()._2
711+ let arr = if (userIsExisting)
712+ then nil
713+ else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)]
714+ $Tuple2(((((arr ++ LockParamsEntry(userAddressStr, userNumStr, pmtAmount, lockStart, duration, k, b, period)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting)
715+ then 0
716+ else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, k, b, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyTotalCachedGwx(), (totalCachedGwxRaw + gWxAmountStart))]), gWxAmountStart)
717+ }
693718 }
694719 }
695720 }
696721
697722
698-func getWxWithdrawable (userAddress,txIdOption) = {
699- let userRecordArray = readLockParamsRecordOrFail(userAddress, txIdOption)
700- let userAmount = parseIntValue(userRecordArray[IdxLockAmount])
701- let lockStart = parseIntValue(userRecordArray[IdxLockStart])
702- let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
703- let lockEnd = (lockStart + lockDuration)
704- let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed])
705- let t = ((height - lockStart) / blocksInPeriod)
706- let exponent = fraction(toBigInt(t), (toBigInt((DECAY_CONSTANT * blocksInPeriod)) * MULT18BI), toBigInt(lockDuration))
707- let wxWithdrawableTotal = if ((height > lockEnd))
708- then userAmount
709- else toInt(fraction(toBigInt(userAmount), (MULT18BI - pow(toBigInt(5), 1, exponent, SCALE18, SCALE18, DOWN)), MULT18BI))
710- let wxWithdrawable = (wxWithdrawableTotal - wxClaimed)
711- wxWithdrawable
712- }
713-
714-
715723 @Callable(i)
716-func lockRef (duration,referrerAddress,signature) = {
717- let suspensionCheck = throwIfSuspended()
718- if ((suspensionCheck == suspensionCheck))
719- then {
720- let $t02840028465 = lockActions(i, duration)
721- let lockActionsResult = $t02840028465._1
722- let gWxAmountStart = $t02840028465._2
723- let referralAddress = toString(i.caller)
724- let refInv = if (if ((referrerAddress == ""))
725- then true
726- else (signature == base58''))
727- then unit
728- else invoke(referralsContractAddressOrFail, "createPair", [referralProgramName, referrerAddress, referralAddress, signature], nil)
729- if ((refInv == refInv))
730- then {
731- let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil)
732- if ((updateRefActivity == updateRefActivity))
733- then $Tuple2(lockActionsResult, unit)
734- else throw("Strict value is not equal to itself.")
735- }
736- else throw("Strict value is not equal to itself.")
737- }
724+func constructor (factoryAddressStr,lockAssetIdStr,minLockAmount,minDuration,maxDuration,mathContract) = {
725+ let checkCaller = mustManager(i)
726+ if ((checkCaller == checkCaller))
727+ then ([IntegerEntry(keyNextUserNum(), 0), StringEntry(keyConfig(), formatConfig(lockAssetIdStr, minLockAmount, minDuration, maxDuration, mathContract)), StringEntry(keyFactoryAddress(), factoryAddressStr)] ++ StatsEntry(0, 0, 0, 0))
738728 else throw("Strict value is not equal to itself.")
739729 }
740730
741731
742732
743733 @Callable(i)
744-func lock (duration) = {
745- let suspensionCheck = throwIfSuspended()
746- if ((suspensionCheck == suspensionCheck))
734+func lockRef (duration,referrerAddress,signature) = {
735+ let $t03117031235 = lockActions(i, duration)
736+ let lockActionsResult = $t03117031235._1
737+ let gWxAmountStart = $t03117031235._2
738+ let referralAddress = toString(i.caller)
739+ let refInv = if (if ((referrerAddress == ""))
740+ then true
741+ else (signature == base58''))
742+ then unit
743+ else invoke(referralsContractAddressOrFail, "createPair", [referralProgramName, referrerAddress, referralAddress, signature], nil)
744+ if ((refInv == refInv))
747745 then {
748- let $t02896929034 = lockActions(i, duration)
749- let lockActionsResult = $t02896929034._1
750- let gWxAmountStart = $t02896929034._2
751746 let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil)
752747 if ((updateRefActivity == updateRefActivity))
753748 then $Tuple2(lockActionsResult, unit)
759754
760755
761756 @Callable(i)
762-func claimWxBoost (lpAssetIdStr,userAddressStr) = {
763- let suspensionCheck = throwIfSuspended()
764- if ((suspensionCheck == suspensionCheck))
765- then if ((stakingContract != i.caller))
766- then throwErr("permissions denied")
767- else {
768- let $t02939029492 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false)
769- let userBoostAvailable = $t02939029492._1
770- let dataState = $t02939029492._2
771- let debug = $t02939029492._3
772- $Tuple2(dataState, [userBoostAvailable])
773- }
757+func lock (duration) = {
758+ let $t03169331758 = lockActions(i, duration)
759+ let lockActionsResult = $t03169331758._1
760+ let gWxAmountStart = $t03169331758._2
761+ let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil)
762+ if ((updateRefActivity == updateRefActivity))
763+ then $Tuple2(lockActionsResult, unit)
774764 else throw("Strict value is not equal to itself.")
775765 }
776766
777767
778768
779769 @Callable(i)
770+func increaseLock (deltaDuration) = {
771+ let cfgArray = readConfigArrayOrFail()
772+ let assetIdStr = cfgArray[IdxCfgAssetId]
773+ let assetId = fromBase58String(assetIdStr)
774+ let minLockDuration = parseIntValue(cfgArray[IdxCfgMinLockDuration])
775+ let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration])
776+ let pmtAmount = extractOptionalPaymentAmountOrFail(i, assetId)
777+ let userAddressStr = toString(i.caller)
778+ let userRecordArray = readLockParamsRecordOrFail(userAddressStr)
779+ let userNumStr = userRecordArray[IdxLockUserNum]
780+ let userAmount = parseIntValue(userRecordArray[IdxLockAmount])
781+ let lockStart = parseIntValue(userRecordArray[IdxLockStart])
782+ let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
783+ let lockEnd = (lockStart + lockDuration)
784+ let remainingDuration = max([(lockEnd - height), 0])
785+ let userAmountNew = (userAmount + pmtAmount)
786+ let lockDurationNew = (remainingDuration + deltaDuration)
787+ if ((0 > deltaDuration))
788+ then throwErr("duration is less then zero")
789+ else if ((minLockDuration > lockDurationNew))
790+ then throwErr(("lockDurationNew is less then minLockDuration=" + toString(minLockDuration)))
791+ else if ((lockDurationNew > maxLockDuration))
792+ then throwErr(("deltaDuration + existedLockDuration is greater then maxLockDuration=" + toString(maxLockDuration)))
793+ else {
794+ let coeffX8 = fraction(lockDurationNew, MULT8, maxLockDuration)
795+ let gWxAmountStart = fraction(userAmountNew, coeffX8, MULT8)
796+ let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil)
797+ if ((updateRefActivity == updateRefActivity))
798+ then {
799+ let lockStartNew = height
800+ let gWxParamsResultList = aal(invoke(mathContract, "calcGwxParamsREADONLY", [gWxAmountStart, lockStartNew, lockDurationNew], nil))
801+ let k = ai(gWxParamsResultList[0])
802+ let b = ai(gWxParamsResultList[1])
803+ let period = toString(ai(gWxParamsResultList[2]))
804+ let currUserGwx = calcCurrentGwxAmount(userAddressStr)
805+ let gwxDiff = (gWxAmountStart - currUserGwx)
806+ if ((0 > gwxDiff))
807+ then throwErr(("gwxDiff is less then 0: " + toString(gwxDiff)))
808+ else {
809+ let totalCachedGwxRaw = getTotalCachedGwx(false)
810+ let totalCachedGwxCorrected = getTotalCachedGwx(true)
811+ (((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))])
812+ }
813+ }
814+ else throw("Strict value is not equal to itself.")
815+ }
816+ }
817+
818+
819+
820+@Callable(i)
821+func claimWxBoost (lpAssetIdStr,userAddressStr) = if ((stakingContract != i.caller))
822+ then throwErr("permissions denied")
823+ else {
824+ let $t03486334965 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false)
825+ let userBoostAvailable = $t03486334965._1
826+ let dataState = $t03486334965._2
827+ let debug = $t03486334965._3
828+ $Tuple2(dataState, [userBoostAvailable])
829+ }
830+
831+
832+
833+@Callable(i)
780834 func claimWxBoostREADONLY (lpAssetIdStr,userAddressStr) = {
781- let $t02962429725 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true)
782- let userBoostAvailable = $t02962429725._1
783- let dataState = $t02962429725._2
784- let debug = $t02962429725._3
835+ let $t03509735198 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true)
836+ let userBoostAvailable = $t03509735198._1
837+ let dataState = $t03509735198._2
838+ let debug = $t03509735198._3
785839 $Tuple2(nil, [userBoostAvailable, debug])
786840 }
787841
788842
789843
790844 @Callable(i)
791-func unlock (txIdStr) = {
792- let suspensionCheck = throwIfSuspended()
793- if ((suspensionCheck == suspensionCheck))
794- then {
795- let userAddress = i.caller
796- let userAddressStr = toString(userAddress)
797- let txIdOption = if ((txIdStr == ""))
798- then unit
799- else fromBase58String(txIdStr)
800- let userRecordArray = readLockParamsRecordOrFail(userAddress, txIdOption)
801- let userAmount = parseIntValue(userRecordArray[IdxLockAmount])
802- let lockStart = parseIntValue(userRecordArray[IdxLockStart])
803- let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
804- let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed])
805- let gwxAmount = parseIntValue(userRecordArray[IdxLockGwxAmount])
806- let t = ((height - lockStart) / blocksInPeriod)
807- let wxWithdrawable = getWxWithdrawable(userAddress, txIdOption)
808- let gwxBurned = min([fraction(wxWithdrawable, lockDuration, maxLockDuration), gwxAmount])
809- let gwxRemaining = ensurePositive((gwxAmount - gwxBurned), "gwxRemaining")
810- let lockedGwxAmount = getLockedGwxAmount(userAddress)
811- if ((0 >= wxWithdrawable))
812- then throwErr("nothing to unlock")
813- else {
814- let gwxAmountTotal = getGwxAmountTotal()
815- let userGwxAmountTotal = getUserGwxAmountTotal(userAddress)
816- let userGwxAmountTotalNew = ensurePositive((userGwxAmountTotal - gwxBurned), "userGwxAmountTotalNew")
817- if ((lockedGwxAmount > userGwxAmountTotalNew))
818- then throwErr(("locked gwx amount: " + toString(lockedGwxAmount)))
819- else {
820- let userNum = parseIntValue(valueOrErrorMessage(getString(keyUser2NumMapping(userAddressStr)), wrapErr("invalid user number")))
821- let gwxRewardInv = invoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes, userNum], nil)
822- if ((gwxRewardInv == gwxRewardInv))
823- then ((((LockParamsEntry(userAddress, txIdOption, userAmount, lockStart, lockDuration, gwxRemaining, (wxClaimed + wxWithdrawable)) ++ StatsEntry(-(wxWithdrawable), 0, 0, 0)) :+ HistoryEntry("unlock", userAddressStr, wxWithdrawable, lockStart, lockDuration, gwxBurned, i)) :+ ScriptTransfer(userAddress, wxWithdrawable, assetId)) ++ [IntegerEntry(keyGwxTotal(), ensurePositive((gwxAmountTotal - gwxBurned), "gwxTotal")), IntegerEntry(keyUserGwxAmountTotal(userAddress), userGwxAmountTotalNew)])
824- else throw("Strict value is not equal to itself.")
825- }
826- }
827- }
828- else throw("Strict value is not equal to itself.")
845+func unlock (userAddress) = {
846+ let userRecordArray = readLockParamsRecordOrFail(userAddress)
847+ let userNumStr = userRecordArray[IdxLockUserNum]
848+ let userAmount = parseIntValue(userRecordArray[IdxLockAmount])
849+ let lockStart = parseIntValue(userRecordArray[IdxLockStart])
850+ let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
851+ let lockEnd = (lockStart + lockDuration)
852+ let cfgArray = readConfigArrayOrFail()
853+ let assetId = fromBase58String(cfgArray[IdxCfgAssetId])
854+ if ((lockEnd >= height))
855+ then throwErr((("wait " + toString(lockEnd)) + " to unlock"))
856+ else if ((0 >= userAmount))
857+ then throwErr("nothing to unlock")
858+ else {
859+ let period = valueOrElse(getInteger(mathContract, keyNextPeriod()), 0)
860+ (((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))
861+ }
829862 }
830863
831864
832865
833866 @Callable(i)
834-func gwxUserInfoREADONLY (userAddressStr) = {
835- let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
836- let gwxAmount = getUserGwxAmountTotal(userAddress)
867+func gwxUserInfoREADONLY (userAddress) = {
868+ let gwxAmount = calcCurrentGwxAmount(userAddress)
837869 $Tuple2(nil, [gwxAmount])
838870 }
839871
840872
841873
842874 @Callable(i)
843-func userMaxDurationREADONLY (userAddressStr) = $Tuple2(nil, $Tuple2("lock", maxLockDuration))
875+func userMaxDurationREADONLY (userAddressStr) = {
876+ let cfgArray = readConfigArrayOrFail()
877+ let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration])
878+ let userRecordOption = getString(this, keyLockParamsRecord(userAddressStr))
879+ if ((userRecordOption == unit))
880+ then $Tuple2(nil, $Tuple2("lock", maxLockDuration))
881+ else {
882+ let userRecordArray = split(value(userRecordOption), SEP)
883+ let lockStart = parseIntValue(userRecordArray[IdxLockStart])
884+ let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
885+ let lockEnd = (lockStart + lockDuration)
886+ let remainingDuration = max([(lockEnd - height), 0])
887+ let maxDeltaDuration = (maxLockDuration - remainingDuration)
888+ $Tuple2(nil, $Tuple2("increaseLock", maxDeltaDuration))
889+ }
890+ }
844891
845892
846893
847894 @Callable(i)
848-func getUserGwxAmountAtHeightREADONLY (userAddressStr,targetHeight) = {
849- let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
850- let gwxAmount = getUserGwxAmountTotal(userAddress)
895+func getUserGwxAmountAtHeightREADONLY (userAddress,targetHeight) = {
896+ let gwxAmount = calcUserGwxAmountAtHeight(userAddress, targetHeight)
851897 $Tuple2(nil, gwxAmount)
852898 }
853899
854900
855901
856902 @Callable(i)
857-func getUserGwxAmount (userAddressStr) = {
858- let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
859- let gwxAmount = getUserGwxAmountTotal(userAddress)
860- $Tuple2(nil, gwxAmount)
861- }
862-
863-
864-
865-@Callable(i)
866-func getGwxTotalREADONLY () = $Tuple2(nil, getGwxAmountTotal())
903+func getTotalCachedGwxREADONLY () = $Tuple2(nil, getTotalCachedGwx(true))
867904
868905
869906
870907 @Callable(i)
871908 func onBoostEmissionUpdate () = {
872- let suspensionCheck = throwIfSuspended()
873- if ((suspensionCheck == suspensionCheck))
874- then {
875- let checkCaller = if ((i.caller == emissionContract))
876- then true
877- else mustManager(i)
878- if ((checkCaller == checkCaller))
879- then refreshBoostEmissionIntegral()
880- else throw("Strict value is not equal to itself.")
881- }
909+ let checkCaller = if ((i.caller == emissionContract))
910+ then true
911+ else mustManager(i)
912+ if ((checkCaller == checkCaller))
913+ then refreshBoostEmissionIntegral()
882914 else throw("Strict value is not equal to itself.")
883915 }
884916
886918
887919 @Callable(i)
888920 func onStakedVoteUpdate (lpAssetIdStr,userAddressStr,edge) = {
889- let suspensionCheck = throwIfSuspended()
890- if ((suspensionCheck == suspensionCheck))
921+ let checkCaller = if ((i.caller == stakingContract))
922+ then true
923+ else mustManager(i)
924+ if ((checkCaller == checkCaller))
891925 then {
892- let checkCaller = if ((i.caller == stakingContract))
893- then true
894- else mustManager(i)
895- if ((checkCaller == checkCaller))
896- then {
897- let actions = refreshVoteStakedIntegral(lpAssetIdStr, userAddressStr, edge)
898- $Tuple2(actions, unit)
899- }
900- else throw("Strict value is not equal to itself.")
926+ let actions = refreshVoteStakedIntegral(lpAssetIdStr, userAddressStr, edge)
927+ $Tuple2(actions, unit)
901928 }
902929 else throw("Strict value is not equal to itself.")
903930 }
923950 func getUserVoteStakedIntegralREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr))
924951
925952
926-
927-@Callable(i)
928-func suspend (v) = {
929- let checkCaller = mustManager(i)
930- if ((checkCaller == checkCaller))
931- then $Tuple2([BooleanEntry(keySuspension, v)], v)
932- else throw("Strict value is not equal to itself.")
933- }
934-
935-
936953 @Verifier(tx)
937954 func verify () = {
938955 let targetPublicKey = match managerPublicKeyOrUnit() {
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let SCALE8 = 8
77
88 let MULT8 = 100000000
99
1010 let POOLWEIGHTMULT = MULT8
1111
12-let contractFilename = "boosting.ride"
13-
14-let SCALE18 = 18
15-
16-let MULT18 = 1000000000000000000
17-
18-let MULT18BI = toBigInt(MULT18)
19-
20-let DECAY_CONSTANT = 8
21-
22-func wrapErr (msg) = makeString([contractFilename, ": ", msg], "")
12+func wrapErr (msg) = makeString(["boosting.ride:", msg], " ")
2313
2414
2515 func throwErr (msg) = throw(wrapErr(msg))
2616
2717
28-func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((("mandatory this." + key) + " is not defined")))
18+func strf (address,key) = valueOrErrorMessage(getString(address, key), wrapErr((("mandatory this." + key) + " is not defined")))
2919
3020
31-func getIntOrZero (address,key) = valueOrElse(getInteger(address, key), 0)
21+func ioz (address,key) = valueOrElse(getInteger(address, key), 0)
3222
3323
34-func getIntOrDefault (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal)
24+func iod (address,key,defaultVal) = valueOrElse(getInteger(address, key), defaultVal)
3525
3626
37-func getIntOrFail (address,key) = valueOrErrorMessage(getInteger(address, key), wrapErr((("mandatory this." + key) + " is not defined")))
27+func iof (address,key) = valueOrErrorMessage(getInteger(address, key), wrapErr((("mandatory this." + key) + " is not defined")))
3828
3929
4030 func abs (val) = if ((0 > val))
4131 then -(val)
4232 else val
4333
4434
45-func ensurePositive (v,m) = if ((v >= 0))
46- then v
47- else throwErr((valueOrElse(m, "value") + " should be positive"))
35+func aal (val) = match val {
36+ case valAnyLyst: List[Any] =>
37+ valAnyLyst
38+ case _ =>
39+ throwErr("fail to cast into List[Any]")
40+}
41+
42+
43+func ai (val) = match val {
44+ case valInt: Int =>
45+ valInt
46+ case _ =>
47+ throwErr("fail to cast into Int")
48+}
4849
4950
5051 func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP)
5152
5253
53-let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(this, keyReferralsContractAddress()))
54+let referralsContractAddressOrFail = addressFromStringValue(strf(this, keyReferralsContractAddress()))
5455
5556 let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP)
5657
5758 let referralProgramNameDefault = "wxlock"
5859
5960 let referralProgramName = valueOrElse(getString(this, keyReferralProgramName), referralProgramNameDefault)
6061
6162 func keyFactoryAddress () = "%s%s__config__factoryAddress"
6263
6364
6465 let IdxFactoryCfgStakingDapp = 1
6566
6667 let IdxFactoryCfgBoostingDapp = 2
6768
6869 let IdxFactoryCfgIdoDapp = 3
6970
7071 let IdxFactoryCfgTeamDapp = 4
7172
7273 let IdxFactoryCfgEmissionDapp = 5
7374
7475 let IdxFactoryCfgRestDapp = 6
7576
7677 let IdxFactoryCfgSlippageDapp = 7
7778
7879 let IdxFactoryCfgDaoDapp = 8
7980
8081 let IdxFactoryCfgMarketingDapp = 9
8182
8283 let IdxFactoryCfgGwxRewardDapp = 10
8384
8485 let IdxFactoryCfgBirdsDapp = 11
8586
8687 func keyFactoryCfg () = "%s__factoryConfig"
8788
8889
90+func keyFactoryLpList () = "%s__lpTokensList"
91+
92+
8993 func keyFactoryLpAssetToPoolContractAddress (lpAssetStr) = makeString(["%s%s%s", lpAssetStr, "mappings__lpAsset2PoolContract"], SEP)
9094
9195
9296 func keyFactoryPoolWeight (contractAddress) = makeString(["%s%s", "poolWeight", contractAddress], SEP)
9397
9498
9599 func keyFactoryPoolWeightHistory (poolAddress,num) = ((("%s%s__poolWeight__" + poolAddress) + "__") + toString(num))
96100
97101
98-func readFactoryAddressOrFail () = addressFromStringValue(getStringOrFail(this, keyFactoryAddress()))
102+func readFactoryAddressOrFail () = addressFromStringValue(strf(this, keyFactoryAddress()))
99103
100104
101-func readFactoryCfgOrFail (factory) = split(getStringOrFail(factory, keyFactoryCfg()), SEP)
105+func readLpList () = split(valueOrElse(getString(readFactoryAddressOrFail(), keyFactoryLpList()), ""), SEP)
106+
107+
108+func readFactoryCfgOrFail (factory) = split(strf(factory, keyFactoryCfg()), SEP)
102109
103110
104111 func getBoostingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgBoostingDapp])
105112
106113
107114 func getEmissionAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgEmissionDapp])
108115
109116
110117 func getStakingAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgStakingDapp])
111118
112119
113120 func getGwxRewardAddressOrFail (factoryCfg) = addressFromStringValue(factoryCfg[IdxFactoryCfgGwxRewardDapp])
114121
115122
116123 func keyManagerPublicKey () = "%s__managerPublicKey"
117124
118125
119126 func keyManagerVaultAddress () = "%s__managerVaultAddress"
120127
121128
122129 func keyEmissionRatePerBlockCurrent () = "%s%s__ratePerBlock__current"
123130
124131
125132 func keyEmissionRatePerBlockMaxCurrent () = "%s%s__ratePerBlockMax__current"
126133
127134
128135 func keyEmissionStartBlock () = "%s%s__emission__startBlock"
129136
130137
131138 func keyBoostingV2LastUpdateHeight () = "%s%s__boostingV2__startBlock"
132139
133140
134141 func keyBoostingV2Integral () = "%s%s__boostingV2__integral"
135142
136143
137144 func keyEmissionDurationInBlocks () = "%s%s__emission__duration"
138145
139146
140147 func keyEmissionEndBlock () = "%s%s__emission__endBlock"
141148
142149
150+func keyNextPeriod () = "%s__nextPeriod"
151+
152+
153+func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight"
154+
155+
143156 let IdxCfgAssetId = 1
144157
145158 let IdxCfgMinLockAmount = 2
146159
147160 let IdxCfgMinLockDuration = 3
148161
149162 let IdxCfgMaxLockDuration = 4
150163
151164 let IdxCfgMathContract = 5
152165
153-let IdxCfgBlocksInPeriod = 6
154-
155-let IdxCfgLockStepBlocks = 7
156-
157166 func keyConfig () = "%s__config"
158167
159168
160-func readConfigArrayOrFail () = split(getStringOrFail(this, keyConfig()), SEP)
169+func readConfigArrayOrFail () = split(strf(this, keyConfig()), SEP)
161170
162171
163-let cfgArray = readConfigArrayOrFail()
172+let mathContract = addressFromStringValue(readConfigArrayOrFail()[IdxCfgMathContract])
164173
165-let assetId = fromBase58String(cfgArray[IdxCfgAssetId])
174+func formatConfigS (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = makeString(["%s%d%d%d", assetId, minLockAmount, minLockDuration, maxLockDuration, mathContract], SEP)
166175
167-let minLockAmount = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMinLockAmount]), wrapErr("invalid min lock amount"))
168176
169-let minLockDuration = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMinLockDuration]), wrapErr("invalid min lock duration"))
170-
171-let maxLockDuration = valueOrErrorMessage(parseInt(cfgArray[IdxCfgMaxLockDuration]), wrapErr("invalid max lock duration"))
172-
173-let mathContract = valueOrErrorMessage(addressFromString(cfgArray[IdxCfgMathContract]), wrapErr("invalid math contract address"))
174-
175-let blocksInPeriod = valueOrErrorMessage(parseInt(cfgArray[IdxCfgBlocksInPeriod]), wrapErr("invalid blocks in period"))
176-
177-let lockStepBlocks = valueOrErrorMessage(parseInt(cfgArray[IdxCfgLockStepBlocks]), wrapErr("invalid lock step blocks"))
178-
179-let keySuspension = "%s__suspension"
180-
181-let isSuspended = valueOrElse(getBoolean(this, keySuspension), false)
182-
183-func throwIfSuspended () = if (!(isSuspended))
184- then true
185- else throwErr("suspended")
177+func formatConfig (assetId,minLockAmount,minLockDuration,maxLockDuration,mathContract) = formatConfigS(assetId, toString(minLockAmount), toString(minLockDuration), toString(maxLockDuration), mathContract)
186178
187179
188180 func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) {
189181 case s: String =>
190182 addressFromStringValue(s)
191183 case _ =>
192184 this
193185 }
194186
195187
196188 func managerPublicKeyOrUnit () = {
197189 let managerVaultAddress = getManagerVaultAddressOrThis()
198190 match getString(managerVaultAddress, keyManagerPublicKey()) {
199191 case s: String =>
200192 fromBase58String(s)
201193 case _: Unit =>
202194 unit
203195 case _ =>
204196 throw("Match error")
205197 }
206198 }
207199
208200
209201 func mustManager (i) = {
210202 let pd = throwErr("Permission denied")
211203 match managerPublicKeyOrUnit() {
212204 case pk: ByteVector =>
213205 if ((i.callerPublicKey == pk))
214206 then true
215207 else pd
216208 case _: Unit =>
217209 if ((i.caller == this))
218210 then true
219211 else pd
220212 case _ =>
221213 throw("Match error")
222214 }
223215 }
224216
225217
226-let IdxLockAmount = 1
218+let IdxLockUserNum = 1
227219
228-let IdxLockStart = 2
220+let IdxLockAmount = 2
229221
230-let IdxLockDuration = 3
222+let IdxLockStart = 3
231223
232-let IdxLockLastUpdateTimestamp = 4
224+let IdxLockDuration = 4
233225
234-let IdxLockGwxAmount = 5
226+let IdxLockParamK = 5
235227
236-let IdxLockWxClaimed = 6
228+let IdxLockParamB = 6
237229
238-func keyLockParamsRecord (userAddress,txId) = makeString(["%s%s%s__lock", toString(userAddress), match txId {
239- case b: ByteVector =>
240- toBase58String(b)
241- case _: Unit =>
242- "legacy"
243- case _ =>
244- throw("Match error")
245-}], SEP)
230+func keyLockParamsRecord (userAddress) = makeString(["%s%s__lock", userAddress], SEP)
246231
247232
248-func readLockParamsRecordOrFail (userAddress,txId) = split(getStringOrFail(this, keyLockParamsRecord(userAddress, txId)), SEP)
233+func readLockParamsRecordOrFail (userAddress) = split(strf(this, keyLockParamsRecord(userAddress)), SEP)
249234
250235
251-func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP)
236+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)
252237
253238
254-func formatLockParamsRecord (amount,start,duration,gwxAmount,wxClaimed) = makeString(["%d%d%d%d%d%d", toString(amount), toString(start), toString(duration), toString(lastBlock.timestamp), toString(gwxAmount), toString(wxClaimed)], SEP)
239+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))
255240
256241
257242 func keyNextUserNum () = "%s__nextUserNum"
258243
259244
260245 func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", userAddress], SEP)
261246
262247
263248 func keyNum2UserMapping (num) = makeString(["%s%s%s__mapping__num2user", num], SEP)
249+
250+
251+func keyLockParamUserAmount (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "amount"], SEP)
252+
253+
254+func keyLockParamStartBlock (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "start"], SEP)
255+
256+
257+func keyLockParamDuration (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "duration"], SEP)
258+
259+
260+func keyLockParamK (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "k"], SEP)
261+
262+
263+func keyLockParamB (userNum) = makeString(["%s%d%s__paramByUserNum", userNum, "b"], SEP)
264+
265+
266+func keyLockParamByPeriodK (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "k", period], SEP)
267+
268+
269+func keyLockParamByPeriodB (userNum,period) = makeString(["%s%d%s%d__paramByPeriod", userNum, "b", period], SEP)
264270
265271
266272 func keyLockParamTotalAmount () = "%s%s__stats__activeTotalLocked"
267273
268274
269275 func keyStatsLocksDurationSumInBlocks () = "%s%s__stats__locksDurationSumInBlocks"
270276
271277
272278 func keyStatsLocksCount () = "%s%s__stats__locksCount"
273279
274280
275281 func keyStatsUsersCount () = "%s%s__stats__activeUsersCount"
276282
277283
278-func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastIntV2", toString(userNum)], SEP)
284+func keyUserBoostEmissionLastINTEGRAL (userNum) = makeString(["%s%d__userBoostEmissionLastIntV2", userNum], SEP)
279285
280286
281-func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__userBoostEmissionLastIntV2", toString(userNum), lpAssetId], SEP)
287+func keyUserLpBoostEmissionLastINTEGRAL (userNum,lpAssetId) = makeString(["%s%d__userBoostEmissionLastIntV2", userNum, lpAssetId], SEP)
282288
283289
284-func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", toString(userNum)], SEP)
290+func keyUserMaxBoostINTEGRAL (userNum) = makeString(["%s%d__maxBoostInt", userNum], SEP)
285291
286292
287293 func keyTotalMaxBoostINTEGRAL () = "%s%s__maxBoostInt__total"
288294
289295
290-func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", toString(userNum)], SEP)
296+func keyUserBoostAvalaibleToClaimTotal (userNum) = makeString(["%s%d__userBoostAvaliableToClaimTotal", userNum], SEP)
291297
292298
293-func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", toString(userNum)], SEP)
299+func keyUserBoostClaimed (userNum) = makeString(["%s%d__userBoostClaimed", userNum], SEP)
294300
295301
296-func keyGwxTotal () = "%s%s__gwx__total"
302+func keyTotalCachedGwx () = "%s%s__gwxCached__total"
303+
304+
305+func keyTotalCachedGwxCorrective () = "%s__gwxCachedTotalCorrective"
297306
298307
299308 func keyVote (amountAssetId,priceAssetId,address,epoch) = makeString(["%s%s%s%s%d", "vote", amountAssetId, priceAssetId, toString(address), toString(epoch)], SEP)
300309
301310
302311 func keyStartHeightByEpoch (epoch) = makeString(["%s%d", "startHeight", toString(epoch)], SEP)
303312
304313
305314 func keyCurrentEpochUi () = makeString(["%s", "currentEpochUi"], SEP)
306315
307316
308317 func keyVotingResultStaked (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStaked", lpAssetIdStr, toString(epoch)], SEP)
309318
310319
311320 func keyVotingResultStakedIntegral (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegral", lpAssetIdStr, toString(epoch)], SEP)
312321
313322
314323 func keyVotingResultStakedLastUpdateHeight (lpAssetIdStr,epoch) = makeString(["%s%s%d", "votingResultStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(epoch)], SEP)
315324
316325
317326 func keyVotingResultStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "votingResultStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP)
318327
319328
320329 func keyVoteStakedIntegral (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegral", lpAssetIdStr, toString(address), toString(epoch)], SEP)
321330
322331
323332 func keyVoteStakedLastUpdateHeight (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLastUpdateHeight", lpAssetIdStr, toString(address), toString(epoch)], SEP)
324333
325334
326335 func keyVoteStakedIntegralLast (lpAssetIdStr,address,epoch) = makeString(["%s%s%s%d", "voteStakedIntegralLast", lpAssetIdStr, toString(address), toString(epoch)], SEP)
327336
328337
329338 func keyStakedByUser (userAddressStr,lpAssetIdStr) = makeString(["%s%s%s", "staked", userAddressStr, lpAssetIdStr], SEP)
330339
331340
332341 let factoryContract = readFactoryAddressOrFail()
333342
334343 let factoryCfg = readFactoryCfgOrFail(factoryContract)
335344
336345 let emissionContract = getEmissionAddressOrFail(factoryCfg)
337346
338347 let stakingContract = getStakingAddressOrFail(factoryCfg)
339348
340349 let gwxRewardContract = getGwxRewardAddressOrFail(factoryCfg)
341350
342351 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"))
343352
344353 let keyVotingEmissionContract = makeString(["%s", "votingEmissionContract"], SEP)
345354
346355 let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract))
347356
348-let keyVotingEmissionRateContract = makeString(["%s", "votingEmissionRateContract"], SEP)
349-
350357 let boostCoeff = {
351358 let @ = invoke(emissionContract, "getBoostCoeffREADONLY", nil, nil)
352359 if ($isInstanceOf(@, "Int"))
353360 then @
354361 else throw(($getType(@) + " couldn't be cast to Int"))
355362 }
356363
357-func userNumberByAddressOrFail (userAddress) = match getString(this, keyUser2NumMapping(toString(userAddress))) {
358- case s: String =>
359- valueOrErrorMessage(parseInt(s), wrapErr("invalid user number"))
360- case _: Unit =>
361- throwErr("invalid user")
362- case _ =>
363- throw("Match error")
364-}
365-
366-
367-func getGwxAmountTotal () = valueOrElse(getInteger(this, keyGwxTotal()), 0)
368-
369-
370-func getLockedGwxAmount (userAddress) = {
371- let functionName = "getLockedGwxAmount"
372- let votingEmissionRateContract = valueOrErrorMessage( match getString(votingEmissionContract, keyVotingEmissionRateContract) {
373- case _: Unit =>
374- unit
375- case s: String =>
376- addressFromString(s)
377- case _ =>
378- throw("Match error")
379- }, wrapErr("invalid voting emission rate address"))
380- let lockedVotingEmissionRate = {
381- let @ = invoke(votingEmissionContract, functionName, [toString(userAddress)], nil)
382- if ($isInstanceOf(@, "Int"))
383- then @
384- else throw(($getType(@) + " couldn't be cast to Int"))
385- }
386- let lockedVotingEmission = {
387- let @ = invoke(votingEmissionRateContract, functionName, [toString(userAddress)], nil)
388- if ($isInstanceOf(@, "Int"))
389- then @
390- else throw(($getType(@) + " couldn't be cast to Int"))
391- }
392- let locked = max([lockedVotingEmissionRate, lockedVotingEmission])
393- locked
364+func getTotalCachedGwx (correct) = {
365+ let currentEpochUi = getIntegerValue(votingEmissionContract, keyCurrentEpochUi())
366+ let keyTargetEpoch = makeString(["%s%s", "totalCachedGwxCorrection__activationEpoch"], SEP)
367+ let targetEpochOption = getInteger(this, keyTargetEpoch)
368+ let totalCachedGwxRaw = valueOrElse(getInteger(this, keyTotalCachedGwx()), 0)
369+ let isCorrectionActivated = if (isDefined(targetEpochOption))
370+ then (currentEpochUi >= value(targetEpochOption))
371+ else false
372+ let corrective = if (if (isCorrectionActivated)
373+ then correct
374+ else false)
375+ then valueOrElse(getInteger(this, keyTotalCachedGwxCorrective()), 0)
376+ else 0
377+ max([0, (totalCachedGwxRaw + corrective)])
394378 }
395379
396380
397-func HistoryEntry (type,user,amount,lockStart,duration,gwxAmount,i) = {
381+func HistoryEntry (type,user,amount,lockStart,duration,k,b,i) = {
398382 let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP)
399- let historyDATA = makeString(["%d%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount), toString(lockStart), toString(duration), toString(gwxAmount)], SEP)
383+ 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)
400384 StringEntry(historyKEY, historyDATA)
401385 }
402386
403387
404388 func StatsEntry (totalLockedInc,durationInc,lockCountInc,usersCountInc) = {
405389 let locksDurationSumInBlocksKEY = keyStatsLocksDurationSumInBlocks()
406390 let locksCountKEY = keyStatsLocksCount()
407391 let usersCountKEY = keyStatsUsersCount()
408392 let totalAmountKEY = keyLockParamTotalAmount()
409- let locksDurationSumInBlocks = getIntOrZero(this, locksDurationSumInBlocksKEY)
410- let locksCount = getIntOrZero(this, locksCountKEY)
411- let usersCount = getIntOrZero(this, usersCountKEY)
412- let totalAmount = getIntOrZero(this, totalAmountKEY)
393+ let locksDurationSumInBlocks = ioz(this, locksDurationSumInBlocksKEY)
394+ let locksCount = ioz(this, locksCountKEY)
395+ let usersCount = ioz(this, usersCountKEY)
396+ let totalAmount = ioz(this, totalAmountKEY)
413397 [IntegerEntry(locksDurationSumInBlocksKEY, (locksDurationSumInBlocks + durationInc)), IntegerEntry(locksCountKEY, (locksCount + lockCountInc)), IntegerEntry(usersCountKEY, (usersCount + usersCountInc)), IntegerEntry(totalAmountKEY, (totalAmount + totalLockedInc))]
414398 }
415399
416400
417-func LockParamsEntry (userAddress,txId,amount,start,duration,gwxAmount,wxClaimed) = [StringEntry(keyLockParamsRecord(userAddress, txId), formatLockParamsRecord(amount, start, duration, gwxAmount, wxClaimed))]
401+func calcGwxAmount (kRaw,bRaw,h) = {
402+ let SCALE = 1000
403+ (((kRaw * h) + bRaw) / SCALE)
404+ }
405+
406+
407+func LockParamsEntry (userAddress,userNum,amount,start,duration,k,b,period) = {
408+ let userAmountKEY = keyLockParamUserAmount(userNum)
409+ let startBlockKEY = keyLockParamStartBlock(userNum)
410+ let durationKEY = keyLockParamDuration(userNum)
411+ let kKEY = keyLockParamK(userNum)
412+ let bKEY = keyLockParamB(userNum)
413+ let kByPeriodKEY = keyLockParamByPeriodK(userNum, period)
414+ let bByPeriodKEY = keyLockParamByPeriodB(userNum, period)
415+ let gwxAmount = calcGwxAmount(k, b, height)
416+[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))]
417+ }
418418
419419
420420 func extractOptionalPaymentAmountOrFail (i,expectedAssetId) = if ((size(i.payments) > 1))
421421 then throwErr("only one payment is allowed")
422422 else if ((size(i.payments) == 0))
423423 then 0
424424 else {
425425 let pmt = i.payments[0]
426426 if ((value(pmt.assetId) != expectedAssetId))
427427 then throwErr("invalid asset id in payment")
428428 else pmt.amount
429429 }
430430
431431
432-func getUserGwxAmountTotal (userAddress) = valueOrElse(getInteger(this, keyUserGwxAmountTotal(userAddress)), 0)
432+func calcUserGwxAmountAtHeight (userAddress,targetHeight) = {
433+ let EMPTY = "empty"
434+ let user2NumMappingKEY = keyUser2NumMapping(userAddress)
435+ let userNum = valueOrElse(getString(user2NumMappingKEY), EMPTY)
436+ let k = valueOrElse(getInteger(keyLockParamK(userNum)), 0)
437+ let b = valueOrElse(getInteger(keyLockParamB(userNum)), 0)
438+ let gwxAmountCalc = calcGwxAmount(k, b, targetHeight)
439+ let gwxAmount = if ((0 > gwxAmountCalc))
440+ then 0
441+ else gwxAmountCalc
442+ gwxAmount
443+ }
444+
445+
446+func calcCurrentGwxAmount (userAddress) = calcUserGwxAmountAtHeight(userAddress, height)
433447
434448
435449 func getVotingEmissionEpochInfo () = {
436- let $t01468614976 = {
450+ let $t01718617476 = {
437451 let currentEpochUi = value(getInteger(votingEmissionContract, keyCurrentEpochUi()))
438452 let lastFinalizedEpoch = (currentEpochUi - 1)
439453 if ((0 > lastFinalizedEpoch))
440454 then throwErr("invalid epoch")
441455 else $Tuple2(currentEpochUi, lastFinalizedEpoch)
442456 }
443- let currentEpochUi = $t01468614976._1
444- let lastFinalizedEpoch = $t01468614976._2
457+ let currentEpochUi = $t01718617476._1
458+ let lastFinalizedEpoch = $t01718617476._2
445459 let currentEpochStartHeight = value(getInteger(votingEmissionContract, keyStartHeightByEpoch(currentEpochUi)))
446460 $Tuple2(lastFinalizedEpoch, currentEpochStartHeight)
447461 }
448462
449463
450464 func getPoolAssetsByLpAssetId (lpAssetIdStr) = {
451465 let idxAmountAssetId = 4
452466 let idxPriceAssetId = 5
453467 let poolCfg = {
454468 let @ = invoke(factoryContract, "getPoolConfigByLpAssetIdREADONLY", [lpAssetIdStr], nil)
455469 if ($isInstanceOf(@, "List[Any]"))
456470 then @
457471 else throw(($getType(@) + " couldn't be cast to List[Any]"))
458472 }
459473 let amountAssetId = {
460474 let @ = poolCfg[idxAmountAssetId]
461475 if ($isInstanceOf(@, "String"))
462476 then @
463477 else throw(($getType(@) + " couldn't be cast to String"))
464478 }
465479 let priceAssetId = {
466480 let @ = poolCfg[idxPriceAssetId]
467481 if ($isInstanceOf(@, "String"))
468482 then @
469483 else throw(($getType(@) + " couldn't be cast to String"))
470484 }
471485 $Tuple2(amountAssetId, priceAssetId)
472486 }
473487
474488
475489 func getUserVoteFinalized (lpAssetIdStr,userAddressStr) = {
476490 let userAddress = addressFromStringValue(userAddressStr)
477- let $t01566715747 = getVotingEmissionEpochInfo()
478- let lastFinalizedEpoch = $t01566715747._1
479- let currentEpochStartHeight = $t01566715747._2
480- let $t01575015825 = getPoolAssetsByLpAssetId(lpAssetIdStr)
481- let amountAssetId = $t01575015825._1
482- let priceAssetId = $t01575015825._2
491+ let $t01816718247 = getVotingEmissionEpochInfo()
492+ let lastFinalizedEpoch = $t01816718247._1
493+ let currentEpochStartHeight = $t01816718247._2
494+ let $t01825018325 = getPoolAssetsByLpAssetId(lpAssetIdStr)
495+ let amountAssetId = $t01825018325._1
496+ let priceAssetId = $t01825018325._2
483497 let userVoteKey = keyVote(amountAssetId, priceAssetId, userAddress, lastFinalizedEpoch)
484498 let userVote = valueOrElse(getInteger(votingEmissionContract, userVoteKey), 0)
485499 userVote
486500 }
487501
488502
489503 func getUserVoteStaked (lpAssetIdStr,userAddressStr) = {
490504 let stakedByUser = valueOrElse(getInteger(stakingContract, keyStakedByUser(userAddressStr, lpAssetIdStr)), 0)
491505 let userVote = getUserVoteFinalized(lpAssetIdStr, userAddressStr)
492506 if ((stakedByUser == 0))
493507 then 0
494508 else userVote
495509 }
496510
497511
498512 func getVotingResultStaked (lpAssetIdStr) = {
499- let $t01636916449 = getVotingEmissionEpochInfo()
500- let lastFinalizedEpoch = $t01636916449._1
501- let currentEpochStartHeight = $t01636916449._2
513+ let $t01886918949 = getVotingEmissionEpochInfo()
514+ let lastFinalizedEpoch = $t01886918949._1
515+ let currentEpochStartHeight = $t01886918949._2
502516 let votingResultStakedStart = valueOrElse(getInteger(votingEmissionContract, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), 0)
503517 let votingResultStaked = valueOrElse(getInteger(this, keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch)), votingResultStakedStart)
504518 votingResultStaked
505519 }
506520
507521
508522 func getVotingResultStakedIntegral (lpAssetIdStr) = {
509- let $t01681116891 = getVotingEmissionEpochInfo()
510- let lastFinalizedEpoch = $t01681116891._1
511- let currentEpochStartHeight = $t01681116891._2
523+ let $t01931119391 = getVotingEmissionEpochInfo()
524+ let lastFinalizedEpoch = $t01931119391._1
525+ let currentEpochStartHeight = $t01931119391._2
512526 let votingResultStaked = getVotingResultStaked(lpAssetIdStr)
513527 let votingResultStakedIntegralPrev = valueOrElse(getInteger(this, keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch)), 0)
514528 let votingResultStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch)), currentEpochStartHeight)
515529 let votingResultStakedIntegralDh = (height - votingResultStakedLastUpdateHeight)
516530 let votingResultStakedIntegral = ((votingResultStakedIntegralDh * votingResultStaked) + votingResultStakedIntegralPrev)
517531 votingResultStakedIntegral
518532 }
519533
520534
521535 func refreshVotingResultStakedIntegral (lpAssetIdStr,stakedVoteDelta) = {
522- let $t01772817808 = getVotingEmissionEpochInfo()
523- let lastFinalizedEpoch = $t01772817808._1
524- let currentEpochStartHeight = $t01772817808._2
536+ let $t02022820308 = getVotingEmissionEpochInfo()
537+ let lastFinalizedEpoch = $t02022820308._1
538+ let currentEpochStartHeight = $t02022820308._2
525539 let votingResultStaked = getVotingResultStaked(lpAssetIdStr)
526540 let votingResultStakedNew = (votingResultStaked + stakedVoteDelta)
527541 let votingResultStakedIntegral = getVotingResultStakedIntegral(lpAssetIdStr)
528542 [IntegerEntry(keyVotingResultStaked(lpAssetIdStr, lastFinalizedEpoch), votingResultStakedNew), IntegerEntry(keyVotingResultStakedLastUpdateHeight(lpAssetIdStr, lastFinalizedEpoch), height), IntegerEntry(keyVotingResultStakedIntegral(lpAssetIdStr, lastFinalizedEpoch), votingResultStakedIntegral)]
529543 }
530544
531545
532546 func getUserVoteStakedIntegral (lpAssetIdStr,userAddressStr) = {
533- let $t01841918499 = getVotingEmissionEpochInfo()
534- let lastFinalizedEpoch = $t01841918499._1
535- let currentEpochStartHeight = $t01841918499._2
547+ let $t02091920999 = getVotingEmissionEpochInfo()
548+ let lastFinalizedEpoch = $t02091920999._1
549+ let currentEpochStartHeight = $t02091920999._2
536550 let userAddress = addressFromStringValue(userAddressStr)
537551 let userVoteStaked = getUserVoteStaked(lpAssetIdStr, userAddressStr)
538552 let userVoteStakedIntegralPrev = valueOrElse(getInteger(this, keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch)), 0)
539553 let userVoteStakedLastUpdateHeight = valueOrElse(getInteger(this, keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch)), currentEpochStartHeight)
540554 let userVoteStakedIntegralDh = (height - userVoteStakedLastUpdateHeight)
541555 let userVoteStakedIntegral = ((userVoteStakedIntegralDh * userVoteStaked) + userVoteStakedIntegralPrev)
542556 userVoteStakedIntegral
543557 }
544558
545559
546560 func refreshVoteStakedIntegral (lpAssetIdStr,userAddressStr,edge) = {
547- let $t01928719367 = getVotingEmissionEpochInfo()
548- let lastFinalizedEpoch = $t01928719367._1
549- let currentEpochStartHeight = $t01928719367._2
561+ let $t02178721867 = getVotingEmissionEpochInfo()
562+ let lastFinalizedEpoch = $t02178721867._1
563+ let currentEpochStartHeight = $t02178721867._2
550564 let userAddress = addressFromStringValue(userAddressStr)
551565 let userVoteFinalized = getUserVoteFinalized(lpAssetIdStr, userAddressStr)
552566 let actions = if ((userVoteFinalized == 0))
553567 then nil
554568 else {
555569 let stakedVoteDelta = if (edge)
556570 then userVoteFinalized
557571 else -(userVoteFinalized)
558572 let votingResultActions = refreshVotingResultStakedIntegral(lpAssetIdStr, stakedVoteDelta)
559573 let userVoteStakedIntegral = getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr)
560574 let voteActions = [IntegerEntry(keyVoteStakedLastUpdateHeight(lpAssetIdStr, userAddress, lastFinalizedEpoch), height), IntegerEntry(keyVoteStakedIntegral(lpAssetIdStr, userAddress, lastFinalizedEpoch), userVoteStakedIntegral)]
561575 (votingResultActions ++ voteActions)
562576 }
563577 actions
564578 }
565579
566580
567581 func getStakedVotesIntegralsDiff (lpAssetIdStr,userAddressStr) = {
568- let $t02022120301 = getVotingEmissionEpochInfo()
569- let lastFinalizedEpoch = $t02022120301._1
570- let currentEpochStartHeight = $t02022120301._2
582+ let $t02272122801 = getVotingEmissionEpochInfo()
583+ let lastFinalizedEpoch = $t02272122801._1
584+ let currentEpochStartHeight = $t02272122801._2
571585 let userAddress = addressFromStringValue(userAddressStr)
572586 let userVoteStakedIntegralLastKey = keyVoteStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch)
573587 let userVoteStakedIntegralLast = valueOrElse(getInteger(this, userVoteStakedIntegralLastKey), 0)
574588 let votingResultStakedIntegralLastKey = keyVotingResultStakedIntegralLast(lpAssetIdStr, userAddress, lastFinalizedEpoch)
575589 let votingResultStakedIntegralLast = valueOrElse(getInteger(this, votingResultStakedIntegralLastKey), 0)
576590 let userVoteStakedIntegral = getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr)
577591 let votingResultStakedIntegral = getVotingResultStakedIntegral(lpAssetIdStr)
578592 let userVoteStakedIntegralDiff = (userVoteStakedIntegral - userVoteStakedIntegralLast)
579593 let votingResultStakedIntegralDiff = (votingResultStakedIntegral - votingResultStakedIntegralLast)
580594 $Tuple3([IntegerEntry(userVoteStakedIntegralLastKey, userVoteStakedIntegral), IntegerEntry(votingResultStakedIntegralLastKey, votingResultStakedIntegral)], userVoteStakedIntegralDiff, votingResultStakedIntegralDiff)
581595 }
582596
583597
584598 func refreshBoostEmissionIntegral () = {
585- let wxEmissionPerBlock = getIntOrFail(emissionContract, keyEmissionRatePerBlockCurrent())
599+ let wxEmissionPerBlock = iof(emissionContract, keyEmissionRatePerBlockCurrent())
586600 let boostingV2LastUpdateHeightOption = getInteger(this, keyBoostingV2LastUpdateHeight())
587601 let boostingV2IngergalOption = getInteger(this, keyBoostingV2Integral())
588- let emissionEnd = getIntOrFail(emissionContract, keyEmissionEndBlock())
602+ let emissionEnd = iof(emissionContract, keyEmissionEndBlock())
589603 let h = if ((height > emissionEnd))
590604 then emissionEnd
591605 else height
592606 let dh = match boostingV2LastUpdateHeightOption {
593607 case lastUpdateHeight: Int =>
594608 max([(h - lastUpdateHeight), 0])
595609 case _: Unit =>
596610 0
597611 case _ =>
598612 throw("Match error")
599613 }
600614 let boostEmissionPerBlock = ((wxEmissionPerBlock * (boostCoeff - 1)) / boostCoeff)
601615 let boostEmissionIntegralPrev = valueOrElse(boostingV2IngergalOption, 0)
602616 let boostEmissionIntegral = ((boostEmissionPerBlock * dh) + boostEmissionIntegralPrev)
603617 $Tuple2([IntegerEntry(keyBoostingV2Integral(), boostEmissionIntegral), IntegerEntry(keyBoostingV2LastUpdateHeight(), height)], boostEmissionIntegral)
604618 }
605619
606620
607621 func internalClaimWxBoost (lpAssetIdStr,userAddressStr,readOnly) = {
608- let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
609- let userNum = userNumberByAddressOrFail(userAddress)
610- if ((userNum == userNum))
611- then {
622+ let userRecordOption = getString(this, keyLockParamsRecord(userAddressStr))
623+ if ((userRecordOption == unit))
624+ then $Tuple3(0, nil, "userRecord::is::empty")
625+ else {
626+ let userRecordArray = split(value(userRecordOption), SEP)
627+ let userNumStr = userRecordArray[IdxLockUserNum]
612628 let EMPTYSTR = "empty"
613629 let poolWeight = if ((lpAssetIdStr != EMPTYSTR))
614630 then {
615631 let poolAddressStr = valueOrErrorMessage(getString(factoryContract, keyFactoryLpAssetToPoolContractAddress(lpAssetIdStr)), wrapErr(("unsupported lp asset " + lpAssetIdStr)))
616632 getIntegerValue(factoryContract, keyFactoryPoolWeight(poolAddressStr))
617633 }
618634 else if (readOnly)
619635 then 0
620636 else throwErr(("not readonly mode: unsupported lp asset " + lpAssetIdStr))
621- let userLpBoostEmissionLastIntegralKEY = keyUserLpBoostEmissionLastINTEGRAL(userNum, lpAssetIdStr)
622- let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum)
623- let userBoostEmissionLastIntegral = valueOrElse(getInteger(this, userLpBoostEmissionLastIntegralKEY), getIntOrZero(this, userBoostEmissionLastIntegralKEY))
637+ let userLpBoostEmissionLastIntegralKEY = keyUserLpBoostEmissionLastINTEGRAL(userNumStr, lpAssetIdStr)
638+ let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr)
639+ let userBoostEmissionLastIntegral = valueOrElse(getInteger(this, userLpBoostEmissionLastIntegralKEY), ioz(this, userBoostEmissionLastIntegralKEY))
624640 let boostEmissionIntegral = refreshBoostEmissionIntegral()._2
625641 let userBoostEmissionIntegral = (boostEmissionIntegral - userBoostEmissionLastIntegral)
626642 if ((0 > userBoostEmissionIntegral))
627643 then throwErr("wrong calculations")
628644 else {
629- let $t02384323982 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr)
630- let stakedVotesIntegralsActions = $t02384323982._1
631- let userVoteIntegralDiff = $t02384323982._2
632- let totalVotesIntegralDiff = $t02384323982._3
645+ let $t02642026559 = getStakedVotesIntegralsDiff(lpAssetIdStr, userAddressStr)
646+ let stakedVotesIntegralsActions = $t02642026559._1
647+ let userVoteIntegralDiff = $t02642026559._2
648+ let totalVotesIntegralDiff = $t02642026559._3
633649 let poolUserBoostEmissionIntegral = fraction(userBoostEmissionIntegral, poolWeight, POOLWEIGHTMULT)
634650 let userBoostAvaliableToClaimTotalNew = if ((totalVotesIntegralDiff == 0))
635651 then 0
636652 else fraction(poolUserBoostEmissionIntegral, userVoteIntegralDiff, totalVotesIntegralDiff)
637653 let dataState = ([IntegerEntry(userLpBoostEmissionLastIntegralKEY, boostEmissionIntegral)] ++ stakedVotesIntegralsActions)
638654 let debug = makeString([toString(userBoostEmissionLastIntegral), toString(userBoostEmissionIntegral), toString(poolWeight), toString(userVoteIntegralDiff), toString(totalVotesIntegralDiff)], ":")
639655 $Tuple3(userBoostAvaliableToClaimTotalNew, dataState, debug)
640656 }
641657 }
642- else throw("Strict value is not equal to itself.")
643658 }
644659
645660
646661 func lockActions (i,duration) = {
647- let assetIdStr = toBase58String(assetId)
662+ let cfgArray = readConfigArrayOrFail()
663+ let assetIdStr = cfgArray[IdxCfgAssetId]
664+ let assetId = fromBase58String(assetIdStr)
665+ let minLockAmount = parseIntValue(cfgArray[IdxCfgMinLockAmount])
666+ let minLockDuration = parseIntValue(cfgArray[IdxCfgMinLockDuration])
667+ let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration])
648668 if ((size(i.payments) != 1))
649669 then throwErr("invalid payment - exact one payment must be attached")
650670 else {
651671 let pmt = i.payments[0]
652672 let pmtAmount = pmt.amount
653673 if ((assetId != value(pmt.assetId)))
654674 then throwErr((("invalid asset is in payment - " + assetIdStr) + " is expected"))
655675 else {
656676 let nextUserNumKEY = keyNextUserNum()
657- let userAddress = i.caller
658- let userAddressStr = toString(userAddress)
677+ let userAddressStr = toString(i.caller)
659678 let userIsExisting = isDefined(getString(keyUser2NumMapping(userAddressStr)))
660679 let userNumStr = if (userIsExisting)
661680 then value(getString(keyUser2NumMapping(userAddressStr)))
662- else toString(getIntOrFail(this, nextUserNumKEY))
681+ else toString(iof(this, nextUserNumKEY))
663682 let userNum = parseIntValue(userNumStr)
664683 let lockStart = height
684+ let startBlockKEY = keyLockParamStartBlock(userNumStr)
685+ let durationKEY = keyLockParamDuration(userNumStr)
686+ let userAmountKEY = keyLockParamUserAmount(userNumStr)
665687 if (if ((minLockAmount > pmtAmount))
666- then (userAddress != lpStakingPoolsContract)
688+ then (i.caller != lpStakingPoolsContract)
667689 else false)
668690 then throwErr(("amount is less then minLockAmount=" + toString(minLockAmount)))
669691 else if ((minLockDuration > duration))
670- then throwErr(("passed duration is less than minLockDuration=" + toString(minLockDuration)))
692+ then throwErr(("passed duration is less then minLockDuration=" + toString(minLockDuration)))
671693 else if ((duration > maxLockDuration))
672- then throwErr(("passed duration is greater than maxLockDuration=" + toString(maxLockDuration)))
673- else if (((duration % lockStepBlocks) != 0))
674- then throwErr(("duration must be multiple of lockStepBlocks=" + toString(lockStepBlocks)))
675- else {
676- let gWxAmountStart = fraction(pmtAmount, duration, maxLockDuration)
677- let gwxAmountTotal = getGwxAmountTotal()
678- let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNum)
679- let boostEmissionIntegral = refreshBoostEmissionIntegral()._2
680- let userGwxAmountTotal = getUserGwxAmountTotal(userAddress)
681- let gwxRewardInv = invoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes, userNum], nil)
682- if ((gwxRewardInv == gwxRewardInv))
683- then {
684- let arr = if (userIsExisting)
685- then nil
686- else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)]
687- $Tuple2(((((arr ++ LockParamsEntry(userAddress, i.transactionId, pmtAmount, lockStart, duration, gWxAmountStart, 0)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting)
688- then 0
689- else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, gWxAmountStart, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyGwxTotal(), (gwxAmountTotal + gWxAmountStart)), IntegerEntry(keyUserGwxAmountTotal(userAddress), (userGwxAmountTotal + gWxAmountStart))]), gWxAmountStart)
690- }
691- else throw("Strict value is not equal to itself.")
692- }
694+ then throwErr(("passed duration is greater then maxLockDuration=" + toString(maxLockDuration)))
695+ else if (if (userIsExisting)
696+ then ((iof(this, startBlockKEY) + iof(this, durationKEY)) >= lockStart)
697+ else false)
698+ then throwErr("there is an active lock - consider to use increaseLock")
699+ else if ((ioz(this, userAmountKEY) > 0))
700+ then throwErr(("there are locked WXs - consider to use increaseLock " + userAmountKEY))
701+ else {
702+ let coeffX8 = fraction(duration, MULT8, maxLockDuration)
703+ let gWxAmountStart = fraction(pmtAmount, coeffX8, MULT8)
704+ let gWxParamsResultList = aal(invoke(mathContract, "calcGwxParamsREADONLY", [gWxAmountStart, lockStart, duration], nil))
705+ let k = ai(gWxParamsResultList[0])
706+ let b = ai(gWxParamsResultList[1])
707+ let period = toString(ai(gWxParamsResultList[2]))
708+ let totalCachedGwxRaw = getTotalCachedGwx(false)
709+ let userBoostEmissionLastIntegralKEY = keyUserBoostEmissionLastINTEGRAL(userNumStr)
710+ let boostEmissionIntegral = refreshBoostEmissionIntegral()._2
711+ let arr = if (userIsExisting)
712+ then nil
713+ else [IntegerEntry(nextUserNumKEY, (userNum + 1)), StringEntry(keyUser2NumMapping(userAddressStr), userNumStr), StringEntry(keyNum2UserMapping(userNumStr), userAddressStr)]
714+ $Tuple2(((((arr ++ LockParamsEntry(userAddressStr, userNumStr, pmtAmount, lockStart, duration, k, b, period)) ++ StatsEntry(pmtAmount, duration, 1, if (userIsExisting)
715+ then 0
716+ else 1)) :+ HistoryEntry("lock", userAddressStr, pmtAmount, lockStart, duration, k, b, i)) ++ [IntegerEntry(userBoostEmissionLastIntegralKEY, boostEmissionIntegral), IntegerEntry(keyTotalCachedGwx(), (totalCachedGwxRaw + gWxAmountStart))]), gWxAmountStart)
717+ }
693718 }
694719 }
695720 }
696721
697722
698-func getWxWithdrawable (userAddress,txIdOption) = {
699- let userRecordArray = readLockParamsRecordOrFail(userAddress, txIdOption)
700- let userAmount = parseIntValue(userRecordArray[IdxLockAmount])
701- let lockStart = parseIntValue(userRecordArray[IdxLockStart])
702- let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
703- let lockEnd = (lockStart + lockDuration)
704- let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed])
705- let t = ((height - lockStart) / blocksInPeriod)
706- let exponent = fraction(toBigInt(t), (toBigInt((DECAY_CONSTANT * blocksInPeriod)) * MULT18BI), toBigInt(lockDuration))
707- let wxWithdrawableTotal = if ((height > lockEnd))
708- then userAmount
709- else toInt(fraction(toBigInt(userAmount), (MULT18BI - pow(toBigInt(5), 1, exponent, SCALE18, SCALE18, DOWN)), MULT18BI))
710- let wxWithdrawable = (wxWithdrawableTotal - wxClaimed)
711- wxWithdrawable
712- }
713-
714-
715723 @Callable(i)
716-func lockRef (duration,referrerAddress,signature) = {
717- let suspensionCheck = throwIfSuspended()
718- if ((suspensionCheck == suspensionCheck))
719- then {
720- let $t02840028465 = lockActions(i, duration)
721- let lockActionsResult = $t02840028465._1
722- let gWxAmountStart = $t02840028465._2
723- let referralAddress = toString(i.caller)
724- let refInv = if (if ((referrerAddress == ""))
725- then true
726- else (signature == base58''))
727- then unit
728- else invoke(referralsContractAddressOrFail, "createPair", [referralProgramName, referrerAddress, referralAddress, signature], nil)
729- if ((refInv == refInv))
730- then {
731- let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil)
732- if ((updateRefActivity == updateRefActivity))
733- then $Tuple2(lockActionsResult, unit)
734- else throw("Strict value is not equal to itself.")
735- }
736- else throw("Strict value is not equal to itself.")
737- }
724+func constructor (factoryAddressStr,lockAssetIdStr,minLockAmount,minDuration,maxDuration,mathContract) = {
725+ let checkCaller = mustManager(i)
726+ if ((checkCaller == checkCaller))
727+ then ([IntegerEntry(keyNextUserNum(), 0), StringEntry(keyConfig(), formatConfig(lockAssetIdStr, minLockAmount, minDuration, maxDuration, mathContract)), StringEntry(keyFactoryAddress(), factoryAddressStr)] ++ StatsEntry(0, 0, 0, 0))
738728 else throw("Strict value is not equal to itself.")
739729 }
740730
741731
742732
743733 @Callable(i)
744-func lock (duration) = {
745- let suspensionCheck = throwIfSuspended()
746- if ((suspensionCheck == suspensionCheck))
734+func lockRef (duration,referrerAddress,signature) = {
735+ let $t03117031235 = lockActions(i, duration)
736+ let lockActionsResult = $t03117031235._1
737+ let gWxAmountStart = $t03117031235._2
738+ let referralAddress = toString(i.caller)
739+ let refInv = if (if ((referrerAddress == ""))
740+ then true
741+ else (signature == base58''))
742+ then unit
743+ else invoke(referralsContractAddressOrFail, "createPair", [referralProgramName, referrerAddress, referralAddress, signature], nil)
744+ if ((refInv == refInv))
747745 then {
748- let $t02896929034 = lockActions(i, duration)
749- let lockActionsResult = $t02896929034._1
750- let gWxAmountStart = $t02896929034._2
751746 let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil)
752747 if ((updateRefActivity == updateRefActivity))
753748 then $Tuple2(lockActionsResult, unit)
754749 else throw("Strict value is not equal to itself.")
755750 }
756751 else throw("Strict value is not equal to itself.")
757752 }
758753
759754
760755
761756 @Callable(i)
762-func claimWxBoost (lpAssetIdStr,userAddressStr) = {
763- let suspensionCheck = throwIfSuspended()
764- if ((suspensionCheck == suspensionCheck))
765- then if ((stakingContract != i.caller))
766- then throwErr("permissions denied")
767- else {
768- let $t02939029492 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false)
769- let userBoostAvailable = $t02939029492._1
770- let dataState = $t02939029492._2
771- let debug = $t02939029492._3
772- $Tuple2(dataState, [userBoostAvailable])
773- }
757+func lock (duration) = {
758+ let $t03169331758 = lockActions(i, duration)
759+ let lockActionsResult = $t03169331758._1
760+ let gWxAmountStart = $t03169331758._2
761+ let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil)
762+ if ((updateRefActivity == updateRefActivity))
763+ then $Tuple2(lockActionsResult, unit)
774764 else throw("Strict value is not equal to itself.")
775765 }
776766
777767
778768
779769 @Callable(i)
770+func increaseLock (deltaDuration) = {
771+ let cfgArray = readConfigArrayOrFail()
772+ let assetIdStr = cfgArray[IdxCfgAssetId]
773+ let assetId = fromBase58String(assetIdStr)
774+ let minLockDuration = parseIntValue(cfgArray[IdxCfgMinLockDuration])
775+ let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration])
776+ let pmtAmount = extractOptionalPaymentAmountOrFail(i, assetId)
777+ let userAddressStr = toString(i.caller)
778+ let userRecordArray = readLockParamsRecordOrFail(userAddressStr)
779+ let userNumStr = userRecordArray[IdxLockUserNum]
780+ let userAmount = parseIntValue(userRecordArray[IdxLockAmount])
781+ let lockStart = parseIntValue(userRecordArray[IdxLockStart])
782+ let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
783+ let lockEnd = (lockStart + lockDuration)
784+ let remainingDuration = max([(lockEnd - height), 0])
785+ let userAmountNew = (userAmount + pmtAmount)
786+ let lockDurationNew = (remainingDuration + deltaDuration)
787+ if ((0 > deltaDuration))
788+ then throwErr("duration is less then zero")
789+ else if ((minLockDuration > lockDurationNew))
790+ then throwErr(("lockDurationNew is less then minLockDuration=" + toString(minLockDuration)))
791+ else if ((lockDurationNew > maxLockDuration))
792+ then throwErr(("deltaDuration + existedLockDuration is greater then maxLockDuration=" + toString(maxLockDuration)))
793+ else {
794+ let coeffX8 = fraction(lockDurationNew, MULT8, maxLockDuration)
795+ let gWxAmountStart = fraction(userAmountNew, coeffX8, MULT8)
796+ let updateRefActivity = invoke(mathContract, "updateReferralActivity", [toString(i.caller), gWxAmountStart], nil)
797+ if ((updateRefActivity == updateRefActivity))
798+ then {
799+ let lockStartNew = height
800+ let gWxParamsResultList = aal(invoke(mathContract, "calcGwxParamsREADONLY", [gWxAmountStart, lockStartNew, lockDurationNew], nil))
801+ let k = ai(gWxParamsResultList[0])
802+ let b = ai(gWxParamsResultList[1])
803+ let period = toString(ai(gWxParamsResultList[2]))
804+ let currUserGwx = calcCurrentGwxAmount(userAddressStr)
805+ let gwxDiff = (gWxAmountStart - currUserGwx)
806+ if ((0 > gwxDiff))
807+ then throwErr(("gwxDiff is less then 0: " + toString(gwxDiff)))
808+ else {
809+ let totalCachedGwxRaw = getTotalCachedGwx(false)
810+ let totalCachedGwxCorrected = getTotalCachedGwx(true)
811+ (((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))])
812+ }
813+ }
814+ else throw("Strict value is not equal to itself.")
815+ }
816+ }
817+
818+
819+
820+@Callable(i)
821+func claimWxBoost (lpAssetIdStr,userAddressStr) = if ((stakingContract != i.caller))
822+ then throwErr("permissions denied")
823+ else {
824+ let $t03486334965 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, false)
825+ let userBoostAvailable = $t03486334965._1
826+ let dataState = $t03486334965._2
827+ let debug = $t03486334965._3
828+ $Tuple2(dataState, [userBoostAvailable])
829+ }
830+
831+
832+
833+@Callable(i)
780834 func claimWxBoostREADONLY (lpAssetIdStr,userAddressStr) = {
781- let $t02962429725 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true)
782- let userBoostAvailable = $t02962429725._1
783- let dataState = $t02962429725._2
784- let debug = $t02962429725._3
835+ let $t03509735198 = internalClaimWxBoost(lpAssetIdStr, userAddressStr, true)
836+ let userBoostAvailable = $t03509735198._1
837+ let dataState = $t03509735198._2
838+ let debug = $t03509735198._3
785839 $Tuple2(nil, [userBoostAvailable, debug])
786840 }
787841
788842
789843
790844 @Callable(i)
791-func unlock (txIdStr) = {
792- let suspensionCheck = throwIfSuspended()
793- if ((suspensionCheck == suspensionCheck))
794- then {
795- let userAddress = i.caller
796- let userAddressStr = toString(userAddress)
797- let txIdOption = if ((txIdStr == ""))
798- then unit
799- else fromBase58String(txIdStr)
800- let userRecordArray = readLockParamsRecordOrFail(userAddress, txIdOption)
801- let userAmount = parseIntValue(userRecordArray[IdxLockAmount])
802- let lockStart = parseIntValue(userRecordArray[IdxLockStart])
803- let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
804- let wxClaimed = parseIntValue(userRecordArray[IdxLockWxClaimed])
805- let gwxAmount = parseIntValue(userRecordArray[IdxLockGwxAmount])
806- let t = ((height - lockStart) / blocksInPeriod)
807- let wxWithdrawable = getWxWithdrawable(userAddress, txIdOption)
808- let gwxBurned = min([fraction(wxWithdrawable, lockDuration, maxLockDuration), gwxAmount])
809- let gwxRemaining = ensurePositive((gwxAmount - gwxBurned), "gwxRemaining")
810- let lockedGwxAmount = getLockedGwxAmount(userAddress)
811- if ((0 >= wxWithdrawable))
812- then throwErr("nothing to unlock")
813- else {
814- let gwxAmountTotal = getGwxAmountTotal()
815- let userGwxAmountTotal = getUserGwxAmountTotal(userAddress)
816- let userGwxAmountTotalNew = ensurePositive((userGwxAmountTotal - gwxBurned), "userGwxAmountTotalNew")
817- if ((lockedGwxAmount > userGwxAmountTotalNew))
818- then throwErr(("locked gwx amount: " + toString(lockedGwxAmount)))
819- else {
820- let userNum = parseIntValue(valueOrErrorMessage(getString(keyUser2NumMapping(userAddressStr)), wrapErr("invalid user number")))
821- let gwxRewardInv = invoke(gwxRewardContract, "refreshUserReward", [userAddress.bytes, userNum], nil)
822- if ((gwxRewardInv == gwxRewardInv))
823- then ((((LockParamsEntry(userAddress, txIdOption, userAmount, lockStart, lockDuration, gwxRemaining, (wxClaimed + wxWithdrawable)) ++ StatsEntry(-(wxWithdrawable), 0, 0, 0)) :+ HistoryEntry("unlock", userAddressStr, wxWithdrawable, lockStart, lockDuration, gwxBurned, i)) :+ ScriptTransfer(userAddress, wxWithdrawable, assetId)) ++ [IntegerEntry(keyGwxTotal(), ensurePositive((gwxAmountTotal - gwxBurned), "gwxTotal")), IntegerEntry(keyUserGwxAmountTotal(userAddress), userGwxAmountTotalNew)])
824- else throw("Strict value is not equal to itself.")
825- }
826- }
827- }
828- else throw("Strict value is not equal to itself.")
845+func unlock (userAddress) = {
846+ let userRecordArray = readLockParamsRecordOrFail(userAddress)
847+ let userNumStr = userRecordArray[IdxLockUserNum]
848+ let userAmount = parseIntValue(userRecordArray[IdxLockAmount])
849+ let lockStart = parseIntValue(userRecordArray[IdxLockStart])
850+ let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
851+ let lockEnd = (lockStart + lockDuration)
852+ let cfgArray = readConfigArrayOrFail()
853+ let assetId = fromBase58String(cfgArray[IdxCfgAssetId])
854+ if ((lockEnd >= height))
855+ then throwErr((("wait " + toString(lockEnd)) + " to unlock"))
856+ else if ((0 >= userAmount))
857+ then throwErr("nothing to unlock")
858+ else {
859+ let period = valueOrElse(getInteger(mathContract, keyNextPeriod()), 0)
860+ (((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))
861+ }
829862 }
830863
831864
832865
833866 @Callable(i)
834-func gwxUserInfoREADONLY (userAddressStr) = {
835- let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
836- let gwxAmount = getUserGwxAmountTotal(userAddress)
867+func gwxUserInfoREADONLY (userAddress) = {
868+ let gwxAmount = calcCurrentGwxAmount(userAddress)
837869 $Tuple2(nil, [gwxAmount])
838870 }
839871
840872
841873
842874 @Callable(i)
843-func userMaxDurationREADONLY (userAddressStr) = $Tuple2(nil, $Tuple2("lock", maxLockDuration))
875+func userMaxDurationREADONLY (userAddressStr) = {
876+ let cfgArray = readConfigArrayOrFail()
877+ let maxLockDuration = parseIntValue(cfgArray[IdxCfgMaxLockDuration])
878+ let userRecordOption = getString(this, keyLockParamsRecord(userAddressStr))
879+ if ((userRecordOption == unit))
880+ then $Tuple2(nil, $Tuple2("lock", maxLockDuration))
881+ else {
882+ let userRecordArray = split(value(userRecordOption), SEP)
883+ let lockStart = parseIntValue(userRecordArray[IdxLockStart])
884+ let lockDuration = parseIntValue(userRecordArray[IdxLockDuration])
885+ let lockEnd = (lockStart + lockDuration)
886+ let remainingDuration = max([(lockEnd - height), 0])
887+ let maxDeltaDuration = (maxLockDuration - remainingDuration)
888+ $Tuple2(nil, $Tuple2("increaseLock", maxDeltaDuration))
889+ }
890+ }
844891
845892
846893
847894 @Callable(i)
848-func getUserGwxAmountAtHeightREADONLY (userAddressStr,targetHeight) = {
849- let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
850- let gwxAmount = getUserGwxAmountTotal(userAddress)
895+func getUserGwxAmountAtHeightREADONLY (userAddress,targetHeight) = {
896+ let gwxAmount = calcUserGwxAmountAtHeight(userAddress, targetHeight)
851897 $Tuple2(nil, gwxAmount)
852898 }
853899
854900
855901
856902 @Callable(i)
857-func getUserGwxAmount (userAddressStr) = {
858- let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address"))
859- let gwxAmount = getUserGwxAmountTotal(userAddress)
860- $Tuple2(nil, gwxAmount)
861- }
862-
863-
864-
865-@Callable(i)
866-func getGwxTotalREADONLY () = $Tuple2(nil, getGwxAmountTotal())
903+func getTotalCachedGwxREADONLY () = $Tuple2(nil, getTotalCachedGwx(true))
867904
868905
869906
870907 @Callable(i)
871908 func onBoostEmissionUpdate () = {
872- let suspensionCheck = throwIfSuspended()
873- if ((suspensionCheck == suspensionCheck))
874- then {
875- let checkCaller = if ((i.caller == emissionContract))
876- then true
877- else mustManager(i)
878- if ((checkCaller == checkCaller))
879- then refreshBoostEmissionIntegral()
880- else throw("Strict value is not equal to itself.")
881- }
909+ let checkCaller = if ((i.caller == emissionContract))
910+ then true
911+ else mustManager(i)
912+ if ((checkCaller == checkCaller))
913+ then refreshBoostEmissionIntegral()
882914 else throw("Strict value is not equal to itself.")
883915 }
884916
885917
886918
887919 @Callable(i)
888920 func onStakedVoteUpdate (lpAssetIdStr,userAddressStr,edge) = {
889- let suspensionCheck = throwIfSuspended()
890- if ((suspensionCheck == suspensionCheck))
921+ let checkCaller = if ((i.caller == stakingContract))
922+ then true
923+ else mustManager(i)
924+ if ((checkCaller == checkCaller))
891925 then {
892- let checkCaller = if ((i.caller == stakingContract))
893- then true
894- else mustManager(i)
895- if ((checkCaller == checkCaller))
896- then {
897- let actions = refreshVoteStakedIntegral(lpAssetIdStr, userAddressStr, edge)
898- $Tuple2(actions, unit)
899- }
900- else throw("Strict value is not equal to itself.")
926+ let actions = refreshVoteStakedIntegral(lpAssetIdStr, userAddressStr, edge)
927+ $Tuple2(actions, unit)
901928 }
902929 else throw("Strict value is not equal to itself.")
903930 }
904931
905932
906933
907934 @Callable(i)
908935 func getVotingResultStakedREADONLY (lpAssetIdStr) = $Tuple2(nil, getVotingResultStaked(lpAssetIdStr))
909936
910937
911938
912939 @Callable(i)
913940 func getVotingResultStakedIntegralREADONLY (lpAssetIdStr) = $Tuple2(nil, getVotingResultStakedIntegral(lpAssetIdStr))
914941
915942
916943
917944 @Callable(i)
918945 func getUserVoteFinalizedREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteFinalized(lpAssetIdStr, userAddressStr))
919946
920947
921948
922949 @Callable(i)
923950 func getUserVoteStakedIntegralREADONLY (lpAssetIdStr,userAddressStr) = $Tuple2(nil, getUserVoteStakedIntegral(lpAssetIdStr, userAddressStr))
924951
925952
926-
927-@Callable(i)
928-func suspend (v) = {
929- let checkCaller = mustManager(i)
930- if ((checkCaller == checkCaller))
931- then $Tuple2([BooleanEntry(keySuspension, v)], v)
932- else throw("Strict value is not equal to itself.")
933- }
934-
935-
936953 @Verifier(tx)
937954 func verify () = {
938955 let targetPublicKey = match managerPublicKeyOrUnit() {
939956 case pk: ByteVector =>
940957 pk
941958 case _: Unit =>
942959 tx.senderPublicKey
943960 case _ =>
944961 throw("Match error")
945962 }
946963 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
947964 }
948965

github/deemru/w8io/026f985 
154.95 ms