tx · 3Fk2KfwHLRibW9g4DvSGvAHjtHiaGeD1x3jBGN91vo8b 3N2M4PztorHwrfENp7D6LhYGgGodjiD1fjn: -0.02300000 Waves 2023.08.24 15:26 [2724717] smart account 3N2M4PztorHwrfENp7D6LhYGgGodjiD1fjn > SELF 0.00000000 Waves
{ "type": 13, "id": "3Fk2KfwHLRibW9g4DvSGvAHjtHiaGeD1x3jBGN91vo8b", "fee": 2300000, "feeAssetId": null, "timestamp": 1692879966827, "version": 2, "chainId": 84, "sender": "3N2M4PztorHwrfENp7D6LhYGgGodjiD1fjn", "senderPublicKey": "Fj9LPkCtmW3pDnVU6wPQnvqpZJCBieWSvZqY5FAGeCyp", "proofs": [ "4tvCrdM4PVJ8vixBPWnSyBSBqvNDwxHiUWN3527eda41L4dfuk4oRoEc1BZrqfLni4dX6LnyNfQwhM7kAhJExaZW", "2QDytcJo1kvmyWFsAFpAN3wKcPeEeGLA4TV1eqaP3ZP7R8jbaf5CAeq1EMcdanCCzviuxt6LUmynjbS1XYpysGTS" ], "script": "base64:BgIhCAISABIAEgQKAggIEgMKAQgSBwoFCAgIAQESAwoBCBIAUQAGU0NBTEU4AIDC1y8AC0xFTkRFUlNfQVBSCQDMCAIAlgEJAMwIAgB4CQDMCAIAZAkAzAgCAFAJAMwIAgA8CQDMCAIAKAkAzAgCAB4JAMwIAgAUCQDMCAIACgUDbmlsABNMRU5ERVJTX0FQUl9QRVJJT0RTCQDMCAICAzEtMQkAzAgCAgMyLTIJAMwIAgIDMy0zCQDMCAICAzQtNAkAzAgCAgM1LTgJAMwIAgIEOS0xMgkAzAgCAgcxNCAtIDE2CQDMCAICBTE3LTIwCQDMCAICBjIwLTEwNAUDbmlsABNMRU5ERVJTX01BWF9QRVJJT0RTAGgABkxQX0FQUgkAzAgCAJYBCQDMCAIAeAkAzAgCAGQJAMwIAgBQCQDMCAIAPAkAzAgCACgFA25pbAAOTFBfQVBSX1BFUklPRFMJAMwIAgIDMS0xCQDMCAICAzItMgkAzAgCA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nRIZWlnaHQJAMwIAgUGaGVpZ2h0BQNuaWwBAnR4AQZ2ZXJpZnkABBNtdWx0aVNpZ25lZEJ5QWRtaW5zBBJhZG1pblB1YktleTFTaWduZWQDCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQhhZG1pbjFQSwABAAAEEmFkbWluUHViS2V5MlNpZ25lZAMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAEFCGFkbWluMlBLAAEAAAQSYWRtaW5QdWJLZXkzU2lnbmVkAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAgUIYWRtaW4zUEsAAQAACQBnAgkAZAIJAGQCBRJhZG1pblB1YktleTFTaWduZWQFEmFkbWluUHViS2V5MlNpZ25lZAUSYWRtaW5QdWJLZXkzU2lnbmVkAAIEByRtYXRjaDAFAnR4AwkAAQIFByRtYXRjaDACF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBANpbnYFByRtYXRjaDAEBmlzU2VsZgkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleQQKaXNSaWdodEZlZQMJAAACCAUDaW52A2ZlZQCg9zYJAAACCAUDaW52CmZlZUFzc2V0SWQFBHVuaXQHBAppc0luaXRDYWxsCQAAAggFA2ludghmdW5jdGlvbgIEaW5pdAQMaXNub1BheW1lbnRzCQAAAgkAkAMBCAUDaW52CHBheW1lbnRzAAADAwMDBQppc1JpZ2h0RmVlBQppc0luaXRDYWxsBwUGaXNTZWxmBwUMaXNub1BheW1lbnRzBwYFE211bHRpU2lnbmVkQnlBZG1pbnMFE211bHRpU2lnbmVkQnlBZG1pbnPjznVf", "height": 2724717, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GpxJnAjmHNE1LqjAupRpKFsGEheKm3N5bkM7NLr3SeM7 Next: 2dh898hSMEeoAvR25DE53RCGXkHrz6yz86qyw8fANhKh Diff:
Old | New | Differences | |
---|---|---|---|
5 | 5 | ||
6 | 6 | let LENDERS_APR = [150, 120, 100, 80, 60, 40, 30, 20, 10] | |
7 | 7 | ||
8 | - | let LENDERS_APR_PERIODS = ["1-1", "2-2", "3-3", "4-4", "5-8", "9-12", "14 | |
8 | + | let LENDERS_APR_PERIODS = ["1-1", "2-2", "3-3", "4-4", "5-8", "9-12", "14 - 16", "17-20", "20-104"] | |
9 | 9 | ||
10 | 10 | let LENDERS_MAX_PERIODS = 104 | |
11 | 11 | ||
33 | 33 | ||
34 | 34 | let kTokenRewardPerBlock = "_tokenRewardPerBlock" | |
35 | 35 | ||
36 | - | let | |
36 | + | let kRewardUpdateHeight = "rewardUpdateHeight" | |
37 | 37 | ||
38 | 38 | let kUserLendInterest = "_userLandInterest" | |
39 | 39 | ||
115 | 115 | ||
116 | 116 | let periodLength = getIntegerValue(this, kPeriodLength) | |
117 | 117 | ||
118 | + | let curPeriod = ((height - startHeight) / periodLength) | |
119 | + | ||
118 | 120 | let lendMaxAmount = getIntegerValue(tokenContract, kLendersMaxAmount) | |
119 | 121 | ||
120 | 122 | let lendMaxPeriodAmount = (lendMaxAmount / LENDERS_MAX_PERIODS) | |
174 | 176 | ||
175 | 177 | func getAdoptedAPRByPeriod (period,aprPeriods,apr) = { | |
176 | 178 | func for (a,aperiod) = { | |
177 | - | let $ | |
178 | - | let index = $ | |
179 | - | let found = $ | |
179 | + | let $t054205442 = a | |
180 | + | let index = $t054205442._1 | |
181 | + | let found = $t054205442._2 | |
180 | 182 | let ft = split(aperiod, "-") | |
181 | - | let $ | |
182 | - | let from = $ | |
183 | - | let to = $ | |
183 | + | let $t054795542 = $Tuple2(parseIntValue(ft[0]), parseIntValue(ft[1])) | |
184 | + | let from = $t054795542._1 | |
185 | + | let to = $t054795542._2 | |
184 | 186 | if (found) | |
185 | 187 | then a | |
186 | 188 | else if (if ((period >= from)) | |
190 | 192 | else $Tuple2((index + 1), false) | |
191 | 193 | } | |
192 | 194 | ||
193 | - | let $ | |
195 | + | let $t056795745 = { | |
194 | 196 | let $l = LENDERS_APR_PERIODS | |
195 | 197 | let $s = size($l) | |
196 | 198 | let $acc0 = $Tuple2(0, false) | |
204 | 206 | ||
205 | 207 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9) | |
206 | 208 | } | |
207 | - | let index = $ | |
208 | - | let found = $ | |
209 | + | let index = $t056795745._1 | |
210 | + | let found = $t056795745._2 | |
209 | 211 | if (found) | |
210 | 212 | then fraction((LENDERS_APR[index] * SCALE8), 7, 365) | |
211 | 213 | else 0 | |
214 | 216 | ||
215 | 217 | func getTotalSupplyAllTokens () = { | |
216 | 218 | func for (a,tokenId) = { | |
217 | - | let $ | |
218 | - | let totalSupply = $ | |
219 | - | let totalSupplyUsd = $ | |
220 | - | let totalSupplyUsdAll = $ | |
219 | + | let $t059335989 = a | |
220 | + | let totalSupply = $t059335989._1 | |
221 | + | let totalSupplyUsd = $t059335989._2 | |
222 | + | let totalSupplyUsdAll = $t059335989._3 | |
221 | 223 | let tSupply = valueOrElse(getInteger(lendContract, (kLendTokenSupply + tokenId)), 0) | |
222 | 224 | let assetPrice = getAssetPrice(tokenId) | |
223 | 225 | let assetPrecision = getAssetPrecision(tokenId) | |
248 | 250 | } | |
249 | 251 | ||
250 | 252 | ||
251 | - | func calcNewTokenInterest (tokenId,totalSupply) = if (( | |
253 | + | func calcNewTokenInterest (tokenId,totalSupply) = if ((height >= startHeight)) | |
252 | 254 | then 0 | |
253 | 255 | else { | |
254 | 256 | let rewardPerBlock = getIntegerValue(this, (tokenId + kTokenRewardPerBlock)) | |
262 | 264 | } | |
263 | 265 | ||
264 | 266 | ||
265 | - | func calcNewLpInterest (totalSupply) = if (( | |
267 | + | func calcNewLpInterest (totalSupply) = if ((height >= startHeight)) | |
266 | 268 | then 0 | |
267 | 269 | else { | |
268 | 270 | let rewardPerBlock = valueOrElse(getInteger(this, kLpRewardPerBlock), 0) | |
291 | 293 | func calcLpUserReward (user) = { | |
292 | 294 | let totalSupply = valueOrElse(getInteger(sfFarmingContract, (axlyPool + kSFTotalSupply)), 0) | |
293 | 295 | let tokenInterest = calcNewLpInterest(totalSupply) | |
294 | - | let userSupply = valueOrElse(getInteger( | |
296 | + | let userSupply = valueOrElse(getInteger(lendContract, (((axlyPool + "_") + user) + kSFUserTotalSupply)), 0) | |
295 | 297 | let userTokenInterest = valueOrElse(getInteger(this, (user + kUserLpInterest)), if ((userSupply == 0)) | |
296 | 298 | then tokenInterest | |
297 | 299 | else 0) | |
302 | 304 | ||
303 | 305 | func claimLenderRewardsCommon (user,readOnly) = { | |
304 | 306 | func claim (a,tokenId) = { | |
305 | - | let $ | |
306 | - | let tokenIds = $ | |
307 | - | let cAmount = $ | |
308 | - | let total = $ | |
309 | - | let enteries = $ | |
307 | + | let $t088738917 = a | |
308 | + | let tokenIds = $t088738917._1 | |
309 | + | let cAmount = $t088738917._2 | |
310 | + | let total = $t088738917._3 | |
311 | + | let enteries = $t088738917._4 | |
310 | 312 | let userAvailableClaim = valueOrElse(getInteger(this, (((tokenId + "_") + user) + kUserLendAvailableClaim)), 0) | |
311 | - | let $ | |
312 | - | let uReward = $ | |
313 | - | let newTokenInterest = $ | |
314 | - | let userSupply = $ | |
313 | + | let $t090309109 = calcLendUserReward(user, tokenId) | |
314 | + | let uReward = $t090309109._1 | |
315 | + | let newTokenInterest = $t090309109._2 | |
316 | + | let userSupply = $t090309109._3 | |
315 | 317 | let totalToClaim = (userAvailableClaim + uReward) | |
316 | 318 | if (if ((totalToClaim > 0)) | |
317 | 319 | then true | |
344 | 346 | ||
345 | 347 | func claimLpRewardsCommon (user,readOnly) = { | |
346 | 348 | let userAvailableClaim = valueOrElse(getInteger(this, (user + kUserLpAvailableClaim)), 0) | |
347 | - | let $ | |
348 | - | let uReward = $ | |
349 | - | let newLpInterest = $ | |
350 | - | let userSupply = $ | |
349 | + | let $t01004110106 = calcLpUserReward(user) | |
350 | + | let uReward = $t01004110106._1 | |
351 | + | let newLpInterest = $t01004110106._2 | |
352 | + | let userSupply = $t01004110106._3 | |
351 | 353 | let totalToClaim = (userAvailableClaim + uReward) | |
352 | 354 | if (if (readOnly) | |
353 | 355 | then true | |
386 | 388 | let lpId = getStringValue(addressFromStringValue(axlyPool), kLpId) | |
387 | 389 | let lpPrecision = getAssetPrecision(lpId) | |
388 | 390 | let lpPrice = { | |
389 | - | let @ = invoke(mainContract, "getShareAssetPriceREADONLY", [lpId], nil) | |
391 | + | let @ = ({ | |
392 | + | let @ = invoke(mainContract, "getShareAssetPriceREADONLY", [[lpId]], nil) | |
393 | + | if ($isInstanceOf(@, "List[Any]")) | |
394 | + | then @ | |
395 | + | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
396 | + | })[0] | |
390 | 397 | if ($isInstanceOf(@, "Int")) | |
391 | 398 | then @ | |
392 | 399 | else throw(($getType(@) + " couldn't be cast to Int")) | |
433 | 440 | @Callable(i) | |
434 | 441 | func lendAction (user,tokenId) = valueOrElse(isLandCall(i), { | |
435 | 442 | let userAvailableClaim = valueOrElse(getInteger(this, (tokenId + kUserLendAvailableClaim)), 0) | |
436 | - | let $ | |
437 | - | let uReward = $ | |
438 | - | let newTokenInterest = $ | |
439 | - | [IntegerEntry(((( | |
443 | + | let $t01247712544 = calcLendUserReward(user, tokenId) | |
444 | + | let uReward = $t01247712544._1 | |
445 | + | let newTokenInterest = $t01247712544._2 | |
446 | + | [IntegerEntry((((tokenId + "_") + user) + kUserLendInterest), newTokenInterest), IntegerEntry((((tokenId + "_") + user) + kUserLendAvailableClaim), (userAvailableClaim + uReward)), IntegerEntry((tokenId + kTokenInterest), newTokenInterest), IntegerEntry((tokenId + kTokenInterestHeight), height)] | |
440 | 447 | }) | |
441 | 448 | ||
442 | 449 | ||
444 | 451 | @Callable(i) | |
445 | 452 | func lpAction (user) = valueOrElse(isSFFarmingCall(i), { | |
446 | 453 | let userAvailableClaim = valueOrElse(getInteger(this, kUserLpAvailableClaim), 0) | |
447 | - | let $ | |
448 | - | let uReward = $ | |
449 | - | let newLpInterest = $ | |
454 | + | let $t01300913062 = calcLpUserReward(user) | |
455 | + | let uReward = $t01300913062._1 | |
456 | + | let newLpInterest = $t01300913062._2 | |
450 | 457 | [IntegerEntry((user + kUserLpInterest), newLpInterest), IntegerEntry((user + kUserLpAvailableClaim), (userAvailableClaim + uReward)), IntegerEntry((user + kLpInterest), newLpInterest), IntegerEntry((user + kLpInterestHeight), height)] | |
451 | 458 | }) | |
452 | 459 | ||
475 | 482 | ||
476 | 483 | @Callable(i) | |
477 | 484 | func updateRewards () = valueOrElse(isOperatorCall(i), { | |
478 | - | let lastUpdatePeriod = valueOrElse(getInteger(this, kLastUpdatePeriod), 0) | |
479 | - | let calcPeriod = (((height - startHeight) / periodLength) + 1) | |
480 | - | let curPeriod = if ((0 >= calcPeriod)) | |
481 | - | then 1 | |
482 | - | else calcPeriod | |
483 | - | if ((curPeriod > 104)) | |
484 | - | then throw("max period is 104") | |
485 | - | else if (if ((lastUpdatePeriod >= curPeriod)) | |
486 | - | then (lastUpdatePeriod != 0) | |
487 | - | else false) | |
488 | - | then throw("rewards alredy updated in this period") | |
489 | - | else { | |
490 | - | let $t01494415024 = getTotalSupplyAllTokens() | |
491 | - | let totalSupply = $t01494415024._1 | |
492 | - | let totalSupplyUsd = $t01494415024._2 | |
493 | - | let totalSupplyUsdAll = $t01494415024._3 | |
494 | - | let axlyPrice = getAssetPrice(axlyId) | |
495 | - | let axlyPrecision = getAssetPrecision(axlyId) | |
496 | - | let maxAPR = getAdoptedAPRByPeriod(curPeriod, LENDERS_APR_PERIODS, LENDERS_APR) | |
497 | - | func updateReward (a,tokenId) = { | |
498 | - | let $t01527315317 = a | |
499 | - | let enteries = $t01527315317._1 | |
500 | - | let totalPeriodReward = $t01527315317._2 | |
501 | - | let index = $t01527315317._3 | |
502 | - | if ((totalSupply[index] == 0)) | |
503 | - | then $Tuple3((enteries ++ [IntegerEntry((tokenId + kPrevLendTokenSupply), totalSupply[index]), IntegerEntry((tokenId + kTokenRewardPerBlock), 0), IntegerEntry((tokenId + kTokenInterest), calcNewTokenInterest(tokenId, totalSupply[index])), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height]))]), totalPeriodReward, (index + 1)) | |
504 | - | else { | |
505 | - | let share = fraction(totalSupplyUsd[index], SCALE8, totalSupplyUsdAll) | |
506 | - | let maxReward = fraction(share, lendMaxPeriodAmount, SCALE8) | |
507 | - | let maxRewardUsd = fraction(maxReward, axlyPrice, axlyPrecision) | |
508 | - | let prevTotalSupply = valueOrElse(getInteger(this, (tokenId + kPrevLendTokenSupply)), 0) | |
509 | - | let rtCoef = if (if ((prevTotalSupply == 0)) | |
510 | - | then true | |
511 | - | else (totalSupply[index] == 0)) | |
512 | - | then 0 | |
513 | - | else (fraction(totalSupply[index], SCALE8, prevTotalSupply) - SCALE8) | |
514 | - | let reward = ((min([(maxAPR * (SCALE8 + max([rtCoef, 0]))), fraction(maxAPR, (15 * SCALE8), 10)]) / SCALE8) / 100) | |
515 | - | let rewardUsd = min([maxRewardUsd, fraction(totalSupplyUsd[index], reward, SCALE8)]) | |
516 | - | let rewardPeriod = fraction(rewardUsd, axlyPrecision, axlyPrice) | |
517 | - | let rewardPerBlock = (rewardPeriod / periodLength) | |
518 | - | $Tuple3((enteries ++ [IntegerEntry((tokenId + kPrevLendTokenSupply), totalSupply[index]), IntegerEntry((tokenId + kTokenRewardPerBlock), rewardPerBlock), IntegerEntry((tokenId + kTokenInterest), calcNewTokenInterest(tokenId, totalSupply[index])), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height]))]), (totalPeriodReward + rewardPeriod), (index + 1)) | |
519 | - | } | |
520 | - | } | |
485 | + | let lastUpdateHeight = valueOrElse(getInteger(this, kRewardUpdateHeight), 0) | |
486 | + | if (((lastUpdateHeight + periodLength) > height)) | |
487 | + | then throw("rewards alredy updated in this period") | |
488 | + | else { | |
489 | + | let $t01482914909 = getTotalSupplyAllTokens() | |
490 | + | let totalSupply = $t01482914909._1 | |
491 | + | let totalSupplyUsd = $t01482914909._2 | |
492 | + | let totalSupplyUsdAll = $t01482914909._3 | |
493 | + | let axlyPrice = getAssetPrice(axlyId) | |
494 | + | let axlyPrecision = getAssetPrecision(axlyId) | |
495 | + | let maxAPR = getAdoptedAPRByPeriod(curPeriod, LENDERS_APR_PERIODS, LENDERS_APR) | |
496 | + | func updateReward (a,tokenId) = { | |
497 | + | let $t01515315178 = a | |
498 | + | let enteries = $t01515315178._1 | |
499 | + | let index = $t01515315178._2 | |
500 | + | if ((totalSupply[index] == 0)) | |
501 | + | then $Tuple2((enteries ++ [IntegerEntry((tokenId + kPrevLendTokenSupply), totalSupply[index]), IntegerEntry((tokenId + kTokenRewardPerBlock), 0), IntegerEntry((tokenId + kTokenInterest), calcNewTokenInterest(tokenId, totalSupply[index])), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height]))]), (index + 1)) | |
502 | + | else { | |
503 | + | let share = fraction(totalSupplyUsd[index], SCALE8, totalSupplyUsdAll) | |
504 | + | let maxReward = fraction(share, lendMaxPeriodAmount, SCALE8) | |
505 | + | let maxRewardUsd = fraction(maxReward, axlyPrice, axlyPrecision) | |
506 | + | let prevTotalSupply = valueOrElse(getInteger(this, kPrevLendTokenSupply), 0) | |
507 | + | let rtCoef = if (if ((prevTotalSupply == 0)) | |
508 | + | then true | |
509 | + | else (totalSupply[index] == 0)) | |
510 | + | then 0 | |
511 | + | else fraction(prevTotalSupply, SCALE8, totalSupply[index]) | |
512 | + | let reward = (min([(maxAPR * (SCALE8 + rtCoef)), fraction(maxAPR, (15 * SCALE8), 10)]) / SCALE8) | |
513 | + | let rewardUsd = min([maxRewardUsd, fraction(totalSupplyUsd[index], reward, SCALE8)]) | |
514 | + | let rewardPeriod = fraction(rewardUsd, axlyPrecision, axlyPrice) | |
515 | + | let rewardPerBlock = (rewardPeriod / periodLength) | |
516 | + | $Tuple2((enteries ++ [IntegerEntry((tokenId + kPrevLendTokenSupply), totalSupply[index]), IntegerEntry((tokenId + kTokenRewardPerBlock), rewardPerBlock), IntegerEntry((tokenId + kTokenInterest), calcNewTokenInterest(tokenId, totalSupply[index])), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height]))]), (index + 1)) | |
517 | + | } | |
518 | + | } | |
521 | 519 | ||
522 | - | ||
523 | - | ||
524 | - | ||
525 | - | ||
526 | - | ||
527 | - | ||
528 | - | ||
520 | + | let $t01676516842 = { | |
521 | + | let $l = getAllTokens() | |
522 | + | let $s = size($l) | |
523 | + | let $acc0 = $Tuple2(nil, 0) | |
524 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
525 | + | then $a | |
526 | + | else updateReward($a, $l[$i]) | |
529 | 527 | ||
530 | - | ||
531 | - | ||
532 | - | ||
528 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
529 | + | then $a | |
530 | + | else throw("List size exceeds 30") | |
533 | 531 | ||
534 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
535 | - | } | |
536 | - | let tokensEnteries = $t01700917101._1 | |
537 | - | let totalTokenReward = $t01700917101._2 | |
538 | - | let lpMaxAPR = getAdoptedAPRByPeriod(curPeriod, LP_APR_PERIODS, LP_APR) | |
539 | - | let lpTotalSupply = getIntegerValue(sfFarmingContract, (axlyPool + kSFTotalSupply)) | |
540 | - | let preLPSupply = valueOrElse(getInteger(this, kPrevLPSupply), 0) | |
541 | - | let lpId = getStringValue(addressFromStringValue(axlyPool), kLpId) | |
542 | - | let lpPrecision = getAssetPrecision(lpId) | |
543 | - | let lpPrice = { | |
544 | - | let @ = invoke(mainContract, "getShareAssetPriceREADONLY", [lpId], nil) | |
545 | - | if ($isInstanceOf(@, "Int")) | |
546 | - | then @ | |
547 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
548 | - | } | |
549 | - | let lpTotalSupplyUsd = fraction(lpTotalSupply, lpPrice, lpPrecision) | |
550 | - | let maxLPRewardUsd = fraction(lpMaxPeriodAmount, axlyPrice, axlyPrecision) | |
551 | - | let rtLPCoef = if (if ((preLPSupply == 0)) | |
552 | - | then true | |
553 | - | else (lpTotalSupply == 0)) | |
554 | - | then 0 | |
555 | - | else (fraction(lpTotalSupply, SCALE8, preLPSupply) - SCALE8) | |
556 | - | let rewardLp = ((min([(lpMaxAPR * (SCALE8 + max([rtLPCoef, 0]))), fraction(lpMaxAPR, (15 * SCALE8), 10)]) / SCALE8) / 100) | |
557 | - | let rewardLpUsd = min([maxLPRewardUsd, fraction(lpTotalSupplyUsd, rewardLp, SCALE8)]) | |
558 | - | let rewardLpPeriod = fraction(rewardLpUsd, axlyPrecision, axlyPrice) | |
559 | - | let rewardLpPerBlock = (rewardLpPeriod / periodLength) | |
560 | - | let burnLend = (lendMaxPeriodAmount - totalTokenReward) | |
561 | - | let burnLp = (lpMaxPeriodAmount - rewardLpPeriod) | |
562 | - | let inv = invoke(tokenContract, "withdrawLpReward", [(burnLend + burnLp), toString(this)], nil) | |
563 | - | if ((inv == inv)) | |
564 | - | then { | |
565 | - | let lpEnteries = if ((12 >= curPeriod)) | |
566 | - | then [IntegerEntry(kPrevLPSupply, lpTotalSupply), IntegerEntry(kLpRewardPerBlock, rewardLpPerBlock), IntegerEntry(kLpInterest, calcNewLpInterest(lpTotalSupply)), IntegerEntry(kLpInterestHeight, max([startHeight, height])), ScriptTransfer(Address(base58'3MsXJ3BesPECkYejzBQGHZPJT8GVYy4Fd3Q'), burnLend, fromBase58String(axlyId)), ScriptTransfer(Address(base58'3MsXJ3BesPECkYejzBQGHZPJT8GVYy4Fd3Q'), burnLp, fromBase58String(axlyId))] | |
567 | - | else nil | |
568 | - | ((lpEnteries ++ tokensEnteries) :+ IntegerEntry(kLastUpdatePeriod, curPeriod)) | |
569 | - | } | |
570 | - | else throw("Strict value is not equal to itself.") | |
532 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
571 | 533 | } | |
534 | + | let tokensEnteries = $t01676516842._1 | |
535 | + | let index = $t01676516842._2 | |
536 | + | let lpMaxAPR = getAdoptedAPRByPeriod(curPeriod, LP_APR_PERIODS, LP_APR) | |
537 | + | let lpTotalSupply = getIntegerValue(sfFarmingContract, (axlyPool + kSFTotalSupply)) | |
538 | + | let preLPSupply = valueOrElse(getInteger(this, kPrevLPSupply), 0) | |
539 | + | let lpId = getStringValue(addressFromStringValue(axlyPool), kLpId) | |
540 | + | let lpPrecision = getAssetPrecision(lpId) | |
541 | + | let lpPrice = { | |
542 | + | let @ = invoke(mainContract, "getShareAssetPriceREADONLY", [lpId], nil) | |
543 | + | if ($isInstanceOf(@, "Int")) | |
544 | + | then @ | |
545 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
546 | + | } | |
547 | + | let lpTotalSupplyUsd = fraction(lpTotalSupply, lpPrice, lpPrecision) | |
548 | + | let maxLPRewardUsd = fraction(lpMaxPeriodAmount, axlyPrice, axlyPrecision) | |
549 | + | let rtLPCoef = if (if ((preLPSupply == 0)) | |
550 | + | then true | |
551 | + | else (lpTotalSupply == 0)) | |
552 | + | then 0 | |
553 | + | else fraction(preLPSupply, SCALE8, lpTotalSupply) | |
554 | + | let rewardLp = (min([(lpMaxAPR * (SCALE8 + rtLPCoef)), fraction(lpMaxAPR, (15 * SCALE8), 10)]) / SCALE8) | |
555 | + | let rewardLpUsd = min([maxLPRewardUsd, fraction(lpTotalSupplyUsd, rewardLp, SCALE8)]) | |
556 | + | let rewardLpPeriod = fraction(rewardLpUsd, axlyPrice, axlyPrecision) | |
557 | + | let rewardLpPerBlock = (rewardLpPeriod / periodLength) | |
558 | + | let lpEnteries = [IntegerEntry(kPrevLPSupply, lpTotalSupply), IntegerEntry(kLpRewardPerBlock, rewardLpPerBlock), IntegerEntry(kLpInterest, calcNewLpInterest(lpTotalSupply)), IntegerEntry(kLpInterestHeight, max([startHeight, height]))] | |
559 | + | ((lpEnteries ++ tokensEnteries) :+ IntegerEntry(kRewardUpdateHeight, max([startHeight, height]))) | |
560 | + | } | |
572 | 561 | }) | |
573 | 562 | ||
574 | 563 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SCALE8 = 100000000 | |
5 | 5 | ||
6 | 6 | let LENDERS_APR = [150, 120, 100, 80, 60, 40, 30, 20, 10] | |
7 | 7 | ||
8 | - | let LENDERS_APR_PERIODS = ["1-1", "2-2", "3-3", "4-4", "5-8", "9-12", "14 | |
8 | + | let LENDERS_APR_PERIODS = ["1-1", "2-2", "3-3", "4-4", "5-8", "9-12", "14 - 16", "17-20", "20-104"] | |
9 | 9 | ||
10 | 10 | let LENDERS_MAX_PERIODS = 104 | |
11 | 11 | ||
12 | 12 | let LP_APR = [150, 120, 100, 80, 60, 40] | |
13 | 13 | ||
14 | 14 | let LP_APR_PERIODS = ["1-1", "2-2", "3-3", "4-4", "5-8", "9-12"] | |
15 | 15 | ||
16 | 16 | let LP_MAX_PERIODS = 12 | |
17 | 17 | ||
18 | 18 | let kStartHeight = "startHeight" | |
19 | 19 | ||
20 | 20 | let kPeriodLength = "periodLength" | |
21 | 21 | ||
22 | 22 | let kLendersMaxAmount = "lendRewardsAmount" | |
23 | 23 | ||
24 | 24 | let kLPMaxAmount = "lpRewardAmount" | |
25 | 25 | ||
26 | 26 | let kTokens = "tokens" | |
27 | 27 | ||
28 | 28 | let kUserSupply = "_userTotalSupply" | |
29 | 29 | ||
30 | 30 | let kTokenInterest = "_tokenInterest" | |
31 | 31 | ||
32 | 32 | let kTokenInterestHeight = "_tokenInterestHeight" | |
33 | 33 | ||
34 | 34 | let kTokenRewardPerBlock = "_tokenRewardPerBlock" | |
35 | 35 | ||
36 | - | let | |
36 | + | let kRewardUpdateHeight = "rewardUpdateHeight" | |
37 | 37 | ||
38 | 38 | let kUserLendInterest = "_userLandInterest" | |
39 | 39 | ||
40 | 40 | let kUserLendAvailableClaim = "_userLendAvailableClaim" | |
41 | 41 | ||
42 | 42 | let kUserLpAvailableClaim = "_userLpAvailableClaim" | |
43 | 43 | ||
44 | 44 | let kLpInterest = "lpInterest" | |
45 | 45 | ||
46 | 46 | let kLpInterestHeight = "lpInterestHeight" | |
47 | 47 | ||
48 | 48 | let kPrevLPSupply = "prevLPTotalSupply" | |
49 | 49 | ||
50 | 50 | let kLpRewardPerBlock = "lpRewardPerBlock" | |
51 | 51 | ||
52 | 52 | let kUserLpInterest = "_userLpInterest" | |
53 | 53 | ||
54 | 54 | let kPriceInOracle = "_twap5B" | |
55 | 55 | ||
56 | 56 | let kPrevLendTokenSupply = "_prevLendTotalSupply" | |
57 | 57 | ||
58 | 58 | let kAXLYTokenId = "axlyTokenId" | |
59 | 59 | ||
60 | 60 | let kLendTokenSupply = "total_supplied_" | |
61 | 61 | ||
62 | 62 | let kLendUserSupply = "_supplied_" | |
63 | 63 | ||
64 | 64 | let kLendSetupTokens = "setup_tokens" | |
65 | 65 | ||
66 | 66 | let kSFTotalSupply = "_total_share_tokens_locked" | |
67 | 67 | ||
68 | 68 | let kSFUserTotalSupply = "_share_tokens_locked" | |
69 | 69 | ||
70 | 70 | let kAxlyPool = "axlyPool" | |
71 | 71 | ||
72 | 72 | let kLpId = "share_asset_id" | |
73 | 73 | ||
74 | 74 | let kPriceOracle = "price_oracle" | |
75 | 75 | ||
76 | 76 | let kAxlyMainContract = "mainContract" | |
77 | 77 | ||
78 | 78 | let kAxlyTokenomicContract = "tokenomicContract" | |
79 | 79 | ||
80 | 80 | let kSFFarmingContract = "swopfi_farming_addr" | |
81 | 81 | ||
82 | 82 | let kLendContract = "lend_service_addr" | |
83 | 83 | ||
84 | 84 | let kAdmin1PK = "group1_admin1_pub_key" | |
85 | 85 | ||
86 | 86 | let kAdmin2PK = "group1_admin2_pub_key" | |
87 | 87 | ||
88 | 88 | let kAdmin3PK = "group1_admin3_pub_key" | |
89 | 89 | ||
90 | 90 | let kOperatorCallPK = "admin_call_pub_key" | |
91 | 91 | ||
92 | 92 | let axlyPool = valueOrErrorMessage(getString(this, kAxlyPool), "Can't get axlyPool key") | |
93 | 93 | ||
94 | 94 | let mainContract = addressFromStringValue(valueOrErrorMessage(getString(this, kAxlyMainContract), "Can't get mainContact key")) | |
95 | 95 | ||
96 | 96 | let tokenContract = addressFromStringValue(valueOrErrorMessage(getString(this, kAxlyTokenomicContract), "Can't get tokenomicContract key")) | |
97 | 97 | ||
98 | 98 | let lendContract = addressFromStringValue(valueOrErrorMessage(getString(mainContract, kLendContract), "Can't get lend_service_addr key")) | |
99 | 99 | ||
100 | 100 | let sfFarmingContract = addressFromStringValue(valueOrErrorMessage(getString(mainContract, kSFFarmingContract), "Can't get swopfi_farming_addr key")) | |
101 | 101 | ||
102 | 102 | let priceOracleAddr = addressFromStringValue(valueOrErrorMessage(getString(mainContract, kPriceOracle), "Can't get price_oracle key")) | |
103 | 103 | ||
104 | 104 | let admin1PK = fromBase58String(valueOrErrorMessage(getString(mainContract, kAdmin1PK), "Can't get admin1PK")) | |
105 | 105 | ||
106 | 106 | let admin2PK = fromBase58String(valueOrErrorMessage(getString(mainContract, kAdmin2PK), "Can't get admin2PK")) | |
107 | 107 | ||
108 | 108 | let admin3PK = fromBase58String(valueOrErrorMessage(getString(mainContract, kAdmin3PK), "Can't get operatorPK")) | |
109 | 109 | ||
110 | 110 | let operatorPK = fromBase58String(valueOrErrorMessage(getString(this, kOperatorCallPK), "Can't get operatorPK")) | |
111 | 111 | ||
112 | 112 | let axlyId = valueOrErrorMessage(getString(tokenContract, kAXLYTokenId), "Can't get Axly token id") | |
113 | 113 | ||
114 | 114 | let startHeight = getIntegerValue(this, kStartHeight) | |
115 | 115 | ||
116 | 116 | let periodLength = getIntegerValue(this, kPeriodLength) | |
117 | 117 | ||
118 | + | let curPeriod = ((height - startHeight) / periodLength) | |
119 | + | ||
118 | 120 | let lendMaxAmount = getIntegerValue(tokenContract, kLendersMaxAmount) | |
119 | 121 | ||
120 | 122 | let lendMaxPeriodAmount = (lendMaxAmount / LENDERS_MAX_PERIODS) | |
121 | 123 | ||
122 | 124 | let lpMaxAmount = getIntegerValue(tokenContract, kLPMaxAmount) | |
123 | 125 | ||
124 | 126 | let lpMaxPeriodAmount = (lpMaxAmount / LP_MAX_PERIODS) | |
125 | 127 | ||
126 | 128 | func isAdminCall (i) = if (containsElement([admin1PK, admin2PK, admin3PK], i.callerPublicKey)) | |
127 | 129 | then unit | |
128 | 130 | else throw("Only admin group1 can call this function") | |
129 | 131 | ||
130 | 132 | ||
131 | 133 | func isSelfCall (i) = if ((i.caller == this)) | |
132 | 134 | then unit | |
133 | 135 | else throw("Only contract itself can call this function") | |
134 | 136 | ||
135 | 137 | ||
136 | 138 | func isOperatorCall (i) = if ((i.callerPublicKey == operatorPK)) | |
137 | 139 | then unit | |
138 | 140 | else throw("Only operator can call this function") | |
139 | 141 | ||
140 | 142 | ||
141 | 143 | func isLandCall (i) = if ((i.caller == lendContract)) | |
142 | 144 | then unit | |
143 | 145 | else throw("Only land contract can call this function") | |
144 | 146 | ||
145 | 147 | ||
146 | 148 | func isSFFarmingCall (i) = if ((i.caller == sfFarmingContract)) | |
147 | 149 | then unit | |
148 | 150 | else throw("Only land contract can call this function") | |
149 | 151 | ||
150 | 152 | ||
151 | 153 | func getAllTokens () = { | |
152 | 154 | let tokens = valueOrElse(getString(this, kTokens), "") | |
153 | 155 | if ((tokens == "")) | |
154 | 156 | then nil | |
155 | 157 | else split(tokens, ",") | |
156 | 158 | } | |
157 | 159 | ||
158 | 160 | ||
159 | 161 | func getAssetPrice (assetId) = getIntegerValue(priceOracleAddr, (assetId + kPriceInOracle)) | |
160 | 162 | ||
161 | 163 | ||
162 | 164 | func getAssetDecimals (assetId) = if ((assetId == "WAVES")) | |
163 | 165 | then 8 | |
164 | 166 | else match assetInfo(fromBase58String(assetId)) { | |
165 | 167 | case asset: Asset => | |
166 | 168 | asset.decimals | |
167 | 169 | case _ => | |
168 | 170 | throw("Can't find asset") | |
169 | 171 | } | |
170 | 172 | ||
171 | 173 | ||
172 | 174 | func getAssetPrecision (assetId) = pow(10, 0, getAssetDecimals(assetId), 0, 0, DOWN) | |
173 | 175 | ||
174 | 176 | ||
175 | 177 | func getAdoptedAPRByPeriod (period,aprPeriods,apr) = { | |
176 | 178 | func for (a,aperiod) = { | |
177 | - | let $ | |
178 | - | let index = $ | |
179 | - | let found = $ | |
179 | + | let $t054205442 = a | |
180 | + | let index = $t054205442._1 | |
181 | + | let found = $t054205442._2 | |
180 | 182 | let ft = split(aperiod, "-") | |
181 | - | let $ | |
182 | - | let from = $ | |
183 | - | let to = $ | |
183 | + | let $t054795542 = $Tuple2(parseIntValue(ft[0]), parseIntValue(ft[1])) | |
184 | + | let from = $t054795542._1 | |
185 | + | let to = $t054795542._2 | |
184 | 186 | if (found) | |
185 | 187 | then a | |
186 | 188 | else if (if ((period >= from)) | |
187 | 189 | then (to >= period) | |
188 | 190 | else false) | |
189 | 191 | then $Tuple2(index, true) | |
190 | 192 | else $Tuple2((index + 1), false) | |
191 | 193 | } | |
192 | 194 | ||
193 | - | let $ | |
195 | + | let $t056795745 = { | |
194 | 196 | let $l = LENDERS_APR_PERIODS | |
195 | 197 | let $s = size($l) | |
196 | 198 | let $acc0 = $Tuple2(0, false) | |
197 | 199 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
198 | 200 | then $a | |
199 | 201 | else for($a, $l[$i]) | |
200 | 202 | ||
201 | 203 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
202 | 204 | then $a | |
203 | 205 | else throw("List size exceeds 9") | |
204 | 206 | ||
205 | 207 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9) | |
206 | 208 | } | |
207 | - | let index = $ | |
208 | - | let found = $ | |
209 | + | let index = $t056795745._1 | |
210 | + | let found = $t056795745._2 | |
209 | 211 | if (found) | |
210 | 212 | then fraction((LENDERS_APR[index] * SCALE8), 7, 365) | |
211 | 213 | else 0 | |
212 | 214 | } | |
213 | 215 | ||
214 | 216 | ||
215 | 217 | func getTotalSupplyAllTokens () = { | |
216 | 218 | func for (a,tokenId) = { | |
217 | - | let $ | |
218 | - | let totalSupply = $ | |
219 | - | let totalSupplyUsd = $ | |
220 | - | let totalSupplyUsdAll = $ | |
219 | + | let $t059335989 = a | |
220 | + | let totalSupply = $t059335989._1 | |
221 | + | let totalSupplyUsd = $t059335989._2 | |
222 | + | let totalSupplyUsdAll = $t059335989._3 | |
221 | 223 | let tSupply = valueOrElse(getInteger(lendContract, (kLendTokenSupply + tokenId)), 0) | |
222 | 224 | let assetPrice = getAssetPrice(tokenId) | |
223 | 225 | let assetPrecision = getAssetPrecision(tokenId) | |
224 | 226 | let tSupplyUsd = fraction(tSupply, assetPrice, assetPrecision) | |
225 | 227 | $Tuple3((totalSupply :+ tSupply), (totalSupplyUsd :+ tSupplyUsd), (totalSupplyUsdAll + tSupplyUsd)) | |
226 | 228 | } | |
227 | 229 | ||
228 | 230 | let $l = getAllTokens() | |
229 | 231 | let $s = size($l) | |
230 | 232 | let $acc0 = $Tuple3(nil, nil, 0) | |
231 | 233 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
232 | 234 | then $a | |
233 | 235 | else for($a, $l[$i]) | |
234 | 236 | ||
235 | 237 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
236 | 238 | then $a | |
237 | 239 | else throw("List size exceeds 30") | |
238 | 240 | ||
239 | 241 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
240 | 242 | } | |
241 | 243 | ||
242 | 244 | ||
243 | 245 | func getTotalSupplyUsd (tokenId) = { | |
244 | 246 | let tSupply = valueOrElse(getInteger(lendContract, (kLendTokenSupply + tokenId)), 0) | |
245 | 247 | let assetPrice = getAssetPrice(tokenId) | |
246 | 248 | let assetPrecision = getAssetPrecision(tokenId) | |
247 | 249 | fraction(tSupply, assetPrice, assetPrecision) | |
248 | 250 | } | |
249 | 251 | ||
250 | 252 | ||
251 | - | func calcNewTokenInterest (tokenId,totalSupply) = if (( | |
253 | + | func calcNewTokenInterest (tokenId,totalSupply) = if ((height >= startHeight)) | |
252 | 254 | then 0 | |
253 | 255 | else { | |
254 | 256 | let rewardPerBlock = getIntegerValue(this, (tokenId + kTokenRewardPerBlock)) | |
255 | 257 | let oldInterest = getIntegerValue(this, (tokenId + kTokenInterest)) | |
256 | 258 | let updateHeight = getIntegerValue(this, (tokenId + kTokenInterestHeight)) | |
257 | 259 | let reward = ((height - updateHeight) * rewardPerBlock) | |
258 | 260 | let interest = if ((totalSupply > 0)) | |
259 | 261 | then fraction(reward, SCALE8, totalSupply) | |
260 | 262 | else 0 | |
261 | 263 | (oldInterest + interest) | |
262 | 264 | } | |
263 | 265 | ||
264 | 266 | ||
265 | - | func calcNewLpInterest (totalSupply) = if (( | |
267 | + | func calcNewLpInterest (totalSupply) = if ((height >= startHeight)) | |
266 | 268 | then 0 | |
267 | 269 | else { | |
268 | 270 | let rewardPerBlock = valueOrElse(getInteger(this, kLpRewardPerBlock), 0) | |
269 | 271 | let oldInterest = valueOrElse(getInteger(this, kLpInterest), 0) | |
270 | 272 | let updateHeight = valueOrElse(getInteger(this, kLpInterestHeight), height) | |
271 | 273 | let reward = ((height - updateHeight) * rewardPerBlock) | |
272 | 274 | let interest = if ((totalSupply > 0)) | |
273 | 275 | then fraction(reward, SCALE8, totalSupply) | |
274 | 276 | else 0 | |
275 | 277 | (oldInterest + interest) | |
276 | 278 | } | |
277 | 279 | ||
278 | 280 | ||
279 | 281 | func calcLendUserReward (user,tokenId) = { | |
280 | 282 | let totalSupply = valueOrElse(getInteger(lendContract, (kLendTokenSupply + tokenId)), 0) | |
281 | 283 | let tokenInterest = calcNewTokenInterest(tokenId, totalSupply) | |
282 | 284 | let userSupply = valueOrElse(getInteger(lendContract, ((user + kLendUserSupply) + tokenId)), 0) | |
283 | 285 | let userTokenInterest = valueOrElse(getInteger(this, (((tokenId + "_") + user) + kUserLendInterest)), if ((userSupply == 0)) | |
284 | 286 | then tokenInterest | |
285 | 287 | else 0) | |
286 | 288 | let reward = fraction(userSupply, (tokenInterest - userTokenInterest), SCALE8) | |
287 | 289 | $Tuple3(reward, tokenInterest, userSupply) | |
288 | 290 | } | |
289 | 291 | ||
290 | 292 | ||
291 | 293 | func calcLpUserReward (user) = { | |
292 | 294 | let totalSupply = valueOrElse(getInteger(sfFarmingContract, (axlyPool + kSFTotalSupply)), 0) | |
293 | 295 | let tokenInterest = calcNewLpInterest(totalSupply) | |
294 | - | let userSupply = valueOrElse(getInteger( | |
296 | + | let userSupply = valueOrElse(getInteger(lendContract, (((axlyPool + "_") + user) + kSFUserTotalSupply)), 0) | |
295 | 297 | let userTokenInterest = valueOrElse(getInteger(this, (user + kUserLpInterest)), if ((userSupply == 0)) | |
296 | 298 | then tokenInterest | |
297 | 299 | else 0) | |
298 | 300 | let reward = fraction(userSupply, (tokenInterest - userTokenInterest), SCALE8) | |
299 | 301 | $Tuple3(reward, tokenInterest, userSupply) | |
300 | 302 | } | |
301 | 303 | ||
302 | 304 | ||
303 | 305 | func claimLenderRewardsCommon (user,readOnly) = { | |
304 | 306 | func claim (a,tokenId) = { | |
305 | - | let $ | |
306 | - | let tokenIds = $ | |
307 | - | let cAmount = $ | |
308 | - | let total = $ | |
309 | - | let enteries = $ | |
307 | + | let $t088738917 = a | |
308 | + | let tokenIds = $t088738917._1 | |
309 | + | let cAmount = $t088738917._2 | |
310 | + | let total = $t088738917._3 | |
311 | + | let enteries = $t088738917._4 | |
310 | 312 | let userAvailableClaim = valueOrElse(getInteger(this, (((tokenId + "_") + user) + kUserLendAvailableClaim)), 0) | |
311 | - | let $ | |
312 | - | let uReward = $ | |
313 | - | let newTokenInterest = $ | |
314 | - | let userSupply = $ | |
313 | + | let $t090309109 = calcLendUserReward(user, tokenId) | |
314 | + | let uReward = $t090309109._1 | |
315 | + | let newTokenInterest = $t090309109._2 | |
316 | + | let userSupply = $t090309109._3 | |
315 | 317 | let totalToClaim = (userAvailableClaim + uReward) | |
316 | 318 | if (if ((totalToClaim > 0)) | |
317 | 319 | then true | |
318 | 320 | else (userSupply > 0)) | |
319 | 321 | then { | |
320 | 322 | let newEntreries = if (if (readOnly) | |
321 | 323 | then true | |
322 | 324 | else (totalToClaim == 0)) | |
323 | 325 | then enteries | |
324 | 326 | else (enteries ++ [IntegerEntry((((tokenId + "_") + user) + kUserLendInterest), newTokenInterest), IntegerEntry((((tokenId + "_") + user) + kUserLendAvailableClaim), 0), IntegerEntry((tokenId + kTokenInterest), newTokenInterest), IntegerEntry((tokenId + kTokenInterestHeight), height)]) | |
325 | 327 | $Tuple4((tokenIds :+ tokenId), (cAmount :+ totalToClaim), (total + totalToClaim), newEntreries) | |
326 | 328 | } | |
327 | 329 | else $Tuple4(tokenIds, cAmount, total, enteries) | |
328 | 330 | } | |
329 | 331 | ||
330 | 332 | let $l = getAllTokens() | |
331 | 333 | let $s = size($l) | |
332 | 334 | let $acc0 = $Tuple4(nil, nil, 0, nil) | |
333 | 335 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
334 | 336 | then $a | |
335 | 337 | else claim($a, $l[$i]) | |
336 | 338 | ||
337 | 339 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
338 | 340 | then $a | |
339 | 341 | else throw("List size exceeds 30") | |
340 | 342 | ||
341 | 343 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
342 | 344 | } | |
343 | 345 | ||
344 | 346 | ||
345 | 347 | func claimLpRewardsCommon (user,readOnly) = { | |
346 | 348 | let userAvailableClaim = valueOrElse(getInteger(this, (user + kUserLpAvailableClaim)), 0) | |
347 | - | let $ | |
348 | - | let uReward = $ | |
349 | - | let newLpInterest = $ | |
350 | - | let userSupply = $ | |
349 | + | let $t01004110106 = calcLpUserReward(user) | |
350 | + | let uReward = $t01004110106._1 | |
351 | + | let newLpInterest = $t01004110106._2 | |
352 | + | let userSupply = $t01004110106._3 | |
351 | 353 | let totalToClaim = (userAvailableClaim + uReward) | |
352 | 354 | if (if (readOnly) | |
353 | 355 | then true | |
354 | 356 | else (totalToClaim == 0)) | |
355 | 357 | then $Tuple2(totalToClaim, nil) | |
356 | 358 | else $Tuple2(totalToClaim, [IntegerEntry((user + kUserLpInterest), newLpInterest), IntegerEntry((user + kUserLpAvailableClaim), 0), IntegerEntry(kLpInterest, newLpInterest), IntegerEntry(kLpInterestHeight, height)]) | |
357 | 359 | } | |
358 | 360 | ||
359 | 361 | ||
360 | 362 | func getTokensAPRs () = { | |
361 | 363 | let axlyPrice = getAssetPrice(axlyId) | |
362 | 364 | let axlyPrecision = getAssetPrecision(axlyId) | |
363 | 365 | func tokensAprs (apr,tokenId) = { | |
364 | 366 | let rwpb = valueOrElse(getInteger(this, (tokenId + kTokenRewardPerBlock)), 0) | |
365 | 367 | let rwpbUsd = fraction(rwpb, axlyPrice, axlyPrecision) | |
366 | 368 | let rwYear = ((rwpbUsd * periodLength) * 52) | |
367 | 369 | let totalSupplyUsd = getTotalSupplyUsd(tokenId) | |
368 | 370 | (apr :+ fraction(rwYear, SCALE8, totalSupplyUsd)) | |
369 | 371 | } | |
370 | 372 | ||
371 | 373 | let aprs = { | |
372 | 374 | let $l = getAllTokens() | |
373 | 375 | let $s = size($l) | |
374 | 376 | let $acc0 = nil | |
375 | 377 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
376 | 378 | then $a | |
377 | 379 | else tokensAprs($a, $l[$i]) | |
378 | 380 | ||
379 | 381 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
380 | 382 | then $a | |
381 | 383 | else throw("List size exceeds 30") | |
382 | 384 | ||
383 | 385 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
384 | 386 | } | |
385 | 387 | let lpTotalSupply = getIntegerValue(sfFarmingContract, (axlyPool + kSFTotalSupply)) | |
386 | 388 | let lpId = getStringValue(addressFromStringValue(axlyPool), kLpId) | |
387 | 389 | let lpPrecision = getAssetPrecision(lpId) | |
388 | 390 | let lpPrice = { | |
389 | - | let @ = invoke(mainContract, "getShareAssetPriceREADONLY", [lpId], nil) | |
391 | + | let @ = ({ | |
392 | + | let @ = invoke(mainContract, "getShareAssetPriceREADONLY", [[lpId]], nil) | |
393 | + | if ($isInstanceOf(@, "List[Any]")) | |
394 | + | then @ | |
395 | + | else throw(($getType(@) + " couldn't be cast to List[Any]")) | |
396 | + | })[0] | |
390 | 397 | if ($isInstanceOf(@, "Int")) | |
391 | 398 | then @ | |
392 | 399 | else throw(($getType(@) + " couldn't be cast to Int")) | |
393 | 400 | } | |
394 | 401 | let lpTotalSupplyUsd = fraction(lpTotalSupply, lpPrice, lpPrecision) | |
395 | 402 | let rwpb = valueOrElse(getInteger(this, kLpRewardPerBlock), 0) | |
396 | 403 | let rwpbUsd = fraction(rwpb, axlyPrice, axlyPrecision) | |
397 | 404 | let rwYear = ((rwpbUsd * periodLength) * 52) | |
398 | 405 | let lpApr = fraction(rwYear, SCALE8, lpTotalSupplyUsd) | |
399 | 406 | $Tuple3(getAllTokens(), aprs, lpApr) | |
400 | 407 | } | |
401 | 408 | ||
402 | 409 | ||
403 | 410 | @Callable(i) | |
404 | 411 | func claimLenderRewards () = { | |
405 | 412 | let claimRes = claimLenderRewardsCommon(toString(i.caller), false) | |
406 | 413 | if ((claimRes._3 == 0)) | |
407 | 414 | then throw("claim amount must be greater than 0") | |
408 | 415 | else { | |
409 | 416 | let inv = invoke(tokenContract, "withdrawLendReward", [claimRes._3, toString(i.caller)], nil) | |
410 | 417 | if ((inv == inv)) | |
411 | 418 | then claimRes._4 | |
412 | 419 | else throw("Strict value is not equal to itself.") | |
413 | 420 | } | |
414 | 421 | } | |
415 | 422 | ||
416 | 423 | ||
417 | 424 | ||
418 | 425 | @Callable(i) | |
419 | 426 | func claimLpRewards () = { | |
420 | 427 | let claimRes = claimLpRewardsCommon(toString(i.caller), false) | |
421 | 428 | if ((claimRes._1 == 0)) | |
422 | 429 | then throw("claim amount must be greater than 0") | |
423 | 430 | else { | |
424 | 431 | let inv = invoke(tokenContract, "withdrawLpReward", [claimRes._1, toString(i.caller)], nil) | |
425 | 432 | if ((inv == inv)) | |
426 | 433 | then claimRes._2 | |
427 | 434 | else throw("Strict value is not equal to itself.") | |
428 | 435 | } | |
429 | 436 | } | |
430 | 437 | ||
431 | 438 | ||
432 | 439 | ||
433 | 440 | @Callable(i) | |
434 | 441 | func lendAction (user,tokenId) = valueOrElse(isLandCall(i), { | |
435 | 442 | let userAvailableClaim = valueOrElse(getInteger(this, (tokenId + kUserLendAvailableClaim)), 0) | |
436 | - | let $ | |
437 | - | let uReward = $ | |
438 | - | let newTokenInterest = $ | |
439 | - | [IntegerEntry(((( | |
443 | + | let $t01247712544 = calcLendUserReward(user, tokenId) | |
444 | + | let uReward = $t01247712544._1 | |
445 | + | let newTokenInterest = $t01247712544._2 | |
446 | + | [IntegerEntry((((tokenId + "_") + user) + kUserLendInterest), newTokenInterest), IntegerEntry((((tokenId + "_") + user) + kUserLendAvailableClaim), (userAvailableClaim + uReward)), IntegerEntry((tokenId + kTokenInterest), newTokenInterest), IntegerEntry((tokenId + kTokenInterestHeight), height)] | |
440 | 447 | }) | |
441 | 448 | ||
442 | 449 | ||
443 | 450 | ||
444 | 451 | @Callable(i) | |
445 | 452 | func lpAction (user) = valueOrElse(isSFFarmingCall(i), { | |
446 | 453 | let userAvailableClaim = valueOrElse(getInteger(this, kUserLpAvailableClaim), 0) | |
447 | - | let $ | |
448 | - | let uReward = $ | |
449 | - | let newLpInterest = $ | |
454 | + | let $t01300913062 = calcLpUserReward(user) | |
455 | + | let uReward = $t01300913062._1 | |
456 | + | let newLpInterest = $t01300913062._2 | |
450 | 457 | [IntegerEntry((user + kUserLpInterest), newLpInterest), IntegerEntry((user + kUserLpAvailableClaim), (userAvailableClaim + uReward)), IntegerEntry((user + kLpInterest), newLpInterest), IntegerEntry((user + kLpInterestHeight), height)] | |
451 | 458 | }) | |
452 | 459 | ||
453 | 460 | ||
454 | 461 | ||
455 | 462 | @Callable(i) | |
456 | 463 | func init (axlyMainContractAddr,axlyTokenomicContractAddr,axlyPoolAddr,farmingStartHeight,periodLength) = valueOrElse(isSelfCall(i), if (!(isDefined(addressFromString(axlyMainContractAddr)))) | |
457 | 464 | then throw("Wrong farming address") | |
458 | 465 | else if (!(isDefined(addressFromString(axlyTokenomicContractAddr)))) | |
459 | 466 | then throw("Wrong main contract address") | |
460 | 467 | else [StringEntry(kAxlyMainContract, axlyMainContractAddr), StringEntry(kAxlyTokenomicContract, axlyTokenomicContractAddr), StringEntry(kAxlyPool, axlyPoolAddr), IntegerEntry(kStartHeight, farmingStartHeight), IntegerEntry(kPeriodLength, periodLength)]) | |
461 | 468 | ||
462 | 469 | ||
463 | 470 | ||
464 | 471 | @Callable(i) | |
465 | 472 | func initNewToken (tokenId) = valueOrElse(isAdminCall(i), if (isDefined(getInteger(this, (tokenId + kTokenInterest)))) | |
466 | 473 | then throw("token already inited") | |
467 | 474 | else if (!(contains(getStringValue(lendContract, kLendSetupTokens), tokenId))) | |
468 | 475 | then throw("no token on landing") | |
469 | 476 | else { | |
470 | 477 | let newAllTokens = (getAllTokens() :+ tokenId) | |
471 | 478 | [IntegerEntry((tokenId + kTokenInterest), 0), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height])), StringEntry(kTokens, makeString(newAllTokens, ",")), IntegerEntry((tokenId + kTokenRewardPerBlock), 0)] | |
472 | 479 | }) | |
473 | 480 | ||
474 | 481 | ||
475 | 482 | ||
476 | 483 | @Callable(i) | |
477 | 484 | func updateRewards () = valueOrElse(isOperatorCall(i), { | |
478 | - | let lastUpdatePeriod = valueOrElse(getInteger(this, kLastUpdatePeriod), 0) | |
479 | - | let calcPeriod = (((height - startHeight) / periodLength) + 1) | |
480 | - | let curPeriod = if ((0 >= calcPeriod)) | |
481 | - | then 1 | |
482 | - | else calcPeriod | |
483 | - | if ((curPeriod > 104)) | |
484 | - | then throw("max period is 104") | |
485 | - | else if (if ((lastUpdatePeriod >= curPeriod)) | |
486 | - | then (lastUpdatePeriod != 0) | |
487 | - | else false) | |
488 | - | then throw("rewards alredy updated in this period") | |
489 | - | else { | |
490 | - | let $t01494415024 = getTotalSupplyAllTokens() | |
491 | - | let totalSupply = $t01494415024._1 | |
492 | - | let totalSupplyUsd = $t01494415024._2 | |
493 | - | let totalSupplyUsdAll = $t01494415024._3 | |
494 | - | let axlyPrice = getAssetPrice(axlyId) | |
495 | - | let axlyPrecision = getAssetPrecision(axlyId) | |
496 | - | let maxAPR = getAdoptedAPRByPeriod(curPeriod, LENDERS_APR_PERIODS, LENDERS_APR) | |
497 | - | func updateReward (a,tokenId) = { | |
498 | - | let $t01527315317 = a | |
499 | - | let enteries = $t01527315317._1 | |
500 | - | let totalPeriodReward = $t01527315317._2 | |
501 | - | let index = $t01527315317._3 | |
502 | - | if ((totalSupply[index] == 0)) | |
503 | - | then $Tuple3((enteries ++ [IntegerEntry((tokenId + kPrevLendTokenSupply), totalSupply[index]), IntegerEntry((tokenId + kTokenRewardPerBlock), 0), IntegerEntry((tokenId + kTokenInterest), calcNewTokenInterest(tokenId, totalSupply[index])), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height]))]), totalPeriodReward, (index + 1)) | |
504 | - | else { | |
505 | - | let share = fraction(totalSupplyUsd[index], SCALE8, totalSupplyUsdAll) | |
506 | - | let maxReward = fraction(share, lendMaxPeriodAmount, SCALE8) | |
507 | - | let maxRewardUsd = fraction(maxReward, axlyPrice, axlyPrecision) | |
508 | - | let prevTotalSupply = valueOrElse(getInteger(this, (tokenId + kPrevLendTokenSupply)), 0) | |
509 | - | let rtCoef = if (if ((prevTotalSupply == 0)) | |
510 | - | then true | |
511 | - | else (totalSupply[index] == 0)) | |
512 | - | then 0 | |
513 | - | else (fraction(totalSupply[index], SCALE8, prevTotalSupply) - SCALE8) | |
514 | - | let reward = ((min([(maxAPR * (SCALE8 + max([rtCoef, 0]))), fraction(maxAPR, (15 * SCALE8), 10)]) / SCALE8) / 100) | |
515 | - | let rewardUsd = min([maxRewardUsd, fraction(totalSupplyUsd[index], reward, SCALE8)]) | |
516 | - | let rewardPeriod = fraction(rewardUsd, axlyPrecision, axlyPrice) | |
517 | - | let rewardPerBlock = (rewardPeriod / periodLength) | |
518 | - | $Tuple3((enteries ++ [IntegerEntry((tokenId + kPrevLendTokenSupply), totalSupply[index]), IntegerEntry((tokenId + kTokenRewardPerBlock), rewardPerBlock), IntegerEntry((tokenId + kTokenInterest), calcNewTokenInterest(tokenId, totalSupply[index])), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height]))]), (totalPeriodReward + rewardPeriod), (index + 1)) | |
519 | - | } | |
520 | - | } | |
485 | + | let lastUpdateHeight = valueOrElse(getInteger(this, kRewardUpdateHeight), 0) | |
486 | + | if (((lastUpdateHeight + periodLength) > height)) | |
487 | + | then throw("rewards alredy updated in this period") | |
488 | + | else { | |
489 | + | let $t01482914909 = getTotalSupplyAllTokens() | |
490 | + | let totalSupply = $t01482914909._1 | |
491 | + | let totalSupplyUsd = $t01482914909._2 | |
492 | + | let totalSupplyUsdAll = $t01482914909._3 | |
493 | + | let axlyPrice = getAssetPrice(axlyId) | |
494 | + | let axlyPrecision = getAssetPrecision(axlyId) | |
495 | + | let maxAPR = getAdoptedAPRByPeriod(curPeriod, LENDERS_APR_PERIODS, LENDERS_APR) | |
496 | + | func updateReward (a,tokenId) = { | |
497 | + | let $t01515315178 = a | |
498 | + | let enteries = $t01515315178._1 | |
499 | + | let index = $t01515315178._2 | |
500 | + | if ((totalSupply[index] == 0)) | |
501 | + | then $Tuple2((enteries ++ [IntegerEntry((tokenId + kPrevLendTokenSupply), totalSupply[index]), IntegerEntry((tokenId + kTokenRewardPerBlock), 0), IntegerEntry((tokenId + kTokenInterest), calcNewTokenInterest(tokenId, totalSupply[index])), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height]))]), (index + 1)) | |
502 | + | else { | |
503 | + | let share = fraction(totalSupplyUsd[index], SCALE8, totalSupplyUsdAll) | |
504 | + | let maxReward = fraction(share, lendMaxPeriodAmount, SCALE8) | |
505 | + | let maxRewardUsd = fraction(maxReward, axlyPrice, axlyPrecision) | |
506 | + | let prevTotalSupply = valueOrElse(getInteger(this, kPrevLendTokenSupply), 0) | |
507 | + | let rtCoef = if (if ((prevTotalSupply == 0)) | |
508 | + | then true | |
509 | + | else (totalSupply[index] == 0)) | |
510 | + | then 0 | |
511 | + | else fraction(prevTotalSupply, SCALE8, totalSupply[index]) | |
512 | + | let reward = (min([(maxAPR * (SCALE8 + rtCoef)), fraction(maxAPR, (15 * SCALE8), 10)]) / SCALE8) | |
513 | + | let rewardUsd = min([maxRewardUsd, fraction(totalSupplyUsd[index], reward, SCALE8)]) | |
514 | + | let rewardPeriod = fraction(rewardUsd, axlyPrecision, axlyPrice) | |
515 | + | let rewardPerBlock = (rewardPeriod / periodLength) | |
516 | + | $Tuple2((enteries ++ [IntegerEntry((tokenId + kPrevLendTokenSupply), totalSupply[index]), IntegerEntry((tokenId + kTokenRewardPerBlock), rewardPerBlock), IntegerEntry((tokenId + kTokenInterest), calcNewTokenInterest(tokenId, totalSupply[index])), IntegerEntry((tokenId + kTokenInterestHeight), max([startHeight, height]))]), (index + 1)) | |
517 | + | } | |
518 | + | } | |
521 | 519 | ||
522 | - | ||
523 | - | ||
524 | - | ||
525 | - | ||
526 | - | ||
527 | - | ||
528 | - | ||
520 | + | let $t01676516842 = { | |
521 | + | let $l = getAllTokens() | |
522 | + | let $s = size($l) | |
523 | + | let $acc0 = $Tuple2(nil, 0) | |
524 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
525 | + | then $a | |
526 | + | else updateReward($a, $l[$i]) | |
529 | 527 | ||
530 | - | ||
531 | - | ||
532 | - | ||
528 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
529 | + | then $a | |
530 | + | else throw("List size exceeds 30") | |
533 | 531 | ||
534 | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
535 | - | } | |
536 | - | let tokensEnteries = $t01700917101._1 | |
537 | - | let totalTokenReward = $t01700917101._2 | |
538 | - | let lpMaxAPR = getAdoptedAPRByPeriod(curPeriod, LP_APR_PERIODS, LP_APR) | |
539 | - | let lpTotalSupply = getIntegerValue(sfFarmingContract, (axlyPool + kSFTotalSupply)) | |
540 | - | let preLPSupply = valueOrElse(getInteger(this, kPrevLPSupply), 0) | |
541 | - | let lpId = getStringValue(addressFromStringValue(axlyPool), kLpId) | |
542 | - | let lpPrecision = getAssetPrecision(lpId) | |
543 | - | let lpPrice = { | |
544 | - | let @ = invoke(mainContract, "getShareAssetPriceREADONLY", [lpId], nil) | |
545 | - | if ($isInstanceOf(@, "Int")) | |
546 | - | then @ | |
547 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
548 | - | } | |
549 | - | let lpTotalSupplyUsd = fraction(lpTotalSupply, lpPrice, lpPrecision) | |
550 | - | let maxLPRewardUsd = fraction(lpMaxPeriodAmount, axlyPrice, axlyPrecision) | |
551 | - | let rtLPCoef = if (if ((preLPSupply == 0)) | |
552 | - | then true | |
553 | - | else (lpTotalSupply == 0)) | |
554 | - | then 0 | |
555 | - | else (fraction(lpTotalSupply, SCALE8, preLPSupply) - SCALE8) | |
556 | - | let rewardLp = ((min([(lpMaxAPR * (SCALE8 + max([rtLPCoef, 0]))), fraction(lpMaxAPR, (15 * SCALE8), 10)]) / SCALE8) / 100) | |
557 | - | let rewardLpUsd = min([maxLPRewardUsd, fraction(lpTotalSupplyUsd, rewardLp, SCALE8)]) | |
558 | - | let rewardLpPeriod = fraction(rewardLpUsd, axlyPrecision, axlyPrice) | |
559 | - | let rewardLpPerBlock = (rewardLpPeriod / periodLength) | |
560 | - | let burnLend = (lendMaxPeriodAmount - totalTokenReward) | |
561 | - | let burnLp = (lpMaxPeriodAmount - rewardLpPeriod) | |
562 | - | let inv = invoke(tokenContract, "withdrawLpReward", [(burnLend + burnLp), toString(this)], nil) | |
563 | - | if ((inv == inv)) | |
564 | - | then { | |
565 | - | let lpEnteries = if ((12 >= curPeriod)) | |
566 | - | then [IntegerEntry(kPrevLPSupply, lpTotalSupply), IntegerEntry(kLpRewardPerBlock, rewardLpPerBlock), IntegerEntry(kLpInterest, calcNewLpInterest(lpTotalSupply)), IntegerEntry(kLpInterestHeight, max([startHeight, height])), ScriptTransfer(Address(base58'3MsXJ3BesPECkYejzBQGHZPJT8GVYy4Fd3Q'), burnLend, fromBase58String(axlyId)), ScriptTransfer(Address(base58'3MsXJ3BesPECkYejzBQGHZPJT8GVYy4Fd3Q'), burnLp, fromBase58String(axlyId))] | |
567 | - | else nil | |
568 | - | ((lpEnteries ++ tokensEnteries) :+ IntegerEntry(kLastUpdatePeriod, curPeriod)) | |
569 | - | } | |
570 | - | else throw("Strict value is not equal to itself.") | |
532 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) | |
571 | 533 | } | |
534 | + | let tokensEnteries = $t01676516842._1 | |
535 | + | let index = $t01676516842._2 | |
536 | + | let lpMaxAPR = getAdoptedAPRByPeriod(curPeriod, LP_APR_PERIODS, LP_APR) | |
537 | + | let lpTotalSupply = getIntegerValue(sfFarmingContract, (axlyPool + kSFTotalSupply)) | |
538 | + | let preLPSupply = valueOrElse(getInteger(this, kPrevLPSupply), 0) | |
539 | + | let lpId = getStringValue(addressFromStringValue(axlyPool), kLpId) | |
540 | + | let lpPrecision = getAssetPrecision(lpId) | |
541 | + | let lpPrice = { | |
542 | + | let @ = invoke(mainContract, "getShareAssetPriceREADONLY", [lpId], nil) | |
543 | + | if ($isInstanceOf(@, "Int")) | |
544 | + | then @ | |
545 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
546 | + | } | |
547 | + | let lpTotalSupplyUsd = fraction(lpTotalSupply, lpPrice, lpPrecision) | |
548 | + | let maxLPRewardUsd = fraction(lpMaxPeriodAmount, axlyPrice, axlyPrecision) | |
549 | + | let rtLPCoef = if (if ((preLPSupply == 0)) | |
550 | + | then true | |
551 | + | else (lpTotalSupply == 0)) | |
552 | + | then 0 | |
553 | + | else fraction(preLPSupply, SCALE8, lpTotalSupply) | |
554 | + | let rewardLp = (min([(lpMaxAPR * (SCALE8 + rtLPCoef)), fraction(lpMaxAPR, (15 * SCALE8), 10)]) / SCALE8) | |
555 | + | let rewardLpUsd = min([maxLPRewardUsd, fraction(lpTotalSupplyUsd, rewardLp, SCALE8)]) | |
556 | + | let rewardLpPeriod = fraction(rewardLpUsd, axlyPrice, axlyPrecision) | |
557 | + | let rewardLpPerBlock = (rewardLpPeriod / periodLength) | |
558 | + | let lpEnteries = [IntegerEntry(kPrevLPSupply, lpTotalSupply), IntegerEntry(kLpRewardPerBlock, rewardLpPerBlock), IntegerEntry(kLpInterest, calcNewLpInterest(lpTotalSupply)), IntegerEntry(kLpInterestHeight, max([startHeight, height]))] | |
559 | + | ((lpEnteries ++ tokensEnteries) :+ IntegerEntry(kRewardUpdateHeight, max([startHeight, height]))) | |
560 | + | } | |
572 | 561 | }) | |
573 | 562 | ||
574 | 563 | ||
575 | 564 | @Verifier(tx) | |
576 | 565 | func verify () = { | |
577 | 566 | let multiSignedByAdmins = { | |
578 | 567 | let adminPubKey1Signed = if (sigVerify(tx.bodyBytes, tx.proofs[0], admin1PK)) | |
579 | 568 | then 1 | |
580 | 569 | else 0 | |
581 | 570 | let adminPubKey2Signed = if (sigVerify(tx.bodyBytes, tx.proofs[1], admin2PK)) | |
582 | 571 | then 1 | |
583 | 572 | else 0 | |
584 | 573 | let adminPubKey3Signed = if (sigVerify(tx.bodyBytes, tx.proofs[2], admin3PK)) | |
585 | 574 | then 1 | |
586 | 575 | else 0 | |
587 | 576 | (((adminPubKey1Signed + adminPubKey2Signed) + adminPubKey3Signed) >= 2) | |
588 | 577 | } | |
589 | 578 | match tx { | |
590 | 579 | case inv: InvokeScriptTransaction => | |
591 | 580 | let isSelf = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
592 | 581 | let isRightFee = if ((inv.fee == 900000)) | |
593 | 582 | then (inv.feeAssetId == unit) | |
594 | 583 | else false | |
595 | 584 | let isInitCall = (inv.function == "init") | |
596 | 585 | let isnoPayments = (size(inv.payments) == 0) | |
597 | 586 | if (if (if (if (isRightFee) | |
598 | 587 | then isInitCall | |
599 | 588 | else false) | |
600 | 589 | then isSelf | |
601 | 590 | else false) | |
602 | 591 | then isnoPayments | |
603 | 592 | else false) | |
604 | 593 | then true | |
605 | 594 | else multiSignedByAdmins | |
606 | 595 | case _ => | |
607 | 596 | multiSignedByAdmins | |
608 | 597 | } | |
609 | 598 | } | |
610 | 599 |
github/deemru/w8io/026f985 96.96 ms ◑