tx · H6nozFM2yfZ3KB3F8zKweSGE18fi1PH9HA5cfpG858zS 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq: -0.01000000 Waves 2024.03.04 12:22 [3003072] smart account 3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq > SELF 0.00000000 Waves
{ "type": 13, "id": "H6nozFM2yfZ3KB3F8zKweSGE18fi1PH9HA5cfpG858zS", "fee": 1000000, "feeAssetId": null, "timestamp": 1709544167686, "version": 2, "chainId": 84, "sender": "3N61RYWc9QuqKUwLvowpZZLpgUnqpQSFwLq", "senderPublicKey": "HdwFH8HPYu3HG27yK6bszu1CdR4uik4HgzyTimeSfcYf", "proofs": [ "2ZhPbFrLrDYvsn7jmeSgTRxeT2az3fUEuXdrQz2hTvABkGKu3VMeWNGfx8XcXmQbNXwSM45C2sqTpQnVxQX8SqDx" ], "script": "base64:BgIJCAISABIDCgEIEQAQYW1vdW50QXNzZXRJZEtleQINYW1vdW50QXNzZXRJZAAPcHJpY2VBc3NldElkS2V5AgxwcmljZUFzc2V0SWQACmZlZVJhdGVLZXkCB2ZlZVJhdGUBCmdldEFzc2V0SWQBDWFzc2V0SWRTdHJpbmcDCQAAAgUNYXNzZXRJZFN0cmluZwIFV0FWRVMFBHVuaXQJANkEAQUNYXNzZXRJZFN0cmluZwEPZ2V0QXNzZXRCYWxhbmNlAQdhc3NldElkBAckbWF0Y2gwBQdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAmlkBQckbWF0Y2gwCQDwBwIFBHRoaXMFAmlkCAkA7wcBBQR0aGlzCWF2YWlsYWJsZQATYW1vdW50QXNzZXRJZFN0cmluZwkBEUBleHRyTmF0aXZlKDEwNTMpAgUEdGhpcwUQYW1vdW50QXNzZXRJZEtleQANYW1vdW50QXNzZXRJZAkBCmdldEFzc2V0SWQBBRNhbW91bnRBc3NldElkU3RyaW5nABJhbW91bnRBc3NldEJhbGFuY2UJAQ9nZXRBc3NldEJhbGFuY2UBBQ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ICgJAMwIAgUTYW1vdW50QXNzZXRJZFN0cmluZwkAzAgCAgYpIG9yICgJAMwIAgUScHJpY2VBc3NldElkU3RyaW5nCQDMCAICASkFA25pbAIBIAUDbmlsAwkAAAIFBmNoZWNrcwUGY2hlY2tzBA5wYXltZW50QXNzZXRJZAgJAJEDAggFAWkIcGF5bWVudHMAAAdhc3NldElkBA1wYXltZW50QW1vdW50CAkAkQMCCAUBaQhwYXltZW50cwAABmFtb3VudAQLJHQwMjg4MDI5ODMJAQ5jYWxjU2VuZEFtb3VudAIFDnBheW1lbnRBc3NldElkBQ1wYXltZW50QW1vdW50BApzZW5kQW1vdW50CAULJHQwMjg4MDI5ODMCXzEECWZlZUFtb3VudAgFCyR0MDI4ODAyOTgzAl8yBAtzZW5kQXNzZXRJZAgFCyR0MDI4ODAyOTgzAl8zBA11c2VyUmVhbFByaWNlCAULJHQwMjg4MDI5ODMCXzQEC3NlbmRBY3Rpb25zAwkBAiE9AgUJZmVlQW1vdW50AAAJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwUHYWRkcmVzcwUKc2VuZEFtb3VudAULc2VuZEFzc2V0SWQFA25pbAkAAgECEWFtb3VudCBpcyB0b28gbG93CQCUCgIFC3NlbmRBY3Rpb25zCQCVCgMFCnNlbmRBbW91bnQFCWZlZUFtb3VudAUNdXNlclJlYWxQcmljZQkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgIBaQEEc3dhcAAJAQxzd2FwSW50ZXJuYWwCCAUBaQZjYWxsZXIFAWkBaQEHc3dhcEZvcgEHYWRkcmVzcwkBDHN3YXBJbnRlcm5hbAIJARFAZXh0ck5hdGl2ZSgxMDYyKQEFB2FkZHJlc3MFAWkAymU4pw==", "height": 3003072, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3RZ6ZnBgHeKoREten5xR15wRpwjGSa4nyjbhyF6e19Lc Next: 47XFd1viawS1782AFAiqcsWBSXUdtELv9ixndhRCcyCj Diff:
Old | New | Differences | |
---|---|---|---|
67 | 67 | let t = (f(F) - u) | |
68 | 68 | let G = A(s, t, u) | |
69 | 69 | let H = fraction(G, q, p) | |
70 | - | $Tuple3((G - H), H, E) | |
70 | + | let v = (G - H) | |
71 | + | let I = fraction(v, p, u) | |
72 | + | $Tuple4(v, H, E, I) | |
71 | 73 | } | |
72 | 74 | ||
73 | 75 | ||
74 | - | func | |
75 | - | let | |
76 | + | func J (K,L) = { | |
77 | + | let M = [if ((size(L.payments) > 0)) | |
76 | 78 | then true | |
77 | - | else throw("should be with 1 payment"), if (if (( | |
79 | + | else throw("should be with 1 payment"), if (if ((L.payments[0].assetId == k)) | |
78 | 80 | then true | |
79 | - | else ( | |
81 | + | else (L.payments[0].assetId == n)) | |
80 | 82 | then true | |
81 | 83 | else throw(makeString(["payment assetId should be (", j, ") or (", m, ")"], " "))] | |
82 | - | if (( | |
84 | + | if ((M == M)) | |
83 | 85 | then { | |
84 | - | let C = K.payments[0].assetId | |
85 | - | let u = K.payments[0].amount | |
86 | - | let M = B(C, u) | |
87 | - | let v = M._1 | |
88 | - | let H = M._2 | |
89 | - | let N = M._3 | |
90 | - | let O = if ((H != 0)) | |
91 | - | then [ScriptTransfer(J, v, N)] | |
86 | + | let C = L.payments[0].assetId | |
87 | + | let u = L.payments[0].amount | |
88 | + | let N = B(C, u) | |
89 | + | let v = N._1 | |
90 | + | let H = N._2 | |
91 | + | let O = N._3 | |
92 | + | let I = N._4 | |
93 | + | let P = if ((H != 0)) | |
94 | + | then [ScriptTransfer(K, v, O)] | |
92 | 95 | else throw("amount is too low") | |
93 | - | let P = fraction(v, p, u) | |
94 | - | $Tuple2(O, $Tuple3(v, H, P)) | |
96 | + | $Tuple2(P, $Tuple3(v, H, I)) | |
95 | 97 | } | |
96 | 98 | else throw("Strict value is not equal to itself.") | |
97 | 99 | } | |
98 | 100 | ||
99 | 101 | ||
100 | - | @Callable( | |
101 | - | func swap () = | |
102 | + | @Callable(L) | |
103 | + | func swap () = J(L.caller, L) | |
102 | 104 | ||
103 | 105 | ||
104 | 106 | ||
105 | - | @Callable( | |
106 | - | func swapFor ( | |
107 | + | @Callable(L) | |
108 | + | func swapFor (K) = J(addressFromStringValue(K), L) | |
107 | 109 | ||
108 | 110 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = "amountAssetId" | |
5 | 5 | ||
6 | 6 | let b = "priceAssetId" | |
7 | 7 | ||
8 | 8 | let c = "feeRate" | |
9 | 9 | ||
10 | 10 | func d (e) = if ((e == "WAVES")) | |
11 | 11 | then unit | |
12 | 12 | else fromBase58String(e) | |
13 | 13 | ||
14 | 14 | ||
15 | 15 | func f (g) = { | |
16 | 16 | let h = g | |
17 | 17 | if ($isInstanceOf(h, "ByteVector")) | |
18 | 18 | then { | |
19 | 19 | let i = h | |
20 | 20 | assetBalance(this, i) | |
21 | 21 | } | |
22 | 22 | else wavesBalance(this).available | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | let j = getStringValue(this, a) | |
27 | 27 | ||
28 | 28 | let k = d(j) | |
29 | 29 | ||
30 | 30 | let l = f(k) | |
31 | 31 | ||
32 | 32 | let m = getStringValue(this, b) | |
33 | 33 | ||
34 | 34 | let n = d(m) | |
35 | 35 | ||
36 | 36 | let o = f(n) | |
37 | 37 | ||
38 | 38 | let p = 100000000 | |
39 | 39 | ||
40 | 40 | let q = valueOrElse(getInteger(this, c), 1000000) | |
41 | 41 | ||
42 | 42 | func r (s,t,u) = { | |
43 | 43 | let v = (s - fraction(s, t, (t + u))) | |
44 | 44 | let w = (s - v) | |
45 | 45 | let x = (t + u) | |
46 | 46 | let y = (w * x) | |
47 | 47 | let z = (s * t) | |
48 | 48 | $Tuple7(v, s, t, z, w, x, y) | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func A (s,t,u) = { | |
53 | 53 | let v = (s - fraction(s, t, (t + u))) | |
54 | 54 | let w = (s - v) | |
55 | 55 | let x = (t + u) | |
56 | 56 | v | |
57 | 57 | } | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func B (C,u) = { | |
61 | 61 | let D = if ((C == k)) | |
62 | 62 | then $Tuple2(n, k) | |
63 | 63 | else $Tuple2(k, n) | |
64 | 64 | let E = D._1 | |
65 | 65 | let F = D._2 | |
66 | 66 | let s = f(E) | |
67 | 67 | let t = (f(F) - u) | |
68 | 68 | let G = A(s, t, u) | |
69 | 69 | let H = fraction(G, q, p) | |
70 | - | $Tuple3((G - H), H, E) | |
70 | + | let v = (G - H) | |
71 | + | let I = fraction(v, p, u) | |
72 | + | $Tuple4(v, H, E, I) | |
71 | 73 | } | |
72 | 74 | ||
73 | 75 | ||
74 | - | func | |
75 | - | let | |
76 | + | func J (K,L) = { | |
77 | + | let M = [if ((size(L.payments) > 0)) | |
76 | 78 | then true | |
77 | - | else throw("should be with 1 payment"), if (if (( | |
79 | + | else throw("should be with 1 payment"), if (if ((L.payments[0].assetId == k)) | |
78 | 80 | then true | |
79 | - | else ( | |
81 | + | else (L.payments[0].assetId == n)) | |
80 | 82 | then true | |
81 | 83 | else throw(makeString(["payment assetId should be (", j, ") or (", m, ")"], " "))] | |
82 | - | if (( | |
84 | + | if ((M == M)) | |
83 | 85 | then { | |
84 | - | let C = K.payments[0].assetId | |
85 | - | let u = K.payments[0].amount | |
86 | - | let M = B(C, u) | |
87 | - | let v = M._1 | |
88 | - | let H = M._2 | |
89 | - | let N = M._3 | |
90 | - | let O = if ((H != 0)) | |
91 | - | then [ScriptTransfer(J, v, N)] | |
86 | + | let C = L.payments[0].assetId | |
87 | + | let u = L.payments[0].amount | |
88 | + | let N = B(C, u) | |
89 | + | let v = N._1 | |
90 | + | let H = N._2 | |
91 | + | let O = N._3 | |
92 | + | let I = N._4 | |
93 | + | let P = if ((H != 0)) | |
94 | + | then [ScriptTransfer(K, v, O)] | |
92 | 95 | else throw("amount is too low") | |
93 | - | let P = fraction(v, p, u) | |
94 | - | $Tuple2(O, $Tuple3(v, H, P)) | |
96 | + | $Tuple2(P, $Tuple3(v, H, I)) | |
95 | 97 | } | |
96 | 98 | else throw("Strict value is not equal to itself.") | |
97 | 99 | } | |
98 | 100 | ||
99 | 101 | ||
100 | - | @Callable( | |
101 | - | func swap () = | |
102 | + | @Callable(L) | |
103 | + | func swap () = J(L.caller, L) | |
102 | 104 | ||
103 | 105 | ||
104 | 106 | ||
105 | - | @Callable( | |
106 | - | func swapFor ( | |
107 | + | @Callable(L) | |
108 | + | func swapFor (K) = J(addressFromStringValue(K), L) | |
107 | 109 | ||
108 | 110 |
github/deemru/w8io/169f3d6 31.94 ms ◑