BCD

Tezos Contract Explorer
Search Networks Deploy
  • Home
  • /
  • Mainnet
  • /
  • KT1CdMT...tjzk
operations (487)Storage Code Interact Tokens Fork Views Statistics Details
Latest
​x
49
 
1
{ parameter (or (unit %default) (contract %get_price nat)) ;
2
  storage (pair (string %base_symbol) (pair (address %oracle) (string %quote_symbol))) ;
3
  code { UNPAIR ;
4
         IF_LEFT
5
           { DROP ;
6
             NIL operation ;
7
             SENDER ;
8
             CONTRACT unit ;
9
             IF_NONE { PUSH int 244 ; FAILWITH } {} ;
10
             AMOUNT ;
11
             UNIT ;
12
             TRANSFER_TOKENS ;
13
             CONS }
14
           { AMOUNT ;
15
             PUSH mutez 0 ;
16
             COMPARE ;
17
             EQ ;
18
             IF {} { AMOUNT ; FAILWITH } ;
19
             NIL operation ;
20
             SWAP ;
21
             PUSH mutez 0 ;
22
             SELF_ADDRESS ;
23
             UNIT ;
24
             VIEW "view_price" nat ;
25
             IF_NONE { PUSH int 502 ; FAILWITH } {} ;
26
             TRANSFER_TOKENS ;
27
             CONS } ;
28
         PAIR } ;
29
  view "view_price" unit nat
30
        { CDR ;
31
          DUP ;
32
          GET 3 ;
33
          SWAP ;
34
          DUP ;
35
          DUG 2 ;
36
          GET 4 ;
37
          VIEW "get_price" nat ;
38
          IF_NONE { PUSH int 502 ; FAILWITH } {} ;
39
          PUSH nat 1000000 ;
40
          DIG 2 ;
41
          DUP ;
42
          GET 3 ;
43
          SWAP ;
44
          CAR ;
45
          VIEW "get_price" nat ;
46
          IF_NONE { PUSH int 502 ; FAILWITH } {} ;
47
          MUL ;
48
          EDIV ;
49
          IF_NONE { PUSH int 271 ; FAILWITH } { CAR } } }