Unit ID
tzoQiBXne27mFEr+uWeTbMsoSVSQooDGxK7hwMsEq80=
Received
31.05.2021 22:34:38
Confirmation delay (full node)
4 minutes 16 seconds
Confirmation delay (light node)
5 minutes 3 seconds
Messages
Definition
Definition: [ "autonomous agent", { "bounce_fees": { "base": 10000 }, "init": "{ if (NOT exists(trigger.data["method"])) bounce("method field is mandatory"); $method = trigger.data["method"]; $spendableFunds = balance["base"] - storage_size; //The max amount the owner can withdraw without bouncing due to not enough funds $owner = var["owner"]; }", "getters": "{ $getCurrency = $ticker=>{ return var["CURRENCY_" || $ticker]; }; $getExchangeRate = $ticker=>{ $currency = $getCurrency($ticker); if (NOT $currency) bounce("That currency was not found"); $multiplier = $currency.feed2 ? 1 / data_feed[[oracles=$currency.oracle2, feed_name=$currency.feed2, ifseveral="last"]] * data_feed[[oracles=$currency.oracle1, feed_name=$currency.feed1, ifseveral="last"]] : data_feed[[oracles=$currency.oracle1, feed_name=$currency.feed1, ifseveral="last"]]; return $multiplier / 1000000000; }; }", "messages": { "cases": [ { "if": "{ NOT $owner //The owner has not been set }", "messages": [ { "app": "state", "state": "{ var["owner"] = "IUU43O7TS2TBYKAPGKUARDZHOTAE275A"; var["CURRENCY_USD"] = { oracle1: "F4KHJUCLJKY4JV7M5F754LAJX4EB7M4N", //GBYTE_USD feed1: "GBYTE_USD", oracle2: false, //FIAT_USD feed2: false }; var["FEE"] = 0.03; }" } ] }, { "if": "{ trigger.address == $owner AND ($method == "payout" OR $method == "transferOwnership" OR $method == "addCurrency" OR $method == "delCurrency") }", "messages": { "cases": [ { "if": "{ $method == "payout" }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}", "amount": "{$spendableFunds}" } ] } } ] }, { "if": "{ $method == "transferOwnership" }", "init": "{ if (NOT exists(trigger.data["newOwner"])) bounce("newOwner field is mandatory"); if (NOT is_valid_address(trigger.data["newOwner"])) bounce("newOwner field is not a valid address"); }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}", "amount": "{$spendableFunds}" } ] } }, { "app": "state", "state": "{ var["owner"] = trigger.data["newOwner"]; }" } ] }, { "if": "{ $method == "addCurrency" }", "init": "{ if (NOT exists(trigger.data["ticker"])) bounce("ticker field is mandatory"); if (NOT exists(trigger.data["oracle1"])) bounce("oracle1 field is mandatory"); if (NOT is_valid_address(trigger.data["oracle1"])) bounce("oracle1 address is invalid"); if (NOT exists(trigger.data["feed1"])) bounce("feed1 field is mandatory"); if (exists(trigger.data["oracle2"])){ if (NOT is_valid_address(trigger.data["oracle2"])) bounce("oracle2 address is invalid"); if (NOT exists(trigger.data["oracle1"])) bounce("If you provided oracle2 you have to provide oracle1"); if (NOT exists(trigger.data["feed2"])) bounce("If you provided oracle2 you have to provide feed2"); if (NOT data_feed[[oracles=trigger.data["oracle2"], feed_name=trigger.data["feed2"], ifseveral="last", ifnone=false]]) bounce("oracle2 does not post that feed"); } if (NOT data_feed[[oracles=trigger.data["oracle1"], feed_name=trigger.data["feed1"], ifseveral="last", ifnone=false]]) bounce("oracle1 does not post that feed"); }", "messages": [ { "app": "state", "state": "{ var["CURRENCY_" || trigger.data["ticker"]] = { oracle1: trigger.data["oracle1"], feed1: trigger.data["feed1"], oracle2: trigger.data["oracle2"], feed2: trigger.data["feed2"] }; }" } ] }, { "if": "{ $method == "delCurrency" }", "init": "{ if (NOT exists(trigger.data["ticker"])) bounce("ticker field is mandatory"); if (NOT var[trigger.data["ticker"]]) bounce("That currency is unknown for the AA"); }", "messages": [ { "app": "state", "state": "{ var["CURRENCY_" || trigger.data["ticker"]] = false; }" } ] } ] } } ] } } ]
Technical information
Fees:
4,795 bytes
(452 headers, 4343 payload)
Level:2026084
Witnessed level:2026077
Main chain index:2018093
Latest included mc index:2018092
Status:stable/confirmed/final