<!-- todo - simplify if logic, use model logic -->
{% if swap.wow_to_xmr %}
  {% set receive_coin = 'WOW' %}
  {% set send_coin = 'XMR' %}
  {% set receive_amount = swap.receive_amount_atomic | from_atomic_wow %}
  {% set send_amount = swap.send_amount_atomic | from_atomic_xmr %}
  {% set fee_amount = swap.fee_amount_atomic | from_atomic_xmr %}
  {% set fee_value = ((fee_amount) * (swap.xmr_price_ausd | from_atomic_usd)) | round(4) %}
  {% set swap_value = ((receive_amount) * (swap.wow_price_ausd | from_atomic_usd)) | round(4) %}
{% else %}
  {% set receive_coin = 'XMR' %}
  {% set send_coin = 'WOW' %}
  {% set receive_amount = swap.receive_amount_atomic | from_atomic_xmr %}
  {% set send_amount = swap.send_amount_atomic | from_atomic_wow %}
  {% set fee_amount = swap.fee_amount_atomic | from_atomic_wow %}
  {% set fee_value = (fee_amount) * (swap.wow_price_ausd | from_atomic_usd) | round(4) %}
  {% set swap_value = (receive_amount) * (swap.xmr_price_ausd | from_atomic_usd) | round(4) %}
{% endif %}

<!DOCTYPE HTML>
<html>

	{% include 'includes/head.html' %}

  <meta http-equiv="refresh" content="300">

	<body class="is-preload landing">
		<div id="page-wrapper">

			{% include 'includes/header.html' %}

				<section class="wrapper style1 special fade-down">
					<div class="container">
						<header class="major">
							<h2>Swap Details</h2>
              <p></p>
              <p>Your swap ID is <span class="highlight">{{ swap.id }}</span>. Use this ID to check back in on the status of the swap.</p>
              {% if not swap.funds_received and not swap.completed %}
              <p>
                You will be receiving {{ send_amount }} {{ send_coin }} (${{ swap_value }}) to the {{ send_coin }} address below when funds are received.
                I will be withholding {{ fee_amount }} {{ send_coin }} (${{ fee_value }}) as a service fee.
                <br /><br />
                Double-check the details below are correct and send {{ receive_amount }} {{ receive_coin }}
                to <span class="highlight">{{ swap.swap_address }}</span> to initiate the swap.
              </p>
              <img src="data:image/png;base64,{{ qrcode }}" width=200 class="center">
              <!-- todo - implement block explorer link template filters -->
              {% if txes.in %}
              <br />
              <h3>Found Transactions!</h3>
              <ul>
                {% for tx in txes.in %}
                  <li>
                    {% if swap.wow_to_xmr %}
                      <span class="highlight"><a href="{{ tx.txid | wow_block_explorer }}" target="_blank">{{ tx.txid }}</a></span> -
                      {{ tx.amount | from_atomic_wow }}
                    {% else %}
                      <span class="highlight"><a href="{{ tx.txid | xmr_block_explorer }}" target="_blank">{{ tx.txid }}</a></span> -
                      {{ tx.amount | from_atomic_xmr }}
                    {% endif %} -
                    {{ tx.confirmations }} confirmations
                  </li>
                {% endfor %}
              </ul>
              {% endif %}

						</header>
						<div class="box alt">
              <p class="small white">Your WOW Address:<br /><span class="highlight">{{ swap.return_wow_address }}</span></p>
              <p class="small white">Your XMR Address:<br /><span class="highlight">{{ swap.return_xmr_address }}</span></p>
						</div>
            {% elif swap.funds_received and not swap.completed %}
              <p>Incoming {{ receive_coin }} funds have been confirmed! Your {{ send_coin }} funds should be sent soon.</p>
            {% endif %}

            {% if swap.send_tx_id %}
              <p>Outgoing {{ send_coin }} funds have been sent! Tx ID:
                {% if swap.wow_to_xmr %}
                  <span class="highlight"><a href="{{ swap.send_tx_id | xmr_block_explorer }}" target="_blank">{{ swap.send_tx_id }}</a></span>
                {% else %}
                  <span class="highlight"><a href="{{ swap.send_tx_id | wow_block_explorer }}" target="_blank">{{ swap.send_tx_id }}</a></span>
                {% endif %}
              </p>
              <p>No further action is required; you can close this tab. Thanks for using the service!</p>
            {% endif %}
					</div>
				</section>

        <section class="wrapper style2 special fade-down">
					<div class="container">
						<header class="major">
							<h2>Need Help?</h2>
              <p></p>
              <p>You can contact me for support at the links in the footer below. Please provide your swap ID.</p>
              <p>
                If you'd like to cancel the swap and have not sent funds,
                simply do nothing and the swap will be deleted after several days of inactivity.
              </p>
            </header>
          </div>
        </section>

				{% include 'includes/footer.html' %}

		</div>

		{% include 'includes/scripts.html' %}

	</body>
</html>


{% if config.DEBUG %}
<ul class="no-bullets">
  <li>Datetime: {{ swap.date }} UTC</li>
  <li>WOW Price: ${{ swap.wow_price_ausd | from_atomic_usd }}</li>
  <li>XMR Price: ${{ swap.xmr_price_ausd | from_atomic_usd }}</li>
  <li>Swap type: {{ receive_coin }} to {{ send_coin }}</li>
  <li>Swap value: ${{ swap_value }}</li>
  <li>Fee Amount: {{ fee_amount }} {{ send_coin }}</li>
  <li>Send Amount: {{ send_amount }} {{ send_coin }}</li>
  <li>Funds Received: {{ swap.funds_received }}</li>
  <li>Send Tx ID: {{ swap.send_tx_id }}</li>
  <li>Completed: {{ swap.completed }}</li>
</ul>
{% endif %}
