| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 11000 |
| 6 | }, |
| 7 | "init": "{ |
| 8 | $oracle = "F4KHJUCLJKY4JV7M5F754LAJX4EB7M4N"; |
| 9 | $feed_name = "BBD"; |
| 10 | $decimals = 8; |
| 11 | $rate = data_feed[[oracles=$oracle, feed_name=$feed_name, ifnone=0.49486499]]; |
| 12 | }", |
| 13 | "messages": { |
| 14 | "cases": [ |
| 15 | { |
| 16 | "if": "{trigger.data.define}", |
| 17 | "messages": [ |
| 18 | { |
| 19 | "app": "asset", |
| 20 | "payload": { |
| 21 | "cap": "{trigger.data.cap otherwise ''}", |
| 22 | "is_private": false, |
| 23 | "is_transferrable": true, |
| 24 | "auto_destroy": "{!!trigger.data.auto_destroy}", |
| 25 | "fixed_denominations": false, |
| 26 | "issued_by_definer_only": "{!!trigger.data.issued_by_definer_only}", |
| 27 | "cosigned_by_definer": false, |
| 28 | "spender_attested": "{!!trigger.data.attestor1}", |
| 29 | "attestors": [ |
| 30 | "{trigger.data.attestor1 otherwise ''}", |
| 31 | "{trigger.data.attestor2 otherwise ''}", |
| 32 | "{trigger.data.attestor3 otherwise ''}" |
| 33 | ] |
| 34 | } |
| 35 | }, |
| 36 | { |
| 37 | "app": "state", |
| 38 | "state": "{ |
| 39 | var[response_unit] = trigger.address; |
| 40 | var['rate'] = $rate; }" |
| 41 | } |
| 42 | ] |
| 43 | }, |
| 44 | { |
| 45 | "if": "{trigger.output[[asset='CPPYMBzFzI4+eMk7tLMTGjLF4E60t5MUfo2Gq7Y6Cn4=']] AND trigger.data.issue AND trigger.data.asset}", |
| 46 | "init": "{ |
| 47 | $asset_amount = ( 100 * trigger.output[[asset='CPPYMBzFzI4+eMk7tLMTGjLF4E60t5MUfo2Gq7Y6Cn4=']]) / var['rate']; |
| 48 | $fees = floor($asset_amount * 0.009999, 0) <= 1 ? $asset_amount * 0.009999 : floor($asset_amount * 0.009999, 0) ; |
| 49 | response['message'] = 'exchanged '|| |
| 50 | trigger.output[[asset='CPPYMBzFzI4+eMk7tLMTGjLF4E60t5MUfo2Gq7Y6Cn4=']].amount || |
| 51 | trigger.output[[asset='CPPYMBzFzI4+eMk7tLMTGjLF4E60t5MUfo2Gq7Y6Cn4=']].asset || |
| 52 | ' for '|| |
| 53 | $asset_amount|| |
| 54 | ' asset.'; }", |
| 55 | "messages": [ |
| 56 | { |
| 57 | "app": "payment", |
| 58 | "payload": { |
| 59 | "asset": "{trigger.data.asset}", |
| 60 | "outputs": [ |
| 61 | { |
| 62 | "address": "{trigger.address}", |
| 63 | "amount": "{round(($asset_amount - 1) * 0.99, 0)}" |
| 64 | }, |
| 65 | { |
| 66 | "address": "{this_address}", |
| 67 | "amount": "{round($fees + 1)}" |
| 68 | } |
| 69 | ] |
| 70 | } |
| 71 | }, |
| 72 | { |
| 73 | "app": "state", |
| 74 | "state": "{ |
| 75 | var['rate'] = $rate; |
| 76 | }" |
| 77 | } |
| 78 | ] |
| 79 | }, |
| 80 | { |
| 81 | "if": "{trigger.output[[asset='JHk+yzbuBHfefV7L5xw5tZOJ/9cjrmIKTimk209HMhI=']] AND trigger.data.issue AND trigger.data.asset}", |
| 82 | "init": "{ |
| 83 | $asset_amount = ( 100 * trigger.output[[asset='JHk+yzbuBHfefV7L5xw5tZOJ/9cjrmIKTimk209HMhI=']]) / var['rate'] ; |
| 84 | $fees = floor($asset_amount * 0.009999, 0) <= 1 ? $asset_amount * 0.009999 : floor($asset_amount * 0.009999, 0) ; |
| 85 | response['message'] = 'exchanged '|| |
| 86 | trigger.output[[asset='JHk+yzbuBHfefV7L5xw5tZOJ/9cjrmIKTimk209HMhI=']].amount || |
| 87 | trigger.output[[asset='JHk+yzbuBHfefV7L5xw5tZOJ/9cjrmIKTimk209HMhI=']].asset || |
| 88 | ' for '|| |
| 89 | $asset_amount|| |
| 90 | ' asset.'; }", |
| 91 | "messages": [ |
| 92 | { |
| 93 | "app": "payment", |
| 94 | "payload": { |
| 95 | "asset": "{trigger.data.asset}", |
| 96 | "outputs": [ |
| 97 | { |
| 98 | "address": "{trigger.address}", |
| 99 | "amount": "{round(($asset_amount - 1)* 0.99, 0)}" |
| 100 | }, |
| 101 | { |
| 102 | "address": "{this_address}", |
| 103 | "amount": "{round($fees + 1)}" |
| 104 | } |
| 105 | ] |
| 106 | } |
| 107 | }, |
| 108 | { |
| 109 | "app": "state", |
| 110 | "state": "{ |
| 111 | var['rate'] = $rate; |
| 112 | }" |
| 113 | } |
| 114 | ] |
| 115 | }, |
| 116 | { |
| 117 | "if": "{var[trigger.data.asset] == trigger.address AND trigger.output[[asset=base]] >= 1000000}", |
| 118 | "messages": [ |
| 119 | { |
| 120 | "app": "payment", |
| 121 | "payload": { |
| 122 | "asset": "base", |
| 123 | "outputs": [ |
| 124 | { |
| 125 | "address": "{trigger.address}", |
| 126 | "amount": "{trigger.output[[asset=base]]}" |
| 127 | } |
| 128 | ] |
| 129 | } |
| 130 | }, |
| 131 | { |
| 132 | "app": "payment", |
| 133 | "payload": { |
| 134 | "asset": "{var[trigger.data.asset]}", |
| 135 | "outputs": [ |
| 136 | { |
| 137 | "address": "{trigger.address}" |
| 138 | } |
| 139 | ] |
| 140 | } |
| 141 | } |
| 142 | ] |
| 143 | } |
| 144 | ] |
| 145 | } |
| 146 | } |
| 147 | ] |