tx · Hdr2qht6YgFPXdN3fvAwRQhRZQq7LZRt5cDfuzKK2ehC

3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq:  -0.01100000 Waves

2024.07.15 10:18 [3194838] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves

{ "type": 13, "id": "Hdr2qht6YgFPXdN3fvAwRQhRZQq7LZRt5cDfuzKK2ehC", "fee": 1100000, "feeAssetId": null, "timestamp": 1721027930313, "version": 1, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "4sYSRTsUsfARdBz2APngBpKiCf6tEDupdH36c6eH91hhRo5iEmWL9tkw3QiPfadVHvLcEABHyd8XFPCpE4jB9xqJ" ], "script": "base64:BgIQCAISBQoDAQgIEgUKAwEICBkAA1NFUAICX18ACGZlZVNjYWxlCQC2AgEAgMLXLwEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEWa2V5TWFuYWdlclZhdWx0QWRkcmVzcwACFyVzX19tYW5hZ2VyVmF1bHRBZGRyZXNzAQJmYwACEyVzX19mYWN0b3J5Q29udHJhY3QAD2ZhY3RvcnlDb250cmFjdAkBEUBleHRyTmF0aXZlKDEwNjIpAQkBD2dldFN0cmluZ09yRmFpbAEJAQJmYwABC3Byb3RvY29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ibGljS2V5lOXcVg==", "chainId": 84, "height": 3194838, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: EtVYfFaBUbs2evGPSU4RvB9nEUHYpAzej2tNzNm6ijmM Next: 4mAEE6mkGF31F2dz8awaZhAakdKKC1Xv3dWeoB8AAyR3 Diff:
OldNewDifferences
188188 let aj = if ((toInt(ah) == 0))
189189 then toBigInt(1)
190190 else ah
191- let ak = ((toBigInt(ab) - ai) - aj)
191+ let ak = if ((X == true))
192+ then ((toBigInt(ab) - ai) - aj)
193+ else (toBigInt(ab) - aj)
192194 let al = {
193195 let T = invoke(aa, "calculateAmountOutForSwapREADONLY", [toInt(ak), X, toInt(aj)], nil)
194196 if ($isInstanceOf(T, "Int"))
195197 then T
196198 else throw(($getType(T) + " couldn't be cast to Int"))
197199 }
198- $Tuple2(nil, al)
200+ let am = if ((X == true))
201+ then al
202+ else {
203+ let an = fraction(toBigInt(al), toBigInt(af), b)
204+ let ao = if ((toInt(an) == 0))
205+ then toInt(toBigInt(1))
206+ else toInt(an)
207+ (al - ao)
208+ }
209+ $Tuple2(nil, am)
199210 }
200211
201212
202213
203214 @Callable(D)
204-func swap (am,an,ao) = {
205- let R = if ((an == ""))
206- then "WAVES"
207- else an
208- let ap = value(D.payments[0])
209- let Q = if ((ap.assetId == unit))
210- then "WAVES"
211- else toBase58String(value(ap.assetId))
212- let ab = value(ap.amount)
213- let aq = P(Q, R)
214- let aa = aq._1
215- let X = aq._2
216- let ar = K(toString(aa))
217- let ae = ar._1
218- let af = ar._2
219- let ag = fraction(toBigInt(ab), toBigInt(af), b)
220- let ah = fraction(toBigInt(ab), toBigInt(ae), b)
221- let as = addressFromStringValue(ao)
222- let ai = if ((toInt(ag) == 0))
223- then toBigInt(1)
224- else ag
225- let aj = if ((toInt(ah) == 0))
226- then toBigInt(1)
227- else ah
228- let ak = if ((X == true))
229- then ((toBigInt(ab) - ai) - aj)
230- else (toBigInt(ab) - aj)
231- let at = [if ((size(D.payments) == 1))
215+func swap (ap,aq,ar) = {
216+ let as = [if ((size(D.payments) == 1))
232217 then true
233218 else throw("exactly 1 payment are expected")]
234- if ((at == at))
219+ if ((as == as))
235220 then {
236- let au = I(Q)
237- let av = {
238- let T = invoke(aa, "calculateAmountOutForSwapAndSendTokens", [toInt(ak), X, am, toString(this), toInt(aj)], [AttachedPayment(au, toInt(ak))])
221+ let R = if ((aq == ""))
222+ then "WAVES"
223+ else aq
224+ let at = value(D.payments[0])
225+ let Q = if ((at.assetId == unit))
226+ then "WAVES"
227+ else toBase58String(value(at.assetId))
228+ let ab = value(at.amount)
229+ let au = P(Q, R)
230+ let aa = au._1
231+ let X = au._2
232+ let av = K(toString(aa))
233+ let ae = av._1
234+ let af = av._2
235+ let ag = fraction(toBigInt(ab), toBigInt(af), b)
236+ let ah = fraction(toBigInt(ab), toBigInt(ae), b)
237+ let aw = addressFromStringValue(ar)
238+ let ai = if ((toInt(ag) == 0))
239+ then toBigInt(1)
240+ else ag
241+ let aj = if ((toInt(ah) == 0))
242+ then toBigInt(1)
243+ else ah
244+ let ak = if ((X == true))
245+ then ((toBigInt(ab) - ai) - aj)
246+ else (toBigInt(ab) - aj)
247+ let ax = I(Q)
248+ let al = {
249+ let T = invoke(aa, "calculateAmountOutForSwapAndSendTokens", [toInt(ak), X, ap, toString(this), toInt(aj)], [AttachedPayment(ax, toInt(ak))])
239250 if ($isInstanceOf(T, "Int"))
240251 then T
241252 else throw(($getType(T) + " couldn't be cast to Int"))
242253 }
243- let aw = if ((X == true))
244- then $Tuple2([ScriptTransfer(q, toInt(ai), au)], av)
254+ let ay = if ((X == true))
255+ then $Tuple2([ScriptTransfer(q, toInt(ai), ax)], al)
245256 else {
246- let ax = fraction(toBigInt(av), toBigInt(af), b)
247- let ay = if ((toInt(ax) == 0))
257+ let an = fraction(toBigInt(al), toBigInt(af), b)
258+ let ao = if ((toInt(an) == 0))
248259 then toInt(toBigInt(1))
249- else toInt(ax)
250- $Tuple2([ScriptTransfer(q, ay, I(R))], (av - ay))
260+ else toInt(an)
261+ $Tuple2([ScriptTransfer(q, ao, I(R))], (al - ao))
251262 }
252- let az = aw._1
253- let aA = aw._2
254- $Tuple2((az ++ [ScriptTransfer(aa, toInt(aj), au), ScriptTransfer(as, aA, I(R))]), aA)
263+ let az = ay._1
264+ let am = ay._2
265+ $Tuple2((az ++ [ScriptTransfer(aa, toInt(aj), ax), ScriptTransfer(aw, am, I(R))]), am)
255266 }
256267 else throw("Strict value is not equal to itself.")
257268 }
258269
259270
260-@Verifier(aB)
261-func aC () = {
262- let aD = {
271+@Verifier(aA)
272+func aB () = {
273+ let aC = {
263274 let s = A()
264275 if ($isInstanceOf(s, "ByteVector"))
265276 then {
267278 E
268279 }
269280 else if ($isInstanceOf(s, "Unit"))
270- then aB.senderPublicKey
281+ then aA.senderPublicKey
271282 else throw("Match error")
272283 }
273- sigVerify(aB.bodyBytes, aB.proofs[0], aD)
284+ sigVerify(aA.bodyBytes, aA.proofs[0], aC)
274285 }
275286
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let a = "__"
55
66 let b = toBigInt(100000000)
77
88 func c (d) = valueOrErrorMessage(getString(this, d), ("No data for this.key=" + d))
99
1010
1111 let e = throw("Pool disabled")
1212
1313 let f = throw("Pool is not exist")
1414
1515 let g = throw("Slippage is too big")
1616
1717 func h () = "%s__managerPublicKey"
1818
1919
2020 func i () = "%s__managerVaultAddress"
2121
2222
2323 func j () = "%s__factoryContract"
2424
2525
2626 let k = addressFromStringValue(c(j()))
2727
2828 func l () = makeString(["%s", "protocolFee"], a)
2929
3030
3131 func m () = makeString(["%s", "poolFee"], a)
3232
3333
3434 func n (o,d) = valueOrErrorMessage(getString(o, d), makeString(["mandatory ", toString(o), ".", d, " is not defined"], ""))
3535
3636
3737 let p = "%s__feeCollectorAddress"
3838
3939 let q = addressFromStringValue(n(k, p))
4040
4141 func r () = {
4242 let s = getString(i())
4343 if ($isInstanceOf(s, "String"))
4444 then {
4545 let t = s
4646 addressFromStringValue(t)
4747 }
4848 else this
4949 }
5050
5151
5252 func u (v) = {
5353 let s = v
5454 if ($isInstanceOf(s, "Int"))
5555 then {
5656 let w = s
5757 w
5858 }
5959 else throw("fail to cast into Int")
6060 }
6161
6262
6363 func x (y,z) = makeString(["%d%d", toString(y), toString(z)], a)
6464
6565
6666 func A () = {
6767 let B = r()
6868 let s = getString(B, h())
6969 if ($isInstanceOf(s, "String"))
7070 then {
7171 let t = s
7272 fromBase58String(t)
7373 }
7474 else if ($isInstanceOf(s, "Unit"))
7575 then unit
7676 else throw("Match error")
7777 }
7878
7979
8080 func C (D) = {
8181 let s = A()
8282 if ($isInstanceOf(s, "ByteVector"))
8383 then {
8484 let E = s
8585 (D.callerPublicKey == E)
8686 }
8787 else if ($isInstanceOf(s, "Unit"))
8888 then (D.caller == this)
8989 else throw("Match error")
9090 }
9191
9292
9393 func F (D) = if (C(D))
9494 then true
9595 else throw("permission denied")
9696
9797
9898 func G (H) = if ((H == "WAVES"))
9999 then wavesBalance(this).available
100100 else assetBalance(this, fromBase58String(H))
101101
102102
103103 func I (J) = if ((J == "WAVES"))
104104 then unit
105105 else fromBase58String(J)
106106
107107
108108 func K (L) = {
109109 let M = value(getInteger(this, m()))
110110 let N = value(getInteger(this, l()))
111111 let s = invoke(k, "getSwapFeeREADONLY", [L], nil)
112112 if ($isInstanceOf(s, "(Int, Int)"))
113113 then {
114114 let O = s
115115 $Tuple2(O._1, O._2)
116116 }
117117 else $Tuple2(M, N)
118118 }
119119
120120
121121 func P (Q,R) = {
122122 let S = {
123123 let T = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [Q, R], nil)
124124 if ($isInstanceOf(T, "String"))
125125 then T
126126 else unit
127127 }
128128 let U = {
129129 let T = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [R, Q], nil)
130130 if ($isInstanceOf(T, "String"))
131131 then T
132132 else unit
133133 }
134134 let V = if ((S != unit))
135135 then {
136136 let W = {
137137 let T = invoke(k, "getPoolAddressFromLpAssetREADONLY", [value(S)], nil)
138138 if ($isInstanceOf(T, "String"))
139139 then T
140140 else throw(($getType(T) + " couldn't be cast to String"))
141141 }
142142 $Tuple2(false, W)
143143 }
144144 else if ((U != unit))
145145 then {
146146 let W = {
147147 let T = invoke(k, "getPoolAddressFromLpAssetREADONLY", [value(U)], nil)
148148 if ($isInstanceOf(T, "String"))
149149 then T
150150 else throw(($getType(T) + " couldn't be cast to String"))
151151 }
152152 $Tuple2(true, W)
153153 }
154154 else f
155155 let X = V._1
156156 let W = V._2
157157 let Y = {
158158 let T = invoke(k, "getPoolStatusREADONLY", [W], nil)
159159 if ($isInstanceOf(T, "Int"))
160160 then T
161161 else throw(($getType(T) + " couldn't be cast to Int"))
162162 }
163163 let Z = if ((Y == 1))
164164 then true
165165 else e
166166 if ((Z == Z))
167167 then {
168168 let aa = addressFromStringValue(valueOrElse(W, ""))
169169 $Tuple2(aa, X)
170170 }
171171 else throw("Strict value is not equal to itself.")
172172 }
173173
174174
175175 @Callable(D)
176176 func swapCalculateREADONLY (ab,Q,R) = {
177177 let ac = P(Q, R)
178178 let aa = ac._1
179179 let X = ac._2
180180 let ad = K(toString(aa))
181181 let ae = ad._1
182182 let af = ad._2
183183 let ag = fraction(toBigInt(ab), toBigInt(af), b)
184184 let ah = fraction(toBigInt(ab), toBigInt(ae), b)
185185 let ai = if ((toInt(ag) == 0))
186186 then toBigInt(1)
187187 else ag
188188 let aj = if ((toInt(ah) == 0))
189189 then toBigInt(1)
190190 else ah
191- let ak = ((toBigInt(ab) - ai) - aj)
191+ let ak = if ((X == true))
192+ then ((toBigInt(ab) - ai) - aj)
193+ else (toBigInt(ab) - aj)
192194 let al = {
193195 let T = invoke(aa, "calculateAmountOutForSwapREADONLY", [toInt(ak), X, toInt(aj)], nil)
194196 if ($isInstanceOf(T, "Int"))
195197 then T
196198 else throw(($getType(T) + " couldn't be cast to Int"))
197199 }
198- $Tuple2(nil, al)
200+ let am = if ((X == true))
201+ then al
202+ else {
203+ let an = fraction(toBigInt(al), toBigInt(af), b)
204+ let ao = if ((toInt(an) == 0))
205+ then toInt(toBigInt(1))
206+ else toInt(an)
207+ (al - ao)
208+ }
209+ $Tuple2(nil, am)
199210 }
200211
201212
202213
203214 @Callable(D)
204-func swap (am,an,ao) = {
205- let R = if ((an == ""))
206- then "WAVES"
207- else an
208- let ap = value(D.payments[0])
209- let Q = if ((ap.assetId == unit))
210- then "WAVES"
211- else toBase58String(value(ap.assetId))
212- let ab = value(ap.amount)
213- let aq = P(Q, R)
214- let aa = aq._1
215- let X = aq._2
216- let ar = K(toString(aa))
217- let ae = ar._1
218- let af = ar._2
219- let ag = fraction(toBigInt(ab), toBigInt(af), b)
220- let ah = fraction(toBigInt(ab), toBigInt(ae), b)
221- let as = addressFromStringValue(ao)
222- let ai = if ((toInt(ag) == 0))
223- then toBigInt(1)
224- else ag
225- let aj = if ((toInt(ah) == 0))
226- then toBigInt(1)
227- else ah
228- let ak = if ((X == true))
229- then ((toBigInt(ab) - ai) - aj)
230- else (toBigInt(ab) - aj)
231- let at = [if ((size(D.payments) == 1))
215+func swap (ap,aq,ar) = {
216+ let as = [if ((size(D.payments) == 1))
232217 then true
233218 else throw("exactly 1 payment are expected")]
234- if ((at == at))
219+ if ((as == as))
235220 then {
236- let au = I(Q)
237- let av = {
238- let T = invoke(aa, "calculateAmountOutForSwapAndSendTokens", [toInt(ak), X, am, toString(this), toInt(aj)], [AttachedPayment(au, toInt(ak))])
221+ let R = if ((aq == ""))
222+ then "WAVES"
223+ else aq
224+ let at = value(D.payments[0])
225+ let Q = if ((at.assetId == unit))
226+ then "WAVES"
227+ else toBase58String(value(at.assetId))
228+ let ab = value(at.amount)
229+ let au = P(Q, R)
230+ let aa = au._1
231+ let X = au._2
232+ let av = K(toString(aa))
233+ let ae = av._1
234+ let af = av._2
235+ let ag = fraction(toBigInt(ab), toBigInt(af), b)
236+ let ah = fraction(toBigInt(ab), toBigInt(ae), b)
237+ let aw = addressFromStringValue(ar)
238+ let ai = if ((toInt(ag) == 0))
239+ then toBigInt(1)
240+ else ag
241+ let aj = if ((toInt(ah) == 0))
242+ then toBigInt(1)
243+ else ah
244+ let ak = if ((X == true))
245+ then ((toBigInt(ab) - ai) - aj)
246+ else (toBigInt(ab) - aj)
247+ let ax = I(Q)
248+ let al = {
249+ let T = invoke(aa, "calculateAmountOutForSwapAndSendTokens", [toInt(ak), X, ap, toString(this), toInt(aj)], [AttachedPayment(ax, toInt(ak))])
239250 if ($isInstanceOf(T, "Int"))
240251 then T
241252 else throw(($getType(T) + " couldn't be cast to Int"))
242253 }
243- let aw = if ((X == true))
244- then $Tuple2([ScriptTransfer(q, toInt(ai), au)], av)
254+ let ay = if ((X == true))
255+ then $Tuple2([ScriptTransfer(q, toInt(ai), ax)], al)
245256 else {
246- let ax = fraction(toBigInt(av), toBigInt(af), b)
247- let ay = if ((toInt(ax) == 0))
257+ let an = fraction(toBigInt(al), toBigInt(af), b)
258+ let ao = if ((toInt(an) == 0))
248259 then toInt(toBigInt(1))
249- else toInt(ax)
250- $Tuple2([ScriptTransfer(q, ay, I(R))], (av - ay))
260+ else toInt(an)
261+ $Tuple2([ScriptTransfer(q, ao, I(R))], (al - ao))
251262 }
252- let az = aw._1
253- let aA = aw._2
254- $Tuple2((az ++ [ScriptTransfer(aa, toInt(aj), au), ScriptTransfer(as, aA, I(R))]), aA)
263+ let az = ay._1
264+ let am = ay._2
265+ $Tuple2((az ++ [ScriptTransfer(aa, toInt(aj), ax), ScriptTransfer(aw, am, I(R))]), am)
255266 }
256267 else throw("Strict value is not equal to itself.")
257268 }
258269
259270
260-@Verifier(aB)
261-func aC () = {
262- let aD = {
271+@Verifier(aA)
272+func aB () = {
273+ let aC = {
263274 let s = A()
264275 if ($isInstanceOf(s, "ByteVector"))
265276 then {
266277 let E = s
267278 E
268279 }
269280 else if ($isInstanceOf(s, "Unit"))
270- then aB.senderPublicKey
281+ then aA.senderPublicKey
271282 else throw("Match error")
272283 }
273- sigVerify(aB.bodyBytes, aB.proofs[0], aD)
284+ sigVerify(aA.bodyBytes, aA.proofs[0], aC)
274285 }
275286

github/deemru/w8io/026f985 
39.20 ms