tx · B4tw6JUmfdpcDni1S2mf9oM5xX52zGgKdAEdmPAP6iDw 3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy: -0.01000000 Waves 2023.06.05 16:32 [2609438] smart account 3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy > SELF 0.00000000 Waves
{ "type": 13, "id": "B4tw6JUmfdpcDni1S2mf9oM5xX52zGgKdAEdmPAP6iDw", "fee": 1000000, "feeAssetId": null, "timestamp": 1685972005188, "version": 2, "chainId": 84, "sender": "3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy", "senderPublicKey": "FsR18761ZAsUqsTd7TK3XmR6bhihs1UXVmpHYxz5JzQ1", "proofs": [ "4TzDovE3wL8fnHYqVnPrAjmhiRr7UpvM8Q7K5HaV4bVLmc73mAP8JgZNdHLydgHZBrpAFF2YBMDhwguQr8Z9h1zR" ], "script": "base64:BgIVCAISBQoDCAgIEgMKAQESAwoBARIAJwAFY2hhaW4JAMkBAgkAygECCAUEdGhpcwVieXRlcwABAAEAFWRlZmF1bHRSZXN0QWRkcmVzc1N0cgQHJG1hdGNoMAUFY2hhaW4DCQAAAgEBVwUHJG1hdGNoMAIjM1BRQ3V2RmJ2aDRMa1BVbnJuVTF6M2puYkExcDltM1dOaHYDCQAAAgEBVAUHJG1hdGNoMAIjM011bWtHR3p0Q0tBWHBXRHF4a2Rkb2ZxWFNVYnFRa3ZTSnkJAAIBAg1Vbmtub3duIGNoYWluAANTRVACAl9fAAVNVUxUNgDAhD0ABVNTSVpFABkABU1TSVpFAGQABUxTSVpFAOEBAAZYTFNJWkUAkAMAB1hYTFNJWkUA8QQAC3JlY0xhbmRTaXplAAEBD2dldFN0cmluZ09yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuC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kBC3ZhbHVlT3JFbHNlAgkAnwgBBQt1c2VyVGltZUtleQUJaXNzdWVUaW1lBANlZmYJAQ5nZXRWb3RpbmdQb3dlcgEFCmNhbGxlckFkZHIECnVzZXJBbW91bnQJAGsDCQBrAwkAawMFBk1VTFQxNAULUExBWUVSU0hBUkUFBU1VTFQ2CQCRAwIFA2VmZgUKSWR4RWZmVXNlcgkAkQMCBQNlZmYFC0lkeEVmZlRvdGFsCQBlAgUDbm93BQxsYXN0VXNlclRpbWUJAGgCAAMFCllFQVJNSUxMSVMJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwUNbWFya2V0aW5nQWRkcgUPbWFya2V0aW5nQW1vdW50BQp3bGdBc3NldElkCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMFCHRlYW1BZGRyBQp0ZWFtQW1vdW50BQp3bGdBc3NldElkCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMFDHJlc3RDb250cmFjdAUJYWN0QW1vdW50BQp3bGdBc3NldElkCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMFBmNhbGxlcgUKdXNlckFtb3VudAUKd2xnQXNzZXRJZAkAzAgCCQEMSW50ZWdlckVudHJ5AgUUbGFzdE1hcmtldGluZ1RpbWVLZXkFA25vdwkAzAgCCQEMSW50ZWdlckVudHJ5AgUPbGFzdFRlYW1UaW1lS2V5BQNub3cJAMwIAgkBDEludGVnZXJFbnRyeQIFFWxhc3RBY3Rpdml0aWVzVGltZUtleQUDbm93CQDMCAIJAQxJbnRlZ2VyRW50cnkCBQt1c2VyVGltZUtleQUDbm93BQNuaWwAIkfGjQ==", "height": 2609438, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: A3ggoZJHcLYD45zjLSGy2818nuQzSZL1FRfyvfkmvYRZ Next: H5RbdsG7QRKzR6YpJ7yX4U5aoAJd7dndHaBGmXyvaJAZ Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let chain = take(drop(this.bytes, 1), 1) | |
5 | + | ||
6 | + | let defaultRestAddressStr = match chain { | |
7 | + | case _ => | |
8 | + | if ((base58'2W' == $match0)) | |
9 | + | then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv" | |
10 | + | else if ((base58'2T' == $match0)) | |
11 | + | then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy" | |
12 | + | else throw("Unknown chain") | |
13 | + | } | |
14 | + | ||
15 | + | let SEP = "__" | |
16 | + | ||
17 | + | let MULT6 = 1000000 | |
18 | + | ||
19 | + | let SSIZE = 25 | |
20 | + | ||
21 | + | let MSIZE = 100 | |
22 | + | ||
23 | + | let LSIZE = 225 | |
24 | + | ||
25 | + | let XLSIZE = 400 | |
26 | + | ||
27 | + | let XXLSIZE = 625 | |
28 | + | ||
29 | + | let recLandSize = 1 | |
30 | + | ||
31 | + | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
32 | + | ||
33 | + | ||
34 | + | let IdxCfgStakingDapp = 1 | |
35 | + | ||
36 | + | func keyRestCfg () = "%s__restConfig" | |
37 | + | ||
38 | + | ||
39 | + | func keyRestAddress () = "%s__restAddr" | |
40 | + | ||
41 | + | ||
42 | + | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
43 | + | ||
44 | + | ||
45 | + | func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
46 | + | ||
47 | + | ||
48 | + | let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr)) | |
49 | + | ||
50 | + | let restCfg = readRestCfgOrFail(restContract) | |
51 | + | ||
52 | + | let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp) | |
53 | + | ||
54 | + | func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr) | |
55 | + | ||
56 | + | ||
57 | + | func keyResProportions () = "resTypesProportions" | |
58 | + | ||
59 | + | ||
60 | + | func numPiecesBySize (landSize) = match landSize { | |
61 | + | case _ => | |
62 | + | if (("S" == $match0)) | |
63 | + | then SSIZE | |
64 | + | else if (("M" == $match0)) | |
65 | + | then MSIZE | |
66 | + | else if (("L" == $match0)) | |
67 | + | then LSIZE | |
68 | + | else if (("XL" == $match0)) | |
69 | + | then XLSIZE | |
70 | + | else if (("XXL" == $match0)) | |
71 | + | then XXLSIZE | |
72 | + | else throw("Unknown land size") | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | let IdxEffTotal = 0 | |
77 | + | ||
78 | + | let IdxEffUser = 1 | |
79 | + | ||
80 | + | func getVotingPower (userAddrStrOrEmpty) = { | |
81 | + | let props = split(valueOrElse(getString(stakingContract, keyResProportions()), "0_0_0_0_0_0"), "_") | |
82 | + | func adder (acc,item) = (acc + parseIntValue(item)) | |
83 | + | ||
84 | + | let totalPower = { | |
85 | + | let $l = props | |
86 | + | let $s = size($l) | |
87 | + | let $acc0 = 0 | |
88 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
89 | + | then $a | |
90 | + | else adder($a, $l[$i]) | |
91 | + | ||
92 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
93 | + | then $a | |
94 | + | else throw("List size exceeds 6") | |
95 | + | ||
96 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
97 | + | } | |
98 | + | let usersPower = if ((userAddrStrOrEmpty == "")) | |
99 | + | then 0 | |
100 | + | else { | |
101 | + | let landsStr = getString(stakingContract, keyStakedLandsByOwner(userAddrStrOrEmpty)) | |
102 | + | let lands = if (isDefined(landsStr)) | |
103 | + | then split_51C(value(landsStr), "_") | |
104 | + | else nil | |
105 | + | func oneLand (acc,landAssetId) = { | |
106 | + | let asset = value(assetInfo(fromBase58String(landAssetId))) | |
107 | + | let landSize = split(asset.description, "_")[recLandSize] | |
108 | + | (acc + numPiecesBySize(landSize)) | |
109 | + | } | |
110 | + | ||
111 | + | let $l = lands | |
112 | + | let $s = size($l) | |
113 | + | let $acc0 = 0 | |
114 | + | func $f1_1 ($a,$i) = if (($i >= $s)) | |
115 | + | then $a | |
116 | + | else oneLand($a, $l[$i]) | |
117 | + | ||
118 | + | func $f1_2 ($a,$i) = if (($i >= $s)) | |
119 | + | then $a | |
120 | + | else throw("List size exceeds 100") | |
121 | + | ||
122 | + | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100) | |
123 | + | } | |
124 | + | [totalPower, usersPower] | |
125 | + | } | |
126 | + | ||
127 | + | ||
128 | + | let MULT14 = 100000000000000 | |
129 | + | ||
130 | + | let MARKETINGSHARE = 100000 | |
131 | + | ||
132 | + | let TEAMSHARE = 200000 | |
133 | + | ||
134 | + | let ACTIVITYSHARE = 100000 | |
135 | + | ||
136 | + | let PLAYERSHARE = 400000 | |
137 | + | ||
138 | + | let YEARMILLIS = 31557600000 | |
139 | + | ||
140 | + | let wlgAssetIdKey = "wlg_assetId" | |
141 | + | ||
142 | + | let wlgIssueTimeKey = "wlg_issueTime" | |
143 | + | ||
144 | + | let marketingAddrKey = "marketingAddr" | |
145 | + | ||
146 | + | let teamAddrKey = "teamAddr" | |
147 | + | ||
148 | + | let lastMarketingTimeKey = "lastClaimedTime_marketing" | |
149 | + | ||
150 | + | let lastTeamTimeKey = "lastClaimedTime_team" | |
151 | + | ||
152 | + | let lastActivitiesTimeKey = "lastClaimedTime_activities" | |
153 | + | ||
154 | + | func keyLastClaimedTimeByUser (addr) = "lastClaimedTimeUser_ + addr" | |
4 | 155 | ||
5 | 156 | ||
6 | 157 | @Callable(i) | |
7 | - | func test1 () = { | |
8 | - | let result = 666 | |
9 | - | $Tuple2(nil, result) | |
158 | + | func constructorV1 (restAddr,marketingAddr,teamAddr) = if ((i.caller != this)) | |
159 | + | then throw("Permission denied") | |
160 | + | else if (isDefined(getString(wlgAssetIdKey))) | |
161 | + | then throw("Already initialized") | |
162 | + | else { | |
163 | + | let issue = Issue("WLGOLD", "WavesLands Gold investment token", MULT14, 8, true, unit, 0) | |
164 | + | let assetId = calculateAssetId(issue) | |
165 | + | [issue, IntegerEntry(wlgIssueTimeKey, lastBlock.timestamp), BinaryEntry(wlgAssetIdKey, assetId), StringEntry(keyRestAddress(), restAddr), StringEntry(marketingAddrKey, marketingAddr), StringEntry(teamAddrKey, teamAddr)] | |
166 | + | } | |
167 | + | ||
168 | + | ||
169 | + | ||
170 | + | @Callable(i) | |
171 | + | func buyWlg (amount) = nil | |
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | @Callable(i) | |
176 | + | func sellWlg (amount) = nil | |
177 | + | ||
178 | + | ||
179 | + | ||
180 | + | @Callable(i) | |
181 | + | func claim () = { | |
182 | + | let caller = i.caller | |
183 | + | let callerAddr = toString(caller) | |
184 | + | let now = lastBlock.timestamp | |
185 | + | let issueTime = valueOrErrorMessage(getInteger(wlgIssueTimeKey), "Not initialized") | |
186 | + | let wlgAssetId = value(getBinary(wlgAssetIdKey)) | |
187 | + | let lastMarketingTime = valueOrElse(getInteger(lastMarketingTimeKey), issueTime) | |
188 | + | let marketingAddr = addressFromStringValue(value(getString(marketingAddrKey))) | |
189 | + | let marketingAmount = fraction(fraction(MULT14, MARKETINGSHARE, MULT6), (now - lastMarketingTime), YEARMILLIS) | |
190 | + | let lastTeamTime = valueOrElse(getInteger(lastTeamTimeKey), issueTime) | |
191 | + | let teamAddr = addressFromStringValue(value(getString(teamAddrKey))) | |
192 | + | let teamAmount = fraction(fraction(MULT14, TEAMSHARE, MULT6), (now - lastTeamTime), (3 * YEARMILLIS)) | |
193 | + | let lastActivitiesTime = valueOrElse(getInteger(lastActivitiesTimeKey), issueTime) | |
194 | + | let actAmount = fraction(fraction(MULT14, ACTIVITYSHARE, MULT6), (now - lastActivitiesTime), (3 * YEARMILLIS)) | |
195 | + | let userTimeKey = keyLastClaimedTimeByUser(callerAddr) | |
196 | + | let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime) | |
197 | + | let eff = getVotingPower(callerAddr) | |
198 | + | let userAmount = fraction(fraction(fraction(MULT14, PLAYERSHARE, MULT6), eff[IdxEffUser], eff[IdxEffTotal]), (now - lastUserTime), (3 * YEARMILLIS)) | |
199 | + | [ScriptTransfer(marketingAddr, marketingAmount, wlgAssetId), ScriptTransfer(teamAddr, teamAmount, wlgAssetId), ScriptTransfer(restContract, actAmount, wlgAssetId), ScriptTransfer(caller, userAmount, wlgAssetId), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(userTimeKey, now)] | |
10 | 200 | } | |
11 | 201 | ||
12 | 202 |
github/deemru/w8io/026f985 27.37 ms ◑