Unit ID
AaefQO3E0nEtNKr1vvAufLqvXp2G1qwMJmiztu0DXOM=
Received
10.08.2021 04:49:24
Confirmation delay (full node)
4 minutes 0 seconds
Confirmation delay (light node)
5 minutes 4 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["QEQTX5CZHGLKB4P3YCMWCII3GIMAOB6N"]["owner"]; if (NOT $owner) bounce("The smart contract has not been initialized yet"); }", "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 var["CURRENCY_USD"]}", "messages": [ { "app": "state", "state": "{ var["CURRENCY_USD"] = { oracle1: "JPQKPRI5FMTQRJF4ZZMYZYDQVRD55OTC", //GBYTE_USD feed1: "GBYTE_USD", oracle2: false, //TICKER_USD feed2: false }; }" } ] }, { "if": "{ trigger.address == $owner AND ($method == "payout" OR $method == "addCurrency" OR $method == "delCurrency") }", "messages": { "cases": [ { "if": "{$method == "payout"}", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{trigger.address}" } ] } } ] }, { "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:
6,479 bytes
(452 headers, 6027 payload)
Level:2182638
Witnessed level:2182630
Main chain index:2172936
Latest included mc index:2172935
Status:stable/confirmed/final