tx · Ho8NaFeBXJDYPonGysPxBESR4yNTeygT8ZG5ecMCe9Tn 3MuFfcccPDaPFLFRZJoUocV868STc8wjRoE: -0.05000000 Waves 2023.10.06 13:29 [2786640] smart account 3MuFfcccPDaPFLFRZJoUocV868STc8wjRoE > SELF 0.00000000 Waves
{ "type": 13, "id": "Ho8NaFeBXJDYPonGysPxBESR4yNTeygT8ZG5ecMCe9Tn", "fee": 5000000, "feeAssetId": null, "timestamp": 1696588240560, "version": 1, "sender": "3MuFfcccPDaPFLFRZJoUocV868STc8wjRoE", "senderPublicKey": "55j69b38Jc11a44VEKMFifbzFPc9gqpS2dzVMY6rbHyt", "proofs": [ "5rbudP4AoGgCFHNserMgZ38izS559nnj5i1VqqZoC8bUuxSMU6hDsvC8HVuJedKAY1eCH9xxh9VtPAGqayixY74X" ], "script": "base64:BgIsCAISABIDCgEIEgMKAQgSAwoBARIECgIIARIDCgEIEgMKAQgSABIAEgMKAQgnARB3cml0ZUNvbnN0U3RyaW5nAgNrZXkFdmFsdWUDCQEBIQEJAQlpc0RlZmluZWQBCQCdCAIFBHRoaXMFA2tleQkBC1N0cmluZ0VudHJ5AgUDa2V5BQV2YWx1ZQkAAgEJAKwCAgIVYWxyZWFkeSBpbml0aWFsaXplZDogBQNrZXkBCHdyaXRlSW50AgNrZXkFdmFsdWUDCQBmAgAABQV2YWx1ZQkAAgEJAKwCAgkArAICCQCsAgICF3dyaXRpbmcgbmVnYXRpdmUgdmFsdWUgCQCkAwEFBXZhbHVlAgkgZm9yIGtleSAFA2tleQkBDEludGVnZXJFbnRyeQIFA2tleQUFdmFsdWUBCGNoYW5nZUJ5AgNrZXkFdmFsdWUJAQh3cml0ZUludAIFA2tleQkAZAIJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwUDa2V5AAAFBXZhbHVlABJjb25maWdBZGRyZXNzU3RvcmUCBmNvbmZpZwANY29uZmlnQWRkcmVzcwkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCmCAE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Gl0c2VsZi4BaQEKdXNlclNoYXJlcwEHYWRkcmVzcwkAlAoCBQNuaWwJAQZzaGFyZXMBBQdhZGRyZXNzAWkBCXVzZXJQb3dlcgEHYWRkcmVzcwkAlAoCBQNuaWwJAQZzdGFrZWQBBQdhZGRyZXNzAWkBCnRvdGFsUG93ZXIACQCUCgIFA25pbAUNY3VycmVudFN0YWtlZAFpAQt0b3RhbFNoYXJlcwAJAJQKAgUDbmlsCQELdmFsdWVPckVsc2UCCQCfCAEFEHRvdGFsU2hhcmVzU3RvcmUAAAFpAQRpbml0AQRjb25mCQDMCAIJARB3cml0ZUNvbnN0U3RyaW5nAgUSY29uZmlnQWRkcmVzc1N0b3JlBQRjb25mBQNuaWwA1homdQ==", "chainId": 84, "height": 2786640, "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 | + | func a (b,c) = if (!(isDefined(getString(this, b)))) | |
5 | + | then StringEntry(b, c) | |
6 | + | else throw(("already initialized: " + b)) | |
7 | + | ||
8 | + | ||
9 | + | func d (b,c) = if ((0 > c)) | |
10 | + | then throw(((("writing negative value " + toString(c)) + " for key ") + b)) | |
11 | + | else IntegerEntry(b, c) | |
12 | + | ||
13 | + | ||
14 | + | func e (b,c) = d(b, (valueOrElse(getInteger(this, b), 0) + c)) | |
15 | + | ||
16 | + | ||
17 | + | let f = "config" | |
18 | + | ||
19 | + | let g = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, f), "staking: config address not found")), "invalid config address") | |
20 | + | ||
21 | + | func h (i) = invoke(g, "opAllowed", [i], nil) | |
22 | + | ||
23 | + | ||
24 | + | let j = valueOrErrorMessage(getString(g, "powerAssetId"), "pwr asset id not found") | |
25 | + | ||
26 | + | let k = fromBase58String(j) | |
27 | + | ||
28 | + | let l = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(g, "contract_minter"), "no contract_minter")), "invalid minter contract") | |
29 | + | ||
30 | + | let m = valueOrElse(getString(g, "main_addresses"), "") | |
31 | + | ||
32 | + | let n = valueOrErrorMessage(getInteger(g, (toString(this) + "_min_lock_time")), "min_lock_time not set") | |
33 | + | ||
34 | + | func o (p) = (p + "_shares") | |
35 | + | ||
36 | + | ||
37 | + | func q (r) = (r + "_height") | |
38 | + | ||
39 | + | ||
40 | + | func s (r) = (r + "_lock") | |
41 | + | ||
42 | + | ||
43 | + | func t (u) = valueOrErrorMessage(getInteger(this, q(o(u))), "no stake height") | |
44 | + | ||
45 | + | ||
46 | + | func v (u) = valueOrElse(getInteger(this, s(o(u))), 0) | |
47 | + | ||
48 | + | ||
49 | + | func w (u) = (v(u) + n) | |
50 | + | ||
51 | + | ||
52 | + | func x (u) = (t(u) + n) | |
53 | + | ||
54 | + | ||
55 | + | let y = valueOrElse(getString(g, (toString(this) + "_slashers")), "") | |
56 | + | ||
57 | + | let z = height | |
58 | + | ||
59 | + | let A = "stakedHeight" | |
60 | + | ||
61 | + | let B = "totalShares" | |
62 | + | ||
63 | + | let C = "staked" | |
64 | + | ||
65 | + | let D = 10000000000000000 | |
66 | + | ||
67 | + | let E = valueOrErrorMessage(getInteger(g, (toString(this) + "_staker_apr")), "no staker_apr") | |
68 | + | ||
69 | + | let F = ((365 * 24) * 60) | |
70 | + | ||
71 | + | let G = fraction(E, D, (1000 * F)) | |
72 | + | ||
73 | + | let H = valueOrElse(getInteger(this, C), 0) | |
74 | + | ||
75 | + | let I = { | |
76 | + | let J = valueOrElse(getInteger(this, A), 0) | |
77 | + | let K = (z - J) | |
78 | + | let L = (D + (K * G)) | |
79 | + | fraction(H, L, D) | |
80 | + | } | |
81 | + | ||
82 | + | func M (N) = { | |
83 | + | let O = valueOrElse(getInteger(this, B), 0) | |
84 | + | if ((O == 0)) | |
85 | + | then N | |
86 | + | else fraction(N, O, I) | |
87 | + | } | |
88 | + | ||
89 | + | ||
90 | + | func P (Q) = { | |
91 | + | let O = valueOrElse(getInteger(this, B), 0) | |
92 | + | if ((O == 0)) | |
93 | + | then Q | |
94 | + | else fraction(Q, I, O) | |
95 | + | } | |
96 | + | ||
97 | + | ||
98 | + | func R (S) = { | |
99 | + | let T = assetBalance(this, k) | |
100 | + | if ((S > T)) | |
101 | + | then { | |
102 | + | let U = invoke(l, "mint", [(S - T)], nil) | |
103 | + | if ((U == U)) | |
104 | + | then nil | |
105 | + | else throw("Strict value is not equal to itself.") | |
106 | + | } | |
107 | + | else nil | |
108 | + | } | |
109 | + | ||
110 | + | ||
111 | + | func V (p,S) = { | |
112 | + | let W = R(S) | |
113 | + | if ((W == W)) | |
114 | + | then ScriptTransfer(addressFromStringValue(p), S, k) | |
115 | + | else throw("Strict value is not equal to itself.") | |
116 | + | } | |
117 | + | ||
118 | + | ||
119 | + | func X (u) = valueOrElse(getInteger(this, o(u)), 0) | |
120 | + | ||
121 | + | ||
122 | + | func Y (u) = P(X(u)) | |
123 | + | ||
124 | + | ||
125 | + | func Z () = { | |
126 | + | let O = valueOrElse(getInteger(this, B), 0) | |
127 | + | let aa = P(O) | |
128 | + | ((((("height: " + toString(z)) + ", totalStaked: ") + toString(aa)) + ", totalShares: ") + toString(O)) | |
129 | + | } | |
130 | + | ||
131 | + | ||
132 | + | func ab (p) = { | |
133 | + | let ac = X(p) | |
134 | + | let ad = P(ac) | |
135 | + | let ae = ((("height: " + toString(z)) + ", account: ") + p) | |
136 | + | if ((ac == 0)) | |
137 | + | then ((((ae + ", staked: 0") + ", voting_power: 0") + ", stake_height: -1") + ", unstake_height: -1") | |
138 | + | else ((((((((ae + ", staked: ") + toString(ad)) + ", voting_power: ") + toString(ac)) + ", stake_height: ") + toString(t(p))) + ", unstake_height: ") + toString(max([x(p), w(p)]))) | |
139 | + | } | |
140 | + | ||
141 | + | ||
142 | + | func af (u,ag) = if ((ag.assetId != k)) | |
143 | + | then throw("invalid asset id") | |
144 | + | else { | |
145 | + | let ah = ag.amount | |
146 | + | let Q = M(ah) | |
147 | + | [d(C, (I + ah)), d(A, z), e(B, Q), e(o(u), Q), IntegerEntry(q(o(u)), z)] | |
148 | + | } | |
149 | + | ||
150 | + | ||
151 | + | func ai (u,aj,N) = { | |
152 | + | let ac = X(u) | |
153 | + | if ((ac == 0)) | |
154 | + | then throw("nothing to unstake") | |
155 | + | else { | |
156 | + | let ak = P(ac) | |
157 | + | let S = if ((N == -1)) | |
158 | + | then ak | |
159 | + | else N | |
160 | + | if ((0 > S)) | |
161 | + | then throw("cannot unstake negative amount") | |
162 | + | else if ((S > ak)) | |
163 | + | then throw("cannot unstake more than you have") | |
164 | + | else { | |
165 | + | let Q = min([M(S), ac]) | |
166 | + | if ((Q == 0)) | |
167 | + | then throw("cannot unstake 0 shares") | |
168 | + | else [d(C, (I - S)), d(A, z), e(B, -(Q)), e(o(u), -(Q)), V(aj, S)] | |
169 | + | } | |
170 | + | } | |
171 | + | } | |
172 | + | ||
173 | + | ||
174 | + | @Callable(al) | |
175 | + | func stake () = { | |
176 | + | let am = h("stake") | |
177 | + | if ((am == am)) | |
178 | + | then af(toString(al.caller), al.payments[0]) | |
179 | + | else throw("Strict value is not equal to itself.") | |
180 | + | } | |
181 | + | ||
182 | + | ||
183 | + | ||
184 | + | @Callable(al) | |
185 | + | func stakeFor (u) = { | |
186 | + | let am = h("stakeFor") | |
187 | + | if ((am == am)) | |
188 | + | then if (if ((u != toString(al.originCaller))) | |
189 | + | then !(contains(m, toString(al.caller))) | |
190 | + | else false) | |
191 | + | then throw("denied") | |
192 | + | else af(u, al.payments[0]) | |
193 | + | else throw("Strict value is not equal to itself.") | |
194 | + | } | |
195 | + | ||
196 | + | ||
197 | + | ||
198 | + | @Callable(al) | |
199 | + | func restakeFor (u) = { | |
200 | + | let am = h("restakeFor") | |
201 | + | if ((am == am)) | |
202 | + | then if (!(contains(m, toString(al.caller)))) | |
203 | + | then throw("denied") | |
204 | + | else [IntegerEntry(s(o(u)), z)] | |
205 | + | else throw("Strict value is not equal to itself.") | |
206 | + | } | |
207 | + | ||
208 | + | ||
209 | + | ||
210 | + | @Callable(al) | |
211 | + | func unstake (N) = { | |
212 | + | let am = h("unstake") | |
213 | + | if ((am == am)) | |
214 | + | then { | |
215 | + | let an = toString(al.caller) | |
216 | + | if ((x(an) > z)) | |
217 | + | then throw("still locked in staking") | |
218 | + | else if ((w(an) > z)) | |
219 | + | then throw("still locked in voting") | |
220 | + | else ai(an, an, N) | |
221 | + | } | |
222 | + | else throw("Strict value is not equal to itself.") | |
223 | + | } | |
224 | + | ||
225 | + | ||
226 | + | ||
227 | + | @Callable(al) | |
228 | + | func unstakeFrom (u,N) = { | |
229 | + | let am = h("unstakeFrom") | |
230 | + | if ((am == am)) | |
231 | + | then { | |
232 | + | let ao = toString(al.caller) | |
233 | + | if (!(contains(m, ao))) | |
234 | + | then throw("denied") | |
235 | + | else ai(u, ao, N) | |
236 | + | } | |
237 | + | else throw("Strict value is not equal to itself.") | |
238 | + | } | |
239 | + | ||
240 | + | ||
241 | + | ||
242 | + | @Callable(al) | |
243 | + | func userShares (u) = $Tuple2(nil, X(u)) | |
244 | + | ||
245 | + | ||
246 | + | ||
247 | + | @Callable(al) | |
248 | + | func userPower (u) = $Tuple2(nil, Y(u)) | |
249 | + | ||
250 | + | ||
251 | + | ||
252 | + | @Callable(al) | |
253 | + | func totalPower () = $Tuple2(nil, I) | |
254 | + | ||
255 | + | ||
256 | + | ||
257 | + | @Callable(al) | |
258 | + | func totalShares () = $Tuple2(nil, valueOrElse(getInteger(B), 0)) | |
259 | + | ||
260 | + | ||
261 | + | ||
262 | + | @Callable(al) | |
263 | + | func init (ap) = [a(f, ap)] | |
264 | + | ||
265 | + |
github/deemru/w8io/fabc49c 23.00 ms ◑