Unit ID
h6bvRJm5Tfi/z262GNz63m56TuInSZiPz8QUyr6IxIM=
Received
16.07.2021 02:47:30
Confirmation delay (full node)
3 minutes 3 seconds
Confirmation delay (light node)
4 minutes 49 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"]; $owner = var["owner"]; }", "getters": "{ $getCurrency = $ticker=>{ //Caller should bounce if getCurrency returns false as it means the currency is not supported or was deprecated. You can still calculate exchange rates and convert deprecated currencies to prevent locking NFTs return var["CURRENCY_" || $ticker]; }; //Does NOT provide GBYTE->anything pairs $getExchangeRate = $ticker=>{ $currency = $getCurrency($ticker) OTHERWISE var["DEPRECATED_" || $ticker]; if (NOT $currency) bounce("That currency was not found"); if ($currency.lastRate) return $currency.lastRate; $multiplier = $ticker!="USD" ? (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"]]; if ($ticker != "USD") return $multiplier; return (1/$multiplier); }; $convert = ($amount, $sourceTicker)=>{ if ($amount < 0) bounce("You cannot convert a negative amount"); $multiplier = $getExchangeRate($sourceTicker); $bytes = $amount * $multiplier * 1e9; return round($bytes, 0); }; }", "messages": { "cases": [ { "if": "{NOT $owner}", "messages": [ { "app": "state", "state": "{ var["owner"] = "IUU43O7TS2TBYKAPGKUARDZHOTAE275A"; var["CURRENCY_USD"] = { oracle1: "IUU43O7TS2TBYKAPGKUARDZHOTAE275A", //GBYTE_USD feed1: "GBYTE_USD", oracle2: false, //FIAT_USD feed2: false }; }" } ] }, { "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}" } ] } } ] }, { "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}" } ] } }, { "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["DEPRECATED_" || trigger.data["ticker"]] = false; //Undeprecate if applicable var["CURRENCY_" || trigger.data["ticker"]] = { oracle1: trigger.data["oracle1"], //x->GBYTE or x->pivot feed1: trigger.data["feed1"], oracle2: trigger.data["oracle2"], //pivot->GBYTE feed2: trigger.data["feed2"] }; }" } ] }, { "if": "{$method == "delCurrency"}", "init": "{ if (NOT exists(trigger.data["ticker"])) bounce("ticker field is mandatory"); if (NOT var["CURRENCY_" || trigger.data["ticker"]]) bounce("That currency is unknown for the AA"); }", "messages": [ { "app": "state", "state": "{ var["DEPRECATED_" || trigger.data["ticker"]] = var["CURRENCY_" || trigger.data["ticker"]] || {lastRate: $getExchangeRate(trigger.data["ticker"])}; var["CURRENCY_" || trigger.data["ticker"]] = false; }" } ] } ] } } ] } } ]
Technical information
Fees:
7,052 bytes
(452 headers, 6600 payload)
Level:2086145
Witnessed level:2086138
Main chain index:2077826
Latest included mc index:2077825
Status:stable/confirmed/final