tx · 313dui9xvkTyESCyFrLr3X3YvrmiX2FTR7HF4iY6sXFW

3NCGjbgqZVk7eaqrLMEnEnqRhozNm1KTG5z:  -0.01000000 Waves

2024.12.31 04:58 [3438053] smart account 3NCGjbgqZVk7eaqrLMEnEnqRhozNm1KTG5z > SELF 0.00000000 Waves

{ "type": 13, "id": "313dui9xvkTyESCyFrLr3X3YvrmiX2FTR7HF4iY6sXFW", "fee": 1000000, "feeAssetId": null, "timestamp": 1735610318443, "version": 2, "chainId": 84, "sender": "3NCGjbgqZVk7eaqrLMEnEnqRhozNm1KTG5z", "senderPublicKey": "5CoDbXxoqnvJpx9GrS6M4G5GYJXh9rcoiXJz7RYTPVkL", "proofs": [ "FJkPzREd59wozEahcXyggKtMjm6UNP3NDxmnDoZZ9dH1YVDQQ3p8P4bQMYbpy26SdcSRCrmcftZpVDQHsWt1pet" ], "script": "base64:BgImCAISCgoIAQgEAhEYFBISBAoCCAgSABIDCgEBEgASABIAEgMKAQgUAANNMTYAgICE/qbe4READlNUQUtFUlNfQU1PVU5UAICAmqbqr+MBAAtURUFNX0FNT1VOVACAgJqm6q/jAQANTUFSS0VUX0FNT1VOVACAgNCx0v6aDgALWUVBUl9CTE9DS1MJAGgCAO0CAKALAAxTVEFLRV9QRVJJT0QJAGgCAAUFC1lFQVJfQkxPQ0tTAAtCTEVTU19QUklDRQCA0NvD9AIAC0ZPTU9fUEVSSU9EADwADmdvcmNBc3NldElkS2V5Agtnb3JjQXNzZXRJZAALZ29yY0Fzc2V0SWQJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAoQgBBQ5nb3JjQXNzZXRJZEtleQIWR09SQyBpcyBub3QgaXNzdWVkIHlldAAMaXNzdWVUaW1lS2V5Aglpc3N1ZVRpbWUAFHN0YWtlcnNBbW91bnRMZWZ0S2V5AhFzdGFrZXJzQW1vdW50TGVmdAAUc3Rha2VkQW1vdW50VG90YWxLZXkCC3N0YWtlZFRvdGFsARVzdGFrZWRBbW91bnRCeVVzZXJ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FG1i Diff:
OldNewDifferences
129129 let userAmount = $t050115062._1
130130 let amountLeftTotal = $t050115062._2
131131 let userAmountKey = stakedAmountByUserKey(addr)
132- $Tuple2([ScriptTransfer(i.caller, userAmount, gorcAssetId), IntegerEntry(stakedAmountTotalKey, (valueOrElse(getInteger(stakedAmountTotalKey), 0) + amt)), IntegerEntry(userAmountKey, (valueOrElse(getInteger(userAmountKey), 0) + amt)), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)], userAmount)
132+ let claimActions = if ((userAmount > 0))
133+ then [ScriptTransfer(i.caller, userAmount, gorcAssetId)]
134+ else nil
135+ $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrElse(getInteger(stakedAmountTotalKey), 0) + amt)), IntegerEntry(userAmountKey, (valueOrElse(getInteger(userAmountKey), 0) + amt)), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), userAmount)
133136 }
134137 }
135138
148151 if ((0 > (oldAmount - amount)))
149152 then throw(((("You have only " + fixedPoint(oldAmount, 8)) + " GORC staked, tried to unstake ") + fixedPoint(amount, 8)))
150153 else {
151- let $t059566007 = gorcStats(addr)
152- let userAmount = $t059566007._1
153- let amountLeftTotal = $t059566007._2
154- $Tuple2([ScriptTransfer(i.caller, userAmount, gorcAssetId), IntegerEntry(stakedAmountTotalKey, (valueOrErrorMessage(getInteger(stakedAmountTotalKey), "No GORC staked") - amount)), IntegerEntry(userAmountKey, (oldAmount - amount)), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)], 0)
154+ let $t060236074 = gorcStats(addr)
155+ let userAmount = $t060236074._1
156+ let amountLeftTotal = $t060236074._2
157+ let claimActions = if ((userAmount > 0))
158+ then [ScriptTransfer(i.caller, userAmount, gorcAssetId)]
159+ else nil
160+ $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrErrorMessage(getInteger(stakedAmountTotalKey), "No GORC staked") - amount)), IntegerEntry(userAmountKey, (oldAmount - amount)), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), 0)
155161 }
156162 }
157163 }
163169 then throw("No payments required")
164170 else {
165171 let addr = toString(i.caller)
166- let $t065046555 = gorcStats(addr)
167- let userAmount = $t065046555._1
168- let amountLeftTotal = $t065046555._2
169- $Tuple2([ScriptTransfer(i.caller, userAmount, gorcAssetId), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)], userAmount)
172+ let $t066386689 = gorcStats(addr)
173+ let userAmount = $t066386689._1
174+ let amountLeftTotal = $t066386689._2
175+ let claimActions = if ((userAmount > 0))
176+ then [ScriptTransfer(i.caller, userAmount, gorcAssetId)]
177+ else nil
178+ $Tuple2((claimActions ++ [IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), userAmount)
170179 }
171180
172181
183192
184193 @Callable(i)
185194 func statsREADONLY (userAddrOpt) = {
186- let $t069477005 = gorcStats(userAddrOpt)
187- let userAmount = $t069477005._1
188- let amountLeftTotal = $t069477005._2
195+ let $t071487206 = gorcStats(userAddrOpt)
196+ let userAmount = $t071487206._1
197+ let amountLeftTotal = $t071487206._2
189198 let jackpotAmount = valueOrElse(getInteger(currentJackpotKey), 0)
190199 let lastFomoTime = valueOrElse(getInteger(lastFomoTimeKey), 0)
191200 $Tuple2(nil, [("%s%d__gorcAvailToClaim__" + toString(userAmount)), ("%s%d__jackpotAmount__" + toString(jackpotAmount)), ("%s%d__lastFomoTime__" + toString(lastFomoTime)), ("%s%d__amountLeftTotal__" + toString(amountLeftTotal))])
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let M16 = 10000000000000000
55
66 let STAKERS_AMOUNT = 1000000000000000
77
88 let TEAM_AMOUNT = 1000000000000000
99
1010 let MARKET_AMOUNT = 8000000000000000
1111
1212 let YEAR_BLOCKS = (365 * 1440)
1313
1414 let STAKE_PERIOD = (5 * YEAR_BLOCKS)
1515
1616 let BLESS_PRICE = 100000000000
1717
1818 let FOMO_PERIOD = 60
1919
2020 let gorcAssetIdKey = "gorcAssetId"
2121
2222 let gorcAssetId = valueOrErrorMessage(getBinary(gorcAssetIdKey), "GORC is not issued yet")
2323
2424 let issueTimeKey = "issueTime"
2525
2626 let stakersAmountLeftKey = "stakersAmountLeft"
2727
2828 let stakedAmountTotalKey = "stakedTotal"
2929
3030 func stakedAmountByUserKey (addr) = ("stakedAmount_" + addr)
3131
3232
3333 func keyLastClaimTimeByUser (addr) = ("lastClaimTime_" + addr)
3434
3535
3636 let lastFomoTimeKey = "lastFomoTime"
3737
3838 let currentJackpotKey = "currentJackpot"
3939
4040 func gorcStats (userAddrOpt) = {
4141 let amountLeftTotal = valueOrElse(getInteger(stakersAmountLeftKey), 0)
4242 let lastUserTime = valueOrElse(getInteger(keyLastClaimTimeByUser(userAddrOpt)), -1)
4343 if ((0 > lastUserTime))
4444 then $Tuple2(0, amountLeftTotal)
4545 else {
4646 let issueTime = valueOrErrorMessage(getInteger(issueTimeKey), "GORC is not issued yet")
4747 let nowLimited = min([height, (issueTime + STAKE_PERIOD)])
4848 let userShares = valueOrElse(getInteger(stakedAmountByUserKey(userAddrOpt)), 0)
4949 let totalShares = valueOrElse(getInteger(stakedAmountTotalKey), 0)
5050 let userTemporal = fraction(STAKERS_AMOUNT, (nowLimited - lastUserTime), STAKE_PERIOD)
5151 let userAmount = if ((totalShares != 0))
5252 then fraction(userTemporal, userShares, totalShares)
5353 else 0
5454 $Tuple2(userAmount, (amountLeftTotal - userAmount))
5555 }
5656 }
5757
5858
5959 func fixedPoint (val,decimals) = {
6060 let tenPow = pow(10, 0, decimals, 0, 0, DOWN)
6161 let lowPart = toString((val % tenPow))
6262 let zeroes = drop(toString(tenPow), (1 + size(lowPart)))
6363 (((toString((val / tenPow)) + ".") + zeroes) + lowPart)
6464 }
6565
6666
6767 func fomoInternal (i) = if ((size(i.payments) != 1))
6868 then throw("exactly 1 payment must be attached")
6969 else {
7070 let pmt = i.payments[0]
7171 let amt = pmt.amount
7272 if (if (!(isDefined(pmt.assetId)))
7373 then true
7474 else (value(pmt.assetId) != gorcAssetId))
7575 then throw("GORC payments only!")
7676 else {
7777 let change = (amt - BLESS_PRICE)
7878 if ((0 > change))
7979 then throw(((("You need to sacrifice " + fixedPoint(BLESS_PRICE, 8)) + " GORC, but I see only ") + fixedPoint(amt, 8)))
8080 else {
8181 let changeActions = if ((change > 0))
8282 then [ScriptTransfer(i.caller, change, gorcAssetId)]
8383 else nil
8484 let lastFomoTime = valueOrElse(getInteger(lastFomoTimeKey), 0)
8585 let fomoActions = if ((height > (lastFomoTime + FOMO_PERIOD)))
8686 then {
8787 let jackpotAmount = valueOrElse(getInteger(currentJackpotKey), 0)
8888 if ((jackpotAmount > 0))
8989 then [ScriptTransfer(i.caller, jackpotAmount, gorcAssetId)]
9090 else nil
9191 }
9292 else nil
9393 (([IntegerEntry(currentJackpotKey, BLESS_PRICE), IntegerEntry(lastFomoTimeKey, height)] ++ changeActions) ++ fomoActions)
9494 }
9595 }
9696 }
9797
9898
9999 @Callable(i)
100100 func testArgs (intVal,strVal,boolVal,binVal,arrInt,arrStr,arrBool,arrBin) = nil
101101
102102
103103
104104 @Callable(i)
105105 func constructorV1 (teamWalletAddr,brokerAddr) = if ((i.caller != this))
106106 then throw("Permission denied")
107107 else {
108108 let issuedAmount = M16
109109 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)
110110 let assetId = calculateAssetId(issue)
111111 [issue, BinaryEntry(gorcAssetIdKey, assetId), IntegerEntry(issueTimeKey, height), IntegerEntry(stakersAmountLeftKey, STAKERS_AMOUNT), ScriptTransfer(addressFromStringValue(teamWalletAddr), TEAM_AMOUNT, assetId), ScriptTransfer(addressFromStringValue(brokerAddr), MARKET_AMOUNT, assetId)]
112112 }
113113
114114
115115
116116 @Callable(i)
117117 func stakeGorc () = if ((size(i.payments) != 1))
118118 then throw("exactly 1 payment must be attached")
119119 else {
120120 let pmt = i.payments[0]
121121 let amt = pmt.amount
122122 if (if (!(isDefined(pmt.assetId)))
123123 then true
124124 else (value(pmt.assetId) != gorcAssetId))
125125 then throw("GORC payments only!")
126126 else {
127127 let addr = toString(i.caller)
128128 let $t050115062 = gorcStats(addr)
129129 let userAmount = $t050115062._1
130130 let amountLeftTotal = $t050115062._2
131131 let userAmountKey = stakedAmountByUserKey(addr)
132- $Tuple2([ScriptTransfer(i.caller, userAmount, gorcAssetId), IntegerEntry(stakedAmountTotalKey, (valueOrElse(getInteger(stakedAmountTotalKey), 0) + amt)), IntegerEntry(userAmountKey, (valueOrElse(getInteger(userAmountKey), 0) + amt)), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)], userAmount)
132+ let claimActions = if ((userAmount > 0))
133+ then [ScriptTransfer(i.caller, userAmount, gorcAssetId)]
134+ else nil
135+ $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrElse(getInteger(stakedAmountTotalKey), 0) + amt)), IntegerEntry(userAmountKey, (valueOrElse(getInteger(userAmountKey), 0) + amt)), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), userAmount)
133136 }
134137 }
135138
136139
137140
138141 @Callable(i)
139142 func unstakeGorc (amount) = if ((0 >= amount))
140143 then throw("Amount should be positive")
141144 else {
142145 let addr = toString(i.caller)
143146 if ((size(i.payments) != 0))
144147 then throw("No payments required")
145148 else {
146149 let userAmountKey = stakedAmountByUserKey(addr)
147150 let oldAmount = valueOrElse(getInteger(userAmountKey), 0)
148151 if ((0 > (oldAmount - amount)))
149152 then throw(((("You have only " + fixedPoint(oldAmount, 8)) + " GORC staked, tried to unstake ") + fixedPoint(amount, 8)))
150153 else {
151- let $t059566007 = gorcStats(addr)
152- let userAmount = $t059566007._1
153- let amountLeftTotal = $t059566007._2
154- $Tuple2([ScriptTransfer(i.caller, userAmount, gorcAssetId), IntegerEntry(stakedAmountTotalKey, (valueOrErrorMessage(getInteger(stakedAmountTotalKey), "No GORC staked") - amount)), IntegerEntry(userAmountKey, (oldAmount - amount)), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)], 0)
154+ let $t060236074 = gorcStats(addr)
155+ let userAmount = $t060236074._1
156+ let amountLeftTotal = $t060236074._2
157+ let claimActions = if ((userAmount > 0))
158+ then [ScriptTransfer(i.caller, userAmount, gorcAssetId)]
159+ else nil
160+ $Tuple2((claimActions ++ [IntegerEntry(stakedAmountTotalKey, (valueOrErrorMessage(getInteger(stakedAmountTotalKey), "No GORC staked") - amount)), IntegerEntry(userAmountKey, (oldAmount - amount)), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), 0)
155161 }
156162 }
157163 }
158164
159165
160166
161167 @Callable(i)
162168 func claimGorc () = if ((size(i.payments) != 0))
163169 then throw("No payments required")
164170 else {
165171 let addr = toString(i.caller)
166- let $t065046555 = gorcStats(addr)
167- let userAmount = $t065046555._1
168- let amountLeftTotal = $t065046555._2
169- $Tuple2([ScriptTransfer(i.caller, userAmount, gorcAssetId), IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)], userAmount)
172+ let $t066386689 = gorcStats(addr)
173+ let userAmount = $t066386689._1
174+ let amountLeftTotal = $t066386689._2
175+ let claimActions = if ((userAmount > 0))
176+ then [ScriptTransfer(i.caller, userAmount, gorcAssetId)]
177+ else nil
178+ $Tuple2((claimActions ++ [IntegerEntry(keyLastClaimTimeByUser(addr), height), IntegerEntry(stakersAmountLeftKey, amountLeftTotal)]), userAmount)
170179 }
171180
172181
173182
174183 @Callable(i)
175184 func answerMe () = $Tuple2(fomoInternal(i), toInt(i.transactionId))
176185
177186
178187
179188 @Callable(i)
180189 func blessMe () = $Tuple2(fomoInternal(i), 42)
181190
182191
183192
184193 @Callable(i)
185194 func statsREADONLY (userAddrOpt) = {
186- let $t069477005 = gorcStats(userAddrOpt)
187- let userAmount = $t069477005._1
188- let amountLeftTotal = $t069477005._2
195+ let $t071487206 = gorcStats(userAddrOpt)
196+ let userAmount = $t071487206._1
197+ let amountLeftTotal = $t071487206._2
189198 let jackpotAmount = valueOrElse(getInteger(currentJackpotKey), 0)
190199 let lastFomoTime = valueOrElse(getInteger(lastFomoTimeKey), 0)
191200 $Tuple2(nil, [("%s%d__gorcAvailToClaim__" + toString(userAmount)), ("%s%d__jackpotAmount__" + toString(jackpotAmount)), ("%s%d__lastFomoTime__" + toString(lastFomoTime)), ("%s%d__amountLeftTotal__" + toString(amountLeftTotal))])
192201 }
193202
194203

github/deemru/w8io/169f3d6 
93.41 ms