BCD

Tezos Contract Explorer
Search Networks Deploy
  • Home
  • /
  • Mainnet
  • /
  • QuipuSwap FA2 Factory Old 2
Contract factory
operations (73)Storage Code Interact Tokens Metadata Fork Views Statistics Details
Latest
​x
497
1100
 
1
parameter (or
2
            (or (pair %launchExchange (pair %token address nat) (nat %token_amount))
3
                (pair %setDexFunction
4
                  (lambda %func
5
                    (pair
6
                      (pair
7
                        (or
8
                          (or
9
                            (or
10
                              (pair %divestLiquidity
11
                                (pair (nat %min_tez) (nat %min_tokens))
12
                                (nat %shares))
13
                              (nat %initializeExchange))
14
                            (or (nat %investLiquidity)
15
                                (pair %tezToTokenPayment (nat %min_out)
16
                                                         (address %receiver))))
17
                          (or
18
                            (or
19
                              (pair %tokenToTezPayment
20
                                (pair (nat %amount) (nat %min_out))
21
                                (address %receiver))
22
                              (pair %veto (nat %value) (address %voter)))
23
                            (or
24
                              (pair %vote (pair (key_hash %candidate) (nat %value))
25
                                          (address %voter))
26
                              (address %withdrawProfit))))
27
                        (pair
28
                          (pair
29
                            (pair
30
                              (pair
31
                                (pair (option %current_candidate key_hash)
32
                                      (option %current_delegated key_hash))
33
                                (pair (nat %invariant) (timestamp %last_update_time)))
34
                              (pair
35
                                (pair (timestamp %last_veto)
36
                                      (big_map %ledger address
37
                                                       (pair
38
                                                         (pair (set %allowances address)
39
                                                               (nat %balance))
40
                                                         (nat %frozen_balance))))
41
                                (pair (timestamp %period_finish) (nat %reward))))
42
                            (pair
43
                              (pair (pair (nat %reward_paid) (nat %reward_per_sec))
44
                                    (pair (nat %reward_per_share) (nat %tez_pool)))
45
                              (pair (pair (address %token_address) (nat %token_id))
46
                                    (pair (nat %token_pool) (nat %total_reward)))))
47
                          (pair
48
                            (pair (pair (nat %total_supply) (nat %total_votes))
49
                                  (pair
50
                                    (big_map %user_rewards address
51
                                                           (pair (nat %reward)
52
                                                                 (nat %reward_paid)))
53
                                    (nat %veto)))
54
                            (pair
55
                              (pair (big_map %vetos key_hash timestamp)
56
                                    (big_map %voters address
57
                                                     (pair
58
                                                       (pair
59
                                                         (option %candidate key_hash)
60
                                                         (timestamp %last_veto))
61
                                                       (pair (nat %veto) (nat %vote)))))
62
                              (big_map %votes key_hash nat)))))
63
                      address)
64
                    (pair (list operation)
65
                          (pair
66
                            (pair
67
                              (pair
68
                                (pair
69
                                  (pair (option %current_candidate key_hash)
70
                                        (option %current_delegated key_hash))
71
                                  (pair (nat %invariant) (timestamp %last_update_time)))
72
                                (pair
73
                                  (pair (timestamp %last_veto)
74
                                        (big_map %ledger address
75
                                                         (pair
76
                                                           (pair
77
                                                             (set %allowances address)
78
                                                             (nat %balance))
79
                                                           (nat %frozen_balance))))
80
                                  (pair (timestamp %period_finish) (nat %reward))))
81
                              (pair
82
                                (pair (pair (nat %reward_paid) (nat %reward_per_sec))
83
                                      (pair (nat %reward_per_share) (nat %tez_pool)))
84
                                (pair (pair (address %token_address) (nat %token_id))
85
                                      (pair (nat %token_pool) (nat %total_reward)))))
86
                            (pair
87
                              (pair (pair (nat %total_supply) (nat %total_votes))
88
                                    (pair
89
                                      (big_map %user_rewards address
90
                                                             (pair (nat %reward)
91
                                                                   (nat %reward_paid)))
92
                                      (nat %veto)))
93
                              (pair
94
                                (pair (big_map %vetos key_hash timestamp)
95
                                      (big_map %voters address
96
                                                       (pair
97
                                                         (pair
98
                                                           (option %candidate key_hash)
99
                                                           (timestamp %last_veto))
100
                                                         (pair (nat %veto) (nat %vote)))))
101
                                (big_map %votes key_hash nat))))))
102
                  (nat %index)))
103
            (pair %setTokenFunction
104
              (lambda %func
105
                (pair
106
                  (pair
107
                    (or
108
                      (or
109
                        (pair %iBalance_of
110
                          (list %requests (pair (address %owner) (nat %token_id)))
111
                          (contract %callback (list (pair
112
                                                    (pair %request (address %owner)
113
                                                                   (nat %token_id))
114
                                                    (nat %balance)))))
115
                        (list %iTransfer (pair (address %from_)
116
                                              (list %txs (pair (address %to_)
117
                                                              (pair (nat %token_id)
118
                                                                    (nat %amount)))))))
119
                      (list %iUpdate_operators (or
120
                                                (pair %add_operator (address %owner)
121
                                                                    (pair
122
                                                                      (address %operator)
123
                                                                      (nat %token_id)))
124
                                                (pair %remove_operator (address %owner)
125
                                                                       (pair
126
                                                                         (address %operator)
127
                                                                         (nat %token_id))))))
128
                    (pair
129
                      (pair
130
                        (pair
131
                          (pair
132
                            (pair (option %current_candidate key_hash)
133
                                  (option %current_delegated key_hash))
134
                            (pair (nat %invariant) (timestamp %last_update_time)))
135
                          (pair
136
                            (pair (timestamp %last_veto)
137
                                  (big_map %ledger address
138
                                                   (pair
139
                                                     (pair (set %allowances address)
140
                                                           (nat %balance))
141
                                                     (nat %frozen_balance))))
142
                            (pair (timestamp %period_finish) (nat %reward))))
143
                        (pair
144
                          (pair (pair (nat %reward_paid) (nat %reward_per_sec))
145
                                (pair (nat %reward_per_share) (nat %tez_pool)))
146
                          (pair (pair (address %token_address) (nat %token_id))
147
                                (pair (nat %token_pool) (nat %total_reward)))))
148
                      (pair
149
                        (pair (pair (nat %total_supply) (nat %total_votes))
150
                              (pair
151
                                (big_map %user_rewards address
152
                                                       (pair (nat %reward)
153
                                                             (nat %reward_paid)))
154
                                (nat %veto)))
155
                        (pair
156
                          (pair (big_map %vetos key_hash timestamp)
157
                                (big_map %voters address
158
                                                 (pair
159
                                                   (pair (option %candidate key_hash)
160
                                                         (timestamp %last_veto))
161
                                                   (pair (nat %veto) (nat %vote)))))
162
                          (big_map %votes key_hash nat)))))
163
                  address)
164
                (pair (list operation)
165
                      (pair
166
                        (pair
167
                          (pair
168
                            (pair
169
                              (pair (option %current_candidate key_hash)
170
                                    (option %current_delegated key_hash))
171
                              (pair (nat %invariant) (timestamp %last_update_time)))
172
                            (pair
173
                              (pair (timestamp %last_veto)
174
                                    (big_map %ledger address
175
                                                     (pair
176
                                                       (pair (set %allowances address)
177
                                                             (nat %balance))
178
                                                       (nat %frozen_balance))))
179
                              (pair (timestamp %period_finish) (nat %reward))))
180
                          (pair
181
                            (pair (pair (nat %reward_paid) (nat %reward_per_sec))
182
                                  (pair (nat %reward_per_share) (nat %tez_pool)))
183
                            (pair (pair (address %token_address) (nat %token_id))
184
                                  (pair (nat %token_pool) (nat %total_reward)))))
185
                        (pair
186
                          (pair (pair (nat %total_supply) (nat %total_votes))
187
                                (pair
188
                                  (big_map %user_rewards address
189
                                                         (pair (nat %reward)
190
                                                               (nat %reward_paid)))
191
                                  (nat %veto)))
192
                          (pair
193
                            (pair (big_map %vetos key_hash timestamp)
194
                                  (big_map %voters address
195
                                                   (pair
196
                                                     (pair (option %candidate key_hash)
197
                                                           (timestamp %last_veto))
198
                                                     (pair (nat %veto) (nat %vote)))))
199
                            (big_map %votes key_hash nat))))))
200
              (nat %index)));
