tx · FQR71EwWYET2D37rV9cyPQy9c57AsVrLSPBFetrAPMsk 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h: -0.05000000 Waves 2023.03.28 09:53 [2509468] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves
{ "type": 13, "id": "FQR71EwWYET2D37rV9cyPQy9c57AsVrLSPBFetrAPMsk", "fee": 5000000, "feeAssetId": null, "timestamp": 1679986407647, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "4Hf2zM5FTDj64zR1dnYNtjKb11pjMh6yt1uDxvu673rLvPzK6wJiwKhM2493Nhjf9vnUkgYUoL1kQ9txttwgrnPY" ], "script": "base64:BgIRCAISABIAEgASBQoDAQEBEgAOAAxjb250cmFjdEZpbGUCCXJlYmFsYW5jZQAPa2V5c1RhcmdldFJhdGlvAg8lc19fdGFyZ2V0UmF0aW8AFGtleUFkZGl0aW9uYWxCYWxhbmNlAholc19fYWRkaXRpb25hbFdhdmVzQmFsYW5jZQAaa2V5U1dhdmVzQWRkaXRpb25hbEJhbGFuY2UCESVzX19zV2F2ZXNCYWxhbmNlABBrZXlTV2F2ZXNBc3NldElkAhElc19fc1dhdmVzQXNzZXRJZAAPa2V5UHJveHlBZGRyZXNzAhAlc19fcHJveHlBZGRyZXNzARBnZXRJbnRlZ2VyT3JaZXJvAQppbnRlZ2VyS2V5BAckbWF0Y2gwCQCaCAIFBHRoaXMFCmludGVnZXJLZXkDCQABAgUHJG1hdGNoMAIDSW50BAN2YWwFByRtYXRjaDAFA3ZhbAAAARBnZXRTdHJpbmdPclRocm93AQlzdHJpbmdLZXkEByRtYXRjaDAJAJ0IAgUEdGhpcwUJc3RyaW5nS2V5AwkAAQIFByRtYXRjaDACBlN0cmluZwQBcwUHJG1hdGNoMAUBcwkAAgEJAKwC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sQmFsYW5jZQkAawMFC3RhcmdldFJhdGlvBQ13aG9sZUJsYWxhbmNlAGQEBmNoYW5nZQkAZQIFEWFkZGl0aW9uYWxCYWxhbmNlBRd0YXJnZXRBZGRpdGlvbmFsQmFsYW5jZQQGbmV3UmVnCQBkAgUOcmVndWxhckJhbGFuY2UFBmNoYW5nZQMJAGYCAAAFBmNoYW5nZQQPc2VuZFdhdmVzQW1vdW50CQBoAgUGY2hhbmdlAP///////////wEJAQdkZXBvc2l0AQUPc2VuZFdhdmVzQW1vdW50BA5nZXRXYXZlc0Ftb3VudAUGY2hhbmdlCQEId2l0aGRyYXcBBQ5nZXRXYXZlc0Ftb3VudAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAxfZFj", "height": 2509468, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BN14Vfd9aoDBtQospVDznCoZboQsFZ5bmmSTPvtknHZD Next: ZYfmLsTeAxZk97CX7PPMQG7g1478dGJrXATh9cfAWYD Diff:
Old | New | Differences | |
---|---|---|---|
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | - | func n () = (wavesBalance(this).regular + g(c)) | |
39 | - | ||
40 | - | ||
41 | - | func o () = { | |
42 | - | let p = g(c) | |
43 | - | let q = g(d) | |
44 | - | if ((p == 0)) | |
45 | - | then 0 | |
46 | - | else fraction(100000000000, p, q) | |
38 | + | func n () = { | |
39 | + | let i = getInteger(b) | |
40 | + | if ($isInstanceOf(i, "Int")) | |
41 | + | then { | |
42 | + | let m = i | |
43 | + | m | |
44 | + | } | |
45 | + | else 80 | |
47 | 46 | } | |
48 | 47 | ||
49 | 48 | ||
50 | - | func r () = { | |
51 | - | let s = addressFromStringValue(k(f)) | |
52 | - | let t = invoke(s, "getRate", nil, nil) | |
53 | - | if ((t == t)) | |
49 | + | func o () = (wavesBalance(this).regular + g(c)) | |
50 | + | ||
51 | + | ||
52 | + | func p () = { | |
53 | + | let q = g(c) | |
54 | + | let r = g(d) | |
55 | + | if ((q == 0)) | |
56 | + | then 0 | |
57 | + | else fraction(100000000000, q, r) | |
58 | + | } | |
59 | + | ||
60 | + | ||
61 | + | func s () = { | |
62 | + | let t = addressFromStringValue(k(f)) | |
63 | + | let u = invoke(t, "getRate", nil, nil) | |
64 | + | if ((u == u)) | |
54 | 65 | then { | |
55 | - | let i = | |
66 | + | let i = u | |
56 | 67 | if ($isInstanceOf(i, "String")) | |
57 | 68 | then { | |
58 | 69 | let m = i | |
59 | 70 | parseIntValue(m) | |
60 | 71 | } | |
61 | - | else | |
72 | + | else throw("ZERO rate") | |
62 | 73 | } | |
63 | 74 | else throw("Strict value is not equal to itself.") | |
64 | 75 | } | |
65 | 76 | ||
66 | 77 | ||
67 | - | @Callable(u) | |
68 | - | func returnWavesBalance () = $Tuple2(nil, n()) | |
78 | + | func v (w) = { | |
79 | + | let t = addressFromStringValue(k(f)) | |
80 | + | let x = g(c) | |
81 | + | if ((x == x)) | |
82 | + | then { | |
83 | + | let y = g(d) | |
84 | + | if ((y == y)) | |
85 | + | then { | |
86 | + | let z = invoke(t, "deposit", nil, [AttachedPayment(unit, w)]) | |
87 | + | if ((z == z)) | |
88 | + | then { | |
89 | + | let i = z | |
90 | + | if ($isInstanceOf(i, "Int")) | |
91 | + | then { | |
92 | + | let A = i | |
93 | + | let B = (x - w) | |
94 | + | let C = (y + A) | |
95 | + | [IntegerEntry(c, B), IntegerEntry(d, C)] | |
96 | + | } | |
97 | + | else nil | |
98 | + | } | |
99 | + | else throw("Strict value is not equal to itself.") | |
100 | + | } | |
101 | + | else throw("Strict value is not equal to itself.") | |
102 | + | } | |
103 | + | else throw("Strict value is not equal to itself.") | |
104 | + | } | |
105 | + | ||
106 | + | ||
107 | + | func D (w) = { | |
108 | + | let t = addressFromStringValue(k(f)) | |
109 | + | let E = fromBase58String(k(e)) | |
110 | + | if ((E == E)) | |
111 | + | then { | |
112 | + | let x = g(c) | |
113 | + | if ((x == x)) | |
114 | + | then { | |
115 | + | let y = g(d) | |
116 | + | if ((y == y)) | |
117 | + | then { | |
118 | + | let F = s() | |
119 | + | if ((F == F)) | |
120 | + | then { | |
121 | + | let G = fraction(1000000000000, w, F) | |
122 | + | let z = invoke(t, "withdraw", nil, [AttachedPayment(E, G)]) | |
123 | + | if ((z == z)) | |
124 | + | then { | |
125 | + | let i = z | |
126 | + | if ($isInstanceOf(i, "Int")) | |
127 | + | then { | |
128 | + | let H = i | |
129 | + | let B = (x + H) | |
130 | + | let C = (y - G) | |
131 | + | [IntegerEntry(c, B), IntegerEntry(d, C)] | |
132 | + | } | |
133 | + | else nil | |
134 | + | } | |
135 | + | else throw("Strict value is not equal to itself.") | |
136 | + | } | |
137 | + | else throw("Strict value is not equal to itself.") | |
138 | + | } | |
139 | + | else throw("Strict value is not equal to itself.") | |
140 | + | } | |
141 | + | else throw("Strict value is not equal to itself.") | |
142 | + | } | |
143 | + | else throw("Strict value is not equal to itself.") | |
144 | + | } | |
145 | + | ||
146 | + | ||
147 | + | @Callable(I) | |
148 | + | func returnWavesBalance () = $Tuple2(nil, o()) | |
69 | 149 | ||
70 | 150 | ||
71 | 151 | ||
72 | - | @Callable( | |
152 | + | @Callable(I) | |
73 | 153 | func returnSWavesBalance () = $Tuple2(nil, g(d)) | |
74 | 154 | ||
75 | 155 | ||
76 | 156 | ||
77 | - | @Callable( | |
157 | + | @Callable(I) | |
78 | 158 | func calcRatio () = { | |
79 | - | let | |
80 | - | let | |
81 | - | let | |
82 | - | $Tuple2(nil, | |
159 | + | let J = wavesBalance(this).regular | |
160 | + | let K = g(c) | |
161 | + | let L = fraction(100, K, (K + J)) | |
162 | + | $Tuple2(nil, L) | |
83 | 163 | } | |
84 | 164 | ||
85 | 165 | ||
86 | 166 | ||
87 | - | @Callable( | |
88 | - | func calcRatioTest ( | |
89 | - | let | |
90 | - | let | |
91 | - | let | |
92 | - | let | |
93 | - | if ((0 > | |
167 | + | @Callable(I) | |
168 | + | func calcRatioTest (M,K,N) = { | |
169 | + | let O = (M + K) | |
170 | + | let P = fraction(N, O, 100) | |
171 | + | let Q = (K - P) | |
172 | + | let R = (M + Q) | |
173 | + | if ((0 > Q)) | |
94 | 174 | then { | |
95 | - | let | |
96 | - | $Tuple2(nil, [ | |
175 | + | let S = (Q * -1) | |
176 | + | $Tuple2(nil, [R, P, Q, ("deposit: " + toString(S))]) | |
97 | 177 | } | |
98 | 178 | else { | |
99 | - | let | |
100 | - | $Tuple2(nil, [ | |
179 | + | let S = Q | |
180 | + | $Tuple2(nil, [R, P, Q, ("withdraw: " + toString(S))]) | |
101 | 181 | } | |
182 | + | } | |
183 | + | ||
184 | + | ||
185 | + | ||
186 | + | @Callable(I) | |
187 | + | func rebalance () = { | |
188 | + | let M = wavesBalance(this).regular | |
189 | + | if ((M == M)) | |
190 | + | then { | |
191 | + | let q = g(c) | |
192 | + | if ((q == q)) | |
193 | + | then { | |
194 | + | let N = n() | |
195 | + | if ((N == N)) | |
196 | + | then { | |
197 | + | let T = (M + q) | |
198 | + | let P = fraction(N, T, 100) | |
199 | + | let Q = (q - P) | |
200 | + | let R = (M + Q) | |
201 | + | if ((0 > Q)) | |
202 | + | then { | |
203 | + | let U = (Q * -1) | |
204 | + | v(U) | |
205 | + | } | |
206 | + | else { | |
207 | + | let V = Q | |
208 | + | D(V) | |
209 | + | } | |
210 | + | } | |
211 | + | else throw("Strict value is not equal to itself.") | |
212 | + | } | |
213 | + | else throw("Strict value is not equal to itself.") | |
214 | + | } | |
215 | + | else throw("Strict value is not equal to itself.") | |
102 | 216 | } | |
103 | 217 | ||
104 | 218 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "rebalance" | |
5 | 5 | ||
6 | 6 | let b = "%s__targetRatio" | |
7 | 7 | ||
8 | 8 | let c = "%s__additionalWavesBalance" | |
9 | 9 | ||
10 | 10 | let d = "%s__sWavesBalance" | |
11 | 11 | ||
12 | 12 | let e = "%s__sWavesAssetId" | |
13 | 13 | ||
14 | 14 | let f = "%s__proxyAddress" | |
15 | 15 | ||
16 | 16 | func g (h) = { | |
17 | 17 | let i = getInteger(this, h) | |
18 | 18 | if ($isInstanceOf(i, "Int")) | |
19 | 19 | then { | |
20 | 20 | let j = i | |
21 | 21 | j | |
22 | 22 | } | |
23 | 23 | else 0 | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func k (l) = { | |
28 | 28 | let i = getString(this, l) | |
29 | 29 | if ($isInstanceOf(i, "String")) | |
30 | 30 | then { | |
31 | 31 | let m = i | |
32 | 32 | m | |
33 | 33 | } | |
34 | 34 | else throw((("[" + l) + "] is empty")) | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | - | func n () = (wavesBalance(this).regular + g(c)) | |
39 | - | ||
40 | - | ||
41 | - | func o () = { | |
42 | - | let p = g(c) | |
43 | - | let q = g(d) | |
44 | - | if ((p == 0)) | |
45 | - | then 0 | |
46 | - | else fraction(100000000000, p, q) | |
38 | + | func n () = { | |
39 | + | let i = getInteger(b) | |
40 | + | if ($isInstanceOf(i, "Int")) | |
41 | + | then { | |
42 | + | let m = i | |
43 | + | m | |
44 | + | } | |
45 | + | else 80 | |
47 | 46 | } | |
48 | 47 | ||
49 | 48 | ||
50 | - | func r () = { | |
51 | - | let s = addressFromStringValue(k(f)) | |
52 | - | let t = invoke(s, "getRate", nil, nil) | |
53 | - | if ((t == t)) | |
49 | + | func o () = (wavesBalance(this).regular + g(c)) | |
50 | + | ||
51 | + | ||
52 | + | func p () = { | |
53 | + | let q = g(c) | |
54 | + | let r = g(d) | |
55 | + | if ((q == 0)) | |
56 | + | then 0 | |
57 | + | else fraction(100000000000, q, r) | |
58 | + | } | |
59 | + | ||
60 | + | ||
61 | + | func s () = { | |
62 | + | let t = addressFromStringValue(k(f)) | |
63 | + | let u = invoke(t, "getRate", nil, nil) | |
64 | + | if ((u == u)) | |
54 | 65 | then { | |
55 | - | let i = | |
66 | + | let i = u | |
56 | 67 | if ($isInstanceOf(i, "String")) | |
57 | 68 | then { | |
58 | 69 | let m = i | |
59 | 70 | parseIntValue(m) | |
60 | 71 | } | |
61 | - | else | |
72 | + | else throw("ZERO rate") | |
62 | 73 | } | |
63 | 74 | else throw("Strict value is not equal to itself.") | |
64 | 75 | } | |
65 | 76 | ||
66 | 77 | ||
67 | - | @Callable(u) | |
68 | - | func returnWavesBalance () = $Tuple2(nil, n()) | |
78 | + | func v (w) = { | |
79 | + | let t = addressFromStringValue(k(f)) | |
80 | + | let x = g(c) | |
81 | + | if ((x == x)) | |
82 | + | then { | |
83 | + | let y = g(d) | |
84 | + | if ((y == y)) | |
85 | + | then { | |
86 | + | let z = invoke(t, "deposit", nil, [AttachedPayment(unit, w)]) | |
87 | + | if ((z == z)) | |
88 | + | then { | |
89 | + | let i = z | |
90 | + | if ($isInstanceOf(i, "Int")) | |
91 | + | then { | |
92 | + | let A = i | |
93 | + | let B = (x - w) | |
94 | + | let C = (y + A) | |
95 | + | [IntegerEntry(c, B), IntegerEntry(d, C)] | |
96 | + | } | |
97 | + | else nil | |
98 | + | } | |
99 | + | else throw("Strict value is not equal to itself.") | |
100 | + | } | |
101 | + | else throw("Strict value is not equal to itself.") | |
102 | + | } | |
103 | + | else throw("Strict value is not equal to itself.") | |
104 | + | } | |
105 | + | ||
106 | + | ||
107 | + | func D (w) = { | |
108 | + | let t = addressFromStringValue(k(f)) | |
109 | + | let E = fromBase58String(k(e)) | |
110 | + | if ((E == E)) | |
111 | + | then { | |
112 | + | let x = g(c) | |
113 | + | if ((x == x)) | |
114 | + | then { | |
115 | + | let y = g(d) | |
116 | + | if ((y == y)) | |
117 | + | then { | |
118 | + | let F = s() | |
119 | + | if ((F == F)) | |
120 | + | then { | |
121 | + | let G = fraction(1000000000000, w, F) | |
122 | + | let z = invoke(t, "withdraw", nil, [AttachedPayment(E, G)]) | |
123 | + | if ((z == z)) | |
124 | + | then { | |
125 | + | let i = z | |
126 | + | if ($isInstanceOf(i, "Int")) | |
127 | + | then { | |
128 | + | let H = i | |
129 | + | let B = (x + H) | |
130 | + | let C = (y - G) | |
131 | + | [IntegerEntry(c, B), IntegerEntry(d, C)] | |
132 | + | } | |
133 | + | else nil | |
134 | + | } | |
135 | + | else throw("Strict value is not equal to itself.") | |
136 | + | } | |
137 | + | else throw("Strict value is not equal to itself.") | |
138 | + | } | |
139 | + | else throw("Strict value is not equal to itself.") | |
140 | + | } | |
141 | + | else throw("Strict value is not equal to itself.") | |
142 | + | } | |
143 | + | else throw("Strict value is not equal to itself.") | |
144 | + | } | |
145 | + | ||
146 | + | ||
147 | + | @Callable(I) | |
148 | + | func returnWavesBalance () = $Tuple2(nil, o()) | |
69 | 149 | ||
70 | 150 | ||
71 | 151 | ||
72 | - | @Callable( | |
152 | + | @Callable(I) | |
73 | 153 | func returnSWavesBalance () = $Tuple2(nil, g(d)) | |
74 | 154 | ||
75 | 155 | ||
76 | 156 | ||
77 | - | @Callable( | |
157 | + | @Callable(I) | |
78 | 158 | func calcRatio () = { | |
79 | - | let | |
80 | - | let | |
81 | - | let | |
82 | - | $Tuple2(nil, | |
159 | + | let J = wavesBalance(this).regular | |
160 | + | let K = g(c) | |
161 | + | let L = fraction(100, K, (K + J)) | |
162 | + | $Tuple2(nil, L) | |
83 | 163 | } | |
84 | 164 | ||
85 | 165 | ||
86 | 166 | ||
87 | - | @Callable( | |
88 | - | func calcRatioTest ( | |
89 | - | let | |
90 | - | let | |
91 | - | let | |
92 | - | let | |
93 | - | if ((0 > | |
167 | + | @Callable(I) | |
168 | + | func calcRatioTest (M,K,N) = { | |
169 | + | let O = (M + K) | |
170 | + | let P = fraction(N, O, 100) | |
171 | + | let Q = (K - P) | |
172 | + | let R = (M + Q) | |
173 | + | if ((0 > Q)) | |
94 | 174 | then { | |
95 | - | let | |
96 | - | $Tuple2(nil, [ | |
175 | + | let S = (Q * -1) | |
176 | + | $Tuple2(nil, [R, P, Q, ("deposit: " + toString(S))]) | |
97 | 177 | } | |
98 | 178 | else { | |
99 | - | let | |
100 | - | $Tuple2(nil, [ | |
179 | + | let S = Q | |
180 | + | $Tuple2(nil, [R, P, Q, ("withdraw: " + toString(S))]) | |
101 | 181 | } | |
182 | + | } | |
183 | + | ||
184 | + | ||
185 | + | ||
186 | + | @Callable(I) | |
187 | + | func rebalance () = { | |
188 | + | let M = wavesBalance(this).regular | |
189 | + | if ((M == M)) | |
190 | + | then { | |
191 | + | let q = g(c) | |
192 | + | if ((q == q)) | |
193 | + | then { | |
194 | + | let N = n() | |
195 | + | if ((N == N)) | |
196 | + | then { | |
197 | + | let T = (M + q) | |
198 | + | let P = fraction(N, T, 100) | |
199 | + | let Q = (q - P) | |
200 | + | let R = (M + Q) | |
201 | + | if ((0 > Q)) | |
202 | + | then { | |
203 | + | let U = (Q * -1) | |
204 | + | v(U) | |
205 | + | } | |
206 | + | else { | |
207 | + | let V = Q | |
208 | + | D(V) | |
209 | + | } | |
210 | + | } | |
211 | + | else throw("Strict value is not equal to itself.") | |
212 | + | } | |
213 | + | else throw("Strict value is not equal to itself.") | |
214 | + | } | |
215 | + | else throw("Strict value is not equal to itself.") | |
102 | 216 | } | |
103 | 217 | ||
104 | 218 |
github/deemru/w8io/026f985 34.18 ms ◑