tx · 95Qmh2UMcxgtRYrLNxj1Hhv9eJE4krhpttBxDFRi5SiR
3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h: -0.05000000 Waves
2023.03.29 10:12 [2510917] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves
{
"type": 13,
"id": "95Qmh2UMcxgtRYrLNxj1Hhv9eJE4krhpttBxDFRi5SiR",
"fee": 5000000,
"feeAssetId": null,
"timestamp": 1680074003694,
"version": 2,
"chainId": 84,
"sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h",
"senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2",
"proofs": [
"3XgS9TubgTJHZ3Zcyj8KHMDeEHyoobyc3A8wMN3NE361rBszHtrPVTRverHXdT1gsGr7ataWBsKyQDJXBng6NHK3"
],
"script": "base64:BgIJCAISAwoBARIAEgAMY29udHJhY3RGaWxlAglyZWJhbGFuY2UAD2tleXNUYXJnZXRSYXRpbwIPJXNfX3RhcmdldFJhdGlvABRrZXlBZGRpdGlvbmFsQmFsYW5jZQIaJXNfX2FkZGl0aW9uYWxXYXZlc0JhbGFuY2UAGmtleVNXYXZlc0FkZGl0aW9uYWxCYWxhbmNlAhElc19fc1dhdmVzQmFsYW5jZQAQa2V5U1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQAD2tleVByb3h5QWRkcmVzcwIQJXNfX3Byb3h5QWRkcmVzcwANa2V5TWluQmFsYW5jZQITJXNfX21pbldhdmVzQmFsYW5jZQAGTVVMVDEyAICglKWNHQEQZ2V0SW50ZWdlck9yWmVybwEKaW50ZWdlcktleQQHJG1hdGNoMAkAmggCBQR0aGlzBQppbnRlZ2VyS2V5AwkAAQIFByRtYXRjaDACA0ludAQDdmFsBQckbWF0Y2gwBQN2YWwAAAEQZ2V0U3RyaW5nT3JUaHJvdwEJc3RyaW5nS2V5BAckbWF0Y2gwCQCdCAIFB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AAFBGRpZmYED3NlbmRXYXZlc0Ftb3VudAkBAS0BBQRkaWZmCQEHZGVwb3NpdAEFD3NlbmRXYXZlc0Ftb3VudAQOZ2V0V2F2ZXNBbW91bnQFBGRpZmYJAQh3aXRoZHJhdwEFDmdldFdhdmVzQW1vdW50CQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAgFpAQ5yZWJhbGFuY2VSYXRpbwELdGFyZ2V0UmF0aW8JARFyZWJhbGFuY2VJbnRlcm5hbAEFC3RhcmdldFJhdGlvAWkBCXJlYmFsYW5jZQAJARFyZWJhbGFuY2VJbnRlcm5hbAEJAQ5nZXRUYXJnZXRSYXRpbwAA712fTQ==",
"height": 2510917,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: Hce4aPAvmT9eMwmJomxYJuuLHT6io955KnNVFzDv8tB
Next: 9B5o6xrQxZesRAhzUguYrZiAsQDiEBE8rwd8j9ahfLaN
Diff:
Old | New | | Differences |
---|
46 | 46 | | let q = k |
---|
47 | 47 | | min([100, max([0, q])]) |
---|
48 | 48 | | } |
---|
49 | | - | else 80 |
---|
| 49 | + | else 0 |
---|
50 | 50 | | } |
---|
51 | 51 | | |
---|
52 | 52 | | |
---|
|
72 | 72 | | let o = k |
---|
73 | 73 | | parseIntValue(o) |
---|
74 | 74 | | } |
---|
75 | | - | else throw("ZERO rate") |
---|
| 75 | + | else throw("Rate is zero (0)") |
---|
76 | 76 | | } |
---|
77 | 77 | | else throw("Strict value is not equal to itself.") |
---|
78 | 78 | | } |
---|
79 | 79 | | |
---|
80 | 80 | | |
---|
81 | | - | func w (x) = { |
---|
82 | | - | let u = addressFromStringValue(m(f)) |
---|
83 | | - | let y = i(c) |
---|
84 | | - | if ((y == y)) |
---|
| 81 | + | func w () = addressFromStringValue(m(f)) |
---|
| 82 | + | |
---|
| 83 | + | |
---|
| 84 | + | func x () = fromBase58String(m(e)) |
---|
| 85 | + | |
---|
| 86 | + | |
---|
| 87 | + | func y (z) = { |
---|
| 88 | + | let u = w() |
---|
| 89 | + | let A = i(c) |
---|
| 90 | + | if ((A == A)) |
---|
85 | 91 | | then { |
---|
86 | | - | let z = i(d) |
---|
87 | | - | if ((z == z)) |
---|
88 | | - | then if ((x > 0)) |
---|
| 92 | + | let B = i(d) |
---|
| 93 | + | if ((B == B)) |
---|
| 94 | + | then if ((z > 0)) |
---|
89 | 95 | | then { |
---|
90 | | - | let A = invoke(u, "deposit", nil, [AttachedPayment(unit, x)]) |
---|
91 | | - | if ((A == A)) |
---|
| 96 | + | let C = invoke(u, "deposit", nil, [AttachedPayment(unit, z)]) |
---|
| 97 | + | if ((C == C)) |
---|
92 | 98 | | then { |
---|
93 | | - | let k = A |
---|
| 99 | + | let k = C |
---|
94 | 100 | | if ($isInstanceOf(k, "Int")) |
---|
95 | 101 | | then { |
---|
96 | | - | let B = k |
---|
97 | | - | let C = (y + x) |
---|
98 | | - | let D = (z + B) |
---|
99 | | - | [IntegerEntry(c, C), IntegerEntry(d, D)] |
---|
| 102 | + | let D = k |
---|
| 103 | + | let E = (A + z) |
---|
| 104 | + | let F = (B + D) |
---|
| 105 | + | [IntegerEntry(c, E), IntegerEntry(d, F)] |
---|
100 | 106 | | } |
---|
101 | 107 | | else nil |
---|
102 | 108 | | } |
---|
|
109 | 115 | | } |
---|
110 | 116 | | |
---|
111 | 117 | | |
---|
112 | | - | func E (x) = { |
---|
113 | | - | let u = addressFromStringValue(m(f)) |
---|
114 | | - | let F = fromBase58String(m(e)) |
---|
115 | | - | if ((F == F)) |
---|
| 118 | + | func G (z) = { |
---|
| 119 | + | let u = w() |
---|
| 120 | + | let A = i(c) |
---|
| 121 | + | if ((A == A)) |
---|
116 | 122 | | then { |
---|
117 | | - | let y = i(c) |
---|
118 | | - | if ((y == y)) |
---|
| 123 | + | let B = i(d) |
---|
| 124 | + | if ((B == B)) |
---|
119 | 125 | | then { |
---|
120 | | - | let z = i(d) |
---|
121 | | - | if ((z == z)) |
---|
| 126 | + | let H = t() |
---|
| 127 | + | if ((H == H)) |
---|
122 | 128 | | then { |
---|
123 | | - | let G = t() |
---|
124 | | - | if ((G == G)) |
---|
| 129 | + | let I = fraction(h, z, H) |
---|
| 130 | + | if ((I > 0)) |
---|
125 | 131 | | then { |
---|
126 | | - | let H = fraction(h, x, G) |
---|
127 | | - | if ((H > 0)) |
---|
| 132 | + | let J = invoke(u, "withdraw", nil, [AttachedPayment(x(), I)]) |
---|
| 133 | + | if ((J == J)) |
---|
128 | 134 | | then { |
---|
129 | | - | let A = invoke(u, "withdraw", nil, [AttachedPayment(F, H)]) |
---|
130 | | - | if ((A == A)) |
---|
| 135 | + | let k = J |
---|
| 136 | + | if ($isInstanceOf(k, "Int")) |
---|
131 | 137 | | then { |
---|
132 | | - | let k = A |
---|
133 | | - | if ($isInstanceOf(k, "Int")) |
---|
134 | | - | then { |
---|
135 | | - | let I = k |
---|
136 | | - | let C = (y - I) |
---|
137 | | - | let D = (z - H) |
---|
138 | | - | [IntegerEntry(c, C), IntegerEntry(d, D)] |
---|
139 | | - | } |
---|
140 | | - | else nil |
---|
| 138 | + | let K = k |
---|
| 139 | + | let E = (A - K) |
---|
| 140 | + | let F = (B - I) |
---|
| 141 | + | [IntegerEntry(c, E), IntegerEntry(d, F)] |
---|
141 | 142 | | } |
---|
142 | | - | else throw("Strict value is not equal to itself.") |
---|
| 143 | + | else nil |
---|
143 | 144 | | } |
---|
144 | | - | else nil |
---|
| 145 | + | else throw("Strict value is not equal to itself.") |
---|
145 | 146 | | } |
---|
146 | | - | else throw("Strict value is not equal to itself.") |
---|
| 147 | + | else nil |
---|
147 | 148 | | } |
---|
148 | 149 | | else throw("Strict value is not equal to itself.") |
---|
149 | 150 | | } |
---|
|
153 | 154 | | } |
---|
154 | 155 | | |
---|
155 | 156 | | |
---|
156 | | - | @Callable(s) |
---|
157 | | - | func rebalanceRatio (J) = { |
---|
158 | | - | let K = max([0, (wavesBalance(this).regular - r())]) |
---|
159 | | - | if ((K == K)) |
---|
| 157 | + | func L (M) = { |
---|
| 158 | + | let N = max([0, (wavesBalance(this).regular - r())]) |
---|
| 159 | + | if ((N == N)) |
---|
160 | 160 | | then { |
---|
161 | | - | let L = i(c) |
---|
162 | | - | if ((L == L)) |
---|
| 161 | + | let O = i(c) |
---|
| 162 | + | if ((O == O)) |
---|
163 | 163 | | then { |
---|
164 | | - | let M = (K + L) |
---|
165 | | - | let N = fraction(J, M, 100) |
---|
166 | | - | let O = (L - N) |
---|
167 | | - | if ((O == 0)) |
---|
| 164 | + | let P = (N + O) |
---|
| 165 | + | let Q = fraction(M, P, 100) |
---|
| 166 | + | let R = (O - Q) |
---|
| 167 | + | if ((R == 0)) |
---|
168 | 168 | | then nil |
---|
169 | | - | else if ((0 > O)) |
---|
| 169 | + | else if ((0 > R)) |
---|
170 | 170 | | then { |
---|
171 | | - | let P = (O * -1) |
---|
172 | | - | w(P) |
---|
| 171 | + | let S = -(R) |
---|
| 172 | + | y(S) |
---|
173 | 173 | | } |
---|
174 | 174 | | else { |
---|
175 | | - | let Q = O |
---|
176 | | - | E(Q) |
---|
| 175 | + | let T = R |
---|
| 176 | + | G(T) |
---|
177 | 177 | | } |
---|
178 | 178 | | } |
---|
179 | 179 | | else throw("Strict value is not equal to itself.") |
---|
|
182 | 182 | | } |
---|
183 | 183 | | |
---|
184 | 184 | | |
---|
| 185 | + | @Callable(s) |
---|
| 186 | + | func rebalanceRatio (M) = L(M) |
---|
| 187 | + | |
---|
| 188 | + | |
---|
| 189 | + | |
---|
| 190 | + | @Callable(s) |
---|
| 191 | + | func rebalance () = L(p()) |
---|
| 192 | + | |
---|
| 193 | + | |
---|
Full:
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 | | let g = "%s__minWavesBalance" |
---|
17 | 17 | | |
---|
18 | 18 | | let h = 1000000000000 |
---|
19 | 19 | | |
---|
20 | 20 | | func i (j) = { |
---|
21 | 21 | | let k = getInteger(this, j) |
---|
22 | 22 | | if ($isInstanceOf(k, "Int")) |
---|
23 | 23 | | then { |
---|
24 | 24 | | let l = k |
---|
25 | 25 | | l |
---|
26 | 26 | | } |
---|
27 | 27 | | else 0 |
---|
28 | 28 | | } |
---|
29 | 29 | | |
---|
30 | 30 | | |
---|
31 | 31 | | func m (n) = { |
---|
32 | 32 | | let k = getString(this, n) |
---|
33 | 33 | | if ($isInstanceOf(k, "String")) |
---|
34 | 34 | | then { |
---|
35 | 35 | | let o = k |
---|
36 | 36 | | o |
---|
37 | 37 | | } |
---|
38 | 38 | | else throw((("[" + n) + "] is empty")) |
---|
39 | 39 | | } |
---|
40 | 40 | | |
---|
41 | 41 | | |
---|
42 | 42 | | func p () = { |
---|
43 | 43 | | let k = getInteger(b) |
---|
44 | 44 | | if ($isInstanceOf(k, "Int")) |
---|
45 | 45 | | then { |
---|
46 | 46 | | let q = k |
---|
47 | 47 | | min([100, max([0, q])]) |
---|
48 | 48 | | } |
---|
49 | | - | else 80 |
---|
| 49 | + | else 0 |
---|
50 | 50 | | } |
---|
51 | 51 | | |
---|
52 | 52 | | |
---|
53 | 53 | | func r () = { |
---|
54 | 54 | | let k = getInteger(g) |
---|
55 | 55 | | if ($isInstanceOf(k, "Int")) |
---|
56 | 56 | | then { |
---|
57 | 57 | | let s = k |
---|
58 | 58 | | max([0, s]) |
---|
59 | 59 | | } |
---|
60 | 60 | | else 0 |
---|
61 | 61 | | } |
---|
62 | 62 | | |
---|
63 | 63 | | |
---|
64 | 64 | | func t () = { |
---|
65 | 65 | | let u = addressFromStringValue(m(f)) |
---|
66 | 66 | | let v = invoke(u, "getRate", nil, nil) |
---|
67 | 67 | | if ((v == v)) |
---|
68 | 68 | | then { |
---|
69 | 69 | | let k = v |
---|
70 | 70 | | if ($isInstanceOf(k, "String")) |
---|
71 | 71 | | then { |
---|
72 | 72 | | let o = k |
---|
73 | 73 | | parseIntValue(o) |
---|
74 | 74 | | } |
---|
75 | | - | else throw("ZERO rate") |
---|
| 75 | + | else throw("Rate is zero (0)") |
---|
76 | 76 | | } |
---|
77 | 77 | | else throw("Strict value is not equal to itself.") |
---|
78 | 78 | | } |
---|
79 | 79 | | |
---|
80 | 80 | | |
---|
81 | | - | func w (x) = { |
---|
82 | | - | let u = addressFromStringValue(m(f)) |
---|
83 | | - | let y = i(c) |
---|
84 | | - | if ((y == y)) |
---|
| 81 | + | func w () = addressFromStringValue(m(f)) |
---|
| 82 | + | |
---|
| 83 | + | |
---|
| 84 | + | func x () = fromBase58String(m(e)) |
---|
| 85 | + | |
---|
| 86 | + | |
---|
| 87 | + | func y (z) = { |
---|
| 88 | + | let u = w() |
---|
| 89 | + | let A = i(c) |
---|
| 90 | + | if ((A == A)) |
---|
85 | 91 | | then { |
---|
86 | | - | let z = i(d) |
---|
87 | | - | if ((z == z)) |
---|
88 | | - | then if ((x > 0)) |
---|
| 92 | + | let B = i(d) |
---|
| 93 | + | if ((B == B)) |
---|
| 94 | + | then if ((z > 0)) |
---|
89 | 95 | | then { |
---|
90 | | - | let A = invoke(u, "deposit", nil, [AttachedPayment(unit, x)]) |
---|
91 | | - | if ((A == A)) |
---|
| 96 | + | let C = invoke(u, "deposit", nil, [AttachedPayment(unit, z)]) |
---|
| 97 | + | if ((C == C)) |
---|
92 | 98 | | then { |
---|
93 | | - | let k = A |
---|
| 99 | + | let k = C |
---|
94 | 100 | | if ($isInstanceOf(k, "Int")) |
---|
95 | 101 | | then { |
---|
96 | | - | let B = k |
---|
97 | | - | let C = (y + x) |
---|
98 | | - | let D = (z + B) |
---|
99 | | - | [IntegerEntry(c, C), IntegerEntry(d, D)] |
---|
| 102 | + | let D = k |
---|
| 103 | + | let E = (A + z) |
---|
| 104 | + | let F = (B + D) |
---|
| 105 | + | [IntegerEntry(c, E), IntegerEntry(d, F)] |
---|
100 | 106 | | } |
---|
101 | 107 | | else nil |
---|
102 | 108 | | } |
---|
103 | 109 | | else throw("Strict value is not equal to itself.") |
---|
104 | 110 | | } |
---|
105 | 111 | | else nil |
---|
106 | 112 | | else throw("Strict value is not equal to itself.") |
---|
107 | 113 | | } |
---|
108 | 114 | | else throw("Strict value is not equal to itself.") |
---|
109 | 115 | | } |
---|
110 | 116 | | |
---|
111 | 117 | | |
---|
112 | | - | func E (x) = { |
---|
113 | | - | let u = addressFromStringValue(m(f)) |
---|
114 | | - | let F = fromBase58String(m(e)) |
---|
115 | | - | if ((F == F)) |
---|
| 118 | + | func G (z) = { |
---|
| 119 | + | let u = w() |
---|
| 120 | + | let A = i(c) |
---|
| 121 | + | if ((A == A)) |
---|
116 | 122 | | then { |
---|
117 | | - | let y = i(c) |
---|
118 | | - | if ((y == y)) |
---|
| 123 | + | let B = i(d) |
---|
| 124 | + | if ((B == B)) |
---|
119 | 125 | | then { |
---|
120 | | - | let z = i(d) |
---|
121 | | - | if ((z == z)) |
---|
| 126 | + | let H = t() |
---|
| 127 | + | if ((H == H)) |
---|
122 | 128 | | then { |
---|
123 | | - | let G = t() |
---|
124 | | - | if ((G == G)) |
---|
| 129 | + | let I = fraction(h, z, H) |
---|
| 130 | + | if ((I > 0)) |
---|
125 | 131 | | then { |
---|
126 | | - | let H = fraction(h, x, G) |
---|
127 | | - | if ((H > 0)) |
---|
| 132 | + | let J = invoke(u, "withdraw", nil, [AttachedPayment(x(), I)]) |
---|
| 133 | + | if ((J == J)) |
---|
128 | 134 | | then { |
---|
129 | | - | let A = invoke(u, "withdraw", nil, [AttachedPayment(F, H)]) |
---|
130 | | - | if ((A == A)) |
---|
| 135 | + | let k = J |
---|
| 136 | + | if ($isInstanceOf(k, "Int")) |
---|
131 | 137 | | then { |
---|
132 | | - | let k = A |
---|
133 | | - | if ($isInstanceOf(k, "Int")) |
---|
134 | | - | then { |
---|
135 | | - | let I = k |
---|
136 | | - | let C = (y - I) |
---|
137 | | - | let D = (z - H) |
---|
138 | | - | [IntegerEntry(c, C), IntegerEntry(d, D)] |
---|
139 | | - | } |
---|
140 | | - | else nil |
---|
| 138 | + | let K = k |
---|
| 139 | + | let E = (A - K) |
---|
| 140 | + | let F = (B - I) |
---|
| 141 | + | [IntegerEntry(c, E), IntegerEntry(d, F)] |
---|
141 | 142 | | } |
---|
142 | | - | else throw("Strict value is not equal to itself.") |
---|
| 143 | + | else nil |
---|
143 | 144 | | } |
---|
144 | | - | else nil |
---|
| 145 | + | else throw("Strict value is not equal to itself.") |
---|
145 | 146 | | } |
---|
146 | | - | else throw("Strict value is not equal to itself.") |
---|
| 147 | + | else nil |
---|
147 | 148 | | } |
---|
148 | 149 | | else throw("Strict value is not equal to itself.") |
---|
149 | 150 | | } |
---|
150 | 151 | | else throw("Strict value is not equal to itself.") |
---|
151 | 152 | | } |
---|
152 | 153 | | else throw("Strict value is not equal to itself.") |
---|
153 | 154 | | } |
---|
154 | 155 | | |
---|
155 | 156 | | |
---|
156 | | - | @Callable(s) |
---|
157 | | - | func rebalanceRatio (J) = { |
---|
158 | | - | let K = max([0, (wavesBalance(this).regular - r())]) |
---|
159 | | - | if ((K == K)) |
---|
| 157 | + | func L (M) = { |
---|
| 158 | + | let N = max([0, (wavesBalance(this).regular - r())]) |
---|
| 159 | + | if ((N == N)) |
---|
160 | 160 | | then { |
---|
161 | | - | let L = i(c) |
---|
162 | | - | if ((L == L)) |
---|
| 161 | + | let O = i(c) |
---|
| 162 | + | if ((O == O)) |
---|
163 | 163 | | then { |
---|
164 | | - | let M = (K + L) |
---|
165 | | - | let N = fraction(J, M, 100) |
---|
166 | | - | let O = (L - N) |
---|
167 | | - | if ((O == 0)) |
---|
| 164 | + | let P = (N + O) |
---|
| 165 | + | let Q = fraction(M, P, 100) |
---|
| 166 | + | let R = (O - Q) |
---|
| 167 | + | if ((R == 0)) |
---|
168 | 168 | | then nil |
---|
169 | | - | else if ((0 > O)) |
---|
| 169 | + | else if ((0 > R)) |
---|
170 | 170 | | then { |
---|
171 | | - | let P = (O * -1) |
---|
172 | | - | w(P) |
---|
| 171 | + | let S = -(R) |
---|
| 172 | + | y(S) |
---|
173 | 173 | | } |
---|
174 | 174 | | else { |
---|
175 | | - | let Q = O |
---|
176 | | - | E(Q) |
---|
| 175 | + | let T = R |
---|
| 176 | + | G(T) |
---|
177 | 177 | | } |
---|
178 | 178 | | } |
---|
179 | 179 | | else throw("Strict value is not equal to itself.") |
---|
180 | 180 | | } |
---|
181 | 181 | | else throw("Strict value is not equal to itself.") |
---|
182 | 182 | | } |
---|
183 | 183 | | |
---|
184 | 184 | | |
---|
| 185 | + | @Callable(s) |
---|
| 186 | + | func rebalanceRatio (M) = L(M) |
---|
| 187 | + | |
---|
| 188 | + | |
---|
| 189 | + | |
---|
| 190 | + | @Callable(s) |
---|
| 191 | + | func rebalance () = L(p()) |
---|
| 192 | + | |
---|
| 193 | + | |
---|