> For the complete documentation index, see [llms.txt](https://flowdex-fi.gitbook.io/flowdex/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://flowdex-fi.gitbook.io/flowdex/for-developers/additional-functions.md).

# Additional Functions

This section describes additional functions that provide flexibility and security when working with pools. These functions include **cooldown**, **exit pool**, and **pool activation**.

### **1. Cooldown Function**

The cooldown function prevents assets from being withdrawn from the pool for a specified period after a deposit. This helps protect the pool from manipulation and ensures stability.

**Implementation:**

```solidity
mapping(address => uint256) public depositTimestamps; // Timestamp of the last deposit
uint256 public cooldownPeriod = 7 days; // Cooldown period (7 days)

function deposit(uint256 _amount) public {
    require(_amount > 0, "Amount must be greater than 0");
    depositTimestamps[msg.sender] = block.timestamp; // Record the deposit timestamp
    IERC20(want).safeTransferFrom(msg.sender, address(this), _amount);
    _stake(_amount); // Delegate assets to the pool
}

function unstake(uint256 _amount) public {
    require(block.timestamp >= depositTimestamps[msg.sender] + cooldownPeriod, "Cooldown period not over");
    _unstake(_amount); // Withdraw assets from the pool
    IERC20(want).safeTransfer(msg.sender, _amount);
}
```

**How It Works:**

1. The user deposits assets via `deposit()`.
2. The deposit timestamp is recorded in `depositTimestamps`.
3. The user cannot withdraw assets via `unstake()` until the cooldown period (7 days) has passed.

### **2. Exit Pool Function**

The `exitPool` function allows users to withdraw their assets from the pool. The withdrawal takes a specified amount of time to ensure pool stability.

**Implementation:**

```solidity
mapping(address => uint256) public exitRequests; // Timestamp of the withdrawal request
uint256 public exitDelay = 3 days; // Withdrawal delay (3 days)

function requestExit(uint256 _amount) public {
    require(_amount > 0, "Amount must be greater than 0");
    exitRequests[msg.sender] = block.timestamp; // Record the request timestamp
    emit ExitRequested(msg.sender, _amount);
}

function exitPool(uint256 _amount) public {
    require(block.timestamp >= exitRequests[msg.sender] + exitDelay, "Exit delay not over");
    _unstake(_amount); // Withdraw assets from the pool
    IERC20(want).safeTransfer(msg.sender, _amount);
    exitRequests[msg.sender] = 0; // Reset the request
}
```

**How It Works:**

1. The user requests a withdrawal via `requestExit()`.
2. After 3 days, the user can call `exitPool()` to complete the withdrawal.

### **3. Pool Activation**

Pool activation is the time required for deposited assets to start generating yield. This may be due to technical limitations of external protocols.

**Implementation:**

```solidity
uint256 public activationPeriod = 1 days; // Activation period (1 day)
mapping(address => uint256) public activationTimestamps; // Activation timestamp

function deposit(uint256 _amount) public {
    require(_amount > 0, "Amount must be greater than 0");
    activationTimestamps[msg.sender] = block.timestamp; // Record the activation timestamp
    IERC20(want).safeTransferFrom(msg.sender, address(this), _amount);
    _stake(_amount); // Delegate assets to the pool
}

function isActive(address user) public view returns (bool) {
    return block.timestamp >= activationTimestamps[user] + activationPeriod;
}
```

**How It Works:**

1. The user deposits assets via `deposit()`.
2. The activation timestamp is recorded in `activationTimestamps`.
3. Assets start generating yield only after the activation period (1 day) has passed.

### **Security**

* **Cooldown:** Protects the pool from rapid asset withdrawals.
* **Withdrawal Delay:** Ensures pool stability.
* **Activation:** Accounts for technical limitations of external protocols.

***

This section of the documentation provides developers with a technical description of FlowDex's additional functions. Let me know if you need further clarification or additions!
