Unit ID
aQVjYFTnzkXPZj43VvkF9ocCnjv/Fq8oziThw1m5yTk=
Received
05.09.2023 20:58:03
Confirmation delay (full node)
3 minutes 41 seconds
Confirmation delay (light node)
4 minutes 43 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $oswap_base_aa = 'BVI5ZXW2Y5P2SN3SP3ZB7YDKY5NE2J2B'; $usd_base_aa = 'AKMFBQ7ZM4NBT7AJO4FWXH4X6Y6EC422'; $getDataFeed = ($oracle, $feedNmae) => data_feed[[oracles=$oracle, feed_name=$feedNmae, ifnone=false]]; }", "messages": { "cases": [ { "init": "{ $data = trigger.data; $type = $data.type; if ($type != 'oswap' AND $type != 'usd') { bounce('type is not supported: ' || $type); } if ($type == 'oswap') { $base_aa = $oswap_base_aa; $names = [ 'oswap_aa', 'x_oracle', 'y_oracle', 'x_feed_name', 'y_feed_name', ]; foreach($names, 5, $v => { $value = $data[$v]; if (!exists($value)) { bounce($v || ' required'); if ($v == 'oswap_aa') { require(is_aa($value), "invalid oswap_aa"); } } }); if (!$getDataFeed($data.x_oracle, $data.x_feed_name)){ bounce('Data feed not found: ' || $data.x_oracle || ' ' || $data.x_feed_name); } if (!$getDataFeed($data.y_oracle, $data.y_feed_name)){ bounce('Data feed not found: ' || $data.x_oracle || ' ' || $data.x_feed_name); } $params = { oswap_aa: $data.oswap_aa, x_oracle: $data.x_oracle, y_oracle: $data.y_oracle, x_feed_name: $data.x_feed_name, y_feed_name: $data.y_feed_name, x_decimals: $data.x_decimals OTHERWISE 0, y_decimals: $data.y_decimals OTHERWISE 0, }; } if ($type == 'usd') { $base_aa = $usd_base_aa; if (!exists($data.oracle)) { bounce("oracle required"); } if (!exists($data.feed_name)) { bounce("feed_name required"); } if (!$getDataFeed($data.oracle, $data.feed_name)){ bounce('Data feed not found: ' || $data.oracle || ' ' || $data.feed_name); } $params = { oracle: $data.oracle, feed_name: $data.feed_name, }; } $aa = [ 'autonomous agent', { base_aa: $base_aa, params: $params } ]; $aa_address = chash160($aa); require(!definition[$aa_address], "such an AA already exists: " || $aa_address); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $aa_address }", "amount": 5000 } ] } }, { "app": "data", "payload": { "define": 1, "factory": "{this_address}" } }, { "app": "definition", "payload": { "definition": "{$aa}" } }, { "app": "state", "state": "{ var['reserve_' || $type || '_' || $aa_address] = $params; response['address'] = $aa_address; }" } ] } ] } } ]
Technical information
Fees:
4,502 bytes
(452 headers, 4050 payload)
Level:3170667
Witnessed level:3170659
Main chain index:3145353
Latest included mc index:3145352
Status:stable/confirmed/final