tx · EhLahnhRAZ4g4PS9GUxs3p4vafZ89q8j6Q1rkR5PjEA 3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE: -0.01600000 Waves 2023.08.31 11:56 [2734645] smart account 3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE > SELF 0.00000000 Waves
{ "type": 13, "id": "EhLahnhRAZ4g4PS9GUxs3p4vafZ89q8j6Q1rkR5PjEA", "fee": 1600000, "feeAssetId": null, "timestamp": 1693472237591, "version": 2, "chainId": 84, "sender": "3Mp5kisFrqESzrXxAMEPk2k69zpeF41czEE", "senderPublicKey": "G349Uq3FTox7dRNLeAfAQeoACvwZ9iEnVSaHcEYn6j8J", "proofs": [ "4tKaMVp6fkJBjJPjgDoRgjt1fJHZjJoWERRc19HVDPTVe5TxZaEMPeMYwdZ61xin71545oPcqdYjpoqEudWWJYEV" ], "script": "base64:BgLZFggCEgQKAgIBEgYKBAEYEQESBAoCCAESABIAEgMKAQgSABIECgIYERIAEgMKAQgSAwoBBCIDU0VQIgVTQ0FMRSIFTVVMVDgiB01VTFQ4QkkiCnplcm9CaWdJbnQiFHByb2Nlc3NpbmdTdGFnZVRvdGFsIhVwcm9jZXNzaW5nU3RhZ2VTaGFyZXMiBk1VTFQxOCIITVVMVDE4QkkiC3dhdmVzU3RyaW5nIgd3cmFwRXJyIgNtc2ciCHRocm93RXJyIg5nZXROdW1iZXJCeUtleSIDa2V5Ig9nZXROdW1iZXJPckZhaWwiDmdldFN0cmluZ0J5S2V5Ig9nZXRTdHJpbmdPckZhaWwiDHBhcnNlQXNzZXRJZCIFaW5wdXQiA2FicyIDdmFsIglhYnNCaWdJbnQiC2tleU1heERlcHRoIg9tYXhEZXB0aERlZmF1bHQiCG1heERlcHRoIhFrZXlGYWN0b3J5QWRkcmVzcyIRZmFjdG9yeUFkZHJlc3NTdHIiD2ZhY3RvcnlDb250cmFjdCISa2V5RW1pc3Npb25BZGRyZXNzIhlrZXlWb3RpbmdFbWlzc2lvbkNvbnRyYWN0I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XRzZWxmLgECY2wBAmNtAAQCY24EAmFTCQECYVUAAwkAAQIFAmFTAgpCeXRlVmVjdG9yBAJhWQUCYVMFAmFZAwkAAQIFAmFTAgRVbml0CAUCY2wPc2VuZGVyUHVibGljS2V5CQACAQILTWF0Y2ggZXJyb3IJAPQDAwgFAmNsCWJvZHlCeXRlcwkAkQMCCAUCY2wGcHJvb2ZzAAAFAmNuZJQbEQ==", "height": 2734645, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G6fZHDhXeatGFoj34kPv9VhdwkiimeX6CM7cG5843yyL Next: 7NvuJ4KAwoJojGajdTuS9iD8jBXST7tKbdzaxaDqENZV Diff:
Old | New | Differences | |
---|---|---|---|
144 | 144 | } | |
145 | 145 | ||
146 | 146 | ||
147 | + | let keySuspension = "%s__suspension" | |
148 | + | ||
149 | + | let isSuspended = valueOrElse(getBoolean(this, keySuspension), false) | |
150 | + | ||
151 | + | func throwIfSuspended () = if (!(isSuspended)) | |
152 | + | then true | |
153 | + | else throwErr("suspended") | |
154 | + | ||
155 | + | ||
147 | 156 | func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight" | |
148 | 157 | ||
149 | 158 | ||
284 | 293 | ||
285 | 294 | ||
286 | 295 | func _refreshUserReward (userAddress,userNum) = { | |
287 | - | let $ | |
288 | - | let rewardPerGwxIntegralActions = $ | |
289 | - | let rewardPerGwxIntegral = $ | |
296 | + | let $t01029210380 = _refreshRewardPerGwxIntegral() | |
297 | + | let rewardPerGwxIntegralActions = $t01029210380._1 | |
298 | + | let rewardPerGwxIntegral = $t01029210380._2 | |
290 | 299 | let rewardPerGwxIntegralUserLast = match getString(this, keyRewardPerGwxIntegralUserLast(userAddress)) { | |
291 | 300 | case s: String => | |
292 | 301 | valueOrErrorMessage(parseBigInt(s), wrapErr("invalid user last integral")) | |
307 | 316 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
308 | 317 | let cfgArray = readConfigArrayOrFail() | |
309 | 318 | let userNum = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddressStr) | |
310 | - | let $ | |
311 | - | let actions = $ | |
312 | - | let reward = $ | |
319 | + | let $t01167111735 = _refreshUserReward(userAddress, userNum) | |
320 | + | let actions = $t01167111735._1 | |
321 | + | let reward = $t01167111735._2 | |
313 | 322 | $Tuple2(reward, ([IntegerEntry(keyUserUnclaimed(userNum), 0)] ++ actions)) | |
314 | 323 | } | |
315 | 324 | ||
316 | 325 | ||
317 | 326 | @Callable(i) | |
318 | 327 | func refreshUserReward (userAddressBytes,userNum) = { | |
319 | - | let checkCaller = if ((i.caller == boostingContractOrFail())) | |
320 | - | then true | |
321 | - | else throwErr("permission denied") | |
322 | - | if ((checkCaller == checkCaller)) | |
328 | + | let suspensionCheck = throwIfSuspended() | |
329 | + | if ((suspensionCheck == suspensionCheck)) | |
323 | 330 | then { | |
324 | - | let $t01184511923 = _refreshUserReward(Address(userAddressBytes), userNum) | |
325 | - | let actions = $t01184511923._1 | |
326 | - | let reward = $t01184511923._2 | |
327 | - | $Tuple2(([IntegerEntry(keyUserUnclaimed(userNum), reward)] ++ actions), reward) | |
331 | + | let checkCaller = if ((i.caller == boostingContractOrFail())) | |
332 | + | then true | |
333 | + | else throwErr("permission denied") | |
334 | + | if ((checkCaller == checkCaller)) | |
335 | + | then { | |
336 | + | let $t01206112139 = _refreshUserReward(Address(userAddressBytes), userNum) | |
337 | + | let actions = $t01206112139._1 | |
338 | + | let reward = $t01206112139._2 | |
339 | + | $Tuple2(([IntegerEntry(keyUserUnclaimed(userNum), reward)] ++ actions), reward) | |
340 | + | } | |
341 | + | else throw("Strict value is not equal to itself.") | |
328 | 342 | } | |
329 | 343 | else throw("Strict value is not equal to itself.") | |
330 | 344 | } | |
332 | 346 | ||
333 | 347 | ||
334 | 348 | @Callable(i) | |
335 | - | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = | |
336 | - | | |
337 | - | | |
338 | - | | |
339 | - | then | |
340 | - | else | |
341 | - | | |
342 | - | | |
343 | - | if (( | |
344 | - | then | |
345 | - | | |
346 | - | if (( | |
349 | + | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = { | |
350 | + | let suspensionCheck = throwIfSuspended() | |
351 | + | if ((suspensionCheck == suspensionCheck)) | |
352 | + | then if ((currentIter == size(userAddresses))) | |
353 | + | then nil | |
354 | + | else { | |
355 | + | let checks = [if ((i.caller == this)) | |
356 | + | then true | |
357 | + | else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter])) | |
358 | + | then true | |
359 | + | else throwErr("insufficient payment assetId")] | |
360 | + | if ((checks == checks)) | |
347 | 361 | then { | |
348 | - | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
349 | - | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
350 | - | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal) | |
362 | + | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil) | |
363 | + | if ((tradeRewardInternal == tradeRewardInternal)) | |
364 | + | then { | |
365 | + | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
366 | + | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
367 | + | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal) | |
368 | + | } | |
369 | + | else throw("Strict value is not equal to itself.") | |
351 | 370 | } | |
352 | 371 | else throw("Strict value is not equal to itself.") | |
353 | 372 | } | |
354 | - | ||
355 | - | ||
373 | + | else throw("Strict value is not equal to itself.") | |
374 | + | } | |
356 | 375 | ||
357 | 376 | ||
358 | 377 | ||
359 | 378 | @Callable(i) | |
360 | 379 | func updateReferralActivity (userAddress,gWxAmountStart) = { | |
361 | - | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
362 | - | let activeReferralInv = if ((referrer == unit)) | |
363 | - | then unit | |
364 | - | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
365 | - | if ((activeReferralInv == activeReferralInv)) | |
366 | - | then $Tuple2(nil, unit) | |
380 | + | let suspensionCheck = throwIfSuspended() | |
381 | + | if ((suspensionCheck == suspensionCheck)) | |
382 | + | then { | |
383 | + | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
384 | + | let activeReferralInv = if ((referrer == unit)) | |
385 | + | then unit | |
386 | + | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
387 | + | if ((activeReferralInv == activeReferralInv)) | |
388 | + | then $Tuple2(nil, unit) | |
389 | + | else throw("Strict value is not equal to itself.") | |
390 | + | } | |
367 | 391 | else throw("Strict value is not equal to itself.") | |
368 | 392 | } | |
369 | 393 | ||
376 | 400 | ||
377 | 401 | @Callable(i) | |
378 | 402 | func claimReward () = { | |
379 | - | let cfgArray = readConfigArrayOrFail() | |
380 | - | let userAddress = i.caller | |
381 | - | let userAddressStr = toString(userAddress) | |
382 | - | let $t01365513712 = commonClaimReward(userAddressStr) | |
383 | - | let amount = $t01365513712._1 | |
384 | - | let actions = $t01365513712._2 | |
385 | - | let checkAmount = if ((amount > 0)) | |
386 | - | then true | |
387 | - | else throw("nothing to claim") | |
388 | - | if ((checkAmount == checkAmount)) | |
403 | + | let suspensionCheck = throwIfSuspended() | |
404 | + | if ((suspensionCheck == suspensionCheck)) | |
389 | 405 | then { | |
390 | - | let userGwxAmount = { | |
391 | - | let @ = invoke(boostingContractOrFail(), "getUserGwxAmount", [userAddressStr], nil) | |
392 | - | if ($isInstanceOf(@, "Int")) | |
393 | - | then @ | |
394 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
395 | - | } | |
396 | - | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddressStr)) | |
397 | - | let activeReferralInv = if ((referrer == unit)) | |
398 | - | then unit | |
399 | - | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userGwxAmount >= referralMinGWxAmount)], nil) | |
400 | - | if ((activeReferralInv == activeReferralInv)) | |
406 | + | let cfgArray = readConfigArrayOrFail() | |
407 | + | let userAddress = i.caller | |
408 | + | let userAddressStr = toString(userAddress) | |
409 | + | let $t01400914066 = commonClaimReward(userAddressStr) | |
410 | + | let amount = $t01400914066._1 | |
411 | + | let actions = $t01400914066._2 | |
412 | + | let checkAmount = if ((amount > 0)) | |
413 | + | then true | |
414 | + | else throw("nothing to claim") | |
415 | + | if ((checkAmount == checkAmount)) | |
401 | 416 | then { | |
402 | - | let referralInv = if (if ((referrer == unit)) | |
403 | - | then true | |
404 | - | else (referralMinGWxAmount > userGwxAmount)) | |
417 | + | let userGwxAmount = { | |
418 | + | let @ = invoke(boostingContractOrFail(), "getUserGwxAmount", [userAddressStr], nil) | |
419 | + | if ($isInstanceOf(@, "Int")) | |
420 | + | then @ | |
421 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
422 | + | } | |
423 | + | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddressStr)) | |
424 | + | let activeReferralInv = if ((referrer == unit)) | |
405 | 425 | then unit | |
406 | - | else { | |
407 | - | let referrerReward = fraction(amount, referrerRewardPermille, SCALE) | |
408 | - | let referralReward = fraction(amount, referralRewardPermille, SCALE) | |
409 | - | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
410 | - | } | |
411 | - | if ((referralInv == referralInv)) | |
426 | + | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userGwxAmount >= referralMinGWxAmount)], nil) | |
427 | + | if ((activeReferralInv == activeReferralInv)) | |
412 | 428 | then { | |
413 | - | let emit = invoke(emissionContract, "emit", [amount], nil) | |
414 | - | if ((emit == emit)) | |
429 | + | let referralInv = if (if ((referrer == unit)) | |
430 | + | then true | |
431 | + | else (referralMinGWxAmount > userGwxAmount)) | |
432 | + | then unit | |
433 | + | else { | |
434 | + | let referrerReward = fraction(amount, referrerRewardPermille, SCALE) | |
435 | + | let referralReward = fraction(amount, referralRewardPermille, SCALE) | |
436 | + | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
437 | + | } | |
438 | + | if ((referralInv == referralInv)) | |
415 | 439 | then { | |
416 | - | let claimedReferral = { | |
417 | - | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
418 | - | if ($isInstanceOf(@, "Int")) | |
419 | - | then @ | |
420 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
421 | - | } | |
422 | - | if ((claimedReferral == claimedReferral)) | |
440 | + | let emit = invoke(emissionContract, "emit", [amount], nil) | |
441 | + | if ((emit == emit)) | |
423 | 442 | then { | |
424 | - | let totalAmount = (amount + claimedReferral) | |
425 | - | $Tuple2(([ScriptTransfer(i.caller, amount, wxAssetId), HistoryEntry("claim", userAddressStr, totalAmount, i)] ++ actions), totalAmount) | |
443 | + | let claimedReferral = { | |
444 | + | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
445 | + | if ($isInstanceOf(@, "Int")) | |
446 | + | then @ | |
447 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
448 | + | } | |
449 | + | if ((claimedReferral == claimedReferral)) | |
450 | + | then { | |
451 | + | let totalAmount = (amount + claimedReferral) | |
452 | + | $Tuple2(([ScriptTransfer(i.caller, amount, wxAssetId), HistoryEntry("claim", userAddressStr, totalAmount, i)] ++ actions), totalAmount) | |
453 | + | } | |
454 | + | else throw("Strict value is not equal to itself.") | |
426 | 455 | } | |
427 | 456 | else throw("Strict value is not equal to itself.") | |
428 | 457 | } | |
439 | 468 | ||
440 | 469 | @Callable(i) | |
441 | 470 | func claimRewardREADONLY (address) = { | |
442 | - | let $ | |
443 | - | let amount = $ | |
444 | - | let actions = $ | |
471 | + | let $t01542315473 = commonClaimReward(address) | |
472 | + | let amount = $t01542315473._1 | |
473 | + | let actions = $t01542315473._2 | |
445 | 474 | let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0) | |
446 | 475 | let totalAmount = (amount + referralUnclaimed) | |
447 | 476 | $Tuple2(nil, totalAmount) | |
450 | 479 | ||
451 | 480 | ||
452 | 481 | @Callable(i) | |
453 | - | func onEmissionForGwxStart () = if ((i.caller != factoryContract)) | |
454 | - | then throw("permissions denied") | |
455 | - | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
482 | + | func onEmissionForGwxStart () = { | |
483 | + | let suspensionCheck = throwIfSuspended() | |
484 | + | if ((suspensionCheck == suspensionCheck)) | |
485 | + | then if ((i.caller != factoryContract)) | |
486 | + | then throw("permissions denied") | |
487 | + | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
488 | + | else throw("Strict value is not equal to itself.") | |
489 | + | } | |
456 | 490 | ||
457 | 491 | ||
458 | 492 | ||
459 | 493 | @Callable(i) | |
460 | 494 | func tradeReward (userAddresses,rewards) = { | |
461 | - | let argsComparison = (size(userAddresses) == size(rewards)) | |
462 | - | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
463 | - | let payment = i.payments[0] | |
464 | - | let paymentAssetId = payment.assetId | |
465 | - | let paymentAmount = payment.amount | |
466 | - | let checks = [if ((maxRecipients >= size(userAddresses))) | |
467 | - | then true | |
468 | - | else throwErr("Too many recipients"), if (argsComparison) | |
469 | - | then true | |
470 | - | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
471 | - | then true | |
472 | - | else throwErr("Wrong asset payment")] | |
473 | - | if ((checks == checks)) | |
495 | + | let suspensionCheck = throwIfSuspended() | |
496 | + | if ((suspensionCheck == suspensionCheck)) | |
474 | 497 | then { | |
475 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
476 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
477 | - | then $Tuple2(nil, tradeRewardInternal) | |
498 | + | let argsComparison = (size(userAddresses) == size(rewards)) | |
499 | + | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
500 | + | let payment = i.payments[0] | |
501 | + | let paymentAssetId = payment.assetId | |
502 | + | let paymentAmount = payment.amount | |
503 | + | let checks = [if ((maxRecipients >= size(userAddresses))) | |
504 | + | then true | |
505 | + | else throwErr("Too many recipients"), if (argsComparison) | |
506 | + | then true | |
507 | + | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
508 | + | then true | |
509 | + | else throwErr("Wrong asset payment")] | |
510 | + | if ((checks == checks)) | |
511 | + | then { | |
512 | + | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
513 | + | if ((tradeRewardInternal == tradeRewardInternal)) | |
514 | + | then $Tuple2(nil, tradeRewardInternal) | |
515 | + | else throw("Strict value is not equal to itself.") | |
516 | + | } | |
478 | 517 | else throw("Strict value is not equal to itself.") | |
479 | 518 | } | |
480 | 519 | else throw("Strict value is not equal to itself.") | |
484 | 523 | ||
485 | 524 | @Callable(i) | |
486 | 525 | func claimTradingReward () = { | |
487 | - | let userAddress = i.caller | |
488 | - | let userAddressString = toString(userAddress) | |
489 | - | let reward = getTradingReward(userAddressString) | |
490 | - | if ((reward > 0)) | |
491 | - | then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward) | |
492 | - | else throwErr("nothing to claim") | |
526 | + | let suspensionCheck = throwIfSuspended() | |
527 | + | if ((suspensionCheck == suspensionCheck)) | |
528 | + | then { | |
529 | + | let userAddress = i.caller | |
530 | + | let userAddressString = toString(userAddress) | |
531 | + | let reward = getTradingReward(userAddressString) | |
532 | + | if ((reward > 0)) | |
533 | + | then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward) | |
534 | + | else throwErr("nothing to claim") | |
535 | + | } | |
536 | + | else throw("Strict value is not equal to itself.") | |
493 | 537 | } | |
494 | 538 | ||
495 | 539 | ||
496 | 540 | ||
497 | 541 | @Callable(i) | |
498 | 542 | func claimTradingRewardREADONLY (userAddress) = $Tuple2(nil, getTradingReward(userAddress)) | |
543 | + | ||
544 | + | ||
545 | + | ||
546 | + | @Callable(i) | |
547 | + | func suspend (v) = { | |
548 | + | let checkCaller = mustManager(i) | |
549 | + | if ((checkCaller == checkCaller)) | |
550 | + | then $Tuple2([BooleanEntry(keySuspension, v)], v) | |
551 | + | else throw("Strict value is not equal to itself.") | |
552 | + | } | |
499 | 553 | ||
500 | 554 | ||
501 | 555 | @Verifier(tx) |
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 SCALE = 1000 | |
7 | 7 | ||
8 | 8 | let MULT8 = 100000000 | |
9 | 9 | ||
10 | 10 | let MULT8BI = toBigInt(MULT8) | |
11 | 11 | ||
12 | 12 | let zeroBigInt = toBigInt(0) | |
13 | 13 | ||
14 | 14 | let processingStageTotal = 0 | |
15 | 15 | ||
16 | 16 | let processingStageShares = 1 | |
17 | 17 | ||
18 | 18 | let MULT18 = 1000000000000000000 | |
19 | 19 | ||
20 | 20 | let MULT18BI = toBigInt(MULT18) | |
21 | 21 | ||
22 | 22 | let wavesString = "WAVES" | |
23 | 23 | ||
24 | 24 | func wrapErr (msg) = makeString(["gwx_reward.ride:", msg], " ") | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func throwErr (msg) = throw(wrapErr(msg)) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func getNumberOrFail (key) = valueOrErrorMessage(getInteger(this, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), wrapErr((("mandatory this." + key) + " is not defined"))) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func parseAssetId (input) = if ((input == wavesString)) | |
43 | 43 | then unit | |
44 | 44 | else fromBase58String(input) | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func abs (val) = if ((0 > val)) | |
48 | 48 | then -(val) | |
49 | 49 | else val | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func absBigInt (val) = if ((zeroBigInt > val)) | |
53 | 53 | then -(val) | |
54 | 54 | else val | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | let keyMaxDepth = "%s__maxDepth" | |
58 | 58 | ||
59 | 59 | let maxDepthDefault = 30 | |
60 | 60 | ||
61 | 61 | let maxDepth = valueOrElse(getInteger(this, keyMaxDepth), maxDepthDefault) | |
62 | 62 | ||
63 | 63 | func keyFactoryAddress () = "%s%s__config__factoryAddress" | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | let factoryAddressStr = getStringOrFail(keyFactoryAddress()) | |
67 | 67 | ||
68 | 68 | let factoryContract = addressFromStringValue(factoryAddressStr) | |
69 | 69 | ||
70 | 70 | func keyEmissionAddress () = "%s%s__config__emissionAddress" | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func keyVotingEmissionContract () = makeString(["%s", "votingEmissionContract"], SEP) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | let votingEmissionContract = addressFromStringValue(getStringValue(factoryContract, keyVotingEmissionContract())) | |
77 | 77 | ||
78 | 78 | func keyNumToUserMapping (num) = makeString(["%s%s%s", "mapping", "num2user", toString(num)], SEP) | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | let keyReferralProgramName = makeString(["%s%s", "referral", "programName"], SEP) | |
82 | 82 | ||
83 | 83 | let referralProgramNameDefault = "wxlock" | |
84 | 84 | ||
85 | 85 | let referralProgramName = valueOrElse(getString(this, keyReferralProgramName), referralProgramNameDefault) | |
86 | 86 | ||
87 | 87 | let keyReferralMinGWxAmount = makeString(["%s%s", "referral", "minGWxAmount"], SEP) | |
88 | 88 | ||
89 | 89 | let referralMinGWxAmountDefault = (500 * MULT8) | |
90 | 90 | ||
91 | 91 | let referralMinGWxAmount = valueOrElse(getInteger(this, keyReferralMinGWxAmount), referralMinGWxAmountDefault) | |
92 | 92 | ||
93 | 93 | let keyReferrerRewardPermille = makeString(["%s%s", "referral", "referrerRewardPermille"], SEP) | |
94 | 94 | ||
95 | 95 | let referrerRewardPermilleDefault = 50 | |
96 | 96 | ||
97 | 97 | let referrerRewardPermille = valueOrElse(getInteger(this, keyReferrerRewardPermille), referrerRewardPermilleDefault) | |
98 | 98 | ||
99 | 99 | let keyReferralRewardPermille = makeString(["%s%s", "referral", "referralRewardPermille"], SEP) | |
100 | 100 | ||
101 | 101 | let referralRewardPermilleDefault = 50 | |
102 | 102 | ||
103 | 103 | let referralRewardPermille = valueOrElse(getInteger(this, keyReferralRewardPermille), referralRewardPermilleDefault) | |
104 | 104 | ||
105 | 105 | func keyReferrer (referralAddress) = makeString(["%s%s%s", "referrer", referralProgramName, referralAddress], SEP) | |
106 | 106 | ||
107 | 107 | ||
108 | 108 | func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], SEP) | |
109 | 109 | ||
110 | 110 | ||
111 | 111 | let emissionAddressStr = getStringOrFail(keyEmissionAddress()) | |
112 | 112 | ||
113 | 113 | let emissionContract = addressFromStringValue(emissionAddressStr) | |
114 | 114 | ||
115 | 115 | let IdxCfgAssetId = 1 | |
116 | 116 | ||
117 | 117 | let IdxCfgPacemakerAddress = 2 | |
118 | 118 | ||
119 | 119 | let IdxCfgBoostingContract = 3 | |
120 | 120 | ||
121 | 121 | let IdxCfgMaxDepth = 4 | |
122 | 122 | ||
123 | 123 | func keyConfig () = "%s__config" | |
124 | 124 | ||
125 | 125 | ||
126 | 126 | func getEmissionAddress () = addressFromStringValue(valueOrErrorMessage(getString(this, keyEmissionAddress()), (("mandatory this." + keyEmissionAddress()) + " is not defined"))) | |
127 | 127 | ||
128 | 128 | ||
129 | 129 | let emissionAddress = getEmissionAddress() | |
130 | 130 | ||
131 | 131 | let wxAssetIdStr = split(value(getString(emissionAddress, keyConfig())), SEP)[1] | |
132 | 132 | ||
133 | 133 | let wxAssetId = fromBase58String(wxAssetIdStr) | |
134 | 134 | ||
135 | 135 | func readConfigArrayOrFail () = split(getStringOrFail(keyConfig()), SEP) | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | func formatConfig (wxAssetIdStr,matcherPacemakerAddressStr,boostingContractAddressStr,maxDepth) = makeString(["%s%s%s%d", wxAssetIdStr, matcherPacemakerAddressStr, boostingContractAddressStr, toString(maxDepth)], SEP) | |
139 | 139 | ||
140 | 140 | ||
141 | 141 | func boostingContractOrFail () = { | |
142 | 142 | let cfgArray = readConfigArrayOrFail() | |
143 | 143 | valueOrErrorMessage(addressFromString(cfgArray[IdxCfgBoostingContract]), "boosting contract address is not defined") | |
144 | 144 | } | |
145 | 145 | ||
146 | 146 | ||
147 | + | let keySuspension = "%s__suspension" | |
148 | + | ||
149 | + | let isSuspended = valueOrElse(getBoolean(this, keySuspension), false) | |
150 | + | ||
151 | + | func throwIfSuspended () = if (!(isSuspended)) | |
152 | + | then true | |
153 | + | else throwErr("suspended") | |
154 | + | ||
155 | + | ||
147 | 156 | func keyGwxRewardEmissionStartHeight () = "%s%s__gwxRewardEmissionPart__startHeight" | |
148 | 157 | ||
149 | 158 | ||
150 | 159 | func keyUsersCount () = "%s__nextUserNum" | |
151 | 160 | ||
152 | 161 | ||
153 | 162 | func keyUser2NumMapping (userAddress) = makeString(["%s%s%s__mapping__user2num", toString(userAddress)], SEP) | |
154 | 163 | ||
155 | 164 | ||
156 | 165 | func keyRatePerBlockCurrent () = "%s%s__ratePerBlock__current" | |
157 | 166 | ||
158 | 167 | ||
159 | 168 | func keyGwxHoldersRewardCurrent () = "%s%s__gwxHoldersReward__current" | |
160 | 169 | ||
161 | 170 | ||
162 | 171 | func keyGwxHoldersRewardNext () = "%s%s__gwxHoldersReward__next" | |
163 | 172 | ||
164 | 173 | ||
165 | 174 | func keyPoolWeightVirtual () = "%s%s__poolWeight__GWXvirtualPOOL" | |
166 | 175 | ||
167 | 176 | ||
168 | 177 | func keyUserUnclaimed (userIndex) = makeString(["%s%d", "userUnclaimed", toString(userIndex)], SEP) | |
169 | 178 | ||
170 | 179 | ||
171 | 180 | func keyReferralsContractAddress () = makeString(["%s%s", "config", "referralsContractAddress"], SEP) | |
172 | 181 | ||
173 | 182 | ||
174 | 183 | let referralsContractAddressOrFail = addressFromStringValue(getStringOrFail(keyReferralsContractAddress())) | |
175 | 184 | ||
176 | 185 | func keyTradingRewardHistory (user,i) = makeString(["%s%s%s%s", "tradingReward", "history", user, toBase58String(i.transactionId)], SEP) | |
177 | 186 | ||
178 | 187 | ||
179 | 188 | func keyTradingReward (userAddress) = makeString(["%s%s", "tradingReward", userAddress], SEP) | |
180 | 189 | ||
181 | 190 | ||
182 | 191 | func keyMaxRecipients () = makeString(["%s", "maxRecipients"], SEP) | |
183 | 192 | ||
184 | 193 | ||
185 | 194 | func HistoryEntry (type,user,amount,i) = { | |
186 | 195 | let historyKEY = makeString(["%s%s%s%s__history", type, user, toBase58String(i.transactionId)], SEP) | |
187 | 196 | let historyDATA = makeString(["%d%d%d%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount)], SEP) | |
188 | 197 | StringEntry(historyKEY, historyDATA) | |
189 | 198 | } | |
190 | 199 | ||
191 | 200 | ||
192 | 201 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
193 | 202 | ||
194 | 203 | ||
195 | 204 | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
196 | 205 | ||
197 | 206 | ||
198 | 207 | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
199 | 208 | case s: String => | |
200 | 209 | addressFromStringValue(s) | |
201 | 210 | case _ => | |
202 | 211 | this | |
203 | 212 | } | |
204 | 213 | ||
205 | 214 | ||
206 | 215 | func managerPublicKeyOrUnit () = { | |
207 | 216 | let managerVaultAddress = getManagerVaultAddressOrThis() | |
208 | 217 | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
209 | 218 | case s: String => | |
210 | 219 | fromBase58String(s) | |
211 | 220 | case _: Unit => | |
212 | 221 | unit | |
213 | 222 | case _ => | |
214 | 223 | throw("Match error") | |
215 | 224 | } | |
216 | 225 | } | |
217 | 226 | ||
218 | 227 | ||
219 | 228 | func mustManager (i) = { | |
220 | 229 | let pd = throw("Permission denied") | |
221 | 230 | match managerPublicKeyOrUnit() { | |
222 | 231 | case pk: ByteVector => | |
223 | 232 | if ((i.callerPublicKey == pk)) | |
224 | 233 | then true | |
225 | 234 | else pd | |
226 | 235 | case _: Unit => | |
227 | 236 | if ((i.caller == this)) | |
228 | 237 | then true | |
229 | 238 | else pd | |
230 | 239 | case _ => | |
231 | 240 | throw("Match error") | |
232 | 241 | } | |
233 | 242 | } | |
234 | 243 | ||
235 | 244 | ||
236 | 245 | func getUserIndexByAddress (boostingContractAddressStr,userAddress) = { | |
237 | 246 | let key = makeString(["%s%s%s", "mapping", "user2num", userAddress], SEP) | |
238 | 247 | parseIntValue(valueOrErrorMessage(getString(Address(fromBase58String(boostingContractAddressStr)), key), ((("User address " + userAddress) + " is not found in boosting contract data, key=") + key))) | |
239 | 248 | } | |
240 | 249 | ||
241 | 250 | ||
242 | 251 | func getTradingReward (userAddress) = valueOrElse(getInteger(this, keyTradingReward(userAddress)), 0) | |
243 | 252 | ||
244 | 253 | ||
245 | 254 | func keyRewardPerGwxIntegral () = makeString(["%s", "rewardPerGwxIntegral"], SEP) | |
246 | 255 | ||
247 | 256 | ||
248 | 257 | func getGwxAmountTotalOption () = { | |
249 | 258 | let keyGwxTotal = "%s%s__gwx__total" | |
250 | 259 | getInteger(boostingContractOrFail(), keyGwxTotal) | |
251 | 260 | } | |
252 | 261 | ||
253 | 262 | ||
254 | 263 | func getUserGwxAmountTotalOption (userAddress) = { | |
255 | 264 | func keyUserGwxAmountTotal (userAddress) = makeString(["%s%s__gwxAmountTotal", toString(userAddress)], SEP) | |
256 | 265 | ||
257 | 266 | getInteger(boostingContractOrFail(), keyUserGwxAmountTotal(userAddress)) | |
258 | 267 | } | |
259 | 268 | ||
260 | 269 | ||
261 | 270 | func _refreshRewardPerGwxIntegral () = { | |
262 | 271 | let rewardPerGwxIntegralPrevious = valueOrElse( match getString(this, keyRewardPerGwxIntegral()) { | |
263 | 272 | case s: String => | |
264 | 273 | parseBigInt(s) | |
265 | 274 | case _: Unit => | |
266 | 275 | unit | |
267 | 276 | case _ => | |
268 | 277 | throw("Match error") | |
269 | 278 | }, zeroBigInt) | |
270 | 279 | let rewardPerGwxIntegralLastHeight = valueOrErrorMessage(getInteger(this, keyGwxRewardEmissionStartHeight()), wrapErr(("invalid " + keyGwxRewardEmissionStartHeight()))) | |
271 | 280 | let emissionRate = valueOrErrorMessage(getInteger(emissionContract, keyRatePerBlockCurrent()), wrapErr(("invalid " + keyRatePerBlockCurrent()))) | |
272 | 281 | let gwxHoldersRewardCurrent = valueOrElse(getInteger(emissionContract, keyGwxHoldersRewardCurrent()), 0) | |
273 | 282 | let gwxAmountTotal = valueOrElse(getGwxAmountTotalOption(), 0) | |
274 | 283 | let dh = toBigInt((height - rewardPerGwxIntegralLastHeight)) | |
275 | 284 | let gwxAmountTotalBI = toBigInt(gwxAmountTotal) | |
276 | 285 | let rewardPerGwxIntegral = (rewardPerGwxIntegralPrevious + (if ((gwxAmountTotalBI == zeroBigInt)) | |
277 | 286 | then zeroBigInt | |
278 | 287 | else fraction(dh, ((toBigInt(emissionRate) * toBigInt(gwxHoldersRewardCurrent)) * MULT18BI), (gwxAmountTotalBI * MULT8BI)))) | |
279 | 288 | $Tuple2([IntegerEntry(keyGwxRewardEmissionStartHeight(), height), StringEntry(keyRewardPerGwxIntegral(), toString(rewardPerGwxIntegral))], rewardPerGwxIntegral) | |
280 | 289 | } | |
281 | 290 | ||
282 | 291 | ||
283 | 292 | func keyRewardPerGwxIntegralUserLast (userAddress) = makeString(["%s%s", "rewardPerGwxIntegralUserLast", toString(userAddress)], SEP) | |
284 | 293 | ||
285 | 294 | ||
286 | 295 | func _refreshUserReward (userAddress,userNum) = { | |
287 | - | let $ | |
288 | - | let rewardPerGwxIntegralActions = $ | |
289 | - | let rewardPerGwxIntegral = $ | |
296 | + | let $t01029210380 = _refreshRewardPerGwxIntegral() | |
297 | + | let rewardPerGwxIntegralActions = $t01029210380._1 | |
298 | + | let rewardPerGwxIntegral = $t01029210380._2 | |
290 | 299 | let rewardPerGwxIntegralUserLast = match getString(this, keyRewardPerGwxIntegralUserLast(userAddress)) { | |
291 | 300 | case s: String => | |
292 | 301 | valueOrErrorMessage(parseBigInt(s), wrapErr("invalid user last integral")) | |
293 | 302 | case _: Unit => | |
294 | 303 | rewardPerGwxIntegral | |
295 | 304 | case _ => | |
296 | 305 | throw("Match error") | |
297 | 306 | } | |
298 | 307 | let userIdxOption = getString(boostingContractOrFail(), keyUser2NumMapping(userAddress)) | |
299 | 308 | let userUnclaimed = valueOrElse(getInteger(keyUserUnclaimed(userNum)), 0) | |
300 | 309 | let userGwxAmount = valueOrElse(getUserGwxAmountTotalOption(userAddress), 0) | |
301 | 310 | let userReward = (toInt(fraction(toBigInt(userGwxAmount), (rewardPerGwxIntegral - rewardPerGwxIntegralUserLast), MULT18BI)) + userUnclaimed) | |
302 | 311 | $Tuple2(([StringEntry(keyRewardPerGwxIntegralUserLast(userAddress), toString(rewardPerGwxIntegral))] ++ rewardPerGwxIntegralActions), userReward) | |
303 | 312 | } | |
304 | 313 | ||
305 | 314 | ||
306 | 315 | func commonClaimReward (userAddressStr) = { | |
307 | 316 | let userAddress = valueOrErrorMessage(addressFromString(userAddressStr), wrapErr("invalid user address")) | |
308 | 317 | let cfgArray = readConfigArrayOrFail() | |
309 | 318 | let userNum = getUserIndexByAddress(cfgArray[IdxCfgBoostingContract], userAddressStr) | |
310 | - | let $ | |
311 | - | let actions = $ | |
312 | - | let reward = $ | |
319 | + | let $t01167111735 = _refreshUserReward(userAddress, userNum) | |
320 | + | let actions = $t01167111735._1 | |
321 | + | let reward = $t01167111735._2 | |
313 | 322 | $Tuple2(reward, ([IntegerEntry(keyUserUnclaimed(userNum), 0)] ++ actions)) | |
314 | 323 | } | |
315 | 324 | ||
316 | 325 | ||
317 | 326 | @Callable(i) | |
318 | 327 | func refreshUserReward (userAddressBytes,userNum) = { | |
319 | - | let checkCaller = if ((i.caller == boostingContractOrFail())) | |
320 | - | then true | |
321 | - | else throwErr("permission denied") | |
322 | - | if ((checkCaller == checkCaller)) | |
328 | + | let suspensionCheck = throwIfSuspended() | |
329 | + | if ((suspensionCheck == suspensionCheck)) | |
323 | 330 | then { | |
324 | - | let $t01184511923 = _refreshUserReward(Address(userAddressBytes), userNum) | |
325 | - | let actions = $t01184511923._1 | |
326 | - | let reward = $t01184511923._2 | |
327 | - | $Tuple2(([IntegerEntry(keyUserUnclaimed(userNum), reward)] ++ actions), reward) | |
331 | + | let checkCaller = if ((i.caller == boostingContractOrFail())) | |
332 | + | then true | |
333 | + | else throwErr("permission denied") | |
334 | + | if ((checkCaller == checkCaller)) | |
335 | + | then { | |
336 | + | let $t01206112139 = _refreshUserReward(Address(userAddressBytes), userNum) | |
337 | + | let actions = $t01206112139._1 | |
338 | + | let reward = $t01206112139._2 | |
339 | + | $Tuple2(([IntegerEntry(keyUserUnclaimed(userNum), reward)] ++ actions), reward) | |
340 | + | } | |
341 | + | else throw("Strict value is not equal to itself.") | |
328 | 342 | } | |
329 | 343 | else throw("Strict value is not equal to itself.") | |
330 | 344 | } | |
331 | 345 | ||
332 | 346 | ||
333 | 347 | ||
334 | 348 | @Callable(i) | |
335 | - | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = | |
336 | - | | |
337 | - | | |
338 | - | | |
339 | - | then | |
340 | - | else | |
341 | - | | |
342 | - | | |
343 | - | if (( | |
344 | - | then | |
345 | - | | |
346 | - | if (( | |
349 | + | func tradeRewardInternal (paymentAmountLeftOver,userAddresses,rewards,currentIter) = { | |
350 | + | let suspensionCheck = throwIfSuspended() | |
351 | + | if ((suspensionCheck == suspensionCheck)) | |
352 | + | then if ((currentIter == size(userAddresses))) | |
353 | + | then nil | |
354 | + | else { | |
355 | + | let checks = [if ((i.caller == this)) | |
356 | + | then true | |
357 | + | else throwErr("Permission denied"), if ((paymentAmountLeftOver >= rewards[currentIter])) | |
358 | + | then true | |
359 | + | else throwErr("insufficient payment assetId")] | |
360 | + | if ((checks == checks)) | |
347 | 361 | then { | |
348 | - | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
349 | - | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
350 | - | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal) | |
362 | + | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [(paymentAmountLeftOver - rewards[currentIter]), userAddresses, rewards, (currentIter + 1)], nil) | |
363 | + | if ((tradeRewardInternal == tradeRewardInternal)) | |
364 | + | then { | |
365 | + | let tradingRewardHistoryKey = keyTradingRewardHistory(userAddresses[currentIter], i) | |
366 | + | let userAddress = addressFromStringValue(userAddresses[currentIter]) | |
367 | + | $Tuple2([IntegerEntry(tradingRewardHistoryKey, rewards[currentIter]), IntegerEntry(keyTradingReward(userAddresses[currentIter]), rewards[currentIter])], tradeRewardInternal) | |
368 | + | } | |
369 | + | else throw("Strict value is not equal to itself.") | |
351 | 370 | } | |
352 | 371 | else throw("Strict value is not equal to itself.") | |
353 | 372 | } | |
354 | - | ||
355 | - | ||
373 | + | else throw("Strict value is not equal to itself.") | |
374 | + | } | |
356 | 375 | ||
357 | 376 | ||
358 | 377 | ||
359 | 378 | @Callable(i) | |
360 | 379 | func updateReferralActivity (userAddress,gWxAmountStart) = { | |
361 | - | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
362 | - | let activeReferralInv = if ((referrer == unit)) | |
363 | - | then unit | |
364 | - | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
365 | - | if ((activeReferralInv == activeReferralInv)) | |
366 | - | then $Tuple2(nil, unit) | |
380 | + | let suspensionCheck = throwIfSuspended() | |
381 | + | if ((suspensionCheck == suspensionCheck)) | |
382 | + | then { | |
383 | + | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddress)) | |
384 | + | let activeReferralInv = if ((referrer == unit)) | |
385 | + | then unit | |
386 | + | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (gWxAmountStart >= referralMinGWxAmount)], nil) | |
387 | + | if ((activeReferralInv == activeReferralInv)) | |
388 | + | then $Tuple2(nil, unit) | |
389 | + | else throw("Strict value is not equal to itself.") | |
390 | + | } | |
367 | 391 | else throw("Strict value is not equal to itself.") | |
368 | 392 | } | |
369 | 393 | ||
370 | 394 | ||
371 | 395 | ||
372 | 396 | @Callable(i) | |
373 | 397 | func processPendingPeriodsAndUsers () = $Tuple2(nil, throwErr("deprecated")) | |
374 | 398 | ||
375 | 399 | ||
376 | 400 | ||
377 | 401 | @Callable(i) | |
378 | 402 | func claimReward () = { | |
379 | - | let cfgArray = readConfigArrayOrFail() | |
380 | - | let userAddress = i.caller | |
381 | - | let userAddressStr = toString(userAddress) | |
382 | - | let $t01365513712 = commonClaimReward(userAddressStr) | |
383 | - | let amount = $t01365513712._1 | |
384 | - | let actions = $t01365513712._2 | |
385 | - | let checkAmount = if ((amount > 0)) | |
386 | - | then true | |
387 | - | else throw("nothing to claim") | |
388 | - | if ((checkAmount == checkAmount)) | |
403 | + | let suspensionCheck = throwIfSuspended() | |
404 | + | if ((suspensionCheck == suspensionCheck)) | |
389 | 405 | then { | |
390 | - | let userGwxAmount = { | |
391 | - | let @ = invoke(boostingContractOrFail(), "getUserGwxAmount", [userAddressStr], nil) | |
392 | - | if ($isInstanceOf(@, "Int")) | |
393 | - | then @ | |
394 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
395 | - | } | |
396 | - | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddressStr)) | |
397 | - | let activeReferralInv = if ((referrer == unit)) | |
398 | - | then unit | |
399 | - | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userGwxAmount >= referralMinGWxAmount)], nil) | |
400 | - | if ((activeReferralInv == activeReferralInv)) | |
406 | + | let cfgArray = readConfigArrayOrFail() | |
407 | + | let userAddress = i.caller | |
408 | + | let userAddressStr = toString(userAddress) | |
409 | + | let $t01400914066 = commonClaimReward(userAddressStr) | |
410 | + | let amount = $t01400914066._1 | |
411 | + | let actions = $t01400914066._2 | |
412 | + | let checkAmount = if ((amount > 0)) | |
413 | + | then true | |
414 | + | else throw("nothing to claim") | |
415 | + | if ((checkAmount == checkAmount)) | |
401 | 416 | then { | |
402 | - | let referralInv = if (if ((referrer == unit)) | |
403 | - | then true | |
404 | - | else (referralMinGWxAmount > userGwxAmount)) | |
417 | + | let userGwxAmount = { | |
418 | + | let @ = invoke(boostingContractOrFail(), "getUserGwxAmount", [userAddressStr], nil) | |
419 | + | if ($isInstanceOf(@, "Int")) | |
420 | + | then @ | |
421 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
422 | + | } | |
423 | + | let referrer = getString(referralsContractAddressOrFail, keyReferrer(userAddressStr)) | |
424 | + | let activeReferralInv = if ((referrer == unit)) | |
405 | 425 | then unit | |
406 | - | else { | |
407 | - | let referrerReward = fraction(amount, referrerRewardPermille, SCALE) | |
408 | - | let referralReward = fraction(amount, referralRewardPermille, SCALE) | |
409 | - | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
410 | - | } | |
411 | - | if ((referralInv == referralInv)) | |
426 | + | else invoke(referralsContractAddressOrFail, "updateReferralActivity", [referralProgramName, userAddress, (userGwxAmount >= referralMinGWxAmount)], nil) | |
427 | + | if ((activeReferralInv == activeReferralInv)) | |
412 | 428 | then { | |
413 | - | let emit = invoke(emissionContract, "emit", [amount], nil) | |
414 | - | if ((emit == emit)) | |
429 | + | let referralInv = if (if ((referrer == unit)) | |
430 | + | then true | |
431 | + | else (referralMinGWxAmount > userGwxAmount)) | |
432 | + | then unit | |
433 | + | else { | |
434 | + | let referrerReward = fraction(amount, referrerRewardPermille, SCALE) | |
435 | + | let referralReward = fraction(amount, referralRewardPermille, SCALE) | |
436 | + | invoke(referralsContractAddressOrFail, "incUnclaimed", [referralProgramName, userAddress, referrerReward, referralReward], nil) | |
437 | + | } | |
438 | + | if ((referralInv == referralInv)) | |
415 | 439 | then { | |
416 | - | let claimedReferral = { | |
417 | - | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
418 | - | if ($isInstanceOf(@, "Int")) | |
419 | - | then @ | |
420 | - | else throw(($getType(@) + " couldn't be cast to Int")) | |
421 | - | } | |
422 | - | if ((claimedReferral == claimedReferral)) | |
440 | + | let emit = invoke(emissionContract, "emit", [amount], nil) | |
441 | + | if ((emit == emit)) | |
423 | 442 | then { | |
424 | - | let totalAmount = (amount + claimedReferral) | |
425 | - | $Tuple2(([ScriptTransfer(i.caller, amount, wxAssetId), HistoryEntry("claim", userAddressStr, totalAmount, i)] ++ actions), totalAmount) | |
443 | + | let claimedReferral = { | |
444 | + | let @ = invoke(referralsContractAddressOrFail, "claim", [referralProgramName], nil) | |
445 | + | if ($isInstanceOf(@, "Int")) | |
446 | + | then @ | |
447 | + | else throw(($getType(@) + " couldn't be cast to Int")) | |
448 | + | } | |
449 | + | if ((claimedReferral == claimedReferral)) | |
450 | + | then { | |
451 | + | let totalAmount = (amount + claimedReferral) | |
452 | + | $Tuple2(([ScriptTransfer(i.caller, amount, wxAssetId), HistoryEntry("claim", userAddressStr, totalAmount, i)] ++ actions), totalAmount) | |
453 | + | } | |
454 | + | else throw("Strict value is not equal to itself.") | |
426 | 455 | } | |
427 | 456 | else throw("Strict value is not equal to itself.") | |
428 | 457 | } | |
429 | 458 | else throw("Strict value is not equal to itself.") | |
430 | 459 | } | |
431 | 460 | else throw("Strict value is not equal to itself.") | |
432 | 461 | } | |
433 | 462 | else throw("Strict value is not equal to itself.") | |
434 | 463 | } | |
435 | 464 | else throw("Strict value is not equal to itself.") | |
436 | 465 | } | |
437 | 466 | ||
438 | 467 | ||
439 | 468 | ||
440 | 469 | @Callable(i) | |
441 | 470 | func claimRewardREADONLY (address) = { | |
442 | - | let $ | |
443 | - | let amount = $ | |
444 | - | let actions = $ | |
471 | + | let $t01542315473 = commonClaimReward(address) | |
472 | + | let amount = $t01542315473._1 | |
473 | + | let actions = $t01542315473._2 | |
445 | 474 | let referralUnclaimed = valueOrElse(getInteger(referralsContractAddressOrFail, keyUnclaimedReferral(referralProgramName, address)), 0) | |
446 | 475 | let totalAmount = (amount + referralUnclaimed) | |
447 | 476 | $Tuple2(nil, totalAmount) | |
448 | 477 | } | |
449 | 478 | ||
450 | 479 | ||
451 | 480 | ||
452 | 481 | @Callable(i) | |
453 | - | func onEmissionForGwxStart () = if ((i.caller != factoryContract)) | |
454 | - | then throw("permissions denied") | |
455 | - | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
482 | + | func onEmissionForGwxStart () = { | |
483 | + | let suspensionCheck = throwIfSuspended() | |
484 | + | if ((suspensionCheck == suspensionCheck)) | |
485 | + | then if ((i.caller != factoryContract)) | |
486 | + | then throw("permissions denied") | |
487 | + | else [IntegerEntry(keyGwxRewardEmissionStartHeight(), height)] | |
488 | + | else throw("Strict value is not equal to itself.") | |
489 | + | } | |
456 | 490 | ||
457 | 491 | ||
458 | 492 | ||
459 | 493 | @Callable(i) | |
460 | 494 | func tradeReward (userAddresses,rewards) = { | |
461 | - | let argsComparison = (size(userAddresses) == size(rewards)) | |
462 | - | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
463 | - | let payment = i.payments[0] | |
464 | - | let paymentAssetId = payment.assetId | |
465 | - | let paymentAmount = payment.amount | |
466 | - | let checks = [if ((maxRecipients >= size(userAddresses))) | |
467 | - | then true | |
468 | - | else throwErr("Too many recipients"), if (argsComparison) | |
469 | - | then true | |
470 | - | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
471 | - | then true | |
472 | - | else throwErr("Wrong asset payment")] | |
473 | - | if ((checks == checks)) | |
495 | + | let suspensionCheck = throwIfSuspended() | |
496 | + | if ((suspensionCheck == suspensionCheck)) | |
474 | 497 | then { | |
475 | - | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
476 | - | if ((tradeRewardInternal == tradeRewardInternal)) | |
477 | - | then $Tuple2(nil, tradeRewardInternal) | |
498 | + | let argsComparison = (size(userAddresses) == size(rewards)) | |
499 | + | let maxRecipients = valueOrElse(getInteger(keyMaxRecipients()), 0) | |
500 | + | let payment = i.payments[0] | |
501 | + | let paymentAssetId = payment.assetId | |
502 | + | let paymentAmount = payment.amount | |
503 | + | let checks = [if ((maxRecipients >= size(userAddresses))) | |
504 | + | then true | |
505 | + | else throwErr("Too many recipients"), if (argsComparison) | |
506 | + | then true | |
507 | + | else throwErr("Arguments size mismatch"), if ((paymentAssetId == wxAssetId)) | |
508 | + | then true | |
509 | + | else throwErr("Wrong asset payment")] | |
510 | + | if ((checks == checks)) | |
511 | + | then { | |
512 | + | let tradeRewardInternal = invoke(this, "tradeRewardInternal", [paymentAmount, userAddresses, rewards, 0], nil) | |
513 | + | if ((tradeRewardInternal == tradeRewardInternal)) | |
514 | + | then $Tuple2(nil, tradeRewardInternal) | |
515 | + | else throw("Strict value is not equal to itself.") | |
516 | + | } | |
478 | 517 | else throw("Strict value is not equal to itself.") | |
479 | 518 | } | |
480 | 519 | else throw("Strict value is not equal to itself.") | |
481 | 520 | } | |
482 | 521 | ||
483 | 522 | ||
484 | 523 | ||
485 | 524 | @Callable(i) | |
486 | 525 | func claimTradingReward () = { | |
487 | - | let userAddress = i.caller | |
488 | - | let userAddressString = toString(userAddress) | |
489 | - | let reward = getTradingReward(userAddressString) | |
490 | - | if ((reward > 0)) | |
491 | - | then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward) | |
492 | - | else throwErr("nothing to claim") | |
526 | + | let suspensionCheck = throwIfSuspended() | |
527 | + | if ((suspensionCheck == suspensionCheck)) | |
528 | + | then { | |
529 | + | let userAddress = i.caller | |
530 | + | let userAddressString = toString(userAddress) | |
531 | + | let reward = getTradingReward(userAddressString) | |
532 | + | if ((reward > 0)) | |
533 | + | then $Tuple2([ScriptTransfer(userAddress, reward, wxAssetId), IntegerEntry(keyTradingReward(userAddressString), 0)], reward) | |
534 | + | else throwErr("nothing to claim") | |
535 | + | } | |
536 | + | else throw("Strict value is not equal to itself.") | |
493 | 537 | } | |
494 | 538 | ||
495 | 539 | ||
496 | 540 | ||
497 | 541 | @Callable(i) | |
498 | 542 | func claimTradingRewardREADONLY (userAddress) = $Tuple2(nil, getTradingReward(userAddress)) | |
543 | + | ||
544 | + | ||
545 | + | ||
546 | + | @Callable(i) | |
547 | + | func suspend (v) = { | |
548 | + | let checkCaller = mustManager(i) | |
549 | + | if ((checkCaller == checkCaller)) | |
550 | + | then $Tuple2([BooleanEntry(keySuspension, v)], v) | |
551 | + | else throw("Strict value is not equal to itself.") | |
552 | + | } | |
499 | 553 | ||
500 | 554 | ||
501 | 555 | @Verifier(tx) | |
502 | 556 | func verify () = { | |
503 | 557 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
504 | 558 | case pk: ByteVector => | |
505 | 559 | pk | |
506 | 560 | case _: Unit => | |
507 | 561 | tx.senderPublicKey | |
508 | 562 | case _ => | |
509 | 563 | throw("Match error") | |
510 | 564 | } | |
511 | 565 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
512 | 566 | } | |
513 | 567 |
github/deemru/w8io/169f3d6 91.26 ms ◑