[
"autonomous agent",
{
"bounce_fees": {
"base": 10000
},
"init": "{
$PERCENT = 0.01;
$SECOND = 1;
$MINUTES = 60;
$HOUR = 60 * $MINUTES;
$DAY = 24 * $HOUR;
$WEEK = 7 * $DAY;
$YEAR = 364.25 * $DAY;
$AA_NAME = "CODAA_ASSET_MANAGER";
$HOW_TO = "I'm made to be used by machine, just review my code to know more";
$AA_ONLY_USER = "";
$CAP = 1e15;
$RETURN_PERCENTAGE = 4* $PERCENT;
$DEBUG = true;
if (!$DEBUG)
if ($AA_ONLY_USER !=trigger.address)
bounce ("Not owner!");
}",
"messages": {
"cases": [
{
"if": "{ !!trigger.data.get_return }",
"init": "{
if (timestamp<
parse_date(var[trigger.data.name||"_last_return_time"]) + var[trigger.data.name||"_return_period"])
bounce ("too early");
$return = var[trigger.data.name||"_balance"] * var[trigger.data.name||"_return_percentage"];
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{ var[trigger.data.name||"_id"] }",
"outputs": [
{
"address": "{trigger.address}",
"amount": "{ $return }"
}
]
}
},
{
"app": "state",
"state": "{
var[trigger.data.name||"_balance"] -= $return;
var[trigger.data.name||"_last_return_time"] = timestamp_to_string(timestamp);
var[trigger.data.name||"_next_return"] =
var[trigger.data.name||"_balance"] * var[trigger.data.name||"_return_percentage"];
response["message"] = "return percentage sent.";
}"
}
]
},
{
"init": "{
if (!!var["asset_id"])
bounce ("already created, use get_return if you are owner");
$return = var[trigger.data.name||"_balance"] * var[trigger.data.name||"_return_percentage"];
}",
"messages": [
{
"app": "asset",
"payload": {
"cap": "{ $CAP }",
"is_private": false,
"is_transferrable": true,
"fixed_denominations": false,
"auto_destroy": false,
"cosigned_by_definer": false,
"issued_by_definer_only": true,
"spender_attested": false
}
},
{
"app": "state",
"state": "{
var["asset_id"] = response_unit;
var["creation_time"] = timestamp_to_string(timestamp);
var["balance"] = $CAP;
var["return_period"] = 1 * $YEAR;
var["return_percentage"] = $RETURN_PERCENTAGE;
var["last_return_time"] = timestamp_to_string(timestamp);
var["next_return_value"] = $CAP * $RETURN_PERCENTAGE;
response["message"] = "Asset created";
}"
}
]
}
]
}
}
]