[
"autonomous agent",
{
"bounce_fees": {
"base": 11000
},
"init": "{
$oracle = "
F4KHJUCLJKY4JV7M5F754LAJX4EB7M4N";
$feed_name = "BBD";
$decimals = 8;
$rate = data_feed[[oracles=$oracle, feed_name=$feed_name, ifnone=0.49486499]];
}",
"messages": {
"cases": [
{
"if": "{trigger.data.define}",
"messages": [
{
"app": "asset",
"payload": {
"cap": "{trigger.data.cap otherwise ''}",
"is_private": false,
"is_transferrable": true,
"auto_destroy": "{!!trigger.data.auto_destroy}",
"fixed_denominations": false,
"issued_by_definer_only": "{!!trigger.data.issued_by_definer_only}",
"cosigned_by_definer": false,
"spender_attested": "{!!trigger.data.attestor1}",
"attestors": [
"{trigger.data.attestor1 otherwise ''}",
"{trigger.data.attestor2 otherwise ''}",
"{trigger.data.attestor3 otherwise ''}"
]
}
},
{
"app": "state",
"state": "{ var[response_unit] = trigger.address;
var['rate'] = $rate; }"
}
]
},
{
"if": "{trigger.output[[asset='CPPYMBzFzI4+eMk7tLMTGjLF4E60t5MUfo2Gq7Y6Cn4=']] >= 0.1 AND trigger.data.issue != '' AND trigger.data.asset != '' AND var[trigger.data.asset] == trigger.address}",
"init": "{
$asset_amount = trigger.output[[asset='CPPYMBzFzI4+eMk7tLMTGjLF4E60t5MUfo2Gq7Y6Cn4=']] / $rate;
$fees = round($asset_amount * 0.009999, 2);
response['message'] = 'exchanged '||
trigger.output[[asset='CPPYMBzFzI4+eMk7tLMTGjLF4E60t5MUfo2Gq7Y6Cn4=']].amount ||
trigger.output[[asset='CPPYMBzFzI4+eMk7tLMTGjLF4E60t5MUfo2Gq7Y6Cn4=']].asset ||
' for '||
$asset_amount||
' asset.'; }",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{trigger.data.asset}",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ round($asset_amount * 0.99, 2)}"
},
{
"address": "{this_address}",
"amount": "{$fees}"
}
]
}
},
{
"app": "state",
"state": "{
var['rate'] = $rate;
}"
}
]
},
{
"if": "{trigger.output[[asset='JHk+yzbuBHfefV7L5xw5tZOJ/9cjrmIKTimk209HMhI=']] >= 0.1 AND trigger.data.issue != '' AND trigger.data.asset != '' AND var[trigger.data.asset] == trigger.address}",
"init": "{
$asset_amount = trigger.output[[asset='JHk+yzbuBHfefV7L5xw5tZOJ/9cjrmIKTimk209HMhI=']] / $rate ;
$fees = round($asset_amount * 0.009999, 2);
response['message'] = 'exchanged '||
trigger.output[[asset='JHk+yzbuBHfefV7L5xw5tZOJ/9cjrmIKTimk209HMhI=']].amount ||
trigger.output[[asset='JHk+yzbuBHfefV7L5xw5tZOJ/9cjrmIKTimk209HMhI=']].asset ||
' for '||
$asset_amount||
' asset.'; }",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{trigger.data.asset}",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ round($asset_amount * 0.99, 2)}"
},
{
"address": "{this_address}",
"amount": "{$fees}"
}
]
}
},
{
"app": "state",
"state": "{
var['rate'] = $rate;
}"
}
]
}
]
}
}
]