201
storage (pair
202
          (pair
203
            (pair
204
              (pair (nat %counter)
205
                    (big_map %dex_lambdas nat
206
                                          (lambda
207
                                            (pair
208
                                              (pair
209
                                                (or
210
                                                  (or
211
                                                    (or
212
                                                      (pair %divestLiquidity
213
                                                        (pair (nat %min_tez)
214
                                                              (nat %min_tokens))
215
                                                        (nat %shares))
216
                                                      (nat %initializeExchange))
217
                                                    (or (nat %investLiquidity)
218
                                                        (pair %tezToTokenPayment
219
                                                          (nat %min_out)
220
                                                          (address %receiver))))
221
                                                  (or
222
                                                    (or
223
                                                      (pair %tokenToTezPayment
224
                                                        (pair (nat %amount)
225
                                                              (nat %min_out))
226
                                                        (address %receiver))
227
                                                      (pair %veto (nat %value)
228
                                                                  (address %voter)))
229
                                                    (or
230
                                                      (pair %vote
231
                                                        (pair (key_hash %candidate)
232
                                                              (nat %value))
233
                                                        (address %voter))
234
                                                      (address %withdrawProfit))))
235
                                                (pair
236
                                                  (pair
237
                                                    (pair
238
                                                      (pair
239
                                                        (pair
240
                                                          (option %current_candidate key_hash)
241
                                                          (option %current_delegated key_hash))
242
                                                        (pair (nat %invariant)
243
                                                              (timestamp %last_update_time)))
244
                                                      (pair
245
                                                        (pair (timestamp %last_veto)
246
                                                              (big_map %ledger address
247
                                                                               (pair
248
                                                                                 (pair
249
                                                                                   (set %allowances address)
250
                                                                                   (nat %balance))
251
                                                                                 (nat %frozen_balance))))
252
                                                        (pair (timestamp %period_finish)
253
                                                              (nat %reward))))
254
                                                    (pair
255
                                                      (pair
256
                                                        (pair (nat %reward_paid)
257
                                                              (nat %reward_per_sec))
258
                                                        (pair (nat %reward_per_share)
259
                                                              (nat %tez_pool)))
260
                                                      (pair
261
                                                        (pair (address %token_address)
262
                                                              (nat %token_id))
263
                                                        (pair (nat %token_pool)
264
                                                              (nat %total_reward)))))
265
                                                  (pair
266
                                                    (pair
267
                                                      (pair (nat %total_supply)
268
                                                            (nat %total_votes))
269
                                                      (pair
270
                                                        (big_map %user_rewards address
271
                                                                               (pair
272
                                                                                 (nat %reward)
273
                                                                                 (nat %reward_paid)))
274
                                                        (nat %veto)))
275
                                                    (pair
276
                                                      (pair
277
                                                        (big_map %vetos key_hash
278
                                                                        timestamp)
279
                                                        (big_map %voters address
280
                                                                         (pair
281
                                                                           (pair
282
                                                                             (option %candidate key_hash)
283
                                                                             (timestamp %last_veto))
284
                                                                           (pair
285
                                                                             (nat %veto)
286
                                                                             (nat %vote)))))
287
                                                      (big_map %votes key_hash nat)))))
288
                                              address)
289
                                            (pair (list operation)
290
                                                  (pair
291
                                                    (pair
292
                                                      (pair
293
                                                        (pair
294
                                                          (pair
295
                                                            (option %current_candidate key_hash)
296
                                                            (option %current_delegated key_hash))
297
                                                          (pair (nat %invariant)
298
                                                                (timestamp %last_update_time)))
299
                                                        (pair
300
                                                          (pair (timestamp %last_veto)
301
                                                                (big_map %ledger address
302
                                                                                 (pair
303
                                                                                   (pair
304
                                                                                     (set %allowances address)
305
                                                                                     (nat %balance))
306
                                                                                   (nat %frozen_balance))))
307
                                                          (pair
308
                                                            (timestamp %period_finish)
309
                                                            (nat %reward))))
310
                                                      (pair
311
                                                        (pair
312
                                                          (pair (nat %reward_paid)
313
                                                                (nat %reward_per_sec))
314
                                                          (pair (nat %reward_per_share)
315
                                                                (nat %tez_pool)))
316
                                                        (pair
317
                                                          (pair (address %token_address)
318
                                                                (nat %token_id))
319
                                                          (pair (nat %token_pool)
320
                                                                (nat %total_reward)))))
321
                                                    (pair
322
                                                      (pair
323
                                                        (pair (nat %total_supply)
324
                                                              (nat %total_votes))
325
                                                        (pair
326
                                                          (big_map %user_rewards address
327
                                                                                 (pair
328
                                                                                   (nat %reward)
329
                                                                                   (nat %reward_paid)))
330
                                                          (nat %veto)))
331
                                                      (pair
332
                                                        (pair
333
                                                          (big_map %vetos key_hash
334
                                                                          timestamp)
335
                                                          (big_map %voters address
336
                                                                           (pair
337
                                                                             (pair
338
                                                                               (option %candidate key_hash)
339
                                                                               (timestamp %last_veto))
340
                                                                             (pair
341
                                                                               (nat %veto)
342
                                                                               (nat %vote)))))
343
                                                        (big_map %votes key_hash nat))))))))
344
              (pair
345
                (big_map %ledger address
346
                                 (pair (pair (set %allowances address) (nat %balance))
347
                                       (nat %frozen_balance)))
348
                (big_map %metadata string bytes)))
349
            (pair
350
              (pair
351
                (big_map %token_lambdas nat
352
                                        (lambda
353
                                          (pair
354
                                            (pair
355
                                              (or
356
                                                (or
357
                                                  (pair %iBalance_of
358
                                                    (list %requests (pair
359
                                                                     (address %owner)
360
                                                                     (nat %token_id)))
361
                                                    (contract %callback (list (pair
362
                                                                              (pair %request
363
                                                                                (address %owner)
364
                                                                                (nat %token_id))
365
                                                                              (nat %balance)))))
366
                                                  (list %iTransfer (pair (address %from_)
367
                                                                        (list %txs (pair
368
                                                                                    (address %to_)
369
                                                                                    (pair
370
                                                                                      (nat %token_id)
371
                                                                                      (nat %amount)))))))
372
                                                (list %iUpdate_operators (or
373
                                                                          (pair %add_operator
374
                                                                            (address %owner)
375
                                                                            (pair
376
                                                                              (address %operator)
377
                                                                              (nat %token_id)))
378
                                                                          (pair %remove_operator
379
                                                                            (address %owner)
380
                                                                            (pair
381
                                                                              (address %operator)
382
                                                                              (nat %token_id))))))
383
                                              (pair
384
                                                (pair
385
                                                  (pair
386
                                                    (pair
387
                                                      (pair
388
                                                        (option %current_candidate key_hash)
389
                                                        (option %current_delegated key_hash))
390
                                                      (pair (nat %invariant)
391
                                                            (timestamp %last_update_time)))
392
                                                    (pair
393
                                                      (pair (timestamp %last_veto)
394
                                                            (big_map %ledger address
395
                                                                             (pair
396
                                                                               (pair
397
                                                                                 (set %allowances address)
398
                                                                                 (nat %balance))
399
                                                                               (nat %frozen_balance))))
400
                                                      (pair (timestamp %period_finish)
401
                                                            (nat %reward))))
402
                                                  (pair
403
                                                    (pair
404
                                                      (pair (nat %reward_paid)
405
                                                            (nat %reward_per_sec))
406
                                                      (pair (nat %reward_per_share)
407
                                                            (nat %tez_pool)))
408
                                                    (pair
409
                                                      (pair (address %token_address)
410
                                                            (nat %token_id))
411
                                                      (pair (nat %token_pool)
412
                                                            (nat %total_reward)))))
413
                                                (pair
414
                                                  (pair
415
                                                    (pair (nat %total_supply)
416
                                                          (nat %total_votes))
417
                                                    (pair
418
                                                      (big_map %user_rewards address
419
                                                                             (pair
420
                                                                               (nat %reward)
421
                                                                               (nat %reward_paid)))
422
                                                      (nat %veto)))
423
                                                  (pair
424
                                                    (pair
425
                                                      (big_map %vetos key_hash timestamp)
426
                                                      (big_map %voters address
427
                                                                       (pair
428
                                                                         (pair
429
                                                                           (option %candidate key_hash)
430
                                                                           (timestamp %last_veto))
431
                                                                         (pair
432
                                                                           (nat %veto)
433
                                                                           (nat %vote)))))
434
                                                    (big_map %votes key_hash nat)))))
435
                                            address)
436
                                          (pair (list operation)
437
                                                (pair
438
                                                  (pair
439
                                                    (pair
440
                                                      (pair
441
                                                        (pair
442
                                                          (option %current_candidate key_hash)
443
                                                          (option %current_delegated key_hash))
444
                                                        (pair (nat %invariant)
445
                                                              (timestamp %last_update_time)))
446
                                                      (pair
447
                                                        (pair (timestamp %last_veto)
448
                                                              (big_map %ledger address
449
                                                                               (pair
450
                                                                                 (pair
451
                                                                                   (set %allowances address)
452
                                                                                   (nat %balance))
453
                                                                                 (nat %frozen_balance))))
454
                                                        (pair (timestamp %period_finish)
455
                                                              (nat %reward))))
456
                                                    (pair
457
                                                      (pair
458
                                                        (pair (nat %reward_paid)
459
                                                              (nat %reward_per_sec))
460
                                                        (pair (nat %reward_per_share)
461
                                                              (nat %tez_pool)))
462
                                                      (pair
463
                                                        (pair (address %token_address)
464
                                                              (nat %token_id))
465
                                                        (pair (nat %token_pool)
466
                                                              (nat %total_reward)))))
467
                                                  (pair
468
                                                    (pair
469
                                                      (pair (nat %total_supply)
470
                                                            (nat %total_votes))
471
                                                      (pair
472
                                                        (big_map %user_rewards address
473
                                                                               (pair
474
                                                                                 (nat %reward)
475
                                                                                 (nat %reward_paid)))
476
                                                        (nat %veto)))
477
                                                    (pair
478
                                                      (pair
479
                                                        (big_map %vetos key_hash
480
                                                                        timestamp)
481
                                                        (big_map %voters address
482
                                                                         (pair
483
                                                                           (pair
484
                                                                             (option %candidate key_hash)
485
                                                                             (timestamp %last_veto))
486
                                                                           (pair
487
                                                                             (nat %veto)
488
                                                                             (nat %vote)))))
489
                                                      (big_map %votes key_hash nat)))))))
490
                (big_map %token_list nat (pair address nat)))
491
              (pair (big_map %token_to_exchange (pair address nat) address)
492
                    (big_map %user_rewards address
493
                                           (pair (nat %reward) (nat %reward_paid))))))
494
          (pair
495
            (pair (big_map %vetos key_hash timestamp)
496
                  (big_map %voters address
497
                                   (pair
498
                                     (pair (option %candidate key_hash)
499
                                           (timestamp %last_veto))
500
                                     (pair (nat %veto) (nat %vote)))))
501
            (big_map %votes key_hash nat)));
