tx · J2DMxezfqgViwjspp1h55dBuFpyFabwac4nMEjM7wxNR 3N11gzZic4yASFhatzjC8zvLnpNhDo2B1Rv: -0.01000000 Waves 2023.10.06 13:34 [2786644] smart account 3N11gzZic4yASFhatzjC8zvLnpNhDo2B1Rv > SELF 0.00000000 Waves
{ "type": 13, "id": "J2DMxezfqgViwjspp1h55dBuFpyFabwac4nMEjM7wxNR", "fee": 1000000, "feeAssetId": null, "timestamp": 1696588469206, "version": 2, "chainId": 84, "sender": "3N11gzZic4yASFhatzjC8zvLnpNhDo2B1Rv", "senderPublicKey": "EnUXxxhBK8wUfh1FveDYv9G5HBMXop6YwZWzVrBrLo2i", "proofs": [ "G6xq6NvoCAJ3ZuatvxvJVnQZwFH7DSD56Nj1Gfxw3X3Pfe7VJdVgeUkBepwQh6vSQcdbvQYKgbY4GQESQNx2hwo" ], "script": "base64:BgIiCAISAwoBCBIICgYBAQgIGBgSBAoCCAgSBAoCCAESAwoBCAoADGFkbWluQWRkcmVzcwkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzAgVhZG1pbgIAAA13eFN3YXBBZGRyZXNzAiMzUDY4ek5pdWZzdTF2aVpwdTFhWTNjZGFoUlJLY3ZWNU45MwELd3JpdGVTdHJpbmcCA2tleQtzdHJpbmdWYWx1ZQkBC1N0cmluZ0VudHJ5AgUDa2V5BQtzdHJpbmdWYWx1ZQEMd3JpdGVJbnRlZ2VyAgNrZXkMaW50ZWdlclZhbHVlCQEMSW50ZWdlckVudHJ5AgUDa2V5BQxpbnRlZ2VyVmFsdWUBB2lzQWRtaW4BDWNhbGxlckFkZHJlc3MDCQAAAgUNY2FsbGVyQWRkcmVzcwkA2QQBBQxhZG1pbkFkZHJlc3MGBwENc3BsaXRDZm1tSnNvbgEFZW50cnkJALUJAgUFZW50cnkCAS8BEWRldGVybWluZVBsYXRmb3JtAwRjZm1tCXRva2VuSWRJbgp0b2tlbklkT3V0BARpdGVtCQENc3BsaXRDZm1tSnNvbgEFBGNmbW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XRoIGFkbWluIGFkZHJlc3MhAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleeZQUnE=", "height": 2786644, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 5WAd5iLZ9EVt2AjjapnsEVyA8G9vgfFQUfAXJNYCijME Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let adminAddress = valueOrElse(getString(this, "admin"), "") | |
5 | + | ||
6 | + | let wxSwapAddress = "3P68zNiufsu1viZpu1aY3cdahRRKcvV5N93" | |
7 | + | ||
8 | + | func writeString (key,stringValue) = StringEntry(key, stringValue) | |
9 | + | ||
10 | + | ||
11 | + | func writeInteger (key,integerValue) = IntegerEntry(key, integerValue) | |
12 | + | ||
13 | + | ||
14 | + | func isAdmin (callerAddress) = if ((callerAddress == fromBase58String(adminAddress))) | |
15 | + | then true | |
16 | + | else false | |
17 | + | ||
18 | + | ||
19 | + | func splitCfmmJson (entry) = split(entry, "/") | |
20 | + | ||
21 | + | ||
22 | + | func determinePlatform (cfmm,tokenIdIn,tokenIdOut) = { | |
23 | + | let item = splitCfmmJson(cfmm) | |
24 | + | let inputAmount = parseInt(item[2]) | |
25 | + | match inputAmount { | |
26 | + | case inputAmount: Int => | |
27 | + | if ((item[0] == "SWOP")) | |
28 | + | then invoke(addressFromStringValue(item[1]), "exchange", [1], [AttachedPayment(fromBase58String(tokenIdIn), inputAmount)]) | |
29 | + | else if ((item[0] == "Waves Exchange")) | |
30 | + | then invoke(addressFromStringValue(wxSwapAddress), "swap", [1, tokenIdOut, adminAddress], [AttachedPayment(fromBase58String(tokenIdIn), inputAmount)]) | |
31 | + | else if ((item[0] == "Puzzle Swap")) | |
32 | + | then invoke(addressFromStringValue(item[1]), "swap", [tokenIdOut, 1], [AttachedPayment(fromBase58String(tokenIdIn), inputAmount)]) | |
33 | + | else throw("Platform id does not match!") | |
34 | + | case _ => | |
35 | + | throw("value is not an int!") | |
36 | + | } | |
37 | + | } | |
38 | + | ||
39 | + | ||
40 | + | func processCfmms (swaps,tokenIdIn,tokenIdOut) = { | |
41 | + | func invokeSwap (accum,next) = { | |
42 | + | let $t022642291 = accum | |
43 | + | let result = $t022642291._1 | |
44 | + | let index = $t022642291._2 | |
45 | + | if ((size(swaps) > index)) | |
46 | + | then $Tuple2(determinePlatform(next, tokenIdIn, tokenIdOut), (index + 1)) | |
47 | + | else $Tuple2(result, index) | |
48 | + | } | |
49 | + | ||
50 | + | let $l = swaps | |
51 | + | let $s = size($l) | |
52 | + | let $acc0 = $Tuple2(nil, 0) | |
53 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
54 | + | then $a | |
55 | + | else invokeSwap($a, $l[$i]) | |
56 | + | ||
57 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
58 | + | then $a | |
59 | + | else throw("List size exceeds 40") | |
60 | + | ||
61 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40) | |
62 | + | } | |
63 | + | ||
64 | + | ||
65 | + | func distributeDifference (swaps,diff) = { | |
66 | + | let totalSwaps = size(swaps) | |
67 | + | func adjustAmounts (accum,next) = { | |
68 | + | let $t026322674 = accum | |
69 | + | let adjustedSwaps = $t026322674._1 | |
70 | + | let remainingDiff = $t026322674._2 | |
71 | + | let item = splitCfmmJson(next) | |
72 | + | let inputAmount = parseInt(item[2]) | |
73 | + | match inputAmount { | |
74 | + | case input: Int => | |
75 | + | let amountToAdjust = { | |
76 | + | let remainDiff = (remainingDiff / ((totalSwaps - size(adjustedSwaps)) + 1)) | |
77 | + | match remainDiff { | |
78 | + | case x: Int => | |
79 | + | if ((remainingDiff > 0)) | |
80 | + | then min([input, x]) | |
81 | + | else if ((0 > remainingDiff)) | |
82 | + | then max([(-(input) + 1), x]) | |
83 | + | else 0 | |
84 | + | case _ => | |
85 | + | throw("Wrong datatype") | |
86 | + | } | |
87 | + | } | |
88 | + | let newInputAmount = max([1, (input + amountToAdjust)]) | |
89 | + | let newItem = ((((item[0] + "/") + item[1]) + "/") + toString(newInputAmount)) | |
90 | + | $Tuple2((adjustedSwaps :+ newItem), (remainingDiff - (amountToAdjust * ((totalSwaps - size(adjustedSwaps)) + 1)))) | |
91 | + | case _ => | |
92 | + | throw("Input has wrong datatype!") | |
93 | + | } | |
94 | + | } | |
95 | + | ||
96 | + | let $l = swaps | |
97 | + | let $s = size($l) | |
98 | + | let $acc0 = $Tuple2(nil, diff) | |
99 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
100 | + | then $a | |
101 | + | else adjustAmounts($a, $l[$i]) | |
102 | + | ||
103 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
104 | + | then $a | |
105 | + | else throw("List size exceeds 40") | |
106 | + | ||
107 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40) | |
108 | + | } | |
109 | + | ||
110 | + | ||
111 | + | func handleSecondInputAmount (predeterminedAmount,availableAmount,swaps) = { | |
112 | + | let diff = (availableAmount - predeterminedAmount) | |
113 | + | let adjustedSwaps = if ((diff != 0)) | |
114 | + | then distributeDifference(swaps, diff)._1 | |
115 | + | else swaps | |
116 | + | adjustedSwaps | |
117 | + | } | |
118 | + | ||
119 | + | ||
120 | + | @Callable(i) | |
121 | + | func setup (admin) = if (!(isDefined(getString(this, "admin")))) | |
122 | + | then [writeString("admin", admin)] | |
123 | + | else throw("Dapp already setup!") | |
124 | + | ||
125 | + | ||
126 | + | ||
127 | + | @Callable(i) | |
128 | + | func basicArb (startAmount,secondAmountIn,firstToken,secondToken,firstSwap,secondSwap) = if (isAdmin(i.caller.bytes)) | |
129 | + | then { | |
130 | + | let firstTokenId = { | |
131 | + | let tId = fromBase58String(firstToken) | |
132 | + | match tId { | |
133 | + | case tId: ByteVector => | |
134 | + | tId | |
135 | + | case _ => | |
136 | + | throw("Invalid datatype") | |
137 | + | } | |
138 | + | } | |
139 | + | let availableAmountFirstToken = assetBalance(this, firstTokenId) | |
140 | + | if ((availableAmountFirstToken >= startAmount)) | |
141 | + | then { | |
142 | + | let result = processCfmms(firstSwap, firstToken, secondToken) | |
143 | + | let secondTokenId = { | |
144 | + | let id = fromBase58String(secondToken) | |
145 | + | match id { | |
146 | + | case id: ByteVector => | |
147 | + | id | |
148 | + | case _ => | |
149 | + | throw("Invalid datatype") | |
150 | + | } | |
151 | + | } | |
152 | + | let availableAmountSecondToken = assetBalance(this, secondTokenId) | |
153 | + | let secondSwaps = if ((availableAmountSecondToken == secondAmountIn)) | |
154 | + | then secondSwap | |
155 | + | else handleSecondInputAmount(secondAmountIn, availableAmountSecondToken, secondSwap) | |
156 | + | let resultTwo = processCfmms(secondSwaps, secondToken, firstToken) | |
157 | + | let currentStartTokenBalance = assetBalance(this, firstTokenId) | |
158 | + | if ((currentStartTokenBalance > startAmount)) | |
159 | + | then nil | |
160 | + | else throw("Trade was not profitable!") | |
161 | + | } | |
162 | + | else throw("Available input amount is not sufficient!") | |
163 | + | } | |
164 | + | else throw("Address does not match with admin address!") | |
165 | + | ||
166 | + | ||
167 | + | ||
168 | + | @Callable(i) | |
169 | + | func updateStringEntry (key,stringValue) = if (isAdmin(i.caller.bytes)) | |
170 | + | then [writeString(key, stringValue)] | |
171 | + | else throw("Address does not match with admin address!") | |
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | @Callable(i) | |
176 | + | func updateIntegerEntry (key,integerValue) = if (isAdmin(i.caller.bytes)) | |
177 | + | then [writeInteger(key, integerValue)] | |
178 | + | else throw("Address does not match with admin address!") | |
179 | + | ||
180 | + | ||
181 | + | ||
182 | + | @Callable(i) | |
183 | + | func deleteStorageEntry (key) = if (isAdmin(i.caller.bytes)) | |
184 | + | then [DeleteEntry(key)] | |
185 | + | else throw("Address does not match with admin address!") | |
186 | + | ||
187 | + | ||
188 | + | @Verifier(tx) | |
189 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
190 | + |
github/deemru/w8io/169f3d6 27.27 ms ◑