2K4UR4ON7ZEC2B55W6DMH2UGQY66UT6C
[
"autonomous agent",
{
"getters": "{
$get_growth_factor = ($curve) => {
$interest_rate = var[$curve]['interest_rate'];
$term = (timestamp - var[$curve]['rate_update_ts']) / (360 * 24 * 3600); // in years
$growth_factor = var[$curve]['growth_factor'] * (1 + $interest_rate)^$term;
$growth_factor
};
}",
"init": "{
if(trigger.output[[asset!=base]].asset != 'none'){
$asset = trigger.output[[asset!=base]].asset;
if($asset and $asset == 'ambiguous')
bounce('Only 1 asset per tx');
}
else
bounce('usage: send any amount of I asset with params:to,amount and will calc and send O asset amount in interest asset');
$def = asset[$asset].definer_address;
if(!is_aa($def))
bounce('asset invalid');
if(definition[$def][1].base_aa != '3DGWRKKWWSC6SV4ZQDWEHYFRYB4TGPKX')
bounce('asset invalid');
$growth_factor = $get_growth_factor($def);
$stable_amount = trigger.data.amount;
if(!$stable_amount OR !is_integer($stable_amount) OR $stable_amount >= 0)
bounce('amount param invalid');
$interest_amount = floor($stable_amount / $growth_factor);
if($interest_amount > trigger.output[[asset=$asset]])
bounce('not enough i tokens sent');
if(!trigger.data.to or !is_valid_address(trigger.data.to) or is_aa(trigger.data.to))
bounce('to param invalid');
}",
"messages": [
{
"app": "payment",
"payload": {
"asset": "{$asset}",
"outputs": [
{
"address": "{trigger.data.to}",
"amount": "{$interest_amount}"
},
{
"address": "{trigger.address}"
}
]
}
},
{
"app": "payment",
"payload": {
"asset": "base",
"outputs": [
{
"address": "{trigger.address}"
}
]
}
}
]
}
]
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount