Response: {
"error": "formula
if (trigger.data.to AND !is_valid_address(trigger.data.to))
bounce("bad to address");
require($allow_draw OR !exists(trigger.data.draw_amount), "draw asset does not exist");
require(timestamp <= $end_of_trading_period OR timestamp >= $end_of_waiting_period, "the trading period is closed");
if ((trigger.data.yes_amount OR trigger.data.no_amount OR trigger.data.draw_amount OR trigger.output[[asset=$yes_asset]] > 0 OR trigger.output[[asset=$no_asset]] > 0 OR ($allow_draw AND trigger.output[[asset=$draw_asset]] > 0)) AND trigger.data.type) {
bounce("both type and amount");
}
$min_expected_amount = trigger.data.min_expected_amount OTHERWISE 0;
if ($type AND (!is_integer($min_expected_amount) OR $min_expected_amount < 0)) {
bounce("invalid min_expected_amount");
}
$to = trigger.data.to OTHERWISE trigger.address;
$yes_amount = (!$type OR $type != 'yes') ? trigger.data.yes_amount OTHERWISE -trigger.output[[asset=$yes_asset]] : $get_token_amount('yes', $reserve_amount);
$no_amount = (!$type OR $type != 'no') ? trigger.data.no_amount OTHERWISE -trigger.output[[asset=$no_asset]] : $get_token_amount('no', $reserve_amount);
$draw_amount = $allow_draw ? ((!$type OR $type != 'draw') ? trigger.data.draw_amount OTHERWISE -trigger.output[[asset=$draw_asset]] : $get_token_amount('draw', $reserve_amount)) : 0;
if (trigger.data.yes_amount AND (!is_integer(trigger.data.yes_amount) OR trigger.data.yes_amount <= 0))
bounce("invalid number of yes_amount");
if (trigger.data.no_amount AND (!is_integer(trigger.data.no_amount) OR trigger.data.no_amount <= 0))
bounce("invalid number of no_amount");
if ($allow_draw AND trigger.data.draw_amount AND (!is_integer(trigger.data.draw_amount) OR trigger.data.draw_amount <= 0))
bounce("invalid number of draw_amount");
if (trigger.data.yes_amount AND trigger.output[[asset=$yes_asset]] > 0)
bounce("both yes_amount param and amount");
if (trigger.data.no_amount AND trigger.output[[asset=$no_asset]] > 0)
bounce("both no_amount param and amount");
if ($allow_draw AND trigger.data.draw_amount AND trigger.output[[asset=$draw_asset]] > 0)
bounce("both draw_amount param and amount");
$res = $get_exchange_result($yes_amount, $no_amount, $draw_amount);
$payout = floor($res.payout + $reserve_amount - $res.reserve_needed - $res.fee - $network_fee);
if ($type) {
$amount = $type == 'yes' ? $yes_amount : ($type == 'no' ? $no_amount : $draw_amount);
require($amount >= $min_expected_amount, "amount less than minimum");
}
if ($res.reserve_needed > 0) {
require($res.reserve_needed + $res.fee + $network_fee <= $reserve_amount, "expected reserve amount: " || ($res.reserve_needed + $res.fee + $network_fee));
}
failed: not finite in /"
}