tx · 3XNuPqrLxCykM5YCU9L5mZmYiGrmPeEwC9g3UQwpDNG9

3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq:  -0.01300000 Waves

2023.01.26 14:16 [2421866] smart account 3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq > SELF 0.00000000 Waves

{ "type": 13, "id": "3XNuPqrLxCykM5YCU9L5mZmYiGrmPeEwC9g3UQwpDNG9", "fee": 1300000, "feeAssetId": null, "timestamp": 1674731782857, "version": 1, "sender": "3N6LHjfGb6Fgcy7YsVcNxGyPTj49XbQAijq", "senderPublicKey": "2u2wYYcVBQv43Cc71zkhHPPitkqgg6dqTZ3nUMvYJ1uq", "proofs": [ "AaUKfJfJ29FFiRGXHMWLBTTTM5hjijKp65RFD5fyzjNe789SSBnsuYSGHHhMjZLKnsqohXMzdC3yEWjYXc1UNzM" ], "script": "base64:BgIXCAISBQoDAQgIEgUKAwEICBIDCgEIEgAUAANTRVACAl9fAAhmZWVTY2FsZQkAtgIBAKCNBgEPZ2V0U3RyaW5nT3JGYWlsAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQR0aGlzBQNrZXkJAKwCAgIVTm8gZGF0YSBmb3IgdGhpcy5rZXk9BQNrZXkADHBvb2xEaXNhYmxlZAkAAgECDVBvb2wgZGlzYWJsZWQADHBvb2xOb3RFeGlzdAkAAgECEVBvb2wgaXMgbm90IGV4aXN0AA5zbGlwcGFnZVRvb0JpZwkAAgECE1NsaXBwYWdlIGlzIHRvbyBiaWcBE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuYWdlclB1YmxpY0tleQEaa2V5UGVuZGluZ01hbmFnZXJQdWJsaWNLZXkAAhslc19fcGVuZGluZ01hbmFnZXJQdWJsaWNLZXkBAmZjAAITJXNfX2ZhY3RvcnlDb250cmFjdAAPZmFjdG9yeUNvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBCQEPZ2V0U3RyaW5nT3JGYWl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prev: ZbukTgBHH3KsgfZPGV2kZBR3SKvD2zW5wgMHEbddpog Next: 4LDgK1DQT1SAcPwQ1cis7UAysoZz2dFoN5vPHTU98Nek Diff:
OldNewDifferences
2828 func l () = makeString(["%s", "feeLiquidityContractAddress"], a)
2929
3030
31-func m () = makeString(["%d", "feeLiquidity"], a)
31+func m () = makeString(["%s", "feeLiquidity"], a)
3232
3333
34-func n () = makeString(["%d", "protocolFee"], a)
34+func n () = makeString(["%s", "protocolFee"], a)
3535
3636
3737 func o (p) = {
9292 else throw("permission denied")
9393
9494
95+func C (D) = if ((D == "WAVES"))
96+ then wavesBalance(this).available
97+ else assetBalance(this, fromBase58String(D))
98+
99+
95100 @Callable(z)
96-func constructor (C,D,E,j) = {
97- let F = B(z)
98- if ((F == F))
99- then [StringEntry(l(), E), IntegerEntry(m(), D), IntegerEntry(n(), C), StringEntry(j(), j)]
101+func swapCalulateREADONLY (E,F,G) = {
102+ let H = value(getInteger(n()))
103+ let I = fraction(toBigInt(E), toBigInt(H), b)
104+ let J = fraction(toBigInt(E), toBigInt(H), b)
105+ let K = (toBigInt(E) - I)
106+ let L = (K - J)
107+ let M = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [F, G], nil)
108+ let N = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [G, F], nil)
109+ let O = if ((M != unit))
110+ then {
111+ let P = false
112+ let Q = {
113+ let R = invoke(k, "getPoolAddressFromLpAssetREADONLY", [M], nil)
114+ if ($isInstanceOf(R, "Address"))
115+ then R
116+ else throw(($getType(R) + " couldn't be cast to Address"))
117+ }
118+ $Tuple2(P, Q)
119+ }
120+ else if ((N != unit))
121+ then {
122+ let P = true
123+ let Q = invoke(k, "getPoolAddressFromLpAssetREADONLY", [N], nil)
124+ $Tuple2(P, Q)
125+ }
126+ else f
127+ let P = O._1
128+ let Q = O._2
129+ let S = {
130+ let R = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [Q], nil)
131+ if ($isInstanceOf(R, "Boolean"))
132+ then R
133+ else throw(($getType(R) + " couldn't be cast to Boolean"))
134+ }
135+ let T = if (S)
136+ then true
137+ else e
138+ if ((T == T))
139+ then {
140+ let U = addressFromStringValue(valueOrElse(Q, ""))
141+ let V = {
142+ let R = invoke(U, "calculateAmountOutForSwapREADONLY", [L, P], nil)
143+ if ($isInstanceOf(R, "Int"))
144+ then R
145+ else throw(($getType(R) + " couldn't be cast to Int"))
146+ }
147+ $Tuple2(nil, V)
148+ }
100149 else throw("Strict value is not equal to itself.")
101150 }
102151
103152
104153
105154 @Callable(z)
106-func swap (G,H,I) = {
107- let J = value(z.payments[0])
108- let K = value(J.assetId)
109- let L = value(J.amount)
110- let M = value(getInteger(n()))
111- let N = fraction(toBigInt(L), toBigInt(M), b)
112- let D = fraction(toBigInt(L), toBigInt(M), b)
113- let O = (toBigInt(L) - N)
114- let P = (O - D)
115- let Q = [if ((size(z.payments) == 1))
155+func swap (W,G,X) = {
156+ let Y = value(z.payments[0])
157+ let F = if ((Y.assetId == unit))
158+ then toBytes("WAVES")
159+ else value(Y.assetId)
160+ let E = value(Y.amount)
161+ let H = value(getInteger(n()))
162+ let I = fraction(toBigInt(E), toBigInt(H), b)
163+ let J = fraction(toBigInt(E), toBigInt(H), b)
164+ let K = (toBigInt(E) - I)
165+ let L = (K - J)
166+ let Z = [if ((size(z.payments) == 1))
116167 then true
117168 else throw("exactly 1 payment are expected")]
118- if ((Q == Q))
169+ if ((Z == Z))
119170 then {
120- let R = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [K, H], nil)
121- let S = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [H, K], nil)
122- let T = if ((R != unit))
171+ let M = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [F, G], nil)
172+ let N = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [G, F], nil)
173+ let aa = if ((M != unit))
123174 then {
124- let U = false
125- let V = invoke(k, "getPoolAddressFromLpAssetREADONLY", [R], nil)
126- $Tuple2(U, V)
175+ let P = false
176+ let Q = {
177+ let R = invoke(k, "getPoolAddressFromLpAssetREADONLY", [M], nil)
178+ if ($isInstanceOf(R, "Address"))
179+ then R
180+ else throw(($getType(R) + " couldn't be cast to Address"))
181+ }
182+ $Tuple2(P, Q)
127183 }
128- else if ((S != unit))
184+ else if ((N != unit))
129185 then {
130- let U = true
131- let V = invoke(k, "getPoolAddressFromLpAssetREADONLY", [S], nil)
132- $Tuple2(U, V)
186+ let P = true
187+ let Q = invoke(k, "getPoolAddressFromLpAssetREADONLY", [N], nil)
188+ $Tuple2(P, Q)
133189 }
134- else {
135- let U = true
136- let V = ""
137- $Tuple2(U, V)
190+ else f
191+ let P = aa._1
192+ let Q = aa._2
193+ let S = {
194+ let R = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [Q], nil)
195+ if ($isInstanceOf(R, "Boolean"))
196+ then R
197+ else throw(($getType(R) + " couldn't be cast to Boolean"))
198+ }
199+ let T = if (S)
200+ then true
201+ else e
202+ if ((T == T))
203+ then {
204+ let U = addressFromStringValue(valueOrElse(Q, ""))
205+ let V = {
206+ let R = invoke(U, "calculateAmountOutForSwapAndSendTokens", [L, P, W, X], [AttachedPayment(F, toInt(K))])
207+ if ($isInstanceOf(R, "Boolean"))
208+ then R
209+ else throw(($getType(R) + " couldn't be cast to Boolean"))
138210 }
139- let U = T._1
140- let V = T._2
141- let W = [if ((V != ""))
142- then true
143- else f]
144- if ((W == W))
145- then {
146- let X = {
147- let Y = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [V], nil)
148- if ($isInstanceOf(Y, "Boolean"))
149- then Y
150- else throw(($getType(Y) + " couldn't be cast to Boolean"))
151- }
152- let F = [if (X)
153- then true
154- else e]
155- if ((F == F))
156- then {
157- let Z = addressFromStringValue(valueOrElse(V, ""))
158- let aa = invoke(Z, "calculateAmountOutForSwapAndSendTokens", [P, U, G, I], [AttachedPayment(K, toInt(O))])
159- $Tuple2(nil, true)
160- }
161- else throw("Strict value is not equal to itself.")
211+ $Tuple2(nil, V)
162212 }
163213 else throw("Strict value is not equal to itself.")
164214 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let a = "__"
55
66 let b = toBigInt(100000)
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__pendingManagerPublicKey"
2121
2222
2323 func j () = "%s__factoryContract"
2424
2525
2626 let k = addressFromStringValue(c(j()))
2727
2828 func l () = makeString(["%s", "feeLiquidityContractAddress"], a)
2929
3030
31-func m () = makeString(["%d", "feeLiquidity"], a)
31+func m () = makeString(["%s", "feeLiquidity"], a)
3232
3333
34-func n () = makeString(["%d", "protocolFee"], a)
34+func n () = makeString(["%s", "protocolFee"], a)
3535
3636
3737 func o (p) = {
3838 let q = p
3939 if ($isInstanceOf(q, "Int"))
4040 then {
4141 let r = q
4242 r
4343 }
4444 else throw("fail to cast into Int")
4545 }
4646
4747
4848 func s (t,u) = makeString(["%d%d", toString(t), toString(u)], a)
4949
5050
5151 func v () = {
5252 let q = getString(h())
5353 if ($isInstanceOf(q, "String"))
5454 then {
5555 let w = q
5656 fromBase58String(w)
5757 }
5858 else if ($isInstanceOf(q, "Unit"))
5959 then unit
6060 else throw("Match error")
6161 }
6262
6363
6464 func x () = {
6565 let q = getString(i())
6666 if ($isInstanceOf(q, "String"))
6767 then {
6868 let w = q
6969 fromBase58String(w)
7070 }
7171 else if ($isInstanceOf(q, "Unit"))
7272 then unit
7373 else throw("Match error")
7474 }
7575
7676
7777 func y (z) = {
7878 let q = v()
7979 if ($isInstanceOf(q, "ByteVector"))
8080 then {
8181 let A = q
8282 (z.callerPublicKey == A)
8383 }
8484 else if ($isInstanceOf(q, "Unit"))
8585 then (z.caller == this)
8686 else throw("Match error")
8787 }
8888
8989
9090 func B (z) = if (y(z))
9191 then true
9292 else throw("permission denied")
9393
9494
95+func C (D) = if ((D == "WAVES"))
96+ then wavesBalance(this).available
97+ else assetBalance(this, fromBase58String(D))
98+
99+
95100 @Callable(z)
96-func constructor (C,D,E,j) = {
97- let F = B(z)
98- if ((F == F))
99- then [StringEntry(l(), E), IntegerEntry(m(), D), IntegerEntry(n(), C), StringEntry(j(), j)]
101+func swapCalulateREADONLY (E,F,G) = {
102+ let H = value(getInteger(n()))
103+ let I = fraction(toBigInt(E), toBigInt(H), b)
104+ let J = fraction(toBigInt(E), toBigInt(H), b)
105+ let K = (toBigInt(E) - I)
106+ let L = (K - J)
107+ let M = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [F, G], nil)
108+ let N = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [G, F], nil)
109+ let O = if ((M != unit))
110+ then {
111+ let P = false
112+ let Q = {
113+ let R = invoke(k, "getPoolAddressFromLpAssetREADONLY", [M], nil)
114+ if ($isInstanceOf(R, "Address"))
115+ then R
116+ else throw(($getType(R) + " couldn't be cast to Address"))
117+ }
118+ $Tuple2(P, Q)
119+ }
120+ else if ((N != unit))
121+ then {
122+ let P = true
123+ let Q = invoke(k, "getPoolAddressFromLpAssetREADONLY", [N], nil)
124+ $Tuple2(P, Q)
125+ }
126+ else f
127+ let P = O._1
128+ let Q = O._2
129+ let S = {
130+ let R = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [Q], nil)
131+ if ($isInstanceOf(R, "Boolean"))
132+ then R
133+ else throw(($getType(R) + " couldn't be cast to Boolean"))
134+ }
135+ let T = if (S)
136+ then true
137+ else e
138+ if ((T == T))
139+ then {
140+ let U = addressFromStringValue(valueOrElse(Q, ""))
141+ let V = {
142+ let R = invoke(U, "calculateAmountOutForSwapREADONLY", [L, P], nil)
143+ if ($isInstanceOf(R, "Int"))
144+ then R
145+ else throw(($getType(R) + " couldn't be cast to Int"))
146+ }
147+ $Tuple2(nil, V)
148+ }
100149 else throw("Strict value is not equal to itself.")
101150 }
102151
103152
104153
105154 @Callable(z)
106-func swap (G,H,I) = {
107- let J = value(z.payments[0])
108- let K = value(J.assetId)
109- let L = value(J.amount)
110- let M = value(getInteger(n()))
111- let N = fraction(toBigInt(L), toBigInt(M), b)
112- let D = fraction(toBigInt(L), toBigInt(M), b)
113- let O = (toBigInt(L) - N)
114- let P = (O - D)
115- let Q = [if ((size(z.payments) == 1))
155+func swap (W,G,X) = {
156+ let Y = value(z.payments[0])
157+ let F = if ((Y.assetId == unit))
158+ then toBytes("WAVES")
159+ else value(Y.assetId)
160+ let E = value(Y.amount)
161+ let H = value(getInteger(n()))
162+ let I = fraction(toBigInt(E), toBigInt(H), b)
163+ let J = fraction(toBigInt(E), toBigInt(H), b)
164+ let K = (toBigInt(E) - I)
165+ let L = (K - J)
166+ let Z = [if ((size(z.payments) == 1))
116167 then true
117168 else throw("exactly 1 payment are expected")]
118- if ((Q == Q))
169+ if ((Z == Z))
119170 then {
120- let R = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [K, H], nil)
121- let S = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [H, K], nil)
122- let T = if ((R != unit))
171+ let M = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [F, G], nil)
172+ let N = invoke(k, "getLpAssetFromPoolAssetsREADONLY", [G, F], nil)
173+ let aa = if ((M != unit))
123174 then {
124- let U = false
125- let V = invoke(k, "getPoolAddressFromLpAssetREADONLY", [R], nil)
126- $Tuple2(U, V)
175+ let P = false
176+ let Q = {
177+ let R = invoke(k, "getPoolAddressFromLpAssetREADONLY", [M], nil)
178+ if ($isInstanceOf(R, "Address"))
179+ then R
180+ else throw(($getType(R) + " couldn't be cast to Address"))
181+ }
182+ $Tuple2(P, Q)
127183 }
128- else if ((S != unit))
184+ else if ((N != unit))
129185 then {
130- let U = true
131- let V = invoke(k, "getPoolAddressFromLpAssetREADONLY", [S], nil)
132- $Tuple2(U, V)
186+ let P = true
187+ let Q = invoke(k, "getPoolAddressFromLpAssetREADONLY", [N], nil)
188+ $Tuple2(P, Q)
133189 }
134- else {
135- let U = true
136- let V = ""
137- $Tuple2(U, V)
190+ else f
191+ let P = aa._1
192+ let Q = aa._2
193+ let S = {
194+ let R = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [Q], nil)
195+ if ($isInstanceOf(R, "Boolean"))
196+ then R
197+ else throw(($getType(R) + " couldn't be cast to Boolean"))
198+ }
199+ let T = if (S)
200+ then true
201+ else e
202+ if ((T == T))
203+ then {
204+ let U = addressFromStringValue(valueOrElse(Q, ""))
205+ let V = {
206+ let R = invoke(U, "calculateAmountOutForSwapAndSendTokens", [L, P, W, X], [AttachedPayment(F, toInt(K))])
207+ if ($isInstanceOf(R, "Boolean"))
208+ then R
209+ else throw(($getType(R) + " couldn't be cast to Boolean"))
138210 }
139- let U = T._1
140- let V = T._2
141- let W = [if ((V != ""))
142- then true
143- else f]
144- if ((W == W))
145- then {
146- let X = {
147- let Y = invoke(k, "isPoolOneTokenOperationsDisabledREADONLY", [V], nil)
148- if ($isInstanceOf(Y, "Boolean"))
149- then Y
150- else throw(($getType(Y) + " couldn't be cast to Boolean"))
151- }
152- let F = [if (X)
153- then true
154- else e]
155- if ((F == F))
156- then {
157- let Z = addressFromStringValue(valueOrElse(V, ""))
158- let aa = invoke(Z, "calculateAmountOutForSwapAndSendTokens", [P, U, G, I], [AttachedPayment(K, toInt(O))])
159- $Tuple2(nil, true)
160- }
161- else throw("Strict value is not equal to itself.")
211+ $Tuple2(nil, V)
162212 }
163213 else throw("Strict value is not equal to itself.")
164214 }
165215 else throw("Strict value is not equal to itself.")
166216 }
167217
168218
169219
170220 @Callable(z)
171221 func setManager (ab) = {
172222 let ac = B(z)
173223 if ((ac == ac))
174224 then {
175225 let ad = fromBase58String(ab)
176226 if ((ad == ad))
177227 then [StringEntry(i(), ab)]
178228 else throw("Strict value is not equal to itself.")
179229 }
180230 else throw("Strict value is not equal to itself.")
181231 }
182232
183233
184234
185235 @Callable(z)
186236 func confirmManager () = {
187237 let ae = x()
188238 let af = if (isDefined(ae))
189239 then true
190240 else throw("no pending manager")
191241 if ((af == af))
192242 then {
193243 let ag = if ((z.callerPublicKey == value(ae)))
194244 then true
195245 else throw("you are not pending manager")
196246 if ((ag == ag))
197247 then [StringEntry(h(), toBase58String(value(ae))), DeleteEntry(i())]
198248 else throw("Strict value is not equal to itself.")
199249 }
200250 else throw("Strict value is not equal to itself.")
201251 }
202252
203253
204254 @Verifier(ah)
205255 func ai () = {
206256 let aj = {
207257 let q = v()
208258 if ($isInstanceOf(q, "ByteVector"))
209259 then {
210260 let A = q
211261 A
212262 }
213263 else if ($isInstanceOf(q, "Unit"))
214264 then ah.senderPublicKey
215265 else throw("Match error")
216266 }
217267 sigVerify(ah.bodyBytes, ah.proofs[0], aj)
218268 }
219269

github/deemru/w8io/169f3d6 
92.94 ms