tx · AthrWG1KEF9rPcku21SYhknMWAPUzsexz9JH6Ag3n3ki 3N2iKmAK2hjZiqPD459iBpCfpoLLAiTu2Jz: -0.01000000 Waves 2024.10.07 20:27 [3316721] smart account 3N2iKmAK2hjZiqPD459iBpCfpoLLAiTu2Jz > SELF 0.00000000 Waves
{ "type": 13, "id": "AthrWG1KEF9rPcku21SYhknMWAPUzsexz9JH6Ag3n3ki", "fee": 1000000, "feeAssetId": null, "timestamp": 1728322082203, "version": 2, "chainId": 84, "sender": "3N2iKmAK2hjZiqPD459iBpCfpoLLAiTu2Jz", "senderPublicKey": "2KEygigiAaQkFXjU52DGSgnqArqAnT8Ah37KknQRvuhC", "proofs": [ "323c6YM9sVWDyBhHgFvrwuy3afyvNqJLyfYRVpkFCPVwkeqmv7hubwBXHLdTDhMzZVAiA9XG2ZrjyWDVVhr2iEa" ], "script": "base64:BgIWCAISAwoBCBIDCgEBEgQKAgEBEgASABkAC1NUQVJUX1BSSUNFAKDCHgAIUVVPVElFTlQAAgAIREVDSU1BTFMAgMLXLwEXc3RhdGljS2V5X29yYWNsZUFkZHJlc3MAAhRzdGF0aWNfb3JhY2xlQWRkcmVzcwEUc3RhdGljS2V5X2VnZ0Fzc2V0SWQAAhFzdGF0aWNfZWdnQXNzZXRJZAESc3RhdGljS2V5X2V4dHJhRmVlAAIPc3RhdGljX2V4dHJhRmVlARdzdGF0aWNLZXlfZmVlQWdncmVnYXRvcgACFHN0YXRpY19mZWVBZ2dyZWdhdG9yARhzdGF0aWNLZXlfY291cG9uc0FkZHJlc3MAAhVzdGF0aWNfY291cG9uc0FkZHJlc3MBFXN0YXRpY0tleV9idXJuQWRkcmVzcwACEnN0YXRpY19idXJuQWRkcmVzcwEJaXNUZXN0RW52AAQHdGVzdGVudgQHJG1hdGNoMAkAmwgCBQR0aGlzAgdURVNURU5WAwkAAQIFByRtYXRjaDACB0Jvb2xlYW4EAXgFByRtYXRjaDAFAXgHBQd0ZXN0ZW52AQ5rZXlVc2VyQWRk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9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAQUJZmlyc3RVc2VyAAEDCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwACBQlmaXJzdFVzZXIAAQAABBBzZWNvbmRVc2VyU2lnbmVkAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAUKc2Vjb25kVXNlcgABAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAQUKc2Vjb25kVXNlcgABAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAgUKc2Vjb25kVXNlcgABAAAED3RoaXJkVXNlclNpZ25lZAMJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAFCXRoaXJkVXNlcgABAwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAQUJdGhpcmRVc2VyAAEDCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwACBQl0aGlyZFVzZXIAAQAABA9zaWduYXR1cmVzQ291bnQJAGQCCQBkAgUPZmlyc3RVc2VyU2lnbmVkBRBzZWNvbmRVc2VyU2lnbmVkBQ90aGlyZFVzZXJTaWduZWQEByRtYXRjaDAFAnR4CQBnAgUPc2lnbmF0dXJlc0NvdW50AAKf7xPL", "height": 3316721, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let START_PRICE = 500000 | |
5 | + | ||
6 | + | let QUOTIENT = 2 | |
7 | + | ||
8 | + | let DECIMALS = 100000000 | |
9 | + | ||
10 | + | func staticKey_oracleAddress () = "static_oracleAddress" | |
11 | + | ||
12 | + | ||
13 | + | func staticKey_eggAssetId () = "static_eggAssetId" | |
14 | + | ||
15 | + | ||
16 | + | func staticKey_extraFee () = "static_extraFee" | |
17 | + | ||
18 | + | ||
19 | + | func staticKey_feeAggregator () = "static_feeAggregator" | |
20 | + | ||
21 | + | ||
22 | + | func staticKey_couponsAddress () = "static_couponsAddress" | |
23 | + | ||
24 | + | ||
25 | + | func staticKey_burnAddress () = "static_burnAddress" | |
26 | + | ||
27 | + | ||
28 | + | func isTestEnv () = { | |
29 | + | let testenv = match getBoolean(this, "TESTENV") { | |
30 | + | case x: Boolean => | |
31 | + | x | |
32 | + | case _ => | |
33 | + | false | |
34 | + | } | |
35 | + | testenv | |
36 | + | } | |
37 | + | ||
38 | + | ||
39 | + | func keyUserAddress (address) = (address + "_level") | |
40 | + | ||
41 | + | ||
42 | + | func keyUserSpentOnLevel (address) = (address + "_spentOnLevel") | |
43 | + | ||
44 | + | ||
45 | + | func keyUserSkillResetTimes (address) = (address + "_skillsResetTimes") | |
46 | + | ||
47 | + | ||
48 | + | func keyUserSpentOnReset (address) = (address + "_spentOnReset") | |
49 | + | ||
50 | + | ||
51 | + | func tryGetInteger (key) = match getInteger(this, key) { | |
52 | + | case b: Int => | |
53 | + | b | |
54 | + | case _ => | |
55 | + | 0 | |
56 | + | } | |
57 | + | ||
58 | + | ||
59 | + | func tryGetStringExternal (address,key) = match getString(address, key) { | |
60 | + | case a: String => | |
61 | + | a | |
62 | + | case _ => | |
63 | + | "" | |
64 | + | } | |
65 | + | ||
66 | + | ||
67 | + | func tryGetString (key) = tryGetStringExternal(this, key) | |
68 | + | ||
69 | + | ||
70 | + | func getOracle () = Address(fromBase58String(tryGetString(staticKey_oracleAddress()))) | |
71 | + | ||
72 | + | ||
73 | + | func getEggAssetId () = fromBase58String(tryGetStringExternal(getOracle(), staticKey_eggAssetId())) | |
74 | + | ||
75 | + | ||
76 | + | func getFeeAggregator () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_feeAggregator()))) | |
77 | + | ||
78 | + | ||
79 | + | func getCouponsAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_couponsAddress()))) | |
80 | + | ||
81 | + | ||
82 | + | func getBurnAddress () = Address(fromBase58String(tryGetStringExternal(getOracle(), staticKey_burnAddress()))) | |
83 | + | ||
84 | + | ||
85 | + | func calculateLevelUp (futureLevel) = { | |
86 | + | let p1 = pow(START_PRICE, 8, (10000 / futureLevel), 4, 8, CEILING) | |
87 | + | let p2 = pow(futureLevel, 0, (10000 / QUOTIENT), 4, 8, CEILING) | |
88 | + | let total = fraction(p1, p2, DECIMALS) | |
89 | + | let debug = makeString([("newLevel=" + toString(futureLevel)), ("p1=" + toString(p1)), ("p2=" + toString(p2)), ("total=" + toString(total))], ";") | |
90 | + | $Tuple2([StringEntry("DEBUG", debug)], total) | |
91 | + | } | |
92 | + | ||
93 | + | ||
94 | + | func calculateReset (currentLevel,resetTimes) = { | |
95 | + | let DEVIDER = 4 | |
96 | + | let resetTimesToUse = (resetTimes + 1) | |
97 | + | let result = fraction(resetTimesToUse, (currentLevel * DECIMALS), DEVIDER) | |
98 | + | let debug = makeString([("level=" + toString(currentLevel)), ("resetTimes=" + toString(resetTimes)), ("resetTimesToUse=" + toString(resetTimesToUse)), ("result=" + toString(result))], ";") | |
99 | + | $Tuple2([StringEntry("DEBUG", debug)], result) | |
100 | + | } | |
101 | + | ||
102 | + | ||
103 | + | func checkAdditionalPayment (payment) = if (isDefined(payment.assetId)) | |
104 | + | then throw("LSCAP: Please attach waves") | |
105 | + | else { | |
106 | + | let feeAmount = getIntegerValue(getOracle(), staticKey_extraFee()) | |
107 | + | if ((payment.amount != feeAmount)) | |
108 | + | then throw((("LSCAP: Please attach exactly " + toString(feeAmount)) + " amount of wavelets")) | |
109 | + | else [ScriptTransfer(getFeeAggregator(), feeAmount, unit)] | |
110 | + | } | |
111 | + | ||
112 | + | ||
113 | + | @Callable(i) | |
114 | + | func configureOracle (oracle) = if ((i.caller != this)) | |
115 | + | then throw("RCO: admin only") | |
116 | + | else [StringEntry(staticKey_oracleAddress(), oracle)] | |
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | @Callable(i) | |
121 | + | func levelUpMath (futureLevel) = calculateLevelUp(futureLevel) | |
122 | + | ||
123 | + | ||
124 | + | ||
125 | + | @Callable(i) | |
126 | + | func resetSkillsMath (currentLevel,resetTimes) = calculateReset(currentLevel, resetTimes) | |
127 | + | ||
128 | + | ||
129 | + | ||
130 | + | @Callable(i) | |
131 | + | func levelUp () = { | |
132 | + | let keyUserAddressFilled = keyUserAddress(toString(i.caller)) | |
133 | + | let keyUserSpentOnLevelFilled = keyUserSpentOnLevel(toString(i.caller)) | |
134 | + | let levelOfUser = tryGetInteger(keyUserAddressFilled) | |
135 | + | let totalSpentUser = tryGetInteger(keyUserSpentOnLevelFilled) | |
136 | + | let priceCalc = calculateLevelUp((levelOfUser + 1)) | |
137 | + | let price = priceCalc._2 | |
138 | + | let firstPayment = value(i.payments[0]) | |
139 | + | let amount = firstPayment.amount | |
140 | + | if ((firstPayment.assetId != getEggAssetId())) | |
141 | + | then throw(("LLU: You can attach only EGG tokens with the following asset id: " + toBase58String(getEggAssetId()))) | |
142 | + | else if ((amount != price)) | |
143 | + | then throw(("LLU: Please attach the exact asset amount" + toString(price))) | |
144 | + | else { | |
145 | + | let recordAction = invoke(getCouponsAddress(), "recordAction", ["LEVELUP"], nil) | |
146 | + | if ((recordAction == recordAction)) | |
147 | + | then { | |
148 | + | let burnCall = invoke(getBurnAddress(), "burnAttachedPayments", nil, [AttachedPayment(getEggAssetId(), amount)]) | |
149 | + | if ((burnCall == burnCall)) | |
150 | + | then (([IntegerEntry(keyUserAddressFilled, (levelOfUser + 1)), IntegerEntry(keyUserSpentOnLevelFilled, (totalSpentUser + amount))] ++ priceCalc._1) ++ checkAdditionalPayment(i.payments[1])) | |
151 | + | else throw("Strict value is not equal to itself.") | |
152 | + | } | |
153 | + | else throw("Strict value is not equal to itself.") | |
154 | + | } | |
155 | + | } | |
156 | + | ||
157 | + | ||
158 | + | ||
159 | + | @Callable(i) | |
160 | + | func reset () = { | |
161 | + | let keyUserAddressFilled = keyUserAddress(toString(i.caller)) | |
162 | + | let levelOfUser = tryGetInteger(keyUserAddressFilled) | |
163 | + | let keyUserSkillResetTimesFilled = keyUserSkillResetTimes(toString(i.caller)) | |
164 | + | let resetsOfUser = tryGetInteger(keyUserSkillResetTimesFilled) | |
165 | + | let keyUserSpentOnResetFilled = keyUserSpentOnReset(toString(i.caller)) | |
166 | + | let amountOfSpendOnReset = tryGetInteger(keyUserSpentOnResetFilled) | |
167 | + | let calculateResetCalculated = calculateReset(levelOfUser, resetsOfUser) | |
168 | + | let price = calculateResetCalculated._2 | |
169 | + | let firstPayment = value(i.payments[0]) | |
170 | + | let amount = firstPayment.amount | |
171 | + | if ((firstPayment.assetId != getEggAssetId())) | |
172 | + | then throw(("LR: You can attach only EGG tokens with the following asset id: " + toBase58String(getEggAssetId()))) | |
173 | + | else if ((amount != price)) | |
174 | + | then throw(("LR: Please attach the exact asset amount" + toString(price))) | |
175 | + | else (([IntegerEntry(keyUserSkillResetTimesFilled, (resetsOfUser + 1)), IntegerEntry(keyUserSpentOnResetFilled, (amountOfSpendOnReset + amount))] ++ calculateResetCalculated._1) ++ checkAdditionalPayment(i.payments[1])) | |
176 | + | } | |
177 | + | ||
178 | + | ||
179 | + | @Verifier(tx) | |
180 | + | func verify () = if (isTestEnv()) | |
181 | + | then sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
182 | + | else { | |
183 | + | let firstUser = base58'6TdaXEfhnjYquvPf3yV7MFxt2CbgFmaqsvGwkKfXtKi4' | |
184 | + | let secondUser = base58'7DsP2WaMLocbHuUxux7pbXRjTrrZ1TFQPsi5QumS3gr8' | |
185 | + | let thirdUser = base58'BpFWP3p3JgYrrP45xfrKzeMcWMEXoinj4FVPPkUiA8D3' | |
186 | + | let firstUserSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], firstUser)) | |
187 | + | then 1 | |
188 | + | else if (sigVerify(tx.bodyBytes, tx.proofs[1], firstUser)) | |
189 | + | then 1 | |
190 | + | else if (sigVerify(tx.bodyBytes, tx.proofs[2], firstUser)) | |
191 | + | then 1 | |
192 | + | else 0 | |
193 | + | let secondUserSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], secondUser)) | |
194 | + | then 1 | |
195 | + | else if (sigVerify(tx.bodyBytes, tx.proofs[1], secondUser)) | |
196 | + | then 1 | |
197 | + | else if (sigVerify(tx.bodyBytes, tx.proofs[2], secondUser)) | |
198 | + | then 1 | |
199 | + | else 0 | |
200 | + | let thirdUserSigned = if (sigVerify(tx.bodyBytes, tx.proofs[0], thirdUser)) | |
201 | + | then 1 | |
202 | + | else if (sigVerify(tx.bodyBytes, tx.proofs[1], thirdUser)) | |
203 | + | then 1 | |
204 | + | else if (sigVerify(tx.bodyBytes, tx.proofs[2], thirdUser)) | |
205 | + | then 1 | |
206 | + | else 0 | |
207 | + | let signaturesCount = ((firstUserSigned + secondUserSigned) + thirdUserSigned) | |
208 | + | match tx { | |
209 | + | case _ => | |
210 | + | (signaturesCount >= 2) | |
211 | + | } | |
212 | + | } | |
213 | + |
github/deemru/w8io/169f3d6 55.59 ms ◑