Unit ID
zXSopadUO+OL/8jrYAozO3z24So2nLuXZoWahhrStxk=
Received
21.12.2024 13:21:51
Confirmation delay (full node)
5 minutes 56 seconds
Messages
Definition
Definition: [ "autonomous agent", { "messages": { "cases": [ { "if": "{ $key = 'balance'||trigger.address||''||trigger.data.asset; trigger.data.withdraw AND trigger.data.asset AND trigger.data.amount AND trigger.data.amount <= var[$key] }", "messages": [ { "app": "payment", "payload": { "asset": "{trigger.data.asset}", "outputs": [ { "address": "{trigger.address}", "amount": "{trigger.data.amount}" } ] } }, { "app": "state", "state": "{ var[$key] = var[$key] - trigger.data.amount; }" } ] }, { "if": "{ $order1 = trigger.data.order1.signed_message; $order2 = trigger.data.order2.signed_message; if (!$order1.sell_asset OR !$order2.sell_asset) return false; if ($order1.sell_asset != $order2.buy_asset OR $order1.buy_asset != $order2.sell_asset) return false; // to do check expiry $sell_key1 = 'balance' || $order1.address || '' || $order1.sell_asset; $sell_key2 = 'balance' || $order2.address || '' || $order2.sell_asset; $id1 = sha256($order1.address || $order1.sell_asset || $order1.buy_asset || $order1.sell_amount || $order1.price || trigger.data.order1.last_ball_unit); $id2 = sha256($order2.address || $order2.sell_asset || $order2.buy_asset || $order2.sell_amount || $order2.price || trigger.data.order2.last_ball_unit); if (var['executed' || $id1] OR var['executed' || $id2]) return false; if (!is_valid_signed_package(trigger.data.order1, $order1.address) OR !is_valid_signed_package(trigger.data.order2, $order2.address)) return false; $amount_left1 = var['amount_left' || $id1] otherwise $order1.sell_amount; $amount_left2 = var['amount_left' || $id2] otherwise $order2.sell_amount; if ($amount_left1 > var[$sell_key1] OR $amount_left2 > var[$sell_key2]) return false; $buy_amount1 = round($amount_left1 * $order1.price); if ($buy_amount1 > $amount_left2) // order1 is not the smaller one return false; $expected_buy_amount2 = round($buy_amount1 * $order2.price); if ($expected_buy_amount2 > $amount_left1) // user2 doesn't like the price, he gets less than expects return false; true }", "messages": [ { "app": "state", "state": "{ $buy_key1 = 'balance' || $order1.address || '' || $order1.buy_asset; $buy_key2 = 'balance' || $order2.address || '' || $order2.buy_asset; $base_key1 = 'balance' || $order1.address || 'base'; $base_key2 = 'balance' || $order2.address || 'base'; var[$sell_key1] = var[$sell_key1] - $amount_left1; var[$sell_key2] = var[$sell_key2] - $buy_amount1; var[$buy_key1] = var[$buy_key1] + $buy_amount1; var[$buy_key2] = var[$buy_key2] + $amount_left1; $fee = 1000; var[$base_key1] = var[$base_key1] - $fee; var[$base_key2] = var[$base_key2] - $fee; if (var[$base_key1] < 0 OR var[$base_key2] < 0) bounce('not enough balance for fees'); var['executed' || $id1] = 1; $new_amount_left2 = $amount_left2 - $buy_amount1; if ($new_amount_left2) var['amount_left' || $id2] = $new_amount_left2; else var['executed' || $id2] = 1; // parsable response for transaction log response[$order1.address || '' || $order1.sell_asset] = -$amount_left1; response[$order2.address || '' || $order2.buy_asset] = $amount_left1; response[$order1.address || '' || $order1.buy_asset] = $buy_amount1; response[$order2.address || '' || $order2.sell_asset] = -$buy_amount1; }" } ] }, { "if": "{!trigger.data}", "messages": [ { "app": "state", "state": "{ $asset = trigger.output[[asset!=base]].asset; if ($asset == 'ambiguous') bounce('ambiguous asset'); if (trigger.output[[asset=base]] > 10000){ $base_key = 'balance'||trigger.address||''||'base'; var[$base_key] = var[$base_key] + trigger.output[[asset=base]]; $response_base = trigger.output[[asset=base]] || ' bytes\ '; } if ($asset != 'none'){ $asset_key = 'balance'||trigger.address||''||$asset; var[$asset_key] = var[$asset_key] + trigger.output[[asset=$asset]]; $response_asset = trigger.output[[asset=$asset]] || ' of ' || $asset || '\ '; } response['message'] = 'accepted coins:\ ' || ($response_base otherwise '') || ($response_asset otherwise ''); }" } ] } ] } } ]
Technical information
Fees:
4,966 bytes
(405 headers, 4561 payload)
TPS fee:
0 bytes
Actual TPS fee:
1 bytes
Level:11434917
Witnessed level:11434902
Main chain index:11045863
Latest included mc index:11045862
Status:stable/confirmed/final