Unit ID
BAW+rV4bNFm2aVhc85v0iLi+nl1TbKN+8K58ltvVJ0Y=
Received
13.08.2019 20:04:40
Confirmation delay (full node)
4 minutes 34 seconds
Confirmation delay (light node)
6 minutes 44 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $addr = trigger.address; $base_inp = trigger.output[[asset=base]]; if(trigger.output[[asset!=base]].asset != 'none') $asset = trigger.output[[asset!=base]].asset; if($asset){ if($asset == 'ambiguous'){ bounce("only 1 asset per tx"); } if(trigger.output[[asset!=base]] ==0) bounce("zero asset tx"); $asset_inp = trigger.output[[asset!=base]]; } if(var['asset']){ if($asset and var['asset'] != $asset) bounce("not a previously defined asset"); } $ratio = round(1000/data_feed[[oracles='F4KHJUCLJKY4JV7M5F754LAJX4EB7M4N', feed_name='GBYTE_USD']]); //bytes per 1 asset-microUSD- if(var['amount'] and var['amount'] != 0) $max_ratio = round((balance[base]-9000)/var['amount']); }", "messages": { "cases": [ { "if": "{!var['asset']}", "messages": [ { "app": "asset", "payload": { "is_private": false, "is_transferrable": true, "auto_destroy": true, "fixed_denominations": false, "issued_by_definer_only": false, "cosigned_by_definer": false, "spender_attested": false } }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$addr}", "amount": "{$base_inp - 1000}" } ] } }, { "app": "state", "state": "{ var['asset'] = response_unit; var['owner'] = $addr; var['amount'] = 0; }" } ] }, { "if": "{ $asset }", "messages": [ { "if": "{trigger.data}", "app": "data", "payload": "{trigger.data}" }, { "init": "{ if($ratio > $max_ratio){ bounce('Not enough liquidity to cover, please hodl'); } $byte_amount = round($asset_inp*0.998*$ratio); }", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$addr}", "amount": "{$byte_amount}" } ] } }, { "app": "state", "state": "{ var['amount'] -= $asset_inp; response['message'] = 'redeemed '||$asset_inp||' centUSD at'||(0.998*$ratio)||' bytes per token'; }" } ] }, { "if": "{ !$asset }", "init": "{ $issue_amount = ($base_inp - ($base_inp % $ratio)) / $ratio; if($issue_amount <= 0){ bounce('Minimum: '||$ratio); } }", "messages": [ { "if": "{trigger.data}", "app": "data", "payload": "{trigger.data}" }, { "app": "payment", "payload": { "asset": "{var['asset']}", "outputs": [ { "address": "{$addr}", "amount": "{$issue_amount}" } ] } }, { "app": "state", "state": "{ var['amount'] += $issue_amount; response['message'] = 'issued '||$issue_amount||' centUSD at '||$ratio||' bytes per token'; }" } ] } ] } } ]
Technical information
Fees:
2,337 bytes
(353 headers, 1984 payload)
Level:997159
Witnessed level:997151
Main chain index:995977
Latest included mc index:995976
Status:stable/confirmed/final