23 | 14 | | |
---|
24 | 15 | | let WX_SWAP_DAPP = Address(base58'3P68zNiufsu1viZpu1aY3cdahRRKcvV5N93') |
---|
25 | 16 | | |
---|
26 | 17 | | let assets_in = ["DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"] |
---|
27 | 18 | | |
---|
28 | 19 | | func getBalance (assetId) = match assetId { |
---|
29 | 20 | | case b: ByteVector => |
---|
30 | 21 | | assetBalance(this, b) |
---|
31 | 22 | | case _ => |
---|
32 | 23 | | wavesBalance(this).available |
---|
33 | 24 | | } |
---|
34 | 25 | | |
---|
35 | 26 | | |
---|
36 | 27 | | func getBase1 (data) = { |
---|
37 | 28 | | let p_data = split_4C(data, "_") |
---|
38 | 29 | | let a = p_data[0] |
---|
39 | 30 | | let a2 = p_data[1] |
---|
40 | 31 | | let assetIn = assets_in[value(parseInt(p_data[2]))] |
---|
41 | 32 | | let amountIn = p_data[3] |
---|
42 | 33 | | $Tuple4(a, a2, assetIn, amountIn) |
---|
43 | 34 | | } |
---|
44 | 35 | | |
---|
45 | 36 | | |
---|
46 | 37 | | func getBase2 (data) = { |
---|
47 | 38 | | let p_data = split(data, "_") |
---|
48 | 39 | | let p1 = p_data[0] |
---|
49 | 40 | | let t = p_data[1] |
---|
50 | 41 | | $Tuple2(p1, t) |
---|
51 | 42 | | } |
---|
52 | 43 | | |
---|
53 | 44 | | |
---|
54 | 45 | | func getAssetBytes (assetId) = if ((assetId == "WAVES")) |
---|
55 | 46 | | then unit |
---|
56 | 47 | | else fromBase58String(assetId) |
---|
57 | 48 | | |
---|
58 | 49 | | |
---|
59 | 50 | | func swap_wx (p,asset,amount,a) = { |
---|
60 | 51 | | let call = invoke(WX_SWAP_DAPP, "swap", [1, a, toString(this)], [AttachedPayment(getAssetBytes(asset), amount)]) |
---|
61 | 52 | | if ((call == call)) |
---|
62 | 53 | | then nil |
---|
63 | 54 | | else throw("Strict value is not equal to itself.") |
---|
64 | 55 | | } |
---|
65 | 56 | | |
---|
66 | 57 | | |
---|
67 | 58 | | func swap_swop (p,asset,amount) = { |
---|
68 | 59 | | let swap = invoke(Address(fromBase58String(p)), "exchange", [1], [AttachedPayment(getAssetBytes(asset), amount)]) |
---|
69 | 60 | | if ((swap == swap)) |
---|
70 | 61 | | then nil |
---|
71 | 62 | | else throw("Strict value is not equal to itself.") |
---|
72 | 63 | | } |
---|
73 | 64 | | |
---|
74 | 65 | | |
---|
75 | 66 | | func swap_puzzle (p,asset,amount,assetOut) = { |
---|
76 | 67 | | let swap = invoke(Address(fromBase58String(p)), "swap", [assetOut, 1], [AttachedPayment(getAssetBytes(asset), amount)]) |
---|
77 | 68 | | if ((swap == swap)) |
---|
78 | 69 | | then nil |
---|
79 | 70 | | else throw("Strict value is not equal to itself.") |
---|
80 | 71 | | } |
---|
81 | 72 | | |
---|
82 | 73 | | |
---|
83 | 74 | | func ucheck (id) = match transactionHeightById(id) { |
---|
84 | 75 | | case h: Int => |
---|
85 | 76 | | h |
---|
86 | 77 | | case _ => |
---|
87 | 78 | | 0 |
---|
88 | 79 | | } |
---|
89 | 80 | | |
---|
90 | 81 | | |
---|
91 | 82 | | @Callable(i) |
---|
92 | 83 | | func s () = if ((i.caller != this)) |
---|
93 | 84 | | then throw("self") |
---|
94 | 85 | | else [StringEntry("current", toBase58String(i.transactionId))] |
---|
95 | 86 | | |
---|
96 | 87 | | |
---|
97 | 88 | | |
---|
98 | 89 | | @Callable(i) |
---|
99 | 90 | | func e () = if ((i.caller != this)) |
---|
100 | 91 | | then throw("self") |
---|
101 | 92 | | else [DeleteEntry("current")] |
---|
102 | 93 | | |
---|
103 | 94 | | |
---|
104 | 95 | | |
---|
105 | 96 | | @Callable(i) |
---|
106 | 97 | | func sf (fee) = if ((i.caller != this)) |
---|
107 | 98 | | then throw("self") |
---|
108 | 99 | | else [IntegerEntry("fee", fee)] |
---|
109 | 100 | | |
---|
110 | 101 | | |
---|
111 | 102 | | |
---|
112 | 103 | | @Callable(i) |
---|
113 | 104 | | func d () = if (!(containsElement(split_4C(w1, "|"), toBase58String(i.caller.bytes)))) |
---|
114 | 105 | | then throw("wl") |
---|
115 | 106 | | else { |
---|
116 | 107 | | let current = match getString(this, "current") { |
---|
117 | 108 | | case ret: String => |
---|
118 | 109 | | throw("current") |
---|
119 | 110 | | case _ => |
---|
120 | 111 | | "" |
---|
121 | 112 | | } |
---|
122 | 113 | | let pmt = if ((size(i.payments) == 1)) |
---|
123 | 114 | | then i.payments[0] |
---|
124 | 115 | | else throw("1 payment expected") |
---|
125 | 116 | | if ((pmt.assetId != TOKEN)) |
---|
126 | 117 | | then throw("wrong token") |
---|
127 | 118 | | else { |
---|
128 | 119 | | let caller = toBase58String(i.caller.bytes) |
---|
129 | 120 | | let currentAmount = match getInteger(this, ("deposit_" + caller)) { |
---|
130 | 121 | | case a: Int => |
---|
131 | 122 | | a |
---|
132 | 123 | | case _ => |
---|
133 | 124 | | 0 |
---|
134 | 125 | | } |
---|
135 | 126 | | let totalDeposit = match getInteger(this, "total_deposit") { |
---|
136 | 127 | | case a: Int => |
---|
137 | 128 | | a |
---|
138 | 129 | | case _ => |
---|
139 | 130 | | 0 |
---|
140 | 131 | | } |
---|
141 | 132 | | let newAmount = (currentAmount + pmt.amount) |
---|
142 | 133 | | [IntegerEntry(("deposit_" + caller), newAmount), IntegerEntry("total_deposit", (totalDeposit + pmt.amount))] |
---|
143 | 134 | | } |
---|
144 | 135 | | } |
---|
145 | 136 | | |
---|
146 | 137 | | |
---|
147 | 138 | | |
---|
148 | 139 | | @Callable(i) |
---|
149 | 140 | | func w (amnt) = if ((this != i.caller)) |
---|
150 | 141 | | then throw("wl") |
---|
151 | 142 | | else { |
---|
152 | 143 | | let current = match getString(this, "current") { |
---|
153 | 144 | | case ret: String => |
---|
154 | 145 | | throw("current") |
---|
155 | 146 | | case _ => |
---|
156 | 147 | | "" |
---|
157 | 148 | | } |
---|
158 | 149 | | let caller = toBase58String(i.caller.bytes) |
---|
159 | 150 | | let currentAmount = match getInteger(this, ("deposit_" + caller)) { |
---|
160 | 151 | | case a: Int => |
---|
161 | 152 | | a |
---|
162 | 153 | | case _ => |
---|
163 | 154 | | 0 |
---|
164 | 155 | | } |
---|
165 | 156 | | if ((amnt > currentAmount)) |
---|
166 | 157 | | then throw("w > d") |
---|
167 | 158 | | else { |
---|
168 | 159 | | let newAmount = (currentAmount - amnt) |
---|
169 | 160 | | if ((0 > newAmount)) |
---|
170 | 161 | | then throw("underflow") |
---|
171 | 162 | | else { |
---|
172 | 163 | | let totalDeposit = match getInteger(this, "total_deposit") { |
---|
173 | 164 | | case a: Int => |
---|
174 | 165 | | a |
---|
175 | 166 | | case _ => |
---|
176 | 167 | | 0 |
---|
177 | 168 | | } |
---|
178 | 169 | | [IntegerEntry(("deposit_" + caller), newAmount), IntegerEntry("total_deposit", (totalDeposit - amnt)), ScriptTransfer(i.caller, amnt, TOKEN)] |
---|
179 | 170 | | } |
---|
180 | 171 | | } |
---|
181 | 172 | | } |
---|
182 | 173 | | |
---|
183 | 174 | | |
---|
184 | 175 | | |
---|
185 | 176 | | @Callable(i) |
---|
186 | 177 | | func x (amnt,a,f,data) = if ((this != i.caller)) |
---|
187 | 178 | | then throw("wl") |
---|
188 | 179 | | else { |
---|
189 | 180 | | let st = assetBalance(this, TOKEN) |
---|
190 | 181 | | if ((st == st)) |
---|
191 | 182 | | then { |
---|
192 | 183 | | let ii = reentrantInvoke(addressFromStringValue(a), f, [data], [AttachedPayment(TOKEN, amnt)]) |
---|
193 | 184 | | if ((ii == ii)) |
---|
194 | 185 | | then { |
---|
195 | 186 | | let et = assetBalance(this, TOKEN) |
---|
196 | 187 | | if ((et == et)) |
---|
197 | 188 | | then { |
---|
198 | 189 | | let fee_r = match getInteger(this, "fee") { |
---|
199 | 190 | | case ret: Int => |
---|
200 | 191 | | ret |
---|
201 | 192 | | case _ => |
---|
202 | 193 | | 0 |
---|
203 | 194 | | } |
---|
204 | 195 | | let fee = fraction(st, fee_r, fee_scale, DOWN) |
---|
205 | 196 | | if (((st + fee) > et)) |
---|
206 | 197 | | then throw(("! " + toString((st + fee)))) |
---|
207 | 198 | | else nil |
---|
208 | 199 | | } |
---|
209 | 200 | | else throw("Strict value is not equal to itself.") |
---|
210 | 201 | | } |
---|
211 | 202 | | else throw("Strict value is not equal to itself.") |
---|
212 | 203 | | } |
---|
213 | 204 | | else throw("Strict value is not equal to itself.") |
---|
214 | 205 | | } |
---|
215 | 206 | | |
---|
216 | 207 | | |
---|
217 | 208 | | |
---|
218 | 209 | | @Callable(i) |
---|
219 | 210 | | func arbWaves (path,amount) = { |
---|
220 | 211 | | let poolAddress = "3PPZWgFNRKHLvM51pwS934C8VZ7d2F4Z58g" |
---|
221 | 212 | | let pool = addressFromStringValue(poolAddress) |
---|
222 | 213 | | let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
223 | 214 | | let usdnAssetIdString = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" |
---|
224 | 215 | | let usdnWavesLPTokenAssetId = base58'7KZbJrVopwJhkdwbe1eFDBbex4dkY63MxjTNjqXtrzj1' |
---|
225 | 216 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
226 | 217 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
227 | 218 | | if ((i.caller != this)) |
---|
228 | 219 | | then throw("you are not allowed to arb!") |
---|
229 | 220 | | else { |
---|
230 | 221 | | let initialWavesBalance = wavesBalance(this).available |
---|
231 | 222 | | if ((initialWavesBalance == initialWavesBalance)) |
---|
232 | 223 | | then { |
---|
233 | 224 | | let initialAmount = assetBalance(this, usdnAssetId) |
---|
234 | 225 | | if ((initialAmount == initialAmount)) |
---|
235 | 226 | | then { |
---|
236 | 227 | | let buyOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(usdnAssetId, (amount * 1000000))]) |
---|
237 | 228 | | if ((buyOnPuzzle == buyOnPuzzle)) |
---|
238 | 229 | | then { |
---|
239 | 230 | | let wavesTokenBalance = (wavesBalance(this).available - initialWavesBalance) |
---|
240 | 231 | | if ((wavesTokenBalance == wavesTokenBalance)) |
---|
241 | 232 | | then { |
---|
242 | 233 | | let putTheTokenInThePool = invoke(pool, "putOneTkn", [1, false], [AttachedPayment(unit, wavesTokenBalance)]) |
---|
243 | 234 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
244 | 235 | | then { |
---|
245 | 236 | | let lpTokenBalance = assetBalance(this, usdnWavesLPTokenAssetId) |
---|
246 | 237 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
247 | 238 | | then { |
---|
248 | 239 | | let sellPoolToken = invoke(pool, "getOneTkn", [usdnAssetIdString, 1], [AttachedPayment(usdnWavesLPTokenAssetId, lpTokenBalance)]) |
---|
249 | 240 | | if ((sellPoolToken == sellPoolToken)) |
---|
250 | 241 | | then { |
---|
251 | 242 | | let finalAmount = assetBalance(this, usdnAssetId) |
---|
252 | 243 | | if ((finalAmount == finalAmount)) |
---|
253 | 244 | | then if ((initialAmount >= finalAmount)) |
---|
254 | 245 | | then throw("arb not successful!") |
---|
255 | 246 | | else nil |
---|
256 | 247 | | else throw("Strict value is not equal to itself.") |
---|
257 | 248 | | } |
---|
258 | 249 | | else throw("Strict value is not equal to itself.") |
---|
259 | 250 | | } |
---|
260 | 251 | | else throw("Strict value is not equal to itself.") |
---|
261 | 252 | | } |
---|
262 | 253 | | else throw("Strict value is not equal to itself.") |
---|
263 | 254 | | } |
---|
264 | 255 | | else throw("Strict value is not equal to itself.") |
---|
265 | 256 | | } |
---|
266 | 257 | | else throw("Strict value is not equal to itself.") |
---|
267 | 258 | | } |
---|
268 | 259 | | else throw("Strict value is not equal to itself.") |
---|
269 | 260 | | } |
---|
270 | 261 | | else throw("Strict value is not equal to itself.") |
---|
271 | 262 | | } |
---|
272 | 263 | | } |
---|
273 | 264 | | |
---|
274 | 265 | | |
---|
275 | 266 | | |
---|
276 | 267 | | @Callable(i) |
---|
277 | 268 | | func arbWaves2 (path,amount) = { |
---|
278 | 269 | | let poolAddress = "3PPZWgFNRKHLvM51pwS934C8VZ7d2F4Z58g" |
---|
279 | 270 | | let pool = addressFromStringValue(poolAddress) |
---|
280 | 271 | | let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
281 | 272 | | let usdnAssetIdString = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" |
---|
282 | 273 | | let usdnWavesLPTokenAssetId = base58'7KZbJrVopwJhkdwbe1eFDBbex4dkY63MxjTNjqXtrzj1' |
---|
283 | 274 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
284 | 275 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
285 | 276 | | if ((i.caller != this)) |
---|
286 | 277 | | then throw("you are not allowed to arb!") |
---|
287 | 278 | | else { |
---|
288 | 279 | | let initialWavesBalance = wavesBalance(this).available |
---|
289 | 280 | | if ((initialWavesBalance == initialWavesBalance)) |
---|
290 | 281 | | then { |
---|
291 | 282 | | let initialAmount = assetBalance(this, usdnAssetId) |
---|
292 | 283 | | if ((initialAmount == initialAmount)) |
---|
293 | 284 | | then { |
---|
294 | 285 | | let putTheTokenInThePool = invoke(pool, "putOneTkn", [1, false], [AttachedPayment(usdnAssetId, (amount * 1000000))]) |
---|
295 | 286 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
296 | 287 | | then { |
---|
297 | 288 | | let lpTokenBalance = assetBalance(this, usdnWavesLPTokenAssetId) |
---|
298 | 289 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
299 | 290 | | then { |
---|
300 | 291 | | let sellPoolToken = invoke(pool, "getOneTkn", ["WAVES", 1], [AttachedPayment(usdnWavesLPTokenAssetId, lpTokenBalance)]) |
---|
301 | 292 | | if ((sellPoolToken == sellPoolToken)) |
---|
302 | 293 | | then { |
---|
303 | 294 | | let wavesTokenBalance = (wavesBalance(this).available - initialWavesBalance) |
---|
304 | 295 | | if ((wavesTokenBalance == wavesTokenBalance)) |
---|
305 | 296 | | then { |
---|
306 | 297 | | let sellOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(unit, wavesTokenBalance)]) |
---|
307 | 298 | | if ((sellOnPuzzle == sellOnPuzzle)) |
---|
308 | 299 | | then { |
---|
309 | 300 | | let finalAmount = assetBalance(this, usdnAssetId) |
---|
310 | 301 | | if ((finalAmount == finalAmount)) |
---|
311 | 302 | | then if ((initialAmount >= finalAmount)) |
---|
312 | 303 | | then throw("arb not successful!") |
---|
313 | 304 | | else nil |
---|
314 | 305 | | else throw("Strict value is not equal to itself.") |
---|
315 | 306 | | } |
---|
316 | 307 | | else throw("Strict value is not equal to itself.") |
---|
317 | 308 | | } |
---|
318 | 309 | | else throw("Strict value is not equal to itself.") |
---|
319 | 310 | | } |
---|
320 | 311 | | else throw("Strict value is not equal to itself.") |
---|
321 | 312 | | } |
---|
322 | 313 | | else throw("Strict value is not equal to itself.") |
---|
323 | 314 | | } |
---|
324 | 315 | | else throw("Strict value is not equal to itself.") |
---|
325 | 316 | | } |
---|
326 | 317 | | else throw("Strict value is not equal to itself.") |
---|
327 | 318 | | } |
---|
328 | 319 | | else throw("Strict value is not equal to itself.") |
---|
329 | 320 | | } |
---|
330 | 321 | | } |
---|
331 | 322 | | |
---|
332 | 323 | | |
---|
333 | 324 | | |
---|
334 | 325 | | @Callable(i) |
---|
335 | 326 | | func arbUSDC (path,amount) = { |
---|
336 | 327 | | let poolAddress = "3PC3HtupBxBmy4WtZf1Tym1vrxg9MwbZRK1" |
---|
337 | 328 | | let pool = addressFromStringValue(poolAddress) |
---|
338 | 329 | | let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
339 | 330 | | let usdnAssetIdString = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" |
---|
340 | 331 | | let usdcAssetIdString = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" |
---|
341 | 332 | | let usdcAssetId = base58'6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ' |
---|
342 | 333 | | let usdnUsdcLPTokenAssetId = base58'EK6N7S38xbtBT3SxAqoGdDLCiX6rojX6G169CnSyuE5' |
---|
343 | 334 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
344 | 335 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
345 | 336 | | if ((i.caller != this)) |
---|
346 | 337 | | then throw("you are not allowed to arb!") |
---|
347 | 338 | | else { |
---|
348 | 339 | | let initialAmount = assetBalance(this, usdnAssetId) |
---|
349 | 340 | | if ((initialAmount == initialAmount)) |
---|
350 | 341 | | then { |
---|
351 | 342 | | let initialAmountUSDC = assetBalance(this, usdcAssetId) |
---|
352 | 343 | | if ((initialAmountUSDC == initialAmountUSDC)) |
---|
353 | 344 | | then { |
---|
354 | 345 | | let buyOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(usdnAssetId, (amount * 1000000))]) |
---|
355 | 346 | | if ((buyOnPuzzle == buyOnPuzzle)) |
---|
356 | 347 | | then { |
---|
357 | 348 | | let usdcTokenBalance = (assetBalance(this, usdcAssetId) - initialAmountUSDC) |
---|
358 | 349 | | if ((usdcTokenBalance == usdcTokenBalance)) |
---|
359 | 350 | | then { |
---|
360 | 351 | | let putTheTokenInThePool = invoke(pool, "putOneTknV2", [1, false], [AttachedPayment(usdcAssetId, usdcTokenBalance)]) |
---|
361 | 352 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
362 | 353 | | then { |
---|
363 | 354 | | let lpTokenBalance = assetBalance(this, usdnUsdcLPTokenAssetId) |
---|
364 | 355 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
365 | 356 | | then { |
---|
366 | 357 | | let sellPoolToken = invoke(pool, "getOneTknV2", [usdnAssetIdString, 1], [AttachedPayment(usdnUsdcLPTokenAssetId, lpTokenBalance)]) |
---|
367 | 358 | | if ((sellPoolToken == sellPoolToken)) |
---|
368 | 359 | | then { |
---|
369 | 360 | | let finalAmount = assetBalance(this, usdnAssetId) |
---|
370 | 361 | | if ((finalAmount == finalAmount)) |
---|
371 | 362 | | then if ((initialAmount >= finalAmount)) |
---|
372 | 363 | | then throw("arb not successful!") |
---|
373 | 364 | | else nil |
---|
374 | 365 | | else throw("Strict value is not equal to itself.") |
---|
375 | 366 | | } |
---|
376 | 367 | | else throw("Strict value is not equal to itself.") |
---|
377 | 368 | | } |
---|
378 | 369 | | else throw("Strict value is not equal to itself.") |
---|
379 | 370 | | } |
---|
380 | 371 | | else throw("Strict value is not equal to itself.") |
---|
381 | 372 | | } |
---|
382 | 373 | | else throw("Strict value is not equal to itself.") |
---|
383 | 374 | | } |
---|
384 | 375 | | else throw("Strict value is not equal to itself.") |
---|
385 | 376 | | } |
---|
386 | 377 | | else throw("Strict value is not equal to itself.") |
---|
387 | 378 | | } |
---|
388 | 379 | | else throw("Strict value is not equal to itself.") |
---|
389 | 380 | | } |
---|
390 | 381 | | } |
---|
391 | 382 | | |
---|
392 | 383 | | |
---|
393 | 384 | | |
---|
394 | 385 | | @Callable(i) |
---|
395 | 386 | | func arbUSDC2 (path,amount) = { |
---|
396 | 387 | | let poolAddress = "3PC3HtupBxBmy4WtZf1Tym1vrxg9MwbZRK1" |
---|
397 | 388 | | let pool = addressFromStringValue(poolAddress) |
---|
398 | 389 | | let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
399 | 390 | | let usdnAssetIdString = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" |
---|
400 | 391 | | let usdcAssetIdString = "6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ" |
---|
401 | 392 | | let usdcAssetId = base58'6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ' |
---|
402 | 393 | | let usdnUsdcLPTokenAssetId = base58'EK6N7S38xbtBT3SxAqoGdDLCiX6rojX6G169CnSyuE5' |
---|
403 | 394 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
404 | 395 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
405 | 396 | | if ((i.caller != this)) |
---|
406 | 397 | | then throw("you are not allowed to arb!") |
---|
407 | 398 | | else { |
---|
408 | 399 | | let initialAmount = assetBalance(this, usdnAssetId) |
---|
409 | 400 | | if ((initialAmount == initialAmount)) |
---|
410 | 401 | | then { |
---|
411 | 402 | | let initialAmountUSDC = assetBalance(this, usdcAssetId) |
---|
412 | 403 | | if ((initialAmountUSDC == initialAmountUSDC)) |
---|
413 | 404 | | then { |
---|
414 | 405 | | let putTheTokenInThePool = invoke(pool, "putOneTknV2", [1, false], [AttachedPayment(usdnAssetId, (amount * 1000000))]) |
---|
415 | 406 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
416 | 407 | | then { |
---|
417 | 408 | | let lpTokenBalance = assetBalance(this, usdnUsdcLPTokenAssetId) |
---|
418 | 409 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
419 | 410 | | then { |
---|
420 | 411 | | let sellPoolToken = invoke(pool, "getOneTknV2", [usdcAssetIdString, 1], [AttachedPayment(usdnUsdcLPTokenAssetId, lpTokenBalance)]) |
---|
421 | 412 | | if ((sellPoolToken == sellPoolToken)) |
---|
422 | 413 | | then { |
---|
423 | 414 | | let usdcTokenBalance = (assetBalance(this, usdcAssetId) - initialAmountUSDC) |
---|
424 | 415 | | if ((usdcTokenBalance == usdcTokenBalance)) |
---|
425 | 416 | | then { |
---|
426 | 417 | | let sellOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(usdcAssetId, usdcTokenBalance)]) |
---|
427 | 418 | | if ((sellOnPuzzle == sellOnPuzzle)) |
---|
428 | 419 | | then { |
---|
429 | 420 | | let finalAmount = assetBalance(this, usdnAssetId) |
---|
430 | 421 | | if ((finalAmount == finalAmount)) |
---|
431 | 422 | | then if ((initialAmount >= finalAmount)) |
---|
432 | 423 | | then throw("arb not successful!") |
---|
433 | 424 | | else nil |
---|
434 | 425 | | else throw("Strict value is not equal to itself.") |
---|
435 | 426 | | } |
---|
436 | 427 | | else throw("Strict value is not equal to itself.") |
---|
437 | 428 | | } |
---|
438 | 429 | | else throw("Strict value is not equal to itself.") |
---|
439 | 430 | | } |
---|
440 | 431 | | else throw("Strict value is not equal to itself.") |
---|
441 | 432 | | } |
---|
442 | 433 | | else throw("Strict value is not equal to itself.") |
---|
443 | 434 | | } |
---|
444 | 435 | | else throw("Strict value is not equal to itself.") |
---|
445 | 436 | | } |
---|
446 | 437 | | else throw("Strict value is not equal to itself.") |
---|
447 | 438 | | } |
---|
448 | 439 | | else throw("Strict value is not equal to itself.") |
---|
449 | 440 | | } |
---|
450 | 441 | | } |
---|
451 | 442 | | |
---|
452 | 443 | | |
---|
453 | 444 | | |
---|
454 | 445 | | @Callable(i) |
---|
455 | 446 | | func arbUSDT (path,amount) = { |
---|
456 | 447 | | let poolAddress = "3P8KMyAJCPWNcyedqrmymxaeWonvmkhGauz" |
---|
457 | 448 | | let pool = addressFromStringValue(poolAddress) |
---|
458 | 449 | | let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
459 | 450 | | let usdnAssetIdString = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" |
---|
460 | 451 | | let usdtAssetIdString = "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" |
---|
461 | 452 | | let usdtAssetId = base58'34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ' |
---|
462 | 453 | | let usdnUsdtLPTokenAssetId = base58'97zHFp1C3cB7qfvx8Xv5f2rWp9nUSG5UnAamfPcW6txf' |
---|
463 | 454 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
464 | 455 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
465 | 456 | | if ((i.caller != this)) |
---|
466 | 457 | | then throw("you are not allowed to arb!") |
---|
467 | 458 | | else { |
---|
468 | 459 | | let initialAmount = assetBalance(this, usdnAssetId) |
---|
469 | 460 | | if ((initialAmount == initialAmount)) |
---|
470 | 461 | | then { |
---|
471 | 462 | | let initialAmountUSDT = assetBalance(this, usdtAssetId) |
---|
472 | 463 | | if ((initialAmountUSDT == initialAmountUSDT)) |
---|
473 | 464 | | then { |
---|
474 | 465 | | let buyOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(usdnAssetId, (amount * 1000000))]) |
---|
475 | 466 | | if ((buyOnPuzzle == buyOnPuzzle)) |
---|
476 | 467 | | then { |
---|
477 | 468 | | let usdtTokenBalance = (assetBalance(this, usdtAssetId) - initialAmountUSDT) |
---|
478 | 469 | | if ((usdtTokenBalance == usdtTokenBalance)) |
---|
479 | 470 | | then { |
---|
480 | 471 | | let putTheTokenInThePool = invoke(pool, "putOneTknV2", [1, false], [AttachedPayment(usdtAssetId, usdtTokenBalance)]) |
---|
481 | 472 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
482 | 473 | | then { |
---|
483 | 474 | | let lpTokenBalance = assetBalance(this, usdnUsdtLPTokenAssetId) |
---|
484 | 475 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
485 | 476 | | then { |
---|
486 | 477 | | let sellPoolToken = invoke(pool, "getOneTknV2", [usdnAssetIdString, 1], [AttachedPayment(usdnUsdtLPTokenAssetId, lpTokenBalance)]) |
---|
487 | 478 | | if ((sellPoolToken == sellPoolToken)) |
---|
488 | 479 | | then { |
---|
489 | 480 | | let finalAmount = assetBalance(this, usdnAssetId) |
---|
490 | 481 | | if ((finalAmount == finalAmount)) |
---|
491 | 482 | | then if ((initialAmount >= finalAmount)) |
---|
492 | 483 | | then throw("arb not successful!") |
---|
493 | 484 | | else nil |
---|
494 | 485 | | else throw("Strict value is not equal to itself.") |
---|
495 | 486 | | } |
---|
496 | 487 | | else throw("Strict value is not equal to itself.") |
---|
497 | 488 | | } |
---|
498 | 489 | | else throw("Strict value is not equal to itself.") |
---|
499 | 490 | | } |
---|
500 | 491 | | else throw("Strict value is not equal to itself.") |
---|
501 | 492 | | } |
---|
502 | 493 | | else throw("Strict value is not equal to itself.") |
---|
503 | 494 | | } |
---|
504 | 495 | | else throw("Strict value is not equal to itself.") |
---|
505 | 496 | | } |
---|
506 | 497 | | else throw("Strict value is not equal to itself.") |
---|
507 | 498 | | } |
---|
508 | 499 | | else throw("Strict value is not equal to itself.") |
---|
509 | 500 | | } |
---|
510 | 501 | | } |
---|
511 | 502 | | |
---|
512 | 503 | | |
---|
513 | 504 | | |
---|
514 | 505 | | @Callable(i) |
---|
515 | 506 | | func arbUSDT2 (path,amount) = { |
---|
516 | 507 | | let poolAddress = "3P8KMyAJCPWNcyedqrmymxaeWonvmkhGauz" |
---|
517 | 508 | | let pool = addressFromStringValue(poolAddress) |
---|
518 | 509 | | let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
519 | 510 | | let usdnAssetIdString = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" |
---|
520 | 511 | | let usdtAssetIdString = "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ" |
---|
521 | 512 | | let usdtAssetId = base58'34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ' |
---|
522 | 513 | | let usdnUsdtLPTokenAssetId = base58'97zHFp1C3cB7qfvx8Xv5f2rWp9nUSG5UnAamfPcW6txf' |
---|
523 | 514 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
524 | 515 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
525 | 516 | | if ((i.caller != this)) |
---|
526 | 517 | | then throw("you are not allowed to arb!") |
---|
527 | 518 | | else { |
---|
528 | 519 | | let initialAmount = assetBalance(this, usdnAssetId) |
---|
529 | 520 | | if ((initialAmount == initialAmount)) |
---|
530 | 521 | | then { |
---|
531 | 522 | | let initialAmountUSDT = assetBalance(this, usdtAssetId) |
---|
532 | 523 | | if ((initialAmountUSDT == initialAmountUSDT)) |
---|
533 | 524 | | then { |
---|
534 | 525 | | let putTheTokenInThePool = invoke(pool, "putOneTknV2", [1, false], [AttachedPayment(usdnAssetId, (amount * 1000000))]) |
---|
535 | 526 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
536 | 527 | | then { |
---|
537 | 528 | | let lpTokenBalance = assetBalance(this, usdnUsdtLPTokenAssetId) |
---|
538 | 529 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
539 | 530 | | then { |
---|
540 | 531 | | let sellPoolToken = invoke(pool, "getOneTknV2", [usdtAssetIdString, 1], [AttachedPayment(usdnUsdtLPTokenAssetId, lpTokenBalance)]) |
---|
541 | 532 | | if ((sellPoolToken == sellPoolToken)) |
---|
542 | 533 | | then { |
---|
543 | 534 | | let usdtTokenBalance = (assetBalance(this, usdtAssetId) - initialAmountUSDT) |
---|
544 | 535 | | if ((usdtTokenBalance == usdtTokenBalance)) |
---|
545 | 536 | | then { |
---|
546 | 537 | | let sellOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(usdtAssetId, usdtTokenBalance)]) |
---|
547 | 538 | | if ((sellOnPuzzle == sellOnPuzzle)) |
---|
548 | 539 | | then { |
---|
549 | 540 | | let finalAmount = assetBalance(this, usdnAssetId) |
---|
550 | 541 | | if ((finalAmount == finalAmount)) |
---|
551 | 542 | | then if ((initialAmount >= finalAmount)) |
---|
552 | 543 | | then throw("arb not successful!") |
---|
553 | 544 | | else nil |
---|
554 | 545 | | else throw("Strict value is not equal to itself.") |
---|
555 | 546 | | } |
---|
556 | 547 | | else throw("Strict value is not equal to itself.") |
---|
557 | 548 | | } |
---|
558 | 549 | | else throw("Strict value is not equal to itself.") |
---|
559 | 550 | | } |
---|
560 | 551 | | else throw("Strict value is not equal to itself.") |
---|
561 | 552 | | } |
---|
562 | 553 | | else throw("Strict value is not equal to itself.") |
---|
563 | 554 | | } |
---|
564 | 555 | | else throw("Strict value is not equal to itself.") |
---|
565 | 556 | | } |
---|
566 | 557 | | else throw("Strict value is not equal to itself.") |
---|
567 | 558 | | } |
---|
568 | 559 | | else throw("Strict value is not equal to itself.") |
---|
569 | 560 | | } |
---|
570 | 561 | | } |
---|
571 | 562 | | |
---|
572 | 563 | | |
---|
573 | 564 | | |
---|
574 | 565 | | @Callable(i) |
---|
575 | 566 | | func arbTSN (path,amount) = { |
---|
576 | 567 | | let poolAddress = "3PH832eKnw67PFvJfUg9Knz6BHM87QvjMeL" |
---|
577 | 568 | | let pool = addressFromStringValue(poolAddress) |
---|
578 | 569 | | let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
579 | 570 | | let usdnAssetIdString = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" |
---|
580 | 571 | | let tsnAssetId = base58'8t4DPWTwPzpatHA9AkTxWAB47THnYzBsDnoY7fQqbG91' |
---|
581 | 572 | | let usdnTsnLPTokenAssetId = base58'EbwpqrZjrvi7XLowkM5Z2rg7xVdzfg6S5ec9asarpAU9' |
---|
582 | 573 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
583 | 574 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
584 | 575 | | if ((i.caller != this)) |
---|
585 | 576 | | then throw("you are not allowed to arb!") |
---|
586 | 577 | | else { |
---|
587 | 578 | | let initialAmount = assetBalance(this, usdnAssetId) |
---|
588 | 579 | | if ((initialAmount == initialAmount)) |
---|
589 | 580 | | then { |
---|
590 | 581 | | let initialAmountTSN = assetBalance(this, tsnAssetId) |
---|
591 | 582 | | if ((initialAmountTSN == initialAmountTSN)) |
---|
592 | 583 | | then { |
---|
593 | 584 | | let buyOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(usdnAssetId, (amount * 1000000))]) |
---|
594 | 585 | | if ((buyOnPuzzle == buyOnPuzzle)) |
---|
595 | 586 | | then { |
---|
596 | 587 | | let tsnTokenBalance = (assetBalance(this, tsnAssetId) - initialAmountTSN) |
---|
597 | 588 | | if ((tsnTokenBalance == tsnTokenBalance)) |
---|
598 | 589 | | then { |
---|
599 | 590 | | let putTheTokenInThePool = invoke(pool, "putOneTkn", [1, false], [AttachedPayment(tsnAssetId, tsnTokenBalance)]) |
---|
600 | 591 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
601 | 592 | | then { |
---|
602 | 593 | | let lpTokenBalance = assetBalance(this, usdnTsnLPTokenAssetId) |
---|
603 | 594 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
604 | 595 | | then { |
---|
605 | 596 | | let sellPoolToken = invoke(pool, "getOneTkn", [usdnAssetIdString, 1], [AttachedPayment(usdnTsnLPTokenAssetId, lpTokenBalance)]) |
---|
606 | 597 | | if ((sellPoolToken == sellPoolToken)) |
---|
607 | 598 | | then { |
---|
608 | 599 | | let finalAmount = assetBalance(this, usdnAssetId) |
---|
609 | 600 | | if ((finalAmount == finalAmount)) |
---|
610 | 601 | | then if ((initialAmount >= finalAmount)) |
---|
611 | 602 | | then throw("arb not successful!") |
---|
612 | 603 | | else nil |
---|
613 | 604 | | else throw("Strict value is not equal to itself.") |
---|
614 | 605 | | } |
---|
615 | 606 | | else throw("Strict value is not equal to itself.") |
---|
616 | 607 | | } |
---|
617 | 608 | | else throw("Strict value is not equal to itself.") |
---|
618 | 609 | | } |
---|
619 | 610 | | else throw("Strict value is not equal to itself.") |
---|
620 | 611 | | } |
---|
621 | 612 | | else throw("Strict value is not equal to itself.") |
---|
622 | 613 | | } |
---|
623 | 614 | | else throw("Strict value is not equal to itself.") |
---|
624 | 615 | | } |
---|
625 | 616 | | else throw("Strict value is not equal to itself.") |
---|
626 | 617 | | } |
---|
627 | 618 | | else throw("Strict value is not equal to itself.") |
---|
628 | 619 | | } |
---|
629 | 620 | | } |
---|
630 | 621 | | |
---|
631 | 622 | | |
---|
632 | 623 | | |
---|
633 | 624 | | @Callable(i) |
---|
634 | 625 | | func arbTSN2 (path,amount) = { |
---|
635 | 626 | | let poolAddress = "3PH832eKnw67PFvJfUg9Knz6BHM87QvjMeL" |
---|
636 | 627 | | let pool = addressFromStringValue(poolAddress) |
---|
637 | 628 | | let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' |
---|
638 | 629 | | let usdnAssetIdString = "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p" |
---|
639 | 630 | | let tsnAssetId = base58'8t4DPWTwPzpatHA9AkTxWAB47THnYzBsDnoY7fQqbG91' |
---|
640 | 631 | | let tsnAssetIdString = "8t4DPWTwPzpatHA9AkTxWAB47THnYzBsDnoY7fQqbG91" |
---|
641 | 632 | | let usdnTsnLPTokenAssetId = base58'EbwpqrZjrvi7XLowkM5Z2rg7xVdzfg6S5ec9asarpAU9' |
---|
642 | 633 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
643 | 634 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
644 | 635 | | if ((i.caller != this)) |
---|
645 | 636 | | then throw("you are not allowed to arb!") |
---|
646 | 637 | | else { |
---|
647 | 638 | | let initialAmount = assetBalance(this, usdnAssetId) |
---|
648 | 639 | | if ((initialAmount == initialAmount)) |
---|
649 | 640 | | then { |
---|
650 | 641 | | let initialAmountTSN = assetBalance(this, tsnAssetId) |
---|
651 | 642 | | if ((initialAmountTSN == initialAmountTSN)) |
---|
652 | 643 | | then { |
---|
653 | 644 | | let putTheTokenInThePool = invoke(pool, "putOneTkn", [1, false], [AttachedPayment(usdnAssetId, (amount * 1000000))]) |
---|
654 | 645 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
655 | 646 | | then { |
---|
656 | 647 | | let lpTokenBalance = assetBalance(this, usdnTsnLPTokenAssetId) |
---|
657 | 648 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
658 | 649 | | then { |
---|
659 | 650 | | let sellPoolToken = invoke(pool, "getOneTkn", [tsnAssetIdString, 1], [AttachedPayment(usdnTsnLPTokenAssetId, lpTokenBalance)]) |
---|
660 | 651 | | if ((sellPoolToken == sellPoolToken)) |
---|
661 | 652 | | then { |
---|
662 | 653 | | let tsnTokenBalance = (assetBalance(this, tsnAssetId) - initialAmountTSN) |
---|
663 | 654 | | if ((tsnTokenBalance == tsnTokenBalance)) |
---|
664 | 655 | | then { |
---|
665 | 656 | | let sellOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(tsnAssetId, tsnTokenBalance)]) |
---|
666 | 657 | | if ((sellOnPuzzle == sellOnPuzzle)) |
---|
667 | 658 | | then { |
---|
668 | 659 | | let finalAmount = assetBalance(this, usdnAssetId) |
---|
669 | 660 | | if ((finalAmount == finalAmount)) |
---|
670 | 661 | | then if ((initialAmount >= finalAmount)) |
---|
671 | 662 | | then throw("arb not successful!") |
---|
672 | 663 | | else nil |
---|
673 | 664 | | else throw("Strict value is not equal to itself.") |
---|
674 | 665 | | } |
---|
675 | 666 | | else throw("Strict value is not equal to itself.") |
---|
676 | 667 | | } |
---|
677 | 668 | | else throw("Strict value is not equal to itself.") |
---|
678 | 669 | | } |
---|
679 | 670 | | else throw("Strict value is not equal to itself.") |
---|
680 | 671 | | } |
---|
681 | 672 | | else throw("Strict value is not equal to itself.") |
---|
682 | 673 | | } |
---|
683 | 674 | | else throw("Strict value is not equal to itself.") |
---|
684 | 675 | | } |
---|
685 | 676 | | else throw("Strict value is not equal to itself.") |
---|
686 | 677 | | } |
---|
687 | 678 | | else throw("Strict value is not equal to itself.") |
---|
688 | 679 | | } |
---|
689 | 680 | | } |
---|
690 | 681 | | |
---|
691 | 682 | | |
---|
692 | 683 | | |
---|
693 | 684 | | @Callable(i) |
---|
694 | 685 | | func arbPool (firstAsset,secondAsset,poolAddress,lpToken,path,amount) = { |
---|
695 | 686 | | let pool = addressFromStringValue(poolAddress) |
---|
696 | 687 | | let firstAssetId = fromBase58String(firstAsset) |
---|
697 | 688 | | let secondAssetId = fromBase58String(secondAsset) |
---|
698 | 689 | | let lpTokenAssetId = fromBase58String(lpToken) |
---|
699 | 690 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
700 | 691 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
701 | 692 | | if ((i.caller != this)) |
---|
702 | 693 | | then throw("you are not allowed to arb!") |
---|
703 | 694 | | else { |
---|
704 | 695 | | let initialAmount = assetBalance(this, firstAssetId) |
---|
705 | 696 | | if ((initialAmount == initialAmount)) |
---|
706 | 697 | | then { |
---|
707 | 698 | | let initialAmountSecondAsset = assetBalance(this, secondAssetId) |
---|
708 | 699 | | if ((initialAmountSecondAsset == initialAmountSecondAsset)) |
---|
709 | 700 | | then { |
---|
710 | 701 | | let buyOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(firstAssetId, (amount * 1000000))]) |
---|
711 | 702 | | if ((buyOnPuzzle == buyOnPuzzle)) |
---|
712 | 703 | | then { |
---|
713 | 704 | | let secondTokenBalance = (assetBalance(this, secondAssetId) - initialAmountSecondAsset) |
---|
714 | 705 | | if ((secondTokenBalance == secondTokenBalance)) |
---|
715 | 706 | | then { |
---|
716 | 707 | | let putTheTokenInThePool = invoke(pool, "putOneTkn", [1, false], [AttachedPayment(secondAssetId, secondTokenBalance)]) |
---|
717 | 708 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
718 | 709 | | then { |
---|
719 | 710 | | let lpTokenBalance = assetBalance(this, lpTokenAssetId) |
---|
720 | 711 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
721 | 712 | | then { |
---|
722 | 713 | | let sellPoolToken = invoke(pool, "getOneTkn", [firstAsset, 1], [AttachedPayment(lpTokenAssetId, lpTokenBalance)]) |
---|
723 | 714 | | if ((sellPoolToken == sellPoolToken)) |
---|
724 | 715 | | then { |
---|
725 | 716 | | let finalAmount = assetBalance(this, firstAssetId) |
---|
726 | 717 | | if ((finalAmount == finalAmount)) |
---|
727 | 718 | | then if ((initialAmount >= finalAmount)) |
---|
728 | 719 | | then throw("arb not successful!") |
---|
729 | 720 | | else nil |
---|
730 | 721 | | else throw("Strict value is not equal to itself.") |
---|
731 | 722 | | } |
---|
732 | 723 | | else throw("Strict value is not equal to itself.") |
---|
733 | 724 | | } |
---|
734 | 725 | | else throw("Strict value is not equal to itself.") |
---|
735 | 726 | | } |
---|
736 | 727 | | else throw("Strict value is not equal to itself.") |
---|
737 | 728 | | } |
---|
738 | 729 | | else throw("Strict value is not equal to itself.") |
---|
739 | 730 | | } |
---|
740 | 731 | | else throw("Strict value is not equal to itself.") |
---|
741 | 732 | | } |
---|
742 | 733 | | else throw("Strict value is not equal to itself.") |
---|
743 | 734 | | } |
---|
744 | 735 | | else throw("Strict value is not equal to itself.") |
---|
745 | 736 | | } |
---|
746 | 737 | | } |
---|
747 | 738 | | |
---|
748 | 739 | | |
---|
749 | 740 | | |
---|
750 | 741 | | @Callable(i) |
---|
751 | 742 | | func arbPool2 (firstAsset,secondAsset,poolAddress,lpToken,path,amount) = { |
---|
752 | 743 | | let pool = addressFromStringValue(poolAddress) |
---|
753 | 744 | | let firstAssetId = fromBase58String(firstAsset) |
---|
754 | 745 | | let secondAssetId = fromBase58String(secondAsset) |
---|
755 | 746 | | let lpTokenAssetId = fromBase58String(lpToken) |
---|
756 | 747 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
757 | 748 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
758 | 749 | | if ((i.caller != this)) |
---|
759 | 750 | | then throw("you are not allowed to arb!") |
---|
760 | 751 | | else { |
---|
761 | 752 | | let initialAmount = assetBalance(this, firstAssetId) |
---|
762 | 753 | | if ((initialAmount == initialAmount)) |
---|
763 | 754 | | then { |
---|
764 | 755 | | let initialAmountSecondAsset = assetBalance(this, secondAssetId) |
---|
765 | 756 | | if ((initialAmountSecondAsset == initialAmountSecondAsset)) |
---|
766 | 757 | | then { |
---|
767 | 758 | | let putTheTokenInThePool = invoke(pool, "putOneTkn", [1, false], [AttachedPayment(firstAssetId, (amount * 1000000))]) |
---|
768 | 759 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
769 | 760 | | then { |
---|
770 | 761 | | let lpTokenBalance = assetBalance(this, lpTokenAssetId) |
---|
771 | 762 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
772 | 763 | | then { |
---|
773 | 764 | | let sellPoolToken = invoke(pool, "getOneTkn", [secondAsset, 1], [AttachedPayment(lpTokenAssetId, lpTokenBalance)]) |
---|
774 | 765 | | if ((sellPoolToken == sellPoolToken)) |
---|
775 | 766 | | then { |
---|
776 | 767 | | let secondTokenBalance = (assetBalance(this, secondAssetId) - initialAmountSecondAsset) |
---|
777 | 768 | | if ((secondTokenBalance == secondTokenBalance)) |
---|
778 | 769 | | then { |
---|
779 | 770 | | let sellOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(secondAssetId, secondTokenBalance)]) |
---|
780 | 771 | | if ((sellOnPuzzle == sellOnPuzzle)) |
---|
781 | 772 | | then { |
---|
782 | 773 | | let finalAmount = assetBalance(this, firstAssetId) |
---|
783 | 774 | | if ((finalAmount == finalAmount)) |
---|
784 | 775 | | then if ((initialAmount >= finalAmount)) |
---|
785 | 776 | | then throw("arb not successful!") |
---|
786 | 777 | | else nil |
---|
787 | 778 | | else throw("Strict value is not equal to itself.") |
---|
788 | 779 | | } |
---|
789 | 780 | | else throw("Strict value is not equal to itself.") |
---|
790 | 781 | | } |
---|
791 | 782 | | else throw("Strict value is not equal to itself.") |
---|
792 | 783 | | } |
---|
793 | 784 | | else throw("Strict value is not equal to itself.") |
---|
794 | 785 | | } |
---|
795 | 786 | | else throw("Strict value is not equal to itself.") |
---|
796 | 787 | | } |
---|
797 | 788 | | else throw("Strict value is not equal to itself.") |
---|
798 | 789 | | } |
---|
799 | 790 | | else throw("Strict value is not equal to itself.") |
---|
800 | 791 | | } |
---|
801 | 792 | | else throw("Strict value is not equal to itself.") |
---|
802 | 793 | | } |
---|
803 | 794 | | } |
---|
804 | 795 | | |
---|
805 | 796 | | |
---|
806 | 797 | | |
---|
807 | 798 | | @Callable(i) |
---|
808 | 799 | | func arbPoolV2 (firstAsset,secondAsset,poolAddress,lpToken,path,amount) = { |
---|
809 | 800 | | let pool = addressFromStringValue(poolAddress) |
---|
810 | 801 | | let firstAssetId = fromBase58String(firstAsset) |
---|
811 | 802 | | let secondAssetId = fromBase58String(secondAsset) |
---|
812 | 803 | | let lpTokenAssetId = fromBase58String(lpToken) |
---|
813 | 804 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
814 | 805 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
815 | 806 | | if ((i.caller != this)) |
---|
816 | 807 | | then throw("you are not allowed to arb!") |
---|
817 | 808 | | else { |
---|
818 | 809 | | let initialAmount = assetBalance(this, firstAssetId) |
---|
819 | 810 | | if ((initialAmount == initialAmount)) |
---|
820 | 811 | | then { |
---|
821 | 812 | | let initialAmountSecondAsset = assetBalance(this, secondAssetId) |
---|
822 | 813 | | if ((initialAmountSecondAsset == initialAmountSecondAsset)) |
---|
823 | 814 | | then { |
---|
824 | 815 | | let buyOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(firstAssetId, (amount * 1000000))]) |
---|
825 | 816 | | if ((buyOnPuzzle == buyOnPuzzle)) |
---|
826 | 817 | | then { |
---|
827 | 818 | | let secondTokenBalance = (assetBalance(this, secondAssetId) - initialAmountSecondAsset) |
---|
828 | 819 | | if ((secondTokenBalance == secondTokenBalance)) |
---|
829 | 820 | | then { |
---|
830 | 821 | | let putTheTokenInThePool = invoke(pool, "putOneTknV2", [1, false], [AttachedPayment(secondAssetId, secondTokenBalance)]) |
---|
831 | 822 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
832 | 823 | | then { |
---|
833 | 824 | | let lpTokenBalance = assetBalance(this, lpTokenAssetId) |
---|
834 | 825 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
835 | 826 | | then { |
---|
836 | 827 | | let sellPoolToken = invoke(pool, "getOneTknV2", [firstAsset, 1], [AttachedPayment(lpTokenAssetId, lpTokenBalance)]) |
---|
837 | 828 | | if ((sellPoolToken == sellPoolToken)) |
---|
838 | 829 | | then { |
---|
839 | 830 | | let finalAmount = assetBalance(this, firstAssetId) |
---|
840 | 831 | | if ((finalAmount == finalAmount)) |
---|
841 | 832 | | then if ((initialAmount >= finalAmount)) |
---|
842 | 833 | | then throw("arb not successful!") |
---|
843 | 834 | | else nil |
---|
844 | 835 | | else throw("Strict value is not equal to itself.") |
---|
845 | 836 | | } |
---|
846 | 837 | | else throw("Strict value is not equal to itself.") |
---|
847 | 838 | | } |
---|
848 | 839 | | else throw("Strict value is not equal to itself.") |
---|
849 | 840 | | } |
---|
850 | 841 | | else throw("Strict value is not equal to itself.") |
---|
851 | 842 | | } |
---|
852 | 843 | | else throw("Strict value is not equal to itself.") |
---|
853 | 844 | | } |
---|
854 | 845 | | else throw("Strict value is not equal to itself.") |
---|
855 | 846 | | } |
---|
856 | 847 | | else throw("Strict value is not equal to itself.") |
---|
857 | 848 | | } |
---|
858 | 849 | | else throw("Strict value is not equal to itself.") |
---|
859 | 850 | | } |
---|
860 | 851 | | } |
---|
861 | 852 | | |
---|
862 | 853 | | |
---|
863 | 854 | | |
---|
864 | 855 | | @Callable(i) |
---|
865 | 856 | | func arbPool2V2 (firstAsset,secondAsset,poolAddress,lpToken,path,amount) = { |
---|
866 | 857 | | let pool = addressFromStringValue(poolAddress) |
---|
867 | 858 | | let firstAssetId = fromBase58String(firstAsset) |
---|
868 | 859 | | let secondAssetId = fromBase58String(secondAsset) |
---|
869 | 860 | | let lpTokenAssetId = fromBase58String(lpToken) |
---|
870 | 861 | | let puzzlePoolAddress = "3PGFHzVGT4NTigwCKP1NcwoXkodVZwvBuuU" |
---|
871 | 862 | | let puzzlePool = addressFromStringValue(puzzlePoolAddress) |
---|
872 | 863 | | if ((i.caller != this)) |
---|
873 | 864 | | then throw("you are not allowed to arb!") |
---|
874 | 865 | | else { |
---|
875 | 866 | | let initialAmount = assetBalance(this, firstAssetId) |
---|
876 | 867 | | if ((initialAmount == initialAmount)) |
---|
877 | 868 | | then { |
---|
878 | 869 | | let initialAmountSecondAsset = assetBalance(this, secondAssetId) |
---|
879 | 870 | | if ((initialAmountSecondAsset == initialAmountSecondAsset)) |
---|
880 | 871 | | then { |
---|
881 | 872 | | let putTheTokenInThePool = invoke(pool, "putOneTknV2", [1, false], [AttachedPayment(firstAssetId, (amount * 1000000))]) |
---|
882 | 873 | | if ((putTheTokenInThePool == putTheTokenInThePool)) |
---|
883 | 874 | | then { |
---|
884 | 875 | | let lpTokenBalance = assetBalance(this, lpTokenAssetId) |
---|
885 | 876 | | if ((lpTokenBalance == lpTokenBalance)) |
---|
886 | 877 | | then { |
---|
887 | 878 | | let sellPoolToken = invoke(pool, "getOneTknV2", [secondAsset, 1], [AttachedPayment(lpTokenAssetId, lpTokenBalance)]) |
---|
888 | 879 | | if ((sellPoolToken == sellPoolToken)) |
---|
889 | 880 | | then { |
---|
890 | 881 | | let secondTokenBalance = (assetBalance(this, secondAssetId) - initialAmountSecondAsset) |
---|
891 | 882 | | if ((secondTokenBalance == secondTokenBalance)) |
---|
892 | 883 | | then { |
---|
893 | 884 | | let sellOnPuzzle = invoke(puzzlePool, "swap", [path, 1], [AttachedPayment(secondAssetId, secondTokenBalance)]) |
---|
894 | 885 | | if ((sellOnPuzzle == sellOnPuzzle)) |
---|
895 | 886 | | then { |
---|
896 | 887 | | let finalAmount = assetBalance(this, firstAssetId) |
---|
897 | 888 | | if ((finalAmount == finalAmount)) |
---|
898 | 889 | | then if ((initialAmount >= finalAmount)) |
---|
899 | 890 | | then throw("arb not successful!") |
---|
900 | 891 | | else nil |
---|
901 | 892 | | else throw("Strict value is not equal to itself.") |
---|
902 | 893 | | } |
---|
903 | 894 | | else throw("Strict value is not equal to itself.") |
---|
904 | 895 | | } |
---|
905 | 896 | | else throw("Strict value is not equal to itself.") |
---|
906 | 897 | | } |
---|
907 | 898 | | else throw("Strict value is not equal to itself.") |
---|
908 | 899 | | } |
---|
909 | 900 | | else throw("Strict value is not equal to itself.") |
---|
910 | 901 | | } |
---|
911 | 902 | | else throw("Strict value is not equal to itself.") |
---|
912 | 903 | | } |
---|
913 | 904 | | else throw("Strict value is not equal to itself.") |
---|
914 | 905 | | } |
---|
915 | 906 | | else throw("Strict value is not equal to itself.") |
---|
916 | 907 | | } |
---|
917 | 908 | | } |
---|
918 | 909 | | |
---|
919 | 910 | | |
---|
920 | 911 | | |
---|
921 | 912 | | @Callable(i) |
---|
922 | 913 | | func y (data) = if ((i.caller != this)) |
---|
923 | 914 | | then throw("you are not allowed to arb!") |
---|
924 | 915 | | else { |
---|
925 | 916 | | let data_array = split_4C(data, "|") |
---|
926 | 917 | | let t030083064 = getBase1(data_array[0]) |
---|
927 | 918 | | let a = t030083064._1 |
---|
928 | 919 | | let a2 = t030083064._2 |
---|
929 | 920 | | let assetIn = t030083064._3 |
---|
930 | 921 | | let amountIn = t030083064._4 |
---|
931 | 922 | | let t030693107 = getBase2(data_array[1]) |
---|
932 | 923 | | let p1 = t030693107._1 |
---|
933 | 924 | | let t1 = t030693107._2 |
---|
934 | 925 | | let t031123150 = getBase2(data_array[2]) |
---|
935 | 926 | | let p2 = t031123150._1 |
---|
936 | 927 | | let t2 = t031123150._2 |
---|
937 | 928 | | let t031553193 = getBase2(data_array[3]) |
---|
938 | 929 | | let p3 = t031553193._1 |
---|
939 | 930 | | let t3 = t031553193._2 |
---|
940 | 931 | | let idu = if ((size(data_array[4]) > 1)) |
---|
941 | 932 | | then split_4C(data_array[4], "-") |
---|
942 | 933 | | else nil |
---|
943 | 934 | | if (if (if ((size(idu) > 0)) |
---|
944 | 935 | | then (ucheck(fromBase58String(idu[0])) > 0) |
---|
945 | 936 | | else false) |
---|
946 | 937 | | then true |
---|
947 | 938 | | else (1 >= size(data_array[4]))) |
---|
948 | 939 | | then { |
---|
949 | 940 | | let amount_bef_assetIn = getBalance(getAssetBytes(assetIn)) |
---|
950 | 941 | | if ((amount_bef_assetIn == amount_bef_assetIn)) |
---|
951 | 942 | | then { |
---|
952 | 943 | | let ulimit = valueOrElse(getInteger(this, "ulimit"), 100) |
---|
953 | 944 | | let max_amount = if ((size(idu) > 0)) |
---|
954 | 945 | | then fraction(amount_bef_assetIn, ulimit, 100) |
---|
955 | 946 | | else amount_bef_assetIn |
---|
956 | 947 | | let new_amountIn = if ((value(parseInt(amountIn)) > max_amount)) |
---|
957 | 948 | | then max_amount |
---|
958 | 949 | | else value(parseInt(amountIn)) |
---|
959 | 950 | | if ((new_amountIn == new_amountIn)) |
---|
960 | 951 | | then { |
---|
961 | 952 | | let amount_bef_asset1 = getBalance(getAssetBytes(a)) |
---|
962 | 953 | | if ((amount_bef_asset1 == amount_bef_asset1)) |
---|
963 | 954 | | then { |
---|
964 | 955 | | let swap1 = if ((t1 == "W")) |
---|
965 | 956 | | then swap_wx(p1, assetIn, new_amountIn, a) |
---|
966 | 957 | | else if ((t1 == "S")) |
---|
967 | 958 | | then swap_swop(p1, assetIn, new_amountIn) |
---|
968 | 959 | | else swap_puzzle(p1, assetIn, new_amountIn, a) |
---|
969 | 960 | | if ((swap1 == swap1)) |
---|
970 | 961 | | then { |
---|
971 | 962 | | let nb = (getBalance(getAssetBytes(a)) - amount_bef_asset1) |
---|
972 | 963 | | if ((nb == nb)) |
---|
973 | 964 | | then { |
---|
974 | 965 | | let amount_bef_asset2 = getBalance(getAssetBytes(a2)) |
---|
975 | 966 | | if ((amount_bef_asset2 == amount_bef_asset2)) |
---|
976 | 967 | | then { |
---|
977 | 968 | | let swap2 = if ((t2 == "W")) |
---|
978 | 969 | | then swap_wx(p2, a, nb, a2) |
---|
979 | 970 | | else if ((t2 == "S")) |
---|
980 | 971 | | then swap_swop(p2, a, nb) |
---|
981 | 972 | | else swap_puzzle(p2, a, nb, a2) |
---|
982 | 973 | | if ((swap2 == swap2)) |
---|
983 | 974 | | then { |
---|
984 | 975 | | let nb2 = (getBalance(getAssetBytes(a2)) - amount_bef_asset2) |
---|
985 | 976 | | if ((nb2 == nb2)) |
---|
986 | 977 | | then { |
---|
987 | 978 | | let amount_bef_base_asset = getBalance(getAssetBytes(assetIn)) |
---|
988 | 979 | | if ((amount_bef_base_asset == amount_bef_base_asset)) |
---|
989 | 980 | | then { |
---|
990 | 981 | | let swap3 = if ((t3 == "W")) |
---|
991 | 982 | | then swap_wx(p3, a2, nb2, assetIn) |
---|
992 | 983 | | else if ((t3 == "S")) |
---|
993 | 984 | | then swap_swop(p3, a2, nb2) |
---|
994 | 985 | | else swap_puzzle(p3, a2, nb2, assetIn) |
---|
995 | 986 | | if ((swap3 == swap3)) |
---|
996 | 987 | | then { |
---|
997 | 988 | | let nb3 = (getBalance(getAssetBytes(assetIn)) - amount_bef_base_asset) |
---|
998 | 989 | | if ((nb3 == nb3)) |
---|
999 | 990 | | then { |
---|
1000 | 991 | | let treshold = valueOrElse(getInteger(this, "treshold"), 150000) |
---|
1001 | 992 | | if ((nb3 > (new_amountIn + treshold))) |
---|
1002 | 993 | | then nil |
---|
1003 | 994 | | else throw(((((((((("origin amountIn = " + amountIn) + ", new_amountIn = ") + toString(new_amountIn)) + ", newBal_1: ") + toString(nb)) + ", newBal_2: ") + toString(nb2)) + ", newBal_3: ") + toString(nb3))) |
---|
1004 | 995 | | } |
---|
1005 | 996 | | else throw("Strict value is not equal to itself.") |
---|
1006 | 997 | | } |
---|
1007 | 998 | | else throw("Strict value is not equal to itself.") |
---|
1008 | 999 | | } |
---|
1009 | 1000 | | else throw("Strict value is not equal to itself.") |
---|
1010 | 1001 | | } |
---|
1011 | 1002 | | else throw("Strict value is not equal to itself.") |
---|
1012 | 1003 | | } |
---|
1013 | 1004 | | else throw("Strict value is not equal to itself.") |
---|
1014 | 1005 | | } |
---|
1015 | 1006 | | else throw("Strict value is not equal to itself.") |
---|
1016 | 1007 | | } |
---|
1017 | 1008 | | else throw("Strict value is not equal to itself.") |
---|
1018 | 1009 | | } |
---|
1019 | 1010 | | else throw("Strict value is not equal to itself.") |
---|
1020 | 1011 | | } |
---|
1021 | 1012 | | else throw("Strict value is not equal to itself.") |
---|
1022 | 1013 | | } |
---|
1023 | 1014 | | else throw("Strict value is not equal to itself.") |
---|
1024 | 1015 | | } |
---|
1025 | 1016 | | else throw("Strict value is not equal to itself.") |
---|
1026 | 1017 | | } |
---|
1027 | 1018 | | else nil |
---|
1028 | 1019 | | } |
---|
1029 | 1020 | | |
---|
1030 | 1021 | | |
---|
1031 | 1022 | | @Verifier(tx) |
---|
1032 | 1023 | | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) |
---|
1033 | 1024 | | |
---|