> For the complete documentation index, see [llms.txt](https://docs.kryptox.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kryptox.finance/getting-started/deposit-and-withdrawal-onchain.md).

# Deposit and withdrawal onchain

KryptoX uses a hybrid model of offchain matching and onchain settlement. This delivers CEX-grade performance while keeping asset control fully decentralized.

***

### Deposit

A deposit moves funds from your personal wallet, such as MetaMask, into your **KryptoX NFT account**.

#### Deposit steps

1. **Connect your wallet:** Click **Connect** in the top-right corner and confirm the wallet connection request.
2. **Enable trading:** Click **Enable Trading**. This triggers a **gas-free** EIP-712 signature request. This authorizes the matching engine to recognize your instructions.
3. **Select or create an NFT account:**
   * **First-time users:** If your wallet does not already hold a KryptoX NFT, the system automatically creates an NFT account during deposit.
   * **Users with multiple accounts:** If you hold multiple KryptoX NFTs, select the account you want to fund from the dropdown before confirming the deposit.
4. **Start the deposit:**
   * Choose the asset, such as **USDC** on Arbitrum.
   * Enter the amount and click **Deposit**.
5. **Confirm onchain:** Confirm the transaction in your wallet. Once the transaction is included onchain, usually within seconds, the funds arrive in your NFT account and you can start trading immediately.

> **💡 Tip:** You can view the protocol's USDC balance transparency at the smart contract at any time.

***

### On-chain Withdrawal

KryptoX treats **user asset sovereignty** as the first principle of withdrawals. The platform cannot approve, freeze, or reject a valid withdrawal request.

#### Withdrawal flow: two-step safety model

To keep offchain order state and onchain asset state synchronized, withdrawals use an efficient two-step model:

1. **Step 1: Request Withdraw**\
   The user submits a withdrawal request to the smart contract. The withdrawal instruction is then recorded onchain.
   * **System response:** The matching system immediately tries to cancel open orders that consume margin in that account and pauses new position openings to keep the withdrawal amount accurate.
2. **Step 2: Finalize Withdraw**\
   After a very short onchain confirmation window, up to 10 seconds and usually completed automatically within 1 second, the system completes the transfer based on the live account state.
   * **User guarantee:** If the matching system does not trigger execution automatically, the user can call the `Finalize` function directly onchain. This ensures the platform cannot block asset withdrawal.

***

### FAQ

#### Q1: How is the maximum withdrawable amount calculated?

KryptoX does not use manual approval to control withdrawals. Instead, it relies on a contract-level **dynamic limit algorithm** to keep the system stable:

> **Maximum withdrawable amount = Account equity − Position risk requirement − Dynamic safety buffer**

* **About the buffer:** This is the system risk reserve.
  * **In calm markets:** The buffer stays lower, so you can withdraw most of your assets.
  * **In extreme volatility:** The buffer increases automatically to prevent immediate liquidation after withdrawal and to protect the insurance fund and overall system safety.

#### Q2: What should I know before withdrawing?

* **NFT ownership:** Assets are stored in the NFT account. Only the current holder of that NFT, meaning the controlling wallet address, can withdraw.
* **Open order cancellation:** Starting a withdrawal automatically cancels all open orders that consume margin. Only **reduce-only** orders remain unaffected.
* **Final amount variance:** The final transferred amount is determined by the real onchain state at the moment of `Finalize`. It may differ slightly from the requested amount because of market-driven equity changes.

#### Q3: What are the advantages and trade-offs of the KryptoX withdrawal model?

| Dimension          | KryptoX pure onchain withdrawals            | Traditional or other platforms              |
| ------------------ | ------------------------------------------- | ------------------------------------------- |
| **Control**        | Triggered fully by the user                 | Depends on backend approval                 |
| **Transparency**   | Enforced by contract rules                  | Manual judgment with black-box risk         |
| **Risk isolation** | Only affects the individual risk account    | May lead to platform-wide withdrawal pauses |
| **Determinism**    | Rules are transparent and cannot be refused | Funds may be frozen                         |

To achieve real decentralized asset sovereignty, KryptoX accepts a few necessary trade-offs:

1. **Trading continuity impact:** A withdrawal forces order cancellation and may interrupt automated strategies.
2. **Very short waiting window:** The 1 to 10 second confirmation window is slightly slower than centralized internal transfers, but it gives you non-interruptible asset security.
3. **Calculation delay:** The final amount is based on live onchain data at execution time. In a hybrid architecture, this is the best way to prevent bad debt.

***

**KryptoX team:** Our goal is to keep asset control on the user side at all times.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kryptox.finance/getting-started/deposit-and-withdrawal-onchain.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
