tx · HnJ2tEckyXM14p72xHyUs35Tamy5xDzsDruqozRxjR6F

3N85YW6NZ9pLYvSdt1ASMQTGxvncnU1vUNx:  -0.01000000 Waves

2022.12.02 16:13 [2342772] smart account 3N85YW6NZ9pLYvSdt1ASMQTGxvncnU1vUNx > SELF 0.00000000 Waves

{ "type": 13, "id": "HnJ2tEckyXM14p72xHyUs35Tamy5xDzsDruqozRxjR6F", "fee": 1000000, "feeAssetId": null, "timestamp": 1669986843675, "version": 2, "chainId": 84, "sender": "3N85YW6NZ9pLYvSdt1ASMQTGxvncnU1vUNx", "senderPublicKey": "EKZmHJ5bK3qKKgRdq8rAamt9qrDbVMLARzRqXoQW258v", "proofs": [ "5SW82Nm6ma5G28EyYqj7nZkd31uNLVPCNhn8vLMqTa4uwQUJvUQZgkD4Q5kLHXtZ9dWnzeQK98d9FSt7sRvg9SQ1" ], "script": "base64:AAIFAAAAAAAAAAgIAhIECgIIAQAAAAcAAAAACXNlcGFyYXRvcgIAAAABXwEAAAAOam9pblBhaXJTdHJ1Y3QAAAAEAAAABnRva2VuMAAAAAZ0b2tlbjEAAAAIcmVzZXJ2ZTAAAAAIcmVzZXJ2ZTEJAAS5AAAAAgkABEwAAAACBQAAAAZ0b2tlbjAJAARMAAAAAgUAAAAGdG9rZW4xCQAETAAAAAIJAAGkAAAAAQUAAAAIcmVzZXJ2ZTAJAARMAAAAAgkAAaQAAAABBQAAAAhyZXNlcnZlMQUAAAADbmlsBQAAAAlzZXBhcmF0b3IBAAAADnNldFBhaXJEZXRhaWxzAAAABQAAAAlscFRva2VuSWQAAAAGdG9rZW4wAAAABnRva2VuMQAAAAhyZXNlcnZlMAAAAAhyZXNlcnZlMQkBAAAAC1N0cmluZ0VudHJ5AAAAAgUAAAAJbHBUb2tlbklkCQEAAAAOam9pblBhaXJTdHJ1Y3QAAAAEBQAAAAZ0b2tlbjAFAAAABnRva2VuMQUAAAAIcmVzZXJ2ZTAFAAAACHJlc2VydmUxAQAAAA1jYWxjQW1vdW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EAAAACWFtb3VudE91dAkBAAAADWNhbGNBbW91bnRPdXQAAAADBQAAAAhhbW91bnRJbgUAAAAMcGFpclJlc2VydmUwBQAAAAxwYWlyUmVzZXJ2ZTEDCQAAZgAAAAIFAAAADGFtb3VudE91dE1pbgUAAAAJYW1vdW50T3V0CQAAAgAAAAECAAAAGkluc3VmZmljaWVudCBvdXRwdXQgYW1vdW50CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAJYW1vdW50T3V0CQACWQAAAAEFAAAACnBhaXJUb2tlbjEJAARMAAAAAgkBAAAADnNldFBhaXJEZXRhaWxzAAAABQUAAAAHbHBUb2tlbgUAAAAHdG9rZW5JbgUAAAAIdG9rZW5PdXQJAABkAAAAAgUAAAAMcGFpclJlc2VydmUwBQAAAAhhbW91bnRJbgkAAGUAAAACBQAAAAxwYWlyUmVzZXJ2ZTEFAAAACWFtb3VudE91dAUAAAADbmlsAAAAAOaRgMs=", "height": 2342772, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B9n1bFVD8QLMneBb5X78y9U89T1ZGsV6UbgiKpnFJAoC Next: G8ThLkwZBdn2Msaejm82aH2rv7uGkT9F4SLFoUq8hsbf Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let a = base58''
4+let a = "_"
55
6-let b = Address(base58'')
7-
8-let c = Address(base58'')
9-
10-let d = base58''
11-
12-let e = 5
13-
14-let f = base58''
15-
16-let g = base58''
17-
18-let h = Address(base58'')
19-
20-let i = Address(base58'')
21-
22-let j = Address(base58'')
23-
24-let k = 5
25-
26-let l = 5
27-
28-let m = 20
29-
30-@Callable(n)
31-func addLiquidity () = if (if ((n.payments[0].assetId != unit))
32- then true
33- else (n.payments[1].assetId != a))
34- then throw("unexpected assets")
35- else {
36- let o = invoke(b, "stake", nil, [n.payments[1]])
37- if ((o == o))
38- then {
39- let p = {
40- let q = o
41- if ($isInstanceOf(q, "Int"))
42- then {
43- let r = q
44- r
45- }
46- else throw("unexpected result type from the staker")
47- }
48- let s = ("STAKING_AMOUNT_" + toString(n.caller))
49- let t = ("LEASE_AMOUNT_" + toString(n.caller))
50- let u = ("ID_" + toString(n.caller))
51- let v = valueOrElse(getInteger(this, t), 0)
52- let w = getString(this, u)
53- let x = Lease(c, (v + n.payments[0].amount))
54- let y = calculateLeaseId(x)
55- let z = {
56- let q = w
57- if ($isInstanceOf(q, "String"))
58- then {
59- let A = q
60-[LeaseCancel(fromBase58String(A))]
61- }
62- else [StringEntry(u, toBase58String(y))]
63- }
64- (z ++ [x, ScriptTransfer(n.caller, 1, d), IntegerEntry(t, (v + n.payments[0].amount)), IntegerEntry(s, p)])
65- }
66- else throw("Strict value is not equal to itself.")
67- }
6+func b (c,d,e,f) = makeString([c, d, toString(e), toString(f)], a)
687
698
9+func g (h,c,d,e,f) = StringEntry(h, b(c, d, e, f))
7010
71-@Callable(n)
72-func trade (B) = {
73- let C = if ((n.payments[0].assetId == f))
74- then n.payments[0].amount
75- else throw("unexpected payment asset")
76- let D = assetBalance(this, g)
77- if ((D == D))
78- then {
79- let E = invoke(h, "exchangeAB", nil, [AttachedPayment(f, C)])
80- if ((E == E))
81- then {
82- let F = (assetBalance(this, g) - D)
83- if ((F == F))
84- then {
85- let G = invoke(i, "exchangeBA", nil, [AttachedPayment(g, F)])
86- if ((G == G))
87- then {
88- let H = fraction(C, (100 + e), 100)
89- let I = (assetBalance(this, f) - H)
90-[ScriptTransfer(Address(B), I, f), ScriptTransfer(j, H, f)]
91- }
92- else throw("Strict value is not equal to itself.")
93- }
94- else throw("Strict value is not equal to itself.")
95- }
96- else throw("Strict value is not equal to itself.")
97- }
98- else throw("Strict value is not equal to itself.")
11+
12+func i (j,k,l) = {
13+ let m = (j * 970)
14+ let n = (m * l)
15+ let o = ((k * 1000) + m)
16+ fraction(1, n, o, HALFEVEN)
9917 }
10018
10119
102-
103-@Callable(n)
104-func exchangeAB () = if ((n.payments[0].assetId == f))
105- then [ScriptTransfer(n.caller, (n.payments[0].amount * k), g)]
106- else throw("unexpected token")
20+func p (c,d) = {
21+ let q = toInt(fromBase58String(c))
22+ let r = toInt(fromBase58String(d))
23+ if ((r > q))
24+ then makeString([c, d], a)
25+ else makeString([d, c], a)
26+ }
10727
10828
109-
110-@Callable(n)
111-func exchangeBA () = if ((n.payments[0].assetId == g))
112- then [ScriptTransfer(n.caller, (n.payments[0].amount / k), f)]
113- else throw("unexpected token")
29+func s (c,d) = valueOrErrorMessage(getString(this, p(c, d)), "Pair doesn`t exist")
11430
11531
116-
117-@Callable(n)
118-func exchangeWavesUsdN () = if ((n.payments[0].assetId != unit))
119- then throw("unexpected asset")
120- else {
121- let o = invoke(b, "cancelStake", [(n.payments[0].amount * l)], nil)
122- if ((o == o))
123- then [ScriptTransfer(n.caller, (n.payments[0].amount * l), a)]
124- else throw("Strict value is not equal to itself.")
125- }
32+func t (h) = {
33+ let u = split(valueOrElse(getString(this, h), "assetId0_assetId1_0_0"), a)
34+ $Tuple4(u[0], u[1], parseIntValue(u[2]), parseIntValue(u[3]))
35+ }
12636
12737
128-
129-@Callable(n)
130-func stake () = if ((n.payments[0].assetId != a))
131- then throw("unexpected asset")
132- else {
133- let J = valueOrElse(getInteger(this, toString(n.originCaller)), 0)
134-[IntegerEntry(toString(n.originCaller), (J + n.payments[0].amount))]
135- }
136-
137-
138-
139-@Callable(n)
140-func cancelStake (K) = if ((getIntegerValue(this, toString(n.caller)) >= K))
141- then [ScriptTransfer(n.caller, K, a)]
142- else throw("too big amount")
38+@Callable(v)
39+func swap (w,x) = {
40+ let y = $Tuple2(toBase58String(value(v.payments[0].assetId)), value(v.payments[0].amount))
41+ let z = y._1
42+ let j = y._2
43+ let A = s(z, w)
44+ let B = t(A)
45+ let C = B._1
46+ let D = B._2
47+ let E = B._3
48+ let F = B._4
49+ let G = i(j, E, F)
50+ if ((x > G))
51+ then throw("Insufficient output amount")
52+ else [ScriptTransfer(v.caller, G, fromBase58String(D)), g(A, z, w, (E + j), (F - G))]
53+ }
14354
14455

github/deemru/w8io/169f3d6 
66.25 ms