502
code { DUP ;
503
       CDR ;
504
       SWAP ;
505
       CAR ;
506
       IF_LEFT
507
         { IF_LEFT
508
             { DUP ;
509
               DUG 2 ;
510
               CDR ;
511
               PAIR ;
512
               SWAP ;
513
               CAR ;
514
               SELF ;
515
               ADDRESS ;
516
               PAIR ;
517
               CDR ;
518
               SWAP ;
519
               DUP ;
520
               CDR ;
521
               SWAP ;
522
               CAR ;
523
               SWAP ;
524
               DUP ;
525
               DUG 2 ;
526
               CAR ;
527
               CDR ;
528
               CDR ;
529
               CAR ;
530
               DIG 3 ;
531
               DUP ;
532
               DUG 4 ;
533
               GET ;
534
               IF_NONE
535
                 {}
536
                 { DROP ; PUSH string "Factory/exchange-launched" ; FAILWITH } ;
537
               PUSH nat 1 ;
538
               SWAP ;
539
               DUP ;
540
               DUG 2 ;
541
               COMPARE ;
542
               LT ;
543
               PUSH mutez 1 ;
544
               AMOUNT ;
545
               COMPARE ;
546
               LT ;
547
               OR ;
548
               IF { PUSH string "Dex/not-allowed" ; FAILWITH } {} ;
549
               SWAP ;
550
               DUP ;
551
               DUG 2 ;
552
               CDR ;
553
               DIG 2 ;
554
               DUP ;
555
               DUG 3 ;
556
               CAR ;
557
               CDR ;
558
               CDR ;
559
               DIG 3 ;
560
               DUP ;
561
               DUG 4 ;
562
               CAR ;
563
               CDR ;
564
               CAR ;
565
               CDR ;
566
               DIG 5 ;
567
               DUP ;
568
               DUG 6 ;
569
               DIG 5 ;
570
               DUP ;
571
               DUG 6 ;
572
               CAR ;
573
               CAR ;
574
               CAR ;
575
               CAR ;
576
               SWAP ;
577
               SOME ;
578
               SWAP ;
579
               UPDATE ;
580
               DIG 4 ;
581
               DUP ;
582
               DUG 5 ;
583
               CAR ;
584
               CDR ;
585
               CAR ;
586
               CAR ;
587
               PAIR ;
588
               PAIR ;
589
               DIG 3 ;
590
               CAR ;
591
               CAR ;
592
               PAIR ;
593
               PAIR ;
594
               DUP ;
595
               CDR ;
596
               SWAP ;
597
               DUP ;
598
               DUG 2 ;
599
               CAR ;
600
               CDR ;
601
               DIG 2 ;
602
               DUP ;
603
               DUG 3 ;
604
               CAR ;
605
               CAR ;
606
               CDR ;
607
               DIG 3 ;
608
               DUP ;
609
               DUG 4 ;
610
               CAR ;
611
               CAR ;
612
               CAR ;
613
               CDR ;
614
               PUSH nat 1 ;
615
               DIG 5 ;
616
               CAR ;
617
               CAR ;
618
               CAR ;
619
               CAR ;
620
               ADD ;
621
               PAIR ;
622
               PAIR ;
623
               PAIR ;
624
               PAIR ;
625
               DUP ;
626
               CDR ;
627
               SWAP ;
628
               DUP ;
629
               DUG 2 ;
630
               CAR ;
631
               CDR ;
632
               DIG 2 ;
633
               DUP ;
634
               DUG 3 ;
635
               CAR ;
636
               CAR ;
637
               CDR ;
638
               CDR ;
639
               DIG 3 ;
640
               DUP ;
641
               DUG 4 ;
642
               CAR ;
643
               CAR ;
644
               CDR ;
645
               CAR ;
646
               PUSH nat 0 ;
647
               PUSH mutez 1 ;
648
               AMOUNT ;
649
               EDIV ;
650
               IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ;
651
               CAR ;
652
               EMPTY_SET address ;
653
               PAIR ;
654
               PAIR ;
655
               SOME ;
656
               SENDER ;
657
               UPDATE ;
658
               PAIR ;
659
               DIG 3 ;
660
               CAR ;
661
               CAR ;
662
               CAR ;
663
               PAIR ;
664
               PAIR ;
665
               PAIR ;
666
               DUP ;
667
               CDR ;
668
               CDR ;
669
               SWAP ;
670
               DUP ;
671
               DUG 2 ;
672
               CDR ;
673
               CAR ;
674
               CDR ;
675
               DIG 2 ;
676
               DUP ;
677
               DUG 3 ;
678
               CDR ;
679
               CAR ;
680
               CAR ;
681
               PAIR ;
682
               PAIR ;
683
               PUSH nat 0 ;
684
               DIG 2 ;
685
               DUP ;
686
               DUG 3 ;
687
               CAR ;
688
               CDR ;
689
               CDR ;
690
               CDR ;
691
               PAIR ;
692
               PUSH nat 0 ;
693
               PUSH mutez 1 ;
694
               AMOUNT ;
695
               EDIV ;
696
               IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ;
697
               CAR ;
698
               PAIR ;
699
               PAIR ;
700
               PAIR ;
701
               PUSH nat 0 ;
702
               DIG 3 ;
703
               DUP ;
704
               DUG 4 ;
705
               PAIR ;
706
               DIG 4 ;
707
               DUP ;
708
               DUG 5 ;
709
               PAIR ;
710
               PUSH mutez 1 ;
711
               AMOUNT ;
712
               EDIV ;
713
               IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ;
714
               CAR ;
715
               PUSH nat 0 ;
716
               PAIR ;
717
               PUSH nat 0 ;
718
               PUSH nat 0 ;
719
               PAIR ;
720
               PAIR ;
721
               PAIR ;
722
               PUSH nat 0 ;
723
               NOW ;
724
               PAIR ;
725
               DIG 3 ;
726
               DUP ;
727
               DUG 4 ;
728
               CAR ;
729
               CAR ;
730
               CDR ;
731
               CAR ;
732
               NOW ;
733
               PAIR ;
734
               PAIR ;
735
               NOW ;
736
               DIG 5 ;
737
               DUP ;
738
               DUG 6 ;
739
               PUSH mutez 1 ;
740
               AMOUNT ;
741
               EDIV ;
742
               IF_NONE { PUSH string "DIV by 0" ; FAILWITH } {} ;
743
               CAR ;
744
               MUL ;
745
               PAIR ;
746
               NONE key_hash ;
747
               NONE key_hash ;
748
               PAIR ;
749
               PAIR ;
750
               PAIR ;
751
               PAIR ;
752
               PAIR ;
753
               SWAP ;
754
               DUP ;
755
               DUG 2 ;
756
               CAR ;
757
               CDR ;
758
               CAR ;
759
               CAR ;
760
               SWAP ;
761
               DUP ;
762
               DUG 2 ;
763
               PAIR ;
764
               DIG 2 ;
765
               DUP ;
766
               DUG 3 ;
767
               CAR ;
768
               CAR ;
769
               CDR ;
770
               CDR ;
771
               DIG 3 ;
772
               DUP ;
773
               DUG 4 ;
774
               CAR ;
775
               CAR ;
776
               CAR ;
777
               CDR ;
778
               PAIR ;
779
               PAIR ;
780
               AMOUNT ;
781
               NONE key_hash ;
782
               PAIR ;
783
               PAIR ;
784
               { { DUP ; CAR ; DIP { CDR } } ; { DUP ; CAR ; DIP { CDR } } } ;
785
               CREATE_CONTRACT { parameter (or
786
                                             (or
787
                                               (or
788
                                                 (pair %balance_of
789
                                                   (list %requests (pair (address %owner)
790
                                                                        (nat %token_id)))
791
                                                   (contract %callback (list (pair
792
                                                                             (pair %request
793
                                                                               (address %owner)
794
                                                                               (nat %token_id))
795
                                                                             (nat %balance)))))
796
                                                 (unit %default))
797
                                               (or
798
                                                 (contract %get_reserves (pair nat nat))
799
                                                 (list %transfer (pair (address %from_)
800
                                                                      (list %txs (pair
801
                                                                                  (address %to_)
802
                                                                                  (pair
803
                                                                                    (nat %token_id)
804
                                                                                    (nat %amount))))))))
805
                                             (or
806
                                               (list %update_operators (or
807
                                                                        (pair %add_operator
808
                                                                          (address %owner)
809
                                                                          (pair
810
                                                                            (address %operator)
811
                                                                            (nat %token_id)))
812
                                                                        (pair %remove_operator
813
                                                                          (address %owner)
814
                                                                          (pair
815
                                                                            (address %operator)
816
                                                                            (nat %token_id)))))
817
                                               (or %use
818
                                                 (or
819
                                                   (or
820
                                                     (pair %divestLiquidity
821
                                                       (pair (nat %min_tez)
822
                                                             (nat %min_tokens))
823
                                                       (nat %shares))
824
                                                     (nat %initializeExchange))
825
                                                   (or (nat %investLiquidity)
826
                                                       (pair %tezToTokenPayment
827
                                                         (nat %min_out)
828
                                                         (address %receiver))))
829
                                                 (or
830
                                                   (or
831
                                                     (pair %tokenToTezPayment
832
                                                       (pair (nat %amount)
833
                                                             (nat %min_out))
834
                                                       (address %receiver))
835
                                                     (pair %veto (nat %value)
836
                                                                 (address %voter)))
837
                                                   (or
838
                                                     (pair %vote
839
                                                       (pair (key_hash %candidate)
840
                                                             (nat %value))
841
                                                       (address %voter))
842
                                                     (address %withdrawProfit)))))) ;
843
                                 storage (pair
844
                                           (pair
845
                                             (big_map %dex_lambdas nat
846
                                                                   (lambda
847
                                                                     (pair
848
                                                                       (pair
849
                                                                         (or
850
                                                                           (or
851
                                                                             (or
852
                                                                               (pair %divestLiquidity
853
                                                                                 (pair
854
                                                                                   (nat %min_tez)
855
                                                                                   (nat %min_tokens))
856
                                                                                 (nat %shares))
857
                                                                               (nat %initializeExchange))
858
                                                                             (or
859
                                                                               (nat %investLiquidity)
860
                                                                               (pair %tezToTokenPayment
861
                                                                                 (nat %min_out)
862
                                                                                 (address %receiver))))
863
                                                                           (or
864
                                                                             (or
865
                                                                               (pair %tokenToTezPayment
866
                                                                                 (pair
867
                                                                                   (nat %amount)
868
                                                                                   (nat %min_out))
869
                                                                                 (address %receiver))
870
                                                                               (pair %veto
871
                                                                                 (nat %value)
872
                                                                                 (address %voter)))
873
                                                                             (or
874
                                                                               (pair %vote
875
                                                                                 (pair
876
                                                                                   (key_hash %candidate)
877
                                                                                   (nat %value))
878
                                                                                 (address %voter))
879
                                                                               (address %withdrawProfit))))
880
                                                                         (pair
881
                                                                           (pair
882
                                                                             (pair
883
                                                                               (pair
884
                                                                                 (pair
885
                                                                                   (option %current_candidate key_hash)
886
                                                                                   (option %current_delegated key_hash))
887
                                                                                 (pair
888
                                                                                   (nat %invariant)
889
                                                                                   (timestamp %last_update_time)))
890
                                                                               (pair
891
                                                                                 (pair
892
                                                                                   (timestamp %last_veto)
893
                                                                                   (big_map %ledger
894
                                                                                     address
895
                                                                                     (pair
896
                                                                                       (pair
897
                                                                                         (set %allowances address)
898
                                                                                         (nat %balance))
899
                                                                                       (nat %frozen_balance))))
900
                                                                                 (pair
901
                                                                                   (timestamp %period_finish)
902
                                                                                   (nat %reward))))
903
                                                                             (pair
904
                                                                               (pair
905
                                                                                 (pair
906
                                                                                   (nat %reward_paid)
907
                                                                                   (nat %reward_per_sec))
908
                                                                                 (pair
909
                                                                                   (nat %reward_per_share)
910
                                                                                   (nat %tez_pool)))
911
                                                                               (pair
912
                                                                                 (pair
913
                                                                                   (address %token_address)
914
                                                                                   (nat %token_id))
915
                                                                                 (pair
916
                                                                                   (nat %token_pool)
917
                                                                                   (nat %total_reward)))))
918
                                                                           (pair
919
                                                                             (pair
920
                                                                               (pair
921
                                                                                 (nat %total_supply)
922
                                                                                 (nat %total_votes))
923
                                                                               (pair
924
                                                                                 (big_map %user_rewards
925
                                                                                   address
926
                                                                                   (pair
927
                                                                                     (nat %reward)
928
                                                                                     (nat %reward_paid)))
929
                                                                                 (nat %veto)))
930
                                                                             (pair
931
                                                                               (pair
932
                                                                                 (big_map %vetos
933
                                                                                   key_hash
934
                                                                                   timestamp)
935
                                                                                 (big_map %voters
936
                                                                                   address
937
                                                                                   (pair
938
                                                                                     (pair
939
                                                                                       (option %candidate key_hash)
940
                                                                                       (timestamp %last_veto))
941
                                                                                     (pair
942
                                                                                       (nat %veto)
943
                                                                                       (nat %vote)))))
944
                                                                               (big_map %votes
945
                                                                                 key_hash
946
                                                                                 nat)))))
947
                                                                       address)
948
                                                                     (pair
949
                                                                       (list operation)
950
                                                                       (pair
951
                                                                         (pair
952
                                                                           (pair
953
                                                                             (pair
954
                                                                               (pair
955
                                                                                 (option %current_candidate key_hash)
956
                                                                                 (option %current_delegated key_hash))
957
                                                                               (pair
958
                                                                                 (nat %invariant)
959
                                                                                 (timestamp %last_update_time)))
960
                                                                             (pair
961
                                                                               (pair
962
                                                                                 (timestamp %last_veto)
963
                                                                                 (big_map %ledger
964
                                                                                   address
965
                                                                                   (pair
966
                                                                                     (pair
967
                                                                                       (set %allowances address)
968
                                                                                       (nat %balance))
969
                                                                                     (nat %frozen_balance))))
970
                                                                               (pair
971
                                                                                 (timestamp %period_finish)
972
                                                                                 (nat %reward))))
973
                                                                           (pair
974
                                                                             (pair
975
                                                                               (pair
976
                                                                                 (nat %reward_paid)
977
                                                                                 (nat %reward_per_sec))
978
                                                                               (pair
979
                                                                                 (nat %reward_per_share)
980
                                                                                 (nat %tez_pool)))
981
                                                                             (pair
982
                                                                               (pair
983
                                                                                 (address %token_address)
984
                                                                                 (nat %token_id))
985
                                                                               (pair
986
                                                                                 (nat %token_pool)
987
                                                                                 (nat %total_reward)))))
988
                                                                         (pair
989
                                                                           (pair
990
                                                                             (pair
991
                                                                               (nat %total_supply)
992
                                                                               (nat %total_votes))
993
                                                                             (pair
994
                                                                               (big_map %user_rewards
995
                                                                                 address
996
                                                                                 (pair
997
                                                                                   (nat %reward)
998
                                                                                   (nat %reward_paid)))
999
                                                                               (nat %veto)))
1000
                                                                           (pair
1001
                                                                             (pair
1002
                                                                               (big_map %vetos
1003
                                                                                 key_hash
1004
                                                                                 timestamp)
1005
                                                                               (big_map %voters
1006
                                                                                 address
1007
                                                                                 (pair
1008
                                                                                   (pair
1009
                                                                                     (option %candidate key_hash)
1010
                                                                                     (timestamp %last_veto))
1011
                                                                                   (pair
1012
                                                                                     (nat %veto)
1013
                                                                                     (nat %vote)))))
1014
                                                                             (big_map %votes
1015
                                                                               key_hash
1016
                                                                               nat)))))))
1017
                                             (big_map %metadata string bytes))
1018
                                           (pair
1019
                                             (pair %storage
1020
                                               (pair
1021
                                                 (pair
1022
                                                   (pair
1023
                                                     (pair
1024
                                                       (option %current_candidate key_hash)
1025
                                                       (option %current_delegated key_hash))
1026
                                                     (pair (nat %invariant)
1027
                                                           (timestamp %last_update_time)))
1028
                                                   (pair
1029
                                                     (pair (timestamp %last_veto)
1030
                                                           (big_map %ledger address
1031
                                                                            (pair
1032
                                                                              (pair
1033
                                                                                (set %allowances address)
1034
                                                                                (nat %balance))
1035
                                                                              (nat %frozen_balance))))
1036
                                                     (pair (timestamp %period_finish)
1037
                                                           (nat %reward))))
1038
                                                 (pair
1039
                                                   (pair
1040
                                                     (pair (nat %reward_paid)
1041
                                                           (nat %reward_per_sec))
1042
                                                     (pair (nat %reward_per_share)
1043
                                                           (nat %tez_pool)))
1044
                                                   (pair
1045
                                                     (pair (address %token_address)
1046
                                                           (nat %token_id))
1047
                                                     (pair (nat %token_pool)
1048
                                                           (nat %total_reward)))))
1049
                                               (pair
1050
                                                 (pair
1051
                                                   (pair (nat %total_supply)
1052
                                                         (nat %total_votes))
1053
                                                   (pair
1054
                                                     (big_map %user_rewards address
1055
                                                                            (pair
1056
                                                                              (nat %reward)
1057
                                                                              (nat %reward_paid)))
1058
                                                     (nat %veto)))
1059
                                                 (pair
1060
                                                   (pair
1061
                                                     (big_map %vetos key_hash timestamp)
1062
                                                     (big_map %voters address
1063
                                                                      (pair
1064
                                                                        (pair
1065
                                                                          (option %candidate key_hash)
1066
                                                                          (timestamp %last_veto))
1067
                                                                        (pair
1068
                                                                          (nat %veto)
1069
                                                                          (nat %vote)))))
1070
                                                   (big_map %votes key_hash nat))))
1071
                                             (big_map %token_lambdas nat
1072
                                                                     (lambda
1073
                                                                       (pair
1074
                                                                         (pair
1075
                                                                           (or
1076
                                                                             (or
1077
                                                                               (pair %iBalance_of
1078
                                                                                 (list %requests (pair
1079
                                                                                                  (address %owner)
1080
                                                                                                  (nat %token_id)))
1081
                                                                                 (contract %callback (list (pair
1082
                                                                                                           (pair %request
1083
                                                                                                             (address %owner)
1084
                                                                                                             (nat %token_id))
1085
                                                                                                           (nat %balance)))))
1086
                                                                               (list %iTransfer (pair
1087
                                                                                                 (address %from_)
1088
                                                                                                 (list %txs (pair
1089
                                                                                                             (address %to_)
1090
                                                                                                             (pair
1091
                                                                                                               (nat %token_id)
1092
                                                                                                               (nat %amount)))))))
1093
                                                                             (list %iUpdate_operators (or
1094
                                                                                                       (pair %add_operator
1095
                                                                                                         (address %owner)
1096
                                                                                                         (pair
1097
                                                                                                           (address %operator)
1098
                                                                                                           (nat %token_id)))
1099
                                                                                                       (pair %remove_operator
1100
                                                                                                         (address %owner)
1101
                                                                                                         (pair
1102
                                                                                                           (address %operator)
1103
                                                                                                           (nat %token_id))))))
1104
                                                                           (pair
1105
                                                                             (pair
1106
                                                                               (pair
1107
                                                                                 (pair
1108
                                                                                   (pair
1109
                                                                                     (option %current_candidate key_hash)
1110
                                                                                     (option %current_delegated key_hash))
1111
                                                                                   (pair
1112
                                                                                     (nat %invariant)
1113
                                                                                     (timestamp %last_update_time)))
1114
                                                                                 (pair
1115
                                                                                   (pair
1116
                                                                                     (timestamp %last_veto)
1117
                                                                                     (big_map %ledger
1118
                                                                                       address
1119
                                                                                       (pair
1120
                                                                                         (pair
1121
                                                                                           (set %allowances address)
1122
                                                                                           (nat %balance))
1123
                                                                                         (nat %frozen_balance))))
1124
                                                                                   (pair
1125
                                                                                     (timestamp %period_finish)
1126
                                                                                     (nat %reward))))
1127
                                                                               (pair
1128
                                                                                 (pair
1129
                                                                                   (pair
1130
                                                                                     (nat %reward_paid)
1131
                                                                                     (nat %reward_per_sec))
1132
                                                                                   (pair
1133
                                                                                     (nat %reward_per_share)
1134
                                                                                     (nat %tez_pool)))
1135
                                                                                 (pair
1136
                                                                                   (pair
1137
                                                                                     (address %token_address)
1138
                                                                                     (nat %token_id))
1139
                                                                                   (pair
1140
                                                                                     (nat %token_pool)
1141
                                                                                     (nat %total_reward)))))
1142
                                                                             (pair
1143
                                                                               (pair
1144
                                                                                 (pair
1145
                                                                                   (nat %total_supply)
1146
                                                                                   (nat %total_votes))
1147
                                                                                 (pair
1148
                                                                                   (big_map %user_rewards
1149
                                                                                     address
1150
                                                                                     (pair
1151
                                                                                       (nat %reward)
1152
                                                                                       (nat %reward_paid)))
1153
                                                                                   (nat %veto)))
1154
                                                                               (pair
1155
                                                                                 (pair
1156
                                                                                   (big_map %vetos
1157
                                                                                     key_hash
1158
                                                                                     timestamp)
1159
                                                                                   (big_map %voters
1160
                                                                                     address
1161
                                                                                     (pair
1162
                                                                                       (pair
1163
                                                                                         (option %candidate key_hash)
1164
                                                                                         (timestamp %last_veto))
1165
                                                                                       (pair
1166
                                                                                         (nat %veto)
1167
                                                                                         (nat %vote)))))
1168
                                                                                 (big_map %votes
1169
                                                                                   key_hash
1170
                                                                                   nat)))))
1171
                                                                         address)
1172
                                                                       (pair
1173
                                                                         (list operation)
1174
                                                                         (pair
1175
                                                                           (pair
1176
                                                                             (pair
1177
                                                                               (pair
1178
                                                                                 (pair
1179
                                                                                   (option %current_candidate key_hash)
1180
                                                                                   (option %current_delegated key_hash))
1181
                                                                                 (pair
1182
                                                                                   (nat %invariant)
1183
                                                                                   (timestamp %last_update_time)))
1184
                                                                               (pair
1185
                                                                                 (pair
1186
                                                                                   (timestamp %last_veto)
1187
                                                                                   (big_map %ledger
1188
                                                                                     address
1189
                                                                                     (pair
1190
                                                                                       (pair
1191
                                                                                         (set %allowances address)
1192
                                                                                         (nat %balance))
1193
                                                                                       (nat %frozen_balance))))
1194
                                                                                 (pair
1195
                                                                                   (timestamp %period_finish)
1196
                                                                                   (nat %reward))))
1197
                                                                             (pair
1198
                                                                               (pair
1199
                                                                                 (pair
1200
                                                                                   (nat %reward_paid)
1201
                                                                                   (nat %reward_per_sec))
1202
                                                                                 (pair
1203
                                                                                   (nat %reward_per_share)
1204
                                                                                   (nat %tez_pool)))
1205
                                                                               (pair
1206
                                                                                 (pair
1207
                                                                                   (address %token_address)
1208
                                                                                   (nat %token_id))
1209
                                                                                 (pair
1210
                                                                                   (nat %token_pool)
1211
                                                                                   (nat %total_reward)))))
1212
                                                                           (pair
1213
                                                                             (pair
1214
                                                                               (pair
1215
                                                                                 (nat %total_supply)
1216
                                                                                 (nat %total_votes))
1217
                                                                               (pair
1218
                                                                                 (big_map %user_rewards
1219
                                                                                   address
1220
                                                                                   (pair
1221
                                                                                     (nat %reward)
1222
                                                                                     (nat %reward_paid)))
1223
                                                                                 (nat %veto)))
1224
                                                                             (pair
1225
                                                                               (pair
1226
                                                                                 (big_map %vetos
1227
                                                                                   key_hash
1228
                                                                                   timestamp)
1229
                                                                                 (big_map %voters
1230
                                                                                   address
1231
                                                                                   (pair
1232
                                                                                     (pair
1233
                                                                                       (option %candidate key_hash)
1234
                                                                                       (timestamp %last_veto))
1235
                                                                                     (pair
1236
                                                                                       (nat %veto)
1237
                                                                                       (nat %vote)))))
1238
                                                                               (big_map %votes
1239
                                                                                 key_hash
1240
                                                                                 nat))))))))) ;
1241
                                 code { DUP ;
1242
                                        CDR ;
1243
                                        SWAP ;
1244
                                        CAR ;
1245
                                        SELF ;
1246
                                        ADDRESS ;
1247
                                        SWAP ;
1248
                                        IF_LEFT
1249
                                          { IF_LEFT
1250
                                              { IF_LEFT
1251
                                                  { DIG 2 ;
1252
                                                    PUSH nat 2 ;
1253
                                                    PAIR ;
1254
                                                    DUG 2 ;
1255
                                                    LEFT (list (pair address
1256
                                                                    (list (pair address
1257
                                                                               (pair nat
1258
                                                                                     nat))))) ;
1259
                                                    LEFT (list (or
1260
                                                                (pair address
1261
                                                                      (pair address nat))
1262
                                                                (pair address
1263
                                                                      (pair address nat)))) ;
1264
                                                    DIG 2 ;
1265
                                                    DUP ;
1266
                                                    CDR ;
1267
                                                    SWAP ;
1268
                                                    CAR ;
1269
                                                    SWAP ;
1270
                                                    DUP ;
1271
                                                    DUG 2 ;
1272
                                                    CDR ;
1273
                                                    CDR ;
1274
                                                    SWAP ;
1275
                                                    GET ;
1276
                                                    IF_NONE
1277
                                                      { SWAP ;
1278
                                                        DROP ;
1279
                                                        SWAP ;
1280
                                                        DROP ;
1281
                                                        PUSH string "Dex/function-not-set" ;
1282
                                                        FAILWITH }
1283
                                                      { DIG 3 ;
1284
                                                        DIG 2 ;
1285
                                                        DUP ;
1286
                                                        DUG 3 ;
1287
                                                        CDR ;
1288
                                                        CAR ;
1289
                                                        DIG 4 ;
1290
                                                        PAIR ;
1291
                                                        PAIR ;
1292
                                                        EXEC } ;
1293
                                                    SWAP ;
1294
                                                    DUP ;
1295
                                                    DUG 2 ;
1296
                                                    CDR ;
1297
                                                    CDR ;
1298
                                                    SWAP ;
1299
                                                    DUP ;
1300
                                                    DUG 2 ;
1301
                                                    CDR ;
1302
                                                    PAIR ;
1303
                                                    DIG 2 ;
1304
                                                    CAR ;
1305
                                                    PAIR ;
1306
                                                    SWAP ;
1307
                                                    CAR ;
1308
                                                    PAIR }
1309
                                                  { DROP 2 ;
1310
                                                    DUP ;
1311
                                                    CAR ;
1312
                                                    CAR ;
1313
                                                    PUSH nat 8 ;
1314
                                                    GET ;
1315
                                                    IF_NONE
1316
                                                      { PUSH string "Dex/function-not-set" ;
1317
                                                        FAILWITH }
1318
                                                      { SELF ;
1319
                                                        ADDRESS ;
1320
                                                        DIG 2 ;
1321
                                                        DUP ;
1322
                                                        DUG 3 ;
1323
                                                        CDR ;
1324
                                                        CAR ;
1325
                                                        PUSH nat 0 ;
1326
                                                        RIGHT (pair (pair nat nat) nat) ;
1327
                                                        LEFT (or nat (pair nat address)) ;
1328
                                                        LEFT (or
1329
                                                               (or
1330
                                                                 (pair (pair nat nat)
1331
                                                                       address)
1332
                                                                 (pair nat address))
1333
                                                               (or
1334
                                                                 (pair
1335
                                                                   (pair key_hash nat)
1336
                                                                   address)
1337
                                                                 address)) ;
1338
                                                        PAIR ;
1339
                                                        PAIR ;
1340
                                                        EXEC } ;
1341
                                                    SWAP ;
1342
                                                    DUP ;
1343
                                                    DUG 2 ;
1344
                                                    CDR ;
1345
                                                    CDR ;
1346
                                                    SWAP ;
1347
                                                    DUP ;
1348
                                                    DUG 2 ;
1349
                                                    CDR ;
1350
                                                    PAIR ;
1351
                                                    DIG 2 ;
1352
                                                    CAR ;
1353
                                                    PAIR ;
1354
                                                    SWAP ;
1355
                                                    CAR ;
1356
                                                    PAIR } }
1357
                                              { IF_LEFT
1358
                                                  { SWAP ;
1359
                                                    DROP ;
1360
                                                    SWAP ;
1361
                                                    DUP ;
1362
                                                    DUG 2 ;
1363
                                                    NIL operation ;
1364
                                                    DIG 2 ;
1365
                                                    PUSH mutez 0 ;
1366
                                                    DIG 4 ;
1367
                                                    DUP ;
1368
                                                    DUG 5 ;
1369
                                                    CDR ;
1370
                                                    CAR ;
1371
                                                    CAR ;
1372
                                                    CDR ;
1373
                                                    CDR ;
1374
                                                    CDR ;
1375
                                                    CAR ;
1376
                                                    DIG 5 ;
1377
                                                    CDR ;
1378
                                                    CAR ;
1379
                                                    CAR ;
1380
                                                    CDR ;
1381
                                                    CAR ;
1382
                                                    CDR ;
1383
                                                    CDR ;
1384
                                                    PAIR ;
1385
                                                    TRANSFER_TOKENS ;
1386
                                                    CONS ;
1387
                                                    PAIR }
1388
                                                  { DIG 2 ;
1389
                                                    PUSH nat 0 ;
1390
                                                    PAIR ;
1391
                                                    DUG 2 ;
1392
                                                    RIGHT (pair
1393
                                                            (list (pair address nat))
1394
                                                            (contract (list (pair
1395
                                                                            (pair
1396
                                                                              address
1397
                                                                              nat)
1398
                                                                            nat)))) ;
1399
                                                    LEFT (list (or
1400
                                                                (pair address
1401
                                                                      (pair address nat))
1402
                                                                (pair address
1403
                                                                      (pair address nat)))) ;
1404
                                                    DIG 2 ;
1405
                                                    DUP ;
1406
                                                    CDR ;
1407
                                                    SWAP ;
1408
                                                    CAR ;
1409
                                                    SWAP ;
1410
                                                    DUP ;
1411
                                                    DUG 2 ;
1412
                                                    CDR ;
1413
                                                    CDR ;
1414
                                                    SWAP ;
1415
                                                    GET ;
1416
                                                    IF_NONE
1417
                                                      { SWAP ;
1418
                                                        DROP ;
1419
                                                        SWAP ;
1420
                                                        DROP ;
1421
                                                        PUSH string "Dex/function-not-set" ;
1422
                                                        FAILWITH }
1423
                                                      { DIG 3 ;
1424
                                                        DIG 2 ;
1425
                                                        DUP ;
1426
                                                        DUG 3 ;
1427
                                                        CDR ;
1428
                                                        CAR ;
1429
                                                        DIG 4 ;
1430
                                                        PAIR ;
1431
                                                        PAIR ;
1432
                                                        EXEC } ;
1433
                                                    SWAP ;
1434
                                                    DUP ;
1435
                                                    DUG 2 ;
1436
                                                    CDR ;
1437
                                                    CDR ;
1438
                                                    SWAP ;
1439
                                                    DUP ;
1440
                                                    DUG 2 ;
1441
                                                    CDR ;
1442
                                                    PAIR ;
1443
                                                    DIG 2 ;
1444
                                                    CAR ;
1445
                                                    PAIR ;
1446
                                                    SWAP ;
1447
                                                    CAR ;
1448
                                                    PAIR } } }
1449
                                          { IF_LEFT
1450
                                              { DIG 2 ;
1451
                                                PUSH nat 1 ;
1452
                                                PAIR ;
1453
                                                DUG 2 ;
1454
                                                RIGHT (or
1455
                                                        (pair (list (pair address nat))
1456
                                                              (contract (list (pair
1457
                                                                              (pair
1458
                                                                                address
1459
                                                                                nat)
1460
                                                                              nat))))
1461
                                                        (list (pair address
1462
                                                                   (list (pair address
1463
                                                                              (pair nat
1464
                                                                                    nat)))))) ;
1465
                                                DIG 2 ;
1466
                                                DUP ;
1467
                                                CDR ;
1468
                                                SWAP ;
1469
                                                CAR ;
1470
                                                SWAP ;
1471
                                                DUP ;
1472
                                                DUG 2 ;
1473
                                                CDR ;
1474
                                                CDR ;
1475
                                                SWAP ;
1476
                                                GET ;
1477
                                                IF_NONE
1478
                                                  { SWAP ;
1479
                                                    DROP ;
1480
                                                    SWAP ;
1481
                                                    DROP ;
1482
                                                    PUSH string "Dex/function-not-set" ;
1483
                                                    FAILWITH }
1484
                                                  { DIG 3 ;
1485
                                                    DIG 2 ;
1486
                                                    DUP ;
1487
                                                    DUG 3 ;
1488
                                                    CDR ;
1489
                                                    CAR ;
1490
                                                    DIG 4 ;
1491
                                                    PAIR ;
1492
                                                    PAIR ;
1493
                                                    EXEC } ;
1494
                                                SWAP ;
1495
                                                DUP ;
1496
                                                DUG 2 ;
1497
                                                CDR ;
1498
                                                CDR ;
1499
                                                SWAP ;
1500
                                                DUP ;
1501
                                                DUG 2 ;
1502
                                                CDR ;
1503
                                                PAIR ;
1504
                                                DIG 2 ;
1505
                                                CAR ;
1506
                                                PAIR ;
1507
                                                SWAP ;
1508
                                                CAR ;
1509
                                                PAIR }
1510
                                              { DIG 2 ;
1511
                                                DUP ;
1512
                                                DUG 3 ;
1513
                                                CAR ;
1514
                                                CAR ;
1515
                                                SWAP ;
1516
                                                DUP ;
1517
                                                DUG 2 ;
1518
                                                IF_LEFT
1519
                                                  { IF_LEFT
1520
                                                      { IF_LEFT
1521
                                                          { DROP ; PUSH nat 5 }
1522
                                                          { DROP ; PUSH nat 0 } }
1523
                                                      { IF_LEFT
1524
                                                          { DROP ; PUSH nat 4 }
1525
                                                          { DROP ; PUSH nat 1 } } }
1526
                                                  { IF_LEFT
1527
                                                      { IF_LEFT
1528
                                                          { DROP ; PUSH nat 2 }
1529
                                                          { DROP ; PUSH nat 7 } }
1530
                                                      { IF_LEFT
1531
                                                          { DROP ; PUSH nat 6 }
1532
                                                          { DROP ; PUSH nat 3 } } } ;
1533
                                                GET ;
1534
                                                IF_NONE
1535
                                                  { DROP 2 ;
1536
                                                    PUSH string "Dex/function-not-set" ;
1537
                                                    FAILWITH }
1538
                                                  { DIG 2 ;
1539
                                                    DIG 3 ;
1540
                                                    DUP ;
1541
                                                    DUG 4 ;
1542
                                                    CDR ;
1543
                                                    CAR ;
1544
                                                    DIG 3 ;
1545
                                                    PAIR ;
1546
                                                    PAIR ;
1547
                                                    EXEC } ;
1548
                                                SWAP ;
1549
                                                DUP ;
1550
                                                DUG 2 ;
1551
                                                CDR ;
1552
                                                CDR ;
1553
                                                SWAP ;
1554
                                                DUP ;
1555
                                                DUG 2 ;
1556
                                                CDR ;
1557
                                                PAIR ;
1558
                                                DIG 2 ;
1559
                                                CAR ;
1560
                                                PAIR ;
1561
                                                SWAP ;
1562
                                                CAR ;
1563
                                                PAIR } } } } ;
1564
               PAIR ;
1565
               DIG 2 ;
1566
               DUP ;
1567
               DUG 3 ;
1568
               CDR ;
1569
               DIG 3 ;
1570
               DUP ;
1571
               DUG 4 ;
1572
               CAR ;
1573
               CDR ;
1574
               DIG 4 ;
1575
               DUP ;
1576
               DUG 5 ;
1577
               CAR ;
1578
               CAR ;
1579
               CDR ;
1580
               CDR ;
1581
               DIG 5 ;
1582
               DUP ;
1583
               DUG 6 ;
1584
               CAR ;
1585
               CAR ;
1586
               CDR ;
1587
               CAR ;
1588
               NONE (pair (pair (set address) nat) nat) ;
1589
               SENDER ;
1590
               UPDATE ;
1591
               PAIR ;
1592
               DIG 5 ;
1593
               CAR ;
1594
               CAR ;
1595
               CAR ;
1596
               PAIR ;
1597
               PAIR ;
1598
               PAIR ;
1599
               DUP ;
1600
               CDR ;
1601
               SWAP ;
1602
               DUP ;
1603
               DUG 2 ;
1604
               CAR ;
1605
               CDR ;
1606
               CDR ;
1607
               CDR ;
1608
               DIG 2 ;
1609
               DUP ;
1610
               DUG 3 ;
1611
               CAR ;
1612
               CDR ;
1613
               CDR ;
1614
               CAR ;
1615
               DIG 4 ;
1616
               DUP ;
1617
               DUG 5 ;
1618
               CDR ;
1619
               DIG 8 ;
1620
               DUP ;
1621
               DUG 9 ;
1622
               SWAP ;
1623
               SOME ;
1624
               SWAP ;
1625
               UPDATE ;
1626
               PAIR ;
1627
               DIG 2 ;
1628
               DUP ;
1629
               DUG 3 ;
1630
               CAR ;
1631
               CDR ;
1632
               CAR ;
1633
               PAIR ;
1634
               DIG 2 ;
1635
               CAR ;
1636
               CAR ;
1637
               PAIR ;
1638
               PAIR ;
1639
               NIL operation ;
1640
               DIG 5 ;
1641
               CAR ;
1642
               CONTRACT %transfer (list (pair (address %from_)
1643
                                             (list %txs (pair (address %to_)
1644
                                                             (pair (nat %token_id)
1645
                                                                   (nat %amount)))))) ;
1646
               IF_NONE { PUSH string "Dex/not-token" ; FAILWITH } {} ;
1647
               PUSH mutez 0 ;
1648
               DIG 5 ;
1649
               DIG 6 ;
1650
               PAIR ;
1651
               DIG 5 ;
1652
               DUP ;
1653
               DUG 6 ;
1654
               CDR ;
1655
               SENDER ;
1656
               DIG 2 ;
1657
               DUP ;
1658
               CDR ;
1659
               SWAP ;
1660
               CAR ;
1661
               NIL (pair address (list (pair address (pair nat nat)))) ;
1662
               NIL (pair address (pair nat nat)) ;
1663
               DIG 2 ;
1664
               DIG 3 ;
1665
               CAR ;
1666
               CDR ;
1667
               CDR ;
1668
               CAR ;
1669
               CDR ;
1670
               PAIR ;
1671
               DIG 4 ;
1672
               PAIR ;
1673
               CONS ;
1674
               DIG 2 ;
1675
               PAIR ;
1676
               CONS ;
1677
               TRANSFER_TOKENS ;
1678
               CONS ;
1679
               DIG 2 ;
1680
               CAR ;
1681
               CONS ;
1682
               PAIR }
1683
             { PUSH nat 8 ;
1684
               SWAP ;
1685
               DUP ;
1686
               DUG 2 ;
1687
               CDR ;
1688
               COMPARE ;
1689
               GT ;
1690
               IF
1691
                 { DROP 2 ; PUSH string "Factory/wrong-index" ; FAILWITH }
1692
                 { DUP ;
1693
                   DUG 2 ;
1694
                   CAR ;
1695
                   DIG 2 ;
1696
                   CDR ;
1697
                   DIG 2 ;
1698
                   DUP ;
1699
                   DUG 3 ;
1700
                   CAR ;
1701
                   CAR ;
1702
                   CAR ;
1703
                   CDR ;
1704
                   SWAP ;
1705
                   DUP ;
1706
                   DUG 2 ;
1707
                   GET ;
1708
                   IF_NONE
1709
                     { DIG 2 ;
1710
                       DUP ;
1711
                       DUG 3 ;
1712
                       CDR ;
1713
                       DIG 3 ;
1714
                       DUP ;
1715
                       DUG 4 ;
1716
                       CAR ;
1717
                       CDR ;
1718
                       DIG 4 ;
1719
                       DUP ;
1720
                       DUG 5 ;
1721
                       CAR ;
1722
                       CAR ;
1723
                       CDR ;
1724
                       DIG 5 ;
1725
                       DUP ;
1726
                       DUG 6 ;
1727
                       CAR ;
1728
                       CAR ;
1729
                       CAR ;
1730
                       CDR ;
1731
                       DIG 5 ;
1732
                       DIG 5 ;
1733
                       SWAP ;
1734
                       SOME ;
1735
                       SWAP ;
1736
                       UPDATE ;
1737
                       DIG 4 ;
1738
                       CAR ;
1739
                       CAR ;
1740
                       CAR ;
1741
                       CAR ;
1742
                       PAIR ;
1743
                       PAIR ;
1744
                       PAIR ;
1745
                       PAIR }
1746
                     { DROP 3 ; PUSH string "Factory/function-set" ; FAILWITH } } ;
1747
               NIL operation ;
1748
               PAIR } }
1749
         { PUSH nat 2 ;
1750
           SWAP ;
1751
           DUP ;
1752
           DUG 2 ;
1753
           CDR ;
1754
           COMPARE ;
1755
           GT ;
1756
           IF
1757
             { DROP 2 ; PUSH string "Factory/wrong-index" ; FAILWITH }
1758
             { DUP ;
1759
               DUG 2 ;
1760
               CAR ;
1761
               DIG 2 ;
1762
               CDR ;
1763
               DIG 2 ;
1764
               DUP ;
1765
               DUG 3 ;
1766
               CAR ;
1767
               CDR ;
1768
               CAR ;
1769
               CAR ;
1770
               SWAP ;
1771
               DUP ;
1772
               DUG 2 ;
1773
               GET ;
1774
               IF_NONE
1775
                 { DIG 2 ;
1776
                   DUP ;
1777
                   DUG 3 ;
1778
                   CDR ;
1779
                   DIG 3 ;
1780
                   DUP ;
1781
                   DUG 4 ;
1782
                   CAR ;
1783
                   CDR ;
1784
                   CDR ;
1785
                   DIG 4 ;
1786
                   DUP ;
1787
                   DUG 5 ;
1788
                   CAR ;
1789
                   CDR ;
1790
                   CAR ;
1791
                   CDR ;
1792
                   DIG 5 ;
1793
                   DUP ;
1794
                   DUG 6 ;
1795
                   CAR ;
1796
                   CDR ;
1797
                   CAR ;
1798
                   CAR ;
1799
                   DIG 5 ;
1800
                   DIG 5 ;
1801
                   SWAP ;
1802
                   SOME ;
1803
                   SWAP ;
1804
                   UPDATE ;
1805
                   PAIR ;
1806
                   PAIR ;
1807
                   DIG 2 ;
1808
                   CAR ;
1809
                   CAR ;
1810
                   PAIR ;
1811
                   PAIR }
1812
                 { DROP 3 ; PUSH string "Factory/function-set" ; FAILWITH } } ;
1813
           NIL operation ;
1814
           PAIR } }