Unit ID
2K1m0QwCCGoMwbqH4NTkvLahaD7TlXciwbB9bdooIsg=
Received
21.09.2021 04:22:36
Confirmation delay (full node)
1 minute 17 seconds
Confirmation delay (light node)
3 minutes 52 seconds
Messages
Definition
Definition: [ "autonomous agent", { "bounce_fees": { "base": 10000 }, "init": "{ $POOL_BASE_AA = "5DNICJLNOBPANH536Y7YVBN5ZDBLQ4LE"; $definition = definition[trigger.data["_pl"]][1]; $asset = trigger.output[[asset!="base"]].asset == "none" ? trigger.output[[asset!="base"]].asset : "base"; if (definition["base_aa"] != $POOL_BASE_AA) bounce("That pool version is unsupported"); if (NOT trigger.data["_fwto"]) bounce("_fwto field is mandatory"); if (NOT is_valid_address(trigger.data["_fwto"])) bounce("_fwto field is not a valid address"); if (trigger.output[[asset!="base"]].asset == "ambiguous") bounce("AAs cannot handle payments with multiple assets"); if (NOT trigger.data["_opr"]) bounce("_opr field is mandatory"); if (NOT is_valid_amount(trigger.data["_opr"])) bounce("_opr must be a positive amount"); $getAmount = ($outputAmount, $outputReserve, $inputReserve, $fee)=>{ $swapNoFee = 1e11 - $fee; $numerator = $outputAmount * $inputReserve * 1e11; $denominator = ($outputReserve - $outputAmount) * $swapNoFee; return ceil($numerator / $denominator, 0); }; $calculateNeededAmount = ()=>{ $asset0 = definition["params"]["asset0"]; $asset1 = definition["params"]["asset1"]; $fee = definition["params"]["swap_fee"]; $buy = $asset == $asset0; $reserve0 = balance[trigger.data["_pl"]][$asset0]; $reserve1 = balance[trigger.data["_pl"]][$asset1]; if ($buy) return $getAmount(trigger.data["_opr"], $reserve1, $reserve0, $fee); return $getAmount(trigger.data["_opr"], $reserve0, $reserve1, $fee); }; $price = $calculateNeededAmount(); $remaining = trigger.output[[asset=$asset]].amount - $price; }", "messages": [ { "app": "payment", "payload": { "asset": "{$asset}", "outputs": [ { "address": "{trigger.initial_address}", "amount": "{$remaining}" }, { "address": "{trigger.data["_fwto"]}", "amount": "{$price}" } ] } }, { "app": "data", "payload": { "to": "{trigger.initial_address}" } } ] } ]
Technical information
Fees:
2,957 bytes
(452 headers, 2505 payload)
Level:2334801
Witnessed level:2334792
Main chain index:2322515
Latest included mc index:2322514
Status:stable/confirmed/final