tx · DQt4xk4Jmmd4G5RqUeFENbHXh7xgRaazXXQ4AFQhFG1i 3NCGjbgqZVk7eaqrLMEnEnqRhozNm1KTG5z: -0.01000000 Waves 2024.12.31 05:02 [3438057] smart account 3NCGjbgqZVk7eaqrLMEnEnqRhozNm1KTG5z > SELF 0.00000000 Waves
{ "type": 13, "id": "DQt4xk4Jmmd4G5RqUeFENbHXh7xgRaazXXQ4AFQhFG1i", "fee": 1000000, "feeAssetId": null, "timestamp": 1735610590936, "version": 2, "chainId": 84, "sender": "3NCGjbgqZVk7eaqrLMEnEnqRhozNm1KTG5z", "senderPublicKey": "5CoDbXxoqnvJpx9GrS6M4G5GYJXh9rcoiXJz7RYTPVkL", "proofs": [ "G4jHRRbub2Jo39Hg2HacUCuJPYTyThVeXSrdbrkusHDnUc2Q7jDMpL6HKLF6mdbieC62QuREtt8kTMmDxcBdUBH" ], "script": "base64:BgImCAISCgoIAQgEAhEYFBISBAoCCAgSABIDCgEBEgASABIAEgMKAQgWAANNMTYAgICE/qbe4READlNUQUtFUlNfQU1PVU5UAICAmqbqr+MBAAtURUFNX0FNT1VOVACAgJqm6q/jAQANTUFSS0VUX0FNT1VOVACAgNCx0v6aDgALWUVBUl9CTE9DS1MJAGgCAO0CAKALAAxTVEFLRV9QRVJJT0QJAGgCAAUFC1lFQVJfQkxPQ0tTAAtCTEVTU19QUklDRQCA0NvD9AIAC0ZPTU9fUEVSSU9EADwADmdvcmNBc3NldElkS2V5Agtnb3JjQXNzZXRJZAALZ29yY0Fzc2V0SWQJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAoQgBBQ5nb3JjQXNzZXRJZEtleQIWR09SQyBpcyBub3QgaXNzdWVkIHlldAAMaXNzdWVUaW1lS2V5Aglpc3N1ZVRpbWUAFHN0YWtlcnNBbW91bnRMZWZ0S2V5AhFzdGFrZXJzQW1vdW50TGVmdAAUc3Rha2VkQW1vdW50VG90YWxLZXkCC3N0YWtlZFRvdGFsARVzdGFrZWRBbW91bnRC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dGFsX18JAKQDAQUPYW1vdW50TGVmdFRvdGFsBQNuaWwAwNEaOQ==", "height": 3438057, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 313dui9xvkTyESCyFrLr3X3YvrmiX2FTR7HF4iY6sXFW Next: AmxgdiqTBFbeeWbRqAzCtMKSk4Q6XAiZQuUCQj2CZcKs Diff:
Old | New | Differences | |
---|---|---|---|
30 | 30 | func stakedAmountByUserKey (addr) = ("stakedAmount_" + addr) | |
31 | 31 | ||
32 | 32 | ||
33 | - | func | |
33 | + | func lastClaimTimeByUserKey (addr) = ("lastClaimTime_" + addr) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | let lastFomoTimeKey = "lastFomoTime" | |
37 | 37 | ||
38 | 38 | let currentJackpotKey = "currentJackpot" | |
39 | 39 | ||
40 | + | let teamWalletAddrKey = "teamWalletAddr" | |
41 | + | ||
42 | + | let brokerAddrKey = "brokerAddr" | |
43 | + | ||
40 | 44 | func gorcStats (userAddrOpt) = { | |
41 | 45 | let amountLeftTotal = valueOrElse(getInteger(stakersAmountLeftKey), 0) | |
42 | - | let lastUserTime = valueOrElse(getInteger( | |
46 | + | let lastUserTime = valueOrElse(getInteger(lastClaimTimeByUserKey(userAddrOpt)), -1) | |
43 | 47 | if ((0 > lastUserTime)) | |
44 | 48 | then $Tuple2(0, amountLeftTotal) | |
45 | 49 | else { | |
108 | 112 | let issuedAmount = M16 | |
109 | 113 | let issue = Issue("GORC", "Meme coin by God of Random Chance. Visit https://gorc.meme, sacrifice to the God of Random and you will receive an answer to any question or a blessing. Lucky one gets a Gift of God", issuedAmount, 8, false, unit, 0) | |
110 | 114 | let assetId = calculateAssetId(issue) | |
111 | - | [issue, BinaryEntry(gorcAssetIdKey, assetId), IntegerEntry(issueTimeKey, height), IntegerEntry(stakersAmountLeftKey, STAKERS_AMOUNT), ScriptTransfer(addressFromStringValue(teamWalletAddr), TEAM_AMOUNT, assetId), ScriptTransfer(addressFromStringValue(brokerAddr), MARKET_AMOUNT, assetId)] | |
115 | + | [issue, BinaryEntry(gorcAssetIdKey, assetId), IntegerEntry(issueTimeKey, height), IntegerEntry(stakersAmountLeftKey, STAKERS_AMOUNT), StringEntry(teamWalletAddrKey, teamWalletAddr), StringEntry(brokerAddrKey, brokerAddr), ScriptTransfer(addressFromStringValue(teamWalletAddr), TEAM_AMOUNT, assetId), ScriptTransfer(addressFromStringValue(brokerAddr), MARKET_AMOUNT, assetId)] | |
112 | 116 | } | |
113 | 117 | ||
114 | 118 | ||
125 | 129 | then throw("GORC payments only!") | |
126 | 130 | else { | |
127 | 131 | let addr = toString(i.caller) | |
128 | - | let $ | |
129 | - | let userAmount = $ | |
130 | - | let amountLeftTotal = $ | |
132 | + | let $t051815232 = gorcStats(addr) | |
133 | + | let userAmount = $t051815232._1 | |
134 | + | let amountLeftTotal = $t051815232._2 | |
131 | 135 | let userAmountKey = stakedAmountByUserKey(addr) | |
132 | 136 | let claimActions = if ((userAmount > 0)) | |
133 | 137 | then [ScriptTransfer(i.caller, userAmount, gorcAssetId)] | |
134 | 138 | else nil | |
135 | - | $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrElse(getInteger(stakedAmountTotalKey), 0) + amt)), IntegerEntry(userAmountKey, (valueOrElse(getInteger(userAmountKey), 0) + amt)), IntegerEntry( | |
139 | + | $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrElse(getInteger(stakedAmountTotalKey), 0) + amt)), IntegerEntry(userAmountKey, (valueOrElse(getInteger(userAmountKey), 0) + amt)), IntegerEntry(lastClaimTimeByUserKey(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), userAmount) | |
136 | 140 | } | |
137 | 141 | } | |
138 | 142 | ||
151 | 155 | if ((0 > (oldAmount - amount))) | |
152 | 156 | then throw(((("You have only " + fixedPoint(oldAmount, 8)) + " GORC staked, tried to unstake ") + fixedPoint(amount, 8))) | |
153 | 157 | else { | |
154 | - | let $ | |
155 | - | let userAmount = $ | |
156 | - | let amountLeftTotal = $ | |
158 | + | let $t061936244 = gorcStats(addr) | |
159 | + | let userAmount = $t061936244._1 | |
160 | + | let amountLeftTotal = $t061936244._2 | |
157 | 161 | let claimActions = if ((userAmount > 0)) | |
158 | 162 | then [ScriptTransfer(i.caller, userAmount, gorcAssetId)] | |
159 | 163 | else nil | |
160 | - | $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrErrorMessage(getInteger(stakedAmountTotalKey), "No GORC staked") - amount)), IntegerEntry(userAmountKey, (oldAmount - amount)), IntegerEntry( | |
164 | + | $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrErrorMessage(getInteger(stakedAmountTotalKey), "No GORC staked") - amount)), IntegerEntry(userAmountKey, (oldAmount - amount)), IntegerEntry(lastClaimTimeByUserKey(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), 0) | |
161 | 165 | } | |
162 | 166 | } | |
163 | 167 | } | |
169 | 173 | then throw("No payments required") | |
170 | 174 | else { | |
171 | 175 | let addr = toString(i.caller) | |
172 | - | let $ | |
173 | - | let userAmount = $ | |
174 | - | let amountLeftTotal = $ | |
176 | + | let $t068086859 = gorcStats(addr) | |
177 | + | let userAmount = $t068086859._1 | |
178 | + | let amountLeftTotal = $t068086859._2 | |
175 | 179 | let claimActions = if ((userAmount > 0)) | |
176 | 180 | then [ScriptTransfer(i.caller, userAmount, gorcAssetId)] | |
177 | 181 | else nil | |
178 | - | $Tuple2((claimActions ++ [IntegerEntry( | |
182 | + | $Tuple2((claimActions ++ [IntegerEntry(lastClaimTimeByUserKey(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), userAmount) | |
179 | 183 | } | |
180 | 184 | ||
181 | 185 | ||
192 | 196 | ||
193 | 197 | @Callable(i) | |
194 | 198 | func statsREADONLY (userAddrOpt) = { | |
195 | - | let $ | |
196 | - | let userAmount = $ | |
197 | - | let amountLeftTotal = $ | |
199 | + | let $t073187376 = gorcStats(userAddrOpt) | |
200 | + | let userAmount = $t073187376._1 | |
201 | + | let amountLeftTotal = $t073187376._2 | |
198 | 202 | let jackpotAmount = valueOrElse(getInteger(currentJackpotKey), 0) | |
199 | 203 | let lastFomoTime = valueOrElse(getInteger(lastFomoTimeKey), 0) | |
200 | 204 | $Tuple2(nil, [("%s%d__gorcAvailToClaim__" + toString(userAmount)), ("%s%d__jackpotAmount__" + toString(jackpotAmount)), ("%s%d__lastFomoTime__" + toString(lastFomoTime)), ("%s%d__amountLeftTotal__" + toString(amountLeftTotal))]) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let M16 = 10000000000000000 | |
5 | 5 | ||
6 | 6 | let STAKERS_AMOUNT = 1000000000000000 | |
7 | 7 | ||
8 | 8 | let TEAM_AMOUNT = 1000000000000000 | |
9 | 9 | ||
10 | 10 | let MARKET_AMOUNT = 8000000000000000 | |
11 | 11 | ||
12 | 12 | let YEAR_BLOCKS = (365 * 1440) | |
13 | 13 | ||
14 | 14 | let STAKE_PERIOD = (5 * YEAR_BLOCKS) | |
15 | 15 | ||
16 | 16 | let BLESS_PRICE = 100000000000 | |
17 | 17 | ||
18 | 18 | let FOMO_PERIOD = 60 | |
19 | 19 | ||
20 | 20 | let gorcAssetIdKey = "gorcAssetId" | |
21 | 21 | ||
22 | 22 | let gorcAssetId = valueOrErrorMessage(getBinary(gorcAssetIdKey), "GORC is not issued yet") | |
23 | 23 | ||
24 | 24 | let issueTimeKey = "issueTime" | |
25 | 25 | ||
26 | 26 | let stakersAmountLeftKey = "stakersAmountLeft" | |
27 | 27 | ||
28 | 28 | let stakedAmountTotalKey = "stakedTotal" | |
29 | 29 | ||
30 | 30 | func stakedAmountByUserKey (addr) = ("stakedAmount_" + addr) | |
31 | 31 | ||
32 | 32 | ||
33 | - | func | |
33 | + | func lastClaimTimeByUserKey (addr) = ("lastClaimTime_" + addr) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | let lastFomoTimeKey = "lastFomoTime" | |
37 | 37 | ||
38 | 38 | let currentJackpotKey = "currentJackpot" | |
39 | 39 | ||
40 | + | let teamWalletAddrKey = "teamWalletAddr" | |
41 | + | ||
42 | + | let brokerAddrKey = "brokerAddr" | |
43 | + | ||
40 | 44 | func gorcStats (userAddrOpt) = { | |
41 | 45 | let amountLeftTotal = valueOrElse(getInteger(stakersAmountLeftKey), 0) | |
42 | - | let lastUserTime = valueOrElse(getInteger( | |
46 | + | let lastUserTime = valueOrElse(getInteger(lastClaimTimeByUserKey(userAddrOpt)), -1) | |
43 | 47 | if ((0 > lastUserTime)) | |
44 | 48 | then $Tuple2(0, amountLeftTotal) | |
45 | 49 | else { | |
46 | 50 | let issueTime = valueOrErrorMessage(getInteger(issueTimeKey), "GORC is not issued yet") | |
47 | 51 | let nowLimited = min([height, (issueTime + STAKE_PERIOD)]) | |
48 | 52 | let userShares = valueOrElse(getInteger(stakedAmountByUserKey(userAddrOpt)), 0) | |
49 | 53 | let totalShares = valueOrElse(getInteger(stakedAmountTotalKey), 0) | |
50 | 54 | let userTemporal = fraction(STAKERS_AMOUNT, (nowLimited - lastUserTime), STAKE_PERIOD) | |
51 | 55 | let userAmount = if ((totalShares != 0)) | |
52 | 56 | then fraction(userTemporal, userShares, totalShares) | |
53 | 57 | else 0 | |
54 | 58 | $Tuple2(userAmount, (amountLeftTotal - userAmount)) | |
55 | 59 | } | |
56 | 60 | } | |
57 | 61 | ||
58 | 62 | ||
59 | 63 | func fixedPoint (val,decimals) = { | |
60 | 64 | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
61 | 65 | let lowPart = toString((val % tenPow)) | |
62 | 66 | let zeroes = drop(toString(tenPow), (1 + size(lowPart))) | |
63 | 67 | (((toString((val / tenPow)) + ".") + zeroes) + lowPart) | |
64 | 68 | } | |
65 | 69 | ||
66 | 70 | ||
67 | 71 | func fomoInternal (i) = if ((size(i.payments) != 1)) | |
68 | 72 | then throw("exactly 1 payment must be attached") | |
69 | 73 | else { | |
70 | 74 | let pmt = i.payments[0] | |
71 | 75 | let amt = pmt.amount | |
72 | 76 | if (if (!(isDefined(pmt.assetId))) | |
73 | 77 | then true | |
74 | 78 | else (value(pmt.assetId) != gorcAssetId)) | |
75 | 79 | then throw("GORC payments only!") | |
76 | 80 | else { | |
77 | 81 | let change = (amt - BLESS_PRICE) | |
78 | 82 | if ((0 > change)) | |
79 | 83 | then throw(((("You need to sacrifice " + fixedPoint(BLESS_PRICE, 8)) + " GORC, but I see only ") + fixedPoint(amt, 8))) | |
80 | 84 | else { | |
81 | 85 | let changeActions = if ((change > 0)) | |
82 | 86 | then [ScriptTransfer(i.caller, change, gorcAssetId)] | |
83 | 87 | else nil | |
84 | 88 | let lastFomoTime = valueOrElse(getInteger(lastFomoTimeKey), 0) | |
85 | 89 | let fomoActions = if ((height > (lastFomoTime + FOMO_PERIOD))) | |
86 | 90 | then { | |
87 | 91 | let jackpotAmount = valueOrElse(getInteger(currentJackpotKey), 0) | |
88 | 92 | if ((jackpotAmount > 0)) | |
89 | 93 | then [ScriptTransfer(i.caller, jackpotAmount, gorcAssetId)] | |
90 | 94 | else nil | |
91 | 95 | } | |
92 | 96 | else nil | |
93 | 97 | (([IntegerEntry(currentJackpotKey, BLESS_PRICE), IntegerEntry(lastFomoTimeKey, height)] ++ changeActions) ++ fomoActions) | |
94 | 98 | } | |
95 | 99 | } | |
96 | 100 | } | |
97 | 101 | ||
98 | 102 | ||
99 | 103 | @Callable(i) | |
100 | 104 | func testArgs (intVal,strVal,boolVal,binVal,arrInt,arrStr,arrBool,arrBin) = nil | |
101 | 105 | ||
102 | 106 | ||
103 | 107 | ||
104 | 108 | @Callable(i) | |
105 | 109 | func constructorV1 (teamWalletAddr,brokerAddr) = if ((i.caller != this)) | |
106 | 110 | then throw("Permission denied") | |
107 | 111 | else { | |
108 | 112 | let issuedAmount = M16 | |
109 | 113 | let issue = Issue("GORC", "Meme coin by God of Random Chance. Visit https://gorc.meme, sacrifice to the God of Random and you will receive an answer to any question or a blessing. Lucky one gets a Gift of God", issuedAmount, 8, false, unit, 0) | |
110 | 114 | let assetId = calculateAssetId(issue) | |
111 | - | [issue, BinaryEntry(gorcAssetIdKey, assetId), IntegerEntry(issueTimeKey, height), IntegerEntry(stakersAmountLeftKey, STAKERS_AMOUNT), ScriptTransfer(addressFromStringValue(teamWalletAddr), TEAM_AMOUNT, assetId), ScriptTransfer(addressFromStringValue(brokerAddr), MARKET_AMOUNT, assetId)] | |
115 | + | [issue, BinaryEntry(gorcAssetIdKey, assetId), IntegerEntry(issueTimeKey, height), IntegerEntry(stakersAmountLeftKey, STAKERS_AMOUNT), StringEntry(teamWalletAddrKey, teamWalletAddr), StringEntry(brokerAddrKey, brokerAddr), ScriptTransfer(addressFromStringValue(teamWalletAddr), TEAM_AMOUNT, assetId), ScriptTransfer(addressFromStringValue(brokerAddr), MARKET_AMOUNT, assetId)] | |
112 | 116 | } | |
113 | 117 | ||
114 | 118 | ||
115 | 119 | ||
116 | 120 | @Callable(i) | |
117 | 121 | func stakeGorc () = if ((size(i.payments) != 1)) | |
118 | 122 | then throw("exactly 1 payment must be attached") | |
119 | 123 | else { | |
120 | 124 | let pmt = i.payments[0] | |
121 | 125 | let amt = pmt.amount | |
122 | 126 | if (if (!(isDefined(pmt.assetId))) | |
123 | 127 | then true | |
124 | 128 | else (value(pmt.assetId) != gorcAssetId)) | |
125 | 129 | then throw("GORC payments only!") | |
126 | 130 | else { | |
127 | 131 | let addr = toString(i.caller) | |
128 | - | let $ | |
129 | - | let userAmount = $ | |
130 | - | let amountLeftTotal = $ | |
132 | + | let $t051815232 = gorcStats(addr) | |
133 | + | let userAmount = $t051815232._1 | |
134 | + | let amountLeftTotal = $t051815232._2 | |
131 | 135 | let userAmountKey = stakedAmountByUserKey(addr) | |
132 | 136 | let claimActions = if ((userAmount > 0)) | |
133 | 137 | then [ScriptTransfer(i.caller, userAmount, gorcAssetId)] | |
134 | 138 | else nil | |
135 | - | $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrElse(getInteger(stakedAmountTotalKey), 0) + amt)), IntegerEntry(userAmountKey, (valueOrElse(getInteger(userAmountKey), 0) + amt)), IntegerEntry( | |
139 | + | $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrElse(getInteger(stakedAmountTotalKey), 0) + amt)), IntegerEntry(userAmountKey, (valueOrElse(getInteger(userAmountKey), 0) + amt)), IntegerEntry(lastClaimTimeByUserKey(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), userAmount) | |
136 | 140 | } | |
137 | 141 | } | |
138 | 142 | ||
139 | 143 | ||
140 | 144 | ||
141 | 145 | @Callable(i) | |
142 | 146 | func unstakeGorc (amount) = if ((0 >= amount)) | |
143 | 147 | then throw("Amount should be positive") | |
144 | 148 | else { | |
145 | 149 | let addr = toString(i.caller) | |
146 | 150 | if ((size(i.payments) != 0)) | |
147 | 151 | then throw("No payments required") | |
148 | 152 | else { | |
149 | 153 | let userAmountKey = stakedAmountByUserKey(addr) | |
150 | 154 | let oldAmount = valueOrElse(getInteger(userAmountKey), 0) | |
151 | 155 | if ((0 > (oldAmount - amount))) | |
152 | 156 | then throw(((("You have only " + fixedPoint(oldAmount, 8)) + " GORC staked, tried to unstake ") + fixedPoint(amount, 8))) | |
153 | 157 | else { | |
154 | - | let $ | |
155 | - | let userAmount = $ | |
156 | - | let amountLeftTotal = $ | |
158 | + | let $t061936244 = gorcStats(addr) | |
159 | + | let userAmount = $t061936244._1 | |
160 | + | let amountLeftTotal = $t061936244._2 | |
157 | 161 | let claimActions = if ((userAmount > 0)) | |
158 | 162 | then [ScriptTransfer(i.caller, userAmount, gorcAssetId)] | |
159 | 163 | else nil | |
160 | - | $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrErrorMessage(getInteger(stakedAmountTotalKey), "No GORC staked") - amount)), IntegerEntry(userAmountKey, (oldAmount - amount)), IntegerEntry( | |
164 | + | $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrErrorMessage(getInteger(stakedAmountTotalKey), "No GORC staked") - amount)), IntegerEntry(userAmountKey, (oldAmount - amount)), IntegerEntry(lastClaimTimeByUserKey(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), 0) | |
161 | 165 | } | |
162 | 166 | } | |
163 | 167 | } | |
164 | 168 | ||
165 | 169 | ||
166 | 170 | ||
167 | 171 | @Callable(i) | |
168 | 172 | func claimGorc () = if ((size(i.payments) != 0)) | |
169 | 173 | then throw("No payments required") | |
170 | 174 | else { | |
171 | 175 | let addr = toString(i.caller) | |
172 | - | let $ | |
173 | - | let userAmount = $ | |
174 | - | let amountLeftTotal = $ | |
176 | + | let $t068086859 = gorcStats(addr) | |
177 | + | let userAmount = $t068086859._1 | |
178 | + | let amountLeftTotal = $t068086859._2 | |
175 | 179 | let claimActions = if ((userAmount > 0)) | |
176 | 180 | then [ScriptTransfer(i.caller, userAmount, gorcAssetId)] | |
177 | 181 | else nil | |
178 | - | $Tuple2((claimActions ++ [IntegerEntry( | |
182 | + | $Tuple2((claimActions ++ [IntegerEntry(lastClaimTimeByUserKey(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), userAmount) | |
179 | 183 | } | |
180 | 184 | ||
181 | 185 | ||
182 | 186 | ||
183 | 187 | @Callable(i) | |
184 | 188 | func answerMe () = $Tuple2(fomoInternal(i), toInt(i.transactionId)) | |
185 | 189 | ||
186 | 190 | ||
187 | 191 | ||
188 | 192 | @Callable(i) | |
189 | 193 | func blessMe () = $Tuple2(fomoInternal(i), 42) | |
190 | 194 | ||
191 | 195 | ||
192 | 196 | ||
193 | 197 | @Callable(i) | |
194 | 198 | func statsREADONLY (userAddrOpt) = { | |
195 | - | let $ | |
196 | - | let userAmount = $ | |
197 | - | let amountLeftTotal = $ | |
199 | + | let $t073187376 = gorcStats(userAddrOpt) | |
200 | + | let userAmount = $t073187376._1 | |
201 | + | let amountLeftTotal = $t073187376._2 | |
198 | 202 | let jackpotAmount = valueOrElse(getInteger(currentJackpotKey), 0) | |
199 | 203 | let lastFomoTime = valueOrElse(getInteger(lastFomoTimeKey), 0) | |
200 | 204 | $Tuple2(nil, [("%s%d__gorcAvailToClaim__" + toString(userAmount)), ("%s%d__jackpotAmount__" + toString(jackpotAmount)), ("%s%d__lastFomoTime__" + toString(lastFomoTime)), ("%s%d__amountLeftTotal__" + toString(amountLeftTotal))]) | |
201 | 205 | } | |
202 | 206 | ||
203 | 207 |
github/deemru/w8io/169f3d6 40.35 ms ◑