tx · HxEv2bmkMuQYShH8eE9nj6ueGG8M52TMRBtvePdbbPzQ 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh: -0.00900000 Waves 2022.12.06 23:58 [2348989] smart account 3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh > SELF 0.00000000 Waves
{ "type": 13, "id": "HxEv2bmkMuQYShH8eE9nj6ueGG8M52TMRBtvePdbbPzQ", "fee": 900000, "feeAssetId": null, "timestamp": 1670360352818, "version": 2, "chainId": 84, "sender": "3MwLW8P5yh5T2xML9QqFuVxkVkm9RXqnzXh", "senderPublicKey": "HscGVyJG5M3NMHWKfQbucCBsFLGPi8VmTxTAmcBbaWTa", "proofs": [ "5ru4Df7TvhLb97GFqS5AWvAsrnBneyx6w6h9skHaVkCmcr949cRAmcMyuJXWb57yhei2RDnhNdDngo3TQ7hDPkpY" ], "script": "base64:BgITCAISAwoBCBIDCgEIEgASAwoBARUABlNjYWxlNgDAhD0ABlNjYWxlOACAwtcvAAdTY2FsZTE2CQBoAgUGU2NhbGU4BQZTY2FsZTgACnZhbGlkYXRvcnMJAMwIAgIjM05BbXFHanhSQlJQb1JIWlVVcXZoaU5TNmF4bkdwaW5MSEMFA25pbAAPbW9uZXlCb3hBZGRyZXNzCQEHQWRkcmVzcwEBGgFUZKnP467xWXotJQOt2k8QiNBvrQpHH8SpAAdhc3NldElkAixISG1hRlFwVW9id0t4emp6NEVDYUJQdG9GNjlrdWpLd1UyY296YVV6VHNndgALcHV6emxlUG9vbHMJAMwIAgIjM042U3RKZGdtVGZBUnNSTm45WHQ1ckRZRXMzcHI0S0d5MXYFA25pbAEKZ2V0QmFsYW5jZQEHYXNzZXRJZAQHJG1hdGNoMAUHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgRVbml0BAF4BQckbWF0Y2gwCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQkA8AcCBQR0aGlzCQEFdmFsdWUBBQdhc3NldElkAQl0cnlHZXRJbnQCB2FkZHJlc3MDa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BHVzZXIFBmFtb3VudAkBDHN1cHBseVJlc3VsdAIFC2N1cnJlbnRQb29sBQNmZWUBaQEHdW5zdGFrZQEGYW1vdW50BAR1c2VyCQClCAEIBQFpBmNhbGxlcgQLY3VycmVudFBvb2wJAQl0cnlHZXRTdHICBQR0aGlzAgtjdXJyZW50UG9vbAQDZmVlCQEHY2FsY0ZlZQAEBWFzc2V0CQDZBAEFB2Fzc2V0SWQEEnVuc3Rha2VSZXN1bHRTdGF0ZQkBDXVuc3Rha2VSZXN1bHQCBQR1c2VyBQZhbW91bnQEAnR4CQEWd2l0aGRyYXdGcm9tUHV6emxlUG9vbAIFC2N1cnJlbnRQb29sCQBkAgUGYW1vdW50BQNmZWUDCQAAAgUCdHgFAnR4CQDOCAIFEnVuc3Rha2VSZXN1bHRTdGF0ZQkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIFBmFtb3VudAUFYXNzZXQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwUPbW9uZXlCb3hBZGRyZXNzBQNmZWUFBWFzc2V0BQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5iZkWJA==", "height": 2348989, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HsT7hAfvd3PqREvak2ng9VC37kFLpg5xwBwoW9eiPutv Next: AiyEJ2Mr4gsuUNeX1c2hjmfXT5o1qhQu5Xn26TVVsM49 Diff:
Old | New | Differences | |
---|---|---|---|
117 | 117 | func K (L) = { | |
118 | 118 | let A = k(this, "global_staked") | |
119 | 119 | let J = G() | |
120 | - | [IntegerEntry("global_staked", (A + L)), IntegerEntry("global_lastCheckSRate", J)] | |
120 | + | if ((J > 0)) | |
121 | + | then throw(("sRate: " + toString(J))) | |
122 | + | else [IntegerEntry("global_staked", (A + L)), IntegerEntry("global_lastCheckSRate", J)] | |
121 | 123 | } | |
122 | 124 | ||
123 | 125 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = 1000000 | |
5 | 5 | ||
6 | 6 | let b = 100000000 | |
7 | 7 | ||
8 | 8 | let c = (b * b) | |
9 | 9 | ||
10 | 10 | let d = ["3NAmqGjxRBRPoRHZUUqvhiNS6axnGpinLHC"] | |
11 | 11 | ||
12 | 12 | let e = Address(base58'3My6LmrRSRvJ73T14oT5k53SGPavGFoacWc') | |
13 | 13 | ||
14 | 14 | let f = "HHmaFQpUobwKxzjz4ECaBPtoF69kujKwU2cozaUzTsgv" | |
15 | 15 | ||
16 | 16 | let g = ["3N6StJdgmTfARsRNn9Xt5rDYEs3pr4KGy1v"] | |
17 | 17 | ||
18 | 18 | func h (f) = { | |
19 | 19 | let i = f | |
20 | 20 | if ($isInstanceOf(i, "Unit")) | |
21 | 21 | then { | |
22 | 22 | let j = i | |
23 | 23 | wavesBalance(this).available | |
24 | 24 | } | |
25 | 25 | else assetBalance(this, value(f)) | |
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func k (l,m) = { | |
30 | 30 | let i = getInteger(l, m) | |
31 | 31 | if ($isInstanceOf(i, "Int")) | |
32 | 32 | then { | |
33 | 33 | let n = i | |
34 | 34 | n | |
35 | 35 | } | |
36 | 36 | else 0 | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func o (l,m) = { | |
41 | 41 | let i = getString(l, m) | |
42 | 42 | if ($isInstanceOf(i, "String")) | |
43 | 43 | then { | |
44 | 44 | let n = i | |
45 | 45 | n | |
46 | 46 | } | |
47 | 47 | else "" | |
48 | 48 | } | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func p (f) = { | |
52 | 52 | let i = f | |
53 | 53 | if ($isInstanceOf(i, "ByteVector")) | |
54 | 54 | then { | |
55 | 55 | let n = i | |
56 | 56 | toBase58String(n) | |
57 | 57 | } | |
58 | 58 | else "WAVES" | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func q (r) = { | |
63 | 63 | let s = assetBalance(Address(fromBase58String(r)), fromBase58String(f)) | |
64 | 64 | s | |
65 | 65 | } | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func t () = { | |
69 | 69 | let u = o(this, "currentPool") | |
70 | 70 | if ((u == "")) | |
71 | 71 | then throw(("Cannot find pool with id " + u)) | |
72 | 72 | else q(u) | |
73 | 73 | } | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func v (r,w) = { | |
77 | 77 | let x = Address(fromBase58String(r)) | |
78 | 78 | let y = if ((w > 0)) | |
79 | 79 | then invoke(x, "withdraw", [f, w], nil) | |
80 | 80 | else "" | |
81 | 81 | if ((y == y)) | |
82 | 82 | then y | |
83 | 83 | else throw("Strict value is not equal to itself.") | |
84 | 84 | } | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func z () = { | |
88 | 88 | let A = k(this, "global_staked") | |
89 | 89 | let B = k(this, "global_lastCheckSRate") | |
90 | 90 | let C = fraction(A, B, b) | |
91 | 91 | let D = t() | |
92 | 92 | let E = (D - C) | |
93 | 93 | let F = fraction(E, 5000000, b) | |
94 | 94 | if ((F > 0)) | |
95 | 95 | then F | |
96 | 96 | else 0 | |
97 | 97 | } | |
98 | 98 | ||
99 | 99 | ||
100 | 100 | func G () = { | |
101 | 101 | let H = k(this, "global_lastCheckSRate") | |
102 | 102 | let A = k(this, "global_staked") | |
103 | 103 | let I = fraction(A, H, b) | |
104 | 104 | if ((H == 0)) | |
105 | 105 | then b | |
106 | 106 | else if ((I == 0)) | |
107 | 107 | then H | |
108 | 108 | else { | |
109 | 109 | let J = fraction(H, (fraction((fraction(t(), a, I) - a), (b - 5000000), b) + a), a) | |
110 | 110 | if ((b > J)) | |
111 | 111 | then H | |
112 | 112 | else J | |
113 | 113 | } | |
114 | 114 | } | |
115 | 115 | ||
116 | 116 | ||
117 | 117 | func K (L) = { | |
118 | 118 | let A = k(this, "global_staked") | |
119 | 119 | let J = G() | |
120 | - | [IntegerEntry("global_staked", (A + L)), IntegerEntry("global_lastCheckSRate", J)] | |
120 | + | if ((J > 0)) | |
121 | + | then throw(("sRate: " + toString(J))) | |
122 | + | else [IntegerEntry("global_staked", (A + L)), IntegerEntry("global_lastCheckSRate", J)] | |
121 | 123 | } | |
122 | 124 | ||
123 | 125 | ||
124 | 126 | func M (r,F) = if ((indexOf(g, r) == unit)) | |
125 | 127 | then throw(("Unknown poolId " + r)) | |
126 | 128 | else { | |
127 | 129 | let N = fromBase58String(f) | |
128 | 130 | let s = h(N) | |
129 | 131 | let O = invoke(Address(fromBase58String(r)), "supply", nil, [AttachedPayment(N, s)]) | |
130 | 132 | if ((O == O)) | |
131 | 133 | then { | |
132 | 134 | let P = v(r, F) | |
133 | 135 | if ((P == P)) | |
134 | 136 | then [StringEntry("currentPool", r), ScriptTransfer(e, F, fromBase58String(f))] | |
135 | 137 | else throw("Strict value is not equal to itself.") | |
136 | 138 | } | |
137 | 139 | else throw("Strict value is not equal to itself.") | |
138 | 140 | } | |
139 | 141 | ||
140 | 142 | ||
141 | 143 | func Q () = { | |
142 | 144 | let u = o(this, "currentPool") | |
143 | 145 | if ((u == "")) | |
144 | 146 | then throw(("Cannot find pool with id " + u)) | |
145 | 147 | else { | |
146 | 148 | let w = q(u) | |
147 | 149 | let R = v(u, w) | |
148 | 150 | if ((R == R)) | |
149 | 151 | then R | |
150 | 152 | else throw("Strict value is not equal to itself.") | |
151 | 153 | } | |
152 | 154 | } | |
153 | 155 | ||
154 | 156 | ||
155 | 157 | func S (T,w) = { | |
156 | 158 | let C = fraction(w, b, G()) | |
157 | 159 | (K(C) ++ [IntegerEntry((T + "_staked"), (k(this, (T + "_staked")) + C))]) | |
158 | 160 | } | |
159 | 161 | ||
160 | 162 | ||
161 | 163 | func U (T,w) = { | |
162 | 164 | let C = fraction(w, b, G()) | |
163 | 165 | let V = k(this, (T + "_staked")) | |
164 | 166 | let W = if ((C > V)) | |
165 | 167 | then V | |
166 | 168 | else C | |
167 | 169 | (K(-(W)) ++ [IntegerEntry((T + "_staked"), (V - W))]) | |
168 | 170 | } | |
169 | 171 | ||
170 | 172 | ||
171 | 173 | @Callable(X) | |
172 | 174 | func init (r) = { | |
173 | 175 | let u = o(this, "currentPool") | |
174 | 176 | if ((indexOf(d, toString(X.caller)) == unit)) | |
175 | 177 | then throw("Access denied") | |
176 | 178 | else if ((u == "")) | |
177 | 179 | then [StringEntry("currentPool", r)] | |
178 | 180 | else nil | |
179 | 181 | } | |
180 | 182 | ||
181 | 183 | ||
182 | 184 | ||
183 | 185 | @Callable(X) | |
184 | 186 | func rebalance (r) = { | |
185 | 187 | let u = o(this, "currentPool") | |
186 | 188 | if ((indexOf(d, toString(X.caller)) == unit)) | |
187 | 189 | then throw("Access denied") | |
188 | 190 | else if ((u == r)) | |
189 | 191 | then throw(("Already supplied to" + u)) | |
190 | 192 | else { | |
191 | 193 | let y = Q() | |
192 | 194 | if ((y == y)) | |
193 | 195 | then (M(r, 0) ++ K(0)) | |
194 | 196 | else throw("Strict value is not equal to itself.") | |
195 | 197 | } | |
196 | 198 | } | |
197 | 199 | ||
198 | 200 | ||
199 | 201 | ||
200 | 202 | @Callable(X) | |
201 | 203 | func stake () = { | |
202 | 204 | let T = toString(X.caller) | |
203 | 205 | let w = X.payments[0].amount | |
204 | 206 | let u = o(this, "currentPool") | |
205 | 207 | if (if ((0 >= w)) | |
206 | 208 | then true | |
207 | 209 | else (X.payments[0].assetId != fromBase58String(f))) | |
208 | 210 | then throw("invalid token attached") | |
209 | 211 | else if ((u == "")) | |
210 | 212 | then throw("Pool not initialized") | |
211 | 213 | else { | |
212 | 214 | let F = z() | |
213 | 215 | (S(T, w) ++ M(u, F)) | |
214 | 216 | } | |
215 | 217 | } | |
216 | 218 | ||
217 | 219 | ||
218 | 220 | ||
219 | 221 | @Callable(X) | |
220 | 222 | func unstake (w) = { | |
221 | 223 | let T = toString(X.caller) | |
222 | 224 | let u = o(this, "currentPool") | |
223 | 225 | let F = z() | |
224 | 226 | let Y = fromBase58String(f) | |
225 | 227 | let Z = U(T, w) | |
226 | 228 | let R = v(u, (w + F)) | |
227 | 229 | if ((R == R)) | |
228 | 230 | then (Z ++ [ScriptTransfer(X.caller, w, Y), ScriptTransfer(e, F, Y)]) | |
229 | 231 | else throw("Strict value is not equal to itself.") | |
230 | 232 | } | |
231 | 233 | ||
232 | 234 | ||
233 | 235 | @Verifier(R) | |
234 | 236 | func aa () = sigVerify(R.bodyBytes, R.proofs[0], R.senderPublicKey) | |
235 | 237 |
github/deemru/w8io/026f985 53.03 ms ◑