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:AAIFAAAAAAAAAA0IAhIDCgEIEgASABIAAAAAEAAAAAAJcHJlY2lzaW9uAA3gtrOnZAAAAQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAkABCIAAAABAgAAABBtYW5hZ2VyUHVibGljS2V5AQAAABZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAAAAAQAAAAHJG1hdGNoMAkBAAAAE2tleU1hbmFnZXJQdWJsaWNLZXkAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAXMFAAAAByRtYXRjaDAJAAJZAAAAAQUAAAABcwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAEVW5pdAUAAAAEdW5pdAkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgEAAAALbXVzdE1hbmFnZXIAAAABAAAAAWkEAAAAAnBkCQAAAgAAAAECAAAAEXBlcm1pc3Npb24gZGVuaWVkBAAAAAckbWF0Y2gwCQEAAAAWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAAAAADCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGV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XYXZlcwAAAAEIBQAAAAdwYXltZW50AAAABmFtb3VudAkBAAAACXNlbmRXYXZlcwAAAAIIBQAAAAFpAAAABmNhbGxlcgUAAAAOdHJhbnNmZXJBbW91bnQJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAWkBAAAACGNvbXBvdW5kAAAAAAQAAAAFcmF0aW8JAQAAAA5jYWxjdWxhdGVSYXRpbwAAAAAJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAICAAAABXJhdGlvBQAAAAVyYXRpbwUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXm9av7l", "height": 2305451, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B1yz65pFKbqHwmNfrbj39XzMnYxXQ1hbjyKyuQACSks3 Next: BxV7wh1pPFKDP66uooy1C7ueFvgTqHBP8zEWn6Z6isHR Diff:
OldNewDifferences
6868 func n (o) = IntegerEntry("leasedAmount", o)
6969
7070
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)
7981 [u, BinaryEntry("leaseId", v)]
80- }
81- else nil
82- ((l() ++ t) :+ n(s))
83- }
82+ }
83+ else nil
84+ ((l() ++ t) :+ n(s))
85+ }
8486
8587
8688 func w (o) = {
131133 }
132134
133135
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.")
138142 }
139-
140143
141144
142145 @Callable(g)
143146 func init (q) = {
144- let M = [f(g), j()]
145- if ((M == M))
147+ let O = [f(g), j()]
148+ if ((O == O))
146149 then {
147- let N = Issue("sWaves", "", 0, 8, true, unit, 0)
148- let x = calculateAssetId(N)
149-[BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(x)), StringEntry("leaserAddress", q), IntegerEntry("ratio", a), IntegerEntry("leasedAmount", 0), N]
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]
150153 }
151154 else throw("Strict value is not equal to itself.")
152155 }
155158
156159 @Callable(g)
157160 func stake () = {
158- let O = g.payments[0]
159- if ((O.assetId != unit))
161+ let Q = g.payments[0]
162+ if ((Q.assetId != unit))
160163 then throw("Only WAVES supported")
161164 else if ((size(g.payments) != 1))
162165 then throw("Wrong payments amount")
163166 else {
164- let L = getIntegerValue("ratio")
165- let P = fraction(O.amount, a, L)
166- ((p(O.amount) :+ w(P)) :+ z(g.caller, P))
167+ let R = getIntegerValue("ratio")
168+ let S = fraction(Q.amount, a, R)
169+ ((p(Q.amount) :+ w(S)) :+ z(g.caller, S))
167170 }
168171 }
169172
170173
171174
172175 @Callable(g)
173-func withdraw () = {
174- let O = g.payments[0]
176+func unstake () = {
177+ let Q = g.payments[0]
175178 let x = fromBase58String(getStringValue("sWavesAssetId"))
176- if ((O.assetId != x))
179+ if ((Q.assetId != x))
177180 then throw("Only sWAVES supported")
178181 else if ((size(g.payments) != 1))
179182 then throw("Wrong payments amount")
180183 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.")
184197 }
185198 }
186199
187200
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)
190211
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let a = 1000000000000000000
55
66 func b () = getString("managerPublicKey")
77
88
99 func c () = {
1010 let d = b()
1111 if ($isInstanceOf(d, "String"))
1212 then {
1313 let e = d
1414 fromBase58String(e)
1515 }
1616 else if ($isInstanceOf(d, "Unit"))
1717 then unit
1818 else throw("Match error")
1919 }
2020
2121
2222 func f (g) = {
2323 let h = throw("permission denied")
2424 let d = c()
2525 if ($isInstanceOf(d, "ByteVector"))
2626 then {
2727 let i = d
2828 if ((g.callerPublicKey == i))
2929 then true
3030 else h
3131 }
3232 else if ($isInstanceOf(d, "Unit"))
3333 then if ((g.caller == this))
3434 then true
3535 else h
3636 else throw("Match error")
3737 }
3838
3939
4040 func j () = {
4141 let d = getBoolean("inited")
4242 if ($isInstanceOf(d, "Boolean"))
4343 then {
4444 let k = d
4545 if ((k == false))
4646 then true
4747 else throw("Already inited")
4848 }
4949 else if ($isInstanceOf(d, "Unit"))
5050 then false
5151 else throw("Match error")
5252 }
5353
5454
5555 func l () = {
5656 let d = getBinary("leaseId")
5757 if ($isInstanceOf(d, "ByteVector"))
5858 then {
5959 let m = d
6060 [LeaseCancel(m), DeleteEntry("leaseId")]
6161 }
6262 else if ($isInstanceOf(d, "Unit"))
6363 then nil
6464 else throw("Match error")
6565 }
6666
6767
6868 func n (o) = IntegerEntry("leasedAmount", o)
6969
7070
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)
7981 [u, BinaryEntry("leaseId", v)]
80- }
81- else nil
82- ((l() ++ t) :+ n(s))
83- }
82+ }
83+ else nil
84+ ((l() ++ t) :+ n(s))
85+ }
8486
8587
8688 func w (o) = {
8789 let x = fromBase58String(getStringValue("sWavesAssetId"))
8890 Reissue(x, o, true)
8991 }
9092
9193
9294 func y (o) = {
9395 let x = fromBase58String(getStringValue("sWavesAssetId"))
9496 Burn(x, o)
9597 }
9698
9799
98100 func z (A,o) = {
99101 let x = fromBase58String(getStringValue("sWavesAssetId"))
100102 ScriptTransfer(A, o, x)
101103 }
102104
103105
104106 func B (A,o) = ScriptTransfer(A, o, unit)
105107
106108
107109 func C () = {
108110 let D = fromBase58String(getStringValue("sWavesAssetId"))
109111 let d = assetInfo(D)
110112 if ($isInstanceOf(d, "Asset"))
111113 then {
112114 let E = d
113115 E.quantity
114116 }
115117 else throw("Can't find asset")
116118 }
117119
118120
119121 func F () = {
120122 let q = Address(fromBase58String(getStringValue("leaserAddress")))
121123 wavesBalance(q).regular
122124 }
123125
124126
125127 func G () = {
126128 let H = getIntegerValue("leasedAmount")
127129 let I = C()
128130 let J = F()
129131 let K = (H + J)
130132 fraction(K, a, I)
131133 }
132134
133135
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.")
138142 }
139-
140143
141144
142145 @Callable(g)
143146 func init (q) = {
144- let M = [f(g), j()]
145- if ((M == M))
147+ let O = [f(g), j()]
148+ if ((O == O))
146149 then {
147- let N = Issue("sWaves", "", 0, 8, true, unit, 0)
148- let x = calculateAssetId(N)
149-[BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(x)), StringEntry("leaserAddress", q), IntegerEntry("ratio", a), IntegerEntry("leasedAmount", 0), N]
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]
150153 }
151154 else throw("Strict value is not equal to itself.")
152155 }
153156
154157
155158
156159 @Callable(g)
157160 func stake () = {
158- let O = g.payments[0]
159- if ((O.assetId != unit))
161+ let Q = g.payments[0]
162+ if ((Q.assetId != unit))
160163 then throw("Only WAVES supported")
161164 else if ((size(g.payments) != 1))
162165 then throw("Wrong payments amount")
163166 else {
164- let L = getIntegerValue("ratio")
165- let P = fraction(O.amount, a, L)
166- ((p(O.amount) :+ w(P)) :+ z(g.caller, P))
167+ let R = getIntegerValue("ratio")
168+ let S = fraction(Q.amount, a, R)
169+ ((p(Q.amount) :+ w(S)) :+ z(g.caller, S))
167170 }
168171 }
169172
170173
171174
172175 @Callable(g)
173-func withdraw () = {
174- let O = g.payments[0]
176+func unstake () = {
177+ let Q = g.payments[0]
175178 let x = fromBase58String(getStringValue("sWavesAssetId"))
176- if ((O.assetId != x))
179+ if ((Q.assetId != x))
177180 then throw("Only sWAVES supported")
178181 else if ((size(g.payments) != 1))
179182 then throw("Wrong payments amount")
180183 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.")
184197 }
185198 }
186199
187200
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)
190211

github/deemru/w8io/026f985 
42.31 ms