tx · HTxJqi7dKQfP4Hv4izxRpjLK6GuokUSqeT8BGEGX9Src 3P5x9RxuqbMaVFPsaycvXHeFZXPmcswxA1c: -0.01000000 Waves 2022.11.02 13:18 [3364710] smart account 3P5x9RxuqbMaVFPsaycvXHeFZXPmcswxA1c > SELF 0.00000000 Waves
{ "type": 13, "id": "HTxJqi7dKQfP4Hv4izxRpjLK6GuokUSqeT8BGEGX9Src", "fee": 1000000, "feeAssetId": null, "timestamp": 1667384290540, "version": 2, "chainId": 87, "sender": "3P5x9RxuqbMaVFPsaycvXHeFZXPmcswxA1c", "senderPublicKey": "9uEm8fN7ZMqn6sPuc39LRogUGXKNPPmRThGEL4GAqGa3", "proofs": [ "3fQQYZSJqHuijtFzNWwAEUage3FoqhRiM1mq3wMwJRTKuk9GaY1k7Hja25Z62zcy6uoLxgSYHQYbmskFi5NZ3H2U" ], "script": "base64:BgIWCAISAwoBCBIDCgEBEgQKAgEBEgASAA4AC1NUQVJUX1BSSUNFAKDCHgAIUVVPVElFTlQAAgAIREVDSU1BTFMAgMLXLwEOa2V5VXNlckFkZHJlc3MBB2FkZHJlc3MJAKwCAgUHYWRkcmVzcwIGX2xldmVsARNrZXlVc2VyU3BlbnRPbkxldmVsAQdhZGRyZXNzCQCsAgIFB2FkZHJlc3MCDV9zcGVudE9uTGV2ZWwBFmtleVVzZXJTa2lsbFJlc2V0VGltZXMBB2FkZHJlc3MJAKwCAgUHYWRkcmVzcwIRX3NraWxsc1Jlc2V0VGltZXMBE2tleVVzZXJTcGVudE9uUmVzZXQBB2FkZHJlc3MJAKwCAgUHYWRkcmVzcwINX3NwZW50T25SZXNldAENdHJ5R2V0SW50ZWdlcgEDa2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFA2tleQMJAAECBQckbWF0Y2gwAgNJbnQEAWIFByRtYXRjaDAFAWIAAAEUdHJ5R2V0U3RyaW5nRXh0ZXJuYWwCB2FkZHJlc3MDa2V5BAckbWF0Y2gwCQCdCAIFB2FkZHJlc3MF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dHJ5R2V0SW50ZWdlcgEFGWtleVVzZXJTcGVudE9uUmVzZXRGaWxsZWQEGGNhbGN1bGF0ZVJlc2V0Q2FsY3VsYXRlZAkBDmNhbGN1bGF0ZVJlc2V0AgULbGV2ZWxPZlVzZXIFDHJlc2V0c09mVXNlcgQFcHJpY2UIBRhjYWxjdWxhdGVSZXNldENhbGN1bGF0ZWQCXzIEDGZpcnN0UGF5bWVudAkBBXZhbHVlAQkAkQMCCAUBaQhwYXltZW50cwAABAZhbW91bnQIBQxmaXJzdFBheW1lbnQGYW1vdW50AwkBAiE9AggFDGZpcnN0UGF5bWVudAdhc3NldElkCQENZ2V0RWdnQXNzZXRJZAAJAAIBCQCsAgICQExSOiBZb3UgY2FuIGF0dGFjaCBvbmx5IEVHRyB0b2tlbnMgd2l0aCB0aGUgZm9sbG93aW5nIGFzc2V0IGlkOiAJANgEAQkBDWdldEVnZ0Fzc2V0SWQAAwkBAiE9AgUGYW1vdW50BQVwcmljZQkAAgEJAKwCAgIoTFI6IFBsZWFzZSBhdHRhY2ggdGhlIGV4YWN0IGFzc2V0IGFtb3VudAkApAMBBQVwcmljZQkAzggCCQDMCAIJAQxJbnRlZ2VyRW50cnkCBRxrZXlVc2VyU2tpbGxSZXNldFRpbWVzRmlsbGVkCQBkAgUMcmVzZXRzT2ZVc2VyAAEJAMwIAgkBDEludGVnZXJFbnRyeQIFGWtleVVzZXJTcGVudE9uUmVzZXRGaWxsZWQJAGQCBRRhbW91bnRPZlNwZW5kT25SZXNldAUGYW1vdW50BQNuaWwIBRhjYWxjdWxhdGVSZXNldENhbGN1bGF0ZWQCXzEAMhwDHg==", "height": 3364710, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3ZnqCPzxa59KrPfdLAgSo9H48bMhtCPvnfnvf53nk2PT Next: FqzC8FRHCiRjgzSDc4gSbdSSNRiEG6bT9RtaXg4UkDiB Diff:
Old | New | Differences | |
---|---|---|---|
44 | 44 | func getEggAssetId () = fromBase58String(tryGetStringExternal(getOracle(), "static_eggAssetId")) | |
45 | 45 | ||
46 | 46 | ||
47 | - | func calculateLevelUp ( | |
48 | - | let p1 = pow(START_PRICE, 8, (10000 / | |
49 | - | let p2 = pow( | |
47 | + | func calculateLevelUp (futureLevel) = { | |
48 | + | let p1 = pow(START_PRICE, 8, (10000 / futureLevel), 4, 8, CEILING) | |
49 | + | let p2 = pow(futureLevel, 0, (10000 / QUOTIENT), 4, 8, CEILING) | |
50 | 50 | let total = fraction(p1, p2, DECIMALS) | |
51 | - | let debug = makeString([(" | |
51 | + | let debug = makeString([("newLevel=" + toString(futureLevel)), ("p1=" + toString(p1)), ("p2=" + toString(p2)), ("total=" + toString(total))], ";") | |
52 | 52 | $Tuple2([StringEntry("DEBUG", debug)], total) | |
53 | 53 | } | |
54 | 54 | ||
70 | 70 | ||
71 | 71 | ||
72 | 72 | @Callable(i) | |
73 | - | func levelUpMath ( | |
73 | + | func levelUpMath (futureLevel) = calculateLevelUp(futureLevel) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
85 | 85 | let keyUserSpentOnLevelFilled = keyUserSpentOnLevel(toString(i.caller)) | |
86 | 86 | let levelOfUser = tryGetInteger(keyUserAddressFilled) | |
87 | 87 | let totalSpentUser = tryGetInteger(keyUserSpentOnLevelFilled) | |
88 | - | let priceCalc = calculateLevelUp(levelOfUser) | |
88 | + | let priceCalc = calculateLevelUp((levelOfUser + 1)) | |
89 | 89 | let price = priceCalc._2 | |
90 | 90 | let firstPayment = value(i.payments[0]) | |
91 | 91 | let amount = firstPayment.amount |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let START_PRICE = 500000 | |
5 | 5 | ||
6 | 6 | let QUOTIENT = 2 | |
7 | 7 | ||
8 | 8 | let DECIMALS = 100000000 | |
9 | 9 | ||
10 | 10 | func keyUserAddress (address) = (address + "_level") | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func keyUserSpentOnLevel (address) = (address + "_spentOnLevel") | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func keyUserSkillResetTimes (address) = (address + "_skillsResetTimes") | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func keyUserSpentOnReset (address) = (address + "_spentOnReset") | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func tryGetInteger (key) = match getInteger(this, key) { | |
23 | 23 | case b: Int => | |
24 | 24 | b | |
25 | 25 | case _ => | |
26 | 26 | 0 | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func tryGetStringExternal (address,key) = match getString(address, key) { | |
31 | 31 | case a: String => | |
32 | 32 | a | |
33 | 33 | case _ => | |
34 | 34 | "" | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func tryGetString (key) = tryGetStringExternal(this, key) | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func getOracle () = Address(fromBase58String(tryGetString("static_oracleAddress"))) | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func getEggAssetId () = fromBase58String(tryGetStringExternal(getOracle(), "static_eggAssetId")) | |
45 | 45 | ||
46 | 46 | ||
47 | - | func calculateLevelUp ( | |
48 | - | let p1 = pow(START_PRICE, 8, (10000 / | |
49 | - | let p2 = pow( | |
47 | + | func calculateLevelUp (futureLevel) = { | |
48 | + | let p1 = pow(START_PRICE, 8, (10000 / futureLevel), 4, 8, CEILING) | |
49 | + | let p2 = pow(futureLevel, 0, (10000 / QUOTIENT), 4, 8, CEILING) | |
50 | 50 | let total = fraction(p1, p2, DECIMALS) | |
51 | - | let debug = makeString([(" | |
51 | + | let debug = makeString([("newLevel=" + toString(futureLevel)), ("p1=" + toString(p1)), ("p2=" + toString(p2)), ("total=" + toString(total))], ";") | |
52 | 52 | $Tuple2([StringEntry("DEBUG", debug)], total) | |
53 | 53 | } | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | func calculateReset (currentLevel,resetTimes) = { | |
57 | 57 | let DEVIDER = 4 | |
58 | 58 | let resetTimesToUse = (resetTimes + 1) | |
59 | 59 | let result = fraction(resetTimesToUse, (currentLevel * DECIMALS), DEVIDER) | |
60 | 60 | let debug = makeString([("level=" + toString(currentLevel)), ("resetTimes=" + toString(resetTimes)), ("resetTimesToUse=" + toString(resetTimesToUse)), ("result=" + toString(result))], ";") | |
61 | 61 | $Tuple2([StringEntry("DEBUG", debug)], result) | |
62 | 62 | } | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | @Callable(i) | |
66 | 66 | func configureOracle (oracle) = if ((i.caller != this)) | |
67 | 67 | then throw("RCO: admin only") | |
68 | 68 | else [StringEntry("static_oracleAddress", oracle)] | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | ||
72 | 72 | @Callable(i) | |
73 | - | func levelUpMath ( | |
73 | + | func levelUpMath (futureLevel) = calculateLevelUp(futureLevel) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | 77 | @Callable(i) | |
78 | 78 | func resetSkillsMath (currentLevel,resetTimes) = calculateReset(currentLevel, resetTimes) | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | ||
82 | 82 | @Callable(i) | |
83 | 83 | func levelUp () = { | |
84 | 84 | let keyUserAddressFilled = keyUserAddress(toString(i.caller)) | |
85 | 85 | let keyUserSpentOnLevelFilled = keyUserSpentOnLevel(toString(i.caller)) | |
86 | 86 | let levelOfUser = tryGetInteger(keyUserAddressFilled) | |
87 | 87 | let totalSpentUser = tryGetInteger(keyUserSpentOnLevelFilled) | |
88 | - | let priceCalc = calculateLevelUp(levelOfUser) | |
88 | + | let priceCalc = calculateLevelUp((levelOfUser + 1)) | |
89 | 89 | let price = priceCalc._2 | |
90 | 90 | let firstPayment = value(i.payments[0]) | |
91 | 91 | let amount = firstPayment.amount | |
92 | 92 | if ((firstPayment.assetId != getEggAssetId())) | |
93 | 93 | then throw(("LLU: You can attach only EGG tokens with the following asset id: " + toBase58String(getEggAssetId()))) | |
94 | 94 | else if ((amount != price)) | |
95 | 95 | then throw(("LLU: Please attach the exact asset amount" + toString(price))) | |
96 | 96 | else ([IntegerEntry(keyUserAddressFilled, (levelOfUser + 1)), IntegerEntry(keyUserSpentOnLevelFilled, (totalSpentUser + amount))] ++ priceCalc._1) | |
97 | 97 | } | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | ||
101 | 101 | @Callable(i) | |
102 | 102 | func reset () = { | |
103 | 103 | let keyUserAddressFilled = keyUserAddress(toString(i.caller)) | |
104 | 104 | let levelOfUser = tryGetInteger(keyUserAddressFilled) | |
105 | 105 | let keyUserSkillResetTimesFilled = keyUserSkillResetTimes(toString(i.caller)) | |
106 | 106 | let resetsOfUser = tryGetInteger(keyUserSkillResetTimesFilled) | |
107 | 107 | let keyUserSpentOnResetFilled = keyUserSpentOnReset(toString(i.caller)) | |
108 | 108 | let amountOfSpendOnReset = tryGetInteger(keyUserSpentOnResetFilled) | |
109 | 109 | let calculateResetCalculated = calculateReset(levelOfUser, resetsOfUser) | |
110 | 110 | let price = calculateResetCalculated._2 | |
111 | 111 | let firstPayment = value(i.payments[0]) | |
112 | 112 | let amount = firstPayment.amount | |
113 | 113 | if ((firstPayment.assetId != getEggAssetId())) | |
114 | 114 | then throw(("LR: You can attach only EGG tokens with the following asset id: " + toBase58String(getEggAssetId()))) | |
115 | 115 | else if ((amount != price)) | |
116 | 116 | then throw(("LR: Please attach the exact asset amount" + toString(price))) | |
117 | 117 | else ([IntegerEntry(keyUserSkillResetTimesFilled, (resetsOfUser + 1)), IntegerEntry(keyUserSpentOnResetFilled, (amountOfSpendOnReset + amount))] ++ calculateResetCalculated._1) | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 |
github/deemru/w8io/fabc49c 41.72 ms ◑