| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 10000 |
| 6 | }, |
| 7 | "init": "{ |
| 8 | $asset = var['asset']; |
| 9 | $supply = var['supply']; |
| 10 | $cascading_donations_aa = "2QVJOY3BRRGWP7IOYL64O5BU3WLUJ4TZ"; |
| 11 | $allow_repository = "byteball/ocore"; |
| 12 | }", |
| 13 | "getters": "{ |
| 14 | $is_allowed_tokens = $symbol => { |
| 15 | $allowed_tokens = ["ETH", "MATIC", "WBTC", "USDC", "BNB"]; |
| 16 | |
| 17 | length(filter($allowed_tokens, 20, $t => $t == $symbol)) == 1 |
| 18 | }; |
| 19 | |
| 20 | $asset_to_base = ($asset, $amount) => { |
| 21 | $oracle_address = "F4KHJUCLJKY4JV7M5F754LAJX4EB7M4N"; |
| 22 | $token_registry = "O6H6ZIFI57X3PLTYHOCVYPP5A553CYFQ"; |
| 23 | |
| 24 | if ($asset == 'base') { |
| 25 | $amount_in_base = $amount; |
| 26 | } else { |
| 27 | $symbol = var[$token_registry]['a2s_' || $asset]; |
| 28 | |
| 29 | if ($symbol AND $is_allowed_tokens($symbol)) { |
| 30 | |
| 31 | $current_desc = var[$token_registry]['current_desc_' || $asset]; |
| 32 | |
| 33 | if ($current_desc) { |
| 34 | $decimals = var[$token_registry]['decimals_' || $current_desc] OTHERWISE 0; |
| 35 | } else { |
| 36 | $decimals = 0; |
| 37 | } |
| 38 | |
| 39 | $feed_name = $symbol || "_USD"; |
| 40 | |
| 41 | $rate = data_feed[[oracles=$oracle_address, feed_name=$feed_name, ifnone=false]] / data_feed[[oracles=$oracle_address, feed_name="GBYTE_USD", ifnone=false]]; |
| 42 | |
| 43 | $amount_in_base = floor(($amount / 10 ^ $decimals) * $rate * 1e9); |
| 44 | } else { |
| 45 | $amount_in_base = 0; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | $amount_in_base |
| 50 | }; |
| 51 | }", |
| 52 | "messages": { |
| 53 | "cases": [ |
| 54 | { |
| 55 | "if": "{ trigger.data.define AND !$asset }", |
| 56 | "messages": [ |
| 57 | { |
| 58 | "app": "asset", |
| 59 | "payload": { |
| 60 | "is_private": false, |
| 61 | "is_transferrable": true, |
| 62 | "auto_destroy": false, |
| 63 | "fixed_denominations": false, |
| 64 | "issued_by_definer_only": true, |
| 65 | "cosigned_by_definer": false, |
| 66 | "spender_attested": false |
| 67 | } |
| 68 | }, |
| 69 | { |
| 70 | "app": "state", |
| 71 | "state": "{ |
| 72 | var['asset'] = response_unit; |
| 73 | var['supply'] = 0; |
| 74 | response['asset'] = response_unit; |
| 75 | }" |
| 76 | } |
| 77 | ] |
| 78 | }, |
| 79 | { |
| 80 | "if": "{ $asset AND exists(trigger.data.repo) AND trigger.data.repo == $allow_repository AND is_valid_address(trigger.data.donor) AND trigger.data.amount AND trigger.data.asset AND trigger.address == $cascading_donations_aa }", |
| 81 | "init": "{ |
| 82 | $send_amount = $asset_to_base(trigger.data.asset, trigger.data.amount); |
| 83 | }", |
| 84 | "messages": [ |
| 85 | { |
| 86 | "app": "payment", |
| 87 | "payload": { |
| 88 | "asset": "{ $asset }", |
| 89 | "outputs": [ |
| 90 | { |
| 91 | "address": "{ trigger.data.donor }", |
| 92 | "amount": "{ $send_amount }" |
| 93 | } |
| 94 | ] |
| 95 | } |
| 96 | }, |
| 97 | { |
| 98 | "app": "state", |
| 99 | "state": "{ |
| 100 | var['supply'] += $send_amount; |
| 101 | }" |
| 102 | } |
| 103 | ] |
| 104 | } |
| 105 | ] |
| 106 | } |
| 107 | } |
| 108 | ] |