BCD

Tezos Contract Explorer
Search Networks Deploy
  • Home
  • /
  • Mainnet
  • /
  • KT1Vo6A...WxJ5
operations (156K)Storage Code Interact Tokens Fork Views Statistics Details
Latest
​x
25
 
1
{ parameter (list (pair (string %asset_code) (nat %average_price))) ;
2
  storage (pair
3
            (big_map %asset_map string
4
                                (pair (timestamp %last_updated) (nat %average_price)))
5
            (address %data_source)) ;
6
  code { UNPAIR ;
7
         DUP 2 ;
8
         GET 2 ;
9
         SENDER ;
10
         { COMPARE ;
11
           NEQ ;
12
           IF
13
             { PUSH string "price_feed.only the data source can update prices" ;
14
               FAILWITH }
15
             {} } ;
16
         DIP { DUP ; GET 1 } ;
17
         ITER { UNPAIR ; SWAP ; NOW ; PAIR ; SOME ; SWAP ; UPDATE } ;
18
         UPDATE 1 ;
19
         NIL operation ;
20
         PAIR } ;
21
  view "getPrice" string (pair timestamp nat)
22
        { UNPAIR ;
23
          DIP { GET 1 } ;
24
          GET ;
25
          IF_NONE { PUSH string "price_feed.no such asset to retrieve" ; FAILWITH } {} } }