Definition: [
"autonomous agent",
{
"bounce_fees": {
"base": 30000
},
"init": "{
// bounce_fees might cover premium so make min premium a bit expensive
// varaibles to be filled on front end bu insurance service maker...
$mcr = 110000; // minium capital requirement to activate this service...
$expiration = 86400 * 360; // 12 months of cover
$selected_arbiter = ''; // Address of selected arbiter to make final decision
$min_premium = 100; // min premium to pay by single user one time to get certain amount of coverage
$coverage_times = 12; // Premium amount multiply with this value, so here it could be 100 * 12 = 1200
$author_address = 'T77QBAHR4CN2G6KJ3BHMJLAAPU2WG2KG';
}",
"messages": {
"cases": [
{
"if": "{trigger.data.investor AND var['close_investment'] == false}",
"messages": [
{
"if": "{balance[base] >= $mcr}",
"app": "state",
"state": "{
var['close_investments'] = true; // close further investments
var['investments_locked'] = false; // only locked when a user buy insurance
var['start_service'] = true; // Let users buy services
var['capitalLocked'] = 0;
var['investor_'||trigger.address] = trigger.output[[asset=base]]; // how much invested...
}"
}
]
},
{
"if": "{trigger.data.insured AND trigger.output[[asset=base]] >= $min_premium AND var['start_service'] == true}",
"messages": [
{
"if": "{($mcr - var['capitalLocked']) > (trigger.output[[asset=base]] * $coverage_times)}",
"app": "state",
"state": "{
var['insured_' || trigger.address] = trigger.output[[asset=base]] * $coverage_times;
var['capitalLocked'] = var['capitalLocked'] + (trigger.output[[asset=base]] * $coverage_times);
response['accepted_request'] = 'Your request to get insured is accepted, Your coverage is ' || (trigger.output[[asset=base]] * $coverage_times) || ' and you paid - ' || trigger.output[[asset=base]];
}"
}
]
}
]
}
}
]