Unit ID
lDXsMeLFduHMUOhFgVZkkiLPmLabSyYYRd1CgtjFI0s=
Received
22.08.2021 21:01:10
Confirmation delay (full node)
3 minutes 4 seconds
Confirmation delay (light node)
5 minutes 0 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $pool_aa = params.pool_aa; $fee = 2000; $pool_params = definition[$pool_aa][1].params; $asset0 = $pool_params.asset0; $asset1 = $pool_params.asset1; $amount0 = trigger.output[[asset=$asset0]] - ($asset0 == 'base' ? $fee : 0); $amount1 = trigger.output[[asset=$asset1]] - ($asset1 == 'base' ? $fee : 0); if ($amount0 <= 0) bounce("amount0 = " || $amount0); if ($amount1 <= 0) bounce("amount1 = " || $amount1); $reserve0 = balance[$pool_aa][$asset0]; $reserve1 = balance[$pool_aa][$asset1]; $ratio = $reserve1 / $reserve0; $expectedAmount1 = round($ratio * $amount0); if ($amount1 > $expectedAmount1){ $change0 = 0; $change1 = $amount1 - $expectedAmount1; } else if ($amount1 < $expectedAmount1){ // amount0 is too large $used_amount0 = floor($amount1 / $ratio); if ($used_amount0 > $amount0) bounce("BUG: " || $used_amount0 || " > " || $amount0); $newExpectedAmount1 = round($ratio * $used_amount0); if ($amount1 < $newExpectedAmount1) bounce("rounding issue: adjusted amount0 from " || $amount0 || " to " || $used_amount0 || " but amount1 " || $amount1 || " is still less than the new expected amount1 " || $newExpectedAmount1); $change0 = $amount0 - $used_amount0; $change1 = $amount1 - $newExpectedAmount1; } else{ $change0 = 0; $change1 = 0; } }", "messages": [ { "app": "payment", "payload": { "asset": "{$asset0}", "outputs": [ { "address": "{$pool_aa}", "amount": "{$amount0 - $change0}" }, { "address": "{trigger.address}", "amount": "{$change0}" } ] } }, { "app": "payment", "payload": { "asset": "{$asset1}", "outputs": [ { "address": "{$pool_aa}", "amount": "{$amount1 - $change1}" }, { "address": "{trigger.address}", "amount": "{$change1}" } ] } }, { "if": "{$asset0 != 'base' AND $asset1 != 'base'}", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{$pool_aa}" } ] } } ] } ]
Technical information
Fees:
2,633 bytes
(452 headers, 2181 payload)
Level:2250407
Witnessed level:2250400
Main chain index:2239283
Latest included mc index:2239282
Status:stable/confirmed/final