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