BCD

Tezos Contract Explorer
Search Networks Deploy
  • Home
  • /
  • Mainnet
  • /
  • KT1SgGP...8sV6
operations (415)Storage Code Interact Tokens Fork Statistics Details
Latest
​x
72
 
1
parameter (or (contract %get_price nat)
2
              (or (contract %internal_get_price nat) (pair %set_reserves nat nat)));
3
storage (pair (address %dex_contract) (nat %price));
4
code { CAST (pair (or (contract nat) (or (contract nat) (pair nat nat)))
5
                  (pair address nat)) ;
6
       LAMBDA
7
         (pair unit (pair address nat))
8
         (pair (list operation) (pair unit (pair address nat)))
9
         { NIL operation ;
10
           SWAP ;
11
           CDR ;
12
           SELF_ADDRESS ;
13
           SENDER ;
14
           COMPARE ;
15
           EQ ;
16
           IF {} { PUSH int 400 ; FAILWITH } ;
17
           UNIT ;
18
           DIG 2 ;
19
           PAIR 3 } ;
20
       SWAP ;
21
       UNPAIR ;
22
       IF_LEFT
23
         { DIG 2 ;
24
           DROP ;
25
           NIL operation ;
26
           DUP 3 ;
27
           CAR ;
28
           CONTRACT %get_reserves (contract (pair nat nat)) ;
29
           IF_NONE { PUSH int 50 ; FAILWITH } {} ;
30
           PUSH mutez 0 ;
31
           SELF_ADDRESS ;
32
           CONTRACT %set_reserves (pair nat nat) ;
33
           IF_NONE { PUSH int 52 ; FAILWITH } {} ;
34
           TRANSFER_TOKENS ;
35
           CONS ;
36
           SELF %internal_get_price ;
37
           PUSH mutez 0 ;
38
           DIG 3 ;
39
           TRANSFER_TOKENS ;
40
           CONS }
41
         { IF_LEFT
42
             { DUG 2 ;
43
               UNIT ;
44
               PAIR ;
45
               EXEC ;
46
               DUP ;
47
               GET 4 ;
48
               DUG 2 ;
49
               CAR ;
50
               SWAP ;
51
               PUSH mutez 0 ;
52
               DUP 4 ;
53
               CDR ;
54
               TRANSFER_TOKENS ;
55
               CONS }
56
             { DIG 2 ;
57
               DROP ;
58
               DUP ;
59
               DUG 2 ;
60
               CDR ;
61
               PUSH nat 1000000000000 ;
62
               DIG 3 ;
63
               CAR ;
64
               MUL ;
65
               EDIV ;
66
               IF_NONE { PUSH int 138 ; FAILWITH } { CAR } ;
67
               UPDATE 2 ;
68
               NIL operation } } ;
69
       NIL operation ;
70
       SWAP ;
71
       ITER { CONS } ;
72
       PAIR }