tx · F85abB5RAhaDewZHwtxKQE7YZRptbphgTcgBMJcqZbKX

3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh:  -0.01300000 Waves

2022.10.27 10:05 [2290508] smart account 3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh > SELF 0.00000000 Waves

{ "type": 13, "id": "F85abB5RAhaDewZHwtxKQE7YZRptbphgTcgBMJcqZbKX", "fee": 1300000, "feeAssetId": null, "timestamp": 1666854343339, "version": 1, "sender": "3NAsFvuLwxz1iUtZ9fmhfmSN16r9NEsPqsh", "senderPublicKey": "33fpjdpM9FMu87RZKePniPardKqQXM96sm7VhAk3JEVQ", "proofs": [ "HeedSysnoanmvtsM3AQSaH2r1y65mVTeC7rZN9oNWBDNQiCjp9ok45CZegarpMyhZnnkG6vqVmtELyyd516fttH" ], "script": "base64:BgL3CwgCEgYKBAgICAgSBgoECAgIAhIFCgMICAQSBgoECAgBARIDCgEIEgQKAggIEgMKAQgSACIJc2VwYXJhdG9yIhNrZXlCYWNrZW5kUHVibGljS2V5IhtrZXlFeGlzdHNSZWZlcnJlclRvUmVmZXJyYWwiC3Byb2dyYW1OYW1lIg9yZWZlcnJlckFkZHJlc3MiD3JlZmVycmFsQWRkcmVzcyISa2V5Q2xhaW1lZFJlZmVycmVyIg5jbGFpbWVyQWRkcmVzcyISa2V5Q2xhaW1lZFJlZmVycmFsIhRrZXlVbmNsYWltZWRSZWZlcnJlciIUa2V5VW5jbGFpbWVkUmVmZXJyYWwiC2tleVJlZmVycmVyIg5rZXlQcm9ncmFtTmFtZSIVa2V5VG90YWxSZWZlcnJhbENvdW50IhZrZXlBY3RpdmVSZWZlcnJhbENvdW50IhNrZXlJc1JlZmVycmFsQWN0aXZlIg9rZXlDbGFpbWVkVG90YWwiD2tleVJld2FyZHNUb3RhbCIQa2V5UmV3YXJkQXNzZXRJZCITa2V5VHJlYXN1cnlDb250cmFjdCIZa2V5SW1wbGVtZW50YXRpb25Db250cmFjdCITa2V5TWFu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gMJAAACBQJhSwUCYUsJAMwIAgkBC1N0cmluZ0VudHJ5AgkBAXYACQDYBAEJAQV2YWx1ZQEFAmFJCQDMCAIJAQtEZWxldGVFbnRyeQEJAQF3AAUDbmlsCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJhTAECYU0ABAJhTgQBRwkBAUYAAwkAAQIFAUcCCkJ5dGVWZWN0b3IEAU0FAUcFAU0DCQABAgUBRwIEVW5pdAgFAmFMD3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJhTAlib2R5Qnl0ZXMJAJEDAggFAmFMBnByb29mcwAABQJhTsEbkhc=", "chainId": 84, "height": 2290508, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FVGFexPdz6tRJnWb5YCRvfP7Y9Fnhw1fzA5DhEQq8deA Next: 9WA53dYhMo8abNYSBSwUrCkdBbMjbk8LkVPrdeeGrnYK Diff:
OldNewDifferences
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separator = "__"
5-
6-func keyWxAssetId () = makeString(["%s", "wxAssetId"], separator)
7-
85
96 let keyBackendPublicKey = makeString(["%s", "backendPublicKey"], separator)
107
118 func keyExistsReferrerToReferral (programName,referrerAddress,referralAddress) = makeString(["%s%s%s%s", "existsReferrerToReferral", programName, referrerAddress, referralAddress], separator)
129
1310
14-func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferrer", programName, claimerAddress], separator)
11+func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferrer", programName, claimerAddress], separator)
1512
1613
17-func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferral", programName, claimerAddress], separator)
14+func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferral", programName, claimerAddress], separator)
1815
1916
20-func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator)
17+func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator)
2118
2219
23-func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], separator)
20+func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferral", programName, claimerAddress], separator)
2421
2522
2623 func keyReferrer (programName,referralAddress) = makeString(["%s%s%s", "referrer", programName, referralAddress], separator)
3835 func keyIsReferralActive (programName,referralAddress) = makeString(["%s%s%s", "activeReferral", programName, referralAddress], separator)
3936
4037
41-func keyClaimedTotalAddress (address) = makeString(["%s%s", "claimedTotalAddress", address], separator)
42-
43-
44-func keyUnclaimedTotalAddress (address) = makeString(["%s%s", "unclaimedTotalAddress", address], separator)
45-
46-
4738 func keyClaimedTotal (programName) = makeString(["%s%s", "claimedTotal", programName], separator)
4839
4940
5748
5849
5950 func keyImplementationContract (programName) = makeString(["%s%s", "implementationContract", programName], separator)
60-
61-
62-func keyAllReferralPrograms (address) = makeString(["%s%s", "allReferralPrograms", address], separator)
63-
64-
65-func keyLastIncUnclaimedWithPaymentCallBlock (address) = makeString(["%s%s", "lastIncUnclaimedWithPaymentCallBlock", address], separator)
6651
6752
6853 func keyManagerPublicKey () = "%s__managerPublicKey"
115100 throw("Match error")
116101 }
117102 }
118-
119-
120-func updateAllReferralPrograms (address,programName) = {
121- let allReferralPrograms = valueOrElse(getString(keyAllReferralPrograms(address)), "")
122- let updatedAllReferralPrograms = if (contains(allReferralPrograms, programName))
123- then nil
124- else {
125- let newAllReferralPrograms = if ((allReferralPrograms == ""))
126- then programName
127- else makeString([allReferralPrograms, programName], separator)
128-[StringEntry(keyAllReferralPrograms(address), newAllReferralPrograms)]
129- }
130- updatedAllReferralPrograms
131- }
132-
133-
134-@Callable(i)
135-func claimInternal (programName,claimerAddress,isImplementationContract) = {
136- let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false))
137- then true
138- else throwErr("program does not exist")
139- if ((checkProgramExists == checkProgramExists))
140- then {
141- let $t048215758 = if (isImplementationContract)
142- then $Tuple5(valueOrElse(getInteger(keyClaimedReferral(programName, claimerAddress)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, claimerAddress)), 0), keyClaimedReferral(programName, claimerAddress), keyUnclaimedReferral(programName, claimerAddress), keyClaimHistory(programName, claimerAddress, toBase58String(i.transactionId), "claimReferral"))
143- else $Tuple5(valueOrElse(getInteger(keyClaimedReferrer(programName, claimerAddress)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimerAddress)), 0), keyClaimedReferrer(programName, claimerAddress), keyUnclaimedReferrer(programName, claimerAddress), keyClaimHistory(programName, claimerAddress, toBase58String(i.transactionId), "claimReferrer"))
144- let claimerClaimed = $t048215758._1
145- let claimerUnclaimed = $t048215758._2
146- let keyClaimed = $t048215758._3
147- let keyUnclaimed = $t048215758._4
148- let claimHistoryKey = $t048215758._5
149- let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0)
150- let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName)))))
151- let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName))))
152- let claimedTotalAddress = valueOrElse(getInteger(keyClaimedTotalAddress(claimerAddress)), 0)
153- let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(claimerAddress)), 0)
154- if (if (isImplementationContract)
155- then (claimerUnclaimed == 0)
156- else false)
157- then $Tuple2(nil, 0)
158- else {
159- let checkCanClaim = if ((claimerUnclaimed > 0))
160- then true
161- else throwErr("nothing to claim")
162- if ((checkCanClaim == checkCanClaim))
163- then {
164- let newClaimerClaimed = (claimerClaimed + claimerUnclaimed)
165- let newClaimedTotal = (claimedTotal + claimerUnclaimed)
166- let newClaimedTotalAddress = (claimedTotalAddress + claimerUnclaimed)
167- let newUnclaimedTotalAddress = (unclaimedTotalAddress - claimerUnclaimed)
168- let balanceBefore = value(assetBalance(this, rewardAssetId))
169- if ((balanceBefore == balanceBefore))
170- then {
171- let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil)
172- if ((res == res))
173- then {
174- let balanceAfter = value(assetBalance(this, rewardAssetId))
175- if ((balanceAfter == balanceAfter))
176- then {
177- let balanceDiff = (balanceAfter - balanceBefore)
178- if ((balanceDiff == balanceDiff))
179- then {
180- let checkBalance = if ((balanceDiff == claimerUnclaimed))
181- then true
182- else throwErr("insufficient balance on referral contract")
183- if ((checkBalance == checkBalance))
184- then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyUnclaimed, 0), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyClaimedTotalAddress(claimerAddress), newClaimedTotalAddress), IntegerEntry(keyUnclaimedTotalAddress(claimerAddress), newUnclaimedTotalAddress), ScriptTransfer(addressFromStringValue(claimerAddress), claimerUnclaimed, rewardAssetId), StringEntry(claimHistoryKey, formatClaimHistory(claimerUnclaimed))], claimerUnclaimed)
185- else throw("Strict value is not equal to itself.")
186- }
187- else throw("Strict value is not equal to itself.")
188- }
189- else throw("Strict value is not equal to itself.")
190- }
191- else throw("Strict value is not equal to itself.")
192- }
193- else throw("Strict value is not equal to itself.")
194- }
195- else throw("Strict value is not equal to itself.")
196- }
197- }
198- else throw("Strict value is not equal to itself.")
199- }
200-
201-
202-
203-@Callable(i)
204-func claimBulkInternal (claimer,programNames,currentIter) = {
205- let checkCaller = if ((i.caller == this))
206- then true
207- else throwErr("permission denied")
208- if ((checkCaller == checkCaller))
209- then if ((currentIter == size(programNames)))
210- then nil
211- else {
212- let programName = programNames[currentIter]
213- let programUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimer)), 0)
214- let claimHistoryKey = keyClaimHistory(programName, claimer, toBase58String(i.transactionId), "claimBulk")
215- let claimBulkInternal = invoke(this, "claimBulkInternal", [claimer, programNames, (currentIter + 1)], nil)
216- if ((claimBulkInternal == claimBulkInternal))
217- then {
218- let unclaimedReferrer = valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimer)), 0)
219- let claim = if ((unclaimedReferrer > 0))
220- then invoke(this, "claimInternal", [programName, claimer, false], nil)
221- else unit
222- if ((claim == claim))
223- then $Tuple2(nil, [claimBulkInternal, claim])
224- else throw("Strict value is not equal to itself.")
225- }
226- else throw("Strict value is not equal to itself.")
227- }
228- else throw("Strict value is not equal to itself.")
229- }
230-
231-
232-
233-@Callable(i)
234-func incUnclaimedWithPaymentInternal (paymentAmounts,programName,referrerAddresses,currentIter,resAmount) = {
235- let checkCaller = if ((i.caller == this))
236- then true
237- else throwErr("permission denied")
238- if ((checkCaller == checkCaller))
239- then {
240- let argsComparison = (size(paymentAmounts) == size(referrerAddresses))
241- let check = if (argsComparison)
242- then true
243- else throwErr("lists in args must be same size")
244- if ((check == check))
245- then if ((currentIter == size(paymentAmounts)))
246- then $Tuple2(nil, resAmount)
247- else {
248- let referrerAddress = referrerAddresses[currentIter]
249- let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(referrerAddress)), 0)
250- let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0)
251- let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0)
252- let newUnclaimedTotalAddress = (unclaimedTotalAddress + paymentAmounts[currentIter])
253- let newReferrerUnclaimed = (referrerUnclaimed + paymentAmounts[currentIter])
254- let newResAmount = (resAmount + paymentAmounts[currentIter])
255- let inv = invoke(this, "incUnclaimedWithPaymentInternal", [paymentAmounts, programName, referrerAddresses, (currentIter + 1), newResAmount], nil)
256- if ((inv == inv))
257- then {
258- let updatedAllReferrerPrograms = updateAllReferralPrograms(referrerAddress, programName)
259- $Tuple2(([IntegerEntry(keyUnclaimedTotalAddress(referrerAddress), newUnclaimedTotalAddress), IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyRewardsTotal(programName), (rewardsTotal + paymentAmounts[currentIter]))] ++ updatedAllReferrerPrograms), inv)
260- }
261- else throw("Strict value is not equal to itself.")
262- }
263- else throw("Strict value is not equal to itself.")
264- }
265- else throw("Strict value is not equal to itself.")
266- }
267-
268103
269104
270105 @Callable(i)
327162 then {
328163 let totalReferralCount = valueOrElse(getInteger(keyTotalReferralCount(programName, referrerAddress)), 0)
329164 let newTotalReferralCount = (totalReferralCount + 1)
330- let updatedAllReferrerPrograms = updateAllReferralPrograms(referrerAddress, programName)
331- let updatedAllReferralPrograms = updateAllReferralPrograms(referralAddress, programName)
332- $Tuple2((([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)] ++ updatedAllReferrerPrograms) ++ updatedAllReferralPrograms), unit)
165+ $Tuple2([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)], unit)
333166 }
334167 else throw("Strict value is not equal to itself.")
335168 }
376209 @Callable(i)
377210 func incUnclaimed (programName,referralAddress,referrerReward,referralReward) = {
378211 let implementationContract = value(getString(keyImplementationContract(programName)))
379- let referrerAddress = value(getString(keyReferrer(programName, referralAddress)))
380212 let checkCaller = if ((toString(i.caller) == implementationContract))
381213 then true
382214 else throwErr("permission denied")
383215 if ((checkCaller == checkCaller))
384216 then {
385- let checkProgram = if ((programName == "wxlock"))
386- then true
387- else throwErr("invalid program")
388- if ((checkProgram == checkProgram))
389- then {
390- let checkReferrerInProgram = if (contains(valueOrElse(getString(keyAllReferralPrograms(referrerAddress)), ""), programName))
391- then true
392- else throwErr("referrer not in program")
393- if ((checkReferrerInProgram == checkReferrerInProgram))
394- then {
395- let checkReferralInProgram = if (contains(valueOrElse(getString(keyAllReferralPrograms(referralAddress)), ""), programName))
396- then true
397- else throwErr("referral not in program")
398- if ((checkReferralInProgram == checkReferralInProgram))
399- then {
400- let unclaimedTotalReferrer = valueOrElse(getInteger(keyUnclaimedTotalAddress(referrerAddress)), 0)
401- let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0)
402- let unclaimedTotalReferral = valueOrElse(getInteger(keyUnclaimedTotalAddress(referralAddress)), 0)
403- let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0)
404- let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0)
405- let newUnclaimedTotalReferrer = (unclaimedTotalReferrer + referrerReward)
406- let newReferrerUnclaimed = (referrerUnclaimed + referrerReward)
407- let newUnclaimedTotalReferral = (unclaimedTotalReferral + referralReward)
408- let newReferralUnclaimed = (referralUnclaimed + referralReward)
409- $Tuple2([IntegerEntry(keyUnclaimedTotalAddress(referrerAddress), newUnclaimedTotalReferrer), IntegerEntry(keyUnclaimedTotalAddress(referralAddress), newUnclaimedTotalReferral), IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit)
410- }
411- else throw("Strict value is not equal to itself.")
412- }
413- else throw("Strict value is not equal to itself.")
414- }
415- else throw("Strict value is not equal to itself.")
416- }
417- else throw("Strict value is not equal to itself.")
418- }
419-
420-
421-
422-@Callable(i)
423-func incUnclaimedWithPayment (programName,referrerAddresses) = {
424- let checkProgram = if ((programName == "wxSpotFee"))
425- then true
426- else throwErr("invalid program")
427- if ((checkProgram == checkProgram))
428- then {
429- let callerAddress = toString(i.caller)
430- let lastCall = valueOrElse(getInteger(keyLastIncUnclaimedWithPaymentCallBlock(callerAddress)), 0)
431- let waitBlocks = ((lastCall - height) + 3)
432- let lastCallCheck = if (((height - 3) > lastCall))
433- then true
434- else throwErr(makeString(["wait", toString(waitBlocks), "blocks"], " "))
435- if ((lastCallCheck == lastCallCheck))
436- then {
437- func map (accum,next) = {
438- let assetIdCheck = (toBase58String(value(next.assetId)) == value(getString(keyRewardAssetId(programName))))
439- let amountCheck = if (assetIdCheck)
440- then true
441- else throwErr("invalid asset id")
442- if ((amountCheck == amountCheck))
443- then (accum :+ next.amount)
444- else throw("Strict value is not equal to itself.")
445- }
446-
447- let payments = {
448- let $l = i.payments
449- let $s = size($l)
450- let $acc0 = nil
451- func $f0_1 ($a,$i) = if (($i >= $s))
452- then $a
453- else map($a, $l[$i])
454-
455- func $f0_2 ($a,$i) = if (($i >= $s))
456- then $a
457- else throw("List size exceeds 10")
458-
459- $f0_2($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)
460- }
461- let resAmount = {
462- let @ = invoke(this, "incUnclaimedWithPaymentInternal", [payments, programName, referrerAddresses, 0, 0], nil)
463- if ($isInstanceOf(@, "Int"))
464- then @
465- else throw(($getType(@) + " couldn't be cast to Int"))
466- }
467- if ((resAmount == resAmount))
468- then {
469- let treasuryContract = addressFromStringValue(value(getString(keyTreasuryContract(programName))))
470- let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName))))
471-[ScriptTransfer(treasuryContract, resAmount, rewardAssetId), IntegerEntry(keyLastIncUnclaimedWithPaymentCallBlock(callerAddress), height)]
472- }
473- else throw("Strict value is not equal to itself.")
474- }
475- else throw("Strict value is not equal to itself.")
217+ let referrerAddress = value(getString(keyReferrer(programName, referralAddress)))
218+ let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0)
219+ let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0)
220+ let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0)
221+ let newReferrerUnclaimed = (referrerUnclaimed + referrerReward)
222+ let newReferralUnclaimed = (referralUnclaimed + referralReward)
223+ $Tuple2([IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit)
476224 }
477225 else throw("Strict value is not equal to itself.")
478226 }
487235 if ((checkProgramExists == checkProgramExists))
488236 then {
489237 let isImplementationContract = (toString(i.caller) == value(getString(keyImplementationContract(programName))))
490- let claimerAddress = if (isImplementationContract)
491- then toString(i.originCaller)
492- else toString(i.caller)
493- let claimInternal = invoke(this, "claimInternal", [programName, claimerAddress, isImplementationContract], nil)
494- if ((claimInternal == claimInternal))
495- then $Tuple2(nil, claimInternal)
496- else throw("Strict value is not equal to itself.")
497- }
498- else throw("Strict value is not equal to itself.")
499- }
500-
501-
502-
503-@Callable(i)
504-func claimBulk () = {
505- let callerAddress = toString(i.caller)
506- let callerProgramsStr = getString(keyAllReferralPrograms(toString(i.caller)))
507- let programsExists = if (isDefined(callerProgramsStr))
508- then true
509- else throwErr("no referral programs")
510- if ((programsExists == programsExists))
511- then {
512- let callerPrograms = split(value(callerProgramsStr), "__")
513- let bulkClaim = invoke(this, "claimBulkInternal", [callerAddress, callerPrograms, 0], nil)
514- if ((bulkClaim == bulkClaim))
515- then $Tuple2(nil, bulkClaim)
516- else throw("Strict value is not equal to itself.")
238+ let $t084179346 = if (isImplementationContract)
239+ then {
240+ let user = toString(i.originCaller)
241+ $Tuple6(user, valueOrElse(getInteger(keyClaimedReferral(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, user)), 0), keyClaimedReferral(programName, user), keyUnclaimedReferral(programName, user), keyClaimHistory(programName, user, toBase58String(i.transactionId), "claimReferral"))
242+ }
243+ else {
244+ let user = toString(i.caller)
245+ $Tuple6(user, valueOrElse(getInteger(keyClaimedReferrer(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, user)), 0), keyClaimedReferrer(programName, user), keyUnclaimedReferrer(programName, user), keyClaimHistory(programName, user, toBase58String(i.transactionId), "claimReferrer"))
246+ }
247+ let userAddressStr = $t084179346._1
248+ let claimerClaimed = $t084179346._2
249+ let claimerUnclaimed = $t084179346._3
250+ let keyClaimed = $t084179346._4
251+ let keyUnclaimed = $t084179346._5
252+ let claimHistoryKey = $t084179346._6
253+ let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0)
254+ let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName)))))
255+ let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName))))
256+ if (if (isImplementationContract)
257+ then (claimerUnclaimed == 0)
258+ else false)
259+ then $Tuple2(nil, 0)
260+ else {
261+ let checkCanClaim = if ((claimerUnclaimed > 0))
262+ then true
263+ else throwErr("nothing to claim")
264+ if ((checkCanClaim == checkCanClaim))
265+ then {
266+ let newClaimerClaimed = (claimerClaimed + claimerUnclaimed)
267+ let newClaimedTotal = (claimedTotal + claimerUnclaimed)
268+ let balanceBefore = value(assetBalance(this, rewardAssetId))
269+ if ((balanceBefore == balanceBefore))
270+ then {
271+ let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil)
272+ if ((res == res))
273+ then {
274+ let balanceAfter = value(assetBalance(this, rewardAssetId))
275+ if ((balanceAfter == balanceAfter))
276+ then {
277+ let balanceDiff = (balanceAfter - balanceBefore)
278+ if ((balanceDiff == balanceDiff))
279+ then {
280+ let checkBalance = if ((balanceDiff == claimerUnclaimed))
281+ then true
282+ else throwErr("insufficient balance on referral contract")
283+ if ((checkBalance == checkBalance))
284+ then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyUnclaimed, 0), ScriptTransfer(addressFromStringValue(userAddressStr), claimerUnclaimed, rewardAssetId), StringEntry(claimHistoryKey, formatClaimHistory(claimerUnclaimed))], claimerUnclaimed)
285+ else throw("Strict value is not equal to itself.")
286+ }
287+ else throw("Strict value is not equal to itself.")
288+ }
289+ else throw("Strict value is not equal to itself.")
290+ }
291+ else throw("Strict value is not equal to itself.")
292+ }
293+ else throw("Strict value is not equal to itself.")
294+ }
295+ else throw("Strict value is not equal to itself.")
296+ }
517297 }
518298 else throw("Strict value is not equal to itself.")
519299 }
525305 let claimerClaimed = valueOrElse(getInteger(keyClaimedReferrer(programName, userAddress)), 0)
526306 let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, userAddress)), 0)
527307 $Tuple2(nil, [claimerUnclaimed, claimerClaimed])
528- }
529-
530-
531-
532-@Callable(i)
533-func claimBulkREADONLY (claimer) = {
534- let claimedTotalAddress = valueOrElse(getInteger(keyClaimedTotalAddress(claimer)), 0)
535- let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(claimer)), 0)
536- $Tuple2(nil, [unclaimedTotalAddress, claimedTotalAddress])
537- }
538-
539-
540-
541-@Callable(i)
542-func setTotalKeys (programName,address) = {
543- let claimedReferrer = valueOrElse(getInteger(keyClaimedReferrer(programName, address)), 0)
544- let claimedReferral = valueOrElse(getInteger(keyClaimedReferral(programName, address)), 0)
545- let unclaimedReferrer = valueOrElse(getInteger(keyUnclaimedReferrer(programName, address)), 0)
546- let unclaimedReferral = valueOrElse(getInteger(keyUnclaimedReferral(programName, address)), 0)
547- let claimedTotalAddress = (claimedReferrer + claimedReferral)
548- let unclaimedTotalAddress = (unclaimedReferrer + unclaimedReferral)
549- $Tuple2([IntegerEntry(keyClaimedTotalAddress(address), claimedTotalAddress), IntegerEntry(keyUnclaimedTotalAddress(address), unclaimedTotalAddress)], unit)
550308 }
551309
552310
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separator = "__"
5-
6-func keyWxAssetId () = makeString(["%s", "wxAssetId"], separator)
7-
85
96 let keyBackendPublicKey = makeString(["%s", "backendPublicKey"], separator)
107
118 func keyExistsReferrerToReferral (programName,referrerAddress,referralAddress) = makeString(["%s%s%s%s", "existsReferrerToReferral", programName, referrerAddress, referralAddress], separator)
129
1310
14-func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferrer", programName, claimerAddress], separator)
11+func keyClaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferrer", programName, claimerAddress], separator)
1512
1613
17-func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "claimedReferral", programName, claimerAddress], separator)
14+func keyClaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "claimedReferral", programName, claimerAddress], separator)
1815
1916
20-func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator)
17+func keyUnclaimedReferrer (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferrer", programName, claimerAddress], separator)
2118
2219
23-func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s", "unclaimedReferral", programName, claimerAddress], separator)
20+func keyUnclaimedReferral (programName,claimerAddress) = makeString(["%s%s%s%s", "unclaimedReferral", programName, claimerAddress], separator)
2421
2522
2623 func keyReferrer (programName,referralAddress) = makeString(["%s%s%s", "referrer", programName, referralAddress], separator)
2724
2825
2926 func keyProgramName (programName) = makeString(["%s%s", "programName", programName], separator)
3027
3128
3229 func keyTotalReferralCount (programName,referrerAddress) = makeString(["%s%s%s", "totalReferralCount", programName, referrerAddress], separator)
3330
3431
3532 func keyActiveReferralCount (programName,referrerAddress) = makeString(["%s%s%s", "activeReferralCount", programName, referrerAddress], separator)
3633
3734
3835 func keyIsReferralActive (programName,referralAddress) = makeString(["%s%s%s", "activeReferral", programName, referralAddress], separator)
3936
4037
41-func keyClaimedTotalAddress (address) = makeString(["%s%s", "claimedTotalAddress", address], separator)
42-
43-
44-func keyUnclaimedTotalAddress (address) = makeString(["%s%s", "unclaimedTotalAddress", address], separator)
45-
46-
4738 func keyClaimedTotal (programName) = makeString(["%s%s", "claimedTotal", programName], separator)
4839
4940
5041 func keyRewardsTotal (programName) = makeString(["%s%s", "rewardsTotal", programName], separator)
5142
5243
5344 func keyRewardAssetId (programName) = makeString(["%s%s", "rewardAssetId", programName], separator)
5445
5546
5647 func keyTreasuryContract (programName) = makeString(["%s%s", "treasuryContract", programName], separator)
5748
5849
5950 func keyImplementationContract (programName) = makeString(["%s%s", "implementationContract", programName], separator)
60-
61-
62-func keyAllReferralPrograms (address) = makeString(["%s%s", "allReferralPrograms", address], separator)
63-
64-
65-func keyLastIncUnclaimedWithPaymentCallBlock (address) = makeString(["%s%s", "lastIncUnclaimedWithPaymentCallBlock", address], separator)
6651
6752
6853 func keyManagerPublicKey () = "%s__managerPublicKey"
6954
7055
7156 func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
7257
7358
7459 func keyClaimHistory (programName,userAddress,transactionId,type) = makeString(["%s%s%s%s%s", "history", type, programName, userAddress, transactionId], separator)
7560
7661
7762 func formatClaimHistory (amount) = makeString(["%d%d%d", toString(lastBlock.height), toString(lastBlock.timestamp), toString(amount)], separator)
7863
7964
8065 func throwErr (msg) = throw(makeString(["referral.ride:", msg], " "))
8166
8267
8368 func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
8469 case s: String =>
8570 fromBase58String(s)
8671 case _: Unit =>
8772 unit
8873 case _ =>
8974 throw("Match error")
9075 }
9176
9277
9378 func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
9479 case s: String =>
9580 fromBase58String(s)
9681 case _: Unit =>
9782 unit
9883 case _ =>
9984 throw("Match error")
10085 }
10186
10287
10388 func mustManager (i) = {
10489 let pd = throwErr("permission denied")
10590 match managerPublicKeyOrUnit() {
10691 case pk: ByteVector =>
10792 if ((i.callerPublicKey == pk))
10893 then true
10994 else pd
11095 case _: Unit =>
11196 if ((i.caller == this))
11297 then true
11398 else pd
11499 case _ =>
115100 throw("Match error")
116101 }
117102 }
118-
119-
120-func updateAllReferralPrograms (address,programName) = {
121- let allReferralPrograms = valueOrElse(getString(keyAllReferralPrograms(address)), "")
122- let updatedAllReferralPrograms = if (contains(allReferralPrograms, programName))
123- then nil
124- else {
125- let newAllReferralPrograms = if ((allReferralPrograms == ""))
126- then programName
127- else makeString([allReferralPrograms, programName], separator)
128-[StringEntry(keyAllReferralPrograms(address), newAllReferralPrograms)]
129- }
130- updatedAllReferralPrograms
131- }
132-
133-
134-@Callable(i)
135-func claimInternal (programName,claimerAddress,isImplementationContract) = {
136- let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false))
137- then true
138- else throwErr("program does not exist")
139- if ((checkProgramExists == checkProgramExists))
140- then {
141- let $t048215758 = if (isImplementationContract)
142- then $Tuple5(valueOrElse(getInteger(keyClaimedReferral(programName, claimerAddress)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, claimerAddress)), 0), keyClaimedReferral(programName, claimerAddress), keyUnclaimedReferral(programName, claimerAddress), keyClaimHistory(programName, claimerAddress, toBase58String(i.transactionId), "claimReferral"))
143- else $Tuple5(valueOrElse(getInteger(keyClaimedReferrer(programName, claimerAddress)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimerAddress)), 0), keyClaimedReferrer(programName, claimerAddress), keyUnclaimedReferrer(programName, claimerAddress), keyClaimHistory(programName, claimerAddress, toBase58String(i.transactionId), "claimReferrer"))
144- let claimerClaimed = $t048215758._1
145- let claimerUnclaimed = $t048215758._2
146- let keyClaimed = $t048215758._3
147- let keyUnclaimed = $t048215758._4
148- let claimHistoryKey = $t048215758._5
149- let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0)
150- let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName)))))
151- let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName))))
152- let claimedTotalAddress = valueOrElse(getInteger(keyClaimedTotalAddress(claimerAddress)), 0)
153- let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(claimerAddress)), 0)
154- if (if (isImplementationContract)
155- then (claimerUnclaimed == 0)
156- else false)
157- then $Tuple2(nil, 0)
158- else {
159- let checkCanClaim = if ((claimerUnclaimed > 0))
160- then true
161- else throwErr("nothing to claim")
162- if ((checkCanClaim == checkCanClaim))
163- then {
164- let newClaimerClaimed = (claimerClaimed + claimerUnclaimed)
165- let newClaimedTotal = (claimedTotal + claimerUnclaimed)
166- let newClaimedTotalAddress = (claimedTotalAddress + claimerUnclaimed)
167- let newUnclaimedTotalAddress = (unclaimedTotalAddress - claimerUnclaimed)
168- let balanceBefore = value(assetBalance(this, rewardAssetId))
169- if ((balanceBefore == balanceBefore))
170- then {
171- let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil)
172- if ((res == res))
173- then {
174- let balanceAfter = value(assetBalance(this, rewardAssetId))
175- if ((balanceAfter == balanceAfter))
176- then {
177- let balanceDiff = (balanceAfter - balanceBefore)
178- if ((balanceDiff == balanceDiff))
179- then {
180- let checkBalance = if ((balanceDiff == claimerUnclaimed))
181- then true
182- else throwErr("insufficient balance on referral contract")
183- if ((checkBalance == checkBalance))
184- then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyUnclaimed, 0), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyClaimedTotalAddress(claimerAddress), newClaimedTotalAddress), IntegerEntry(keyUnclaimedTotalAddress(claimerAddress), newUnclaimedTotalAddress), ScriptTransfer(addressFromStringValue(claimerAddress), claimerUnclaimed, rewardAssetId), StringEntry(claimHistoryKey, formatClaimHistory(claimerUnclaimed))], claimerUnclaimed)
185- else throw("Strict value is not equal to itself.")
186- }
187- else throw("Strict value is not equal to itself.")
188- }
189- else throw("Strict value is not equal to itself.")
190- }
191- else throw("Strict value is not equal to itself.")
192- }
193- else throw("Strict value is not equal to itself.")
194- }
195- else throw("Strict value is not equal to itself.")
196- }
197- }
198- else throw("Strict value is not equal to itself.")
199- }
200-
201-
202-
203-@Callable(i)
204-func claimBulkInternal (claimer,programNames,currentIter) = {
205- let checkCaller = if ((i.caller == this))
206- then true
207- else throwErr("permission denied")
208- if ((checkCaller == checkCaller))
209- then if ((currentIter == size(programNames)))
210- then nil
211- else {
212- let programName = programNames[currentIter]
213- let programUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimer)), 0)
214- let claimHistoryKey = keyClaimHistory(programName, claimer, toBase58String(i.transactionId), "claimBulk")
215- let claimBulkInternal = invoke(this, "claimBulkInternal", [claimer, programNames, (currentIter + 1)], nil)
216- if ((claimBulkInternal == claimBulkInternal))
217- then {
218- let unclaimedReferrer = valueOrElse(getInteger(keyUnclaimedReferrer(programName, claimer)), 0)
219- let claim = if ((unclaimedReferrer > 0))
220- then invoke(this, "claimInternal", [programName, claimer, false], nil)
221- else unit
222- if ((claim == claim))
223- then $Tuple2(nil, [claimBulkInternal, claim])
224- else throw("Strict value is not equal to itself.")
225- }
226- else throw("Strict value is not equal to itself.")
227- }
228- else throw("Strict value is not equal to itself.")
229- }
230-
231-
232-
233-@Callable(i)
234-func incUnclaimedWithPaymentInternal (paymentAmounts,programName,referrerAddresses,currentIter,resAmount) = {
235- let checkCaller = if ((i.caller == this))
236- then true
237- else throwErr("permission denied")
238- if ((checkCaller == checkCaller))
239- then {
240- let argsComparison = (size(paymentAmounts) == size(referrerAddresses))
241- let check = if (argsComparison)
242- then true
243- else throwErr("lists in args must be same size")
244- if ((check == check))
245- then if ((currentIter == size(paymentAmounts)))
246- then $Tuple2(nil, resAmount)
247- else {
248- let referrerAddress = referrerAddresses[currentIter]
249- let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(referrerAddress)), 0)
250- let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0)
251- let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0)
252- let newUnclaimedTotalAddress = (unclaimedTotalAddress + paymentAmounts[currentIter])
253- let newReferrerUnclaimed = (referrerUnclaimed + paymentAmounts[currentIter])
254- let newResAmount = (resAmount + paymentAmounts[currentIter])
255- let inv = invoke(this, "incUnclaimedWithPaymentInternal", [paymentAmounts, programName, referrerAddresses, (currentIter + 1), newResAmount], nil)
256- if ((inv == inv))
257- then {
258- let updatedAllReferrerPrograms = updateAllReferralPrograms(referrerAddress, programName)
259- $Tuple2(([IntegerEntry(keyUnclaimedTotalAddress(referrerAddress), newUnclaimedTotalAddress), IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyRewardsTotal(programName), (rewardsTotal + paymentAmounts[currentIter]))] ++ updatedAllReferrerPrograms), inv)
260- }
261- else throw("Strict value is not equal to itself.")
262- }
263- else throw("Strict value is not equal to itself.")
264- }
265- else throw("Strict value is not equal to itself.")
266- }
267-
268103
269104
270105 @Callable(i)
271106 func createReferralProgram (programName,treasuryContract,implementationContract,rewardAssetId) = {
272107 let checkCaller = mustManager(i)
273108 if ((checkCaller == checkCaller))
274109 then {
275110 let checkProgramName = if ((getBoolean(keyProgramName(programName)) == unit))
276111 then true
277112 else throwErr("program name already exists")
278113 if ((checkProgramName == checkProgramName))
279114 then {
280115 let programNameIsValid = if (!(contains(programName, separator)))
281116 then !(contains(programName, " "))
282117 else false
283118 let checkProgramExists = if (programNameIsValid)
284119 then true
285120 else throwErr("invalid program name")
286121 if ((checkProgramExists == checkProgramExists))
287122 then {
288123 let checkRewardAsset = if ((assetInfo(fromBase58String(rewardAssetId)) != unit))
289124 then true
290125 else throwErr("invalid reward asset id")
291126 if ((checkRewardAsset == checkRewardAsset))
292127 then $Tuple2([BooleanEntry(keyProgramName(programName), true), StringEntry(keyTreasuryContract(programName), treasuryContract), StringEntry(keyImplementationContract(programName), implementationContract), StringEntry(keyRewardAssetId(programName), rewardAssetId), IntegerEntry(keyRewardsTotal(programName), 0)], unit)
293128 else throw("Strict value is not equal to itself.")
294129 }
295130 else throw("Strict value is not equal to itself.")
296131 }
297132 else throw("Strict value is not equal to itself.")
298133 }
299134 else throw("Strict value is not equal to itself.")
300135 }
301136
302137
303138
304139 @Callable(i)
305140 func createPair (programName,referrerAddress,referralAddress,signature) = {
306141 let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false))
307142 then true
308143 else throwErr("program does not exist")
309144 if ((checkProgramExists == checkProgramExists))
310145 then {
311146 let pairReferrerToReferralExistCheck = if ((getBoolean(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress)) == unit))
312147 then true
313148 else throwErr("pair already exists")
314149 if ((pairReferrerToReferralExistCheck == pairReferrerToReferralExistCheck))
315150 then {
316151 let noRefSelf = if ((referrerAddress != referralAddress))
317152 then true
318153 else throwErr("cannot refer to self")
319154 if ((noRefSelf == noRefSelf))
320155 then {
321156 let pair = toBytes(makeString([programName, referrerAddress, referralAddress], ":"))
322157 let backendPublicKey = fromBase58String(value(getString(keyBackendPublicKey)))
323158 let validateSignature = if (sigVerify(pair, signature, backendPublicKey))
324159 then true
325160 else throwErr("bad signature")
326161 if ((validateSignature == validateSignature))
327162 then {
328163 let totalReferralCount = valueOrElse(getInteger(keyTotalReferralCount(programName, referrerAddress)), 0)
329164 let newTotalReferralCount = (totalReferralCount + 1)
330- let updatedAllReferrerPrograms = updateAllReferralPrograms(referrerAddress, programName)
331- let updatedAllReferralPrograms = updateAllReferralPrograms(referralAddress, programName)
332- $Tuple2((([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)] ++ updatedAllReferrerPrograms) ++ updatedAllReferralPrograms), unit)
165+ $Tuple2([BooleanEntry(keyExistsReferrerToReferral(programName, referrerAddress, referralAddress), true), IntegerEntry(keyTotalReferralCount(programName, referrerAddress), newTotalReferralCount), StringEntry(keyReferrer(programName, referralAddress), referrerAddress)], unit)
333166 }
334167 else throw("Strict value is not equal to itself.")
335168 }
336169 else throw("Strict value is not equal to itself.")
337170 }
338171 else throw("Strict value is not equal to itself.")
339172 }
340173 else throw("Strict value is not equal to itself.")
341174 }
342175
343176
344177
345178 @Callable(i)
346179 func updateReferralActivity (programName,referralAddress,isActive) = {
347180 let implementationContract = value(getString(keyImplementationContract(programName)))
348181 let isReferralActive = (getBoolean(keyIsReferralActive(programName, referralAddress)) != unit)
349182 let referrerAddress = value(getString(keyReferrer(programName, referralAddress)))
350183 let checkCaller = if ((toString(i.caller) == implementationContract))
351184 then true
352185 else throwErr("permission denied")
353186 if ((checkCaller == checkCaller))
354187 then {
355188 let update = if ((isReferralActive == isActive))
356189 then $Tuple2(nil, unit)
357190 else {
358191 let update = if ((isActive == true))
359192 then {
360193 let newActiveReferralCount = (valueOrElse(getInteger(keyActiveReferralCount(programName, referrerAddress)), 0) + 1)
361194 $Tuple2([BooleanEntry(keyIsReferralActive(programName, referralAddress), true), IntegerEntry(keyActiveReferralCount(programName, referrerAddress), newActiveReferralCount)], unit)
362195 }
363196 else {
364197 let newActiveReferralCount = (valueOrElse(getInteger(keyActiveReferralCount(programName, referrerAddress)), 0) - 1)
365198 $Tuple2([DeleteEntry(keyIsReferralActive(programName, referralAddress)), IntegerEntry(keyActiveReferralCount(programName, referrerAddress), newActiveReferralCount)], unit)
366199 }
367200 update
368201 }
369202 update
370203 }
371204 else throw("Strict value is not equal to itself.")
372205 }
373206
374207
375208
376209 @Callable(i)
377210 func incUnclaimed (programName,referralAddress,referrerReward,referralReward) = {
378211 let implementationContract = value(getString(keyImplementationContract(programName)))
379- let referrerAddress = value(getString(keyReferrer(programName, referralAddress)))
380212 let checkCaller = if ((toString(i.caller) == implementationContract))
381213 then true
382214 else throwErr("permission denied")
383215 if ((checkCaller == checkCaller))
384216 then {
385- let checkProgram = if ((programName == "wxlock"))
386- then true
387- else throwErr("invalid program")
388- if ((checkProgram == checkProgram))
389- then {
390- let checkReferrerInProgram = if (contains(valueOrElse(getString(keyAllReferralPrograms(referrerAddress)), ""), programName))
391- then true
392- else throwErr("referrer not in program")
393- if ((checkReferrerInProgram == checkReferrerInProgram))
394- then {
395- let checkReferralInProgram = if (contains(valueOrElse(getString(keyAllReferralPrograms(referralAddress)), ""), programName))
396- then true
397- else throwErr("referral not in program")
398- if ((checkReferralInProgram == checkReferralInProgram))
399- then {
400- let unclaimedTotalReferrer = valueOrElse(getInteger(keyUnclaimedTotalAddress(referrerAddress)), 0)
401- let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0)
402- let unclaimedTotalReferral = valueOrElse(getInteger(keyUnclaimedTotalAddress(referralAddress)), 0)
403- let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0)
404- let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0)
405- let newUnclaimedTotalReferrer = (unclaimedTotalReferrer + referrerReward)
406- let newReferrerUnclaimed = (referrerUnclaimed + referrerReward)
407- let newUnclaimedTotalReferral = (unclaimedTotalReferral + referralReward)
408- let newReferralUnclaimed = (referralUnclaimed + referralReward)
409- $Tuple2([IntegerEntry(keyUnclaimedTotalAddress(referrerAddress), newUnclaimedTotalReferrer), IntegerEntry(keyUnclaimedTotalAddress(referralAddress), newUnclaimedTotalReferral), IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit)
410- }
411- else throw("Strict value is not equal to itself.")
412- }
413- else throw("Strict value is not equal to itself.")
414- }
415- else throw("Strict value is not equal to itself.")
416- }
417- else throw("Strict value is not equal to itself.")
418- }
419-
420-
421-
422-@Callable(i)
423-func incUnclaimedWithPayment (programName,referrerAddresses) = {
424- let checkProgram = if ((programName == "wxSpotFee"))
425- then true
426- else throwErr("invalid program")
427- if ((checkProgram == checkProgram))
428- then {
429- let callerAddress = toString(i.caller)
430- let lastCall = valueOrElse(getInteger(keyLastIncUnclaimedWithPaymentCallBlock(callerAddress)), 0)
431- let waitBlocks = ((lastCall - height) + 3)
432- let lastCallCheck = if (((height - 3) > lastCall))
433- then true
434- else throwErr(makeString(["wait", toString(waitBlocks), "blocks"], " "))
435- if ((lastCallCheck == lastCallCheck))
436- then {
437- func map (accum,next) = {
438- let assetIdCheck = (toBase58String(value(next.assetId)) == value(getString(keyRewardAssetId(programName))))
439- let amountCheck = if (assetIdCheck)
440- then true
441- else throwErr("invalid asset id")
442- if ((amountCheck == amountCheck))
443- then (accum :+ next.amount)
444- else throw("Strict value is not equal to itself.")
445- }
446-
447- let payments = {
448- let $l = i.payments
449- let $s = size($l)
450- let $acc0 = nil
451- func $f0_1 ($a,$i) = if (($i >= $s))
452- then $a
453- else map($a, $l[$i])
454-
455- func $f0_2 ($a,$i) = if (($i >= $s))
456- then $a
457- else throw("List size exceeds 10")
458-
459- $f0_2($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)
460- }
461- let resAmount = {
462- let @ = invoke(this, "incUnclaimedWithPaymentInternal", [payments, programName, referrerAddresses, 0, 0], nil)
463- if ($isInstanceOf(@, "Int"))
464- then @
465- else throw(($getType(@) + " couldn't be cast to Int"))
466- }
467- if ((resAmount == resAmount))
468- then {
469- let treasuryContract = addressFromStringValue(value(getString(keyTreasuryContract(programName))))
470- let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName))))
471-[ScriptTransfer(treasuryContract, resAmount, rewardAssetId), IntegerEntry(keyLastIncUnclaimedWithPaymentCallBlock(callerAddress), height)]
472- }
473- else throw("Strict value is not equal to itself.")
474- }
475- else throw("Strict value is not equal to itself.")
217+ let referrerAddress = value(getString(keyReferrer(programName, referralAddress)))
218+ let referrerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, referrerAddress)), 0)
219+ let referralUnclaimed = valueOrElse(getInteger(keyUnclaimedReferral(programName, referralAddress)), 0)
220+ let rewardsTotal = valueOrElse(getInteger(keyRewardsTotal(programName)), 0)
221+ let newReferrerUnclaimed = (referrerUnclaimed + referrerReward)
222+ let newReferralUnclaimed = (referralUnclaimed + referralReward)
223+ $Tuple2([IntegerEntry(keyUnclaimedReferrer(programName, referrerAddress), newReferrerUnclaimed), IntegerEntry(keyUnclaimedReferral(programName, referralAddress), newReferralUnclaimed), IntegerEntry(keyRewardsTotal(programName), ((rewardsTotal + referrerReward) + referralReward))], unit)
476224 }
477225 else throw("Strict value is not equal to itself.")
478226 }
479227
480228
481229
482230 @Callable(i)
483231 func claim (programName) = {
484232 let checkProgramExists = if (valueOrElse(getBoolean(keyProgramName(programName)), false))
485233 then true
486234 else throwErr("program does not exist")
487235 if ((checkProgramExists == checkProgramExists))
488236 then {
489237 let isImplementationContract = (toString(i.caller) == value(getString(keyImplementationContract(programName))))
490- let claimerAddress = if (isImplementationContract)
491- then toString(i.originCaller)
492- else toString(i.caller)
493- let claimInternal = invoke(this, "claimInternal", [programName, claimerAddress, isImplementationContract], nil)
494- if ((claimInternal == claimInternal))
495- then $Tuple2(nil, claimInternal)
496- else throw("Strict value is not equal to itself.")
497- }
498- else throw("Strict value is not equal to itself.")
499- }
500-
501-
502-
503-@Callable(i)
504-func claimBulk () = {
505- let callerAddress = toString(i.caller)
506- let callerProgramsStr = getString(keyAllReferralPrograms(toString(i.caller)))
507- let programsExists = if (isDefined(callerProgramsStr))
508- then true
509- else throwErr("no referral programs")
510- if ((programsExists == programsExists))
511- then {
512- let callerPrograms = split(value(callerProgramsStr), "__")
513- let bulkClaim = invoke(this, "claimBulkInternal", [callerAddress, callerPrograms, 0], nil)
514- if ((bulkClaim == bulkClaim))
515- then $Tuple2(nil, bulkClaim)
516- else throw("Strict value is not equal to itself.")
238+ let $t084179346 = if (isImplementationContract)
239+ then {
240+ let user = toString(i.originCaller)
241+ $Tuple6(user, valueOrElse(getInteger(keyClaimedReferral(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferral(programName, user)), 0), keyClaimedReferral(programName, user), keyUnclaimedReferral(programName, user), keyClaimHistory(programName, user, toBase58String(i.transactionId), "claimReferral"))
242+ }
243+ else {
244+ let user = toString(i.caller)
245+ $Tuple6(user, valueOrElse(getInteger(keyClaimedReferrer(programName, user)), 0), valueOrElse(getInteger(keyUnclaimedReferrer(programName, user)), 0), keyClaimedReferrer(programName, user), keyUnclaimedReferrer(programName, user), keyClaimHistory(programName, user, toBase58String(i.transactionId), "claimReferrer"))
246+ }
247+ let userAddressStr = $t084179346._1
248+ let claimerClaimed = $t084179346._2
249+ let claimerUnclaimed = $t084179346._3
250+ let keyClaimed = $t084179346._4
251+ let keyUnclaimed = $t084179346._5
252+ let claimHistoryKey = $t084179346._6
253+ let claimedTotal = valueOrElse(getInteger(keyClaimedTotal(programName)), 0)
254+ let treasuryContract = value(addressFromString(value(getString(keyTreasuryContract(programName)))))
255+ let rewardAssetId = fromBase58String(value(getString(keyRewardAssetId(programName))))
256+ if (if (isImplementationContract)
257+ then (claimerUnclaimed == 0)
258+ else false)
259+ then $Tuple2(nil, 0)
260+ else {
261+ let checkCanClaim = if ((claimerUnclaimed > 0))
262+ then true
263+ else throwErr("nothing to claim")
264+ if ((checkCanClaim == checkCanClaim))
265+ then {
266+ let newClaimerClaimed = (claimerClaimed + claimerUnclaimed)
267+ let newClaimedTotal = (claimedTotal + claimerUnclaimed)
268+ let balanceBefore = value(assetBalance(this, rewardAssetId))
269+ if ((balanceBefore == balanceBefore))
270+ then {
271+ let res = invoke(treasuryContract, "withdrawReferralReward", [claimerUnclaimed], nil)
272+ if ((res == res))
273+ then {
274+ let balanceAfter = value(assetBalance(this, rewardAssetId))
275+ if ((balanceAfter == balanceAfter))
276+ then {
277+ let balanceDiff = (balanceAfter - balanceBefore)
278+ if ((balanceDiff == balanceDiff))
279+ then {
280+ let checkBalance = if ((balanceDiff == claimerUnclaimed))
281+ then true
282+ else throwErr("insufficient balance on referral contract")
283+ if ((checkBalance == checkBalance))
284+ then $Tuple2([IntegerEntry(keyClaimed, newClaimerClaimed), IntegerEntry(keyClaimedTotal(programName), newClaimedTotal), IntegerEntry(keyUnclaimed, 0), ScriptTransfer(addressFromStringValue(userAddressStr), claimerUnclaimed, rewardAssetId), StringEntry(claimHistoryKey, formatClaimHistory(claimerUnclaimed))], claimerUnclaimed)
285+ else throw("Strict value is not equal to itself.")
286+ }
287+ else throw("Strict value is not equal to itself.")
288+ }
289+ else throw("Strict value is not equal to itself.")
290+ }
291+ else throw("Strict value is not equal to itself.")
292+ }
293+ else throw("Strict value is not equal to itself.")
294+ }
295+ else throw("Strict value is not equal to itself.")
296+ }
517297 }
518298 else throw("Strict value is not equal to itself.")
519299 }
520300
521301
522302
523303 @Callable(i)
524304 func claimREADONLY (programName,userAddress) = {
525305 let claimerClaimed = valueOrElse(getInteger(keyClaimedReferrer(programName, userAddress)), 0)
526306 let claimerUnclaimed = valueOrElse(getInteger(keyUnclaimedReferrer(programName, userAddress)), 0)
527307 $Tuple2(nil, [claimerUnclaimed, claimerClaimed])
528- }
529-
530-
531-
532-@Callable(i)
533-func claimBulkREADONLY (claimer) = {
534- let claimedTotalAddress = valueOrElse(getInteger(keyClaimedTotalAddress(claimer)), 0)
535- let unclaimedTotalAddress = valueOrElse(getInteger(keyUnclaimedTotalAddress(claimer)), 0)
536- $Tuple2(nil, [unclaimedTotalAddress, claimedTotalAddress])
537- }
538-
539-
540-
541-@Callable(i)
542-func setTotalKeys (programName,address) = {
543- let claimedReferrer = valueOrElse(getInteger(keyClaimedReferrer(programName, address)), 0)
544- let claimedReferral = valueOrElse(getInteger(keyClaimedReferral(programName, address)), 0)
545- let unclaimedReferrer = valueOrElse(getInteger(keyUnclaimedReferrer(programName, address)), 0)
546- let unclaimedReferral = valueOrElse(getInteger(keyUnclaimedReferral(programName, address)), 0)
547- let claimedTotalAddress = (claimedReferrer + claimedReferral)
548- let unclaimedTotalAddress = (unclaimedReferrer + unclaimedReferral)
549- $Tuple2([IntegerEntry(keyClaimedTotalAddress(address), claimedTotalAddress), IntegerEntry(keyUnclaimedTotalAddress(address), unclaimedTotalAddress)], unit)
550308 }
551309
552310
553311
554312 @Callable(i)
555313 func setManager (pendingManagerPublicKey) = {
556314 let checkCaller = mustManager(i)
557315 if ((checkCaller == checkCaller))
558316 then {
559317 let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
560318 if ((checkManagerPublicKey == checkManagerPublicKey))
561319 then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
562320 else throw("Strict value is not equal to itself.")
563321 }
564322 else throw("Strict value is not equal to itself.")
565323 }
566324
567325
568326
569327 @Callable(i)
570328 func confirmManager () = {
571329 let pm = pendingManagerPublicKeyOrUnit()
572330 let hasPM = if (isDefined(pm))
573331 then true
574332 else throwErr("no pending manager")
575333 if ((hasPM == hasPM))
576334 then {
577335 let checkPM = if ((i.callerPublicKey == value(pm)))
578336 then true
579337 else throwErr("you are not pending manager")
580338 if ((checkPM == checkPM))
581339 then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
582340 else throw("Strict value is not equal to itself.")
583341 }
584342 else throw("Strict value is not equal to itself.")
585343 }
586344
587345
588346 @Verifier(tx)
589347 func verify () = {
590348 let targetPublicKey = match managerPublicKeyOrUnit() {
591349 case pk: ByteVector =>
592350 pk
593351 case _: Unit =>
594352 tx.senderPublicKey
595353 case _ =>
596354 throw("Match error")
597355 }
598356 sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
599357 }
600358

github/deemru/w8io/169f3d6 
65.20 ms