tx · 4Eouaqckyijs7VAZU4N7WupKPZvva2o4DNDD9DfLPkj2 3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy: -0.01000000 Waves 2022.11.06 18:36 [2305451] smart account 3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy > SELF 0.00000000 Waves
{ "type": 13, "id": "4Eouaqckyijs7VAZU4N7WupKPZvva2o4DNDD9DfLPkj2", "fee": 1000000, "feeAssetId": null, "timestamp": 1667749056407, "version": 2, "chainId": 84, "sender": "3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy", "senderPublicKey": "65hdh3BQVcB4NhB1URp1RBWMK7AWDhrCSVjwbFjS64jo", "proofs": [ "K7AMWy5X1S4mb5cLhoFDx5FFyPzntrT7a2k3hEsJ11YB81Xuj7oNuDwwuho1nKuveAvzmVJaXj5qgNDHD2tCewL" ], "script": "base64:AAIFAAAAAAAAAA0IAhIDCgEIEgASABIAAAAAEAAAAAAJcHJlY2lzaW9uAA3gtrOnZAAAAQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAkABCIAAAABAgAAABBtYW5hZ2VyUHVibGljS2V5AQAAABZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAAAAAQAAAAHJG1hdGNoMAkBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAXMFAAAAByRtYXRjaDAJAAJZAAAAAQUAAAABcwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAEVW5pdAUAAAAEdW5pdAkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgEAAAALbXVzdE1hbmFnZXIAAAABAAAAAWkEAAAAAnBkCQAAAgAAAAECAAAAEXBlcm1pc3Npb24gZGVuaWVkBAAAAAckbWF0Y2gwCQEAAAAWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAAAAADCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGVW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YXZlcwAAAAEIBQAAAAdwYXltZW50AAAABmFtb3VudAkBAAAACXNlbmRXYXZlcwAAAAIIBQAAAAFpAAAABmNhbGxlcgUAAAAOdHJhbnNmZXJBbW91bnQJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAWkBAAAACGNvbXBvdW5kAAAAAAQAAAAFcmF0aW8JAQAAAA5jYWxjdWxhdGVSYXRpbwAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAABXJhdGlvBQAAAAVyYXRpbwUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXm9av7l", "height": 2305451, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B1yz65pFKbqHwmNfrbj39XzMnYxXQ1hbjyKyuQACSks3 Next: BxV7wh1pPFKDP66uooy1C7ueFvgTqHBP8zEWn6Z6isHR Diff:
Old | New | Differences | |
---|---|---|---|
68 | 68 | func n (o) = IntegerEntry("leasedAmount", o) | |
69 | 69 | ||
70 | 70 | ||
71 | - | func p (o) = { | |
72 | - | let q = Address(fromBase58String(getStringValue("leaserAddress"))) | |
73 | - | let r = getIntegerValue("leasedAmount") | |
74 | - | let s = (r + o) | |
75 | - | let t = if ((s > 0)) | |
76 | - | then { | |
77 | - | let u = Lease(q, s) | |
78 | - | let v = calculateLeaseId(u) | |
71 | + | func p (o) = if ((o == 0)) | |
72 | + | then nil | |
73 | + | else { | |
74 | + | let q = Address(fromBase58String(getStringValue("leaserAddress"))) | |
75 | + | let r = getIntegerValue("leasedAmount") | |
76 | + | let s = (r + o) | |
77 | + | let t = if ((s > 0)) | |
78 | + | then { | |
79 | + | let u = Lease(q, s) | |
80 | + | let v = calculateLeaseId(u) | |
79 | 81 | [u, BinaryEntry("leaseId", v)] | |
80 | - | } | |
81 | - | else nil | |
82 | - | ((l() ++ t) :+ n(s)) | |
83 | - | } | |
82 | + | } | |
83 | + | else nil | |
84 | + | ((l() ++ t) :+ n(s)) | |
85 | + | } | |
84 | 86 | ||
85 | 87 | ||
86 | 88 | func w (o) = { | |
131 | 133 | } | |
132 | 134 | ||
133 | 135 | ||
134 | - | @Callable(g) | |
135 | - | func compound () = { | |
136 | - | let L = G() | |
137 | - | [IntegerEntry("ratio", L)] | |
136 | + | func L (o) = { | |
137 | + | let M = Address(fromBase58String(getStringValue("leaserAddress"))) | |
138 | + | let N = invoke(M, "withdraw", [o], nil) | |
139 | + | if ((N == N)) | |
140 | + | then N | |
141 | + | else throw("Strict value is not equal to itself.") | |
138 | 142 | } | |
139 | - | ||
140 | 143 | ||
141 | 144 | ||
142 | 145 | @Callable(g) | |
143 | 146 | func init (q) = { | |
144 | - | let | |
145 | - | if (( | |
147 | + | let O = [f(g), j()] | |
148 | + | if ((O == O)) | |
146 | 149 | then { | |
147 | - | let | |
148 | - | let x = calculateAssetId( | |
149 | - | [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(x)), StringEntry("leaserAddress", q), IntegerEntry("ratio", a), IntegerEntry("leasedAmount", 0), | |
150 | + | let P = Issue("sWaves", "", 0, 8, true, unit, 0) | |
151 | + | let x = calculateAssetId(P) | |
152 | + | [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(x)), StringEntry("leaserAddress", q), IntegerEntry("ratio", a), IntegerEntry("leasedAmount", 0), P] | |
150 | 153 | } | |
151 | 154 | else throw("Strict value is not equal to itself.") | |
152 | 155 | } | |
155 | 158 | ||
156 | 159 | @Callable(g) | |
157 | 160 | func stake () = { | |
158 | - | let | |
159 | - | if (( | |
161 | + | let Q = g.payments[0] | |
162 | + | if ((Q.assetId != unit)) | |
160 | 163 | then throw("Only WAVES supported") | |
161 | 164 | else if ((size(g.payments) != 1)) | |
162 | 165 | then throw("Wrong payments amount") | |
163 | 166 | else { | |
164 | - | let | |
165 | - | let | |
166 | - | ((p( | |
167 | + | let R = getIntegerValue("ratio") | |
168 | + | let S = fraction(Q.amount, a, R) | |
169 | + | ((p(Q.amount) :+ w(S)) :+ z(g.caller, S)) | |
167 | 170 | } | |
168 | 171 | } | |
169 | 172 | ||
170 | 173 | ||
171 | 174 | ||
172 | 175 | @Callable(g) | |
173 | - | func | |
174 | - | let | |
176 | + | func unstake () = { | |
177 | + | let Q = g.payments[0] | |
175 | 178 | let x = fromBase58String(getStringValue("sWavesAssetId")) | |
176 | - | if (( | |
179 | + | if ((Q.assetId != x)) | |
177 | 180 | then throw("Only sWAVES supported") | |
178 | 181 | else if ((size(g.payments) != 1)) | |
179 | 182 | then throw("Wrong payments amount") | |
180 | 183 | else { | |
181 | - | let L = getIntegerValue("ratio") | |
182 | - | let Q = fraction(O.amount, L, a) | |
183 | - | ((p(-(Q)) :+ y(O.amount)) :+ B(g.caller, Q)) | |
184 | + | let R = getIntegerValue("ratio") | |
185 | + | let T = fraction(Q.amount, R, a) | |
186 | + | let J = F() | |
187 | + | let U = if ((T > J)) | |
188 | + | then (T - J) | |
189 | + | else 0 | |
190 | + | let V = if ((T > J)) | |
191 | + | then J | |
192 | + | else (J - T) | |
193 | + | let W = L(V) | |
194 | + | if ((W == W)) | |
195 | + | then ((p(-(U)) :+ y(Q.amount)) :+ B(g.caller, T)) | |
196 | + | else throw("Strict value is not equal to itself.") | |
184 | 197 | } | |
185 | 198 | } | |
186 | 199 | ||
187 | 200 | ||
188 | - | @Verifier(R) | |
189 | - | func S () = sigVerify(R.bodyBytes, R.proofs[0], R.senderPublicKey) | |
201 | + | ||
202 | + | @Callable(g) | |
203 | + | func compound () = { | |
204 | + | let R = G() | |
205 | + | [IntegerEntry("ratio", R)] | |
206 | + | } | |
207 | + | ||
208 | + | ||
209 | + | @Verifier(X) | |
210 | + | func Y () = sigVerify(X.bodyBytes, X.proofs[0], X.senderPublicKey) | |
190 | 211 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = 1000000000000000000 | |
5 | 5 | ||
6 | 6 | func b () = getString("managerPublicKey") | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | func c () = { | |
10 | 10 | let d = b() | |
11 | 11 | if ($isInstanceOf(d, "String")) | |
12 | 12 | then { | |
13 | 13 | let e = d | |
14 | 14 | fromBase58String(e) | |
15 | 15 | } | |
16 | 16 | else if ($isInstanceOf(d, "Unit")) | |
17 | 17 | then unit | |
18 | 18 | else throw("Match error") | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func f (g) = { | |
23 | 23 | let h = throw("permission denied") | |
24 | 24 | let d = c() | |
25 | 25 | if ($isInstanceOf(d, "ByteVector")) | |
26 | 26 | then { | |
27 | 27 | let i = d | |
28 | 28 | if ((g.callerPublicKey == i)) | |
29 | 29 | then true | |
30 | 30 | else h | |
31 | 31 | } | |
32 | 32 | else if ($isInstanceOf(d, "Unit")) | |
33 | 33 | then if ((g.caller == this)) | |
34 | 34 | then true | |
35 | 35 | else h | |
36 | 36 | else throw("Match error") | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func j () = { | |
41 | 41 | let d = getBoolean("inited") | |
42 | 42 | if ($isInstanceOf(d, "Boolean")) | |
43 | 43 | then { | |
44 | 44 | let k = d | |
45 | 45 | if ((k == false)) | |
46 | 46 | then true | |
47 | 47 | else throw("Already inited") | |
48 | 48 | } | |
49 | 49 | else if ($isInstanceOf(d, "Unit")) | |
50 | 50 | then false | |
51 | 51 | else throw("Match error") | |
52 | 52 | } | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func l () = { | |
56 | 56 | let d = getBinary("leaseId") | |
57 | 57 | if ($isInstanceOf(d, "ByteVector")) | |
58 | 58 | then { | |
59 | 59 | let m = d | |
60 | 60 | [LeaseCancel(m), DeleteEntry("leaseId")] | |
61 | 61 | } | |
62 | 62 | else if ($isInstanceOf(d, "Unit")) | |
63 | 63 | then nil | |
64 | 64 | else throw("Match error") | |
65 | 65 | } | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | func n (o) = IntegerEntry("leasedAmount", o) | |
69 | 69 | ||
70 | 70 | ||
71 | - | func p (o) = { | |
72 | - | let q = Address(fromBase58String(getStringValue("leaserAddress"))) | |
73 | - | let r = getIntegerValue("leasedAmount") | |
74 | - | let s = (r + o) | |
75 | - | let t = if ((s > 0)) | |
76 | - | then { | |
77 | - | let u = Lease(q, s) | |
78 | - | let v = calculateLeaseId(u) | |
71 | + | func p (o) = if ((o == 0)) | |
72 | + | then nil | |
73 | + | else { | |
74 | + | let q = Address(fromBase58String(getStringValue("leaserAddress"))) | |
75 | + | let r = getIntegerValue("leasedAmount") | |
76 | + | let s = (r + o) | |
77 | + | let t = if ((s > 0)) | |
78 | + | then { | |
79 | + | let u = Lease(q, s) | |
80 | + | let v = calculateLeaseId(u) | |
79 | 81 | [u, BinaryEntry("leaseId", v)] | |
80 | - | } | |
81 | - | else nil | |
82 | - | ((l() ++ t) :+ n(s)) | |
83 | - | } | |
82 | + | } | |
83 | + | else nil | |
84 | + | ((l() ++ t) :+ n(s)) | |
85 | + | } | |
84 | 86 | ||
85 | 87 | ||
86 | 88 | func w (o) = { | |
87 | 89 | let x = fromBase58String(getStringValue("sWavesAssetId")) | |
88 | 90 | Reissue(x, o, true) | |
89 | 91 | } | |
90 | 92 | ||
91 | 93 | ||
92 | 94 | func y (o) = { | |
93 | 95 | let x = fromBase58String(getStringValue("sWavesAssetId")) | |
94 | 96 | Burn(x, o) | |
95 | 97 | } | |
96 | 98 | ||
97 | 99 | ||
98 | 100 | func z (A,o) = { | |
99 | 101 | let x = fromBase58String(getStringValue("sWavesAssetId")) | |
100 | 102 | ScriptTransfer(A, o, x) | |
101 | 103 | } | |
102 | 104 | ||
103 | 105 | ||
104 | 106 | func B (A,o) = ScriptTransfer(A, o, unit) | |
105 | 107 | ||
106 | 108 | ||
107 | 109 | func C () = { | |
108 | 110 | let D = fromBase58String(getStringValue("sWavesAssetId")) | |
109 | 111 | let d = assetInfo(D) | |
110 | 112 | if ($isInstanceOf(d, "Asset")) | |
111 | 113 | then { | |
112 | 114 | let E = d | |
113 | 115 | E.quantity | |
114 | 116 | } | |
115 | 117 | else throw("Can't find asset") | |
116 | 118 | } | |
117 | 119 | ||
118 | 120 | ||
119 | 121 | func F () = { | |
120 | 122 | let q = Address(fromBase58String(getStringValue("leaserAddress"))) | |
121 | 123 | wavesBalance(q).regular | |
122 | 124 | } | |
123 | 125 | ||
124 | 126 | ||
125 | 127 | func G () = { | |
126 | 128 | let H = getIntegerValue("leasedAmount") | |
127 | 129 | let I = C() | |
128 | 130 | let J = F() | |
129 | 131 | let K = (H + J) | |
130 | 132 | fraction(K, a, I) | |
131 | 133 | } | |
132 | 134 | ||
133 | 135 | ||
134 | - | @Callable(g) | |
135 | - | func compound () = { | |
136 | - | let L = G() | |
137 | - | [IntegerEntry("ratio", L)] | |
136 | + | func L (o) = { | |
137 | + | let M = Address(fromBase58String(getStringValue("leaserAddress"))) | |
138 | + | let N = invoke(M, "withdraw", [o], nil) | |
139 | + | if ((N == N)) | |
140 | + | then N | |
141 | + | else throw("Strict value is not equal to itself.") | |
138 | 142 | } | |
139 | - | ||
140 | 143 | ||
141 | 144 | ||
142 | 145 | @Callable(g) | |
143 | 146 | func init (q) = { | |
144 | - | let | |
145 | - | if (( | |
147 | + | let O = [f(g), j()] | |
148 | + | if ((O == O)) | |
146 | 149 | then { | |
147 | - | let | |
148 | - | let x = calculateAssetId( | |
149 | - | [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(x)), StringEntry("leaserAddress", q), IntegerEntry("ratio", a), IntegerEntry("leasedAmount", 0), | |
150 | + | let P = Issue("sWaves", "", 0, 8, true, unit, 0) | |
151 | + | let x = calculateAssetId(P) | |
152 | + | [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(x)), StringEntry("leaserAddress", q), IntegerEntry("ratio", a), IntegerEntry("leasedAmount", 0), P] | |
150 | 153 | } | |
151 | 154 | else throw("Strict value is not equal to itself.") | |
152 | 155 | } | |
153 | 156 | ||
154 | 157 | ||
155 | 158 | ||
156 | 159 | @Callable(g) | |
157 | 160 | func stake () = { | |
158 | - | let | |
159 | - | if (( | |
161 | + | let Q = g.payments[0] | |
162 | + | if ((Q.assetId != unit)) | |
160 | 163 | then throw("Only WAVES supported") | |
161 | 164 | else if ((size(g.payments) != 1)) | |
162 | 165 | then throw("Wrong payments amount") | |
163 | 166 | else { | |
164 | - | let | |
165 | - | let | |
166 | - | ((p( | |
167 | + | let R = getIntegerValue("ratio") | |
168 | + | let S = fraction(Q.amount, a, R) | |
169 | + | ((p(Q.amount) :+ w(S)) :+ z(g.caller, S)) | |
167 | 170 | } | |
168 | 171 | } | |
169 | 172 | ||
170 | 173 | ||
171 | 174 | ||
172 | 175 | @Callable(g) | |
173 | - | func | |
174 | - | let | |
176 | + | func unstake () = { | |
177 | + | let Q = g.payments[0] | |
175 | 178 | let x = fromBase58String(getStringValue("sWavesAssetId")) | |
176 | - | if (( | |
179 | + | if ((Q.assetId != x)) | |
177 | 180 | then throw("Only sWAVES supported") | |
178 | 181 | else if ((size(g.payments) != 1)) | |
179 | 182 | then throw("Wrong payments amount") | |
180 | 183 | else { | |
181 | - | let L = getIntegerValue("ratio") | |
182 | - | let Q = fraction(O.amount, L, a) | |
183 | - | ((p(-(Q)) :+ y(O.amount)) :+ B(g.caller, Q)) | |
184 | + | let R = getIntegerValue("ratio") | |
185 | + | let T = fraction(Q.amount, R, a) | |
186 | + | let J = F() | |
187 | + | let U = if ((T > J)) | |
188 | + | then (T - J) | |
189 | + | else 0 | |
190 | + | let V = if ((T > J)) | |
191 | + | then J | |
192 | + | else (J - T) | |
193 | + | let W = L(V) | |
194 | + | if ((W == W)) | |
195 | + | then ((p(-(U)) :+ y(Q.amount)) :+ B(g.caller, T)) | |
196 | + | else throw("Strict value is not equal to itself.") | |
184 | 197 | } | |
185 | 198 | } | |
186 | 199 | ||
187 | 200 | ||
188 | - | @Verifier(R) | |
189 | - | func S () = sigVerify(R.bodyBytes, R.proofs[0], R.senderPublicKey) | |
201 | + | ||
202 | + | @Callable(g) | |
203 | + | func compound () = { | |
204 | + | let R = G() | |
205 | + | [IntegerEntry("ratio", R)] | |
206 | + | } | |
207 | + | ||
208 | + | ||
209 | + | @Verifier(X) | |
210 | + | func Y () = sigVerify(X.bodyBytes, X.proofs[0], X.senderPublicKey) | |
190 | 211 |
github/deemru/w8io/026f985 42.31 ms ◑