# Swap open/closed

Our **Swap page** lets you swap a Token A for a Token B.

Woken Exchange gives to Project owners/Builders (PairAdmin) the option of enabling their pair's Timekeeper (Token A + Token B) to customize trading hours (swap).

So, if the Timekeeper is enabled for a pair, swaps are only allowed if its market is open.

<details>

<summary><mark style="color:blue;">modifier</mark> <mark style="color:blue;">tradingMustBeOpen</mark></summary>

<pre class="language-solidity" data-title="WokenPair.sol" data-overflow="wrap" data-full-width="false"><code class="lang-solidity">modifier <a data-footnote-ref href="#user-content-fn-1">tradingMustbeOpen</a>() { 
        if (_WokenFactory.isTKEnabled(address(this)) == true) {
            require(_WokenFactory.isTradingOpen(address(this)) == true, 'blocktime is outside trading hours' );
        }  
</code></pre>

<pre class="language-solidity" data-title="WokenPair.sol" data-overflow="wrap"><code class="lang-solidity">function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock <a data-footnote-ref href="#user-content-fn-2">tradingMustbeOpen</a>

</code></pre>

</details>

## Dynamic Open/Closed module

\
We have developed a dynamic "open/closed" module that listens our smart contracts to display 3 different states in real time on our interface: Timekeeper Disabled, Timekeeper Enabled, No Liquidity.\
\
This lets you know whether a pair is tradable or not.

### **Timekeeper Disabled**&#x20;

\
:green\_circle: **The module displays that the pair is tradable 24-7** : just like any AMM, you can swap Token A for Token B at any time.

<figure><img src="https://1024955971-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FucapM7ajIRHbhMUaNv7T%2Fuploads%2Fs0JQlD7tUvNb0Mlpy1r7%2FCapture%20d%E2%80%99e%CC%81cran%202023-09-06%20a%CC%80%2013.20.20.png?alt=media&#x26;token=441d80f2-d140-4bf2-a834-199b78e48757" alt=""><figcaption><p>Timekeeper is not Enabled : this pair is tradable 24-7</p></figcaption></figure>

### **Timekeeper Enabled**&#x20;

\
:red\_circle: **The module displays that the market for the pair is closed** : you cannot swap Token A for Token B until the market opens, which will be done automatically on our interface. \
A countdown warns you of the time remaining before the market opens for this pair. \
The pair's settings (trading days and hours) are also displayed.

<figure><img src="https://1024955971-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FucapM7ajIRHbhMUaNv7T%2Fuploads%2FhzUclww7fnzLAER5dY3M%2FCapture%20d%E2%80%99e%CC%81cran%202023-09-06%20a%CC%80%2015.56.55.png?alt=media&#x26;token=8c87930d-0c82-4e3d-a403-6dcca14bd469" alt=""><figcaption><p>Timekeeper is enabled : market is closed for this pair</p></figcaption></figure>

***

:green\_circle: **The module displays that the market for the pair is open** : you can swap Token A for Token B until the market closes, which will be done automatically on our interface. \
A countdown warns you of the time remaining before the market closed for this pair. \
The pair's settings (trading days and times) are also displayed.

<figure><img src="https://1024955971-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FucapM7ajIRHbhMUaNv7T%2Fuploads%2FXKo84e4el2fEynX1weaX%2FCapture%20d%E2%80%99e%CC%81cran%202023-09-06%20a%CC%80%2013.02.36.png?alt=media&#x26;token=8cdcfecb-3631-4e1b-84ad-5d86a7bf87cb" alt=""><figcaption><p>Timekeeper is enabled : market is open for this pair</p></figcaption></figure>

### The module settings display&#x20;

Timekeeper settings for a pair :

* market opening days
* market opening time
* market closing time
* UTC (timezone)
* 24h/day is enabled: true or false\
  When 24h/day is enabled (true), then the pair's settings no longer consider the specified hours (which become grayed out/inactive), but only the working days according to UTC.<br>

  *In the screenshot example above, the opening market for Pair WKN-WSDQ would then be, if the 24h/Day option has been enabled (true):* \
  *Opening on Monday at 00:00 UTC +2 without interruption until closing on Thursday at 00:00 UTC+2. Then reopening on Friday at 00:00 UTC+2.*
* If the Force Open function has been enabled

{% hint style="success" %}
The countdown is always there to alert you to the exact time before the market opens/closes.
{% endhint %}

### **No Liquidity**

\
:red\_circle: Swap impossible for a pair without liquidity

<figure><img src="https://1024955971-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FucapM7ajIRHbhMUaNv7T%2Fuploads%2F4n0CjZEiSfUlio7lEIxG%2FCapture%20d%E2%80%99e%CC%81cran%202023-09-06%20a%CC%80%2015.18.48.png?alt=media&#x26;token=268aee86-f552-43e7-bd20-65cba1b941a1" alt=""><figcaption><p>No liquidity for this pair</p></figcaption></figure>

{% hint style="info" %}
The UTC displayed for a pair represents its configuration on the blockchain and not your computer's configuration. The countdown is there to notify you about opening or closing trading time for a pair.
{% endhint %}

[^1]: tradingmustbeopen

[^2]: trading must be open to swap
