[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"init": "{
$asset = var['asset'];
$supply = var['supply'];
$cascading_donations_aa = "
2QVJOY3BRRGWP7IOYL64O5BU3WLUJ4TZ"; // D3B42CWMY3A6I6GHC6KUJJSUKOCBE77U - livenet; ARJGCY7F33YB2HONUYQJ2FH6JK2AUJDM - testnet
$allow_repository = "byteball/ocore";
}",
"getters": "{
$is_allowed_tokens = $symbol => {
$allowed_tokens = ["ETH", "MATIC", "WBTC", "USDC", "BNB"];
length(filter($allowed_tokens, 20, $t => $t == $symbol)) == 1
};
$asset_to_base = ($asset, $amount) => {
$oracle_address = "
F4KHJUCLJKY4JV7M5F754LAJX4EB7M4N"; // JPQKPRI5FMTQRJF4ZZMYZYDQVRD55OTC - livenet; F4KHJUCLJKY4JV7M5F754LAJX4EB7M4N - testnet
$token_registry = "
O6H6ZIFI57X3PLTYHOCVYPP5A553CYFQ";
if ($asset == 'base') {
$amount_in_base = $amount;
} else {
$symbol = var[$token_registry]['a2s_' || $asset];
if ($symbol AND $is_allowed_tokens($symbol)) {
$current_desc = var[$token_registry]['current_desc_' || $asset];
if ($current_desc) {
$decimals = var[$token_registry]['decimals_' || $current_desc] OTHERWISE 0;
} else {
$decimals = 0;
}
$feed_name = $symbol || "_USD";
$rate = data_feed[[oracles=$oracle_address, feed_name=$feed_name, ifnone=false]] / data_feed[[oracles=$oracle_address, feed_name="GBYTE_USD", ifnone=false]];
$amount_in_base = floor(($amount / 10 ^ $decimals) * $rate * 1e9);
} else {
$amount_in_base = 0;
}
}
$amount_in_base
};
}",
"messages": {
"cases": [
{
"if": "{ trigger.data.define AND !$asset }",
"messages": [
{
"app": "asset",
"payload": {
"is_private": false,
"is_transferrable": true,
"auto_destroy": false,
"fixed_denominations": false,
"issued_by_definer_only": true,
"cosigned_by_definer": false,
"spender_attested": false
}
},
{
"app": "state",
"state": "{
var['asset'] = response_unit;
var['supply'] = 0;
response['asset'] = response_unit;
}"
}
]
},
{
"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 }",
"init": "{
$send_amount = $asset_to_base(trigger.data.asset, trigger.data.amount);
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{ $asset }",
"outputs": [
{
"address": "{ trigger.data.donor }",
"amount": "{ $send_amount }"
}
]
}
},
{
"app": "state",
"state": "{
var['supply'] += $send_amount;
}"
}
]
}
]
}
}
]