| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "getters": "{ |
| 5 | $pow2 = $x => $x*$x; |
| 6 | |
| 7 | |
| 8 | $get_reserve_price = () => { |
| 9 | $oracle = "PVQHK2I4B7J5WWYMAA7JTEHH463CSWSL"; |
| 10 | $feed_name = "IUSD_BBD_selling"; |
| 11 | $unit = data_feed[[oracles=$oracle, feed_name=$feed_name, what="unit", ifnone=false]]; |
| 12 | if (!$unit) |
| 13 | bounce('No data feed with IUSD_BBD_selling'); |
| 14 | $payload = unit[$unit].messages[[.app="data_feed"]].payload; |
| 15 | $iusd_bbd = $payload.IUSD_BBD_selling; |
| 16 | $bbd_usd = $payload.BBD_USD_selling; |
| 17 | if (!$bbd_usd) |
| 18 | bounce('Missing BBD_USD_selling in the unit'); |
| 19 | $dec_iusd_bbd = $payload.decimals_iusd_bbd; |
| 20 | if (!$dec_iusd_bbd) |
| 21 | bounce('Missing decimals_iusd_bbd in the unit'); |
| 22 | $dec_bbd_usd = $payload.decimals_bbd_usd; |
| 23 | if (!$dec_bbd_usd) |
| 24 | bounce('Missing decimals_bbd_usd in the unit'); |
| 25 | return ($iusd_bbd / (10 ^ $dec_iusd_bbd) * $bbd_usd / (10 ^ $dec_bbd_usd)) / $pow2($pow2(10)); |
| 26 | }; |
| 27 | }", |
| 28 | "messages": [ |
| 29 | { |
| 30 | "app": "state", |
| 31 | "state": "{ |
| 32 | bounce('lib only'); |
| 33 | }" |
| 34 | } |
| 35 | ] |
| 36 | } |
| 37 | ] |